@chem-po/web-demo 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/project.json +1 -1
  2. package/package.json +5 -6
  3. package/dist/assets/Color-YHDXOIA2-CTixio2N.js +0 -1
  4. package/dist/assets/DocsRenderer-CFRXHY34-3rO35qoa.js +0 -575
  5. package/dist/assets/ExampleItemView-CP2a92hN.js +0 -1
  6. package/dist/assets/FirebaseList.stories-Bj5Uw3uM.js +0 -5
  7. package/dist/assets/MobileFrame.stories-C6fRoM1A.js +0 -13
  8. package/dist/assets/Playground.stories-BZjVwCHb.js +0 -1
  9. package/dist/assets/chunk-XP5HYGXS-BpfKkqn7.js +0 -1
  10. package/dist/assets/entry-preview-B_JVi5UV.js +0 -2
  11. package/dist/assets/entry-preview-docs-CEaxHzqF.js +0 -46
  12. package/dist/assets/iframe-CiJg9Ueh.js +0 -211
  13. package/dist/assets/index-BVLMb_CH.js +0 -1
  14. package/dist/assets/index-BcLeTgl6.js +0 -3645
  15. package/dist/assets/index-Bw5gtqQz.js +0 -24
  16. package/dist/assets/index-DFweHObD.js +0 -8
  17. package/dist/assets/index-DqxVLU6x.js +0 -240
  18. package/dist/assets/index-DrFu-skq.js +0 -6
  19. package/dist/assets/index-GiUgBvb1.js +0 -9
  20. package/dist/assets/index-RoHUUooS.js +0 -615
  21. package/dist/assets/jsx-runtime-CDt2p4po.js +0 -9
  22. package/dist/assets/list-RfpQMsfm.js +0 -10
  23. package/dist/assets/preview-B8lJiyuQ.js +0 -34
  24. package/dist/assets/preview-BWzBA1C2.js +0 -396
  25. package/dist/assets/preview-CPX9RCe3.js +0 -1
  26. package/dist/assets/preview-CvbIS5ZJ.js +0 -1
  27. package/dist/assets/preview-D3WyzUYc.js +0 -295
  28. package/dist/assets/preview-DD_OYowb.js +0 -1
  29. package/dist/assets/preview-DGUiP6tS.js +0 -7
  30. package/dist/assets/preview-DHQbi4pV.js +0 -1
  31. package/dist/assets/preview-NEoZ8N1F.js +0 -1
  32. package/dist/assets/preview-ZjA0Xxw0.js +0 -2
  33. package/dist/assets/react-18-B3VHhbvP.js +0 -1
  34. package/dist/assets/test-utils-PLR4qLHw.js +0 -9
  35. package/dist/assets/tiny-invariant-CopsF_GD.js +0 -1
  36. package/dist/iframe.html +0 -696
@@ -1,3645 +0,0 @@
1
- import{x as Jf,y as Po,z as Gt,Q as Zf,A as ep}from"./index-RoHUUooS.js";import{r as nt}from"./index-GiUgBvb1.js";import{j as tp}from"./jsx-runtime-CDt2p4po.js";const np=()=>{};var Oc={};/**
2
- * @license
3
- * Copyright 2017 Google LLC
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */const _l=function(n){const e=[];let t=0;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&r+1<n.length&&(n.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++r)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},rp=function(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const i=n[t++];e[r++]=String.fromCharCode((s&31)<<6|i&63)}else if(s>239&&s<365){const i=n[t++],a=n[t++],c=n[t++],l=((s&7)<<18|(i&63)<<12|(a&63)<<6|c&63)-65536;e[r++]=String.fromCharCode(55296+(l>>10)),e[r++]=String.fromCharCode(56320+(l&1023))}else{const i=n[t++],a=n[t++];e[r++]=String.fromCharCode((s&15)<<12|(i&63)<<6|a&63)}}return e.join("")},yl={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_,r=[];for(let s=0;s<n.length;s+=3){const i=n[s],a=s+1<n.length,c=a?n[s+1]:0,l=s+2<n.length,d=l?n[s+2]:0,f=i>>2,m=(i&3)<<4|c>>4;let _=(c&15)<<2|d>>6,R=d&63;l||(R=64,a||(_=64)),r.push(t[f],t[m],t[_],t[R])}return r.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(_l(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):rp(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<n.length;){const i=t[n.charAt(s++)],c=s<n.length?t[n.charAt(s)]:0;++s;const d=s<n.length?t[n.charAt(s)]:64;++s;const m=s<n.length?t[n.charAt(s)]:64;if(++s,i==null||c==null||d==null||m==null)throw new sp;const _=i<<2|c>>4;if(r.push(_),d!==64){const R=c<<4&240|d>>2;if(r.push(R),m!==64){const S=d<<6&192|m;r.push(S)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};class sp extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const ip=function(n){const e=_l(n);return yl.encodeByteArray(e,!0)},As=function(n){return ip(n).replace(/\./g,"")},El=function(n){try{return yl.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};/**
17
- * @license
18
- * Copyright 2022 Google LLC
19
- *
20
- * Licensed under the Apache License, Version 2.0 (the "License");
21
- * you may not use this file except in compliance with the License.
22
- * You may obtain a copy of the License at
23
- *
24
- * http://www.apache.org/licenses/LICENSE-2.0
25
- *
26
- * Unless required by applicable law or agreed to in writing, software
27
- * distributed under the License is distributed on an "AS IS" BASIS,
28
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
- * See the License for the specific language governing permissions and
30
- * limitations under the License.
31
- */function op(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}/**
32
- * @license
33
- * Copyright 2022 Google LLC
34
- *
35
- * Licensed under the Apache License, Version 2.0 (the "License");
36
- * you may not use this file except in compliance with the License.
37
- * You may obtain a copy of the License at
38
- *
39
- * http://www.apache.org/licenses/LICENSE-2.0
40
- *
41
- * Unless required by applicable law or agreed to in writing, software
42
- * distributed under the License is distributed on an "AS IS" BASIS,
43
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
44
- * See the License for the specific language governing permissions and
45
- * limitations under the License.
46
- */const ap=()=>op().__FIREBASE_DEFAULTS__,cp=()=>{if(typeof process>"u"||typeof Oc>"u")return;const n=Oc.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},up=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&El(n[1]);return e&&JSON.parse(e)},Ks=()=>{try{return np()||ap()||cp()||up()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},Tl=n=>{var e,t;return(t=(e=Ks())===null||e===void 0?void 0:e.emulatorHosts)===null||t===void 0?void 0:t[n]},So=n=>{const e=Tl(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 r=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),r]:[e.substring(0,t),r]},vl=()=>{var n;return(n=Ks())===null||n===void 0?void 0:n.config},Il=n=>{var e;return(e=Ks())===null||e===void 0?void 0:e[`_${n}`]};/**
47
- * @license
48
- * Copyright 2017 Google LLC
49
- *
50
- * Licensed under the Apache License, Version 2.0 (the "License");
51
- * you may not use this file except in compliance with the License.
52
- * You may obtain a copy of the License at
53
- *
54
- * http://www.apache.org/licenses/LICENSE-2.0
55
- *
56
- * Unless required by applicable law or agreed to in writing, software
57
- * distributed under the License is distributed on an "AS IS" BASIS,
58
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
59
- * See the License for the specific language governing permissions and
60
- * limitations under the License.
61
- */class lp{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,r))}}}/**
62
- * @license
63
- * Copyright 2025 Google LLC
64
- *
65
- * Licensed under the Apache License, Version 2.0 (the "License");
66
- * you may not use this file except in compliance with the License.
67
- * You may obtain a copy of the License at
68
- *
69
- * http://www.apache.org/licenses/LICENSE-2.0
70
- *
71
- * Unless required by applicable law or agreed to in writing, software
72
- * distributed under the License is distributed on an "AS IS" BASIS,
73
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
74
- * See the License for the specific language governing permissions and
75
- * limitations under the License.
76
- */function Lt(n){return n.endsWith(".cloudworkstations.dev")}async function Qs(n){return(await fetch(n,{credentials:"include"})).ok}/**
77
- * @license
78
- * Copyright 2021 Google LLC
79
- *
80
- * Licensed under the Apache License, Version 2.0 (the "License");
81
- * you may not use this file except in compliance with the License.
82
- * You may obtain a copy of the License at
83
- *
84
- * http://www.apache.org/licenses/LICENSE-2.0
85
- *
86
- * Unless required by applicable law or agreed to in writing, software
87
- * distributed under the License is distributed on an "AS IS" BASIS,
88
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
89
- * See the License for the specific language governing permissions and
90
- * limitations under the License.
91
- */function wl(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"},r=e||"demo-project",s=n.iat||0,i=n.sub||n.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const a=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},n);return[As(JSON.stringify(t)),As(JSON.stringify(a)),""].join(".")}const dr={};function hp(){const n={prod:[],emulator:[]};for(const e of Object.keys(dr))dr[e]?n.emulator.push(e):n.prod.push(e);return n}function dp(n){let e=document.getElementById(n),t=!1;return e||(e=document.createElement("div"),e.setAttribute("id",n),t=!0),{created:t,element:e}}let Lc=!1;function xt(n,e){if(typeof window>"u"||typeof document>"u"||!Lt(window.location.host)||dr[n]===e||dr[n]||Lc)return;dr[n]=e;function t(_){return`__firebase__banner__${_}`}const r="__firebase__banner",i=hp().prod.length>0;function a(){const _=document.getElementById(r);_&&_.remove()}function c(_){_.style.display="flex",_.style.background="#7faaf0",_.style.position="fixed",_.style.bottom="5px",_.style.left="5px",_.style.padding=".5em",_.style.borderRadius="5px",_.style.alignItems="center"}function l(_,R){_.setAttribute("width","24"),_.setAttribute("id",R),_.setAttribute("height","24"),_.setAttribute("viewBox","0 0 24 24"),_.setAttribute("fill","none"),_.style.marginLeft="-6px"}function d(){const _=document.createElement("span");return _.style.cursor="pointer",_.style.marginLeft="16px",_.style.fontSize="24px",_.innerHTML=" &times;",_.onclick=()=>{Lc=!0,a()},_}function f(_,R){_.setAttribute("id",R),_.innerText="Learn more",_.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",_.setAttribute("target","__blank"),_.style.paddingLeft="5px",_.style.textDecoration="underline"}function m(){const _=dp(r),R=t("text"),S=document.getElementById(R)||document.createElement("span"),N=t("learnmore"),k=document.getElementById(N)||document.createElement("a"),B=t("preprendIcon"),M=document.getElementById(B)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(_.created){const x=_.element;c(x),f(k,N);const $=d();l(M,B),x.append(M,S,k,$),document.body.appendChild(x)}i?(S.innerText="Preview backend disconnected.",M.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
92
- <path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>
93
- </g>
94
- <defs>
95
- <clipPath id="clip0_6013_33858">
96
- <rect width="24" height="24" fill="white"/>
97
- </clipPath>
98
- </defs>`):(M.innerHTML=`<g clip-path="url(#clip0_6083_34804)">
99
- <path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 12.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>
100
- </g>
101
- <defs>
102
- <clipPath id="clip0_6083_34804">
103
- <rect width="24" height="24" fill="white"/>
104
- </clipPath>
105
- </defs>`,S.innerText="Preview backend running in this workspace."),S.setAttribute("id",R)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",m):m()}/**
106
- * @license
107
- * Copyright 2017 Google LLC
108
- *
109
- * Licensed under the Apache License, Version 2.0 (the "License");
110
- * you may not use this file except in compliance with the License.
111
- * You may obtain a copy of the License at
112
- *
113
- * http://www.apache.org/licenses/LICENSE-2.0
114
- *
115
- * Unless required by applicable law or agreed to in writing, software
116
- * distributed under the License is distributed on an "AS IS" BASIS,
117
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
118
- * See the License for the specific language governing permissions and
119
- * limitations under the License.
120
- */function we(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function fp(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(we())}function pp(){var n;const e=(n=Ks())===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 mp(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function gp(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function _p(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function yp(){const n=we();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function Ep(){return!pp()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function Tp(){try{return typeof indexedDB=="object"}catch{return!1}}function vp(){return new Promise((n,e)=>{try{let t=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(r),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{var i;e(((i=s.error)===null||i===void 0?void 0:i.message)||"")}}catch(t){e(t)}})}/**
121
- * @license
122
- * Copyright 2017 Google LLC
123
- *
124
- * Licensed under the Apache License, Version 2.0 (the "License");
125
- * you may not use this file except in compliance with the License.
126
- * You may obtain a copy of the License at
127
- *
128
- * http://www.apache.org/licenses/LICENSE-2.0
129
- *
130
- * Unless required by applicable law or agreed to in writing, software
131
- * distributed under the License is distributed on an "AS IS" BASIS,
132
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133
- * See the License for the specific language governing permissions and
134
- * limitations under the License.
135
- */const Ip="FirebaseError";class ze extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name=Ip,Object.setPrototypeOf(this,ze.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Sr.prototype.create)}}class Sr{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},s=`${this.service}/${e}`,i=this.errors[e],a=i?wp(i,r):"Error",c=`${this.serviceName}: ${a} (${s}).`;return new ze(s,c,r)}}function wp(n,e){return n.replace(Ap,(t,r)=>{const s=e[r];return s!=null?String(s):`<${r}?>`})}const Ap=/\{\$([^}]+)}/g;function Rp(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function Yt(n,e){if(n===e)return!0;const t=Object.keys(n),r=Object.keys(e);for(const s of t){if(!r.includes(s))return!1;const i=n[s],a=e[s];if(xc(i)&&xc(a)){if(!Yt(i,a))return!1}else if(i!==a)return!1}for(const s of r)if(!t.includes(s))return!1;return!0}function xc(n){return n!==null&&typeof n=="object"}/**
136
- * @license
137
- * Copyright 2017 Google LLC
138
- *
139
- * Licensed under the Apache License, Version 2.0 (the "License");
140
- * you may not use this file except in compliance with the License.
141
- * You may obtain a copy of the License at
142
- *
143
- * http://www.apache.org/licenses/LICENSE-2.0
144
- *
145
- * Unless required by applicable law or agreed to in writing, software
146
- * distributed under the License is distributed on an "AS IS" BASIS,
147
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
148
- * See the License for the specific language governing permissions and
149
- * limitations under the License.
150
- */function Cr(n){const e=[];for(const[t,r]of Object.entries(n))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function or(n){const e={};return n.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[s,i]=r.split("=");e[decodeURIComponent(s)]=decodeURIComponent(i)}}),e}function ar(n){const e=n.indexOf("?");if(!e)return"";const t=n.indexOf("#",e);return n.substring(e,t>0?t:void 0)}function bp(n,e){const t=new Pp(n,e);return t.subscribe.bind(t)}class Pp{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(r=>{this.error(r)})}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,r){let s;if(e===void 0&&t===void 0&&r===void 0)throw new Error("Missing Observer.");Sp(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:r},s.next===void 0&&(s.next=Hi),s.error===void 0&&(s.error=Hi),s.complete===void 0&&(s.complete=Hi);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),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(r){typeof console<"u"&&console.error&&console.error(r)}})}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 Sp(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 Hi(){}/**
151
- * @license
152
- * Copyright 2021 Google LLC
153
- *
154
- * Licensed under the Apache License, Version 2.0 (the "License");
155
- * you may not use this file except in compliance with the License.
156
- * You may obtain a copy of the License at
157
- *
158
- * http://www.apache.org/licenses/LICENSE-2.0
159
- *
160
- * Unless required by applicable law or agreed to in writing, software
161
- * distributed under the License is distributed on an "AS IS" BASIS,
162
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
163
- * See the License for the specific language governing permissions and
164
- * limitations under the License.
165
- */function Z(n){return n&&n._delegate?n._delegate:n}class ut{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,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}}/**
166
- * @license
167
- * Copyright 2019 Google LLC
168
- *
169
- * Licensed under the Apache License, Version 2.0 (the "License");
170
- * you may not use this file except in compliance with the License.
171
- * You may obtain a copy of the License at
172
- *
173
- * http://www.apache.org/licenses/LICENSE-2.0
174
- *
175
- * Unless required by applicable law or agreed to in writing, software
176
- * distributed under the License is distributed on an "AS IS" BASIS,
177
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
178
- * See the License for the specific language governing permissions and
179
- * limitations under the License.
180
- */const Wt="[DEFAULT]";/**
181
- * @license
182
- * Copyright 2019 Google LLC
183
- *
184
- * Licensed under the Apache License, Version 2.0 (the "License");
185
- * you may not use this file except in compliance with the License.
186
- * You may obtain a copy of the License at
187
- *
188
- * http://www.apache.org/licenses/LICENSE-2.0
189
- *
190
- * Unless required by applicable law or agreed to in writing, software
191
- * distributed under the License is distributed on an "AS IS" BASIS,
192
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
193
- * See the License for the specific language governing permissions and
194
- * limitations under the License.
195
- */class Cp{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 r=new lp;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const r=this.normalizeInstanceIdentifier(e==null?void 0:e.identifier),s=(t=e==null?void 0:e.optional)!==null&&t!==void 0?t:!1;if(this.isInitialized(r)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:r})}catch(i){if(s)return null;throw i}else{if(s)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(Np(e))try{this.getOrInitializeService({instanceIdentifier:Wt})}catch{}for(const[t,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(t);try{const i=this.getOrInitializeService({instanceIdentifier:s});r.resolve(i)}catch{}}}}clearInstance(e=Wt){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=Wt){return this.instances.has(e)}getOptions(e=Wt){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:r,options:t});for(const[i,a]of this.instancesDeferred.entries()){const c=this.normalizeInstanceIdentifier(i);r===c&&a.resolve(s)}return s}onInit(e,t){var r;const s=this.normalizeInstanceIdentifier(t),i=(r=this.onInitCallbacks.get(s))!==null&&r!==void 0?r:new Set;i.add(e),this.onInitCallbacks.set(s,i);const a=this.instances.get(s);return a&&e(a,s),()=>{i.delete(e)}}invokeOnInitCallbacks(e,t){const r=this.onInitCallbacks.get(t);if(r)for(const s of r)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:kp(e),options:t}),this.instances.set(e,r),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=Wt){return this.component?this.component.multipleInstances?e:Wt:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function kp(n){return n===Wt?void 0:n}function Np(n){return n.instantiationMode==="EAGER"}/**
196
- * @license
197
- * Copyright 2019 Google LLC
198
- *
199
- * Licensed under the Apache License, Version 2.0 (the "License");
200
- * you may not use this file except in compliance with the License.
201
- * You may obtain a copy of the License at
202
- *
203
- * http://www.apache.org/licenses/LICENSE-2.0
204
- *
205
- * Unless required by applicable law or agreed to in writing, software
206
- * distributed under the License is distributed on an "AS IS" BASIS,
207
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
208
- * See the License for the specific language governing permissions and
209
- * limitations under the License.
210
- */class Dp{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 Cp(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}/**
211
- * @license
212
- * Copyright 2017 Google LLC
213
- *
214
- * Licensed under the Apache License, Version 2.0 (the "License");
215
- * you may not use this file except in compliance with the License.
216
- * You may obtain a copy of the License at
217
- *
218
- * http://www.apache.org/licenses/LICENSE-2.0
219
- *
220
- * Unless required by applicable law or agreed to in writing, software
221
- * distributed under the License is distributed on an "AS IS" BASIS,
222
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
223
- * See the License for the specific language governing permissions and
224
- * limitations under the License.
225
- */var H;(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"})(H||(H={}));const Vp={debug:H.DEBUG,verbose:H.VERBOSE,info:H.INFO,warn:H.WARN,error:H.ERROR,silent:H.SILENT},Op=H.INFO,Lp={[H.DEBUG]:"log",[H.VERBOSE]:"log",[H.INFO]:"info",[H.WARN]:"warn",[H.ERROR]:"error"},xp=(n,e,...t)=>{if(e<n.logLevel)return;const r=new Date().toISOString(),s=Lp[e];if(s)console[s](`[${r}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class Co{constructor(e){this.name=e,this._logLevel=Op,this._logHandler=xp,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in H))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?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,H.DEBUG,...e),this._logHandler(this,H.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,H.VERBOSE,...e),this._logHandler(this,H.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,H.INFO,...e),this._logHandler(this,H.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,H.WARN,...e),this._logHandler(this,H.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,H.ERROR,...e),this._logHandler(this,H.ERROR,...e)}}/**
226
- * @license
227
- * Copyright 2019 Google LLC
228
- *
229
- * Licensed under the Apache License, Version 2.0 (the "License");
230
- * you may not use this file except in compliance with the License.
231
- * You may obtain a copy of the License at
232
- *
233
- * http://www.apache.org/licenses/LICENSE-2.0
234
- *
235
- * Unless required by applicable law or agreed to in writing, software
236
- * distributed under the License is distributed on an "AS IS" BASIS,
237
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
238
- * See the License for the specific language governing permissions and
239
- * limitations under the License.
240
- */class Mp{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(Up(t)){const r=t.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(t=>t).join(" ")}}function Up(n){const e=n.getComponent();return(e==null?void 0:e.type)==="VERSION"}const no="@firebase/app",Mc="0.13.0";/**
241
- * @license
242
- * Copyright 2019 Google LLC
243
- *
244
- * Licensed under the Apache License, Version 2.0 (the "License");
245
- * you may not use this file except in compliance with the License.
246
- * You may obtain a copy of the License at
247
- *
248
- * http://www.apache.org/licenses/LICENSE-2.0
249
- *
250
- * Unless required by applicable law or agreed to in writing, software
251
- * distributed under the License is distributed on an "AS IS" BASIS,
252
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
253
- * See the License for the specific language governing permissions and
254
- * limitations under the License.
255
- */const lt=new Co("@firebase/app"),Fp="@firebase/app-compat",Bp="@firebase/analytics-compat",qp="@firebase/analytics",jp="@firebase/app-check-compat",$p="@firebase/app-check",zp="@firebase/auth",Hp="@firebase/auth-compat",Gp="@firebase/database",Wp="@firebase/data-connect",Kp="@firebase/database-compat",Qp="@firebase/functions",Xp="@firebase/functions-compat",Yp="@firebase/installations",Jp="@firebase/installations-compat",Zp="@firebase/messaging",em="@firebase/messaging-compat",tm="@firebase/performance",nm="@firebase/performance-compat",rm="@firebase/remote-config",sm="@firebase/remote-config-compat",im="@firebase/storage",om="@firebase/storage-compat",am="@firebase/firestore",cm="@firebase/ai",um="@firebase/firestore-compat",lm="firebase",hm="11.8.0";/**
256
- * @license
257
- * Copyright 2019 Google LLC
258
- *
259
- * Licensed under the Apache License, Version 2.0 (the "License");
260
- * you may not use this file except in compliance with the License.
261
- * You may obtain a copy of the License at
262
- *
263
- * http://www.apache.org/licenses/LICENSE-2.0
264
- *
265
- * Unless required by applicable law or agreed to in writing, software
266
- * distributed under the License is distributed on an "AS IS" BASIS,
267
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
268
- * See the License for the specific language governing permissions and
269
- * limitations under the License.
270
- */const ro="[DEFAULT]",dm={[no]:"fire-core",[Fp]:"fire-core-compat",[qp]:"fire-analytics",[Bp]:"fire-analytics-compat",[$p]:"fire-app-check",[jp]:"fire-app-check-compat",[zp]:"fire-auth",[Hp]:"fire-auth-compat",[Gp]:"fire-rtdb",[Wp]:"fire-data-connect",[Kp]:"fire-rtdb-compat",[Qp]:"fire-fn",[Xp]:"fire-fn-compat",[Yp]:"fire-iid",[Jp]:"fire-iid-compat",[Zp]:"fire-fcm",[em]:"fire-fcm-compat",[tm]:"fire-perf",[nm]:"fire-perf-compat",[rm]:"fire-rc",[sm]:"fire-rc-compat",[im]:"fire-gcs",[om]:"fire-gcs-compat",[am]:"fire-fst",[um]:"fire-fst-compat",[cm]:"fire-vertex","fire-js":"fire-js",[lm]:"fire-js-all"};/**
271
- * @license
272
- * Copyright 2019 Google LLC
273
- *
274
- * Licensed under the Apache License, Version 2.0 (the "License");
275
- * you may not use this file except in compliance with the License.
276
- * You may obtain a copy of the License at
277
- *
278
- * http://www.apache.org/licenses/LICENSE-2.0
279
- *
280
- * Unless required by applicable law or agreed to in writing, software
281
- * distributed under the License is distributed on an "AS IS" BASIS,
282
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
283
- * See the License for the specific language governing permissions and
284
- * limitations under the License.
285
- */const Rs=new Map,fm=new Map,so=new Map;function Uc(n,e){try{n.container.addComponent(e)}catch(t){lt.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function St(n){const e=n.name;if(so.has(e))return lt.debug(`There were multiple attempts to register component ${e}.`),!1;so.set(e,n);for(const t of Rs.values())Uc(t,n);for(const t of fm.values())Uc(t,n);return!0}function kr(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function Pe(n){return n==null?!1:n.settings!==void 0}/**
286
- * @license
287
- * Copyright 2019 Google LLC
288
- *
289
- * Licensed under the Apache License, Version 2.0 (the "License");
290
- * you may not use this file except in compliance with the License.
291
- * You may obtain a copy of the License at
292
- *
293
- * http://www.apache.org/licenses/LICENSE-2.0
294
- *
295
- * Unless required by applicable law or agreed to in writing, software
296
- * distributed under the License is distributed on an "AS IS" BASIS,
297
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
298
- * See the License for the specific language governing permissions and
299
- * limitations under the License.
300
- */const pm={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},Rt=new Sr("app","Firebase",pm);/**
301
- * @license
302
- * Copyright 2019 Google LLC
303
- *
304
- * Licensed under the Apache License, Version 2.0 (the "License");
305
- * you may not use this file except in compliance with the License.
306
- * You may obtain a copy of the License at
307
- *
308
- * http://www.apache.org/licenses/LICENSE-2.0
309
- *
310
- * Unless required by applicable law or agreed to in writing, software
311
- * distributed under the License is distributed on an "AS IS" BASIS,
312
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
313
- * See the License for the specific language governing permissions and
314
- * limitations under the License.
315
- */class mm{constructor(e,t,r){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new ut("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 Rt.create("app-deleted",{appName:this._name})}}/**
316
- * @license
317
- * Copyright 2019 Google LLC
318
- *
319
- * Licensed under the Apache License, Version 2.0 (the "License");
320
- * you may not use this file except in compliance with the License.
321
- * You may obtain a copy of the License at
322
- *
323
- * http://www.apache.org/licenses/LICENSE-2.0
324
- *
325
- * Unless required by applicable law or agreed to in writing, software
326
- * distributed under the License is distributed on an "AS IS" BASIS,
327
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
328
- * See the License for the specific language governing permissions and
329
- * limitations under the License.
330
- */const sn=hm;function gm(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const r=Object.assign({name:ro,automaticDataCollectionEnabled:!0},e),s=r.name;if(typeof s!="string"||!s)throw Rt.create("bad-app-name",{appName:String(s)});if(t||(t=vl()),!t)throw Rt.create("no-options");const i=Rs.get(s);if(i){if(Yt(t,i.options)&&Yt(r,i.config))return i;throw Rt.create("duplicate-app",{appName:s})}const a=new Dp(s);for(const l of so.values())a.addComponent(l);const c=new mm(t,r,a);return Rs.set(s,c),c}function Xs(n=ro){const e=Rs.get(n);if(!e&&n===ro&&vl())return gm();if(!e)throw Rt.create("no-app",{appName:n});return e}function qe(n,e,t){var r;let s=(r=dm[n])!==null&&r!==void 0?r:n;t&&(s+=`-${t}`);const i=s.match(/\s|\//),a=e.match(/\s|\//);if(i||a){const c=[`Unable to register library "${s}" with version "${e}":`];i&&c.push(`library name "${s}" contains illegal characters (whitespace or "/")`),i&&a&&c.push("and"),a&&c.push(`version name "${e}" contains illegal characters (whitespace or "/")`),lt.warn(c.join(" "));return}St(new ut(`${s}-version`,()=>({library:s,version:e}),"VERSION"))}/**
331
- * @license
332
- * Copyright 2021 Google LLC
333
- *
334
- * Licensed under the Apache License, Version 2.0 (the "License");
335
- * you may not use this file except in compliance with the License.
336
- * You may obtain a copy of the License at
337
- *
338
- * http://www.apache.org/licenses/LICENSE-2.0
339
- *
340
- * Unless required by applicable law or agreed to in writing, software
341
- * distributed under the License is distributed on an "AS IS" BASIS,
342
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
343
- * See the License for the specific language governing permissions and
344
- * limitations under the License.
345
- */const _m="firebase-heartbeat-database",ym=1,yr="firebase-heartbeat-store";let Gi=null;function Al(){return Gi||(Gi=Jf(_m,ym,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(yr)}catch(t){console.warn(t)}}}}).catch(n=>{throw Rt.create("idb-open",{originalErrorMessage:n.message})})),Gi}async function Em(n){try{const t=(await Al()).transaction(yr),r=await t.objectStore(yr).get(Rl(n));return await t.done,r}catch(e){if(e instanceof ze)lt.warn(e.message);else{const t=Rt.create("idb-get",{originalErrorMessage:e==null?void 0:e.message});lt.warn(t.message)}}}async function Fc(n,e){try{const r=(await Al()).transaction(yr,"readwrite");await r.objectStore(yr).put(e,Rl(n)),await r.done}catch(t){if(t instanceof ze)lt.warn(t.message);else{const r=Rt.create("idb-set",{originalErrorMessage:t==null?void 0:t.message});lt.warn(r.message)}}}function Rl(n){return`${n.name}!${n.options.appId}`}/**
346
- * @license
347
- * Copyright 2021 Google LLC
348
- *
349
- * Licensed under the Apache License, Version 2.0 (the "License");
350
- * you may not use this file except in compliance with the License.
351
- * You may obtain a copy of the License at
352
- *
353
- * http://www.apache.org/licenses/LICENSE-2.0
354
- *
355
- * Unless required by applicable law or agreed to in writing, software
356
- * distributed under the License is distributed on an "AS IS" BASIS,
357
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
358
- * See the License for the specific language governing permissions and
359
- * limitations under the License.
360
- */const Tm=1024,vm=30;class Im{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new Am(t),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){var e,t;try{const s=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=Bc();if(((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,((t=this._heartbeatsCache)===null||t===void 0?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(a=>a.date===i))return;if(this._heartbeatsCache.heartbeats.push({date:i,agent:s}),this._heartbeatsCache.heartbeats.length>vm){const a=Rm(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(a,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(r){lt.warn(r)}}async getHeartbeatsHeader(){var e;try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,((e=this._heartbeatsCache)===null||e===void 0?void 0:e.heartbeats)==null||this._heartbeatsCache.heartbeats.length===0)return"";const t=Bc(),{heartbeatsToSend:r,unsentEntries:s}=wm(this._heartbeatsCache.heartbeats),i=As(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=t,s.length>0?(this._heartbeatsCache.heartbeats=s,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(t){return lt.warn(t),""}}}function Bc(){return new Date().toISOString().substring(0,10)}function wm(n,e=Tm){const t=[];let r=n.slice();for(const s of n){const i=t.find(a=>a.agent===s.agent);if(i){if(i.dates.push(s.date),qc(t)>e){i.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),qc(t)>e){t.pop();break}r=r.slice(1)}return{heartbeatsToSend:t,unsentEntries:r}}class Am{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return Tp()?vp().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await Em(this.app);return t!=null&&t.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const s=await this.read();return Fc(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){var t;if(await this._canUseIndexedDBPromise){const s=await this.read();return Fc(this.app,{lastSentHeartbeatDate:(t=e.lastSentHeartbeatDate)!==null&&t!==void 0?t:s.lastSentHeartbeatDate,heartbeats:[...s.heartbeats,...e.heartbeats]})}else return}}function qc(n){return As(JSON.stringify({version:2,heartbeats:n})).length}function Rm(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let r=1;r<n.length;r++)n[r].date<t&&(t=n[r].date,e=r);return e}/**
361
- * @license
362
- * Copyright 2019 Google LLC
363
- *
364
- * Licensed under the Apache License, Version 2.0 (the "License");
365
- * you may not use this file except in compliance with the License.
366
- * You may obtain a copy of the License at
367
- *
368
- * http://www.apache.org/licenses/LICENSE-2.0
369
- *
370
- * Unless required by applicable law or agreed to in writing, software
371
- * distributed under the License is distributed on an "AS IS" BASIS,
372
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
373
- * See the License for the specific language governing permissions and
374
- * limitations under the License.
375
- */function bm(n){St(new ut("platform-logger",e=>new Mp(e),"PRIVATE")),St(new ut("heartbeat",e=>new Im(e),"PRIVATE")),qe(no,Mc,n),qe(no,Mc,"esm2017"),qe("fire-js","")}bm("");/**
376
- * @license
377
- * Copyright 2017 Google LLC
378
- *
379
- * Licensed under the Apache License, Version 2.0 (the "License");
380
- * you may not use this file except in compliance with the License.
381
- * You may obtain a copy of the License at
382
- *
383
- * http://www.apache.org/licenses/LICENSE-2.0
384
- *
385
- * Unless required by applicable law or agreed to in writing, software
386
- * distributed under the License is distributed on an "AS IS" BASIS,
387
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
388
- * See the License for the specific language governing permissions and
389
- * limitations under the License.
390
- */const Pm="type.googleapis.com/google.protobuf.Int64Value",Sm="type.googleapis.com/google.protobuf.UInt64Value";function bl(n,e){const t={};for(const r in n)n.hasOwnProperty(r)&&(t[r]=e(n[r]));return t}function bs(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=>bs(e));if(typeof n=="function"||typeof n=="object")return bl(n,e=>bs(e));throw new Error("Data cannot be encoded in JSON: "+n)}function bn(n){if(n==null)return n;if(n["@type"])switch(n["@type"]){case Pm:case Sm:{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=>bn(e)):typeof n=="function"||typeof n=="object"?bl(n,e=>bn(e)):n}/**
391
- * @license
392
- * Copyright 2020 Google LLC
393
- *
394
- * Licensed under the Apache License, Version 2.0 (the "License");
395
- * you may not use this file except in compliance with the License.
396
- * You may obtain a copy of the License at
397
- *
398
- * http://www.apache.org/licenses/LICENSE-2.0
399
- *
400
- * Unless required by applicable law or agreed to in writing, software
401
- * distributed under the License is distributed on an "AS IS" BASIS,
402
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
403
- * See the License for the specific language governing permissions and
404
- * limitations under the License.
405
- */const ko="functions";/**
406
- * @license
407
- * Copyright 2017 Google LLC
408
- *
409
- * Licensed under the Apache License, Version 2.0 (the "License");
410
- * you may not use this file except in compliance with the License.
411
- * You may obtain a copy of the License at
412
- *
413
- * http://www.apache.org/licenses/LICENSE-2.0
414
- *
415
- * Unless required by applicable law or agreed to in writing, software
416
- * distributed under the License is distributed on an "AS IS" BASIS,
417
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
418
- * See the License for the specific language governing permissions and
419
- * limitations under the License.
420
- */const jc={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 Ne extends ze{constructor(e,t,r){super(`${ko}/${e}`,t||""),this.details=r,Object.setPrototypeOf(this,Ne.prototype)}}function Cm(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 Ps(n,e){let t=Cm(n),r=t,s;try{const i=e&&e.error;if(i){const a=i.status;if(typeof a=="string"){if(!jc[a])return new Ne("internal","internal");t=jc[a],r=a}const c=i.message;typeof c=="string"&&(r=c),s=i.details,s!==void 0&&(s=bn(s))}}catch{}return t==="ok"?null:new Ne(t,r,s)}/**
421
- * @license
422
- * Copyright 2017 Google LLC
423
- *
424
- * Licensed under the Apache License, Version 2.0 (the "License");
425
- * you may not use this file except in compliance with the License.
426
- * You may obtain a copy of the License at
427
- *
428
- * http://www.apache.org/licenses/LICENSE-2.0
429
- *
430
- * Unless required by applicable law or agreed to in writing, software
431
- * distributed under the License is distributed on an "AS IS" BASIS,
432
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
433
- * See the License for the specific language governing permissions and
434
- * limitations under the License.
435
- */class km{constructor(e,t,r,s){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,Pe(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.auth=t.getImmediate({optional:!0}),this.messaging=r.getImmediate({optional:!0}),this.auth||t.get().then(i=>this.auth=i,()=>{}),this.messaging||r.get().then(i=>this.messaging=i,()=>{}),this.appCheck||s==null||s.get().then(i=>this.appCheck=i,()=>{})}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(e){if(this.serverAppAppCheckToken)return this.serverAppAppCheckToken;if(this.appCheck){const t=e?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken();return t.error?null:t.token}return null}async getContext(e){const t=await this.getAuthToken(),r=await this.getMessagingToken(),s=await this.getAppCheckToken(e);return{authToken:t,messagingToken:r,appCheckToken:s}}}/**
436
- * @license
437
- * Copyright 2017 Google LLC
438
- *
439
- * Licensed under the Apache License, Version 2.0 (the "License");
440
- * you may not use this file except in compliance with the License.
441
- * You may obtain a copy of the License at
442
- *
443
- * http://www.apache.org/licenses/LICENSE-2.0
444
- *
445
- * Unless required by applicable law or agreed to in writing, software
446
- * distributed under the License is distributed on an "AS IS" BASIS,
447
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
448
- * See the License for the specific language governing permissions and
449
- * limitations under the License.
450
- */const io="us-central1",Nm=/^data: (.*?)(?:\n|$)/;function Dm(n){let e=null;return{promise:new Promise((t,r)=>{e=setTimeout(()=>{r(new Ne("deadline-exceeded","deadline-exceeded"))},n)}),cancel:()=>{e&&clearTimeout(e)}}}class Vm{constructor(e,t,r,s,i=io,a=(...c)=>fetch(...c)){this.app=e,this.fetchImpl=a,this.emulatorOrigin=null,this.contextProvider=new km(e,t,r,s),this.cancelAllRequests=new Promise(c=>{this.deleteService=()=>Promise.resolve(c())});try{const c=new URL(i);this.customDomain=c.origin+(c.pathname==="/"?"":c.pathname),this.region=io}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 Om(n,e,t){const r=Lt(e);n.emulatorOrigin=`http${r?"s":""}://${e}:${t}`,r&&(Qs(n.emulatorOrigin),xt("Functions",!0))}function Lm(n,e,t){const r=s=>Mm(n,e,s,{});return r.stream=(s,i)=>Fm(n,e,s,i),r}async function xm(n,e,t,r){t["Content-Type"]="application/json";let s;try{s=await r(n,{method:"POST",body:JSON.stringify(e),headers:t})}catch{return{status:0,json:null}}let i=null;try{i=await s.json()}catch{}return{status:s.status,json:i}}async function Pl(n,e){const t={},r=await n.contextProvider.getContext(e.limitedUseAppCheckTokens);return r.authToken&&(t.Authorization="Bearer "+r.authToken),r.messagingToken&&(t["Firebase-Instance-ID-Token"]=r.messagingToken),r.appCheckToken!==null&&(t["X-Firebase-AppCheck"]=r.appCheckToken),t}function Mm(n,e,t,r){const s=n._url(e);return Um(n,s,t,r)}async function Um(n,e,t,r){t=bs(t);const s={data:t},i=await Pl(n,r),a=r.timeout||7e4,c=Dm(a),l=await Promise.race([xm(e,s,i,n.fetchImpl),c.promise,n.cancelAllRequests]);if(c.cancel(),!l)throw new Ne("cancelled","Firebase Functions instance was deleted.");const d=Ps(l.status,l.json);if(d)throw d;if(!l.json)throw new Ne("internal","Response is not valid JSON object.");let f=l.json.data;if(typeof f>"u"&&(f=l.json.result),typeof f>"u")throw new Ne("internal","Response is missing data field.");return{data:bn(f)}}function Fm(n,e,t,r){const s=n._url(e);return Bm(n,s,t,r||{})}async function Bm(n,e,t,r){var s;t=bs(t);const i={data:t},a=await Pl(n,r);a["Content-Type"]="application/json",a.Accept="text/event-stream";let c;try{c=await n.fetchImpl(e,{method:"POST",body:JSON.stringify(i),headers:a,signal:r==null?void 0:r.signal})}catch(R){if(R instanceof Error&&R.name==="AbortError"){const N=new Ne("cancelled","Request was cancelled.");return{data:Promise.reject(N),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(N)}}}}}}const S=Ps(0,null);return{data:Promise.reject(S),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(S)}}}}}}let l,d;const f=new Promise((R,S)=>{l=R,d=S});(s=r==null?void 0:r.signal)===null||s===void 0||s.addEventListener("abort",()=>{const R=new Ne("cancelled","Request was cancelled.");d(R)});const m=c.body.getReader(),_=qm(m,l,d,r==null?void 0:r.signal);return{stream:{[Symbol.asyncIterator](){const R=_.getReader();return{async next(){const{value:S,done:N}=await R.read();return{value:S,done:N}},async return(){return await R.cancel(),{done:!0,value:void 0}}}}},data:f}}function qm(n,e,t,r){const s=(a,c)=>{const l=a.match(Nm);if(!l)return;const d=l[1];try{const f=JSON.parse(d);if("result"in f){e(bn(f.result));return}if("message"in f){c.enqueue(bn(f.message));return}if("error"in f){const m=Ps(0,f);c.error(m),t(m);return}}catch(f){if(f instanceof Ne){c.error(f),t(f);return}}},i=new TextDecoder;return new ReadableStream({start(a){let c="";return l();async function l(){if(r!=null&&r.aborted){const d=new Ne("cancelled","Request was cancelled");return a.error(d),t(d),Promise.resolve()}try{const{value:d,done:f}=await n.read();if(f){c.trim()&&s(c.trim(),a),a.close();return}if(r!=null&&r.aborted){const _=new Ne("cancelled","Request was cancelled");a.error(_),t(_),await n.cancel();return}c+=i.decode(d,{stream:!0});const m=c.split(`
451
- `);c=m.pop()||"";for(const _ of m)_.trim()&&s(_.trim(),a);return l()}catch(d){const f=d instanceof Ne?d:Ps(0,null);a.error(f),t(f)}}},cancel(){return n.cancel()}})}const $c="@firebase/functions",zc="0.12.7";/**
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
- */const jm="auth-internal",$m="app-check-internal",zm="messaging-internal";function Hm(n){const e=(t,{instanceIdentifier:r})=>{const s=t.getProvider("app").getImmediate(),i=t.getProvider(jm),a=t.getProvider(zm),c=t.getProvider($m);return new Vm(s,i,a,c,r)};St(new ut(ko,e,"PUBLIC").setMultipleInstances(!0)),qe($c,zc,n),qe($c,zc,"esm2017")}/**
467
- * @license
468
- * Copyright 2020 Google LLC
469
- *
470
- * Licensed under the Apache License, Version 2.0 (the "License");
471
- * you may not use this file except in compliance with the License.
472
- * You may obtain a copy of the License at
473
- *
474
- * http://www.apache.org/licenses/LICENSE-2.0
475
- *
476
- * Unless required by applicable law or agreed to in writing, software
477
- * distributed under the License is distributed on an "AS IS" BASIS,
478
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
479
- * See the License for the specific language governing permissions and
480
- * limitations under the License.
481
- */function Gm(n=Xs(),e=io){xt("Functions",!1);const r=kr(Z(n),ko).getImmediate({identifier:e}),s=So("functions");return s&&Wm(r,...s),r}function Wm(n,e,t){Om(Z(n),e,t)}function Km(n,e,t){return Lm(Z(n),e)}Hm();function Sl(){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 Qm=Sl,Cl=new Sr("auth","Firebase",Sl());/**
482
- * @license
483
- * Copyright 2020 Google LLC
484
- *
485
- * Licensed under the Apache License, Version 2.0 (the "License");
486
- * you may not use this file except in compliance with the License.
487
- * You may obtain a copy of the License at
488
- *
489
- * http://www.apache.org/licenses/LICENSE-2.0
490
- *
491
- * Unless required by applicable law or agreed to in writing, software
492
- * distributed under the License is distributed on an "AS IS" BASIS,
493
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
494
- * See the License for the specific language governing permissions and
495
- * limitations under the License.
496
- */const Ss=new Co("@firebase/auth");function Xm(n,...e){Ss.logLevel<=H.WARN&&Ss.warn(`Auth (${sn}): ${n}`,...e)}function ps(n,...e){Ss.logLevel<=H.ERROR&&Ss.error(`Auth (${sn}): ${n}`,...e)}/**
497
- * @license
498
- * Copyright 2020 Google LLC
499
- *
500
- * Licensed under the Apache License, Version 2.0 (the "License");
501
- * you may not use this file except in compliance with the License.
502
- * You may obtain a copy of the License at
503
- *
504
- * http://www.apache.org/licenses/LICENSE-2.0
505
- *
506
- * Unless required by applicable law or agreed to in writing, software
507
- * distributed under the License is distributed on an "AS IS" BASIS,
508
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
509
- * See the License for the specific language governing permissions and
510
- * limitations under the License.
511
- */function xe(n,...e){throw Do(n,...e)}function je(n,...e){return Do(n,...e)}function No(n,e,t){const r=Object.assign(Object.assign({},Qm()),{[e]:t});return new Sr("auth","Firebase",r).create(e,{appName:n.name})}function ot(n){return No(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function Ym(n,e,t){const r=t;if(!(e instanceof r))throw r.name!==e.constructor.name&&xe(n,"argument-error"),No(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function Do(n,...e){if(typeof n!="string"){const t=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=n.name),n._errorFactory.create(t,...r)}return Cl.create(n,...e)}function U(n,e,...t){if(!n)throw Do(e,...t)}function st(n){const e="INTERNAL ASSERTION FAILED: "+n;throw ps(e),new Error(e)}function ht(n,e){n||st(e)}/**
512
- * @license
513
- * Copyright 2020 Google LLC
514
- *
515
- * Licensed under the Apache License, Version 2.0 (the "License");
516
- * you may not use this file except in compliance with the License.
517
- * You may obtain a copy of the License at
518
- *
519
- * http://www.apache.org/licenses/LICENSE-2.0
520
- *
521
- * Unless required by applicable law or agreed to in writing, software
522
- * distributed under the License is distributed on an "AS IS" BASIS,
523
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
524
- * See the License for the specific language governing permissions and
525
- * limitations under the License.
526
- */function oo(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.href)||""}function Jm(){return Hc()==="http:"||Hc()==="https:"}function Hc(){var n;return typeof self<"u"&&((n=self.location)===null||n===void 0?void 0:n.protocol)||null}/**
527
- * @license
528
- * Copyright 2020 Google LLC
529
- *
530
- * Licensed under the Apache License, Version 2.0 (the "License");
531
- * you may not use this file except in compliance with the License.
532
- * You may obtain a copy of the License at
533
- *
534
- * http://www.apache.org/licenses/LICENSE-2.0
535
- *
536
- * Unless required by applicable law or agreed to in writing, software
537
- * distributed under the License is distributed on an "AS IS" BASIS,
538
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
539
- * See the License for the specific language governing permissions and
540
- * limitations under the License.
541
- */function Zm(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(Jm()||gp()||"connection"in navigator)?navigator.onLine:!0}function eg(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}/**
542
- * @license
543
- * Copyright 2020 Google LLC
544
- *
545
- * Licensed under the Apache License, Version 2.0 (the "License");
546
- * you may not use this file except in compliance with the License.
547
- * You may obtain a copy of the License at
548
- *
549
- * http://www.apache.org/licenses/LICENSE-2.0
550
- *
551
- * Unless required by applicable law or agreed to in writing, software
552
- * distributed under the License is distributed on an "AS IS" BASIS,
553
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
554
- * See the License for the specific language governing permissions and
555
- * limitations under the License.
556
- */class Nr{constructor(e,t){this.shortDelay=e,this.longDelay=t,ht(t>e,"Short delay should be less than long delay!"),this.isMobile=fp()||_p()}get(){return Zm()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}/**
557
- * @license
558
- * Copyright 2020 Google LLC
559
- *
560
- * Licensed under the Apache License, Version 2.0 (the "License");
561
- * you may not use this file except in compliance with the License.
562
- * You may obtain a copy of the License at
563
- *
564
- * http://www.apache.org/licenses/LICENSE-2.0
565
- *
566
- * Unless required by applicable law or agreed to in writing, software
567
- * distributed under the License is distributed on an "AS IS" BASIS,
568
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
569
- * See the License for the specific language governing permissions and
570
- * limitations under the License.
571
- */function Vo(n,e){ht(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}/**
572
- * @license
573
- * Copyright 2020 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
- */class kl{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;st("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;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;st("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;st("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}/**
587
- * @license
588
- * Copyright 2020 Google LLC
589
- *
590
- * Licensed under the Apache License, Version 2.0 (the "License");
591
- * you may not use this file except in compliance with the License.
592
- * You may obtain a copy of the License at
593
- *
594
- * http://www.apache.org/licenses/LICENSE-2.0
595
- *
596
- * Unless required by applicable law or agreed to in writing, software
597
- * distributed under the License is distributed on an "AS IS" BASIS,
598
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
599
- * See the License for the specific language governing permissions and
600
- * limitations under the License.
601
- */const tg={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};/**
602
- * @license
603
- * Copyright 2020 Google LLC
604
- *
605
- * Licensed under the Apache License, Version 2.0 (the "License");
606
- * you may not use this file except in compliance with the License.
607
- * You may obtain a copy of the License at
608
- *
609
- * http://www.apache.org/licenses/LICENSE-2.0
610
- *
611
- * Unless required by applicable law or agreed to in writing, software
612
- * distributed under the License is distributed on an "AS IS" BASIS,
613
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
614
- * See the License for the specific language governing permissions and
615
- * limitations under the License.
616
- */const ng=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],rg=new Nr(3e4,6e4);function Mt(n,e){return n.tenantId&&!e.tenantId?Object.assign(Object.assign({},e),{tenantId:n.tenantId}):e}async function Ut(n,e,t,r,s={}){return Nl(n,s,async()=>{let i={},a={};r&&(e==="GET"?a=r:i={body:JSON.stringify(r)});const c=Cr(Object.assign({key:n.config.apiKey},a)).slice(1),l=await n._getAdditionalHeaders();l["Content-Type"]="application/json",n.languageCode&&(l["X-Firebase-Locale"]=n.languageCode);const d=Object.assign({method:e,headers:l},i);return mp()||(d.referrerPolicy="no-referrer"),n.emulatorConfig&&Lt(n.emulatorConfig.host)&&(d.credentials="include"),kl.fetch()(await Dl(n,n.config.apiHost,t,c),d)})}async function Nl(n,e,t){n._canInitEmulator=!1;const r=Object.assign(Object.assign({},tg),e);try{const s=new ig(n),i=await Promise.race([t(),s.promise]);s.clearNetworkTimeout();const a=await i.json();if("needConfirmation"in a)throw os(n,"account-exists-with-different-credential",a);if(i.ok&&!("errorMessage"in a))return a;{const c=i.ok?a.errorMessage:a.error.message,[l,d]=c.split(" : ");if(l==="FEDERATED_USER_ID_ALREADY_LINKED")throw os(n,"credential-already-in-use",a);if(l==="EMAIL_EXISTS")throw os(n,"email-already-in-use",a);if(l==="USER_DISABLED")throw os(n,"user-disabled",a);const f=r[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(d)throw No(n,f,d);xe(n,f)}}catch(s){if(s instanceof ze)throw s;xe(n,"network-request-failed",{message:String(s)})}}async function Dr(n,e,t,r,s={}){const i=await Ut(n,e,t,r,s);return"mfaPendingCredential"in i&&xe(n,"multi-factor-auth-required",{_serverResponse:i}),i}async function Dl(n,e,t,r){const s=`${e}${t}?${r}`,i=n,a=i.config.emulator?Vo(n.config,s):`${n.config.apiScheme}://${s}`;return ng.includes(t)&&(await i._persistenceManagerAvailable,i._getPersistenceType()==="COOKIE")?i._getPersistence()._getFinalTarget(a).toString():a}function sg(n){switch(n){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class ig{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,r)=>{this.timer=setTimeout(()=>r(je(this.auth,"network-request-failed")),rg.get())})}}function os(n,e,t){const r={appName:n.name};t.email&&(r.email=t.email),t.phoneNumber&&(r.phoneNumber=t.phoneNumber);const s=je(n,e,r);return s.customData._tokenResponse=t,s}function Gc(n){return n!==void 0&&n.enterprise!==void 0}class og{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return sg(t.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function ag(n,e){return Ut(n,"GET","/v2/recaptchaConfig",Mt(n,e))}/**
617
- * @license
618
- * Copyright 2020 Google LLC
619
- *
620
- * Licensed under the Apache License, Version 2.0 (the "License");
621
- * you may not use this file except in compliance with the License.
622
- * You may obtain a copy of the License at
623
- *
624
- * http://www.apache.org/licenses/LICENSE-2.0
625
- *
626
- * Unless required by applicable law or agreed to in writing, software
627
- * distributed under the License is distributed on an "AS IS" BASIS,
628
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
629
- * See the License for the specific language governing permissions and
630
- * limitations under the License.
631
- */async function cg(n,e){return Ut(n,"POST","/v1/accounts:delete",e)}async function Cs(n,e){return Ut(n,"POST","/v1/accounts:lookup",e)}/**
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
- */function fr(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function Vl(n,e=!1){const t=Z(n),r=await t.getIdToken(e),s=Oo(r);U(s&&s.exp&&s.auth_time&&s.iat,t.auth,"internal-error");const i=typeof s.firebase=="object"?s.firebase:void 0,a=i==null?void 0:i.sign_in_provider;return{claims:s,token:r,authTime:fr(Wi(s.auth_time)),issuedAtTime:fr(Wi(s.iat)),expirationTime:fr(Wi(s.exp)),signInProvider:a||null,signInSecondFactor:(i==null?void 0:i.sign_in_second_factor)||null}}function Wi(n){return Number(n)*1e3}function Oo(n){const[e,t,r]=n.split(".");if(e===void 0||t===void 0||r===void 0)return ps("JWT malformed, contained fewer than 3 sections"),null;try{const s=El(t);return s?JSON.parse(s):(ps("Failed to decode base64 JWT payload"),null)}catch(s){return ps("Caught error parsing JWT payload as JSON",s==null?void 0:s.toString()),null}}function Wc(n){const e=Oo(n);return U(e,"internal-error"),U(typeof e.exp<"u","internal-error"),U(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}/**
647
- * @license
648
- * Copyright 2020 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
- */async function Er(n,e,t=!1){if(t)return e;try{return await e}catch(r){throw r instanceof ze&&ug(r)&&n.auth.currentUser===n&&await n.auth.signOut(),r}}function ug({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}/**
662
- * @license
663
- * Copyright 2020 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
- */class lg{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 r=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),r}else{this.errorBackoff=3e4;const s=((t=this.user.stsTokenManager.expirationTime)!==null&&t!==void 0?t:0)-Date.now()-3e5;return Math.max(0,s)}}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()}}/**
677
- * @license
678
- * Copyright 2020 Google LLC
679
- *
680
- * Licensed under the Apache License, Version 2.0 (the "License");
681
- * you may not use this file except in compliance with the License.
682
- * You may obtain a copy of the License at
683
- *
684
- * http://www.apache.org/licenses/LICENSE-2.0
685
- *
686
- * Unless required by applicable law or agreed to in writing, software
687
- * distributed under the License is distributed on an "AS IS" BASIS,
688
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
689
- * See the License for the specific language governing permissions and
690
- * limitations under the License.
691
- */class ao{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=fr(this.lastLoginAt),this.creationTime=fr(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}/**
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
- */async function ks(n){var e;const t=n.auth,r=await n.getIdToken(),s=await Er(n,Cs(t,{idToken:r}));U(s==null?void 0:s.users.length,t,"internal-error");const i=s.users[0];n._notifyReloadListener(i);const a=!((e=i.providerUserInfo)===null||e===void 0)&&e.length?Ol(i.providerUserInfo):[],c=dg(n.providerData,a),l=n.isAnonymous,d=!(n.email&&i.passwordHash)&&!(c!=null&&c.length),f=l?d:!1,m={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:c,metadata:new ao(i.createdAt,i.lastLoginAt),isAnonymous:f};Object.assign(n,m)}async function hg(n){const e=Z(n);await ks(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function dg(n,e){return[...n.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function Ol(n){return n.map(e=>{var{providerId:t}=e,r=Po(e,["providerId"]);return{providerId:t,uid:r.rawId||"",displayName:r.displayName||null,email:r.email||null,phoneNumber:r.phoneNumber||null,photoURL:r.photoUrl||null}})}/**
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
- */async function fg(n,e){const t=await Nl(n,{},async()=>{const r=Cr({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:i}=n.config,a=await Dl(n,s,"/v1/token",`key=${i}`),c=await n._getAdditionalHeaders();return c["Content-Type"]="application/x-www-form-urlencoded",kl.fetch()(a,{method:"POST",headers:c,body:r})});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function pg(n,e){return Ut(n,"POST","/v2/accounts:revokeToken",Mt(n,e))}/**
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
- */class Tn{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){U(e.idToken,"internal-error"),U(typeof e.idToken<"u","internal-error"),U(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):Wc(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){U(e.length!==0,"internal-error");const t=Wc(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(U(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:r,refreshToken:s,expiresIn:i}=await fg(e,t);this.updateTokensAndExpiration(r,s,Number(i))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,t){const{refreshToken:r,accessToken:s,expirationTime:i}=t,a=new Tn;return r&&(U(typeof r=="string","internal-error",{appName:e}),a.refreshToken=r),s&&(U(typeof s=="string","internal-error",{appName:e}),a.accessToken=s),i&&(U(typeof i=="number","internal-error",{appName:e}),a.expirationTime=i),a}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 Tn,this.toJSON())}_performRefresh(){return st("not implemented")}}/**
737
- * @license
738
- * Copyright 2020 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
- */function yt(n,e){U(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class Fe{constructor(e){var{uid:t,auth:r,stsTokenManager:s}=e,i=Po(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new lg(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=r,this.stsTokenManager=s,this.accessToken=s.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 ao(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){const t=await Er(this,this.stsTokenManager.getToken(this.auth,e));return U(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return Vl(this,e)}reload(){return hg(this)}_assign(e){this!==e&&(U(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>Object.assign({},t)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new Fe(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){U(!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 r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await ks(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Pe(this.auth.app))return Promise.reject(ot(this.auth));const e=await this.getIdToken();return await Er(this,cg(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,isAnonymous: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 r,s,i,a,c,l,d,f;const m=(r=t.displayName)!==null&&r!==void 0?r:void 0,_=(s=t.email)!==null&&s!==void 0?s:void 0,R=(i=t.phoneNumber)!==null&&i!==void 0?i:void 0,S=(a=t.photoURL)!==null&&a!==void 0?a:void 0,N=(c=t.tenantId)!==null&&c!==void 0?c:void 0,k=(l=t._redirectEventId)!==null&&l!==void 0?l:void 0,B=(d=t.createdAt)!==null&&d!==void 0?d:void 0,M=(f=t.lastLoginAt)!==null&&f!==void 0?f:void 0,{uid:x,emailVerified:$,isAnonymous:ce,providerData:X,stsTokenManager:v}=t;U(x&&v,e,"internal-error");const g=Tn.fromJSON(this.name,v);U(typeof x=="string",e,"internal-error"),yt(m,e.name),yt(_,e.name),U(typeof $=="boolean",e,"internal-error"),U(typeof ce=="boolean",e,"internal-error"),yt(R,e.name),yt(S,e.name),yt(N,e.name),yt(k,e.name),yt(B,e.name),yt(M,e.name);const y=new Fe({uid:x,auth:e,email:_,emailVerified:$,displayName:m,isAnonymous:ce,photoURL:S,phoneNumber:R,tenantId:N,stsTokenManager:g,createdAt:B,lastLoginAt:M});return X&&Array.isArray(X)&&(y.providerData=X.map(T=>Object.assign({},T))),k&&(y._redirectEventId=k),y}static async _fromIdTokenResponse(e,t,r=!1){const s=new Tn;s.updateFromServerResponse(t);const i=new Fe({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await ks(i),i}static async _fromGetAccountInfoResponse(e,t,r){const s=t.users[0];U(s.localId!==void 0,"internal-error");const i=s.providerUserInfo!==void 0?Ol(s.providerUserInfo):[],a=!(s.email&&s.passwordHash)&&!(i!=null&&i.length),c=new Tn;c.updateFromIdToken(r);const l=new Fe({uid:s.localId,auth:e,stsTokenManager:c,isAnonymous:a}),d={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:i,metadata:new ao(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!(i!=null&&i.length)};return Object.assign(l,d),l}}/**
752
- * @license
753
- * Copyright 2020 Google LLC
754
- *
755
- * Licensed under the Apache License, Version 2.0 (the "License");
756
- * you may not use this file except in compliance with the License.
757
- * You may obtain a copy of the License at
758
- *
759
- * http://www.apache.org/licenses/LICENSE-2.0
760
- *
761
- * Unless required by applicable law or agreed to in writing, software
762
- * distributed under the License is distributed on an "AS IS" BASIS,
763
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
764
- * See the License for the specific language governing permissions and
765
- * limitations under the License.
766
- */const Kc=new Map;function it(n){ht(n instanceof Function,"Expected a class definition");let e=Kc.get(n);return e?(ht(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,Kc.set(n,e),e)}/**
767
- * @license
768
- * Copyright 2019 Google LLC
769
- *
770
- * Licensed under the Apache License, Version 2.0 (the "License");
771
- * you may not use this file except in compliance with the License.
772
- * You may obtain a copy of the License at
773
- *
774
- * http://www.apache.org/licenses/LICENSE-2.0
775
- *
776
- * Unless required by applicable law or agreed to in writing, software
777
- * distributed under the License is distributed on an "AS IS" BASIS,
778
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
779
- * See the License for the specific language governing permissions and
780
- * limitations under the License.
781
- */class Ll{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){}}Ll.type="NONE";const Qc=Ll;/**
782
- * @license
783
- * Copyright 2019 Google LLC
784
- *
785
- * Licensed under the Apache License, Version 2.0 (the "License");
786
- * you may not use this file except in compliance with the License.
787
- * You may obtain a copy of the License at
788
- *
789
- * http://www.apache.org/licenses/LICENSE-2.0
790
- *
791
- * Unless required by applicable law or agreed to in writing, software
792
- * distributed under the License is distributed on an "AS IS" BASIS,
793
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
794
- * See the License for the specific language governing permissions and
795
- * limitations under the License.
796
- */function ms(n,e,t){return`firebase:${n}:${e}:${t}`}class vn{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;const{config:s,name:i}=this.auth;this.fullUserKey=ms(this.userKey,s.apiKey,i),this.fullPersistenceKey=ms("persistence",s.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);if(!e)return null;if(typeof e=="string"){const t=await Cs(this.auth,{idToken:e}).catch(()=>{});return t?Fe._fromGetAccountInfoResponse(this.auth,t,e):null}return Fe._fromJSON(this.auth,e)}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,r="authUser"){if(!t.length)return new vn(it(Qc),e,r);const s=(await Promise.all(t.map(async d=>{if(await d._isAvailable())return d}))).filter(d=>d);let i=s[0]||it(Qc);const a=ms(r,e.config.apiKey,e.name);let c=null;for(const d of t)try{const f=await d._get(a);if(f){let m;if(typeof f=="string"){const _=await Cs(e,{idToken:f}).catch(()=>{});if(!_)break;m=await Fe._fromGetAccountInfoResponse(e,_,f)}else m=Fe._fromJSON(e,f);d!==i&&(c=m),i=d;break}}catch{}const l=s.filter(d=>d._shouldAllowMigration);return!i._shouldAllowMigration||!l.length?new vn(i,e,r):(i=l[0],c&&await i._set(a,c.toJSON()),await Promise.all(t.map(async d=>{if(d!==i)try{await d._remove(a)}catch{}})),new vn(i,e,r))}}/**
797
- * @license
798
- * Copyright 2020 Google LLC
799
- *
800
- * Licensed under the Apache License, Version 2.0 (the "License");
801
- * you may not use this file except in compliance with the License.
802
- * You may obtain a copy of the License at
803
- *
804
- * http://www.apache.org/licenses/LICENSE-2.0
805
- *
806
- * Unless required by applicable law or agreed to in writing, software
807
- * distributed under the License is distributed on an "AS IS" BASIS,
808
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
809
- * See the License for the specific language governing permissions and
810
- * limitations under the License.
811
- */function Xc(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(Fl(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(xl(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(ql(e))return"Blackberry";if(jl(e))return"Webos";if(Ml(e))return"Safari";if((e.includes("chrome/")||Ul(e))&&!e.includes("edge/"))return"Chrome";if(Bl(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=n.match(t);if((r==null?void 0:r.length)===2)return r[1]}return"Other"}function xl(n=we()){return/firefox\//i.test(n)}function Ml(n=we()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function Ul(n=we()){return/crios\//i.test(n)}function Fl(n=we()){return/iemobile/i.test(n)}function Bl(n=we()){return/android/i.test(n)}function ql(n=we()){return/blackberry/i.test(n)}function jl(n=we()){return/webos/i.test(n)}function Lo(n=we()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function mg(n=we()){var e;return Lo(n)&&!!(!((e=window.navigator)===null||e===void 0)&&e.standalone)}function gg(){return yp()&&document.documentMode===10}function $l(n=we()){return Lo(n)||Bl(n)||jl(n)||ql(n)||/windows phone/i.test(n)||Fl(n)}/**
812
- * @license
813
- * Copyright 2020 Google LLC
814
- *
815
- * Licensed under the Apache License, Version 2.0 (the "License");
816
- * you may not use this file except in compliance with the License.
817
- * You may obtain a copy of the License at
818
- *
819
- * http://www.apache.org/licenses/LICENSE-2.0
820
- *
821
- * Unless required by applicable law or agreed to in writing, software
822
- * distributed under the License is distributed on an "AS IS" BASIS,
823
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
824
- * See the License for the specific language governing permissions and
825
- * limitations under the License.
826
- */function zl(n,e=[]){let t;switch(n){case"Browser":t=Xc(we());break;case"Worker":t=`${Xc(we())}-${n}`;break;default:t=n}const r=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${sn}/${r}`}/**
827
- * @license
828
- * Copyright 2022 Google LLC
829
- *
830
- * Licensed under the Apache License, Version 2.0 (the "License");
831
- * you may not use this file except in compliance with the License.
832
- * You may obtain a copy of the License at
833
- *
834
- * http://www.apache.org/licenses/LICENSE-2.0
835
- *
836
- * Unless required by applicable law or agreed to in writing, software
837
- * distributed under the License is distributed on an "AS IS" BASIS,
838
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
839
- * See the License for the specific language governing permissions and
840
- * limitations under the License.
841
- */class _g{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const r=i=>new Promise((a,c)=>{try{const l=e(i);a(l)}catch(l){c(l)}});r.onAbort=t,this.queue.push(r);const s=this.queue.length-1;return()=>{this.queue[s]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(r){t.reverse();for(const s of t)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r==null?void 0:r.message})}}}/**
842
- * @license
843
- * Copyright 2023 Google LLC
844
- *
845
- * Licensed under the Apache License, Version 2.0 (the "License");
846
- * you may not use this file except in compliance with the License.
847
- * You may obtain a copy of the License at
848
- *
849
- * http://www.apache.org/licenses/LICENSE-2.0
850
- *
851
- * Unless required by applicable law or agreed to in writing, software
852
- * distributed under the License is distributed on an "AS IS" BASIS,
853
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
854
- * See the License for the specific language governing permissions and
855
- * limitations under the License.
856
- */async function yg(n,e={}){return Ut(n,"GET","/v2/passwordPolicy",Mt(n,e))}/**
857
- * @license
858
- * Copyright 2023 Google LLC
859
- *
860
- * Licensed under the Apache License, Version 2.0 (the "License");
861
- * you may not use this file except in compliance with the License.
862
- * You may obtain a copy of the License at
863
- *
864
- * http://www.apache.org/licenses/LICENSE-2.0
865
- *
866
- * Unless required by applicable law or agreed to in writing, software
867
- * distributed under the License is distributed on an "AS IS" BASIS,
868
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
869
- * See the License for the specific language governing permissions and
870
- * limitations under the License.
871
- */const Eg=6;class Tg{constructor(e){var t,r,s,i;const a=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=(t=a.minPasswordLength)!==null&&t!==void 0?t:Eg,a.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=a.maxPasswordLength),a.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=a.containsLowercaseCharacter),a.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=a.containsUppercaseCharacter),a.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=a.containsNumericCharacter),a.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=a.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=(s=(r=e.allowedNonAlphanumericCharacters)===null||r===void 0?void 0:r.join(""))!==null&&s!==void 0?s:"",this.forceUpgradeOnSignin=(i=e.forceUpgradeOnSignin)!==null&&i!==void 0?i:!1,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,r,s,i,a,c;const l={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,l),this.validatePasswordCharacterOptions(e,l),l.isValid&&(l.isValid=(t=l.meetsMinPasswordLength)!==null&&t!==void 0?t:!0),l.isValid&&(l.isValid=(r=l.meetsMaxPasswordLength)!==null&&r!==void 0?r:!0),l.isValid&&(l.isValid=(s=l.containsLowercaseLetter)!==null&&s!==void 0?s:!0),l.isValid&&(l.isValid=(i=l.containsUppercaseLetter)!==null&&i!==void 0?i:!0),l.isValid&&(l.isValid=(a=l.containsNumericCharacter)!==null&&a!==void 0?a:!0),l.isValid&&(l.isValid=(c=l.containsNonAlphanumericCharacter)!==null&&c!==void 0?c:!0),l}validatePasswordLengthOptions(e,t){const r=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),s&&(t.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let r;for(let s=0;s<e.length;s++)r=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(t,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,s,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}/**
872
- * @license
873
- * Copyright 2020 Google LLC
874
- *
875
- * Licensed under the Apache License, Version 2.0 (the "License");
876
- * you may not use this file except in compliance with the License.
877
- * You may obtain a copy of the License at
878
- *
879
- * http://www.apache.org/licenses/LICENSE-2.0
880
- *
881
- * Unless required by applicable law or agreed to in writing, software
882
- * distributed under the License is distributed on an "AS IS" BASIS,
883
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
884
- * See the License for the specific language governing permissions and
885
- * limitations under the License.
886
- */class vg{constructor(e,t,r,s){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Yc(this),this.idTokenSubscription=new Yc(this),this.beforeStateQueue=new _g(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=Cl,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=s.sdkClientVersion,this._persistenceManagerAvailable=new Promise(i=>this._resolvePersistenceManagerAvailable=i)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=it(t)),this._initializationPromise=this.queue(async()=>{var r,s,i;if(!this._deleted&&(this.persistenceManager=await vn.create(this,e),(r=this._resolvePersistenceManagerAvailable)===null||r===void 0||r.call(this),!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=((i=this.currentUser)===null||i===void 0?void 0:i.uid)||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await Cs(this,{idToken:e}),r=await Fe._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if(Pe(this.app)){const a=this.app.settings.authIdToken;return a?new Promise(c=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(a).then(c,c))}):this.directlySetCurrentUser(null)}const r=await this.assertedPersistence.getCurrentUser();let s=r,i=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const a=(t=this.redirectUser)===null||t===void 0?void 0:t._redirectEventId,c=s==null?void 0:s._redirectEventId,l=await this.tryRedirectSignIn(e);(!a||a===c)&&(l!=null&&l.user)&&(s=l.user,i=!0)}if(!s)return this.directlySetCurrentUser(null);if(!s._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(s)}catch(a){s=r,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(a))}return s?this.reloadAndSetCurrentUserOrClear(s):this.directlySetCurrentUser(null)}return U(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===s._redirectEventId?this.directlySetCurrentUser(s):this.reloadAndSetCurrentUserOrClear(s)}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 ks(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=eg()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(Pe(this.app))return Promise.reject(ot(this));const t=e?Z(e):null;return t&&U(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&&U(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 Pe(this.app)?Promise.reject(ot(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Pe(this.app)?Promise.reject(ot(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(it(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await yg(this),t=new Tg(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new Sr("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(r.tenantId=this.tenantId),await pg(this,r)}}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 r=await this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&it(e)||this._popupRedirectResolver;U(t,this,"argument-error"),this.redirectPersistenceManager=await vn.create(this,[it(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,r;return this._isInitialized&&await this.queue(async()=>{}),((t=this._currentUser)===null||t===void 0?void 0:t._redirectEventId)===e?this._currentUser:((r=this.redirectUser)===null||r===void 0?void 0:r._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 r=(t=(e=this.currentUser)===null||e===void 0?void 0:e.uid)!==null&&t!==void 0?t:null;this.lastNotifiedUid!==r&&(this.lastNotifiedUid=r,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,r,s){if(this._deleted)return()=>{};const i=typeof t=="function"?t:t.next.bind(t);let a=!1;const c=this._isInitialized?Promise.resolve():this._initializationPromise;if(U(c,this,"internal-error"),c.then(()=>{a||i(this.currentUser)}),typeof t=="function"){const l=e.addObserver(t,r,s);return()=>{a=!0,l()}}else{const l=e.addObserver(t);return()=>{a=!0,l()}}}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 U(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=zl(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 r=await((e=this.heartbeatServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getHeartbeatsHeader());r&&(t["X-Firebase-Client"]=r);const s=await this._getAppCheckToken();return s&&(t["X-Firebase-AppCheck"]=s),t}async _getAppCheckToken(){var e;if(Pe(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const t=await((e=this.appCheckServiceProvider.getImmediate({optional:!0}))===null||e===void 0?void 0:e.getToken());return t!=null&&t.error&&Xm(`Error while retrieving App Check token: ${t.error}`),t==null?void 0:t.token}}function Ft(n){return Z(n)}class Yc{constructor(e){this.auth=e,this.observer=null,this.addObserver=bp(t=>this.observer=t)}get next(){return U(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}/**
887
- * @license
888
- * Copyright 2020 Google LLC
889
- *
890
- * Licensed under the Apache License, Version 2.0 (the "License");
891
- * you may not use this file except in compliance with the License.
892
- * You may obtain a copy of the License at
893
- *
894
- * http://www.apache.org/licenses/LICENSE-2.0
895
- *
896
- * Unless required by applicable law or agreed to in writing, software
897
- * distributed under the License is distributed on an "AS IS" BASIS,
898
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
899
- * See the License for the specific language governing permissions and
900
- * limitations under the License.
901
- */let Ys={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function Ig(n){Ys=n}function Hl(n){return Ys.loadJS(n)}function wg(){return Ys.recaptchaEnterpriseScript}function Ag(){return Ys.gapiScript}function Rg(n){return`__${n}${Math.floor(Math.random()*1e6)}`}class bg{constructor(){this.enterprise=new Pg}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class Pg{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}const Sg="recaptcha-enterprise",Gl="NO_RECAPTCHA";class Cg{constructor(e){this.type=Sg,this.auth=Ft(e)}async verify(e="verify",t=!1){async function r(i){if(!t){if(i.tenantId==null&&i._agentRecaptchaConfig!=null)return i._agentRecaptchaConfig.siteKey;if(i.tenantId!=null&&i._tenantRecaptchaConfigs[i.tenantId]!==void 0)return i._tenantRecaptchaConfigs[i.tenantId].siteKey}return new Promise(async(a,c)=>{ag(i,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(l=>{if(l.recaptchaKey===void 0)c(new Error("recaptcha Enterprise site key undefined"));else{const d=new og(l);return i.tenantId==null?i._agentRecaptchaConfig=d:i._tenantRecaptchaConfigs[i.tenantId]=d,a(d.siteKey)}}).catch(l=>{c(l)})})}function s(i,a,c){const l=window.grecaptcha;Gc(l)?l.enterprise.ready(()=>{l.enterprise.execute(i,{action:e}).then(d=>{a(d)}).catch(()=>{a(Gl)})}):c(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new bg().execute("siteKey",{action:"verify"}):new Promise((i,a)=>{r(this.auth).then(c=>{if(!t&&Gc(window.grecaptcha))s(c,i,a);else{if(typeof window>"u"){a(new Error("RecaptchaVerifier is only supported in browser"));return}let l=wg();l.length!==0&&(l+=c),Hl(l).then(()=>{s(c,i,a)}).catch(d=>{a(d)})}}).catch(c=>{a(c)})})}}async function Jc(n,e,t,r=!1,s=!1){const i=new Cg(n);let a;if(s)a=Gl;else try{a=await i.verify(t)}catch{a=await i.verify(t,!0)}const c=Object.assign({},e);if(t==="mfaSmsEnrollment"||t==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in c){const l=c.phoneEnrollmentInfo.phoneNumber,d=c.phoneEnrollmentInfo.recaptchaToken;Object.assign(c,{phoneEnrollmentInfo:{phoneNumber:l,recaptchaToken:d,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in c){const l=c.phoneSignInInfo.recaptchaToken;Object.assign(c,{phoneSignInInfo:{recaptchaToken:l,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return c}return r?Object.assign(c,{captchaResp:a}):Object.assign(c,{captchaResponse:a}),Object.assign(c,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(c,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),c}async function Zc(n,e,t,r,s){var i;if(!((i=n._getRecaptchaConfig())===null||i===void 0)&&i.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const a=await Jc(n,e,t,t==="getOobCode");return r(n,a)}else return r(n,e).catch(async a=>{if(a.code==="auth/missing-recaptcha-token"){console.log(`${t} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const c=await Jc(n,e,t,t==="getOobCode");return r(n,c)}else return Promise.reject(a)})}/**
902
- * @license
903
- * Copyright 2020 Google LLC
904
- *
905
- * Licensed under the Apache License, Version 2.0 (the "License");
906
- * you may not use this file except in compliance with the License.
907
- * You may obtain a copy of the License at
908
- *
909
- * http://www.apache.org/licenses/LICENSE-2.0
910
- *
911
- * Unless required by applicable law or agreed to in writing, software
912
- * distributed under the License is distributed on an "AS IS" BASIS,
913
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
914
- * See the License for the specific language governing permissions and
915
- * limitations under the License.
916
- */function kg(n,e){const t=kr(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),i=t.getOptions();if(Yt(i,e??{}))return s;xe(s,"already-initialized")}return t.initialize({options:e})}function Ng(n,e){const t=(e==null?void 0:e.persistence)||[],r=(Array.isArray(t)?t:[t]).map(it);e!=null&&e.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e==null?void 0:e.popupRedirectResolver)}function Dg(n,e,t){const r=Ft(n);U(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,i=Wl(e),{host:a,port:c}=Vg(e),l=c===null?"":`:${c}`,d={url:`${i}//${a}${l}/`},f=Object.freeze({host:a,port:c,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!r._canInitEmulator){U(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),U(Yt(d,r.config.emulator)&&Yt(f,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=d,r.emulatorConfig=f,r.settings.appVerificationDisabledForTesting=!0,Lt(a)?(xt("Auth",!0),Qs(`${i}//${a}${l}`)):Og()}function Wl(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function Vg(n){const e=Wl(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const r=t[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const i=s[1];return{host:i,port:eu(r.substr(i.length+1))}}else{const[i,a]=r.split(":");return{host:i,port:eu(a)}}}function eu(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function Og(){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())}/**
917
- * @license
918
- * Copyright 2020 Google LLC
919
- *
920
- * Licensed under the Apache License, Version 2.0 (the "License");
921
- * you may not use this file except in compliance with the License.
922
- * You may obtain a copy of the License at
923
- *
924
- * http://www.apache.org/licenses/LICENSE-2.0
925
- *
926
- * Unless required by applicable law or agreed to in writing, software
927
- * distributed under the License is distributed on an "AS IS" BASIS,
928
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
929
- * See the License for the specific language governing permissions and
930
- * limitations under the License.
931
- */class xo{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return st("not implemented")}_getIdTokenResponse(e){return st("not implemented")}_linkToIdToken(e,t){return st("not implemented")}_getReauthenticationResolver(e){return st("not implemented")}}async function Lg(n,e){return Ut(n,"POST","/v1/accounts:signUp",e)}/**
932
- * @license
933
- * Copyright 2020 Google LLC
934
- *
935
- * Licensed under the Apache License, Version 2.0 (the "License");
936
- * you may not use this file except in compliance with the License.
937
- * You may obtain a copy of the License at
938
- *
939
- * http://www.apache.org/licenses/LICENSE-2.0
940
- *
941
- * Unless required by applicable law or agreed to in writing, software
942
- * distributed under the License is distributed on an "AS IS" BASIS,
943
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
944
- * See the License for the specific language governing permissions and
945
- * limitations under the License.
946
- */async function xg(n,e){return Dr(n,"POST","/v1/accounts:signInWithPassword",Mt(n,e))}/**
947
- * @license
948
- * Copyright 2020 Google LLC
949
- *
950
- * Licensed under the Apache License, Version 2.0 (the "License");
951
- * you may not use this file except in compliance with the License.
952
- * You may obtain a copy of the License at
953
- *
954
- * http://www.apache.org/licenses/LICENSE-2.0
955
- *
956
- * Unless required by applicable law or agreed to in writing, software
957
- * distributed under the License is distributed on an "AS IS" BASIS,
958
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
959
- * See the License for the specific language governing permissions and
960
- * limitations under the License.
961
- */async function Mg(n,e){return Dr(n,"POST","/v1/accounts:signInWithEmailLink",Mt(n,e))}async function Ug(n,e){return Dr(n,"POST","/v1/accounts:signInWithEmailLink",Mt(n,e))}/**
962
- * @license
963
- * Copyright 2020 Google LLC
964
- *
965
- * Licensed under the Apache License, Version 2.0 (the "License");
966
- * you may not use this file except in compliance with the License.
967
- * You may obtain a copy of the License at
968
- *
969
- * http://www.apache.org/licenses/LICENSE-2.0
970
- *
971
- * Unless required by applicable law or agreed to in writing, software
972
- * distributed under the License is distributed on an "AS IS" BASIS,
973
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
974
- * See the License for the specific language governing permissions and
975
- * limitations under the License.
976
- */class Tr extends xo{constructor(e,t,r,s=null){super("password",r),this._email=e,this._password=t,this._tenantId=s}static _fromEmailAndPassword(e,t){return new Tr(e,t,"password")}static _fromEmailAndCode(e,t,r=null){return new Tr(e,t,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e;if(t!=null&&t.email&&(t!=null&&t.password)){if(t.signInMethod==="password")return this._fromEmailAndPassword(t.email,t.password);if(t.signInMethod==="emailLink")return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":const t={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return Zc(e,t,"signInWithPassword",xg);case"emailLink":return Mg(e,{email:this._email,oobCode:this._password});default:xe(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":const r={idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return Zc(e,r,"signUpPassword",Lg);case"emailLink":return Ug(e,{idToken:t,email:this._email,oobCode:this._password});default:xe(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}/**
977
- * @license
978
- * Copyright 2020 Google LLC
979
- *
980
- * Licensed under the Apache License, Version 2.0 (the "License");
981
- * you may not use this file except in compliance with the License.
982
- * You may obtain a copy of the License at
983
- *
984
- * http://www.apache.org/licenses/LICENSE-2.0
985
- *
986
- * Unless required by applicable law or agreed to in writing, software
987
- * distributed under the License is distributed on an "AS IS" BASIS,
988
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
989
- * See the License for the specific language governing permissions and
990
- * limitations under the License.
991
- */async function In(n,e){return Dr(n,"POST","/v1/accounts:signInWithIdp",Mt(n,e))}/**
992
- * @license
993
- * Copyright 2020 Google LLC
994
- *
995
- * Licensed under the Apache License, Version 2.0 (the "License");
996
- * you may not use this file except in compliance with the License.
997
- * You may obtain a copy of the License at
998
- *
999
- * http://www.apache.org/licenses/LICENSE-2.0
1000
- *
1001
- * Unless required by applicable law or agreed to in writing, software
1002
- * distributed under the License is distributed on an "AS IS" BASIS,
1003
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1004
- * See the License for the specific language governing permissions and
1005
- * limitations under the License.
1006
- */const Fg="http://localhost";class Jt extends xo{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new Jt(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):xe("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:r,signInMethod:s}=t,i=Po(t,["providerId","signInMethod"]);if(!r||!s)return null;const a=new Jt(r,s);return a.idToken=i.idToken||void 0,a.accessToken=i.accessToken||void 0,a.secret=i.secret,a.nonce=i.nonce,a.pendingToken=i.pendingToken||null,a}_getIdTokenResponse(e){const t=this.buildRequest();return In(e,t)}_linkToIdToken(e,t){const r=this.buildRequest();return r.idToken=t,In(e,r)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,In(e,t)}buildRequest(){const e={requestUri:Fg,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=Cr(t)}return e}}/**
1007
- * @license
1008
- * Copyright 2020 Google LLC
1009
- *
1010
- * Licensed under the Apache License, Version 2.0 (the "License");
1011
- * you may not use this file except in compliance with the License.
1012
- * You may obtain a copy of the License at
1013
- *
1014
- * http://www.apache.org/licenses/LICENSE-2.0
1015
- *
1016
- * Unless required by applicable law or agreed to in writing, software
1017
- * distributed under the License is distributed on an "AS IS" BASIS,
1018
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1019
- * See the License for the specific language governing permissions and
1020
- * limitations under the License.
1021
- */function Bg(n){switch(n){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function qg(n){const e=or(ar(n)).link,t=e?or(ar(e)).deep_link_id:null,r=or(ar(n)).deep_link_id;return(r?or(ar(r)).link:null)||r||t||e||n}class Mo{constructor(e){var t,r,s,i,a,c;const l=or(ar(e)),d=(t=l.apiKey)!==null&&t!==void 0?t:null,f=(r=l.oobCode)!==null&&r!==void 0?r:null,m=Bg((s=l.mode)!==null&&s!==void 0?s:null);U(d&&f&&m,"argument-error"),this.apiKey=d,this.operation=m,this.code=f,this.continueUrl=(i=l.continueUrl)!==null&&i!==void 0?i:null,this.languageCode=(a=l.lang)!==null&&a!==void 0?a:null,this.tenantId=(c=l.tenantId)!==null&&c!==void 0?c:null}static parseLink(e){const t=qg(e);try{return new Mo(t)}catch{return null}}}/**
1022
- * @license
1023
- * Copyright 2020 Google LLC
1024
- *
1025
- * Licensed under the Apache License, Version 2.0 (the "License");
1026
- * you may not use this file except in compliance with the License.
1027
- * You may obtain a copy of the License at
1028
- *
1029
- * http://www.apache.org/licenses/LICENSE-2.0
1030
- *
1031
- * Unless required by applicable law or agreed to in writing, software
1032
- * distributed under the License is distributed on an "AS IS" BASIS,
1033
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1034
- * See the License for the specific language governing permissions and
1035
- * limitations under the License.
1036
- */class Ln{constructor(){this.providerId=Ln.PROVIDER_ID}static credential(e,t){return Tr._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const r=Mo.parseLink(t);return U(r,"argument-error"),Tr._fromEmailAndCode(e,r.code,r.tenantId)}}Ln.PROVIDER_ID="password";Ln.EMAIL_PASSWORD_SIGN_IN_METHOD="password";Ln.EMAIL_LINK_SIGN_IN_METHOD="emailLink";/**
1037
- * @license
1038
- * Copyright 2020 Google LLC
1039
- *
1040
- * Licensed under the Apache License, Version 2.0 (the "License");
1041
- * you may not use this file except in compliance with the License.
1042
- * You may obtain a copy of the License at
1043
- *
1044
- * http://www.apache.org/licenses/LICENSE-2.0
1045
- *
1046
- * Unless required by applicable law or agreed to in writing, software
1047
- * distributed under the License is distributed on an "AS IS" BASIS,
1048
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1049
- * See the License for the specific language governing permissions and
1050
- * limitations under the License.
1051
- */class Uo{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}}/**
1052
- * @license
1053
- * Copyright 2019 Google LLC
1054
- *
1055
- * Licensed under the Apache License, Version 2.0 (the "License");
1056
- * you may not use this file except in compliance with the License.
1057
- * You may obtain a copy of the License at
1058
- *
1059
- * http://www.apache.org/licenses/LICENSE-2.0
1060
- *
1061
- * Unless required by applicable law or agreed to in writing, software
1062
- * distributed under the License is distributed on an "AS IS" BASIS,
1063
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1064
- * See the License for the specific language governing permissions and
1065
- * limitations under the License.
1066
- */class Vr extends Uo{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}/**
1067
- * @license
1068
- * Copyright 2020 Google LLC
1069
- *
1070
- * Licensed under the Apache License, Version 2.0 (the "License");
1071
- * you may not use this file except in compliance with the License.
1072
- * You may obtain a copy of the License at
1073
- *
1074
- * http://www.apache.org/licenses/LICENSE-2.0
1075
- *
1076
- * Unless required by applicable law or agreed to in writing, software
1077
- * distributed under the License is distributed on an "AS IS" BASIS,
1078
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1079
- * See the License for the specific language governing permissions and
1080
- * limitations under the License.
1081
- */class Et extends Vr{constructor(){super("facebook.com")}static credential(e){return Jt._fromParams({providerId:Et.PROVIDER_ID,signInMethod:Et.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Et.credentialFromTaggedObject(e)}static credentialFromError(e){return Et.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Et.credential(e.oauthAccessToken)}catch{return null}}}Et.FACEBOOK_SIGN_IN_METHOD="facebook.com";Et.PROVIDER_ID="facebook.com";/**
1082
- * @license
1083
- * Copyright 2020 Google LLC
1084
- *
1085
- * Licensed under the Apache License, Version 2.0 (the "License");
1086
- * you may not use this file except in compliance with the License.
1087
- * You may obtain a copy of the License at
1088
- *
1089
- * http://www.apache.org/licenses/LICENSE-2.0
1090
- *
1091
- * Unless required by applicable law or agreed to in writing, software
1092
- * distributed under the License is distributed on an "AS IS" BASIS,
1093
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1094
- * See the License for the specific language governing permissions and
1095
- * limitations under the License.
1096
- */class rt extends Vr{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return Jt._fromParams({providerId:rt.PROVIDER_ID,signInMethod:rt.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return rt.credentialFromTaggedObject(e)}static credentialFromError(e){return rt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:r}=e;if(!t&&!r)return null;try{return rt.credential(t,r)}catch{return null}}}rt.GOOGLE_SIGN_IN_METHOD="google.com";rt.PROVIDER_ID="google.com";/**
1097
- * @license
1098
- * Copyright 2020 Google LLC
1099
- *
1100
- * Licensed under the Apache License, Version 2.0 (the "License");
1101
- * you may not use this file except in compliance with the License.
1102
- * You may obtain a copy of the License at
1103
- *
1104
- * http://www.apache.org/licenses/LICENSE-2.0
1105
- *
1106
- * Unless required by applicable law or agreed to in writing, software
1107
- * distributed under the License is distributed on an "AS IS" BASIS,
1108
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1109
- * See the License for the specific language governing permissions and
1110
- * limitations under the License.
1111
- */class Tt extends Vr{constructor(){super("github.com")}static credential(e){return Jt._fromParams({providerId:Tt.PROVIDER_ID,signInMethod:Tt.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Tt.credentialFromTaggedObject(e)}static credentialFromError(e){return Tt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Tt.credential(e.oauthAccessToken)}catch{return null}}}Tt.GITHUB_SIGN_IN_METHOD="github.com";Tt.PROVIDER_ID="github.com";/**
1112
- * @license
1113
- * Copyright 2020 Google LLC
1114
- *
1115
- * Licensed under the Apache License, Version 2.0 (the "License");
1116
- * you may not use this file except in compliance with the License.
1117
- * You may obtain a copy of the License at
1118
- *
1119
- * http://www.apache.org/licenses/LICENSE-2.0
1120
- *
1121
- * Unless required by applicable law or agreed to in writing, software
1122
- * distributed under the License is distributed on an "AS IS" BASIS,
1123
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1124
- * See the License for the specific language governing permissions and
1125
- * limitations under the License.
1126
- */class vt extends Vr{constructor(){super("twitter.com")}static credential(e,t){return Jt._fromParams({providerId:vt.PROVIDER_ID,signInMethod:vt.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return vt.credentialFromTaggedObject(e)}static credentialFromError(e){return vt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:r}=e;if(!t||!r)return null;try{return vt.credential(t,r)}catch{return null}}}vt.TWITTER_SIGN_IN_METHOD="twitter.com";vt.PROVIDER_ID="twitter.com";/**
1127
- * @license
1128
- * Copyright 2020 Google LLC
1129
- *
1130
- * Licensed under the Apache License, Version 2.0 (the "License");
1131
- * you may not use this file except in compliance with the License.
1132
- * You may obtain a copy of the License at
1133
- *
1134
- * http://www.apache.org/licenses/LICENSE-2.0
1135
- *
1136
- * Unless required by applicable law or agreed to in writing, software
1137
- * distributed under the License is distributed on an "AS IS" BASIS,
1138
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1139
- * See the License for the specific language governing permissions and
1140
- * limitations under the License.
1141
- */class Zt{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,s=!1){const i=await Fe._fromIdTokenResponse(e,r,s),a=tu(r);return new Zt({user:i,providerId:a,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);const s=tu(r);return new Zt({user:e,providerId:s,_tokenResponse:r,operationType:t})}}function tu(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}/**
1142
- * @license
1143
- * Copyright 2020 Google LLC
1144
- *
1145
- * Licensed under the Apache License, Version 2.0 (the "License");
1146
- * you may not use this file except in compliance with the License.
1147
- * You may obtain a copy of the License at
1148
- *
1149
- * http://www.apache.org/licenses/LICENSE-2.0
1150
- *
1151
- * Unless required by applicable law or agreed to in writing, software
1152
- * distributed under the License is distributed on an "AS IS" BASIS,
1153
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1154
- * See the License for the specific language governing permissions and
1155
- * limitations under the License.
1156
- */class Ns extends ze{constructor(e,t,r,s){var i;super(t.code,t.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,Ns.prototype),this.customData={appName:e.name,tenantId:(i=e.tenantId)!==null&&i!==void 0?i:void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,s){return new Ns(e,t,r,s)}}function Kl(n,e,t,r){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?Ns._fromErrorAndOperation(n,i,e,r):i})}async function jg(n,e,t=!1){const r=await Er(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return Zt._forOperation(n,"link",r)}/**
1157
- * @license
1158
- * Copyright 2019 Google LLC
1159
- *
1160
- * Licensed under the Apache License, Version 2.0 (the "License");
1161
- * you may not use this file except in compliance with the License.
1162
- * You may obtain a copy of the License at
1163
- *
1164
- * http://www.apache.org/licenses/LICENSE-2.0
1165
- *
1166
- * Unless required by applicable law or agreed to in writing, software
1167
- * distributed under the License is distributed on an "AS IS" BASIS,
1168
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1169
- * See the License for the specific language governing permissions and
1170
- * limitations under the License.
1171
- */async function $g(n,e,t=!1){const{auth:r}=n;if(Pe(r.app))return Promise.reject(ot(r));const s="reauthenticate";try{const i=await Er(n,Kl(r,s,e,n),t);U(i.idToken,r,"internal-error");const a=Oo(i.idToken);U(a,r,"internal-error");const{sub:c}=a;return U(n.uid===c,r,"user-mismatch"),Zt._forOperation(n,s,i)}catch(i){throw(i==null?void 0:i.code)==="auth/user-not-found"&&xe(r,"user-mismatch"),i}}/**
1172
- * @license
1173
- * Copyright 2020 Google LLC
1174
- *
1175
- * Licensed under the Apache License, Version 2.0 (the "License");
1176
- * you may not use this file except in compliance with the License.
1177
- * You may obtain a copy of the License at
1178
- *
1179
- * http://www.apache.org/licenses/LICENSE-2.0
1180
- *
1181
- * Unless required by applicable law or agreed to in writing, software
1182
- * distributed under the License is distributed on an "AS IS" BASIS,
1183
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1184
- * See the License for the specific language governing permissions and
1185
- * limitations under the License.
1186
- */async function Ql(n,e,t=!1){if(Pe(n.app))return Promise.reject(ot(n));const r="signIn",s=await Kl(n,r,e),i=await Zt._fromIdTokenResponse(n,r,s);return t||await n._updateCurrentUser(i.user),i}async function zg(n,e){return Ql(Ft(n),e)}/**
1187
- * @license
1188
- * Copyright 2020 Google LLC
1189
- *
1190
- * Licensed under the Apache License, Version 2.0 (the "License");
1191
- * you may not use this file except in compliance with the License.
1192
- * You may obtain a copy of the License at
1193
- *
1194
- * http://www.apache.org/licenses/LICENSE-2.0
1195
- *
1196
- * Unless required by applicable law or agreed to in writing, software
1197
- * distributed under the License is distributed on an "AS IS" BASIS,
1198
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1199
- * See the License for the specific language governing permissions and
1200
- * limitations under the License.
1201
- */async function Hg(n,e){return Dr(n,"POST","/v1/accounts:signInWithCustomToken",Mt(n,e))}/**
1202
- * @license
1203
- * Copyright 2020 Google LLC
1204
- *
1205
- * Licensed under the Apache License, Version 2.0 (the "License");
1206
- * you may not use this file except in compliance with the License.
1207
- * You may obtain a copy of the License at
1208
- *
1209
- * http://www.apache.org/licenses/LICENSE-2.0
1210
- *
1211
- * Unless required by applicable law or agreed to in writing, software
1212
- * distributed under the License is distributed on an "AS IS" BASIS,
1213
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1214
- * See the License for the specific language governing permissions and
1215
- * limitations under the License.
1216
- */async function Gg(n,e){if(Pe(n.app))return Promise.reject(ot(n));const t=Ft(n),r=await Hg(t,{token:e,returnSecureToken:!0}),s=await Zt._fromIdTokenResponse(t,"signIn",r);return await t._updateCurrentUser(s.user),s}/**
1217
- * @license
1218
- * Copyright 2020 Google LLC
1219
- *
1220
- * Licensed under the Apache License, Version 2.0 (the "License");
1221
- * you may not use this file except in compliance with the License.
1222
- * You may obtain a copy of the License at
1223
- *
1224
- * http://www.apache.org/licenses/LICENSE-2.0
1225
- *
1226
- * Unless required by applicable law or agreed to in writing, software
1227
- * distributed under the License is distributed on an "AS IS" BASIS,
1228
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1229
- * See the License for the specific language governing permissions and
1230
- * limitations under the License.
1231
- */async function Wg(n){const e=Ft(n);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}function Kg(n,e,t){return Pe(n.app)?Promise.reject(ot(n)):zg(Z(n),Ln.credential(e,t)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&Wg(n),r})}function Qg(n,e,t,r){return Z(n).onIdTokenChanged(e,t,r)}function Xg(n,e,t){return Z(n).beforeAuthStateChanged(e,t)}function Xl(n,e,t,r){return Z(n).onAuthStateChanged(e,t,r)}function Yg(n){return Z(n).signOut()}const Ds="__sak";/**
1232
- * @license
1233
- * Copyright 2019 Google LLC
1234
- *
1235
- * Licensed under the Apache License, Version 2.0 (the "License");
1236
- * you may not use this file except in compliance with the License.
1237
- * You may obtain a copy of the License at
1238
- *
1239
- * http://www.apache.org/licenses/LICENSE-2.0
1240
- *
1241
- * Unless required by applicable law or agreed to in writing, software
1242
- * distributed under the License is distributed on an "AS IS" BASIS,
1243
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1244
- * See the License for the specific language governing permissions and
1245
- * limitations under the License.
1246
- */class Yl{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Ds,"1"),this.storage.removeItem(Ds),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()}}/**
1247
- * @license
1248
- * Copyright 2020 Google LLC
1249
- *
1250
- * Licensed under the Apache License, Version 2.0 (the "License");
1251
- * you may not use this file except in compliance with the License.
1252
- * You may obtain a copy of the License at
1253
- *
1254
- * http://www.apache.org/licenses/LICENSE-2.0
1255
- *
1256
- * Unless required by applicable law or agreed to in writing, software
1257
- * distributed under the License is distributed on an "AS IS" BASIS,
1258
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1259
- * See the License for the specific language governing permissions and
1260
- * limitations under the License.
1261
- */const Jg=1e3,Zg=10;class Jl extends Yl{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=$l(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const r=this.storage.getItem(t),s=this.localCache[t];r!==s&&e(t,s,r)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((a,c,l)=>{this.notifyListeners(a,l)});return}const r=e.key;t?this.detachListener():this.stopPolling();const s=()=>{const a=this.storage.getItem(r);!t&&this.localCache[r]===a||this.notifyListeners(r,a)},i=this.storage.getItem(r);gg()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,Zg):s()}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:r}),!0)})},Jg)}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]),Object.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]}}Jl.type="LOCAL";const e_=Jl;/**
1262
- * @license
1263
- * Copyright 2020 Google LLC
1264
- *
1265
- * Licensed under the Apache License, Version 2.0 (the "License");
1266
- * you may not use this file except in compliance with the License.
1267
- * You may obtain a copy of the License at
1268
- *
1269
- * http://www.apache.org/licenses/LICENSE-2.0
1270
- *
1271
- * Unless required by applicable law or agreed to in writing, software
1272
- * distributed under the License is distributed on an "AS IS" BASIS,
1273
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1274
- * See the License for the specific language governing permissions and
1275
- * limitations under the License.
1276
- */class Zl extends Yl{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Zl.type="SESSION";const eh=Zl;/**
1277
- * @license
1278
- * Copyright 2019 Google LLC
1279
- *
1280
- * Licensed under the Apache License, Version 2.0 (the "License");
1281
- * you may not use this file except in compliance with the License.
1282
- * You may obtain a copy of the License at
1283
- *
1284
- * http://www.apache.org/licenses/LICENSE-2.0
1285
- *
1286
- * Unless required by applicable law or agreed to in writing, software
1287
- * distributed under the License is distributed on an "AS IS" BASIS,
1288
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1289
- * See the License for the specific language governing permissions and
1290
- * limitations under the License.
1291
- */function t_(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}/**
1292
- * @license
1293
- * Copyright 2019 Google LLC
1294
- *
1295
- * Licensed under the Apache License, Version 2.0 (the "License");
1296
- * you may not use this file except in compliance with the License.
1297
- * You may obtain a copy of the License at
1298
- *
1299
- * http://www.apache.org/licenses/LICENSE-2.0
1300
- *
1301
- * Unless required by applicable law or agreed to in writing, software
1302
- * distributed under the License is distributed on an "AS IS" BASIS,
1303
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1304
- * See the License for the specific language governing permissions and
1305
- * limitations under the License.
1306
- */class Js{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(s=>s.isListeningto(e));if(t)return t;const r=new Js(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:r,eventType:s,data:i}=t.data,a=this.handlersMap[s];if(!(a!=null&&a.size))return;t.ports[0].postMessage({status:"ack",eventId:r,eventType:s});const c=Array.from(a).map(async d=>d(t.origin,i)),l=await t_(c);t.ports[0].postMessage({status:"done",eventId:r,eventType:s,response:l})}_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)}}Js.receivers=[];/**
1307
- * @license
1308
- * Copyright 2020 Google LLC
1309
- *
1310
- * Licensed under the Apache License, Version 2.0 (the "License");
1311
- * you may not use this file except in compliance with the License.
1312
- * You may obtain a copy of the License at
1313
- *
1314
- * http://www.apache.org/licenses/LICENSE-2.0
1315
- *
1316
- * Unless required by applicable law or agreed to in writing, software
1317
- * distributed under the License is distributed on an "AS IS" BASIS,
1318
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1319
- * See the License for the specific language governing permissions and
1320
- * limitations under the License.
1321
- */function Fo(n="",e=10){let t="";for(let r=0;r<e;r++)t+=Math.floor(Math.random()*10);return n+t}/**
1322
- * @license
1323
- * Copyright 2019 Google LLC
1324
- *
1325
- * Licensed under the Apache License, Version 2.0 (the "License");
1326
- * you may not use this file except in compliance with the License.
1327
- * You may obtain a copy of the License at
1328
- *
1329
- * http://www.apache.org/licenses/LICENSE-2.0
1330
- *
1331
- * Unless required by applicable law or agreed to in writing, software
1332
- * distributed under the License is distributed on an "AS IS" BASIS,
1333
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1334
- * See the License for the specific language governing permissions and
1335
- * limitations under the License.
1336
- */class n_{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,r=50){const s=typeof MessageChannel<"u"?new MessageChannel:null;if(!s)throw new Error("connection_unavailable");let i,a;return new Promise((c,l)=>{const d=Fo("",20);s.port1.start();const f=setTimeout(()=>{l(new Error("unsupported_event"))},r);a={messageChannel:s,onMessage(m){const _=m;if(_.data.eventId===d)switch(_.data.status){case"ack":clearTimeout(f),i=setTimeout(()=>{l(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),c(_.data.response);break;default:clearTimeout(f),clearTimeout(i),l(new Error("invalid_response"));break}}},this.handlers.add(a),s.port1.addEventListener("message",a.onMessage),this.target.postMessage({eventType:e,eventId:d,data:t},[s.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}}/**
1337
- * @license
1338
- * Copyright 2020 Google LLC
1339
- *
1340
- * Licensed under the Apache License, Version 2.0 (the "License");
1341
- * you may not use this file except in compliance with the License.
1342
- * You may obtain a copy of the License at
1343
- *
1344
- * http://www.apache.org/licenses/LICENSE-2.0
1345
- *
1346
- * Unless required by applicable law or agreed to in writing, software
1347
- * distributed under the License is distributed on an "AS IS" BASIS,
1348
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1349
- * See the License for the specific language governing permissions and
1350
- * limitations under the License.
1351
- */function Ke(){return window}function r_(n){Ke().location.href=n}/**
1352
- * @license
1353
- * Copyright 2020 Google LLC.
1354
- *
1355
- * Licensed under the Apache License, Version 2.0 (the "License");
1356
- * you may not use this file except in compliance with the License.
1357
- * You may obtain a copy of the License at
1358
- *
1359
- * http://www.apache.org/licenses/LICENSE-2.0
1360
- *
1361
- * Unless required by applicable law or agreed to in writing, software
1362
- * distributed under the License is distributed on an "AS IS" BASIS,
1363
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1364
- * See the License for the specific language governing permissions and
1365
- * limitations under the License.
1366
- */function th(){return typeof Ke().WorkerGlobalScope<"u"&&typeof Ke().importScripts=="function"}async function s_(){if(!(navigator!=null&&navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function i_(){var n;return((n=navigator==null?void 0:navigator.serviceWorker)===null||n===void 0?void 0:n.controller)||null}function o_(){return th()?self:null}/**
1367
- * @license
1368
- * Copyright 2019 Google LLC
1369
- *
1370
- * Licensed under the Apache License, Version 2.0 (the "License");
1371
- * you may not use this file except in compliance with the License.
1372
- * You may obtain a copy of the License at
1373
- *
1374
- * http://www.apache.org/licenses/LICENSE-2.0
1375
- *
1376
- * Unless required by applicable law or agreed to in writing, software
1377
- * distributed under the License is distributed on an "AS IS" BASIS,
1378
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1379
- * See the License for the specific language governing permissions and
1380
- * limitations under the License.
1381
- */const nh="firebaseLocalStorageDb",a_=1,Vs="firebaseLocalStorage",rh="fbase_key";class Or{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 Zs(n,e){return n.transaction([Vs],e?"readwrite":"readonly").objectStore(Vs)}function c_(){const n=indexedDB.deleteDatabase(nh);return new Or(n).toPromise()}function co(){const n=indexedDB.open(nh,a_);return new Promise((e,t)=>{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const r=n.result;try{r.createObjectStore(Vs,{keyPath:rh})}catch(s){t(s)}}),n.addEventListener("success",async()=>{const r=n.result;r.objectStoreNames.contains(Vs)?e(r):(r.close(),await c_(),e(await co()))})})}async function nu(n,e,t){const r=Zs(n,!0).put({[rh]:e,value:t});return new Or(r).toPromise()}async function u_(n,e){const t=Zs(n,!1).get(e),r=await new Or(t).toPromise();return r===void 0?null:r.value}function ru(n,e){const t=Zs(n,!0).delete(e);return new Or(t).toPromise()}const l_=800,h_=3;class sh{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 r=await this._openDb();return await e(r)}catch(r){if(t++>h_)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return th()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Js._getInstance(o_()),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 s_(),!this.activeServiceWorker)return;this.sender=new n_(this.activeServiceWorker);const r=await this.sender._send("ping",{},800);r&&!((e=r[0])===null||e===void 0)&&e.fulfilled&&!((t=r[0])===null||t===void 0)&&t.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||i_()!==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 nu(e,Ds,"1"),await ru(e,Ds),!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(r=>nu(r,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(r=>u_(r,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>ru(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(s=>{const i=Zs(s,!1).getAll();return new Or(i).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],r=new Set;if(e.length!==0)for(const{fbase_key:s,value:i}of e)r.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(i)&&(this.notifyListeners(s,i),t.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!r.has(s)&&(this.notifyListeners(s,null),t.push(s));return t}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),l_)}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]),Object.keys(this.listeners).length===0&&this.stopPolling()}}sh.type="LOCAL";const d_=sh;new Nr(3e4,6e4);/**
1382
- * @license
1383
- * Copyright 2021 Google LLC
1384
- *
1385
- * Licensed under the Apache License, Version 2.0 (the "License");
1386
- * you may not use this file except in compliance with the License.
1387
- * You may obtain a copy of the License at
1388
- *
1389
- * http://www.apache.org/licenses/LICENSE-2.0
1390
- *
1391
- * Unless required by applicable law or agreed to in writing, software
1392
- * distributed under the License is distributed on an "AS IS" BASIS,
1393
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1394
- * See the License for the specific language governing permissions and
1395
- * limitations under the License.
1396
- */function ih(n,e){return e?it(e):(U(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}/**
1397
- * @license
1398
- * Copyright 2019 Google LLC
1399
- *
1400
- * Licensed under the Apache License, Version 2.0 (the "License");
1401
- * you may not use this file except in compliance with the License.
1402
- * You may obtain a copy of the License at
1403
- *
1404
- * http://www.apache.org/licenses/LICENSE-2.0
1405
- *
1406
- * Unless required by applicable law or agreed to in writing, software
1407
- * distributed under the License is distributed on an "AS IS" BASIS,
1408
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1409
- * See the License for the specific language governing permissions and
1410
- * limitations under the License.
1411
- */class Bo extends xo{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return In(e,this._buildIdpRequest())}_linkToIdToken(e,t){return In(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return In(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 f_(n){return Ql(n.auth,new Bo(n),n.bypassAuthState)}function p_(n){const{auth:e,user:t}=n;return U(t,e,"internal-error"),$g(t,new Bo(n),n.bypassAuthState)}async function m_(n){const{auth:e,user:t}=n;return U(t,e,"internal-error"),jg(t,new Bo(n),n.bypassAuthState)}/**
1412
- * @license
1413
- * Copyright 2020 Google LLC
1414
- *
1415
- * Licensed under the Apache License, Version 2.0 (the "License");
1416
- * you may not use this file except in compliance with the License.
1417
- * You may obtain a copy of the License at
1418
- *
1419
- * http://www.apache.org/licenses/LICENSE-2.0
1420
- *
1421
- * Unless required by applicable law or agreed to in writing, software
1422
- * distributed under the License is distributed on an "AS IS" BASIS,
1423
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1424
- * See the License for the specific language governing permissions and
1425
- * limitations under the License.
1426
- */class oh{constructor(e,t,r,s,i=!1){this.auth=e,this.resolver=r,this.user=s,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(r){this.reject(r)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:r,postBody:s,tenantId:i,error:a,type:c}=e;if(a){this.reject(a);return}const l={auth:this.auth,requestUri:t,sessionId:r,tenantId:i||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(c)(l))}catch(d){this.reject(d)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return f_;case"linkViaPopup":case"linkViaRedirect":return m_;case"reauthViaPopup":case"reauthViaRedirect":return p_;default:xe(this.auth,"internal-error")}}resolve(e){ht(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){ht(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()}}/**
1427
- * @license
1428
- * Copyright 2020 Google LLC
1429
- *
1430
- * Licensed under the Apache License, Version 2.0 (the "License");
1431
- * you may not use this file except in compliance with the License.
1432
- * You may obtain a copy of the License at
1433
- *
1434
- * http://www.apache.org/licenses/LICENSE-2.0
1435
- *
1436
- * Unless required by applicable law or agreed to in writing, software
1437
- * distributed under the License is distributed on an "AS IS" BASIS,
1438
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1439
- * See the License for the specific language governing permissions and
1440
- * limitations under the License.
1441
- */const g_=new Nr(2e3,1e4);async function __(n,e,t){if(Pe(n.app))return Promise.reject(je(n,"operation-not-supported-in-this-environment"));const r=Ft(n);Ym(n,e,Uo);const s=ih(r,t);return new Kt(r,"signInViaPopup",e,s).executeNotNull()}class Kt extends oh{constructor(e,t,r,s,i){super(e,t,s,i),this.provider=r,this.authWindow=null,this.pollId=null,Kt.currentPopupAction&&Kt.currentPopupAction.cancel(),Kt.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return U(e,this.auth,"internal-error"),e}async onExecution(){ht(this.filter.length===1,"Popup operations only handle one event");const e=Fo();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(je(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return((e=this.authWindow)===null||e===void 0?void 0:e.associatedEvent)||null}cancel(){this.reject(je(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Kt.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,r;if(!((r=(t=this.authWindow)===null||t===void 0?void 0:t.window)===null||r===void 0)&&r.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(je(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,g_.get())};e()}}Kt.currentPopupAction=null;/**
1442
- * @license
1443
- * Copyright 2020 Google LLC
1444
- *
1445
- * Licensed under the Apache License, Version 2.0 (the "License");
1446
- * you may not use this file except in compliance with the License.
1447
- * You may obtain a copy of the License at
1448
- *
1449
- * http://www.apache.org/licenses/LICENSE-2.0
1450
- *
1451
- * Unless required by applicable law or agreed to in writing, software
1452
- * distributed under the License is distributed on an "AS IS" BASIS,
1453
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1454
- * See the License for the specific language governing permissions and
1455
- * limitations under the License.
1456
- */const y_="pendingRedirect",gs=new Map;class E_ extends oh{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let e=gs.get(this.auth._key());if(!e){try{const r=await T_(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(t){e=()=>Promise.reject(t)}gs.set(this.auth._key(),e)}return this.bypassAuthState||gs.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 T_(n,e){const t=w_(e),r=I_(n);if(!await r._isAvailable())return!1;const s=await r._get(t)==="true";return await r._remove(t),s}function v_(n,e){gs.set(n._key(),e)}function I_(n){return it(n._redirectPersistence)}function w_(n){return ms(y_,n.config.apiKey,n.name)}async function A_(n,e,t=!1){if(Pe(n.app))return Promise.reject(ot(n));const r=Ft(n),s=ih(r,e),a=await new E_(r,s,t).execute();return a&&!t&&(delete a.user._redirectEventId,await r._persistUserIfCurrent(a.user),await r._setRedirectUser(null,e)),a}/**
1457
- * @license
1458
- * Copyright 2020 Google LLC
1459
- *
1460
- * Licensed under the Apache License, Version 2.0 (the "License");
1461
- * you may not use this file except in compliance with the License.
1462
- * You may obtain a copy of the License at
1463
- *
1464
- * http://www.apache.org/licenses/LICENSE-2.0
1465
- *
1466
- * Unless required by applicable law or agreed to in writing, software
1467
- * distributed under the License is distributed on an "AS IS" BASIS,
1468
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1469
- * See the License for the specific language governing permissions and
1470
- * limitations under the License.
1471
- */const R_=10*60*1e3;class b_{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(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!P_(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var r;if(e.error&&!ah(e)){const s=((r=e.error.code)===null||r===void 0?void 0:r.split("auth/")[1])||"internal-error";t.onError(je(this.auth,s))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const r=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=R_&&this.cachedEventUids.clear(),this.cachedEventUids.has(su(e))}saveEventToCache(e){this.cachedEventUids.add(su(e)),this.lastProcessedEventTime=Date.now()}}function su(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function ah({type:n,error:e}){return n==="unknown"&&(e==null?void 0:e.code)==="auth/no-auth-event"}function P_(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return ah(n);default:return!1}}/**
1472
- * @license
1473
- * Copyright 2020 Google LLC
1474
- *
1475
- * Licensed under the Apache License, Version 2.0 (the "License");
1476
- * you may not use this file except in compliance with the License.
1477
- * You may obtain a copy of the License at
1478
- *
1479
- * http://www.apache.org/licenses/LICENSE-2.0
1480
- *
1481
- * Unless required by applicable law or agreed to in writing, software
1482
- * distributed under the License is distributed on an "AS IS" BASIS,
1483
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1484
- * See the License for the specific language governing permissions and
1485
- * limitations under the License.
1486
- */async function S_(n,e={}){return Ut(n,"GET","/v1/projects",e)}/**
1487
- * @license
1488
- * Copyright 2020 Google LLC
1489
- *
1490
- * Licensed under the Apache License, Version 2.0 (the "License");
1491
- * you may not use this file except in compliance with the License.
1492
- * You may obtain a copy of the License at
1493
- *
1494
- * http://www.apache.org/licenses/LICENSE-2.0
1495
- *
1496
- * Unless required by applicable law or agreed to in writing, software
1497
- * distributed under the License is distributed on an "AS IS" BASIS,
1498
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1499
- * See the License for the specific language governing permissions and
1500
- * limitations under the License.
1501
- */const C_=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,k_=/^https?/;async function N_(n){if(n.config.emulator)return;const{authorizedDomains:e}=await S_(n);for(const t of e)try{if(D_(t))return}catch{}xe(n,"unauthorized-domain")}function D_(n){const e=oo(),{protocol:t,hostname:r}=new URL(e);if(n.startsWith("chrome-extension://")){const a=new URL(n);return a.hostname===""&&r===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&a.hostname===r}if(!k_.test(t))return!1;if(C_.test(n))return r===n;const s=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}/**
1502
- * @license
1503
- * Copyright 2020 Google LLC.
1504
- *
1505
- * Licensed under the Apache License, Version 2.0 (the "License");
1506
- * you may not use this file except in compliance with the License.
1507
- * You may obtain a copy of the License at
1508
- *
1509
- * http://www.apache.org/licenses/LICENSE-2.0
1510
- *
1511
- * Unless required by applicable law or agreed to in writing, software
1512
- * distributed under the License is distributed on an "AS IS" BASIS,
1513
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1514
- * See the License for the specific language governing permissions and
1515
- * limitations under the License.
1516
- */const V_=new Nr(3e4,6e4);function iu(){const n=Ke().___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 O_(n){return new Promise((e,t)=>{var r,s,i;function a(){iu(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{iu(),t(je(n,"network-request-failed"))},timeout:V_.get()})}if(!((s=(r=Ke().gapi)===null||r===void 0?void 0:r.iframes)===null||s===void 0)&&s.Iframe)e(gapi.iframes.getContext());else if(!((i=Ke().gapi)===null||i===void 0)&&i.load)a();else{const c=Rg("iframefcb");return Ke()[c]=()=>{gapi.load?a():t(je(n,"network-request-failed"))},Hl(`${Ag()}?onload=${c}`).catch(l=>t(l))}}).catch(e=>{throw _s=null,e})}let _s=null;function L_(n){return _s=_s||O_(n),_s}/**
1517
- * @license
1518
- * Copyright 2020 Google LLC.
1519
- *
1520
- * Licensed under the Apache License, Version 2.0 (the "License");
1521
- * you may not use this file except in compliance with the License.
1522
- * You may obtain a copy of the License at
1523
- *
1524
- * http://www.apache.org/licenses/LICENSE-2.0
1525
- *
1526
- * Unless required by applicable law or agreed to in writing, software
1527
- * distributed under the License is distributed on an "AS IS" BASIS,
1528
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1529
- * See the License for the specific language governing permissions and
1530
- * limitations under the License.
1531
- */const x_=new Nr(5e3,15e3),M_="__/auth/iframe",U_="emulator/auth/iframe",F_={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},B_=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function q_(n){const e=n.config;U(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?Vo(e,U_):`https://${n.config.authDomain}/${M_}`,r={apiKey:e.apiKey,appName:n.name,v:sn},s=B_.get(n.config.apiHost);s&&(r.eid=s);const i=n._getFrameworks();return i.length&&(r.fw=i.join(",")),`${t}?${Cr(r).slice(1)}`}async function j_(n){const e=await L_(n),t=Ke().gapi;return U(t,n,"internal-error"),e.open({where:document.body,url:q_(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:F_,dontclear:!0},r=>new Promise(async(s,i)=>{await r.restyle({setHideOnLeave:!1});const a=je(n,"network-request-failed"),c=Ke().setTimeout(()=>{i(a)},x_.get());function l(){Ke().clearTimeout(c),s(r)}r.ping(l).then(l,()=>{i(a)})}))}/**
1532
- * @license
1533
- * Copyright 2020 Google LLC.
1534
- *
1535
- * Licensed under the Apache License, Version 2.0 (the "License");
1536
- * you may not use this file except in compliance with the License.
1537
- * You may obtain a copy of the License at
1538
- *
1539
- * http://www.apache.org/licenses/LICENSE-2.0
1540
- *
1541
- * Unless required by applicable law or agreed to in writing, software
1542
- * distributed under the License is distributed on an "AS IS" BASIS,
1543
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1544
- * See the License for the specific language governing permissions and
1545
- * limitations under the License.
1546
- */const $_={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},z_=500,H_=600,G_="_blank",W_="http://localhost";class ou{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function K_(n,e,t,r=z_,s=H_){const i=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const l=Object.assign(Object.assign({},$_),{width:r.toString(),height:s.toString(),top:i,left:a}),d=we().toLowerCase();t&&(c=Ul(d)?G_:t),xl(d)&&(e=e||W_,l.scrollbars="yes");const f=Object.entries(l).reduce((_,[R,S])=>`${_}${R}=${S},`,"");if(mg(d)&&c!=="_self")return Q_(e||"",c),new ou(null);const m=window.open(e||"",c,f);U(m,n,"popup-blocked");try{m.focus()}catch{}return new ou(m)}function Q_(n,e){const t=document.createElement("a");t.href=n,t.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(r)}/**
1547
- * @license
1548
- * Copyright 2021 Google LLC
1549
- *
1550
- * Licensed under the Apache License, Version 2.0 (the "License");
1551
- * you may not use this file except in compliance with the License.
1552
- * You may obtain a copy of the License at
1553
- *
1554
- * http://www.apache.org/licenses/LICENSE-2.0
1555
- *
1556
- * Unless required by applicable law or agreed to in writing, software
1557
- * distributed under the License is distributed on an "AS IS" BASIS,
1558
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1559
- * See the License for the specific language governing permissions and
1560
- * limitations under the License.
1561
- */const X_="__/auth/handler",Y_="emulator/auth/handler",J_=encodeURIComponent("fac");async function au(n,e,t,r,s,i){U(n.config.authDomain,n,"auth-domain-config-required"),U(n.config.apiKey,n,"invalid-api-key");const a={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:r,v:sn,eventId:s};if(e instanceof Uo){e.setDefaultLanguage(n.languageCode),a.providerId=e.providerId||"",Rp(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[f,m]of Object.entries({}))a[f]=m}if(e instanceof Vr){const f=e.getScopes().filter(m=>m!=="");f.length>0&&(a.scopes=f.join(","))}n.tenantId&&(a.tid=n.tenantId);const c=a;for(const f of Object.keys(c))c[f]===void 0&&delete c[f];const l=await n._getAppCheckToken(),d=l?`#${J_}=${encodeURIComponent(l)}`:"";return`${Z_(n)}?${Cr(c).slice(1)}${d}`}function Z_({config:n}){return n.emulator?Vo(n,Y_):`https://${n.authDomain}/${X_}`}/**
1562
- * @license
1563
- * Copyright 2020 Google LLC
1564
- *
1565
- * Licensed under the Apache License, Version 2.0 (the "License");
1566
- * you may not use this file except in compliance with the License.
1567
- * You may obtain a copy of the License at
1568
- *
1569
- * http://www.apache.org/licenses/LICENSE-2.0
1570
- *
1571
- * Unless required by applicable law or agreed to in writing, software
1572
- * distributed under the License is distributed on an "AS IS" BASIS,
1573
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1574
- * See the License for the specific language governing permissions and
1575
- * limitations under the License.
1576
- */const Ki="webStorageSupport";class ey{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=eh,this._completeRedirectFn=A_,this._overrideRedirectResult=v_}async _openPopup(e,t,r,s){var i;ht((i=this.eventManagers[e._key()])===null||i===void 0?void 0:i.manager,"_initialize() not called before _openPopup()");const a=await au(e,t,r,oo(),s);return K_(e,a,Fo())}async _openRedirect(e,t,r,s){await this._originValidation(e);const i=await au(e,t,r,oo(),s);return r_(i),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:s,promise:i}=this.eventManagers[t];return s?Promise.resolve(s):(ht(i,"If manager is not set, promise should be"),i)}const r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}async initAndGetManager(e){const t=await j_(e),r=new b_(e);return t.register("authEvent",s=>(U(s==null?void 0:s.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(Ki,{type:Ki},s=>{var i;const a=(i=s==null?void 0:s[0])===null||i===void 0?void 0:i[Ki];a!==void 0&&t(!!a),xe(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=N_(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return $l()||Ml()||Lo()}}const ty=ey;var cu="@firebase/auth",uu="1.10.5";/**
1577
- * @license
1578
- * Copyright 2020 Google LLC
1579
- *
1580
- * Licensed under the Apache License, Version 2.0 (the "License");
1581
- * you may not use this file except in compliance with the License.
1582
- * You may obtain a copy of the License at
1583
- *
1584
- * http://www.apache.org/licenses/LICENSE-2.0
1585
- *
1586
- * Unless required by applicable law or agreed to in writing, software
1587
- * distributed under the License is distributed on an "AS IS" BASIS,
1588
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1589
- * See the License for the specific language governing permissions and
1590
- * limitations under the License.
1591
- */class ny{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(r=>{e((r==null?void 0:r.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(){U(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}/**
1592
- * @license
1593
- * Copyright 2020 Google LLC
1594
- *
1595
- * Licensed under the Apache License, Version 2.0 (the "License");
1596
- * you may not use this file except in compliance with the License.
1597
- * You may obtain a copy of the License at
1598
- *
1599
- * http://www.apache.org/licenses/LICENSE-2.0
1600
- *
1601
- * Unless required by applicable law or agreed to in writing, software
1602
- * distributed under the License is distributed on an "AS IS" BASIS,
1603
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1604
- * See the License for the specific language governing permissions and
1605
- * limitations under the License.
1606
- */function ry(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function sy(n){St(new ut("auth",(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:a,authDomain:c}=r.options;U(a&&!a.includes(":"),"invalid-api-key",{appName:r.name});const l={apiKey:a,authDomain:c,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:zl(n)},d=new vg(r,s,i,l);return Ng(d,t),d},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),St(new ut("auth-internal",e=>{const t=Ft(e.getProvider("auth").getImmediate());return(r=>new ny(r))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),qe(cu,uu,ry(n)),qe(cu,uu,"esm2017")}/**
1607
- * @license
1608
- * Copyright 2021 Google LLC
1609
- *
1610
- * Licensed under the Apache License, Version 2.0 (the "License");
1611
- * you may not use this file except in compliance with the License.
1612
- * You may obtain a copy of the License at
1613
- *
1614
- * http://www.apache.org/licenses/LICENSE-2.0
1615
- *
1616
- * Unless required by applicable law or agreed to in writing, software
1617
- * distributed under the License is distributed on an "AS IS" BASIS,
1618
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1619
- * See the License for the specific language governing permissions and
1620
- * limitations under the License.
1621
- */const iy=5*60,oy=Il("authIdTokenMaxAge")||iy;let lu=null;const ay=n=>async e=>{const t=e&&await e.getIdTokenResult(),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>oy)return;const s=t==null?void 0:t.token;lu!==s&&(lu=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function cy(n=Xs()){const e=kr(n,"auth");if(e.isInitialized())return e.getImmediate();const t=kg(n,{popupRedirectResolver:ty,persistence:[d_,e_,eh]}),r=Il("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const i=new URL(r,location.origin);if(location.origin===i.origin){const a=ay(i.toString());Xg(t,a,()=>a(t.currentUser)),Qg(t,c=>a(c))}}const s=Tl("auth");return s?Dg(t,`http://${s}`):xt("Auth",!1),t}function uy(){var n,e;return(e=(n=document.getElementsByTagName("head"))===null||n===void 0?void 0:n[0])!==null&&e!==void 0?e:document}Ig({loadJS(n){return new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=s=>{const i=je("internal-error");i.customData=s,t(i)},r.type="text/javascript",r.charset="UTF-8",uy().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});sy("Browser");var hu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
1622
- Copyright The Closure Library Authors.
1623
- SPDX-License-Identifier: Apache-2.0
1624
- */var bt,ch;(function(){var n;/** @license
1625
-
1626
- Copyright The Closure Library Authors.
1627
- SPDX-License-Identifier: Apache-2.0
1628
- */function e(v,g){function y(){}y.prototype=g.prototype,v.D=g.prototype,v.prototype=new y,v.prototype.constructor=v,v.C=function(T,I,A){for(var E=Array(arguments.length-2),Ze=2;Ze<arguments.length;Ze++)E[Ze-2]=arguments[Ze];return g.prototype[I].apply(T,E)}}function t(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}e(r,t),r.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(v,g,y){y||(y=0);var T=Array(16);if(typeof g=="string")for(var I=0;16>I;++I)T[I]=g.charCodeAt(y++)|g.charCodeAt(y++)<<8|g.charCodeAt(y++)<<16|g.charCodeAt(y++)<<24;else for(I=0;16>I;++I)T[I]=g[y++]|g[y++]<<8|g[y++]<<16|g[y++]<<24;g=v.g[0],y=v.g[1],I=v.g[2];var A=v.g[3],E=g+(A^y&(I^A))+T[0]+3614090360&4294967295;g=y+(E<<7&4294967295|E>>>25),E=A+(I^g&(y^I))+T[1]+3905402710&4294967295,A=g+(E<<12&4294967295|E>>>20),E=I+(y^A&(g^y))+T[2]+606105819&4294967295,I=A+(E<<17&4294967295|E>>>15),E=y+(g^I&(A^g))+T[3]+3250441966&4294967295,y=I+(E<<22&4294967295|E>>>10),E=g+(A^y&(I^A))+T[4]+4118548399&4294967295,g=y+(E<<7&4294967295|E>>>25),E=A+(I^g&(y^I))+T[5]+1200080426&4294967295,A=g+(E<<12&4294967295|E>>>20),E=I+(y^A&(g^y))+T[6]+2821735955&4294967295,I=A+(E<<17&4294967295|E>>>15),E=y+(g^I&(A^g))+T[7]+4249261313&4294967295,y=I+(E<<22&4294967295|E>>>10),E=g+(A^y&(I^A))+T[8]+1770035416&4294967295,g=y+(E<<7&4294967295|E>>>25),E=A+(I^g&(y^I))+T[9]+2336552879&4294967295,A=g+(E<<12&4294967295|E>>>20),E=I+(y^A&(g^y))+T[10]+4294925233&4294967295,I=A+(E<<17&4294967295|E>>>15),E=y+(g^I&(A^g))+T[11]+2304563134&4294967295,y=I+(E<<22&4294967295|E>>>10),E=g+(A^y&(I^A))+T[12]+1804603682&4294967295,g=y+(E<<7&4294967295|E>>>25),E=A+(I^g&(y^I))+T[13]+4254626195&4294967295,A=g+(E<<12&4294967295|E>>>20),E=I+(y^A&(g^y))+T[14]+2792965006&4294967295,I=A+(E<<17&4294967295|E>>>15),E=y+(g^I&(A^g))+T[15]+1236535329&4294967295,y=I+(E<<22&4294967295|E>>>10),E=g+(I^A&(y^I))+T[1]+4129170786&4294967295,g=y+(E<<5&4294967295|E>>>27),E=A+(y^I&(g^y))+T[6]+3225465664&4294967295,A=g+(E<<9&4294967295|E>>>23),E=I+(g^y&(A^g))+T[11]+643717713&4294967295,I=A+(E<<14&4294967295|E>>>18),E=y+(A^g&(I^A))+T[0]+3921069994&4294967295,y=I+(E<<20&4294967295|E>>>12),E=g+(I^A&(y^I))+T[5]+3593408605&4294967295,g=y+(E<<5&4294967295|E>>>27),E=A+(y^I&(g^y))+T[10]+38016083&4294967295,A=g+(E<<9&4294967295|E>>>23),E=I+(g^y&(A^g))+T[15]+3634488961&4294967295,I=A+(E<<14&4294967295|E>>>18),E=y+(A^g&(I^A))+T[4]+3889429448&4294967295,y=I+(E<<20&4294967295|E>>>12),E=g+(I^A&(y^I))+T[9]+568446438&4294967295,g=y+(E<<5&4294967295|E>>>27),E=A+(y^I&(g^y))+T[14]+3275163606&4294967295,A=g+(E<<9&4294967295|E>>>23),E=I+(g^y&(A^g))+T[3]+4107603335&4294967295,I=A+(E<<14&4294967295|E>>>18),E=y+(A^g&(I^A))+T[8]+1163531501&4294967295,y=I+(E<<20&4294967295|E>>>12),E=g+(I^A&(y^I))+T[13]+2850285829&4294967295,g=y+(E<<5&4294967295|E>>>27),E=A+(y^I&(g^y))+T[2]+4243563512&4294967295,A=g+(E<<9&4294967295|E>>>23),E=I+(g^y&(A^g))+T[7]+1735328473&4294967295,I=A+(E<<14&4294967295|E>>>18),E=y+(A^g&(I^A))+T[12]+2368359562&4294967295,y=I+(E<<20&4294967295|E>>>12),E=g+(y^I^A)+T[5]+4294588738&4294967295,g=y+(E<<4&4294967295|E>>>28),E=A+(g^y^I)+T[8]+2272392833&4294967295,A=g+(E<<11&4294967295|E>>>21),E=I+(A^g^y)+T[11]+1839030562&4294967295,I=A+(E<<16&4294967295|E>>>16),E=y+(I^A^g)+T[14]+4259657740&4294967295,y=I+(E<<23&4294967295|E>>>9),E=g+(y^I^A)+T[1]+2763975236&4294967295,g=y+(E<<4&4294967295|E>>>28),E=A+(g^y^I)+T[4]+1272893353&4294967295,A=g+(E<<11&4294967295|E>>>21),E=I+(A^g^y)+T[7]+4139469664&4294967295,I=A+(E<<16&4294967295|E>>>16),E=y+(I^A^g)+T[10]+3200236656&4294967295,y=I+(E<<23&4294967295|E>>>9),E=g+(y^I^A)+T[13]+681279174&4294967295,g=y+(E<<4&4294967295|E>>>28),E=A+(g^y^I)+T[0]+3936430074&4294967295,A=g+(E<<11&4294967295|E>>>21),E=I+(A^g^y)+T[3]+3572445317&4294967295,I=A+(E<<16&4294967295|E>>>16),E=y+(I^A^g)+T[6]+76029189&4294967295,y=I+(E<<23&4294967295|E>>>9),E=g+(y^I^A)+T[9]+3654602809&4294967295,g=y+(E<<4&4294967295|E>>>28),E=A+(g^y^I)+T[12]+3873151461&4294967295,A=g+(E<<11&4294967295|E>>>21),E=I+(A^g^y)+T[15]+530742520&4294967295,I=A+(E<<16&4294967295|E>>>16),E=y+(I^A^g)+T[2]+3299628645&4294967295,y=I+(E<<23&4294967295|E>>>9),E=g+(I^(y|~A))+T[0]+4096336452&4294967295,g=y+(E<<6&4294967295|E>>>26),E=A+(y^(g|~I))+T[7]+1126891415&4294967295,A=g+(E<<10&4294967295|E>>>22),E=I+(g^(A|~y))+T[14]+2878612391&4294967295,I=A+(E<<15&4294967295|E>>>17),E=y+(A^(I|~g))+T[5]+4237533241&4294967295,y=I+(E<<21&4294967295|E>>>11),E=g+(I^(y|~A))+T[12]+1700485571&4294967295,g=y+(E<<6&4294967295|E>>>26),E=A+(y^(g|~I))+T[3]+2399980690&4294967295,A=g+(E<<10&4294967295|E>>>22),E=I+(g^(A|~y))+T[10]+4293915773&4294967295,I=A+(E<<15&4294967295|E>>>17),E=y+(A^(I|~g))+T[1]+2240044497&4294967295,y=I+(E<<21&4294967295|E>>>11),E=g+(I^(y|~A))+T[8]+1873313359&4294967295,g=y+(E<<6&4294967295|E>>>26),E=A+(y^(g|~I))+T[15]+4264355552&4294967295,A=g+(E<<10&4294967295|E>>>22),E=I+(g^(A|~y))+T[6]+2734768916&4294967295,I=A+(E<<15&4294967295|E>>>17),E=y+(A^(I|~g))+T[13]+1309151649&4294967295,y=I+(E<<21&4294967295|E>>>11),E=g+(I^(y|~A))+T[4]+4149444226&4294967295,g=y+(E<<6&4294967295|E>>>26),E=A+(y^(g|~I))+T[11]+3174756917&4294967295,A=g+(E<<10&4294967295|E>>>22),E=I+(g^(A|~y))+T[2]+718787259&4294967295,I=A+(E<<15&4294967295|E>>>17),E=y+(A^(I|~g))+T[9]+3951481745&4294967295,v.g[0]=v.g[0]+g&4294967295,v.g[1]=v.g[1]+(I+(E<<21&4294967295|E>>>11))&4294967295,v.g[2]=v.g[2]+I&4294967295,v.g[3]=v.g[3]+A&4294967295}r.prototype.u=function(v,g){g===void 0&&(g=v.length);for(var y=g-this.blockSize,T=this.B,I=this.h,A=0;A<g;){if(I==0)for(;A<=y;)s(this,v,A),A+=this.blockSize;if(typeof v=="string"){for(;A<g;)if(T[I++]=v.charCodeAt(A++),I==this.blockSize){s(this,T),I=0;break}}else for(;A<g;)if(T[I++]=v[A++],I==this.blockSize){s(this,T),I=0;break}}this.h=I,this.o+=g},r.prototype.v=function(){var v=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);v[0]=128;for(var g=1;g<v.length-8;++g)v[g]=0;var y=8*this.o;for(g=v.length-8;g<v.length;++g)v[g]=y&255,y/=256;for(this.u(v),v=Array(16),g=y=0;4>g;++g)for(var T=0;32>T;T+=8)v[y++]=this.g[g]>>>T&255;return v};function i(v,g){var y=c;return Object.prototype.hasOwnProperty.call(y,v)?y[v]:y[v]=g(v)}function a(v,g){this.h=g;for(var y=[],T=!0,I=v.length-1;0<=I;I--){var A=v[I]|0;T&&A==g||(y[I]=A,T=!1)}this.g=y}var c={};function l(v){return-128<=v&&128>v?i(v,function(g){return new a([g|0],0>g?-1:0)}):new a([v|0],0>v?-1:0)}function d(v){if(isNaN(v)||!isFinite(v))return m;if(0>v)return k(d(-v));for(var g=[],y=1,T=0;v>=y;T++)g[T]=v/y|0,y*=4294967296;return new a(g,0)}function f(v,g){if(v.length==0)throw Error("number format error: empty string");if(g=g||10,2>g||36<g)throw Error("radix out of range: "+g);if(v.charAt(0)=="-")return k(f(v.substring(1),g));if(0<=v.indexOf("-"))throw Error('number format error: interior "-" character');for(var y=d(Math.pow(g,8)),T=m,I=0;I<v.length;I+=8){var A=Math.min(8,v.length-I),E=parseInt(v.substring(I,I+A),g);8>A?(A=d(Math.pow(g,A)),T=T.j(A).add(d(E))):(T=T.j(y),T=T.add(d(E)))}return T}var m=l(0),_=l(1),R=l(16777216);n=a.prototype,n.m=function(){if(N(this))return-k(this).m();for(var v=0,g=1,y=0;y<this.g.length;y++){var T=this.i(y);v+=(0<=T?T:4294967296+T)*g,g*=4294967296}return v},n.toString=function(v){if(v=v||10,2>v||36<v)throw Error("radix out of range: "+v);if(S(this))return"0";if(N(this))return"-"+k(this).toString(v);for(var g=d(Math.pow(v,6)),y=this,T="";;){var I=$(y,g).g;y=B(y,I.j(g));var A=((0<y.g.length?y.g[0]:y.h)>>>0).toString(v);if(y=I,S(y))return A+T;for(;6>A.length;)A="0"+A;T=A+T}},n.i=function(v){return 0>v?0:v<this.g.length?this.g[v]:this.h};function S(v){if(v.h!=0)return!1;for(var g=0;g<v.g.length;g++)if(v.g[g]!=0)return!1;return!0}function N(v){return v.h==-1}n.l=function(v){return v=B(this,v),N(v)?-1:S(v)?0:1};function k(v){for(var g=v.g.length,y=[],T=0;T<g;T++)y[T]=~v.g[T];return new a(y,~v.h).add(_)}n.abs=function(){return N(this)?k(this):this},n.add=function(v){for(var g=Math.max(this.g.length,v.g.length),y=[],T=0,I=0;I<=g;I++){var A=T+(this.i(I)&65535)+(v.i(I)&65535),E=(A>>>16)+(this.i(I)>>>16)+(v.i(I)>>>16);T=E>>>16,A&=65535,E&=65535,y[I]=E<<16|A}return new a(y,y[y.length-1]&-2147483648?-1:0)};function B(v,g){return v.add(k(g))}n.j=function(v){if(S(this)||S(v))return m;if(N(this))return N(v)?k(this).j(k(v)):k(k(this).j(v));if(N(v))return k(this.j(k(v)));if(0>this.l(R)&&0>v.l(R))return d(this.m()*v.m());for(var g=this.g.length+v.g.length,y=[],T=0;T<2*g;T++)y[T]=0;for(T=0;T<this.g.length;T++)for(var I=0;I<v.g.length;I++){var A=this.i(T)>>>16,E=this.i(T)&65535,Ze=v.i(I)>>>16,qn=v.i(I)&65535;y[2*T+2*I]+=E*qn,M(y,2*T+2*I),y[2*T+2*I+1]+=A*qn,M(y,2*T+2*I+1),y[2*T+2*I+1]+=E*Ze,M(y,2*T+2*I+1),y[2*T+2*I+2]+=A*Ze,M(y,2*T+2*I+2)}for(T=0;T<g;T++)y[T]=y[2*T+1]<<16|y[2*T];for(T=g;T<2*g;T++)y[T]=0;return new a(y,0)};function M(v,g){for(;(v[g]&65535)!=v[g];)v[g+1]+=v[g]>>>16,v[g]&=65535,g++}function x(v,g){this.g=v,this.h=g}function $(v,g){if(S(g))throw Error("division by zero");if(S(v))return new x(m,m);if(N(v))return g=$(k(v),g),new x(k(g.g),k(g.h));if(N(g))return g=$(v,k(g)),new x(k(g.g),g.h);if(30<v.g.length){if(N(v)||N(g))throw Error("slowDivide_ only works with positive integers.");for(var y=_,T=g;0>=T.l(v);)y=ce(y),T=ce(T);var I=X(y,1),A=X(T,1);for(T=X(T,2),y=X(y,2);!S(T);){var E=A.add(T);0>=E.l(v)&&(I=I.add(y),A=E),T=X(T,1),y=X(y,1)}return g=B(v,I.j(g)),new x(I,g)}for(I=m;0<=v.l(g);){for(y=Math.max(1,Math.floor(v.m()/g.m())),T=Math.ceil(Math.log(y)/Math.LN2),T=48>=T?1:Math.pow(2,T-48),A=d(y),E=A.j(g);N(E)||0<E.l(v);)y-=T,A=d(y),E=A.j(g);S(A)&&(A=_),I=I.add(A),v=B(v,E)}return new x(I,v)}n.A=function(v){return $(this,v).h},n.and=function(v){for(var g=Math.max(this.g.length,v.g.length),y=[],T=0;T<g;T++)y[T]=this.i(T)&v.i(T);return new a(y,this.h&v.h)},n.or=function(v){for(var g=Math.max(this.g.length,v.g.length),y=[],T=0;T<g;T++)y[T]=this.i(T)|v.i(T);return new a(y,this.h|v.h)},n.xor=function(v){for(var g=Math.max(this.g.length,v.g.length),y=[],T=0;T<g;T++)y[T]=this.i(T)^v.i(T);return new a(y,this.h^v.h)};function ce(v){for(var g=v.g.length+1,y=[],T=0;T<g;T++)y[T]=v.i(T)<<1|v.i(T-1)>>>31;return new a(y,v.h)}function X(v,g){var y=g>>5;g%=32;for(var T=v.g.length-y,I=[],A=0;A<T;A++)I[A]=0<g?v.i(A+y)>>>g|v.i(A+y+1)<<32-g:v.i(A+y);return new a(I,v.h)}r.prototype.digest=r.prototype.v,r.prototype.reset=r.prototype.s,r.prototype.update=r.prototype.u,ch=r,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.A,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=d,a.fromString=f,bt=a}).apply(typeof hu<"u"?hu:typeof self<"u"?self:typeof window<"u"?window:{});var as=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};/** @license
1629
- Copyright The Closure Library Authors.
1630
- SPDX-License-Identifier: Apache-2.0
1631
- */var uh,cr,lh,ys,uo,hh,dh,fh;(function(){var n,e=typeof Object.defineProperties=="function"?Object.defineProperty:function(o,u,h){return o==Array.prototype||o==Object.prototype||(o[u]=h.value),o};function t(o){o=[typeof globalThis=="object"&&globalThis,o,typeof window=="object"&&window,typeof self=="object"&&self,typeof as=="object"&&as];for(var u=0;u<o.length;++u){var h=o[u];if(h&&h.Math==Math)return h}throw Error("Cannot find global object")}var r=t(this);function s(o,u){if(u)e:{var h=r;o=o.split(".");for(var p=0;p<o.length-1;p++){var w=o[p];if(!(w in h))break e;h=h[w]}o=o[o.length-1],p=h[o],u=u(p),u!=p&&u!=null&&e(h,o,{configurable:!0,writable:!0,value:u})}}function i(o,u){o instanceof String&&(o+="");var h=0,p=!1,w={next:function(){if(!p&&h<o.length){var b=h++;return{value:u(b,o[b]),done:!1}}return p=!0,{done:!0,value:void 0}}};return w[Symbol.iterator]=function(){return w},w}s("Array.prototype.values",function(o){return o||function(){return i(this,function(u,h){return h})}});/** @license
1632
-
1633
- Copyright The Closure Library Authors.
1634
- SPDX-License-Identifier: Apache-2.0
1635
- */var a=a||{},c=this||self;function l(o){var u=typeof o;return u=u!="object"?u:o?Array.isArray(o)?"array":u:"null",u=="array"||u=="object"&&typeof o.length=="number"}function d(o){var u=typeof o;return u=="object"&&o!=null||u=="function"}function f(o,u,h){return o.call.apply(o.bind,arguments)}function m(o,u,h){if(!o)throw Error();if(2<arguments.length){var p=Array.prototype.slice.call(arguments,2);return function(){var w=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(w,p),o.apply(u,w)}}return function(){return o.apply(u,arguments)}}function _(o,u,h){return _=Function.prototype.bind&&Function.prototype.bind.toString().indexOf("native code")!=-1?f:m,_.apply(null,arguments)}function R(o,u){var h=Array.prototype.slice.call(arguments,1);return function(){var p=h.slice();return p.push.apply(p,arguments),o.apply(this,p)}}function S(o,u){function h(){}h.prototype=u.prototype,o.aa=u.prototype,o.prototype=new h,o.prototype.constructor=o,o.Qb=function(p,w,b){for(var D=Array(arguments.length-2),Y=2;Y<arguments.length;Y++)D[Y-2]=arguments[Y];return u.prototype[w].apply(p,D)}}function N(o){const u=o.length;if(0<u){const h=Array(u);for(let p=0;p<u;p++)h[p]=o[p];return h}return[]}function k(o,u){for(let h=1;h<arguments.length;h++){const p=arguments[h];if(l(p)){const w=o.length||0,b=p.length||0;o.length=w+b;for(let D=0;D<b;D++)o[w+D]=p[D]}else o.push(p)}}class B{constructor(u,h){this.i=u,this.j=h,this.h=0,this.g=null}get(){let u;return 0<this.h?(this.h--,u=this.g,this.g=u.next,u.next=null):u=this.i(),u}}function M(o){return/^[\s\xa0]*$/.test(o)}function x(){var o=c.navigator;return o&&(o=o.userAgent)?o:""}function $(o){return $[" "](o),o}$[" "]=function(){};var ce=x().indexOf("Gecko")!=-1&&!(x().toLowerCase().indexOf("webkit")!=-1&&x().indexOf("Edge")==-1)&&!(x().indexOf("Trident")!=-1||x().indexOf("MSIE")!=-1)&&x().indexOf("Edge")==-1;function X(o,u,h){for(const p in o)u.call(h,o[p],p,o)}function v(o,u){for(const h in o)u.call(void 0,o[h],h,o)}function g(o){const u={};for(const h in o)u[h]=o[h];return u}const y="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function T(o,u){let h,p;for(let w=1;w<arguments.length;w++){p=arguments[w];for(h in p)o[h]=p[h];for(let b=0;b<y.length;b++)h=y[b],Object.prototype.hasOwnProperty.call(p,h)&&(o[h]=p[h])}}function I(o){var u=1;o=o.split(":");const h=[];for(;0<u&&o.length;)h.push(o.shift()),u--;return o.length&&h.push(o.join(":")),h}function A(o){c.setTimeout(()=>{throw o},0)}function E(){var o=vi;let u=null;return o.g&&(u=o.g,o.g=o.g.next,o.g||(o.h=null),u.next=null),u}class Ze{constructor(){this.h=this.g=null}add(u,h){const p=qn.get();p.set(u,h),this.h?this.h.next=p:this.g=p,this.h=p}}var qn=new B(()=>new _f,o=>o.reset());class _f{constructor(){this.next=this.g=this.h=null}set(u,h){this.h=u,this.g=h,this.next=null}reset(){this.next=this.g=this.h=null}}let jn,$n=!1,vi=new Ze,Oa=()=>{const o=c.Promise.resolve(void 0);jn=()=>{o.then(yf)}};var yf=()=>{for(var o;o=E();){try{o.h.call(o.g)}catch(h){A(h)}var u=qn;u.j(o),100>u.h&&(u.h++,o.next=u.g,u.g=o)}$n=!1};function pt(){this.s=this.s,this.C=this.C}pt.prototype.s=!1,pt.prototype.ma=function(){this.s||(this.s=!0,this.N())},pt.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function ge(o,u){this.type=o,this.g=this.target=u,this.defaultPrevented=!1}ge.prototype.h=function(){this.defaultPrevented=!0};var Ef=function(){if(!c.addEventListener||!Object.defineProperty)return!1;var o=!1,u=Object.defineProperty({},"passive",{get:function(){o=!0}});try{const h=()=>{};c.addEventListener("test",h,u),c.removeEventListener("test",h,u)}catch{}return o}();function zn(o,u){if(ge.call(this,o?o.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,o){var h=this.type=o.type,p=o.changedTouches&&o.changedTouches.length?o.changedTouches[0]:null;if(this.target=o.target||o.srcElement,this.g=u,u=o.relatedTarget){if(ce){e:{try{$(u.nodeName);var w=!0;break e}catch{}w=!1}w||(u=null)}}else h=="mouseover"?u=o.fromElement:h=="mouseout"&&(u=o.toElement);this.relatedTarget=u,p?(this.clientX=p.clientX!==void 0?p.clientX:p.pageX,this.clientY=p.clientY!==void 0?p.clientY:p.pageY,this.screenX=p.screenX||0,this.screenY=p.screenY||0):(this.clientX=o.clientX!==void 0?o.clientX:o.pageX,this.clientY=o.clientY!==void 0?o.clientY:o.pageY,this.screenX=o.screenX||0,this.screenY=o.screenY||0),this.button=o.button,this.key=o.key||"",this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.shiftKey=o.shiftKey,this.metaKey=o.metaKey,this.pointerId=o.pointerId||0,this.pointerType=typeof o.pointerType=="string"?o.pointerType:Tf[o.pointerType]||"",this.state=o.state,this.i=o,o.defaultPrevented&&zn.aa.h.call(this)}}S(zn,ge);var Tf={2:"touch",3:"pen",4:"mouse"};zn.prototype.h=function(){zn.aa.h.call(this);var o=this.i;o.preventDefault?o.preventDefault():o.returnValue=!1};var qr="closure_listenable_"+(1e6*Math.random()|0),vf=0;function If(o,u,h,p,w){this.listener=o,this.proxy=null,this.src=u,this.type=h,this.capture=!!p,this.ha=w,this.key=++vf,this.da=this.fa=!1}function jr(o){o.da=!0,o.listener=null,o.proxy=null,o.src=null,o.ha=null}function $r(o){this.src=o,this.g={},this.h=0}$r.prototype.add=function(o,u,h,p,w){var b=o.toString();o=this.g[b],o||(o=this.g[b]=[],this.h++);var D=wi(o,u,p,w);return-1<D?(u=o[D],h||(u.fa=!1)):(u=new If(u,this.src,b,!!p,w),u.fa=h,o.push(u)),u};function Ii(o,u){var h=u.type;if(h in o.g){var p=o.g[h],w=Array.prototype.indexOf.call(p,u,void 0),b;(b=0<=w)&&Array.prototype.splice.call(p,w,1),b&&(jr(u),o.g[h].length==0&&(delete o.g[h],o.h--))}}function wi(o,u,h,p){for(var w=0;w<o.length;++w){var b=o[w];if(!b.da&&b.listener==u&&b.capture==!!h&&b.ha==p)return w}return-1}var Ai="closure_lm_"+(1e6*Math.random()|0),Ri={};function La(o,u,h,p,w){if(Array.isArray(u)){for(var b=0;b<u.length;b++)La(o,u[b],h,p,w);return null}return h=Ua(h),o&&o[qr]?o.K(u,h,d(p)?!!p.capture:!1,w):wf(o,u,h,!1,p,w)}function wf(o,u,h,p,w,b){if(!u)throw Error("Invalid event type");var D=d(w)?!!w.capture:!!w,Y=Pi(o);if(Y||(o[Ai]=Y=new $r(o)),h=Y.add(u,h,p,D,b),h.proxy)return h;if(p=Af(),h.proxy=p,p.src=o,p.listener=h,o.addEventListener)Ef||(w=D),w===void 0&&(w=!1),o.addEventListener(u.toString(),p,w);else if(o.attachEvent)o.attachEvent(Ma(u.toString()),p);else if(o.addListener&&o.removeListener)o.addListener(p);else throw Error("addEventListener and attachEvent are unavailable.");return h}function Af(){function o(h){return u.call(o.src,o.listener,h)}const u=Rf;return o}function xa(o,u,h,p,w){if(Array.isArray(u))for(var b=0;b<u.length;b++)xa(o,u[b],h,p,w);else p=d(p)?!!p.capture:!!p,h=Ua(h),o&&o[qr]?(o=o.i,u=String(u).toString(),u in o.g&&(b=o.g[u],h=wi(b,h,p,w),-1<h&&(jr(b[h]),Array.prototype.splice.call(b,h,1),b.length==0&&(delete o.g[u],o.h--)))):o&&(o=Pi(o))&&(u=o.g[u.toString()],o=-1,u&&(o=wi(u,h,p,w)),(h=-1<o?u[o]:null)&&bi(h))}function bi(o){if(typeof o!="number"&&o&&!o.da){var u=o.src;if(u&&u[qr])Ii(u.i,o);else{var h=o.type,p=o.proxy;u.removeEventListener?u.removeEventListener(h,p,o.capture):u.detachEvent?u.detachEvent(Ma(h),p):u.addListener&&u.removeListener&&u.removeListener(p),(h=Pi(u))?(Ii(h,o),h.h==0&&(h.src=null,u[Ai]=null)):jr(o)}}}function Ma(o){return o in Ri?Ri[o]:Ri[o]="on"+o}function Rf(o,u){if(o.da)o=!0;else{u=new zn(u,this);var h=o.listener,p=o.ha||o.src;o.fa&&bi(o),o=h.call(p,u)}return o}function Pi(o){return o=o[Ai],o instanceof $r?o:null}var Si="__closure_events_fn_"+(1e9*Math.random()>>>0);function Ua(o){return typeof o=="function"?o:(o[Si]||(o[Si]=function(u){return o.handleEvent(u)}),o[Si])}function _e(){pt.call(this),this.i=new $r(this),this.M=this,this.F=null}S(_e,pt),_e.prototype[qr]=!0,_e.prototype.removeEventListener=function(o,u,h,p){xa(this,o,u,h,p)};function Ae(o,u){var h,p=o.F;if(p)for(h=[];p;p=p.F)h.push(p);if(o=o.M,p=u.type||u,typeof u=="string")u=new ge(u,o);else if(u instanceof ge)u.target=u.target||o;else{var w=u;u=new ge(p,o),T(u,w)}if(w=!0,h)for(var b=h.length-1;0<=b;b--){var D=u.g=h[b];w=zr(D,p,!0,u)&&w}if(D=u.g=o,w=zr(D,p,!0,u)&&w,w=zr(D,p,!1,u)&&w,h)for(b=0;b<h.length;b++)D=u.g=h[b],w=zr(D,p,!1,u)&&w}_e.prototype.N=function(){if(_e.aa.N.call(this),this.i){var o=this.i,u;for(u in o.g){for(var h=o.g[u],p=0;p<h.length;p++)jr(h[p]);delete o.g[u],o.h--}}this.F=null},_e.prototype.K=function(o,u,h,p){return this.i.add(String(o),u,!1,h,p)},_e.prototype.L=function(o,u,h,p){return this.i.add(String(o),u,!0,h,p)};function zr(o,u,h,p){if(u=o.i.g[String(u)],!u)return!0;u=u.concat();for(var w=!0,b=0;b<u.length;++b){var D=u[b];if(D&&!D.da&&D.capture==h){var Y=D.listener,de=D.ha||D.src;D.fa&&Ii(o.i,D),w=Y.call(de,p)!==!1&&w}}return w&&!p.defaultPrevented}function Fa(o,u,h){if(typeof o=="function")h&&(o=_(o,h));else if(o&&typeof o.handleEvent=="function")o=_(o.handleEvent,o);else throw Error("Invalid listener argument");return 2147483647<Number(u)?-1:c.setTimeout(o,u||0)}function Ba(o){o.g=Fa(()=>{o.g=null,o.i&&(o.i=!1,Ba(o))},o.l);const u=o.h;o.h=null,o.m.apply(null,u)}class bf extends pt{constructor(u,h){super(),this.m=u,this.l=h,this.h=null,this.i=!1,this.g=null}j(u){this.h=arguments,this.g?this.i=!0:Ba(this)}N(){super.N(),this.g&&(c.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Hn(o){pt.call(this),this.h=o,this.g={}}S(Hn,pt);var qa=[];function ja(o){X(o.g,function(u,h){this.g.hasOwnProperty(h)&&bi(u)},o),o.g={}}Hn.prototype.N=function(){Hn.aa.N.call(this),ja(this)},Hn.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Ci=c.JSON.stringify,Pf=c.JSON.parse,Sf=class{stringify(o){return c.JSON.stringify(o,void 0)}parse(o){return c.JSON.parse(o,void 0)}};function ki(){}ki.prototype.h=null;function $a(o){return o.h||(o.h=o.i())}function za(){}var Gn={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function Ni(){ge.call(this,"d")}S(Ni,ge);function Di(){ge.call(this,"c")}S(Di,ge);var jt={},Ha=null;function Hr(){return Ha=Ha||new _e}jt.La="serverreachability";function Ga(o){ge.call(this,jt.La,o)}S(Ga,ge);function Wn(o){const u=Hr();Ae(u,new Ga(u))}jt.STAT_EVENT="statevent";function Wa(o,u){ge.call(this,jt.STAT_EVENT,o),this.stat=u}S(Wa,ge);function Re(o){const u=Hr();Ae(u,new Wa(u,o))}jt.Ma="timingevent";function Ka(o,u){ge.call(this,jt.Ma,o),this.size=u}S(Ka,ge);function Kn(o,u){if(typeof o!="function")throw Error("Fn must not be null and must be a function");return c.setTimeout(function(){o()},u)}function Qn(){this.g=!0}Qn.prototype.xa=function(){this.g=!1};function Cf(o,u,h,p,w,b){o.info(function(){if(o.g)if(b)for(var D="",Y=b.split("&"),de=0;de<Y.length;de++){var K=Y[de].split("=");if(1<K.length){var ye=K[0];K=K[1];var Ee=ye.split("_");D=2<=Ee.length&&Ee[1]=="type"?D+(ye+"="+K+"&"):D+(ye+"=redacted&")}}else D=null;else D=b;return"XMLHTTP REQ ("+p+") [attempt "+w+"]: "+u+`
1636
- `+h+`
1637
- `+D})}function kf(o,u,h,p,w,b,D){o.info(function(){return"XMLHTTP RESP ("+p+") [ attempt "+w+"]: "+u+`
1638
- `+h+`
1639
- `+b+" "+D})}function hn(o,u,h,p){o.info(function(){return"XMLHTTP TEXT ("+u+"): "+Df(o,h)+(p?" "+p:"")})}function Nf(o,u){o.info(function(){return"TIMEOUT: "+u})}Qn.prototype.info=function(){};function Df(o,u){if(!o.g)return u;if(!u)return null;try{var h=JSON.parse(u);if(h){for(o=0;o<h.length;o++)if(Array.isArray(h[o])){var p=h[o];if(!(2>p.length)){var w=p[1];if(Array.isArray(w)&&!(1>w.length)){var b=w[0];if(b!="noop"&&b!="stop"&&b!="close")for(var D=1;D<w.length;D++)w[D]=""}}}}return Ci(h)}catch{return u}}var Gr={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},Qa={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"},Vi;function Wr(){}S(Wr,ki),Wr.prototype.g=function(){return new XMLHttpRequest},Wr.prototype.i=function(){return{}},Vi=new Wr;function mt(o,u,h,p){this.j=o,this.i=u,this.l=h,this.R=p||1,this.U=new Hn(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new Xa}function Xa(){this.i=null,this.g="",this.h=!1}var Ya={},Oi={};function Li(o,u,h){o.L=1,o.v=Yr(et(u)),o.m=h,o.P=!0,Ja(o,null)}function Ja(o,u){o.F=Date.now(),Kr(o),o.A=et(o.v);var h=o.A,p=o.R;Array.isArray(p)||(p=[String(p)]),dc(h.i,"t",p),o.C=0,h=o.j.J,o.h=new Xa,o.g=kc(o.j,h?u:null,!o.m),0<o.O&&(o.M=new bf(_(o.Y,o,o.g),o.O)),u=o.U,h=o.g,p=o.ca;var w="readystatechange";Array.isArray(w)||(w&&(qa[0]=w.toString()),w=qa);for(var b=0;b<w.length;b++){var D=La(h,w[b],p||u.handleEvent,!1,u.h||u);if(!D)break;u.g[D.key]=D}u=o.H?g(o.H):{},o.m?(o.u||(o.u="POST"),u["Content-Type"]="application/x-www-form-urlencoded",o.g.ea(o.A,o.u,o.m,u)):(o.u="GET",o.g.ea(o.A,o.u,null,u)),Wn(),Cf(o.i,o.u,o.A,o.l,o.R,o.m)}mt.prototype.ca=function(o){o=o.target;const u=this.M;u&&tt(o)==3?u.j():this.Y(o)},mt.prototype.Y=function(o){try{if(o==this.g)e:{const Ee=tt(this.g);var u=this.g.Ba();const pn=this.g.Z();if(!(3>Ee)&&(Ee!=3||this.g&&(this.h.h||this.g.oa()||Ec(this.g)))){this.J||Ee!=4||u==7||(u==8||0>=pn?Wn(3):Wn(2)),xi(this);var h=this.g.Z();this.X=h;t:if(Za(this)){var p=Ec(this.g);o="";var w=p.length,b=tt(this.g)==4;if(!this.h.i){if(typeof TextDecoder>"u"){$t(this),Xn(this);var D="";break t}this.h.i=new c.TextDecoder}for(u=0;u<w;u++)this.h.h=!0,o+=this.h.i.decode(p[u],{stream:!(b&&u==w-1)});p.length=0,this.h.g+=o,this.C=0,D=this.h.g}else D=this.g.oa();if(this.o=h==200,kf(this.i,this.u,this.A,this.l,this.R,Ee,h),this.o){if(this.T&&!this.K){t:{if(this.g){var Y,de=this.g;if((Y=de.g?de.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!M(Y)){var K=Y;break t}}K=null}if(h=K)hn(this.i,this.l,h,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Mi(this,h);else{this.o=!1,this.s=3,Re(12),$t(this),Xn(this);break e}}if(this.P){h=!0;let Me;for(;!this.J&&this.C<D.length;)if(Me=Vf(this,D),Me==Oi){Ee==4&&(this.s=4,Re(14),h=!1),hn(this.i,this.l,null,"[Incomplete Response]");break}else if(Me==Ya){this.s=4,Re(15),hn(this.i,this.l,D,"[Invalid Chunk]"),h=!1;break}else hn(this.i,this.l,Me,null),Mi(this,Me);if(Za(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),Ee!=4||D.length!=0||this.h.h||(this.s=1,Re(16),h=!1),this.o=this.o&&h,!h)hn(this.i,this.l,D,"[Invalid Chunked Response]"),$t(this),Xn(this);else if(0<D.length&&!this.W){this.W=!0;var ye=this.j;ye.g==this&&ye.ba&&!ye.M&&(ye.j.info("Great, no buffering proxy detected. Bytes received: "+D.length),$i(ye),ye.M=!0,Re(11))}}else hn(this.i,this.l,D,null),Mi(this,D);Ee==4&&$t(this),this.o&&!this.J&&(Ee==4?bc(this.j,this):(this.o=!1,Kr(this)))}else Xf(this.g),h==400&&0<D.indexOf("Unknown SID")?(this.s=3,Re(12)):(this.s=0,Re(13)),$t(this),Xn(this)}}}catch{}finally{}};function Za(o){return o.g?o.u=="GET"&&o.L!=2&&o.j.Ca:!1}function Vf(o,u){var h=o.C,p=u.indexOf(`
1640
- `,h);return p==-1?Oi:(h=Number(u.substring(h,p)),isNaN(h)?Ya:(p+=1,p+h>u.length?Oi:(u=u.slice(p,p+h),o.C=p+h,u)))}mt.prototype.cancel=function(){this.J=!0,$t(this)};function Kr(o){o.S=Date.now()+o.I,ec(o,o.I)}function ec(o,u){if(o.B!=null)throw Error("WatchDog timer not null");o.B=Kn(_(o.ba,o),u)}function xi(o){o.B&&(c.clearTimeout(o.B),o.B=null)}mt.prototype.ba=function(){this.B=null;const o=Date.now();0<=o-this.S?(Nf(this.i,this.A),this.L!=2&&(Wn(),Re(17)),$t(this),this.s=2,Xn(this)):ec(this,this.S-o)};function Xn(o){o.j.G==0||o.J||bc(o.j,o)}function $t(o){xi(o);var u=o.M;u&&typeof u.ma=="function"&&u.ma(),o.M=null,ja(o.U),o.g&&(u=o.g,o.g=null,u.abort(),u.ma())}function Mi(o,u){try{var h=o.j;if(h.G!=0&&(h.g==o||Ui(h.h,o))){if(!o.K&&Ui(h.h,o)&&h.G==3){try{var p=h.Da.g.parse(u)}catch{p=null}if(Array.isArray(p)&&p.length==3){var w=p;if(w[0]==0){e:if(!h.u){if(h.g)if(h.g.F+3e3<o.F)rs(h),ts(h);else break e;ji(h),Re(18)}}else h.za=w[1],0<h.za-h.T&&37500>w[2]&&h.F&&h.v==0&&!h.C&&(h.C=Kn(_(h.Za,h),6e3));if(1>=rc(h.h)&&h.ca){try{h.ca()}catch{}h.ca=void 0}}else Ht(h,11)}else if((o.K||h.g==o)&&rs(h),!M(u))for(w=h.Da.g.parse(u),u=0;u<w.length;u++){let K=w[u];if(h.T=K[0],K=K[1],h.G==2)if(K[0]=="c"){h.K=K[1],h.ia=K[2];const ye=K[3];ye!=null&&(h.la=ye,h.j.info("VER="+h.la));const Ee=K[4];Ee!=null&&(h.Aa=Ee,h.j.info("SVER="+h.Aa));const pn=K[5];pn!=null&&typeof pn=="number"&&0<pn&&(p=1.5*pn,h.L=p,h.j.info("backChannelRequestTimeoutMs_="+p)),p=h;const Me=o.g;if(Me){const is=Me.g?Me.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(is){var b=p.h;b.g||is.indexOf("spdy")==-1&&is.indexOf("quic")==-1&&is.indexOf("h2")==-1||(b.j=b.l,b.g=new Set,b.h&&(Fi(b,b.h),b.h=null))}if(p.D){const zi=Me.g?Me.g.getResponseHeader("X-HTTP-Session-Id"):null;zi&&(p.ya=zi,ee(p.I,p.D,zi))}}h.G=3,h.l&&h.l.ua(),h.ba&&(h.R=Date.now()-o.F,h.j.info("Handshake RTT: "+h.R+"ms")),p=h;var D=o;if(p.qa=Cc(p,p.J?p.ia:null,p.W),D.K){sc(p.h,D);var Y=D,de=p.L;de&&(Y.I=de),Y.B&&(xi(Y),Kr(Y)),p.g=D}else Ac(p);0<h.i.length&&ns(h)}else K[0]!="stop"&&K[0]!="close"||Ht(h,7);else h.G==3&&(K[0]=="stop"||K[0]=="close"?K[0]=="stop"?Ht(h,7):qi(h):K[0]!="noop"&&h.l&&h.l.ta(K),h.v=0)}}Wn(4)}catch{}}var Of=class{constructor(o,u){this.g=o,this.map=u}};function tc(o){this.l=o||10,c.PerformanceNavigationTiming?(o=c.performance.getEntriesByType("navigation"),o=0<o.length&&(o[0].nextHopProtocol=="hq"||o[0].nextHopProtocol=="h2")):o=!!(c.chrome&&c.chrome.loadTimes&&c.chrome.loadTimes()&&c.chrome.loadTimes().wasFetchedViaSpdy),this.j=o?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function nc(o){return o.h?!0:o.g?o.g.size>=o.j:!1}function rc(o){return o.h?1:o.g?o.g.size:0}function Ui(o,u){return o.h?o.h==u:o.g?o.g.has(u):!1}function Fi(o,u){o.g?o.g.add(u):o.h=u}function sc(o,u){o.h&&o.h==u?o.h=null:o.g&&o.g.has(u)&&o.g.delete(u)}tc.prototype.cancel=function(){if(this.i=ic(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const o of this.g.values())o.cancel();this.g.clear()}};function ic(o){if(o.h!=null)return o.i.concat(o.h.D);if(o.g!=null&&o.g.size!==0){let u=o.i;for(const h of o.g.values())u=u.concat(h.D);return u}return N(o.i)}function Lf(o){if(o.V&&typeof o.V=="function")return o.V();if(typeof Map<"u"&&o instanceof Map||typeof Set<"u"&&o instanceof Set)return Array.from(o.values());if(typeof o=="string")return o.split("");if(l(o)){for(var u=[],h=o.length,p=0;p<h;p++)u.push(o[p]);return u}u=[],h=0;for(p in o)u[h++]=o[p];return u}function xf(o){if(o.na&&typeof o.na=="function")return o.na();if(!o.V||typeof o.V!="function"){if(typeof Map<"u"&&o instanceof Map)return Array.from(o.keys());if(!(typeof Set<"u"&&o instanceof Set)){if(l(o)||typeof o=="string"){var u=[];o=o.length;for(var h=0;h<o;h++)u.push(h);return u}u=[],h=0;for(const p in o)u[h++]=p;return u}}}function oc(o,u){if(o.forEach&&typeof o.forEach=="function")o.forEach(u,void 0);else if(l(o)||typeof o=="string")Array.prototype.forEach.call(o,u,void 0);else for(var h=xf(o),p=Lf(o),w=p.length,b=0;b<w;b++)u.call(void 0,p[b],h&&h[b],o)}var ac=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function Mf(o,u){if(o){o=o.split("&");for(var h=0;h<o.length;h++){var p=o[h].indexOf("="),w=null;if(0<=p){var b=o[h].substring(0,p);w=o[h].substring(p+1)}else b=o[h];u(b,w?decodeURIComponent(w.replace(/\+/g," ")):"")}}}function zt(o){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,o instanceof zt){this.h=o.h,Qr(this,o.j),this.o=o.o,this.g=o.g,Xr(this,o.s),this.l=o.l;var u=o.i,h=new Zn;h.i=u.i,u.g&&(h.g=new Map(u.g),h.h=u.h),cc(this,h),this.m=o.m}else o&&(u=String(o).match(ac))?(this.h=!1,Qr(this,u[1]||"",!0),this.o=Yn(u[2]||""),this.g=Yn(u[3]||"",!0),Xr(this,u[4]),this.l=Yn(u[5]||"",!0),cc(this,u[6]||"",!0),this.m=Yn(u[7]||"")):(this.h=!1,this.i=new Zn(null,this.h))}zt.prototype.toString=function(){var o=[],u=this.j;u&&o.push(Jn(u,uc,!0),":");var h=this.g;return(h||u=="file")&&(o.push("//"),(u=this.o)&&o.push(Jn(u,uc,!0),"@"),o.push(encodeURIComponent(String(h)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),h=this.s,h!=null&&o.push(":",String(h))),(h=this.l)&&(this.g&&h.charAt(0)!="/"&&o.push("/"),o.push(Jn(h,h.charAt(0)=="/"?Bf:Ff,!0))),(h=this.i.toString())&&o.push("?",h),(h=this.m)&&o.push("#",Jn(h,jf)),o.join("")};function et(o){return new zt(o)}function Qr(o,u,h){o.j=h?Yn(u,!0):u,o.j&&(o.j=o.j.replace(/:$/,""))}function Xr(o,u){if(u){if(u=Number(u),isNaN(u)||0>u)throw Error("Bad port number "+u);o.s=u}else o.s=null}function cc(o,u,h){u instanceof Zn?(o.i=u,$f(o.i,o.h)):(h||(u=Jn(u,qf)),o.i=new Zn(u,o.h))}function ee(o,u,h){o.i.set(u,h)}function Yr(o){return ee(o,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),o}function Yn(o,u){return o?u?decodeURI(o.replace(/%25/g,"%2525")):decodeURIComponent(o):""}function Jn(o,u,h){return typeof o=="string"?(o=encodeURI(o).replace(u,Uf),h&&(o=o.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),o):null}function Uf(o){return o=o.charCodeAt(0),"%"+(o>>4&15).toString(16)+(o&15).toString(16)}var uc=/[#\/\?@]/g,Ff=/[#\?:]/g,Bf=/[#\?]/g,qf=/[#\?@]/g,jf=/#/g;function Zn(o,u){this.h=this.g=null,this.i=o||null,this.j=!!u}function gt(o){o.g||(o.g=new Map,o.h=0,o.i&&Mf(o.i,function(u,h){o.add(decodeURIComponent(u.replace(/\+/g," ")),h)}))}n=Zn.prototype,n.add=function(o,u){gt(this),this.i=null,o=dn(this,o);var h=this.g.get(o);return h||this.g.set(o,h=[]),h.push(u),this.h+=1,this};function lc(o,u){gt(o),u=dn(o,u),o.g.has(u)&&(o.i=null,o.h-=o.g.get(u).length,o.g.delete(u))}function hc(o,u){return gt(o),u=dn(o,u),o.g.has(u)}n.forEach=function(o,u){gt(this),this.g.forEach(function(h,p){h.forEach(function(w){o.call(u,w,p,this)},this)},this)},n.na=function(){gt(this);const o=Array.from(this.g.values()),u=Array.from(this.g.keys()),h=[];for(let p=0;p<u.length;p++){const w=o[p];for(let b=0;b<w.length;b++)h.push(u[p])}return h},n.V=function(o){gt(this);let u=[];if(typeof o=="string")hc(this,o)&&(u=u.concat(this.g.get(dn(this,o))));else{o=Array.from(this.g.values());for(let h=0;h<o.length;h++)u=u.concat(o[h])}return u},n.set=function(o,u){return gt(this),this.i=null,o=dn(this,o),hc(this,o)&&(this.h-=this.g.get(o).length),this.g.set(o,[u]),this.h+=1,this},n.get=function(o,u){return o?(o=this.V(o),0<o.length?String(o[0]):u):u};function dc(o,u,h){lc(o,u),0<h.length&&(o.i=null,o.g.set(dn(o,u),N(h)),o.h+=h.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const o=[],u=Array.from(this.g.keys());for(var h=0;h<u.length;h++){var p=u[h];const b=encodeURIComponent(String(p)),D=this.V(p);for(p=0;p<D.length;p++){var w=b;D[p]!==""&&(w+="="+encodeURIComponent(String(D[p]))),o.push(w)}}return this.i=o.join("&")};function dn(o,u){return u=String(u),o.j&&(u=u.toLowerCase()),u}function $f(o,u){u&&!o.j&&(gt(o),o.i=null,o.g.forEach(function(h,p){var w=p.toLowerCase();p!=w&&(lc(this,p),dc(this,w,h))},o)),o.j=u}function zf(o,u){const h=new Qn;if(c.Image){const p=new Image;p.onload=R(_t,h,"TestLoadImage: loaded",!0,u,p),p.onerror=R(_t,h,"TestLoadImage: error",!1,u,p),p.onabort=R(_t,h,"TestLoadImage: abort",!1,u,p),p.ontimeout=R(_t,h,"TestLoadImage: timeout",!1,u,p),c.setTimeout(function(){p.ontimeout&&p.ontimeout()},1e4),p.src=o}else u(!1)}function Hf(o,u){const h=new Qn,p=new AbortController,w=setTimeout(()=>{p.abort(),_t(h,"TestPingServer: timeout",!1,u)},1e4);fetch(o,{signal:p.signal}).then(b=>{clearTimeout(w),b.ok?_t(h,"TestPingServer: ok",!0,u):_t(h,"TestPingServer: server error",!1,u)}).catch(()=>{clearTimeout(w),_t(h,"TestPingServer: error",!1,u)})}function _t(o,u,h,p,w){try{w&&(w.onload=null,w.onerror=null,w.onabort=null,w.ontimeout=null),p(h)}catch{}}function Gf(){this.g=new Sf}function Wf(o,u,h){const p=h||"";try{oc(o,function(w,b){let D=w;d(w)&&(D=Ci(w)),u.push(p+b+"="+encodeURIComponent(D))})}catch(w){throw u.push(p+"type="+encodeURIComponent("_badmap")),w}}function Jr(o){this.l=o.Ub||null,this.j=o.eb||!1}S(Jr,ki),Jr.prototype.g=function(){return new Zr(this.l,this.j)},Jr.prototype.i=function(o){return function(){return o}}({});function Zr(o,u){_e.call(this),this.D=o,this.o=u,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}S(Zr,_e),n=Zr.prototype,n.open=function(o,u){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.B=o,this.A=u,this.readyState=1,tr(this)},n.send=function(o){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");this.g=!0;const u={headers:this.u,method:this.B,credentials:this.m,cache:void 0};o&&(u.body=o),(this.D||c).fetch(new Request(this.A,u)).then(this.Sa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&this.readyState!=4&&(this.g=!1,er(this)),this.readyState=0},n.Sa=function(o){if(this.g&&(this.l=o,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=o.headers,this.readyState=2,tr(this)),this.g&&(this.readyState=3,tr(this),this.g)))if(this.responseType==="arraybuffer")o.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(typeof c.ReadableStream<"u"&&"body"in o){if(this.j=o.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;fc(this)}else o.text().then(this.Ra.bind(this),this.ga.bind(this))};function fc(o){o.j.read().then(o.Pa.bind(o)).catch(o.ga.bind(o))}n.Pa=function(o){if(this.g){if(this.o&&o.value)this.response.push(o.value);else if(!this.o){var u=o.value?o.value:new Uint8Array(0);(u=this.v.decode(u,{stream:!o.done}))&&(this.response=this.responseText+=u)}o.done?er(this):tr(this),this.readyState==3&&fc(this)}},n.Ra=function(o){this.g&&(this.response=this.responseText=o,er(this))},n.Qa=function(o){this.g&&(this.response=o,er(this))},n.ga=function(){this.g&&er(this)};function er(o){o.readyState=4,o.l=null,o.j=null,o.v=null,tr(o)}n.setRequestHeader=function(o,u){this.u.append(o,u)},n.getResponseHeader=function(o){return this.h&&this.h.get(o.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const o=[],u=this.h.entries();for(var h=u.next();!h.done;)h=h.value,o.push(h[0]+": "+h[1]),h=u.next();return o.join(`\r
1641
- `)};function tr(o){o.onreadystatechange&&o.onreadystatechange.call(o)}Object.defineProperty(Zr.prototype,"withCredentials",{get:function(){return this.m==="include"},set:function(o){this.m=o?"include":"same-origin"}});function pc(o){let u="";return X(o,function(h,p){u+=p,u+=":",u+=h,u+=`\r
1642
- `}),u}function Bi(o,u,h){e:{for(p in h){var p=!1;break e}p=!0}p||(h=pc(h),typeof o=="string"?h!=null&&encodeURIComponent(String(h)):ee(o,u,h))}function se(o){_e.call(this),this.headers=new Map,this.o=o||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}S(se,_e);var Kf=/^https?$/i,Qf=["POST","PUT"];n=se.prototype,n.Ha=function(o){this.J=o},n.ea=function(o,u,h,p){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+o);u=u?u.toUpperCase():"GET",this.D=o,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Vi.g(),this.v=this.o?$a(this.o):$a(Vi),this.g.onreadystatechange=_(this.Ea,this);try{this.B=!0,this.g.open(u,String(o),!0),this.B=!1}catch(b){mc(this,b);return}if(o=h||"",h=new Map(this.headers),p)if(Object.getPrototypeOf(p)===Object.prototype)for(var w in p)h.set(w,p[w]);else if(typeof p.keys=="function"&&typeof p.get=="function")for(const b of p.keys())h.set(b,p.get(b));else throw Error("Unknown input type for opt_headers: "+String(p));p=Array.from(h.keys()).find(b=>b.toLowerCase()=="content-type"),w=c.FormData&&o instanceof c.FormData,!(0<=Array.prototype.indexOf.call(Qf,u,void 0))||p||w||h.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[b,D]of h)this.g.setRequestHeader(b,D);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{yc(this),this.u=!0,this.g.send(o),this.u=!1}catch(b){mc(this,b)}};function mc(o,u){o.h=!1,o.g&&(o.j=!0,o.g.abort(),o.j=!1),o.l=u,o.m=5,gc(o),es(o)}function gc(o){o.A||(o.A=!0,Ae(o,"complete"),Ae(o,"error"))}n.abort=function(o){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=o||7,Ae(this,"complete"),Ae(this,"abort"),es(this))},n.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),es(this,!0)),se.aa.N.call(this)},n.Ea=function(){this.s||(this.B||this.u||this.j?_c(this):this.bb())},n.bb=function(){_c(this)};function _c(o){if(o.h&&typeof a<"u"&&(!o.v[1]||tt(o)!=4||o.Z()!=2)){if(o.u&&tt(o)==4)Fa(o.Ea,0,o);else if(Ae(o,"readystatechange"),tt(o)==4){o.h=!1;try{const D=o.Z();e:switch(D){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var u=!0;break e;default:u=!1}var h;if(!(h=u)){var p;if(p=D===0){var w=String(o.D).match(ac)[1]||null;!w&&c.self&&c.self.location&&(w=c.self.location.protocol.slice(0,-1)),p=!Kf.test(w?w.toLowerCase():"")}h=p}if(h)Ae(o,"complete"),Ae(o,"success");else{o.m=6;try{var b=2<tt(o)?o.g.statusText:""}catch{b=""}o.l=b+" ["+o.Z()+"]",gc(o)}}finally{es(o)}}}}function es(o,u){if(o.g){yc(o);const h=o.g,p=o.v[0]?()=>{}:null;o.g=null,o.v=null,u||Ae(o,"ready");try{h.onreadystatechange=p}catch{}}}function yc(o){o.I&&(c.clearTimeout(o.I),o.I=null)}n.isActive=function(){return!!this.g};function tt(o){return o.g?o.g.readyState:0}n.Z=function(){try{return 2<tt(this)?this.g.status:-1}catch{return-1}},n.oa=function(){try{return this.g?this.g.responseText:""}catch{return""}},n.Oa=function(o){if(this.g){var u=this.g.responseText;return o&&u.indexOf(o)==0&&(u=u.substring(o.length)),Pf(u)}};function Ec(o){try{if(!o.g)return null;if("response"in o.g)return o.g.response;switch(o.H){case"":case"text":return o.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in o.g)return o.g.mozResponseArrayBuffer}return null}catch{return null}}function Xf(o){const u={};o=(o.g&&2<=tt(o)&&o.g.getAllResponseHeaders()||"").split(`\r
1643
- `);for(let p=0;p<o.length;p++){if(M(o[p]))continue;var h=I(o[p]);const w=h[0];if(h=h[1],typeof h!="string")continue;h=h.trim();const b=u[w]||[];u[w]=b,b.push(h)}v(u,function(p){return p.join(", ")})}n.Ba=function(){return this.m},n.Ka=function(){return typeof this.l=="string"?this.l:String(this.l)};function nr(o,u,h){return h&&h.internalChannelParams&&h.internalChannelParams[o]||u}function Tc(o){this.Aa=0,this.i=[],this.j=new Qn,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=nr("failFast",!1,o),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=nr("baseRetryDelayMs",5e3,o),this.cb=nr("retryDelaySeedMs",1e4,o),this.Wa=nr("forwardChannelMaxRetries",2,o),this.wa=nr("forwardChannelRequestTimeoutMs",2e4,o),this.pa=o&&o.xmlHttpFactory||void 0,this.Xa=o&&o.Tb||void 0,this.Ca=o&&o.useFetchStreams||!1,this.L=void 0,this.J=o&&o.supportsCrossDomainXhr||!1,this.K="",this.h=new tc(o&&o.concurrentRequestLimit),this.Da=new Gf,this.P=o&&o.fastHandshake||!1,this.O=o&&o.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=o&&o.Rb||!1,o&&o.xa&&this.j.xa(),o&&o.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&o&&o.detectBufferingProxy||!1,this.ja=void 0,o&&o.longPollingTimeout&&0<o.longPollingTimeout&&(this.ja=o.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}n=Tc.prototype,n.la=8,n.G=1,n.connect=function(o,u,h,p){Re(0),this.W=o,this.H=u||{},h&&p!==void 0&&(this.H.OSID=h,this.H.OAID=p),this.F=this.X,this.I=Cc(this,null,this.W),ns(this)};function qi(o){if(vc(o),o.G==3){var u=o.U++,h=et(o.I);if(ee(h,"SID",o.K),ee(h,"RID",u),ee(h,"TYPE","terminate"),rr(o,h),u=new mt(o,o.j,u),u.L=2,u.v=Yr(et(h)),h=!1,c.navigator&&c.navigator.sendBeacon)try{h=c.navigator.sendBeacon(u.v.toString(),"")}catch{}!h&&c.Image&&(new Image().src=u.v,h=!0),h||(u.g=kc(u.j,null),u.g.ea(u.v)),u.F=Date.now(),Kr(u)}Sc(o)}function ts(o){o.g&&($i(o),o.g.cancel(),o.g=null)}function vc(o){ts(o),o.u&&(c.clearTimeout(o.u),o.u=null),rs(o),o.h.cancel(),o.s&&(typeof o.s=="number"&&c.clearTimeout(o.s),o.s=null)}function ns(o){if(!nc(o.h)&&!o.s){o.s=!0;var u=o.Ga;jn||Oa(),$n||(jn(),$n=!0),vi.add(u,o),o.B=0}}function Yf(o,u){return rc(o.h)>=o.h.j-(o.s?1:0)?!1:o.s?(o.i=u.D.concat(o.i),!0):o.G==1||o.G==2||o.B>=(o.Va?0:o.Wa)?!1:(o.s=Kn(_(o.Ga,o,u),Pc(o,o.B)),o.B++,!0)}n.Ga=function(o){if(this.s)if(this.s=null,this.G==1){if(!o){this.U=Math.floor(1e5*Math.random()),o=this.U++;const w=new mt(this,this.j,o);let b=this.o;if(this.S&&(b?(b=g(b),T(b,this.S)):b=this.S),this.m!==null||this.O||(w.H=b,b=null),this.P)e:{for(var u=0,h=0;h<this.i.length;h++){t:{var p=this.i[h];if("__data__"in p.map&&(p=p.map.__data__,typeof p=="string")){p=p.length;break t}p=void 0}if(p===void 0)break;if(u+=p,4096<u){u=h;break e}if(u===4096||h===this.i.length-1){u=h+1;break e}}u=1e3}else u=1e3;u=wc(this,w,u),h=et(this.I),ee(h,"RID",o),ee(h,"CVER",22),this.D&&ee(h,"X-HTTP-Session-Id",this.D),rr(this,h),b&&(this.O?u="headers="+encodeURIComponent(String(pc(b)))+"&"+u:this.m&&Bi(h,this.m,b)),Fi(this.h,w),this.Ua&&ee(h,"TYPE","init"),this.P?(ee(h,"$req",u),ee(h,"SID","null"),w.T=!0,Li(w,h,null)):Li(w,h,u),this.G=2}}else this.G==3&&(o?Ic(this,o):this.i.length==0||nc(this.h)||Ic(this))};function Ic(o,u){var h;u?h=u.l:h=o.U++;const p=et(o.I);ee(p,"SID",o.K),ee(p,"RID",h),ee(p,"AID",o.T),rr(o,p),o.m&&o.o&&Bi(p,o.m,o.o),h=new mt(o,o.j,h,o.B+1),o.m===null&&(h.H=o.o),u&&(o.i=u.D.concat(o.i)),u=wc(o,h,1e3),h.I=Math.round(.5*o.wa)+Math.round(.5*o.wa*Math.random()),Fi(o.h,h),Li(h,p,u)}function rr(o,u){o.H&&X(o.H,function(h,p){ee(u,p,h)}),o.l&&oc({},function(h,p){ee(u,p,h)})}function wc(o,u,h){h=Math.min(o.i.length,h);var p=o.l?_(o.l.Na,o.l,o):null;e:{var w=o.i;let b=-1;for(;;){const D=["count="+h];b==-1?0<h?(b=w[0].g,D.push("ofs="+b)):b=0:D.push("ofs="+b);let Y=!0;for(let de=0;de<h;de++){let K=w[de].g;const ye=w[de].map;if(K-=b,0>K)b=Math.max(0,w[de].g-100),Y=!1;else try{Wf(ye,D,"req"+K+"_")}catch{p&&p(ye)}}if(Y){p=D.join("&");break e}}}return o=o.i.splice(0,h),u.D=o,p}function Ac(o){if(!o.g&&!o.u){o.Y=1;var u=o.Fa;jn||Oa(),$n||(jn(),$n=!0),vi.add(u,o),o.v=0}}function ji(o){return o.g||o.u||3<=o.v?!1:(o.Y++,o.u=Kn(_(o.Fa,o),Pc(o,o.v)),o.v++,!0)}n.Fa=function(){if(this.u=null,Rc(this),this.ba&&!(this.M||this.g==null||0>=this.R)){var o=2*this.R;this.j.info("BP detection timer enabled: "+o),this.A=Kn(_(this.ab,this),o)}},n.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,Re(10),ts(this),Rc(this))};function $i(o){o.A!=null&&(c.clearTimeout(o.A),o.A=null)}function Rc(o){o.g=new mt(o,o.j,"rpc",o.Y),o.m===null&&(o.g.H=o.o),o.g.O=0;var u=et(o.qa);ee(u,"RID","rpc"),ee(u,"SID",o.K),ee(u,"AID",o.T),ee(u,"CI",o.F?"0":"1"),!o.F&&o.ja&&ee(u,"TO",o.ja),ee(u,"TYPE","xmlhttp"),rr(o,u),o.m&&o.o&&Bi(u,o.m,o.o),o.L&&(o.g.I=o.L);var h=o.g;o=o.ia,h.L=1,h.v=Yr(et(u)),h.m=null,h.P=!0,Ja(h,o)}n.Za=function(){this.C!=null&&(this.C=null,ts(this),ji(this),Re(19))};function rs(o){o.C!=null&&(c.clearTimeout(o.C),o.C=null)}function bc(o,u){var h=null;if(o.g==u){rs(o),$i(o),o.g=null;var p=2}else if(Ui(o.h,u))h=u.D,sc(o.h,u),p=1;else return;if(o.G!=0){if(u.o)if(p==1){h=u.m?u.m.length:0,u=Date.now()-u.F;var w=o.B;p=Hr(),Ae(p,new Ka(p,h)),ns(o)}else Ac(o);else if(w=u.s,w==3||w==0&&0<u.X||!(p==1&&Yf(o,u)||p==2&&ji(o)))switch(h&&0<h.length&&(u=o.h,u.i=u.i.concat(h)),w){case 1:Ht(o,5);break;case 4:Ht(o,10);break;case 3:Ht(o,6);break;default:Ht(o,2)}}}function Pc(o,u){let h=o.Ta+Math.floor(Math.random()*o.cb);return o.isActive()||(h*=2),h*u}function Ht(o,u){if(o.j.info("Error code "+u),u==2){var h=_(o.fb,o),p=o.Xa;const w=!p;p=new zt(p||"//www.google.com/images/cleardot.gif"),c.location&&c.location.protocol=="http"||Qr(p,"https"),Yr(p),w?zf(p.toString(),h):Hf(p.toString(),h)}else Re(2);o.G=0,o.l&&o.l.sa(u),Sc(o),vc(o)}n.fb=function(o){o?(this.j.info("Successfully pinged google.com"),Re(2)):(this.j.info("Failed to ping google.com"),Re(1))};function Sc(o){if(o.G=0,o.ka=[],o.l){const u=ic(o.h);(u.length!=0||o.i.length!=0)&&(k(o.ka,u),k(o.ka,o.i),o.h.i.length=0,N(o.i),o.i.length=0),o.l.ra()}}function Cc(o,u,h){var p=h instanceof zt?et(h):new zt(h);if(p.g!="")u&&(p.g=u+"."+p.g),Xr(p,p.s);else{var w=c.location;p=w.protocol,u=u?u+"."+w.hostname:w.hostname,w=+w.port;var b=new zt(null);p&&Qr(b,p),u&&(b.g=u),w&&Xr(b,w),h&&(b.l=h),p=b}return h=o.D,u=o.ya,h&&u&&ee(p,h,u),ee(p,"VER",o.la),rr(o,p),p}function kc(o,u,h){if(u&&!o.J)throw Error("Can't create secondary domain capable XhrIo object.");return u=o.Ca&&!o.pa?new se(new Jr({eb:h})):new se(o.pa),u.Ha(o.J),u}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function Nc(){}n=Nc.prototype,n.ua=function(){},n.ta=function(){},n.sa=function(){},n.ra=function(){},n.isActive=function(){return!0},n.Na=function(){};function ss(){}ss.prototype.g=function(o,u){return new De(o,u)};function De(o,u){_e.call(this),this.g=new Tc(u),this.l=o,this.h=u&&u.messageUrlParams||null,o=u&&u.messageHeaders||null,u&&u.clientProtocolHeaderRequired&&(o?o["X-Client-Protocol"]="webchannel":o={"X-Client-Protocol":"webchannel"}),this.g.o=o,o=u&&u.initMessageHeaders||null,u&&u.messageContentType&&(o?o["X-WebChannel-Content-Type"]=u.messageContentType:o={"X-WebChannel-Content-Type":u.messageContentType}),u&&u.va&&(o?o["X-WebChannel-Client-Profile"]=u.va:o={"X-WebChannel-Client-Profile":u.va}),this.g.S=o,(o=u&&u.Sb)&&!M(o)&&(this.g.m=o),this.v=u&&u.supportsCrossDomainXhr||!1,this.u=u&&u.sendRawJson||!1,(u=u&&u.httpSessionIdParam)&&!M(u)&&(this.g.D=u,o=this.h,o!==null&&u in o&&(o=this.h,u in o&&delete o[u])),this.j=new fn(this)}S(De,_e),De.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},De.prototype.close=function(){qi(this.g)},De.prototype.o=function(o){var u=this.g;if(typeof o=="string"){var h={};h.__data__=o,o=h}else this.u&&(h={},h.__data__=Ci(o),o=h);u.i.push(new Of(u.Ya++,o)),u.G==3&&ns(u)},De.prototype.N=function(){this.g.l=null,delete this.j,qi(this.g),delete this.g,De.aa.N.call(this)};function Dc(o){Ni.call(this),o.__headers__&&(this.headers=o.__headers__,this.statusCode=o.__status__,delete o.__headers__,delete o.__status__);var u=o.__sm__;if(u){e:{for(const h in u){o=h;break e}o=void 0}(this.i=o)&&(o=this.i,u=u!==null&&o in u?u[o]:void 0),this.data=u}else this.data=o}S(Dc,Ni);function Vc(){Di.call(this),this.status=1}S(Vc,Di);function fn(o){this.g=o}S(fn,Nc),fn.prototype.ua=function(){Ae(this.g,"a")},fn.prototype.ta=function(o){Ae(this.g,new Dc(o))},fn.prototype.sa=function(o){Ae(this.g,new Vc)},fn.prototype.ra=function(){Ae(this.g,"b")},ss.prototype.createWebChannel=ss.prototype.g,De.prototype.send=De.prototype.o,De.prototype.open=De.prototype.m,De.prototype.close=De.prototype.close,fh=function(){return new ss},dh=function(){return Hr()},hh=jt,uo={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},Gr.NO_ERROR=0,Gr.TIMEOUT=8,Gr.HTTP_ERROR=6,ys=Gr,Qa.COMPLETE="complete",lh=Qa,za.EventType=Gn,Gn.OPEN="a",Gn.CLOSE="b",Gn.ERROR="c",Gn.MESSAGE="d",_e.prototype.listen=_e.prototype.K,cr=za,se.prototype.listenOnce=se.prototype.L,se.prototype.getLastError=se.prototype.Ka,se.prototype.getLastErrorCode=se.prototype.Ba,se.prototype.getStatus=se.prototype.Z,se.prototype.getResponseJson=se.prototype.Oa,se.prototype.getResponseText=se.prototype.oa,se.prototype.send=se.prototype.ea,se.prototype.setWithCredentials=se.prototype.Ha,uh=se}).apply(typeof as<"u"?as:typeof self<"u"?self:typeof window<"u"?window:{});const du="@firebase/firestore",fu="4.7.15";/**
1644
- * @license
1645
- * Copyright 2017 Google LLC
1646
- *
1647
- * Licensed under the Apache License, Version 2.0 (the "License");
1648
- * you may not use this file except in compliance with the License.
1649
- * You may obtain a copy of the License at
1650
- *
1651
- * http://www.apache.org/licenses/LICENSE-2.0
1652
- *
1653
- * Unless required by applicable law or agreed to in writing, software
1654
- * distributed under the License is distributed on an "AS IS" BASIS,
1655
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1656
- * See the License for the specific language governing permissions and
1657
- * limitations under the License.
1658
- */class ve{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}}ve.UNAUTHENTICATED=new ve(null),ve.GOOGLE_CREDENTIALS=new ve("google-credentials-uid"),ve.FIRST_PARTY=new ve("first-party-uid"),ve.MOCK_USER=new ve("mock-user");/**
1659
- * @license
1660
- * Copyright 2017 Google LLC
1661
- *
1662
- * Licensed under the Apache License, Version 2.0 (the "License");
1663
- * you may not use this file except in compliance with the License.
1664
- * You may obtain a copy of the License at
1665
- *
1666
- * http://www.apache.org/licenses/LICENSE-2.0
1667
- *
1668
- * Unless required by applicable law or agreed to in writing, software
1669
- * distributed under the License is distributed on an "AS IS" BASIS,
1670
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1671
- * See the License for the specific language governing permissions and
1672
- * limitations under the License.
1673
- */let xn="11.8.0";/**
1674
- * @license
1675
- * Copyright 2017 Google LLC
1676
- *
1677
- * Licensed under the Apache License, Version 2.0 (the "License");
1678
- * you may not use this file except in compliance with the License.
1679
- * You may obtain a copy of the License at
1680
- *
1681
- * http://www.apache.org/licenses/LICENSE-2.0
1682
- *
1683
- * Unless required by applicable law or agreed to in writing, software
1684
- * distributed under the License is distributed on an "AS IS" BASIS,
1685
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1686
- * See the License for the specific language governing permissions and
1687
- * limitations under the License.
1688
- */const en=new Co("@firebase/firestore");function gn(){return en.logLevel}function O(n,...e){if(en.logLevel<=H.DEBUG){const t=e.map(qo);en.debug(`Firestore (${xn}): ${n}`,...t)}}function dt(n,...e){if(en.logLevel<=H.ERROR){const t=e.map(qo);en.error(`Firestore (${xn}): ${n}`,...t)}}function Pn(n,...e){if(en.logLevel<=H.WARN){const t=e.map(qo);en.warn(`Firestore (${xn}): ${n}`,...t)}}function qo(n){if(typeof n=="string")return n;try{/**
1689
- * @license
1690
- * Copyright 2020 Google LLC
1691
- *
1692
- * Licensed under the Apache License, Version 2.0 (the "License");
1693
- * you may not use this file except in compliance with the License.
1694
- * You may obtain a copy of the License at
1695
- *
1696
- * http://www.apache.org/licenses/LICENSE-2.0
1697
- *
1698
- * Unless required by applicable law or agreed to in writing, software
1699
- * distributed under the License is distributed on an "AS IS" BASIS,
1700
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1701
- * See the License for the specific language governing permissions and
1702
- * limitations under the License.
1703
- */return function(t){return JSON.stringify(t)}(n)}catch{return n}}/**
1704
- * @license
1705
- * Copyright 2017 Google LLC
1706
- *
1707
- * Licensed under the Apache License, Version 2.0 (the "License");
1708
- * you may not use this file except in compliance with the License.
1709
- * You may obtain a copy of the License at
1710
- *
1711
- * http://www.apache.org/licenses/LICENSE-2.0
1712
- *
1713
- * Unless required by applicable law or agreed to in writing, software
1714
- * distributed under the License is distributed on an "AS IS" BASIS,
1715
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1716
- * See the License for the specific language governing permissions and
1717
- * limitations under the License.
1718
- */function F(n,e,t){let r="Unexpected state";typeof e=="string"?r=e:t=e,ph(n,r,t)}function ph(n,e,t){let r=`FIRESTORE (${xn}) INTERNAL ASSERTION FAILED: ${e} (ID: ${n.toString(16)})`;if(t!==void 0)try{r+=" CONTEXT: "+JSON.stringify(t)}catch{r+=" CONTEXT: "+t}throw dt(r),new Error(r)}function Q(n,e,t,r){let s="Unexpected state";typeof t=="string"?s=t:r=t,n||ph(e,s,r)}function j(n,e){return n}/**
1719
- * @license
1720
- * Copyright 2017 Google LLC
1721
- *
1722
- * Licensed under the Apache License, Version 2.0 (the "License");
1723
- * you may not use this file except in compliance with the License.
1724
- * You may obtain a copy of the License at
1725
- *
1726
- * http://www.apache.org/licenses/LICENSE-2.0
1727
- *
1728
- * Unless required by applicable law or agreed to in writing, software
1729
- * distributed under the License is distributed on an "AS IS" BASIS,
1730
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1731
- * See the License for the specific language governing permissions and
1732
- * limitations under the License.
1733
- */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 ze{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}/**
1734
- * @license
1735
- * Copyright 2017 Google LLC
1736
- *
1737
- * Licensed under the Apache License, Version 2.0 (the "License");
1738
- * you may not use this file except in compliance with the License.
1739
- * You may obtain a copy of the License at
1740
- *
1741
- * http://www.apache.org/licenses/LICENSE-2.0
1742
- *
1743
- * Unless required by applicable law or agreed to in writing, software
1744
- * distributed under the License is distributed on an "AS IS" BASIS,
1745
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1746
- * See the License for the specific language governing permissions and
1747
- * limitations under the License.
1748
- */class at{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}/**
1749
- * @license
1750
- * Copyright 2017 Google LLC
1751
- *
1752
- * Licensed under the Apache License, Version 2.0 (the "License");
1753
- * you may not use this file except in compliance with the License.
1754
- * You may obtain a copy of the License at
1755
- *
1756
- * http://www.apache.org/licenses/LICENSE-2.0
1757
- *
1758
- * Unless required by applicable law or agreed to in writing, software
1759
- * distributed under the License is distributed on an "AS IS" BASIS,
1760
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1761
- * See the License for the specific language governing permissions and
1762
- * limitations under the License.
1763
- */class mh{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class ly{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(ve.UNAUTHENTICATED))}shutdown(){}}class hy{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 dy{constructor(e){this.t=e,this.currentUser=ve.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){Q(this.o===void 0,42304);let r=this.i;const s=l=>this.i!==r?(r=this.i,t(l)):Promise.resolve();let i=new at;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new at,e.enqueueRetryable(()=>s(this.currentUser))};const a=()=>{const l=i;e.enqueueRetryable(async()=>{await l.promise,await s(this.currentUser)})},c=l=>{O("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=l,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit(l=>c(l)),setTimeout(()=>{if(!this.auth){const l=this.t.getImmediate({optional:!0});l?c(l):(O("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new at)}},0),a()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(r=>this.i!==e?(O("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(Q(typeof r.accessToken=="string",31837,{l:r}),new mh(r.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return Q(e===null||typeof e=="string",2055,{h:e}),new ve(e)}}class fy{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=ve.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);const e=this.R();return e&&this.A.set("Authorization",e),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}}class py{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new fy(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(ve.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class pu{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 my{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Pe(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){Q(this.o===void 0,3512);const r=i=>{i.error!=null&&O("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const a=i.token!==this.m;return this.m=i.token,O("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?t(i.token):Promise.resolve()};this.o=i=>{e.enqueueRetryable(()=>r(i))};const s=i=>{O("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(i=>s(i)),setTimeout(()=>{if(!this.appCheck){const i=this.V.getImmediate({optional:!0});i?s(i):O("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new pu(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(Q(typeof t.token=="string",44558,{tokenResult:t}),this.m=t.token,new pu(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}/**
1764
- * @license
1765
- * Copyright 2020 Google LLC
1766
- *
1767
- * Licensed under the Apache License, Version 2.0 (the "License");
1768
- * you may not use this file except in compliance with the License.
1769
- * You may obtain a copy of the License at
1770
- *
1771
- * http://www.apache.org/licenses/LICENSE-2.0
1772
- *
1773
- * Unless required by applicable law or agreed to in writing, software
1774
- * distributed under the License is distributed on an "AS IS" BASIS,
1775
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1776
- * See the License for the specific language governing permissions and
1777
- * limitations under the License.
1778
- */function gy(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 r=0;r<n;r++)t[r]=Math.floor(256*Math.random());return t}/**
1779
- * @license
1780
- * Copyright 2023 Google LLC
1781
- *
1782
- * Licensed under the Apache License, Version 2.0 (the "License");
1783
- * you may not use this file except in compliance with the License.
1784
- * You may obtain a copy of the License at
1785
- *
1786
- * http://www.apache.org/licenses/LICENSE-2.0
1787
- *
1788
- * Unless required by applicable law or agreed to in writing, software
1789
- * distributed under the License is distributed on an "AS IS" BASIS,
1790
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1791
- * See the License for the specific language governing permissions and
1792
- * limitations under the License.
1793
- */function gh(){return new TextEncoder}/**
1794
- * @license
1795
- * Copyright 2017 Google LLC
1796
- *
1797
- * Licensed under the Apache License, Version 2.0 (the "License");
1798
- * you may not use this file except in compliance with the License.
1799
- * You may obtain a copy of the License at
1800
- *
1801
- * http://www.apache.org/licenses/LICENSE-2.0
1802
- *
1803
- * Unless required by applicable law or agreed to in writing, software
1804
- * distributed under the License is distributed on an "AS IS" BASIS,
1805
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1806
- * See the License for the specific language governing permissions and
1807
- * limitations under the License.
1808
- */class _h{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516);let r="";for(;r.length<20;){const s=gy(40);for(let i=0;i<s.length;++i)r.length<20&&s[i]<t&&(r+=e.charAt(s[i]%62))}return r}}function z(n,e){return n<e?-1:n>e?1:0}function lo(n,e){let t=0;for(;t<n.length&&t<e.length;){const r=n.codePointAt(t),s=e.codePointAt(t);if(r!==s){if(r<128&&s<128)return z(r,s);{const i=gh(),a=_y(i.encode(mu(n,t)),i.encode(mu(e,t)));return a!==0?a:z(r,s)}}t+=r>65535?2:1}return z(n.length,e.length)}function mu(n,e){return n.codePointAt(e)>65535?n.substring(e,e+2):n.substring(e,e+1)}function _y(n,e){for(let t=0;t<n.length&&t<e.length;++t)if(n[t]!==e[t])return z(n[t],e[t]);return z(n.length,e.length)}function Sn(n,e,t){return n.length===e.length&&n.every((r,s)=>t(r,e[s]))}/**
1809
- * @license
1810
- * Copyright 2017 Google LLC
1811
- *
1812
- * Licensed under the Apache License, Version 2.0 (the "License");
1813
- * you may not use this file except in compliance with the License.
1814
- * You may obtain a copy of the License at
1815
- *
1816
- * http://www.apache.org/licenses/LICENSE-2.0
1817
- *
1818
- * Unless required by applicable law or agreed to in writing, software
1819
- * distributed under the License is distributed on an "AS IS" BASIS,
1820
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1821
- * See the License for the specific language governing permissions and
1822
- * limitations under the License.
1823
- */const gu=-62135596800,_u=1e6;class ue{static now(){return ue.fromMillis(Date.now())}static fromDate(e){return ue.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*_u);return new ue(t,r)}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<gu)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)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/_u}_compareTo(e){return this.seconds===e.seconds?z(this.nanoseconds,e.nanoseconds):z(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-gu;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}/**
1824
- * @license
1825
- * Copyright 2017 Google LLC
1826
- *
1827
- * Licensed under the Apache License, Version 2.0 (the "License");
1828
- * you may not use this file except in compliance with the License.
1829
- * You may obtain a copy of the License at
1830
- *
1831
- * http://www.apache.org/licenses/LICENSE-2.0
1832
- *
1833
- * Unless required by applicable law or agreed to in writing, software
1834
- * distributed under the License is distributed on an "AS IS" BASIS,
1835
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1836
- * See the License for the specific language governing permissions and
1837
- * limitations under the License.
1838
- */class q{static fromTimestamp(e){return new q(e)}static min(){return new q(new ue(0,0))}static max(){return new q(new ue(253402300799,999999999))}constructor(e){this.timestamp=e}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}}/**
1839
- * @license
1840
- * Copyright 2017 Google LLC
1841
- *
1842
- * Licensed under the Apache License, Version 2.0 (the "License");
1843
- * you may not use this file except in compliance with the License.
1844
- * You may obtain a copy of the License at
1845
- *
1846
- * http://www.apache.org/licenses/LICENSE-2.0
1847
- *
1848
- * Unless required by applicable law or agreed to in writing, software
1849
- * distributed under the License is distributed on an "AS IS" BASIS,
1850
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1851
- * See the License for the specific language governing permissions and
1852
- * limitations under the License.
1853
- */const yu="__name__";class Ge{constructor(e,t,r){t===void 0?t=0:t>e.length&&F(637,{offset:t,range:e.length}),r===void 0?r=e.length-t:r>e.length-t&&F(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return Ge.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Ge?e.forEach(r=>{t.push(r)}):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,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const i=Ge.compareSegments(e.get(s),t.get(s));if(i!==0)return i}return z(e.length,t.length)}static compareSegments(e,t){const r=Ge.isNumericId(e),s=Ge.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?Ge.extractNumericId(e).compare(Ge.extractNumericId(t)):lo(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return bt.fromString(e.substring(4,e.length-2))}}class J extends Ge{construct(e,t,r){return new J(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const r of e){if(r.indexOf("//")>=0)throw new V(P.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter(s=>s.length>0))}return new J(t)}static emptyPath(){return new J([])}}const yy=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class pe extends Ge{construct(e,t,r){return new pe(e,t,r)}static isValidIdentifier(e){return yy.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),pe.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===yu}static keyField(){return new pe([yu])}static fromServerFormat(e){const t=[];let r="",s=0;const i=()=>{if(r.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(r),r=""};let a=!1;for(;s<e.length;){const c=e[s];if(c==="\\"){if(s+1===e.length)throw new V(P.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const l=e[s+1];if(l!=="\\"&&l!=="."&&l!=="`")throw new V(P.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=l,s+=2}else c==="`"?(a=!a,s++):c!=="."||a?(r+=c,s++):(i(),s++)}if(i(),a)throw new V(P.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new pe(t)}static emptyPath(){return new pe([])}}/**
1854
- * @license
1855
- * Copyright 2017 Google LLC
1856
- *
1857
- * Licensed under the Apache License, Version 2.0 (the "License");
1858
- * you may not use this file except in compliance with the License.
1859
- * You may obtain a copy of the License at
1860
- *
1861
- * http://www.apache.org/licenses/LICENSE-2.0
1862
- *
1863
- * Unless required by applicable law or agreed to in writing, software
1864
- * distributed under the License is distributed on an "AS IS" BASIS,
1865
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1866
- * See the License for the specific language governing permissions and
1867
- * limitations under the License.
1868
- */class L{constructor(e){this.path=e}static fromPath(e){return new L(J.fromString(e))}static fromName(e){return new L(J.fromString(e).popFirst(5))}static empty(){return new L(J.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&&J.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return J.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new L(new J(e.slice()))}}/**
1869
- * @license
1870
- * Copyright 2021 Google LLC
1871
- *
1872
- * Licensed under the Apache License, Version 2.0 (the "License");
1873
- * you may not use this file except in compliance with the License.
1874
- * You may obtain a copy of the License at
1875
- *
1876
- * http://www.apache.org/licenses/LICENSE-2.0
1877
- *
1878
- * Unless required by applicable law or agreed to in writing, software
1879
- * distributed under the License is distributed on an "AS IS" BASIS,
1880
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1881
- * See the License for the specific language governing permissions and
1882
- * limitations under the License.
1883
- */const vr=-1;function Ey(n,e){const t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=q.fromTimestamp(r===1e9?new ue(t+1,0):new ue(t,r));return new Ct(s,L.empty(),e)}function Ty(n){return new Ct(n.readTime,n.key,vr)}class Ct{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new Ct(q.min(),L.empty(),vr)}static max(){return new Ct(q.max(),L.empty(),vr)}}function vy(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=L.comparator(n.documentKey,e.documentKey),t!==0?t:z(n.largestBatchId,e.largestBatchId))}/**
1884
- * @license
1885
- * Copyright 2020 Google LLC
1886
- *
1887
- * Licensed under the Apache License, Version 2.0 (the "License");
1888
- * you may not use this file except in compliance with the License.
1889
- * You may obtain a copy of the License at
1890
- *
1891
- * http://www.apache.org/licenses/LICENSE-2.0
1892
- *
1893
- * Unless required by applicable law or agreed to in writing, software
1894
- * distributed under the License is distributed on an "AS IS" BASIS,
1895
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1896
- * See the License for the specific language governing permissions and
1897
- * limitations under the License.
1898
- */const Iy="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class wy{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}/**
1899
- * @license
1900
- * Copyright 2017 Google LLC
1901
- *
1902
- * Licensed under the Apache License, Version 2.0 (the "License");
1903
- * you may not use this file except in compliance with the License.
1904
- * You may obtain a copy of the License at
1905
- *
1906
- * http://www.apache.org/licenses/LICENSE-2.0
1907
- *
1908
- * Unless required by applicable law or agreed to in writing, software
1909
- * distributed under the License is distributed on an "AS IS" BASIS,
1910
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1911
- * See the License for the specific language governing permissions and
1912
- * limitations under the License.
1913
- */async function Mn(n){if(n.code!==P.FAILED_PRECONDITION||n.message!==Iy)throw n;O("LocalStore","Unexpectedly lost primary lease")}/**
1914
- * @license
1915
- * Copyright 2017 Google LLC
1916
- *
1917
- * Licensed under the Apache License, Version 2.0 (the "License");
1918
- * you may not use this file except in compliance with the License.
1919
- * You may obtain a copy of the License at
1920
- *
1921
- * http://www.apache.org/licenses/LICENSE-2.0
1922
- *
1923
- * Unless required by applicable law or agreed to in writing, software
1924
- * distributed under the License is distributed on an "AS IS" BASIS,
1925
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1926
- * See the License for the specific language governing permissions and
1927
- * limitations under the License.
1928
- */class C{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&&F(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new C((r,s)=>{this.nextCallback=i=>{this.wrapSuccess(e,i).next(r,s)},this.catchCallback=i=>{this.wrapFailure(t,i).next(r,s)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{const t=e();return t instanceof C?t:C.resolve(t)}catch(t){return C.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):C.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):C.reject(t)}static resolve(e){return new C((t,r)=>{t(e)})}static reject(e){return new C((t,r)=>{r(e)})}static waitFor(e){return new C((t,r)=>{let s=0,i=0,a=!1;e.forEach(c=>{++s,c.next(()=>{++i,a&&i===s&&t()},l=>r(l))}),a=!0,i===s&&t()})}static or(e){let t=C.resolve(!1);for(const r of e)t=t.next(s=>s?C.resolve(s):r());return t}static forEach(e,t){const r=[];return e.forEach((s,i)=>{r.push(t.call(this,s,i))}),this.waitFor(r)}static mapArray(e,t){return new C((r,s)=>{const i=e.length,a=new Array(i);let c=0;for(let l=0;l<i;l++){const d=l;t(e[d]).next(f=>{a[d]=f,++c,c===i&&r(a)},f=>s(f))}})}static doWhile(e,t){return new C((r,s)=>{const i=()=>{e()===!0?t().next(()=>{i()},s):r()};i()})}}function Ay(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function Un(n){return n.name==="IndexedDbTransactionError"}/**
1929
- * @license
1930
- * Copyright 2018 Google LLC
1931
- *
1932
- * Licensed under the Apache License, Version 2.0 (the "License");
1933
- * you may not use this file except in compliance with the License.
1934
- * You may obtain a copy of the License at
1935
- *
1936
- * http://www.apache.org/licenses/LICENSE-2.0
1937
- *
1938
- * Unless required by applicable law or agreed to in writing, software
1939
- * distributed under the License is distributed on an "AS IS" BASIS,
1940
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1941
- * See the License for the specific language governing permissions and
1942
- * limitations under the License.
1943
- */class ei{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=r=>this.ue(r),this.ce=r=>t.writeSequenceNumber(r))}ue(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ce&&this.ce(e),e}}ei.le=-1;/**
1944
- * @license
1945
- * Copyright 2017 Google LLC
1946
- *
1947
- * Licensed under the Apache License, Version 2.0 (the "License");
1948
- * you may not use this file except in compliance with the License.
1949
- * You may obtain a copy of the License at
1950
- *
1951
- * http://www.apache.org/licenses/LICENSE-2.0
1952
- *
1953
- * Unless required by applicable law or agreed to in writing, software
1954
- * distributed under the License is distributed on an "AS IS" BASIS,
1955
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1956
- * See the License for the specific language governing permissions and
1957
- * limitations under the License.
1958
- */const jo=-1;function ti(n){return n==null}function Os(n){return n===0&&1/n==-1/0}function Ry(n){return typeof n=="number"&&Number.isInteger(n)&&!Os(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}/**
1959
- * @license
1960
- * Copyright 2017 Google LLC
1961
- *
1962
- * Licensed under the Apache License, Version 2.0 (the "License");
1963
- * you may not use this file except in compliance with the License.
1964
- * You may obtain a copy of the License at
1965
- *
1966
- * http://www.apache.org/licenses/LICENSE-2.0
1967
- *
1968
- * Unless required by applicable law or agreed to in writing, software
1969
- * distributed under the License is distributed on an "AS IS" BASIS,
1970
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1971
- * See the License for the specific language governing permissions and
1972
- * limitations under the License.
1973
- */const yh="";function by(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=Eu(e)),e=Py(n.get(t),e);return Eu(e)}function Py(n,e){let t=e;const r=n.length;for(let s=0;s<r;s++){const i=n.charAt(s);switch(i){case"\0":t+="";break;case yh:t+="";break;default:t+=i}}return t}function Eu(n){return n+yh+""}/**
1974
- * @license
1975
- * Copyright 2017 Google LLC
1976
- *
1977
- * Licensed under the Apache License, Version 2.0 (the "License");
1978
- * you may not use this file except in compliance with the License.
1979
- * You may obtain a copy of the License at
1980
- *
1981
- * http://www.apache.org/licenses/LICENSE-2.0
1982
- *
1983
- * Unless required by applicable law or agreed to in writing, software
1984
- * distributed under the License is distributed on an "AS IS" BASIS,
1985
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1986
- * See the License for the specific language governing permissions and
1987
- * limitations under the License.
1988
- */function Tu(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function on(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function Eh(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}/**
1989
- * @license
1990
- * Copyright 2017 Google LLC
1991
- *
1992
- * Licensed under the Apache License, Version 2.0 (the "License");
1993
- * you may not use this file except in compliance with the License.
1994
- * You may obtain a copy of the License at
1995
- *
1996
- * http://www.apache.org/licenses/LICENSE-2.0
1997
- *
1998
- * Unless required by applicable law or agreed to in writing, software
1999
- * distributed under the License is distributed on an "AS IS" BASIS,
2000
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2001
- * See the License for the specific language governing permissions and
2002
- * limitations under the License.
2003
- */class ne{constructor(e,t){this.comparator=e,this.root=t||fe.EMPTY}insert(e,t){return new ne(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,fe.BLACK,null,null))}remove(e){return new ne(this.comparator,this.root.remove(e,this.comparator).copy(null,null,fe.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const r=this.comparator(e,t.key);if(r===0)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){const s=this.comparator(e,r.key);if(s===0)return t+r.left.size;s<0?r=r.left:(t+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,r)=>(e(t,r),!1))}toString(){const e=[];return this.inorderTraversal((t,r)=>(e.push(`${t}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new cs(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new cs(this.root,e,this.comparator,!1)}getReverseIterator(){return new cs(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new cs(this.root,e,this.comparator,!0)}}class cs{constructor(e,t,r,s){this.isReverse=s,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?r(e.key,t):1,t&&s&&(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 fe{constructor(e,t,r,s,i){this.key=e,this.value=t,this.color=r??fe.RED,this.left=s??fe.EMPTY,this.right=i??fe.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,s,i){return new fe(e??this.key,t??this.value,r??this.color,s??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,r){let s=this;const i=r(e,s.key);return s=i<0?s.copy(null,null,null,s.left.insert(e,t,r),null):i===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return fe.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 r,s=this;if(t(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),t(e,s.key)===0){if(s.right.isEmpty())return fe.EMPTY;r=s.right.min(),s=s.copy(r.key,r.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.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,fe.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,fe.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())throw F(43730,{key:this.key,value:this.value});if(this.right.isRed())throw F(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw F(27949);return e+(this.isRed()?0:1)}}fe.EMPTY=null,fe.RED=!0,fe.BLACK=!1;fe.EMPTY=new class{constructor(){this.size=0}get key(){throw F(57766)}get value(){throw F(16141)}get color(){throw F(16727)}get left(){throw F(29726)}get right(){throw F(36894)}copy(e,t,r,s,i){return this}insert(e,t,r){return new fe(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};/**
2004
- * @license
2005
- * Copyright 2017 Google LLC
2006
- *
2007
- * Licensed under the Apache License, Version 2.0 (the "License");
2008
- * you may not use this file except in compliance with the License.
2009
- * You may obtain a copy of the License at
2010
- *
2011
- * http://www.apache.org/licenses/LICENSE-2.0
2012
- *
2013
- * Unless required by applicable law or agreed to in writing, software
2014
- * distributed under the License is distributed on an "AS IS" BASIS,
2015
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2016
- * See the License for the specific language governing permissions and
2017
- * limitations under the License.
2018
- */class le{constructor(e){this.comparator=e,this.data=new ne(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,r)=>(e(t),!1))}forEachInRange(e,t){const r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){const s=r.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let r;for(r=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new vu(this.data.getIterator())}getIteratorFrom(e){return new vu(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(r=>{t=t.add(r)}),t}isEqual(e){if(!(e instanceof le)||this.size!==e.size)return!1;const t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){const s=t.getNext().key,i=r.getNext().key;if(this.comparator(s,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 le(this.comparator);return t.data=e,t}}class vu{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}/**
2019
- * @license
2020
- * Copyright 2020 Google LLC
2021
- *
2022
- * Licensed under the Apache License, Version 2.0 (the "License");
2023
- * you may not use this file except in compliance with the License.
2024
- * You may obtain a copy of the License at
2025
- *
2026
- * http://www.apache.org/licenses/LICENSE-2.0
2027
- *
2028
- * Unless required by applicable law or agreed to in writing, software
2029
- * distributed under the License is distributed on an "AS IS" BASIS,
2030
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2031
- * See the License for the specific language governing permissions and
2032
- * limitations under the License.
2033
- */class Be{constructor(e){this.fields=e,e.sort(pe.comparator)}static empty(){return new Be([])}unionWith(e){let t=new le(pe.comparator);for(const r of this.fields)t=t.add(r);for(const r of e)t=t.add(r);return new Be(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Sn(this.fields,e.fields,(t,r)=>t.isEqual(r))}}/**
2034
- * @license
2035
- * Copyright 2023 Google LLC
2036
- *
2037
- * Licensed under the Apache License, Version 2.0 (the "License");
2038
- * you may not use this file except in compliance with the License.
2039
- * You may obtain a copy of the License at
2040
- *
2041
- * http://www.apache.org/licenses/LICENSE-2.0
2042
- *
2043
- * Unless required by applicable law or agreed to in writing, software
2044
- * distributed under the License is distributed on an "AS IS" BASIS,
2045
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2046
- * See the License for the specific language governing permissions and
2047
- * limitations under the License.
2048
- */class Th extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}/**
2049
- * @license
2050
- * Copyright 2020 Google LLC
2051
- *
2052
- * Licensed under the Apache License, Version 2.0 (the "License");
2053
- * you may not use this file except in compliance with the License.
2054
- * You may obtain a copy of the License at
2055
- *
2056
- * http://www.apache.org/licenses/LICENSE-2.0
2057
- *
2058
- * Unless required by applicable law or agreed to in writing, software
2059
- * distributed under the License is distributed on an "AS IS" BASIS,
2060
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2061
- * See the License for the specific language governing permissions and
2062
- * limitations under the License.
2063
- */class me{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(s){try{return atob(s)}catch(i){throw typeof DOMException<"u"&&i instanceof DOMException?new Th("Invalid base64 string: "+i):i}}(e);return new me(t)}static fromUint8Array(e){const t=function(s){let i="";for(let a=0;a<s.length;++a)i+=String.fromCharCode(s[a]);return i}(e);return new me(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(t){return btoa(t)}(this.binaryString)}toUint8Array(){return function(t){const r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return z(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}me.EMPTY_BYTE_STRING=new me("");const Sy=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function kt(n){if(Q(!!n,39018),typeof n=="string"){let e=0;const t=Sy.exec(n);if(Q(!!t,46558,{timestamp:n}),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}const r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:ie(n.seconds),nanos:ie(n.nanos)}}function ie(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function Nt(n){return typeof n=="string"?me.fromBase64String(n):me.fromUint8Array(n)}/**
2064
- * @license
2065
- * Copyright 2020 Google LLC
2066
- *
2067
- * Licensed under the Apache License, Version 2.0 (the "License");
2068
- * you may not use this file except in compliance with the License.
2069
- * You may obtain a copy of the License at
2070
- *
2071
- * http://www.apache.org/licenses/LICENSE-2.0
2072
- *
2073
- * Unless required by applicable law or agreed to in writing, software
2074
- * distributed under the License is distributed on an "AS IS" BASIS,
2075
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2076
- * See the License for the specific language governing permissions and
2077
- * limitations under the License.
2078
- */const vh="server_timestamp",Ih="__type__",wh="__previous_value__",Ah="__local_write_time__";function ni(n){var e,t;return((t=(((e=n==null?void 0:n.mapValue)===null||e===void 0?void 0:e.fields)||{})[Ih])===null||t===void 0?void 0:t.stringValue)===vh}function ri(n){const e=n.mapValue.fields[wh];return ni(e)?ri(e):e}function Ir(n){const e=kt(n.mapValue.fields[Ah].timestampValue);return new ue(e.seconds,e.nanos)}/**
2079
- * @license
2080
- * Copyright 2017 Google LLC
2081
- *
2082
- * Licensed under the Apache License, Version 2.0 (the "License");
2083
- * you may not use this file except in compliance with the License.
2084
- * You may obtain a copy of the License at
2085
- *
2086
- * http://www.apache.org/licenses/LICENSE-2.0
2087
- *
2088
- * Unless required by applicable law or agreed to in writing, software
2089
- * distributed under the License is distributed on an "AS IS" BASIS,
2090
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2091
- * See the License for the specific language governing permissions and
2092
- * limitations under the License.
2093
- */class Cy{constructor(e,t,r,s,i,a,c,l,d,f){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=s,this.ssl=i,this.forceLongPolling=a,this.autoDetectLongPolling=c,this.longPollingOptions=l,this.useFetchStreams=d,this.isUsingEmulator=f}}const Ls="(default)";class wr{constructor(e,t){this.projectId=e,this.database=t||Ls}static empty(){return new wr("","")}get isDefaultDatabase(){return this.database===Ls}isEqual(e){return e instanceof wr&&e.projectId===this.projectId&&e.database===this.database}}/**
2094
- * @license
2095
- * Copyright 2020 Google LLC
2096
- *
2097
- * Licensed under the Apache License, Version 2.0 (the "License");
2098
- * you may not use this file except in compliance with the License.
2099
- * You may obtain a copy of the License at
2100
- *
2101
- * http://www.apache.org/licenses/LICENSE-2.0
2102
- *
2103
- * Unless required by applicable law or agreed to in writing, software
2104
- * distributed under the License is distributed on an "AS IS" BASIS,
2105
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2106
- * See the License for the specific language governing permissions and
2107
- * limitations under the License.
2108
- */const Rh="__type__",ky="__max__",us={mapValue:{}},bh="__vector__",xs="value";function Dt(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?ni(n)?4:Dy(n)?9007199254740991:Ny(n)?10:11:F(28295,{value:n})}function Je(n,e){if(n===e)return!0;const t=Dt(n);if(t!==Dt(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return Ir(n).isEqual(Ir(e));case 3:return function(s,i){if(typeof s.timestampValue=="string"&&typeof i.timestampValue=="string"&&s.timestampValue.length===i.timestampValue.length)return s.timestampValue===i.timestampValue;const a=kt(s.timestampValue),c=kt(i.timestampValue);return a.seconds===c.seconds&&a.nanos===c.nanos}(n,e);case 5:return n.stringValue===e.stringValue;case 6:return function(s,i){return Nt(s.bytesValue).isEqual(Nt(i.bytesValue))}(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return function(s,i){return ie(s.geoPointValue.latitude)===ie(i.geoPointValue.latitude)&&ie(s.geoPointValue.longitude)===ie(i.geoPointValue.longitude)}(n,e);case 2:return function(s,i){if("integerValue"in s&&"integerValue"in i)return ie(s.integerValue)===ie(i.integerValue);if("doubleValue"in s&&"doubleValue"in i){const a=ie(s.doubleValue),c=ie(i.doubleValue);return a===c?Os(a)===Os(c):isNaN(a)&&isNaN(c)}return!1}(n,e);case 9:return Sn(n.arrayValue.values||[],e.arrayValue.values||[],Je);case 10:case 11:return function(s,i){const a=s.mapValue.fields||{},c=i.mapValue.fields||{};if(Tu(a)!==Tu(c))return!1;for(const l in a)if(a.hasOwnProperty(l)&&(c[l]===void 0||!Je(a[l],c[l])))return!1;return!0}(n,e);default:return F(52216,{left:n})}}function Ar(n,e){return(n.values||[]).find(t=>Je(t,e))!==void 0}function Cn(n,e){if(n===e)return 0;const t=Dt(n),r=Dt(e);if(t!==r)return z(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return z(n.booleanValue,e.booleanValue);case 2:return function(i,a){const c=ie(i.integerValue||i.doubleValue),l=ie(a.integerValue||a.doubleValue);return c<l?-1:c>l?1:c===l?0:isNaN(c)?isNaN(l)?0:-1:1}(n,e);case 3:return Iu(n.timestampValue,e.timestampValue);case 4:return Iu(Ir(n),Ir(e));case 5:return lo(n.stringValue,e.stringValue);case 6:return function(i,a){const c=Nt(i),l=Nt(a);return c.compareTo(l)}(n.bytesValue,e.bytesValue);case 7:return function(i,a){const c=i.split("/"),l=a.split("/");for(let d=0;d<c.length&&d<l.length;d++){const f=z(c[d],l[d]);if(f!==0)return f}return z(c.length,l.length)}(n.referenceValue,e.referenceValue);case 8:return function(i,a){const c=z(ie(i.latitude),ie(a.latitude));return c!==0?c:z(ie(i.longitude),ie(a.longitude))}(n.geoPointValue,e.geoPointValue);case 9:return wu(n.arrayValue,e.arrayValue);case 10:return function(i,a){var c,l,d,f;const m=i.fields||{},_=a.fields||{},R=(c=m[xs])===null||c===void 0?void 0:c.arrayValue,S=(l=_[xs])===null||l===void 0?void 0:l.arrayValue,N=z(((d=R==null?void 0:R.values)===null||d===void 0?void 0:d.length)||0,((f=S==null?void 0:S.values)===null||f===void 0?void 0:f.length)||0);return N!==0?N:wu(R,S)}(n.mapValue,e.mapValue);case 11:return function(i,a){if(i===us.mapValue&&a===us.mapValue)return 0;if(i===us.mapValue)return 1;if(a===us.mapValue)return-1;const c=i.fields||{},l=Object.keys(c),d=a.fields||{},f=Object.keys(d);l.sort(),f.sort();for(let m=0;m<l.length&&m<f.length;++m){const _=lo(l[m],f[m]);if(_!==0)return _;const R=Cn(c[l[m]],d[f[m]]);if(R!==0)return R}return z(l.length,f.length)}(n.mapValue,e.mapValue);default:throw F(23264,{Pe:t})}}function Iu(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return z(n,e);const t=kt(n),r=kt(e),s=z(t.seconds,r.seconds);return s!==0?s:z(t.nanos,r.nanos)}function wu(n,e){const t=n.values||[],r=e.values||[];for(let s=0;s<t.length&&s<r.length;++s){const i=Cn(t[s],r[s]);if(i)return i}return z(t.length,r.length)}function kn(n){return ho(n)}function ho(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(t){const r=kt(t);return`time(${r.seconds},${r.nanos})`}(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?function(t){return Nt(t).toBase64()}(n.bytesValue):"referenceValue"in n?function(t){return L.fromName(t).toString()}(n.referenceValue):"geoPointValue"in n?function(t){return`geo(${t.latitude},${t.longitude})`}(n.geoPointValue):"arrayValue"in n?function(t){let r="[",s=!0;for(const i of t.values||[])s?s=!1:r+=",",r+=ho(i);return r+"]"}(n.arrayValue):"mapValue"in n?function(t){const r=Object.keys(t.fields||{}).sort();let s="{",i=!0;for(const a of r)i?i=!1:s+=",",s+=`${a}:${ho(t.fields[a])}`;return s+"}"}(n.mapValue):F(61005,{value:n})}function Es(n){switch(Dt(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=ri(n);return e?16+Es(e):16;case 5:return 2*n.stringValue.length;case 6:return Nt(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return function(r){return(r.values||[]).reduce((s,i)=>s+Es(i),0)}(n.arrayValue);case 10:case 11:return function(r){let s=0;return on(r.fields,(i,a)=>{s+=i.length+Es(a)}),s}(n.mapValue);default:throw F(13486,{value:n})}}function Ms(n,e){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${e.path.canonicalString()}`}}function fo(n){return!!n&&"integerValue"in n}function $o(n){return!!n&&"arrayValue"in n}function Au(n){return!!n&&"nullValue"in n}function Ru(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function Ts(n){return!!n&&"mapValue"in n}function Ny(n){var e,t;return((t=(((e=n==null?void 0:n.mapValue)===null||e===void 0?void 0:e.fields)||{})[Rh])===null||t===void 0?void 0:t.stringValue)===bh}function pr(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 on(n.mapValue.fields,(t,r)=>e.mapValue.fields[t]=pr(r)),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=pr(n.arrayValue.values[t]);return e}return Object.assign({},n)}function Dy(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===ky}/**
2109
- * @license
2110
- * Copyright 2017 Google LLC
2111
- *
2112
- * Licensed under the Apache License, Version 2.0 (the "License");
2113
- * you may not use this file except in compliance with the License.
2114
- * You may obtain a copy of the License at
2115
- *
2116
- * http://www.apache.org/licenses/LICENSE-2.0
2117
- *
2118
- * Unless required by applicable law or agreed to in writing, software
2119
- * distributed under the License is distributed on an "AS IS" BASIS,
2120
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2121
- * See the License for the specific language governing permissions and
2122
- * limitations under the License.
2123
- */class Oe{constructor(e){this.value=e}static empty(){return new Oe({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(t=(t.mapValue.fields||{})[e.get(r)],!Ts(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=pr(t)}setAll(e){let t=pe.emptyPath(),r={},s=[];e.forEach((a,c)=>{if(!t.isImmediateParentOf(c)){const l=this.getFieldsMap(t);this.applyChanges(l,r,s),r={},s=[],t=c.popLast()}a?r[c.lastSegment()]=pr(a):s.push(c.lastSegment())});const i=this.getFieldsMap(t);this.applyChanges(i,r,s)}delete(e){const t=this.field(e.popLast());Ts(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Je(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let s=t.mapValue.fields[e.get(r)];Ts(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,r){on(t,(s,i)=>e[s]=i);for(const s of r)delete e[s]}clone(){return new Oe(pr(this.value))}}function Ph(n){const e=[];return on(n.fields,(t,r)=>{const s=new pe([t]);if(Ts(r)){const i=Ph(r.mapValue).fields;if(i.length===0)e.push(s);else for(const a of i)e.push(s.child(a))}else e.push(s)}),new Be(e)}/**
2124
- * @license
2125
- * Copyright 2017 Google LLC
2126
- *
2127
- * Licensed under the Apache License, Version 2.0 (the "License");
2128
- * you may not use this file except in compliance with the License.
2129
- * You may obtain a copy of the License at
2130
- *
2131
- * http://www.apache.org/licenses/LICENSE-2.0
2132
- *
2133
- * Unless required by applicable law or agreed to in writing, software
2134
- * distributed under the License is distributed on an "AS IS" BASIS,
2135
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2136
- * See the License for the specific language governing permissions and
2137
- * limitations under the License.
2138
- */class Ie{constructor(e,t,r,s,i,a,c){this.key=e,this.documentType=t,this.version=r,this.readTime=s,this.createTime=i,this.data=a,this.documentState=c}static newInvalidDocument(e){return new Ie(e,0,q.min(),q.min(),q.min(),Oe.empty(),0)}static newFoundDocument(e,t,r,s){return new Ie(e,1,t,q.min(),r,s,0)}static newNoDocument(e,t){return new Ie(e,2,t,q.min(),q.min(),Oe.empty(),0)}static newUnknownDocument(e,t){return new Ie(e,3,t,q.min(),q.min(),Oe.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(q.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=Oe.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Oe.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=q.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 Ie&&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 Ie(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}})`}}/**
2139
- * @license
2140
- * Copyright 2022 Google LLC
2141
- *
2142
- * Licensed under the Apache License, Version 2.0 (the "License");
2143
- * you may not use this file except in compliance with the License.
2144
- * You may obtain a copy of the License at
2145
- *
2146
- * http://www.apache.org/licenses/LICENSE-2.0
2147
- *
2148
- * Unless required by applicable law or agreed to in writing, software
2149
- * distributed under the License is distributed on an "AS IS" BASIS,
2150
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2151
- * See the License for the specific language governing permissions and
2152
- * limitations under the License.
2153
- */class Nn{constructor(e,t){this.position=e,this.inclusive=t}}function bu(n,e,t){let r=0;for(let s=0;s<n.position.length;s++){const i=e[s],a=n.position[s];if(i.field.isKeyField()?r=L.comparator(L.fromName(a.referenceValue),t.key):r=Cn(a,t.data.field(i.field)),i.dir==="desc"&&(r*=-1),r!==0)break}return r}function Pu(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(!Je(n.position[t],e.position[t]))return!1;return!0}/**
2154
- * @license
2155
- * Copyright 2022 Google LLC
2156
- *
2157
- * Licensed under the Apache License, Version 2.0 (the "License");
2158
- * you may not use this file except in compliance with the License.
2159
- * You may obtain a copy of the License at
2160
- *
2161
- * http://www.apache.org/licenses/LICENSE-2.0
2162
- *
2163
- * Unless required by applicable law or agreed to in writing, software
2164
- * distributed under the License is distributed on an "AS IS" BASIS,
2165
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2166
- * See the License for the specific language governing permissions and
2167
- * limitations under the License.
2168
- */class Rr{constructor(e,t="asc"){this.field=e,this.dir=t}}function Vy(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}/**
2169
- * @license
2170
- * Copyright 2022 Google LLC
2171
- *
2172
- * Licensed under the Apache License, Version 2.0 (the "License");
2173
- * you may not use this file except in compliance with the License.
2174
- * You may obtain a copy of the License at
2175
- *
2176
- * http://www.apache.org/licenses/LICENSE-2.0
2177
- *
2178
- * Unless required by applicable law or agreed to in writing, software
2179
- * distributed under the License is distributed on an "AS IS" BASIS,
2180
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2181
- * See the License for the specific language governing permissions and
2182
- * limitations under the License.
2183
- */class Sh{}class ae extends Sh{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new Ly(e,t,r):t==="array-contains"?new Uy(e,r):t==="in"?new Fy(e,r):t==="not-in"?new By(e,r):t==="array-contains-any"?new qy(e,r):new ae(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new xy(e,r):new My(e,r)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&t.nullValue===void 0&&this.matchesComparison(Cn(t,this.value)):t!==null&&Dt(this.value)===Dt(t)&&this.matchesComparison(Cn(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 F(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class $e extends Sh{constructor(e,t){super(),this.filters=e,this.op=t,this.Te=null}static create(e,t){return new $e(e,t)}matches(e){return Ch(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.Te!==null||(this.Te=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.Te}getFilters(){return Object.assign([],this.filters)}}function Ch(n){return n.op==="and"}function kh(n){return Oy(n)&&Ch(n)}function Oy(n){for(const e of n.filters)if(e instanceof $e)return!1;return!0}function po(n){if(n instanceof ae)return n.field.canonicalString()+n.op.toString()+kn(n.value);if(kh(n))return n.filters.map(e=>po(e)).join(",");{const e=n.filters.map(t=>po(t)).join(",");return`${n.op}(${e})`}}function Nh(n,e){return n instanceof ae?function(r,s){return s instanceof ae&&r.op===s.op&&r.field.isEqual(s.field)&&Je(r.value,s.value)}(n,e):n instanceof $e?function(r,s){return s instanceof $e&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce((i,a,c)=>i&&Nh(a,s.filters[c]),!0):!1}(n,e):void F(19439)}function Dh(n){return n instanceof ae?function(t){return`${t.field.canonicalString()} ${t.op} ${kn(t.value)}`}(n):n instanceof $e?function(t){return t.op.toString()+" {"+t.getFilters().map(Dh).join(" ,")+"}"}(n):"Filter"}class Ly extends ae{constructor(e,t,r){super(e,t,r),this.key=L.fromName(r.referenceValue)}matches(e){const t=L.comparator(e.key,this.key);return this.matchesComparison(t)}}class xy extends ae{constructor(e,t){super(e,"in",t),this.keys=Vh("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class My extends ae{constructor(e,t){super(e,"not-in",t),this.keys=Vh("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function Vh(n,e){var t;return(((t=e.arrayValue)===null||t===void 0?void 0:t.values)||[]).map(r=>L.fromName(r.referenceValue))}class Uy extends ae{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return $o(t)&&Ar(t.arrayValue,this.value)}}class Fy extends ae{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&Ar(this.value.arrayValue,t)}}class By extends ae{constructor(e,t){super(e,"not-in",t)}matches(e){if(Ar(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!Ar(this.value.arrayValue,t)}}class qy extends ae{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!$o(t)||!t.arrayValue.values)&&t.arrayValue.values.some(r=>Ar(this.value.arrayValue,r))}}/**
2184
- * @license
2185
- * Copyright 2019 Google LLC
2186
- *
2187
- * Licensed under the Apache License, Version 2.0 (the "License");
2188
- * you may not use this file except in compliance with the License.
2189
- * You may obtain a copy of the License at
2190
- *
2191
- * http://www.apache.org/licenses/LICENSE-2.0
2192
- *
2193
- * Unless required by applicable law or agreed to in writing, software
2194
- * distributed under the License is distributed on an "AS IS" BASIS,
2195
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2196
- * See the License for the specific language governing permissions and
2197
- * limitations under the License.
2198
- */class jy{constructor(e,t=null,r=[],s=[],i=null,a=null,c=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=s,this.limit=i,this.startAt=a,this.endAt=c,this.Ie=null}}function Su(n,e=null,t=[],r=[],s=null,i=null,a=null){return new jy(n,e,t,r,s,i,a)}function zo(n){const e=j(n);if(e.Ie===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(r=>po(r)).join(","),t+="|ob:",t+=e.orderBy.map(r=>function(i){return i.field.canonicalString()+i.dir}(r)).join(","),ti(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(r=>kn(r)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(r=>kn(r)).join(",")),e.Ie=t}return e.Ie}function Ho(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(!Vy(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(!Nh(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!Pu(n.startAt,e.startAt)&&Pu(n.endAt,e.endAt)}function mo(n){return L.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}/**
2199
- * @license
2200
- * Copyright 2017 Google LLC
2201
- *
2202
- * Licensed under the Apache License, Version 2.0 (the "License");
2203
- * you may not use this file except in compliance with the License.
2204
- * You may obtain a copy of the License at
2205
- *
2206
- * http://www.apache.org/licenses/LICENSE-2.0
2207
- *
2208
- * Unless required by applicable law or agreed to in writing, software
2209
- * distributed under the License is distributed on an "AS IS" BASIS,
2210
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2211
- * See the License for the specific language governing permissions and
2212
- * limitations under the License.
2213
- */class Bt{constructor(e,t=null,r=[],s=[],i=null,a="F",c=null,l=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=i,this.limitType=a,this.startAt=c,this.endAt=l,this.Ee=null,this.de=null,this.Ae=null,this.startAt,this.endAt}}function $y(n,e,t,r,s,i,a,c){return new Bt(n,e,t,r,s,i,a,c)}function si(n){return new Bt(n)}function Cu(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 Go(n){return n.collectionGroup!==null}function wn(n){const e=j(n);if(e.Ee===null){e.Ee=[];const t=new Set;for(const i of e.explicitOrderBy)e.Ee.push(i),t.add(i.field.canonicalString());const r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(a){let c=new le(pe.comparator);return a.filters.forEach(l=>{l.getFlattenedFilters().forEach(d=>{d.isInequality()&&(c=c.add(d.field))})}),c})(e).forEach(i=>{t.has(i.canonicalString())||i.isKeyField()||e.Ee.push(new Rr(i,r))}),t.has(pe.keyField().canonicalString())||e.Ee.push(new Rr(pe.keyField(),r))}return e.Ee}function Qe(n){const e=j(n);return e.de||(e.de=zy(e,wn(n))),e.de}function zy(n,e){if(n.limitType==="F")return Su(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map(s=>{const i=s.dir==="desc"?"asc":"desc";return new Rr(s.field,i)});const t=n.endAt?new Nn(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new Nn(n.startAt.position,n.startAt.inclusive):null;return Su(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function go(n,e){const t=n.filters.concat([e]);return new Bt(n.path,n.collectionGroup,n.explicitOrderBy.slice(),t,n.limit,n.limitType,n.startAt,n.endAt)}function Us(n,e,t){return new Bt(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function ii(n,e){return Ho(Qe(n),Qe(e))&&n.limitType===e.limitType}function Oh(n){return`${zo(Qe(n))}|lt:${n.limitType}`}function _n(n){return`Query(target=${function(t){let r=t.path.canonicalString();return t.collectionGroup!==null&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map(s=>Dh(s)).join(", ")}]`),ti(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map(s=>function(a){return`${a.field.canonicalString()} (${a.dir})`}(s)).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map(s=>kn(s)).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map(s=>kn(s)).join(",")),`Target(${r})`}(Qe(n))}; limitType=${n.limitType})`}function oi(n,e){return e.isFoundDocument()&&function(r,s){const i=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(i):L.isDocumentKey(r.path)?r.path.isEqual(i):r.path.isImmediateParentOf(i)}(n,e)&&function(r,s){for(const i of wn(r))if(!i.field.isKeyField()&&s.data.field(i.field)===null)return!1;return!0}(n,e)&&function(r,s){for(const i of r.filters)if(!i.matches(s))return!1;return!0}(n,e)&&function(r,s){return!(r.startAt&&!function(a,c,l){const d=bu(a,c,l);return a.inclusive?d<=0:d<0}(r.startAt,wn(r),s)||r.endAt&&!function(a,c,l){const d=bu(a,c,l);return a.inclusive?d>=0:d>0}(r.endAt,wn(r),s))}(n,e)}function Hy(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function Lh(n){return(e,t)=>{let r=!1;for(const s of wn(n)){const i=Gy(s,e,t);if(i!==0)return i;r=r||s.field.isKeyField()}return 0}}function Gy(n,e,t){const r=n.field.isKeyField()?L.comparator(e.key,t.key):function(i,a,c){const l=a.data.field(i),d=c.data.field(i);return l!==null&&d!==null?Cn(l,d):F(42886)}(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return F(19790,{direction:n.dir})}}/**
2214
- * @license
2215
- * Copyright 2017 Google LLC
2216
- *
2217
- * Licensed under the Apache License, Version 2.0 (the "License");
2218
- * you may not use this file except in compliance with the License.
2219
- * You may obtain a copy of the License at
2220
- *
2221
- * http://www.apache.org/licenses/LICENSE-2.0
2222
- *
2223
- * Unless required by applicable law or agreed to in writing, software
2224
- * distributed under the License is distributed on an "AS IS" BASIS,
2225
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2226
- * See the License for the specific language governing permissions and
2227
- * limitations under the License.
2228
- */class an{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r!==void 0){for(const[s,i]of r)if(this.equalsFn(s,e))return i}}has(e){return this.get(e)!==void 0}set(e,t){const r=this.mapKeyFn(e),s=this.inner[r];if(s===void 0)return this.inner[r]=[[e,t]],void this.innerSize++;for(let i=0;i<s.length;i++)if(this.equalsFn(s[i][0],e))return void(s[i]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r===void 0)return!1;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return r.length===1?delete this.inner[t]:r.splice(s,1),this.innerSize--,!0;return!1}forEach(e){on(this.inner,(t,r)=>{for(const[s,i]of r)e(s,i)})}isEmpty(){return Eh(this.inner)}size(){return this.innerSize}}/**
2229
- * @license
2230
- * Copyright 2017 Google LLC
2231
- *
2232
- * Licensed under the Apache License, Version 2.0 (the "License");
2233
- * you may not use this file except in compliance with the License.
2234
- * You may obtain a copy of the License at
2235
- *
2236
- * http://www.apache.org/licenses/LICENSE-2.0
2237
- *
2238
- * Unless required by applicable law or agreed to in writing, software
2239
- * distributed under the License is distributed on an "AS IS" BASIS,
2240
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2241
- * See the License for the specific language governing permissions and
2242
- * limitations under the License.
2243
- */const Wy=new ne(L.comparator);function ft(){return Wy}const xh=new ne(L.comparator);function ur(...n){let e=xh;for(const t of n)e=e.insert(t.key,t);return e}function Mh(n){let e=xh;return n.forEach((t,r)=>e=e.insert(t,r.overlayedDocument)),e}function Qt(){return mr()}function Uh(){return mr()}function mr(){return new an(n=>n.toString(),(n,e)=>n.isEqual(e))}const Ky=new ne(L.comparator),Qy=new le(L.comparator);function G(...n){let e=Qy;for(const t of n)e=e.add(t);return e}const Xy=new le(z);function Yy(){return Xy}/**
2244
- * @license
2245
- * Copyright 2020 Google LLC
2246
- *
2247
- * Licensed under the Apache License, Version 2.0 (the "License");
2248
- * you may not use this file except in compliance with the License.
2249
- * You may obtain a copy of the License at
2250
- *
2251
- * http://www.apache.org/licenses/LICENSE-2.0
2252
- *
2253
- * Unless required by applicable law or agreed to in writing, software
2254
- * distributed under the License is distributed on an "AS IS" BASIS,
2255
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2256
- * See the License for the specific language governing permissions and
2257
- * limitations under the License.
2258
- */function Wo(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Os(e)?"-0":e}}function Fh(n){return{integerValue:""+n}}function Jy(n,e){return Ry(e)?Fh(e):Wo(n,e)}/**
2259
- * @license
2260
- * Copyright 2018 Google LLC
2261
- *
2262
- * Licensed under the Apache License, Version 2.0 (the "License");
2263
- * you may not use this file except in compliance with the License.
2264
- * You may obtain a copy of the License at
2265
- *
2266
- * http://www.apache.org/licenses/LICENSE-2.0
2267
- *
2268
- * Unless required by applicable law or agreed to in writing, software
2269
- * distributed under the License is distributed on an "AS IS" BASIS,
2270
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2271
- * See the License for the specific language governing permissions and
2272
- * limitations under the License.
2273
- */class ai{constructor(){this._=void 0}}function Zy(n,e,t){return n instanceof Fs?function(s,i){const a={fields:{[Ih]:{stringValue:vh},[Ah]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return i&&ni(i)&&(i=ri(i)),i&&(a.fields[wh]=i),{mapValue:a}}(t,e):n instanceof br?qh(n,e):n instanceof Pr?jh(n,e):function(s,i){const a=Bh(s,i),c=ku(a)+ku(s.Re);return fo(a)&&fo(s.Re)?Fh(c):Wo(s.serializer,c)}(n,e)}function eE(n,e,t){return n instanceof br?qh(n,e):n instanceof Pr?jh(n,e):t}function Bh(n,e){return n instanceof Bs?function(r){return fo(r)||function(i){return!!i&&"doubleValue"in i}(r)}(e)?e:{integerValue:0}:null}class Fs extends ai{}class br extends ai{constructor(e){super(),this.elements=e}}function qh(n,e){const t=$h(e);for(const r of n.elements)t.some(s=>Je(s,r))||t.push(r);return{arrayValue:{values:t}}}class Pr extends ai{constructor(e){super(),this.elements=e}}function jh(n,e){let t=$h(e);for(const r of n.elements)t=t.filter(s=>!Je(s,r));return{arrayValue:{values:t}}}class Bs extends ai{constructor(e,t){super(),this.serializer=e,this.Re=t}}function ku(n){return ie(n.integerValue||n.doubleValue)}function $h(n){return $o(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function tE(n,e){return n.field.isEqual(e.field)&&function(r,s){return r instanceof br&&s instanceof br||r instanceof Pr&&s instanceof Pr?Sn(r.elements,s.elements,Je):r instanceof Bs&&s instanceof Bs?Je(r.Re,s.Re):r instanceof Fs&&s instanceof Fs}(n.transform,e.transform)}class nE{constructor(e,t){this.version=e,this.transformResults=t}}class Xe{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Xe}static exists(e){return new Xe(void 0,e)}static updateTime(e){return new Xe(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 vs(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class ci{}function zh(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new Ko(n.key,Xe.none()):new Lr(n.key,n.data,Xe.none());{const t=n.data,r=Oe.empty();let s=new le(pe.comparator);for(let i of e.fields)if(!s.has(i)){let a=t.field(i);a===null&&i.length>1&&(i=i.popLast(),a=t.field(i)),a===null?r.delete(i):r.set(i,a),s=s.add(i)}return new cn(n.key,r,new Be(s.toArray()),Xe.none())}}function rE(n,e,t){n instanceof Lr?function(s,i,a){const c=s.value.clone(),l=Du(s.fieldTransforms,i,a.transformResults);c.setAll(l),i.convertToFoundDocument(a.version,c).setHasCommittedMutations()}(n,e,t):n instanceof cn?function(s,i,a){if(!vs(s.precondition,i))return void i.convertToUnknownDocument(a.version);const c=Du(s.fieldTransforms,i,a.transformResults),l=i.data;l.setAll(Hh(s)),l.setAll(c),i.convertToFoundDocument(a.version,l).setHasCommittedMutations()}(n,e,t):function(s,i,a){i.convertToNoDocument(a.version).setHasCommittedMutations()}(0,e,t)}function gr(n,e,t,r){return n instanceof Lr?function(i,a,c,l){if(!vs(i.precondition,a))return c;const d=i.value.clone(),f=Vu(i.fieldTransforms,l,a);return d.setAll(f),a.convertToFoundDocument(a.version,d).setHasLocalMutations(),null}(n,e,t,r):n instanceof cn?function(i,a,c,l){if(!vs(i.precondition,a))return c;const d=Vu(i.fieldTransforms,l,a),f=a.data;return f.setAll(Hh(i)),f.setAll(d),a.convertToFoundDocument(a.version,f).setHasLocalMutations(),c===null?null:c.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map(m=>m.field))}(n,e,t,r):function(i,a,c){return vs(i.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):c}(n,e,t)}function sE(n,e){let t=null;for(const r of n.fieldTransforms){const s=e.data.field(r.field),i=Bh(r.transform,s||null);i!=null&&(t===null&&(t=Oe.empty()),t.set(r.field,i))}return t||null}function Nu(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&Sn(r,s,(i,a)=>tE(i,a))}(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 Lr extends ci{constructor(e,t,r,s=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class cn extends ci{constructor(e,t,r,s,i=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=s,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function Hh(n){const e=new Map;return n.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){const r=n.data.field(t);e.set(t,r)}}),e}function Du(n,e,t){const r=new Map;Q(n.length===t.length,32656,{Ve:t.length,me:n.length});for(let s=0;s<t.length;s++){const i=n[s],a=i.transform,c=e.data.field(i.field);r.set(i.field,eE(a,c,t[s]))}return r}function Vu(n,e,t){const r=new Map;for(const s of n){const i=s.transform,a=t.data.field(s.field);r.set(s.field,Zy(i,a,e))}return r}class Ko extends ci{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class iE extends ci{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}/**
2274
- * @license
2275
- * Copyright 2017 Google LLC
2276
- *
2277
- * Licensed under the Apache License, Version 2.0 (the "License");
2278
- * you may not use this file except in compliance with the License.
2279
- * You may obtain a copy of the License at
2280
- *
2281
- * http://www.apache.org/licenses/LICENSE-2.0
2282
- *
2283
- * Unless required by applicable law or agreed to in writing, software
2284
- * distributed under the License is distributed on an "AS IS" BASIS,
2285
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2286
- * See the License for the specific language governing permissions and
2287
- * limitations under the License.
2288
- */class oE{constructor(e,t,r,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=s}applyToRemoteDocument(e,t){const r=t.mutationResults;for(let s=0;s<this.mutations.length;s++){const i=this.mutations[s];i.key.isEqual(e.key)&&rE(i,e,r[s])}}applyToLocalView(e,t){for(const r of this.baseMutations)r.key.isEqual(e.key)&&(t=gr(r,e,t,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(e.key)&&(t=gr(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const r=Uh();return this.mutations.forEach(s=>{const i=e.get(s.key),a=i.overlayedDocument;let c=this.applyToLocalView(a,i.mutatedFields);c=t.has(s.key)?null:c;const l=zh(a,c);l!==null&&r.set(s.key,l),a.isValidDocument()||a.convertToNoDocument(q.min())}),r}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),G())}isEqual(e){return this.batchId===e.batchId&&Sn(this.mutations,e.mutations,(t,r)=>Nu(t,r))&&Sn(this.baseMutations,e.baseMutations,(t,r)=>Nu(t,r))}}class Qo{constructor(e,t,r,s){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=s}static from(e,t,r){Q(e.mutations.length===r.length,58842,{fe:e.mutations.length,ge:r.length});let s=function(){return Ky}();const i=e.mutations;for(let a=0;a<i.length;a++)s=s.insert(i[a].key,r[a].version);return new Qo(e,t,r,s)}}/**
2289
- * @license
2290
- * Copyright 2022 Google LLC
2291
- *
2292
- * Licensed under the Apache License, Version 2.0 (the "License");
2293
- * you may not use this file except in compliance with the License.
2294
- * You may obtain a copy of the License at
2295
- *
2296
- * http://www.apache.org/licenses/LICENSE-2.0
2297
- *
2298
- * Unless required by applicable law or agreed to in writing, software
2299
- * distributed under the License is distributed on an "AS IS" BASIS,
2300
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2301
- * See the License for the specific language governing permissions and
2302
- * limitations under the License.
2303
- */class aE{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{
2304
- largestBatchId: ${this.largestBatchId},
2305
- mutation: ${this.mutation.toString()}
2306
- }`}}/**
2307
- * @license
2308
- * Copyright 2017 Google LLC
2309
- *
2310
- * Licensed under the Apache License, Version 2.0 (the "License");
2311
- * you may not use this file except in compliance with the License.
2312
- * You may obtain a copy of the License at
2313
- *
2314
- * http://www.apache.org/licenses/LICENSE-2.0
2315
- *
2316
- * Unless required by applicable law or agreed to in writing, software
2317
- * distributed under the License is distributed on an "AS IS" BASIS,
2318
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2319
- * See the License for the specific language governing permissions and
2320
- * limitations under the License.
2321
- */class cE{constructor(e,t){this.count=e,this.unchangedNames=t}}/**
2322
- * @license
2323
- * Copyright 2017 Google LLC
2324
- *
2325
- * Licensed under the Apache License, Version 2.0 (the "License");
2326
- * you may not use this file except in compliance with the License.
2327
- * You may obtain a copy of the License at
2328
- *
2329
- * http://www.apache.org/licenses/LICENSE-2.0
2330
- *
2331
- * Unless required by applicable law or agreed to in writing, software
2332
- * distributed under the License is distributed on an "AS IS" BASIS,
2333
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2334
- * See the License for the specific language governing permissions and
2335
- * limitations under the License.
2336
- */var oe,W;function uE(n){switch(n){case P.OK:return F(64938);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;default:return F(15467,{code:n})}}function Gh(n){if(n===void 0)return dt("GRPC error has no .code"),P.UNKNOWN;switch(n){case oe.OK:return P.OK;case oe.CANCELLED:return P.CANCELLED;case oe.UNKNOWN:return P.UNKNOWN;case oe.DEADLINE_EXCEEDED:return P.DEADLINE_EXCEEDED;case oe.RESOURCE_EXHAUSTED:return P.RESOURCE_EXHAUSTED;case oe.INTERNAL:return P.INTERNAL;case oe.UNAVAILABLE:return P.UNAVAILABLE;case oe.UNAUTHENTICATED:return P.UNAUTHENTICATED;case oe.INVALID_ARGUMENT:return P.INVALID_ARGUMENT;case oe.NOT_FOUND:return P.NOT_FOUND;case oe.ALREADY_EXISTS:return P.ALREADY_EXISTS;case oe.PERMISSION_DENIED:return P.PERMISSION_DENIED;case oe.FAILED_PRECONDITION:return P.FAILED_PRECONDITION;case oe.ABORTED:return P.ABORTED;case oe.OUT_OF_RANGE:return P.OUT_OF_RANGE;case oe.UNIMPLEMENTED:return P.UNIMPLEMENTED;case oe.DATA_LOSS:return P.DATA_LOSS;default:return F(39323,{code:n})}}(W=oe||(oe={}))[W.OK=0]="OK",W[W.CANCELLED=1]="CANCELLED",W[W.UNKNOWN=2]="UNKNOWN",W[W.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",W[W.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",W[W.NOT_FOUND=5]="NOT_FOUND",W[W.ALREADY_EXISTS=6]="ALREADY_EXISTS",W[W.PERMISSION_DENIED=7]="PERMISSION_DENIED",W[W.UNAUTHENTICATED=16]="UNAUTHENTICATED",W[W.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",W[W.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",W[W.ABORTED=10]="ABORTED",W[W.OUT_OF_RANGE=11]="OUT_OF_RANGE",W[W.UNIMPLEMENTED=12]="UNIMPLEMENTED",W[W.INTERNAL=13]="INTERNAL",W[W.UNAVAILABLE=14]="UNAVAILABLE",W[W.DATA_LOSS=15]="DATA_LOSS";/**
2337
- * @license
2338
- * Copyright 2022 Google LLC
2339
- *
2340
- * Licensed under the Apache License, Version 2.0 (the "License");
2341
- * you may not use this file except in compliance with the License.
2342
- * You may obtain a copy of the License at
2343
- *
2344
- * http://www.apache.org/licenses/LICENSE-2.0
2345
- *
2346
- * Unless required by applicable law or agreed to in writing, software
2347
- * distributed under the License is distributed on an "AS IS" BASIS,
2348
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2349
- * See the License for the specific language governing permissions and
2350
- * limitations under the License.
2351
- */const lE=new bt([4294967295,4294967295],0);function Ou(n){const e=gh().encode(n),t=new ch;return t.update(e),new Uint8Array(t.digest())}function Lu(n){const e=new DataView(n.buffer),t=e.getUint32(0,!0),r=e.getUint32(4,!0),s=e.getUint32(8,!0),i=e.getUint32(12,!0);return[new bt([t,r],0),new bt([s,i],0)]}class Xo{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new lr(`Invalid padding: ${t}`);if(r<0)throw new lr(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new lr(`Invalid hash count: ${r}`);if(e.length===0&&t!==0)throw new lr(`Invalid padding when bitmap length is 0: ${t}`);this.pe=8*e.length-t,this.ye=bt.fromNumber(this.pe)}we(e,t,r){let s=e.add(t.multiply(bt.fromNumber(r)));return s.compare(lE)===1&&(s=new bt([s.getBits(0),s.getBits(1)],0)),s.modulo(this.ye).toNumber()}Se(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.pe===0)return!1;const t=Ou(e),[r,s]=Lu(t);for(let i=0;i<this.hashCount;i++){const a=this.we(r,s,i);if(!this.Se(a))return!1}return!0}static create(e,t,r){const s=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),a=new Xo(i,s,t);return r.forEach(c=>a.insert(c)),a}insert(e){if(this.pe===0)return;const t=Ou(e),[r,s]=Lu(t);for(let i=0;i<this.hashCount;i++){const a=this.we(r,s,i);this.be(a)}}be(e){const t=Math.floor(e/8),r=e%8;this.bitmap[t]|=1<<r}}class lr extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}/**
2352
- * @license
2353
- * Copyright 2017 Google LLC
2354
- *
2355
- * Licensed under the Apache License, Version 2.0 (the "License");
2356
- * you may not use this file except in compliance with the License.
2357
- * You may obtain a copy of the License at
2358
- *
2359
- * http://www.apache.org/licenses/LICENSE-2.0
2360
- *
2361
- * Unless required by applicable law or agreed to in writing, software
2362
- * distributed under the License is distributed on an "AS IS" BASIS,
2363
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2364
- * See the License for the specific language governing permissions and
2365
- * limitations under the License.
2366
- */class ui{constructor(e,t,r,s,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=s,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,r){const s=new Map;return s.set(e,xr.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new ui(q.min(),s,new ne(z),ft(),G())}}class xr{constructor(e,t,r,s,i){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=s,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new xr(r,t,G(),G(),G())}}/**
2367
- * @license
2368
- * Copyright 2017 Google LLC
2369
- *
2370
- * Licensed under the Apache License, Version 2.0 (the "License");
2371
- * you may not use this file except in compliance with the License.
2372
- * You may obtain a copy of the License at
2373
- *
2374
- * http://www.apache.org/licenses/LICENSE-2.0
2375
- *
2376
- * Unless required by applicable law or agreed to in writing, software
2377
- * distributed under the License is distributed on an "AS IS" BASIS,
2378
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2379
- * See the License for the specific language governing permissions and
2380
- * limitations under the License.
2381
- */class Is{constructor(e,t,r,s){this.De=e,this.removedTargetIds=t,this.key=r,this.ve=s}}class Wh{constructor(e,t){this.targetId=e,this.Ce=t}}class Kh{constructor(e,t,r=me.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}}class xu{constructor(){this.Fe=0,this.Me=Mu(),this.xe=me.EMPTY_BYTE_STRING,this.Oe=!1,this.Ne=!0}get current(){return this.Oe}get resumeToken(){return this.xe}get Be(){return this.Fe!==0}get Le(){return this.Ne}ke(e){e.approximateByteSize()>0&&(this.Ne=!0,this.xe=e)}qe(){let e=G(),t=G(),r=G();return this.Me.forEach((s,i)=>{switch(i){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:r=r.add(s);break;default:F(38017,{changeType:i})}}),new xr(this.xe,this.Oe,e,t,r)}Qe(){this.Ne=!1,this.Me=Mu()}$e(e,t){this.Ne=!0,this.Me=this.Me.insert(e,t)}Ue(e){this.Ne=!0,this.Me=this.Me.remove(e)}Ke(){this.Fe+=1}We(){this.Fe-=1,Q(this.Fe>=0,3241,{Fe:this.Fe})}Ge(){this.Ne=!0,this.Oe=!0}}class hE{constructor(e){this.ze=e,this.je=new Map,this.He=ft(),this.Je=ls(),this.Ye=ls(),this.Ze=new ne(z)}Xe(e){for(const t of e.De)e.ve&&e.ve.isFoundDocument()?this.et(t,e.ve):this.tt(t,e.key,e.ve);for(const t of e.removedTargetIds)this.tt(t,e.key,e.ve)}nt(e){this.forEachTarget(e,t=>{const r=this.rt(t);switch(e.state){case 0:this.it(t)&&r.ke(e.resumeToken);break;case 1:r.We(),r.Be||r.Qe(),r.ke(e.resumeToken);break;case 2:r.We(),r.Be||this.removeTarget(t);break;case 3:this.it(t)&&(r.Ge(),r.ke(e.resumeToken));break;case 4:this.it(t)&&(this.st(t),r.ke(e.resumeToken));break;default:F(56790,{state:e.state})}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.je.forEach((r,s)=>{this.it(s)&&t(s)})}ot(e){const t=e.targetId,r=e.Ce.count,s=this._t(t);if(s){const i=s.target;if(mo(i))if(r===0){const a=new L(i.path);this.tt(t,a,Ie.newNoDocument(a,q.min()))}else Q(r===1,20013,{expectedCount:r});else{const a=this.ut(t);if(a!==r){const c=this.ct(e),l=c?this.lt(c,e,a):1;if(l!==0){this.st(t);const d=l===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ze=this.Ze.insert(t,d)}}}}}ct(e){const t=e.Ce.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:i=0}=t;let a,c;try{a=Nt(r).toUint8Array()}catch(l){if(l instanceof Th)return Pn("Decoding the base64 bloom filter in existence filter failed ("+l.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw l}try{c=new Xo(a,s,i)}catch(l){return Pn(l instanceof lr?"BloomFilter error: ":"Applying bloom filter failed: ",l),null}return c.pe===0?null:c}lt(e,t,r){return t.Ce.count===r-this.Tt(e,t.targetId)?0:2}Tt(e,t){const r=this.ze.getRemoteKeysForTarget(t);let s=0;return r.forEach(i=>{const a=this.ze.Pt(),c=`projects/${a.projectId}/databases/${a.database}/documents/${i.path.canonicalString()}`;e.mightContain(c)||(this.tt(t,i,null),s++)}),s}It(e){const t=new Map;this.je.forEach((i,a)=>{const c=this._t(a);if(c){if(i.current&&mo(c.target)){const l=new L(c.target.path);this.Et(l).has(a)||this.dt(a,l)||this.tt(a,l,Ie.newNoDocument(l,e))}i.Le&&(t.set(a,i.qe()),i.Qe())}});let r=G();this.Ye.forEach((i,a)=>{let c=!0;a.forEachWhile(l=>{const d=this._t(l);return!d||d.purpose==="TargetPurposeLimboResolution"||(c=!1,!1)}),c&&(r=r.add(i))}),this.He.forEach((i,a)=>a.setReadTime(e));const s=new ui(e,t,this.Ze,this.He,r);return this.He=ft(),this.Je=ls(),this.Ye=ls(),this.Ze=new ne(z),s}et(e,t){if(!this.it(e))return;const r=this.dt(e,t.key)?2:0;this.rt(e).$e(t.key,r),this.He=this.He.insert(t.key,t),this.Je=this.Je.insert(t.key,this.Et(t.key).add(e)),this.Ye=this.Ye.insert(t.key,this.At(t.key).add(e))}tt(e,t,r){if(!this.it(e))return;const s=this.rt(e);this.dt(e,t)?s.$e(t,1):s.Ue(t),this.Ye=this.Ye.insert(t,this.At(t).delete(e)),this.Ye=this.Ye.insert(t,this.At(t).add(e)),r&&(this.He=this.He.insert(t,r))}removeTarget(e){this.je.delete(e)}ut(e){const t=this.rt(e).qe();return this.ze.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ke(e){this.rt(e).Ke()}rt(e){let t=this.je.get(e);return t||(t=new xu,this.je.set(e,t)),t}At(e){let t=this.Ye.get(e);return t||(t=new le(z),this.Ye=this.Ye.insert(e,t)),t}Et(e){let t=this.Je.get(e);return t||(t=new le(z),this.Je=this.Je.insert(e,t)),t}it(e){const t=this._t(e)!==null;return t||O("WatchChangeAggregator","Detected inactive target",e),t}_t(e){const t=this.je.get(e);return t&&t.Be?null:this.ze.Rt(e)}st(e){this.je.set(e,new xu),this.ze.getRemoteKeysForTarget(e).forEach(t=>{this.tt(e,t,null)})}dt(e,t){return this.ze.getRemoteKeysForTarget(e).has(t)}}function ls(){return new ne(L.comparator)}function Mu(){return new ne(L.comparator)}const dE={asc:"ASCENDING",desc:"DESCENDING"},fE={"<":"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"},pE={and:"AND",or:"OR"};class mE{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function _o(n,e){return n.useProto3Json||ti(e)?e:{value:e}}function qs(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function Qh(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function gE(n,e){return qs(n,e.toTimestamp())}function Ye(n){return Q(!!n,49232),q.fromTimestamp(function(t){const r=kt(t);return new ue(r.seconds,r.nanos)}(n))}function Yo(n,e){return yo(n,e).canonicalString()}function yo(n,e){const t=function(s){return new J(["projects",s.projectId,"databases",s.database])}(n).child("documents");return e===void 0?t:t.child(e)}function Xh(n){const e=J.fromString(n);return Q(td(e),10190,{key:e.toString()}),e}function Eo(n,e){return Yo(n.databaseId,e.path)}function Qi(n,e){const t=Xh(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 L(Jh(t))}function Yh(n,e){return Yo(n.databaseId,e)}function _E(n){const e=Xh(n);return e.length===4?J.emptyPath():Jh(e)}function To(n){return new J(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function Jh(n){return Q(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function Uu(n,e,t){return{name:Eo(n,e),fields:t.value.mapValue.fields}}function yE(n,e){let t;if("targetChange"in e){e.targetChange;const r=function(d){return d==="NO_CHANGE"?0:d==="ADD"?1:d==="REMOVE"?2:d==="CURRENT"?3:d==="RESET"?4:F(39313,{state:d})}(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],i=function(d,f){return d.useProto3Json?(Q(f===void 0||typeof f=="string",58123),me.fromBase64String(f||"")):(Q(f===void 0||f instanceof Buffer||f instanceof Uint8Array,16193),me.fromUint8Array(f||new Uint8Array))}(n,e.targetChange.resumeToken),a=e.targetChange.cause,c=a&&function(d){const f=d.code===void 0?P.UNKNOWN:Gh(d.code);return new V(f,d.message||"")}(a);t=new Kh(r,s,i,c||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=Qi(n,r.document.name),i=Ye(r.document.updateTime),a=r.document.createTime?Ye(r.document.createTime):q.min(),c=new Oe({mapValue:{fields:r.document.fields}}),l=Ie.newFoundDocument(s,i,a,c),d=r.targetIds||[],f=r.removedTargetIds||[];t=new Is(d,f,l.key,l)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=Qi(n,r.document),i=r.readTime?Ye(r.readTime):q.min(),a=Ie.newNoDocument(s,i),c=r.removedTargetIds||[];t=new Is([],c,a.key,a)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=Qi(n,r.document),i=r.removedTargetIds||[];t=new Is([],i,s,null)}else{if(!("filter"in e))return F(11601,{Vt:e});{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:i}=r,a=new cE(s,i),c=r.targetId;t=new Wh(c,a)}}return t}function EE(n,e){let t;if(e instanceof Lr)t={update:Uu(n,e.key,e.value)};else if(e instanceof Ko)t={delete:Eo(n,e.key)};else if(e instanceof cn)t={update:Uu(n,e.key,e.data),updateMask:SE(e.fieldMask)};else{if(!(e instanceof iE))return F(16599,{ft:e.type});t={verify:Eo(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map(r=>function(i,a){const c=a.transform;if(c instanceof Fs)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(c instanceof br)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:c.elements}};if(c instanceof Pr)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:c.elements}};if(c instanceof Bs)return{fieldPath:a.field.canonicalString(),increment:c.Re};throw F(20930,{transform:a.transform})}(0,r))),e.precondition.isNone||(t.currentDocument=function(s,i){return i.updateTime!==void 0?{updateTime:gE(s,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:F(27497)}(n,e.precondition)),t}function TE(n,e){return n&&n.length>0?(Q(e!==void 0,14353),n.map(t=>function(s,i){let a=s.updateTime?Ye(s.updateTime):Ye(i);return a.isEqual(q.min())&&(a=Ye(i)),new nE(a,s.transformResults||[])}(t,e))):[]}function vE(n,e){return{documents:[Yh(n,e.path)]}}function IE(n,e){const t={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=Yh(n,s);const i=function(d){if(d.length!==0)return ed($e.create(d,"and"))}(e.filters);i&&(t.structuredQuery.where=i);const a=function(d){if(d.length!==0)return d.map(f=>function(_){return{field:yn(_.field),direction:RE(_.dir)}}(f))}(e.orderBy);a&&(t.structuredQuery.orderBy=a);const c=_o(n,e.limit);return c!==null&&(t.structuredQuery.limit=c),e.startAt&&(t.structuredQuery.startAt=function(d){return{before:d.inclusive,values:d.position}}(e.startAt)),e.endAt&&(t.structuredQuery.endAt=function(d){return{before:!d.inclusive,values:d.position}}(e.endAt)),{gt:t,parent:s}}function wE(n){let e=_E(n.parent);const t=n.structuredQuery,r=t.from?t.from.length:0;let s=null;if(r>0){Q(r===1,65062);const f=t.from[0];f.allDescendants?s=f.collectionId:e=e.child(f.collectionId)}let i=[];t.where&&(i=function(m){const _=Zh(m);return _ instanceof $e&&kh(_)?_.getFilters():[_]}(t.where));let a=[];t.orderBy&&(a=function(m){return m.map(_=>function(S){return new Rr(En(S.field),function(k){switch(k){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(S.direction))}(_))}(t.orderBy));let c=null;t.limit&&(c=function(m){let _;return _=typeof m=="object"?m.value:m,ti(_)?null:_}(t.limit));let l=null;t.startAt&&(l=function(m){const _=!!m.before,R=m.values||[];return new Nn(R,_)}(t.startAt));let d=null;return t.endAt&&(d=function(m){const _=!m.before,R=m.values||[];return new Nn(R,_)}(t.endAt)),$y(e,s,a,i,c,"F",l,d)}function AE(n,e){const t=function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return F(28987,{purpose:s})}}(e.purpose);return t==null?null:{"goog-listen-tags":t}}function Zh(n){return n.unaryFilter!==void 0?function(t){switch(t.unaryFilter.op){case"IS_NAN":const r=En(t.unaryFilter.field);return ae.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=En(t.unaryFilter.field);return ae.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const i=En(t.unaryFilter.field);return ae.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=En(t.unaryFilter.field);return ae.create(a,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return F(61313);default:return F(60726)}}(n):n.fieldFilter!==void 0?function(t){return ae.create(En(t.fieldFilter.field),function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return F(58110);default:return F(50506)}}(t.fieldFilter.op),t.fieldFilter.value)}(n):n.compositeFilter!==void 0?function(t){return $e.create(t.compositeFilter.filters.map(r=>Zh(r)),function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return F(1026)}}(t.compositeFilter.op))}(n):F(30097,{filter:n})}function RE(n){return dE[n]}function bE(n){return fE[n]}function PE(n){return pE[n]}function yn(n){return{fieldPath:n.canonicalString()}}function En(n){return pe.fromServerFormat(n.fieldPath)}function ed(n){return n instanceof ae?function(t){if(t.op==="=="){if(Ru(t.value))return{unaryFilter:{field:yn(t.field),op:"IS_NAN"}};if(Au(t.value))return{unaryFilter:{field:yn(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(Ru(t.value))return{unaryFilter:{field:yn(t.field),op:"IS_NOT_NAN"}};if(Au(t.value))return{unaryFilter:{field:yn(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:yn(t.field),op:bE(t.op),value:t.value}}}(n):n instanceof $e?function(t){const r=t.getFilters().map(s=>ed(s));return r.length===1?r[0]:{compositeFilter:{op:PE(t.op),filters:r}}}(n):F(54877,{filter:n})}function SE(n){const e=[];return n.fields.forEach(t=>e.push(t.canonicalString())),{fieldPaths:e}}function td(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}/**
2382
- * @license
2383
- * Copyright 2017 Google LLC
2384
- *
2385
- * Licensed under the Apache License, Version 2.0 (the "License");
2386
- * you may not use this file except in compliance with the License.
2387
- * You may obtain a copy of the License at
2388
- *
2389
- * http://www.apache.org/licenses/LICENSE-2.0
2390
- *
2391
- * Unless required by applicable law or agreed to in writing, software
2392
- * distributed under the License is distributed on an "AS IS" BASIS,
2393
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2394
- * See the License for the specific language governing permissions and
2395
- * limitations under the License.
2396
- */class At{constructor(e,t,r,s,i=q.min(),a=q.min(),c=me.EMPTY_BYTE_STRING,l=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=c,this.expectedCount=l}withSequenceNumber(e){return new At(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new At(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new At(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new At(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}/**
2397
- * @license
2398
- * Copyright 2017 Google LLC
2399
- *
2400
- * Licensed under the Apache License, Version 2.0 (the "License");
2401
- * you may not use this file except in compliance with the License.
2402
- * You may obtain a copy of the License at
2403
- *
2404
- * http://www.apache.org/licenses/LICENSE-2.0
2405
- *
2406
- * Unless required by applicable law or agreed to in writing, software
2407
- * distributed under the License is distributed on an "AS IS" BASIS,
2408
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2409
- * See the License for the specific language governing permissions and
2410
- * limitations under the License.
2411
- */class CE{constructor(e){this.wt=e}}function kE(n){const e=wE({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?Us(e,e.limit,"L"):e}/**
2412
- * @license
2413
- * Copyright 2019 Google LLC
2414
- *
2415
- * Licensed under the Apache License, Version 2.0 (the "License");
2416
- * you may not use this file except in compliance with the License.
2417
- * You may obtain a copy of the License at
2418
- *
2419
- * http://www.apache.org/licenses/LICENSE-2.0
2420
- *
2421
- * Unless required by applicable law or agreed to in writing, software
2422
- * distributed under the License is distributed on an "AS IS" BASIS,
2423
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2424
- * See the License for the specific language governing permissions and
2425
- * limitations under the License.
2426
- */class NE{constructor(){this.Cn=new DE}addToCollectionParentIndex(e,t){return this.Cn.add(t),C.resolve()}getCollectionParents(e,t){return C.resolve(this.Cn.getEntries(t))}addFieldIndex(e,t){return C.resolve()}deleteFieldIndex(e,t){return C.resolve()}deleteAllFieldIndexes(e){return C.resolve()}createTargetIndexes(e,t){return C.resolve()}getDocumentsMatchingTarget(e,t){return C.resolve(null)}getIndexType(e,t){return C.resolve(0)}getFieldIndexes(e,t){return C.resolve([])}getNextCollectionGroupToUpdate(e){return C.resolve(null)}getMinOffset(e,t){return C.resolve(Ct.min())}getMinOffsetFromCollectionGroup(e,t){return C.resolve(Ct.min())}updateCollectionGroup(e,t,r){return C.resolve()}updateIndexEntries(e,t){return C.resolve()}}class DE{constructor(){this.index={}}add(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t]||new le(J.comparator),i=!s.has(r);return this.index[t]=s.add(r),i}has(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t];return s&&s.has(r)}getEntries(e){return(this.index[e]||new le(J.comparator)).toArray()}}/**
2427
- * @license
2428
- * Copyright 2018 Google LLC
2429
- *
2430
- * Licensed under the Apache License, Version 2.0 (the "License");
2431
- * you may not use this file except in compliance with the License.
2432
- * You may obtain a copy of the License at
2433
- *
2434
- * http://www.apache.org/licenses/LICENSE-2.0
2435
- *
2436
- * Unless required by applicable law or agreed to in writing, software
2437
- * distributed under the License is distributed on an "AS IS" BASIS,
2438
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2439
- * See the License for the specific language governing permissions and
2440
- * limitations under the License.
2441
- */const Fu={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},nd=41943040;class Ce{static withCacheSize(e){return new Ce(e,Ce.DEFAULT_COLLECTION_PERCENTILE,Ce.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}/**
2442
- * @license
2443
- * Copyright 2017 Google LLC
2444
- *
2445
- * Licensed under the Apache License, Version 2.0 (the "License");
2446
- * you may not use this file except in compliance with the License.
2447
- * You may obtain a copy of the License at
2448
- *
2449
- * http://www.apache.org/licenses/LICENSE-2.0
2450
- *
2451
- * Unless required by applicable law or agreed to in writing, software
2452
- * distributed under the License is distributed on an "AS IS" BASIS,
2453
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2454
- * See the License for the specific language governing permissions and
2455
- * limitations under the License.
2456
- */Ce.DEFAULT_COLLECTION_PERCENTILE=10,Ce.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Ce.DEFAULT=new Ce(nd,Ce.DEFAULT_COLLECTION_PERCENTILE,Ce.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Ce.DISABLED=new Ce(-1,0,0);/**
2457
- * @license
2458
- * Copyright 2017 Google LLC
2459
- *
2460
- * Licensed under the Apache License, Version 2.0 (the "License");
2461
- * you may not use this file except in compliance with the License.
2462
- * You may obtain a copy of the License at
2463
- *
2464
- * http://www.apache.org/licenses/LICENSE-2.0
2465
- *
2466
- * Unless required by applicable law or agreed to in writing, software
2467
- * distributed under the License is distributed on an "AS IS" BASIS,
2468
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2469
- * See the License for the specific language governing permissions and
2470
- * limitations under the License.
2471
- */class Dn{constructor(e){this.ur=e}next(){return this.ur+=2,this.ur}static cr(){return new Dn(0)}static lr(){return new Dn(-1)}}/**
2472
- * @license
2473
- * Copyright 2020 Google LLC
2474
- *
2475
- * Licensed under the Apache License, Version 2.0 (the "License");
2476
- * you may not use this file except in compliance with the License.
2477
- * You may obtain a copy of the License at
2478
- *
2479
- * http://www.apache.org/licenses/LICENSE-2.0
2480
- *
2481
- * Unless required by applicable law or agreed to in writing, software
2482
- * distributed under the License is distributed on an "AS IS" BASIS,
2483
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2484
- * See the License for the specific language governing permissions and
2485
- * limitations under the License.
2486
- */const Bu="LruGarbageCollector",VE=1048576;function qu([n,e],[t,r]){const s=z(n,t);return s===0?z(e,r):s}class OE{constructor(e){this.Er=e,this.buffer=new le(qu),this.dr=0}Ar(){return++this.dr}Rr(e){const t=[e,this.Ar()];if(this.buffer.size<this.Er)this.buffer=this.buffer.add(t);else{const r=this.buffer.last();qu(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}}class LE{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Vr=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.mr(6e4)}stop(){this.Vr&&(this.Vr.cancel(),this.Vr=null)}get started(){return this.Vr!==null}mr(e){O(Bu,`Garbage collection scheduled in ${e}ms`),this.Vr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Vr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){Un(t)?O(Bu,"Ignoring IndexedDB error during garbage collection: ",t):await Mn(t)}await this.mr(3e5)})}}class xE{constructor(e,t){this.gr=e,this.params=t}calculateTargetCount(e,t){return this.gr.pr(e).next(r=>Math.floor(t/100*r))}nthSequenceNumber(e,t){if(t===0)return C.resolve(ei.le);const r=new OE(t);return this.gr.forEachTarget(e,s=>r.Rr(s.sequenceNumber)).next(()=>this.gr.yr(e,s=>r.Rr(s))).next(()=>r.maxValue)}removeTargets(e,t,r){return this.gr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.gr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(O("LruGarbageCollector","Garbage collection skipped; disabled"),C.resolve(Fu)):this.getCacheSize(e).next(r=>r<this.params.cacheSizeCollectionThreshold?(O("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Fu):this.wr(e,t))}getCacheSize(e){return this.gr.getCacheSize(e)}wr(e,t){let r,s,i,a,c,l,d;const f=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(m=>(m>this.params.maximumSequenceNumbersToCollect?(O("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${m}`),s=this.params.maximumSequenceNumbersToCollect):s=m,a=Date.now(),this.nthSequenceNumber(e,s))).next(m=>(r=m,c=Date.now(),this.removeTargets(e,r,t))).next(m=>(i=m,l=Date.now(),this.removeOrphanedDocuments(e,r))).next(m=>(d=Date.now(),gn()<=H.DEBUG&&O("LruGarbageCollector",`LRU Garbage Collection
2487
- Counted targets in ${a-f}ms
2488
- Determined least recently used ${s} in `+(c-a)+`ms
2489
- Removed ${i} targets in `+(l-c)+`ms
2490
- Removed ${m} documents in `+(d-l)+`ms
2491
- Total Duration: ${d-f}ms`),C.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:i,documentsRemoved:m})))}}function ME(n,e){return new xE(n,e)}/**
2492
- * @license
2493
- * Copyright 2017 Google LLC
2494
- *
2495
- * Licensed under the Apache License, Version 2.0 (the "License");
2496
- * you may not use this file except in compliance with the License.
2497
- * You may obtain a copy of the License at
2498
- *
2499
- * http://www.apache.org/licenses/LICENSE-2.0
2500
- *
2501
- * Unless required by applicable law or agreed to in writing, software
2502
- * distributed under the License is distributed on an "AS IS" BASIS,
2503
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2504
- * See the License for the specific language governing permissions and
2505
- * limitations under the License.
2506
- */class UE{constructor(){this.changes=new an(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,Ie.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const r=this.changes.get(t);return r!==void 0?C.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}/**
2507
- * @license
2508
- * Copyright 2017 Google LLC
2509
- *
2510
- * Licensed under the Apache License, Version 2.0 (the "License");
2511
- * you may not use this file except in compliance with the License.
2512
- * You may obtain a copy of the License at
2513
- *
2514
- * http://www.apache.org/licenses/LICENSE-2.0
2515
- *
2516
- * Unless required by applicable law or agreed to in writing, software
2517
- * distributed under the License is distributed on an "AS IS" BASIS,
2518
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2519
- * See the License for the specific language governing permissions and
2520
- * limitations under the License.
2521
- *//**
2522
- * @license
2523
- * Copyright 2022 Google LLC
2524
- *
2525
- * Licensed under the Apache License, Version 2.0 (the "License");
2526
- * you may not use this file except in compliance with the License.
2527
- * You may obtain a copy of the License at
2528
- *
2529
- * http://www.apache.org/licenses/LICENSE-2.0
2530
- *
2531
- * Unless required by applicable law or agreed to in writing, software
2532
- * distributed under the License is distributed on an "AS IS" BASIS,
2533
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2534
- * See the License for the specific language governing permissions and
2535
- * limitations under the License.
2536
- */class FE{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}/**
2537
- * @license
2538
- * Copyright 2017 Google LLC
2539
- *
2540
- * Licensed under the Apache License, Version 2.0 (the "License");
2541
- * you may not use this file except in compliance with the License.
2542
- * You may obtain a copy of the License at
2543
- *
2544
- * http://www.apache.org/licenses/LICENSE-2.0
2545
- *
2546
- * Unless required by applicable law or agreed to in writing, software
2547
- * distributed under the License is distributed on an "AS IS" BASIS,
2548
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2549
- * See the License for the specific language governing permissions and
2550
- * limitations under the License.
2551
- */class BE{constructor(e,t,r,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next(s=>(r=s,this.remoteDocumentCache.getEntry(e,t))).next(s=>(r!==null&&gr(r.mutation,s,Be.empty(),ue.now()),s))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(r=>this.getLocalViewOfDocuments(e,r,G()).next(()=>r))}getLocalViewOfDocuments(e,t,r=G()){const s=Qt();return this.populateOverlays(e,s,t).next(()=>this.computeViews(e,t,s,r).next(i=>{let a=ur();return i.forEach((c,l)=>{a=a.insert(c,l.overlayedDocument)}),a}))}getOverlayedDocuments(e,t){const r=Qt();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,G()))}populateOverlays(e,t,r){const s=[];return r.forEach(i=>{t.has(i)||s.push(i)}),this.documentOverlayCache.getOverlays(e,s).next(i=>{i.forEach((a,c)=>{t.set(a,c)})})}computeViews(e,t,r,s){let i=ft();const a=mr(),c=function(){return mr()}();return t.forEach((l,d)=>{const f=r.get(d.key);s.has(d.key)&&(f===void 0||f.mutation instanceof cn)?i=i.insert(d.key,d):f!==void 0?(a.set(d.key,f.mutation.getFieldMask()),gr(f.mutation,d,f.mutation.getFieldMask(),ue.now())):a.set(d.key,Be.empty())}),this.recalculateAndSaveOverlays(e,i).next(l=>(l.forEach((d,f)=>a.set(d,f)),t.forEach((d,f)=>{var m;return c.set(d,new FE(f,(m=a.get(d))!==null&&m!==void 0?m:null))}),c))}recalculateAndSaveOverlays(e,t){const r=mr();let s=new ne((a,c)=>a-c),i=G();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(a=>{for(const c of a)c.keys().forEach(l=>{const d=t.get(l);if(d===null)return;let f=r.get(l)||Be.empty();f=c.applyToLocalView(d,f),r.set(l,f);const m=(s.get(c.batchId)||G()).add(l);s=s.insert(c.batchId,m)})}).next(()=>{const a=[],c=s.getReverseIterator();for(;c.hasNext();){const l=c.getNext(),d=l.key,f=l.value,m=Uh();f.forEach(_=>{if(!i.has(_)){const R=zh(t.get(_),r.get(_));R!==null&&m.set(_,R),i=i.add(_)}}),a.push(this.documentOverlayCache.saveOverlays(e,d,m))}return C.waitFor(a)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(r=>this.recalculateAndSaveOverlays(e,r))}getDocumentsMatchingQuery(e,t,r,s){return function(a){return L.isDocumentKey(a.path)&&a.collectionGroup===null&&a.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Go(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,s):this.getDocumentsMatchingCollectionQuery(e,t,r,s)}getNextDocuments(e,t,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,s).next(i=>{const a=s-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,s-i.size):C.resolve(Qt());let c=vr,l=i;return a.next(d=>C.forEach(d,(f,m)=>(c<m.largestBatchId&&(c=m.largestBatchId),i.get(f)?C.resolve():this.remoteDocumentCache.getEntry(e,f).next(_=>{l=l.insert(f,_)}))).next(()=>this.populateOverlays(e,d,i)).next(()=>this.computeViews(e,l,d,G())).next(f=>({batchId:c,changes:Mh(f)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new L(t)).next(r=>{let s=ur();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s})}getDocumentsMatchingCollectionGroupQuery(e,t,r,s){const i=t.collectionGroup;let a=ur();return this.indexManager.getCollectionParents(e,i).next(c=>C.forEach(c,l=>{const d=function(m,_){return new Bt(_,null,m.explicitOrderBy.slice(),m.filters.slice(),m.limit,m.limitType,m.startAt,m.endAt)}(t,l.child(i));return this.getDocumentsMatchingCollectionQuery(e,d,r,s).next(f=>{f.forEach((m,_)=>{a=a.insert(m,_)})})}).next(()=>a))}getDocumentsMatchingCollectionQuery(e,t,r,s){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next(a=>(i=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,i,s))).next(a=>{i.forEach((l,d)=>{const f=d.getKey();a.get(f)===null&&(a=a.insert(f,Ie.newInvalidDocument(f)))});let c=ur();return a.forEach((l,d)=>{const f=i.get(l);f!==void 0&&gr(f.mutation,d,Be.empty(),ue.now()),oi(t,d)&&(c=c.insert(l,d))}),c})}}/**
2552
- * @license
2553
- * Copyright 2020 Google LLC
2554
- *
2555
- * Licensed under the Apache License, Version 2.0 (the "License");
2556
- * you may not use this file except in compliance with the License.
2557
- * You may obtain a copy of the License at
2558
- *
2559
- * http://www.apache.org/licenses/LICENSE-2.0
2560
- *
2561
- * Unless required by applicable law or agreed to in writing, software
2562
- * distributed under the License is distributed on an "AS IS" BASIS,
2563
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2564
- * See the License for the specific language governing permissions and
2565
- * limitations under the License.
2566
- */class qE{constructor(e){this.serializer=e,this.kr=new Map,this.qr=new Map}getBundleMetadata(e,t){return C.resolve(this.kr.get(t))}saveBundleMetadata(e,t){return this.kr.set(t.id,function(s){return{id:s.id,version:s.version,createTime:Ye(s.createTime)}}(t)),C.resolve()}getNamedQuery(e,t){return C.resolve(this.qr.get(t))}saveNamedQuery(e,t){return this.qr.set(t.name,function(s){return{name:s.name,query:kE(s.bundledQuery),readTime:Ye(s.readTime)}}(t)),C.resolve()}}/**
2567
- * @license
2568
- * Copyright 2022 Google LLC
2569
- *
2570
- * Licensed under the Apache License, Version 2.0 (the "License");
2571
- * you may not use this file except in compliance with the License.
2572
- * You may obtain a copy of the License at
2573
- *
2574
- * http://www.apache.org/licenses/LICENSE-2.0
2575
- *
2576
- * Unless required by applicable law or agreed to in writing, software
2577
- * distributed under the License is distributed on an "AS IS" BASIS,
2578
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2579
- * See the License for the specific language governing permissions and
2580
- * limitations under the License.
2581
- */class jE{constructor(){this.overlays=new ne(L.comparator),this.Qr=new Map}getOverlay(e,t){return C.resolve(this.overlays.get(t))}getOverlays(e,t){const r=Qt();return C.forEach(t,s=>this.getOverlay(e,s).next(i=>{i!==null&&r.set(s,i)})).next(()=>r)}saveOverlays(e,t,r){return r.forEach((s,i)=>{this.bt(e,t,i)}),C.resolve()}removeOverlaysForBatchId(e,t,r){const s=this.Qr.get(r);return s!==void 0&&(s.forEach(i=>this.overlays=this.overlays.remove(i)),this.Qr.delete(r)),C.resolve()}getOverlaysForCollection(e,t,r){const s=Qt(),i=t.length+1,a=new L(t.child("")),c=this.overlays.getIteratorFrom(a);for(;c.hasNext();){const l=c.getNext().value,d=l.getKey();if(!t.isPrefixOf(d.path))break;d.path.length===i&&l.largestBatchId>r&&s.set(l.getKey(),l)}return C.resolve(s)}getOverlaysForCollectionGroup(e,t,r,s){let i=new ne((d,f)=>d-f);const a=this.overlays.getIterator();for(;a.hasNext();){const d=a.getNext().value;if(d.getKey().getCollectionGroup()===t&&d.largestBatchId>r){let f=i.get(d.largestBatchId);f===null&&(f=Qt(),i=i.insert(d.largestBatchId,f)),f.set(d.getKey(),d)}}const c=Qt(),l=i.getIterator();for(;l.hasNext()&&(l.getNext().value.forEach((d,f)=>c.set(d,f)),!(c.size()>=s)););return C.resolve(c)}bt(e,t,r){const s=this.overlays.get(r.key);if(s!==null){const a=this.Qr.get(s.largestBatchId).delete(r.key);this.Qr.set(s.largestBatchId,a)}this.overlays=this.overlays.insert(r.key,new aE(t,r));let i=this.Qr.get(t);i===void 0&&(i=G(),this.Qr.set(t,i)),this.Qr.set(t,i.add(r.key))}}/**
2582
- * @license
2583
- * Copyright 2024 Google LLC
2584
- *
2585
- * Licensed under the Apache License, Version 2.0 (the "License");
2586
- * you may not use this file except in compliance with the License.
2587
- * You may obtain a copy of the License at
2588
- *
2589
- * http://www.apache.org/licenses/LICENSE-2.0
2590
- *
2591
- * Unless required by applicable law or agreed to in writing, software
2592
- * distributed under the License is distributed on an "AS IS" BASIS,
2593
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2594
- * See the License for the specific language governing permissions and
2595
- * limitations under the License.
2596
- */class $E{constructor(){this.sessionToken=me.EMPTY_BYTE_STRING}getSessionToken(e){return C.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,C.resolve()}}/**
2597
- * @license
2598
- * Copyright 2017 Google LLC
2599
- *
2600
- * Licensed under the Apache License, Version 2.0 (the "License");
2601
- * you may not use this file except in compliance with the License.
2602
- * You may obtain a copy of the License at
2603
- *
2604
- * http://www.apache.org/licenses/LICENSE-2.0
2605
- *
2606
- * Unless required by applicable law or agreed to in writing, software
2607
- * distributed under the License is distributed on an "AS IS" BASIS,
2608
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2609
- * See the License for the specific language governing permissions and
2610
- * limitations under the License.
2611
- */class Jo{constructor(){this.$r=new le(he.Ur),this.Kr=new le(he.Wr)}isEmpty(){return this.$r.isEmpty()}addReference(e,t){const r=new he(e,t);this.$r=this.$r.add(r),this.Kr=this.Kr.add(r)}Gr(e,t){e.forEach(r=>this.addReference(r,t))}removeReference(e,t){this.zr(new he(e,t))}jr(e,t){e.forEach(r=>this.removeReference(r,t))}Hr(e){const t=new L(new J([])),r=new he(t,e),s=new he(t,e+1),i=[];return this.Kr.forEachInRange([r,s],a=>{this.zr(a),i.push(a.key)}),i}Jr(){this.$r.forEach(e=>this.zr(e))}zr(e){this.$r=this.$r.delete(e),this.Kr=this.Kr.delete(e)}Yr(e){const t=new L(new J([])),r=new he(t,e),s=new he(t,e+1);let i=G();return this.Kr.forEachInRange([r,s],a=>{i=i.add(a.key)}),i}containsKey(e){const t=new he(e,0),r=this.$r.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}}class he{constructor(e,t){this.key=e,this.Zr=t}static Ur(e,t){return L.comparator(e.key,t.key)||z(e.Zr,t.Zr)}static Wr(e,t){return z(e.Zr,t.Zr)||L.comparator(e.key,t.key)}}/**
2612
- * @license
2613
- * Copyright 2017 Google LLC
2614
- *
2615
- * Licensed under the Apache License, Version 2.0 (the "License");
2616
- * you may not use this file except in compliance with the License.
2617
- * You may obtain a copy of the License at
2618
- *
2619
- * http://www.apache.org/licenses/LICENSE-2.0
2620
- *
2621
- * Unless required by applicable law or agreed to in writing, software
2622
- * distributed under the License is distributed on an "AS IS" BASIS,
2623
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2624
- * See the License for the specific language governing permissions and
2625
- * limitations under the License.
2626
- */class zE{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.nr=1,this.Xr=new le(he.Ur)}checkEmpty(e){return C.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,s){const i=this.nr;this.nr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new oE(i,t,r,s);this.mutationQueue.push(a);for(const c of s)this.Xr=this.Xr.add(new he(c.key,i)),this.indexManager.addToCollectionParentIndex(e,c.key.path.popLast());return C.resolve(a)}lookupMutationBatch(e,t){return C.resolve(this.ei(t))}getNextMutationBatchAfterBatchId(e,t){const r=t+1,s=this.ti(r),i=s<0?0:s;return C.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return C.resolve(this.mutationQueue.length===0?jo:this.nr-1)}getAllMutationBatches(e){return C.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const r=new he(t,0),s=new he(t,Number.POSITIVE_INFINITY),i=[];return this.Xr.forEachInRange([r,s],a=>{const c=this.ei(a.Zr);i.push(c)}),C.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new le(z);return t.forEach(s=>{const i=new he(s,0),a=new he(s,Number.POSITIVE_INFINITY);this.Xr.forEachInRange([i,a],c=>{r=r.add(c.Zr)})}),C.resolve(this.ni(r))}getAllMutationBatchesAffectingQuery(e,t){const r=t.path,s=r.length+1;let i=r;L.isDocumentKey(i)||(i=i.child(""));const a=new he(new L(i),0);let c=new le(z);return this.Xr.forEachWhile(l=>{const d=l.key.path;return!!r.isPrefixOf(d)&&(d.length===s&&(c=c.add(l.Zr)),!0)},a),C.resolve(this.ni(c))}ni(e){const t=[];return e.forEach(r=>{const s=this.ei(r);s!==null&&t.push(s)}),t}removeMutationBatch(e,t){Q(this.ri(t.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.Xr;return C.forEach(t.mutations,s=>{const i=new he(s.key,t.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)}).next(()=>{this.Xr=r})}sr(e){}containsKey(e,t){const r=new he(t,0),s=this.Xr.firstAfterOrEqual(r);return C.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,C.resolve()}ri(e,t){return this.ti(e)}ti(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}ei(e){const t=this.ti(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}/**
2627
- * @license
2628
- * Copyright 2017 Google LLC
2629
- *
2630
- * Licensed under the Apache License, Version 2.0 (the "License");
2631
- * you may not use this file except in compliance with the License.
2632
- * You may obtain a copy of the License at
2633
- *
2634
- * http://www.apache.org/licenses/LICENSE-2.0
2635
- *
2636
- * Unless required by applicable law or agreed to in writing, software
2637
- * distributed under the License is distributed on an "AS IS" BASIS,
2638
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2639
- * See the License for the specific language governing permissions and
2640
- * limitations under the License.
2641
- */class HE{constructor(e){this.ii=e,this.docs=function(){return new ne(L.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const r=t.key,s=this.docs.get(r),i=s?s.size:0,a=this.ii(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,r.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 r=this.docs.get(t);return C.resolve(r?r.document.mutableCopy():Ie.newInvalidDocument(t))}getEntries(e,t){let r=ft();return t.forEach(s=>{const i=this.docs.get(s);r=r.insert(s,i?i.document.mutableCopy():Ie.newInvalidDocument(s))}),C.resolve(r)}getDocumentsMatchingQuery(e,t,r,s){let i=ft();const a=t.path,c=new L(a.child("__id-9223372036854775808__")),l=this.docs.getIteratorFrom(c);for(;l.hasNext();){const{key:d,value:{document:f}}=l.getNext();if(!a.isPrefixOf(d.path))break;d.path.length>a.length+1||vy(Ty(f),r)<=0||(s.has(f.key)||oi(t,f))&&(i=i.insert(f.key,f.mutableCopy()))}return C.resolve(i)}getAllFromCollectionGroup(e,t,r,s){F(9500)}si(e,t){return C.forEach(this.docs,r=>t(r))}newChangeBuffer(e){return new GE(this)}getSize(e){return C.resolve(this.size)}}class GE extends UE{constructor(e){super(),this.Br=e}applyChanges(e){const t=[];return this.changes.forEach((r,s)=>{s.isValidDocument()?t.push(this.Br.addEntry(e,s)):this.Br.removeEntry(r)}),C.waitFor(t)}getFromCache(e,t){return this.Br.getEntry(e,t)}getAllFromCache(e,t){return this.Br.getEntries(e,t)}}/**
2642
- * @license
2643
- * Copyright 2017 Google LLC
2644
- *
2645
- * Licensed under the Apache License, Version 2.0 (the "License");
2646
- * you may not use this file except in compliance with the License.
2647
- * You may obtain a copy of the License at
2648
- *
2649
- * http://www.apache.org/licenses/LICENSE-2.0
2650
- *
2651
- * Unless required by applicable law or agreed to in writing, software
2652
- * distributed under the License is distributed on an "AS IS" BASIS,
2653
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2654
- * See the License for the specific language governing permissions and
2655
- * limitations under the License.
2656
- */class WE{constructor(e){this.persistence=e,this.oi=new an(t=>zo(t),Ho),this.lastRemoteSnapshotVersion=q.min(),this.highestTargetId=0,this._i=0,this.ai=new Jo,this.targetCount=0,this.ui=Dn.cr()}forEachTarget(e,t){return this.oi.forEach((r,s)=>t(s)),C.resolve()}getLastRemoteSnapshotVersion(e){return C.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return C.resolve(this._i)}allocateTargetId(e){return this.highestTargetId=this.ui.next(),C.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this._i&&(this._i=t),C.resolve()}Tr(e){this.oi.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.ui=new Dn(t),this.highestTargetId=t),e.sequenceNumber>this._i&&(this._i=e.sequenceNumber)}addTargetData(e,t){return this.Tr(t),this.targetCount+=1,C.resolve()}updateTargetData(e,t){return this.Tr(t),C.resolve()}removeTargetData(e,t){return this.oi.delete(t.target),this.ai.Hr(t.targetId),this.targetCount-=1,C.resolve()}removeTargets(e,t,r){let s=0;const i=[];return this.oi.forEach((a,c)=>{c.sequenceNumber<=t&&r.get(c.targetId)===null&&(this.oi.delete(a),i.push(this.removeMatchingKeysForTargetId(e,c.targetId)),s++)}),C.waitFor(i).next(()=>s)}getTargetCount(e){return C.resolve(this.targetCount)}getTargetData(e,t){const r=this.oi.get(t)||null;return C.resolve(r)}addMatchingKeys(e,t,r){return this.ai.Gr(t,r),C.resolve()}removeMatchingKeys(e,t,r){this.ai.jr(t,r);const s=this.persistence.referenceDelegate,i=[];return s&&t.forEach(a=>{i.push(s.markPotentiallyOrphaned(e,a))}),C.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.ai.Hr(t),C.resolve()}getMatchingKeysForTargetId(e,t){const r=this.ai.Yr(t);return C.resolve(r)}containsKey(e,t){return C.resolve(this.ai.containsKey(t))}}/**
2657
- * @license
2658
- * Copyright 2017 Google LLC
2659
- *
2660
- * Licensed under the Apache License, Version 2.0 (the "License");
2661
- * you may not use this file except in compliance with the License.
2662
- * You may obtain a copy of the License at
2663
- *
2664
- * http://www.apache.org/licenses/LICENSE-2.0
2665
- *
2666
- * Unless required by applicable law or agreed to in writing, software
2667
- * distributed under the License is distributed on an "AS IS" BASIS,
2668
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2669
- * See the License for the specific language governing permissions and
2670
- * limitations under the License.
2671
- */class rd{constructor(e,t){this.ci={},this.overlays={},this.li=new ei(0),this.hi=!1,this.hi=!0,this.Pi=new $E,this.referenceDelegate=e(this),this.Ti=new WE(this),this.indexManager=new NE,this.remoteDocumentCache=function(s){return new HE(s)}(r=>this.referenceDelegate.Ii(r)),this.serializer=new CE(t),this.Ei=new qE(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.hi=!1,Promise.resolve()}get started(){return this.hi}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new jE,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.ci[e.toKey()];return r||(r=new zE(t,this.referenceDelegate),this.ci[e.toKey()]=r),r}getGlobalsCache(){return this.Pi}getTargetCache(){return this.Ti}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ei}runTransaction(e,t,r){O("MemoryPersistence","Starting transaction:",e);const s=new KE(this.li.next());return this.referenceDelegate.di(),r(s).next(i=>this.referenceDelegate.Ai(s).next(()=>i)).toPromise().then(i=>(s.raiseOnCommittedEvent(),i))}Ri(e,t){return C.or(Object.values(this.ci).map(r=>()=>r.containsKey(e,t)))}}class KE extends wy{constructor(e){super(),this.currentSequenceNumber=e}}class Zo{constructor(e){this.persistence=e,this.Vi=new Jo,this.mi=null}static fi(e){return new Zo(e)}get gi(){if(this.mi)return this.mi;throw F(60996)}addReference(e,t,r){return this.Vi.addReference(r,t),this.gi.delete(r.toString()),C.resolve()}removeReference(e,t,r){return this.Vi.removeReference(r,t),this.gi.add(r.toString()),C.resolve()}markPotentiallyOrphaned(e,t){return this.gi.add(t.toString()),C.resolve()}removeTarget(e,t){this.Vi.Hr(t.targetId).forEach(s=>this.gi.add(s.toString()));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(s=>{s.forEach(i=>this.gi.add(i.toString()))}).next(()=>r.removeTargetData(e,t))}di(){this.mi=new Set}Ai(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return C.forEach(this.gi,r=>{const s=L.fromPath(r);return this.pi(e,s).next(i=>{i||t.removeEntry(s,q.min())})}).next(()=>(this.mi=null,t.apply(e)))}updateLimboDocument(e,t){return this.pi(e,t).next(r=>{r?this.gi.delete(t.toString()):this.gi.add(t.toString())})}Ii(e){return 0}pi(e,t){return C.or([()=>C.resolve(this.Vi.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ri(e,t)])}}class js{constructor(e,t){this.persistence=e,this.yi=new an(r=>by(r.path),(r,s)=>r.isEqual(s)),this.garbageCollector=ME(this,t)}static fi(e,t){return new js(e,t)}di(){}Ai(e){return C.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}pr(e){const t=this.Sr(e);return this.persistence.getTargetCache().getTargetCount(e).next(r=>t.next(s=>r+s))}Sr(e){let t=0;return this.yr(e,r=>{t++}).next(()=>t)}yr(e,t){return C.forEach(this.yi,(r,s)=>this.Dr(e,r,s).next(i=>i?C.resolve():t(s)))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0;const s=this.persistence.getRemoteDocumentCache(),i=s.newChangeBuffer();return s.si(e,a=>this.Dr(e,a,t).next(c=>{c||(r++,i.removeEntry(a,q.min()))})).next(()=>i.apply(e)).next(()=>r)}markPotentiallyOrphaned(e,t){return this.yi.set(t,e.currentSequenceNumber),C.resolve()}removeTarget(e,t){const r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.yi.set(r,e.currentSequenceNumber),C.resolve()}removeReference(e,t,r){return this.yi.set(r,e.currentSequenceNumber),C.resolve()}updateLimboDocument(e,t){return this.yi.set(t,e.currentSequenceNumber),C.resolve()}Ii(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Es(e.data.value)),t}Dr(e,t,r){return C.or([()=>this.persistence.Ri(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const s=this.yi.get(t);return C.resolve(s!==void 0&&s>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}/**
2672
- * @license
2673
- * Copyright 2017 Google LLC
2674
- *
2675
- * Licensed under the Apache License, Version 2.0 (the "License");
2676
- * you may not use this file except in compliance with the License.
2677
- * You may obtain a copy of the License at
2678
- *
2679
- * http://www.apache.org/licenses/LICENSE-2.0
2680
- *
2681
- * Unless required by applicable law or agreed to in writing, software
2682
- * distributed under the License is distributed on an "AS IS" BASIS,
2683
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2684
- * See the License for the specific language governing permissions and
2685
- * limitations under the License.
2686
- */class ea{constructor(e,t,r,s){this.targetId=e,this.fromCache=t,this.ds=r,this.As=s}static Rs(e,t){let r=G(),s=G();for(const i of t.docChanges)switch(i.type){case 0:r=r.add(i.doc.key);break;case 1:s=s.add(i.doc.key)}return new ea(e,t.fromCache,r,s)}}/**
2687
- * @license
2688
- * Copyright 2023 Google LLC
2689
- *
2690
- * Licensed under the Apache License, Version 2.0 (the "License");
2691
- * you may not use this file except in compliance with the License.
2692
- * You may obtain a copy of the License at
2693
- *
2694
- * http://www.apache.org/licenses/LICENSE-2.0
2695
- *
2696
- * Unless required by applicable law or agreed to in writing, software
2697
- * distributed under the License is distributed on an "AS IS" BASIS,
2698
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2699
- * See the License for the specific language governing permissions and
2700
- * limitations under the License.
2701
- */class QE{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}/**
2702
- * @license
2703
- * Copyright 2019 Google LLC
2704
- *
2705
- * Licensed under the Apache License, Version 2.0 (the "License");
2706
- * you may not use this file except in compliance with the License.
2707
- * You may obtain a copy of the License at
2708
- *
2709
- * http://www.apache.org/licenses/LICENSE-2.0
2710
- *
2711
- * Unless required by applicable law or agreed to in writing, software
2712
- * distributed under the License is distributed on an "AS IS" BASIS,
2713
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2714
- * See the License for the specific language governing permissions and
2715
- * limitations under the License.
2716
- */class XE{constructor(){this.Vs=!1,this.fs=!1,this.gs=100,this.ps=function(){return Ep()?8:Ay(we())>0?6:4}()}initialize(e,t){this.ys=e,this.indexManager=t,this.Vs=!0}getDocumentsMatchingQuery(e,t,r,s){const i={result:null};return this.ws(e,t).next(a=>{i.result=a}).next(()=>{if(!i.result)return this.Ss(e,t,s,r).next(a=>{i.result=a})}).next(()=>{if(i.result)return;const a=new QE;return this.bs(e,t,a).next(c=>{if(i.result=c,this.fs)return this.Ds(e,t,a,c.size)})}).next(()=>i.result)}Ds(e,t,r,s){return r.documentReadCount<this.gs?(gn()<=H.DEBUG&&O("QueryEngine","SDK will not create cache indexes for query:",_n(t),"since it only creates cache indexes for collection contains","more than or equal to",this.gs,"documents"),C.resolve()):(gn()<=H.DEBUG&&O("QueryEngine","Query:",_n(t),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.ps*s?(gn()<=H.DEBUG&&O("QueryEngine","The SDK decides to create cache indexes for query:",_n(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Qe(t))):C.resolve())}ws(e,t){if(Cu(t))return C.resolve(null);let r=Qe(t);return this.indexManager.getIndexType(e,r).next(s=>s===0?null:(t.limit!==null&&s===1&&(t=Us(t,null,"F"),r=Qe(t)),this.indexManager.getDocumentsMatchingTarget(e,r).next(i=>{const a=G(...i);return this.ys.getDocuments(e,a).next(c=>this.indexManager.getMinOffset(e,r).next(l=>{const d=this.vs(t,c);return this.Cs(t,d,a,l.readTime)?this.ws(e,Us(t,null,"F")):this.Fs(e,d,t,l)}))})))}Ss(e,t,r,s){return Cu(t)||s.isEqual(q.min())?C.resolve(null):this.ys.getDocuments(e,r).next(i=>{const a=this.vs(t,i);return this.Cs(t,a,r,s)?C.resolve(null):(gn()<=H.DEBUG&&O("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),_n(t)),this.Fs(e,a,t,Ey(s,vr)).next(c=>c))})}vs(e,t){let r=new le(Lh(e));return t.forEach((s,i)=>{oi(e,i)&&(r=r.add(i))}),r}Cs(e,t,r,s){if(e.limit===null)return!1;if(r.size!==t.size)return!0;const i=e.limitType==="F"?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(s)>0)}bs(e,t,r){return gn()<=H.DEBUG&&O("QueryEngine","Using full collection scan to execute query:",_n(t)),this.ys.getDocumentsMatchingQuery(e,t,Ct.min(),r)}Fs(e,t,r,s){return this.ys.getDocumentsMatchingQuery(e,r,s).next(i=>(t.forEach(a=>{i=i.insert(a.key,a)}),i))}}/**
2717
- * @license
2718
- * Copyright 2020 Google LLC
2719
- *
2720
- * Licensed under the Apache License, Version 2.0 (the "License");
2721
- * you may not use this file except in compliance with the License.
2722
- * You may obtain a copy of the License at
2723
- *
2724
- * http://www.apache.org/licenses/LICENSE-2.0
2725
- *
2726
- * Unless required by applicable law or agreed to in writing, software
2727
- * distributed under the License is distributed on an "AS IS" BASIS,
2728
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2729
- * See the License for the specific language governing permissions and
2730
- * limitations under the License.
2731
- */const ta="LocalStore",YE=3e8;class JE{constructor(e,t,r,s){this.persistence=e,this.Ms=t,this.serializer=s,this.xs=new ne(z),this.Os=new an(i=>zo(i),Ho),this.Ns=new Map,this.Bs=e.getRemoteDocumentCache(),this.Ti=e.getTargetCache(),this.Ei=e.getBundleCache(),this.Ls(r)}Ls(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new BE(this.Bs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Bs.setIndexManager(this.indexManager),this.Ms.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.xs))}}function ZE(n,e,t,r){return new JE(n,e,t,r)}async function sd(n,e){const t=j(n);return await t.persistence.runTransaction("Handle user change","readonly",r=>{let s;return t.mutationQueue.getAllMutationBatches(r).next(i=>(s=i,t.Ls(e),t.mutationQueue.getAllMutationBatches(r))).next(i=>{const a=[],c=[];let l=G();for(const d of s){a.push(d.batchId);for(const f of d.mutations)l=l.add(f.key)}for(const d of i){c.push(d.batchId);for(const f of d.mutations)l=l.add(f.key)}return t.localDocuments.getDocuments(r,l).next(d=>({ks:d,removedBatchIds:a,addedBatchIds:c}))})})}function eT(n,e){const t=j(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",r=>{const s=e.batch.keys(),i=t.Bs.newChangeBuffer({trackRemovals:!0});return function(c,l,d,f){const m=d.batch,_=m.keys();let R=C.resolve();return _.forEach(S=>{R=R.next(()=>f.getEntry(l,S)).next(N=>{const k=d.docVersions.get(S);Q(k!==null,48541),N.version.compareTo(k)<0&&(m.applyToRemoteDocument(N,d),N.isValidDocument()&&(N.setReadTime(d.commitVersion),f.addEntry(N)))})}),R.next(()=>c.mutationQueue.removeMutationBatch(l,m))}(t,r,e,i).next(()=>i.apply(r)).next(()=>t.mutationQueue.performConsistencyCheck(r)).next(()=>t.documentOverlayCache.removeOverlaysForBatchId(r,s,e.batch.batchId)).next(()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,function(c){let l=G();for(let d=0;d<c.mutationResults.length;++d)c.mutationResults[d].transformResults.length>0&&(l=l.add(c.batch.mutations[d].key));return l}(e))).next(()=>t.localDocuments.getDocuments(r,s))})}function id(n){const e=j(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.Ti.getLastRemoteSnapshotVersion(t))}function tT(n,e){const t=j(n),r=e.snapshotVersion;let s=t.xs;return t.persistence.runTransaction("Apply remote event","readwrite-primary",i=>{const a=t.Bs.newChangeBuffer({trackRemovals:!0});s=t.xs;const c=[];e.targetChanges.forEach((f,m)=>{const _=s.get(m);if(!_)return;c.push(t.Ti.removeMatchingKeys(i,f.removedDocuments,m).next(()=>t.Ti.addMatchingKeys(i,f.addedDocuments,m)));let R=_.withSequenceNumber(i.currentSequenceNumber);e.targetMismatches.get(m)!==null?R=R.withResumeToken(me.EMPTY_BYTE_STRING,q.min()).withLastLimboFreeSnapshotVersion(q.min()):f.resumeToken.approximateByteSize()>0&&(R=R.withResumeToken(f.resumeToken,r)),s=s.insert(m,R),function(N,k,B){return N.resumeToken.approximateByteSize()===0||k.snapshotVersion.toMicroseconds()-N.snapshotVersion.toMicroseconds()>=YE?!0:B.addedDocuments.size+B.modifiedDocuments.size+B.removedDocuments.size>0}(_,R,f)&&c.push(t.Ti.updateTargetData(i,R))});let l=ft(),d=G();if(e.documentUpdates.forEach(f=>{e.resolvedLimboDocuments.has(f)&&c.push(t.persistence.referenceDelegate.updateLimboDocument(i,f))}),c.push(nT(i,a,e.documentUpdates).next(f=>{l=f.qs,d=f.Qs})),!r.isEqual(q.min())){const f=t.Ti.getLastRemoteSnapshotVersion(i).next(m=>t.Ti.setTargetsMetadata(i,i.currentSequenceNumber,r));c.push(f)}return C.waitFor(c).next(()=>a.apply(i)).next(()=>t.localDocuments.getLocalViewOfDocuments(i,l,d)).next(()=>l)}).then(i=>(t.xs=s,i))}function nT(n,e,t){let r=G(),s=G();return t.forEach(i=>r=r.add(i)),e.getEntries(n,r).next(i=>{let a=ft();return t.forEach((c,l)=>{const d=i.get(c);l.isFoundDocument()!==d.isFoundDocument()&&(s=s.add(c)),l.isNoDocument()&&l.version.isEqual(q.min())?(e.removeEntry(c,l.readTime),a=a.insert(c,l)):!d.isValidDocument()||l.version.compareTo(d.version)>0||l.version.compareTo(d.version)===0&&d.hasPendingWrites?(e.addEntry(l),a=a.insert(c,l)):O(ta,"Ignoring outdated watch update for ",c,". Current version:",d.version," Watch version:",l.version)}),{qs:a,Qs:s}})}function rT(n,e){const t=j(n);return t.persistence.runTransaction("Get next mutation batch","readonly",r=>(e===void 0&&(e=jo),t.mutationQueue.getNextMutationBatchAfterBatchId(r,e)))}function sT(n,e){const t=j(n);return t.persistence.runTransaction("Allocate target","readwrite",r=>{let s;return t.Ti.getTargetData(r,e).next(i=>i?(s=i,C.resolve(s)):t.Ti.allocateTargetId(r).next(a=>(s=new At(e,a,"TargetPurposeListen",r.currentSequenceNumber),t.Ti.addTargetData(r,s).next(()=>s))))}).then(r=>{const s=t.xs.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.xs=t.xs.insert(r.targetId,r),t.Os.set(e,r.targetId)),r})}async function vo(n,e,t){const r=j(n),s=r.xs.get(e),i=t?"readwrite":"readwrite-primary";try{t||await r.persistence.runTransaction("Release target",i,a=>r.persistence.referenceDelegate.removeTarget(a,s))}catch(a){if(!Un(a))throw a;O(ta,`Failed to update sequence numbers for target ${e}: ${a}`)}r.xs=r.xs.remove(e),r.Os.delete(s.target)}function ju(n,e,t){const r=j(n);let s=q.min(),i=G();return r.persistence.runTransaction("Execute query","readwrite",a=>function(l,d,f){const m=j(l),_=m.Os.get(f);return _!==void 0?C.resolve(m.xs.get(_)):m.Ti.getTargetData(d,f)}(r,a,Qe(e)).next(c=>{if(c)return s=c.lastLimboFreeSnapshotVersion,r.Ti.getMatchingKeysForTargetId(a,c.targetId).next(l=>{i=l})}).next(()=>r.Ms.getDocumentsMatchingQuery(a,e,t?s:q.min(),t?i:G())).next(c=>(iT(r,Hy(e),c),{documents:c,$s:i})))}function iT(n,e,t){let r=n.Ns.get(e)||q.min();t.forEach((s,i)=>{i.readTime.compareTo(r)>0&&(r=i.readTime)}),n.Ns.set(e,r)}class $u{constructor(){this.activeTargetIds=Yy()}js(e){this.activeTargetIds=this.activeTargetIds.add(e)}Hs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}zs(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class oT{constructor(){this.xo=new $u,this.Oo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.xo.js(e),this.Oo[e]||"not-current"}updateQueryState(e,t,r){this.Oo[e]=t}removeLocalQueryTarget(e){this.xo.Hs(e)}isLocalQueryTarget(e){return this.xo.activeTargetIds.has(e)}clearQueryState(e){delete this.Oo[e]}getAllActiveQueryTargets(){return this.xo.activeTargetIds}isActiveQueryTarget(e){return this.xo.activeTargetIds.has(e)}start(){return this.xo=new $u,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}/**
2732
- * @license
2733
- * Copyright 2019 Google LLC
2734
- *
2735
- * Licensed under the Apache License, Version 2.0 (the "License");
2736
- * you may not use this file except in compliance with the License.
2737
- * You may obtain a copy of the License at
2738
- *
2739
- * http://www.apache.org/licenses/LICENSE-2.0
2740
- *
2741
- * Unless required by applicable law or agreed to in writing, software
2742
- * distributed under the License is distributed on an "AS IS" BASIS,
2743
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2744
- * See the License for the specific language governing permissions and
2745
- * limitations under the License.
2746
- */class aT{No(e){}shutdown(){}}/**
2747
- * @license
2748
- * Copyright 2019 Google LLC
2749
- *
2750
- * Licensed under the Apache License, Version 2.0 (the "License");
2751
- * you may not use this file except in compliance with the License.
2752
- * You may obtain a copy of the License at
2753
- *
2754
- * http://www.apache.org/licenses/LICENSE-2.0
2755
- *
2756
- * Unless required by applicable law or agreed to in writing, software
2757
- * distributed under the License is distributed on an "AS IS" BASIS,
2758
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2759
- * See the License for the specific language governing permissions and
2760
- * limitations under the License.
2761
- */const zu="ConnectivityMonitor";class Hu{constructor(){this.Bo=()=>this.Lo(),this.ko=()=>this.qo(),this.Qo=[],this.$o()}No(e){this.Qo.push(e)}shutdown(){window.removeEventListener("online",this.Bo),window.removeEventListener("offline",this.ko)}$o(){window.addEventListener("online",this.Bo),window.addEventListener("offline",this.ko)}Lo(){O(zu,"Network connectivity changed: AVAILABLE");for(const e of this.Qo)e(0)}qo(){O(zu,"Network connectivity changed: UNAVAILABLE");for(const e of this.Qo)e(1)}static C(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}/**
2762
- * @license
2763
- * Copyright 2023 Google LLC
2764
- *
2765
- * Licensed under the Apache License, Version 2.0 (the "License");
2766
- * you may not use this file except in compliance with the License.
2767
- * You may obtain a copy of the License at
2768
- *
2769
- * http://www.apache.org/licenses/LICENSE-2.0
2770
- *
2771
- * Unless required by applicable law or agreed to in writing, software
2772
- * distributed under the License is distributed on an "AS IS" BASIS,
2773
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2774
- * See the License for the specific language governing permissions and
2775
- * limitations under the License.
2776
- */let hs=null;function Io(){return hs===null?hs=function(){return 268435456+Math.round(2147483648*Math.random())}():hs++,"0x"+hs.toString(16)}/**
2777
- * @license
2778
- * Copyright 2020 Google LLC
2779
- *
2780
- * Licensed under the Apache License, Version 2.0 (the "License");
2781
- * you may not use this file except in compliance with the License.
2782
- * You may obtain a copy of the License at
2783
- *
2784
- * http://www.apache.org/licenses/LICENSE-2.0
2785
- *
2786
- * Unless required by applicable law or agreed to in writing, software
2787
- * distributed under the License is distributed on an "AS IS" BASIS,
2788
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2789
- * See the License for the specific language governing permissions and
2790
- * limitations under the License.
2791
- */const Xi="RestConnection",cT={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class uT{get Uo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.Ko=t+"://"+e.host,this.Wo=`projects/${r}/databases/${s}`,this.Go=this.databaseId.database===Ls?`project_id=${r}`:`project_id=${r}&database_id=${s}`}zo(e,t,r,s,i){const a=Io(),c=this.jo(e,t.toUriEncodedString());O(Xi,`Sending RPC '${e}' ${a}:`,c,r);const l={"google-cloud-resource-prefix":this.Wo,"x-goog-request-params":this.Go};this.Ho(l,s,i);const{host:d}=new URL(c),f=Lt(d);return this.Jo(e,c,l,r,f).then(m=>(O(Xi,`Received RPC '${e}' ${a}: `,m),m),m=>{throw Pn(Xi,`RPC '${e}' ${a} failed with error: `,m,"url: ",c,"request:",r),m})}Yo(e,t,r,s,i,a){return this.zo(e,t,r,s,i)}Ho(e,t,r){e["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+xn}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((s,i)=>e[i]=s),r&&r.headers.forEach((s,i)=>e[i]=s)}jo(e,t){const r=cT[e];return`${this.Ko}/v1/${t}:${r}`}terminate(){}}/**
2792
- * @license
2793
- * Copyright 2017 Google LLC
2794
- *
2795
- * Licensed under the Apache License, Version 2.0 (the "License");
2796
- * you may not use this file except in compliance with the License.
2797
- * You may obtain a copy of the License at
2798
- *
2799
- * http://www.apache.org/licenses/LICENSE-2.0
2800
- *
2801
- * Unless required by applicable law or agreed to in writing, software
2802
- * distributed under the License is distributed on an "AS IS" BASIS,
2803
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2804
- * See the License for the specific language governing permissions and
2805
- * limitations under the License.
2806
- */class lT{constructor(e){this.Zo=e.Zo,this.Xo=e.Xo}e_(e){this.t_=e}n_(e){this.r_=e}i_(e){this.s_=e}onMessage(e){this.o_=e}close(){this.Xo()}send(e){this.Zo(e)}__(){this.t_()}a_(){this.r_()}u_(e){this.s_(e)}c_(e){this.o_(e)}}/**
2807
- * @license
2808
- * Copyright 2017 Google LLC
2809
- *
2810
- * Licensed under the Apache License, Version 2.0 (the "License");
2811
- * you may not use this file except in compliance with the License.
2812
- * You may obtain a copy of the License at
2813
- *
2814
- * http://www.apache.org/licenses/LICENSE-2.0
2815
- *
2816
- * Unless required by applicable law or agreed to in writing, software
2817
- * distributed under the License is distributed on an "AS IS" BASIS,
2818
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2819
- * See the License for the specific language governing permissions and
2820
- * limitations under the License.
2821
- */const Te="WebChannelConnection";class hT extends uT{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}Jo(e,t,r,s,i){const a=Io();return new Promise((c,l)=>{const d=new uh;d.setWithCredentials(!0),d.listenOnce(lh.COMPLETE,()=>{try{switch(d.getLastErrorCode()){case ys.NO_ERROR:const m=d.getResponseJson();O(Te,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(m)),c(m);break;case ys.TIMEOUT:O(Te,`RPC '${e}' ${a} timed out`),l(new V(P.DEADLINE_EXCEEDED,"Request time out"));break;case ys.HTTP_ERROR:const _=d.getStatus();if(O(Te,`RPC '${e}' ${a} failed with status:`,_,"response text:",d.getResponseText()),_>0){let R=d.getResponseJson();Array.isArray(R)&&(R=R[0]);const S=R==null?void 0:R.error;if(S&&S.status&&S.message){const N=function(B){const M=B.toLowerCase().replace(/_/g,"-");return Object.values(P).indexOf(M)>=0?M:P.UNKNOWN}(S.status);l(new V(N,S.message))}else l(new V(P.UNKNOWN,"Server responded with status "+d.getStatus()))}else l(new V(P.UNAVAILABLE,"Connection failed."));break;default:F(9055,{l_:e,streamId:a,h_:d.getLastErrorCode(),P_:d.getLastError()})}}finally{O(Te,`RPC '${e}' ${a} completed.`)}});const f=JSON.stringify(s);O(Te,`RPC '${e}' ${a} sending request:`,s),d.send(t,"POST",f,r,15)})}T_(e,t,r){const s=Io(),i=[this.Ko,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=fh(),c=dh(),l={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},d=this.longPollingOptions.timeoutSeconds;d!==void 0&&(l.longPollingTimeout=Math.round(1e3*d)),this.useFetchStreams&&(l.useFetchStreams=!0),this.Ho(l.initMessageHeaders,t,r),l.encodeInitMessageHeaders=!0;const f=i.join("");O(Te,`Creating RPC '${e}' stream ${s}: ${f}`,l);const m=a.createWebChannel(f,l);let _=!1,R=!1;const S=new lT({Zo:k=>{R?O(Te,`Not sending because RPC '${e}' stream ${s} is closed:`,k):(_||(O(Te,`Opening RPC '${e}' stream ${s} transport.`),m.open(),_=!0),O(Te,`RPC '${e}' stream ${s} sending:`,k),m.send(k))},Xo:()=>m.close()}),N=(k,B,M)=>{k.listen(B,x=>{try{M(x)}catch($){setTimeout(()=>{throw $},0)}})};return N(m,cr.EventType.OPEN,()=>{R||(O(Te,`RPC '${e}' stream ${s} transport opened.`),S.__())}),N(m,cr.EventType.CLOSE,()=>{R||(R=!0,O(Te,`RPC '${e}' stream ${s} transport closed`),S.u_())}),N(m,cr.EventType.ERROR,k=>{R||(R=!0,Pn(Te,`RPC '${e}' stream ${s} transport errored. Name:`,k.name,"Message:",k.message),S.u_(new V(P.UNAVAILABLE,"The operation could not be completed")))}),N(m,cr.EventType.MESSAGE,k=>{var B;if(!R){const M=k.data[0];Q(!!M,16349);const x=M,$=(x==null?void 0:x.error)||((B=x[0])===null||B===void 0?void 0:B.error);if($){O(Te,`RPC '${e}' stream ${s} received error:`,$);const ce=$.status;let X=function(y){const T=oe[y];if(T!==void 0)return Gh(T)}(ce),v=$.message;X===void 0&&(X=P.INTERNAL,v="Unknown error status: "+ce+" with message "+$.message),R=!0,S.u_(new V(X,v)),m.close()}else O(Te,`RPC '${e}' stream ${s} received:`,M),S.c_(M)}}),N(c,hh.STAT_EVENT,k=>{k.stat===uo.PROXY?O(Te,`RPC '${e}' stream ${s} detected buffering proxy`):k.stat===uo.NOPROXY&&O(Te,`RPC '${e}' stream ${s} detected no buffering proxy`)}),setTimeout(()=>{S.a_()},0),S}}function Yi(){return typeof document<"u"?document:null}/**
2822
- * @license
2823
- * Copyright 2020 Google LLC
2824
- *
2825
- * Licensed under the Apache License, Version 2.0 (the "License");
2826
- * you may not use this file except in compliance with the License.
2827
- * You may obtain a copy of the License at
2828
- *
2829
- * http://www.apache.org/licenses/LICENSE-2.0
2830
- *
2831
- * Unless required by applicable law or agreed to in writing, software
2832
- * distributed under the License is distributed on an "AS IS" BASIS,
2833
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2834
- * See the License for the specific language governing permissions and
2835
- * limitations under the License.
2836
- */function li(n){return new mE(n,!0)}/**
2837
- * @license
2838
- * Copyright 2017 Google LLC
2839
- *
2840
- * Licensed under the Apache License, Version 2.0 (the "License");
2841
- * you may not use this file except in compliance with the License.
2842
- * You may obtain a copy of the License at
2843
- *
2844
- * http://www.apache.org/licenses/LICENSE-2.0
2845
- *
2846
- * Unless required by applicable law or agreed to in writing, software
2847
- * distributed under the License is distributed on an "AS IS" BASIS,
2848
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2849
- * See the License for the specific language governing permissions and
2850
- * limitations under the License.
2851
- */class od{constructor(e,t,r=1e3,s=1.5,i=6e4){this.xi=e,this.timerId=t,this.I_=r,this.E_=s,this.d_=i,this.A_=0,this.R_=null,this.V_=Date.now(),this.reset()}reset(){this.A_=0}m_(){this.A_=this.d_}f_(e){this.cancel();const t=Math.floor(this.A_+this.g_()),r=Math.max(0,Date.now()-this.V_),s=Math.max(0,t-r);s>0&&O("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.A_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.R_=this.xi.enqueueAfterDelay(this.timerId,s,()=>(this.V_=Date.now(),e())),this.A_*=this.E_,this.A_<this.I_&&(this.A_=this.I_),this.A_>this.d_&&(this.A_=this.d_)}p_(){this.R_!==null&&(this.R_.skipDelay(),this.R_=null)}cancel(){this.R_!==null&&(this.R_.cancel(),this.R_=null)}g_(){return(Math.random()-.5)*this.A_}}/**
2852
- * @license
2853
- * Copyright 2017 Google LLC
2854
- *
2855
- * Licensed under the Apache License, Version 2.0 (the "License");
2856
- * you may not use this file except in compliance with the License.
2857
- * You may obtain a copy of the License at
2858
- *
2859
- * http://www.apache.org/licenses/LICENSE-2.0
2860
- *
2861
- * Unless required by applicable law or agreed to in writing, software
2862
- * distributed under the License is distributed on an "AS IS" BASIS,
2863
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2864
- * See the License for the specific language governing permissions and
2865
- * limitations under the License.
2866
- */const Gu="PersistentStream";class ad{constructor(e,t,r,s,i,a,c,l){this.xi=e,this.y_=r,this.w_=s,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=c,this.listener=l,this.state=0,this.S_=0,this.b_=null,this.D_=null,this.stream=null,this.v_=0,this.C_=new od(e,t)}F_(){return this.state===1||this.state===5||this.M_()}M_(){return this.state===2||this.state===3}start(){this.v_=0,this.state!==4?this.auth():this.x_()}async stop(){this.F_()&&await this.close(0)}O_(){this.state=0,this.C_.reset()}N_(){this.M_()&&this.b_===null&&(this.b_=this.xi.enqueueAfterDelay(this.y_,6e4,()=>this.B_()))}L_(e){this.k_(),this.stream.send(e)}async B_(){if(this.M_())return this.close(0)}k_(){this.b_&&(this.b_.cancel(),this.b_=null)}q_(){this.D_&&(this.D_.cancel(),this.D_=null)}async close(e,t){this.k_(),this.q_(),this.C_.cancel(),this.S_++,e!==4?this.C_.reset():t&&t.code===P.RESOURCE_EXHAUSTED?(dt(t.toString()),dt("Using maximum backoff delay to prevent overloading the backend."),this.C_.m_()):t&&t.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.Q_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.i_(t)}Q_(){}auth(){this.state=1;const e=this.U_(this.S_),t=this.S_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([r,s])=>{this.S_===t&&this.K_(r,s)},r=>{e(()=>{const s=new V(P.UNKNOWN,"Fetching auth token failed: "+r.message);return this.W_(s)})})}K_(e,t){const r=this.U_(this.S_);this.stream=this.G_(e,t),this.stream.e_(()=>{r(()=>this.listener.e_())}),this.stream.n_(()=>{r(()=>(this.state=2,this.D_=this.xi.enqueueAfterDelay(this.w_,1e4,()=>(this.M_()&&(this.state=3),Promise.resolve())),this.listener.n_()))}),this.stream.i_(s=>{r(()=>this.W_(s))}),this.stream.onMessage(s=>{r(()=>++this.v_==1?this.z_(s):this.onNext(s))})}x_(){this.state=5,this.C_.f_(async()=>{this.state=0,this.start()})}W_(e){return O(Gu,`close with error: ${e}`),this.stream=null,this.close(4,e)}U_(e){return t=>{this.xi.enqueueAndForget(()=>this.S_===e?t():(O(Gu,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class dT extends ad{constructor(e,t,r,s,i,a){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,s,a),this.serializer=i}G_(e,t){return this.connection.T_("Listen",e,t)}z_(e){return this.onNext(e)}onNext(e){this.C_.reset();const t=yE(this.serializer,e),r=function(i){if(!("targetChange"in i))return q.min();const a=i.targetChange;return a.targetIds&&a.targetIds.length?q.min():a.readTime?Ye(a.readTime):q.min()}(e);return this.listener.j_(t,r)}H_(e){const t={};t.database=To(this.serializer),t.addTarget=function(i,a){let c;const l=a.target;if(c=mo(l)?{documents:vE(i,l)}:{query:IE(i,l).gt},c.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){c.resumeToken=Qh(i,a.resumeToken);const d=_o(i,a.expectedCount);d!==null&&(c.expectedCount=d)}else if(a.snapshotVersion.compareTo(q.min())>0){c.readTime=qs(i,a.snapshotVersion.toTimestamp());const d=_o(i,a.expectedCount);d!==null&&(c.expectedCount=d)}return c}(this.serializer,e);const r=AE(this.serializer,e);r&&(t.labels=r),this.L_(t)}J_(e){const t={};t.database=To(this.serializer),t.removeTarget=e,this.L_(t)}}class fT extends ad{constructor(e,t,r,s,i,a){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,s,a),this.serializer=i}get Y_(){return this.v_>0}start(){this.lastStreamToken=void 0,super.start()}Q_(){this.Y_&&this.Z_([])}G_(e,t){return this.connection.T_("Write",e,t)}z_(e){return Q(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,Q(!e.writeResults||e.writeResults.length===0,55816),this.listener.X_()}onNext(e){Q(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.C_.reset();const t=TE(e.writeResults,e.commitTime),r=Ye(e.commitTime);return this.listener.ea(r,t)}ta(){const e={};e.database=To(this.serializer),this.L_(e)}Z_(e){const t={streamToken:this.lastStreamToken,writes:e.map(r=>EE(this.serializer,r))};this.L_(t)}}/**
2867
- * @license
2868
- * Copyright 2017 Google LLC
2869
- *
2870
- * Licensed under the Apache License, Version 2.0 (the "License");
2871
- * you may not use this file except in compliance with the License.
2872
- * You may obtain a copy of the License at
2873
- *
2874
- * http://www.apache.org/licenses/LICENSE-2.0
2875
- *
2876
- * Unless required by applicable law or agreed to in writing, software
2877
- * distributed under the License is distributed on an "AS IS" BASIS,
2878
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2879
- * See the License for the specific language governing permissions and
2880
- * limitations under the License.
2881
- */class pT{}class mT extends pT{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=s,this.na=!1}ra(){if(this.na)throw new V(P.FAILED_PRECONDITION,"The client has already been terminated.")}zo(e,t,r,s){return this.ra(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,a])=>this.connection.zo(e,yo(t,r),s,i,a)).catch(i=>{throw i.name==="FirebaseError"?(i.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new V(P.UNKNOWN,i.toString())})}Yo(e,t,r,s,i){return this.ra(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([a,c])=>this.connection.Yo(e,yo(t,r),s,a,c,i)).catch(a=>{throw a.name==="FirebaseError"?(a.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new V(P.UNKNOWN,a.toString())})}terminate(){this.na=!0,this.connection.terminate()}}class gT{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.ia=0,this.sa=null,this.oa=!0}_a(){this.ia===0&&(this.aa("Unknown"),this.sa=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.sa=null,this.ua("Backend didn't respond within 10 seconds."),this.aa("Offline"),Promise.resolve())))}ca(e){this.state==="Online"?this.aa("Unknown"):(this.ia++,this.ia>=1&&(this.la(),this.ua(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.aa("Offline")))}set(e){this.la(),this.ia=0,e==="Online"&&(this.oa=!1),this.aa(e)}aa(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}ua(e){const t=`Could not reach Cloud Firestore backend. ${e}
2882
- This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.oa?(dt(t),this.oa=!1):O("OnlineStateTracker",t)}la(){this.sa!==null&&(this.sa.cancel(),this.sa=null)}}/**
2883
- * @license
2884
- * Copyright 2017 Google LLC
2885
- *
2886
- * Licensed under the Apache License, Version 2.0 (the "License");
2887
- * you may not use this file except in compliance with the License.
2888
- * You may obtain a copy of the License at
2889
- *
2890
- * http://www.apache.org/licenses/LICENSE-2.0
2891
- *
2892
- * Unless required by applicable law or agreed to in writing, software
2893
- * distributed under the License is distributed on an "AS IS" BASIS,
2894
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2895
- * See the License for the specific language governing permissions and
2896
- * limitations under the License.
2897
- */const tn="RemoteStore";class _T{constructor(e,t,r,s,i){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.ha=[],this.Pa=new Map,this.Ta=new Set,this.Ia=[],this.Ea=i,this.Ea.No(a=>{r.enqueueAndForget(async()=>{un(this)&&(O(tn,"Restarting streams for network reachability change."),await async function(l){const d=j(l);d.Ta.add(4),await Mr(d),d.da.set("Unknown"),d.Ta.delete(4),await hi(d)}(this))})}),this.da=new gT(r,s)}}async function hi(n){if(un(n))for(const e of n.Ia)await e(!0)}async function Mr(n){for(const e of n.Ia)await e(!1)}function cd(n,e){const t=j(n);t.Pa.has(e.targetId)||(t.Pa.set(e.targetId,e),ia(t)?sa(t):Fn(t).M_()&&ra(t,e))}function na(n,e){const t=j(n),r=Fn(t);t.Pa.delete(e),r.M_()&&ud(t,e),t.Pa.size===0&&(r.M_()?r.N_():un(t)&&t.da.set("Unknown"))}function ra(n,e){if(n.Aa.Ke(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(q.min())>0){const t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}Fn(n).H_(e)}function ud(n,e){n.Aa.Ke(e),Fn(n).J_(e)}function sa(n){n.Aa=new hE({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),Rt:e=>n.Pa.get(e)||null,Pt:()=>n.datastore.serializer.databaseId}),Fn(n).start(),n.da._a()}function ia(n){return un(n)&&!Fn(n).F_()&&n.Pa.size>0}function un(n){return j(n).Ta.size===0}function ld(n){n.Aa=void 0}async function yT(n){n.da.set("Online")}async function ET(n){n.Pa.forEach((e,t)=>{ra(n,e)})}async function TT(n,e){ld(n),ia(n)?(n.da.ca(e),sa(n)):n.da.set("Unknown")}async function vT(n,e,t){if(n.da.set("Online"),e instanceof Kh&&e.state===2&&e.cause)try{await async function(s,i){const a=i.cause;for(const c of i.targetIds)s.Pa.has(c)&&(await s.remoteSyncer.rejectListen(c,a),s.Pa.delete(c),s.Aa.removeTarget(c))}(n,e)}catch(r){O(tn,"Failed to remove targets %s: %s ",e.targetIds.join(","),r),await $s(n,r)}else if(e instanceof Is?n.Aa.Xe(e):e instanceof Wh?n.Aa.ot(e):n.Aa.nt(e),!t.isEqual(q.min()))try{const r=await id(n.localStore);t.compareTo(r)>=0&&await function(i,a){const c=i.Aa.It(a);return c.targetChanges.forEach((l,d)=>{if(l.resumeToken.approximateByteSize()>0){const f=i.Pa.get(d);f&&i.Pa.set(d,f.withResumeToken(l.resumeToken,a))}}),c.targetMismatches.forEach((l,d)=>{const f=i.Pa.get(l);if(!f)return;i.Pa.set(l,f.withResumeToken(me.EMPTY_BYTE_STRING,f.snapshotVersion)),ud(i,l);const m=new At(f.target,l,d,f.sequenceNumber);ra(i,m)}),i.remoteSyncer.applyRemoteEvent(c)}(n,t)}catch(r){O(tn,"Failed to raise snapshot:",r),await $s(n,r)}}async function $s(n,e,t){if(!Un(e))throw e;n.Ta.add(1),await Mr(n),n.da.set("Offline"),t||(t=()=>id(n.localStore)),n.asyncQueue.enqueueRetryable(async()=>{O(tn,"Retrying IndexedDB access"),await t(),n.Ta.delete(1),await hi(n)})}function hd(n,e){return e().catch(t=>$s(n,t,e))}async function di(n){const e=j(n),t=Vt(e);let r=e.ha.length>0?e.ha[e.ha.length-1].batchId:jo;for(;IT(e);)try{const s=await rT(e.localStore,r);if(s===null){e.ha.length===0&&t.N_();break}r=s.batchId,wT(e,s)}catch(s){await $s(e,s)}dd(e)&&fd(e)}function IT(n){return un(n)&&n.ha.length<10}function wT(n,e){n.ha.push(e);const t=Vt(n);t.M_()&&t.Y_&&t.Z_(e.mutations)}function dd(n){return un(n)&&!Vt(n).F_()&&n.ha.length>0}function fd(n){Vt(n).start()}async function AT(n){Vt(n).ta()}async function RT(n){const e=Vt(n);for(const t of n.ha)e.Z_(t.mutations)}async function bT(n,e,t){const r=n.ha.shift(),s=Qo.from(r,e,t);await hd(n,()=>n.remoteSyncer.applySuccessfulWrite(s)),await di(n)}async function PT(n,e){e&&Vt(n).Y_&&await async function(r,s){if(function(a){return uE(a)&&a!==P.ABORTED}(s.code)){const i=r.ha.shift();Vt(r).O_(),await hd(r,()=>r.remoteSyncer.rejectFailedWrite(i.batchId,s)),await di(r)}}(n,e),dd(n)&&fd(n)}async function Wu(n,e){const t=j(n);t.asyncQueue.verifyOperationInProgress(),O(tn,"RemoteStore received new credentials");const r=un(t);t.Ta.add(3),await Mr(t),r&&t.da.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.Ta.delete(3),await hi(t)}async function ST(n,e){const t=j(n);e?(t.Ta.delete(2),await hi(t)):e||(t.Ta.add(2),await Mr(t),t.da.set("Unknown"))}function Fn(n){return n.Ra||(n.Ra=function(t,r,s){const i=j(t);return i.ra(),new dT(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)}(n.datastore,n.asyncQueue,{e_:yT.bind(null,n),n_:ET.bind(null,n),i_:TT.bind(null,n),j_:vT.bind(null,n)}),n.Ia.push(async e=>{e?(n.Ra.O_(),ia(n)?sa(n):n.da.set("Unknown")):(await n.Ra.stop(),ld(n))})),n.Ra}function Vt(n){return n.Va||(n.Va=function(t,r,s){const i=j(t);return i.ra(),new fT(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)}(n.datastore,n.asyncQueue,{e_:()=>Promise.resolve(),n_:AT.bind(null,n),i_:PT.bind(null,n),X_:RT.bind(null,n),ea:bT.bind(null,n)}),n.Ia.push(async e=>{e?(n.Va.O_(),await di(n)):(await n.Va.stop(),n.ha.length>0&&(O(tn,`Stopping write stream with ${n.ha.length} pending writes`),n.ha=[]))})),n.Va}/**
2898
- * @license
2899
- * Copyright 2017 Google LLC
2900
- *
2901
- * Licensed under the Apache License, Version 2.0 (the "License");
2902
- * you may not use this file except in compliance with the License.
2903
- * You may obtain a copy of the License at
2904
- *
2905
- * http://www.apache.org/licenses/LICENSE-2.0
2906
- *
2907
- * Unless required by applicable law or agreed to in writing, software
2908
- * distributed under the License is distributed on an "AS IS" BASIS,
2909
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2910
- * See the License for the specific language governing permissions and
2911
- * limitations under the License.
2912
- */class oa{constructor(e,t,r,s,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=s,this.removalCallback=i,this.deferred=new at,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(a=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,s,i){const a=Date.now()+r,c=new oa(e,t,a,s,i);return c.start(r),c}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 aa(n,e){if(dt("AsyncQueue",`${e}: ${n}`),Un(n))return new V(P.UNAVAILABLE,`${e}: ${n}`);throw n}/**
2913
- * @license
2914
- * Copyright 2017 Google LLC
2915
- *
2916
- * Licensed under the Apache License, Version 2.0 (the "License");
2917
- * you may not use this file except in compliance with the License.
2918
- * You may obtain a copy of the License at
2919
- *
2920
- * http://www.apache.org/licenses/LICENSE-2.0
2921
- *
2922
- * Unless required by applicable law or agreed to in writing, software
2923
- * distributed under the License is distributed on an "AS IS" BASIS,
2924
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2925
- * See the License for the specific language governing permissions and
2926
- * limitations under the License.
2927
- */class An{static emptySet(e){return new An(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||L.comparator(t.key,r.key):(t,r)=>L.comparator(t.key,r.key),this.keyedMap=ur(),this.sortedSet=new ne(this.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,r)=>(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 An)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){const s=t.getNext().key,i=r.getNext().key;if(!s.isEqual(i))return!1}return!0}toString(){const e=[];return this.forEach(t=>{e.push(t.toString())}),e.length===0?"DocumentSet ()":`DocumentSet (
2928
- `+e.join(`
2929
- `)+`
2930
- )`}copy(e,t){const r=new An;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}/**
2931
- * @license
2932
- * Copyright 2017 Google LLC
2933
- *
2934
- * Licensed under the Apache License, Version 2.0 (the "License");
2935
- * you may not use this file except in compliance with the License.
2936
- * You may obtain a copy of the License at
2937
- *
2938
- * http://www.apache.org/licenses/LICENSE-2.0
2939
- *
2940
- * Unless required by applicable law or agreed to in writing, software
2941
- * distributed under the License is distributed on an "AS IS" BASIS,
2942
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2943
- * See the License for the specific language governing permissions and
2944
- * limitations under the License.
2945
- */class Ku{constructor(){this.ma=new ne(L.comparator)}track(e){const t=e.doc.key,r=this.ma.get(t);r?e.type!==0&&r.type===3?this.ma=this.ma.insert(t,e):e.type===3&&r.type!==1?this.ma=this.ma.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.ma=this.ma.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.ma=this.ma.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.ma=this.ma.remove(t):e.type===1&&r.type===2?this.ma=this.ma.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.ma=this.ma.insert(t,{type:2,doc:e.doc}):F(63341,{Vt:e,fa:r}):this.ma=this.ma.insert(t,e)}ga(){const e=[];return this.ma.inorderTraversal((t,r)=>{e.push(r)}),e}}class Vn{constructor(e,t,r,s,i,a,c,l,d){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=c,this.excludesMetadataChanges=l,this.hasCachedResults=d}static fromInitialDocuments(e,t,r,s,i){const a=[];return t.forEach(c=>{a.push({type:0,doc:c})}),new Vn(e,t,An.emptySet(t),a,r,s,!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)&&ii(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==r[s].type||!t[s].doc.isEqual(r[s].doc))return!1;return!0}}/**
2946
- * @license
2947
- * Copyright 2017 Google LLC
2948
- *
2949
- * Licensed under the Apache License, Version 2.0 (the "License");
2950
- * you may not use this file except in compliance with the License.
2951
- * You may obtain a copy of the License at
2952
- *
2953
- * http://www.apache.org/licenses/LICENSE-2.0
2954
- *
2955
- * Unless required by applicable law or agreed to in writing, software
2956
- * distributed under the License is distributed on an "AS IS" BASIS,
2957
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2958
- * See the License for the specific language governing permissions and
2959
- * limitations under the License.
2960
- */class CT{constructor(){this.pa=void 0,this.ya=[]}wa(){return this.ya.some(e=>e.Sa())}}class kT{constructor(){this.queries=Qu(),this.onlineState="Unknown",this.ba=new Set}terminate(){(function(t,r){const s=j(t),i=s.queries;s.queries=Qu(),i.forEach((a,c)=>{for(const l of c.ya)l.onError(r)})})(this,new V(P.ABORTED,"Firestore shutting down"))}}function Qu(){return new an(n=>Oh(n),ii)}async function ca(n,e){const t=j(n);let r=3;const s=e.query;let i=t.queries.get(s);i?!i.wa()&&e.Sa()&&(r=2):(i=new CT,r=e.Sa()?0:1);try{switch(r){case 0:i.pa=await t.onListen(s,!0);break;case 1:i.pa=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(a){const c=aa(a,`Initialization of query '${_n(e.query)}' failed`);return void e.onError(c)}t.queries.set(s,i),i.ya.push(e),e.Da(t.onlineState),i.pa&&e.va(i.pa)&&la(t)}async function ua(n,e){const t=j(n),r=e.query;let s=3;const i=t.queries.get(r);if(i){const a=i.ya.indexOf(e);a>=0&&(i.ya.splice(a,1),i.ya.length===0?s=e.Sa()?0:1:!i.wa()&&e.Sa()&&(s=2))}switch(s){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}}function NT(n,e){const t=j(n);let r=!1;for(const s of e){const i=s.query,a=t.queries.get(i);if(a){for(const c of a.ya)c.va(s)&&(r=!0);a.pa=s}}r&&la(t)}function DT(n,e,t){const r=j(n),s=r.queries.get(e);if(s)for(const i of s.ya)i.onError(t);r.queries.delete(e)}function la(n){n.ba.forEach(e=>{e.next()})}var wo,Xu;(Xu=wo||(wo={})).Ca="default",Xu.Cache="cache";class ha{constructor(e,t,r){this.query=e,this.Fa=t,this.Ma=!1,this.xa=null,this.onlineState="Unknown",this.options=r||{}}va(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new Vn(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Ma?this.Oa(e)&&(this.Fa.next(e),t=!0):this.Na(e,this.onlineState)&&(this.Ba(e),t=!0),this.xa=e,t}onError(e){this.Fa.error(e)}Da(e){this.onlineState=e;let t=!1;return this.xa&&!this.Ma&&this.Na(this.xa,e)&&(this.Ba(this.xa),t=!0),t}Na(e,t){if(!e.fromCache||!this.Sa())return!0;const r=t!=="Offline";return(!this.options.La||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}Oa(e){if(e.docChanges.length>0)return!0;const t=this.xa&&this.xa.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}Ba(e){e=Vn.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Ma=!0,this.Fa.next(e)}Sa(){return this.options.source!==wo.Cache}}/**
2961
- * @license
2962
- * Copyright 2017 Google LLC
2963
- *
2964
- * Licensed under the Apache License, Version 2.0 (the "License");
2965
- * you may not use this file except in compliance with the License.
2966
- * You may obtain a copy of the License at
2967
- *
2968
- * http://www.apache.org/licenses/LICENSE-2.0
2969
- *
2970
- * Unless required by applicable law or agreed to in writing, software
2971
- * distributed under the License is distributed on an "AS IS" BASIS,
2972
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2973
- * See the License for the specific language governing permissions and
2974
- * limitations under the License.
2975
- */class pd{constructor(e){this.key=e}}class md{constructor(e){this.key=e}}class VT{constructor(e,t){this.query=e,this.Ga=t,this.za=null,this.hasCachedResults=!1,this.current=!1,this.ja=G(),this.mutatedKeys=G(),this.Ha=Lh(e),this.Ja=new An(this.Ha)}get Ya(){return this.Ga}Za(e,t){const r=t?t.Xa:new Ku,s=t?t.Ja:this.Ja;let i=t?t.mutatedKeys:this.mutatedKeys,a=s,c=!1;const l=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,d=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal((f,m)=>{const _=s.get(f),R=oi(this.query,m)?m:null,S=!!_&&this.mutatedKeys.has(_.key),N=!!R&&(R.hasLocalMutations||this.mutatedKeys.has(R.key)&&R.hasCommittedMutations);let k=!1;_&&R?_.data.isEqual(R.data)?S!==N&&(r.track({type:3,doc:R}),k=!0):this.eu(_,R)||(r.track({type:2,doc:R}),k=!0,(l&&this.Ha(R,l)>0||d&&this.Ha(R,d)<0)&&(c=!0)):!_&&R?(r.track({type:0,doc:R}),k=!0):_&&!R&&(r.track({type:1,doc:_}),k=!0,(l||d)&&(c=!0)),k&&(R?(a=a.add(R),i=N?i.add(f):i.delete(f)):(a=a.delete(f),i=i.delete(f)))}),this.query.limit!==null)for(;a.size>this.query.limit;){const f=this.query.limitType==="F"?a.last():a.first();a=a.delete(f.key),i=i.delete(f.key),r.track({type:1,doc:f})}return{Ja:a,Xa:r,Cs:c,mutatedKeys:i}}eu(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,s){const i=this.Ja;this.Ja=e.Ja,this.mutatedKeys=e.mutatedKeys;const a=e.Xa.ga();a.sort((f,m)=>function(R,S){const N=k=>{switch(k){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return F(20277,{Vt:k})}};return N(R)-N(S)}(f.type,m.type)||this.Ha(f.doc,m.doc)),this.tu(r),s=s!=null&&s;const c=t&&!s?this.nu():[],l=this.ja.size===0&&this.current&&!s?1:0,d=l!==this.za;return this.za=l,a.length!==0||d?{snapshot:new Vn(this.query,e.Ja,i,a,e.mutatedKeys,l===0,d,!1,!!r&&r.resumeToken.approximateByteSize()>0),ru:c}:{ru:c}}Da(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({Ja:this.Ja,Xa:new Ku,mutatedKeys:this.mutatedKeys,Cs:!1},!1)):{ru:[]}}iu(e){return!this.Ga.has(e)&&!!this.Ja.has(e)&&!this.Ja.get(e).hasLocalMutations}tu(e){e&&(e.addedDocuments.forEach(t=>this.Ga=this.Ga.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.Ga=this.Ga.delete(t)),this.current=e.current)}nu(){if(!this.current)return[];const e=this.ja;this.ja=G(),this.Ja.forEach(r=>{this.iu(r.key)&&(this.ja=this.ja.add(r.key))});const t=[];return e.forEach(r=>{this.ja.has(r)||t.push(new md(r))}),this.ja.forEach(r=>{e.has(r)||t.push(new pd(r))}),t}su(e){this.Ga=e.$s,this.ja=G();const t=this.Za(e.documents);return this.applyChanges(t,!0)}ou(){return Vn.fromInitialDocuments(this.query,this.Ja,this.mutatedKeys,this.za===0,this.hasCachedResults)}}const da="SyncEngine";class OT{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class LT{constructor(e){this.key=e,this._u=!1}}class xT{constructor(e,t,r,s,i,a){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=s,this.currentUser=i,this.maxConcurrentLimboResolutions=a,this.au={},this.uu=new an(c=>Oh(c),ii),this.cu=new Map,this.lu=new Set,this.hu=new ne(L.comparator),this.Pu=new Map,this.Tu=new Jo,this.Iu={},this.Eu=new Map,this.du=Dn.lr(),this.onlineState="Unknown",this.Au=void 0}get isPrimaryClient(){return this.Au===!0}}async function MT(n,e,t=!0){const r=vd(n);let s;const i=r.uu.get(e);return i?(r.sharedClientState.addLocalQueryTarget(i.targetId),s=i.view.ou()):s=await gd(r,e,t,!0),s}async function UT(n,e){const t=vd(n);await gd(t,e,!0,!1)}async function gd(n,e,t,r){const s=await sT(n.localStore,Qe(e)),i=s.targetId,a=n.sharedClientState.addLocalQueryTarget(i,t);let c;return r&&(c=await FT(n,e,i,a==="current",s.resumeToken)),n.isPrimaryClient&&t&&cd(n.remoteStore,s),c}async function FT(n,e,t,r,s){n.Ru=(m,_,R)=>async function(N,k,B,M){let x=k.view.Za(B);x.Cs&&(x=await ju(N.localStore,k.query,!1).then(({documents:v})=>k.view.Za(v,x)));const $=M&&M.targetChanges.get(k.targetId),ce=M&&M.targetMismatches.get(k.targetId)!=null,X=k.view.applyChanges(x,N.isPrimaryClient,$,ce);return Ju(N,k.targetId,X.ru),X.snapshot}(n,m,_,R);const i=await ju(n.localStore,e,!0),a=new VT(e,i.$s),c=a.Za(i.documents),l=xr.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),d=a.applyChanges(c,n.isPrimaryClient,l);Ju(n,t,d.ru);const f=new OT(e,t,a);return n.uu.set(e,f),n.cu.has(t)?n.cu.get(t).push(e):n.cu.set(t,[e]),d.snapshot}async function BT(n,e,t){const r=j(n),s=r.uu.get(e),i=r.cu.get(s.targetId);if(i.length>1)return r.cu.set(s.targetId,i.filter(a=>!ii(a,e))),void r.uu.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await vo(r.localStore,s.targetId,!1).then(()=>{r.sharedClientState.clearQueryState(s.targetId),t&&na(r.remoteStore,s.targetId),Ao(r,s.targetId)}).catch(Mn)):(Ao(r,s.targetId),await vo(r.localStore,s.targetId,!0))}async function qT(n,e){const t=j(n),r=t.uu.get(e),s=t.cu.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),na(t.remoteStore,r.targetId))}async function jT(n,e,t){const r=QT(n);try{const s=await function(a,c){const l=j(a),d=ue.now(),f=c.reduce((R,S)=>R.add(S.key),G());let m,_;return l.persistence.runTransaction("Locally write mutations","readwrite",R=>{let S=ft(),N=G();return l.Bs.getEntries(R,f).next(k=>{S=k,S.forEach((B,M)=>{M.isValidDocument()||(N=N.add(B))})}).next(()=>l.localDocuments.getOverlayedDocuments(R,S)).next(k=>{m=k;const B=[];for(const M of c){const x=sE(M,m.get(M.key).overlayedDocument);x!=null&&B.push(new cn(M.key,x,Ph(x.value.mapValue),Xe.exists(!0)))}return l.mutationQueue.addMutationBatch(R,d,B,c)}).next(k=>{_=k;const B=k.applyToLocalDocumentSet(m,N);return l.documentOverlayCache.saveOverlays(R,k.batchId,B)})}).then(()=>({batchId:_.batchId,changes:Mh(m)}))}(r.localStore,e);r.sharedClientState.addPendingMutation(s.batchId),function(a,c,l){let d=a.Iu[a.currentUser.toKey()];d||(d=new ne(z)),d=d.insert(c,l),a.Iu[a.currentUser.toKey()]=d}(r,s.batchId,t),await Ur(r,s.changes),await di(r.remoteStore)}catch(s){const i=aa(s,"Failed to persist write");t.reject(i)}}async function _d(n,e){const t=j(n);try{const r=await tT(t.localStore,e);e.targetChanges.forEach((s,i)=>{const a=t.Pu.get(i);a&&(Q(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?a._u=!0:s.modifiedDocuments.size>0?Q(a._u,14607):s.removedDocuments.size>0&&(Q(a._u,42227),a._u=!1))}),await Ur(t,r,e)}catch(r){await Mn(r)}}function Yu(n,e,t){const r=j(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){const s=[];r.uu.forEach((i,a)=>{const c=a.view.Da(e);c.snapshot&&s.push(c.snapshot)}),function(a,c){const l=j(a);l.onlineState=c;let d=!1;l.queries.forEach((f,m)=>{for(const _ of m.ya)_.Da(c)&&(d=!0)}),d&&la(l)}(r.eventManager,e),s.length&&r.au.j_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function $T(n,e,t){const r=j(n);r.sharedClientState.updateQueryState(e,"rejected",t);const s=r.Pu.get(e),i=s&&s.key;if(i){let a=new ne(L.comparator);a=a.insert(i,Ie.newNoDocument(i,q.min()));const c=G().add(i),l=new ui(q.min(),new Map,new ne(z),a,c);await _d(r,l),r.hu=r.hu.remove(i),r.Pu.delete(e),fa(r)}else await vo(r.localStore,e,!1).then(()=>Ao(r,e,t)).catch(Mn)}async function zT(n,e){const t=j(n),r=e.batch.batchId;try{const s=await eT(t.localStore,e);Ed(t,r,null),yd(t,r),t.sharedClientState.updateMutationState(r,"acknowledged"),await Ur(t,s)}catch(s){await Mn(s)}}async function HT(n,e,t){const r=j(n);try{const s=await function(a,c){const l=j(a);return l.persistence.runTransaction("Reject batch","readwrite-primary",d=>{let f;return l.mutationQueue.lookupMutationBatch(d,c).next(m=>(Q(m!==null,37113),f=m.keys(),l.mutationQueue.removeMutationBatch(d,m))).next(()=>l.mutationQueue.performConsistencyCheck(d)).next(()=>l.documentOverlayCache.removeOverlaysForBatchId(d,f,c)).next(()=>l.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(d,f)).next(()=>l.localDocuments.getDocuments(d,f))})}(r.localStore,e);Ed(r,e,t),yd(r,e),r.sharedClientState.updateMutationState(e,"rejected",t),await Ur(r,s)}catch(s){await Mn(s)}}function yd(n,e){(n.Eu.get(e)||[]).forEach(t=>{t.resolve()}),n.Eu.delete(e)}function Ed(n,e,t){const r=j(n);let s=r.Iu[r.currentUser.toKey()];if(s){const i=s.get(e);i&&(t?i.reject(t):i.resolve(),s=s.remove(e)),r.Iu[r.currentUser.toKey()]=s}}function Ao(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const r of n.cu.get(e))n.uu.delete(r),t&&n.au.Vu(r,t);n.cu.delete(e),n.isPrimaryClient&&n.Tu.Hr(e).forEach(r=>{n.Tu.containsKey(r)||Td(n,r)})}function Td(n,e){n.lu.delete(e.path.canonicalString());const t=n.hu.get(e);t!==null&&(na(n.remoteStore,t),n.hu=n.hu.remove(e),n.Pu.delete(t),fa(n))}function Ju(n,e,t){for(const r of t)r instanceof pd?(n.Tu.addReference(r.key,e),GT(n,r)):r instanceof md?(O(da,"Document no longer in limbo: "+r.key),n.Tu.removeReference(r.key,e),n.Tu.containsKey(r.key)||Td(n,r.key)):F(19791,{mu:r})}function GT(n,e){const t=e.key,r=t.path.canonicalString();n.hu.get(t)||n.lu.has(r)||(O(da,"New document in limbo: "+t),n.lu.add(r),fa(n))}function fa(n){for(;n.lu.size>0&&n.hu.size<n.maxConcurrentLimboResolutions;){const e=n.lu.values().next().value;n.lu.delete(e);const t=new L(J.fromString(e)),r=n.du.next();n.Pu.set(r,new LT(t)),n.hu=n.hu.insert(t,r),cd(n.remoteStore,new At(Qe(si(t.path)),r,"TargetPurposeLimboResolution",ei.le))}}async function Ur(n,e,t){const r=j(n),s=[],i=[],a=[];r.uu.isEmpty()||(r.uu.forEach((c,l)=>{a.push(r.Ru(l,e,t).then(d=>{var f;if((d||t)&&r.isPrimaryClient){const m=d?!d.fromCache:(f=t==null?void 0:t.targetChanges.get(l.targetId))===null||f===void 0?void 0:f.current;r.sharedClientState.updateQueryState(l.targetId,m?"current":"not-current")}if(d){s.push(d);const m=ea.Rs(l.targetId,d);i.push(m)}}))}),await Promise.all(a),r.au.j_(s),await async function(l,d){const f=j(l);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",m=>C.forEach(d,_=>C.forEach(_.ds,R=>f.persistence.referenceDelegate.addReference(m,_.targetId,R)).next(()=>C.forEach(_.As,R=>f.persistence.referenceDelegate.removeReference(m,_.targetId,R)))))}catch(m){if(!Un(m))throw m;O(ta,"Failed to update sequence numbers: "+m)}for(const m of d){const _=m.targetId;if(!m.fromCache){const R=f.xs.get(_),S=R.snapshotVersion,N=R.withLastLimboFreeSnapshotVersion(S);f.xs=f.xs.insert(_,N)}}}(r.localStore,i))}async function WT(n,e){const t=j(n);if(!t.currentUser.isEqual(e)){O(da,"User change. New user:",e.toKey());const r=await sd(t.localStore,e);t.currentUser=e,function(i,a){i.Eu.forEach(c=>{c.forEach(l=>{l.reject(new V(P.CANCELLED,a))})}),i.Eu.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await Ur(t,r.ks)}}function KT(n,e){const t=j(n),r=t.Pu.get(e);if(r&&r._u)return G().add(r.key);{let s=G();const i=t.cu.get(e);if(!i)return s;for(const a of i){const c=t.uu.get(a);s=s.unionWith(c.view.Ya)}return s}}function vd(n){const e=j(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=_d.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=KT.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=$T.bind(null,e),e.au.j_=NT.bind(null,e.eventManager),e.au.Vu=DT.bind(null,e.eventManager),e}function QT(n){const e=j(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=zT.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=HT.bind(null,e),e}class zs{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=li(e.databaseInfo.databaseId),this.sharedClientState=this.pu(e),this.persistence=this.yu(e),await this.persistence.start(),this.localStore=this.wu(e),this.gcScheduler=this.Su(e,this.localStore),this.indexBackfillerScheduler=this.bu(e,this.localStore)}Su(e,t){return null}bu(e,t){return null}wu(e){return ZE(this.persistence,new XE,e.initialUser,this.serializer)}yu(e){return new rd(Zo.fi,this.serializer)}pu(e){return new oT}async terminate(){var e,t;(e=this.gcScheduler)===null||e===void 0||e.stop(),(t=this.indexBackfillerScheduler)===null||t===void 0||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}zs.provider={build:()=>new zs};class XT extends zs{constructor(e){super(),this.cacheSizeBytes=e}Su(e,t){Q(this.persistence.referenceDelegate instanceof js,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new LE(r,e.asyncQueue,t)}yu(e){const t=this.cacheSizeBytes!==void 0?Ce.withCacheSize(this.cacheSizeBytes):Ce.DEFAULT;return new rd(r=>js.fi(r,t),this.serializer)}}class Ro{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=r=>Yu(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=WT.bind(null,this.syncEngine),await ST(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new kT}()}createDatastore(e){const t=li(e.databaseInfo.databaseId),r=function(i){return new hT(i)}(e.databaseInfo);return function(i,a,c,l){return new mT(i,a,c,l)}(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return function(r,s,i,a,c){return new _T(r,s,i,a,c)}(this.localStore,this.datastore,e.asyncQueue,t=>Yu(this.syncEngine,t,0),function(){return Hu.C()?new Hu:new aT}())}createSyncEngine(e,t){return function(s,i,a,c,l,d,f){const m=new xT(s,i,a,c,l,d);return f&&(m.Au=!0),m}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(s){const i=j(s);O(tn,"RemoteStore shutting down."),i.Ta.add(5),await Mr(i),i.Ea.shutdown(),i.da.set("Unknown")}(this.remoteStore),(e=this.datastore)===null||e===void 0||e.terminate(),(t=this.eventManager)===null||t===void 0||t.terminate()}}Ro.provider={build:()=>new Ro};/**
2976
- * @license
2977
- * Copyright 2020 Google LLC
2978
- *
2979
- * Licensed under the Apache License, Version 2.0 (the "License");
2980
- * you may not use this file except in compliance with the License.
2981
- * You may obtain a copy of the License at
2982
- *
2983
- * http://www.apache.org/licenses/LICENSE-2.0
2984
- *
2985
- * Unless required by applicable law or agreed to in writing, software
2986
- * distributed under the License is distributed on an "AS IS" BASIS,
2987
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2988
- * See the License for the specific language governing permissions and
2989
- * limitations under the License.
2990
- *//**
2991
- * @license
2992
- * Copyright 2017 Google LLC
2993
- *
2994
- * Licensed under the Apache License, Version 2.0 (the "License");
2995
- * you may not use this file except in compliance with the License.
2996
- * You may obtain a copy of the License at
2997
- *
2998
- * http://www.apache.org/licenses/LICENSE-2.0
2999
- *
3000
- * Unless required by applicable law or agreed to in writing, software
3001
- * distributed under the License is distributed on an "AS IS" BASIS,
3002
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3003
- * See the License for the specific language governing permissions and
3004
- * limitations under the License.
3005
- */class pa{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.vu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.vu(this.observer.error,e):dt("Uncaught Error in snapshot listener:",e.toString()))}Cu(){this.muted=!0}vu(e,t){setTimeout(()=>{this.muted||e(t)},0)}}/**
3006
- * @license
3007
- * Copyright 2017 Google LLC
3008
- *
3009
- * Licensed under the Apache License, Version 2.0 (the "License");
3010
- * you may not use this file except in compliance with the License.
3011
- * You may obtain a copy of the License at
3012
- *
3013
- * http://www.apache.org/licenses/LICENSE-2.0
3014
- *
3015
- * Unless required by applicable law or agreed to in writing, software
3016
- * distributed under the License is distributed on an "AS IS" BASIS,
3017
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3018
- * See the License for the specific language governing permissions and
3019
- * limitations under the License.
3020
- */const Ot="FirestoreClient";class YT{constructor(e,t,r,s,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this.databaseInfo=s,this.user=ve.UNAUTHENTICATED,this.clientId=_h.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,async a=>{O(Ot,"Received user=",a.uid),await this.authCredentialListener(a),this.user=a}),this.appCheckCredentials.start(r,a=>(O(Ot,"Received new app check token=",a),this.appCheckCredentialListener(a,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new at;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 r=aa(t,"Failed to shutdown persistence");e.reject(r)}}),e.promise}}async function Ji(n,e){n.asyncQueue.verifyOperationInProgress(),O(Ot,"Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener(async s=>{r.isEqual(s)||(await sd(e.localStore,s),r=s)}),e.persistence.setDatabaseDeletedListener(()=>n.terminate()),n._offlineComponents=e}async function Zu(n,e){n.asyncQueue.verifyOperationInProgress();const t=await JT(n);O(Ot,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener(r=>Wu(e.remoteStore,r)),n.setAppCheckTokenChangeListener((r,s)=>Wu(e.remoteStore,s)),n._onlineComponents=e}async function JT(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){O(Ot,"Using user provided OfflineComponentProvider");try{await Ji(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!function(s){return s.name==="FirebaseError"?s.code===P.FAILED_PRECONDITION||s.code===P.UNIMPLEMENTED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11}(t))throw t;Pn("Error using user provided cache. Falling back to memory cache: "+t),await Ji(n,new zs)}}else O(Ot,"Using default OfflineComponentProvider"),await Ji(n,new XT(void 0));return n._offlineComponents}async function Id(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(O(Ot,"Using user provided OnlineComponentProvider"),await Zu(n,n._uninitializedComponentsProvider._online)):(O(Ot,"Using default OnlineComponentProvider"),await Zu(n,new Ro))),n._onlineComponents}function ZT(n){return Id(n).then(e=>e.syncEngine)}async function Hs(n){const e=await Id(n),t=e.eventManager;return t.onListen=MT.bind(null,e.syncEngine),t.onUnlisten=BT.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=UT.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=qT.bind(null,e.syncEngine),t}function ev(n,e,t={}){const r=new at;return n.asyncQueue.enqueueAndForget(async()=>function(i,a,c,l,d){const f=new pa({next:_=>{f.Cu(),a.enqueueAndForget(()=>ua(i,m));const R=_.docs.has(c);!R&&_.fromCache?d.reject(new V(P.UNAVAILABLE,"Failed to get document because the client is offline.")):R&&_.fromCache&&l&&l.source==="server"?d.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.)')):d.resolve(_)},error:_=>d.reject(_)}),m=new ha(si(c.path),f,{includeMetadataChanges:!0,La:!0});return ca(i,m)}(await Hs(n),n.asyncQueue,e,t,r)),r.promise}function tv(n,e,t={}){const r=new at;return n.asyncQueue.enqueueAndForget(async()=>function(i,a,c,l,d){const f=new pa({next:_=>{f.Cu(),a.enqueueAndForget(()=>ua(i,m)),_.fromCache&&l.source==="server"?d.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.)')):d.resolve(_)},error:_=>d.reject(_)}),m=new ha(c,f,{includeMetadataChanges:!0,La:!0});return ca(i,m)}(await Hs(n),n.asyncQueue,e,t,r)),r.promise}/**
3021
- * @license
3022
- * Copyright 2023 Google LLC
3023
- *
3024
- * Licensed under the Apache License, Version 2.0 (the "License");
3025
- * you may not use this file except in compliance with the License.
3026
- * You may obtain a copy of the License at
3027
- *
3028
- * http://www.apache.org/licenses/LICENSE-2.0
3029
- *
3030
- * Unless required by applicable law or agreed to in writing, software
3031
- * distributed under the License is distributed on an "AS IS" BASIS,
3032
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3033
- * See the License for the specific language governing permissions and
3034
- * limitations under the License.
3035
- */function wd(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}/**
3036
- * @license
3037
- * Copyright 2020 Google LLC
3038
- *
3039
- * Licensed under the Apache License, Version 2.0 (the "License");
3040
- * you may not use this file except in compliance with the License.
3041
- * You may obtain a copy of the License at
3042
- *
3043
- * http://www.apache.org/licenses/LICENSE-2.0
3044
- *
3045
- * Unless required by applicable law or agreed to in writing, software
3046
- * distributed under the License is distributed on an "AS IS" BASIS,
3047
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3048
- * See the License for the specific language governing permissions and
3049
- * limitations under the License.
3050
- */const el=new Map;/**
3051
- * @license
3052
- * Copyright 2017 Google LLC
3053
- *
3054
- * Licensed under the Apache License, Version 2.0 (the "License");
3055
- * you may not use this file except in compliance with the License.
3056
- * You may obtain a copy of the License at
3057
- *
3058
- * http://www.apache.org/licenses/LICENSE-2.0
3059
- *
3060
- * Unless required by applicable law or agreed to in writing, software
3061
- * distributed under the License is distributed on an "AS IS" BASIS,
3062
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3063
- * See the License for the specific language governing permissions and
3064
- * limitations under the License.
3065
- */function ma(n,e,t){if(!t)throw new V(P.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function nv(n,e,t,r){if(e===!0&&r===!0)throw new V(P.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function tl(n){if(!L.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 nl(n){if(L.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 fi(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(r){return r.constructor?r.constructor.name:null}(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":F(12329,{type:typeof n})}function Le(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=fi(n);throw new V(P.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}function Ad(n,e){if(e<=0)throw new V(P.INVALID_ARGUMENT,`Function ${n}() requires a positive number, but it was: ${e}.`)}/**
3066
- * @license
3067
- * Copyright 2020 Google LLC
3068
- *
3069
- * Licensed under the Apache License, Version 2.0 (the "License");
3070
- * you may not use this file except in compliance with the License.
3071
- * You may obtain a copy of the License at
3072
- *
3073
- * http://www.apache.org/licenses/LICENSE-2.0
3074
- *
3075
- * Unless required by applicable law or agreed to in writing, software
3076
- * distributed under the License is distributed on an "AS IS" BASIS,
3077
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3078
- * See the License for the specific language governing permissions and
3079
- * limitations under the License.
3080
- */const Rd="firestore.googleapis.com",rl=!0;class sl{constructor(e){var t,r;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=Rd,this.ssl=rl}else this.host=e.host,this.ssl=(t=e.ssl)!==null&&t!==void 0?t:rl;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=nd;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<VE)throw new V(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}nv("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=wd((r=e.experimentalLongPollingOptions)!==null&&r!==void 0?r:{}),function(i){if(i.timeoutSeconds!==void 0){if(isNaN(i.timeoutSeconds))throw new V(P.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (must not be NaN)`);if(i.timeoutSeconds<5)throw new V(P.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (minimum allowed value is 5)`);if(i.timeoutSeconds>30)throw new V(P.INVALID_ARGUMENT,`invalid long polling timeout: ${i.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(r,s){return r.timeoutSeconds===s.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class Fr{constructor(e,t,r,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new sl({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}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!=="notTerminated"}_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 sl(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=function(r){if(!r)return new ly;switch(r.type){case"firstParty":return new py(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new V(P.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,xt("Firestore",this._settings.isUsingEmulator),this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const r=el.get(t);r&&(O("ComponentProvider","Removing Datastore"),el.delete(t),r.terminate())}(this),Promise.resolve()}}function rv(n,e,t,r={}){var s;n=Le(n,Fr);const i=Lt(e),a=n._getSettings(),c=Object.assign(Object.assign({},a),{emulatorOptions:n._getEmulatorOptions()}),l=`${e}:${t}`;a.host!==Rd&&a.host!==l&&Pn("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const d=Object.assign(Object.assign({},a),{host:l,ssl:i,emulatorOptions:r});if(!Yt(d,c)&&(n._setSettings(d),i&&(Qs(`https://${l}`),xt("Firestore",!0)),r.mockUserToken)){let f,m;if(typeof r.mockUserToken=="string")f=r.mockUserToken,m=ve.MOCK_USER;else{f=wl(r.mockUserToken,(s=n._app)===null||s===void 0?void 0:s.options.projectId);const _=r.mockUserToken.sub||r.mockUserToken.user_id;if(!_)throw new V(P.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");m=new ve(_)}n._authCredentials=new hy(new mh(f,m))}}/**
3081
- * @license
3082
- * Copyright 2020 Google LLC
3083
- *
3084
- * Licensed under the Apache License, Version 2.0 (the "License");
3085
- * you may not use this file except in compliance with the License.
3086
- * You may obtain a copy of the License at
3087
- *
3088
- * http://www.apache.org/licenses/LICENSE-2.0
3089
- *
3090
- * Unless required by applicable law or agreed to in writing, software
3091
- * distributed under the License is distributed on an "AS IS" BASIS,
3092
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3093
- * See the License for the specific language governing permissions and
3094
- * limitations under the License.
3095
- */class He{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new He(this.firestore,e,this._query)}}class Se{constructor(e,t,r){this.converter=t,this._key=r,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 Pt(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new Se(this.firestore,e,this._key)}}class Pt extends He{constructor(e,t,r){super(e,t,si(r)),this._path=r,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 Se(this.firestore,null,new L(e))}withConverter(e){return new Pt(this.firestore,e,this._path)}}function bd(n,e,...t){if(n=Z(n),ma("collection","path",e),n instanceof Fr){const r=J.fromString(e,...t);return nl(r),new Pt(n,null,r)}{if(!(n instanceof Se||n instanceof Pt))throw new V(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(J.fromString(e,...t));return nl(r),new Pt(n.firestore,null,r)}}function Pd(n,e){if(n=Le(n,Fr),ma("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new V(P.INVALID_ARGUMENT,`Invalid collection ID '${e}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new He(n,null,function(r){return new Bt(J.emptyPath(),r)}(e))}function Bn(n,e,...t){if(n=Z(n),arguments.length===1&&(e=_h.newId()),ma("doc","path",e),n instanceof Fr){const r=J.fromString(e,...t);return tl(r),new Se(n,null,new L(r))}{if(!(n instanceof Se||n instanceof Pt))throw new V(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(J.fromString(e,...t));return tl(r),new Se(n.firestore,n instanceof Pt?n.converter:null,new L(r))}}/**
3096
- * @license
3097
- * Copyright 2020 Google LLC
3098
- *
3099
- * Licensed under the Apache License, Version 2.0 (the "License");
3100
- * you may not use this file except in compliance with the License.
3101
- * You may obtain a copy of the License at
3102
- *
3103
- * http://www.apache.org/licenses/LICENSE-2.0
3104
- *
3105
- * Unless required by applicable law or agreed to in writing, software
3106
- * distributed under the License is distributed on an "AS IS" BASIS,
3107
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3108
- * See the License for the specific language governing permissions and
3109
- * limitations under the License.
3110
- */const il="AsyncQueue";class ol{constructor(e=Promise.resolve()){this.zu=[],this.ju=!1,this.Hu=[],this.Ju=null,this.Yu=!1,this.Zu=!1,this.Xu=[],this.C_=new od(this,"async_queue_retry"),this.ec=()=>{const r=Yi();r&&O(il,"Visibility state changed to "+r.visibilityState),this.C_.p_()},this.tc=e;const t=Yi();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this.ec)}get isShuttingDown(){return this.ju}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.nc(),this.rc(e)}enterRestrictedMode(e){if(!this.ju){this.ju=!0,this.Zu=e||!1;const t=Yi();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this.ec)}}enqueue(e){if(this.nc(),this.ju)return new Promise(()=>{});const t=new at;return this.rc(()=>this.ju&&this.Zu?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.zu.push(e),this.sc()))}async sc(){if(this.zu.length!==0){try{await this.zu[0](),this.zu.shift(),this.C_.reset()}catch(e){if(!Un(e))throw e;O(il,"Operation failed with retryable error: "+e)}this.zu.length>0&&this.C_.f_(()=>this.sc())}}rc(e){const t=this.tc.then(()=>(this.Yu=!0,e().catch(r=>{throw this.Ju=r,this.Yu=!1,dt("INTERNAL UNHANDLED ERROR: ",al(r)),r}).then(r=>(this.Yu=!1,r))));return this.tc=t,t}enqueueAfterDelay(e,t,r){this.nc(),this.Xu.indexOf(e)>-1&&(t=0);const s=oa.createAndSchedule(this,e,t,r,i=>this.oc(i));return this.Hu.push(s),s}nc(){this.Ju&&F(47125,{_c:al(this.Ju)})}verifyOperationInProgress(){}async ac(){let e;do e=this.tc,await e;while(e!==this.tc)}uc(e){for(const t of this.Hu)if(t.timerId===e)return!0;return!1}cc(e){return this.ac().then(()=>{this.Hu.sort((t,r)=>t.targetTimeMs-r.targetTimeMs);for(const t of this.Hu)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.ac()})}lc(e){this.Xu.push(e)}oc(e){const t=this.Hu.indexOf(e);this.Hu.splice(t,1)}}function al(n){let e=n.message||"";return n.stack&&(e=n.stack.includes(n.message)?n.stack:n.message+`
3111
- `+n.stack),e}/**
3112
- * @license
3113
- * Copyright 2017 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
- */function cl(n){return function(t,r){if(typeof t!="object"||t===null)return!1;const s=t;for(const i of r)if(i in s&&typeof s[i]=="function")return!0;return!1}(n,["next","error","complete"])}class nn extends Fr{constructor(e,t,r,s){super(e,t,r,s),this.type="firestore",this._queue=new ol,this._persistenceKey=(s==null?void 0:s.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new ol(e),this._firestoreClient=void 0,await e}}}function sv(n,e){const t=typeof n=="object"?n:Xs(),r=typeof n=="string"?n:Ls,s=kr(t,"firestore").getImmediate({identifier:r});if(!s._initialized){const i=So("firestore");i&&rv(s,...i)}return s}function pi(n){if(n._terminated)throw new V(P.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||iv(n),n._firestoreClient}function iv(n){var e,t,r;const s=n._freezeSettings(),i=function(c,l,d,f){return new Cy(c,l,d,f.host,f.ssl,f.experimentalForceLongPolling,f.experimentalAutoDetectLongPolling,wd(f.experimentalLongPollingOptions),f.useFetchStreams,f.isUsingEmulator)}(n._databaseId,((e=n._app)===null||e===void 0?void 0:e.options.appId)||"",n._persistenceKey,s);n._componentsProvider||!((t=s.localCache)===null||t===void 0)&&t._offlineComponentProvider&&(!((r=s.localCache)===null||r===void 0)&&r._onlineComponentProvider)&&(n._componentsProvider={_offline:s.localCache._offlineComponentProvider,_online:s.localCache._onlineComponentProvider}),n._firestoreClient=new YT(n._authCredentials,n._appCheckCredentials,n._queue,i,n._componentsProvider&&function(c){const l=c==null?void 0:c._online.build();return{_offline:c==null?void 0:c._offline.build(l),_online:l}}(n._componentsProvider))}/**
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
- */class On{constructor(e){this._byteString=e}static fromBase64String(e){try{return new On(me.fromBase64String(e))}catch(t){throw new V(P.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new On(me.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)}}/**
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 ga{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 pe(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}/**
3157
- * @license
3158
- * Copyright 2020 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 Sd{constructor(e){this._methodName=e}}/**
3172
- * @license
3173
- * Copyright 2017 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 _a{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 z(this._lat,e._lat)||z(this._long,e._long)}}/**
3187
- * @license
3188
- * Copyright 2024 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, software
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 ya{constructor(e){this._values=(e||[]).map(t=>t)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(r,s){if(r.length!==s.length)return!1;for(let i=0;i<r.length;++i)if(r[i]!==s[i])return!1;return!0}(this._values,e._values)}}/**
3202
- * @license
3203
- * Copyright 2017 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
- */const ov=/^__.*__$/;class av{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return this.fieldMask!==null?new cn(e,this.data,this.fieldMask,t,this.fieldTransforms):new Lr(e,this.data,t,this.fieldTransforms)}}function Cd(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw F(40011,{hc:n})}}class Ea{constructor(e,t,r,s,i,a){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=s,i===void 0&&this.Pc(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get hc(){return this.settings.hc}Tc(e){return new Ea(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Ic(e){var t;const r=(t=this.path)===null||t===void 0?void 0:t.child(e),s=this.Tc({path:r,Ec:!1});return s.dc(e),s}Ac(e){var t;const r=(t=this.path)===null||t===void 0?void 0:t.child(e),s=this.Tc({path:r,Ec:!1});return s.Pc(),s}Rc(e){return this.Tc({path:void 0,Ec:!0})}Vc(e){return Gs(e,this.settings.methodName,this.settings.mc||!1,this.path,this.settings.fc)}contains(e){return this.fieldMask.find(t=>e.isPrefixOf(t))!==void 0||this.fieldTransforms.find(t=>e.isPrefixOf(t.field))!==void 0}Pc(){if(this.path)for(let e=0;e<this.path.length;e++)this.dc(this.path.get(e))}dc(e){if(e.length===0)throw this.Vc("Document fields must not be empty");if(Cd(this.hc)&&ov.test(e))throw this.Vc('Document fields cannot begin and end with "__"')}}class cv{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||li(e)}gc(e,t,r,s=!1){return new Ea({hc:e,methodName:t,fc:r,path:pe.emptyPath(),Ec:!1,mc:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function Ta(n){const e=n._freezeSettings(),t=li(n._databaseId);return new cv(n._databaseId,!!e.ignoreUndefinedProperties,t)}function uv(n,e,t,r,s,i={}){const a=n.gc(i.merge||i.mergeFields?2:0,e,t,s);Vd("Data must be an object, but it was:",a,r);const c=Nd(r,a);let l,d;if(i.merge)l=new Be(a.fieldMask),d=a.fieldTransforms;else if(i.mergeFields){const f=[];for(const m of i.mergeFields){const _=lv(e,m,t);if(!a.contains(_))throw new V(P.INVALID_ARGUMENT,`Field '${_}' is specified in your field mask but missing from your input data.`);dv(f,_)||f.push(_)}l=new Be(f),d=a.fieldTransforms.filter(m=>l.covers(m.field))}else l=null,d=a.fieldTransforms;return new av(new Oe(c),l,d)}function kd(n,e,t,r=!1){return va(t,n.gc(r?4:3,e))}function va(n,e){if(Dd(n=Z(n)))return Vd("Unsupported field value:",e,n),Nd(n,e);if(n instanceof Sd)return function(r,s){if(!Cd(s.hc))throw s.Vc(`${r._methodName}() can only be used with update() and set()`);if(!s.path)throw s.Vc(`${r._methodName}() is not currently supported inside arrays`);const i=r._toFieldTransform(s);i&&s.fieldTransforms.push(i)}(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.Ec&&e.hc!==4)throw e.Vc("Nested arrays are not supported");return function(r,s){const i=[];let a=0;for(const c of r){let l=va(c,s.Rc(a));l==null&&(l={nullValue:"NULL_VALUE"}),i.push(l),a++}return{arrayValue:{values:i}}}(n,e)}return function(r,s){if((r=Z(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return Jy(s.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const i=ue.fromDate(r);return{timestampValue:qs(s.serializer,i)}}if(r instanceof ue){const i=new ue(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:qs(s.serializer,i)}}if(r instanceof _a)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof On)return{bytesValue:Qh(s.serializer,r._byteString)};if(r instanceof Se){const i=s.databaseId,a=r.firestore._databaseId;if(!a.isEqual(i))throw s.Vc(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:Yo(r.firestore._databaseId||s.databaseId,r._key.path)}}if(r instanceof ya)return function(a,c){return{mapValue:{fields:{[Rh]:{stringValue:bh},[xs]:{arrayValue:{values:a.toArray().map(d=>{if(typeof d!="number")throw c.Vc("VectorValues must only contain numeric values.");return Wo(c.serializer,d)})}}}}}}(r,s);throw s.Vc(`Unsupported field value: ${fi(r)}`)}(n,e)}function Nd(n,e){const t={};return Eh(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):on(n,(r,s)=>{const i=va(s,e.Ic(r));i!=null&&(t[r]=i)}),{mapValue:{fields:t}}}function Dd(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof ue||n instanceof _a||n instanceof On||n instanceof Se||n instanceof Sd||n instanceof ya)}function Vd(n,e,t){if(!Dd(t)||!function(s){return typeof s=="object"&&s!==null&&(Object.getPrototypeOf(s)===Object.prototype||Object.getPrototypeOf(s)===null)}(t)){const r=fi(t);throw r==="an object"?e.Vc(n+" a custom object"):e.Vc(n+" "+r)}}function lv(n,e,t){if((e=Z(e))instanceof ga)return e._internalPath;if(typeof e=="string")return Od(n,e);throw Gs("Field path arguments must be of type string or ",n,!1,void 0,t)}const hv=new RegExp("[~\\*/\\[\\]]");function Od(n,e,t){if(e.search(hv)>=0)throw Gs(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new ga(...e.split("."))._internalPath}catch{throw Gs(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function Gs(n,e,t,r,s){const i=r&&!r.isEmpty(),a=s!==void 0;let c=`Function ${e}() called with invalid data`;t&&(c+=" (via `toFirestore()`)"),c+=". ";let l="";return(i||a)&&(l+=" (found",i&&(l+=` in field ${r}`),a&&(l+=` in document ${s}`),l+=")"),new V(P.INVALID_ARGUMENT,c+n+l)}function dv(n,e){return n.some(t=>t.isEqual(e))}/**
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 Ia{constructor(e,t,r,s,i){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=s,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new Se(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new fv(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(mi("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class fv extends Ia{data(){return super.data()}}function mi(n,e){return typeof e=="string"?Od(n,e):e instanceof ga?e._internalPath:e._delegate._internalPath}/**
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
- */function Ld(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new V(P.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class wa{}class gi extends wa{}function Ue(n,e,...t){let r=[];e instanceof wa&&r.push(e),r=r.concat(t),function(i){const a=i.filter(l=>l instanceof Aa).length,c=i.filter(l=>l instanceof _i).length;if(a>1||a>0&&c>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(...)))`.")}(r);for(const s of r)n=s._apply(n);return n}class _i extends gi{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new _i(e,t,r)}_apply(e){const t=this._parse(e);return Fd(e._query,t),new He(e.firestore,e.converter,go(e._query,t))}_parse(e){const t=Ta(e.firestore);return function(i,a,c,l,d,f,m){let _;if(d.isKeyField()){if(f==="array-contains"||f==="array-contains-any")throw new V(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${f}' queries on documentId().`);if(f==="in"||f==="not-in"){ll(m,f);const S=[];for(const N of m)S.push(ul(l,i,N));_={arrayValue:{values:S}}}else _=ul(l,i,m)}else f!=="in"&&f!=="not-in"&&f!=="array-contains-any"||ll(m,f),_=kd(c,a,m,f==="in"||f==="not-in");return ae.create(d,f,_)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function Rn(n,e,t){const r=e,s=mi("where",n);return _i._create(s,r,t)}class Aa extends wa{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new Aa(e,t)}_parse(e){const t=this._queryConstraints.map(r=>r._parse(e)).filter(r=>r.getFilters().length>0);return t.length===1?t[0]:$e.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return t.getFilters().length===0?e:(function(s,i){let a=s;const c=i.getFlattenedFilters();for(const l of c)Fd(a,l),a=go(a,l)}(e._query,t),new He(e.firestore,e.converter,go(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}class Ra extends gi{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new Ra(e,t)}_apply(e){const t=function(s,i,a){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().");return new Rr(i,a)}(e._query,this._field,this._direction);return new He(e.firestore,e.converter,function(s,i){const a=s.explicitOrderBy.concat([i]);return new Bt(s.path,s.collectionGroup,a,s.filters.slice(),s.limit,s.limitType,s.startAt,s.endAt)}(e._query,t))}}function xd(n,e="asc"){const t=e,r=mi("orderBy",n);return Ra._create(r,t)}class yi extends gi{constructor(e,t,r){super(),this.type=e,this._limit=t,this._limitType=r}static _create(e,t,r){return new yi(e,t,r)}_apply(e){return new He(e.firestore,e.converter,Us(e._query,this._limit,this._limitType))}}function Md(n){return Ad("limit",n),yi._create("limit",n,"F")}function pv(n){return Ad("limitToLast",n),yi._create("limitToLast",n,"L")}class ba extends gi{constructor(e,t,r){super(),this.type=e,this._docOrFields=t,this._inclusive=r}static _create(e,t,r){return new ba(e,t,r)}_apply(e){const t=mv(e,this.type,this._docOrFields,this._inclusive);return new He(e.firestore,e.converter,function(s,i){return new Bt(s.path,s.collectionGroup,s.explicitOrderBy.slice(),s.filters.slice(),s.limit,s.limitType,i,s.endAt)}(e._query,t))}}function Ud(...n){return ba._create("startAfter",n,!1)}function mv(n,e,t,r){if(t[0]=Z(t[0]),t[0]instanceof Ia)return function(i,a,c,l,d){if(!l)throw new V(P.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${c}().`);const f=[];for(const m of wn(i))if(m.field.isKeyField())f.push(Ms(a,l.key));else{const _=l.data.field(m.field);if(ni(_))throw new V(P.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+m.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(_===null){const R=m.field.canonicalString();throw new V(P.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${R}' (used as the orderBy) does not exist.`)}f.push(_)}return new Nn(f,d)}(n._query,n.firestore._databaseId,e,t[0]._document,r);{const s=Ta(n.firestore);return function(a,c,l,d,f,m){const _=a.explicitOrderBy;if(f.length>_.length)throw new V(P.INVALID_ARGUMENT,`Too many arguments provided to ${d}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const R=[];for(let S=0;S<f.length;S++){const N=f[S];if(_[S].field.isKeyField()){if(typeof N!="string")throw new V(P.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${d}(), but got a ${typeof N}`);if(!Go(a)&&N.indexOf("/")!==-1)throw new V(P.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${d}() must be a plain document ID, but '${N}' contains a slash.`);const k=a.path.child(J.fromString(N));if(!L.isDocumentKey(k))throw new V(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${d}() must result in a valid document path, but '${k}' is not because it contains an odd number of segments.`);const B=new L(k);R.push(Ms(c,B))}else{const k=kd(l,d,N);R.push(k)}}return new Nn(R,m)}(n._query,n.firestore._databaseId,s,e,t,r)}}function ul(n,e,t){if(typeof(t=Z(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(!Go(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 r=e.path.child(J.fromString(t));if(!L.isDocumentKey(r))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 '${r}' is not because it has an odd number of segments (${r.length}).`);return Ms(n,new L(r))}if(t instanceof Se)return Ms(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: ${fi(t)}.`)}function ll(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.`)}function Fd(n,e){const t=function(s,i){for(const a of s)for(const c of a.getFlattenedFilters())if(i.indexOf(c.op)>=0)return c.op;return null}(n.filters,function(s){switch(s){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(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.`)}class gv{convertValue(e,t="none"){switch(Dt(e)){case 0:return null;case 1:return e.booleanValue;case 2:return ie(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(Nt(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw F(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return on(e,(s,i)=>{r[s]=this.convertValue(i,t)}),r}convertVectorValue(e){var t,r,s;const i=(s=(r=(t=e.fields)===null||t===void 0?void 0:t[xs].arrayValue)===null||r===void 0?void 0:r.values)===null||s===void 0?void 0:s.map(a=>ie(a.doubleValue));return new ya(i)}convertGeoPoint(e){return new _a(ie(e.latitude),ie(e.longitude))}convertArray(e,t){return(e.values||[]).map(r=>this.convertValue(r,t))}convertServerTimestamp(e,t){switch(t){case"previous":const r=ri(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(Ir(e));default:return null}}convertTimestamp(e){const t=kt(e);return new ue(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=J.fromString(e);Q(td(r),9688,{name:e});const s=new wr(r.get(1),r.get(3)),i=new L(r.popFirst(5));return s.isEqual(t)||dt(`Document ${i} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}}/**
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
- */function _v(n,e,t){let r;return r=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,r}/**
3262
- * @license
3263
- * Copyright 2020 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
- */class hr{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class Bd extends Ia{constructor(e,t,r,s,i,a){super(e,t,r,s,a),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 r=this._document.data.field(mi("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}}class ws extends Bd{data(e={}){return super.data(e)}}class qd{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new hr(s.hasPendingWrites,s.fromCache),this.query=r}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(r=>{e.call(t,new ws(this._firestore,this._userDataWriter,r.key,r,new hr(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}docChanges(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,i){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map(c=>{const l=new ws(s._firestore,s._userDataWriter,c.doc.key,c.doc,new hr(s._snapshot.mutatedKeys.has(c.doc.key),s._snapshot.fromCache),s.query.converter);return c.doc,{type:"added",doc:l,oldIndex:-1,newIndex:a++}})}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(c=>i||c.type!==3).map(c=>{const l=new ws(s._firestore,s._userDataWriter,c.doc.key,c.doc,new hr(s._snapshot.mutatedKeys.has(c.doc.key),s._snapshot.fromCache),s.query.converter);let d=-1,f=-1;return c.type!==0&&(d=a.indexOf(c.doc.key),a=a.delete(c.doc.key)),c.type!==1&&(a=a.add(c.doc),f=a.indexOf(c.doc.key)),{type:yv(c.type),doc:l,oldIndex:d,newIndex:f}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function yv(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return F(61501,{type:n})}}/**
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
- */function jd(n){n=Le(n,Se);const e=Le(n.firestore,nn);return ev(pi(e),n._key).then(t=>Wd(e,n,t))}class Pa extends gv{constructor(e){super(),this.firestore=e}convertBytes(e){return new On(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Se(this.firestore,null,t)}}function $d(n){n=Le(n,He);const e=Le(n.firestore,nn),t=pi(e),r=new Pa(e);return Ld(n._query),tv(t,n._query).then(s=>new qd(e,r,n,s))}function zd(n,e,t){n=Le(n,Se);const r=Le(n.firestore,nn),s=_v(n.converter,e,t);return Gd(r,[uv(Ta(r),"setDoc",n._key,s,n.converter!==null,t).toMutation(n._key,Xe.none())])}function Ev(n){return Gd(Le(n.firestore,nn),[new Ko(n._key,Xe.none())])}function Hd(n,...e){var t,r,s;n=Z(n);let i={includeMetadataChanges:!1,source:"default"},a=0;typeof e[a]!="object"||cl(e[a])||(i=e[a],a++);const c={includeMetadataChanges:i.includeMetadataChanges,source:i.source};if(cl(e[a])){const m=e[a];e[a]=(t=m.next)===null||t===void 0?void 0:t.bind(m),e[a+1]=(r=m.error)===null||r===void 0?void 0:r.bind(m),e[a+2]=(s=m.complete)===null||s===void 0?void 0:s.bind(m)}let l,d,f;if(n instanceof Se)d=Le(n.firestore,nn),f=si(n._key.path),l={next:m=>{e[a]&&e[a](Wd(d,n,m))},error:e[a+1],complete:e[a+2]};else{const m=Le(n,He);d=Le(m.firestore,nn),f=m._query;const _=new Pa(d);l={next:R=>{e[a]&&e[a](new qd(d,_,m,R))},error:e[a+1],complete:e[a+2]},Ld(n._query)}return function(_,R,S,N){const k=new pa(N),B=new ha(R,k,S);return _.asyncQueue.enqueueAndForget(async()=>ca(await Hs(_),B)),()=>{k.Cu(),_.asyncQueue.enqueueAndForget(async()=>ua(await Hs(_),B))}}(pi(d),f,c,l)}function Gd(n,e){return function(r,s){const i=new at;return r.asyncQueue.enqueueAndForget(async()=>jT(await ZT(r),s,i)),i.promise}(pi(n),e)}function Wd(n,e,t){const r=t.docs.get(e._key),s=new Pa(n);return new Bd(n,s,e._key,r,new hr(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(s){xn=s})(sn),St(new ut("firestore",(r,{instanceIdentifier:s,options:i})=>{const a=r.getProvider("app").getImmediate(),c=new nn(new dy(r.getProvider("auth-internal")),new my(a,r.getProvider("app-check-internal")),function(d,f){if(!Object.prototype.hasOwnProperty.apply(d.options,["projectId"]))throw new V(P.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new wr(d.options.projectId,f)}(a,s),a);return i=Object.assign({useFetchStreams:t},i),c._setSettings(i),c},"PUBLIC").setMultipleInstances(!0)),qe(du,fu,e),qe(du,fu,"esm2017")})();/**
3292
- * @license
3293
- * Copyright 2017 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
- */const Kd="firebasestorage.googleapis.com",Qd="storageBucket",Tv=2*60*1e3,vv=10*60*1e3,Iv=1e3;/**
3307
- * @license
3308
- * Copyright 2017 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, software
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 re extends ze{constructor(e,t,r=0){super(Zi(e),`Firebase Storage: ${t} (${Zi(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,re.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return Zi(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
3322
- ${this.customData.serverResponse}`:this.message=this._baseMessage}}var te;(function(n){n.UNKNOWN="unknown",n.OBJECT_NOT_FOUND="object-not-found",n.BUCKET_NOT_FOUND="bucket-not-found",n.PROJECT_NOT_FOUND="project-not-found",n.QUOTA_EXCEEDED="quota-exceeded",n.UNAUTHENTICATED="unauthenticated",n.UNAUTHORIZED="unauthorized",n.UNAUTHORIZED_APP="unauthorized-app",n.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",n.INVALID_CHECKSUM="invalid-checksum",n.CANCELED="canceled",n.INVALID_EVENT_NAME="invalid-event-name",n.INVALID_URL="invalid-url",n.INVALID_DEFAULT_BUCKET="invalid-default-bucket",n.NO_DEFAULT_BUCKET="no-default-bucket",n.CANNOT_SLICE_BLOB="cannot-slice-blob",n.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",n.NO_DOWNLOAD_URL="no-download-url",n.INVALID_ARGUMENT="invalid-argument",n.INVALID_ARGUMENT_COUNT="invalid-argument-count",n.APP_DELETED="app-deleted",n.INVALID_ROOT_OPERATION="invalid-root-operation",n.INVALID_FORMAT="invalid-format",n.INTERNAL_ERROR="internal-error",n.UNSUPPORTED_ENVIRONMENT="unsupported-environment"})(te||(te={}));function Zi(n){return"storage/"+n}function Sa(){const n="An unknown error occurred, please check the error payload for server response.";return new re(te.UNKNOWN,n)}function wv(n){return new re(te.OBJECT_NOT_FOUND,"Object '"+n+"' does not exist.")}function Av(n){return new re(te.QUOTA_EXCEEDED,"Quota for bucket '"+n+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function Rv(){const n="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new re(te.UNAUTHENTICATED,n)}function bv(){return new re(te.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function Pv(n){return new re(te.UNAUTHORIZED,"User does not have permission to access '"+n+"'.")}function Xd(){return new re(te.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function Yd(){return new re(te.CANCELED,"User canceled the upload/download.")}function Sv(n){return new re(te.INVALID_URL,"Invalid URL '"+n+"'.")}function Cv(n){return new re(te.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+n+"'.")}function kv(){return new re(te.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+Qd+"' property when initializing the app?")}function Jd(){return new re(te.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function Nv(){return new re(te.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.")}function Dv(){return new re(te.NO_DOWNLOAD_URL,"The given file does not have any download URLs.")}function Vv(n){return new re(te.UNSUPPORTED_ENVIRONMENT,`${n} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function bo(n){return new re(te.INVALID_ARGUMENT,n)}function Zd(){return new re(te.APP_DELETED,"The Firebase app was deleted.")}function Ov(n){return new re(te.INVALID_ROOT_OPERATION,"The operation '"+n+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function _r(n,e){return new re(te.INVALID_FORMAT,"String does not match format '"+n+"': "+e)}function sr(n){throw new re(te.INTERNAL_ERROR,"Internal error: "+n)}/**
3323
- * @license
3324
- * Copyright 2017 Google LLC
3325
- *
3326
- * Licensed under the Apache License, Version 2.0 (the "License");
3327
- * you may not use this file except in compliance with the License.
3328
- * You may obtain a copy of the License at
3329
- *
3330
- * http://www.apache.org/licenses/LICENSE-2.0
3331
- *
3332
- * Unless required by applicable law or agreed to in writing, software
3333
- * distributed under the License is distributed on an "AS IS" BASIS,
3334
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3335
- * See the License for the specific language governing permissions and
3336
- * limitations under the License.
3337
- */class Ve{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let r;try{r=Ve.makeFromUrl(e,t)}catch{return new Ve(e,"")}if(r.path==="")return r;throw Cv(e)}static makeFromUrl(e,t){let r=null;const s="([A-Za-z0-9.\\-_]+)";function i($){$.path.charAt($.path.length-1)==="/"&&($.path_=$.path_.slice(0,-1))}const a="(/(.*))?$",c=new RegExp("^gs://"+s+a,"i"),l={bucket:1,path:3};function d($){$.path_=decodeURIComponent($.path)}const f="v[A-Za-z0-9_]+",m=t.replace(/[.]/g,"\\."),_="(/([^?#]*).*)?$",R=new RegExp(`^https?://${m}/${f}/b/${s}/o${_}`,"i"),S={bucket:1,path:3},N=t===Kd?"(?:storage.googleapis.com|storage.cloud.google.com)":t,k="([^?#]*)",B=new RegExp(`^https?://${N}/${s}/${k}`,"i"),x=[{regex:c,indices:l,postModify:i},{regex:R,indices:S,postModify:d},{regex:B,indices:{bucket:1,path:2},postModify:d}];for(let $=0;$<x.length;$++){const ce=x[$],X=ce.regex.exec(e);if(X){const v=X[ce.indices.bucket];let g=X[ce.indices.path];g||(g=""),r=new Ve(v,g),ce.postModify(r);break}}if(r==null)throw Sv(e);return r}}class Lv{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}/**
3338
- * @license
3339
- * Copyright 2017 Google LLC
3340
- *
3341
- * Licensed under the Apache License, Version 2.0 (the "License");
3342
- * you may not use this file except in compliance with the License.
3343
- * You may obtain a copy of the License at
3344
- *
3345
- * http://www.apache.org/licenses/LICENSE-2.0
3346
- *
3347
- * Unless required by applicable law or agreed to in writing, software
3348
- * distributed under the License is distributed on an "AS IS" BASIS,
3349
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3350
- * See the License for the specific language governing permissions and
3351
- * limitations under the License.
3352
- */function xv(n,e,t){let r=1,s=null,i=null,a=!1,c=0;function l(){return c===2}let d=!1;function f(...k){d||(d=!0,e.apply(null,k))}function m(k){s=setTimeout(()=>{s=null,n(R,l())},k)}function _(){i&&clearTimeout(i)}function R(k,...B){if(d){_();return}if(k){_(),f.call(null,k,...B);return}if(l()||a){_(),f.call(null,k,...B);return}r<64&&(r*=2);let x;c===1?(c=2,x=0):x=(r+Math.random())*1e3,m(x)}let S=!1;function N(k){S||(S=!0,_(),!d&&(s!==null?(k||(c=2),clearTimeout(s),m(0)):k||(c=1)))}return m(0),i=setTimeout(()=>{a=!0,N(!0)},t),N}function Mv(n){n(!1)}/**
3353
- * @license
3354
- * Copyright 2017 Google LLC
3355
- *
3356
- * Licensed under the Apache License, Version 2.0 (the "License");
3357
- * you may not use this file except in compliance with the License.
3358
- * You may obtain a copy of the License at
3359
- *
3360
- * http://www.apache.org/licenses/LICENSE-2.0
3361
- *
3362
- * Unless required by applicable law or agreed to in writing, software
3363
- * distributed under the License is distributed on an "AS IS" BASIS,
3364
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3365
- * See the License for the specific language governing permissions and
3366
- * limitations under the License.
3367
- */function Uv(n){return n!==void 0}function Fv(n){return typeof n=="function"}function Bv(n){return typeof n=="object"&&!Array.isArray(n)}function Ei(n){return typeof n=="string"||n instanceof String}function hl(n){return Ca()&&n instanceof Blob}function Ca(){return typeof Blob<"u"}function dl(n,e,t,r){if(r<e)throw bo(`Invalid value for '${n}'. Expected ${e} or greater.`);if(r>t)throw bo(`Invalid value for '${n}'. Expected ${t} or less.`)}/**
3368
- * @license
3369
- * Copyright 2017 Google LLC
3370
- *
3371
- * Licensed under the Apache License, Version 2.0 (the "License");
3372
- * you may not use this file except in compliance with the License.
3373
- * You may obtain a copy of the License at
3374
- *
3375
- * http://www.apache.org/licenses/LICENSE-2.0
3376
- *
3377
- * Unless required by applicable law or agreed to in writing, software
3378
- * distributed under the License is distributed on an "AS IS" BASIS,
3379
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3380
- * See the License for the specific language governing permissions and
3381
- * limitations under the License.
3382
- */function ln(n,e,t){let r=e;return t==null&&(r=`https://${e}`),`${t}://${r}/v0${n}`}function ef(n){const e=encodeURIComponent;let t="?";for(const r in n)if(n.hasOwnProperty(r)){const s=e(r)+"="+e(n[r]);t=t+s+"&"}return t=t.slice(0,-1),t}var Xt;(function(n){n[n.NO_ERROR=0]="NO_ERROR",n[n.NETWORK_ERROR=1]="NETWORK_ERROR",n[n.ABORT=2]="ABORT"})(Xt||(Xt={}));/**
3383
- * @license
3384
- * Copyright 2022 Google LLC
3385
- *
3386
- * Licensed under the Apache License, Version 2.0 (the "License");
3387
- * you may not use this file except in compliance with the License.
3388
- * You may obtain a copy of the License at
3389
- *
3390
- * http://www.apache.org/licenses/LICENSE-2.0
3391
- *
3392
- * Unless required by applicable law or agreed to in writing, software
3393
- * distributed under the License is distributed on an "AS IS" BASIS,
3394
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3395
- * See the License for the specific language governing permissions and
3396
- * limitations under the License.
3397
- */function tf(n,e){const t=n>=500&&n<600,s=[408,429].indexOf(n)!==-1,i=e.indexOf(n)!==-1;return t||s||i}/**
3398
- * @license
3399
- * Copyright 2017 Google LLC
3400
- *
3401
- * Licensed under the Apache License, Version 2.0 (the "License");
3402
- * you may not use this file except in compliance with the License.
3403
- * You may obtain a copy of the License at
3404
- *
3405
- * http://www.apache.org/licenses/LICENSE-2.0
3406
- *
3407
- * Unless required by applicable law or agreed to in writing, software
3408
- * distributed under the License is distributed on an "AS IS" BASIS,
3409
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3410
- * See the License for the specific language governing permissions and
3411
- * limitations under the License.
3412
- */class qv{constructor(e,t,r,s,i,a,c,l,d,f,m,_=!0,R=!1){this.url_=e,this.method_=t,this.headers_=r,this.body_=s,this.successCodes_=i,this.additionalRetryCodes_=a,this.callback_=c,this.errorCallback_=l,this.timeout_=d,this.progressCallback_=f,this.connectionFactory_=m,this.retry=_,this.isUsingEmulator=R,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((S,N)=>{this.resolve_=S,this.reject_=N,this.start_()})}start_(){const e=(r,s)=>{if(s){r(!1,new ds(!1,null,!0));return}const i=this.connectionFactory_();this.pendingConnection_=i;const a=c=>{const l=c.loaded,d=c.lengthComputable?c.total:-1;this.progressCallback_!==null&&this.progressCallback_(l,d)};this.progressCallback_!==null&&i.addUploadProgressListener(a),i.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&i.removeUploadProgressListener(a),this.pendingConnection_=null;const c=i.getErrorCode()===Xt.NO_ERROR,l=i.getStatus();if(!c||tf(l,this.additionalRetryCodes_)&&this.retry){const f=i.getErrorCode()===Xt.ABORT;r(!1,new ds(!1,null,f));return}const d=this.successCodes_.indexOf(l)!==-1;r(!0,new ds(d,i))})},t=(r,s)=>{const i=this.resolve_,a=this.reject_,c=s.connection;if(s.wasSuccessCode)try{const l=this.callback_(c,c.getResponse());Uv(l)?i(l):i()}catch(l){a(l)}else if(c!==null){const l=Sa();l.serverResponse=c.getErrorText(),this.errorCallback_?a(this.errorCallback_(c,l)):a(l)}else if(s.canceled){const l=this.appDelete_?Zd():Yd();a(l)}else{const l=Xd();a(l)}};this.canceled_?t(!1,new ds(!1,null,!0)):this.backoffId_=xv(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&Mv(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class ds{constructor(e,t,r){this.wasSuccessCode=e,this.connection=t,this.canceled=!!r}}function jv(n,e){e!==null&&e.length>0&&(n.Authorization="Firebase "+e)}function $v(n,e){n["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function zv(n,e){e&&(n["X-Firebase-GMPID"]=e)}function Hv(n,e){e!==null&&(n["X-Firebase-AppCheck"]=e)}function Gv(n,e,t,r,s,i,a=!0,c=!1){const l=ef(n.urlParams),d=n.url+l,f=Object.assign({},n.headers);return zv(f,e),jv(f,t),$v(f,i),Hv(f,r),new qv(d,n.method,f,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,s,a,c)}/**
3413
- * @license
3414
- * Copyright 2017 Google LLC
3415
- *
3416
- * Licensed under the Apache License, Version 2.0 (the "License");
3417
- * you may not use this file except in compliance with the License.
3418
- * You may obtain a copy of the License at
3419
- *
3420
- * http://www.apache.org/licenses/LICENSE-2.0
3421
- *
3422
- * Unless required by applicable law or agreed to in writing, software
3423
- * distributed under the License is distributed on an "AS IS" BASIS,
3424
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3425
- * See the License for the specific language governing permissions and
3426
- * limitations under the License.
3427
- */function Wv(){return typeof BlobBuilder<"u"?BlobBuilder:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:void 0}function Kv(...n){const e=Wv();if(e!==void 0){const t=new e;for(let r=0;r<n.length;r++)t.append(n[r]);return t.getBlob()}else{if(Ca())return new Blob(n);throw new re(te.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}}function Qv(n,e,t){return n.webkitSlice?n.webkitSlice(e,t):n.mozSlice?n.mozSlice(e,t):n.slice?n.slice(e,t):null}/**
3428
- * @license
3429
- * Copyright 2021 Google LLC
3430
- *
3431
- * Licensed under the Apache License, Version 2.0 (the "License");
3432
- * you may not use this file except in compliance with the License.
3433
- * You may obtain a copy of the License at
3434
- *
3435
- * http://www.apache.org/licenses/LICENSE-2.0
3436
- *
3437
- * Unless required by applicable law or agreed to in writing, software
3438
- * distributed under the License is distributed on an "AS IS" BASIS,
3439
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3440
- * See the License for the specific language governing permissions and
3441
- * limitations under the License.
3442
- */function Xv(n){if(typeof atob>"u")throw Vv("base-64");return atob(n)}/**
3443
- * @license
3444
- * Copyright 2017 Google LLC
3445
- *
3446
- * Licensed under the Apache License, Version 2.0 (the "License");
3447
- * you may not use this file except in compliance with the License.
3448
- * You may obtain a copy of the License at
3449
- *
3450
- * http://www.apache.org/licenses/LICENSE-2.0
3451
- *
3452
- * Unless required by applicable law or agreed to in writing, software
3453
- * distributed under the License is distributed on an "AS IS" BASIS,
3454
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3455
- * See the License for the specific language governing permissions and
3456
- * limitations under the License.
3457
- */const We={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class eo{constructor(e,t){this.data=e,this.contentType=t||null}}function Yv(n,e){switch(n){case We.RAW:return new eo(nf(e));case We.BASE64:case We.BASE64URL:return new eo(rf(n,e));case We.DATA_URL:return new eo(Zv(e),eI(e))}throw Sa()}function nf(n){const e=[];for(let t=0;t<n.length;t++){let r=n.charCodeAt(t);if(r<=127)e.push(r);else if(r<=2047)e.push(192|r>>6,128|r&63);else if((r&64512)===55296)if(!(t<n.length-1&&(n.charCodeAt(t+1)&64512)===56320))e.push(239,191,189);else{const i=r,a=n.charCodeAt(++t);r=65536|(i&1023)<<10|a&1023,e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}else(r&64512)===56320?e.push(239,191,189):e.push(224|r>>12,128|r>>6&63,128|r&63)}return new Uint8Array(e)}function Jv(n){let e;try{e=decodeURIComponent(n)}catch{throw _r(We.DATA_URL,"Malformed data URL.")}return nf(e)}function rf(n,e){switch(n){case We.BASE64:{const s=e.indexOf("-")!==-1,i=e.indexOf("_")!==-1;if(s||i)throw _r(n,"Invalid character '"+(s?"-":"_")+"' found: is it base64url encoded?");break}case We.BASE64URL:{const s=e.indexOf("+")!==-1,i=e.indexOf("/")!==-1;if(s||i)throw _r(n,"Invalid character '"+(s?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let t;try{t=Xv(e)}catch(s){throw s.message.includes("polyfill")?s:_r(n,"Invalid character found")}const r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}class sf{constructor(e){this.base64=!1,this.contentType=null;const t=e.match(/^data:([^,]+)?,/);if(t===null)throw _r(We.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const r=t[1]||null;r!=null&&(this.base64=tI(r,";base64"),this.contentType=this.base64?r.substring(0,r.length-7):r),this.rest=e.substring(e.indexOf(",")+1)}}function Zv(n){const e=new sf(n);return e.base64?rf(We.BASE64,e.rest):Jv(e.rest)}function eI(n){return new sf(n).contentType}function tI(n,e){return n.length>=e.length?n.substring(n.length-e.length)===e:!1}/**
3458
- * @license
3459
- * Copyright 2017 Google LLC
3460
- *
3461
- * Licensed under the Apache License, Version 2.0 (the "License");
3462
- * you may not use this file except in compliance with the License.
3463
- * You may obtain a copy of the License at
3464
- *
3465
- * http://www.apache.org/licenses/LICENSE-2.0
3466
- *
3467
- * Unless required by applicable law or agreed to in writing, software
3468
- * distributed under the License is distributed on an "AS IS" BASIS,
3469
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3470
- * See the License for the specific language governing permissions and
3471
- * limitations under the License.
3472
- */class It{constructor(e,t){let r=0,s="";hl(e)?(this.data_=e,r=e.size,s=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),r=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),r=e.length),this.size_=r,this.type_=s}size(){return this.size_}type(){return this.type_}slice(e,t){if(hl(this.data_)){const r=this.data_,s=Qv(r,e,t);return s===null?null:new It(s)}else{const r=new Uint8Array(this.data_.buffer,e,t-e);return new It(r,!0)}}static getBlob(...e){if(Ca()){const t=e.map(r=>r instanceof It?r.data_:r);return new It(Kv.apply(null,t))}else{const t=e.map(a=>Ei(a)?Yv(We.RAW,a).data:a.data_);let r=0;t.forEach(a=>{r+=a.byteLength});const s=new Uint8Array(r);let i=0;return t.forEach(a=>{for(let c=0;c<a.length;c++)s[i++]=a[c]}),new It(s,!0)}}uploadData(){return this.data_}}/**
3473
- * @license
3474
- * Copyright 2017 Google LLC
3475
- *
3476
- * Licensed under the Apache License, Version 2.0 (the "License");
3477
- * you may not use this file except in compliance with the License.
3478
- * You may obtain a copy of the License at
3479
- *
3480
- * http://www.apache.org/licenses/LICENSE-2.0
3481
- *
3482
- * Unless required by applicable law or agreed to in writing, software
3483
- * distributed under the License is distributed on an "AS IS" BASIS,
3484
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3485
- * See the License for the specific language governing permissions and
3486
- * limitations under the License.
3487
- */function of(n){let e;try{e=JSON.parse(n)}catch{return null}return Bv(e)?e:null}/**
3488
- * @license
3489
- * Copyright 2017 Google LLC
3490
- *
3491
- * Licensed under the Apache License, Version 2.0 (the "License");
3492
- * you may not use this file except in compliance with the License.
3493
- * You may obtain a copy of the License at
3494
- *
3495
- * http://www.apache.org/licenses/LICENSE-2.0
3496
- *
3497
- * Unless required by applicable law or agreed to in writing, software
3498
- * distributed under the License is distributed on an "AS IS" BASIS,
3499
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3500
- * See the License for the specific language governing permissions and
3501
- * limitations under the License.
3502
- */function nI(n){if(n.length===0)return null;const e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function rI(n,e){const t=e.split("/").filter(r=>r.length>0).join("/");return n.length===0?t:n+"/"+t}function af(n){const e=n.lastIndexOf("/",n.length-2);return e===-1?n:n.slice(e+1)}/**
3503
- * @license
3504
- * Copyright 2017 Google LLC
3505
- *
3506
- * Licensed under the Apache License, Version 2.0 (the "License");
3507
- * you may not use this file except in compliance with the License.
3508
- * You may obtain a copy of the License at
3509
- *
3510
- * http://www.apache.org/licenses/LICENSE-2.0
3511
- *
3512
- * Unless required by applicable law or agreed to in writing, software
3513
- * distributed under the License is distributed on an "AS IS" BASIS,
3514
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3515
- * See the License for the specific language governing permissions and
3516
- * limitations under the License.
3517
- */function sI(n,e){return e}class be{constructor(e,t,r,s){this.server=e,this.local=t||e,this.writable=!!r,this.xform=s||sI}}let fs=null;function iI(n){return!Ei(n)||n.length<2?n:af(n)}function ka(){if(fs)return fs;const n=[];n.push(new be("bucket")),n.push(new be("generation")),n.push(new be("metageneration")),n.push(new be("name","fullPath",!0));function e(i,a){return iI(a)}const t=new be("name");t.xform=e,n.push(t);function r(i,a){return a!==void 0?Number(a):a}const s=new be("size");return s.xform=r,n.push(s),n.push(new be("timeCreated")),n.push(new be("updated")),n.push(new be("md5Hash",null,!0)),n.push(new be("cacheControl",null,!0)),n.push(new be("contentDisposition",null,!0)),n.push(new be("contentEncoding",null,!0)),n.push(new be("contentLanguage",null,!0)),n.push(new be("contentType",null,!0)),n.push(new be("metadata","customMetadata",!0)),fs=n,fs}function oI(n,e){function t(){const r=n.bucket,s=n.fullPath,i=new Ve(r,s);return e._makeStorageReference(i)}Object.defineProperty(n,"ref",{get:t})}function aI(n,e,t){const r={};r.type="file";const s=t.length;for(let i=0;i<s;i++){const a=t[i];r[a.local]=a.xform(r,e[a.server])}return oI(r,n),r}function cf(n,e,t){const r=of(e);return r===null?null:aI(n,r,t)}function cI(n,e,t,r){const s=of(e);if(s===null||!Ei(s.downloadTokens))return null;const i=s.downloadTokens;if(i.length===0)return null;const a=encodeURIComponent;return i.split(",").map(d=>{const f=n.bucket,m=n.fullPath,_="/b/"+a(f)+"/o/"+a(m),R=ln(_,t,r),S=ef({alt:"media",token:d});return R+S})[0]}function uf(n,e){const t={},r=e.length;for(let s=0;s<r;s++){const i=e[s];i.writable&&(t[i.server]=n[i.local])}return JSON.stringify(t)}class qt{constructor(e,t,r,s){this.url=e,this.method=t,this.handler=r,this.timeout=s,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}/**
3518
- * @license
3519
- * Copyright 2017 Google LLC
3520
- *
3521
- * Licensed under the Apache License, Version 2.0 (the "License");
3522
- * you may not use this file except in compliance with the License.
3523
- * You may obtain a copy of the License at
3524
- *
3525
- * http://www.apache.org/licenses/LICENSE-2.0
3526
- *
3527
- * Unless required by applicable law or agreed to in writing, software
3528
- * distributed under the License is distributed on an "AS IS" BASIS,
3529
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3530
- * See the License for the specific language governing permissions and
3531
- * limitations under the License.
3532
- */function ct(n){if(!n)throw Sa()}function Na(n,e){function t(r,s){const i=cf(n,s,e);return ct(i!==null),i}return t}function uI(n,e){function t(r,s){const i=cf(n,s,e);return ct(i!==null),cI(i,s,n.host,n._protocol)}return t}function Br(n){function e(t,r){let s;return t.getStatus()===401?t.getErrorText().includes("Firebase App Check token is invalid")?s=bv():s=Rv():t.getStatus()===402?s=Av(n.bucket):t.getStatus()===403?s=Pv(n.path):s=r,s.status=t.getStatus(),s.serverResponse=r.serverResponse,s}return e}function Ti(n){const e=Br(n);function t(r,s){let i=e(r,s);return r.getStatus()===404&&(i=wv(n.path)),i.serverResponse=s.serverResponse,i}return t}function lf(n,e,t){const r=e.fullServerUrl(),s=ln(r,n.host,n._protocol),i="GET",a=n.maxOperationRetryTime,c=new qt(s,i,Na(n,t),a);return c.errorHandler=Ti(e),c}function lI(n,e,t){const r=e.fullServerUrl(),s=ln(r,n.host,n._protocol)+"?alt=media",i="GET",a=n.maxOperationRetryTime,c=new qt(s,i,(l,d)=>d,a);return c.errorHandler=Ti(e),c}function hI(n,e,t){const r=e.fullServerUrl(),s=ln(r,n.host,n._protocol),i="GET",a=n.maxOperationRetryTime,c=new qt(s,i,uI(n,t),a);return c.errorHandler=Ti(e),c}function dI(n,e){const t=e.fullServerUrl(),r=ln(t,n.host,n._protocol),s="DELETE",i=n.maxOperationRetryTime;function a(l,d){}const c=new qt(r,s,a,i);return c.successCodes=[200,204],c.errorHandler=Ti(e),c}function fI(n,e){return n&&n.contentType||e&&e.type()||"application/octet-stream"}function hf(n,e,t){const r=Object.assign({},t);return r.fullPath=n.path,r.size=e.size(),r.contentType||(r.contentType=fI(null,e)),r}function pI(n,e,t,r,s){const i=e.bucketOnlyServerUrl(),a={"X-Goog-Upload-Protocol":"multipart"};function c(){let x="";for(let $=0;$<2;$++)x=x+Math.random().toString().slice(2);return x}const l=c();a["Content-Type"]="multipart/related; boundary="+l;const d=hf(e,r,s),f=uf(d,t),m="--"+l+`\r
3533
- Content-Type: application/json; charset=utf-8\r
3534
- \r
3535
- `+f+`\r
3536
- --`+l+`\r
3537
- Content-Type: `+d.contentType+`\r
3538
- \r
3539
- `,_=`\r
3540
- --`+l+"--",R=It.getBlob(m,r,_);if(R===null)throw Jd();const S={name:d.fullPath},N=ln(i,n.host,n._protocol),k="POST",B=n.maxUploadRetryTime,M=new qt(N,k,Na(n,t),B);return M.urlParams=S,M.headers=a,M.body=R.uploadData(),M.errorHandler=Br(e),M}class Ws{constructor(e,t,r,s){this.current=e,this.total=t,this.finalized=!!r,this.metadata=s||null}}function Da(n,e){let t=null;try{t=n.getResponseHeader("X-Goog-Upload-Status")}catch{ct(!1)}return ct(!!t&&(e||["active"]).indexOf(t)!==-1),t}function mI(n,e,t,r,s){const i=e.bucketOnlyServerUrl(),a=hf(e,r,s),c={name:a.fullPath},l=ln(i,n.host,n._protocol),d="POST",f={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${r.size()}`,"X-Goog-Upload-Header-Content-Type":a.contentType,"Content-Type":"application/json; charset=utf-8"},m=uf(a,t),_=n.maxUploadRetryTime;function R(N){Da(N);let k;try{k=N.getResponseHeader("X-Goog-Upload-URL")}catch{ct(!1)}return ct(Ei(k)),k}const S=new qt(l,d,R,_);return S.urlParams=c,S.headers=f,S.body=m,S.errorHandler=Br(e),S}function gI(n,e,t,r){const s={"X-Goog-Upload-Command":"query"};function i(d){const f=Da(d,["active","final"]);let m=null;try{m=d.getResponseHeader("X-Goog-Upload-Size-Received")}catch{ct(!1)}m||ct(!1);const _=Number(m);return ct(!isNaN(_)),new Ws(_,r.size(),f==="final")}const a="POST",c=n.maxUploadRetryTime,l=new qt(t,a,i,c);return l.headers=s,l.errorHandler=Br(e),l}const fl=256*1024;function _I(n,e,t,r,s,i,a,c){const l=new Ws(0,0);if(a?(l.current=a.current,l.total=a.total):(l.current=0,l.total=r.size()),r.size()!==l.total)throw Nv();const d=l.total-l.current;let f=d;s>0&&(f=Math.min(f,s));const m=l.current,_=m+f;let R="";f===0?R="finalize":d===f?R="upload, finalize":R="upload";const S={"X-Goog-Upload-Command":R,"X-Goog-Upload-Offset":`${l.current}`},N=r.slice(m,_);if(N===null)throw Jd();function k($,ce){const X=Da($,["active","final"]),v=l.current+f,g=r.size();let y;return X==="final"?y=Na(e,i)($,ce):y=null,new Ws(v,g,X==="final",y)}const B="POST",M=e.maxUploadRetryTime,x=new qt(t,B,k,M);return x.headers=S,x.body=N.uploadData(),x.progressCallback=c||null,x.errorHandler=Br(n),x}const ke={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function to(n){switch(n){case"running":case"pausing":case"canceling":return ke.RUNNING;case"paused":return ke.PAUSED;case"success":return ke.SUCCESS;case"canceled":return ke.CANCELED;case"error":return ke.ERROR;default:return ke.ERROR}}/**
3541
- * @license
3542
- * Copyright 2017 Google LLC
3543
- *
3544
- * Licensed under the Apache License, Version 2.0 (the "License");
3545
- * you may not use this file except in compliance with the License.
3546
- * You may obtain a copy of the License at
3547
- *
3548
- * http://www.apache.org/licenses/LICENSE-2.0
3549
- *
3550
- * Unless required by applicable law or agreed to in writing, software
3551
- * distributed under the License is distributed on an "AS IS" BASIS,
3552
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3553
- * See the License for the specific language governing permissions and
3554
- * limitations under the License.
3555
- */class yI{constructor(e,t,r){if(Fv(e)||t!=null||r!=null)this.next=e,this.error=t??void 0,this.complete=r??void 0;else{const i=e;this.next=i.next,this.error=i.error,this.complete=i.complete}}}/**
3556
- * @license
3557
- * Copyright 2017 Google LLC
3558
- *
3559
- * Licensed under the Apache License, Version 2.0 (the "License");
3560
- * you may not use this file except in compliance with the License.
3561
- * You may obtain a copy of the License at
3562
- *
3563
- * http://www.apache.org/licenses/LICENSE-2.0
3564
- *
3565
- * Unless required by applicable law or agreed to in writing, software
3566
- * distributed under the License is distributed on an "AS IS" BASIS,
3567
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3568
- * See the License for the specific language governing permissions and
3569
- * limitations under the License.
3570
- */function mn(n){return(...e)=>{Promise.resolve().then(()=>n(...e))}}class df{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=Xt.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=Xt.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=Xt.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,r,s,i){if(this.sent_)throw sr("cannot .send() more than once");if(Lt(e)&&r&&(this.xhr_.withCredentials=!0),this.sent_=!0,this.xhr_.open(t,e,!0),i!==void 0)for(const a in i)i.hasOwnProperty(a)&&this.xhr_.setRequestHeader(a,i[a].toString());return s!==void 0?this.xhr_.send(s):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw sr("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw sr("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw sr("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw sr("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener("progress",e)}}class EI extends df{initXhr(){this.xhr_.responseType="text"}}function wt(){return new EI}class TI extends df{initXhr(){this.xhr_.responseType="blob"}}function vI(){return new TI}/**
3571
- * @license
3572
- * Copyright 2017 Google LLC
3573
- *
3574
- * Licensed under the Apache License, Version 2.0 (the "License");
3575
- * you may not use this file except in compliance with the License.
3576
- * You may obtain a copy of the License at
3577
- *
3578
- * http://www.apache.org/licenses/LICENSE-2.0
3579
- *
3580
- * Unless required by applicable law or agreed to in writing, software
3581
- * distributed under the License is distributed on an "AS IS" BASIS,
3582
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3583
- * See the License for the specific language governing permissions and
3584
- * limitations under the License.
3585
- */class II{isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}constructor(e,t,r=null){this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=e,this._blob=t,this._metadata=r,this._mappings=ka(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=s=>{if(this._request=void 0,this._chunkMultiplier=1,s._codeEquals(te.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{const i=this.isExponentialBackoffExpired();if(tf(s.status,[]))if(i)s=Xd();else{this.sleepTime=Math.max(this.sleepTime*2,Iv),this._needToFetchStatus=!0,this.completeTransitions_();return}this._error=s,this._transition("error")}},this._metadataErrorHandler=s=>{this._request=void 0,s._codeEquals(te.CANCELED)?this.completeTransitions_():(this._error=s,this._transition("error"))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((s,i)=>{this._resolve=s,this._reject=i,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){const e=this._transferred;return t=>this._updateProgress(e+t)}_shouldDoResumable(e){return e.size()>256*1024}_start(){this._state==="running"&&this._request===void 0&&(this._resumable?this._uploadUrl===void 0?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(e){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([t,r])=>{switch(this._state){case"running":e(t,r);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused");break}})}_createResumable(){this._resolveToken((e,t)=>{const r=mI(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),s=this._ref.storage._makeRequest(r,wt,e,t);this._request=s,s.getPromise().then(i=>{this._request=void 0,this._uploadUrl=i,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){const e=this._uploadUrl;this._resolveToken((t,r)=>{const s=gI(this._ref.storage,this._ref._location,e,this._blob),i=this._ref.storage._makeRequest(s,wt,t,r);this._request=i,i.getPromise().then(a=>{a=a,this._request=void 0,this._updateProgress(a.current),this._needToFetchStatus=!1,a.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){const e=fl*this._chunkMultiplier,t=new Ws(this._transferred,this._blob.size()),r=this._uploadUrl;this._resolveToken((s,i)=>{let a;try{a=_I(this._ref._location,this._ref.storage,r,this._blob,e,this._mappings,t,this._makeProgressCallback())}catch(l){this._error=l,this._transition("error");return}const c=this._ref.storage._makeRequest(a,wt,s,i,!1);this._request=c,c.getPromise().then(l=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(l.current),l.finalized?(this._metadata=l.metadata,this._transition("success")):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){fl*this._chunkMultiplier*2<32*1024*1024&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{const r=lf(this._ref.storage,this._ref._location,this._mappings),s=this._ref.storage._makeRequest(r,wt,e,t);this._request=s,s.getPromise().then(i=>{this._request=void 0,this._metadata=i,this._transition("success")},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((e,t)=>{const r=pI(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),s=this._ref.storage._makeRequest(r,wt,e,t);this._request=s,s.getPromise().then(i=>{this._request=void 0,this._metadata=i,this._updateProgress(this._blob.size()),this._transition("success")},this._errorHandler)})}_updateProgress(e){const t=this._transferred;this._transferred=e,this._transferred!==t&&this._notifyObservers()}_transition(e){if(this._state!==e)switch(e){case"canceling":case"pausing":this._state=e,this._request!==void 0?this._request.cancel():this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_());break;case"running":const t=this._state==="paused";this._state=e,t&&(this._notifyObservers(),this._start());break;case"paused":this._state=e,this._notifyObservers();break;case"canceled":this._error=Yd(),this._state=e,this._notifyObservers();break;case"error":this._state=e,this._notifyObservers();break;case"success":this._state=e,this._notifyObservers();break}}completeTransitions_(){switch(this._state){case"pausing":this._transition("paused");break;case"canceling":this._transition("canceled");break;case"running":this._start();break}}get snapshot(){const e=to(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,t,r,s){const i=new yI(t||void 0,r||void 0,s||void 0);return this._addObserver(i),()=>{this._removeObserver(i)}}then(e,t){return this._promise.then(e,t)}catch(e){return this.then(null,e)}_addObserver(e){this._observers.push(e),this._notifyObserver(e)}_removeObserver(e){const t=this._observers.indexOf(e);t!==-1&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise(),this._observers.slice().forEach(t=>{this._notifyObserver(t)})}_finishPromise(){if(this._resolve!==void 0){let e=!0;switch(to(this._state)){case ke.SUCCESS:mn(this._resolve.bind(null,this.snapshot))();break;case ke.CANCELED:case ke.ERROR:const t=this._reject;mn(t.bind(null,this._error))();break;default:e=!1;break}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(to(this._state)){case ke.RUNNING:case ke.PAUSED:e.next&&mn(e.next.bind(e,this.snapshot))();break;case ke.SUCCESS:e.complete&&mn(e.complete.bind(e))();break;case ke.CANCELED:case ke.ERROR:e.error&&mn(e.error.bind(e,this._error))();break;default:e.error&&mn(e.error.bind(e,this._error))()}}resume(){const e=this._state==="paused"||this._state==="pausing";return e&&this._transition("running"),e}pause(){const e=this._state==="running";return e&&this._transition("pausing"),e}cancel(){const e=this._state==="running"||this._state==="pausing";return e&&this._transition("canceling"),e}}/**
3586
- * @license
3587
- * Copyright 2019 Google LLC
3588
- *
3589
- * Licensed under the Apache License, Version 2.0 (the "License");
3590
- * you may not use this file except in compliance with the License.
3591
- * You may obtain a copy of the License at
3592
- *
3593
- * http://www.apache.org/licenses/LICENSE-2.0
3594
- *
3595
- * Unless required by applicable law or agreed to in writing, software
3596
- * distributed under the License is distributed on an "AS IS" BASIS,
3597
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3598
- * See the License for the specific language governing permissions and
3599
- * limitations under the License.
3600
- */class rn{constructor(e,t){this._service=e,t instanceof Ve?this._location=t:this._location=Ve.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new rn(e,t)}get root(){const e=new Ve(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return af(this._location.path)}get storage(){return this._service}get parent(){const e=nI(this._location.path);if(e===null)return null;const t=new Ve(this._location.bucket,e);return new rn(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw Ov(e)}}function wI(n,e){n._throwIfRoot("getBlob");const t=lI(n.storage,n._location);return n.storage.makeRequestWithTokens(t,vI).then(r=>r)}function AI(n,e,t){return n._throwIfRoot("uploadBytesResumable"),new II(n,new It(e),t)}function RI(n){n._throwIfRoot("getMetadata");const e=lf(n.storage,n._location,ka());return n.storage.makeRequestWithTokens(e,wt)}function bI(n){n._throwIfRoot("getDownloadURL");const e=hI(n.storage,n._location,ka());return n.storage.makeRequestWithTokens(e,wt).then(t=>{if(t===null)throw Dv();return t})}function PI(n){n._throwIfRoot("deleteObject");const e=dI(n.storage,n._location);return n.storage.makeRequestWithTokens(e,wt)}function SI(n,e){const t=rI(n._location.path,e),r=new Ve(n._location.bucket,t);return new rn(n.storage,r)}/**
3601
- * @license
3602
- * Copyright 2017 Google LLC
3603
- *
3604
- * Licensed under the Apache License, Version 2.0 (the "License");
3605
- * you may not use this file except in compliance with the License.
3606
- * You may obtain a copy of the License at
3607
- *
3608
- * http://www.apache.org/licenses/LICENSE-2.0
3609
- *
3610
- * Unless required by applicable law or agreed to in writing, software
3611
- * distributed under the License is distributed on an "AS IS" BASIS,
3612
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3613
- * See the License for the specific language governing permissions and
3614
- * limitations under the License.
3615
- */function CI(n){return/^[A-Za-z]+:\/\//.test(n)}function kI(n,e){return new rn(n,e)}function ff(n,e){if(n instanceof Va){const t=n;if(t._bucket==null)throw kv();const r=new rn(t,t._bucket);return e!=null?ff(r,e):r}else return e!==void 0?SI(n,e):n}function NI(n,e){if(e&&CI(e)){if(n instanceof Va)return kI(n,e);throw bo("To use ref(service, url), the first argument must be a Storage instance.")}else return ff(n,e)}function pl(n,e){const t=e==null?void 0:e[Qd];return t==null?null:Ve.makeFromBucketSpec(t,n)}function DI(n,e,t,r={}){n.host=`${e}:${t}`;const s=Lt(e);s&&(Qs(`https://${n.host}`),xt("Storage",!0)),n._isUsingEmulator=!0,n._protocol=s?"https":"http";const{mockUserToken:i}=r;i&&(n._overrideAuthToken=typeof i=="string"?i:wl(i,n.app.options.projectId))}class Va{constructor(e,t,r,s,i,a=!1){this.app=e,this._authProvider=t,this._appCheckProvider=r,this._url=s,this._firebaseVersion=i,this._isUsingEmulator=a,this._bucket=null,this._host=Kd,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=Tv,this._maxUploadRetryTime=vv,this._requests=new Set,s!=null?this._bucket=Ve.makeFromBucketSpec(s,this._host):this._bucket=pl(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=Ve.makeFromBucketSpec(this._url,e):this._bucket=pl(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){dl("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){dl("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){const t=await e.getToken();if(t!==null)return t.accessToken}return null}async _getAppCheckToken(){if(Pe(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new rn(this,e)}_makeRequest(e,t,r,s,i=!0){if(this._deleted)return new Lv(Zd());{const a=Gv(e,this._appId,r,s,t,this._firebaseVersion,i,this._isUsingEmulator);return this._requests.add(a),a.getPromise().then(()=>this._requests.delete(a),()=>this._requests.delete(a)),a}}async makeRequestWithTokens(e,t){const[r,s]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,r,s).getPromise()}}const ml="@firebase/storage",gl="0.13.11";/**
3616
- * @license
3617
- * Copyright 2020 Google LLC
3618
- *
3619
- * Licensed under the Apache License, Version 2.0 (the "License");
3620
- * you may not use this file except in compliance with the License.
3621
- * You may obtain a copy of the License at
3622
- *
3623
- * http://www.apache.org/licenses/LICENSE-2.0
3624
- *
3625
- * Unless required by applicable law or agreed to in writing, software
3626
- * distributed under the License is distributed on an "AS IS" BASIS,
3627
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3628
- * See the License for the specific language governing permissions and
3629
- * limitations under the License.
3630
- */const pf="storage";function VI(n,e,t){return n=Z(n),AI(n,e,t)}function OI(n){return n=Z(n),RI(n)}function LI(n){return n=Z(n),bI(n)}function xI(n){return n=Z(n),PI(n)}function ir(n,e){return n=Z(n),NI(n,e)}function MI(n=Xs(),e){n=Z(n),xt("Storage",!1);const r=kr(n,pf).getImmediate({identifier:e}),s=So("storage");return s&&UI(r,...s),r}function UI(n,e,t,r={}){DI(n,e,t,r)}/**
3631
- * @license
3632
- * Copyright 2021 Google LLC
3633
- *
3634
- * Licensed under the Apache License, Version 2.0 (the "License");
3635
- * you may not use this file except in compliance with the License.
3636
- * You may obtain a copy of the License at
3637
- *
3638
- * http://www.apache.org/licenses/LICENSE-2.0
3639
- *
3640
- * Unless required by applicable law or agreed to in writing, software
3641
- * distributed under the License is distributed on an "AS IS" BASIS,
3642
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3643
- * See the License for the specific language governing permissions and
3644
- * limitations under the License.
3645
- */function FI(n,e){return n=Z(n),wI(n)}function BI(n,{instanceIdentifier:e}){const t=n.getProvider("app").getImmediate(),r=n.getProvider("auth-internal"),s=n.getProvider("app-check-internal");return new Va(t,r,s,e,sn)}function qI(){St(new ut(pf,BI,"PUBLIC").setMultipleInstances(!0)),qe(ml,gl,""),qe(ml,gl,"esm2017")}qI();var jI=new rt,$I=n=>({getCurrentUser:async()=>{let e=n.currentUser;if(!e)return null;let{claims:t}=await e.getIdTokenResult();return{...e,role:t.role}},loginWithPassword:async(e,{email:t,password:r})=>{let s=(await Kg(n,t,r)).user;if(!s)throw new Error("No user found");let{claims:i}=await s.getIdTokenResult();return{...s,role:i.role}},loginWithPopup:async()=>{let e=(await __(n,jI)).user;if(!e)throw new Error("No user found");let{claims:t}=await e.getIdTokenResult();return{...e,role:t.role}},logout:async()=>{await Yg(n)},loginWithToken:async e=>{let t=(await Gg(n,e)).user;if(!t)throw new Error("No user found");let{claims:r}=await t.getIdTokenResult();return{...t,role:r.role}},subscribeToUser:e=>Xl(n,t=>{t?t.getIdTokenResult().then(r=>{let{claims:s}=r;e({...t,role:s==null?void 0:s.role})}):e(null)})}),mf=(n,e)=>{var f;let{collection:t,filters:r,limit:s,search:i,sort:a,isCollectionGroup:c,cursor:l}=e,d=c?Pd(n,t):bd(n,t);if(r&&r.forEach(({key:m,operator:_,value:R})=>{d=Ue(d,Rn(m,_,R))}),a&&(d=Ue(d,xd(a.key,a.direction))),l&&(d=Ue(d,Ud(l))),((f=i.paths)==null?void 0:f.length)&&i.query){let m=(i.query||"").trim();m&&(d=Ue(d,Rn(i.paths[0].prop,">=",m),Rn(i.paths[0].prop,"<=",`${m}`)))}return Ue(d,Md(s))},zI=(n,e,t)=>{var f;let{collection:r,filters:s,sort:i,isCollectionGroup:a,search:c,limit:l}=e,d=a?Pd(n,r):bd(n,r);if(s&&s.forEach(({key:m,operator:_,value:R})=>{d=Ue(d,Rn(m,_,R))}),i&&(d=Ue(d,xd(i.key,i.direction))),((f=c.paths)==null?void 0:f.length)&&c.query){let m=(c.query||"").trim();m&&(d=Ue(d,Rn(c.paths[0].prop,">=",m),Rn(c.paths[0].prop,"<=",`${m}`)))}return t&&(d=Ue(d,Ud(t))),d=Ue(d,Md(l)),Ue(d,pv(1))},HI=n=>(e,t,r)=>{let s=mf(n,e);return Hd(s,i=>{let a=i.docs.map(c=>c.data());t(a,i.docs[i.docs.length-1])},i=>{r({code:i.code,message:i.name,description:i.message})})},GI=n=>async e=>{let{cursor:t}=e,r=t?await jd(Bn(n,e.collection,t.id)):null,s=zI(n,e,r);return(await $d(s)).docs[0]??null},WI=n=>async e=>{let t=Km(n,"getQueryCount"),{data:r}=await t(e);return r.count},KI=n=>async e=>{let t=Bn(n,e),r=await jd(t),s=r.data();return s?{...s,_id:r.id}:null},QI=n=>async e=>{let t=mf(n,e);return(await $d(t)).docs.map(r=>({...r.data(),_id:r.id}))},XI=n=>async(e,t)=>{let r=Bn(n,e),s=ep(Gt.getState().user,t,!0);return await zd(r,s,{merge:!0}),r.id},YI=n=>async e=>{let t=Bn(n,e);await Ev(t)},JI=n=>async(e,t)=>{let r=Bn(n,e);await zd(r,t,{merge:!0})},ZI=n=>(e,t,r)=>{let s=Bn(n,e);return Hd(s,i=>{let a=i.data();t(a?{...a,_id:i.id}:null)},i=>{r({code:i.code,message:i.name,description:i.message})})},ew=(n,e)=>({subscribeToQuery:HI(n),fetchNextCursor:GI(n),fetchCount:WI(e),fetchItem:KI(n),fetchItems:QI(n),createItem:XI(n),deleteItem:YI(n),updateItem:JI(n),subscribeToItem:ZI(n)}),tw=n=>({delete:async e=>{await xI(ir(n,e))},fetchObject:async e=>{let t=ir(n,e);return await FI(t)},fetchMetadata:async e=>{let t=ir(n,e);return await OI(t)},getObjectUrl:async e=>{let t=ir(n,e);return await LI(t)},upload:async(e,t,r)=>{let s=ir(n,e),i=VI(s,new Blob([t.dataUrl]));i.on("state_changed",c=>{let l=c.bytesTransferred/c.totalBytes*100;r({loaded:c.bytesTransferred,total:c.totalBytes,percent:l})});let a={filename:t.filename,type:t.type,storagePath:e};return await i.then(),a}}),ow=(n,e,t,r)=>({auth:$I(n),db:ew(e,r),storage:tw(t)}),gf=nt.createContext({app:null,auth:null,db:null,storage:null,functions:null,authProviders:[],signOut:()=>{}}),aw=({children:n,app:e,authProviders:t})=>{let[r]=nt.useState(cy(e)),[s]=nt.useState(sv(e)),[i]=nt.useState(MI(e)),[a]=nt.useState(Gm(e));nt.useEffect(()=>Xl(r,d=>{if(!d){Gt.setState({user:null,loading:!1});return}Gt.setState({loading:!0}),Vl(d).then(f=>{Gt.setState({user:{...d,role:f.claims.admin?"admin":"user"},loading:!1})})}),[r]);let c=nt.useCallback(async()=>{Gt.setState({loading:!0});try{await r.signOut(),Gt.setState({user:null,loading:!1})}catch(d){console.error(d)}finally{Gt.setState({loading:!1})}},[r]),l=nt.useMemo(()=>({app:e,auth:r,authProviders:t,db:s,storage:i,signOut:c,functions:a}),[e,r,s,i,a,c,t]);return tp.jsx(gf.Provider,{value:l,children:n})},cw=()=>nt.useContext(gf),uw=()=>Zf();export{uw as G,aw as O,cw as S,ow as a,MI as b,sv as c,cy as d,Gm as g,Km as h,gm as i,qe as r};