1/** 2 * @license 3 * Copyright 2017 Google LLC 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 *//** 17 * @license 18 * Copyright 2017 Google LLC 19 * 20 * Licensed under the Apache License, Version 2.0 (the "License"); 21 * you may not use this file except in compliance with the License. 22 * You may obtain a copy of the License at 23 * 24 * http://www.apache.org/licenses/LICENSE-2.0 25 * 26 * Unless required by applicable law or agreed to in writing, software 27 * distributed under the License is distributed on an "AS IS" BASIS, 28 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 * See the License for the specific language governing permissions and 30 * limitations under the License. 31 */const ju=function(n){const e=[];let t=0;for(let s=0;s<n.length;s++){let r=n.charCodeAt(s);r<128?e[t++]=r:r<2048?(e[t++]=r>>6|192,e[t++]=r&63|128):(r&64512)===55296&&s+1<n.length&&(n.charCodeAt(s+1)&64512)===56320?(r=65536+((r&1023)<<10)+(n.charCodeAt(++s)&1023),e[t++]=r>>18|240,e[t++]=r>>12&63|128,e[t++]=r>>6&63|128,e[t++]=r&63|128):(e[t++]=r>>12|224,e[t++]=r>>6&63|128,e[t++]=r&63|128)}return e},cp=function(n){const e=[];let t=0,s=0;for(;t<n.length;){const r=n[t++];if(r<128)e[s++]=String.fromCharCode(r);else if(r>191&&r<224){const i=n[t++];e[s++]=String.fromCharCode((r&31)<<6|i&63)}else if(r>239&&r<365){const i=n[t++],o=n[t++],a=n[t++],c=((r&7)<<18|(i&63)<<12|(o&63)<<6|a&63)-65536;e[s++]=String.fromCharCode(55296+(c>>10)),e[s++]=String.fromCharCode(56320+(c&1023))}else{const i=n[t++],o=n[t++];e[s++]=String.fromCharCode((r&15)<<12|(i&63)<<6|o&63)}}return e.join("")},Gu={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,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,s=[];for(let r=0;r<n.length;r+=3){const i=n[r],o=r+1<n.length,a=o?n[r+1]:0,c=r+2<n.length,u=c?n[r+2]:0,l=i>>2,h=(i&3)<<4|a>>4;let d=(a&15)<<2|u>>6,m=u&63;c||(m=64,o||(d=64)),s.push(t[l],t[h],t[d],t[m])}return s.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(ju(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):cp(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,s=[];for(let r=0;r<n.length;){const i=t[n.charAt(r++)],a=r<n.length?t[n.charAt(r)]:0;++r;const u=r<n.length?t[n.charAt(r)]:64;++r;const h=r<n.length?t[n.charAt(r)]:64;if(++r,i==null||a==null||u==null||h==null)throw Error();const d=i<<2|a>>4;if(s.push(d),u!==64){const m=a<<4&240|u>>2;if(s.push(m),h!==64){const y=u<<6&192|h;s.push(y)}}}return s},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)}}},up=function(n){const e=ju(n);return Gu.encodeByteArray(e,!0)},Zs=function(n){return up(n).replace(/\./g,"")},Ku=function(n){try{return Gu.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/** 32 * @license 33 * Copyright 2022 Google LLC 34 * 35 * Licensed under the Apache License, Version 2.0 (the "License");
36 * you may not use this file except in compliance with the License. 37 * You may obtain a copy of the License at 38 * 39 * http://www.apache.org/licenses/LICENSE-2.0 40 * 41 * Unless required by applicable law or agreed to in writing, software 42 * distributed under the License is distributed on an "AS IS" BASIS, 43 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 44 * See the License for the specific language governing permissions and 45 * limitations under the License. 46 */function lp(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/** 47 * @license 48 * Copyright 2022 Google LLC 49 * 50 * Licensed under the Apache License, Version 2.0 (the "License"); 51 * you may not use this file except in compliance with the License. 52 * You may obtain a copy of the License at 53 * 54 * http://www.apache.org/licenses/LICENSE-2.0 55 * 56 * Unless required by applicable law or agreed to in writing, software 57 * distributed under the License is distributed on an "AS IS" BASIS, 58 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 59 * See the License for the specific language governing permissions and 60 * limitations under the License. 61 */const hp=()=>lp().__FIREBASE_DEFAULTS__,dp=()=>{if(typeof process>"u"||typeof process.env>"u")return;const n={}.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},fp=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&Ku(n[1]);return e&&JSON.parse(e)},kr=()=>{try{return hp()||dp()||fp()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},zu=n=>{var e,t;return(t=(e=kr())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[n]},Hu=n=>{const e=zu(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const s=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),s]:[e.substring(0,t),s]},pp=()=>{var n;return(n=kr())===null||n===void 0?void 0:n.config},Wu=n=>{var e;return(e=kr())===null||e===void 0?void 0:e[`_${n}`]};/** 62 * @license 63 * Copyright 2017 Google LLC 64 * 65 * Licensed under the Apache License, Version 2.0 (the "License"); 66 * you may not use this file except in compliance with the License. 67 * You may obtain a copy of the License at 68 * 69 * http://www.apache.org/licenses/LICENSE-2.0 70 * 71 * Unless required by applicable law or agreed to in writing, software 72 * distributed under the License is distributed on an "AS IS" BASIS, 73 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 74 * See the License for the specific language governing permissions and 75 * limitations under the License. 76 */class mp{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,s)=>{t?this.reject(t):this.resolve(s),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,s))}}}/** 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 gp(n,e){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 t={alg:"none",type:"JWT"},s=e||"demo-project",r=n.iat||0,i=n.sub||n.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${s}`,aud:s,iat:r,exp:r+3600,auth_time:r,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},n),a="";return[Zs(JSON.stringify(t)),Zs(JSON.stringify(o)),a].join(".")}/** 92 * @license 93 * Copyright 2017 Google LLC 94 * 95 * Licensed under the Apache License, Version 2.0 (the "License");
96 * you may not use this file except in compliance with the License. 97 * You may obtain a copy of the License at 98 * 99 * http://www.apache.org/licenses/LICENSE-2.0 100 * 101 * Unless required by applicable law or agreed to in writing, software 102 * distributed under the License is distributed on an "AS IS" BASIS, 103 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 104 * See the License for the specific language governing permissions and 105 * limitations under the License. 106 */function Z(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function yp(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(Z())}function vp(){var n;const e=(n=kr())===null||n===void 0?void 0:n.forceEnvironment;if(e==="node")return!0;if(e==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function Qu(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function wp(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function Ip(){const n=Z();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function Tp(){return!vp()&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function ko(){try{return typeof indexedDB=="object"}catch{return!1}}function Yu(){return new Promise((n,e)=>{try{let t=!0;const s="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(s);r.onsuccess=()=>{r.result.close(),t||self.indexedDB.deleteDatabase(s),n(!0)},r.onupgradeneeded=()=>{t=!1},r.onerror=()=>{var i;e(((i=r.error)===null||i===void 0?void 0:i.message)||"")}}catch(t){e(t)}})}function Ep(){return!(typeof navigator>"u"||!navigator.cookieEnabled)}/** 107 * @license 108 * Copyright 2017 Google LLC 109 * 110 * Licensed under the Apache License, Version 2.0 (the "License"); 111 * you may not use this file except in compliance with the License. 112 * You may obtain a copy of the License at 113 * 114 * http://www.apache.org/licenses/LICENSE-2.0 115 * 116 * Unless required by applicable law or agreed to in writing, software 117 * distributed under the License is distributed on an "AS IS" BASIS, 118 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 119 * See the License for the specific language governing permissions and 120 * limitations under the License. 121 */const bp="FirebaseError";class ke extends Error{constructor(e,t,s){super(t),this.code=e,this.customData=s,this.name=bp,Object.setPrototypeOf(this,ke.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,qt.prototype.create)}}class qt{constructor(e,t,s){this.service=e,this.serviceName=t,this.errors=s}create(e,...t){const s=t[0]||{},r=`${this.service}/${e}`,i=this.errors[e],o=i?_p(i,s):"Error",a=`${this.serviceName}: ${o} (${r}).`;return new ke(r,a,s)}}function _p(n,e){return n.replace(Sp,(t,s)=>{const r=e[s];return r!=null?String(r):`<${s}?>`})}const Sp=/\{\$([^}]+)}/g;function Ap(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function Gn(n,e){if(n===e)return!0;const t=Object.keys(n),s=Object.keys(e);for(const r of t){if(!s.includes(r))return!1;const i=n[r],o=e[r];if(za(i)&&za(o)){if(!Gn(i,o))return!1}else if(i!==o)return!1}for(const r of s)if(!t.includes(r))return!1;return!0}function za(n){return n!==null&&typeof n=="object"}/** 122 * @license 123 * Copyright 2017 Google LLC 124 * 125 * Licensed under the Apache License, Version 2.0 (the "License"); 126 * you may not use this file except in compliance with the License. 127 * You may obtain a copy of the License at 128 * 129 * http://www.apache.org/licenses/LICENSE-2.0 130 * 131 * Unless required by applicable law or agreed to in writing, software 132 * distributed under the License is distributed on an "AS IS" BASIS, 133 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134 * See the License for the specific language governing permissions and 135 * limitations under the License. 136 */function os(n){const e=[];
136for(const[t,s]of Object.entries(n))Array.isArray(s)?s.forEach(r=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(r))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(s));return e.length?"&"+e.join("&"):""}function Cp(n,e){const t=new kp(n,e);return t.subscribe.bind(t)}class kp{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(s=>{this.error(s)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,s){let r;if(e===void 0&&t===void 0&&s===void 0)throw new Error("Missing Observer.");Dp(e,["next","error","complete"])?r=e:r={next:e,error:t,complete:s},r.next===void 0&&(r.next=wi),r.error===void 0&&(r.error=wi),r.complete===void 0&&(r.complete=wi);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch{}}),this.observers.push(r),i}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(s){typeof console<"u"&&console.error&&console.error(s)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function Dp(n,e){if(typeof n!="object"||n===null)return!1;for(const t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function wi(){}/** 137 * @license 138 * Copyright 2019 Google LLC 139 * 140 * Licensed under the Apache License, Version 2.0 (the "License"); 141 * you may not use this file except in compliance with the License. 142 * You may obtain a copy of the License at 143 * 144 * http://www.apache.org/licenses/LICENSE-2.0 145 * 146 * Unless required by applicable law or agreed to in writing, software 147 * distributed under the License is distributed on an "AS IS" BASIS, 148 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 149 * See the License for the specific language governing permissions and 150 * limitations under the License. 151 */const Np=1e3,xp=2,Rp=4*60*60*1e3,Op=.5;function Ha(n,e=Np,t=xp){const s=e*Math.pow(t,n),r=Math.round(Op*s*(Math.random()-.5)*2);return Math.min(Rp,s+r)}/** 152 * @license 153 * Copyright 2021 Google LLC 154 * 155 * Licensed under the Apache License, Version 2.0 (the "License"); 156 * you may not use this file except in compliance with the License. 157 * You may obtain a copy of the License at 158 * 159 * http://www.apache.org/licenses/LICENSE-2.0 160 * 161 * Unless required by applicable law or agreed to in writing, software 162 * distributed under the License is distributed on an "AS IS" BASIS, 163 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 164 * See the License for the specific language governing permissions and 165 * limitations under the License. 166 */function q(n){return n&&n._delegate?n._delegate:n}class Ce{constructor(e,t,s){this.name=e,this.instanceFactory=t,this.type=s,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}/** 167 * @license 168 * Copyright 2019 Google LLC 169 * 170 * Licensed under the Apache License, Version 2.0 (the "License"); 171 * you may not use this file except in compliance with the License. 172 * You may obtain a copy of the License at 173 * 174 * http://www.apache.org/licenses/LICENSE-2.0 175 * 176 * Unless required by applicable law or agreed to in writing, software 177 * distributed under the License is distributed on an "AS IS" BASIS, 178 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 179 * See the License for the specific language governing permissions and 180 * limitations under the License. 181 */const yt="[DEFAULT]";/** 182 * @license 183 * Copyright 2019 Google LLC 184 * 185 * Licensed under the Apache License, Version 2.0 (the "License");
186 * you may not use this file except in compliance with the License. 187 * You may obtain a copy of the License at 188 * 189 * http://www.apache.org/licenses/LICENSE-2.0 190 * 191 * Unless required by applicable law or agreed to in writing, software 192 * distributed under the License is distributed on an "AS IS" BASIS, 193 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 194 * See the License for the specific language governing permissions and 195 * limitations under the License. 196 */class Mp{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const s=new mp;if(this.instancesDeferred.set(t,s),this.isInitialized(t)||this.shouldAutoInitialize())try{const r=this.getOrInitializeService({instanceIdentifier:t});r&&s.resolve(r)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const s=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),r=(t=e==null?void 0:e.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(s)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:s})}catch(i){if(r)return null;throw i}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(Lp(e))try{this.getOrInitializeService({instanceIdentifier:yt})}catch{}for(const[t,s]of this.instancesDeferred.entries()){const r=this.normalizeInstanceIdentifier(t);try{const i=this.getOrInitializeService({instanceIdentifier:r});s.resolve(i)}catch{}}}}clearInstance(e=yt){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=yt){return this.instances.has(e)}getOptions(e=yt){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,s=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(s))throw Error(`${this.name}(${s}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:s,options:t});for(const[i,o]of this.instancesDeferred.entries()){const a=this.normalizeInstanceIdentifier(i);s===a&&o.resolve(r)}return r}onInit(e,t){var s;const r=this.normalizeInstanceIdentifier(t),i=(s=this.onInitCallbacks.get(r))!==null&&s!==void 0?s:new Set;i.add(e),this.onInitCallbacks.set(r,i);const o=this.instances.get(r);return o&&e(o,r),()=>{i.delete(e)}}invokeOnInitCallbacks(e,t){const s=this.onInitCallbacks.get(t);if(s)for(const r of s)try{r(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let s=this.instances.get(e);if(!s&&this.component&&(s=this.component.instanceFactory(this.container,{instanceIdentifier:Pp(e),options:t}),this.instances.set(e,s),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(s,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,s)}catch{}return s||null}normalizeInstanceIdentifier(e=yt){return this.component?this.component.multipleInstances?e:yt:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function Pp(n){return n===yt?void 0:n}function Lp(n){return n.instantiationMode==="EAGER"}/** 197 * @license 198 * Copyright 2019 Google LLC 199 * 200 * Licensed under the Apache License, Version 2.0 (the "License"); 201 * you may not use this file except in compliance with the License. 202 * You may obtain a copy of the License at 203 * 204 * http://www.apache.org/licenses/LICENSE-2.0 205 * 206 * Unless required by applicable law or agreed to in writing, softw
206are 207 * distributed under the License is distributed on an "AS IS" BASIS, 208 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 209 * See the License for the specific language governing permissions and 210 * limitations under the License. 211 */class Fp{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new Mp(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}/** 212 * @license 213 * Copyright 2017 Google LLC 214 * 215 * Licensed under the Apache License, Version 2.0 (the "License"); 216 * you may not use this file except in compliance with the License. 217 * You may obtain a copy of the License at 218 * 219 * http://www.apache.org/licenses/LICENSE-2.0 220 * 221 * Unless required by applicable law or agreed to in writing, software 222 * distributed under the License is distributed on an "AS IS" BASIS, 223 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 224 * See the License for the specific language governing permissions and 225 * limitations under the License. 226 */var O;(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"})(O||(O={}));const Vp={debug:O.DEBUG,verbose:O.VERBOSE,info:O.INFO,warn:O.WARN,error:O.ERROR,silent:O.SILENT},Up=O.INFO,Bp={[O.DEBUG]:"log",[O.VERBOSE]:"log",[O.INFO]:"info",[O.WARN]:"warn",[O.ERROR]:"error"},$p=(n,e,...t)=>{if(e<n.logLevel)return;const s=new Date().toISOString(),r=Bp[e];if(r)console[r](`[${s}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Dr{constructor(e){this.name=e,this._logLevel=Up,this._logHandler=$p,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in O))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?Vp[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,O.DEBUG,...e),this._logHandler(this,O.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,O.VERBOSE,...e),this._logHandler(this,O.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,O.INFO,...e),this._logHandler(this,O.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,O.WARN,...e),this._logHandler(this,O.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,O.ERROR,...e),this._logHandler(this,O.ERROR,...e)}}const qp=(n,e)=>e.some(t=>n instanceof t);let Wa,Qa;function jp(){return Wa||(Wa=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Gp(){return Qa||(Qa=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const Xu=new WeakMap,Bi=new WeakMap,Ju=new WeakMap,Ii=new WeakMap,Do=new WeakMap;function Kp(n){const e=new Promise((t,s)=>{const r=()=>{n.removeEventListener("success",i),n.removeEventListener("error",o)},i=()=>{t(nt(n.result)),r()},o=()=>{s(n.error),r()};n.addEventListener("success",i),n.addEventListener("error",o)});return e.then(t=>{t instanceof IDBCursor&&Xu.set(t,n)}).catch(()=>{}),Do.set(e,n),e}function zp(n){if(Bi.has(n))return;const e=new Promise((t,s)=>{const r=()=>{n.removeEventListener("complete",i),n.removeEventListener("error",o),n.removeEventListener("abort",o)},i=()=>{t(),r()},o=()=>{s(n.error||new DOMException("AbortError","AbortError")),r()};n.addEventListener("complete",i),n.addEventListener("error",o),n.addEventListener("abort",o)});Bi.set(n,e)}let $i={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return Bi.get(n);if(e==="objectStoreNames")return n.objectStoreNames||Ju.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return nt(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Hp(n){$i=n($i)}
226function Wp(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const s=n.call(Ti(this),e,...t);return Ju.set(s,e.sort?e.sort():[e]),nt(s)}:Gp().includes(n)?function(...e){return n.apply(Ti(this),e),nt(Xu.get(this))}:function(...e){return nt(n.apply(Ti(this),e))}}function Qp(n){return typeof n=="function"?Wp(n):(n instanceof IDBTransaction&&zp(n),qp(n,jp())?new Proxy(n,$i):n)}function nt(n){if(n instanceof IDBRequest)return Kp(n);if(Ii.has(n))return Ii.get(n);const e=Qp(n);return e!==n&&(Ii.set(n,e),Do.set(e,n)),e}const Ti=n=>Do.get(n);function Zu(n,e,{blocked:t,upgrade:s,blocking:r,terminated:i}={}){const o=indexedDB.open(n,e),a=nt(o);return s&&o.addEventListener("upgradeneeded",c=>{s(nt(o.result),c.oldVersion,c.newVersion,nt(o.transaction))}),t&&o.addEventListener("blocked",()=>t()),a.then(c=>{i&&c.addEventListener("close",()=>i()),r&&c.addEventListener("versionchange",()=>r())}).catch(()=>{}),a}const Yp=["get","getKey","getAll","getAllKeys","count"],Xp=["put","add","delete","clear"],Ei=new Map;function Ya(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(Ei.get(e))return Ei.get(e);const t=e.replace(/FromIndex$/,""),s=e!==t,r=Xp.includes(t);if(!(t in(s?IDBIndex:IDBObjectStore).prototype)||!(r||Yp.includes(t)))return;const i=async function(o,...a){const c=this.transaction(o,r?"readwrite":"readonly");let u=c.store;return s&&(u=u.index(a.shift())),(await Promise.all([u[t](...a),r&&c.done]))[0]};return Ei.set(e,i),i}Hp(n=>({...n,get:(e,t,s)=>Ya(e,t)||n.get(e,t,s),has:(e,t)=>!!Ya(e,t)||n.has(e,t)}));/** 227 * @license 228 * Copyright 2019 Google LLC 229 * 230 * Licensed under the Apache License, Version 2.0 (the "License"); 231 * you may not use this file except in compliance with the License. 232 * You may obtain a copy of the License at 233 * 234 * http://www.apache.org/licenses/LICENSE-2.0 235 * 236 * Unless required by applicable law or agreed to in writing, software 237 * distributed under the License is distributed on an "AS IS" BASIS, 238 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 239 * See the License for the specific language governing permissions and 240 * limitations under the License. 241 */class Jp{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(Zp(t)){const s=t.getImmediate();return`${s.library}/${s.version}`}else return null}).filter(t=>t).join(" ")}}function Zp(n){const e=n.getComponent();return(e==null?void 0:e.type)==="VERSION"}const qi="@firebase/app",Xa="0.9.3";/** 242 * @license 243 * Copyright 2019 Google LLC 244 * 245 * Licensed under the Apache License, Version 2.0 (the "License"); 246 * you may not use this file except in compliance with the License. 247 * You may obtain a copy of the License at 248 * 249 * http://www.apache.org/licenses/LICENSE-2.0 250 * 251 * Unless required by applicable law or agreed to in writing, software 252 * distributed under the License is distributed on an "AS IS" BASIS, 253 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 254 * See the License for the specific language governing permissions and 255 * limitations under the License. 256 */const Nt=new Dr("@firebase/app"),em="@firebase/app-compat",tm="@firebase/analytics-compat",nm="@firebase/analytics",sm="@firebase/app-check-compat",rm="@firebase/app-check",im="@firebase/auth",om="@firebase/auth-compat",am="@firebase/database",cm="@firebase/database-compat",um="@firebase/functions",lm="@firebase/functions-compat",hm="@firebase/installations",dm="@firebase/installations-compat",fm="@firebase/messaging",pm="@firebase/messaging-compat",mm="@firebase/performance",gm="@firebase/performance-compat",ym="@firebase/remote-config",vm="@firebase/remote-config-compat",wm="@firebase/storage",Im="@firebase/storage-compat",Tm="@firebase/firestore",Em="@firebase/firestore-compat",bm="firebase",_m="9.17.1";/** 257 * @license 258 * Copyright 2019 Google LLC 259 * 260 * Licensed under the Apache License, Version 2.0 (the "License"); 261 * you may not use this file except in compliance with the License. 262 * You may obtain a copy of the License at 263 * 264 * http://www.apache.org/licenses/LICENSE-2.0 265 * 266 * Unless required by applicable law or agreed to in writing, softw
266are 267 * distributed under the License is distributed on an "AS IS" BASIS, 268 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 269 * See the License for the specific language governing permissions and 270 * limitations under the License. 271 */const ji="[DEFAULT]",Sm={[qi]:"fire-core",[em]:"fire-core-compat",[nm]:"fire-analytics",[tm]:"fire-analytics-compat",[rm]:"fire-app-check",[sm]:"fire-app-check-compat",[im]:"fire-auth",[om]:"fire-auth-compat",[am]:"fire-rtdb",[cm]:"fire-rtdb-compat",[um]:"fire-fn",[lm]:"fire-fn-compat",[hm]:"fire-iid",[dm]:"fire-iid-compat",[fm]:"fire-fcm",[pm]:"fire-fcm-compat",[mm]:"fire-perf",[gm]:"fire-perf-compat",[ym]:"fire-rc",[vm]:"fire-rc-compat",[wm]:"fire-gcs",[Im]:"fire-gcs-compat",[Tm]:"fire-fst",[Em]:"fire-fst-compat","fire-js":"fire-js",[bm]:"fire-js-all"};/** 272 * @license 273 * Copyright 2019 Google LLC 274 * 275 * Licensed under the Apache License, Version 2.0 (the "License"); 276 * you may not use this file except in compliance with the License. 277 * You may obtain a copy of the License at 278 * 279 * http://www.apache.org/licenses/LICENSE-2.0 280 * 281 * Unless required by applicable law or agreed to in writing, software 282 * distributed under the License is distributed on an "AS IS" BASIS, 283 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 284 * See the License for the specific language governing permissions and 285 * limitations under the License. 286 */const er=new Map,Gi=new Map;function Am(n,e){try{n.container.addComponent(e)}catch(t){Nt.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function Ne(n){const e=n.name;if(Gi.has(e))return Nt.debug(`There were multiple attempts to register component ${e}.`),!1;Gi.set(e,n);for(const t of er.values())Am(t,n);return!0}function ut(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}/** 287 * @license 288 * Copyright 2019 Google LLC 289 * 290 * Licensed under the Apache License, Version 2.0 (the "License"); 291 * you may not use this file except in compliance with the License. 292 * You may obtain a copy of the License at 293 * 294 * http://www.apache.org/licenses/LICENSE-2.0 295 * 296 * Unless required by applicable law or agreed to in writing, software 297 * distributed under the License is distributed on an "AS IS" BASIS, 298 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 299 * See the License for the specific language governing permissions and 300 * limitations under the License. 301 */const Cm={["no-app"]:"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()",["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",["no-options"]:"Need to provide options, when not being deployed to hosting via source.",["invalid-app-argument"]:"firebase.{$appName}() takes either no argument or a Firebase App instance.",["invalid-log-argument"]:"First argument to `onLog` must be null or a function.",["idb-open"]:"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.",["idb-get"]:"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.",["idb-set"]:"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.",["idb-delete"]:"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}."},st=new qt("app","Firebase",Cm);/** 302 * @license 303 * Copyright 2019 Google LLC 304 * 305 * Licensed under the Apache License, Version 2.0 (the "License"); 306 * you may not use this file except in compliance with the License. 307 * You may obtain a copy of the License at 308 * 309 * http://www.apache.org/licenses/LICENSE-2.0 310 * 311 * Unless required by applicable law or agreed to in writing, software 312 * distributed under the License is distributed on an "AS IS" BASIS, 313 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 314 * See the License for the specific language governing permissions and 315 * limitations under the License. 316 */class km{constructor(e,t,s){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=s,this.container.addComponent(new Ce("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw st.create("app-deleted",{appName:this._name})}}/** 317 * @license 318 * Copyright 2019 Google LLC 319 * 320 * Licensed under the Apache License, Version 2.0 (the "License");
321 * you may not use this file except in compliance with the License. 322 * You may obtain a copy of the License at 323 * 324 * http://www.apache.org/licenses/LICENSE-2.0 325 * 326 * Unless required by applicable law or agreed to in writing, software 327 * distributed under the License is distributed on an "AS IS" BASIS, 328 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 329 * See the License for the specific language governing permissions and 330 * limitations under the License. 331 */const as=_m;function el(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const s=Object.assign({name:ji,automaticDataCollectionEnabled:!1},e),r=s.name;if(typeof r!="string"||!r)throw st.create("bad-app-name",{appName:String(r)});if(t||(t=pp()),!t)throw st.create("no-options");const i=er.get(r);if(i){if(Gn(t,i.options)&&Gn(s,i.config))return i;throw st.create("duplicate-app",{appName:r})}const o=new Fp(r);for(const c of Gi.values())o.addComponent(c);const a=new km(t,s,o);return er.set(r,a),a}function Nr(n=ji){const e=er.get(n);if(!e&&n===ji)return el();if(!e)throw st.create("no-app",{appName:n});return e}function Ie(n,e,t){var s;let r=(s=Sm[n])!==null&&s!==void 0?s:n;t&&(r+=`-${t}`);const i=r.match(/\s|\//),o=e.match(/\s|\//);if(i||o){const a=[`Unable to register library "${r}" with version "${e}":`];i&&a.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&o&&a.push("and"),o&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),Nt.warn(a.join(" "));return}Ne(new Ce(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}/** 332 * @license 333 * Copyright 2021 Google LLC 334 * 335 * Licensed under the Apache License, Version 2.0 (the "License"); 336 * you may not use this file except in compliance with the License. 337 * You may obtain a copy of the License at 338 * 339 * http://www.apache.org/licenses/LICENSE-2.0 340 * 341 * Unless required by applicable law or agreed to in writing, software 342 * distributed under the License is distributed on an "AS IS" BASIS, 343 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 344 * See the License for the specific language governing permissions and 345 * limitations under the License. 346 */const Dm="firebase-heartbeat-database",Nm=1,Kn="firebase-heartbeat-store";let bi=null;function tl(){return bi||(bi=Zu(Dm,Nm,{upgrade:(n,e)=>{switch(e){case 0:n.createObjectStore(Kn)}}}).catch(n=>{throw st.create("idb-open",{originalErrorMessage:n.message})})),bi}async function xm(n){try{return(await tl()).transaction(Kn).objectStore(Kn).get(nl(n))}catch(e){if(e instanceof ke)Nt.warn(e.message);else{const t=st.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});Nt.warn(t.message)}}}async function Ja(n,e){try{const s=(await tl()).transaction(Kn,"readwrite");return await s.objectStore(Kn).put(e,nl(n)),s.done}catch(t){if(t instanceof ke)Nt.warn(t.message);else{const s=st.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});Nt.warn(s.message)}}}function nl(n){return`${n.name}!${n.options.appId}`}/** 347 * @license 348 * Copyright 2021 Google LLC 349 * 350 * Licensed under the Apache License, Version 2.0 (the "License"); 351 * you may not use this file except in compliance with the License. 352 * You may obtain a copy of the License at 353 * 354 * http://www.apache.org/licenses/LICENSE-2.0 355 * 356 * Unless required by applicable law or agreed to in writing, software 357 * distributed under the License is distributed on an "AS IS" BASIS, 358 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 359 * See the License for the specific language governing permissions and 360 * limitations under the License. 361 */const Rm=1024,Om=30*24*60*60*1e3;class Mm{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new Lm(t),this._heartbeatsCachePromise=this._storage.read().then(s=>(this._heartbeatsCache=s,s))}async triggerHeartbeat(){const t=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),s=Za();if(this._heartbeatsCache===null&&(this._heartbeatsCache=await this._heartbeatsCachePromise),!(this._heartbeatsCache.lastSentHeartbeatDate===s||this._heartbeatsCache.heartbeats.some(r=>r.date===s)))return this._heartbeatsCache.heartbeats.push({date:s,agent:t}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter(r=>{const i=new Date(r.date).valueOf();return Date.now()-i<=Om}),this._storage.overwrite(this._heartbeatsCache)}
361async getHeartbeatsHeader(){if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache===null||this._heartbeatsCache.heartbeats.length===0)return"";const e=Za(),{heartbeatsToSend:t,unsentEntries:s}=Pm(this._heartbeatsCache.heartbeats),r=Zs(JSON.stringify({version:2,heartbeats:t}));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)),r}}function Za(){return new Date().toISOString().substring(0,10)}function Pm(n,e=Rm){const t=[];let s=n.slice();for(const r of n){const i=t.find(o=>o.agent===r.agent);if(i){if(i.dates.push(r.date),ec(t)>e){i.dates.pop();break}}else if(t.push({agent:r.agent,dates:[r.date]}),ec(t)>e){t.pop();break}s=s.slice(1)}return{heartbeatsToSend:t,unsentEntries:s}}class Lm{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return ko()?Yu().then(()=>!0).catch(()=>!1):!1}async read(){return await this._canUseIndexedDBPromise?await xm(this.app)||{heartbeats:[]}:{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const r=await this.read();return Ja(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){const r=await this.read();return Ja(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function ec(n){return Zs(JSON.stringify({version:2,heartbeats:n})).length}/** 362 * @license 363 * Copyright 2019 Google LLC 364 * 365 * Licensed under the Apache License, Version 2.0 (the "License"); 366 * you may not use this file except in compliance with the License. 367 * You may obtain a copy of the License at 368 * 369 * http://www.apache.org/licenses/LICENSE-2.0 370 * 371 * Unless required by applicable law or agreed to in writing, software 372 * distributed under the License is distributed on an "AS IS" BASIS, 373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 374 * See the License for the specific language governing permissions and 375 * limitations under the License. 376 */function Fm(n){Ne(new Ce("platform-logger",e=>new Jp(e),"PRIVATE")),Ne(new Ce("heartbeat",e=>new Mm(e),"PRIVATE")),Ie(qi,Xa,n),Ie(qi,Xa,"esm2017"),Ie("fire-js","")}Fm("");var Vm="firebase",Um="9.17.1";/** 377 * @license 378 * Copyright 2020 Google LLC 379 * 380 * Licensed under the Apache License, Version 2.0 (the "License"); 381 * you may not use this file except in compliance with the License. 382 * You may obtain a copy of the License at 383 * 384 * http://www.apache.org/licenses/LICENSE-2.0 385 * 386 * Unless required by applicable law or agreed to in writing, software 387 * distributed under the License is distributed on an "AS IS" BASIS, 388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 389 * See the License for the specific language governing permissions and 390 * limitations under the License. 391 */Ie(Vm,Um,"app");const sl="@firebase/installations",No="0.6.3";/** 392 * @license 393 * Copyright 2019 Google LLC 394 * 395 * Licensed under the Apache License, Version 2.0 (the "License"); 396 * you may not use this file except in compliance with the License. 397 * You may obtain a copy of the License at 398 * 399 * http://www.apache.org/licenses/LICENSE-2.0 400 * 401 * Unless required by applicable law or agreed to in writing, software 402 * distributed under the License is distributed on an "AS IS" BASIS, 403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 404 * See the License for the specific language governing permissions and 405 * limitations under the License. 406 */const rl=1e4,il=`w:${No}`,ol="FIS_v2",Bm="https://firebaseinstallations.googleapis.com/v1",$m=60*60*1e3,qm="installations",jm="Installations";/** 407 * @license 408 * Copyright 2019 Google LLC 409 * 410 * Licensed under the Apache License, Version 2.0 (the "License");
411 * you may not use this file except in compliance with the License. 412 * You may obtain a copy of the License at 413 * 414 * http://www.apache.org/licenses/LICENSE-2.0 415 * 416 * Unless required by applicable law or agreed to in writing, software 417 * distributed under the License is distributed on an "AS IS" BASIS, 418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 419 * See the License for the specific language governing permissions and 420 * limitations under the License. 421 */const Gm={["missing-app-config-values"]:'Missing App configuration value: "{$valueName}"',["not-registered"]:"Firebase Installation is not registered.",["installation-not-found"]:"Firebase Installation not found.",["request-failed"]:'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',["app-offline"]:"Could not process request. Application offline.",["delete-pending-registration"]:"Can't delete installation while there is a pending registration request."},xt=new qt(qm,jm,Gm);function al(n){return n instanceof ke&&n.code.includes("request-failed")}/** 422 * @license 423 * Copyright 2019 Google LLC 424 * 425 * Licensed under the Apache License, Version 2.0 (the "License"); 426 * you may not use this file except in compliance with the License. 427 * You may obtain a copy of the License at 428 * 429 * http://www.apache.org/licenses/LICENSE-2.0 430 * 431 * Unless required by applicable law or agreed to in writing, software 432 * distributed under the License is distributed on an "AS IS" BASIS, 433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 434 * See the License for the specific language governing permissions and 435 * limitations under the License. 436 */function cl({projectId:n}){return`${Bm}/projects/${n}/installations`}function ul(n){return{token:n.token,requestStatus:2,expiresIn:zm(n.expiresIn),creationTime:Date.now()}}async function ll(n,e){const s=(await e.json()).error;return xt.create("request-failed",{requestName:n,serverCode:s.code,serverMessage:s.message,serverStatus:s.status})}function hl({apiKey:n}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":n})}function Km(n,{refreshToken:e}){const t=hl(n);return t.append("Authorization",Hm(e)),t}async function dl(n){const e=await n();return e.status>=500&&e.status<600?n():e}function zm(n){return Number(n.replace("s","000"))}function Hm(n){return`${ol} ${n}`}/** 437 * @license 438 * Copyright 2019 Google LLC 439 * 440 * Licensed under the Apache License, Version 2.0 (the "License"); 441 * you may not use this file except in compliance with the License. 442 * You may obtain a copy of the License at 443 * 444 * http://www.apache.org/licenses/LICENSE-2.0 445 * 446 * Unless required by applicable law or agreed to in writing, software 447 * distributed under the License is distributed on an "AS IS" BASIS, 448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 449 * See the License for the specific language governing permissions and 450 * limitations under the License. 451 */async function Wm({appConfig:n,heartbeatServiceProvider:e},{fid:t}){const s=cl(n),r=hl(n),i=e.getImmediate({optional:!0});if(i){const u=await i.getHeartbeatsHeader();u&&r.append("x-firebase-client",u)}const o={fid:t,authVersion:ol,appId:n.appId,sdkVersion:il},a={method:"POST",headers:r,body:JSON.stringify(o)},c=await dl(()=>fetch(s,a));if(c.ok){const u=await c.json();return{fid:u.fid||t,registrationStatus:2,refreshToken:u.refreshToken,authToken:ul(u.authToken)}}else throw await ll("Create Installation",c)}/** 452 * @license 453 * Copyright 2019 Google LLC 454 * 455 * Licensed under the Apache License, Version 2.0 (the "License"); 456 * you may not use this file except in compliance with the License. 457 * You may obtain a copy of the License at 458 * 459 * http://www.apache.org/licenses/LICENSE-2.0 460 * 461 * Unless required by applicable law or agreed to in writing, software 462 * distributed under the License is distributed on an "AS IS" BASIS, 463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 464 * See the License for the specific language governing permissions and 465 * limitations under the License. 466 */function fl(n){return new Promise(e=>{setTimeout(e,n)})}/** 467 * @license 468 * Copyright 2019 Google LLC 469 * 470 * Licensed under the Apache License, Version 2.0 (the "License");
471 * you may not use this file except in compliance with the License. 472 * You may obtain a copy of the License at 473 * 474 * http://www.apache.org/licenses/LICENSE-2.0 475 * 476 * Unless required by applicable law or agreed to in writing, software 477 * distributed under the License is distributed on an "AS IS" BASIS, 478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 479 * See the License for the specific language governing permissions and 480 * limitations under the License. 481 */function Qm(n){return btoa(String.fromCharCode(...n)).replace(/\+/g,"-").replace(/\//g,"_")}/** 482 * @license 483 * Copyright 2019 Google LLC 484 * 485 * Licensed under the Apache License, Version 2.0 (the "License"); 486 * you may not use this file except in compliance with the License. 487 * You may obtain a copy of the License at 488 * 489 * http://www.apache.org/licenses/LICENSE-2.0 490 * 491 * Unless required by applicable law or agreed to in writing, software 492 * distributed under the License is distributed on an "AS IS" BASIS, 493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 494 * See the License for the specific language governing permissions and 495 * limitations under the License. 496 */const Ym=/^[cdef][\w-]{21}$/,Ki="";function Xm(){try{const n=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(n),n[0]=112+n[0]%16;const t=Jm(n);return Ym.test(t)?t:Ki}catch{return Ki}}function Jm(n){return Qm(n).substr(0,22)}/** 497 * @license 498 * Copyright 2019 Google LLC 499 * 500 * Licensed under the Apache License, Version 2.0 (the "License"); 501 * you may not use this file except in compliance with the License. 502 * You may obtain a copy of the License at 503 * 504 * http://www.apache.org/licenses/LICENSE-2.0 505 * 506 * Unless required by applicable law or agreed to in writing, software 507 * distributed under the License is distributed on an "AS IS" BASIS, 508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 509 * See the License for the specific language governing permissions and 510 * limitations under the License. 511 */function xr(n){return`${n.appName}!${n.appId}`}/** 512 * @license 513 * Copyright 2019 Google LLC 514 * 515 * Licensed under the Apache License, Version 2.0 (the "License"); 516 * you may not use this file except in compliance with the License. 517 * You may obtain a copy of the License at 518 * 519 * http://www.apache.org/licenses/LICENSE-2.0 520 * 521 * Unless required by applicable law or agreed to in writing, software 522 * distributed under the License is distributed on an "AS IS" BASIS, 523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 524 * See the License for the specific language governing permissions and 525 * limitations under the License. 526 */const pl=new Map;function ml(n,e){const t=xr(n);gl(t,e),Zm(t,e)}function gl(n,e){const t=pl.get(n);if(t)for(const s of t)s(e)}function Zm(n,e){const t=eg();t&&t.postMessage({key:n,fid:e}),tg()}let bt=null;function eg(){return!bt&&"BroadcastChannel"in self&&(bt=new BroadcastChannel("[Firebase] FID Change"),bt.onmessage=n=>{gl(n.data.key,n.data.fid)}),bt}function tg(){pl.size===0&&bt&&(bt.close(),bt=null)}/** 527 * @license 528 * Copyright 2019 Google LLC 529 * 530 * Licensed under the Apache License, Version 2.0 (the "License"); 531 * you may not use this file except in compliance with the License. 532 * You may obtain a copy of the License at 533 * 534 * http://www.apache.org/licenses/LICENSE-2.0 535 * 536 * Unless required by applicable law or agreed to in writing, software 537 * distributed under the License is distributed on an "AS IS" BASIS, 538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 539 * See the License for the specific language governing permissions and 540 * limitations under the License. 541 */const ng="firebase-installations-database",sg=1,Rt="firebase-installations-store";let _i=null;function xo(){return _i||(_i=Zu(ng,sg,{upgrade:(n,e)=>{switch(e){case 0:n.createObjectStore(Rt)}}})),_i}async function tr(n,e){const t=xr(n),r=(await xo()).transaction(Rt,"readwrite"),i=r.objectStore(Rt),o=await i.get(t);return await i.put(e,t),await r.done,(!o||o.fid!==e.fid)&&ml(n,e.fid),e}async function yl(n){const e=xr(n),s=(await xo()).transaction(Rt,"readwrite");await s.objectStore(Rt).delete(e),await s.done}async function Rr(n,e){const t=xr(n),r=(await xo()).transaction(Rt,"readwrite"),i=r.objectStore(Rt),o=await i.get(t),a=e(o);return a===void 0?await i.delete(t):await i.put(a,t),await r.done,a&&(!o||o.fid!==a.fid)&&ml(n,a.fid),a}/** 542 * @license 543 * Copyright 2019 Google LLC 544 * 545 * Licensed under the Apache License, Version 2.0 (the "License");
546 * you may not use this file except in compliance with the License. 547 * You may obtain a copy of the License at 548 * 549 * http://www.apache.org/licenses/LICENSE-2.0 550 * 551 * Unless required by applicable law or agreed to in writing, software 552 * distributed under the License is distributed on an "AS IS" BASIS, 553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 554 * See the License for the specific language governing permissions and 555 * limitations under the License. 556 */async function Ro(n){let e;const t=await Rr(n.appConfig,s=>{const r=rg(s),i=ig(n,r);return e=i.registrationPromise,i.installationEntry});return t.fid===Ki?{installationEntry:await e}:{installationEntry:t,registrationPromise:e}}function rg(n){const e=n||{fid:Xm(),registrationStatus:0};return vl(e)}function ig(n,e){if(e.registrationStatus===0){if(!navigator.onLine){const r=Promise.reject(xt.create("app-offline"));return{installationEntry:e,registrationPromise:r}}const t={fid:e.fid,registrationStatus:1,registrationTime:Date.now()},s=og(n,t);return{installationEntry:t,registrationPromise:s}}else return e.registrationStatus===1?{installationEntry:e,registrationPromise:ag(n)}:{installationEntry:e}}async function og(n,e){try{const t=await Wm(n,e);return tr(n.appConfig,t)}catch(t){throw al(t)&&t.customData.serverCode===409?await yl(n.appConfig):await tr(n.appConfig,{fid:e.fid,registrationStatus:0}),t}}async function ag(n){let e=await tc(n.appConfig);for(;e.registrationStatus===1;)await fl(100),e=await tc(n.appConfig);if(e.registrationStatus===0){const{installationEntry:t,registrationPromise:s}=await Ro(n);return s||t}return e}function tc(n){return Rr(n,e=>{if(!e)throw xt.create("installation-not-found");return vl(e)})}function vl(n){return cg(n)?{fid:n.fid,registrationStatus:0}:n}function cg(n){return n.registrationStatus===1&&n.registrationTime+rl<Date.now()}/** 557 * @license 558 * Copyright 2019 Google LLC 559 * 560 * Licensed under the Apache License, Version 2.0 (the "License"); 561 * you may not use this file except in compliance with the License. 562 * You may obtain a copy of the License at 563 * 564 * http://www.apache.org/licenses/LICENSE-2.0 565 * 566 * Unless required by applicable law or agreed to in writing, software 567 * distributed under the License is distributed on an "AS IS" BASIS, 568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 569 * See the License for the specific language governing permissions and 570 * limitations under the License. 571 */async function ug({appConfig:n,heartbeatServiceProvider:e},t){const s=lg(n,t),r=Km(n,t),i=e.getImmediate({optional:!0});if(i){const u=await i.getHeartbeatsHeader();u&&r.append("x-firebase-client",u)}const o={installation:{sdkVersion:il,appId:n.appId}},a={method:"POST",headers:r,body:JSON.stringify(o)},c=await dl(()=>fetch(s,a));if(c.ok){const u=await c.json();return ul(u)}else throw await ll("Generate Auth Token",c)}function lg(n,{fid:e}){return`${cl(n)}/${e}/authTokens:generate`}/** 572 * @license 573 * Copyright 2019 Google LLC 574 * 575 * Licensed under the Apache License, Version 2.0 (the "License"); 576 * you may not use this file except in compliance with the License. 577 * You may obtain a copy of the License at 578 * 579 * http://www.apache.org/licenses/LICENSE-2.0 580 * 581 * Unless required by applicable law or agreed to in writing, software 582 * distributed under the License is distributed on an "AS IS" BASIS, 583 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 584 * See the License for the specific language governing permissions and 585 * limitations under the License. 586 */async function Oo(n,e=!1){let t;const s=await Rr(n.appConfig,i=>{if(!wl(i))throw xt.create("not-registered");const o=i.authToken;if(!e&&fg(o))return i;if(o.requestStatus===1)return t=hg(n,e),i;{if(!navigator.onLine)throw xt.create("app-offline");const a=mg(i);return t=dg(n,a),a}});return t?await t:s.authToken}async function hg(n,e){let t=await nc(n.appConfig);for(;t.authToken.requestStatus===1;)await fl(100),t=await nc(n.appConfig);const s=t.authToken;return s.requestStatus===0?Oo(n,e):s}function nc(n){return Rr(n,e=>{if(!wl(e))throw xt.create("not-registered");const t=e.authToken;return gg(t)?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e})}async function dg(n,e){try{const t=await ug(n,e),s=Object.assign(Object.assign({},e),{authToken:t});return await tr(n.appConfig,s),t}catch(t){if(al(t)&&(t.customData.serverCode===401||t.customData.serverCode===404))await yl(n.appConfig);else{const s=Object.assign(Object.assign({},e),{authToken:{requestStatus:0}});await tr(n.appConfig,s)}throw t}}function wl(n){return n!==void 0&&n.registrationStatus===2}function fg(n){return n.requestStatus===2&&!pg(n)}function pg(n){const e=Date.now();return e<n.creationTime||n.creationTime+n.expiresIn<e+$m}function mg(n){const e={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},n),{authToken:e})}function gg(n){return n.requestStatus===1&&n.requestTime+rl<Date.now()}/** 587 * @license 588 * Copyright 2019 Google LLC 589 * 590 * Licensed under the Apache License, Version 2.0 (the "License");
591 * you may not use this file except in compliance with the License. 592 * You may obtain a copy of the License at 593 * 594 * http://www.apache.org/licenses/LICENSE-2.0 595 * 596 * Unless required by applicable law or agreed to in writing, software 597 * distributed under the License is distributed on an "AS IS" BASIS, 598 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 599 * See the License for the specific language governing permissions and 600 * limitations under the License. 601 */async function yg(n){const e=n,{installationEntry:t,registrationPromise:s}=await Ro(e);return s?s.catch(console.error):Oo(e).catch(console.error),t.fid}/** 602 * @license 603 * Copyright 2019 Google LLC 604 * 605 * Licensed under the Apache License, Version 2.0 (the "License"); 606 * you may not use this file except in compliance with the License. 607 * You may obtain a copy of the License at 608 * 609 * http://www.apache.org/licenses/LICENSE-2.0 610 * 611 * Unless required by applicable law or agreed to in writing, software 612 * distributed under the License is distributed on an "AS IS" BASIS, 613 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 614 * See the License for the specific language governing permissions and 615 * limitations under the License. 616 */async function vg(n,e=!1){const t=n;return await wg(t),(await Oo(t,e)).token}async function wg(n){const{registrationPromise:e}=await Ro(n);e&&await e}/** 617 * @license 618 * Copyright 2019 Google LLC 619 * 620 * Licensed under the Apache License, Version 2.0 (the "License"); 621 * you may not use this file except in compliance with the License. 622 * You may obtain a copy of the License at 623 * 624 * http://www.apache.org/licenses/LICENSE-2.0 625 * 626 * Unless required by applicable law or agreed to in writing, software 627 * distributed under the License is distributed on an "AS IS" BASIS, 628 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 629 * See the License for the specific language governing permissions and 630 * limitations under the License. 631 */function Ig(n){if(!n||!n.options)throw Si("App Configuration");if(!n.name)throw Si("App Name");const e=["projectId","apiKey","appId"];for(const t of e)if(!n.options[t])throw Si(t);return{appName:n.name,projectId:n.options.projectId,apiKey:n.options.apiKey,appId:n.options.appId}}function Si(n){return xt.create("missing-app-config-values",{valueName:n})}/** 632 * @license 633 * Copyright 2020 Google LLC 634 * 635 * Licensed under the Apache License, Version 2.0 (the "License"); 636 * you may not use this file except in compliance with the License. 637 * You may obtain a copy of the License at 638 * 639 * http://www.apache.org/licenses/LICENSE-2.0 640 * 641 * Unless required by applicable law or agreed to in writing, software 642 * distributed under the License is distributed on an "AS IS" BASIS, 643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 644 * See the License for the specific language governing permissions and 645 * limitations under the License. 646 */const Il="installations",Tg="installations-internal",Eg=n=>{const e=n.getProvider("app").getImmediate(),t=Ig(e),s=ut(e,"heartbeat");return{app:e,appConfig:t,heartbeatServiceProvider:s,_delete:()=>Promise.resolve()}},bg=n=>{const e=n.getProvider("app").getImmediate(),t=ut(e,Il).getImmediate();return{getId:()=>yg(t),getToken:r=>vg(t,r)}};function _g(){Ne(new Ce(Il,Eg,"PUBLIC")),Ne(new Ce(Tg,bg,"PRIVATE"))}_g();Ie(sl,No);Ie(sl,No,"esm2017");/** 647 * @license 648 * Copyright 2019 Google LLC 649 * 650 * Licensed under the Apache License, Version 2.0 (the "License"); 651 * you may not use this file except in compliance with the License. 652 * You may obtain a copy of the License at 653 * 654 * http://www.apache.org/licenses/LICENSE-2.0 655 * 656 * Unless required by applicable law or agreed to in writing, software 657 * distributed under the License is distributed on an "AS IS" BASIS, 658 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 659 * See the License for the specific language governing permissions and 660 * limitations under the License. 661 */const nr="analytics",Sg="firebase_id",Ag="origin",Cg=60*1e3,kg="https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig",Tl="https://www.googletagmanager.com/gtag/js";/** 662 * @license 663 * Copyright 2019 Google LLC 664 * 665 * Licensed under the Apache License, Version 2.0 (the "License");
666 * you may not use this file except in compliance with the License. 667 * You may obtain a copy of the License at 668 * 669 * http://www.apache.org/licenses/LICENSE-2.0 670 * 671 * Unless required by applicable law or agreed to in writing, software 672 * distributed under the License is distributed on an "AS IS" BASIS, 673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 674 * See the License for the specific language governing permissions and 675 * limitations under the License. 676 */const Ee=new Dr("@firebase/analytics");/** 677 * @license 678 * Copyright 2019 Google LLC 679 * 680 * Licensed under the Apache License, Version 2.0 (the "License"); 681 * you may not use this file except in compliance with the License. 682 * You may obtain a copy of the License at 683 * 684 * http://www.apache.org/licenses/LICENSE-2.0 685 * 686 * Unless required by applicable law or agreed to in writing, software 687 * distributed under the License is distributed on an "AS IS" BASIS, 688 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 689 * See the License for the specific language governing permissions and 690 * limitations under the License. 691 */function El(n){return Promise.all(n.map(e=>e.catch(t=>t)))}function Dg(n,e){const t=document.createElement("script");t.src=`${Tl}?l=${n}&id=${e}`,t.async=!0,document.head.appendChild(t)}function Ng(n){let e=[];return Array.isArray(window[n])?e=window[n]:window[n]=e,e}async function xg(n,e,t,s,r,i){const o=s[r];try{if(o)await e[o];else{const c=(await El(t)).find(u=>u.measurementId===r);c&&await e[c.appId]}}catch(a){Ee.error(a)}n("config",r,i)}async function Rg(n,e,t,s,r){try{let i=[];if(r&&r.send_to){let o=r.send_to;Array.isArray(o)||(o=[o]);const a=await El(t);for(const c of o){const u=a.find(h=>h.measurementId===c),l=u&&e[u.appId];if(l)i.push(l);else{i=[];break}}}i.length===0&&(i=Object.values(e)),await Promise.all(i),n("event",s,r||{})}catch(i){Ee.error(i)}}function Og(n,e,t,s){async function r(i,o,a){try{i==="event"?await Rg(n,e,t,o,a):i==="config"?await xg(n,e,t,s,o,a):i==="consent"?n("consent","update",a):n("set",o)}catch(c){Ee.error(c)}}return r}function Mg(n,e,t,s,r){let i=function(...o){window[s].push(arguments)};return window[r]&&typeof window[r]=="function"&&(i=window[r]),window[r]=Og(i,n,e,t),{gtagCore:i,wrappedGtag:window[r]}}function Pg(n){const e=window.document.getElementsByTagName("script");for(const t of Object.values(e))if(t.src&&t.src.includes(Tl)&&t.src.includes(n))return t;return null}/** 692 * @license 693 * Copyright 2019 Google LLC 694 * 695 * Licensed under the Apache License, Version 2.0 (the "License"); 696 * you may not use this file except in compliance with the License. 697 * You may obtain a copy of the License at 698 * 699 * http://www.apache.org/licenses/LICENSE-2.0 700 * 701 * Unless required by applicable law or agreed to in writing, software 702 * distributed under the License is distributed on an "AS IS" BASIS, 703 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 704 * See the License for the specific language governing permissions and 705 * limitations under the License. 706 */const Lg={["already-exists"]:"A Firebase Analytics instance with the appId {$id} already exists. Only one Firebase Analytics instance can be created for each appId.",["already-initialized"]:"initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-intialized instance.",["already-initialized-settings"]:"Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.",["interop-component-reg-failed"]:"Firebase Analytics Interop Component failed to instantiate: {$reason}",["invalid-analytics-context"]:"Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}",["indexeddb-unavailable"]:"IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}",["fetch-throttle"]:"The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.",["config-fetch-failed"]:"Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}",["no-api-key"]:'The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.',["no-app-id"]:'The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.'},Ae=new qt("analytics","Analytics",Lg);/** 707 * @license 708 * Copyright 2020 Google LLC 709 * 710 * Licensed under the Apache License, Version 2.0 (the "License");
711 * you may not use this file except in compliance with the License. 712 * You may obtain a copy of the License at 713 * 714 * http://www.apache.org/licenses/LICENSE-2.0 715 * 716 * Unless required by applicable law or agreed to in writing, software 717 * distributed under the License is distributed on an "AS IS" BASIS, 718 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 719 * See the License for the specific language governing permissions and 720 * limitations under the License. 721 */const Fg=30,Vg=1e3;class Ug{constructor(e={},t=Vg){this.throttleMetadata=e,this.intervalMillis=t}getThrottleMetadata(e){return this.throttleMetadata[e]}setThrottleMetadata(e,t){this.throttleMetadata[e]=t}deleteThrottleMetadata(e){delete this.throttleMetadata[e]}}const bl=new Ug;function Bg(n){return new Headers({Accept:"application/json","x-goog-api-key":n})}async function $g(n){var e;const{appId:t,apiKey:s}=n,r={method:"GET",headers:Bg(s)},i=kg.replace("{app-id}",t),o=await fetch(i,r);if(o.status!==200&&o.status!==304){let a="";try{const c=await o.json();!((e=c.error)===null||e===void 0)&&e.message&&(a=c.error.message)}catch{}throw Ae.create("config-fetch-failed",{httpStatus:o.status,responseMessage:a})}return o.json()}async function qg(n,e=bl,t){const{appId:s,apiKey:r,measurementId:i}=n.options;if(!s)throw Ae.create("no-app-id");if(!r){if(i)return{measurementId:i,appId:s};throw Ae.create("no-api-key")}const o=e.getThrottleMetadata(s)||{backoffCount:0,throttleEndTimeMillis:Date.now()},a=new Kg;return setTimeout(async()=>{a.abort()},t!==void 0?t:Cg),_l({appId:s,apiKey:r,measurementId:i},o,a,e)}async function _l(n,{throttleEndTimeMillis:e,backoffCount:t},s,r=bl){var i;const{appId:o,measurementId:a}=n;try{await jg(s,e)}catch(c){if(a)return Ee.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${c==null?void 0:c.message}]`),{appId:o,measurementId:a};throw c}try{const c=await $g(n);return r.deleteThrottleMetadata(o),c}catch(c){const u=c;if(!Gg(u)){if(r.deleteThrottleMetadata(o),a)return Ee.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${a} provided in the "measurementId" field in the local Firebase config. [${u==null?void 0:u.message}]`),{appId:o,measurementId:a};throw c}const l=Number((i=u==null?void 0:u.customData)===null||i===void 0?void 0:i.httpStatus)===503?Ha(t,r.intervalMillis,Fg):Ha(t,r.intervalMillis),h={throttleEndTimeMillis:Date.now()+l,backoffCount:t+1};return r.setThrottleMetadata(o,h),Ee.debug(`Calling attemptFetch again in ${l} millis`),_l(n,h,s,r)}}function jg(n,e){return new Promise((t,s)=>{const r=Math.max(e-Date.now(),0),i=setTimeout(t,r);n.addEventListener(()=>{clearTimeout(i),s(Ae.create("fetch-throttle",{throttleEndTimeMillis:e}))})})}function Gg(n){if(!(n instanceof ke)||!n.customData)return!1;const e=Number(n.customData.httpStatus);return e===429||e===500||e===503||e===504}class Kg{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}}async function zg(n,e,t,s,r){if(r&&r.global){n("event",t,s);return}else{const i=await e,o=Object.assign(Object.assign({},s),{send_to:i});n("event",t,o)}}/** 722 * @license 723 * Copyright 2020 Google LLC 724 * 725 * Licensed under the Apache License, Version 2.0 (the "License"); 726 * you may not use this file except in compliance with the License. 727 * You may obtain a copy of the License at 728 * 729 * http://www.apache.org/licenses/LICENSE-2.0 730 * 731 * Unless required by applicable law or agreed to in writing, software 732 * distributed under the License is distributed on an "AS IS" BASIS, 733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 734 * See the License for the specific language governing permissions and 735 * limitations under the License. 736 */async function Hg(){if(ko())try{await Yu()}catch(n){return Ee.warn(Ae.create("indexeddb-unavailable",{errorInfo:n==null?void 0:n.toString()}).message),!1}else return Ee.warn(Ae.create("indexeddb-unavailable",{errorInfo:"IndexedDB is not available in this environment."}).message),!1;return!0}async function Wg(n,e,t,s,r,i,o){var a;const c=qg(n);c.then(m=>{t[m.measurementId]=m.appId,n.options.measurementId&&m.measurementId!==n.options.measurementId&&Ee.warn(`The measurement ID in the local Firebase config (${n.options.measurementId}) does not match the measurement ID fetched from the server (${m.measurementId}). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.`)}).catch(m=>Ee.error(m)),e.push(c);const u=Hg().then(m=>{if(m)return s.getId()}),[l,h]=await Promise.all([c,u]);Pg(i)||Dg(i,l.measurementId),r("js",new Date);const d=(a=o==null?void 0:o.config)!==null&&a!==void 0?a:{};return d[Ag]="firebase",d.update=!0,h!=null&&(d[Sg]=h),r("config",l.measurementId,d),l.measurementId}/** 737 * @license 738 * Copyright 2019 Google LLC 739 * 740 * Licensed under the Apache License, Version 2.0 (the "License");
741 * you may not use this file except in compliance with the License. 742 * You may obtain a copy of the License at 743 * 744 * http://www.apache.org/licenses/LICENSE-2.0 745 * 746 * Unless required by applicable law or agreed to in writing, software 747 * distributed under the License is distributed on an "AS IS" BASIS, 748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 749 * See the License for the specific language governing permissions and 750 * limitations under the License. 751 */class Qg{constructor(e){this.app=e}_delete(){return delete Fn[this.app.options.appId],Promise.resolve()}}let Fn={},sc=[];const rc={};let Ai="dataLayer",Yg="gtag",ic,Sl,oc=!1;function Xg(){const n=[];if(Qu()&&n.push("This is a browser extension environment."),Ep()||n.push("Cookies are not available."),n.length>0){const e=n.map((s,r)=>`(${r+1}) ${s}`).join(" "),t=Ae.create("invalid-analytics-context",{errorInfo:e});Ee.warn(t.message)}}function Jg(n,e,t){Xg();const s=n.options.appId;if(!s)throw Ae.create("no-app-id");if(!n.options.apiKey)if(n.options.measurementId)Ee.warn(`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID ${n.options.measurementId} provided in the "measurementId" field in the local Firebase config.`);else throw Ae.create("no-api-key");if(Fn[s]!=null)throw Ae.create("already-exists",{id:s});if(!oc){Ng(Ai);const{wrappedGtag:i,gtagCore:o}=Mg(Fn,sc,rc,Ai,Yg);Sl=i,ic=o,oc=!0}return Fn[s]=Wg(n,sc,rc,e,ic,Ai,t),new Qg(n)}function Zg(n=Nr()){n=q(n);const e=ut(n,nr);return e.isInitialized()?e.getImmediate():ey(n)}function ey(n,e={}){const t=ut(n,nr);if(t.isInitialized()){const r=t.getImmediate();if(Gn(e,t.getOptions()))return r;throw Ae.create("already-initialized")}return t.initialize({options:e})}function ty(n,e,t,s){n=q(n),zg(Sl,Fn[n.app.options.appId],e,t,s).catch(r=>Ee.error(r))}const ac="@firebase/analytics",cc="0.9.3";function ny(){Ne(new Ce(nr,(e,{options:t})=>{const s=e.getProvider("app").getImmediate(),r=e.getProvider("installations-internal").getImmediate();return Jg(s,r,t)},"PUBLIC")),Ne(new Ce("analytics-internal",n,"PRIVATE")),Ie(ac,cc),Ie(ac,cc,"esm2017");function n(e){try{const t=e.getProvider(nr).getImmediate();return{logEvent:(s,r,i)=>ty(t,s,r,i)}}catch(t){throw Ae.create("interop-component-reg-failed",{reason:t})}}}ny();var sy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},T,Mo=Mo||{},C=sy||self;function sr(){}function Or(n){var e=typeof n;return e=e!="object"?e:n?Array.isArray(n)?"array":e:"null",e=="array"||e=="object"&&typeof n.length=="number"}function cs(n){var e=typeof n;return e=="object"&&n!=null||e=="function"}function ry(n){return Object.prototype.hasOwnProperty.call(n,Ci)&&n[Ci]||(n[Ci]=++iy)}var Ci="closure_uid_"+(1e9*Math.random()>>>0),iy=0;function oy(n,e,t){return n.call.apply(n.bind,arguments)}function ay(n,e,t){if(!n)throw Error();if(2<arguments.length){var s=Array.prototype.slice.call(arguments,2);return function(){var r=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(r,s),n.apply(e,r)}}return function(){return n.apply(e,arguments)}}function le(n,e,t){return Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?le=oy:le=ay,le.apply(null,arguments)}function Rs(n,e){var t=Array.prototype.slice.call(arguments,1);return function(){var s=t.slice();return s.push.apply(s,arguments),n.apply(this,s)}}function ce(n,e){function t(){}t.prototype=e.prototype,n.X=e.prototype,n.prototype=new t,n.prototype.constructor=n,n.Wb=function(s,r,i){for(var o=Array(arguments.length-2),a=2;a<arguments.length;a++)o[a-2]=arguments[a];return e.prototype[r].apply(s,o)}}function lt(){this.s=this.s,this.o=this.o}var cy=0;lt.prototype.s=!1;lt.prototype.na=function(){!this.s&&(this.s=!0,this.M(),cy!=0)&&ry(this)};lt.prototype.M=function(){if(this.o)for(;this.o.length;)this.o.shift()()};const Al=Array.prototype.indexOf?function(n,e){return Array.prototype.indexOf.call(n,e,void 0)}:function(n,e){if(typeof n=="string")return typeof e!="string"||e.length!=1?-1:n.indexOf(e,0);for(let t=0;t<n.length;t++)if(t in n&&n[t]===e)return t;return-1};function Po(n){const e=n.length;if(0<e){const t=Array(e);for(let s=0;s<e;s++)t[s]=n[s];return t}return[]}function uc(n,e){for(let t=1;t<arguments.length;t++){const s=arguments[t];if(Or(s)){const r=n.length||0,i=s.length||0;n.length=r+i;for(let o=0;o<i;o++)n[r+o]=s[o]}else n.push(s)}}function he(n,e){this.type=n,this.g=this.target=e,this.defaultPrevented=!1}he.prototype.h=function(){this.defaultPrevented=!0};var uy=function(){if(!C.addEventListener||!Object.defineProperty)return!1;var n=!1,e=Object.defineProperty({},"passive",{get:function(){n=!0}});try{C.addEventListener("test",sr,e),C.removeEventListener("test",sr,e)}catch{}return n}();function rr(n){return/^[\s\xa0]*$/.test(n)}var lc=String.prototype.trim?function(n){return n.trim()}:function(n){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(n)[1]};function ki(n,e){return n<e?-1:n>e?1:0}function Mr(){var n=C.navigator;return n&&(n=n.userAgent)?n:""}function Oe(n){return Mr().indexOf(n)!=-1}function Lo(n){return Lo[" "](n),n}Lo[" "]=sr;function ly(n){var e=fy;return Object.prototype.hasOwnProperty.call(e,9)?e[9]:e[9]=n(9)}var hy=Oe("Opera"),on=Oe("Trident")||Oe("MSIE"),Cl=Oe("Edge"),zi=Cl||on,kl=Oe("Gecko")&&!(Mr().toLowerCase().indexOf("webkit")!=-1&&!Oe("Edge"))&&!(Oe("Trident")||Oe("MSIE"))&&!Oe("Edge"),dy=Mr().toLowerCase().indexOf("webkit")!=-1&&!Oe("Edge");function Dl(){var n=C.document;return n?n.documentMode:void 0}var ir;e:{var Di="",Ni=function(){var n=Mr();if(kl)return/rv:([^\);]+)(\)|;)/.exec(n);if(Cl)return/Edge\/([\d\.]+)/.exec(n);if(on)return/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(n);if(dy)return/WebKit\/(\S+)/.exec(n);if(hy)return/(?:Version)[ \/]?(\S+)/.exec(n)}();if(Ni&&(Di=Ni?Ni[1]:""),on){var xi=Dl();if(xi!=null&&xi>parseFloat(Di)){ir=String(xi);break e}}ir=Di}var fy={};function py(){return ly(function(){let n=0;const e=lc(String(ir)).split("."),t=lc("9").split("."),s=Math.max(e.length,t.length);for(let o=0;n==0&&o<s;o++){var r=e[o]||"",i=t[o]||"";do{if(r=/(\d*)(\D*)(.*)/.exec(r)||["","","",""],i=/(\d*)(\D*)(.*)/.exec(i)||["","","",""],r[0].length==0&&i[0].length==0)break;n=ki(r[1].length==0?0:parseInt(r[1],10),i[1].length==0?0:parseInt(i[1],10))||ki(r[2].length==0,i[2].length==0)||ki(r[2],i[2]),r=r[3],i=i[3]}while(n==0)}return 0<=n})}var Hi;if(C.document&&on){var hc=Dl();Hi=hc||parseInt(ir,10)||void 0}else Hi=void 0;var my=Hi;function zn(n,e){if(he.call(this,n?n.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,n){var t=this.t
751ype=n.type,s=n.changedTouches&&n.changedTouches.length?n.changedTouches[0]:null;if(this.target=n.target||n.srcElement,this.g=e,e=n.relatedTarget){if(kl){e:{try{Lo(e.nodeName);var r=!0;break e}catch{}r=!1}r||(e=null)}}else t=="mouseover"?e=n.fromElement:t=="mouseout"&&(e=n.toElement);this.relatedTarget=e,s?(this.clientX=s.clientX!==void 0?s.clientX:s.pageX,this.clientY=s.clientY!==void 0?s.clientY:s.pageY,this.screenX=s.screenX||0,this.screenY=s.screenY||0):(this.clientX=n.clientX!==void 0?n.clientX:n.pageX,this.clientY=n.clientY!==void 0?n.clientY:n.pageY,this.screenX=n.screenX||0,this.screenY=n.screenY||0),this.button=n.button,this.key=n.key||"",this.ctrlKey=n.ctrlKey,this.altKey=n.altKey,this.shiftKey=n.shiftKey,this.metaKey=n.metaKey,this.pointerId=n.pointerId||0,this.pointerType=typeof n.pointerType=="string"?n.pointerType:gy[n.pointerType]||"",this.state=n.state,this.i=n,n.defaultPrevented&&zn.X.h.call(this)}}ce(zn,he);var gy={2:"touch",3:"pen",4:"mouse"};zn.prototype.h=function(){zn.X.h.call(this);var n=this.i;n.preventDefault?n.preventDefault():n.returnValue=!1};var us="closure_listenable_"+(1e6*Math.random()|0),yy=0;function vy(n,e,t,s,r){this.listener=n,this.proxy=null,this.src=e,this.type=t,this.capture=!!s,this.ha=r,this.key=++yy,this.ba=this.ea=!1}function Pr(n){n.ba=!0,n.listener=null,n.proxy=null,n.src=null,n.ha=null}function Fo(n,e,t){for(const s in n)e.call(t,n[s],s,n)}function Nl(n){const e={};for(const t in n)e[t]=n[t];return e}const dc="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function xl(n,e){let t,s;for(let r=1;r<arguments.length;r++){s=arguments[r];for(t in s)n[t]=s[t];for(let i=0;i<dc.length;i++)t=dc[i],Object.prototype.hasOwnProperty.call(s,t)&&(n[t]=s[t])}}function Lr(n){this.src=n,this.g={},this.h=0}Lr.prototype.add=function(n,e,t,s,r){var i=n.toString();n=this.g[i],n||(n=this.g[i]=[],this.h++);var o=Qi(n,e,s,r);return-1<o?(e=n[o],t||(e.ea=!1)):(e=new vy(e,this.src,i,!!s,r),e.ea=t,n.push(e)),e};function Wi(n,e){var t=e.type;if(t in n.g){var s=n.g[t],r=Al(s,e),i;(i=0<=r)&&Array.prototype.splice.call(s,r,1),i&&(Pr(e),n.g[t].length==0&&(delete n.g[t],n.h--))}}function Qi(n,e,t,s){for(var r=0;r<n.length;++r){var i=n[r];if(!i.ba&&i.listener==e&&i.capture==!!t&&i.ha==s)return r}return-1}var Vo="closure_lm_"+(1e6*Math.random()|0),Ri={};function Rl(n,e,t,s,r){if(s&&s.once)return Ml(n,e,t,s,r);if(Array.isArray(e)){for(var i=0;i<e.length;i++)Rl(n,e[i],t,s,r);return null}return t=$o(t),n&&n[us]?n.N(e,t,cs(s)?!!s.capture:!!s,r):Ol(n,e,t,!1,s,r)}function Ol(n,e,t,s,r,i){if(!e)throw Error("Invalid event type");var o=cs(r)?!!r.capture:!!r,a=Bo(n);if(a||(n[Vo]=a=new Lr(n)),t=a.add(e,t,s,o,i),t.proxy)return t;if(s=wy(),t.proxy=s,s.src=n,s.listener=t,n.addEventListener)uy||(r=o),r===void 0&&(r=!1),n.addEventListener(e.toString(),s,r);else if(n.attachEvent)n.attachEvent(Ll(e.toString()),s);else if(n.addListener&&n.removeListener)n.addListener(s);else throw Error("addEventListener and attachEvent are unavailable.");return t}function wy(){function n(t){return e.call(n.src,n.listener,t)}const e=Iy;return n}function Ml(n,e,t,s,r){if(Array.isArray(e)){for(var i=0;i<e.length;i++)Ml(n,e[i],t,s,r);return null}return t=$o(t),n&&n[us]?n.O(e,t,cs(s)?!!s.capture:!!s,r):Ol(n,e,t,!0,s,r)}function Pl(n,e,t,s,r){if(Array.isArray(e))for(var i=0;i<e.length;i++)Pl(n,e[i],t,s,r);else s=cs(s)?!!s.capture:!!s,t=$o(t),n&&n[us]?(n=n.i,e=String(e).toString(),e in n.g&&(i=n.g[e],t=Qi(i,t,s,r),-1<t&&(Pr(i[t]),Array.prototype.splice.call(i,t,1),i.length==0&&(delete n.g[e],n.h--)))):n&&(n=Bo(n))&&(e=n.g[e.toString()],n=-1,e&&(n=Qi(e,t,s,r)),(t=-1<n?e[n]:null)&&Uo(t))}function Uo(n){if(typeof n!="number"&&n&&!n.ba){var e=n.src;if(e&&e[us])Wi(e.i,n);else{var t=n.type,s=n.proxy;e.removeEventListener?e.removeEventListener(t,s,n.capture):e.detachEvent?e.detachEvent(Ll(t),s):e.addListener&&e.removeListener&&e.removeListener(s),(t=Bo(e))?(Wi(t,n),t.h==0&&(t.src=null,e[Vo]=null)):Pr(n)}}}function Ll(n){return n in Ri?Ri[n]:Ri[n]="on"+n}function Iy(n,e){if(n.ba)n=!0;else{e=new zn(e,this);var t=n.listener,s=n.ha||n.src;n.ea&&Uo(n),n=t.call(s,e)}return n}function Bo(n){return n=n[Vo],n instanceof Lr?n:null}var Oi="__closure_events_fn_"+(1e9*Math.random()>>>0);function $o(n){return typeof n=="function"?n:(n[Oi]||(n[Oi]=function(e){return n.handleEvent(e)}),n[Oi])}function te(){lt.call(this),this.i=new Lr(this),this.P=this,this.I=null}ce(te,lt);te.prototype[us]=!0;te.prototype.removeEventListener=function(n,e,t,s){Pl(this,n,e,t,s)};function oe(n,e){var t,s=n.I;if(s)for(t=[];s;s=s.I)t.push(s);if(n=n.P,s=e.type||e,typeof e=="string")e=new he(e,n);else if(e instanceof he)e.target=e.target||n;else{var r=e;e=new he(s,n),xl(e,r)}if(r=!0,t)for(var i=t.length-1;0<=i;i--){var o=e.g=t[i];r=Os(o,s,!0,e)&&r}if(o=e.g=n,r=Os(o,s,!0,e)&&r,r=Os(o,s,!1,e)&&r,t)for(i=0;i<t.length;i++)o=e.g=t[i],r=Os(o,s,!1,e)&&r}te.prototype.M=function(){if(te.X.M.call(this),this.i){var n=this.i,e;for(e in n.g){for(var t=n.g[e],s=0;s<t.length;s++)Pr(t[s]);delete n.g[e],n.h--}}this.I=null};te.prototype.N=function(n,e,t,s){return this.i.add(String(n),e,!1,t,s)};te.prototype.O=function(n,e,t,s){return this.i.add(String(n),e,!0,t,s)};function Os(n,e,t,s){if(e=n.i.g[String(e)],!e)return!0;e=e.concat();for(var r=!0,i=0;i<e.length;++i){var o=e[i];if(o&&!o.ba&&o.capture==t){var a=o.listener,c=o.ha||o.src;o.ea&&Wi(n.i,o),r=a.call(c,s)!==!1&&r}}return r&&!s.defaultPrevented}var qo=C.JSON.stringify;function Ty(){var n=Ul;let e=null;return n.g&&(e=n.g,n.g=n.g.next,n.g||(n.h=null),e.next=null),e}class Ey{constructor(){this.h=this.g=null}add(e,t){const s=Fl.get();s.set(e,t),this.h?this.h.next=s:this.g=s,this.h=s}}var Fl=new class{constructor(n,e){this.i=n,this.j=e,this.h=0,this.g=null}get(){let n;return 0<this.h?(this.h--,n=this.g,this.g=n.next,n.next=null):n=this.i(),n}}(()=>new by,n=>n.reset());class by{constructor(){this.next=this.g=this.h=null}set(e,t){this.h=e,this.g=t,this.next=null}reset(){this.next=this.g=this.h=null}}function _y(n){C.setTimeout(()=>{throw n},0)}function Vl(n,e){Yi||Sy(),Xi||(Yi(),Xi=!0),Ul.add(n,e)}var Yi;function Sy(){var n=C.Promise.resolve(void 0);Yi=function(){n.then(Ay)}}var Xi=!1,Ul=new Ey;function Ay(){for(var n;n=Ty();){try{n.h.call(n.g)}catch(t){_y(t)}var e=Fl;e.j(n),100>e.h&&(e.h++,n.next=e.g,e.g=n)}Xi=!1}function Fr(n,e){te.call(this),this.h=n||1,this.g=e||C,this.j=le(this.lb,this),this.l=Date.now()}ce(Fr,te);T=Fr.prototype;T.ca=!1;T.R=null;T.lb=function(){if(this.ca){var n=Date.now()-this.l;0<n&&n<.8*this.h?this.R=this.g.setTimeout(this.j,this.h-n):(this.R&&(this.g.clearTimeout(this.R),this.R=null),oe(this,"tick"),this.ca&&(jo(this),this.start()))}};T.start=function(){this.ca=!0,this.R||(this.R=this.g.setTimeout(this.j,this.h),this.l=Date.now())};function jo(n){n.ca=!1,n.R&&(n.g.clearTimeout(n.R),n.R=null)}T.M=function(){Fr.X.M.call(this),jo(this),delete this.g};function Go(n,e,t){if(typeof n=="function")t&&(n=le(n,t));else if(n&&typeof n.handleEvent=="function")n=le(n.handleEvent,n);else throw Error("Invalid listener argument");return 2147483647<Number(e)?-1:C.setTimeout(n,e||0)}function Bl(n){n.g=Go(()=>{n.g=null,n.i&&(n.i=!1,Bl(n))},n.j);const e=n.h;n.h=null,n.m.apply(null,e)}class Cy extends lt{constructor(e,t){super(),this.m=e,this.j=t,this.h=null,this.i=!1,this.g=null}l(e){this.h=arguments,this.g?this.i=!0:Bl(this)}
751M(){super.M(),this.g&&(C.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Hn(n){lt.call(this),this.h=n,this.g={}}ce(Hn,lt);var fc=[];function $l(n,e,t,s){Array.isArray(t)||(t&&(fc[0]=t.toString()),t=fc);for(var r=0;r<t.length;r++){var i=Rl(e,t[r],s||n.handleEvent,!1,n.h||n);if(!i)break;n.g[i.key]=i}}function ql(n){Fo(n.g,function(e,t){this.g.hasOwnProperty(t)&&Uo(e)},n),n.g={}}Hn.prototype.M=function(){Hn.X.M.call(this),ql(this)};Hn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};function Vr(){this.g=!0}Vr.prototype.Aa=function(){this.g=!1};function ky(n,e,t,s,r,i){n.info(function(){if(n.g)if(i)for(var o="",a=i.split("&"),c=0;c<a.length;c++){var u=a[c].split("=");if(1<u.length){var l=u[0];u=u[1];var h=l.split("_");o=2<=h.length&&h[1]=="type"?o+(l+"="+u+"&"):o+(l+"=redacted&")}}else o=null;else o=i;return"XMLHTTP REQ ("+s+") [attempt "+r+"]: "+e+` 752`+t+` 753`+o})}function Dy(n,e,t,s,r,i,o){n.info(function(){return"XMLHTTP RESP ("+s+") [ attempt "+r+"]: "+e+` 754`+t+` 755`+i+" "+o})}function Jt(n,e,t,s){n.info(function(){return"XMLHTTP TEXT ("+e+"): "+xy(n,t)+(s?" "+s:"")})}function Ny(n,e){n.info(function(){return"TIMEOUT: "+e})}Vr.prototype.info=function(){};function xy(n,e){if(!n.g)return e;if(!e)return null;try{var t=JSON.parse(e);if(t){for(n=0;n<t.length;n++)if(Array.isArray(t[n])){var s=t[n];if(!(2>s.length)){var r=s[1];if(Array.isArray(r)&&!(1>r.length)){var i=r[0];if(i!="noop"&&i!="stop"&&i!="close")for(var o=1;o<r.length;o++)r[o]=""}}}}return qo(t)}catch{return e}}var jt={},pc=null;function Ur(){return pc=pc||new te}jt.Pa="serverreachability";function jl(n){he.call(this,jt.Pa,n)}ce(jl,he);function Wn(n){const e=Ur();oe(e,new jl(e))}jt.STAT_EVENT="statevent";function Gl(n,e){he.call(this,jt.STAT_EVENT,n),this.stat=e}ce(Gl,he);function me(n){const e=Ur();oe(e,new Gl(e,n))}jt.Qa="timingevent";function Kl(n,e){he.call(this,jt.Qa,n),this.size=e}ce(Kl,he);function ls(n,e){if(typeof n!="function")throw Error("Fn must not be null and must be a function");return C.setTimeout(function(){n()},e)}var Br={NO_ERROR:0,mb:1,zb:2,yb:3,tb:4,xb:5,Ab:6,Ma:7,TIMEOUT:8,Db:9},zl={rb:"complete",Nb:"success",Na:"error",Ma:"abort",Fb:"ready",Gb:"readystatechange",TIMEOUT:"timeout",Bb:"incrementaldata",Eb:"progress",ub:"downloadprogress",Vb:"uploadprogress"};function Ko(){}Ko.prototype.h=null;function mc(n){return n.h||(n.h=n.i())}function Hl(){}var hs={OPEN:"a",qb:"b",Na:"c",Cb:"d"};function zo(){he.call(this,"d")}ce(zo,he);function Ho(){he.call(this,"c")}ce(Ho,he);var Ji;function $r(){}ce($r,Ko);$r.prototype.g=function(){return new XMLHttpRequest};$r.prototype.i=function(){return{}};Ji=new $r;function ds(n,e,t,s){this.l=n,this.j=e,this.m=t,this.U=s||1,this.S=new Hn(this),this.O=Ry,n=zi?125:void 0,this.T=new Fr(n),this.H=null,this.i=!1,this.s=this.A=this.v=this.K=this.F=this.V=this.B=null,this.D=[],this.g=null,this.C=0,this.o=this.u=null,this.Y=-1,this.I=!1,this.N=0,this.L=null,this.$=this.J=this.Z=this.P=!1,this.h=new Wl}function Wl(){this.i=null,this.g="",this.h=!1}var Ry=45e3,Zi={},or={};T=ds.prototype;T.setTimeout=function(n){this.O=n};function eo(n,e,t){n.K=1,n.v=jr(Ke(e)),n.s=t,n.P=!0,Ql(n,null)}function Ql(n,e){n.F=Date.now(),fs(n),n.A=Ke(n.v);var t=n.A,s=n.U;Array.isArray(s)||(s=[String(s)]),sh(t.i,"t",s),n.C=0,t=n.l.H,n.h=new Wl,n.g=_h(n.l,t?e:null,!n.s),0<n.N&&(n.L=new Cy(le(n.La,n,n.g),n.N)),$l(n.S,n.g,"readystatechange",n.ib),e=n.H?Nl(n.H):{},n.s?(n.u||(n.u="POST"),e["Content-Type"]="application/x-www-form-urlencoded",n.g.da(n.A,n.u,n.s,e)):(n.u="GET",n.g.da(n.A,n.u,null,e)),Wn(),ky(n.j,n.u,n.A,n.m,n.U,n.s)}T.ib=function(n){n=n.target;const e=this.L;e&&$e(n)==3?e.l():this.La(n)};T.La=function(n){try{if(n==this.g)e:{const l=$e(this.g);var e=this.g.Ea();const h=this.g.aa();if(!(3>l)&&(l!=3||zi||this.g&&(this.h.h||this.g.fa()||wc(this.g)))){this.I||l!=4||e==7||(e==8||0>=h?Wn(3):Wn(2)),qr(this);var t=this.g.aa();this.Y=t;t:if(Yl(this)){var s=wc(this.g);n="";var r=s.length,i=$e(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){_t(this),Vn(this);var o="";break t}this.h.i=new C.TextDecoder}for(e=0;e<r;e++)this.h.h=!0,n+=this.h.i.decode(s[e],{stream:i&&e==r-1});s.splice(0,r),this.h.g+=n,this.C=0,o=this.h.g}else o=this.g.fa();if(this.i=t==200,Dy(this.j,this.u,this.A,this.m,this.U,l,t),this.i){if(this.Z&&!this.J){t:{if(this.g){var a,c=this.g;if((a=c.g?c.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!rr(a)){var u=a;break t}}u=null}if(t=u)Jt(this.j,this.m,t,"Initial handshake response via X-HTTP-Initial-Response"),this.J=!0,to(this,t);else{this.i=!1,this.o=3,me(12),_t(this),Vn(this);break e}}this.P?(Xl(this,l,o),zi&&this.i&&l==3&&($l(this.S,this.T,"tick",this.hb),this.T.start())):(Jt(this.j,this.m,o,null),to(this,o)),l==4&&_t(this),this.i&&!this.I&&(l==4?Ih(this.l,this):(this.i=!1,fs(this)))}else t==400&&0<o.indexOf("Unknown SID")?(this.o=3,me(12)):(this.o=0,me(13)),_t(this),Vn(this)}}}catch{}finally{}};function Yl(n){return n.g?n.u=="GET"&&n.K!=2&&n.l.Da:!1}function Xl(n,e,t){let s=!0,r;for(;!n.I&&n.C<t.length;)if(r=Oy(n,t),r==or){e==4&&(n.o=4,me(14),s=!1),Jt(n.j,n.m,null,"[Incomplete Response]");break}else if(r==Zi){n.o=4,me(15),Jt(n.j,n.m,t,"[Invalid Chunk]"),s=!1;break}else Jt(n.j,n.m,r,null),to(n,r);Yl(n)&&r!=or&&r!=Zi&&(n.h.g="",n.C=0),e!=4||t.length!=0||n.h.h||(n.o=1,me(16),s=!1),n.i=n.i&&s,s?0<t.length&&!n.$&&(n.$=!0,e=n.l,e.g==n&&e.$&&!e.K&&(e.j.info("Great, no buffering proxy detected. Bytes received: "+t.length),ea(e),e.K=!0,me(11))):(Jt(n.j,n.m,t,"[Invalid Chunked Response]"),_t(n),Vn(n))}T.hb=function(){if(this.g){var n=$e(this.g),e=this.g.fa();this.C<e.length&&(qr(this),Xl(this,n,e),this.i&&n!=4&&fs(this))}};function Oy(n,e){var t=n.C,s=e.indexOf(` 756`,t);return s==-1?or:(t=Number(e.substring(t,s)),isNaN(t)?Zi:(s+=1,s+t>e.length?or:(e=e.substr(s,t),n.C=s+t,e)))}T.cancel=function(){this.I=!0,_t(this)};function fs(n){n.V=Date.now()+n.O,Jl(n,n.O)}function Jl(n,e){if(n.B!=null)throw Error("WatchDog timer not null");
vendor: 5,722 bytes, line 756
756n.B=ls(le(n.gb,n),e)}function qr(n){n.B&&(C.clearTimeout(n.B),n.B=null)}T.gb=function(){this.B=null;const n=Date.now();0<=n-this.V?(Ny(this.j,this.A),this.K!=2&&(Wn(),me(17)),_t(this),this.o=2,Vn(this)):Jl(this,this.V-n)};function Vn(n){n.l.G==0||n.I||Ih(n.l,n)}function _t(n){qr(n);var e=n.L;e&&typeof e.na=="function"&&e.na(),n.L=null,jo(n.T),ql(n.S),n.g&&(e=n.g,n.g=null,e.abort(),e.na())}function to(n,e){try{var t=n.l;if(t.G!=0&&(t.g==n||no(t.h,n))){if(!n.J&&no(t.h,n)&&t.G==3){try{var s=t.Fa.g.parse(e)}catch{s=null}if(Array.isArray(s)&&s.length==3){var r=s;if(r[0]==0){e:if(!t.u){if(t.g)if(t.g.F+3e3<n.F)ur(t),zr(t);else break e;Zo(t),me(18)}}else t.Ba=r[1],0<t.Ba-t.T&&37500>r[2]&&t.L&&t.A==0&&!t.v&&(t.v=ls(le(t.cb,t),6e3));if(1>=oh(t.h)&&t.ja){try{t.ja()}catch{}t.ja=void 0}}else St(t,11)}else if((n.J||t.g==n)&&ur(t),!rr(e))for(r=t.Fa.g.parse(e),e=0;e<r.length;e++){let u=r[e];if(t.T=u[0],u=u[1],t.G==2)if(u[0]=="c"){t.I=u[1],t.ka=u[2];const l=u[3];l!=null&&(t.ma=l,t.j.info("VER="+t.ma));const h=u[4];h!=null&&(t.Ca=h,t.j.info("SVER="+t.Ca));const d=u[5];d!=null&&typeof d=="number"&&0<d&&(s=1.5*d,t.J=s,t.j.info("backChannelRequestTimeoutMs_="+s)),s=t;const m=n.g;if(m){const y=m.g?m.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(y){var i=s.h;i.g||y.indexOf("spdy")==-1&&y.indexOf("quic")==-1&&y.indexOf("h2")==-1||(i.j=i.l,i.g=new Set,i.h&&(Wo(i,i.h),i.h=null))}if(s.D){const E=m.g?m.g.getResponseHeader("X-HTTP-Session-Id"):null;E&&(s.za=E,$(s.F,s.D,E))}}t.G=3,t.l&&t.l.xa(),t.$&&(t.P=Date.now()-n.F,t.j.info("Handshake RTT: "+t.P+"ms")),s=t;var o=n;if(s.sa=bh(s,s.H?s.ka:null,s.V),o.J){ah(s.h,o);var a=o,c=s.J;c&&a.setTimeout(c),a.B&&(qr(a),fs(a)),s.g=o}else vh(s);0<t.i.length&&Hr(t)}else u[0]!="stop"&&u[0]!="close"||St(t,7);else t.G==3&&(u[0]=="stop"||u[0]=="close"?u[0]=="stop"?St(t,7):Jo(t):u[0]!="noop"&&t.l&&t.l.wa(u),t.A=0)}}Wn(4)}catch{}}function My(n){if(n.W&&typeof n.W=="function")return n.W();if(typeof Map<"u"&&n instanceof Map||typeof Set<"u"&&n instanceof Set)return Array.from(n.values());if(typeof n=="string")return n.split("");if(Or(n)){for(var e=[],t=n.length,s=0;s<t;s++)e.push(n[s]);return e}e=[],t=0;for(s in n)e[t++]=n[s];return e}function Py(n){if(n.oa&&typeof n.oa=="function")return n.oa();if(!n.W||typeof n.W!="function"){if(typeof Map<"u"&&n instanceof Map)return Array.from(n.keys());if(!(typeof Set<"u"&&n instanceof Set)){if(Or(n)||typeof n=="string"){var e=[];n=n.length;for(var t=0;t<n;t++)e.push(t);return e}e=[],t=0;for(const s in n)e[t++]=s;return e}}}function Zl(n,e){if(n.forEach&&typeof n.forEach=="function")n.forEach(e,void 0);else if(Or(n)||typeof n=="string")Array.prototype.forEach.call(n,e,void 0);else for(var t=Py(n),s=My(n),r=s.length,i=0;i<r;i++)e.call(void 0,s[i],t&&t[i],n)}var eh=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Ly(n,e){if(n){n=n.split("&");for(var t=0;t<n.length;t++){var s=n[t].indexOf("="),r=null;if(0<=s){var i=n[t].substring(0,s);r=n[t].substring(s+1)}else i=n[t];e(i,r?decodeURIComponent(r.replace(/\+/g," ")):"")}}}function Ct(n,e){if(this.g=this.s=this.j="",this.m=null,this.o=this.l="",this.h=!1,n instanceof Ct){this.h=e!==void 0?e:n.h,ar(this,n.j),this.s=n.s,this.g=n.g,cr(this,n.m),this.l=n.l,e=n.i;var t=new Qn;t.i=e.i,e.g&&(t.g=new Map(e.g),t.h=e.h),gc(this,t),this.o=n.o}else n&&(t=String(n).match(eh))?(this.h=!!e,ar(this,t[1]||"",!0),this.s=Rn(t[2]||""),this.g=Rn(t[3]||"",!0),cr(this,t[4]),this.l=Rn(t[5]||"",!0),gc(this,t[6]||"",!0),this.o=Rn(t[7]||"")):(this.h=!!e,this.i=new Qn(null,this.h))}Ct.prototype.toString=function(){var n=[],e=this.j;e&&n.push(On(e,yc,!0),":");var t=this.g;return(t||e=="file")&&(n.push("//"),(e=this.s)&&n.push(On(e,yc,!0),"@"),n.push(encodeURIComponent(String(t)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),t=this.m,t!=null&&n.push(":",String(t))),(t=this.l)&&(this.g&&t.charAt(0)!="/"&&n.push("/"),n.push(On(t,t.charAt(0)=="/"?Uy:Vy,!0))),(t=this.i.toString())&&n.push("?",t),(t=this.o)&&n.push("#",On(t,$y)),n.join("")};function Ke(n){return new Ct(n)}function ar(n,e,t){n.j=t?Rn(e,!0):e,n.j&&(n.j=n.j.replace(/:$/,""))}function cr(n,e){if(e){if(e=Number(e),isNaN(e)||0>e)throw Error("Bad port number "+e);n.m=e}else n.m=null}function gc(n,e,t){e instanceof Qn?(n.i=e,qy(n.i,n.h)):(t||(e=On(e,By)),n.i=new Qn(e,n.h))}function $(n,e,t){n.i.set(e,t)}function jr(n){return $(n,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),n}function Rn(n,e){return n?e?decodeURI(n.replace(/%25/g,"%2525")):decodeURIComponent(n):""}function On(n,e,t){return typeof n=="string"?(n=encodeURI(n).replace(e,Fy),t&&(n=n.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),n):null}function Fy(n){return n=n.charCodeAt(0),"%"+(n>>4&15).toString(16)+(n&15).toString(16)}var yc=/[#\/\?@]/g,Vy=/[#\?:]/g,Uy=/[#\?]/g,By=/[#\?@]/g,$y=/#/g;function Qn(n,e){this.h=this.g=null,this.i=n||null,this.j=!!e}function ht(n){n.g||(n.g=new Map,n.h=0,n.i&&Ly(n.i,function(e,t){n.add(decodeURIComponent(e.replace(/\+/g," ")),t)}))}T=Qn.prototype;T.add=function(n,e){ht(this),this.i=null,n=vn(this,n);var t=this.g.get(n);return t||this.g.set(n,t=[]),t.push(e),this.h+=1,this};function th(n,e){ht(n),e=vn(n,e),n.g.has(e)&&(n.i=null,n.h-=n.g.get(e).length,n.g.delete(e))}function nh(n,e){return ht(n),e=vn(n,e),n.g.has(e)}T.forEach=function(n,e){ht(this),this.g.forEach(function(t,s){t.forEach(function(r){n.call(e,r,s,this)},this)},this)};T.oa=function(){ht(this);const n=Array.from(this.g.values()),e=Array.from(this.g.keys()),t=[];for(let s=0;s<e.length;s++){const r=n[s];for(let i=0;i<r.length;i++)t.push(e[s])}return t};T.W=function(n){ht(this);let e=[];
756if(typeof n=="string")nh(this,n)&&(e=e.concat(this.g.get(vn(this,n))));else{n=Array.from(this.g.values());for(let t=0;t<n.length;t++)e=e.concat(n[t])}return e};T.set=function(n,e){return ht(this),this.i=null,n=vn(this,n),nh(this,n)&&(this.h-=this.g.get(n).length),this.g.set(n,[e]),this.h+=1,this};T.get=function(n,e){return n?(n=this.W(n),0<n.length?String(n[0]):e):e};function sh(n,e,t){th(n,e),0<t.length&&(n.i=null,n.g.set(vn(n,e),Po(t)),n.h+=t.length)}T.toString=function(){if(this.i)return this.i;if(!this.g)return"";const n=[],e=Array.from(this.g.keys());for(var t=0;t<e.length;t++){var s=e[t];const i=encodeURIComponent(String(s)),o=this.W(s);for(s=0;s<o.length;s++){var r=i;o[s]!==""&&(r+="="+encodeURIComponent(String(o[s]))),n.push(r)}}return this.i=n.join("&")};function vn(n,e){return e=String(e),n.j&&(e=e.toLowerCase()),e}function qy(n,e){e&&!n.j&&(ht(n),n.i=null,n.g.forEach(function(t,s){var r=s.toLowerCase();s!=r&&(th(this,s),sh(this,r,t))},n)),n.j=e}var jy=class{constructor(e,t){this.h=e,this.g=t}};function rh(n){this.l=n||Gy,C.PerformanceNavigationTiming?(n=C.performance.getEntriesByType("navigation"),n=0<n.length&&(n[0].nextHopProtocol=="hq"||n[0].nextHopProtocol=="h2")):n=!!(C.g&&C.g.Ga&&C.g.Ga()&&C.g.Ga().$b),this.j=n?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}var Gy=10;function ih(n){return n.h?!0:n.g?n.g.size>=n.j:!1}function oh(n){return n.h?1:n.g?n.g.size:0}function no(n,e){return n.h?n.h==e:n.g?n.g.has(e):!1}function Wo(n,e){n.g?n.g.add(e):n.h=e}function ah(n,e){n.h&&n.h==e?n.h=null:n.g&&n.g.has(e)&&n.g.delete(e)}rh.prototype.cancel=function(){if(this.i=ch(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const n of this.g.values())n.cancel();this.g.clear()}};function ch(n){if(n.h!=null)return n.i.concat(n.h.D);if(n.g!=null&&n.g.size!==0){let e=n.i;for(const t of n.g.values())e=e.concat(t.D);return e}return Po(n.i)}function Qo(){}Qo.prototype.stringify=function(n){return C.JSON.stringify(n,void 0)};Qo.prototype.parse=function(n){return C.JSON.parse(n,void 0)};function Ky(){this.g=new Qo}function zy(n,e,t){const s=t||"";try{Zl(n,function(r,i){let o=r;cs(r)&&(o=qo(r)),e.push(s+i+"="+encodeURIComponent(o))})}catch(r){throw e.push(s+"type="+encodeURIComponent("_badmap")),r}}function Hy(n,e){const t=new Vr;if(C.Image){const s=new Image;s.onload=Rs(Ms,t,s,"TestLoadImage: loaded",!0,e),s.onerror=Rs(Ms,t,s,"TestLoadImage: error",!1,e),s.onabort=Rs(Ms,t,s,"TestLoadImage: abort",!1,e),s.ontimeout=Rs(Ms,t,s,"TestLoadImage: timeout",!1,e),C.setTimeout(function(){s.ontimeout&&s.ontimeout()},1e4),s.src=n}else e(!1)}function Ms(n,e,t,s,r){try{e.onload=null,e.onerror=null,e.onabort=null,e.ontimeout=null,r(s)}catch{}}function ps(n){this.l=n.ac||null,this.j=n.jb||!1}ce(ps,Ko);ps.prototype.g=function(){return new Gr(this.l,this.j)};ps.prototype.i=function(n){return function(){return n}}({});function Gr(n,e){te.call(this),this.D=n,this.u=e,this.m=void 0,this.readyState=Yo,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}ce(Gr,te);var Yo=0;T=Gr.prototype;T.open=function(n,e){if(this.readyState!=Yo)throw this.abort(),Error("Error reopening a connection");this.C=n,this.B=e,this.readyState=1,Yn(this)};T.send=function(n){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const e={headers:this.v,method:this.C,credentials:this.m,cache:void 0};n&&(e.body=n),(this.D||C).fetch(new Request(this.B,e)).then(this.Wa.bind(this),this.ga.bind(this))};T.abort=function(){this.response=this.responseText="",this.v=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,ms(this)),this.readyState=Yo};T.Wa=function(n){if(this.g&&(this.l=n,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=n.headers,this.readyState=2,Yn(this)),this.g&&(this.readyState=3,Yn(this),this.g)))if(this.responseType==="arraybuffer")n.arrayBuffer().then(this.Ua.bind(this),this.ga.bind(this));else if(typeof C.ReadableStream<"u"&&"body"in n){if(this.j=n.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;uh(this)}else n.text().then(this.Va.bind(this),this.ga.bind(this))};function uh(n){n.j.read().then(n.Ta.bind(n)).catch(n.ga.bind(n))}T.Ta=function(n){if(this.g){if(this.u&&n.value)this.response.push(n.value);else if(!this.u){var e=n.value?n.value:new Uint8Array(0);(e=this.A.decode(e,{stream:!n.done}))&&(this.response=this.responseText+=e)}n.done?ms(this):Yn(this),this.readyState==3&&uh(this)}};T.Va=function(n){this.g&&(this.response=this.responseText=n,ms(this))};T.Ua=function(n){this.g&&(this.response=n,ms(this))};T.ga=function(){this.g&&ms(this)};function ms(n){n.readyState=4,n.l=null,n.j=null,n.A=null,Yn(n)}T.setRequestHeader=function(n,e){this.v.append(n,e)};T.getResponseHeader=function(n){return this.h&&this.h.get(n.toLowerCase())||""};T.getAllResponseHeaders=function(){if(!this.h)return"";const n=[],e=this.h.entries();for(var t=e.next();!t.done;)t=t.value,n.push(t[0]+": "+t[1]),t=e.next();return n.join(`\r 757`)};function Yn(n){n.onreadystatechange&&n.onreadystatechange.call(n)}Object.defineProperty(Gr.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(n){this.m=n?"include":"same-origin"}});var Wy=C.JSON.parse;function H(n){te.call(this),this.headers=new Map,this.u=n||null,this.h=!1,this.C=this.g=null,this.H="",this.m=0,this.j="",this.l=this.F=this.v=this.D=!1,this.B=0,this.A=null,this.J=lh,this.K=this.L=!1}ce(H,te);var lh="",Qy=/^https?$/i,Yy=["POST","PUT"];T=H.prototype;T.Ka=function(n){this.L=n};T.da=function(n,e,t,s){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.H+"; newUri="+n);e=e?e.toUpperCase():"GET",this.H=n,this.j="",this.m=0,this.D=!1,this.h=!0,this.g=this.u?this.u.g():Ji.g(),this.C=this.u?mc(this.u):mc(Ji),this.g.onreadystatechange=le(this.Ha,this);try{this.F=!0,this.g.open(e,String(n),!0),this.F=!1}catch(i){vc(this,i);return}if(n=t||"",t=new Map(this.headers),s)if(Object.getPrototypeOf(s)===Object.prototype)for(var r in s)t.set(r,s[r]);else if(typeof s.keys=="function"&&typeof s.get=="function")for(const i of s.keys())t.set(i,s.get(i));else throw Error("Unknown input type for opt_headers: "+String(s));s=Array.from(t.keys()).find(i=>i.toLowerCase()=="content-type"),r=C.FormData&&n instanceof C.FormData,!(0<=Al(Yy,e))||s||r||t.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[i,o]of t)this.g.setRequestHeader(i,o);this.J&&(this.g.responseType=this.J),"withCredentials"in this.g&&this.g.withCredentials!==this.L&&(this.g.withCredentials=this.L);try{fh(this),0<this.B&&((this.K=Xy(this.g))?(this.g.timeout=this.B,this.g.ontimeout=le(this.qa,this)):this.A=Go(this.qa,this.B,this)),this.v=!0,this.g.send(n),this.v=!1}catch(i){vc(this,i)}};function Xy(n){return on&&py()&&typeof n.timeout=="number"&&n.ontimeout!==void 0}T.qa=function(){typeof Mo<"u"&&this.g&&(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,oe(this,"timeout"),this.abort(8))};function vc(n,e){n.h=!1,n.g&&(n.l=!0,n.g.abort(),n.l=!1),n.j=e,n.m=5,hh(n),Kr(n)}function hh(n){n.D||(n.D=!0,oe(n,"complete"),oe(n,"error"))}T.abort=function(n){this.g&&this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=n||7,oe(this,"complete"),oe(this,"abort"),Kr(this))};T.M=function(){this.g&&(this.h&&(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),Kr(this,!0)),H.X.M.call(this)};T.Ha=function(){this.s||(this.F||this.v||this.l?dh(this):this.fb())};T.fb=function(){dh(this)};
757function dh(n){if(n.h&&typeof Mo<"u"&&(!n.C[1]||$e(n)!=4||n.aa()!=2)){if(n.v&&$e(n)==4)Go(n.Ha,0,n);else if(oe(n,"readystatechange"),$e(n)==4){n.h=!1;try{const a=n.aa();e:switch(a){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var e=!0;break e;default:e=!1}var t;if(!(t=e)){var s;if(s=a===0){var r=String(n.H).match(eh)[1]||null;if(!r&&C.self&&C.self.location){var i=C.self.location.protocol;r=i.substr(0,i.length-1)}s=!Qy.test(r?r.toLowerCase():"")}t=s}if(t)oe(n,"complete"),oe(n,"success");else{n.m=6;try{var o=2<$e(n)?n.g.statusText:""}catch{o=""}n.j=o+" ["+n.aa()+"]",hh(n)}}finally{Kr(n)}}}}function Kr(n,e){if(n.g){fh(n);const t=n.g,s=n.C[0]?sr:null;n.g=null,n.C=null,e||oe(n,"ready");try{t.onreadystatechange=s}catch{}}}function fh(n){n.g&&n.K&&(n.g.ontimeout=null),n.A&&(C.clearTimeout(n.A),n.A=null)}function $e(n){return n.g?n.g.readyState:0}T.aa=function(){try{return 2<$e(this)?this.g.status:-1}catch{return-1}};T.fa=function(){try{return this.g?this.g.responseText:""}catch{return""}};T.Sa=function(n){if(this.g){var e=this.g.responseText;return n&&e.indexOf(n)==0&&(e=e.substring(n.length)),Wy(e)}};function wc(n){try{if(!n.g)return null;if("response"in n.g)return n.g.response;switch(n.J){case lh:case"text":return n.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in n.g)return n.g.mozResponseArrayBuffer}return null}catch{return null}}T.Ea=function(){return this.m};T.Oa=function(){return typeof this.j=="string"?this.j:String(this.j)};function ph(n){let e="";return Fo(n,function(t,s){e+=s,e+=":",e+=t,e+=`\r 758`}),e}function Xo(n,e,t){e:{for(s in t){var s=!1;break e}s=!0}s||(t=ph(t),typeof n=="string"?t!=null&&encodeURIComponent(String(t)):$(n,e,t))}function Sn(n,e,t){return t&&t.internalChannelParams&&t.internalChannelParams[n]||e}function mh(n){this.Ca=0,this.i=[],this.j=new Vr,this.ka=this.sa=this.F=this.V=this.g=this.za=this.D=this.ia=this.o=this.S=this.s=null,this.ab=this.U=0,this.Za=Sn("failFast",!1,n),this.L=this.v=this.u=this.m=this.l=null,this.Y=!0,this.pa=this.Ba=this.T=-1,this.Z=this.A=this.C=0,this.Xa=Sn("baseRetryDelayMs",5e3,n),this.bb=Sn("retryDelaySeedMs",1e4,n),this.$a=Sn("forwardChannelMaxRetries",2,n),this.ta=Sn("forwardChannelRequestTimeoutMs",2e4,n),this.ra=n&&n.xmlHttpFactory||void 0,this.Da=n&&n.Zb||!1,this.J=void 0,this.H=n&&n.supportsCrossDomainXhr||!1,this.I="",this.h=new rh(n&&n.concurrentRequestLimit),this.Fa=new Ky,this.O=n&&n.fastHandshake||!1,this.N=n&&n.encodeInitMessageHeaders||!1,this.O&&this.N&&(this.N=!1),this.Ya=n&&n.Xb||!1,n&&n.Aa&&this.j.Aa(),n&&n.forceLongPolling&&(this.Y=!1),this.$=!this.O&&this.Y&&n&&n.detectBufferingProxy||!1,this.ja=void 0,this.P=0,this.K=!1,this.la=this.B=null}T=mh.prototype;T.ma=8;T.G=1;function Jo(n){if(gh(n),n.G==3){var e=n.U++,t=Ke(n.F);$(t,"SID",n.I),$(t,"RID",e),$(t,"TYPE","terminate"),gs(n,t),e=new ds(n,n.j,e,void 0),e.K=2,e.v=jr(Ke(t)),t=!1,C.navigator&&C.navigator.sendBeacon&&(t=C.navigator.sendBeacon(e.v.toString(),"")),!t&&C.Image&&(new Image().src=e.v,t=!0),t||(e.g=_h(e.l,null),e.g.da(e.v)),e.F=Date.now(),fs(e)}Eh(n)}function zr(n){n.g&&(ea(n),n.g.cancel(),n.g=null)}function gh(n){zr(n),n.u&&(C.clearTimeout(n.u),n.u=null),ur(n),n.h.cancel(),n.m&&(typeof n.m=="number"&&C.clearTimeout(n.m),n.m=null)}function Hr(n){ih(n.h)||n.m||(n.m=!0,Vl(n.Ja,n),n.C=0)}function Jy(n,e){return oh(n.h)>=n.h.j-(n.m?1:0)?!1:n.m?(n.i=e.D.concat(n.i),!0):n.G==1||n.G==2||n.C>=(n.Za?0:n.$a)?!1:(n.m=ls(le(n.Ja,n,e),Th(n,n.C)),n.C++,!0)}T.Ja=function(n){if(this.m)if(this.m=null,this.G==1){if(!n){this.U=Math.floor(1e5*Math.random()),n=this.U++;const r=new ds(this,this.j,n,void 0);let i=this.s;if(this.S&&(i?(i=Nl(i),xl(i,this.S)):i=this.S),this.o!==null||this.N||(r.H=i,i=null),this.O)e:{for(var e=0,t=0;t<this.i.length;t++){t:{var s=this.i[t];if("__data__"in s.g&&(s=s.g.__data__,typeof s=="string")){s=s.length;break t}s=void 0}if(s===void 0)break;if(e+=s,4096<e){e=t;break e}if(e===4096||t===this.i.length-1){e=t+1;break e}}e=1e3}else e=1e3;e=yh(this,r,e),t=Ke(this.F),$(t,"RID",n),$(t,"CVER",22),this.D&&$(t,"X-HTTP-Session-Id",this.D),gs(this,t),i&&(this.N?e="headers="+encodeURIComponent(String(ph(i)))+"&"+e:this.o&&Xo(t,this.o,i)),Wo(this.h,r),this.Ya&&$(t,"TYPE","init"),this.O?($(t,"$req",e),$(t,"SID","null"),r.Z=!0,eo(r,t,null)):eo(r,t,e),this.G=2}}else this.G==3&&(n?Ic(this,n):this.i.length==0||ih(this.h)||Ic(this))};function Ic(n,e){var t;e?t=e.m:t=n.U++;const s=Ke(n.F);$(s,"SID",n.I),$(s,"RID",t),$(s,"AID",n.T),gs(n,s),n.o&&n.s&&Xo(s,n.o,n.s),t=new ds(n,n.j,t,n.C+1),n.o===null&&(t.H=n.s),e&&(n.i=e.D.concat(n.i)),e=yh(n,t,1e3),t.setTimeout(
758Math.round(.5*n.ta)+Math.round(.5*n.ta*Math.random())),Wo(n.h,t),eo(t,s,e)}function gs(n,e){n.ia&&Fo(n.ia,function(t,s){$(e,s,t)}),n.l&&Zl({},function(t,s){$(e,s,t)})}function yh(n,e,t){t=Math.min(n.i.length,t);var s=n.l?le(n.l.Ra,n.l,n):null;e:{var r=n.i;let i=-1;for(;;){const o=["count="+t];i==-1?0<t?(i=r[0].h,o.push("ofs="+i)):i=0:o.push("ofs="+i);let a=!0;for(let c=0;c<t;c++){let u=r[c].h;const l=r[c].g;if(u-=i,0>u)i=Math.max(0,r[c].h-100),a=!1;else try{zy(l,o,"req"+u+"_")}catch{s&&s(l)}}if(a){s=o.join("&");break e}}}return n=n.i.splice(0,t),e.D=n,s}function vh(n){n.g||n.u||(n.Z=1,Vl(n.Ia,n),n.A=0)}function Zo(n){return n.g||n.u||3<=n.A?!1:(n.Z++,n.u=ls(le(n.Ia,n),Th(n,n.A)),n.A++,!0)}T.Ia=function(){if(this.u=null,wh(this),this.$&&!(this.K||this.g==null||0>=this.P)){var n=2*this.P;this.j.info("BP detection timer enabled: "+n),this.B=ls(le(this.eb,this),n)}};T.eb=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.L=!1,this.K=!0,me(10),zr(this),wh(this))};function ea(n){n.B!=null&&(C.clearTimeout(n.B),n.B=null)}function wh(n){n.g=new ds(n,n.j,"rpc",n.Z),n.o===null&&(n.g.H=n.s),n.g.N=0;var e=Ke(n.sa);$(e,"RID","rpc"),$(e,"SID",n.I),$(e,"CI",n.L?"0":"1"),$(e,"AID",n.T),$(e,"TYPE","xmlhttp"),gs(n,e),n.o&&n.s&&Xo(e,n.o,n.s),n.J&&n.g.setTimeout(n.J);var t=n.g;n=n.ka,t.K=1,t.v=jr(Ke(e)),t.s=null,t.P=!0,Ql(t,n)}T.cb=function(){this.v!=null&&(this.v=null,zr(this),Zo(this),me(19))};function ur(n){n.v!=null&&(C.clearTimeout(n.v),n.v=null)}function Ih(n,e){var t=null;if(n.g==e){ur(n),ea(n),n.g=null;var s=2}else if(no(n.h,e))t=e.D,ah(n.h,e),s=1;else return;if(n.G!=0){if(n.pa=e.Y,e.i)if(s==1){t=e.s?e.s.length:0,e=Date.now()-e.F;var r=n.C;s=Ur(),oe(s,new Kl(s,t)),Hr(n)}else vh(n);else if(r=e.o,r==3||r==0&&0<n.pa||!(s==1&&Jy(n,e)||s==2&&Zo(n)))switch(t&&0<t.length&&(e=n.h,e.i=e.i.concat(t)),r){case 1:St(n,5);break;case 4:St(n,10);break;case 3:St(n,6);break;default:St(n,2)}}}function Th(n,e){let t=n.Xa+Math.floor(Math.random()*n.bb);return n.l||(t*=2),t*e}function St(n,e){if(n.j.info("Error code "+e),e==2){var t=null;n.l&&(t=null);var s=le(n.kb,n);t||(t=new Ct("//www.google.com/images/cleardot.gif"),C.location&&C.location.protocol=="http"||ar(t,"https"),jr(t)),Hy(t.toString(),s)}else me(2);n.G=0,n.l&&n.l.va(e),Eh(n),gh(n)}T.kb=function(n){n?(this.j.info("Successfully pinged google.com"),me(2)):(this.j.info("Failed to ping google.com"),me(1))};function Eh(n){if(n.G=0,n.la=[],n.l){const e=ch(n.h);(e.length!=0||n.i.length!=0)&&(uc(n.la,e),uc(n.la,n.i),n.h.i.length=0,Po(n.i),n.i.length=0),n.l.ua()}}function bh(n,e,t){var s=t instanceof Ct?Ke(t):new Ct(t,void 0);if(s.g!="")e&&(s.g=e+"."+s.g),cr(s,s.m);else{var r=C.location;s=r.protocol,e=e?e+"."+r.hostname:r.hostname,r=+r.port;var i=new Ct(null,void 0);s&&ar(i,s),e&&(i.g=e),r&&cr(i,r),t&&(i.l=t),s=i}return t=n.D,e=n.za,t&&e&&$(s,t,e),$(s,"VER",n.ma),gs(n,s),s}function _h(n,e,t){if(e&&!n.H)throw Error("Can't create secondary domain capable XhrIo object.");return e=t&&n.Da&&!n.ra?new H(new ps({jb:!0})):new H(n.ra),e.Ka(n.H),e}function Sh(){}T=Sh.prototype;T.xa=function(){};T.wa=function(){};T.va=function(){};T.ua=function(){};T.Ra=function(){};function lr(){if(on&&!(10<=Number(my)))throw Error("Environmental error: no available transport.")}lr.prototype.g=function(n,e){return new be(n,e)};function be(n,e){te.call(this),this.g=new mh(e),this.l=n,this.h=e&&e.messageUrlParams||null,n=e&&e.messageHeaders||null,e&&e.clientProtocolHeaderRequired&&(n?n["X-Client-Protocol"]="webchannel":n={"X-Client-Protocol":"webchannel"}),this.g.s=n,n=e&&e.initMessageHeaders||null,e&&e.messageContentType&&(n?n["X-WebChannel-Content-Type"]=e.messageContentType:n={"X-WebChannel-Content-Type":e.messageContentType}),e&&e.ya&&(n?n["X-WebChannel-Client-Profile"]=e.ya:n={"X-WebChannel-Client-Profile":e.ya}),this.g.S=n,(n=e&&e.Yb)&&!rr(n)&&(this.g.o=n),this.A=e&&e.supportsCrossDomainXhr||!1,this.v=e&&e.sendRawJson||!1,(e=e&&e.httpSessionIdParam)&&!rr(e)&&(this.g.D=e,n=this.h,n!==null&&e in n&&(n=this.h,e in n&&delete n[e])),this.j=new wn(this)}ce(be,te);be.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.H=!0);var n=this.g,e=this.l,t=this.h||void 0;me(0),n.V=e,n.ia=t||{},n.L=n.Y,n.F=bh(n,null,n.V),Hr(n)};be.prototype.close=function(){Jo(this.g)};be.prototype.u=function(n){var e=this.g;if(typeof n=="string"){var t={};t.__data__=n,n=t}else this.v&&(t={},t.__data__=qo(n),n=t);e.i.push(new jy(e.ab++,n)),e.G==3&&Hr(e)};be.prototype.M=function(){this.g.l=null,delete this.j,Jo(this.g),delete this.g,be.X.M.call(this)};function Ah(n){zo.call(this);var e=n.__sm__;if(e){e:{for(const t in e){n=t;break e}n=void 0}(this.i=n)&&(n=this.i,e=e!==null&&n in e?e[n]:void 0),this.data=e}else this.data=n}ce(Ah,zo);function Ch(){Ho.call(this),this.status=1}ce(Ch,Ho);function wn(n){this.g=n}ce(wn,Sh);wn.prototype.xa=function(){oe(this.g,"a")};wn.prototype.wa=function(n){oe(this.g,new Ah(n))};wn.prototype.va=function(n){oe(this.g,new Ch)};wn.prototype.ua=function(){oe(this.g,"b")};lr.prototype.createWebChannel=lr.prototype.g;be.prototype.send=be.prototype.u;be.prototype.open=be.prototype.m;be.prototype.close=be.prototype.close;Br.NO_ERROR=0;Br.TIMEOUT=8;Br.HTTP_ERROR=6;zl.COMPLETE="complete";Hl.EventType=hs;hs.OPEN="a";hs.CLOSE="b";hs.ERROR="c";hs.MESSAGE="d";te.prototype.listen=te.prototype.N;H.prototype.listenOnce=H.prototype.O;H.prototype.getLastError=H.prototype.Oa;H.prototype.getLastErrorCode=H.prototype.Ea;H.prototype.getStatus=H.prototype.aa;H.prototype.getResponseJson=H.prototype.Sa;H.prototype.getResponseText=H.prototype.fa;H.prototype.send=H.prototype.da;H.prototype.setWithCredentials=H.prototype.Ka;var Zy=function(){return new lr}
758,ev=function(){return Ur()},Mi=Br,tv=zl,nv=jt,Tc={sb:0,vb:1,wb:2,Pb:3,Ub:4,Rb:5,Sb:6,Qb:7,Ob:8,Tb:9,PROXY:10,NOPROXY:11,Mb:12,Ib:13,Jb:14,Hb:15,Kb:16,Lb:17,ob:18,nb:19,pb:20},sv=ps,Ps=Hl,rv=H;const Ec="@firebase/firestore";/** 759 * @license 760 * Copyright 2017 Google LLC 761 * 762 * Licensed under the Apache License, Version 2.0 (the "License"); 763 * you may not use this file except in compliance with the License. 764 * You may obtain a copy of the License at 765 * 766 * http://www.apache.org/licenses/LICENSE-2.0 767 * 768 * Unless required by applicable law or agreed to in writing, software 769 * distributed under the License is distributed on an "AS IS" BASIS, 770 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 771 * See the License for the specific language governing permissions and 772 * limitations under the License. 773 */class re{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}re.UNAUTHENTICATED=new re(null),re.GOOGLE_CREDENTIALS=new re("google-credentials-uid"),re.FIRST_PARTY=new re("first-party-uid"),re.MOCK_USER=new re("mock-user");/** 774 * @license 775 * Copyright 2017 Google LLC 776 * 777 * Licensed under the Apache License, Version 2.0 (the "License"); 778 * you may not use this file except in compliance with the License. 779 * You may obtain a copy of the License at 780 * 781 * http://www.apache.org/licenses/LICENSE-2.0 782 * 783 * Unless required by applicable law or agreed to in writing, software 784 * distributed under the License is distributed on an "AS IS" BASIS, 785 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 786 * See the License for the specific language governing permissions and 787 * limitations under the License. 788 */let In="9.17.1";/** 789 * @license 790 * Copyright 2017 Google LLC 791 * 792 * Licensed under the Apache License, Version 2.0 (the "License"); 793 * you may not use this file except in compliance with the License. 794 * You may obtain a copy of the License at 795 * 796 * http://www.apache.org/licenses/LICENSE-2.0 797 * 798 * Unless required by applicable law or agreed to in writing, software 799 * distributed under the License is distributed on an "AS IS" BASIS, 800 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 801 * See the License for the specific language governing permissions and 802 * limitations under the License. 803 */const Ot=new Dr("@firebase/firestore");function so(){return Ot.logLevel}function g(n,...e){if(Ot.logLevel<=O.DEBUG){const t=e.map(ta);Ot.debug(`Firestore (${In}): ${n}`,...t)}}function pe(n,...e){if(Ot.logLevel<=O.ERROR){const t=e.map(ta);Ot.error(`Firestore (${In}): ${n}`,...t)}}function hr(n,...e){if(Ot.logLevel<=O.WARN){const t=e.map(ta);Ot.warn(`Firestore (${In}): ${n}`,...t)}}function ta(n){if(typeof n=="string")return n;try{return e=n,JSON.stringify(e)}catch{return n}/** 804* @license 805* Copyright 2020 Google LLC 806* 807* Licensed under the Apache License, Version 2.0 (the "License"); 808* you may not use this file except in compliance with the License. 809* You may obtain a copy of the License at 810* 811* http://www.apache.org/licenses/LICENSE-2.0 812* 813* Unless required by applicable law or agreed to in writing, software 814* distributed under the License is distributed on an "AS IS" BASIS, 815* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 816* See the License for the specific language governing permissions and 817* limitations under the License. 818*/var e}/** 819 * @license 820 * Copyright 2017 Google LLC 821 * 822 * Licensed under the Apache License, Version 2.0 (the "License"); 823 * you may not use this file except in compliance with the License. 824 * You may obtain a copy of the License at 825 * 826 * http://www.apache.org/licenses/LICENSE-2.0 827 * 828 * Unless required by applicable law or agreed to in writing, software 829 * distributed under the License is distributed on an "AS IS" BASIS, 830 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 831 * See the License for the specific language governing permissions and 832 * limitations under the License. 833 */function I(n="Unexpected state"){const e=`FIRESTORE (${In}) INTERNAL ASSERTION FAILED: `+n;throw pe(e),new Error(e)}function b(n,e){n||I()}function k(n,e){return n}/** 834 * @license 835 * Copyright 2017 Google LLC 836 * 837 * Licensed under the Apache License, Version 2.0 (the "License");
838 * you may not use this file except in compliance with the License. 839 * You may obtain a copy of the License at 840 * 841 * http://www.apache.org/licenses/LICENSE-2.0 842 * 843 * Unless required by applicable law or agreed to in writing, software 844 * distributed under the License is distributed on an "AS IS" BASIS, 845 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 846 * See the License for the specific language governing permissions and 847 * limitations under the License. 848 */const p={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class v extends ke{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/** 849 * @license 850 * Copyright 2017 Google LLC 851 * 852 * Licensed under the Apache License, Version 2.0 (the "License"); 853 * you may not use this file except in compliance with the License. 854 * You may obtain a copy of the License at 855 * 856 * http://www.apache.org/licenses/LICENSE-2.0 857 * 858 * Unless required by applicable law or agreed to in writing, software 859 * distributed under the License is distributed on an "AS IS" BASIS, 860 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 861 * See the License for the specific language governing permissions and 862 * limitations under the License. 863 */class De{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}/** 864 * @license 865 * Copyright 2017 Google LLC 866 * 867 * Licensed under the Apache License, Version 2.0 (the "License"); 868 * you may not use this file except in compliance with the License. 869 * You may obtain a copy of the License at 870 * 871 * http://www.apache.org/licenses/LICENSE-2.0 872 * 873 * Unless required by applicable law or agreed to in writing, software 874 * distributed under the License is distributed on an "AS IS" BASIS, 875 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 876 * See the License for the specific language governing permissions and 877 * limitations under the License. 878 */class kh{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class iv{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(re.UNAUTHENTICATED))}shutdown(){}}class ov{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}}class av{constructor(e){this.t=e,this.currentUser=re.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){let s=this.i;const r=c=>this.i!==s?(s=this.i,t(c)):Promise.resolve();let i=new De;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new De,e.enqueueRetryable(()=>r(this.currentUser))};const o=()=>{const c=i;e.enqueueRetryable(async()=>{await c.promise,await r(this.currentUser)})},a=c=>{g("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=c,this.auth.addAuthTokenListener(this.o),o()};this.t.onInit(c=>a(c)),setTimeout(()=>{if(!this.auth){const c=this.t.getImmediate({optional:!0});c?a(c):(g("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new De)}},0),o()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(s=>this.i!==e?(g("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):s?(b(typeof s.accessToken=="string"),new kh(s.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.auth.removeAuthTokenListener(this.o)}u(){const e=this.auth&&this.auth.getUid();return b(e===null||typeof e=="string"),new re(e)}}class cv{constructor(e,t,s,r){this.h=e,this.l=t,this.m=s,this.g=r,this.type="FirstParty",this.user=re.FIRST_PARTY,this.p=new Map}I(){return this.g?this.g():(b(!(typeof this.h!="object"||this.h===null||!this.h.auth||!this.h.auth.getAuthHeaderValueForFirstParty)),this.h.auth.getAuthHeaderValueForFirstParty([]))}get headers(){this.p.set("X-Goog-AuthUser",this.l);const e=this.I();return e&&this.p.set("Authorization",e),this.m&&this.p.set("X-Goog-Iam-Authorization-Token",this.m),this.p}}class uv{constructor(e,t,s,r){this.h=e,this.l=t,this.m=s,this.g=r}getToken(){return Promise.resolve(new cv(this.h,this.l,this.m,this.g))}start(e,t){e.enqueueRetryable(()=>t(re.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class lv{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class hv{constructor(e){this.T=e,this.forceRefresh=!1,this.appCheck=null,this.A=null}start(e,t){const s=i=>{i.error!=null&&g("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const o=i.token!==this.A;return this.A=i.token,g("FirebaseAppCheckTokenProvider",`Received ${o?"new":"existing"} token.`),o?t(i.token):Promise.resolve()};this.o=i=>{e.enqueueRetryable(()=>s(i))};const r=i=>{g("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.appCheck.addTokenListener(this.o)};this.T.onInit(i=>r(i)),setTimeout(()=>{if(!this.appCheck){const i=this.T.getImmediate({optional:!0});i?r(i):g("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(b(typeof t.token=="string"),this.A=t.token,new lv(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.appCheck.removeTokenListener(this.o)}}/** 879 * @license 880 * Copyright 2020 Google LLC 881 * 882 * Licensed under the Apache License, Version 2.0 (the "License");
883 * you may not use this file except in compliance with the License. 884 * You may obtain a copy of the License at 885 * 886 * http://www.apache.org/licenses/LICENSE-2.0 887 * 888 * Unless required by applicable law or agreed to in writing, software 889 * distributed under the License is distributed on an "AS IS" BASIS, 890 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 891 * See the License for the specific language governing permissions and 892 * limitations under the License. 893 */function dv(n){const e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let s=0;s<n;s++)t[s]=Math.floor(256*Math.random());return t}/** 894 * @license 895 * Copyright 2017 Google LLC 896 * 897 * Licensed under the Apache License, Version 2.0 (the "License"); 898 * you may not use this file except in compliance with the License. 899 * You may obtain a copy of the License at 900 * 901 * http://www.apache.org/licenses/LICENSE-2.0 902 * 903 * Unless required by applicable law or agreed to in writing, software 904 * distributed under the License is distributed on an "AS IS" BASIS, 905 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 906 * See the License for the specific language governing permissions and 907 * limitations under the License. 908 */class Dh{static R(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=Math.floor(256/e.length)*e.length;let s="";for(;s.length<20;){const r=dv(40);for(let i=0;i<r.length;++i)s.length<20&&r[i]<t&&(s+=e.charAt(r[i]%e.length))}return s}}function D(n,e){return n<e?-1:n>e?1:0}function an(n,e,t){return n.length===e.length&&n.every((s,r)=>t(s,e[r]))}function Nh(n){return n+"\0"}/** 909 * @license 910 * Copyright 2017 Google LLC 911 * 912 * Licensed under the Apache License, Version 2.0 (the "License"); 913 * you may not use this file except in compliance with the License. 914 * You may obtain a copy of the License at 915 * 916 * http://www.apache.org/licenses/LICENSE-2.0 917 * 918 * Unless required by applicable law or agreed to in writing, software 919 * distributed under the License is distributed on an "AS IS" BASIS, 920 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 921 * See the License for the specific language governing permissions and 922 * limitations under the License. 923 */class j{constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new v(p.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new v(p.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-62135596800)throw new v(p.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new v(p.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return j.fromMillis(Date.now())}static fromDate(e){return j.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),s=Math.floor(1e6*(e-1e3*t));return new j(t,s)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?D(this.nanoseconds,e.nanoseconds):D(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}/** 924 * @license 925 * Copyright 2017 Google LLC 926 * 927 * Licensed under the Apache License, Version 2.0 (the "License"); 928 * you may not use this file except in compliance with the License. 929 * You may obtain a copy of the License at 930 * 931 * http://www.apache.org/licenses/LICENSE-2.0 932 * 933 * Unless required by applicable law or agreed to in writing, software 934 * distributed under the License is distributed on an "AS IS" BASIS, 935 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 936 * See the License for the specific language governing permissions and 937 * limitations under the License. 938 */class _{constructor(e){this.timestamp=e}static fromTimestamp(e){return new _(e)}static min(){return new _(new j(0,0))}static max(){return new _(new j(253402300799,999999999))}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}/** 939 * @license 940 * Copyright 2017 Google LLC 941 * 942 * Licensed under the Apache License, Version 2.0 (the "License");
943 * you may not use this file except in compliance with the License. 944 * You may obtain a copy of the License at 945 * 946 * http://www.apache.org/licenses/LICENSE-2.0 947 * 948 * Unless required by applicable law or agreed to in writing, software 949 * distributed under the License is distributed on an "AS IS" BASIS, 950 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 951 * See the License for the specific language governing permissions and 952 * limitations under the License. 953 */class Xn{constructor(e,t,s){t===void 0?t=0:t>e.length&&I(),s===void 0?s=e.length-t:s>e.length-t&&I(),this.segments=e,this.offset=t,this.len=s}get length(){return this.len}isEqual(e){return Xn.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Xn?e.forEach(s=>{t.push(s)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,s=this.limit();t<s;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const s=Math.min(e.length,t.length);for(let r=0;r<s;r++){const i=e.get(r),o=t.get(r);if(i<o)return-1;if(i>o)return 1}return e.length<t.length?-1:e.length>t.length?1:0}}class M extends Xn{construct(e,t,s){return new M(e,t,s)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}static fromString(...e){const t=[];for(const s of e){if(s.indexOf("//")>=0)throw new v(p.INVALID_ARGUMENT,`Invalid segment (${s}). Paths must not contain // in them.`);t.push(...s.split("/").filter(r=>r.length>0))}return new M(t)}static emptyPath(){return new M([])}}const fv=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class Q extends Xn{construct(e,t,s){return new Q(e,t,s)}static isValidIdentifier(e){return fv.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),Q.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)==="__name__"}static keyField(){return new Q(["__name__"])}static fromServerFormat(e){const t=[];let s="",r=0;const i=()=>{if(s.length===0)throw new v(p.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(s),s=""};let o=!1;for(;r<e.length;){const a=e[r];if(a==="\\"){if(r+1===e.length)throw new v(p.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const c=e[r+1];if(c!=="\\"&&c!=="."&&c!=="`")throw new v(p.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);s+=c,r+=2}else a==="`"?(o=!o,r++):a!=="."||o?(s+=a,r++):(i(),r++)}if(i(),o)throw new v(p.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new Q(t)}static emptyPath(){return new Q([])}}/** 954 * @license 955 * Copyright 2017 Google LLC 956 * 957 * Licensed under the Apache License, Version 2.0 (the "License"); 958 * you may not use this file except in compliance with the License. 959 * You may obtain a copy of the License at 960 * 961 * http://www.apache.org/licenses/LICENSE-2.0 962 * 963 * Unless required by applicable law or agreed to in writing, software 964 * distributed under the License is distributed on an "AS IS" BASIS, 965 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 966 * See the License for the specific language governing permissions and 967 * limitations under the License. 968 */class w{constructor(e){this.path=e}static fromPath(e){return new w(M.fromString(e))}static fromName(e){return new w(M.fromString(e).popFirst(5))}static empty(){return new w(M.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&M.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return M.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new w(new M(e.slice()))}}/** 969 * @license 970 * Copyright 2021 Google LLC 971 * 972 * Licensed under the Apache License, Version 2.0 (the "License");
973 * you may not use this file except in compliance with the License. 974 * You may obtain a copy of the License at 975 * 976 * http://www.apache.org/licenses/LICENSE-2.0 977 * 978 * Unless required by applicable law or agreed to in writing, software 979 * distributed under the License is distributed on an "AS IS" BASIS, 980 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 981 * See the License for the specific language governing permissions and 982 * limitations under the License. 983 */class xh{constructor(e,t,s,r){this.indexId=e,this.collectionGroup=t,this.fields=s,this.indexState=r}}function ro(n){return n.fields.find(e=>e.kind===2)}function vt(n){return n.fields.filter(e=>e.kind!==2)}xh.UNKNOWN_ID=-1;class pv{constructor(e,t){this.fieldPath=e,this.kind=t}}class dr{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new dr(0,_e.min())}}function mv(n,e){const t=n.toTimestamp().seconds,s=n.toTimestamp().nanoseconds+1,r=_.fromTimestamp(s===1e9?new j(t+1,0):new j(t,s));return new _e(r,w.empty(),e)}function Rh(n){return new _e(n.readTime,n.key,-1)}class _e{constructor(e,t,s){this.readTime=e,this.documentKey=t,this.largestBatchId=s}static min(){return new _e(_.min(),w.empty(),-1)}static max(){return new _e(_.max(),w.empty(),-1)}}function na(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=w.comparator(n.documentKey,e.documentKey),t!==0?t:D(n.largestBatchId,e.largestBatchId))}/** 984 * @license 985 * Copyright 2020 Google LLC 986 * 987 * Licensed under the Apache License, Version 2.0 (the "License"); 988 * you may not use this file except in compliance with the License. 989 * You may obtain a copy of the License at 990 * 991 * http://www.apache.org/licenses/LICENSE-2.0 992 * 993 * Unless required by applicable law or agreed to in writing, software 994 * distributed under the License is distributed on an "AS IS" BASIS, 995 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 996 * See the License for the specific language governing permissions and 997 * limitations under the License. 998 */const Oh="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class Mh{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}/** 999 * @license 1000 * Copyright 2017 Google LLC 1001 * 1002 * Licensed under the Apache License, Version 2.0 (the "License"); 1003 * you may not use this file except in compliance with the License. 1004 * You may obtain a copy of the License at 1005 * 1006 * http://www.apache.org/licenses/LICENSE-2.0 1007 * 1008 * Unless required by applicable law or agreed to in writing, software 1009 * distributed under the License is distributed on an "AS IS" BASIS, 1010 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1011 * See the License for the specific language governing permissions and 1012 * limitations under the License. 1013 */async function Gt(n){if(n.code!==p.FAILED_PRECONDITION||n.message!==Oh)throw n;g("LocalStore","Unexpectedly lost primary lease")}/** 1014 * @license 1015 * Copyright 2017 Google LLC 1016 * 1017 * Licensed under the Apache License, Version 2.0 (the "License"); 1018 * you may not use this file except in compliance with the License. 1019 * You may obtain a copy of the License at 1020 * 1021 * http://www.apache.org/licenses/LICENSE-2.0 1022 * 1023 * Unless required by applicable law or agreed to in writing, software 1024 * distributed under the License is distributed on an "AS IS" BASIS, 1025 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1026 * See the License for the specific language governing permissions and 1027 * limitations under the License. 1028 */class f{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&I(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new f((s,r)=>{this.nextCallback=i=>{this.wrapSuccess(e,i).next(s,r)},this.catchCallback=i=>{this.wrapFailure(t,i).next(s,r)}})}toPromise(){return new Promise((e,t)=>
1028{this.next(e,t)})}wrapUserFunction(e){try{const t=e();return t instanceof f?t:f.resolve(t)}catch(t){return f.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):f.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):f.reject(t)}static resolve(e){return new f((t,s)=>{t(e)})}static reject(e){return new f((t,s)=>{s(e)})}static waitFor(e){return new f((t,s)=>{let r=0,i=0,o=!1;e.forEach(a=>{++r,a.next(()=>{++i,o&&i===r&&t()},c=>s(c))}),o=!0,i===r&&t()})}static or(e){let t=f.resolve(!1);for(const s of e)t=t.next(r=>r?f.resolve(r):s());return t}static forEach(e,t){const s=[];return e.forEach((r,i)=>{s.push(t.call(this,r,i))}),this.waitFor(s)}static mapArray(e,t){return new f((s,r)=>{const i=e.length,o=new Array(i);let a=0;for(let c=0;c<i;c++){const u=c;t(e[u]).next(l=>{o[u]=l,++a,a===i&&s(o)},l=>r(l))}})}static doWhile(e,t){return new f((s,r)=>{const i=()=>{e()===!0?t().next(()=>{i()},r):s()};i()})}}/** 1029 * @license 1030 * Copyright 2017 Google LLC 1031 * 1032 * Licensed under the Apache License, Version 2.0 (the "License"); 1033 * you may not use this file except in compliance with the License. 1034 * You may obtain a copy of the License at 1035 * 1036 * http://www.apache.org/licenses/LICENSE-2.0 1037 * 1038 * Unless required by applicable law or agreed to in writing, software 1039 * distributed under the License is distributed on an "AS IS" BASIS, 1040 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1041 * See the License for the specific language governing permissions and 1042 * limitations under the License. 1043 */class Wr{constructor(e,t){this.action=e,this.transaction=t,this.aborted=!1,this.P=new De,this.transaction.oncomplete=()=>{this.P.resolve()},this.transaction.onabort=()=>{t.error?this.P.reject(new Un(e,t.error)):this.P.resolve()},this.transaction.onerror=s=>{const r=sa(s.target.error);this.P.reject(new Un(e,r))}}static open(e,t,s,r){try{return new Wr(t,e.transaction(r,s))}catch(i){throw new Un(t,i)}}get v(){return this.P.promise}abort(e){e&&this.P.reject(e),this.aborted||(g("SimpleDb","Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}V(){const e=this.transaction;this.aborted||typeof e.commit!="function"||e.commit()}store(e){const t=this.transaction.objectStore(e);return new yv(t)}}class qe{constructor(e,t,s){this.name=e,this.version=t,this.S=s,qe.D(Z())===12.2&&pe("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}static delete(e){return g("SimpleDb","Removing database:",e),wt(window.indexedDB.deleteDatabase(e)).toPromise()}static C(){if(!ko())return!1;if(qe.N())return!0;const e=Z(),t=qe.D(e),s=0<t&&t<10,r=qe.k(e),i=0<r&&r<4.5;return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||s||i)}static N(){var e;return typeof process<"u"&&((e=process.env)===null||e===void 0?void 0:e.O)==="YES"}static M(e,t){return e.store(t)}static D(e){const t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i),s=t?t[1].split("_").slice(0,2).join("."):"-1";return Number(s)}static k(e){const t=e.match(/Android ([\d.]+)/i),s=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(s)}async F(e){return this.db||(g("SimpleDb","Opening database:",this.name),this.db=await new Promise((t,s)=>{const r=indexedDB.open(this.name,this.version);r.onsuccess=i=>{const o=i.target.result;t(o)},r.onblocked=()=>{s(new Un(e,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},r.onerror=i=>{const o=i.target.error;o.name==="VersionError"?s(new v(p.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):o.name==="InvalidStateError"?s(new v(p.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+o)):s(new Un(e,o))},r.onupgradeneeded=i=>{g("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',i.oldVersion);const o=i.target.result;this.S.$(o,r.transaction,i.oldVersion,this.version).next(()=>{g("SimpleDb","Database upgrade to version "+this.version+" complete")}
1043)}})),this.B&&(this.db.onversionchange=t=>this.B(t)),this.db}L(e){this.B=e,this.db&&(this.db.onversionchange=t=>e(t))}async runTransaction(e,t,s,r){const i=t==="readonly";let o=0;for(;;){++o;try{this.db=await this.F(e);const a=Wr.open(this.db,e,i?"readonly":"readwrite",s),c=r(a).next(u=>(a.V(),u)).catch(u=>(a.abort(u),f.reject(u))).toPromise();return c.catch(()=>{}),await a.v,c}catch(a){const c=a,u=c.name!=="FirebaseError"&&o<3;if(g("SimpleDb","Transaction failed with error:",c.message,"Retrying:",u),this.close(),!u)return Promise.reject(c)}}}close(){this.db&&this.db.close(),this.db=void 0}}class gv{constructor(e){this.q=e,this.U=!1,this.K=null}get isDone(){return this.U}get G(){return this.K}set cursor(e){this.q=e}done(){this.U=!0}j(e){this.K=e}delete(){return wt(this.q.delete())}}class Un extends v{constructor(e,t){super(p.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function dt(n){return n.name==="IndexedDbTransactionError"}class yv{constructor(e){this.store=e}put(e,t){let s;return t!==void 0?(g("SimpleDb","PUT",this.store.name,e,t),s=this.store.put(t,e)):(g("SimpleDb","PUT",this.store.name,"<auto-key>",e),s=this.store.put(e)),wt(s)}add(e){return g("SimpleDb","ADD",this.store.name,e,e),wt(this.store.add(e))}get(e){return wt(this.store.get(e)).next(t=>(t===void 0&&(t=null),g("SimpleDb","GET",this.store.name,e,t),t))}delete(e){return g("SimpleDb","DELETE",this.store.name,e),wt(this.store.delete(e))}count(){return g("SimpleDb","COUNT",this.store.name),wt(this.store.count())}W(e,t){const s=this.options(e,t);if(s.index||typeof this.store.getAll!="function"){const r=this.cursor(s),i=[];return this.H(r,(o,a)=>{i.push(a)}).next(()=>i)}{const r=this.store.getAll(s.range);return new f((i,o)=>{r.onerror=a=>{o(a.target.error)},r.onsuccess=a=>{i(a.target.result)}})}}J(e,t){const s=this.store.getAll(e,t===null?void 0:t);return new f((r,i)=>{s.onerror=o=>{i(o.target.error)},s.onsuccess=o=>{r(o.target.result)}})}Y(e,t){g("SimpleDb","DELETE ALL",this.store.name);const s=this.options(e,t);s.X=!1;const r=this.cursor(s);return this.H(r,(i,o,a)=>a.delete())}Z(e,t){let s;t?s=e:(s={},t=e);const r=this.cursor(s);return this.H(r,t)}tt(e){const t=this.cursor({});return new f((s,r)=>{t.onerror=i=>{const o=sa(i.target.error);r(o)},t.onsuccess=i=>{const o=i.target.result;o?e(o.primaryKey,o.value).next(a=>{a?o.continue():s()}):s()}})}H(e,t){const s=[];return new f((r,i)=>{e.onerror=o=>{i(o.target.error)},e.onsuccess=o=>{const a=o.target.result;if(!a)return void r();const c=new gv(a),u=t(a.primaryKey,a.value,c);if(u instanceof f){const l=u.catch(h=>(c.done(),f.reject(h)));s.push(l)}c.isDone?r():c.G===null?a.continue():a.continue(c.G)}}).next(()=>f.waitFor(s))}options(e,t){let s;return e!==void 0&&(typeof e=="string"?s=e:t=e),{index:s,range:t}}cursor(e){let t="next";if(e.reverse&&(t="prev"),e.index){const s=this.store.index(e.index);return e.X?s.openKeyCursor(e.range,t):s.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function wt(n){return new f((e,t)=>{n.onsuccess=s=>{const r=s.target.result;e(r)},n.onerror=s=>{const r=sa(s.target.error);t(r)}})}let bc=!1;function sa(n){const e=qe.D(Z());if(e>=12.2&&e<13){const t="An internal error was encountered in the Indexed Database server";if(n.message.indexOf(t)>=0){const s=new v("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${t}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return bc||(bc=!0,setTimeout(()=>{throw s},0)),s}}return n}class vv{constructor(e,t){this.asyncQueue=e,this.et=t,this.task=null}start(){this.nt(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return this.task!==null}nt(e){g("IndexBackiller",`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,async()=>{this.task=null;try{g("IndexBackiller",`Documents written: ${await this.et.st()}`)}catch(t){dt(t)?g("IndexBackiller","Ignoring IndexedDB error during index backfill: ",t):await Gt(t)}await this.nt(6e4)})}}class wv{constructor(e,t){this.localStore=e,this.persistence=t}async st(e=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",t=>this.it(t,e))}it(e,t){const s=new Set;let r=t,i=!0;return f.doWhile(()=>i===!0&&r>0,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next(o=>{if(o!==null&&!s.has(o))return g("IndexBackiller",`Processing collection: ${o}`),this.rt(e,o,r).next(a=>{r-=a,s.add(o)});i=!1})).next(()=>t-r)}rt(e,t,s){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e,t).next(r=>this.localStore.localDocuments.getNextDocuments(e,t,r,s).next(i=>{const o=i.changes;return this.localStore.indexManager.updateIndexEntries(e,o).next(()=>this.ot(r,i)).next(a=>(g("IndexBackiller",`Updating offset: ${a}
1043`),this.localStore.indexManager.updateCollectionGroup(e,t,a))).next(()=>o.size)}))}ot(e,t){let s=e;return t.changes.forEach((r,i)=>{const o=Rh(i);na(o,s)>0&&(s=o)}),new _e(s.readTime,s.documentKey,Math.max(t.batchId,e.largestBatchId))}}/** 1044 * @license 1045 * Copyright 2018 Google LLC 1046 * 1047 * Licensed under the Apache License, Version 2.0 (the "License"); 1048 * you may not use this file except in compliance with the License. 1049 * You may obtain a copy of the License at 1050 * 1051 * http://www.apache.org/licenses/LICENSE-2.0 1052 * 1053 * Unless required by applicable law or agreed to in writing, software 1054 * distributed under the License is distributed on an "AS IS" BASIS, 1055 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1056 * See the License for the specific language governing permissions and 1057 * limitations under the License. 1058 */class Se{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=s=>this.ut(s),this.ct=s=>t.writeSequenceNumber(s))}ut(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ct&&this.ct(e),e}}Se.at=-1;/** 1059 * @license 1060 * Copyright 2017 Google LLC 1061 * 1062 * Licensed under the Apache License, Version 2.0 (the "License"); 1063 * you may not use this file except in compliance with the License. 1064 * You may obtain a copy of the License at 1065 * 1066 * http://www.apache.org/licenses/LICENSE-2.0 1067 * 1068 * Unless required by applicable law or agreed to in writing, software 1069 * distributed under the License is distributed on an "AS IS" BASIS, 1070 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1071 * See the License for the specific language governing permissions and 1072 * limitations under the License. 1073 */class Iv{constructor(e,t,s,r,i,o,a,c){this.databaseId=e,this.appId=t,this.persistenceKey=s,this.host=r,this.ssl=i,this.forceLongPolling=o,this.autoDetectLongPolling=a,this.useFetchStreams=c}}class Mt{constructor(e,t){this.projectId=e,this.database=t||"(default)"}static empty(){return new Mt("","")}get isDefaultDatabase(){return this.database==="(default)"}isEqual(e){return e instanceof Mt&&e.projectId===this.projectId&&e.database===this.database}}/** 1074 * @license 1075 * Copyright 2017 Google LLC 1076 * 1077 * Licensed under the Apache License, Version 2.0 (the "License"); 1078 * you may not use this file except in compliance with the License. 1079 * You may obtain a copy of the License at 1080 * 1081 * http://www.apache.org/licenses/LICENSE-2.0 1082 * 1083 * Unless required by applicable law or agreed to in writing, software 1084 * distributed under the License is distributed on an "AS IS" BASIS, 1085 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1086 * See the License for the specific language governing permissions and 1087 * limitations under the License. 1088 */function _c(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function Kt(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function Ph(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}/** 1089 * @license 1090 * Copyright 2017 Google LLC 1091 * 1092 * Licensed under the Apache License, Version 2.0 (the "License"); 1093 * you may not use this file except in compliance with the License. 1094 * You may obtain a copy of the License at 1095 * 1096 * http://www.apache.org/licenses/LICENSE-2.0 1097 * 1098 * Unless required by applicable law or agreed to in writing, software 1099 * distributed under the License is distributed on an "AS IS" BASIS, 1100 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1101 * See the License for the specific language governing permissions and 1102 * limitations under the License. 1103 */function Qr(n){return n==null}function Jn(n){return n===0&&1/n==-1/0}function Tv(n){return typeof n=="number"&&Number.isInteger(n)&&!Jn(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}/** 1104 * @license 1105 * Copyright 2020 Google LLC 1106 * 1107 * Licensed under the Apache License, Version 2.0 (the "License"); 1108 * you may not use this file except in compliance with the License. 1109 * You may obtain a copy of the License at 1110 * 1111 * http://www.apache.org/licenses/LICENSE-2.0 1112 * 1113 * Unless required by applicable law or agreed to in writing, softw
1113are 1114 * distributed under the License is distributed on an "AS IS" BASIS, 1115 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1116 * See the License for the specific language governing permissions and 1117 * limitations under the License. 1118 */class ae{constructor(e){this.binaryString=e}static fromBase64String(e){const t=atob(e);return new ae(t)}static fromUint8Array(e){const t=function(s){let r="";for(let i=0;i<s.length;++i)r+=String.fromCharCode(s[i]);return r}(e);return new ae(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return e=this.binaryString,btoa(e);var e}toUint8Array(){return function(e){const t=new Uint8Array(e.length);for(let s=0;s<e.length;s++)t[s]=e.charCodeAt(s);return t}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return D(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}ae.EMPTY_BYTE_STRING=new ae("");const Ev=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ot(n){if(b(!!n),typeof n=="string"){let e=0;const t=Ev.exec(n);if(b(!!t),t[1]){let r=t[1];r=(r+"000000000").substr(0,9),e=Number(r)}const s=new Date(n);return{seconds:Math.floor(s.getTime()/1e3),nanos:e}}return{seconds:K(n.seconds),nanos:K(n.nanos)}}function K(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function Pt(n){return typeof n=="string"?ae.fromBase64String(n):ae.fromUint8Array(n)}/** 1119 * @license 1120 * Copyright 2020 Google LLC 1121 * 1122 * Licensed under the Apache License, Version 2.0 (the "License"); 1123 * you may not use this file except in compliance with the License. 1124 * You may obtain a copy of the License at 1125 * 1126 * http://www.apache.org/licenses/LICENSE-2.0 1127 * 1128 * Unless required by applicable law or agreed to in writing, software 1129 * distributed under the License is distributed on an "AS IS" BASIS, 1130 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1131 * See the License for the specific language governing permissions and 1132 * limitations under the License. 1133 */function Lh(n){var e,t;return((t=(((e=n==null?void 0:n.mapValue)===null||e===void 0?void 0:e.fields)||{}).__type__)===null||t===void 0?void 0:t.stringValue)==="server_timestamp"}function Fh(n){const e=n.mapValue.fields.__previous_value__;return Lh(e)?Fh(e):e}function Zn(n){const e=ot(n.mapValue.fields.__local_write_time__.timestampValue);return new j(e.seconds,e.nanos)}/** 1134 * @license 1135 * Copyright 2020 Google LLC 1136 * 1137 * Licensed under the Apache License, Version 2.0 (the "License"); 1138 * you may not use this file except in compliance with the License. 1139 * You may obtain a copy of the License at 1140 * 1141 * http://www.apache.org/licenses/LICENSE-2.0 1142 * 1143 * Unless required by applicable law or agreed to in writing, software 1144 * distributed under the License is distributed on an "AS IS" BASIS, 1145 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1146 * See the License for the specific language governing permissions and 1147 * limitations under the License. 1148 */const tt={mapValue:{fields:{__type__:{stringValue:"__max__"}}}},qs={nullValue:"NULL_VALUE"};function Lt(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?Lh(n)?4:Vh(n)?9007199254740991:10:I()}function Ve(n,e){if(n===e)return!0;const t=Lt(n);if(t!==Lt(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return Zn(n).isEqual(Zn(e));case 3:return function(s,r){if(typeof s.timestampValue=="string"&&typeof r.timestampValue=="string"&&s.timestampValue.length===r.timestampValue.length)return s.timestampValue===r.timestampValue;const i=ot(s.timestampValue),o=ot(r.timestampValue);return i.seconds===o.seconds&&i.nanos===o.nanos}(n,e);case 5:return n.stringValue===e.stringValue;case 6:return function(s,r){return Pt(s.bytesValue).isEqual(Pt(r.bytesValue))}(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return function(s,r){return K(s.geoPointValue.latitude)===K(r.geoPointValue.latitude)&&K(s.geoPointValue.longitude)===K(r.geoPointValue.longitude)}(n,e);case 2:return function(s,r){if("integerValue"in s&&"integerValue"in r)return K(s.integerValue)===K(r.integerValue);if("doubleValue"in s&&"doubleValue"in r){const i=K(s.doubleValue),o=K(r.doubleValue);return i===o?Jn(i)===Jn(o):isNaN(i)&&isNaN(o)}return!1}(n,e);case 9:return an(n.arrayValue.values||[],e.arrayValue.values||[],Ve);case 10:return function(s,r){const i=s.mapValue.fields||{},o=r.mapValue.fields||{};if(_c(i)!==_c(o))return!1;for(const a in i)if(i.hasOwnProperty(a)&&(o[a]===void 0||!Ve(i[a],o[a])))return!1;return!0}(n,e);default:return I()}}function es(n,e){return(n.values||[]).find(t=>Ve(t,e))!==void 0}function at(n,e){if(n===e)return 0;const t=Lt(n),s=Lt(e);if(t!==s)return D(t,s);switch(t){case 0:case 9007199254740991:return 0;case 1:return D(n.booleanValue,e.booleanValue);case 2:return function(r,i){const o=K(r.integerValue||r.doubleValue),a=K(i.integerValue||i.doubleValue);return o<a?-1:o>a?1:o===a?0:isNaN(o)?isNaN(a)?0:-1:1}(n,e);case 3:return Sc(n.timestampValue,e.timestampValue);case 4:return Sc(Zn(n),Zn(e));case 5:return D(n.stringValue,e.stringValue);case 6:return function(r,i){const o=Pt(r),a=Pt(i);return o.compareTo(a)}(n.bytesValue,e.bytesValue);case 7:return function(r,i){const o=r.split("/"),a=i.split("/");for(let c=0;c<o.length&&c<a.length;c++){const u=D(o[c],a[c]);if(u!==0)return u}return D(o.length,a.length)}(n.referenceValue,e.referenceValue);case 8:return function(r,i){const o=D(K(r.latitude),K(i.latitude));return o!==0?o:D(K(r.longitude),K(i.longitude))}(n.geoPointValue,e.geoPointValue);case 9:return function(r,i){const o=r.values||[],a=i.values||[];for(let c=0;c<o.length&&c<a.length;++c){const u=at(o[c],a[c]);if(u)return u}return D(o.length,a.length)}(n.arrayValue,e.arrayValue);case 10:return function(r,i){if(r===tt.mapValue&&i===tt.mapValue)return 0;if(r===tt.mapValue)return 1;if(i===tt.mapValue)return-1;const o=r.fields||{},a=Object.keys(o),c=i.fields||{},u=Object.keys(c);a.sort(),u.sort();for(let l=0;l<a.length&&l<u.length;++l){const h=D(a[l],u[l]);if(h!==0)return h;
1148const d=at(o[a[l]],c[u[l]]);if(d!==0)return d}return D(a.length,u.length)}(n.mapValue,e.mapValue);default:throw I()}}function Sc(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return D(n,e);const t=ot(n),s=ot(e),r=D(t.seconds,s.seconds);return r!==0?r:D(t.nanos,s.nanos)}function cn(n){return io(n)}function io(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(s){const r=ot(s);return`time(${r.seconds},${r.nanos})`}(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?Pt(n.bytesValue).toBase64():"referenceValue"in n?(t=n.referenceValue,w.fromName(t).toString()):"geoPointValue"in n?`geo(${(e=n.geoPointValue).latitude},${e.longitude})`:"arrayValue"in n?function(s){let r="[",i=!0;for(const o of s.values||[])i?i=!1:r+=",",r+=io(o);return r+"]"}(n.arrayValue):"mapValue"in n?function(s){const r=Object.keys(s.fields||{}).sort();let i="{",o=!0;for(const a of r)o?o=!1:i+=",",i+=`${a}:${io(s.fields[a])}`;return i+"}"}(n.mapValue):I();var e,t}function ts(n,e){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${e.path.canonicalString()}`}}function oo(n){return!!n&&"integerValue"in n}function ns(n){return!!n&&"arrayValue"in n}function Ac(n){return!!n&&"nullValue"in n}function Cc(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function js(n){return!!n&&"mapValue"in n}function Bn(n){if(n.geoPointValue)return{geoPointValue:Object.assign({},n.geoPointValue)};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:Object.assign({},n.timestampValue)};if(n.mapValue){const e={mapValue:{fields:{}}};return Kt(n.mapValue.fields,(t,s)=>e.mapValue.fields[t]=Bn(s)),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=Bn(n.arrayValue.values[t]);return e}return Object.assign({},n)}function Vh(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue==="__max__"}function bv(n){return"nullValue"in n?qs:"booleanValue"in n?{booleanValue:!1}:"integerValue"in n||"doubleValue"in n?{doubleValue:NaN}:"timestampValue"in n?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in n?{stringValue:""}:"bytesValue"in n?{bytesValue:""}:"referenceValue"in n?ts(Mt.empty(),w.empty()):"geoPointValue"in n?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in n?{arrayValue:{}}:"mapValue"in n?{mapValue:{}}:I()}function _v(n){return"nullValue"in n?{booleanValue:!1}:"booleanValue"in n?{doubleValue:NaN}:"integerValue"in n||"doubleValue"in n?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in n?{stringValue:""}:"stringValue"in n?{bytesValue:""}:"bytesValue"in n?ts(Mt.empty(),w.empty()):"referenceValue"in n?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in n?{arrayValue:{}}:"arrayValue"in n?{mapValue:{}}:"mapValue"in n?tt:I()}function kc(n,e){const t=at(n.value,e.value);return t!==0?t:n.inclusive&&!e.inclusive?-1:!n.inclusive&&e.inclusive?1:0}function Dc(n,e){const t=at(n.value,e.value);return t!==0?t:n.inclusive&&!e.inclusive?1:!n.inclusive&&e.inclusive?-1:0}/** 1149 * @license 1150 * Copyright 2022 Google LLC 1151 * 1152 * Licensed under the Apache License, Version 2.0 (the "License"); 1153 * you may not use this file except in compliance with the License. 1154 * You may obtain a copy of the License at 1155 * 1156 * http://www.apache.org/licenses/LICENSE-2.0 1157 * 1158 * Unless required by applicable law or agreed to in writing, software 1159 * distributed under the License is distributed on an "AS IS" BASIS, 1160 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1161 * See the License for the specific language governing permissions and 1162 * limitations under the License. 1163 */class un{constructor(e,t){this.position=e,this.inclusive=t}}function Nc(n,e,t){let s=0;for(let r=0;r<n.position.length;r++){const i=e[r],o=n.position[r];if(i.field.isKeyField()?s=w.comparator(w.fromName(o.referenceValue),t.key):s=at(o,t.data.field(i.field)),i.dir==="desc"&&(s*=-1),s!==0)break}return s}function xc(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!Ve(n.position[t],e.position[t]))return!1;return!0}/** 1164 * @license 1165 * Copyright 2022 Google LLC 1166 * 1167 * Licensed under the Apache License, Version 2.0 (the "License");
1168 * you may not use this file except in compliance with the License. 1169 * You may obtain a copy of the License at 1170 * 1171 * http://www.apache.org/licenses/LICENSE-2.0 1172 * 1173 * Unless required by applicable law or agreed to in writing, software 1174 * distributed under the License is distributed on an "AS IS" BASIS, 1175 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1176 * See the License for the specific language governing permissions and 1177 * limitations under the License. 1178 */class Uh{}class x extends Uh{constructor(e,t,s){super(),this.field=e,this.op=t,this.value=s}static create(e,t,s){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,s):new Sv(e,t,s):t==="array-contains"?new kv(e,s):t==="in"?new Kh(e,s):t==="not-in"?new Dv(e,s):t==="array-contains-any"?new Nv(e,s):new x(e,t,s)}static createKeyFieldInFilter(e,t,s){return t==="in"?new Av(e,s):new Cv(e,s)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&this.matchesComparison(at(t,this.value)):t!==null&&Lt(this.value)===Lt(t)&&this.matchesComparison(at(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return I()}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}getFirstInequalityField(){return this.isInequality()?this.field:null}}class P extends Uh{constructor(e,t){super(),this.filters=e,this.op=t,this.ht=null}static create(e,t){return new P(e,t)}matches(e){return ln(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.ht!==null||(this.ht=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.ht}getFilters(){return Object.assign([],this.filters)}getFirstInequalityField(){const e=this.lt(t=>t.isInequality());return e!==null?e.field:null}lt(e){for(const t of this.getFlattenedFilters())if(e(t))return t;return null}}function ln(n){return n.op==="and"}function ao(n){return n.op==="or"}function ra(n){return Bh(n)&&ln(n)}function Bh(n){for(const e of n.filters)if(e instanceof P)return!1;return!0}function co(n){if(n instanceof x)return n.field.canonicalString()+n.op.toString()+cn(n.value);if(ra(n))return n.filters.map(e=>co(e)).join(",");{const e=n.filters.map(t=>co(t)).join(",");return`${n.op}(${e})`}}function $h(n,e){return n instanceof x?function(t,s){return s instanceof x&&t.op===s.op&&t.field.isEqual(s.field)&&Ve(t.value,s.value)}(n,e):n instanceof P?function(t,s){return s instanceof P&&t.op===s.op&&t.filters.length===s.filters.length?t.filters.reduce((r,i,o)=>r&&$h(i,s.filters[o]),!0):!1}(n,e):void I()}function qh(n,e){const t=n.filters.concat(e);return P.create(t,n.op)}function jh(n){return n instanceof x?function(e){return`${e.field.canonicalString()} ${e.op} ${cn(e.value)}`}(n):n instanceof P?function(e){return e.op.toString()+" {"+e.getFilters().map(jh).join(" ,")+"}"}(n):"Filter"}class Sv extends x{constructor(e,t,s){super(e,t,s),this.key=w.fromName(s.referenceValue)}matches(e){const t=w.comparator(e.key,this.key);return this.matchesComparison(t)}}class Av extends x{constructor(e,t){super(e,"in",t),this.keys=Gh("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class Cv extends x{constructor(e,t){super(e,"not-in",t),this.keys=Gh("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function Gh(n,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map(s=>w.fromName(s.referenceValue))}class kv extends x{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return ns(t)&&es(t.arrayValue,this.value)}}class Kh extends x{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&es(this.value.arrayValue,t)}}class Dv extends x{constructor(e,t){super(e,"not-in",t)}matches(e){if(es(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&!es(this.value.arrayValue,t)}}class Nv extends x{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!ns(t)||!t.arrayValue.values)&&t.arrayValue.values.some(s=>es(this.value.arrayValue,s))}}/** 1179 * @license 1180 * Copyright 2022 Google LLC 1181 * 1182 * Licensed under the Apache License, Version 2.0 (the "License");
1183 * you may not use this file except in compliance with the License. 1184 * You may obtain a copy of the License at 1185 * 1186 * http://www.apache.org/licenses/LICENSE-2.0 1187 * 1188 * Unless required by applicable law or agreed to in writing, software 1189 * distributed under the License is distributed on an "AS IS" BASIS, 1190 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1191 * See the License for the specific language governing permissions and 1192 * limitations under the License. 1193 */class Zt{constructor(e,t="asc"){this.field=e,this.dir=t}}function xv(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}/** 1194 * @license 1195 * Copyright 2017 Google LLC 1196 * 1197 * Licensed under the Apache License, Version 2.0 (the "License"); 1198 * you may not use this file except in compliance with the License. 1199 * You may obtain a copy of the License at 1200 * 1201 * http://www.apache.org/licenses/LICENSE-2.0 1202 * 1203 * Unless required by applicable law or agreed to in writing, software 1204 * distributed under the License is distributed on an "AS IS" BASIS, 1205 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1206 * See the License for the specific language governing permissions and 1207 * limitations under the License. 1208 */class Y{constructor(e,t){this.comparator=e,this.root=t||ie.EMPTY}insert(e,t){return new Y(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,ie.BLACK,null,null))}remove(e){return new Y(this.comparator,this.root.remove(e,this.comparator).copy(null,null,ie.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const s=this.comparator(e,t.key);if(s===0)return t.value;s<0?t=t.left:s>0&&(t=t.right)}return null}indexOf(e){let t=0,s=this.root;for(;!s.isEmpty();){const r=this.comparator(e,s.key);if(r===0)return t+s.left.size;r<0?s=s.left:(t+=s.left.size+1,s=s.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,s)=>(e(t,s),!1))}toString(){const e=[];return this.inorderTraversal((t,s)=>(e.push(`${t}:${s}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Ls(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Ls(this.root,e,this.comparator,!1)}getReverseIterator(){return new Ls(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Ls(this.root,e,this.comparator,!0)}}class Ls{constructor(e,t,s,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?s(e.key,t):1,t&&r&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class ie{constructor(e,t,s,r,i){this.key=e,this.value=t,this.color=s??ie.RED,this.left=r??ie.EMPTY,this.right=i??ie.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,s,r,i){return new ie(e??this.key,t??this.value,s??this.color,r??this.left,i??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,s){let r=this;const i=s(e,r.key);return r=i<0?r.copy(null,null,null,r.left.insert(e,t,s),null):i===0?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,s)),r.fixUp()}removeMin(){if(this.left.isEmpty())return ie.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let s,r=this;if(t(e,r.key)<0)r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(e,t),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),t(e,r.key)===0){if(r.right.isEmpty())return ie.EMPTY;s=r.right.min(),r=r.copy(s.key,s.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(e,t))}return r.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,ie.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,ie.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw I();const e=this.left.check();if(e!==this.right.check())throw I();return e+(this.isRed()?0:1)}}ie.EMPTY=null,ie.RED=!0,ie.BLACK=!1;
1208ie.EMPTY=new class{constructor(){this.size=0}get key(){throw I()}get value(){throw I()}get color(){throw I()}get left(){throw I()}get right(){throw I()}copy(n,e,t,s,r){return this}insert(n,e,t){return new ie(n,e)}remove(n,e){return this}isEmpty(){return!0}inorderTraversal(n){return!1}reverseTraversal(n){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/** 1209 * @license 1210 * Copyright 2017 Google LLC 1211 * 1212 * Licensed under the Apache License, Version 2.0 (the "License"); 1213 * you may not use this file except in compliance with the License. 1214 * You may obtain a copy of the License at 1215 * 1216 * http://www.apache.org/licenses/LICENSE-2.0 1217 * 1218 * Unless required by applicable law or agreed to in writing, software 1219 * distributed under the License is distributed on an "AS IS" BASIS, 1220 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1221 * See the License for the specific language governing permissions and 1222 * limitations under the License. 1223 */class L{constructor(e){this.comparator=e,this.data=new Y(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,s)=>(e(t),!1))}forEachInRange(e,t){const s=this.data.getIteratorFrom(e[0]);for(;s.hasNext();){const r=s.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}forEachWhile(e,t){let s;for(s=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();s.hasNext();)if(!e(s.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new Rc(this.data.getIterator())}getIteratorFrom(e){return new Rc(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(s=>{t=t.add(s)}),t}isEqual(e){if(!(e instanceof L)||this.size!==e.size)return!1;const t=this.data.getIterator(),s=e.data.getIterator();for(;t.hasNext();){const r=t.getNext().key,i=s.getNext().key;if(this.comparator(r,i)!==0)return!1}return!0}toArray(){const e=[];return this.forEach(t=>{e.push(t)}),e}toString(){const e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){const t=new L(this.comparator);return t.data=e,t}}class Rc{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function Ht(n){return n.hasNext()?n.getNext():void 0}/** 1224 * @license 1225 * Copyright 2020 Google LLC 1226 * 1227 * Licensed under the Apache License, Version 2.0 (the "License"); 1228 * you may not use this file except in compliance with the License. 1229 * You may obtain a copy of the License at 1230 * 1231 * http://www.apache.org/licenses/LICENSE-2.0 1232 * 1233 * Unless required by applicable law or agreed to in writing, software 1234 * distributed under the License is distributed on an "AS IS" BASIS, 1235 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1236 * See the License for the specific language governing permissions and 1237 * limitations under the License. 1238 */class we{constructor(e){this.fields=e,e.sort(Q.comparator)}static empty(){return new we([])}unionWith(e){let t=new L(Q.comparator);for(const s of this.fields)t=t.add(s);for(const s of e)t=t.add(s);return new we(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return an(this.fields,e.fields,(t,s)=>t.isEqual(s))}}/** 1239 * @license 1240 * Copyright 2017 Google LLC 1241 * 1242 * Licensed under the Apache License, Version 2.0 (the "License"); 1243 * you may not use this file except in compliance with the License. 1244 * You may obtain a copy of the License at 1245 * 1246 * http://www.apache.org/licenses/LICENSE-2.0 1247 * 1248 * Unless required by applicable law or agreed to in writing, software 1249 * distributed under the License is distributed on an "AS IS" BASIS, 1250 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1251 * See the License for the specific language governing permissions and 1252 * limitations under the License. 1253 */class ue{constructor(e){this.value=e}static empty(){return new ue({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let s=0;s<e.length-1;++s)if(t=(t.mapValue.fields||{})[e.get(s)],!js(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Bn(t)}setAll(e){let t=Q.emptyPath(),s={},r=[];e.forEach((o,a)=>
vendor: 6,619 bytes, lines 1253-1287
1253{if(!t.isImmediateParentOf(a)){const c=this.getFieldsMap(t);this.applyChanges(c,s,r),s={},r=[],t=a.popLast()}o?s[a.lastSegment()]=Bn(o):r.push(a.lastSegment())});const i=this.getFieldsMap(t);this.applyChanges(i,s,r)}delete(e){const t=this.field(e.popLast());js(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Ve(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let s=0;s<e.length;++s){let r=t.mapValue.fields[e.get(s)];js(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(s)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,s){Kt(t,(r,i)=>e[r]=i);for(const r of s)delete e[r]}clone(){return new ue(Bn(this.value))}}function zh(n){const e=[];return Kt(n.fields,(t,s)=>{const r=new Q([t]);if(js(s)){const i=zh(s.mapValue).fields;if(i.length===0)e.push(r);else for(const o of i)e.push(r.child(o))}else e.push(r)}),new we(e)}/** 1254 * @license 1255 * Copyright 2017 Google LLC 1256 * 1257 * Licensed under the Apache License, Version 2.0 (the "License"); 1258 * you may not use this file except in compliance with the License. 1259 * You may obtain a copy of the License at 1260 * 1261 * http://www.apache.org/licenses/LICENSE-2.0 1262 * 1263 * Unless required by applicable law or agreed to in writing, software 1264 * distributed under the License is distributed on an "AS IS" BASIS, 1265 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1266 * See the License for the specific language governing permissions and 1267 * limitations under the License. 1268 */class z{constructor(e,t,s,r,i,o,a){this.key=e,this.documentType=t,this.version=s,this.readTime=r,this.createTime=i,this.data=o,this.documentState=a}static newInvalidDocument(e){return new z(e,0,_.min(),_.min(),_.min(),ue.empty(),0)}static newFoundDocument(e,t,s,r){return new z(e,1,t,_.min(),s,r,0)}static newNoDocument(e,t){return new z(e,2,t,_.min(),_.min(),ue.empty(),0)}static newUnknownDocument(e,t){return new z(e,3,t,_.min(),_.min(),ue.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(_.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=ue.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=ue.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=_.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof z&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new z(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}})`}}/** 1269 * @license 1270 * Copyright 2019 Google LLC 1271 * 1272 * Licensed under the Apache License, Version 2.0 (the "License"); 1273 * you may not use this file except in compliance with the License. 1274 * You may obtain a copy of the License at 1275 * 1276 * http://www.apache.org/licenses/LICENSE-2.0 1277 * 1278 * Unless required by applicable law or agreed to in writing, software 1279 * distributed under the License is distributed on an "AS IS" BASIS, 1280 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1281 * See the License for the specific language governing permissions and 1282 * limitations under the License. 1283 */class Rv{constructor(e,t=null,s=[],r=[],i=null,o=null,a=null){this.path=e,this.collectionGroup=t,this.orderBy=s,this.filters=r,this.limit=i,this.startAt=o,this.endAt=a,this.ft=null}}function uo(n,e=null,t=[],s=[],r=null,i=null,o=null){return new Rv(n,e,t,s,r,i,o)}function Ft(n){const e=k(n);if(e.ft===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(s=>co(s)).join(","),t+="|ob:",t+=e.orderBy.map(s=>function(r){return r.field.canonicalString()+r.dir}(s)).join(","),Qr(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(s=>cn(s)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(s=>cn(s)).join(",")),e.ft=t}return e.ft}function ys(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!xv(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!$h(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!xc(n.startAt,e.startAt)&&xc(n.endAt,e.endAt)}function fr(n){return w.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}function pr(n,e){return n.filters.filter(t=>t instanceof x&&t.field.isEqual(e))}function Oc(n,e,t){let s=qs,r=!0;for(const i of pr(n,e)){let o=qs,a=!0;switch(i.op){case"<":case"<=":o=bv(i.value);break;case"==":case"in":case">=":o=i.value;break;case">":o=i.value,a=!1;break;case"!=":case"not-in":o=qs}kc({value:s,inclusive:r},{value:o,inclusive:a})<0&&(s=o,r=a)}if(t!==null){for(let i=0;i<n.orderBy.length;++i)if(n.orderBy[i].field.isEqual(e)){const o=t.position[i];kc({value:s,inclusive:r},{value:o,inclusive:t.inclusive})<0&&(s=o,r=t.inclusive);break}}return{value:s,inclusive:r}}function Mc(n,e,t){let s=tt,r=!0;for(const i of pr(n,e)){let o=tt,a=!0;switch(i.op){case">=":case">":o=_v(i.value),a=!1;break;case"==":case"in":case"<=":o=i.value;break;case"<":o=i.value,a=!1;break;case"!=":case"not-in":o=tt}Dc({value:s,inclusive:r},{value:o,inclusive:a})>0&&(s=o,r=a)}if(t!==null){for(let i=0;i<n.orderBy.length;++i)if(n.orderBy[i].field.isEqual(e)){const o=t.position[i];Dc({value:s,inclusive:r},{value:o,inclusive:t.inclusive})>0&&(s=o,r=t.inclusive);break}}return{value:s,inclusive:r}}/** 1284 * @license 1285 * Copyright 2017 Google LLC 1286 * 1287 * Licensed under the Apache License, Version 2.0 (the "License");
1288 * you may not use this file except in compliance with the License. 1289 * You may obtain a copy of the License at 1290 * 1291 * http://www.apache.org/licenses/LICENSE-2.0 1292 * 1293 * Unless required by applicable law or agreed to in writing, software 1294 * distributed under the License is distributed on an "AS IS" BASIS, 1295 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1296 * See the License for the specific language governing permissions and 1297 * limitations under the License. 1298 */class Tn{constructor(e,t=null,s=[],r=[],i=null,o="F",a=null,c=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=s,this.filters=r,this.limit=i,this.limitType=o,this.startAt=a,this.endAt=c,this.dt=null,this._t=null,this.startAt,this.endAt}}function Ov(n,e,t,s,r,i,o,a){return new Tn(n,e,t,s,r,i,o,a)}function vs(n){return new Tn(n)}function Pc(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 ia(n){return n.explicitOrderBy.length>0?n.explicitOrderBy[0].field:null}function Yr(n){for(const e of n.filters){const t=e.getFirstInequalityField();if(t!==null)return t}return null}function Hh(n){return n.collectionGroup!==null}function en(n){const e=k(n);if(e.dt===null){e.dt=[];const t=Yr(e),s=ia(e);if(t!==null&&s===null)t.isKeyField()||e.dt.push(new Zt(t)),e.dt.push(new Zt(Q.keyField(),"asc"));else{let r=!1;for(const i of e.explicitOrderBy)e.dt.push(i),i.field.isKeyField()&&(r=!0);if(!r){const i=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e.dt.push(new Zt(Q.keyField(),i))}}}return e.dt}function xe(n){const e=k(n);if(!e._t)if(e.limitType==="F")e._t=uo(e.path,e.collectionGroup,en(e),e.filters,e.limit,e.startAt,e.endAt);else{const t=[];for(const i of en(e)){const o=i.dir==="desc"?"asc":"desc";t.push(new Zt(i.field,o))}const s=e.endAt?new un(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new un(e.startAt.position,e.startAt.inclusive):null;e._t=uo(e.path,e.collectionGroup,t,e.filters,e.limit,s,r)}return e._t}function lo(n,e){e.getFirstInequalityField(),Yr(n);const t=n.filters.concat([e]);return new Tn(n.path,n.collectionGroup,n.explicitOrderBy.slice(),t,n.limit,n.limitType,n.startAt,n.endAt)}function ho(n,e,t){return new Tn(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function Xr(n,e){return ys(xe(n),xe(e))&&n.limitType===e.limitType}function Wh(n){return`${Ft(xe(n))}|lt:${n.limitType}`}function fo(n){return`Query(target=${function(e){let t=e.path.canonicalString();return e.collectionGroup!==null&&(t+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(t+=`, filters: [${e.filters.map(s=>jh(s)).join(", ")}]`),Qr(e.limit)||(t+=", limit: "+e.limit),e.orderBy.length>0&&(t+=`, orderBy: [${e.orderBy.map(s=>function(r){return`${r.field.canonicalString()} (${r.dir})`}(s)).join(", ")}]`),e.startAt&&(t+=", startAt: ",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(s=>cn(s)).join(",")),e.endAt&&(t+=", endAt: ",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(s=>cn(s)).join(",")),`Target(${t})`}(xe(n))}; limitType=${n.limitType})`}function ws(n,e){return e.isFoundDocument()&&function(t,s){const r=s.key.path;return t.collectionGroup!==null?s.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(r):w.isDocumentKey(t.path)?t.path.isEqual(r):t.path.isImmediateParentOf(r)}(n,e)&&function(t,s){for(const r of en(t))if(!r.field.isKeyField()&&s.data.field(r.field)===null)return!1;return!0}(n,e)&&function(t,s){for(const r of t.filters)if(!r.matches(s))return!1;return!0}(n,e)&&function(t,s){return!(t.startAt&&!function(r,i,o){const a=Nc(r,i,o);return r.inclusive?a<=0:a<0}(t.startAt,en(t),s)||t.endAt&&!function(r,i,o){const a=Nc(r,i,o);return r.inclusive?a>=0:a>0}(t.endAt,en(t),s))}(n,e)}function Mv(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function Qh(n){return(e,t)=>{let s=!1;for(const r of en(n)){const i=Pv(r,e,t);if(i!==0)return i;s=s||r.field.isKeyField()}return 0}}function Pv(n,e,t){const s=n.field.isKeyField()?w.comparator(e.key,t.key):function(r,i,o){const a=i.data.field(r),c=o.data.field(r);return a!==null&&c!==null?at(a,c):I()}(n.field,e,t);switch(n.dir){case"asc":return s;
1298case"desc":return-1*s;default:return I()}}/** 1299 * @license 1300 * Copyright 2020 Google LLC 1301 * 1302 * Licensed under the Apache License, Version 2.0 (the "License"); 1303 * you may not use this file except in compliance with the License. 1304 * You may obtain a copy of the License at 1305 * 1306 * http://www.apache.org/licenses/LICENSE-2.0 1307 * 1308 * Unless required by applicable law or agreed to in writing, software 1309 * distributed under the License is distributed on an "AS IS" BASIS, 1310 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1311 * See the License for the specific language governing permissions and 1312 * limitations under the License. 1313 */function Yh(n,e){if(n.wt){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Jn(e)?"-0":e}}function Xh(n){return{integerValue:""+n}}function Lv(n,e){return Tv(e)?Xh(e):Yh(n,e)}/** 1314 * @license 1315 * Copyright 2018 Google LLC 1316 * 1317 * Licensed under the Apache License, Version 2.0 (the "License"); 1318 * you may not use this file except in compliance with the License. 1319 * You may obtain a copy of the License at 1320 * 1321 * http://www.apache.org/licenses/LICENSE-2.0 1322 * 1323 * Unless required by applicable law or agreed to in writing, software 1324 * distributed under the License is distributed on an "AS IS" BASIS, 1325 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1326 * See the License for the specific language governing permissions and 1327 * limitations under the License. 1328 */class Jr{constructor(){this._=void 0}}function Fv(n,e,t){return n instanceof hn?function(s,r){const i={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return r&&(i.fields.__previous_value__=r),{mapValue:i}}(t,e):n instanceof dn?Zh(n,e):n instanceof fn?ed(n,e):function(s,r){const i=Jh(s,r),o=Lc(i)+Lc(s.gt);return oo(i)&&oo(s.gt)?Xh(o):Yh(s.yt,o)}(n,e)}function Vv(n,e,t){return n instanceof dn?Zh(n,e):n instanceof fn?ed(n,e):t}function Jh(n,e){return n instanceof ss?oo(t=e)||function(s){return!!s&&"doubleValue"in s}(t)?e:{integerValue:0}:null;var t}class hn extends Jr{}class dn extends Jr{constructor(e){super(),this.elements=e}}function Zh(n,e){const t=td(e);for(const s of n.elements)t.some(r=>Ve(r,s))||t.push(s);return{arrayValue:{values:t}}}class fn extends Jr{constructor(e){super(),this.elements=e}}function ed(n,e){let t=td(e);for(const s of n.elements)t=t.filter(r=>!Ve(r,s));return{arrayValue:{values:t}}}class ss extends Jr{constructor(e,t){super(),this.yt=e,this.gt=t}}function Lc(n){return K(n.integerValue||n.doubleValue)}function td(n){return ns(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}/** 1329 * @license 1330 * Copyright 2017 Google LLC 1331 * 1332 * Licensed under the Apache License, Version 2.0 (the "License"); 1333 * you may not use this file except in compliance with the License. 1334 * You may obtain a copy of the License at 1335 * 1336 * http://www.apache.org/licenses/LICENSE-2.0 1337 * 1338 * Unless required by applicable law or agreed to in writing, software 1339 * distributed under the License is distributed on an "AS IS" BASIS, 1340 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1341 * See the License for the specific language governing permissions and 1342 * limitations under the License. 1343 */class nd{constructor(e,t){this.field=e,this.transform=t}}function Uv(n,e){return n.field.isEqual(e.field)&&function(t,s){return t instanceof dn&&s instanceof dn||t instanceof fn&&s instanceof fn?an(t.elements,s.elements,Ve):t instanceof ss&&s instanceof ss?Ve(t.gt,s.gt):t instanceof hn&&s instanceof hn}(n.transform,e.transform)}class Bv{constructor(e,t){this.version=e,this.transformResults=t}}class J{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new J}static exists(e){return new J(void 0,e)}static updateTime(e){return new J(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function Gs(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class Zr{}function sd(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new Is(n.key,J.none()):new En(n.key,n.data,J.none());{const t=n.data,s=ue.empty();let r=new L(Q.comparator);for(let i of e.fields)if(!r.has(i)){let o=t.field(i);o===null&&i.length>1&&(i=i.popLast(),o=t.field(i)),o===null?s.delete(i):s.set(i,o),r=r.add(i)}return new He(n.key,s,new we(r.toArray()),J.none())}}function $v(n,e,t){n instanceof En?function(s,r,i){const o=s.value.clone(),a=Vc(s.fieldTransforms,r,i.transformResults);o.setAll(a),r.convertToFoundDocument(i.version,o).setHasCommittedMutations()}
1343(n,e,t):n instanceof He?function(s,r,i){if(!Gs(s.precondition,r))return void r.convertToUnknownDocument(i.version);const o=Vc(s.fieldTransforms,r,i.transformResults),a=r.data;a.setAll(rd(s)),a.setAll(o),r.convertToFoundDocument(i.version,a).setHasCommittedMutations()}(n,e,t):function(s,r,i){r.convertToNoDocument(i.version).setHasCommittedMutations()}(0,e,t)}function $n(n,e,t,s){return n instanceof En?function(r,i,o,a){if(!Gs(r.precondition,i))return o;const c=r.value.clone(),u=Uc(r.fieldTransforms,a,i);return c.setAll(u),i.convertToFoundDocument(i.version,c).setHasLocalMutations(),null}(n,e,t,s):n instanceof He?function(r,i,o,a){if(!Gs(r.precondition,i))return o;const c=Uc(r.fieldTransforms,a,i),u=i.data;return u.setAll(rd(r)),u.setAll(c),i.convertToFoundDocument(i.version,u).setHasLocalMutations(),o===null?null:o.unionWith(r.fieldMask.fields).unionWith(r.fieldTransforms.map(l=>l.field))}(n,e,t,s):function(r,i,o){return Gs(r.precondition,i)?(i.convertToNoDocument(i.version).setHasLocalMutations(),null):o}(n,e,t)}function qv(n,e){let t=null;for(const s of n.fieldTransforms){const r=e.data.field(s.field),i=Jh(s.transform,r||null);i!=null&&(t===null&&(t=ue.empty()),t.set(s.field,i))}return t||null}function Fc(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!function(t,s){return t===void 0&&s===void 0||!(!t||!s)&&an(t,s,(r,i)=>Uv(r,i))}(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class En extends Zr{constructor(e,t,s,r=[]){super(),this.key=e,this.value=t,this.precondition=s,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class He extends Zr{constructor(e,t,s,r,i=[]){super(),this.key=e,this.data=t,this.fieldMask=s,this.precondition=r,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function rd(n){const e=new Map;return n.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){const s=n.data.field(t);e.set(t,s)}}),e}function Vc(n,e,t){const s=new Map;b(n.length===t.length);for(let r=0;r<t.length;r++){const i=n[r],o=i.transform,a=e.data.field(i.field);s.set(i.field,Vv(o,a,t[r]))}return s}function Uc(n,e,t){const s=new Map;for(const r of n){const i=r.transform,o=t.data.field(r.field);s.set(r.field,Fv(i,o,e))}return s}class Is extends Zr{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}
1343class id extends Zr{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/** 1344 * @license 1345 * Copyright 2017 Google LLC 1346 * 1347 * Licensed under the Apache License, Version 2.0 (the "License"); 1348 * you may not use this file except in compliance with the License. 1349 * You may obtain a copy of the License at 1350 * 1351 * http://www.apache.org/licenses/LICENSE-2.0 1352 * 1353 * Unless required by applicable law or agreed to in writing, software 1354 * distributed under the License is distributed on an "AS IS" BASIS, 1355 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1356 * See the License for the specific language governing permissions and 1357 * limitations under the License. 1358 */class jv{constructor(e){this.count=e}}/** 1359 * @license 1360 * Copyright 2017 Google LLC 1361 * 1362 * Licensed under the Apache License, Version 2.0 (the "License"); 1363 * you may not use this file except in compliance with the License. 1364 * You may obtain a copy of the License at 1365 * 1366 * http://www.apache.org/licenses/LICENSE-2.0 1367 * 1368 * Unless required by applicable law or agreed to in writing, software 1369 * distributed under the License is distributed on an "AS IS" BASIS, 1370 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1371 * See the License for the specific language governing permissions and 1372 * limitations under the License. 1373 */var W,R;function Gv(n){switch(n){default:return I();case p.CANCELLED:case p.UNKNOWN:case p.DEADLINE_EXCEEDED:case p.RESOURCE_EXHAUSTED:case p.INTERNAL:case p.UNAVAILABLE:case p.UNAUTHENTICATED:return!1;case p.INVALID_ARGUMENT:case p.NOT_FOUND:case p.ALREADY_EXISTS:case p.PERMISSION_DENIED:case p.FAILED_PRECONDITION:case p.ABORTED:case p.OUT_OF_RANGE:case p.UNIMPLEMENTED:case p.DATA_LOSS:return!0}}function od(n){if(n===void 0)return pe("GRPC error has no .code"),p.UNKNOWN;switch(n){case W.OK:return p.OK;case W.CANCELLED:return p.CANCELLED;case W.UNKNOWN:return p.UNKNOWN;case W.DEADLINE_EXCEEDED:return p.DEADLINE_EXCEEDED;case W.RESOURCE_EXHAUSTED:return p.RESOURCE_EXHAUSTED;case W.INTERNAL:return p.INTERNAL;case W.UNAVAILABLE:return p.UNAVAILABLE;case W.UNAUTHENTICATED:return p.UNAUTHENTICATED;case W.INVALID_ARGUMENT:return p.INVALID_ARGUMENT;case W.NOT_FOUND:return p.NOT_FOUND;case W.ALREADY_EXISTS:return p.ALREADY_EXISTS;case W.PERMISSION_DENIED:return p.PERMISSION_DENIED;case W.FAILED_PRECONDITION:return p.FAILED_PRECONDITION;case W.ABORTED:return p.ABORTED;case W.OUT_OF_RANGE:return p.OUT_OF_RANGE;case W.UNIMPLEMENTED:return p.UNIMPLEMENTED;case W.DATA_LOSS:return p.DATA_LOSS;default:return I()}}(R=W||(W={}))[R.OK=0]="OK",R[R.CANCELLED=1]="CANCELLED",R[R.UNKNOWN=2]="UNKNOWN",R[R.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",R[R.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",R[R.NOT_FOUND=5]="NOT_FOUND",R[R.ALREADY_EXISTS=6]="ALREADY_EXISTS",R[R.PERMISSION_DENIED=7]="PERMISSION_DENIED",R[R.UNAUTHENTICATED=16]="UNAUTHENTICATED",R[R.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",R[R.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",R[R.ABORTED=10]="ABORTED",R[R.OUT_OF_RANGE=11]="OUT_OF_RANGE",R[R.UNIMPLEMENTED=12]="UNIMPLEMENTED",R[R.INTERNAL=13]="INTERNAL",R[R.UNAVAILABLE=14]="UNAVAILABLE",R[R.DATA_LOSS=15]="DATA_LOSS";/** 1374 * @license 1375 * Copyright 2017 Google LLC 1376 * 1377 * Licensed under the Apache License, Version 2.0 (the "License"); 1378 * you may not use this file except in compliance with the License. 1379 * You may obtain a copy of the License at 1380 * 1381 * http://www.apache.org/licenses/LICENSE-2.0 1382 * 1383 * Unless required by applicable law or agreed to in writing, software 1384 * distributed under the License is distributed on an "AS IS" BASIS, 1385 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1386 * See the License for the specific language governing permissions and 1387 * limitations under the License. 1388 */class ft{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),s=this.inner[t];if(s!==void 0){for(const[r,i]of s)if(this.equalsFn(r,e))return i}}has(e){return this.get(e)!==void 0}set(e,t){const s=this.mapKeyFn(e),r=this.inner[s];if(r===void 0)return this.inner[s]=[[e,t]],void this.innerSize++;for(let i=0;i<r.length;i++)if(this.equalsFn(r[i][0],e))return void(r[i]=[e,t]);
1388r.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),s=this.inner[t];if(s===void 0)return!1;for(let r=0;r<s.length;r++)if(this.equalsFn(s[r][0],e))return s.length===1?delete this.inner[t]:s.splice(r,1),this.innerSize--,!0;return!1}forEach(e){Kt(this.inner,(t,s)=>{for(const[r,i]of s)e(r,i)})}isEmpty(){return Ph(this.inner)}size(){return this.innerSize}}/** 1389 * @license 1390 * Copyright 2017 Google LLC 1391 * 1392 * Licensed under the Apache License, Version 2.0 (the "License"); 1393 * you may not use this file except in compliance with the License. 1394 * You may obtain a copy of the License at 1395 * 1396 * http://www.apache.org/licenses/LICENSE-2.0 1397 * 1398 * Unless required by applicable law or agreed to in writing, software 1399 * distributed under the License is distributed on an "AS IS" BASIS, 1400 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1401 * See the License for the specific language governing permissions and 1402 * limitations under the License. 1403 */const Kv=new Y(w.comparator);function Te(){return Kv}const ad=new Y(w.comparator);function Mn(...n){let e=ad;for(const t of n)e=e.insert(t.key,t);return e}function cd(n){let e=ad;return n.forEach((t,s)=>e=e.insert(t,s.overlayedDocument)),e}function Me(){return qn()}function ud(){return qn()}function qn(){return new ft(n=>n.toString(),(n,e)=>n.isEqual(e))}const zv=new Y(w.comparator),Hv=new L(w.comparator);function N(...n){let e=Hv;for(const t of n)e=e.add(t);return e}const Wv=new L(D);function ld(){return Wv}/** 1404 * @license 1405 * Copyright 2017 Google LLC 1406 * 1407 * Licensed under the Apache License, Version 2.0 (the "License"); 1408 * you may not use this file except in compliance with the License. 1409 * You may obtain a copy of the License at 1410 * 1411 * http://www.apache.org/licenses/LICENSE-2.0 1412 * 1413 * Unless required by applicable law or agreed to in writing, software 1414 * distributed under the License is distributed on an "AS IS" BASIS, 1415 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1416 * See the License for the specific language governing permissions and 1417 * limitations under the License. 1418 */class ei{constructor(e,t,s,r,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=s,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,s){const r=new Map;return r.set(e,Ts.createSynthesizedTargetChangeForCurrentChange(e,t,s)),new ei(_.min(),r,ld(),Te(),N())}}class Ts{constructor(e,t,s,r,i){this.resumeToken=e,this.current=t,this.addedDocuments=s,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,s){return new Ts(s,t,N(),N(),N())}}/** 1419 * @license 1420 * Copyright 2017 Google LLC 1421 * 1422 * Licensed under the Apache License, Version 2.0 (the "License"); 1423 * you may not use this file except in compliance with the License. 1424 * You may obtain a copy of the License at 1425 * 1426 * http://www.apache.org/licenses/LICENSE-2.0 1427 * 1428 * Unless required by applicable law or agreed to in writing, software 1429 * distributed under the License is distributed on an "AS IS" BASIS, 1430 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1431 * See the License for the specific language governing permissions and 1432 * limitations under the License. 1433 */class Ks{constructor(e,t,s,r){this.It=e,this.removedTargetIds=t,this.key=s,this.Tt=r}}class hd{constructor(e,t){this.targetId=e,this.Et=t}}class dd{constructor(e,t,s=ae.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=s,this.cause=r}}class Bc{constructor(){this.At=0,this.Rt=qc(),this.bt=ae.EMPTY_BYTE_STRING,this.Pt=!1,this.vt=!0}get current(){return this.Pt}get resumeToken(){return this.bt}get Vt(){return this.At!==0}get St(){return this.vt}Dt(e){e.approximateByteSize()>0&&(this.vt=!0,this.bt=e)}Ct(){let e=N(),t=N(),s=N();return this.Rt.forEach((r,i)=>{switch(i){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:s=s.add(r);break;default:I()}}),new Ts(this.bt,this.Pt,e,t,s)}xt(){this.vt=!1,this.Rt=qc()}Nt(e,t){this.vt=!0,this.Rt=this.Rt.insert(e,t)}kt(e){this.vt=!0,this.Rt=this.Rt.remove(e)}Ot(){this.At+=1}Mt(){this.At-=1}Ft(){this.vt=!0,this.Pt=!0}}
1433class Qv{constructor(e){this.$t=e,this.Bt=new Map,this.Lt=Te(),this.qt=$c(),this.Ut=new L(D)}Kt(e){for(const t of e.It)e.Tt&&e.Tt.isFoundDocument()?this.Gt(t,e.Tt):this.Qt(t,e.key,e.Tt);for(const t of e.removedTargetIds)this.Qt(t,e.key,e.Tt)}jt(e){this.forEachTarget(e,t=>{const s=this.Wt(t);switch(e.state){case 0:this.zt(t)&&s.Dt(e.resumeToken);break;case 1:s.Mt(),s.Vt||s.xt(),s.Dt(e.resumeToken);break;case 2:s.Mt(),s.Vt||this.removeTarget(t);break;case 3:this.zt(t)&&(s.Ft(),s.Dt(e.resumeToken));break;case 4:this.zt(t)&&(this.Ht(t),s.Dt(e.resumeToken));break;default:I()}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Bt.forEach((s,r)=>{this.zt(r)&&t(r)})}Jt(e){const t=e.targetId,s=e.Et.count,r=this.Yt(t);if(r){const i=r.target;if(fr(i))if(s===0){const o=new w(i.path);this.Qt(t,o,z.newNoDocument(o,_.min()))}else b(s===1);else this.Xt(t)!==s&&(this.Ht(t),this.Ut=this.Ut.add(t))}}Zt(e){const t=new Map;this.Bt.forEach((i,o)=>{const a=this.Yt(o);if(a){if(i.current&&fr(a.target)){const c=new w(a.target.path);this.Lt.get(c)!==null||this.te(o,c)||this.Qt(o,c,z.newNoDocument(c,e))}i.St&&(t.set(o,i.Ct()),i.xt())}});let s=N();this.qt.forEach((i,o)=>{let a=!0;o.forEachWhile(c=>{const u=this.Yt(c);return!u||u.purpose===2||(a=!1,!1)}),a&&(s=s.add(i))}),this.Lt.forEach((i,o)=>o.setReadTime(e));const r=new ei(e,t,this.Ut,this.Lt,s);return this.Lt=Te(),this.qt=$c(),this.Ut=new L(D),r}Gt(e,t){if(!this.zt(e))return;const s=this.te(e,t.key)?2:0;this.Wt(e).Nt(t.key,s),this.Lt=this.Lt.insert(t.key,t),this.qt=this.qt.insert(t.key,this.ee(t.key).add(e))}Qt(e,t,s){if(!this.zt(e))return;const r=this.Wt(e);this.te(e,t)?r.Nt(t,1):r.kt(t),this.qt=this.qt.insert(t,this.ee(t).delete(e)),s&&(this.Lt=this.Lt.insert(t,s))}removeTarget(e){this.Bt.delete(e)}Xt(e){const t=this.Wt(e).Ct();return this.$t.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ot(e){this.Wt(e).Ot()}Wt(e){let t=this.Bt.get(e);return t||(t=new Bc,this.Bt.set(e,t)),t}ee(e){let t=this.qt.get(e);return t||(t=new L(D),this.qt=this.qt.insert(e,t)),t}zt(e){const t=this.Yt(e)!==null;return t||g("WatchChangeAggregator","Detected inactive target",e),t}Yt(e){const t=this.Bt.get(e);return t&&t.Vt?null:this.$t.ne(e)}Ht(e){this.Bt.set(e,new Bc),this.$t.getRemoteKeysForTarget(e).forEach(t=>{this.Qt(e,t,null)})}te(e,t){return this.$t.getRemoteKeysForTarget(e).has(t)}}function $c(){return new Y(w.comparator)}function qc(){return new Y(w.comparator)}/** 1434 * @license 1435 * Copyright 2017 Google LLC 1436 * 1437 * Licensed under the Apache License, Version 2.0 (the "License"); 1438 * you may not use this file except in compliance with the License. 1439 * You may obtain a copy of the License at 1440 * 1441 * http://www.apache.org/licenses/LICENSE-2.0 1442 * 1443 * Unless required by applicable law or agreed to in writing, software 1444 * distributed under the License is distributed on an "AS IS" BASIS, 1445 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1446 * See the License for the specific language governing permissions and 1447 * limitations under the License. 1448 */const Yv=(()=>({asc:"ASCENDING",desc:"DESCENDING"}))(),Xv=(()=>({"<":"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"}))(),Jv=(()=>({and:"AND",or:"OR"}))();class Zv{constructor(e,t){this.databaseId=e,this.wt=t}}function pn(n,e){return n.wt?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function fd(n,e){return n.wt?e.toBase64():e.toUint8Array()}function ew(n,e){return pn(n,e.toTimestamp())}function ge(n){return b(!!n),_.fromTimestamp(function(e){const t=ot(e);return new j(t.seconds,t.nanos)}(n))}function oa(n,e){return function(t){return new M(["projects",t.projectId,"databases",t.database])}(n).child("documents").child(e).canonicalString()}function pd(n){const e=M.fromString(n);return b(Ed(e)),e}function mr(n,e){return oa(n.databaseId,e.path)}function kt(n,e){const t=pd(e);if(t.get(1)!==n.databaseId.projectId)throw new v(p.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new v(p.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new w(gd(t))}function po(n,e){return oa(n.databaseId,e)}function md(n){const e=pd(n);return e.length===4?M.emptyPath():gd(e)}function mo(n){return new M(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function gd(n){return b(n.length>4&&n.get(4)==="documents"),n.popFirst(5)}function jc(n,e,t){return{name:mr(n,e),fields:t.value.mapValue.fields}}function tw(n,e,t){const s=kt(n,e.name),r=ge(e.updateTime),i=e.createTime?ge(e.createTime):_.min(),o=new ue({mapValue:{fields:e.fields}}),a=z.newFoundDocument(s,r,i,o);return t&&a.setHasCommittedMutations(),t?a.setHasCommittedMutations():a}function nw(n,e){let t;if("targetChange"in e){e.targetChange;const s=function(c){return c==="NO_CHANGE"?0:c==="ADD"?1:c==="REMOVE"?2:c==="CURRENT"?3:c==="RESET"?4:I()}(e.targetChange.targetChangeType||"NO_CHANGE"),r=e.targetChange.targetIds||[],i=function(c,u){return c.wt?(b(u===void 0||typeof u=="string"),ae.fromBase64String(u||"")):(b(u===void 0||u instanceof Uint8Array),ae.fromUint8Array(u||new Uint8Array))}(n,e.targetChange.resumeToken),o=e.targetChange.cause,a=o&&function(c){const u=c.code===void 0?p.UNKNOWN:od(c.code);return new v(u,c.message||"")}(o);t=new dd(s,r,i,a||null)}else if("documentChange"in e){e.documentChange;const s=e.documentChange;s.document,s.document.name,s.document.updateTime;const r=kt(n,s.document.name),i=ge(s.document.updateTime),o=s.document.createTime?ge(s.document.createTime):_.min(),a=new ue({mapValue:{fields:s.document.fields}}),c=z.newFoundDocument(r,i,o,a),u=s.targetIds||[],l=s.removedTargetIds||[];t=new Ks(u,l,c.key,c)}else if("documentDelete"in e){e.documentDelete;const s=e.documentDelete;s.document;const r=kt(n,s.document),i=s.readTime?ge(s.readTime):_.min(),o=z.newNoDocument(r,i),a=s.removedTargetIds||[];t=new Ks([],a,o.key,o)}else if("documentRemove"in e){e.documentRemove;const s=e.documentRemove;s.document;const r=kt(n,s.document),i=s.removedTargetIds||[];t=new Ks([],i,r,null)}else{if(!("filter"in e))return I();{e.filter;const s=e.filter;s.targetId;const r=s.count||0,i=new jv(r),o=s.targetId;t=new hd(o,i)}}return t}function gr(n,e){let t;if(e instanceof En)t={update:jc(n,e.key,e.value)};else if(e instanceof Is)t={delete:mr(n,e.key)};else if(e instanceof He)t={update:jc(n,e.key,e.data),updateMask:cw(e.fieldMask)};else{if(!(e instanceof id))return I();t={verify:mr(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map(s=>function(r,i){const o=i.transform;if(o instanceof hn)return{fieldPath:i.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(o instanceof dn)return{fieldPath:i.field.canonicalString(),appendMissingElements:{values:o.elements}};if(o instanceof fn)return{fieldPath:i.field.canonicalString(),removeAllFromArray:{values:o.elements}};if(o instanceof ss)return{fieldPath:i.field.canonicalString(),increment:o.gt};throw I()}(0,s))),e.precondition.isNone||(t.currentDocument=function(s,r){return r.updateTime!==void 0?{updateTime:ew(s,r.updateTime)}:r.exists!==void 0?{exists:r.exists}:I()}(n,e.precondition)),t}function go(n,e){const t=e.currentDocument?function(r){return r.updateTime!==void 0?J.updateTime(ge(r.updateTime)):r.exists!==void 0?J.exists(r.exists):J.none()}(e.currentDocument):J.none(),s=e.updateTransforms?e.updateTransforms.map(r=>function(i,o){let a=null;if("setToServerValue"in o)b(o.setToServerValue==="REQUEST_TIME"),a=new hn;else if("appendMissingElements"in o){const u=o.appendMissingElements.values||[];a=new dn(u)}else if("removeAllFromArray"in o){const u=o.removeAllFromArray.values||[];a=new fn(u)}else"increment"in o?a=new ss(i,o.increment):I();const c=Q.fromServerFormat(o.fieldPath);return new nd(c,a)}(n,r)):[];if(e.update){e.update.name;const r=kt(n,e.update.name),i=new ue({mapValue:{fields:e.update.fields}});if(e.updateMask){const o=function(a){const c=a.fieldPaths||[];return new we(c.map(u=>Q.fromServerFormat(u)))}(e.updateMask);return new He(r,i,o,t,s)}return new En(r,i,t,s)}if(e.delete){const r=kt(n,e.delete);return new Is(r,t)}if(e.verify){const r=kt(n,e.verify);return new id(r,t)}return I()}function sw(n,e){return n&&n.length>0?(b(e!==void 0),n.map(t=>function(s,r){let i=s.updateTime?ge(s.updateTime):ge(r);return i.isEqual(_.min())&&(i=ge(r)),new Bv(i,s.transformResults||[])}(t,e))):[]}function yd(n,e){return{documents:[po(n,e.path)]}}function vd(n,e){const t={structuredQuery:{}},s=e.path;e.collectionGroup!==null?(t.parent=po(n,s),t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(t.parent=po(n,s.popLast()),t.structuredQuery.from=[{collectionId:s.lastSegment()}]);const r=function(c){if(c.length!==0)return Td(P.create(c,"and"))}(e.filters);r&&(t.structuredQuery.where=r);const i=function(c){if(c.length!==0)return c.map(u=>function(l){return{field:Qt(l.field),direction:iw(l.dir)}}(u))}(e.orderBy);i&&(t.structuredQuery.orderBy=i);const o=function(c,u){return c.wt||Qr(u)?u:{value:u}}(n,e.limit);var a;return o!==null&&(t.structuredQuery.limit=o),e.startAt&&(t.structuredQuery.startAt={before:(a=e.startAt).inclusive,values:a.position}),e.endAt&&(t.structuredQuery.endAt=function(c){return{before:!c.inclusive,values:c.position}}(e.endAt)),t}function wd(n){let e=md(n.parent);const t=n.structuredQuery,s=t.from?t.from.length:0;let r=null;if(s>0){b(s===1);const l=t.from[0];l.allDescendants?r=l.collectionId:e=e.child(l.collectionId)}let i=[];t.where&&(i=function(l){const h=Id(l);return h instanceof P&&ra(h)?h.getFilters():[h]}(t.where));let o=[];t.orderBy&&(o=t.orderBy.map(l=>function(h){return new Zt(Yt(h.field),function(d){switch(d){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(h.direction))}(l)));let a=null;t.limit&&(a=function(l){let h;return h=typeof l=="object"?l.value:l,Qr(h)?null:h}(t.limit));let c=null;t.startAt&&(c=function(l){const h=!!l.before,d=l.values||[];return new un(d,h)}(t.startAt));let u=null;return t.endAt&&(u=function(l){const h=!l.before,d=l.values||[];return new un(d,h)}(t.endAt)),Ov(e,r,o,i,a,"F",c,u)}function rw(n,e){const t=function(s,r){switch(r){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return I()}}(0,e.purpose);return t==null?null:{"goog-listen-tags":t}}function Id(n){return n.unaryFilter!==void 0?function(e){switch(e.unaryFilter.op){case"IS_NAN":const t=Yt(e.unaryFilter.field);return x.create(t,"==",{doubleValue:NaN});case"IS_NULL":const s=Yt(e.unaryFilter.field);return x.create(s,"==",{nullValue:"NULL_VALUE"});
1448case"IS_NOT_NAN":const r=Yt(e.unaryFilter.field);return x.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const i=Yt(e.unaryFilter.field);return x.create(i,"!=",{nullValue:"NULL_VALUE"});default:return I()}}(n):n.fieldFilter!==void 0?function(e){return x.create(Yt(e.fieldFilter.field),function(t){switch(t){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return I()}}(e.fieldFilter.op),e.fieldFilter.value)}(n):n.compositeFilter!==void 0?function(e){return P.create(e.compositeFilter.filters.map(t=>Id(t)),function(t){switch(t){case"AND":return"and";case"OR":return"or";default:return I()}}(e.compositeFilter.op))}(n):I()}function iw(n){return Yv[n]}function ow(n){return Xv[n]}function aw(n){return Jv[n]}function Qt(n){return{fieldPath:n.canonicalString()}}function Yt(n){return Q.fromServerFormat(n.fieldPath)}function Td(n){return n instanceof x?function(e){if(e.op==="=="){if(Cc(e.value))return{unaryFilter:{field:Qt(e.field),op:"IS_NAN"}};if(Ac(e.value))return{unaryFilter:{field:Qt(e.field),op:"IS_NULL"}}}else if(e.op==="!="){if(Cc(e.value))return{unaryFilter:{field:Qt(e.field),op:"IS_NOT_NAN"}};if(Ac(e.value))return{unaryFilter:{field:Qt(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Qt(e.field),op:ow(e.op),value:e.value}}}(n):n instanceof P?function(e){const t=e.getFilters().map(s=>Td(s));return t.length===1?t[0]:{compositeFilter:{op:aw(e.op),filters:t}}}(n):I()}function cw(n){const e=[];return n.fields.forEach(t=>e.push(t.canonicalString())),{fieldPaths:e}}function Ed(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}/** 1449 * @license 1450 * Copyright 2017 Google LLC 1451 * 1452 * Licensed under the Apache License, Version 2.0 (the "License"); 1453 * you may not use this file except in compliance with the License. 1454 * You may obtain a copy of the License at 1455 * 1456 * http://www.apache.org/licenses/LICENSE-2.0 1457 * 1458 * Unless required by applicable law or agreed to in writing, software 1459 * distributed under the License is distributed on an "AS IS" BASIS, 1460 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1461 * See the License for the specific language governing permissions and 1462 * limitations under the License. 1463 */function ye(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=Gc(e)),e=uw(n.get(t),e);return Gc(e)}function uw(n,e){let t=e;const s=n.length;for(let r=0;r<s;r++){const i=n.charAt(r);switch(i){case"\0":t+="��";break;case"�":t+="��";break;default:t+=i}}return t}function Gc(n){return n+"��"}function Pe(n){const e=n.length;if(b(e>=2),e===2)return b(n.charAt(0)==="�"&&n.charAt(1)==="�"),M.emptyPath();const t=e-2,s=[];let r="";for(let i=0;i<e;){const o=n.indexOf("�",i);switch((o<0||o>t)&&I(),n.charAt(o+1)){case"�":const a=n.substring(i,o);let c;r.length===0?c=a:(r+=a,c=r,r=""),s.push(c);break;case"�":r+=n.substring(i,o),r+="\0";break;case"�":r+=n.substring(i,o+1);break;default:I()}i=o+2}return new M(s)}/** 1464 * @license 1465 * Copyright 2022 Google LLC 1466 * 1467 * Licensed under the Apache License, Version 2.0 (the "License"); 1468 * you may not use this file except in compliance with the License. 1469 * You may obtain a copy of the License at 1470 * 1471 * http://www.apache.org/licenses/LICENSE-2.0 1472 * 1473 * Unless required by applicable law or agreed to in writing, software 1474 * distributed under the License is distributed on an "AS IS" BASIS, 1475 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1476 * See the License for the specific language governing permissions and 1477 * limitations under the License. 1478 */const Kc=["userId","batchId"];/** 1479 * @license 1480 * Copyright 2022 Google LLC 1481 * 1482 * Licensed under the Apache License, Version 2.0 (the "License"); 1483 * you may not use this file except in compliance with the License. 1484 * You may obtain a copy of the License at 1485 * 1486 * http://www.apache.org/licenses/LICENSE-2.0 1487 * 1488 * Unless required by applicable law or agreed to in writing, softw
1488are 1489 * distributed under the License is distributed on an "AS IS" BASIS, 1490 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1491 * See the License for the specific language governing permissions and 1492 * limitations under the License. 1493 */function zs(n,e){return[n,ye(e)]}function bd(n,e,t){return[n,ye(e),t]}const lw={},hw=["prefixPath","collectionGroup","readTime","documentId"],dw=["prefixPath","collectionGroup","documentId"],fw=["collectionGroup","readTime","prefixPath","documentId"],pw=["canonicalId","targetId"],mw=["targetId","path"],gw=["path","targetId"],yw=["collectionId","parent"],vw=["indexId","uid"],ww=["uid","sequenceNumber"],Iw=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],Tw=["indexId","uid","orderedDocumentKey"],Ew=["userId","collectionPath","documentId"],bw=["userId","collectionPath","largestBatchId"],_w=["userId","collectionGroup","largestBatchId"],_d=["mutationQueues","mutations","documentMutations","remoteDocuments","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries"],Sw=[..._d,"documentOverlays"],Sd=["mutationQueues","mutations","documentMutations","remoteDocumentsV14","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries","documentOverlays"],Ad=Sd,Aw=[...Ad,"indexConfiguration","indexState","indexEntries"];/** 1494 * @license 1495 * Copyright 2020 Google LLC 1496 * 1497 * Licensed under the Apache License, Version 2.0 (the "License"); 1498 * you may not use this file except in compliance with the License. 1499 * You may obtain a copy of the License at 1500 * 1501 * http://www.apache.org/licenses/LICENSE-2.0 1502 * 1503 * Unless required by applicable law or agreed to in writing, software 1504 * distributed under the License is distributed on an "AS IS" BASIS, 1505 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1506 * See the License for the specific language governing permissions and 1507 * limitations under the License. 1508 */class yo extends Mh{constructor(e,t){super(),this.se=e,this.currentSequenceNumber=t}}function ne(n,e){const t=k(n);return qe.M(t.se,e)}/** 1509 * @license 1510 * Copyright 2017 Google LLC 1511 * 1512 * Licensed under the Apache License, Version 2.0 (the "License"); 1513 * you may not use this file except in compliance with the License. 1514 * You may obtain a copy of the License at 1515 * 1516 * http://www.apache.org/licenses/LICENSE-2.0 1517 * 1518 * Unless required by applicable law or agreed to in writing, software 1519 * distributed under the License is distributed on an "AS IS" BASIS, 1520 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1521 * See the License for the specific language governing permissions and 1522 * limitations under the License. 1523 */class aa{constructor(e,t,s,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=s,this.mutations=r}applyToRemoteDocument(e,t){const s=t.mutationResults;for(let r=0;r<this.mutations.length;r++){const i=this.mutations[r];i.key.isEqual(e.key)&&$v(i,e,s[r])}}applyToLocalView(e,t){for(const s of this.baseMutations)s.key.isEqual(e.key)&&(t=$n(s,e,t,this.localWriteTime));for(const s of this.mutations)s.key.isEqual(e.key)&&(t=$n(s,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const s=ud();return this.mutations.forEach(r=>{const i=e.get(r.key),o=i.overlayedDocument;let a=this.applyToLocalView(o,i.mutatedFields);a=t.has(r.key)?null:a;const c=sd(o,a);c!==null&&s.set(r.key,c),o.isValidDocument()||o.convertToNoDocument(_.min())}),s}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),N())}isEqual(e){return this.batchId===e.batchId&&an(this.mutations,e.mutations,(t,s)=>Fc(t,s))&&an(this.baseMutations,e.baseMutations,(t,s)=>Fc(t,s))}}class ca{constructor(e,t,s,r){this.batch=e,this.commitVersion=t,this.mutationResults=s,this.docVersions=r}static from(e,t,s){b(e.mutations.length===s.length);let r=zv;const i=e.mutations;for(let o=0;o<i.length;o++)r=r.insert(i[o].key,s[o].version);return new ca(e,t,s,r)}}/** 1524 * @license 1525 * Copyright 2022 Google LLC 1526 * 1527 * Licensed under the Apache License, Version 2.0 (the "License");
1528 * you may not use this file except in compliance with the License. 1529 * You may obtain a copy of the License at 1530 * 1531 * http://www.apache.org/licenses/LICENSE-2.0 1532 * 1533 * Unless required by applicable law or agreed to in writing, software 1534 * distributed under the License is distributed on an "AS IS" BASIS, 1535 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1536 * See the License for the specific language governing permissions and 1537 * limitations under the License. 1538 */class ua{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{ 1539 largestBatchId: ${this.largestBatchId}, 1540 mutation: ${this.mutation.toString()} 1541 }`}}/** 1542 * @license 1543 * Copyright 2017 Google LLC 1544 * 1545 * Licensed under the Apache License, Version 2.0 (the "License"); 1546 * you may not use this file except in compliance with the License. 1547 * You may obtain a copy of the License at 1548 * 1549 * http://www.apache.org/licenses/LICENSE-2.0 1550 * 1551 * Unless required by applicable law or agreed to in writing, software 1552 * distributed under the License is distributed on an "AS IS" BASIS, 1553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1554 * See the License for the specific language governing permissions and 1555 * limitations under the License. 1556 */class rt{constructor(e,t,s,r,i=_.min(),o=_.min(),a=ae.EMPTY_BYTE_STRING){this.target=e,this.targetId=t,this.purpose=s,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=a}withSequenceNumber(e){return new rt(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)}withResumeToken(e,t){return new rt(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e)}withLastLimboFreeSnapshotVersion(e){return new rt(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken)}}/** 1557 * @license 1558 * Copyright 2017 Google LLC 1559 * 1560 * Licensed under the Apache License, Version 2.0 (the "License"); 1561 * you may not use this file except in compliance with the License. 1562 * You may obtain a copy of the License at 1563 * 1564 * http://www.apache.org/licenses/LICENSE-2.0 1565 * 1566 * Unless required by applicable law or agreed to in writing, software 1567 * distributed under the License is distributed on an "AS IS" BASIS, 1568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1569 * See the License for the specific language governing permissions and 1570 * limitations under the License. 1571 */class Cd{constructor(e){this.ie=e}}function Cw(n,e){let t;if(e.document)t=tw(n.ie,e.document,!!e.hasCommittedMutations);else if(e.noDocument){const s=w.fromSegments(e.noDocument.path),r=Ut(e.noDocument.readTime);t=z.newNoDocument(s,r),e.hasCommittedMutations&&t.setHasCommittedMutations()}else{if(!e.unknownDocument)return I();{const s=w.fromSegments(e.unknownDocument.path),r=Ut(e.unknownDocument.version);t=z.newUnknownDocument(s,r)}}return e.readTime&&t.setReadTime(function(s){const r=new j(s[0],s[1]);return _.fromTimestamp(r)}(e.readTime)),t}function zc(n,e){const t=e.key,s={prefixPath:t.getCollectionPath().popLast().toArray(),collectionGroup:t.collectionGroup,documentId:t.path.lastSegment(),readTime:yr(e.readTime),hasCommittedMutations:e.hasCommittedMutations};if(e.isFoundDocument())s.document=function(r,i){return{name:mr(r,i.key),fields:i.data.value.mapValue.fields,updateTime:pn(r,i.version.toTimestamp()),createTime:pn(r,i.createTime.toTimestamp())}}(n.ie,e);else if(e.isNoDocument())s.noDocument={path:t.path.toArray(),readTime:Vt(e.version)};else{if(!e.isUnknownDocument())return I();s.unknownDocument={path:t.path.toArray(),version:Vt(e.version)}}return s}function yr(n){const e=n.toTimestamp();return[e.seconds,e.nanoseconds]}function Vt(n){const e=n.toTimestamp();return{seconds:e.seconds,nanoseconds:e.nanoseconds}}function Ut(n){const e=new j(n.seconds,n.nanoseconds);return _.fromTimestamp(e)}function It(n,e){const t=(e.baseMutations||[]).map(i=>go(n.ie,i));for(let i=0;i<e.mutations.length-1;++i){const o=e.mutations[i];if(i+1<e.mutations.length&&e.mutations[i+1].transform!==void 0){const a=e.mutations[i+1];o.updateTransforms=a.transform.fieldTransforms,e.mutations.splice(i+1,1),++i}}const s=e.mutations.map(i=>go(n.ie,i)),r=j.fromMillis(e.localWriteTimeMs);return new aa(e.batchId,r,t,s)}function Pn(n){const e=Ut(n.readTime),t=n.lastLimboFreeSnapshotVersion!==void 0?Ut(n.lastLimboFreeSnapshotVersion):_.min();let s;var r;return n.query.documents!==void 0?(b((r=n.query).documents.length===1),s=xe(vs(md(r.documents[0])))):s=function(i){return xe(wd(i))}(n.query),new rt(s,n.targetId,0,n.lastListenSequenceNumber,e,t,ae.fromBase64String(n.resumeToken))}function kd(n,e){const t=Vt(e.snapshotVersion),s=Vt(e.lastLimboFreeSnapshotVersion);let r;r=fr(e.target)?yd(n.ie,e.target):vd(n.ie,e.target);const i=e.resumeToken.toBase64();return{targetId:e.targetId,canonicalId:Ft(e.target),readTime:t,resumeToken:i,lastListenSequenceNumber:e.sequenceNumber,lastLimboFreeSnapshotVersion:s,query:r}}function Dd(n){const e=wd({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?ho(e,e.limit,"L"):e}function Pi(n,e){return new ua(e.largestBatchId,go(n.ie,e.overlayMutation))}function Hc(n,e){const t=e.path.lastSegment();return[n,ye(e.path.popLast()),t]}function Wc(n,e,t,s){return{indexId:n,uid:e.uid||"",sequenceNumber:t,readTime:Vt(s.readTime),documentKey:ye(s.documentKey.path),largestBatchId:s.largestBatchId}}/** 1572 * @license 1573 * Copyright 2020 Google LLC 1574 * 1575 * Licensed under the Apache License, Version 2.0 (the "License");
1576 * you may not use this file except in compliance with the License. 1577 * You may obtain a copy of the License at 1578 * 1579 * http://www.apache.org/licenses/LICENSE-2.0 1580 * 1581 * Unless required by applicable law or agreed to in writing, software 1582 * distributed under the License is distributed on an "AS IS" BASIS, 1583 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1584 * See the License for the specific language governing permissions and 1585 * limitations under the License. 1586 */class kw{getBundleMetadata(e,t){return Qc(e).get(t).next(s=>{if(s)return{id:(r=s).bundleId,createTime:Ut(r.createTime),version:r.version};var r})}saveBundleMetadata(e,t){return Qc(e).put({bundleId:(s=t).id,createTime:Vt(ge(s.createTime)),version:s.version});var s}getNamedQuery(e,t){return Yc(e).get(t).next(s=>{if(s)return{name:(r=s).name,query:Dd(r.bundledQuery),readTime:Ut(r.readTime)};var r})}saveNamedQuery(e,t){return Yc(e).put(function(s){return{name:s.name,readTime:Vt(ge(s.readTime)),bundledQuery:s.bundledQuery}}(t))}}function Qc(n){return ne(n,"bundles")}function Yc(n){return ne(n,"namedQueries")}/** 1587 * @license 1588 * Copyright 2022 Google LLC 1589 * 1590 * Licensed under the Apache License, Version 2.0 (the "License"); 1591 * you may not use this file except in compliance with the License. 1592 * You may obtain a copy of the License at 1593 * 1594 * http://www.apache.org/licenses/LICENSE-2.0 1595 * 1596 * Unless required by applicable law or agreed to in writing, software 1597 * distributed under the License is distributed on an "AS IS" BASIS, 1598 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1599 * See the License for the specific language governing permissions and 1600 * limitations under the License. 1601 */class ti{constructor(e,t){this.yt=e,this.userId=t}static re(e,t){const s=t.uid||"";
1601return new ti(e,s)}getOverlay(e,t){return An(e).get(Hc(this.userId,t)).next(s=>s?Pi(this.yt,s):null)}getOverlays(e,t){const s=Me();return f.forEach(t,r=>this.getOverlay(e,r).next(i=>{i!==null&&s.set(r,i)})).next(()=>s)}saveOverlays(e,t,s){const r=[];return s.forEach((i,o)=>{const a=new ua(t,o);r.push(this.oe(e,a))}),f.waitFor(r)}removeOverlaysForBatchId(e,t,s){const r=new Set;t.forEach(o=>r.add(ye(o.getCollectionPath())));const i=[];return r.forEach(o=>{const a=IDBKeyRange.bound([this.userId,o,s],[this.userId,o,s+1],!1,!0);i.push(An(e).Y("collectionPathOverlayIndex",a))}),f.waitFor(i)}getOverlaysForCollection(e,t,s){const r=Me(),i=ye(t),o=IDBKeyRange.bound([this.userId,i,s],[this.userId,i,Number.POSITIVE_INFINITY],!0);return An(e).W("collectionPathOverlayIndex",o).next(a=>{for(const c of a){const u=Pi(this.yt,c);r.set(u.getKey(),u)}return r})}getOverlaysForCollectionGroup(e,t,s,r){const i=Me();let o;const a=IDBKeyRange.bound([this.userId,t,s],[this.userId,t,Number.POSITIVE_INFINITY],!0);return An(e).Z({index:"collectionGroupOverlayIndex",range:a},(c,u,l)=>{const h=Pi(this.yt,u);i.size()<r||h.largestBatchId===o?(i.set(h.getKey(),h),o=h.largestBatchId):l.done()}).next(()=>i)}oe(e,t){return An(e).put(function(s,r,i){const[o,a,c]=Hc(r,i.mutation.key);return{userId:r,collectionPath:a,documentId:c,collectionGroup:i.mutation.key.getCollectionGroup(),largestBatchId:i.largestBatchId,overlayMutation:gr(s.ie,i.mutation)}}(this.yt,this.userId,t))}}function An(n){return ne(n,"documentOverlays")}/** 1602 * @license 1603 * Copyright 2021 Google LLC 1604 * 1605 * Licensed under the Apache License, Version 2.0 (the "License"); 1606 * you may not use this file except in compliance with the License. 1607 * You may obtain a copy of the License at 1608 * 1609 * http://www.apache.org/licenses/LICENSE-2.0 1610 * 1611 * Unless required by applicable law or agreed to in writing, software 1612 * distributed under the License is distributed on an "AS IS" BASIS, 1613 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1614 * See the License for the specific language governing permissions and 1615 * limitations under the License. 1616 */class Tt{constructor(){}ue(e,t){this.ce(e,t),t.ae()}ce(e,t){if("nullValue"in e)this.he(t,5);else if("booleanValue"in e)this.he(t,10),t.le(e.booleanValue?1:0);else if("integerValue"in e)this.he(t,15),t.le(K(e.integerValue));else if("doubleValue"in e){const s=K(e.doubleValue);isNaN(s)?this.he(t,13):(this.he(t,15),Jn(s)?t.le(0):t.le(s))}else if("timestampValue"in e){const s=e.timestampValue;this.he(t,20),typeof s=="string"?t.fe(s):(t.fe(`${s.seconds||""}`),t.le(s.nanos||0))}else if("stringValue"in e)this.de(e.stringValue,t),this._e(t);else if("bytesValue"in e)this.he(t,30),t.we(Pt(e.bytesValue)),this._e(t);else if("referenceValue"in e)this.me(e.referenceValue,t);else if("geoPointValue"in e){const s=e.geoPointValue;this.he(t,45),t.le(s.latitude||0),t.le(s.longitude||0)}else"mapValue"in e?Vh(e)?this.he(t,Number.MAX_SAFE_INTEGER):(this.ge(e.mapValue,t),this._e(t)):"arrayValue"in e?(this.ye(e.arrayValue,t),this._e(t)):I()}de(e,t){this.he(t,25),this.pe(e,t)}pe(e,t){t.fe(e)}ge(e,t){const s=e.fields||{};this.he(t,55);for(const r of Object.keys(s))this.de(r,t),this.ce(s[r],t)}ye(e,t){const s=e.values||[];this.he(t,50);for(const r of s)this.ce(r,t)}me(e,t){this.he(t,37),w.fromName(e).path.forEach(s=>{this.he(t,60),this.pe(s,t)})}he(e,t){e.le(t)}_e(e){e.le(2)}}Tt.Ie=new Tt;function Dw(n){if(n===0)return 8;let e=0;return!(n>>4)&&(e+=4,n<<=4),!(n>>6)&&(e+=2,n<<=2),!(n>>7)&&(e+=1),e}function Xc(n){const e=64-function(t){let s=0;for(let r=0;r<8;++r){const i=Dw(255&t[r]);if(s+=i,i!==8)break}return s}(n);return Math.ceil(e/8)}class Nw{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Te(e){const t=e[Symbol.iterator]();let s=t.next();for(;!s.done;)this.Ee(s.value),s=t.next();this.Ae()}Re(e){const t=e[Symbol.iterator]();let s=t.next();for(;!s.done;)this.be(s.value),s=t.next();this.Pe()}ve(e){for(const t of e){const s=t.charCodeAt(0);if(s<128)this.Ee(s);else if(s<2048)this.Ee(960|s>>>6),this.Ee(128|63&s);else if(t<"\uD800"||"\uDBFF"<t)this.Ee(480|s>>>12),this.Ee(128|63&s>>>6),this.Ee(128|63&s);else{const r=t.codePointAt(0);this.Ee(240|r>>>18),this.Ee(128|63&r>>>12),this.Ee(128|63&r>>>6),this.Ee(128|63&r)}}this.Ae()}Ve(e){for(const t of e){const s=t.charCodeAt(0);if(s<128)this.be(s);else if(s<2048)this.be(960|s>>>6),this.be(128|63&s);else if(t<"\uD800"||"\uDBFF"<t)this.be(480|s>>>12),this.be(128|63&s>>>6),this.be(128|63&s);else{const r=t.codePointAt(0);this.be(240|r>>>18),this.be(128|63&r>>>12),this.be(128|63&r>>>6),this.be(128|63&r)}}this.Pe()}Se(e){const t=this.De(e),s=Xc(t);this.Ce(1+s),this.buffer[this.position++]=255&s;for(let r=t.length-s;r<t.length;++r)this.buffer[this.position++]=255&t[r]}xe(e){const t=this.De(e),s=Xc(t);this.Ce(1+s),this.buffer[this.position++]=~(255&s);for(let r=t.length-s;r<t.length;++r)this.buffer[this.position++]=~(255&t[r])}Ne(){this.ke(255),this.ke(255)}Oe(){this.Me(255),this.Me(255)}reset(){this.position=0}seed(e){this.Ce(e.length),this.buffer.set(e,this.position),this.position+=e.length}Fe(){return this.buffer.slice(0,this.position)}De(e){const t=function(r){const i=new DataView(new ArrayBuffer(8));return i.setFloat64(0,r,!1),new Uint8Array(i.buffer)}(e),s=(128&t[0])!=0;t[0]^=s?255:128;for(let r=1;r<t.length;++r)t[r]^=s?255:0;return t}Ee(e){const t=255&e;t===0?(this.ke(0),this.ke(255)):t===255?(this.ke(255),this.ke(0)):this.ke(t)}be(e){const t=255&e;t===0?(this.Me(0),this.Me(255)):t===255?(this.Me(255),this.Me(0)):this.Me(e)}Ae(){this.ke(0),this.ke(1)}Pe(){this.Me(0),this.Me(1)}ke(e){this.Ce(1),this.buffer[this.position++]=e}Me(e){this.Ce(1),this.buffer[this.position++]=~e}Ce(e){const t=e+this.position;if(t<=this.buffer.length)return;let s=2*this.buffer.length;s<t&&(s=t);
1616const r=new Uint8Array(s);r.set(this.buffer),this.buffer=r}}class xw{constructor(e){this.$e=e}we(e){this.$e.Te(e)}fe(e){this.$e.ve(e)}le(e){this.$e.Se(e)}ae(){this.$e.Ne()}}class Rw{constructor(e){this.$e=e}we(e){this.$e.Re(e)}fe(e){this.$e.Ve(e)}le(e){this.$e.xe(e)}ae(){this.$e.Oe()}}class Cn{constructor(){this.$e=new Nw,this.Be=new xw(this.$e),this.Le=new Rw(this.$e)}seed(e){this.$e.seed(e)}qe(e){return e===0?this.Be:this.Le}Fe(){return this.$e.Fe()}reset(){this.$e.reset()}}/** 1617 * @license 1618 * Copyright 2022 Google LLC 1619 * 1620 * Licensed under the Apache License, Version 2.0 (the "License"); 1621 * you may not use this file except in compliance with the License. 1622 * You may obtain a copy of the License at 1623 * 1624 * http://www.apache.org/licenses/LICENSE-2.0 1625 * 1626 * Unless required by applicable law or agreed to in writing, software 1627 * distributed under the License is distributed on an "AS IS" BASIS, 1628 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1629 * See the License for the specific language governing permissions and 1630 * limitations under the License. 1631 */class Et{constructor(e,t,s,r){this.indexId=e,this.documentKey=t,this.arrayValue=s,this.directionalValue=r}Ue(){const e=this.directionalValue.length,t=e===0||this.directionalValue[e-1]===255?e+1:e,s=new Uint8Array(t);return s.set(this.directionalValue,0),t!==e?s.set([0],this.directionalValue.length):++s[s.length-1],new Et(this.indexId,this.documentKey,this.arrayValue,s)}}function We(n,e){let t=n.indexId-e.indexId;return t!==0?t:(t=Jc(n.arrayValue,e.arrayValue),t!==0?t:(t=Jc(n.directionalValue,e.directionalValue),t!==0?t:w.comparator(n.documentKey,e.documentKey)))}function Jc(n,e){for(let t=0;t<n.length&&t<e.length;++t){const s=n[t]-e[t];if(s!==0)return s}return n.length-e.length}/** 1632 * @license 1633 * Copyright 2022 Google LLC 1634 * 1635 * Licensed under the Apache License, Version 2.0 (the "License"); 1636 * you may not use this file except in compliance with the License. 1637 * You may obtain a copy of the License at 1638 * 1639 * http://www.apache.org/licenses/LICENSE-2.0 1640 * 1641 * Unless required by applicable law or agreed to in writing, software 1642 * distributed under the License is distributed on an "AS IS" BASIS, 1643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1644 * See the License for the specific language governing permissions and 1645 * limitations under the License. 1646 */class Ow{constructor(e){this.collectionId=e.collectionGroup!=null?e.collectionGroup:e.path.lastSegment(),this.Ke=e.orderBy,this.Ge=[];for(const t of e.filters){const s=t;s.isInequality()?this.Qe=s:this.Ge.push(s)}}je(e){b(e.collectionGroup===this.collectionId);const t=ro(e);if(t!==void 0&&!this.We(t))return!1;const s=vt(e);let r=0,i=0;for(;r<s.length&&this.We(s[r]);++r);if(r===s.length)return!0;if(this.Qe!==void 0){const o=s[r];if(!this.ze(this.Qe,o)||!this.He(this.Ke[i++],o))return!1;++r}for(;r<s.length;++r){const o=s[r];if(i>=this.Ke.length||!this.He(this.Ke[i++],o))return!1}return!0}We(e){for(const t of this.Ge)if(this.ze(t,e))return!0;return!1}ze(e,t){if(e===void 0||!e.field.isEqual(t.fieldPath))return!1;const s=e.op==="array-contains"||e.op==="array-contains-any";return t.kind===2===s}He(e,t){return!!e.field.isEqual(t.fieldPath)&&(t.kind===0&&e.dir==="asc"||t.kind===1&&e.dir==="desc")}}/** 1647 * @license 1648 * Copyright 2022 Google LLC 1649 * 1650 * Licensed under the Apache License, Version 2.0 (the "License"); 1651 * you may not use this file except in compliance with the License. 1652 * You may obtain a copy of the License at 1653 * 1654 * http://www.apache.org/licenses/LICENSE-2.0 1655 * 1656 * Unless required by applicable law or agreed to in writing, software 1657 * distributed under the License is distributed on an "AS IS" BASIS, 1658 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1659 * See the License for the specific language governing permissions and 1660 * limitations under the License. 1661 */function Nd(n){var e,t;if(b(n instanceof x||n instanceof P),n instanceof x){if(n instanceof Kh){const r=((t=(e=n.value.arrayValue)===null||e===void 0?void 0:e.values)===null||t===void 0?void 0:t.map(i=>x.create(n.field,"==",i)))||[];return P.create(r,"or")}return n}const s=n.filters.map(r=>Nd(r));return P.create(s,n.op)}function Mw(n){if(n.getFilters().length===0)return[];const e=Io(Nd(n));return b(xd(e)),vo(e)||wo(e)?[e]:e.getFilters()}function vo(n){return n instanceof x}function wo(n){return n instanceof P&&ra(n)}function xd(n){return vo(n)||wo(n)||function(e){if(e instanceof P&&ao(e)){for(const t of e.getFilters())if(!vo(t)&&!wo(t))return!1;return!0}return!1}(n)}function Io(n){if(b(n instanceof x||n instanceof P),n instanceof x)return n;if(n.filters.length===1)return Io(n.filters[0]);const e=n.filters.map(s=>Io(s));let t=P.create(e,n.op);return t=vr(t),xd(t)?t:(b(t instanceof P),b(ln(t)),b(t.filters.length>1),t.filters.reduce((s,r)=>la(s,r)))}function la(n,e){let t;return b(n instanceof x||n instanceof P),b(e instanceof x||e instanceof P),t=n instanceof x?e instanceof x?function(s,r){return P.create([s,r],"and")}(n,e):Zc(n,e):e instanceof x?Zc(e,n):function(s,r){if(b(s.filters.length>
16610&&r.filters.length>0),ln(s)&&ln(r))return qh(s,r.getFilters());const i=ao(s)?s:r,o=ao(s)?r:s,a=i.filters.map(c=>la(c,o));return P.create(a,"or")}(n,e),vr(t)}function Zc(n,e){if(ln(e))return qh(e,n.getFilters());{const t=e.filters.map(s=>la(n,s));return P.create(t,"or")}}function vr(n){if(b(n instanceof x||n instanceof P),n instanceof x)return n;const e=n.getFilters();if(e.length===1)return vr(e[0]);if(Bh(n))return n;const t=e.map(r=>vr(r)),s=[];return t.forEach(r=>{r instanceof x?s.push(r):r instanceof P&&(r.op===n.op?s.push(...r.filters):s.push(r))}),s.length===1?s[0]:P.create(s,n.op)}/** 1662 * @license 1663 * Copyright 2019 Google LLC 1664 * 1665 * Licensed under the Apache License, Version 2.0 (the "License"); 1666 * you may not use this file except in compliance with the License. 1667 * You may obtain a copy of the License at 1668 * 1669 * http://www.apache.org/licenses/LICENSE-2.0 1670 * 1671 * Unless required by applicable law or agreed to in writing, software 1672 * distributed under the License is distributed on an "AS IS" BASIS, 1673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1674 * See the License for the specific language governing permissions and 1675 * limitations under the License. 1676 */class Pw{constructor(){this.Je=new ha}addToCollectionParentIndex(e,t){return this.Je.add(t),f.resolve()}getCollectionParents(e,t){return f.resolve(this.Je.getEntries(t))}addFieldIndex(e,t){return f.resolve()}deleteFieldIndex(e,t){return f.resolve()}getDocumentsMatchingTarget(e,t){return f.resolve(null)}getIndexType(e,t){return f.resolve(0)}getFieldIndexes(e,t){return f.resolve([])}getNextCollectionGroupToUpdate(e){return f.resolve(null)}getMinOffset(e,t){return f.resolve(_e.min())}getMinOffsetFromCollectionGroup(e,t){return f.resolve(_e.min())}updateCollectionGroup(e,t,s){return f.resolve()}updateIndexEntries(e,t){return f.resolve()}}class ha{constructor(){this.index={}}add(e){const t=e.lastSegment(),s=e.popLast(),r=this.index[t]||new L(M.comparator),i=!r.has(s);return this.index[t]=r.add(s),i}has(e){const t=e.lastSegment(),s=e.popLast(),r=this.index[t];return r&&r.has(s)}getEntries(e){return(this.index[e]||new L(M.comparator)).toArray()}}/** 1677 * @license 1678 * Copyright 2019 Google LLC 1679 * 1680 * Licensed under the Apache License, Version 2.0 (the "License"); 1681 * you may not use this file except in compliance with the License. 1682 * You may obtain a copy of the License at 1683 * 1684 * http://www.apache.org/licenses/LICENSE-2.0 1685 * 1686 * Unless required by applicable law or agreed to in writing, software 1687 * distributed under the License is distributed on an "AS IS" BASIS, 1688 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1689 * See the License for the specific language governing permissions and 1690 * limitations under the License. 1691 */const Fs=new Uint8Array(0);class Lw{constructor(e,t){this.user=e,this.databaseId=t,this.Ye=new ha,this.Xe=new ft(s=>Ft(s),(s,r)=>ys(s,r)),this.uid=e.uid||""}addToCollectionParentIndex(e,t){if(!this.Ye.has(t)){const s=t.lastSegment(),r=t.popLast();e.addOnCommittedListener(()=>{this.Ye.add(t)});const i={collectionId:s,parent:ye(r)};return eu(e).put(i)}return f.resolve()}getCollectionParents(e,t){const s=[],r=IDBKeyRange.bound([t,""],[Nh(t),""],!1,!0);return eu(e).W(r).next(i=>{for(const o of i){if(o.collectionId!==t)break;s.push(Pe(o.parent))}return s})}addFieldIndex(e,t){const s=Vs(e),r=function(o){return{indexId:o.indexId,collectionGroup:o.collectionGroup,fields:o.fields.map(a=>[a.fieldPath.canonicalString(),a.kind])}}(t);delete r.indexId;const i=s.add(r);if(t.indexState){const o=Dn(e);return i.next(a=>{o.put(Wc(a,this.user,t.indexState.sequenceNumber,t.indexState.offset))})}return i.next()}deleteFieldIndex(e,t){const s=Vs(e),r=Dn(e),i=kn(e);return s.delete(t.indexId).next(()=>r.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))).next(()=>i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0)))}getDocumentsMatchingTarget(e,t){const s=kn(e);let r=!0;const i=new Map;return f.forEach(this.Ze(t),o=>this.tn(e,o).next(a=>{r&&(r=!!a),i.set(o,a)})).next(()=>{if(r){let o=N();const a=[];return f.forEach(i,(c,u)=>{var l;g("IndexedDbIndexManager",`Using index ${l=c,`id=${l.indexId}|cg=${l.collectionGroup}|f=${l.fields.map(F=>`${F.fieldPath}:${F.kind}`).join(",")}`} to execute ${Ft(t)}`);const h=function(F,X){const G=ro(X);if(G===void 0)return null;for(const U of pr(F,G.fieldPath))switch(U.op){case"array-contains-any":return U.value.arrayValue.values||[];case"array-contains":return[U.value]}return null}(u,c),d=function(F,X){const G=new Map;for(const U of vt(X))for(const se of pr(F,U.fieldPath))switch(se.op){case"==":case"in":G.set(U.fieldPath.canonicalString(),se.value);break;case"not-in":case"!=":return G.set(U.fieldPath.canonicalString(),se.value),Array.from(G.values())}return null}(u,c),m=function(F,X){const G=[];let U=!0;for(const se of vt(X)){const mt=se.kind===0?Oc(F,se.fieldPath,F.startAt):Mc(F,se.fieldPath,F.startAt);G.push(mt.value),U&&(U=mt.inclusive)}return new un(G,U)}(u,c),y=function(F,X){const G=[];let U=!0;for(const se of vt(X)){const mt=se.kind===0?Mc(F,se.fieldPath,F.endAt):Oc(F,se.fieldPath,F.endAt);G.push(mt.value),U&&(U=mt.inclusive)}return new un(G,U)}(u,c),E=this.en(c,u,m),S=this.en(c,u,y),V=this.nn(c,u,d),B=this.sn(c.indexId,h,E,m.inclusive,S,y.inclusive,V);return f.forEach(B,F=>s.J(F,t.limit).next(X=>
1691{X.forEach(G=>{const U=w.fromSegments(G.documentKey);o.has(U)||(o=o.add(U),a.push(U))})}))}).next(()=>a)}return f.resolve(null)})}Ze(e){let t=this.Xe.get(e);return t||(e.filters.length===0?t=[e]:t=Mw(P.create(e.filters,"and")).map(s=>uo(e.path,e.collectionGroup,e.orderBy,s.getFilters(),e.limit,e.startAt,e.endAt)),this.Xe.set(e,t),t)}sn(e,t,s,r,i,o,a){const c=(t!=null?t.length:1)*Math.max(s.length,i.length),u=c/(t!=null?t.length:1),l=[];for(let h=0;h<c;++h){const d=t?this.rn(t[h/u]):Fs,m=this.on(e,d,s[h%u],r),y=this.un(e,d,i[h%u],o),E=a.map(S=>this.on(e,d,S,!0));l.push(...this.createRange(m,y,E))}return l}on(e,t,s,r){const i=new Et(e,w.empty(),t,s);return r?i:i.Ue()}un(e,t,s,r){const i=new Et(e,w.empty(),t,s);return r?i.Ue():i}tn(e,t){const s=new Ow(t),r=t.collectionGroup!=null?t.collectionGroup:t.path.lastSegment();return this.getFieldIndexes(e,r).next(i=>{let o=null;for(const a of i)s.je(a)&&(!o||a.fields.length>o.fields.length)&&(o=a);return o})}getIndexType(e,t){let s=2;const r=this.Ze(t);return f.forEach(r,i=>this.tn(e,i).next(o=>{o?s!==0&&o.fields.length<function(a){let c=new L(Q.comparator),u=!1;for(const l of a.filters)for(const h of l.getFlattenedFilters())h.field.isKeyField()||(h.op==="array-contains"||h.op==="array-contains-any"?u=!0:c=c.add(h.field));for(const l of a.orderBy)l.field.isKeyField()||(c=c.add(l.field));return c.size+(u?1:0)}(i)&&(s=1):s=0})).next(()=>function(i){return i.limit!==null}(t)&&r.length>1&&s===2?1:s)}cn(e,t){const s=new Cn;for(const r of vt(e)){const i=t.data.field(r.fieldPath);if(i==null)return null;const o=s.qe(r.kind);Tt.Ie.ue(i,o)}return s.Fe()}rn(e){const t=new Cn;return Tt.Ie.ue(e,t.qe(0)),t.Fe()}an(e,t){const s=new Cn;return Tt.Ie.ue(ts(this.databaseId,t),s.qe(function(r){const i=vt(r);return i.length===0?0:i[i.length-1].kind}(e))),s.Fe()}nn(e,t,s){if(s===null)return[];let r=[];r.push(new Cn);let i=0;for(const o of vt(e)){const a=s[i++];for(const c of r)if(this.hn(t,o.fieldPath)&&ns(a))r=this.ln(r,o,a);else{const u=c.qe(o.kind);Tt.Ie.ue(a,u)}}return this.fn(r)}en(e,t,s){return this.nn(e,t,s.position)}fn(e){const t=[];for(let s=0;s<e.length;++s)t[s]=e[s].Fe();return t}ln(e,t,s){const r=[...e],i=[];for(const o of s.arrayValue.values||[])for(const a of r){const c=new Cn;c.seed(a.Fe()),Tt.Ie.ue(o,c.qe(t.kind)),i.push(c)}return i}hn(e,t){return!!e.filters.find(s=>s instanceof x&&s.field.isEqual(t)&&(s.op==="in"||s.op==="not-in"))}getFieldIndexes(e,t){const s=Vs(e),r=Dn(e);return(t?s.W("collectionGroupIndex",IDBKeyRange.bound(t,t)):s.W()).next(i=>{const o=[];return f.forEach(i,a=>r.get([a.indexId,this.uid]).next(c=>{o.push(function(u,l){const h=l?new dr(l.sequenceNumber,new _e(Ut(l.readTime),new w(Pe(l.documentKey)),l.largestBatchId)):dr.empty(),d=u.fields.map(([m,y])=>new pv(Q.fromServerFormat(m),y));return new xh(u.indexId,u.collectionGroup,d,h)}(a,c))})).next(()=>o)})}getNextCollectionGroupToUpdate(e){return this.getFieldIndexes(e).next(t=>t.length===0?null:(t.sort((s,r)=>{const i=s.indexState.sequenceNumber-r.indexState.sequenceNumber;return i!==0?i:D(s.collectionGroup,r.collectionGroup)}),t[0].collectionGroup))}updateCollectionGroup(e,t,s){const r=Vs(e),i=Dn(e);return this.dn(e).next(o=>r.W("collectionGroupIndex",IDBKeyRange.bound(t,t)).next(a=>f.forEach(a,c=>i.put(Wc(c.indexId,this.user,o,s)))))}updateIndexEntries(e,t){const s=new Map;return f.forEach(t,(r,i)=>{const o=s.get(r.collectionGroup);return(o?f.resolve(o):this.getFieldIndexes(e,r.collectionGroup)).next(a=>(s.set(r.collectionGroup,a),f.forEach(a,c=>this._n(e,r,c).next(u=>{const l=this.wn(i,c);return u.isEqual(l)?f.resolve():this.mn(e,i,c,u,l)}))))})}gn(e,t,s,r){return kn(e).put({indexId:r.indexId,uid:this.uid,arrayValue:r.arrayValue,directionalValue:r.directionalValue,orderedDocumentKey:this.an(s,t.key),documentKey:t.key.path.toArray()})}yn(e,t,s,r){return kn(e).delete([r.indexId,this.uid,r.arrayValue,r.directionalValue,this.an(s,t.key),t.key.path.toArray()])}_n(e,t,s){const r=kn(e);let i=new L(We);return r.Z({index:"documentKeyIndex",range:IDBKeyRange.only([s.indexId,this.uid,this.an(s,t)])},(o,a)=>{i=i.add(new Et(s.indexId,t,a.arrayValue,a.directionalValue))}).next(()=>i)}wn(e,t){let s=new L(We);const r=this.cn(t,e);if(r==null)return s;const i=ro(t);if(i!=null){const o=e.data.field(i.fieldPath);if(ns(o))for(const a of o.arrayValue.values||[])s=s.add(new Et(t.indexId,e.key,this.rn(a),r))}else s=s.add(new Et(t.indexId,e.key,Fs,r));return s}mn(e,t,s,r,i){g("IndexedDbIndexManager","Updating index entries for document '%s'",t.key);const o=[];return function(a,c,u,l,h){const d=a.getIterator(),m=c.getIterator();let y=Ht(d),E=Ht(m);for(;y||E;){let S=!1,V=!1;if(y&&E){const B=u(y,E);B<0?V=!0:B>0&&(S=!0)}else y!=null?V=!0:S=!0;S?(l(E),E=Ht(m)):V?(h(y),y=Ht(d)):(y=Ht(d),E=Ht(m))}}(r,i,We,a=>{o.push(this.gn(e,t,s,a))},a=>{o.push(this.yn(e,t,s,a))}),f.waitFor(o)}dn(e){let t=1;return Dn(e).Z({index:"sequenceNumberIndex",reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},(s,r,i)=>{i.done(),t=r.sequenceNumber+1}
1691).next(()=>t)}createRange(e,t,s){s=s.sort((o,a)=>We(o,a)).filter((o,a,c)=>!a||We(o,c[a-1])!==0);const r=[];r.push(e);for(const o of s){const a=We(o,e),c=We(o,t);if(a===0)r[0]=e.Ue();else if(a>0&&c<0)r.push(o),r.push(o.Ue());else if(c>0)break}r.push(t);const i=[];for(let o=0;o<r.length;o+=2){if(this.pn(r[o],r[o+1]))return[];const a=[r[o].indexId,this.uid,r[o].arrayValue,r[o].directionalValue,Fs,[]],c=[r[o+1].indexId,this.uid,r[o+1].arrayValue,r[o+1].directionalValue,Fs,[]];i.push(IDBKeyRange.bound(a,c))}return i}pn(e,t){return We(e,t)>0}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(tu)}getMinOffset(e,t){return f.mapArray(this.Ze(t),s=>this.tn(e,s).next(r=>r||I())).next(tu)}}function eu(n){return ne(n,"collectionParents")}function kn(n){return ne(n,"indexEntries")}function Vs(n){return ne(n,"indexConfiguration")}function Dn(n){return ne(n,"indexState")}function tu(n){b(n.length!==0);let e=n[0].indexState.offset,t=e.largestBatchId;for(let s=1;s<n.length;s++){const r=n[s].indexState.offset;na(r,e)<0&&(e=r),t<r.largestBatchId&&(t=r.largestBatchId)}return new _e(e.readTime,e.documentKey,t)}/** 1692 * @license 1693 * Copyright 2018 Google LLC 1694 * 1695 * Licensed under the Apache License, Version 2.0 (the "License"); 1696 * you may not use this file except in compliance with the License. 1697 * You may obtain a copy of the License at 1698 * 1699 * http://www.apache.org/licenses/LICENSE-2.0 1700 * 1701 * Unless required by applicable law or agreed to in writing, software 1702 * distributed under the License is distributed on an "AS IS" BASIS, 1703 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1704 * See the License for the specific language governing permissions and 1705 * limitations under the License. 1706 */const nu={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class ve{constructor(e,t,s){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=s}static withCacheSize(e){return new ve(e,ve.DEFAULT_COLLECTION_PERCENTILE,ve.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}/** 1707 * @license 1708 * Copyright 2020 Google LLC 1709 * 1710 * Licensed under the Apache License, Version 2.0 (the "License"); 1711 * you may not use this file except in compliance with the License. 1712 * You may obtain a copy of the License at 1713 * 1714 * http://www.apache.org/licenses/LICENSE-2.0 1715 * 1716 * Unless required by applicable law or agreed to in writing, software 1717 * distributed under the License is distributed on an "AS IS" BASIS, 1718 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1719 * See the License for the specific language governing permissions and 1720 * limitations under the License. 1721 */function Rd(n,e,t){const s=n.store("mutations"),r=n.store("documentMutations"),i=[],o=IDBKeyRange.only(t.batchId);let a=0;const c=s.Z({range:o},(l,h,d)=>(a++,d.delete()));i.push(c.next(()=>{b(a===1)}));const u=[];for(const l of t.mutations){const h=bd(e,l.key.path,t.batchId);i.push(r.delete(h)),u.push(l.key)}return f.waitFor(i).next(()=>u)}function wr(n){if(!n)return 0;let e;if(n.document)e=n.document;else if(n.unknownDocument)e=n.unknownDocument;else{if(!n.noDocument)throw I();e=n.noDocument}return JSON.stringify(e).length}/** 1722 * @license 1723 * Copyright 2017 Google LLC 1724 * 1725 * Licensed under the Apache License, Version 2.0 (the "License"); 1726 * you may not use this file except in compliance with the License. 1727 * You may obtain a copy of the License at 1728 * 1729 * http://www.apache.org/licenses/LICENSE-2.0 1730 * 1731 * Unless required by applicable law or agreed to in writing, software 1732 * distributed under the License is distributed on an "AS IS" BASIS, 1733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1734 * See the License for the specific language governing permissions and 1735 * limitations under the License. 1736 */ve.DEFAULT_COLLECTION_PERCENTILE=10,ve.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,ve.DEFAULT=new ve(41943040,ve.DEFAULT_COLLECTION_PERCENTILE,ve.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),ve.DISABLED=new ve(-1,0,0);class ni{constructor(e,t,s,r){this.userId=e,this.yt=t,this.indexManager=s,this.referenceDelegate=r,this.In={}}static re(e,t,s,r){b(e.uid!=="");const i=e.isAuthenticated()?e.uid:"";return new ni(i,t,s,r)}checkEmpty(e){let t=!0;const s=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return Qe(e).Z({index:"userMutationsIndex",range:s},(r,i,o)=>{t=!1,o.done()}).next(()=>t)}addMutationBatch(e,t,s,r){const i=Xt(e),o=Qe(e);return o.add({}).next(a=>{b(typeof a=="number");const c=new aa(a,t,s,r),u=function(d,m,y){const E=y.baseMutations.map(V=>gr(d.ie,V)),S=y.mutations.map(V=>gr(d.ie,V));return{userId:m,batchId:y.batchId,localWriteTimeMs:y.localWriteTime.toMillis(),baseMutations:E,mutations:S}}(this.yt,this.userId,c),l=[];let h=new L((d,m)=>D(d.canonicalString(),m.canonicalString()));for(const d of r){const m=bd(this.userId,d.key.path,a);h=h.add(d.key.path.popLast()),l.push(o.put(u)),l.push(i.put(m,lw))}return h.forEach(d=>{l.push(this.indexManager.addToCollectionParentIndex(e,d))}),e.addOnCommittedListener(()=>{this.In[a]=c.keys()}),f.waitFor(l).next(()=>c)})}lookupMutationBatch(e,t){return Qe(e).get(t).next(s=>s?(b(s.userId===this.userId),It(this.yt,s)):null)}Tn(e,t){return this.In[t]?f.resolve(this.In[t]):this.lookupMutationBatch(e,t).next(s=>{if(s){const r=s.keys();return this.In[t]=r,r}return null})}getNextMutationBatchAfterBatchId(e,t){const s=t+1,r=IDBKeyRange.lowerBound([this.userId,s]);let i=null;return Qe(e).Z({index:"userMutationsIndex",range:r},(o,a,c)=>{a.userId===this.userId&&(b(a.batchId>=s),i=It(this.yt,a)),c.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(e){const t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let s=-1;return Qe(e).Z({index:"userMutationsIndex",range:t,reverse:!0},(r,i,o)=>{s=i.batchId,o.done()}).next(()=>s)}getAllMutationBatches(e){const t=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return Qe(e).W("userMutationsIndex",t).next(s=>s.map(r=>It(this.yt,r)))}getAllMutationBatchesAffectingDocumentKey(e,t){const s=zs(this.userId,t.path),r=IDBKeyRange.lowerBound(s),i=[];return Xt(e).Z({range:r},(o,a,c)=>{const[u,l,h]=o,d=Pe(l);if(u===this.userId&&t.path.isEqual(d))return Qe(e).get(h).next(m=>{if(!m)throw I();b(m.userId===this.userId),i.push(It(this.yt,m))});c.done()}).next(()=>i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let s=new L(D);const r=[];return t.forEach(i=>
1736{const o=zs(this.userId,i.path),a=IDBKeyRange.lowerBound(o),c=Xt(e).Z({range:a},(u,l,h)=>{const[d,m,y]=u,E=Pe(m);d===this.userId&&i.path.isEqual(E)?s=s.add(y):h.done()});r.push(c)}),f.waitFor(r).next(()=>this.En(e,s))}getAllMutationBatchesAffectingQuery(e,t){const s=t.path,r=s.length+1,i=zs(this.userId,s),o=IDBKeyRange.lowerBound(i);let a=new L(D);return Xt(e).Z({range:o},(c,u,l)=>{const[h,d,m]=c,y=Pe(d);h===this.userId&&s.isPrefixOf(y)?y.length===r&&(a=a.add(m)):l.done()}).next(()=>this.En(e,a))}En(e,t){const s=[],r=[];return t.forEach(i=>{r.push(Qe(e).get(i).next(o=>{if(o===null)throw I();b(o.userId===this.userId),s.push(It(this.yt,o))}))}),f.waitFor(r).next(()=>s)}removeMutationBatch(e,t){return Rd(e.se,this.userId,t).next(s=>(e.addOnCommittedListener(()=>{this.An(t.batchId)}),f.forEach(s,r=>this.referenceDelegate.markPotentiallyOrphaned(e,r))))}An(e){delete this.In[e]}performConsistencyCheck(e){return this.checkEmpty(e).next(t=>{if(!t)return f.resolve();const s=IDBKeyRange.lowerBound([this.userId]),r=[];return Xt(e).Z({range:s},(i,o,a)=>{if(i[0]===this.userId){const c=Pe(i[1]);r.push(c)}else a.done()}).next(()=>{b(r.length===0)})})}containsKey(e,t){return Od(e,this.userId,t)}Rn(e){return Md(e).get(this.userId).next(t=>t||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""})}}function Od(n,e,t){const s=zs(e,t.path),r=s[1],i=IDBKeyRange.lowerBound(s);let o=!1;return Xt(n).Z({range:i,X:!0},(a,c,u)=>{const[l,h,d]=a;l===e&&h===r&&(o=!0),u.done()}).next(()=>o)}function Qe(n){return ne(n,"mutations")}function Xt(n){return ne(n,"documentMutations")}function Md(n){return ne(n,"mutationQueues")}/** 1737 * @license 1738 * Copyright 2017 Google LLC 1739 * 1740 * Licensed under the Apache License, Version 2.0 (the "License"); 1741 * you may not use this file except in compliance with the License. 1742 * You may obtain a copy of the License at 1743 * 1744 * http://www.apache.org/licenses/LICENSE-2.0 1745 * 1746 * Unless required by applicable law or agreed to in writing, software 1747 * distributed under the License is distributed on an "AS IS" BASIS, 1748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1749 * See the License for the specific language governing permissions and 1750 * limitations under the License. 1751 */class Bt{constructor(e){this.bn=e}next(){return this.bn+=2,this.bn}static Pn(){return new Bt(0)}static vn(){return new Bt(-1)}}/** 1752 * @license 1753 * Copyright 2017 Google LLC 1754 * 1755 * Licensed under the Apache License, Version 2.0 (the "License"); 1756 * you may not use this file except in compliance with the License. 1757 * You may obtain a copy of the License at 1758 * 1759 * http://www.apache.org/licenses/LICENSE-2.0 1760 * 1761 * Unless required by applicable law or agreed to in writing, software 1762 * distributed under the License is distributed on an "AS IS" BASIS, 1763 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1764 * See the License for the specific language governing permissions and 1765 * limitations under the License. 1766 */class Fw{constructor(e,t){this.referenceDelegate=e,this.yt=t}allocateTargetId(e){return this.Vn(e).next(t=>{const s=new Bt(t.highestTargetId);return t.highestTargetId=s.next(),this.Sn(e,t).next(()=>t.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.Vn(e).next(t=>_.fromTimestamp(new j(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(e){return this.Vn(e).next(t=>t.highestListenSequenceNumber)}setTargetsMetadata(e,t,s){return this.Vn(e).next(r=>(r.highestListenSequenceNumber=t,s&&(r.lastRemoteSnapshotVersion=s.toTimestamp()),t>r.highestListenSequenceNumber&&(r.highestListenSequenceNumber=t),this.Sn(e,r)))}addTargetData(e,t){return this.Dn(e,t).next(()=>this.Vn(e).next(s=>(s.targetCount+=1,this.Cn(t,s),this.Sn(e,s))))}updateTargetData(e,t){return this.Dn(e,t)}removeTargetData(e,t){return this.removeMatchingKeysForTargetId(e,t.targetId).next(()=>Wt(e).delete(t.targetId)).next(()=>this.Vn(e)).next(s=>(b(s.targetCount>0),s.targetCount-=1,this.Sn(e,s)))}removeTargets(e,t,s){let r=0;const i=[];return Wt(e).Z((o,a)=>{const c=Pn(a);c.sequenceNumber<=t&&s.get(c.targetId)===null&&(r++,i.push(this.removeTargetData(e,c)))}).next(()=>f.waitFor(i)).next(()=>r)}forEachTarget(e,t){return Wt(e).Z((s,r)=>{const i=Pn(r);t(i)})}Vn(e){return su(e).get("targetGlobalKey").next(t=>(b(t!==null),t))}Sn(e,t){return su(e).put("targetGlobalKey",t)}Dn(e,t){return Wt(e).put(kd(this.yt,t))}Cn(e,t){let s=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,s=!0),e.sequenceNumber>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,s=!0),s}getTargetCount(e){return this.Vn(e).next(t=>t.targetCount)}getTargetData(e,t){const s=Ft(t),r=IDBKeyRange.bound([s,Number.NEGATIVE_INFINITY],[s,Number.POSITIVE_INFINITY]);let i=null;return Wt(e).Z({range:r,index:"queryTargetsIndex"},(o,a,c)=>{const u=Pn(a);ys(t,u.target)&&(i=u,c.done())}).next(()=>i)}addMatchingKeys(e,t,s){const r=[],i=Xe(e);return t.forEach(o=>{const a=ye(o.path);r.push(i.put({targetId:s,path:a})),r.push(this.referenceDelegate.addReference(e,s,o))}),f.waitFor(r)}removeMatchingKeys(e,t,s){const r=Xe(e);return f.forEach(t,i=>{const o=ye(i.path);return f.waitFor([r.delete([s,o]),this.referenceDelegate.removeReference(e,s,i)])})}removeMatchingKeysForTargetId(e,t){const s=Xe(e),r=IDBKeyRange.bound([t],[t+1],!1,!0);return s.delete(r)}getMatchingKeysForTargetId(e,t){const s=IDBKeyRange.bound([t],[t+1],!1,!0),r=Xe(e);let i=N();return r.Z({range:s,X:!0},(o,a,c)=>{const u=Pe(o[1]),l=new w(u);i=i.add(l)}).next(()=>i)}containsKey(e,t){const s=ye(t.path),r=IDBKeyRange.bound([s],[Nh(s)],!1,!0);let i=0;return Xe(e).Z({index:"documentTargetsIndex",X:!0,range:r},([o,a],c,u)=>{o!==0&&(i++,u.done())}).next(()=>i>0)}ne(e,t){return Wt(e).get(t).next(s=>s?Pn(s):null)}}function Wt(n){return ne(n,"targets")}function su(n){return ne(n,"targetGlobal")}function Xe(n){return ne(n,"targetDocuments")}/** 1767 * @license 1768 * Copyright 2020 Google LLC 1769 * 1770 * Licensed under the Apache License, Version 2.0 (the "License");
1771 * you may not use this file except in compliance with the License. 1772 * You may obtain a copy of the License at 1773 * 1774 * http://www.apache.org/licenses/LICENSE-2.0 1775 * 1776 * Unless required by applicable law or agreed to in writing, software 1777 * distributed under the License is distributed on an "AS IS" BASIS, 1778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1779 * See the License for the specific language governing permissions and 1780 * limitations under the License. 1781 */function ru([n,e],[t,s]){const r=D(n,t);return r===0?D(e,s):r}class Vw{constructor(e){this.xn=e,this.buffer=new L(ru),this.Nn=0}kn(){return++this.Nn}On(e){const t=[e,this.kn()];if(this.buffer.size<this.xn)this.buffer=this.buffer.add(t);else{const s=this.buffer.last();ru(t,s)<0&&(this.buffer=this.buffer.delete(s).add(t))}}get maxValue(){return this.buffer.last()[0]}}class Uw{constructor(e,t,s){this.garbageCollector=e,this.asyncQueue=t,this.localStore=s,this.Mn=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Fn(6e4)}stop(){this.Mn&&(this.Mn.cancel(),this.Mn=null)}get started(){return this.Mn!==null}Fn(e){g("LruGarbageCollector",`Garbage collection scheduled in ${e}ms`),this.Mn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Mn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){dt(t)?g("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",t):await Gt(t)}await this.Fn(3e5)})}}class Bw{constructor(e,t){this.$n=e,this.params=t}calculateTargetCount(e,t){return this.$n.Bn(e).next(s=>Math.floor(t/100*s))}nthSequenceNumber(e,t){if(t===0)return f.resolve(Se.at);const s=new Vw(t);return this.$n.forEachTarget(e,r=>s.On(r.sequenceNumber)).next(()=>this.$n.Ln(e,r=>s.On(r))).next(()=>s.maxValue)}removeTargets(e,t,s){return this.$n.removeTargets(e,t,s)}removeOrphanedDocuments(e,t){return this.$n.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(g("LruGarbageCollector","Garbage collection skipped; disabled"),f.resolve(nu)):this.getCacheSize(e).next(s=>s<this.params.cacheSizeCollectionThreshold?(g("LruGarbageCollector",`Garbage collection skipped; Cache size ${s} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),nu):this.qn(e,t))}getCacheSize(e){return this.$n.getCacheSize(e)}qn(e,t){let s,r,i,o,a,c,u;const l=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(h=>(h>this.params.maximumSequenceNumbersToCollect?(g("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${h}`),r=this.params.maximumSequenceNumbersToCollect):r=h,o=Date.now(),this.nthSequenceNumber(e,r))).next(h=>(s=h,a=Date.now(),this.removeTargets(e,s,t))).next(h=>(i=h,c=Date.now(),this.removeOrphanedDocuments(e,s))).next(h=>(u=Date.now(),so()<=O.DEBUG&&g("LruGarbageCollector",`LRU Garbage Collection 1782 Counted targets in ${o-l}ms 1783 Determined least recently used ${r} in `+(a-o)+`ms 1784 Removed ${i} targets in `+(c-a)+`ms 1785 Removed ${h} documents in `+(u-c)+`ms 1786Total Duration: ${u-l}ms`),f.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:h})))}}/** 1787 * @license 1788 * Copyright 2020 Google LLC 1789 * 1790 * Licensed under the Apache License, Version 2.0 (the "License"); 1791 * you may not use this file except in compliance with the License. 1792 * You may obtain a copy of the License at 1793 * 1794 * http://www.apache.org/licenses/LICENSE-2.0 1795 * 1796 * Unless required by applicable law or agreed to in writing, software 1797 * distributed under the License is distributed on an "AS IS" BASIS, 1798 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1799 * See the License for the specific language governing permissions and 1800 * limitations under the License. 1801 */class $w{constructor(e,t){this.db=e,this.garbageCollector=function(s,r){return new Bw(s,r)}(this,t)}Bn(e){const t=this.Un(e);return this.db.getTargetCache().getTargetCount(e).next(s=>t.next(r=>s+r))}Un(e){let t=0;return this.Ln(e,s=>{t++}).next(()=>t)}
1801forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}Ln(e,t){return this.Kn(e,(s,r)=>t(r))}addReference(e,t,s){return Us(e,s)}removeReference(e,t,s){return Us(e,s)}removeTargets(e,t,s){return this.db.getTargetCache().removeTargets(e,t,s)}markPotentiallyOrphaned(e,t){return Us(e,t)}Gn(e,t){return function(s,r){let i=!1;return Md(s).tt(o=>Od(s,o,r).next(a=>(a&&(i=!0),f.resolve(!a)))).next(()=>i)}(e,t)}removeOrphanedDocuments(e,t){const s=this.db.getRemoteDocumentCache().newChangeBuffer(),r=[];let i=0;return this.Kn(e,(o,a)=>{if(a<=t){const c=this.Gn(e,o).next(u=>{if(!u)return i++,s.getEntry(e,o).next(()=>(s.removeEntry(o,_.min()),Xe(e).delete([0,ye(o.path)])))});r.push(c)}}).next(()=>f.waitFor(r)).next(()=>s.apply(e)).next(()=>i)}removeTarget(e,t){const s=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,s)}updateLimboDocument(e,t){return Us(e,t)}Kn(e,t){const s=Xe(e);let r,i=Se.at;return s.Z({index:"documentTargetsIndex"},([o,a],{path:c,sequenceNumber:u})=>{o===0?(i!==Se.at&&t(new w(Pe(r)),i),i=u,r=c):i=Se.at}).next(()=>{i!==Se.at&&t(new w(Pe(r)),i)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function Us(n,e){return Xe(n).put(function(t,s){return{targetId:0,path:ye(t.path),sequenceNumber:s}}(e,n.currentSequenceNumber))}/** 1802 * @license 1803 * Copyright 2017 Google LLC 1804 * 1805 * Licensed under the Apache License, Version 2.0 (the "License"); 1806 * you may not use this file except in compliance with the License. 1807 * You may obtain a copy of the License at 1808 * 1809 * http://www.apache.org/licenses/LICENSE-2.0 1810 * 1811 * Unless required by applicable law or agreed to in writing, software 1812 * distributed under the License is distributed on an "AS IS" BASIS, 1813 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1814 * See the License for the specific language governing permissions and 1815 * limitations under the License. 1816 */class Pd{constructor(){this.changes=new ft(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,z.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const s=this.changes.get(t);return s!==void 0?f.resolve(s):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}/** 1817 * @license 1818 * Copyright 2017 Google LLC 1819 * 1820 * Licensed under the Apache License, Version 2.0 (the "License"); 1821 * you may not use this file except in compliance with the License. 1822 * You may obtain a copy of the License at 1823 * 1824 * http://www.apache.org/licenses/LICENSE-2.0 1825 * 1826 * Unless required by applicable law or agreed to in writing, software 1827 * distributed under the License is distributed on an "AS IS" BASIS, 1828 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1829 * See the License for the specific language governing permissions and 1830 * limitations under the License. 1831 */class qw{constructor(e){this.yt=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,s){return gt(e).put(s)}removeEntry(e,t,s){return gt(e).delete(function(r,i){const o=r.path.toArray();return[o.slice(0,o.length-2),o[o.length-2],yr(i),o[o.length-1]]}(t,s))}updateMetadata(e,t){return this.getMetadata(e).next(s=>(s.byteSize+=t,this.Qn(e,s)))}getEntry(e,t){let s=z.newInvalidDocument(t);return gt(e).Z({index:"documentKeyIndex",range:IDBKeyRange.only(Nn(t))},(r,i)=>{s=this.jn(t,i)}).next(()=>s)}Wn(e,t){let s={size:0,document:z.newInvalidDocument(t)};return gt(e).Z({index:"documentKeyIndex",range:IDBKeyRange.only(Nn(t))},(r,i)=>{s={document:this.jn(t,i),size:wr(i)}}).next(()=>s)}getEntries(e,t){let s=Te();return this.zn(e,t,(r,i)=>{const o=this.jn(r,i);s=s.insert(r,o)}).next(()=>s)}Hn(e,t){let s=Te(),r=new Y(w.comparator);return this.zn(e,t,(i,o)=>{const a=this.jn(i,o);s=s.insert(i,a),r=r.insert(i,wr(o))}).next(()=>({documents:s,Jn:r}))}zn(e,t,s){if(t.isEmpty())return f.resolve();let r=new L(au);t.forEach(c=>r=r.add(c));const i=IDBKeyRange.bound(Nn(r.first()),Nn(r.last())),o=r.getIterator();let a=o.getNext();return gt(e).Z({index:"documentKeyIndex",range:i},(c,u,l)=>{const h=w.fromSegments([...u.prefixPath,u.collectionGroup,u.documentId]);for(;a&&au(a,h)<0;)s(a,null),a=o.getNext();a&&a.isEqual(h)&&(s(a,u),a=o.hasNext()?o.getNext():null),a?l.j(Nn(a)):l.done()}).next(()=>{for(;a;)s(a,null),a=o.hasNext()?o.getNext():null})}getDocumentsMatchingQuery(e,t,s,r){const i=t.path,o=[i.popLast().toArray(),i.lastSegment(),yr(s.readTime),s.documentKey.path.isEmpty()?"":s.documentKey.path.lastSegment()],a=[i.popLast().toArray(),i.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return gt(e).W(IDBKeyRange.bound(o,a,!0)).next(c=>{let u=Te();for(const l of c){const h=this.jn(w.fromSegments(l.prefixPath.concat(l.collectionGroup,l.documentId)),l);
1831h.isFoundDocument()&&(ws(t,h)||r.has(h.key))&&(u=u.insert(h.key,h))}return u})}getAllFromCollectionGroup(e,t,s,r){let i=Te();const o=ou(t,s),a=ou(t,_e.max());return gt(e).Z({index:"collectionGroupIndex",range:IDBKeyRange.bound(o,a,!0)},(c,u,l)=>{const h=this.jn(w.fromSegments(u.prefixPath.concat(u.collectionGroup,u.documentId)),u);i=i.insert(h.key,h),i.size===r&&l.done()}).next(()=>i)}newChangeBuffer(e){return new jw(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(t=>t.byteSize)}getMetadata(e){return iu(e).get("remoteDocumentGlobalKey").next(t=>(b(!!t),t))}Qn(e,t){return iu(e).put("remoteDocumentGlobalKey",t)}jn(e,t){if(t){const s=Cw(this.yt,t);if(!(s.isNoDocument()&&s.version.isEqual(_.min())))return s}return z.newInvalidDocument(e)}}function Ld(n){return new qw(n)}class jw extends Pd{constructor(e,t){super(),this.Yn=e,this.trackRemovals=t,this.Xn=new ft(s=>s.toString(),(s,r)=>s.isEqual(r))}applyChanges(e){const t=[];let s=0,r=new L((i,o)=>D(i.canonicalString(),o.canonicalString()));return this.changes.forEac
1831h((i,o)=>{const a=this.Xn.get(i);if(t.push(this.Yn.removeEntry(e,i,a.readTime)),o.isValidDocument()){const c=zc(this.Yn.yt,o);r=r.add(i.path.popLast());const u=wr(c);s+=u-a.size,t.push(this.Yn.addEntry(e,i,c))}else if(s-=a.size,this.trackRemovals){const c=zc(this.Yn.yt,o.convertToNoDocument(_.min()));t.push(this.Yn.addEntry(e,i,c))}}),r.forEach(i=>{t.push(this.Yn.indexManager.addToCollectionParentIndex(e,i))}),t.push(this.Yn.updateMetadata(e,s)),f.waitFor(t)}getFromCache(e,t){return this.Yn.Wn(e,t).next(s=>(this.Xn.set(t,{size:s.size,readTime:s.document.readTime}),s.document))}getAllFromCache(e,t){return this.Yn.Hn(e,t).next(({documents:s,Jn:r})=>(r.forEach((i,o)=>{this.Xn.set(i,{size:o,readTime:s.get(i).readTime})}),s))}}function iu(n){return ne(n,"remoteDocumentGlobal")}function gt(n){return ne(n,"remoteDocumentsV14")}function Nn(n){const e=n.path.toArray();return[e.slice(0,e.length-2),e[e.length-2],e[e.length-1]]}function ou(n,e){const t=e.documentKey.path.toArray();return[n,yr(e.readTime),t.slice(0,t.length-2),t.length>0?t[t.length-1]:""]}function au(n,e){const t=n.path.toArray(),s=e.path.toArray();let r=0;for(let i=0;i<t.length-2&&i<s.length-2;++i)if(r=D(t[i],s[i]),r)return r;return r=D(t.length,s.length),r||(r=D(t[t.length-2],s[s.length-2]),r||D(t[t.length-1],s[s.length-1]))}/** 1832 * @license 1833 * Copyright 2017 Google LLC 1834 * 1835 * Licensed under the Apache License, Version 2.0 (the "License"); 1836 * you may not use this file except in compliance with the License. 1837 * You may obtain a copy of the License at 1838 * 1839 * http://www.apache.org/licenses/LICENSE-2.0 1840 * 1841 * Unless required by applicable law or agreed to in writing, software 1842 * distributed under the License is distributed on an "AS IS" BASIS, 1843 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1844 * See the License for the specific language governing permissions and 1845 * limitations under the License. 1846 *//** 1847 * @license 1848 * Copyright 2022 Google LLC 1849 * 1850 * Licensed under the Apache License, Version 2.0 (the "License"); 1851 * you may not use this file except in compliance with the License. 1852 * You may obtain a copy of the License at 1853 * 1854 * http://www.apache.org/licenses/LICENSE-2.0 1855 * 1856 * Unless required by applicable law or agreed to in writing, software 1857 * distributed under the License is distributed on an "AS IS" BASIS, 1858 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1859 * See the License for the specific language governing permissions and 1860 * limitations under the License. 1861 */class Gw{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}/** 1862 * @license 1863 * Copyright 2017 Google LLC 1864 * 1865 * Licensed under the Apache License, Version 2.0 (the "License"); 1866 * you may not use this file except in compliance with the License. 1867 * You may obtain a copy of the License at 1868 * 1869 * http://www.apache.org/licenses/LICENSE-2.0 1870 * 1871 * Unless required by applicable law or agreed to in writing, software 1872 * distributed under the License is distributed on an "AS IS" BASIS, 1873 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1874 * See the License for the specific language governing permissions and 1875 * limitations under the License. 1876 */class Fd{constructor(e,t,s,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=s,this.indexManager=r}getDocument(e,t){let s=null;return this.documentOverlayCache.getOverlay(e,t).next(r=>(s=r,this.remoteDocumentCache.getEntry(e,t))).next(r=>(s!==null&&$n(s.mutation,r,we.empty(),j.now()),r))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(s=>this.getLocalViewOfDocuments(e,s,N()).next(()=>s))}getLocalViewOfDocuments(e,t,s=N()){const r=Me();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,s).next(i=>{let o=Mn();return i.forEach((a,c)=>{o=o.insert(a,c.overlayedDocument)}),o}))}getOverlayedDocuments(e,t){const s=Me();return this.populateOverlays(e,s,t).next(()=>this.computeViews(e,t,s,N()))}populateOverlays(e,t,s){const r=[];return s.forEach(i=>{t.has(i)||r.push(i)}),this.documentOverlayCache.getOverlays(e,r).next(i=>{i.forEach((o,a)=>{t.set(o,a)})})}computeViews(e,t,s,r){let i=Te();const o=qn(),a=qn();return t.forEach((c,u)=>{const l=s.get(u.key);
1876r.has(u.key)&&(l===void 0||l.mutation instanceof He)?i=i.insert(u.key,u):l!==void 0?(o.set(u.key,l.mutation.getFieldMask()),$n(l.mutation,u,l.mutation.getFieldMask(),j.now())):o.set(u.key,we.empty())}),this.recalculateAndSaveOverlays(e,i).next(c=>(c.forEach((u,l)=>o.set(u,l)),t.forEach((u,l)=>{var h;return a.set(u,new Gw(l,(h=o.get(u))!==null&&h!==void 0?h:null))}),a))}recalculateAndSaveOverlays(e,t){const s=qn();let r=new Y((o,a)=>o-a),i=N();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(o=>{for(const a of o)a.keys().forEach(c=>{const u=t.get(c);if(u===null)return;let l=s.get(c)||we.empty();l=a.applyToLocalView(u,l),s.set(c,l);const h=(r.get(a.batchId)||N()).add(c);r=r.insert(a.batchId,h)})}).next(()=>{const o=[],a=r.getReverseIterator();for(;a.hasNext();){const c=a.getNext(),u=c.key,l=c.value,h=ud();l.forEach(d=>{if(!i.has(d)){const m=sd(t.get(d),s.get(d));m!==null&&h.set(d,m),i=i.add(d)}}),o.push(this.documentOverlayCache.saveOverlays(e,u,h))}return f.waitFor(o)}).next(()=>s)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(s=>this.recalculateAndSaveOverlays(e,s))}getDocumentsMatchingQuery(e,t,s){return function(r){return w.isDocumentKey(r.path)&&r.collectionGroup===null&&r.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Hh(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,s):this.getDocumentsMatchingCollectionQuery(e,t,s)}getNextDocuments(e,t,s,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,s,r).next(i=>{const o=r-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,s.largestBatchId,r-i.size):f.resolve(Me());let a=-1,c=i;return o.next(u=>f.forEach(u,(l,h)=>(a<h.largestBatchId&&(a=h.largestBatchId),i.get(l)?f.resolve():this.remoteDocumentCache.getEntry(e,l).next(d=>{c=c.insert(l,d)}))).next(()=>this.populateOverlays(e,u,i)).next(()=>this.computeViews(e,c,u,N())).next(l=>({batchId:a,changes:cd(l)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new w(t)).next(s=>{let r=Mn();return s.isFoundDocument()&&(r=r.insert(s.key,s)),r})}getDocumentsMatchingCollectionGroupQuery(e,t,s){const r=t.collectionGroup;let i=Mn();return this.indexManager.getCollectionParents(e,r).next(o=>f.forEach(o,a=>{const c=function(u,l){return new Tn(l,null,u.explicitOrderBy.slice(),u.filters.slice(),u.limit,u.limitType,u.startAt,u.endAt)}(t,a.child(r));return this.getDocumentsMatchingCollectionQuery(e,c,s).next(u=>{u.forEach((l,h)=>{i=i.insert(l,h)})})}).next(()=>i))}getDocumentsMatchingCollectionQuery(e,t,s){let r;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,s.largestBatchId).next(i=>(r=i,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,s,r))).next(i=>{r.forEach((a,c)=>{const u=c.getKey();i.get(u)===null&&(i=i.insert(u,z.newInvalidDocument(u)))});let o=Mn();return i.forEach((a,c)=>{const u=r.get(a);u!==void 0&&$n(u.mutation,c,we.empty(),j.now()),ws(t,c)&&(o=o.insert(a,c))}),o})}}/** 1877 * @license 1878 * Copyright 2020 Google LLC 1879 * 1880 * Licensed under the Apache License, Version 2.0 (the "License"); 1881 * you may not use this file except in compliance with the License. 1882 * You may obtain a copy of the License at 1883 * 1884 * http://www.apache.org/licenses/LICENSE-2.0 1885 * 1886 * Unless required by applicable law or agreed to in writing, software 1887 * distributed under the License is distributed on an "AS IS" BASIS, 1888 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1889 * See the License for the specific language governing permissions and 1890 * limitations under the License. 1891 */class Kw{constructor(e){this.yt=e,this.Zn=new Map,this.ts=new Map}getBundleMetadata(e,t){return f.resolve(this.Zn.get(t))}saveBundleMetadata(e,t){var s;return this.Zn.set(t.id,{id:(s=t).id,version:s.version,createTime:ge(s.createTime)}),f.resolve()}getNamedQuery(e,t){return f.resolve(this.ts.get(t))}saveNamedQuery(e,t){return this.ts.set(t.name,function(s){return{name:s.name,query:Dd(s.bundledQuery),readTime:ge(s.readTime)}}(t)),f.resolve()}}/** 1892 * @license 1893 * Copyright 2022 Google LLC 1894 * 1895 * Licensed under the Apache License, Version 2.0 (the "License");
1896 * you may not use this file except in compliance with the License. 1897 * You may obtain a copy of the License at 1898 * 1899 * http://www.apache.org/licenses/LICENSE-2.0 1900 * 1901 * Unless required by applicable law or agreed to in writing, software 1902 * distributed under the License is distributed on an "AS IS" BASIS, 1903 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1904 * See the License for the specific language governing permissions and 1905 * limitations under the License. 1906 */class zw{constructor(){this.overlays=new Y(w.comparator),this.es=new Map}getOverlay(e,t){return f.resolve(this.overlays.get(t))}getOverlays(e,t){const s=Me();return f.forEach(t,r=>this.getOverlay(e,r).next(i=>{i!==null&&s.set(r,i)})).next(()=>s)}saveOverlays(e,t,s){return s.forEach((r,i)=>{this.oe(e,t,i)}),f.resolve()}removeOverlaysForBatchId(e,t,s){const r=this.es.get(s);return r!==void 0&&(r.forEach(i=>this.overlays=this.overlays.remove(i)),this.es.delete(s)),f.resolve()}getOverlaysForCollection(e,t,s){const r=Me(),i=t.length+1,o=new w(t.child("")),a=this.overlays.getIteratorFrom(o);for(;a.hasNext();){const c=a.getNext().value,u=c.getKey();if(!t.isPrefixOf(u.path))break;u.path.length===i&&c.largestBatchId>s&&r.set(c.getKey(),c)}return f.resolve(r)}getOverlaysForCollectionGroup(e,t,s,r){let i=new Y((u,l)=>u-l);const o=this.overlays.getIterator();for(;o.hasNext();){const u=o.getNext().value;if(u.getKey().getCollectionGroup()===t&&u.largestBatchId>s){let l=i.get(u.largestBatchId);l===null&&(l=Me(),i=i.insert(u.largestBatchId,l)),l.set(u.getKey(),u)}}const a=Me(),c=i.getIterator();for(;c.hasNext()&&(c.getNext().value.forEach((u,l)=>a.set(u,l)),!(a.size()>=r)););return f.resolve(a)}oe(e,t,s){const r=this.overlays.get(s.key);if(r!==null){const o=this.es.get(r.largestBatchId).delete(s.key);this.es.set(r.largestBatchId,o)}this.overlays=this.overlays.insert(s.key,new ua(t,s));let i=this.es.get(t);i===void 0&&(i=N(),this.es.set(t,i)),this.es.set(t,i.add(s.key))}}/** 1907 * @license 1908 * Copyright 2017 Google LLC 1909 * 1910 * Licensed under the Apache License, Version 2.0 (the "License"); 1911 * you may not use this file except in compliance with the License. 1912 * You may obtain a copy of the License at 1913 * 1914 * http://www.apache.org/licenses/LICENSE-2.0 1915 * 1916 * Unless required by applicable law or agreed to in writing, software 1917 * distributed under the License is distributed on an "AS IS" BASIS, 1918 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1919 * See the License for the specific language governing permissions and 1920 * limitations under the License. 1921 */class da{constructor(){this.ns=new L(ee.ss),this.rs=new L(ee.os)}isEmpty(){return this.ns.isEmpty()}addReference(e,t){const s=new ee(e,t);this.ns=this.ns.add(s),this.rs=this.rs.add(s)}us(e,t){e.forEach(s=>this.addReference(s,t))}removeReference(e,t){this.cs(new ee(e,t))}hs(e,t){e.forEach(s=>this.removeReference(s,t))}ls(e){const t=new w(new M([])),s=new ee(t,e),r=new ee(t,e+1),i=[];return this.rs.forEachInRange([s,r],o=>{this.cs(o),i.push(o.key)}),i}fs(){this.ns.forEach(e=>this.cs(e))}cs(e){this.ns=this.ns.delete(e),this.rs=this.rs.delete(e)}ds(e){const t=new w(new M([])),s=new ee(t,e),r=new ee(t,e+1);let i=N();return this.rs.forEachInRange([s,r],o=>{i=i.add(o.key)}),i}containsKey(e){const t=new ee(e,0),s=this.ns.firstAfterOrEqual(t);return s!==null&&e.isEqual(s.key)}}class ee{constructor(e,t){this.key=e,this._s=t}static ss(e,t){return w.comparator(e.key,t.key)||D(e._s,t._s)}static os(e,t){return D(e._s,t._s)||w.comparator(e.key,t.key)}}/** 1922 * @license 1923 * Copyright 2017 Google LLC 1924 * 1925 * Licensed under the Apache License, Version 2.0 (the "License"); 1926 * you may not use this file except in compliance with the License. 1927 * You may obtain a copy of the License at 1928 * 1929 * http://www.apache.org/licenses/LICENSE-2.0 1930 * 1931 * Unless required by applicable law or agreed to in writing, software 1932 * distributed under the License is distributed on an "AS IS" BASIS, 1933 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1934 * See the License for the specific language governing permissions and 1935 * limitations under the License. 1936 */class Hw{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutation
1936Queue=[],this.ws=1,this.gs=new L(ee.ss)}checkEmpty(e){return f.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,s,r){const i=this.ws;this.ws++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const o=new aa(i,t,s,r);this.mutationQueue.push(o);for(const a of r)this.gs=this.gs.add(new ee(a.key,i)),this.indexManager.addToCollectionParentIndex(e,a.key.path.popLast());return f.resolve(o)}lookupMutationBatch(e,t){return f.resolve(this.ys(t))}getNextMutationBatchAfterBatchId(e,t){const s=t+1,r=this.ps(s),i=r<0?0:r;return f.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return f.resolve(this.mutationQueue.length===0?-1:this.ws-1)}getAllMutationBatches(e){return f.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const s=new ee(t,0),r=new ee(t,Number.POSITIVE_INFINITY),i=[];return this.gs.forEachInRange([s,r],o=>{const a=this.ys(o._s);i.push(a)}),f.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let s=new L(D);return t.forEach(r=>{const i=new ee(r,0),o=new ee(r,Number.POSITIVE_INFINITY);this.gs.forEachInRange([i,o],a=>{s=s.add(a._s)})}),f.resolve(this.Is(s))}getAllMutationBatchesAffectingQuery(e,t){const s=t.path,r=s.length+1;let i=s;w.isDocumentKey(i)||(i=i.child(""));const o=new ee(new w(i),0);let a=new L(D);return this.gs.forEachWhile(c=>{const u=c.key.path;return!!s.isPrefixOf(u)&&(u.length===r&&(a=a.add(c._s)),!0)},o),f.resolve(this.Is(a))}Is(e){const t=[];return e.forEach(s=>{const r=this.ys(s);r!==null&&t.push(r)}),t}removeMutationBatch(e,t){b(this.Ts(t.batchId,"removed")===0),this.mutationQueue.shift();let s=this.gs;return f.forEach(t.mutations,r=>{const i=new ee(r.key,t.batchId);return s=s.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)}).next(()=>{this.gs=s})}An(e){}containsKey(e,t){const s=new ee(t,0),r=this.gs.firstAfterOrEqual(s);return f.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,f.resolve()}Ts(e,t){return this.ps(e)}ps(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}ys(e){const t=this.ps(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}/** 1937 * @license 1938 * Copyright 2017 Google LLC 1939 * 1940 * Licensed under the Apache License, Version 2.0 (the "License"); 1941 * you may not use this file except in compliance with the License. 1942 * You may obtain a copy of the License at 1943 * 1944 * http://www.apache.org/licenses/LICENSE-2.0 1945 * 1946 * Unless required by applicable law or agreed to in writing, software 1947 * distributed under the License is distributed on an "AS IS" BASIS, 1948 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1949 * See the License for the specific language governing permissions and 1950 * limitations under the License. 1951 */class Ww{constructor(e){this.Es=e,this.docs=new Y(w.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const s=t.key,r=this.docs.get(s),i=r?r.size:0,o=this.Es(t);return this.docs=this.docs.insert(s,{document:t.mutableCopy(),size:o}),this.size+=o-i,this.indexManager.addToCollectionParentIndex(e,s.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const s=this.docs.get(t);return f.resolve(s?s.document.mutableCopy():z.newInvalidDocument(t))}getEntries(e,t){let s=Te();return t.forEach(r=>{const i=this.docs.get(r);s=s.insert(r,i?i.document.mutableCopy():z.newInvalidDocument(r))}),f.resolve(s)}getDocumentsMatchingQuery(e,t,s,r){let i=Te();const o=t.path,a=new w(o.child("")),c=this.docs.getIteratorFrom(a);for(;c.hasNext();){const{key:u,value:{document:l}}=c.getNext();if(!o.isPrefixOf(u.path))break;u.path.length>o.length+1||na(Rh(l),s)<=0||(r.has(l.key)||ws(t,l))&&(i=i.insert(l.key,l.mutableCopy()))}return f.resolve(i)}getAllFromCollectionGroup(e,t,s,r){I()}As(e,t){return f.forEach(this.docs,s=>t(s))}newChangeBuffer(e){return new Qw(this)}getSize(e){return f.resolve(this.size)}}class Qw extends Pd{constructor(e){super(),this.Yn=e}applyChanges(e){const t=[];
1951return this.changes.forEach((s,r)=>{r.isValidDocument()?t.push(this.Yn.addEntry(e,r)):this.Yn.removeEntry(s)}),f.waitFor(t)}getFromCache(e,t){return this.Yn.getEntry(e,t)}getAllFromCache(e,t){return this.Yn.getEntries(e,t)}}/** 1952 * @license 1953 * Copyright 2017 Google LLC 1954 * 1955 * Licensed under the Apache License, Version 2.0 (the "License"); 1956 * you may not use this file except in compliance with the License. 1957 * You may obtain a copy of the License at 1958 * 1959 * http://www.apache.org/licenses/LICENSE-2.0 1960 * 1961 * Unless required by applicable law or agreed to in writing, software 1962 * distributed under the License is distributed on an "AS IS" BASIS, 1963 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1964 * See the License for the specific language governing permissions and 1965 * limitations under the License. 1966 */class Yw{constructor(e){this.persistence=e,this.Rs=new ft(t=>Ft(t),ys),this.lastRemoteSnapshotVersion=_.min(),this.highestTargetId=0,this.bs=0,this.Ps=new da,this.targetCount=0,this.vs=Bt.Pn()}forEachTarget(e,t){return this.Rs.forEach((s,r)=>t(r)),f.resolve()}getLastRemoteSnapshotVersion(e){return f.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return f.resolve(this.bs)}allocateTargetId(e){return this.highestTargetId=this.vs.next(),f.resolve(this.highestTargetId)}setTargetsMetadata(e,t,s){return s&&(this.lastRemoteSnapshotVersion=s),t>this.bs&&(this.bs=t),f.resolve()}Dn(e){this.Rs.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.vs=new Bt(t),this.highestTargetId=t),e.sequenceNumber>this.bs&&(this.bs=e.sequenceNumber)}addTargetData(e,t){return this.Dn(t),this.targetCount+=1,f.resolve()}updateTargetData(e,t){return this.Dn(t),f.resolve()}removeTargetData(e,t){return this.Rs.delete(t.target),this.Ps.ls(t.targetId),this.targetCount-=1,f.resolve()}removeTargets(e,t,s){let r=0;const i=[];return this.Rs.forEach((o,a)=>{a.sequenceNumber<=t&&s.get(a.targetId)===null&&(this.Rs.delete(o),i.push(this.removeMatchingKeysForTargetId(e,a.targetId)),r++)}),f.waitFor(i).next(()=>r)}getTargetCount(e){return f.resolve(this.targetCount)}getTargetData(e,t){const s=this.Rs.get(t)||null;return f.resolve(s)}addMatchingKeys(e,t,s){return this.Ps.us(t,s),f.resolve()}removeMatchingKeys(e,t,s){this.Ps.hs(t,s);const r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(o=>{i.push(r.markPotentiallyOrphaned(e,o))}),f.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.Ps.ls(t),f.resolve()}getMatchingKeysForTargetId(e,t){const s=this.Ps.ds(t);return f.resolve(s)}containsKey(e,t){return f.resolve(this.Ps.containsKey(t))}}/** 1967 * @license 1968 * Copyright 2017 Google LLC 1969 * 1970 * Licensed under the Apache License, Version 2.0 (the "License"); 1971 * you may not use this file except in compliance with the License. 1972 * You may obtain a copy of the License at 1973 * 1974 * http://www.apache.org/licenses/LICENSE-2.0 1975 * 1976 * Unless required by applicable law or agreed to in writing, software 1977 * distributed under the License is distributed on an "AS IS" BASIS, 1978 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1979 * See the License for the specific language governing permissions and 1980 * limitations under the License. 1981 */class Vd{constructor(e,t){this.Vs={},this.overlays={},this.Ss=new Se(0),this.Ds=!1,this.Ds=!0,this.referenceDelegate=e(this),this.Cs=new Yw(this),this.indexManager=new Pw,this.remoteDocumentCache=function(s){return new Ww(s)}(s=>this.referenceDelegate.xs(s)),this.yt=new Cd(t),this.Ns=new Kw(this.yt)}start(){return Promise.resolve()}shutdown(){return this.Ds=!1,Promise.resolve()}get started(){return this.Ds}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new zw,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let s=this.Vs[e.toKey()];return s||(s=new Hw(t,this.referenceDelegate),this.Vs[e.toKey()]=s),s}getTargetCache(){return this.Cs}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ns}runTransaction(e,t,s){g("MemoryPersistence","Starting transaction:",e);const r=new Xw(this.Ss.next());return this.referenceDelegate.ks(),s(r).next(i=>this.referenceDelegate.Os(r).next(()=>i)).toPromise().then(i=>(r.raiseOnCommittedEvent(),i))}Ms(e,t){return f.or(Object.values(this.Vs).map(s=>()=>s.containsKey(e,t)))}}class Xw extends Mh{constructor(e){super(),this.currentSequenceNumber=e}}class si{constructor(e){this.persistence=e,this.Fs=new da,this.$s=null}static Bs(e){return new si(e)}get Ls(){if(this.$s)return this.$s;throw I()}
1981addReference(e,t,s){return this.Fs.addReference(s,t),this.Ls.delete(s.toString()),f.resolve()}removeReference(e,t,s){return this.Fs.removeReference(s,t),this.Ls.add(s.toString()),f.resolve()}markPotentiallyOrphaned(e,t){return this.Ls.add(t.toString()),f.resolve()}removeTarget(e,t){this.Fs.ls(t.targetId).forEach(r=>this.Ls.add(r.toString()));const s=this.persistence.getTargetCache();return s.getMatchingKeysForTargetId(e,t.targetId).next(r=>{r.forEach(i=>this.Ls.add(i.toString()))}).next(()=>s.removeTargetData(e,t))}ks(){this.$s=new Set}Os(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return f.forEach(this.Ls,s=>{const r=w.fromPath(s);return this.qs(e,r).next(i=>{i||t.removeEntry(r,_.min())})}).next(()=>(this.$s=null,t.apply(e)))}updateLimboDocument(e,t){return this.qs(e,t).next(s=>{s?this.Ls.delete(t.toString()):this.Ls.add(t.toString())})}xs(e){return 0}qs(e,t){return f.or([()=>f.resolve(this.Fs.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ms(e,t)])}}/** 1982 * @license 1983 * Copyright 2020 Google LLC 1984 * 1985 * Licensed under the Apache License, Version 2.0 (the "License"); 1986 * you may not use this file except in compliance with the License. 1987 * You may obtain a copy of the License at 1988 * 1989 * http://www.apache.org/licenses/LICENSE-2.0 1990 * 1991 * Unless required by applicable law or agreed to in writing, software 1992 * distributed under the License is distributed on an "AS IS" BASIS, 1993 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1994 * See the License for the specific language governing permissions and 1995 * limitations under the License. 1996 */class Jw{constructor(e){this.yt=e}$(e,t,s,r){const i=new Wr("createOrUpgrade",t);s<1&&r>=1&&(function(a){a.createObjectStore("owner")}(e),function(a){a.createObjectStore("mutationQueues",{keyPath:"userId"}),a.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Kc,{unique:!0}),a.createObjectStore("documentMutations")}(e),cu(e),function(a){a.createObjectStore("remoteDocuments")}(e));let o=f.resolve();return s<3&&r>=3&&(s!==0&&(function(a){a.deleteObjectStore("targetDocuments"),a.deleteObjectStore("targets"),a.deleteObjectStore("targetGlobal")}(e),cu(e)),o=o.next(()=>function(a){const c=a.store("targetGlobal"),u={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:_.min().toTimestamp(),targetCount:0};return c.put("targetGlobalKey",u)}(i))),s<4&&r>=4&&(s!==0&&(o=o.next(()=>function(a,c){return c.store("mutations").W().next(u=>{a.deleteObjectStore("mutations"),a.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Kc,{unique:!0});const l=c.store("mutations"),h=u.map(d=>l.put(d));return f.waitFor(h)})}(e,i))),o=o.next(()=>{(function(a){a.createObjectStore("clientMetadata",{keyPath:"clientId"})})(e)})),s<5&&r>=5&&(o=o.next(()=>this.Us(i))),s<6&&r>=6&&(o=o.next(()=>(function(a){a.createObjectStore("remoteDocumentGlobal")}(e),this.Ks(i)))),s<7&&r>=7&&(o=o.next(()=>this.Gs(i))),s<8&&r>=8&&(o=o.next(()=>this.Qs(e,i))),s<9&&r>=9&&(o=o.next(()=>{(function(a){a.objectStoreNames.contains("remoteDocumentChanges")&&a.deleteObjectStore("remoteDocumentChanges")})(e)})),s<10&&r>=10&&(o=o.next(()=>this.js(i))),s<11&&r>=11&&(o=o.next(()=>{(function(a){a.createObjectStore("bundles",{keyPath:"bundleId"})})(e),function(a){a.createObjectStore("namedQueries",{keyPath:"name"})}(e)})),s<12&&r>=12&&(o=o.next(()=>{(function(a){const c=a.createObjectStore("documentOverlays",{keyPath:Ew});c.createIndex("collectionPathOverlayIndex",bw,{unique:!1}),c.createIndex("collectionGroupOverlayIndex",_w,{unique:!1})})(e)})),s<13&&r>=13&&(o=o.next(()=>function(a){const c=a.createObjectStore("remoteDocumentsV14",{keyPath:hw});c.createIndex("documentKeyIndex",dw),c.createIndex("collectionGroupIndex",fw)}(e)).next(()=>this.Ws(e,i)).next(()=>e.deleteObjectStore("remoteDocuments"))),s<14&&r>=14&&(o=o.next(()=>this.zs(e,i))),s<15&&r>=15&&(o=o.next(()=>function(a){a.createObjectStore("indexConfiguration",{keyPath:"indexId",autoIncrement:!0}).createIndex("collectionGroupIndex","collectionGroup",{unique:!1}),a.createObjectStore("indexState",{keyPath:vw}).createIndex("sequenceNumberIndex",ww,{unique:!1}),a.createObjectStore("indexEntries",{keyPath:Iw}).createIndex("documentKeyIndex",Tw,{unique:!1})}(e))),o}Ks(e){let t=0;return e.store("remoteDocuments").Z((s,r)=>{t+=wr(r)}).next(()=>{const s={byteSize:t};return e.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey",s)})}
1996Us(e){const t=e.store("mutationQueues"),s=e.store("mutations");return t.W().next(r=>f.forEach(r,i=>{const o=IDBKeyRange.bound([i.userId,-1],[i.userId,i.lastAcknowledgedBatchId]);return s.W("userMutationsIndex",o).next(a=>f.forEach(a,c=>{b(c.userId===i.userId);const u=It(this.yt,c);return Rd(e,i.userId,u).next(()=>{})}))}))}Gs(e){const t=e.store("targetDocuments"),s=e.store("remoteDocuments");return e.store("targetGlobal").get("targetGlobalKey").next(r=>{const i=[];return s.Z((o,a)=>{const c=new M(o),u=function(l){return[0,ye(l)]}(c);i.push(t.get(u).next(l=>l?f.resolve():(h=>t.put({targetId:0,path:ye(h),sequenceNumber:r.highestListenSequenceNumber}))(c)))}).next(()=>f.waitFor(i))})}Qs(e,t){e.createObjectStore("collectionParents",{keyPath:yw});const s=t.store("collectionParents"),r=new ha,i=o=>{if(r.add(o)){const a=o.lastSegment(),c=o.popLast();return s.put({collectionId:a,parent:ye(c)})}};return t.store("remoteDocuments").Z({X:!0},(o,a)=>{const c=new M(o);return i(c.popLast())}).next(()=>t.store("documentMutations").Z({X:!0},([o,a,c],u)=>{const l=Pe(a);return i(l.popLast())}))}js(e){const t=e.store("targets");return t.Z((s,r)=>{const i=Pn(r),o=kd(this.yt,i);return t.put(o)})}Ws(e,t){const s=t.store("remoteDocuments"),r=[];return s.Z((i,o)=>{const a=t.store("remoteDocumentsV14"),c=(u=o,u.document?new w(M.fromString(u.document.name).popFirst(5)):u.noDocument?w.fromSegments(u.noDocument.path):u.unknownDocument?w.fromSegments(u.unknownDocument.path):I()).path.toArray();var u;/** 1997* @license 1998* Copyright 2017 Google LLC 1999* 2000* Licensed under the Apache License, Version 2.0 (the "License"); 2001* you may not use this file except in compliance with the License. 2002* You may obtain a copy of the License at 2003* 2004* http://www.apache.org/licenses/LICENSE-2.0 2005* 2006* Unless required by applicable law or agreed to in writing, software 2007* distributed under the License is distributed on an "AS IS" BASIS, 2008* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2009* See the License for the specific language governing permissions and 2010* limitations under the License. 2011*/const l={prefixPath:c.slice(0,c.length-2),collectionGroup:c[c.length-2],documentId:c[c.length-1],readTime:o.readTime||[0,0],unknownDocument:o.unknownDocument,noDocument:o.noDocument,document:o.document,hasCommittedMutations:!!o.hasCommittedMutations};r.push(a.put(l))}).next(()=>f.waitFor(r))}zs(e,t){const s=t.store("mutations"),r=Ld(this.yt),i=new Vd(si.Bs,this.yt.ie);return s.W().next(o=>{const a=new Map;return o.forEach(c=>{var u;let l=(u=a.get(c.userId))!==null&&u!==void 0?u:N();It(this.yt,c).keys().forEach(h=>l=l.add(h)),a.set(c.userId,l)}),f.forEach(a,(c,u)=>{const l=new re(u),h=ti.re(this.yt,l),d=i.getIndexManager(l),m=ni.re(l,this.yt,d,i.referenceDelegate);return new Fd(r,m,h,d).recalculateAndSaveOverlaysForDocumentKeys(new yo(t,Se.at),c).next()})})}}function cu(n){n.createObjectStore("targetDocuments",{keyPath:mw}).createIndex("documentTargetsIndex",gw,{unique:!0}),n.createObjectStore("targets",{keyPath:"targetId"}).createIndex("queryTargetsIndex",pw,{unique:!0}),n.createObjectStore("targetGlobal")}const Li="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.";class fa{constructor(e,t,s,r,i,o,a,c,u,l,h=15){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=s,this.Hs=i,this.window=o,this.document=a,this.Js=u,this.Ys=l,this.Xs=h,this.Ss=null,this.Ds=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Zs=null,this.inForeground=!1,this.ti=null,this.ei=null,this.ni=Number.NEGATIVE_INFINITY,this.si=d=>Promise.resolve(),!fa.C())throw new v(p.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new $w(this,r),this.ii=t+"main",this.yt=new Cd(c),this.ri=new qe(this.ii,this.Xs,new Jw(this.yt)),this.Cs=new Fw(this.referenceDelegate,this.yt),this.remoteDocumentCache=Ld(this.yt),this.Ns=new kw,this.window&&this.window.localStorage?this.oi=this.window.localStorage:(this.oi=null,l===!1&&pe("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.ui().then(()=>
2011{if(!this.isPrimary&&!this.allowTabSynchronization)throw new v(p.FAILED_PRECONDITION,Li);return this.ci(),this.ai(),this.hi(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.Cs.getHighestSequenceNumber(e))}).then(e=>{this.Ss=new Se(e,this.Js)}).then(()=>{this.Ds=!0}).catch(e=>(this.ri&&this.ri.close(),Promise.reject(e)))}li(e){return this.si=async t=>{if(this.started)return e(t)},e(this.isPrimary)}setDatabaseDeletedListener(e){this.ri.L(async t=>{t.newVersion===null&&await e()})}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.Hs.enqueueAndForget(async()=>{this.started&&await this.ui()}))}ui(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",e=>Bs(e).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.fi(e).next(t=>{t||(this.isPrimary=!1,this.Hs.enqueueRetryable(()=>this.si(!1)))})}).next(()=>this.di(e)).next(t=>this.isPrimary&&!t?this._i(e).next(()=>!1):!!t&&this.wi(e).next(()=>!0))).catch(e=>{if(dt(e))return g("IndexedDbPersistence","Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return g("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1}).then(e=>{this.isPrimary!==e&&this.Hs.enqueueRetryable(()=>this.si(e)),this.isPrimary=e})}fi(e){return xn(e).get("owner").next(t=>f.resolve(this.mi(t)))}gi(e){return Bs(e).delete(this.clientId)}async yi(){if(this.isPrimary&&!this.pi(this.ni,18e5)){this.ni=Date.now();const e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",t=>{const s=ne(t,"clientMetadata");return s.W().next(r=>{const i=this.Ii(r,18e5),o=r.filter(a=>i.indexOf(a)===-1);return f.forEach(o,a=>s.delete(a.clientId)).next(()=>o)})}).catch(()=>[]);if(this.oi)for(const t of e)this.oi.removeItem(this.Ti(t.clientId))}}hi(){this.ei=this.Hs.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.ui().then(()=>this.yi()).then(()=>this.hi()))}mi(e){return!!e&&e.ownerId===this.clientId}di(e){return this.Ys?f.resolve(!0):xn(e).get("owner").next(t=>{if(t!==null&&this.pi(t.leaseTimestampMs,5e3)&&!this.Ei(t.ownerId)){if(this.mi(t)&&this.networkEnabled)return!0;if(!this.mi(t)){if(!t.allowTabSynchronization)throw new v(p.FAILED_PRECONDITION,Li);return!1}}return!(!this.networkEnabled||!this.inForeground)||Bs(e).W().next(s=>this.Ii(s,5e3).find(r=>{if(this.clientId!==r.clientId){const i=!this.networkEnabled&&r.networkEnabled,o=!this.inForeground&&r.inForeground,a=this.networkEnabled===r.networkEnabled;if(i||o&&a)return!0}return!1})===void 0)}).next(t=>(this.isPrimary!==t&&g("IndexedDbPersistence",`Client ${t?"is":"is not"} eligible for a primary lease.`),t))}async shutdown(){this.Ds=!1,this.Ai(),this.ei&&(this.ei.cancel(),this.ei=null),this.Ri(),this.bi(),await this.ri.runTransaction("shutdown","readwrite",["owner","clientMetadata"],e=>{const t=new yo(e,Se.at);return this._i(t).next(()=>this.gi(t))}),this.ri.close(),this.Pi()}Ii(e,t){return e.filter(s=>this.pi(s.updateTimeMs,t)&&!this.Ei(s.clientId))}vi(){return this.runTransaction("getActiveClients","readonly",e=>Bs(e).W().next(t=>this.Ii(t,18e5).map(s=>s.clientId)))}get started(){return this.Ds}getMutationQueue(e,t){return ni.re(e,this.yt,t,this.referenceDelegate)}getTargetCache(){return this.Cs}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new Lw(e,this.yt.ie.databaseId)}getDocumentOverlayCache(e){return ti.re(this.yt,e)}getBundleCache(){return this.Ns}runTransaction(e,t,s){g("IndexedDbPersistence","Starting transaction:",e);const r=t==="readonly"?"readonly":"readwrite",i=(o=this.Xs)===15?Aw:o===14?Ad:o===13?Sd:o===12?Sw:o===11?_d:void I();var o;let a;return this.ri.runTransaction(e,r,i,c=>(a=new yo(c,this.Ss?this.Ss.next():Se.at),t==="readwrite-primary"?this.fi(a).next(u=>!!u||this.di(a)).next(u=>{if(!u)throw pe(`Failed to obtain primary lease for action '${e}'.`),this.isPrimary=!1,this.Hs.enqueueRetryable(()=>this.si(!1)),new v(p.FAILED_PRECONDITION,Oh);return s(a)}).next(u=>this.wi(a).next(()=>u)):this.Vi(a).next(()=>s(a)))).then(c=>(a.raiseOnCommittedEvent(),c))}Vi(e){return xn(e).get("owner").next(t=>
2011{if(t!==null&&this.pi(t.leaseTimestampMs,5e3)&&!this.Ei(t.ownerId)&&!this.mi(t)&&!(this.Ys||this.allowTabSynchronization&&t.allowTabSynchronization))throw new v(p.FAILED_PRECONDITION,Li)})}wi(e){const t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return xn(e).put("owner",t)}static C(){return qe.C()}_i(e){const t=xn(e);return t.get("owner").next(s=>this.mi(s)?(g("IndexedDbPersistence","Releasing primary lease."),t.delete("owner")):f.resolve())}pi(e,t){const s=Date.now();return!(e<s-t)&&(!(e>s)||(pe(`Detected an update time that is in the future: ${e} > ${s}`),!1))}ci(){this.document!==null&&typeof this.document.addEventListener=="function"&&(this.ti=()=>{this.Hs.enqueueAndForget(()=>(this.inForeground=this.document.visibilityState==="visible",this.ui()))},this.document.addEventListener("visibilitychange",this.ti),this.inForeground=this.document.visibilityState==="visible")}Ri(){this.ti&&(this.document.removeEventListener("visibilitychange",this.ti),this.ti=null)}ai(){var e;typeof((e=this.window)===null||e===void 0?void 0:e.addEventListener)=="function"&&(this.Zs=()=>{this.Ai(),Tp()&&navigator.appVersion.match(/Version\/1[45]/)&&this.Hs.enterRestrictedMode(!0),this.Hs.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.Zs))}bi(){this.Zs&&(this.window.removeEventListener("pagehide",this.Zs),this.Zs=null)}Ei(e){var t;try{const s=((t=this.oi)===null||t===void 0?void 0:t.getItem(this.Ti(e)))!==null;return g("IndexedDbPersistence",`Client '${e}' ${s?"is":"is not"} zombied in LocalStorage`),s}catch(s){return pe("IndexedDbPersistence","Failed to get zombied client id.",s),!1}}Ai(){if(this.oi)try{this.oi.setItem(this.Ti(this.clientId),String(Date.now()))}catch(e){pe("Failed to set zombie client id.",e)}}Pi(){if(this.oi)try{this.oi.removeItem(this.Ti(this.clientId))}catch{}}Ti(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function xn(n){return ne(n,"owner")}function Bs(n){return ne(n,"clientMetadata")}function Zw(n,e){let t=n.projectId;return n.isDefaultDatabase||(t+="."+n.database),"firestore/"+e+"/"+t+"/"}/** 2012 * @license 2013 * Copyright 2017 Google LLC 2014 * 2015 * Licensed under the Apache License, Version 2.0 (the "License"); 2016 * you may not use this file except in compliance with the License. 2017 * You may obtain a copy of the License at 2018 * 2019 * http://www.apache.org/licenses/LICENSE-2.0 2020 * 2021 * Unless required by applicable law or agreed to in writing, software 2022 * distributed under the License is distributed on an "AS IS" BASIS, 2023 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2024 * See the License for the specific language governing permissions and 2025 * limitations under the License. 2026 */class pa{constructor(e,t,s,r){this.targetId=e,this.fromCache=t,this.Si=s,this.Di=r}static Ci(e,t){let s=N(),r=N();for(const i of t.docChanges)switch(i.type){case 0:s=s.add(i.doc.key);break;case 1:r=r.add(i.doc.key)}return new pa(e,t.fromCache,s,r)}}/** 2027 * @license 2028 * Copyright 2019 Google LLC 2029 * 2030 * Licensed under the Apache License, Version 2.0 (the "License"); 2031 * you may not use this file except in compliance with the License. 2032 * You may obtain a copy of the License at 2033 * 2034 * http://www.apache.org/licenses/LICENSE-2.0 2035 * 2036 * Unless required by applicable law or agreed to in writing, software 2037 * distributed under the License is distributed on an "AS IS" BASIS, 2038 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2039 * See the License for the specific language governing permissions and 2040 * limitations under the License. 2041 */class Ud{constructor(){this.xi=!1}initialize(e,t){this.Ni=e,this.indexManager=t,this.xi=!0}getDocumentsMatchingQuery(e,t,s,r){return this.ki(e,t).next(i=>i||this.Oi(e,t,r,s)).next(i=>i||this.Mi(e,t))}ki(e,t){if(Pc(t))return f.resolve(null);let s=xe(t);return this.indexManager.getIndexType(e,s).next(r=>r===0?null:(t.limit!==null&&r===1&&(t=ho(t,null,"F"),s=xe(t)),this.indexManager.getDocumentsMatchingTarget(e,s).next(i=>{const o=N(...i);return this.Ni.getDocuments(e,o).next(a=>this.indexManager.getMinOffset(e,s).next(c=>{const u=this.Fi(t,a);return this.$i(t,u,o,c.readTime)?this.ki(e,ho(t,null,"F")):this.Bi(e,u,t,c)}))})))}Oi(e,t,s,r){return Pc(t)||r.isEqual(_.min())?this.Mi(e,t):this.Ni.getDocuments(e,s).next(i=>{const o=this.Fi(t,i);return this.$i(t,o,s,r)?this.Mi(e,t):(so()<=O.DEBUG&&g("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),fo(t)),this.Bi(e,o,t,mv(r,-1)))})}Fi(e,t){let s=new L(Qh(e));return t.forEach((r,i)=>{ws(e,i)&&(s=s.add(i))}),s}$i(e,t,s,r){if(e.limit===null)return!1;if(s.size!==t.size)return!0;const i=e.limitType==="F"?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}Mi(e,t){return so()<=O.DEBUG&&g("QueryEngine","Using full collection scan to execute query:",fo(t)),this.Ni.getDocumentsMatchingQuery(e,t,_e.min())}
2041Bi(e,t,s,r){return this.Ni.getDocumentsMatchingQuery(e,s,r).next(i=>(t.forEach(o=>{i=i.insert(o.key,o)}),i))}}/** 2042 * @license 2043 * Copyright 2020 Google LLC 2044 * 2045 * Licensed under the Apache License, Version 2.0 (the "License"); 2046 * you may not use this file except in compliance with the License. 2047 * You may obtain a copy of the License at 2048 * 2049 * http://www.apache.org/licenses/LICENSE-2.0 2050 * 2051 * Unless required by applicable law or agreed to in writing, software 2052 * distributed under the License is distributed on an "AS IS" BASIS, 2053 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2054 * See the License for the specific language governing permissions and 2055 * limitations under the License. 2056 */class eI{constructor(e,t,s,r){this.persistence=e,this.Li=t,this.yt=r,this.qi=new Y(D),this.Ui=new ft(i=>Ft(i),ys),this.Ki=new Map,this.Gi=e.getRemoteDocumentCache(),this.Cs=e.getTargetCache(),this.Ns=e.getBundleCache(),this.Qi(s)}Qi(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Fd(this.Gi,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Gi.setIndexManager(this.indexManager),this.Li.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.qi))}}function Bd(n,e,t,s){return new eI(n,e,t,s)}async function $d(n,e){const t=k(n);return await t.persistence.runTransaction("Handle user change","readonly",s=>{let r;return t.mutationQueue.getAllMutationBatches(s).next(i=>(r=i,t.Qi(e),t.mutationQueue.getAllMutationBatches(s))).next(i=>{const o=[],a=[];let c=N();for(const u of r){o.push(u.batchId);for(const l of u.mutations)c=c.add(l.key)}for(const u of i){a.push(u.batchId);for(const l of u.mutations)c=c.add(l.key)}return t.localDocuments.getDocuments(s,c).next(u=>({ji:u,removedBatchIds:o,addedBatchIds:a}))})})}function tI(n,e){const t=k(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",s=>{const r=e.batch.keys(),i=t.Gi.newChangeBuffer({trackRemovals:!0});return function(o,a,c,u){const l=c.batch,h=l.keys();let d=f.resolve();return h.forEach(m=>{d=d.next(()=>u.getEntry(a,m)).next(y=>{const E=c.docVersions.get(m);b(E!==null),y.version.compareTo(E)<0&&(l.applyToRemoteDocument(y,c),y.isValidDocument()&&(y.setReadTime(c.commitVersion),u.addEntry(y)))})}),d.next(()=>o.mutationQueue.removeMutationBatch(a,l))}(t,s,e,i).next(()=>i.apply(s)).next(()=>t.mutationQueue.performConsistencyCheck(s)).next(()=>t.documentOverlayCache.removeOverlaysForBatchId(s,r,e.batch.batchId)).next(()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(s,function(o){let a=N();for(let c=0;c<o.mutationResults.length;++c)o.mutationResults[c].transformResults.length>0&&(a=a.add(o.batch.mutations[c].key));return a}(e))).next(()=>t.localDocuments.getDocuments(s,r))})}function qd(n){const e=k(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Cs.getLastRemoteSnapshotVersion(t))}function nI(n,e){const t=k(n),s=e.snapshotVersion;let r=t.qi;return t.persistence.runTransaction("Apply remote event","readwrite-primary",i=>{const o=t.Gi.newChangeBuffer({trackRemovals:!0});r=t.qi;const a=[];
2056e.targetChanges.forEach((l,h)=>{const d=r.get(h);if(!d)return;a.push(t.Cs.removeMatchingKeys(i,l.removedDocuments,h).next(()=>t.Cs.addMatchingKeys(i,l.addedDocuments,h)));let m=d.withSequenceNumber(i.currentSequenceNumber);e.targetMismatches.has(h)?m=m.withResumeToken(ae.EMPTY_BYTE_STRING,_.min()).withLastLimboFreeSnapshotVersion(_.min()):l.resumeToken.approximateByteSize()>0&&(m=m.withResumeToken(l.resumeToken,s)),r=r.insert(h,m),function(y,E,S){return y.resumeToken.approximateByteSize()===0||E.snapshotVersion.toMicroseconds()-y.snapshotVersion.toMicroseconds()>=3e8?!0:S.addedDocuments.size+S.modifiedDocuments.size+S.removedDocuments.size>0}(d,m,l)&&a.push(t.Cs.updateTargetData(i,m))});let c=Te(),u=N();if(e.documentUpdates.forEach(l=>{e.resolvedLimboDocuments.has(l)&&a.push(t.persistence.referenceDelegate.updateLimboDocument(i,l))}),a.push(sI(i,o,e.documentUpdates).next(l=>{c=l.Wi,u=l.zi})),!s.isEqual(_.min())){const l=t.Cs.getLastRemoteSnapshotVersion(i).next(h=>t.Cs.setTargetsMetadata(i,i.currentSequenceNumber,s));a.push(l)}return f.waitFor(a).next(()=>o.apply(i)).next(()=>t.localDocuments.getLocalViewOfDocuments(i,c,u)).next(()=>c)}).then(i=>(t.qi=r,i))}function sI(n,e,t){let s=N(),r=N();return t.forEach(i=>s=s.add(i)),e.getEntries(n,s).next(i=>{let o=Te();return t.forEach((a,c)=>{const u=i.get(a);c.isFoundDocument()!==u.isFoundDocument()&&(r=r.add(a)),c.isNoDocument()&&c.version.isEqual(_.min())?(e.removeEntry(a,c.readTime),o=o.insert(a,c)):!u.isValidDocument()||c.version.compareTo(u.version)>0||c.version.compareTo(u.version)===0&&u.hasPendingWrites?(e.addEntry(c),o=o.insert(a,c)):g("LocalStore","Ignoring outdated watch update for ",a,". Current version:",u.version," Watch version:",c.version)}),{Wi:o,zi:r}})}function rI(n,e){const t=k(n);return t.persistence.runTransaction("Get next mutation batch","readonly",s=>(e===void 0&&(e=-1),t.mutationQueue.getNextMutationBatchAfterBatchId(s,e)))}function iI(n,e){const t=k(n);return t.persistence.runTransaction("Allocate target","readwrite",s=>{let r;return t.Cs.getTargetData(s,e).next(i=>i?(r=i,f.resolve(r)):t.Cs.allocateTargetId(s).next(o=>(r=new rt(e,o,0,s.currentSequenceNumber),t.Cs.addTargetData(s,r).next(()=>r))))}).then(s=>{const r=t.qi.get(s.targetId);return(r===null||s.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(t.qi=t.qi.insert(s.targetId,s),t.Ui.set(e,s.targetId)),s})}async function To(n,e,t){const s=k(n),r=s.qi.get(e),i=t?"readwrite":"readwrite-primary";try{t||await s.persistence.runTransaction("Release target",i,o=>s.persistence.referenceDelegate.removeTarget(o,r))}catch(o){if(!dt(o))throw o;g("LocalStore",`Failed to update sequence numbers for target ${e}: ${o}`)}s.qi=s.qi.remove(e),s.Ui.delete(r.target)}function uu(n,e,t){const s=k(n);let r=_.min(),i=N();return s.persistence.runTransaction("Execute query","readonly",o=>function(a,c,u){const l=k(a),h=l.Ui.get(u);return h!==void 0?f.resolve(l.qi.get(h)):l.Cs.getTargetData(c,u)}(s,o,xe(e)).next(a=>{if(a)return r=a.lastLimboFreeSnapshotVersion,s.Cs.getMatchingKeysForTargetId(o,a.targetId).next(c=>{i=c})}).next(()=>s.Li.getDocumentsMatchingQuery(o,e,t?r:_.min(),t?i:N())).next(a=>(oI(s,Mv(e),a),{documents:a,Hi:i})))}function oI(n,e,t){let s=n.Ki.get(e)||_.min();t.forEach((r,i)=>{i.readTime.compareTo(s)>0&&(s=i.readTime)}),n.Ki.set(e,s)}class lu{constructor(){this.activeTargetIds=ld()}er(e){this.activeTargetIds=this.activeTargetIds.add(e)}nr(e){this.activeTargetIds=this.activeTargetIds.delete(e)}tr(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class jd{constructor(){this.Lr=new lu,this.qr={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}
2056updateMutationState(e,t,s){}addLocalQueryTarget(e){return this.Lr.er(e),this.qr[e]||"not-current"}updateQueryState(e,t,s){this.qr[e]=t}removeLocalQueryTarget(e){this.Lr.nr(e)}isLocalQueryTarget(e){return this.Lr.activeTargetIds.has(e)}clearQueryState(e){delete this.qr[e]}getAllActiveQueryTargets(){return this.Lr.activeTargetIds}isActiveQueryTarget(e){return this.Lr.activeTargetIds.has(e)}start(){return this.Lr=new lu,Promise.resolve()}handleUserChange(e,t,s){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/** 2057 * @license 2058 * Copyright 2019 Google LLC 2059 * 2060 * Licensed under the Apache License, Version 2.0 (the "License"); 2061 * you may not use this file except in compliance with the License. 2062 * You may obtain a copy of the License at 2063 * 2064 * http://www.apache.org/licenses/LICENSE-2.0 2065 * 2066 * Unless required by applicable law or agreed to in writing, software 2067 * distributed under the License is distributed on an "AS IS" BASIS, 2068 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2069 * See the License for the specific language governing permissions and 2070 * limitations under the License. 2071 */class aI{Ur(e){}shutdown(){}}/** 2072 * @license 2073 * Copyright 2019 Google LLC 2074 * 2075 * Licensed under the Apache License, Version 2.0 (the "License"); 2076 * you may not use this file except in compliance with the License. 2077 * You may obtain a copy of the License at 2078 * 2079 * http://www.apache.org/licenses/LICENSE-2.0 2080 * 2081 * Unless required by applicable law or agreed to in writing, software 2082 * distributed under the License is distributed on an "AS IS" BASIS, 2083 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2084 * See the License for the specific language governing permissions and 2085 * limitations under the License. 2086 */class hu{constructor(){this.Kr=()=>this.Gr(),this.Qr=()=>this.jr(),this.Wr=[],this.zr()}Ur(e){this.Wr.push(e)}shutdown(){window.removeEventListener("online",this.Kr),window.removeEventListener("offline",this.Qr)}zr(){window.addEventListener("online",this.Kr),window.addEventListener("offline",this.Qr)}Gr(){g("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.Wr)e(0)}jr(){g("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.Wr)e(1)}static C(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/** 2087 * @license 2088 * Copyright 2020 Google LLC 2089 * 2090 * Licensed under the Apache License, Version 2.0 (the "License"); 2091 * you may not use this file except in compliance with the License. 2092 * You may obtain a copy of the License at 2093 * 2094 * http://www.apache.org/licenses/LICENSE-2.0 2095 * 2096 * Unless required by applicable law or agreed to in writing, software 2097 * distributed under the License is distributed on an "AS IS" BASIS, 2098 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2099 * See the License for the specific language governing permissions and 2100 * limitations under the License. 2101 */const cI={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};/** 2102 * @license 2103 * Copyright 2017 Google LLC 2104 * 2105 * Licensed under the Apache License, Version 2.0 (the "License"); 2106 * you may not use this file except in compliance with the License. 2107 * You may obtain a copy of the License at 2108 * 2109 * http://www.apache.org/licenses/LICENSE-2.0 2110 * 2111 * Unless required by applicable law or agreed to in writing, software 2112 * distributed under the License is distributed on an "AS IS" BASIS, 2113 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2114 * See the License for the specific language governing permissions and 2115 * limitations under the License. 2116 */class uI{constructor(e){this.Hr=e.Hr,this.Jr=e.Jr}Yr(e){this.Xr=e}Zr(e){this.eo=e}onMessage(e){this.no=e}close(){this.Jr()}send(e){this.Hr(e)}so(){this.Xr()}io(e){this.eo(e)}ro(e){this.no(e)}}/** 2117 * @license 2118 * Copyright 2017 Google LLC 2119 * 2120 * Licensed under the Apache License, Version 2.0 (the "License"); 2121 * you may not use this file except in compliance with the License. 2122 * You may obtain a copy of the License at 2123 * 2124 * http://www.apache.org/licenses/LICENSE-2.0 2125 * 2126 * Unless required by applicable law or agreed to in writing, softw
2126are 2127 * distributed under the License is distributed on an "AS IS" BASIS, 2128 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2129 * See the License for the specific language governing permissions and 2130 * limitations under the License. 2131 */class lI extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http";this.oo=t+"://"+e.host,this.uo="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}get co(){return!1}ao(e,t,s,r,i){const o=this.ho(e,t);g("RestConnection","Sending: ",o,s);const a={};return this.lo(a,r,i),this.fo(e,o,a,s).then(c=>(g("RestConnection","Received: ",c),c),c=>{throw hr("RestConnection",`${e} failed with error: `,c,"url: ",o,"request:",s),c})}_o(e,t,s,r,i,o){return this.ao(e,t,s,r,i)}lo(e,t,s){e["X-Goog-Api-Client"]="gl-js/ fire/"+In,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((r,i)=>e[i]=r),s&&s.headers.forEach((r,i)=>e[i]=r)}ho(e,t){const s=cI[e];return`${this.oo}/v1/${t}:${s}`}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams}fo(e,t,s,r){return new Promise((i,o)=>{const a=new rv;a.setWithCredentials(!0),a.listenOnce(tv.COMPLETE,()=>{try{switch(a.getLastErrorCode()){case Mi.NO_ERROR:const u=a.getResponseJson();g("Connection","XHR received:",JSON.stringify(u)),i(u);break;case Mi.TIMEOUT:g("Connection",'RPC "'+e+'" timed out'),o(new v(p.DEADLINE_EXCEEDED,"Request time out"));break;case Mi.HTTP_ERROR:const l=a.getStatus();if(g("Connection",'RPC "'+e+'" failed with status:',l,"response text:",a.getResponseText()),l>0){let h=a.getResponseJson();Array.isArray(h)&&(h=h[0]);const d=h==null?void 0:h.error;if(d&&d.status&&d.message){const m=function(y){const E=y.toLowerCase().replace(/_/g,"-");return Object.values(p).indexOf(E)>=0?E:p.UNKNOWN}(d.status);o(new v(m,d.message))}else o(new v(p.UNKNOWN,"Server responded with status "+a.getStatus()))}else o(new v(p.UNAVAILABLE,"Connection failed."));break;default:I()}}finally{g("Connection",'RPC "'+e+'" completed.')}});const c=JSON.stringify(r);a.send(t,"POST",c,s,15)})}wo(e,t,s){const r=[this.oo,"/","google.firestore.v1.Firestore","/",e,"/channel"],i=Zy(),o=ev(),a={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};this.useFetchStreams&&(a.xmlHttpFactory=new sv({})),this.lo(a.initMessageHeaders,t,s),a.encodeInitMessageHeaders=!0;const c=r.join("");g("Connection","Creating WebChannel: "+c,a);const u=i.createWebChannel(c,a);let l=!1,h=!1;const d=new uI({Hr:y=>{h?g("Connection","Not sending because WebChannel is closed:",y):(l||(g("Connection","Opening WebChannel transport."),u.open(),l=!0),g("Connection","WebChannel sending:",y),u.send(y))},Jr:()=>u.close()}),m=(y,E,S)=>{y.listen(E,V=>{try{S(V)}catch(B){setTimeout(()=>{throw B},0)}})};return m(u,Ps.EventType.OPEN,()=>{h||g("Connection","WebChannel transport opened.")}),m(u,Ps.EventType.CLOSE,()=>{h||(h=!0,g("Connection","WebChannel transport closed"),d.io())}),m(u,Ps.EventType.ERROR,y=>{h||(h=!0,hr("Connection","WebChannel transport errored:",y),d.io(new v(p.UNAVAILABLE,"The operation could not be completed")))}),m(u,Ps.EventType.MESSAGE,y=>{var E;if(!h){const S=y.data[0];b(!!S);const V=S,B=V.error||((E=V[0])===null||E===void 0?void 0:E.error);if(B){g("Connection","WebChannel received error:",B);const F=B.status;let X=function(U){const se=W[U];if(se!==void 0)return od(se)}(F),G=B.message;X===void 0&&(X=p.INTERNAL,G="Unknown error status: "+F+" with message "+B.message),h=!0,d.io(new v(X,G)),u.close()}else g("Connection","WebChannel received:",S),d.ro(S)}}),m(o,nv.STAT_EVENT,y=>{y.stat===Tc.PROXY?g("Connection","Detected buffering proxy"):y.stat===Tc.NOPROXY&&g("Connection","Detected no buffering proxy")}),setTimeout(()=>{d.so()},0),d}}/** 2132 * @license 2133 * Copyright 2020 Google LLC 2134 * 2135 * Licensed under the Apache License, Version 2.0 (the "License");
2136 * you may not use this file except in compliance with the License. 2137 * You may obtain a copy of the License at 2138 * 2139 * http://www.apache.org/licenses/LICENSE-2.0 2140 * 2141 * Unless required by applicable law or agreed to in writing, software 2142 * distributed under the License is distributed on an "AS IS" BASIS, 2143 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2144 * See the License for the specific language governing permissions and 2145 * limitations under the License. 2146 *//** 2147 * @license 2148 * Copyright 2020 Google LLC 2149 * 2150 * Licensed under the Apache License, Version 2.0 (the "License"); 2151 * you may not use this file except in compliance with the License. 2152 * You may obtain a copy of the License at 2153 * 2154 * http://www.apache.org/licenses/LICENSE-2.0 2155 * 2156 * Unless required by applicable law or agreed to in writing, software 2157 * distributed under the License is distributed on an "AS IS" BASIS, 2158 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2159 * See the License for the specific language governing permissions and 2160 * limitations under the License. 2161 */function hI(){return typeof window<"u"?window:null}function Hs(){return typeof document<"u"?document:null}/** 2162 * @license 2163 * Copyright 2020 Google LLC 2164 * 2165 * Licensed under the Apache License, Version 2.0 (the "License"); 2166 * you may not use this file except in compliance with the License. 2167 * You may obtain a copy of the License at 2168 * 2169 * http://www.apache.org/licenses/LICENSE-2.0 2170 * 2171 * Unless required by applicable law or agreed to in writing, software 2172 * distributed under the License is distributed on an "AS IS" BASIS, 2173 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2174 * See the License for the specific language governing permissions and 2175 * limitations under the License. 2176 */function ri(n){return new Zv(n,!0)}class Gd{constructor(e,t,s=1e3,r=1.5,i=6e4){this.Hs=e,this.timerId=t,this.mo=s,this.yo=r,this.po=i,this.Io=0,this.To=null,this.Eo=Date.now(),this.reset()}reset(){this.Io=0}Ao(){this.Io=this.po}Ro(e){this.cancel();const t=Math.floor(this.Io+this.bo()),s=Math.max(0,Date.now()-this.Eo),r=Math.max(0,t-s);r>0&&g("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.Io} ms, delay with jitter: ${t} ms, last attempt: ${s} ms ago)`),this.To=this.Hs.enqueueAfterDelay(this.timerId,r,()=>(this.Eo=Date.now(),e())),this.Io*=this.yo,this.Io<this.mo&&(this.Io=this.mo),this.Io>this.po&&(this.Io=this.po)}Po(){this.To!==null&&(this.To.skipDelay(),this.To=null)}cancel(){this.To!==null&&(this.To.cancel(),this.To=null)}bo(){return(Math.random()-.5)*this.Io}}/** 2177 * @license 2178 * Copyright 2017 Google LLC 2179 * 2180 * Licensed under the Apache License, Version 2.0 (the "License"); 2181 * you may not use this file except in compliance with the License. 2182 * You may obtain a copy of the License at 2183 * 2184 * http://www.apache.org/licenses/LICENSE-2.0 2185 * 2186 * Unless required by applicable law or agreed to in writing, software 2187 * distributed under the License is distributed on an "AS IS" BASIS, 2188 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2189 * See the License for the specific language governing permissions and 2190 * limitations under the License. 2191 */class Kd{constructor(e,t,s,r,i,o,a,c){this.Hs=e,this.vo=s,this.Vo=r,this.connection=i,this.authCredentialsProvider=o,this.appCheckCredentialsProvider=a,this.listener=c,this.state=0,this.So=0,this.Do=null,this.Co=null,this.stream=null,this.xo=new Gd(e,t)}No(){return this.state===1||this.state===5||this.ko()}ko(){return this.state===2||this.state===3}start(){this.state!==4?this.auth():this.Oo()}async stop(){this.No()&&await this.close(0)}Mo(){this.state=0,this.xo.reset()}Fo(){this.ko()&&this.Do===null&&(this.Do=this.Hs.enqueueAfterDelay(this.vo,6e4,()=>this.$o()))}Bo(e){this.Lo(),this.stream.send(e)}async $o(){if(this.ko())return this.close(0)}Lo(){this.Do&&(this.Do.cancel(),this.Do=null)}qo(){this.Co&&(this.Co.cancel(),this.Co=null)}async close(e,t){this.Lo(),this.qo(),this.xo.cancel(),this.So++,e!==4?this.xo.reset():t&&t.code===p.RESOURCE_EXHAUSTED?(pe(t.toString()),pe("Using maximum backoff delay to prevent overloading the backend."),this.xo.Ao()):t&&t.code===p.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.Uo(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Zr(t)}Uo(){}auth(){this.state=1;const e=this.Ko(this.So),t=this.So;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([s,r])=>{this.So===t&&this.Go(s,r)},s=>{e(()=>{const r=new v(p.UNKNOWN,"Fetching auth token failed: "+s.message);return this.Qo(r)})})}Go(e,t){const s=this.Ko(this.So);this.stream=this.jo(e,t),this.stream.Yr(()=>{s(()=>(this.state=2,this.Co=this.Hs.enqueueAfterDelay(this.Vo,1e4,()=>(this.ko()&&(this.state=3),Promise.resolve())),this.listener.Yr()))}),this.stream.Zr(r=>{s(()=>this.Qo(r))}),this.stream.onMessage(r=>{s(()=>this.onMessage(r))})}Oo(){this.state=5,this.xo.Ro(async()=>{this.state=0,this.start()})}Qo(e){return g("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}Ko(e){return t=>{this.Hs.enqueueAndForget(()=>this.So===e?t():(g("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class dI extends Kd{constructor(e,t,s,r,i,o){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,s,r,o),this.yt=i}jo(e,t){return this.connection.wo("Listen",e,t)}onMessage(e){this.xo.reset();const t=nw(this.yt,e),s=function(r){if(!("targetChange"in r))return _.min();const i=r.targetChange;return i.targetIds&&i.targetIds.length?_.min():i.readTime?ge(i.readTime):_.min()}(e);return this.listener.Wo(t,s)}zo(e){const t={};t.database=mo(this.yt),t.addTarget=function(r,i){let o;const a=i.target;return o=fr(a)?{documents:yd(r,a)}:{query:vd(r,a)},o.targetId=i.targetId,i.resumeToken.approximateByteSize()>0?o.resumeToken=fd(r,i.resumeToken):i.snapshotVersion.compareTo(_.min())>0&&(o.readTime=pn(r,i.snapshotVersion.toTimestamp())),o}(this.yt,e);const s=rw(this.yt,e);s&&(t.labels=s),this.Bo(t)}Ho(e){const t={};t.database=mo(this.yt),t.removeTarget=e,this.Bo(t)}}class fI extends Kd{constructor(e,t,s,r,i,o){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,s,r,o),this.yt=i,this.Jo=!1}get Yo(){return this.Jo}start(){this.Jo=!1,this.lastStreamToken=void 0,super.start()}Uo(){this.Jo&&this.Xo([])}jo(e,t){return this.connection.wo("Write",e,t)}onMessage(e){if(b(!!e.streamToken),this.lastStreamToken=e.streamToken,this.Jo){this.xo.reset();const t=sw(e.writeResults,e.commitTime),s=ge(e.commitTime);return this.listener.Zo(s,t)}return b(!e.writeResults||e.writeResults.length===0),this.Jo=!0,this.listener.tu()}eu(){const e={};e.database=mo(this.yt),this.Bo(e)}Xo(e){const t={streamToken:this.lastStreamToken,writes:e.map(s=>gr(this.yt,s))};this.Bo(t)}}/** 2192 * @license 2193 * Copyright 2017 Google LLC 2194 * 2195 * Licensed under the Apache License, Version 2.0 (the "License");
2196 * you may not use this file except in compliance with the License. 2197 * You may obtain a copy of the License at 2198 * 2199 * http://www.apache.org/licenses/LICENSE-2.0 2200 * 2201 * Unless required by applicable law or agreed to in writing, software 2202 * distributed under the License is distributed on an "AS IS" BASIS, 2203 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2204 * See the License for the specific language governing permissions and 2205 * limitations under the License. 2206 */class pI extends class{}{constructor(e,t,s,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=s,this.yt=r,this.nu=!1}su(){if(this.nu)throw new v(p.FAILED_PRECONDITION,"The client has already been terminated.")}ao(e,t,s){return this.su(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([r,i])=>this.connection.ao(e,t,s,r,i)).catch(r=>{throw r.name==="FirebaseError"?(r.code===p.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),r):new v(p.UNKNOWN,r.toString())})}_o(e,t,s,r){return this.su(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,o])=>this.connection._o(e,t,s,i,o,r)).catch(i=>{throw i.name==="FirebaseError"?(i.code===p.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new v(p.UNKNOWN,i.toString())})}terminate(){this.nu=!0}}class mI{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.iu=0,this.ru=null,this.ou=!0}uu(){this.iu===0&&(this.cu("Unknown"),this.ru=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.ru=null,this.au("Backend didn't respond within 10 seconds."),this.cu("Offline"),Promise.resolve())))}hu(e){this.state==="Online"?this.cu("Unknown"):(this.iu++,this.iu>=1&&(this.lu(),this.au(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.cu("Offline")))}set(e){this.lu(),this.iu=0,e==="Online"&&(this.ou=!1),this.cu(e)}cu(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}au(e){const t=`Could not reach Cloud Firestore backend. ${e} 2207This 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.ou?(pe(t),this.ou=!1):g("OnlineStateTracker",t)}lu(){this.ru!==null&&(this.ru.cancel(),this.ru=null)}}/** 2208 * @license 2209 * Copyright 2017 Google LLC 2210 * 2211 * Licensed under the Apache License, Version 2.0 (the "License"); 2212 * you may not use this file except in compliance with the License. 2213 * You may obtain a copy of the License at 2214 * 2215 * http://www.apache.org/licenses/LICENSE-2.0 2216 * 2217 * Unless required by applicable law or agreed to in writing, software 2218 * distributed under the License is distributed on an "AS IS" BASIS, 2219 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2220 * See the License for the specific language governing permissions and 2221 * limitations under the License. 2222 */class gI{constructor(e,t,s,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=s,this.remoteSyncer={},this.fu=[],this.du=new Map,this._u=new Set,this.wu=[],this.mu=i,this.mu.Ur(o=>{s.enqueueAndForget(async()=>{zt(this)&&(g("RemoteStore","Restarting streams for network reachability change."),await async function(a){const c=k(a);c._u.add(4),await Es(c),c.gu.set("Unknown"),c._u.delete(4),await ii(c)}(this))})}),this.gu=new mI(s,r)}}async function ii(n){if(zt(n))for(const e of n.wu)await e(!0)}async function Es(n){for(const e of n.wu)await e(!1)}function zd(n,e){const t=k(n);t.du.has(e.targetId)||(t.du.set(e.targetId,e),ya(t)?ga(t):bn(t).ko()&&ma(t,e))}function Hd(n,e){const t=k(n),s=bn(t);t.du.delete(e),s.ko()&&Wd(t,e),t.du.size===0&&(s.ko()?s.Fo():zt(t)&&t.gu.set("Unknown"))}function ma(n,e){n.yu.Ot(e.targetId),bn(n).zo(e)}function Wd(n,e){n.yu.Ot(e),bn(n).Ho(e)}function ga(n){n.yu=new Qv({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),ne:e=>n.du.get(e)||null}),bn(n).start(),n.gu.uu()}function ya(n){return zt(n)&&!bn(n).No()&&n.du.size>0}function zt(n){return k(n)._u.size===0}function Qd(n){n.yu=void 0}async function yI(n){n.du.forEach((e,t)=>{ma(n,e)})}async function vI(n,e){Qd(n),ya(n)?(n.gu.hu(e),ga(n)):n.gu.set("Unknown")}async function wI(n,e,t){if(n.gu.set("Online"),e instanceof dd&&e.state===2&&e.cause)try{await async function(s,r){const i=r.cause;for(const o of r.targetIds)s.du.has(o)&&(await s.remoteSyncer.rejectListen(o,i),s.du.delete(o),s.yu.removeTarget(o))}(n,e)}catch(s){g("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),s),await Ir(n,s)}else if(e instanceof Ks?n.yu.Kt(e):e instanceof hd?n.yu.Jt(e):n.yu.jt(e),!t.isEqual(_.min()))try{const s=await qd(n.localStore);t.compareTo(s)>=0&&await function(r,i){const o=r.yu.Zt(i);
2222return o.targetChanges.forEach((a,c)=>{if(a.resumeToken.approximateByteSize()>0){const u=r.du.get(c);u&&r.du.set(c,u.withResumeToken(a.resumeToken,i))}}),o.targetMismatches.forEach(a=>{const c=r.du.get(a);if(!c)return;r.du.set(a,c.withResumeToken(ae.EMPTY_BYTE_STRING,c.snapshotVersion)),Wd(r,a);const u=new rt(c.target,a,1,c.sequenceNumber);ma(r,u)}),r.remoteSyncer.applyRemoteEvent(o)}(n,t)}catch(s){g("RemoteStore","Failed to raise snapshot:",s),await Ir(n,s)}}async function Ir(n,e,t){if(!dt(e))throw e;n._u.add(1),await Es(n),n.gu.set("Offline"),t||(t=()=>qd(n.localStore)),n.asyncQueue.enqueueRetryable(async()=>{g("RemoteStore","Retrying IndexedDB access"),await t(),n._u.delete(1),await ii(n)})}function Yd(n,e){return e().catch(t=>Ir(n,t,e))}async function bs(n){const e=k(n),t=ct(e);let s=e.fu.length>0?e.fu[e.fu.length-1].batchId:-1;for(;II(e);)try{const r=await rI(e.localStore,s);if(r===null){e.fu.length===0&&t.Fo();break}s=r.batchId,TI(e,r)}catch(r){await Ir(e,r)}Xd(e)&&Jd(e)}function II(n){return zt(n)&&n.fu.length<10}function TI(n,e){n.fu.push(e);const t=ct(n);t.ko()&&t.Yo&&t.Xo(e.mutations)}function Xd(n){return zt(n)&&!ct(n).No()&&n.fu.length>0}function Jd(n){ct(n).start()}async function EI(n){ct(n).eu()}async function bI(n){const e=ct(n);for(const t of n.fu)e.Xo(t.mutations)}async function _I(n,e,t){const s=n.fu.shift(),r=ca.from(s,e,t);await Yd(n,()=>n.remoteSyncer.applySuccessfulWrite(r)),await bs(n)}async function SI(n,e){e&&ct(n).Yo&&await async function(t,s){if(r=s.code,Gv(r)&&r!==p.ABORTED){const i=t.fu.shift();ct(t).Mo(),await Yd(t,()=>t.remoteSyncer.rejectFailedWrite(i.batchId,s)),await bs(t)}var r}(n,e),Xd(n)&&Jd(n)}async function du(n,e){const t=k(n);t.asyncQueue.verifyOperationInProgress(),g("RemoteStore","RemoteStore received new credentials");const s=zt(t);t._u.add(3),await Es(t),s&&t.gu.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t._u.delete(3),await ii(t)}async function AI(n,e){const t=k(n);e?(t._u.delete(2),await ii(t)):e||(t._u.add(2),await Es(t),t.gu.set("Unknown"))}function bn(n){return n.pu||(n.pu=function(e,t,s){const r=k(e);return r.su(),new dI(t,r.connection,r.authCredentials,r.appCheckCredentials,r.yt,s)}(n.datastore,n.asyncQueue,{Yr:yI.bind(null,n),Zr:vI.bind(null,n),Wo:wI.bind(null,n)}),n.wu.push(async e=>{e?(n.pu.Mo(),ya(n)?ga(n):n.gu.set("Unknown")):(await n.pu.stop(),Qd(n))})),n.pu}function ct(n){return n.Iu||(n.Iu=function(e,t,s){const r=k(e);return r.su(),new fI(t,r.connection,r.authCredentials,r.appCheckCredentials,r.yt,s)}(n.datastore,n.asyncQueue,{Yr:EI.bind(null,n),Zr:SI.bind(null,n),tu:bI.bind(null,n),Zo:_I.bind(null,n)}),n.wu.push(async e=>{e?(n.Iu.Mo(),await bs(n)):(await n.Iu.stop(),n.fu.length>0&&(g("RemoteStore",`Stopping write stream with ${n.fu.length} pending writes`),n.fu=[]))})),n.Iu}/** 2223 * @license 2224 * Copyright 2017 Google LLC 2225 * 2226 * Licensed under the Apache License, Version 2.0 (the "License"); 2227 * you may not use this file except in compliance with the License. 2228 * You may obtain a copy of the License at 2229 * 2230 * http://www.apache.org/licenses/LICENSE-2.0 2231 * 2232 * Unless required by applicable law or agreed to in writing, software 2233 * distributed under the License is distributed on an "AS IS" BASIS, 2234 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2235 * See the License for the specific language governing permissions and 2236 * limitations under the License. 2237 */class va{constructor(e,t,s,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=s,this.op=r,this.removalCallback=i,this.deferred=new De,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(o=>{})}static createAndSchedule(e,t,s,r,i){const o=Date.now()+s,a=new va(e,t,o,r,i);return a.start(s),a}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new v(p.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function wa(n,e){if(pe("AsyncQueue",`${e}: ${n}`),dt(n))return new v(p.UNAVAILABLE,`${e}: ${n}`);throw n}/** 2238 * @license 2239 * Copyright 2017 Google LLC 2240 * 2241 * Licensed under the Apache License, Version 2.0 (the "License");
2242 * you may not use this file except in compliance with the License. 2243 * You may obtain a copy of the License at 2244 * 2245 * http://www.apache.org/licenses/LICENSE-2.0 2246 * 2247 * Unless required by applicable law or agreed to in writing, software 2248 * distributed under the License is distributed on an "AS IS" BASIS, 2249 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2250 * See the License for the specific language governing permissions and 2251 * limitations under the License. 2252 */class tn{constructor(e){this.comparator=e?(t,s)=>e(t,s)||w.comparator(t.key,s.key):(t,s)=>w.comparator(t.key,s.key),this.keyedMap=Mn(),this.sortedSet=new Y(this.comparator)}static emptySet(e){return new tn(e.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,s)=>(e(t),!1))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof tn)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),s=e.sortedSet.getIterator();for(;t.hasNext();){const r=t.getNext().key,i=s.getNext().key;if(!r.isEqual(i))return!1}return!0}toString(){const e=[];return this.forEach(t=>{e.push(t.toString())}),e.length===0?"DocumentSet ()":`DocumentSet ( 2253 `+e.join(` 2254`)+` 2255)`}copy(e,t){const s=new tn;return s.comparator=this.comparator,s.keyedMap=e,s.sortedSet=t,s}}/** 2256 * @license 2257 * Copyright 2017 Google LLC 2258 * 2259 * Licensed under the Apache License, Version 2.0 (the "License"); 2260 * you may not use this file except in compliance with the License. 2261 * You may obtain a copy of the License at 2262 * 2263 * http://www.apache.org/licenses/LICENSE-2.0 2264 * 2265 * Unless required by applicable law or agreed to in writing, software 2266 * distributed under the License is distributed on an "AS IS" BASIS, 2267 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2268 * See the License for the specific language governing permissions and 2269 * limitations under the License. 2270 */class fu{constructor(){this.Tu=new Y(w.comparator)}track(e){const t=e.doc.key,s=this.Tu.get(t);s?e.type!==0&&s.type===3?this.Tu=this.Tu.insert(t,e):e.type===3&&s.type!==1?this.Tu=this.Tu.insert(t,{type:s.type,doc:e.doc}):e.type===2&&s.type===2?this.Tu=this.Tu.insert(t,{type:2,doc:e.doc}):e.type===2&&s.type===0?this.Tu=this.Tu.insert(t,{type:0,doc:e.doc}):e.type===1&&s.type===0?this.Tu=this.Tu.remove(t):e.type===1&&s.type===2?this.Tu=this.Tu.insert(t,{type:1,doc:s.doc}):e.type===0&&s.type===1?this.Tu=this.Tu.insert(t,{type:2,doc:e.doc}):I():this.Tu=this.Tu.insert(t,e)}Eu(){const e=[];return this.Tu.inorderTraversal((t,s)=>{e.push(s)}),e}}class mn{constructor(e,t,s,r,i,o,a,c,u){this.query=e,this.docs=t,this.oldDocs=s,this.docChanges=r,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=a,this.excludesMetadataChanges=c,this.hasCachedResults=u}static fromInitialDocuments(e,t,s,r,i){const o=[];return t.forEach(a=>{o.push({type:0,doc:a})}),new mn(e,t,tn.emptySet(t),o,s,r,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Xr(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,s=e.docChanges;if(t.length!==s.length)return!1;for(let r=0;r<t.length;r++)if(t[r].type!==s[r].type||!t[r].doc.isEqual(s[r].doc))return!1;return!0}}/** 2271 * @license 2272 * Copyright 2017 Google LLC 2273 * 2274 * Licensed under the Apache License, Version 2.0 (the "License"); 2275 * you may not use this file except in compliance with the License. 2276 * You may obtain a copy of the License at 2277 * 2278 * http://www.apache.org/licenses/LICENSE-2.0 2279 * 2280 * Unless required by applicable law or agreed to in writing, softw
2280are 2281 * distributed under the License is distributed on an "AS IS" BASIS, 2282 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2283 * See the License for the specific language governing permissions and 2284 * limitations under the License. 2285 */class CI{constructor(){this.Au=void 0,this.listeners=[]}}class kI{constructor(){this.queries=new ft(e=>Wh(e),Xr),this.onlineState="Unknown",this.Ru=new Set}}async function Ia(n,e){const t=k(n),s=e.query;let r=!1,i=t.queries.get(s);if(i||(r=!0,i=new CI),r)try{i.Au=await t.onListen(s)}catch(o){const a=wa(o,`Initialization of query '${fo(e.query)}' failed`);return void e.onError(a)}t.queries.set(s,i),i.listeners.push(e),e.bu(t.onlineState),i.Au&&e.Pu(i.Au)&&Ea(t)}async function Ta(n,e){const t=k(n),s=e.query;let r=!1;const i=t.queries.get(s);if(i){const o=i.listeners.indexOf(e);o>=0&&(i.listeners.splice(o,1),r=i.listeners.length===0)}if(r)return t.queries.delete(s),t.onUnlisten(s)}function DI(n,e){const t=k(n);let s=!1;for(const r of e){const i=r.query,o=t.queries.get(i);if(o){for(const a of o.listeners)a.Pu(r)&&(s=!0);o.Au=r}}s&&Ea(t)}function NI(n,e,t){const s=k(n),r=s.queries.get(e);if(r)for(const i of r.listeners)i.onError(t);s.queries.delete(e)}function Ea(n){n.Ru.forEach(e=>{e.next()})}class ba{constructor(e,t,s){this.query=e,this.vu=t,this.Vu=!1,this.Su=null,this.onlineState="Unknown",this.options=s||{}}Pu(e){if(!this.options.includeMetadataChanges){const s=[];for(const r of e.docChanges)r.type!==3&&s.push(r);e=new mn(e.query,e.docs,e.oldDocs,s,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Vu?this.Du(e)&&(this.vu.next(e),t=!0):this.Cu(e,this.onlineState)&&(this.xu(e),t=!0),this.Su=e,t}onError(e){this.vu.error(e)}bu(e){this.onlineState=e;let t=!1;return this.Su&&!this.Vu&&this.Cu(this.Su,e)&&(this.xu(this.Su),t=!0),t}Cu(e,t){if(!e.fromCache)return!0;const s=t!=="Offline";return(!this.options.Nu||!s)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}Du(e){if(e.docChanges.length>0)return!0;const t=this.Su&&this.Su.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}xu(e){e=mn.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Vu=!0,this.vu.next(e)}}/** 2286 * @license 2287 * Copyright 2017 Google LLC 2288 * 2289 * Licensed under the Apache License, Version 2.0 (the "License"); 2290 * you may not use this file except in compliance with the License. 2291 * You may obtain a copy of the License at 2292 * 2293 * http://www.apache.org/licenses/LICENSE-2.0 2294 * 2295 * Unless required by applicable law or agreed to in writing, software 2296 * distributed under the License is distributed on an "AS IS" BASIS, 2297 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2298 * See the License for the specific language governing permissions and 2299 * limitations under the License. 2300 */class Zd{constructor(e){this.key=e}}class ef{constructor(e){this.key=e}}class xI{constructor(e,t){this.query=e,this.qu=t,this.Uu=null,this.hasCachedResults=!1,this.current=!1,this.Ku=N(),this.mutatedKeys=N(),this.Gu=Qh(e),this.Qu=new tn(this.Gu)}get ju(){return this.qu}Wu(e,t){const s=t?t.zu:new fu,r=t?t.Qu:this.Qu;let i=t?t.mutatedKeys:this.mutatedKeys,o=r,a=!1;const c=this.query.limitType==="F"&&r.size===this.query.limit?r.last():null,u=this.query.limitType==="L"&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal((l,h)=>{const d=r.get(l),m=ws(this.query,h)?h:null,y=!!d&&this.mutatedKeys.has(d.key),E=!!m&&(m.hasLocalMutations||this.mutatedKeys.has(m.key)&&m.hasCommittedMutations);let S=!1;d&&m?d.data.isEqual(m.data)?y!==E&&(s.track({type:3,doc:m}),S=!0):this.Hu(d,m)||(s.track({type:2,doc:m}),S=!0,(c&&this.Gu(m,c)>0||u&&this.Gu(m,u)<0)&&(a=!0)):!d&&m?(s.track({type:0,doc:m}),S=!0):d&&!m&&(s.track({type:1,doc:d}),S=!0,(c||u)&&(a=!0)),S&&(m?(o=o.add(m),i=E?i.add(l):i.delete(l)):(o=o.delete(l),i=i.delete(l)))}),this.query.limit!==null)for(;o.size>this.query.limit;){const l=this.query.limitType==="F"?o.last():o.first();o=o.delete(l.key),i=i.delete(l.key),s.track({type:1,doc:l})}return{Qu:o,zu:s,$i:a,mutatedKeys:i}}Hu(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}
2300applyChanges(e,t,s){const r=this.Qu;this.Qu=e.Qu,this.mutatedKeys=e.mutatedKeys;const i=e.zu.Eu();i.sort((u,l)=>function(h,d){const m=y=>{switch(y){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return I()}};return m(h)-m(d)}(u.type,l.type)||this.Gu(u.doc,l.doc)),this.Ju(s);const o=t?this.Yu():[],a=this.Ku.size===0&&this.current?1:0,c=a!==this.Uu;return this.Uu=a,i.length!==0||c?{snapshot:new mn(this.query,e.Qu,r,i,e.mutatedKeys,a===0,c,!1,!!s&&s.resumeToken.approximateByteSize()>0),Xu:o}:{Xu:o}}bu(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({Qu:this.Qu,zu:new fu,mutatedKeys:this.mutatedKeys,$i:!1},!1)):{Xu:[]}}Zu(e){return!this.qu.has(e)&&!!this.Qu.has(e)&&!this.Qu.get(e).hasLocalMutations}Ju(e){e&&(e.addedDocuments.forEach(t=>this.qu=this.qu.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.qu=this.qu.delete(t)),this.current=e.current)}Yu(){if(!this.current)return[];const e=this.Ku;this.Ku=N(),this.Qu.forEach(s=>{this.Zu(s.key)&&(this.Ku=this.Ku.add(s.key))});const t=[];return e.forEach(s=>{this.Ku.has(s)||t.push(new ef(s))}),this.Ku.forEach(s=>{e.has(s)||t.push(new Zd(s))}),t}tc(e){this.qu=e.Hi,this.Ku=N();const t=this.Wu(e.documents);return this.applyChanges(t,!0)}ec(){return mn.fromInitialDocuments(this.query,this.Qu,this.mutatedKeys,this.Uu===0,this.hasCachedResults)}}class RI{constructor(e,t,s){this.query=e,this.targetId=t,this.view=s}}class OI{constructor(e){this.key=e,this.nc=!1}}class MI{constructor(e,t,s,r,i,o){this.localStore=e,this.remoteStore=t,this.eventManager=s,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=o,this.sc={},this.ic=new ft(a=>Wh(a),Xr),this.rc=new Map,this.oc=new Set,this.uc=new Y(w.comparator),this.cc=new Map,this.ac=new da,this.hc={},this.lc=new Map,this.fc=Bt.vn(),this.onlineState="Unknown",this.dc=void 0}get isPrimaryClient(){return this.dc===!0}}async function PI(n,e){const t=KI(n);let s,r;const i=t.ic.get(e);if(i)s=i.targetId,t.sharedClientState.addLocalQueryTarget(s),r=i.view.ec();else{const o=await iI(t.localStore,xe(e));t.isPrimaryClient&&zd(t.remoteStore,o);const a=t.sharedClientState.addLocalQueryTarget(o.targetId);s=o.targetId,r=await LI(t,e,s,a==="current",o.resumeToken)}return r}async function LI(n,e,t,s,r){n._c=(h,d,m)=>async function(y,E,S,V){let B=E.view.Wu(S);B.$i&&(B=await uu(y.localStore,E.query,!1).then(({documents:G})=>E.view.Wu(G,B)));const F=V&&V.targetChanges.get(E.targetId),X=E.view.applyChanges(B,y.isPrimaryClient,F);return mu(y,E.targetId,X.Xu),X.snapshot}(n,h,d,m);const i=await uu(n.localStore,e,!0),o=new xI(e,i.Hi),a=o.Wu(i.documents),c=Ts.createSynthesizedTargetChangeForCurrentChange(t,s&&n.onlineState!=="Offline",r),u=o.applyChanges(a,n.isPrimaryClient,c);mu(n,t,u.Xu);const l=new RI(e,t,o);return n.ic.set(e,l),n.rc.has(t)?n.rc.get(t).push(e):n.rc.set(t,[e]),u.snapshot}async function FI(n,e){const t=k(n),s=t.ic.get(e),r=t.rc.get(s.targetId);if(r.length>1)return t.rc.set(s.targetId,r.filter(i=>!Xr(i,e))),void t.ic.delete(e);t.isPrimaryClient?(t.sharedClientState.removeLocalQueryTarget(s.targetId),t.sharedClientState.isActiveQueryTarget(s.targetId)||await To(t.localStore,s.targetId,!1).then(()=>{t.sharedClientState.clearQueryState(s.targetId),Hd(t.remoteStore,s.targetId),Eo(t,s.targetId)}).catch(Gt)):(Eo(t,s.targetId),await To(t.localStore,s.targetId,!0))}async function VI(n,e,t){const s=of(n);try{const r=await function(i,o){const a=k(i),c=j.now(),u=o.reduce((d,m)=>d.add(m.key),N());let l,h;return a.persistence.runTransaction("Locally write mutations","readwrite",d=>{let m=Te(),y=N();return a.Gi.getEntries(d,u).next(E=>{m=E,m.forEach((S,V)=>{V.isValidDocument()||(y=y.add(S))})}).next(()=>a.localDocuments.getOverlayedDocuments(d,m)).next(E=>{l=E;const S=[];for(const V of o){const B=qv(V,l.get(V.key).overlayedDocument);B!=null&&S.push(new He(V.key,B,zh(B.value.mapValue),J.exists(!0)))}return a.mutationQueue.addMutationBatch(d,c,S,o)}).next(E=>{h=E;const S=E.applyToLocalDocumentSet(l,y);return a.documentOverlayCache.saveOverlays(d,E.batchId,S)})}).then(()=>({batchId:h.batchId,changes:cd(l)}))}(s.localStore,e);
2300s.sharedClientState.addPendingMutation(r.batchId),function(i,o,a){let c=i.hc[i.currentUser.toKey()];c||(c=new Y(D)),c=c.insert(o,a),i.hc[i.currentUser.toKey()]=c}(s,r.batchId,t),await _s(s,r.changes),await bs(s.remoteStore)}catch(r){const i=wa(r,"Failed to persist write");t.reject(i)}}async function tf(n,e){const t=k(n);try{const s=await nI(t.localStore,e);e.targetChanges.forEach((r,i)=>{const o=t.cc.get(i);o&&(b(r.addedDocuments.size+r.modifiedDocuments.size+r.removedDocuments.size<=1),r.addedDocuments.size>0?o.nc=!0:r.modifiedDocuments.size>0?b(o.nc):r.removedDocuments.size>0&&(b(o.nc),o.nc=!1))}),await _s(t,s,e)}catch(s){await Gt(s)}}function pu(n,e,t){const s=k(n);if(s.isPrimaryClient&&t===0||!s.isPrimaryClient&&t===1){const r=[];s.ic.forEach((i,o)=>{const a=o.view.bu(e);a.snapshot&&r.push(a.snapshot)}),function(i,o){const a=k(i);a.onlineState=o;let c=!1;a.queries.forEach((u,l)=>{for(const h of l.listeners)h.bu(o)&&(c=!0)}),c&&Ea(a)}(s.eventManager,e),r.length&&s.sc.Wo(r),s.onlineState=e,s.isPrimaryClient&&s.sharedClientState.setOnlineState(e)}}async function UI(n,e,t){const s=k(n);s.sharedClientState.updateQueryState(e,"rejected",t);const r=s.cc.get(e),i=r&&r.key;if(i){let o=new Y(w.comparator);o=o.insert(i,z.newNoDocument(i,_.min()));const a=N().add(i),c=new ei(_.min(),new Map,new L(D),o,a);await tf(s,c),s.uc=s.uc.remove(i),s.cc.delete(e),_a(s)}else await To(s.localStore,e,!1).then(()=>Eo(s,e,t)).catch(Gt)}async function BI(n,e){const t=k(n),s=e.batch.batchId;try{const r=await tI(t.localStore,e);sf(t,s,null),nf(t,s),t.sharedClientState.updateMutationState(s,"acknowledged"),await _s(t,r)}catch(r){await Gt(r)}}async function $I(n,e,t){const s=k(n);try{const r=await function(i,o){const a=k(i);return a.persistence.runTransaction("Reject batch","readwrite-primary",c=>{let u;return a.mutationQueue.lookupMutationBatch(c,o).next(l=>(b(l!==null),u=l.keys(),a.mutationQueue.removeMutationBatch(c,l))).next(()=>a.mutationQueue.performConsistencyCheck(c)).next(()=>a.documentOverlayCache.removeOverlaysForBatchId(c,u,o)).next(()=>a.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(c,u)).next(()=>a.localDocuments.getDocuments(c,u))})}(s.localStore,e);sf(s,e,t),nf(s,e),s.sharedClientState.updateMutationState(e,"rejected",t),await _s(s,r)}catch(r){await Gt(r)}}function nf(n,e){(n.lc.get(e)||[]).forEach(t=>{t.resolve()}),n.lc.delete(e)}function sf(n,e,t){const s=k(n);let r=s.hc[s.currentUser.toKey()];if(r){const i=r.get(e);i&&(t?i.reject(t):i.resolve(),r=r.remove(e)),s.hc[s.currentUser.toKey()]=r}}function Eo(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const s of n.rc.get(e))n.ic.delete(s),t&&n.sc.wc(s,t);n.rc.delete(e),n.isPrimaryClient&&n.ac.ls(e).forEach(s=>{n.ac.containsKey(s)||rf(n,s)})}function rf(n,e){n.oc.delete(e.path.canonicalString());const t=n.uc.get(e);t!==null&&(Hd(n.remoteStore,t),n.uc=n.uc.remove(e),n.cc.delete(t),_a(n))}function mu(n,e,t){for(const s of t)s instanceof Zd?(n.ac.addReference(s.key,e),qI(n,s)):s instanceof ef?(g("SyncEngine","Document no longer in limbo: "+s.key),n.ac.removeReference(s.key,e),n.ac.containsKey(s.key)||rf(n,s.key)):I()}function qI(n,e){const t=e.key,s=t.path.canonicalString();n.uc.get(t)||n.oc.has(s)||(g("SyncEngine","New document in limbo: "+t),n.oc.add(s),_a(n))}function _a(n){for(;n.oc.size>0&&n.uc.size<n.maxConcurrentLimboResolutions;){const e=n.oc.values().next().value;n.oc.delete(e);const t=new w(M.fromString(e)),s=n.fc.next();n.cc.set(s,new OI(t)),n.uc=n.uc.insert(t,s),zd(n.remoteStore,new rt(xe(vs(t.path)),s,2,Se.at))}}async function _s(n,e,t){const s=k(n),r=[],i=[],o=[];s.ic.isEmpty()||(s.ic.forEach((a,c)=>{o.push(s._c(c,e,t).then(u=>{if((u||t)&&s.isPrimaryClient&&s.sharedClientState.updateQueryState(c.targetId,u!=null&&u.fromCache?"not-current":"current"),u){r.push(u);const l=pa.Ci(c.targetId,u);i.push(l)}}))}),await Promise.all(o),s.sc.Wo(r),await async function(a,c){const u=k(a);try{await u.persistence.runTransaction("notifyLocalViewChanges","readwrite",l=>f.forEach(c,h=>f.forEach(h.Si,d=>u.persistence.referenceDelegate.addReference(l,h.targetId,d)).next(()=>f.forEach(h.Di,d=>u.persistence.referenceDelegate.removeReference(l,h.targetId,d)))))}
2300catch(l){if(!dt(l))throw l;g("LocalStore","Failed to update sequence numbers: "+l)}for(const l of c){const h=l.targetId;if(!l.fromCache){const d=u.qi.get(h),m=d.snapshotVersion,y=d.withLastLimboFreeSnapshotVersion(m);u.qi=u.qi.insert(h,y)}}}(s.localStore,i))}async function jI(n,e){const t=k(n);if(!t.currentUser.isEqual(e)){g("SyncEngine","User change. New user:",e.toKey());const s=await $d(t.localStore,e);t.currentUser=e,function(r,i){r.lc.forEach(o=>{o.forEach(a=>{a.reject(new v(p.CANCELLED,i))})}),r.lc.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,s.removedBatchIds,s.addedBatchIds),await _s(t,s.ji)}}function GI(n,e){const t=k(n),s=t.cc.get(e);if(s&&s.nc)return N().add(s.key);{let r=N();const i=t.rc.get(e);if(!i)return r;for(const o of i){const a=t.ic.get(o);r=r.unionWith(a.view.ju)}return r}}function KI(n){const e=k(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=tf.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=GI.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=UI.bind(null,e),e.sc.Wo=DI.bind(null,e.eventManager),e.sc.wc=NI.bind(null,e.eventManager),e}function of(n){const e=k(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=BI.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=$I.bind(null,e),e}class af{constructor(){this.synchronizeTabs=!1}async initialize(e){this.yt=ri(e.databaseInfo.databaseId),this.sharedClientState=this.gc(e),this.persistence=this.yc(e),await this.persistence.start(),this.localStore=this.Ic(e),this.gcScheduler=this.Tc(e,this.localStore),this.indexBackfillerScheduler=this.Ec(e,this.localStore)}Tc(e,t){return null}Ec(e,t){return null}Ic(e){return Bd(this.persistence,new Ud,e.initialUser,this.yt)}yc(e){return new Vd(si.Bs,this.yt)}gc(e){return new jd}async terminate(){this.gcScheduler&&this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class zI extends af{constructor(e,t,s){super(),this.Ac=e,this.cacheSizeBytes=t,this.forceOwnership=s,this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await this.Ac.initialize(this,e),await of(this.Ac.syncEngine),await bs(this.Ac.remoteStore),await this.persistence.li(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve()))}Ic(e){return Bd(this.persistence,new Ud,e.initialUser,this.yt)}Tc(e,t){const s=this.persistence.referenceDelegate.garbageCollector;return new Uw(s,e.asyncQueue,t)}Ec(e,t){const s=new wv(t,this.persistence);return new vv(e.asyncQueue,s)}yc(e){const t=Zw(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),s=this.cacheSizeBytes!==void 0?ve.withCacheSize(this.cacheSizeBytes):ve.DEFAULT;return new fa(this.synchronizeTabs,t,e.clientId,s,e.asyncQueue,hI(),Hs(),this.yt,this.sharedClientState,!!this.forceOwnership)}gc(e){return new jd}}class cf{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=s=>pu(this.syncEngine,s,1),this.remoteStore.remoteSyncer.handleCredentialChange=jI.bind(null,this.syncEngine),await AI(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new kI}createDatastore(e){const t=ri(e.databaseInfo.databaseId),s=(r=e.databaseInfo,new lI(r));var r;return function(i,o,a,c){return new pI(i,o,a,c)}(e.authCredentials,e.appCheckCredentials,s,t)}createRemoteStore(e){return t=this.localStore,s=this.datastore,r=e.asyncQueue,i=a=>pu(this.syncEngine,a,0),o=hu.C()?new hu:new aI,new gI(t,s,r,i,o);var t,s,r,i,o}createSyncEngine(e,t){return function(s,r,i,o,a,c,u){const l=new MI(s,r,i,o,a,c);return u&&(l.dc=!0),l}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}terminate(){return async function(e){const t=k(e);g("RemoteStore","RemoteStore shutting down."),t._u.add(5),await Es(t),t.mu.shutdown(),t.gu.set("Unknown")}(this.remoteStore)}}/** 2301 * @license 2302 * Copyright 2017 Google LLC 2303 * 2304 * Licensed under the Apache License, Version 2.0 (the "License");
2305 * you may not use this file except in compliance with the License. 2306 * You may obtain a copy of the License at 2307 * 2308 * http://www.apache.org/licenses/LICENSE-2.0 2309 * 2310 * Unless required by applicable law or agreed to in writing, software 2311 * distributed under the License is distributed on an "AS IS" BASIS, 2312 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2313 * See the License for the specific language governing permissions and 2314 * limitations under the License. 2315 */function uf(n,e,t){if(!t)throw new v(p.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function HI(n,e,t,s){if(e===!0&&s===!0)throw new v(p.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function gu(n){if(!w.isDocumentKey(n))throw new v(p.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function yu(n){if(w.isDocumentKey(n))throw new v(p.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${n} has ${n.length}.`)}function oi(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 e=function(t){return t.constructor?t.constructor.name:null}(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":I()}function de(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new v(p.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=oi(n);throw new v(p.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}/** 2316 * @license 2317 * Copyright 2020 Google LLC 2318 * 2319 * Licensed under the Apache License, Version 2.0 (the "License"); 2320 * you may not use this file except in compliance with the License. 2321 * You may obtain a copy of the License at 2322 * 2323 * http://www.apache.org/licenses/LICENSE-2.0 2324 * 2325 * Unless required by applicable law or agreed to in writing, software 2326 * distributed under the License is distributed on an "AS IS" BASIS, 2327 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2328 * See the License for the specific language governing permissions and 2329 * limitations under the License. 2330 */const vu=new Map;class wu{constructor(e){var t;if(e.host===void 0){if(e.ssl!==void 0)throw new v(p.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=e.host,this.ssl=(t=e.ssl)===null||t===void 0||t;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,e.cacheSizeBytes===void 0)this.cacheSizeBytes=41943040;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<1048576)throw new v(p.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.useFetchStreams=!!e.useFetchStreams,HI("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling)}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}/** 2331 * @license 2332 * Copyright 2020 Google LLC 2333 * 2334 * Licensed under the Apache License, Version 2.0 (the "License"); 2335 * you may not use this file except in compliance with the License. 2336 * You may obtain a copy of the License at 2337 * 2338 * http://www.apache.org/licenses/LICENSE-2.0 2339 * 2340 * Unless required by applicable law or agreed to in writing, softw
2340are 2341 * distributed under the License is distributed on an "AS IS" BASIS, 2342 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2343 * See the License for the specific language governing permissions and 2344 * limitations under the License. 2345 */class ai{constructor(e,t,s,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=s,this._app=r,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new wu({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new v(p.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!==void 0}_setSettings(e){if(this._settingsFrozen)throw new v(p.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new wu(e),e.credentials!==void 0&&(this._authCredentials=function(t){if(!t)return new iv;switch(t.type){case"gapi":const s=t.client;return new uv(s,t.sessionIndex||"0",t.iamToken||null,t.authTokenFactory||null);case"provider":return t.client;default:throw new v(p.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){const t=vu.get(e);t&&(g("ComponentProvider","Removing Datastore"),vu.delete(e),t.terminate())}(this),Promise.resolve()}}function WI(n,e,t,s={}){var r;const i=(n=de(n,ai))._getSettings();if(i.host!=="firestore.googleapis.com"&&i.host!==e&&hr("Host has been set in both settings() and useEmulator(), emulator host will be used"),n._setSettings(Object.assign(Object.assign({},i),{host:`${e}:${t}`,ssl:!1})),s.mockUserToken){let o,a;if(typeof s.mockUserToken=="string")o=s.mockUserToken,a=re.MOCK_USER;else{o=gp(s.mockUserToken,(r=n._app)===null||r===void 0?void 0:r.options.projectId);const c=s.mockUserToken.sub||s.mockUserToken.user_id;if(!c)throw new v(p.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");a=new re(c)}n._authCredentials=new ov(new kh(o,a))}}/** 2346 * @license 2347 * Copyright 2020 Google LLC 2348 * 2349 * Licensed under the Apache License, Version 2.0 (the "License"); 2350 * you may not use this file except in compliance with the License. 2351 * You may obtain a copy of the License at 2352 * 2353 * http://www.apache.org/licenses/LICENSE-2.0 2354 * 2355 * Unless required by applicable law or agreed to in writing, software 2356 * distributed under the License is distributed on an "AS IS" BASIS, 2357 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2358 * See the License for the specific language governing permissions and 2359 * limitations under the License. 2360 */class fe{constructor(e,t,s){this.converter=t,this._key=s,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new it(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new fe(this.firestore,e,this._key)}}class pt{constructor(e,t,s){this.converter=t,this._query=s,this.type="query",this.firestore=e}withConverter(e){return new pt(this.firestore,e,this._query)}}class it extends pt{constructor(e,t,s){super(e,t,vs(s)),this._path=s,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new fe(this.firestore,null,new w(e))}withConverter(e){return new it(this.firestore,e,this._path)}}function R0(n,e,...t){if(n=q(n),uf("collection","path",e),n instanceof ai){const s=M.fromString(e,...t);return yu(s),new it(n,null,s)}{if(!(n instanceof fe||n instanceof it))throw new v(p.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const s=n._path.child(M.fromString(e,...t));
2360return yu(s),new it(n.firestore,null,s)}}function QI(n,e,...t){if(n=q(n),arguments.length===1&&(e=Dh.R()),uf("doc","path",e),n instanceof ai){const s=M.fromString(e,...t);return gu(s),new fe(n,null,new w(s))}{if(!(n instanceof fe||n instanceof it))throw new v(p.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const s=n._path.child(M.fromString(e,...t));return gu(s),new fe(n.firestore,n instanceof it?n.converter:null,new w(s))}}/** 2361 * @license 2362 * Copyright 2020 Google LLC 2363 * 2364 * Licensed under the Apache License, Version 2.0 (the "License"); 2365 * you may not use this file except in compliance with the License. 2366 * You may obtain a copy of the License at 2367 * 2368 * http://www.apache.org/licenses/LICENSE-2.0 2369 * 2370 * Unless required by applicable law or agreed to in writing, software 2371 * distributed under the License is distributed on an "AS IS" BASIS, 2372 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2373 * See the License for the specific language governing permissions and 2374 * limitations under the License. 2375 *//** 2376 * @license 2377 * Copyright 2017 Google LLC 2378 * 2379 * Licensed under the Apache License, Version 2.0 (the "License"); 2380 * you may not use this file except in compliance with the License. 2381 * You may obtain a copy of the License at 2382 * 2383 * http://www.apache.org/licenses/LICENSE-2.0 2384 * 2385 * Unless required by applicable law or agreed to in writing, software 2386 * distributed under the License is distributed on an "AS IS" BASIS, 2387 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2388 * See the License for the specific language governing permissions and 2389 * limitations under the License. 2390 */class Sa{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next&&this.Rc(this.observer.next,e)}error(e){this.observer.error?this.Rc(this.observer.error,e):pe("Uncaught Error in snapshot listener:",e.toString())}bc(){this.muted=!0}Rc(e,t){this.muted||setTimeout(()=>{this.muted||e(t)},0)}}/** 2391 * @license 2392 * Copyright 2017 Google LLC 2393 * 2394 * Licensed under the Apache License, Version 2.0 (the "License"); 2395 * you may not use this file except in compliance with the License. 2396 * You may obtain a copy of the License at 2397 * 2398 * http://www.apache.org/licenses/LICENSE-2.0 2399 * 2400 * Unless required by applicable law or agreed to in writing, software 2401 * distributed under the License is distributed on an "AS IS" BASIS, 2402 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2403 * See the License for the specific language governing permissions and 2404 * limitations under the License. 2405 */class YI{constructor(e,t,s,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=s,this.databaseInfo=r,this.user=re.UNAUTHENTICATED,this.clientId=Dh.R(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this.authCredentials.start(s,async i=>{g("FirestoreClient","Received user=",i.uid),await this.authCredentialListener(i),this.user=i}),this.appCheckCredentials.start(s,i=>(g("FirestoreClient","Received new app check token=",i),this.appCheckCredentialListener(i,this.user)))}async getConfiguration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new v(p.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const e=new De;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this.onlineComponents&&await this.onlineComponents.terminate(),this.offlineComponents&&await this.offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const s=wa(t,"Failed to shutdown persistence");e.reject(s)}}),e.promise}}async function lf(n,e){n.asyncQueue.verifyOperationInProgress(),g("FirestoreClient","Initializing OfflineComponentProvider");const t=await n.getConfiguration();await e.initialize(t);let s=t.initialUser;n.setCredentialChangeListener(async r=>{s.isEqual(r)||(await $d(e.localStore,r),s=r)}),e.persistence.setDatabaseDeletedListener(()=>n.terminate()),n.offlineComponents=e}async function hf(n,e){n.asyncQueue.verifyOperationInProgress();const t=await XI(n);g("FirestoreClient","Initializing OnlineComponentProvider");const s=await n.getConfiguration();await e.initialize(t,s),n.setCredentialChangeListener(r=>du(e.remoteStore,r)),n.setAppCheckTokenChangeListener((r,i)=>du(e.remoteStore,i)),n.onlineComponents=e}async function XI(n){return n.offlineComponents||(g("FirestoreClient","Using default OfflineComponentProvider"),await lf(n,new af)),n.offlineComponents}async function df(n){return n.onlineComponents||(g("FirestoreClient","Using default OnlineComponentProvider"),await hf(n,new cf)),n.onlineComponents}function JI(n){return df(n).then(e=>e.syncEngine)}async function Tr(n){const e=await df(n),t=e.eventManager;return t.onListen=PI.bind(null,e.syncEngine),t.onUnlisten=FI.bind(null,e.syncEngine),t}function ZI(n,e,t={}){const s=new De;return n.asyncQueue.enqueueAndForget(async()=>function(r,i,o,a,c){const u=new Sa({next:h=>{i.enqueueAndForget(()=>Ta(r,l));const d=h.docs.has(o);!d&&h.fromCache?c.reject(new v(p.UNAVAILABLE,"Failed to get document because the client is offline.")):d&&h.fromCache&&a&&a.source==="server"?c.reject(new v(p.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):c.resolve(h)},error:h=>c.reject(h)}),l=new ba(vs(o.path),u,{includeMetadataChanges:!0,Nu:!0});return Ia(r,l)}(await Tr(n),n.asyncQueue,e,t,s)),s.promise}function eT(n,e,t={}){const s=new De;return n.asyncQueue.enqueueAndForget(async()=>function(r,i,o,a,c){const u=new Sa({next:h=>{i.enqueueAndForget(()=>Ta(r,l)),h.fromCache&&a.source==="server"?c.reject(new v(p.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):c.resolve(h)},error:h=>c.reject(h)}),l=new ba(o,u,{includeMetadataChanges:!0,Nu:!0});return Ia(r,l)}(await Tr(n),n.asyncQueue,e,t,s)),s.promise}
2405class tT{constructor(){this.Bc=Promise.resolve(),this.Lc=[],this.qc=!1,this.Uc=[],this.Kc=null,this.Gc=!1,this.Qc=!1,this.jc=[],this.xo=new Gd(this,"async_queue_retry"),this.Wc=()=>{const t=Hs();t&&g("AsyncQueue","Visibility state changed to "+t.visibilityState),this.xo.Po()};const e=Hs();e&&typeof e.addEventListener=="function"&&e.addEventListener("visibilitychange",this.Wc)}get isShuttingDown(){return this.qc}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.zc(),this.Hc(e)}enterRestrictedMode(e){if(!this.qc){this.qc=!0,this.Qc=e||!1;const t=Hs();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.Wc)}}enqueue(e){if(this.zc(),this.qc)return new Promise(()=>{});const t=new De;return this.Hc(()=>this.qc&&this.Qc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Lc.push(e),this.Jc()))}async Jc(){if(this.Lc.length!==0){try{await this.Lc[0](),this.Lc.shift(),this.xo.reset()}catch(e){if(!dt(e))throw e;g("AsyncQueue","Operation failed with retryable error: "+e)}this.Lc.length>0&&this.xo.Ro(()=>this.Jc())}}Hc(e){const t=this.Bc.then(()=>(this.Gc=!0,e().catch(s=>{this.Kc=s,this.Gc=!1;const r=function(i){let o=i.message||"";return i.stack&&(o=i.stack.includes(i.message)?i.stack:i.message+` 2406`+i.stack),o}(s);throw pe("INTERNAL UNHANDLED ERROR: ",r),s}).then(s=>(this.Gc=!1,s))));return this.Bc=t,t}enqueueAfterDelay(e,t,s){this.zc(),this.jc.indexOf(e)>-1&&(t=0);const r=va.createAndSchedule(this,e,t,s,i=>this.Yc(i));return this.Uc.push(r),r}zc(){this.Kc&&I()}verifyOperationInProgress(){}async Xc(){let e;do e=this.Bc,await e;while(e!==this.Bc)}Zc(e){for(const t of this.Uc)if(t.timerId===e)return!0;return!1}ta(e){return this.Xc().then(()=>{this.Uc.sort((t,s)=>t.targetTimeMs-s.targetTimeMs);for(const t of this.Uc)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Xc()})}ea(e){this.jc.push(e)}Yc(e){const t=this.Uc.indexOf(e);this.Uc.splice(t,1)}}function Iu(n){return function(e,t){if(typeof e!="object"||e===null)return!1;const s=e;for(const r of t)if(r in s&&typeof s[r]=="function")return!0;return!1}(n,["next","error","complete"])}class Re extends ai{constructor(e,t,s,r){super(e,t,s,r),this.type="firestore",this._queue=new tT,this._persistenceKey=(r==null?void 0:r.name)||"[DEFAULT]"}_terminate(){return this._firestoreClient||ff(this),this._firestoreClient.terminate()}}function nT(n,e){const t=typeof n=="object"?n:Nr(),s=typeof n=="string"?n:e||"(default)",r=ut(t,"firestore").getImmediate({identifier:s});if(!r._initialized){const i=Hu("firestore");i&&WI(r,...i)}return r}function _n(n){return n._firestoreClient||ff(n),n._firestoreClient.verifyNotTerminated(),n._firestoreClient}function ff(n){var e;const t=n._freezeSettings(),s=function(r,i,o,a){return new Iv(r,i,o,a.host,a.ssl,a.experimentalForceLongPolling,a.experimentalAutoDetectLongPolling,a.useFetchStreams)}(n._databaseId,((e=n._app)===null||e===void 0?void 0:e.options.appId)||"",n._persistenceKey,t);n._firestoreClient=new YI(n._authCredentials,n._appCheckCredentials,n._queue,s)}function sT(n,e){iT(n=de(n,Re));const t=_n(n),s=n._freezeSettings(),r=new cf;return rT(t,r,new zI(r,s.cacheSizeBytes,e==null?void 0:e.forceOwnership))}function rT(n,e,t){const s=new De;return n.asyncQueue.enqueue(async()=>{try{await lf(n,t),await hf(n,e),s.resolve()}catch(r){const i=r;if(!function(o){return o.name==="FirebaseError"?o.code===p.FAILED_PRECONDITION||o.code===p.UNIMPLEMENTED:typeof DOMException<"u"&&o instanceof DOMException?o.code===22||o.code===20||o.code===11:!0}(i))throw i;hr("Error enabling offline persistence. Falling back to persistence disabled: "+i),s.reject(i)}}).then(()=>s.promise)}function iT(n){if(n._initialized||n._terminated)throw new v(p.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}/** 2407 * @license 2408 * Copyright 2020 Google LLC 2409 * 2410 * Licensed under the Apache License, Version 2.0 (the "License");
2411 * you may not use this file except in compliance with the License. 2412 * You may obtain a copy of the License at 2413 * 2414 * http://www.apache.org/licenses/LICENSE-2.0 2415 * 2416 * Unless required by applicable law or agreed to in writing, software 2417 * distributed under the License is distributed on an "AS IS" BASIS, 2418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2419 * See the License for the specific language governing permissions and 2420 * limitations under the License. 2421 *//** 2422 * @license 2423 * Copyright 2020 Google LLC 2424 * 2425 * Licensed under the Apache License, Version 2.0 (the "License"); 2426 * you may not use this file except in compliance with the License. 2427 * You may obtain a copy of the License at 2428 * 2429 * http://www.apache.org/licenses/LICENSE-2.0 2430 * 2431 * Unless required by applicable law or agreed to in writing, software 2432 * distributed under the License is distributed on an "AS IS" BASIS, 2433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2434 * See the License for the specific language governing permissions and 2435 * limitations under the License. 2436 */class gn{constructor(e){this._byteString=e}static fromBase64String(e){try{return new gn(ae.fromBase64String(e))}catch(t){throw new v(p.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new gn(ae.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}}/** 2437 * @license 2438 * Copyright 2020 Google LLC 2439 * 2440 * Licensed under the Apache License, Version 2.0 (the "License"); 2441 * you may not use this file except in compliance with the License. 2442 * You may obtain a copy of the License at 2443 * 2444 * http://www.apache.org/licenses/LICENSE-2.0 2445 * 2446 * Unless required by applicable law or agreed to in writing, software 2447 * distributed under the License is distributed on an "AS IS" BASIS, 2448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2449 * See the License for the specific language governing permissions and 2450 * limitations under the License. 2451 */class Ss{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new v(p.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new Q(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/** 2452 * @license 2453 * Copyright 2020 Google LLC 2454 * 2455 * Licensed under the Apache License, Version 2.0 (the "License"); 2456 * you may not use this file except in compliance with the License. 2457 * You may obtain a copy of the License at 2458 * 2459 * http://www.apache.org/licenses/LICENSE-2.0 2460 * 2461 * Unless required by applicable law or agreed to in writing, software 2462 * distributed under the License is distributed on an "AS IS" BASIS, 2463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2464 * See the License for the specific language governing permissions and 2465 * limitations under the License. 2466 */class ci{constructor(e){this._methodName=e}}/** 2467 * @license 2468 * Copyright 2017 Google LLC 2469 * 2470 * Licensed under the Apache License, Version 2.0 (the "License"); 2471 * you may not use this file except in compliance with the License. 2472 * You may obtain a copy of the License at 2473 * 2474 * http://www.apache.org/licenses/LICENSE-2.0 2475 * 2476 * Unless required by applicable law or agreed to in writing, software 2477 * distributed under the License is distributed on an "AS IS" BASIS, 2478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2479 * See the License for the specific language governing permissions and 2480 * limitations under the License. 2481 */class Aa{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new v(p.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new v(p.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return D(this._lat,e._lat)||D(this._long,e._long)}}/** 2482 * @license 2483 * Copyright 2017 Google LLC 2484 * 2485 * Licensed under the Apache License, Version 2.0 (the "License");
2486 * you may not use this file except in compliance with the License. 2487 * You may obtain a copy of the License at 2488 * 2489 * http://www.apache.org/licenses/LICENSE-2.0 2490 * 2491 * Unless required by applicable law or agreed to in writing, software 2492 * distributed under the License is distributed on an "AS IS" BASIS, 2493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2494 * See the License for the specific language governing permissions and 2495 * limitations under the License. 2496 */const oT=/^__.*__$/;class aT{constructor(e,t,s){this.data=e,this.fieldMask=t,this.fieldTransforms=s}toMutation(e,t){return this.fieldMask!==null?new He(e,this.data,this.fieldMask,t,this.fieldTransforms):new En(e,this.data,t,this.fieldTransforms)}}class pf{constructor(e,t,s){this.data=e,this.fieldMask=t,this.fieldTransforms=s}toMutation(e,t){return new He(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function mf(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw I()}}class Ca{constructor(e,t,s,r,i,o){this.settings=e,this.databaseId=t,this.yt=s,this.ignoreUndefinedProperties=r,i===void 0&&this.na(),this.fieldTransforms=i||[],this.fieldMask=o||[]}get path(){return this.settings.path}get sa(){return this.settings.sa}ia(e){return new Ca(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.yt,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}ra(e){var t;const s=(t=this.path)===null||t===void 0?void 0:t.child(e),r=this.ia({path:s,oa:!1});return r.ua(e),r}ca(e){var t;const s=(t=this.path)===null||t===void 0?void 0:t.child(e),r=this.ia({path:s,oa:!1});return r.na(),r}aa(e){return this.ia({path:void 0,oa:!0})}ha(e){return Er(e,this.settings.methodName,this.settings.la||!1,this.path,this.settings.fa)}contains(e){return this.fieldMask.find(t=>e.isPrefixOf(t))!==void 0||this.fieldTransforms.find(t=>e.isPrefixOf(t.field))!==void 0}na(){if(this.path)for(let e=0;e<this.path.length;e++)this.ua(this.path.get(e))}ua(e){if(e.length===0)throw this.ha("Document fields must not be empty");if(mf(this.sa)&&oT.test(e))throw this.ha('Document fields cannot begin and end with "__"')}}class cT{constructor(e,t,s){this.databaseId=e,this.ignoreUndefinedProperties=t,this.yt=s||ri(e)}da(e,t,s,r=!1){return new Ca({sa:e,methodName:t,fa:s,path:Q.emptyPath(),oa:!1,la:r},this.databaseId,this.yt,this.ignoreUndefinedProperties)}}function As(n){const e=n._freezeSettings(),t=ri(n._databaseId);return new cT(n._databaseId,!!e.ignoreUndefinedProperties,t)}function ka(n,e,t,s,r,i={}){const o=n.da(i.merge||i.mergeFields?2:0,e,t,r);Na("Data must be an object, but it was:",o,s);const a=vf(s,o);let c,u;if(i.merge)c=new we(o.fieldMask),u=o.fieldTransforms;else if(i.mergeFields){const l=[];for(const h of i.mergeFields){const d=bo(e,h,t);if(!o.contains(d))throw new v(p.INVALID_ARGUMENT,`Field '${d}' is specified in your field mask but missing from your input data.`);If(l,d)||l.push(d)}c=new we(l),u=o.fieldTransforms.filter(h=>c.covers(h.field))}else c=null,u=o.fieldTransforms;return new aT(new ue(a),c,u)}class ui extends ci{_toFieldTransform(e){if(e.sa!==2)throw e.sa===1?e.ha(`${this._methodName}() can only appear at the top level of your update data`):e.ha(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof ui}}class Da extends ci{_toFieldTransform(e){return new nd(e.path,new hn)}isEqual(e){return e instanceof Da}}function gf(n,e,t,s){const r=n.da(1,e,t);Na("Data must be an object, but it was:",r,s);const i=[],o=ue.empty();Kt(s,(c,u)=>{const l=xa(e,c,t);u=q(u);const h=r.ca(l);if(u instanceof ui)i.push(l);else{const d=Cs(u,h);d!=null&&(i.push(l),o.set(l,d))}});const a=new we(i);return new pf(o,a,r.fieldTransforms)}function yf(n,e,t,s,r,i){const o=n.da(1,e,t),a=[bo(e,s,t)],c=[r];if(i.length%2!=0)throw new v(p.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let d=0;d<i.length;d+=2)a.push(bo(e,i[d])),c.push(i[d+1]);const u=[],l=ue.empty();for(let d=a.length-1;d>=0;--d)if(!If(u,a[d])){const m=a[d];let y=c[d];y=q(y);const E=o.ca(m);
2496if(y instanceof ui)u.push(m);else{const S=Cs(y,E);S!=null&&(u.push(m),l.set(m,S))}}const h=new we(u);return new pf(l,h,o.fieldTransforms)}function uT(n,e,t,s=!1){return Cs(t,n.da(s?4:3,e))}function Cs(n,e){if(wf(n=q(n)))return Na("Unsupported field value:",e,n),vf(n,e);if(n instanceof ci)return function(t,s){if(!mf(s.sa))throw s.ha(`${t._methodName}() can only be used with update() and set()`);if(!s.path)throw s.ha(`${t._methodName}() is not currently supported inside arrays`);const r=t._toFieldTransform(s);r&&s.fieldTransforms.push(r)}(n,e),null;if(n===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),n instanceof Array){if(e.settings.oa&&e.sa!==4)throw e.ha("Nested arrays are not supported");return function(t,s){const r=[];let i=0;for(const o of t){let a=Cs(o,s.aa(i));a==null&&(a={nullValue:"NULL_VALUE"}),r.push(a),i++}return{arrayValue:{values:r}}}(n,e)}return function(t,s){if((t=q(t))===null)return{nullValue:"NULL_VALUE"};if(typeof t=="number")return Lv(s.yt,t);if(typeof t=="boolean")return{booleanValue:t};if(typeof t=="string")return{stringValue:t};if(t instanceof Date){const r=j.fromDate(t);return{timestampValue:pn(s.yt,r)}}if(t instanceof j){const r=new j(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:pn(s.yt,r)}}if(t instanceof Aa)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof gn)return{bytesValue:fd(s.yt,t._byteString)};if(t instanceof fe){const r=s.databaseId,i=t.firestore._databaseId;if(!i.isEqual(r))throw s.ha(`Document reference is for database ${i.projectId}/${i.database} but should be for database ${r.projectId}/${r.database}`);return{referenceValue:oa(t.firestore._databaseId||s.databaseId,t._key.path)}}throw s.ha(`Unsupported field value: ${oi(t)}`)}(n,e)}function vf(n,e){const t={};return Ph(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Kt(n,(s,r)=>{const i=Cs(r,e.ra(s));i!=null&&(t[s]=i)}),{mapValue:{fields:t}}}function wf(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof j||n instanceof Aa||n instanceof gn||n instanceof fe||n instanceof ci)}function Na(n,e,t){if(!wf(t)||!function(s){return typeof s=="object"&&s!==null&&(Object.getPrototypeOf(s)===Object.prototype||Object.getPrototypeOf(s)===null)}(t)){const s=oi(t);throw s==="an object"?e.ha(n+" a custom object"):e.ha(n+" "+s)}}function bo(n,e,t){if((e=q(e))instanceof Ss)return e._internalPath;if(typeof e=="string")return xa(n,e);throw Er("Field path arguments must be of type string or ",n,!1,void 0,t)}const lT=new RegExp("[~\\*/\\[\\]]");function xa(n,e,t){if(e.search(lT)>=0)throw Er(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new Ss(...e.split("."))._internalPath}catch{throw Er(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function Er(n,e,t,s,r){const i=s&&!s.isEmpty(),o=r!==void 0;let a=`Function ${e}() called with invalid data`;t&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(i||o)&&(c+=" (found",i&&(c+=` in field ${s}`),o&&(c+=` in document ${r}`),c+=")"),new v(p.INVALID_ARGUMENT,a+n+c)}function If(n,e){return n.some(t=>t.isEqual(e))}/** 2497 * @license 2498 * Copyright 2020 Google LLC 2499 * 2500 * Licensed under the Apache License, Version 2.0 (the "License"); 2501 * you may not use this file except in compliance with the License. 2502 * You may obtain a copy of the License at 2503 * 2504 * http://www.apache.org/licenses/LICENSE-2.0 2505 * 2506 * Unless required by applicable law or agreed to in writing, software 2507 * distributed under the License is distributed on an "AS IS" BASIS, 2508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2509 * See the License for the specific language governing permissions and 2510 * limitations under the License. 2511 */class Tf{constructor(e,t,s,r,i){this._firestore=e,this._userDataWriter=t,this._key=s,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new fe(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new hT(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const t=this._document.data.field(li("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class hT extends Tf{data(){return super.data()}}function li(n,e){return typeof e=="string"?xa(n,e):e instanceof Ss?e._internalPath:e._delegate._internalPath}/** 2512 * @license 2513 * Copyright 2020 Google LLC 2514 * 2515 * Licensed under the Apache License, Version 2.0 (the "License");
2516 * you may not use this file except in compliance with the License. 2517 * You may obtain a copy of the License at 2518 * 2519 * http://www.apache.org/licenses/LICENSE-2.0 2520 * 2521 * Unless required by applicable law or agreed to in writing, software 2522 * distributed under the License is distributed on an "AS IS" BASIS, 2523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2524 * See the License for the specific language governing permissions and 2525 * limitations under the License. 2526 */function Ef(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new v(p.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Ra{}class bf extends Ra{}function O0(n,e,...t){let s=[];e instanceof Ra&&s.push(e),s=s.concat(t),function(r){const i=r.filter(a=>a instanceof Oa).length,o=r.filter(a=>a instanceof hi).length;if(i>1||i>0&&o>0)throw new v(p.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(s);for(const r of s)n=r._apply(n);return n}class hi extends bf{constructor(e,t,s){super(),this._field=e,this._op=t,this._value=s,this.type="where"}static _create(e,t,s){return new hi(e,t,s)}_apply(e){const t=this._parse(e);return _f(e._query,t),new pt(e.firestore,e.converter,lo(e._query,t))}_parse(e){const t=As(e.firestore);return function(r,i,o,a,c,u,l){let h;if(c.isKeyField()){if(u==="array-contains"||u==="array-contains-any")throw new v(p.INVALID_ARGUMENT,`Invalid Query. You can't perform '${u}' queries on documentId().`);if(u==="in"||u==="not-in"){Eu(l,u);const d=[];for(const m of l)d.push(Tu(a,r,m));h={arrayValue:{values:d}}}else h=Tu(a,r,l)}else u!=="in"&&u!=="not-in"&&u!=="array-contains-any"||Eu(l,u),h=uT(o,i,l,u==="in"||u==="not-in");return x.create(c,u,h)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function M0(n,e,t){const s=e,r=li("where",n);return hi._create(r,s,t)}class Oa extends Ra{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new Oa(e,t)}_parse(e){const t=this._queryConstraints.map(s=>s._parse(e)).filter(s=>s.getFilters().length>0);return t.length===1?t[0]:P.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return t.getFilters().length===0?e:(function(s,r){let i=s;const o=r.getFlattenedFilters();for(const a of o)_f(i,a),i=lo(i,a)}(e._query,t),new pt(e.firestore,e.converter,lo(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class Ma extends bf{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new Ma(e,t)}_apply(e){const t=function(s,r,i){if(s.startAt!==null)throw new v(p.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(s.endAt!==null)throw new v(p.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");const o=new Zt(r,i);return function(a,c){if(ia(a)===null){const u=Yr(a);u!==null&&Sf(a,u,c.field)}}(s,o),o}(e._query,this._field,this._direction);return new pt(e.firestore,e.converter,function(s,r){const i=s.explicitOrderBy.concat([r]);return new Tn(s.path,s.collectionGroup,i,s.filters.slice(),s.limit,s.limitType,s.startAt,s.endAt)}(e._query,t))}}function P0(n,e="asc"){const t=e,s=li("orderBy",n);return Ma._create(s,t)}function Tu(n,e,t){if(typeof(t=q(t))=="string"){if(t==="")throw new v(p.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Hh(e)&&t.indexOf("/")!==-1)throw new v(p.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${t}' contains a '/' character.`);const s=e.path.child(M.fromString(t));if(!w.isDocumentKey(s))throw new v(p.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${s}' is not because it has an odd number of segments (${s.length}).`);return ts(n,new w(s))}if(t instanceof fe)return ts(n,t._key);throw new v(p.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${oi(t)}.`)}function Eu(n,e){if(!Array.isArray(n)||n.length===0)throw new v(p.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`);if(n.length>10)throw new v(p.INVALID_ARGUMENT,`Invalid Query. '${e.toString()}' filters support a maximum of 10 elements in the value array.`)}function _f(n,e){if(e.isInequality()){const s=Yr(n),r=e.field;if(s!==null&&!s.isEqual(r))throw new v(p.INVALID_ARGUMENT,`Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '${s.toString()}' and '${r.toString()}'`);const i=ia(n);i!==null&&Sf(n,r,i)}const t=function(s,r){for(const i of s)for(const o of i.getFlattenedFilters())if(r.indexOf(o.op)>=0)return o.op;return null}(n.filters,function(s){switch(s){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","
2526not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(t!==null)throw t===e.op?new v(p.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new v(p.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${t.toString()}' filters.`)}function Sf(n,e,t){if(!t.isEqual(e))throw new v(p.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '${e.toString()}' and so you must also use '${e.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${t.toString()}' instead.`)}class dT{convertValue(e,t="none"){switch(Lt(e)){case 0:return null;case 1:return e.booleanValue;case 2:return K(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Pt(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 10:return this.convertObject(e.mapValue,t);default:throw I()}}convertObject(e,t){const s={};return Kt(e.fields,(r,i)=>{s[r]=this.convertValue(i,t)}),s}convertGeoPoint(e){return new Aa(K(e.latitude),K(e.longitude))}convertArray(e,t){return(e.values||[]).map(s=>this.convertValue(s,t))}convertServerTimestamp(e,t){switch(t){case"previous":const s=Fh(e);return s==null?null:this.convertValue(s,t);case"estimate":return this.convertTimestamp(Zn(e));default:return null}}convertTimestamp(e){const t=ot(e);return new j(t.seconds,t.nanos)}convertDocumentKey(e,t){const s=M.fromString(e);b(Ed(s));const r=new Mt(s.get(1),s.get(3)),i=new w(s.popFirst(5));return r.isEqual(t)||pe(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}}/** 2527 * @license 2528 * Copyright 2020 Google LLC 2529 * 2530 * Licensed under the Apache License, Version 2.0 (the "License"); 2531 * you may not use this file except in compliance with the License. 2532 * You may obtain a copy of the License at 2533 * 2534 * http://www.apache.org/licenses/LICENSE-2.0 2535 * 2536 * Unless required by applicable law or agreed to in writing, software 2537 * distributed under the License is distributed on an "AS IS" BASIS, 2538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2539 * See the License for the specific language governing permissions and 2540 * limitations under the License. 2541 */function Pa(n,e,t){let s;return s=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,s}/** 2542 * @license 2543 * Copyright 2020 Google LLC 2544 * 2545 * Licensed under the Apache License, Version 2.0 (the "License"); 2546 * you may not use this file except in compliance with the License. 2547 * You may obtain a copy of the License at 2548 * 2549 * http://www.apache.org/licenses/LICENSE-2.0 2550 * 2551 * Unless required by applicable law or agreed to in writing, software 2552 * distributed under the License is distributed on an "AS IS" BASIS, 2553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2554 * See the License for the specific language governing permissions and 2555 * limitations under the License. 2556 */class Ln{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class Af extends Tf{constructor(e,t,s,r,i,o){super(e,t,s,r,o),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new Ws(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const s=this._document.data.field(li("DocumentSnapshot.get",e));if(s!==null)return this._userDataWriter.convertValue(s,t.serverTimestamps)}}}class Ws extends Af{data(e={}){return super.data(e)}}class Cf{constructor(e,t,s,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new Ln(r.hasPendingWrites,r.fromCache),this.query=s}get docs(){const e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach(s=>{e.call(t,new Ws(this._firestore,this._userDataWriter,s.key,s,new Ln(this._snapshot.mutatedKeys.has(s.key),this._snapshot.fromCache),this.query.converter))})}
2556docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new v(p.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(s,r){if(s._snapshot.oldDocs.isEmpty()){let i=0;return s._snapshot.docChanges.map(o=>{const a=new Ws(s._firestore,s._userDataWriter,o.doc.key,o.doc,new Ln(s._snapshot.mutatedKeys.has(o.doc.key),s._snapshot.fromCache),s.query.converter);return o.doc,{type:"added",doc:a,oldIndex:-1,newIndex:i++}})}{let i=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(o=>r||o.type!==3).map(o=>{const a=new Ws(s._firestore,s._userDataWriter,o.doc.key,o.doc,new Ln(s._snapshot.mutatedKeys.has(o.doc.key),s._snapshot.fromCache),s.query.converter);let c=-1,u=-1;return o.type!==0&&(c=i.indexOf(o.doc.key),i=i.delete(o.doc.key)),o.type!==1&&(i=i.add(o.doc),u=i.indexOf(o.doc.key)),{type:fT(o.type),doc:a,oldIndex:c,newIndex:u}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function fT(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return I()}}/** 2557 * @license 2558 * Copyright 2020 Google LLC 2559 * 2560 * Licensed under the Apache License, Version 2.0 (the "License"); 2561 * you may not use this file except in compliance with the License. 2562 * You may obtain a copy of the License at 2563 * 2564 * http://www.apache.org/licenses/LICENSE-2.0 2565 * 2566 * Unless required by applicable law or agreed to in writing, software 2567 * distributed under the License is distributed on an "AS IS" BASIS, 2568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2569 * See the License for the specific language governing permissions and 2570 * limitations under the License. 2571 */function L0(n){n=de(n,fe);const e=de(n.firestore,Re);return ZI(_n(e),n._key).then(t=>kf(e,n,t))}class La extends dT{constructor(e){super(),this.firestore=e}convertBytes(e){return new gn(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new fe(this.firestore,null,t)}}function F0(n){n=de(n,pt);const e=de(n.firestore,Re),t=_n(e),s=new La(e);return Ef(n._query),eT(t,n._query).then(r=>new Cf(e,s,n,r))}function V0(n,e,t){n=de(n,fe);const s=de(n.firestore,Re),r=Pa(n.converter,e,t);return ks(s,[ka(As(s),"setDoc",n._key,r,n.converter!==null,t).toMutation(n._key,J.none())])}function U0(n,e,t,...s){n=de(n,fe);const r=de(n.firestore,Re),i=As(r);let o;return o=typeof(e=q(e))=="string"||e instanceof Ss?yf(i,"updateDoc",n._key,e,t,s):gf(i,"updateDoc",n._key,e),ks(r,[o.toMutation(n._key,J.exists(!0))])}function B0(n){return ks(de(n.firestore,Re),[new Is(n._key,J.none())])}function $0(n,e){const t=de(n.firestore,Re),s=QI(n),r=Pa(n.converter,e);return ks(t,[ka(As(n.firestore),"addDoc",s._key,r,n.converter!==null,{}).toMutation(s._key,J.exists(!1))]).then(()=>s)}function q0(n,...e){var t,s,r;n=q(n);let i={includeMetadataChanges:!1},o=0;typeof e[o]!="object"||Iu(e[o])||(i=e[o],o++);const a={includeMetadataChanges:i.includeMetadataChanges};if(Iu(e[o])){const h=e[o];e[o]=(t=h.next)===null||t===void 0?void 0:t.bind(h),e[o+1]=(s=h.error)===null||s===void 0?void 0:s.bind(h),e[o+2]=(r=h.complete)===null||r===void 0?void 0:r.bind(h)}let c,u,l;if(n instanceof fe)u=de(n.firestore,Re),l=vs(n._key.path),c={next:h=>{e[o]&&e[o](kf(u,n,h))},error:e[o+1],complete:e[o+2]};else{const h=de(n,pt);u=de(h.firestore,Re),l=h._query;const d=new La(u);c={next:m=>{e[o]&&e[o](new Cf(u,d,h,m))},error:e[o+1],complete:e[o+2]},Ef(n._query)}return function(h,d,m,y){const E=new Sa(y),S=new ba(d,E,m);return h.asyncQueue.enqueueAndForget(async()=>Ia(await Tr(h),S)),()=>{E.bc(),h.asyncQueue.enqueueAndForget(async()=>Ta(await Tr(h),S))}}(_n(u),l,a,c)}function ks(n,e){return function(t,s){const r=new De;return t.asyncQueue.enqueueAndForget(async()=>VI(await JI(t),s,r)),r.promise}(_n(n),e)}function kf(n,e,t){const s=t.docs.get(e._key),r=new La(n);return new Af(n,r,e._key,s,new Ln(t.hasPendingWrites,t.fromCache),e.converter)}/** 2572 * @license 2573 * Copyright 2020 Google LLC 2574 * 2575 * Licensed under the Apache License, Version 2.0 (the "License");
2576 * you may not use this file except in compliance with the License. 2577 * You may obtain a copy of the License at 2578 * 2579 * http://www.apache.org/licenses/LICENSE-2.0 2580 * 2581 * Unless required by applicable law or agreed to in writing, software 2582 * distributed under the License is distributed on an "AS IS" BASIS, 2583 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2584 * See the License for the specific language governing permissions and 2585 * limitations under the License. 2586 */class pT{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=As(e)}set(e,t,s){this._verifyNotCommitted();const r=Fi(e,this._firestore),i=Pa(r.converter,t,s),o=ka(this._dataReader,"WriteBatch.set",r._key,i,r.converter!==null,s);return this._mutations.push(o.toMutation(r._key,J.none())),this}update(e,t,s,...r){this._verifyNotCommitted();const i=Fi(e,this._firestore);let o;return o=typeof(t=q(t))=="string"||t instanceof Ss?yf(this._dataReader,"WriteBatch.update",i._key,t,s,r):gf(this._dataReader,"WriteBatch.update",i._key,t),this._mutations.push(o.toMutation(i._key,J.exists(!0))),this}delete(e){this._verifyNotCommitted();const t=Fi(e,this._firestore);return this._mutations=this._mutations.concat(new Is(t._key,J.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new v(p.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function Fi(n,e){if((n=q(n)).firestore!==e)throw new v(p.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return n}function j0(){return new Da("serverTimestamp")}/** 2587 * @license 2588 * Copyright 2020 Google LLC 2589 * 2590 * Licensed under the Apache License, Version 2.0 (the "License"); 2591 * you may not use this file except in compliance with the License. 2592 * You may obtain a copy of the License at 2593 * 2594 * http://www.apache.org/licenses/LICENSE-2.0 2595 * 2596 * Unless required by applicable law or agreed to in writing, software 2597 * distributed under the License is distributed on an "AS IS" BASIS, 2598 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2599 * See the License for the specific language governing permissions and 2600 * limitations under the License. 2601 */function G0(n){return _n(n=de(n,Re)),new pT(n,e=>ks(n,e))}(function(n,e=!0){(function(t){In=t})(as),Ne(new Ce("firestore",(t,{instanceIdentifier:s,options:r})=>{const i=t.getProvider("app").getImmediate(),o=new Re(new av(t.getProvider("auth-internal")),new hv(t.getProvider("app-check-internal")),function(a,c){if(!Object.prototype.hasOwnProperty.apply(a.options,["projectId"]))throw new v(p.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Mt(a.options.projectId,c)}(i,s),i);return r=Object.assign({useFetchStreams:e},r),o._setSettings(r),o},"PUBLIC").setMultipleInstances(!0)),Ie(Ec,"3.8.3",n),Ie(Ec,"3.8.3","esm2017")})();/** 2602 * @license 2603 * Copyright 2017 Google LLC 2604 * 2605 * Licensed under the Apache License, Version 2.0 (the "License"); 2606 * you may not use this file except in compliance with the License. 2607 * You may obtain a copy of the License at 2608 * 2609 * http://www.apache.org/licenses/LICENSE-2.0 2610 * 2611 * Unless required by applicable law or agreed to in writing, software 2612 * distributed under the License is distributed on an "AS IS" BASIS, 2613 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2614 * See the License for the specific language governing permissions and 2615 * limitations under the License. 2616 */const mT="type.googleapis.com/google.protobuf.Int64Value",gT="type.googleapis.com/google.protobuf.UInt64Value";function Df(n,e){const t={};for(const s in n)n.hasOwnProperty(s)&&(t[s]=e(n[s]));return t}function _o(n){if(n==null)return null;if(n instanceof Number&&(n=n.valueOf()),typeof n=="number"&&isFinite(n)||n===!0||n===!1||Object.prototype.toString.call(n)==="[object String]")return n;if(n instanceof Date)return n.toISOString();if(Array.isArray(n))return n.map(e=>_o(e));if(typeof n=="function"||typeof n=="object")return Df(n,e=>_o(e));throw new Error("Data cannot be encoded in JSON: "+n)}function br(n){if(n==null)return n;if(n["@type"])switch(n["@type"]){case mT:case gT:{const e=Number(n.value);if(isNaN(e))throw new Error("Data cannot be decoded from JSON: "+n);return e}default:throw new Error("Data cannot be decoded from JSON: "+n)}return Array.isArray(n)?n.map(e=>br(e)):typeof n=="function"||typeof n=="object"?Df(n,e=>br(e)):n}/** 2617 * @license 2618 * Copyright 2020 Google LLC 2619 * 2620 * Licensed under the Apache License, Version 2.0 (the "License");
2621 * you may not use this file except in compliance with the License. 2622 * You may obtain a copy of the License at 2623 * 2624 * http://www.apache.org/licenses/LICENSE-2.0 2625 * 2626 * Unless required by applicable law or agreed to in writing, software 2627 * distributed under the License is distributed on an "AS IS" BASIS, 2628 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2629 * See the License for the specific language governing permissions and 2630 * limitations under the License. 2631 */const Fa="functions";/** 2632 * @license 2633 * Copyright 2017 Google LLC 2634 * 2635 * Licensed under the Apache License, Version 2.0 (the "License"); 2636 * you may not use this file except in compliance with the License. 2637 * You may obtain a copy of the License at 2638 * 2639 * http://www.apache.org/licenses/LICENSE-2.0 2640 * 2641 * Unless required by applicable law or agreed to in writing, software 2642 * distributed under the License is distributed on an "AS IS" BASIS, 2643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2644 * See the License for the specific language governing permissions and 2645 * limitations under the License. 2646 */const bu={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 nn extends ke{constructor(e,t,s){super(`${Fa}/${e}`,t||""),this.details=s}}function yT(n){if(n>=200&&n<300)return"ok";switch(n){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}function vT(n,e){let t=yT(n),s=t,r;try{const i=e&&e.error;if(i){const o=i.status;if(typeof o=="string"){if(!bu[o])return new nn("internal","internal");t=bu[o],s=o}const a=i.message;typeof a=="string"&&(s=a),r=i.details,r!==void 0&&(r=br(r))}}catch{}return t==="ok"?null:new nn(t,s,r)}/** 2647 * @license 2648 * Copyright 2017 Google LLC 2649 * 2650 * Licensed under the Apache License, Version 2.0 (the "License"); 2651 * you may not use this file except in compliance with the License. 2652 * You may obtain a copy of the License at 2653 * 2654 * http://www.apache.org/licenses/LICENSE-2.0 2655 * 2656 * Unless required by applicable law or agreed to in writing, software 2657 * distributed under the License is distributed on an "AS IS" BASIS, 2658 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2659 * See the License for the specific language governing permissions and 2660 * limitations under the License. 2661 */class wT{constructor(e,t,s){this.auth=null,this.messaging=null,this.appCheck=null,this.auth=e.getImmediate({optional:!0}),this.messaging=t.getImmediate({optional:!0}),this.auth||e.get().then(r=>this.auth=r,()=>{}),this.messaging||t.get().then(r=>this.messaging=r,()=>{}),this.appCheck||s.get().then(r=>this.appCheck=r,()=>{})}async getAuthToken(){if(this.auth)try{const e=await this.auth.getToken();return e==null?void 0:e.accessToken}catch{return}}async getMessagingToken(){if(!(!this.messaging||!("Notification"in self)||Notification.permission!=="granted"))try{return await this.messaging.getToken()}catch{return}}async getAppCheckToken(){if(this.appCheck){const e=await this.appCheck.getToken();return e.error?null:e.token}return null}async getContext(){const e=await this.getAuthToken(),t=await this.getMessagingToken(),s=await this.getAppCheckToken();return{authToken:e,messagingToken:t,appCheckToken:s}}}/** 2662 * @license 2663 * Copyright 2017 Google LLC 2664 * 2665 * Licensed under the Apache License, Version 2.0 (the "License"); 2666 * you may not use this file except in compliance with the License. 2667 * You may obtain a copy of the License at 2668 * 2669 * http://www.apache.org/licenses/LICENSE-2.0 2670 * 2671 * Unless required by applicable law or agreed to in writing, softw
2671are 2672 * distributed under the License is distributed on an "AS IS" BASIS, 2673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2674 * See the License for the specific language governing permissions and 2675 * limitations under the License. 2676 */const So="us-central1";function IT(n){let e=null;return{promise:new Promise((t,s)=>{e=setTimeout(()=>{s(new nn("deadline-exceeded","deadline-exceeded"))},n)}),cancel:()=>{e&&clearTimeout(e)}}}class TT{constructor(e,t,s,r,i=So,o){this.app=e,this.fetchImpl=o,this.emulatorOrigin=null,this.contextProvider=new wT(t,s,r),this.cancelAllRequests=new Promise(a=>{this.deleteService=()=>Promise.resolve(a())});try{const a=new URL(i);this.customDomain=a.origin,this.region=So}catch{this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){const t=this.app.options.projectId;return this.emulatorOrigin!==null?`${this.emulatorOrigin}/${t}/${this.region}/${e}`:this.customDomain!==null?`${this.customDomain}/${e}`:`https://${this.region}-${t}.cloudfunctions.net/${e}`}}function ET(n,e,t){n.emulatorOrigin=`http://${e}:${t}`}function bT(n,e,t){return s=>ST(n,e,s,t||{})}async function _T(n,e,t,s){t["Content-Type"]="application/json";let r;try{r=await s(n,{method:"POST",body:JSON.stringify(e),headers:t})}catch{return{status:0,json:null}}let i=null;try{i=await r.json()}catch{}return{status:r.status,json:i}}function ST(n,e,t,s){const r=n._url(e);return AT(n,r,t,s)}async function AT(n,e,t,s){t=_o(t);const r={data:t},i={},o=await n.contextProvider.getContext();o.authToken&&(i.Authorization="Bearer "+o.authToken),o.messagingToken&&(i["Firebase-Instance-ID-Token"]=o.messagingToken),o.appCheckToken!==null&&(i["X-Firebase-AppCheck"]=o.appCheckToken);const a=s.timeout||7e4,c=IT(a),u=await Promise.race([_T(e,r,i,n.fetchImpl),c.promise,n.cancelAllRequests]);if(c.cancel(),!u)throw new nn("cancelled","Firebase Functions instance was deleted.");const l=vT(u.status,u.json);if(l)throw l;if(!u.json)throw new nn("internal","Response is not valid JSON object.");let h=u.json.data;if(typeof h>"u"&&(h=u.json.result),typeof h>"u")throw new nn("internal","Response is missing data field.");return{data:br(h)}}const _u="@firebase/functions",Su="0.9.3";/** 2677 * @license 2678 * Copyright 2019 Google LLC 2679 * 2680 * Licensed under the Apache License, Version 2.0 (the "License"); 2681 * you may not use this file except in compliance with the License. 2682 * You may obtain a copy of the License at 2683 * 2684 * http://www.apache.org/licenses/LICENSE-2.0 2685 * 2686 * Unless required by applicable law or agreed to in writing, software 2687 * distributed under the License is distributed on an "AS IS" BASIS, 2688 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2689 * See the License for the specific language governing permissions and 2690 * limitations under the License. 2691 */const CT="auth-internal",kT="app-check-internal",DT="messaging-internal";function NT(n,e){const t=(s,{instanceIdentifier:r})=>{const i=s.getProvider("app").getImmediate(),o=s.getProvider(CT),a=s.getProvider(DT),c=s.getProvider(kT);return new TT(i,o,a,c,r,n)};Ne(new Ce(Fa,t,"PUBLIC").setMultipleInstances(!0)),Ie(_u,Su,e),Ie(_u,Su,"esm2017")}/** 2692 * @license 2693 * Copyright 2020 Google LLC 2694 * 2695 * Licensed under the Apache License, Version 2.0 (the "License"); 2696 * you may not use this file except in compliance with the License. 2697 * You may obtain a copy of the License at 2698 * 2699 * http://www.apache.org/licenses/LICENSE-2.0 2700 * 2701 * Unless required by applicable law or agreed to in writing, software 2702 * distributed under the License is distributed on an "AS IS" BASIS, 2703 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2704 * See the License for the specific language governing permissions and 2705 * limitations under the License. 2706 */function xT(n=Nr(),e=So){const s=ut(q(n),Fa).getImmediate({identifier:e}),r=Hu("functions");return r&&RT(s,...r),s}function RT(n,e,t){ET(q(n),e,t)}function K0(n,e,t){return bT(q(n),e,t)}NT(fetch.bind(self));function Va(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(n);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(n,s[r])&&(t[s[r]]=n[s[r]]);return t}function Nf(){return{["dependent-sdk-initialized-before-auth"]:"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const OT=Nf,xf=new qt("auth","Firebase",Nf());/** 2707 * @license 2708 * Copyright 2020 Google LLC 2709 * 2710 * Licensed under the Apache License, Version 2.0 (the "License");
2711 * you may not use this file except in compliance with the License. 2712 * You may obtain a copy of the License at 2713 * 2714 * http://www.apache.org/licenses/LICENSE-2.0 2715 * 2716 * Unless required by applicable law or agreed to in writing, software 2717 * distributed under the License is distributed on an "AS IS" BASIS, 2718 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2719 * See the License for the specific language governing permissions and 2720 * limitations under the License. 2721 */const Au=new Dr("@firebase/auth");function Qs(n,...e){Au.logLevel<=O.ERROR&&Au.error(`Auth (${as}): ${n}`,...e)}/** 2722 * @license 2723 * Copyright 2020 Google LLC 2724 * 2725 * Licensed under the Apache License, Version 2.0 (the "License"); 2726 * you may not use this file except in compliance with the License. 2727 * You may obtain a copy of the License at 2728 * 2729 * http://www.apache.org/licenses/LICENSE-2.0 2730 * 2731 * Unless required by applicable law or agreed to in writing, software 2732 * distributed under the License is distributed on an "AS IS" BASIS, 2733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2734 * See the License for the specific language governing permissions and 2735 * limitations under the License. 2736 */function Ue(n,...e){throw Ua(n,...e)}function Le(n,...e){return Ua(n,...e)}function Rf(n,e,t){const s=Object.assign(Object.assign({},OT()),{[e]:t});return new qt("auth","Firebase",s).create(e,{appName:n.name})}function MT(n,e,t){const s=t;if(!(e instanceof s))throw s.name!==e.constructor.name&&Ue(n,"argument-error"),Rf(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function Ua(n,...e){if(typeof n!="string"){const t=e[0],s=[...e.slice(1)];return s[0]&&(s[0].appName=n.name),n._errorFactory.create(t,...s)}return xf.create(n,...e)}function A(n,e,...t){if(!n)throw Ua(e,...t)}function je(n){const e="INTERNAL ASSERTION FAILED: "+n;throw Qs(e),new Error(e)}function ze(n,e){n||je(e)}/** 2737 * @license 2738 * Copyright 2020 Google LLC 2739 * 2740 * Licensed under the Apache License, Version 2.0 (the "License"); 2741 * you may not use this file except in compliance with the License. 2742 * You may obtain a copy of the License at 2743 * 2744 * http://www.apache.org/licenses/LICENSE-2.0 2745 * 2746 * Unless required by applicable law or agreed to in writing, software 2747 * distributed under the License is distributed on an "AS IS" BASIS, 2748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2749 * See the License for the specific language governing permissions and 2750 * limitations under the License. 2751 */const Cu=new Map;function Ge(n){ze(n instanceof Function,"Expected a class definition");let e=Cu.get(n);return e?(ze(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,Cu.set(n,e),e)}/** 2752 * @license 2753 * Copyright 2020 Google LLC 2754 * 2755 * Licensed under the Apache License, Version 2.0 (the "License"); 2756 * you may not use this file except in compliance with the License. 2757 * You may obtain a copy of the License at 2758 * 2759 * http://www.apache.org/licenses/LICENSE-2.0 2760 * 2761 * Unless required by applicable law or agreed to in writing, software 2762 * distributed under the License is distributed on an "AS IS" BASIS, 2763 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2764 * See the License for the specific language governing permissions and 2765 * limitations under the License. 2766 */function PT(n,e){const t=ut(n,"auth");if(t.isInitialized()){const r=t.getImmediate(),i=t.getOptions();if(Gn(i,e??{}))return r;Ue(r,"already-initialized")}return t.initialize({options:e})}function LT(n,e){const t=(e==null?void 0:e.persistence)||[],s=(Array.isArray(t)?t:[t]).map(Ge);e!=null&&e.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(s,e==null?void 0:e.popupRedirectResolver)}/** 2767 * @license 2768 * Copyright 2020 Google LLC 2769 * 2770 * Licensed under the Apache License, Version 2.0 (the "License"); 2771 * you may not use this file except in compliance with the License. 2772 * You may obtain a copy of the License at 2773 * 2774 * http://www.apache.org/licenses/LICENSE-2.0 2775 * 2776 * Unless required by applicable law or agreed to in writing, softw
2776are 2777 * distributed under the License is distributed on an "AS IS" BASIS, 2778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2779 * See the License for the specific language governing permissions and 2780 * limitations under the License. 2781 */function Ao(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.href)||""}function FT(){return ku()==="http:"||ku()==="https:"}function ku(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.protocol)||null}/** 2782 * @license 2783 * Copyright 2020 Google LLC 2784 * 2785 * Licensed under the Apache License, Version 2.0 (the "License"); 2786 * you may not use this file except in compliance with the License. 2787 * You may obtain a copy of the License at 2788 * 2789 * http://www.apache.org/licenses/LICENSE-2.0 2790 * 2791 * Unless required by applicable law or agreed to in writing, software 2792 * distributed under the License is distributed on an "AS IS" BASIS, 2793 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2794 * See the License for the specific language governing permissions and 2795 * limitations under the License. 2796 */function VT(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(FT()||Qu()||"connection"in navigator)?navigator.onLine:!0}function UT(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}/** 2797 * @license 2798 * Copyright 2020 Google LLC 2799 * 2800 * Licensed under the Apache License, Version 2.0 (the "License"); 2801 * you may not use this file except in compliance with the License. 2802 * You may obtain a copy of the License at 2803 * 2804 * http://www.apache.org/licenses/LICENSE-2.0 2805 * 2806 * Unless required by applicable law or agreed to in writing, software 2807 * distributed under the License is distributed on an "AS IS" BASIS, 2808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2809 * See the License for the specific language governing permissions and 2810 * limitations under the License. 2811 */class Ds{constructor(e,t){this.shortDelay=e,this.longDelay=t,ze(t>e,"Short delay should be less than long delay!"),this.isMobile=yp()||wp()}get(){return VT()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/** 2812 * @license 2813 * Copyright 2020 Google LLC 2814 * 2815 * Licensed under the Apache License, Version 2.0 (the "License"); 2816 * you may not use this file except in compliance with the License. 2817 * You may obtain a copy of the License at 2818 * 2819 * http://www.apache.org/licenses/LICENSE-2.0 2820 * 2821 * Unless required by applicable law or agreed to in writing, software 2822 * distributed under the License is distributed on an "AS IS" BASIS, 2823 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2824 * See the License for the specific language governing permissions and 2825 * limitations under the License. 2826 */function Ba(n,e){ze(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}/** 2827 * @license 2828 * Copyright 2020 Google LLC 2829 * 2830 * Licensed under the Apache License, Version 2.0 (the "License"); 2831 * you may not use this file except in compliance with the License. 2832 * You may obtain a copy of the License at 2833 * 2834 * http://www.apache.org/licenses/LICENSE-2.0 2835 * 2836 * Unless required by applicable law or agreed to in writing, software 2837 * distributed under the License is distributed on an "AS IS" BASIS, 2838 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2839 * See the License for the specific language governing permissions and 2840 * limitations under the License. 2841 */class Of{static initialize(e,t,s){this.fetchImpl=e,t&&(this.headersImpl=t),s&&(this.responseImpl=s)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;je("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;je("Could not find Headers implementation, make sure you call FetchProvi
2841der.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;je("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/** 2842 * @license 2843 * Copyright 2020 Google LLC 2844 * 2845 * Licensed under the Apache License, Version 2.0 (the "License"); 2846 * you may not use this file except in compliance with the License. 2847 * You may obtain a copy of the License at 2848 * 2849 * http://www.apache.org/licenses/LICENSE-2.0 2850 * 2851 * Unless required by applicable law or agreed to in writing, software 2852 * distributed under the License is distributed on an "AS IS" BASIS, 2853 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2854 * See the License for the specific language governing permissions and 2855 * limitations under the License. 2856 */const BT={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"internal-error",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error"};/** 2857 * @license 2858 * Copyright 2020 Google LLC 2859 * 2860 * Licensed under the Apache License, Version 2.0 (the "License"); 2861 * you may not use this file except in compliance with the License. 2862 * You may obtain a copy of the License at 2863 * 2864 * http://www.apache.org/licenses/LICENSE-2.0 2865 * 2866 * Unless required by applicable law or agreed to in writing, software 2867 * distributed under the License is distributed on an "AS IS" BASIS, 2868 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2869 * See the License for the specific language governing permissions and 2870 * limitations under the License. 2871 */const $T=new Ds(3e4,6e4);function qT(n,e){return n.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:n.tenantId}):e}async function di(n,e,t,s,r={}){return Mf(n,r,async()=>{let i={},o={};s&&(e==="GET"?o=s:i={body:JSON.stringify(s)});const a=os(Object.assign({key:n.config.apiKey},o)).slice(1),c=await n._getAdditionalHeaders();return c["Content-Type"]="application/json",n.languageCode&&(c["X-Firebase-Locale"]=n.languageCode),Of.fetch()(Pf(n,n.config.apiHost,t,a),Object.assign({method:e,headers:c,referrerPolicy:"no-referrer"},i))})}async function Mf(n,e,t){n._canInitEmulator=!1;const s=Object.assign(Object.assign({},BT),e);try{const r=new GT(n),i=await Promise.race([t(),r.promise]);r.clearNetworkTimeout();const o=await i.json();if("needConfirmation"in o)throw $s(n,"account-exists-with-different-credential",o);if(i.ok&&!("errorMessage"in o))return o;{const a=i.ok?o.errorMessage:o.error.message,[c,u]=a.split(" : ");if(c==="FEDERATED_USER_ID_ALREADY_LINKED")throw $s(n,"credential-already-in-use",o);if(c==="EMAIL_EXISTS")throw $s(n,"email-already-in-use",o);if(c==="USER_DISABLED")throw $s(n,"user-disabled",o);const l=s[c]||c.toLowerCase().replace(/[_\s]+/g,"-");if(u)throw Rf(n,l,u);Ue(n,l)}}catch(r){if(r instanceof ke)throw r;Ue(n,"network-request-failed")}}async function jT(n,e,t,s,r={}){const i=await di(n,e,t,s,r);return"mfaPendingCredential"in i&&Ue(n,"multi-factor-auth-required",{_serverResponse:i}),i}function Pf(n,e,t,s){const r=`${e}${t}?${s}`;return n.config.emulator?Ba(n.config,r):`${n.config.apiScheme}://${r}`}class GT{constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,s)=>{this.timer=setTimeout(()=>s(Le(this.auth,"network-request-failed")),$T.get())})}clearNetworkTimeout(){clearTimeout(this.timer)}}function $s(n,e,t){const s={appName:n.name};t.email&&(s.email=t.email),t.phoneNumber&&(s.phoneNumber=t.phoneNumber);const r=Le(n,e,s);return r.customData._tokenResponse=t,r}/** 2872 * @license 2873 * Copyright 2020 Google LLC 2874 * 2875 * Licensed under the Apache License, Version 2.0 (the "License");
2876 * you may not use this file except in compliance with the License. 2877 * You may obtain a copy of the License at 2878 * 2879 * http://www.apache.org/licenses/LICENSE-2.0 2880 * 2881 * Unless required by applicable law or agreed to in writing, software 2882 * distributed under the License is distributed on an "AS IS" BASIS, 2883 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2884 * See the License for the specific language governing permissions and 2885 * limitations under the License. 2886 */async function KT(n,e){return di(n,"POST","/v1/accounts:delete",e)}async function zT(n,e){return di(n,"POST","/v1/accounts:lookup",e)}/** 2887 * @license 2888 * Copyright 2020 Google LLC 2889 * 2890 * Licensed under the Apache License, Version 2.0 (the "License"); 2891 * you may not use this file except in compliance with the License. 2892 * You may obtain a copy of the License at 2893 * 2894 * http://www.apache.org/licenses/LICENSE-2.0 2895 * 2896 * Unless required by applicable law or agreed to in writing, software 2897 * distributed under the License is distributed on an "AS IS" BASIS, 2898 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2899 * See the License for the specific language governing permissions and 2900 * limitations under the License. 2901 */function jn(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function HT(n,e=!1){const t=q(n),s=await t.getIdToken(e),r=$a(s);A(r&&r.exp&&r.auth_time&&r.iat,t.auth,"internal-error");const i=typeof r.firebase=="object"?r.firebase:void 0,o=i==null?void 0:i.sign_in_provider;return{claims:r,token:s,authTime:jn(Vi(r.auth_time)),issuedAtTime:jn(Vi(r.iat)),expirationTime:jn(Vi(r.exp)),signInProvider:o||null,signInSecondFactor:(i==null?void 0:i.sign_in_second_factor)||null}}function Vi(n){return Number(n)*1e3}function $a(n){const[e,t,s]=n.split(".");if(e===void 0||t===void 0||s===void 0)return Qs("JWT malformed, contained fewer than 3 sections"),null;try{const r=Ku(t);return r?JSON.parse(r):(Qs("Failed to decode base64 JWT payload"),null)}catch(r){return Qs("Caught error parsing JWT payload as JSON",r==null?void 0:r.toString()),null}}function WT(n){const e=$a(n);return A(e,"internal-error"),A(typeof e.exp<"u","internal-error"),A(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}/** 2902 * @license 2903 * Copyright 2020 Google LLC 2904 * 2905 * Licensed under the Apache License, Version 2.0 (the "License"); 2906 * you may not use this file except in compliance with the License. 2907 * You may obtain a copy of the License at 2908 * 2909 * http://www.apache.org/licenses/LICENSE-2.0 2910 * 2911 * Unless required by applicable law or agreed to in writing, software 2912 * distributed under the License is distributed on an "AS IS" BASIS, 2913 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2914 * See the License for the specific language governing permissions and 2915 * limitations under the License. 2916 */async function rs(n,e,t=!1){if(t)return e;try{return await e}catch(s){throw s instanceof ke&&QT(s)&&n.auth.currentUser===n&&await n.auth.signOut(),s}}function QT({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}/** 2917 * @license 2918 * Copyright 2020 Google LLC 2919 * 2920 * Licensed under the Apache License, Version 2.0 (the "License"); 2921 * you may not use this file except in compliance with the License. 2922 * You may obtain a copy of the License at 2923 * 2924 * http://www.apache.org/licenses/LICENSE-2.0 2925 * 2926 * Unless required by applicable law or agreed to in writing, software 2927 * distributed under the License is distributed on an "AS IS" BASIS, 2928 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2929 * See the License for the specific language governing permissions and 2930 * limitations under the License. 2931 */class YT{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){var t;if(e){const s=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),s}else{this.errorBackoff=3e4;const r=((t=this.user.stsTokenManager.expirationTime)!==null&&t!==void 0?t:0)-Date.now()-3e5;return Math.max(0,r)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){(e==null?void 0:e.code)==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}/** 2932 * @license 2933 * Copyright 2020 Google LLC 2934 * 2935 * Licensed under the Apache License, Version 2.0 (the "License");
2936 * you may not use this file except in compliance with the License. 2937 * You may obtain a copy of the License at 2938 * 2939 * http://www.apache.org/licenses/LICENSE-2.0 2940 * 2941 * Unless required by applicable law or agreed to in writing, software 2942 * distributed under the License is distributed on an "AS IS" BASIS, 2943 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2944 * See the License for the specific language governing permissions and 2945 * limitations under the License. 2946 */class Lf{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=jn(this.lastLoginAt),this.creationTime=jn(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/** 2947 * @license 2948 * Copyright 2019 Google LLC 2949 * 2950 * Licensed under the Apache License, Version 2.0 (the "License"); 2951 * you may not use this file except in compliance with the License. 2952 * You may obtain a copy of the License at 2953 * 2954 * http://www.apache.org/licenses/LICENSE-2.0 2955 * 2956 * Unless required by applicable law or agreed to in writing, software 2957 * distributed under the License is distributed on an "AS IS" BASIS, 2958 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2959 * See the License for the specific language governing permissions and 2960 * limitations under the License. 2961 */async function _r(n){var e;const t=n.auth,s=await n.getIdToken(),r=await rs(n,zT(t,{idToken:s}));A(r==null?void 0:r.users.length,t,"internal-error");const i=r.users[0];n._notifyReloadListener(i);const o=!((e=i.providerUserInfo)===null||e===void 0)&&e.length?ZT(i.providerUserInfo):[],a=JT(n.providerData,o),c=n.isAnonymous,u=!(n.email&&i.passwordHash)&&!(a!=null&&a.length),l=c?u:!1,h={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:a,metadata:new Lf(i.createdAt,i.lastLoginAt),isAnonymous:l};Object.assign(n,h)}async function XT(n){const e=q(n);await _r(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function JT(n,e){return[...n.filter(s=>!e.some(r=>r.providerId===s.providerId)),...e]}function ZT(n){return n.map(e=>{var{providerId:t}=e,s=Va(e,["providerId"]);return{providerId:t,uid:s.rawId||"",displayName:s.displayName||null,email:s.email||null,phoneNumber:s.phoneNumber||null,photoURL:s.photoUrl||null}})}/** 2962 * @license 2963 * Copyright 2020 Google LLC 2964 * 2965 * Licensed under the Apache License, Version 2.0 (the "License"); 2966 * you may not use this file except in compliance with the License. 2967 * You may obtain a copy of the License at 2968 * 2969 * http://www.apache.org/licenses/LICENSE-2.0 2970 * 2971 * Unless required by applicable law or agreed to in writing, software 2972 * distributed under the License is distributed on an "AS IS" BASIS, 2973 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2974 * See the License for the specific language governing permissions and 2975 * limitations under the License. 2976 */async function eE(n,e){const t=await Mf(n,{},async()=>{const s=os({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:r,apiKey:i}=n.config,o=Pf(n,r,"/v1/token",`key=${i}`),a=await n._getAdditionalHeaders();return a["Content-Type"]="application/x-www-form-urlencoded",Of.fetch()(o,{method:"POST",headers:a,body:s})});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}/** 2977 * @license 2978 * Copyright 2020 Google LLC 2979 * 2980 * Licensed under the Apache License, Version 2.0 (the "License"); 2981 * you may not use this file except in compliance with the License. 2982 * You may obtain a copy of the License at 2983 * 2984 * http://www.apache.org/licenses/LICENSE-2.0 2985 * 2986 * Unless required by applicable law or agreed to in writing, software 2987 * distributed under the License is distributed on an "AS IS" BASIS, 2988 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 2989 * See the License for the specific language governing permissions and 2990 * limitations under the License. 2991 */class is{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){A(e.idToken,"internal-error"),A(typeof e.idToken<"u","internal-error"),A(typeof e.refreshToken<"u","internal-error");
2991const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):WT(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}async getToken(e,t=!1){return A(!this.accessToken||this.refreshToken,e,"user-token-expired"),!t&&this.accessToken&&!this.isExpired?this.accessToken:this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:s,refreshToken:r,expiresIn:i}=await eE(e,t);this.updateTokensAndExpiration(s,r,Number(i))}updateTokensAndExpiration(e,t,s){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+s*1e3}static fromJSON(e,t){const{refreshToken:s,accessToken:r,expirationTime:i}=t,o=new is;return s&&(A(typeof s=="string","internal-error",{appName:e}),o.refreshToken=s),r&&(A(typeof r=="string","internal-error",{appName:e}),o.accessToken=r),i&&(A(typeof i=="number","internal-error",{appName:e}),o.expirationTime=i),o}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new is,this.toJSON())}_performRefresh(){return je("not implemented")}}/** 2992 * @license 2993 * Copyright 2020 Google LLC 2994 * 2995 * Licensed under the Apache License, Version 2.0 (the "License"); 2996 * you may not use this file except in compliance with the License. 2997 * You may obtain a copy of the License at 2998 * 2999 * http://www.apache.org/licenses/LICENSE-2.0 3000 * 3001 * Unless required by applicable law or agreed to in writing, software 3002 * distributed under the License is distributed on an "AS IS" BASIS, 3003 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3004 * See the License for the specific language governing permissions and 3005 * limitations under the License. 3006 */function Ye(n,e){A(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class Dt{constructor(e){var{uid:t,auth:s,stsTokenManager:r}=e,i=Va(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new YT(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=s,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.providerData=i.providerData?[...i.providerData]:[],this.metadata=new Lf(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){const t=await rs(this,this.stsTokenManager.getToken(this.auth,e));return A(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return HT(this,e)}reload(){return XT(this)}_assign(e){this!==e&&(A(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>Object.assign({},t)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){return new Dt(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}))}_onReload(e){A(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let s=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),s=!0),t&&await _r(this),await this.auth._persistUserIfCurrent(this),s&&this.auth._notifyListenersIfCurrent(this)}async delete(){const e=await this.getIdToken();return await rs(this,KT(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isA
3006nonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var s,r,i,o,a,c,u,l;const h=(s=t.displayName)!==null&&s!==void 0?s:void 0,d=(r=t.email)!==null&&r!==void 0?r:void 0,m=(i=t.phoneNumber)!==null&&i!==void 0?i:void 0,y=(o=t.photoURL)!==null&&o!==void 0?o:void 0,E=(a=t.tenantId)!==null&&a!==void 0?a:void 0,S=(c=t._redirectEventId)!==null&&c!==void 0?c:void 0,V=(u=t.createdAt)!==null&&u!==void 0?u:void 0,B=(l=t.lastLoginAt)!==null&&l!==void 0?l:void 0,{uid:F,emailVerified:X,isAnonymous:G,providerData:U,stsTokenManager:se}=t;A(F&&se,e,"internal-error");const mt=is.fromJSON(this.name,se);A(typeof F=="string",e,"internal-error"),Ye(h,e.name),Ye(d,e.name),A(typeof X=="boolean",e,"internal-error"),A(typeof G=="boolean",e,"internal-error"),Ye(m,e.name),Ye(y,e.name),Ye(E,e.name),Ye(S,e.name),Ye(V,e.name),Ye(B,e.name);const vi=new Dt({uid:F,auth:e,email:d,emailVerified:X,displayName:h,isAnonymous:G,photoURL:y,phoneNumber:m,tenantId:E,stsTokenManager:mt,createdAt:V,lastLoginAt:B});return U&&Array.isArray(U)&&(vi.providerData=U.map(ap=>Object.assign({},ap))),S&&(vi._redirectEventId=S),vi}static async _fromIdTokenResponse(e,t,s=!1){const r=new is;r.updateFromServerResponse(t);const i=new Dt({uid:t.localId,auth:e,stsTokenManager:r,isAnonymous:s});return await _r(i),i}}/** 3007 * @license 3008 * Copyright 2019 Google LLC 3009 * 3010 * Licensed under the Apache License, Version 2.0 (the "License"); 3011 * you may not use this file except in compliance with the License. 3012 * You may obtain a copy of the License at 3013 * 3014 * http://www.apache.org/licenses/LICENSE-2.0 3015 * 3016 * Unless required by applicable law or agreed to in writing, software 3017 * distributed under the License is distributed on an "AS IS" BASIS, 3018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3019 * See the License for the specific language governing permissions and 3020 * limitations under the License. 3021 */class Ff{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}Ff.type="NONE";const Du=Ff;/** 3022 * @license 3023 * Copyright 2019 Google LLC 3024 * 3025 * Licensed under the Apache License, Version 2.0 (the "License"); 3026 * you may not use this file except in compliance with the License. 3027 * You may obtain a copy of the License at 3028 * 3029 * http://www.apache.org/licenses/LICENSE-2.0 3030 * 3031 * Unless required by applicable law or agreed to in writing, software 3032 * distributed under the License is distributed on an "AS IS" BASIS, 3033 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3034 * See the License for the specific language governing permissions and 3035 * limitations under the License. 3036 */function Ys(n,e,t){return`firebase:${n}:${e}:${t}`}class sn{constructor(e,t,s){this.persistence=e,this.auth=t,this.userKey=s;const{config:r,name:i}=this.auth;this.fullUserKey=Ys(this.userKey,r.apiKey,i),this.fullPersistenceKey=Ys("persistence",r.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);return e?Dt._fromJSON(this.auth,e):null}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,s="authUser"){if(!t.length)return new sn(Ge(Du),e,s);const r=(await Promise.all(t.map(async u=>
3036{if(await u._isAvailable())return u}))).filter(u=>u);let i=r[0]||Ge(Du);const o=Ys(s,e.config.apiKey,e.name);let a=null;for(const u of t)try{const l=await u._get(o);if(l){const h=Dt._fromJSON(e,l);u!==i&&(a=h),i=u;break}}catch{}const c=r.filter(u=>u._shouldAllowMigration);return!i._shouldAllowMigration||!c.length?new sn(i,e,s):(i=c[0],a&&await i._set(o,a.toJSON()),await Promise.all(t.map(async u=>{if(u!==i)try{await u._remove(o)}catch{}})),new sn(i,e,s))}}/** 3037 * @license 3038 * Copyright 2020 Google LLC 3039 * 3040 * Licensed under the Apache License, Version 2.0 (the "License"); 3041 * you may not use this file except in compliance with the License. 3042 * You may obtain a copy of the License at 3043 * 3044 * http://www.apache.org/licenses/LICENSE-2.0 3045 * 3046 * Unless required by applicable law or agreed to in writing, software 3047 * distributed under the License is distributed on an "AS IS" BASIS, 3048 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3049 * See the License for the specific language governing permissions and 3050 * limitations under the License. 3051 */function Nu(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(Bf(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(Vf(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(qf(e))return"Blackberry";if(jf(e))return"Webos";if(qa(e))return"Safari";if((e.includes("chrome/")||Uf(e))&&!e.includes("edge/"))return"Chrome";if($f(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,s=n.match(t);if((s==null?void 0:s.length)===2)return s[1]}return"Other"}function Vf(n=Z()){return/firefox\//i.test(n)}function qa(n=Z()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function Uf(n=Z()){return/crios\//i.test(n)}function Bf(n=Z()){return/iemobile/i.test(n)}function $f(n=Z()){return/android/i.test(n)}function qf(n=Z()){return/blackberry/i.test(n)}function jf(n=Z()){return/webos/i.test(n)}function fi(n=Z()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function tE(n=Z()){var e;return fi(n)&&!!(!((e=window.navigator)===null||e===void 0)&&e.standalone)}function nE(){return Ip()&&document.documentMode===10}function Gf(n=Z()){return fi(n)||$f(n)||jf(n)||qf(n)||/windows phone/i.test(n)||Bf(n)}function sE(){try{return!!(window&&window!==window.top)}catch{return!1}}/** 3052 * @license 3053 * Copyright 2020 Google LLC 3054 * 3055 * Licensed under the Apache License, Version 2.0 (the "License"); 3056 * you may not use this file except in compliance with the License. 3057 * You may obtain a copy of the License at 3058 * 3059 * http://www.apache.org/licenses/LICENSE-2.0 3060 * 3061 * Unless required by applicable law or agreed to in writing, software 3062 * distributed under the License is distributed on an "AS IS" BASIS, 3063 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3064 * See the License for the specific language governing permissions and 3065 * limitations under the License. 3066 */function Kf(n,e=[]){let t;switch(n){case"Browser":t=Nu(Z());break;case"Worker":t=`${Nu(Z())}-${n}`;break;default:t=n}const s=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${as}/${s}`}/** 3067 * @license 3068 * Copyright 2022 Google LLC 3069 * 3070 * Licensed under the Apache License, Version 2.0 (the "License"); 3071 * you may not use this file except in compliance with the License. 3072 * You may obtain a copy of the License at 3073 * 3074 * http://www.apache.org/licenses/LICENSE-2.0 3075 * 3076 * Unless required by applicable law or agreed to in writing, software 3077 * distributed under the License is distributed on an "AS IS" BASIS, 3078 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3079 * See the License for the specific language governing permissions and 3080 * limitations under the License. 3081 */class rE{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const s=i=>new Promise((o,a)=>{try{const c=e(i);o(c)}catch(c){a(c)}});s.onAbort=t,this.queue.push(s);const r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const s of this.queue)await s(e),s.onAbort&&t.push(s.onAbort)}catch(s){t.reverse();for(const r of t)try{r()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:s==null?void 0:s.message})}}}/** 3082 * @license 3083 * Copyright 2020 Google LLC 3084 * 3085 * Licensed under the Apache License, Version 2.0 (the "License");
3086 * you may not use this file except in compliance with the License. 3087 * You may obtain a copy of the License at 3088 * 3089 * http://www.apache.org/licenses/LICENSE-2.0 3090 * 3091 * Unless required by applicable law or agreed to in writing, software 3092 * distributed under the License is distributed on an "AS IS" BASIS, 3093 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3094 * See the License for the specific language governing permissions and 3095 * limitations under the License. 3096 */class iE{constructor(e,t,s){this.app=e,this.heartbeatServiceProvider=t,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new xu(this),this.idTokenSubscription=new xu(this),this.beforeStateQueue=new rE(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=xf,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=s.sdkClientVersion}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=Ge(t)),this._initializationPromise=this.queue(async()=>{var s,r;if(!this._deleted&&(this.persistenceManager=await sn.create(this,e),!this._deleted)){if(!((s=this._popupRedirectResolver)===null||s===void 0)&&s._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=((r=this.currentUser)===null||r===void 0?void 0:r.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUser(e){var t;const s=await this.assertedPersistence.getCurrentUser();let r=s,i=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const o=(t=this.redirectUser)===null||t===void 0?void 0:t._redirectEventId,a=r==null?void 0:r._redirectEventId,c=await this.tryRedirectSignIn(e);(!o||o===a)&&(c!=null&&c.user)&&(r=c.user,i=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(r)}catch(o){r=s,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(o))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return A(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await _r(e)}catch(t){if((t==null?void 0:t.code)!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=UT()}async _delete(){this._deleted=!0}async updateCurrentUser(e){const t=e?q(e):null;return t&&A(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&A(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0)}setPersistence(e){return this.queue(async()=>{await this.assertedPersistence.setPersistence(Ge(e))})}_getPersistence(){return this.assertedPersistence.persistence.type}_updateErrorMap(e){this._errorFactory=new qt("auth","Firebase",e())}onAuthStateChanged(e,t,s){return this.registerStateListener(this.authStateSubscription,e,t,s)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,s){return this.registerStateListener(this.idTokenSubscription,e,t,s)}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:(e=this._currentUser)===null||e===void 0?void 0:e.toJSON()}}async _setRedirectUser(e,t){const s=await this.getOrInitRedirectPersistenceManager(t);return e===null?s.removeCurrentUser():s.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&Ge(e)||this._popupRedirectResolver;A(t,this,"argument-error"),this.redirectPersistenceManager=await sn.create(this,[Ge(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,s;return this._isInitialized&&await this.queue(async()=>{}),((t=this._currentUser)===null||t===void 0?void 0:t._redirectEventId)===e?this._currentUser:((s=this.redirectUser)===null||s===void 0?void 0:s._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const s=(t=(e=this.currentUser)===null||e===void 0?void 0:e.uid)!==null&&t!==void 0?t:null;this.lastNotifiedUid!==s&&(this.lastNotifiedUid=s,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,s,r){if(this._deleted)return()=>{};const i=typeof t=="function"?t:t.next.bind(t),o=this._isInitialized?Promise.resolve():this._initializationPromise;return A(o,this,"internal-error"),o.then(()=>i(this.currentUser)),typeof t=="function"?e.addObserver(t,s,r):e.addObserver(t)}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return A(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=Kf(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={["X-Client-Version"]:this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const s=await((e=this.heartbeatServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getHeartbeatsHeader());return s&&(t["X-Firebase-Client"]=s),t}}function pi(n){return q(n)}class xu{constructor(e){this.auth=e,this.observer=null,this.addObserver=Cp(t=>this.observer=t)}get next(){return A(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}function oE(n,e,t){const s=pi(n);A(s._canInitEmulator,s,"emulator-config-failed"),A(/^https?:\/\//.test(e),s,"invalid-emulator-scheme");const r=!!(t!=null&&t.disableWarnings),i=zf(e),{host:o,port:a}=aE(e),c=a===null?"":`:${a}`;s.config.emulator={url:`${i}//${o}${c}/`},s.settings.appVerificationDisabledForTesting=!0,s.emulatorConfig=Object.freeze({host:o,port:a,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:r})}),r||cE()}function zf(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function aE(n){const e=zf(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const s=t[2].split("@").pop()||"",r=/^(\[[^\]]+\])(:|$)/.exec(s);if(r){const i=r[1];return{host:i,port:Ru(s.substr(i.length+1))}}else{const[i,o]=s.split(":");return{host:i,port:Ru(o)}}}function Ru(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function cE(){function n(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",n):n())}/** 3097 * @license 3098 * Copyright 2020 Google LLC 3099 * 3100 * Licensed under the Apache License, Version 2.0 (the "License");
3101 * you may not use this file except in compliance with the License. 3102 * You may obtain a copy of the License at 3103 * 3104 * http://www.apache.org/licenses/LICENSE-2.0 3105 * 3106 * Unless required by applicable law or agreed to in writing, software 3107 * distributed under the License is distributed on an "AS IS" BASIS, 3108 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3109 * See the License for the specific language governing permissions and 3110 * limitations under the License. 3111 */class Hf{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return je("not implemented")}_getIdTokenResponse(e){return je("not implemented")}_linkToIdToken(e,t){return je("not implemented")}_getReauthenticationResolver(e){return je("not implemented")}}/** 3112 * @license 3113 * Copyright 2020 Google LLC 3114 * 3115 * Licensed under the Apache License, Version 2.0 (the "License"); 3116 * you may not use this file except in compliance with the License. 3117 * You may obtain a copy of the License at 3118 * 3119 * http://www.apache.org/licenses/LICENSE-2.0 3120 * 3121 * Unless required by applicable law or agreed to in writing, software 3122 * distributed under the License is distributed on an "AS IS" BASIS, 3123 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3124 * See the License for the specific language governing permissions and 3125 * limitations under the License. 3126 */async function rn(n,e){return jT(n,"POST","/v1/accounts:signInWithIdp",qT(n,e))}/** 3127 * @license 3128 * Copyright 2020 Google LLC 3129 * 3130 * Licensed under the Apache License, Version 2.0 (the "License"); 3131 * you may not use this file except in compliance with the License. 3132 * You may obtain a copy of the License at 3133 * 3134 * http://www.apache.org/licenses/LICENSE-2.0 3135 * 3136 * Unless required by applicable law or agreed to in writing, software 3137 * distributed under the License is distributed on an "AS IS" BASIS, 3138 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3139 * See the License for the specific language governing permissions and 3140 * limitations under the License. 3141 */const uE="http://localhost";class $t extends Hf{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new $t(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):Ue("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,n
3141once:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:s,signInMethod:r}=t,i=Va(t,["providerId","signInMethod"]);if(!s||!r)return null;const o=new $t(s,r);return o.idToken=i.idToken||void 0,o.accessToken=i.accessToken||void 0,o.secret=i.secret,o.nonce=i.nonce,o.pendingToken=i.pendingToken||null,o}_getIdTokenResponse(e){const t=this.buildRequest();return rn(e,t)}_linkToIdToken(e,t){const s=this.buildRequest();return s.idToken=t,rn(e,s)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,rn(e,t)}buildRequest(){const e={requestUri:uE,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=os(t)}return e}}/** 3142 * @license 3143 * Copyright 2020 Google LLC 3144 * 3145 * Licensed under the Apache License, Version 2.0 (the "License"); 3146 * you may not use this file except in compliance with the License. 3147 * You may obtain a copy of the License at 3148 * 3149 * http://www.apache.org/licenses/LICENSE-2.0 3150 * 3151 * Unless required by applicable law or agreed to in writing, software 3152 * distributed under the License is distributed on an "AS IS" BASIS, 3153 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3154 * See the License for the specific language governing permissions and 3155 * limitations under the License. 3156 */class ja{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}/** 3157 * @license 3158 * Copyright 2019 Google LLC 3159 * 3160 * Licensed under the Apache License, Version 2.0 (the "License"); 3161 * you may not use this file except in compliance with the License. 3162 * You may obtain a copy of the License at 3163 * 3164 * http://www.apache.org/licenses/LICENSE-2.0 3165 * 3166 * Unless required by applicable law or agreed to in writing, software 3167 * distributed under the License is distributed on an "AS IS" BASIS, 3168 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3169 * See the License for the specific language governing permissions and 3170 * limitations under the License. 3171 */class Ns extends ja{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}/** 3172 * @license 3173 * Copyright 2020 Google LLC 3174 * 3175 * Licensed under the Apache License, Version 2.0 (the "License"); 3176 * you may not use this file except in compliance with the License. 3177 * You may obtain a copy of the License at 3178 * 3179 * http://www.apache.org/licenses/LICENSE-2.0 3180 * 3181 * Unless required by applicable law or agreed to in writing, software 3182 * distributed under the License is distributed on an "AS IS" BASIS, 3183 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3184 * See the License for the specific language governing permissions and 3185 * limitations under the License. 3186 */class Je extends Ns{constructor(){super("facebook.com")}static credential(e){return $t._fromParams({providerId:Je.PROVIDER_ID,signInMethod:Je.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Je.credentialFromTaggedObject(e)}static credentialFromError(e){return Je.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Je.credential(e.oauthAccessToken)}catch{return null}}}Je.FACEBOOK_SIGN_IN_METHOD="facebook.com";Je.PROVIDER_ID="facebook.com";/** 3187 * @license 3188 * Copyright 2020 Google LLC 3189 * 3190 * Licensed under the Apache License, Version 2.0 (the "License"); 3191 * you may not use this file except in compliance with the License. 3192 * You may obtain a copy of the License at 3193 * 3194 * http://www.apache.org/licenses/LICENSE-2.0 3195 * 3196 * Unless required by applicable law or agreed to in writing, softw
3196are 3197 * distributed under the License is distributed on an "AS IS" BASIS, 3198 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3199 * See the License for the specific language governing permissions and 3200 * limitations under the License. 3201 */class Be extends Ns{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return $t._fromParams({providerId:Be.PROVIDER_ID,signInMethod:Be.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return Be.credentialFromTaggedObject(e)}static credentialFromError(e){return Be.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:s}=e;if(!t&&!s)return null;try{return Be.credential(t,s)}catch{return null}}}Be.GOOGLE_SIGN_IN_METHOD="google.com";Be.PROVIDER_ID="google.com";/** 3202 * @license 3203 * Copyright 2020 Google LLC 3204 * 3205 * Licensed under the Apache License, Version 2.0 (the "License"); 3206 * you may not use this file except in compliance with the License. 3207 * You may obtain a copy of the License at 3208 * 3209 * http://www.apache.org/licenses/LICENSE-2.0 3210 * 3211 * Unless required by applicable law or agreed to in writing, software 3212 * distributed under the License is distributed on an "AS IS" BASIS, 3213 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3214 * See the License for the specific language governing permissions and 3215 * limitations under the License. 3216 */class Ze extends Ns{constructor(){super("github.com")}static credential(e){return $t._fromParams({providerId:Ze.PROVIDER_ID,signInMethod:Ze.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Ze.credentialFromTaggedObject(e)}static credentialFromError(e){return Ze.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Ze.credential(e.oauthAccessToken)}catch{return null}}}Ze.GITHUB_SIGN_IN_METHOD="github.com";Ze.PROVIDER_ID="github.com";/** 3217 * @license 3218 * Copyright 2020 Google LLC 3219 * 3220 * Licensed under the Apache License, Version 2.0 (the "License"); 3221 * you may not use this file except in compliance with the License. 3222 * You may obtain a copy of the License at 3223 * 3224 * http://www.apache.org/licenses/LICENSE-2.0 3225 * 3226 * Unless required by applicable law or agreed to in writing, software 3227 * distributed under the License is distributed on an "AS IS" BASIS, 3228 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3229 * See the License for the specific language governing permissions and 3230 * limitations under the License. 3231 */class et extends Ns{constructor(){super("twitter.com")}static credential(e,t){return $t._fromParams({providerId:et.PROVIDER_ID,signInMethod:et.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return et.credentialFromTaggedObject(e)}static credentialFromError(e){return et.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:s}=e;if(!t||!s)return null;try{return et.credential(t,s)}catch{return null}}}et.TWITTER_SIGN_IN_METHOD="twitter.com";et.PROVIDER_ID="twitter.com";/** 3232 * @license 3233 * Copyright 2020 Google LLC 3234 * 3235 * Licensed under the Apache License, Version 2.0 (the "License"); 3236 * you may not use this file except in compliance with the License. 3237 * You may obtain a copy of the License at 3238 * 3239 * http://www.apache.org/licenses/LICENSE-2.0 3240 * 3241 * Unless required by applicable law or agreed to in writing, software 3242 * distributed under the License is distributed on an "AS IS" BASIS, 3243 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3244 * See the License for the specific language governing permissions and 3245 * limitations under the License. 3246 */class yn{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,s,r=!1){const i=await Dt._fromIdTokenResponse(e,s,r),o=Ou(s);return new yn({user:i,providerId:o,_tokenResponse:s,operationType:t})}static async _forOperation(e,t,s){await e._updateTokensIfNecessary(s,!0);const r=Ou(s);
3246return new yn({user:e,providerId:r,_tokenResponse:s,operationType:t})}}function Ou(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}/** 3247 * @license 3248 * Copyright 2020 Google LLC 3249 * 3250 * Licensed under the Apache License, Version 2.0 (the "License"); 3251 * you may not use this file except in compliance with the License. 3252 * You may obtain a copy of the License at 3253 * 3254 * http://www.apache.org/licenses/LICENSE-2.0 3255 * 3256 * Unless required by applicable law or agreed to in writing, software 3257 * distributed under the License is distributed on an "AS IS" BASIS, 3258 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3259 * See the License for the specific language governing permissions and 3260 * limitations under the License. 3261 */class Sr extends ke{constructor(e,t,s,r){var i;super(t.code,t.message),this.operationType=s,this.user=r,Object.setPrototypeOf(this,Sr.prototype),this.customData={appName:e.name,tenantId:(i=e.tenantId)!==null&&i!==void 0?i:void 0,_serverResponse:t.customData._serverResponse,operationType:s}}static _fromErrorAndOperation(e,t,s,r){return new Sr(e,t,s,r)}}function Wf(n,e,t,s){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?Sr._fromErrorAndOperation(n,i,e,s):i})}async function lE(n,e,t=!1){const s=await rs(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return yn._forOperation(n,"link",s)}/** 3262 * @license 3263 * Copyright 2019 Google LLC 3264 * 3265 * Licensed under the Apache License, Version 2.0 (the "License"); 3266 * you may not use this file except in compliance with the License. 3267 * You may obtain a copy of the License at 3268 * 3269 * http://www.apache.org/licenses/LICENSE-2.0 3270 * 3271 * Unless required by applicable law or agreed to in writing, software 3272 * distributed under the License is distributed on an "AS IS" BASIS, 3273 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3274 * See the License for the specific language governing permissions and 3275 * limitations under the License. 3276 */async function hE(n,e,t=!1){const{auth:s}=n,r="reauthenticate";try{const i=await rs(n,Wf(s,r,e,n),t);A(i.idToken,s,"internal-error");const o=$a(i.idToken);A(o,s,"internal-error");const{sub:a}=o;return A(n.uid===a,s,"user-mismatch"),yn._forOperation(n,r,i)}catch(i){throw(i==null?void 0:i.code)==="auth/user-not-found"&&Ue(s,"user-mismatch"),i}}/** 3277 * @license 3278 * Copyright 2020 Google LLC 3279 * 3280 * Licensed under the Apache License, Version 2.0 (the "License"); 3281 * you may not use this file except in compliance with the License. 3282 * You may obtain a copy of the License at 3283 * 3284 * http://www.apache.org/licenses/LICENSE-2.0 3285 * 3286 * Unless required by applicable law or agreed to in writing, software 3287 * distributed under the License is distributed on an "AS IS" BASIS, 3288 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3289 * See the License for the specific language governing permissions and 3290 * limitations under the License. 3291 */async function dE(n,e,t=!1){const s="signIn",r=await Wf(n,s,e),i=await yn._fromIdTokenResponse(n,s,r);return t||await n._updateCurrentUser(i.user),i}/** 3292 * @license 3293 * Copyright 2020 Google LLC 3294 * 3295 * Licensed under the Apache License, Version 2.0 (the "License"); 3296 * you may not use this file except in compliance with the License. 3297 * You may obtain a copy of the License at 3298 * 3299 * http://www.apache.org/licenses/LICENSE-2.0 3300 * 3301 * Unless required by applicable law or agreed to in writing, software 3302 * distributed under the License is distributed on an "AS IS" BASIS, 3303 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3304 * See the License for the specific language governing permissions and 3305 * limitations under the License. 3306 */function fE(n,e){return q(n).setPersistence(e)}function pE(n,e,t,s){return q(n).onIdTokenChanged(e,t,s)}function mE(n,e,t){return q(n).beforeAuthStateChanged(e,t)}const Ar="__sak";/** 3307 * @license 3308 * Copyright 2019 Google LLC 3309 * 3310 * Licensed under the Apache License, Version 2.0 (the "License"); 3311 * you may not use this file except in compliance with the License. 3312 * You may obtain a copy of the License at 3313 * 3314 * http://www.apache.org/licenses/LICENSE-2.0 3315 * 3316 * Unless required by applicable law or agreed to in writing, softw
3316are 3317 * distributed under the License is distributed on an "AS IS" BASIS, 3318 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3319 * See the License for the specific language governing permissions and 3320 * limitations under the License. 3321 */class Qf{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Ar,"1"),this.storage.removeItem(Ar),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}/** 3322 * @license 3323 * Copyright 2020 Google LLC 3324 * 3325 * Licensed under the Apache License, Version 2.0 (the "License"); 3326 * you may not use this file except in compliance with the License. 3327 * You may obtain a copy of the License at 3328 * 3329 * http://www.apache.org/licenses/LICENSE-2.0 3330 * 3331 * Unless required by applicable law or agreed to in writing, software 3332 * distributed under the License is distributed on an "AS IS" BASIS, 3333 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3334 * See the License for the specific language governing permissions and 3335 * limitations under the License. 3336 */function gE(){const n=Z();return qa(n)||fi(n)}const yE=1e3,vE=10;class Yf extends Qf{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.safariLocalStorageNotSynced=gE()&&sE(),this.fallbackToPolling=Gf(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const s=this.storage.getItem(t),r=this.localCache[t];s!==r&&e(t,r,s)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((o,a,c)=>{this.notifyListeners(o,c)});return}const s=e.key;if(t?this.detachListener():this.stopPolling(),this.safariLocalStorageNotSynced){const o=this.storage.getItem(s);if(e.newValue!==o)e.newValue!==null?this.storage.setItem(s,e.newValue):this.storage.removeItem(s);else if(this.localCache[s]===e.newValue&&!t)return}const r=()=>{const o=this.storage.getItem(s);!t&&this.localCache[s]===o||this.notifyListeners(s,o)},i=this.storage.getItem(s);nE()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(r,vE):r()}notifyListeners(e,t){this.localCache[e]=t;const s=this.listeners[e];if(s)for(const r of Array.from(s))r(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,s)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:s}),!0)})},yE)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
3336ject.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Yf.type="LOCAL";const Xf=Yf;/** 3337 * @license 3338 * Copyright 2020 Google LLC 3339 * 3340 * Licensed under the Apache License, Version 2.0 (the "License"); 3341 * you may not use this file except in compliance with the License. 3342 * You may obtain a copy of the License at 3343 * 3344 * http://www.apache.org/licenses/LICENSE-2.0 3345 * 3346 * Unless required by applicable law or agreed to in writing, software 3347 * distributed under the License is distributed on an "AS IS" BASIS, 3348 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3349 * See the License for the specific language governing permissions and 3350 * limitations under the License. 3351 */class Jf extends Qf{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Jf.type="SESSION";const Zf=Jf;/** 3352 * @license 3353 * Copyright 2019 Google LLC 3354 * 3355 * Licensed under the Apache License, Version 2.0 (the "License"); 3356 * you may not use this file except in compliance with the License. 3357 * You may obtain a copy of the License at 3358 * 3359 * http://www.apache.org/licenses/LICENSE-2.0 3360 * 3361 * Unless required by applicable law or agreed to in writing, software 3362 * distributed under the License is distributed on an "AS IS" BASIS, 3363 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3364 * See the License for the specific language governing permissions and 3365 * limitations under the License. 3366 */function wE(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}/** 3367 * @license 3368 * Copyright 2019 Google LLC 3369 * 3370 * Licensed under the Apache License, Version 2.0 (the "License"); 3371 * you may not use this file except in compliance with the License. 3372 * You may obtain a copy of the License at 3373 * 3374 * http://www.apache.org/licenses/LICENSE-2.0 3375 * 3376 * Unless required by applicable law or agreed to in writing, software 3377 * distributed under the License is distributed on an "AS IS" BASIS, 3378 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3379 * See the License for the specific language governing permissions and 3380 * limitations under the License. 3381 */class mi{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(r=>r.isListeningto(e));if(t)return t;const s=new mi(e);return this.receivers.push(s),s}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:s,eventType:r,data:i}=t.data,o=this.handlersMap[r];if(!(o!=null&&o.size))return;t.ports[0].postMessage({status:"ack",eventId:s,eventType:r});const a=Array.from(o).map(async u=>u(t.origin,i)),c=await wE(a);t.ports[0].postMessage({status:"done",eventId:s,eventType:r,response:c})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),(!t||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}mi.receivers=[];/** 3382 * @license 3383 * Copyright 2020 Google LLC 3384 * 3385 * Licensed under the Apache License, Version 2.0 (the "License"); 3386 * you may not use this file except in compliance with the License. 3387 * You may obtain a copy of the License at 3388 * 3389 * http://www.apache.org/licenses/LICENSE-2.0 3390 * 3391 * Unless required by applicable law or agreed to in writing, software 3392 * distributed under the License is distributed on an "AS IS" BASIS, 3393 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3394 * See the License for the specific language governing permissions and 3395 * limitations under the License. 3396 */function Ga(n="",e=10){let t="";for(let s=0;s<e;s++)t+=Math.floor(Math.random()*10);return n+t}/** 3397 * @license 3398 * Copyright 2019 Google LLC 3399 * 3400 * Licensed under the Apache License, Version 2.0 (the "License");
3401 * you may not use this file except in compliance with the License. 3402 * You may obtain a copy of the License at 3403 * 3404 * http://www.apache.org/licenses/LICENSE-2.0 3405 * 3406 * Unless required by applicable law or agreed to in writing, software 3407 * distributed under the License is distributed on an "AS IS" BASIS, 3408 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3409 * See the License for the specific language governing permissions and 3410 * limitations under the License. 3411 */class IE{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,s=50){const r=typeof MessageChannel<"u"?new MessageChannel:null;if(!r)throw new Error("connection_unavailable");let i,o;return new Promise((a,c)=>{const u=Ga("",20);r.port1.start();const l=setTimeout(()=>{c(new Error("unsupported_event"))},s);o={messageChannel:r,onMessage(h){const d=h;if(d.data.eventId===u)switch(d.data.status){case"ack":clearTimeout(l),i=setTimeout(()=>{c(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),a(d.data.response);break;default:clearTimeout(l),clearTimeout(i),c(new Error("invalid_response"));break}}},this.handlers.add(o),r.port1.addEventListener("message",o.onMessage),this.target.postMessage({eventType:e,eventId:u,data:t},[r.port2])}).finally(()=>{o&&this.removeMessageHandler(o)})}}/** 3412 * @license 3413 * Copyright 2020 Google LLC 3414 * 3415 * Licensed under the Apache License, Version 2.0 (the "License"); 3416 * you may not use this file except in compliance with the License. 3417 * You may obtain a copy of the License at 3418 * 3419 * http://www.apache.org/licenses/LICENSE-2.0 3420 * 3421 * Unless required by applicable law or agreed to in writing, software 3422 * distributed under the License is distributed on an "AS IS" BASIS, 3423 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3424 * See the License for the specific language governing permissions and 3425 * limitations under the License. 3426 */function Fe(){return window}function TE(n){Fe().location.href=n}/** 3427 * @license 3428 * Copyright 2020 Google LLC. 3429 * 3430 * Licensed under the Apache License, Version 2.0 (the "License"); 3431 * you may not use this file except in compliance with the License. 3432 * You may obtain a copy of the License at 3433 * 3434 * http://www.apache.org/licenses/LICENSE-2.0 3435 * 3436 * Unless required by applicable law or agreed to in writing, software 3437 * distributed under the License is distributed on an "AS IS" BASIS, 3438 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3439 * See the License for the specific language governing permissions and 3440 * limitations under the License. 3441 */function ep(){return typeof Fe().WorkerGlobalScope<"u"&&typeof Fe().importScripts=="function"}async function EE(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function bE(){var n;return((n=navigator==null?void 0:navigator.serviceWorker)===null||n===void 0?void 0:n.controller)||null}function _E(){return ep()?self:null}/** 3442 * @license 3443 * Copyright 2019 Google LLC 3444 * 3445 * Licensed under the Apache License, Version 2.0 (the "License"); 3446 * you may not use this file except in compliance with the License. 3447 * You may obtain a copy of the License at 3448 * 3449 * http://www.apache.org/licenses/LICENSE-2.0 3450 * 3451 * Unless required by applicable law or agreed to in writing, software 3452 * distributed under the License is distributed on an "AS IS" BASIS, 3453 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3454 * See the License for the specific language governing permissions and 3455 * limitations under the License. 3456 */const tp="firebaseLocalStorageDb",SE=1,Cr="firebaseLocalStorage",np="fbase_key";class xs{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function gi(n,e){return n.transaction([Cr],e?"readwrite":"readonly").objectStore(Cr)}function AE(){const n=indexedDB.deleteDatabase(tp);return new xs(n).toPromise()}function Co(){const n=indexedDB.open(tp,SE);return new Promise((e,t)=>
3456{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const s=n.result;try{s.createObjectStore(Cr,{keyPath:np})}catch(r){t(r)}}),n.addEventListener("success",async()=>{const s=n.result;s.objectStoreNames.contains(Cr)?e(s):(s.close(),await AE(),e(await Co()))})})}async function Mu(n,e,t){const s=gi(n,!0).put({[np]:e,value:t});return new xs(s).toPromise()}async function CE(n,e){const t=gi(n,!1).get(e),s=await new xs(t).toPromise();return s===void 0?null:s.value}function Pu(n,e){const t=gi(n,!0).delete(e);return new xs(t).toPromise()}const kE=800,DE=3;class sp{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await Co(),this.db)}async _withRetries(e){let t=0;for(;;)try{const s=await this._openDb();return await e(s)}catch(s){if(t++>DE)throw s;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return ep()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=mi._getInstance(_E()),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t;if(this.activeServiceWorker=await EE(),!this.activeServiceWorker)return;this.sender=new IE(this.activeServiceWorker);const s=await this.sender._send("ping",{},800);s&&!((e=s[0])===null||e===void 0)&&e.fulfilled&&!((t=s[0])===null||t===void 0)&&t.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||bE()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await Co();return await Mu(e,Ar,"1"),await Pu(e,Ar),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(s=>Mu(s,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(s=>CE(s,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Pu(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(r=>{const i=gi(r,!1).getAll();return new xs(i).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],s=new Set;for(const{fbase_key:r,value:i}of e)s.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),t.push(r));for(const r of Object.keys(this.localCache))this.localCache[r]&&!s.has(r)&&(this.notifyListeners(r,null),t.push(r));return t}notifyListeners(e,t){this.localCache[e]=t;const s=this.listeners[e];if(s)for(const r of Array.from(s))r(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),kE)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Ob
3456ject.keys(this.listeners).length===0&&this.stopPolling()}}sp.type="LOCAL";const NE=sp;/** 3457 * @license 3458 * Copyright 2020 Google LLC 3459 * 3460 * Licensed under the Apache License, Version 2.0 (the "License"); 3461 * you may not use this file except in compliance with the License. 3462 * You may obtain a copy of the License at 3463 * 3464 * http://www.apache.org/licenses/LICENSE-2.0 3465 * 3466 * Unless required by applicable law or agreed to in writing, software 3467 * distributed under the License is distributed on an "AS IS" BASIS, 3468 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3469 * See the License for the specific language governing permissions and 3470 * limitations under the License. 3471 */function xE(){var n,e;return(e=(n=document.getElementsByTagName("head"))===null||n===void 0?void 0:n[0])!==null&&e!==void 0?e:document}function RE(n){return new Promise((e,t)=>{const s=document.createElement("script");s.setAttribute("src",n),s.onload=e,s.onerror=r=>{const i=Le("internal-error");i.customData=r,t(i)},s.type="text/javascript",s.charset="UTF-8",xE().appendChild(s)})}function OE(n){return`__${n}${Math.floor(Math.random()*1e6)}`}new Ds(3e4,6e4);/** 3472 * @license 3473 * Copyright 2021 Google LLC 3474 * 3475 * Licensed under the Apache License, Version 2.0 (the "License"); 3476 * you may not use this file except in compliance with the License. 3477 * You may obtain a copy of the License at 3478 * 3479 * http://www.apache.org/licenses/LICENSE-2.0 3480 * 3481 * Unless required by applicable law or agreed to in writing, software 3482 * distributed under the License is distributed on an "AS IS" BASIS, 3483 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3484 * See the License for the specific language governing permissions and 3485 * limitations under the License. 3486 */function rp(n,e){return e?Ge(e):(A(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}/** 3487 * @license 3488 * Copyright 2019 Google LLC 3489 * 3490 * Licensed under the Apache License, Version 2.0 (the "License"); 3491 * you may not use this file except in compliance with the License. 3492 * You may obtain a copy of the License at 3493 * 3494 * http://www.apache.org/licenses/LICENSE-2.0 3495 * 3496 * Unless required by applicable law or agreed to in writing, software 3497 * distributed under the License is distributed on an "AS IS" BASIS, 3498 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3499 * See the License for the specific language governing permissions and 3500 * limitations under the License. 3501 */class Ka extends Hf{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return rn(e,this._buildIdpRequest())}_linkToIdToken(e,t){return rn(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return rn(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function ME(n){return dE(n.auth,new Ka(n),n.bypassAuthState)}function PE(n){const{auth:e,user:t}=n;return A(t,e,"internal-error"),hE(t,new Ka(n),n.bypassAuthState)}async function LE(n){const{auth:e,user:t}=n;return A(t,e,"internal-error"),lE(t,new Ka(n),n.bypassAuthState)}/** 3502 * @license 3503 * Copyright 2020 Google LLC 3504 * 3505 * Licensed under the Apache License, Version 2.0 (the "License"); 3506 * you may not use this file except in compliance with the License. 3507 * You may obtain a copy of the License at 3508 * 3509 * http://www.apache.org/licenses/LICENSE-2.0 3510 * 3511 * Unless required by applicable law or agreed to in writing, software 3512 * distributed under the License is distributed on an "AS IS" BASIS, 3513 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3514 * See the License for the specific language governing permissions and 3515 * limitations under the License. 3516 */class ip{constructor(e,t,s,r,i=!1){this.auth=e,this.resolver=s,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(s){this.reject(s)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:s,postBody:r,tenantId:i,error:o,type:a}=e;if(o){this.reject(o);return}const c={auth:this.auth,requestUri:t,sessionId:s,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(a)(c))}catch(u){this.reject(u)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return ME;case"linkViaPopup":case"linkViaRedirect":return LE;case"reauthViaPopup":case"reauthViaRedirect":return PE;default:Ue(this.auth,"internal-error")}}resolve(e){ze(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){ze(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}/** 3517 * @license 3518 * Copyright 2020 Google LLC 3519 * 3520 * Licensed under the Apache License, Version 2.0 (the "License");
3521 * you may not use this file except in compliance with the License. 3522 * You may obtain a copy of the License at 3523 * 3524 * http://www.apache.org/licenses/LICENSE-2.0 3525 * 3526 * Unless required by applicable law or agreed to in writing, software 3527 * distributed under the License is distributed on an "AS IS" BASIS, 3528 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3529 * See the License for the specific language governing permissions and 3530 * limitations under the License. 3531 */const FE=new Ds(2e3,1e4);async function z0(n,e,t){const s=pi(n);MT(n,e,ja);const r=rp(s,t);return new At(s,"signInViaPopup",e,r).executeNotNull()}class At extends ip{constructor(e,t,s,r,i){super(e,t,r,i),this.provider=s,this.authWindow=null,this.pollId=null,At.currentPopupAction&&At.currentPopupAction.cancel(),At.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return A(e,this.auth,"internal-error"),e}async onExecution(){ze(this.filter.length===1,"Popup operations only handle one event");const e=Ga();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(Le(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)===null||e===void 0?void 0:e.associatedEvent)||null}cancel(){this.reject(Le(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,At.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,s;if(!((s=(t=this.authWindow)===null||t===void 0?void 0:t.window)===null||s===void 0)&&s.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Le(this.auth,"popup-closed-by-user"))},2e3);return}this.pollId=window.setTimeout(e,FE.get())};e()}}At.currentPopupAction=null;/** 3532 * @license 3533 * Copyright 2020 Google LLC 3534 * 3535 * Licensed under the Apache License, Version 2.0 (the "License"); 3536 * you may not use this file except in compliance with the License. 3537 * You may obtain a copy of the License at 3538 * 3539 * http://www.apache.org/licenses/LICENSE-2.0 3540 * 3541 * Unless required by applicable law or agreed to in writing, software 3542 * distributed under the License is distributed on an "AS IS" BASIS, 3543 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3544 * See the License for the specific language governing permissions and 3545 * limitations under the License. 3546 */const VE="pendingRedirect",Xs=new Map;class UE extends ip{constructor(e,t,s=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,s),this.eventId=null}async execute(){let e=Xs.get(this.auth._key());if(!e){try{const s=await BE(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(s)}catch(t){e=()=>Promise.reject(t)}Xs.set(this.auth._key(),e)}return this.bypassAuthState||Xs.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function BE(n,e){const t=jE(e),s=qE(n);if(!await s._isAvailable())return!1;const r=await s._get(t)==="true";return await s._remove(t),r}function $E(n,e){Xs.set(n._key(),e)}function qE(n){return Ge(n._redirectPersistence)}function jE(n){return Ys(VE,n.config.apiKey,n.name)}async function GE(n,e,t=!1){const s=pi(n),r=rp(s,e),o=await new UE(s,r,t).execute();return o&&!t&&(delete o.user._redirectEventId,await s._persistUserIfCurrent(o.user),await s._setRedirectUser(null,e)),o}/** 3547 * @license 3548 * Copyright 2020 Google LLC 3549 * 3550 * Licensed under the Apache License, Version 2.0 (the "License"); 3551 * you may not use this file except in compliance with the License. 3552 * You may obtain a copy of the License at 3553 * 3554 * http://www.apache.org/licenses/LICENSE-2.0 3555 * 3556 * Unless required by applicable law or agreed to in writing, softw
3556are 3557 * distributed under the License is distributed on an "AS IS" BASIS, 3558 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3559 * See the License for the specific language governing permissions and 3560 * limitations under the License. 3561 */const KE=10*60*1e3;class zE{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(s=>{this.isEventForConsumer(e,s)&&(t=!0,this.sendToConsumer(e,s),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!HE(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var s;if(e.error&&!op(e)){const r=((s=e.error.code)===null||s===void 0?void 0:s.split("auth/")[1])||"internal-error";t.onError(Le(this.auth,r))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const s=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&s}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=KE&&this.cachedEventUids.clear(),this.cachedEventUids.has(Lu(e))}saveEventToCache(e){this.cachedEventUids.add(Lu(e)),this.lastProcessedEventTime=Date.now()}}function Lu(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function op({type:n,error:e}){return n==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function HE(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return op(n);default:return!1}}/** 3562 * @license 3563 * Copyright 2020 Google LLC 3564 * 3565 * Licensed under the Apache License, Version 2.0 (the "License"); 3566 * you may not use this file except in compliance with the License. 3567 * You may obtain a copy of the License at 3568 * 3569 * http://www.apache.org/licenses/LICENSE-2.0 3570 * 3571 * Unless required by applicable law or agreed to in writing, software 3572 * distributed under the License is distributed on an "AS IS" BASIS, 3573 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3574 * See the License for the specific language governing permissions and 3575 * limitations under the License. 3576 */async function WE(n,e={}){return di(n,"GET","/v1/projects",e)}/** 3577 * @license 3578 * Copyright 2020 Google LLC 3579 * 3580 * Licensed under the Apache License, Version 2.0 (the "License"); 3581 * you may not use this file except in compliance with the License. 3582 * You may obtain a copy of the License at 3583 * 3584 * http://www.apache.org/licenses/LICENSE-2.0 3585 * 3586 * Unless required by applicable law or agreed to in writing, software 3587 * distributed under the License is distributed on an "AS IS" BASIS, 3588 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3589 * See the License for the specific language governing permissions and 3590 * limitations under the License. 3591 */const QE=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,YE=/^https?/;async function XE(n){if(n.config.emulator)return;const{authorizedDomains:e}=await WE(n);for(const t of e)try{if(JE(t))return}catch{}Ue(n,"unauthorized-domain")}function JE(n){const e=Ao(),{protocol:t,hostname:s}=new URL(e);if(n.startsWith("chrome-extension://")){const o=new URL(n);return o.hostname===""&&s===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&o.hostname===s}if(!YE.test(t))return!1;if(QE.test(n))return s===n;const r=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+r+"|"+r+")$","i").test(s)}/** 3592 * @license 3593 * Copyright 2020 Google LLC. 3594 * 3595 * Licensed under the Apache License, Version 2.0 (the "License"); 3596 * you may not use this file except in compliance with the License. 3597 * You may obtain a copy of the License at 3598 * 3599 * http://www.apache.org/licenses/LICENSE-2.0 3600 * 3601 * Unless required by applicable law or agreed to in writing, softw
3601are 3602 * distributed under the License is distributed on an "AS IS" BASIS, 3603 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3604 * See the License for the specific language governing permissions and 3605 * limitations under the License. 3606 */const ZE=new Ds(3e4,6e4);function Fu(){const n=Fe().___jsl;if(n!=null&&n.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function e0(n){return new Promise((e,t)=>{var s,r,i;function o(){Fu(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{Fu(),t(Le(n,"network-request-failed"))},timeout:ZE.get()})}if(!((r=(s=Fe().gapi)===null||s===void 0?void 0:s.iframes)===null||r===void 0)&&r.Iframe)e(gapi.iframes.getContext());else if(!((i=Fe().gapi)===null||i===void 0)&&i.load)o();else{const a=OE("iframefcb");return Fe()[a]=()=>{gapi.load?o():t(Le(n,"network-request-failed"))},RE(`https://apis.google.com/js/api.js?onload=${a}`).catch(c=>t(c))}}).catch(e=>{throw Js=null,e})}let Js=null;function t0(n){return Js=Js||e0(n),Js}/** 3607 * @license 3608 * Copyright 2020 Google LLC. 3609 * 3610 * Licensed under the Apache License, Version 2.0 (the "License"); 3611 * you may not use this file except in compliance with the License. 3612 * You may obtain a copy of the License at 3613 * 3614 * http://www.apache.org/licenses/LICENSE-2.0 3615 * 3616 * Unless required by applicable law or agreed to in writing, software 3617 * distributed under the License is distributed on an "AS IS" BASIS, 3618 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3619 * See the License for the specific language governing permissions and 3620 * limitations under the License. 3621 */const n0=new Ds(5e3,15e3),s0="__/auth/iframe",r0="emulator/auth/iframe",i0={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},o0=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function a0(n){const e=n.config;A(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?Ba(e,r0):`https://${n.config.authDomain}/${s0}`,s={apiKey:e.apiKey,appName:n.name,v:as},r=o0.get(n.config.apiHost);r&&(s.eid=r);const i=n._getFrameworks();return i.length&&(s.fw=i.join(",")),`${t}?${os(s).slice(1)}`}async function c0(n){const e=await t0(n),t=Fe().gapi;return A(t,n,"internal-error"),e.open({where:document.body,url:a0(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:i0,dontclear:!0},s=>new Promise(async(r,i)=>{await s.restyle({setHideOnLeave:!1});const o=Le(n,"network-request-failed"),a=Fe().setTimeout(()=>{i(o)},n0.get());function c(){Fe().clearTimeout(a),r(s)}s.ping(c).then(c,()=>{i(o)})}))}/** 3622 * @license 3623 * Copyright 2020 Google LLC. 3624 * 3625 * Licensed under the Apache License, Version 2.0 (the "License"); 3626 * you may not use this file except in compliance with the License. 3627 * You may obtain a copy of the License at 3628 * 3629 * http://www.apache.org/licenses/LICENSE-2.0 3630 * 3631 * Unless required by applicable law or agreed to in writing, software 3632 * distributed under the License is distributed on an "AS IS" BASIS, 3633 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3634 * See the License for the specific language governing permissions and 3635 * limitations under the License. 3636 */const u0={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},l0=500,h0=600,d0="_blank",f0="http://localhost";class Vu{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function p0(n,e,t,s=l0,r=h0){const i=Math.max((window.screen.availHeight-r)/2,0).toString(),o=Math.max((window.screen.availWidth-s)/2,0).toString();let a="";const c=Object.assign(Object.assign({},u0),{width:s.toString(),height:r.toString(),top:i,left:o}),u=Z().toLowerCase();t&&(a=Uf(u)?d0:t),Vf(u)&&(e=e||f0,c.scrollbars="yes");const l=Object.entries(c).reduce((d,[m,y])=>`${d}${m}=${y},`,"");if(tE(u)&&a!=="_self")return m0(e||"",a),new Vu(null);const h=window.open(e||"",a,l);A(h,n,"popup-blocked");try{h.focus()}catch{}return new Vu(h)}function m0(n,e){const t=document.createElement("a");t.href=n,t.target=e;const s=document.createEvent("MouseEvent");
3636s.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(s)}/** 3637 * @license 3638 * Copyright 2021 Google LLC 3639 * 3640 * Licensed under the Apache License, Version 2.0 (the "License"); 3641 * you may not use this file except in compliance with the License. 3642 * You may obtain a copy of the License at 3643 * 3644 * http://www.apache.org/licenses/LICENSE-2.0 3645 * 3646 * Unless required by applicable law or agreed to in writing, software 3647 * distributed under the License is distributed on an "AS IS" BASIS, 3648 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3649 * See the License for the specific language governing permissions and 3650 * limitations under the License. 3651 */const g0="__/auth/handler",y0="emulator/auth/handler";function Uu(n,e,t,s,r,i){A(n.config.authDomain,n,"auth-domain-config-required"),A(n.config.apiKey,n,"invalid-api-key");const o={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:s,v:as,eventId:r};if(e instanceof ja){e.setDefaultLanguage(n.languageCode),o.providerId=e.providerId||"",Ap(e.getCustomParameters())||(o.customParameters=JSON.stringify(e.getCustomParameters()));for(const[c,u]of Object.entries(i||{}))o[c]=u}if(e instanceof Ns){const c=e.getScopes().filter(u=>u!=="");c.length>0&&(o.scopes=c.join(","))}n.tenantId&&(o.tid=n.tenantId);const a=o;for(const c of Object.keys(a))a[c]===void 0&&delete a[c];return`${v0(n)}?${os(a).slice(1)}`}function v0({config:n}){return n.emulator?Ba(n,y0):`https://${n.authDomain}/${g0}`}/** 3652 * @license 3653 * Copyright 2020 Google LLC 3654 * 3655 * Licensed under the Apache License, Version 2.0 (the "License"); 3656 * you may not use this file except in compliance with the License. 3657 * You may obtain a copy of the License at 3658 * 3659 * http://www.apache.org/licenses/LICENSE-2.0 3660 * 3661 * Unless required by applicable law or agreed to in writing, software 3662 * distributed under the License is distributed on an "AS IS" BASIS, 3663 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3664 * See the License for the specific language governing permissions and 3665 * limitations under the License. 3666 */const Ui="webStorageSupport";class w0{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Zf,this._completeRedirectFn=GE,this._overrideRedirectResult=$E}async _openPopup(e,t,s,r){var i;ze((i=this.eventManagers[e._key()])===null||i===void 0?void 0:i.manager,"_initialize() not called before _openPopup()");const o=Uu(e,t,s,Ao(),r);return p0(e,o,Ga())}async _openRedirect(e,t,s,r){return await this._originValidation(e),TE(Uu(e,t,s,Ao(),r)),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:r,promise:i}=this.eventManagers[t];return r?Promise.resolve(r):(ze(i,"If manager is not set, promise should be"),i)}const s=this.initAndGetManager(e);return this.eventManagers[t]={promise:s},s.catch(()=>{delete this.eventManagers[t]}),s}async initAndGetManager(e){const t=await c0(e),s=new zE(e);return t.register("authEvent",r=>(A(r==null?void 0:r.authEvent,e,"invalid-auth-event"),{status:s.onEvent(r.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:s},this.iframes[e._key()]=t,s}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(Ui,{type:Ui},r=>{var i;const o=(i=r==null?void 0:r[0])===null||i===void 0?void 0:i[Ui];o!==void 0&&t(!!o),Ue(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=XE(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return Gf()||qa()||fi()}}const I0=w0;var Bu="@firebase/auth",$u="0.21.3";/** 3667 * @license 3668 * Copyright 2020 Google LLC 3669 * 3670 * Licensed under the Apache License, Version 2.0 (the "License"); 3671 * you may not use this file except in compliance with the License. 3672 * You may obtain a copy of the License at 3673 * 3674 * http://www.apache.org/licenses/LICENSE-2.0 3675 * 3676 * Unless required by applicable law or agreed to in writing, software 3677 * distributed under the License is distributed on an "AS IS" BASIS, 3678 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3679 * See the License for the specific language governing permissions and 3680 * limitations under the License. 3681 */class T0{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),((e=this.auth.currentUser)===null||e===void 0?void 0:e.uid)||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(s=>{e((s==null?void 0:s.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){A(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/** 3682 * @license 3683 * Copyright 2020 Google LLC 3684 * 3685 * Licensed under the Apache License, Version 2.0 (the "License");
3686 * you may not use this file except in compliance with the License. 3687 * You may obtain a copy of the License at 3688 * 3689 * http://www.apache.org/licenses/LICENSE-2.0 3690 * 3691 * Unless required by applicable law or agreed to in writing, software 3692 * distributed under the License is distributed on an "AS IS" BASIS, 3693 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3694 * See the License for the specific language governing permissions and 3695 * limitations under the License. 3696 */function E0(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";default:return}}function b0(n){Ne(new Ce("auth",(e,{options:t})=>{const s=e.getProvider("app").getImmediate(),r=e.getProvider("heartbeat"),{apiKey:i,authDomain:o}=s.options;return((a,c)=>{A(i&&!i.includes(":"),"invalid-api-key",{appName:a.name}),A(!(o!=null&&o.includes(":")),"argument-error",{appName:a.name});const u={apiKey:i,authDomain:o,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:Kf(n)},l=new iE(a,c,u);return LT(l,t),l})(s,r)},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,s)=>{e.getProvider("auth-internal").initialize()})),Ne(new Ce("auth-internal",e=>{const t=pi(e.getProvider("auth").getImmediate());return(s=>new T0(s))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),Ie(Bu,$u,E0(n)),Ie(Bu,$u,"esm2017")}/** 3697 * @license 3698 * Copyright 2021 Google LLC 3699 * 3700 * Licensed under the Apache License, Version 2.0 (the "License"); 3701 * you may not use this file except in compliance with the License. 3702 * You may obtain a copy of the License at 3703 * 3704 * http://www.apache.org/licenses/LICENSE-2.0 3705 * 3706 * Unless required by applicable law or agreed to in writing, software 3707 * distributed under the License is distributed on an "AS IS" BASIS, 3708 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 3709 * See the License for the specific language governing permissions and 3710 * limitations under the License. 3711 */const _0=5*60,S0=Wu("authIdTokenMaxAge")||_0;let qu=null;const A0=n=>async e=>{const t=e&&await e.getIdTokenResult(),s=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(s&&s>S0)return;const r=t==null?void 0:t.token;qu!==r&&(qu=r,await fetch(n,{method:r?"POST":"DELETE",headers:r?{Authorization:`Bearer ${r}`}:{}}))};function C0(n=Nr()){const e=ut(n,"auth");if(e.isInitialized())return e.getImmediate();const t=PT(n,{popupRedirectResolver:I0,persistence:[NE,Xf,Zf]}),s=Wu("authTokenSyncURL");if(s){const i=A0(s);mE(t,i,()=>i(t.currentUser)),pE(t,o=>i(o))}const r=zu("auth");return r&&oE(t,`http://${r}`),t}b0("Browser");const k0={apiKey:"AIzaSyANJ1I-4LHF8iMhOsqVZugeU8Ppmha_viM",authDomain:"selfwalkmarriottcoralsprings.firebaseapp.com",projectId:"selfwalkmarriottcoralsprings",storageBucket:"selfwalkmarriottcoralsprings.appspot.com",messagingSenderId:"1059257601974",appId:"1:1059257601974:web:0912269c6bf6c10fb77b17",measurementId:"G-5SDKMTT1FT"},yi=el(k0);Zg(yi);const D0=nT(yi);sT(D0).then(()=>{console.log("Firestore persistence enabled.")}).catch(n=>{n.code=="failed-precondition"||n.code=="unimplemented"});const N0=C0(yi);fE(N0,Xf).then(()=>{console.log("Firebase Auth will use local persistence.")}).catch(n=>{console.error("Error setting Firebase Auth persistence:",n)});new Be;xT(yi);export{QI as A,F0 as B,Ce as C,ke as F,B0 as G,U0 as K,L0 as O,$0 as Q,as as S,R0 as T,V0 as U,Ne as _,G0 as a,Ie as b,q as c,D0 as d,ut as e,Hu as f,Zg as g,P0 as h,Nr as i,gp as j,vp as k,ty as l,N0 as m,xT as n,nT as o,K0 as p,q0 as q,j0 as r,O0 as s,M0 as t,Be as u,z0 as v};
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.