@thefittingroom/shop-ui 3.2.3 → 4.2.0

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 (70) hide show
  1. package/dist/index.js +22270 -0
  2. package/dist/index.umd.cjs +22274 -0
  3. package/package.json +20 -22
  4. package/.env.dev +0 -2
  5. package/.env.example +0 -3
  6. package/.env.prod +0 -2
  7. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/ErrorModal.js +0 -43
  8. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/ErrorModal.js.map +0 -1
  9. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/FitModal.js +0 -106
  10. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/FitModal.js.map +0 -1
  11. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/ForgotPasswordModal.js +0 -43
  12. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/ForgotPasswordModal.js.map +0 -1
  13. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/LoadingAvatarModal.js +0 -38
  14. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/LoadingAvatarModal.js.map +0 -1
  15. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/LoggedOutModal.js +0 -36
  16. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/LoggedOutModal.js.map +0 -1
  17. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/ModalManager.js +0 -107
  18. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/ModalManager.js.map +0 -1
  19. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/NoAvatarModal.js +0 -19
  20. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/NoAvatarModal.js.map +0 -1
  21. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/ResetLinkModal.js +0 -31
  22. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/ResetLinkModal.js.map +0 -1
  23. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/ScanCodeModal.js +0 -77
  24. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/ScanCodeModal.js.map +0 -1
  25. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/SignInModal.js +0 -94
  26. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/SignInModal.js.map +0 -1
  27. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/SizeErrorModal.js +0 -43
  28. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/SizeErrorModal.js.map +0 -1
  29. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/TryOnModal.js +0 -51
  30. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Modals/TryOnModal.js.map +0 -1
  31. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/SizeRec.js +0 -365
  32. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/SizeRec.js.map +0 -1
  33. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Vto.js +0 -52
  34. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/Vto.js.map +0 -1
  35. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/index.js +0 -16
  36. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/index.js.map +0 -1
  37. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/locale.js +0 -108
  38. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/locale.js.map +0 -1
  39. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/slider.js +0 -44
  40. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/slider.js.map +0 -1
  41. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/svgs.js +0 -33
  42. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/svgs.js.map +0 -1
  43. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/uiError.js +0 -8
  44. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/components/uiError.js.map +0 -1
  45. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/helpers/telephone.js +0 -12368
  46. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/helpers/telephone.js.map +0 -1
  47. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/helpers/validations.js +0 -15
  48. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/helpers/validations.js.map +0 -1
  49. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/index.js +0 -3
  50. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/index.js.map +0 -1
  51. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/init.js +0 -7
  52. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/init.js.map +0 -1
  53. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/styles/index.js +0 -12
  54. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/styles/index.js.map +0 -1
  55. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/tfr-modal.js +0 -77
  56. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/tfr-modal.js.map +0 -1
  57. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/tfr-size-rec.js +0 -202
  58. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/tfr-size-rec.js.map +0 -1
  59. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/tfr.js +0 -212
  60. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/tfr.js.map +0 -1
  61. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/types/index.js +0 -15
  62. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/esm/types/index.js.map +0 -1
  63. package/.rollup.cache/home/runner/work/shop-sdk-ui/shop-sdk-ui/dist/tsconfig.tsbuildinfo +0 -1
  64. package/README.md +0 -153
  65. package/dist/esm/index.js +0 -28142
  66. package/dist/esm/index.js.map +0 -1
  67. package/dist/esm/index.min.js +0 -3399
  68. package/dist/esm/index.min.js.map +0 -1
  69. package/dist/tsconfig.tsbuildinfo +0 -1
  70. package/index.html +0 -126
@@ -1,3399 +0,0 @@
1
- /*!
2
- * thefittingroom v3.2.3 (2025-09-09T18:41:38.889Z)
3
- * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
4
- */
5
- function e(t,n){let i=function(){0!==n.length&&e(n.slice(-1),n.slice(0,-1))};var r=new Image;r.onload=i,r.onerror=i,r.src=t}function t(t){e(t.slice(-1),t.slice(0,-1))}const n=(e,n)=>{const i=document.getElementById(e);if(!i)throw new Error(`Slider with id ${e} not found`);return{Load(e,r){if(!Array.isArray(e)||!e.length)return console.debug("slider has no images to load"),new Error("slider has no images to load");t(e);const s=void 0!==r?r:0;i.value=s.toString(),i.max=(e.length-1).toString();const o=()=>{const t=parseInt(i.value);n(i,e[t])};return n(i,e[s]),i.removeEventListener("input",o),i.addEventListener("input",o),()=>{i.removeEventListener("input",o)}}}},i=function(e){const t=[];let n=0;for(let i=0;i<e.length;i++){let r=e.charCodeAt(i);r<128?t[n++]=r:r<2048?(t[n++]=r>>6|192,t[n++]=63&r|128):55296==(64512&r)&&i+1<e.length&&56320==(64512&e.charCodeAt(i+1))?(r=65536+((1023&r)<<10)+(1023&e.charCodeAt(++i)),t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=63&r|128):(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=63&r|128)}return t},r={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:"function"==typeof atob,encodeByteArray(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,i=[];for(let t=0;t<e.length;t+=3){const r=e[t],s=t+1<e.length,o=s?e[t+1]:0,a=t+2<e.length,c=a?e[t+2]:0,l=r>>2,u=(3&r)<<4|o>>4;let h=(15&o)<<2|c>>6,d=63&c;a||(d=64,s||(h=64)),i.push(n[l],n[u],n[h],n[d])}return i.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(i(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let n=0,i=0;for(;n<e.length;){const r=e[n++];if(r<128)t[i++]=String.fromCharCode(r);else if(r>191&&r<224){const s=e[n++];t[i++]=String.fromCharCode((31&r)<<6|63&s)}else if(r>239&&r<365){const s=((7&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t[i++]=String.fromCharCode(55296+(s>>10)),t[i++]=String.fromCharCode(56320+(1023&s))}else{const s=e[n++],o=e[n++];t[i++]=String.fromCharCode((15&r)<<12|(63&s)<<6|63&o)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const n=t?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let t=0;t<e.length;){const r=n[e.charAt(t++)],o=t<e.length?n[e.charAt(t)]:0;++t;const a=t<e.length?n[e.charAt(t)]:64;++t;const c=t<e.length?n[e.charAt(t)]:64;if(++t,null==r||null==o||null==a||null==c)throw new s;const l=r<<2|o>>4;if(i.push(l),64!==a){const e=o<<4&240|a>>2;if(i.push(e),64!==c){const e=a<<6&192|c;i.push(e)}}}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};
6
- /*!
7
- * thefittingroom v2.0.8 (2025-08-04T16:23:04.367Z)
8
- * Copyright 2022-present, TheFittingRoom, Inc. All rights reserved.
9
- */class s extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const o=function(e){return function(e){const t=i(e);return r.encodeByteArray(t,!0)}(e).replace(/\./g,"")},a=function(e){try{return r.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};
10
- /**
11
- * @license
12
- * Copyright 2022 Google LLC
13
- *
14
- * Licensed under the Apache License, Version 2.0 (the "License");
15
- * you may not use this file except in compliance with the License.
16
- * You may obtain a copy of the License at
17
- *
18
- * http://www.apache.org/licenses/LICENSE-2.0
19
- *
20
- * Unless required by applicable law or agreed to in writing, software
21
- * distributed under the License is distributed on an "AS IS" BASIS,
22
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
- * See the License for the specific language governing permissions and
24
- * limitations under the License.
25
- */
26
- const c=()=>
27
- /**
28
- * @license
29
- * Copyright 2022 Google LLC
30
- *
31
- * Licensed under the Apache License, Version 2.0 (the "License");
32
- * you may not use this file except in compliance with the License.
33
- * You may obtain a copy of the License at
34
- *
35
- * http://www.apache.org/licenses/LICENSE-2.0
36
- *
37
- * Unless required by applicable law or agreed to in writing, software
38
- * distributed under the License is distributed on an "AS IS" BASIS,
39
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
40
- * See the License for the specific language governing permissions and
41
- * limitations under the License.
42
- */
43
- function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__,l=()=>{try{return c()||(()=>{if("undefined"==typeof process||void 0===process.env)return;const e=process.env.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||(()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&&a(e[1]);return t&&JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},u=e=>{var t,n;return null===(n=null===(t=l())||void 0===t?void 0:t.emulatorHosts)||void 0===n?void 0:n[e]},h=()=>{var e;return null===(e=l())||void 0===e?void 0:e.config},d=e=>{var t;return null===(t=l())||void 0===t?void 0:t[`_${e}`]};
44
- /**
45
- * @license
46
- * Copyright 2017 Google LLC
47
- *
48
- * Licensed under the Apache License, Version 2.0 (the "License");
49
- * you may not use this file except in compliance with the License.
50
- * You may obtain a copy of the License at
51
- *
52
- * http://www.apache.org/licenses/LICENSE-2.0
53
- *
54
- * Unless required by applicable law or agreed to in writing, software
55
- * distributed under the License is distributed on an "AS IS" BASIS,
56
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
57
- * See the License for the specific language governing permissions and
58
- * limitations under the License.
59
- */
60
- class f{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),"function"==typeof e&&(this.promise.catch(()=>{}),1===e.length?e(t):e(t,n))}}}
61
- /**
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 p(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch(e){return!1}}async function g(e){return(await fetch(e,{credentials:"include"})).ok}
77
- /**
78
- * @license
79
- * Copyright 2021 Google LLC
80
- *
81
- * Licensed under the Apache License, Version 2.0 (the "License");
82
- * you may not use this file except in compliance with the License.
83
- * You may obtain a copy of the License at
84
- *
85
- * http://www.apache.org/licenses/LICENSE-2.0
86
- *
87
- * Unless required by applicable law or agreed to in writing, software
88
- * distributed under the License is distributed on an "AS IS" BASIS,
89
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
90
- * See the License for the specific language governing permissions and
91
- * limitations under the License.
92
- */const m={};let y=!1;function v(e,t){if("undefined"==typeof window||"undefined"==typeof document||!p(window.location.host)||m[e]===t||m[e]||y)return;function n(e){return`__firebase__banner__${e}`}m[e]=t;const i="__firebase__banner",r=function(){const e={prod:[],emulator:[]};for(const t of Object.keys(m))m[t]?e.emulator.push(t):e.prod.push(t);return e}().prod.length>0;function s(){const e=document.createElement("span");return e.style.cursor="pointer",e.style.marginLeft="16px",e.style.fontSize="24px",e.innerHTML=" &times;",e.onclick=()=>{y=!0,function(){const e=document.getElementById(i);e&&e.remove()}()},e}function o(){const e=function(e){let t=document.getElementById(e),n=!1;return t||(t=document.createElement("div"),t.setAttribute("id",e),n=!0),{created:n,element:t}}(i),t=n("text"),o=document.getElementById(t)||document.createElement("span"),a=n("learnmore"),c=document.getElementById(a)||document.createElement("a"),l=n("preprendIcon"),u=document.getElementById(l)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(e.created){const t=e.element;!function(e){e.style.display="flex",e.style.background="#7faaf0",e.style.position="fixed",e.style.bottom="5px",e.style.left="5px",e.style.padding=".5em",e.style.borderRadius="5px",e.style.alignItems="center"}(t),function(e,t){e.setAttribute("id",t),e.innerText="Learn more",e.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",e.setAttribute("target","__blank"),e.style.paddingLeft="5px",e.style.textDecoration="underline"}(c,a);const n=s();!function(e,t){e.setAttribute("width","24"),e.setAttribute("id",t),e.setAttribute("height","24"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.style.marginLeft="-6px"}(u,l),t.append(u,o,c,n),document.body.appendChild(t)}r?(o.innerText="Preview backend disconnected.",u.innerHTML='<g clip-path="url(#clip0_6013_33858)">\n<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"/>\n</g>\n<defs>\n<clipPath id="clip0_6013_33858">\n<rect width="24" height="24" fill="white"/>\n</clipPath>\n</defs>'):(u.innerHTML='<g clip-path="url(#clip0_6083_34804)">\n<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"/>\n</g>\n<defs>\n<clipPath id="clip0_6083_34804">\n<rect width="24" height="24" fill="white"/>\n</clipPath>\n</defs>',o.innerText="Preview backend running in this workspace."),o.setAttribute("id",t)}"loading"===document.readyState?window.addEventListener("DOMContentLoaded",o):o()}
93
- /**
94
- * @license
95
- * Copyright 2017 Google LLC
96
- *
97
- * Licensed under the Apache License, Version 2.0 (the "License");
98
- * you may not use this file except in compliance with the License.
99
- * You may obtain a copy of the License at
100
- *
101
- * http://www.apache.org/licenses/LICENSE-2.0
102
- *
103
- * Unless required by applicable law or agreed to in writing, software
104
- * distributed under the License is distributed on an "AS IS" BASIS,
105
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
106
- * See the License for the specific language governing permissions and
107
- * limitations under the License.
108
- */function w(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function b(){return!function(){var e;const t=null===(e=l())||void 0===e?void 0:e.forceEnvironment;if("node"===t)return!0;if("browser"===t)return!1;try{return"[object process]"===Object.prototype.toString.call(global.process)}catch(e){return!1}}()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}class _ extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,_.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,S.prototype.create)}}class S{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){const n=t[0]||{},i=`${this.service}/${e}`,r=this.errors[e],s=r?function(e,t){return e.replace(E,(e,n)=>{const i=t[n];return null!=i?String(i):`<${n}?>`})}(r,n):"Error",o=`${this.serviceName}: ${s} (${i}).`;return new _(i,o,n)}}const E=/\{\$([^}]+)}/g;function T(e,t){if(e===t)return!0;const n=Object.keys(e),i=Object.keys(t);for(const r of n){if(!i.includes(r))return!1;const n=e[r],s=t[r];if(I(n)&&I(s)){if(!T(n,s))return!1}else if(n!==s)return!1}for(const e of i)if(!n.includes(e))return!1;return!0}function I(e){return null!==e&&"object"==typeof e}
109
- /**
110
- * @license
111
- * Copyright 2017 Google LLC
112
- *
113
- * Licensed under the Apache License, Version 2.0 (the "License");
114
- * you may not use this file except in compliance with the License.
115
- * You may obtain a copy of the License at
116
- *
117
- * http://www.apache.org/licenses/LICENSE-2.0
118
- *
119
- * Unless required by applicable law or agreed to in writing, software
120
- * distributed under the License is distributed on an "AS IS" BASIS,
121
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
122
- * See the License for the specific language governing permissions and
123
- * limitations under the License.
124
- */function C(e){const t=[];for(const[n,i]of Object.entries(e))Array.isArray(i)?i.forEach(e=>{t.push(encodeURIComponent(n)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(n)+"="+encodeURIComponent(i));return t.length?"&"+t.join("&"):""}function k(e){const t={};return e.replace(/^\?/,"").split("&").forEach(e=>{if(e){const[n,i]=e.split("=");t[decodeURIComponent(n)]=decodeURIComponent(i)}}),t}function A(e){const t=e.indexOf("?");if(!t)return"";const n=e.indexOf("#",t);return e.substring(t,n>0?n:void 0)}class R{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(e=>{this.error(e)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,n){let i;if(void 0===e&&void 0===t&&void 0===n)throw new Error("Missing Observer.");i=function(e,t){if("object"!=typeof e||null===e)return!1;for(const n of t)if(n in e&&"function"==typeof e[n])return!0;return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:n},void 0===i.next&&(i.next=x),void 0===i.error&&(i.error=x),void 0===i.complete&&(i.complete=x);const r=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch(e){}}),this.observers.push(i),r}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&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(void 0!==this.observers&&void 0!==this.observers[e])try{t(this.observers[e])}catch(e){"undefined"!=typeof console&&console.error&&console.error(e)}})}close(e){this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function x(){}
125
- /**
126
- * @license
127
- * Copyright 2021 Google LLC
128
- *
129
- * Licensed under the Apache License, Version 2.0 (the "License");
130
- * you may not use this file except in compliance with the License.
131
- * You may obtain a copy of the License at
132
- *
133
- * http://www.apache.org/licenses/LICENSE-2.0
134
- *
135
- * Unless required by applicable law or agreed to in writing, software
136
- * distributed under the License is distributed on an "AS IS" BASIS,
137
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
138
- * See the License for the specific language governing permissions and
139
- * limitations under the License.
140
- */function N(e){return e&&e._delegate?e._delegate:e}class O{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}
141
- /**
142
- * @license
143
- * Copyright 2019 Google LLC
144
- *
145
- * Licensed under the Apache License, Version 2.0 (the "License");
146
- * you may not use this file except in compliance with the License.
147
- * You may obtain a copy of the License at
148
- *
149
- * http://www.apache.org/licenses/LICENSE-2.0
150
- *
151
- * Unless required by applicable law or agreed to in writing, software
152
- * distributed under the License is distributed on an "AS IS" BASIS,
153
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
154
- * See the License for the specific language governing permissions and
155
- * limitations under the License.
156
- */const L="[DEFAULT]";
157
- /**
158
- * @license
159
- * Copyright 2019 Google LLC
160
- *
161
- * Licensed under the Apache License, Version 2.0 (the "License");
162
- * you may not use this file except in compliance with the License.
163
- * You may obtain a copy of the License at
164
- *
165
- * http://www.apache.org/licenses/LICENSE-2.0
166
- *
167
- * Unless required by applicable law or agreed to in writing, software
168
- * distributed under the License is distributed on an "AS IS" BASIS,
169
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
170
- * See the License for the specific language governing permissions and
171
- * limitations under the License.
172
- */class P{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 e=new f;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{const n=this.getOrInitializeService({instanceIdentifier:t});n&&e.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const n=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),i=null!==(t=null==e?void 0:e.optional)&&void 0!==t&&t;if(!this.isInitialized(n)&&!this.shouldAutoInitialize()){if(i)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(e){if(i)return null;throw e}}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(function(e){return"EAGER"===e.instantiationMode}
173
- /**
174
- * @license
175
- * Copyright 2019 Google LLC
176
- *
177
- * Licensed under the Apache License, Version 2.0 (the "License");
178
- * you may not use this file except in compliance with the License.
179
- * You may obtain a copy of the License at
180
- *
181
- * http://www.apache.org/licenses/LICENSE-2.0
182
- *
183
- * Unless required by applicable law or agreed to in writing, software
184
- * distributed under the License is distributed on an "AS IS" BASIS,
185
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
186
- * See the License for the specific language governing permissions and
187
- * limitations under the License.
188
- */(e))try{this.getOrInitializeService({instanceIdentifier:L})}catch(e){}for(const[e,t]of this.instancesDeferred.entries()){const n=this.normalizeInstanceIdentifier(e);try{const e=this.getOrInitializeService({instanceIdentifier:n});t.resolve(e)}catch(e){}}}}clearInstance(e=L){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(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return null!=this.component}isInitialized(e=L){return this.instances.has(e)}getOptions(e=L){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:n,options:t});for(const[e,t]of this.instancesDeferred.entries()){n===this.normalizeInstanceIdentifier(e)&&t.resolve(i)}return i}onInit(e,t){var n;const i=this.normalizeInstanceIdentifier(t),r=null!==(n=this.onInitCallbacks.get(i))&&void 0!==n?n:new Set;r.add(e),this.onInitCallbacks.set(i,r);const s=this.instances.get(i);return s&&e(s,i),()=>{r.delete(e)}}invokeOnInitCallbacks(e,t){const n=this.onInitCallbacks.get(t);if(n)for(const i of n)try{i(e,t)}catch(e){}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:(i=e,i===L?void 0:i),options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch(e){}var i;return n||null}normalizeInstanceIdentifier(e=L){return this.component?this.component.multipleInstances?e:L:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class D{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 P(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}
189
- /**
190
- * @license
191
- * Copyright 2017 Google LLC
192
- *
193
- * Licensed under the Apache License, Version 2.0 (the "License");
194
- * you may not use this file except in compliance with the License.
195
- * You may obtain a copy of the License at
196
- *
197
- * http://www.apache.org/licenses/LICENSE-2.0
198
- *
199
- * Unless required by applicable law or agreed to in writing, software
200
- * distributed under the License is distributed on an "AS IS" BASIS,
201
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
- * See the License for the specific language governing permissions and
203
- * limitations under the License.
204
- */var M;!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.ERROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(M||(M={}));const z={debug:M.DEBUG,verbose:M.VERBOSE,info:M.INFO,warn:M.WARN,error:M.ERROR,silent:M.SILENT},F=M.INFO,U={[M.DEBUG]:"log",[M.VERBOSE]:"log",[M.INFO]:"info",[M.WARN]:"warn",[M.ERROR]:"error"},V=(e,t,...n)=>{if(t<e.logLevel)return;const i=(new Date).toISOString(),r=U[t];if(!r)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[r](`[${i}] ${e.name}:`,...n)};class B{constructor(e){this.name=e,this._logLevel=F,this._logHandler=V,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in M))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?z[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)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,M.DEBUG,...e),this._logHandler(this,M.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,M.VERBOSE,...e),this._logHandler(this,M.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,M.INFO,...e),this._logHandler(this,M.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,M.WARN,...e),this._logHandler(this,M.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,M.ERROR,...e),this._logHandler(this,M.ERROR,...e)}}let j,H;const $=new WeakMap,q=new WeakMap,G=new WeakMap,K=new WeakMap,W=new WeakMap;let Q={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return q.get(e);if("objectStoreNames"===t)return e.objectStoreNames||G.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return X(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function J(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(H||(H=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Z(this),t),X($.get(this))}:function(...t){return X(e.apply(Z(this),t))}:function(t,...n){const i=e.call(Z(this),t,...n);return G.set(i,t.sort?t.sort():[t]),X(i)}}function Y(e){return"function"==typeof e?J(e):(e instanceof IDBTransaction&&function(e){if(q.has(e))return;const t=new Promise((t,n)=>{const i=()=>{e.removeEventListener("complete",r),e.removeEventListener("error",s),e.removeEventListener("abort",s)},r=()=>{t(),i()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),i()};e.addEventListener("complete",r),e.addEventListener("error",s),e.addEventListener("abort",s)});q.set(e,t)}(e),t=e,(j||(j=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some(e=>t instanceof e)?new Proxy(e,Q):e);var t}function X(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const i=()=>{e.removeEventListener("success",r),e.removeEventListener("error",s)},r=()=>{t(X(e.result)),i()},s=()=>{n(e.error),i()};e.addEventListener("success",r),e.addEventListener("error",s)});return t.then(t=>{t instanceof IDBCursor&&$.set(t,e)}).catch(()=>{}),W.set(t,e),t}(e);if(K.has(e))return K.get(e);const t=Y(e);return t!==e&&(K.set(e,t),W.set(t,e)),t}const Z=e=>W.get(e);const ee=["get","getKey","getAll","getAllKeys","count"],te=["put","add","delete","clear"],ne=new Map;function ie(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(ne.get(t))return ne.get(t);const n=t.replace(/FromIndex$/,""),i=t!==n,r=te.includes(n);if(!(n in(i?IDBIndex:IDBObjectStore).prototype)||!r&&!ee.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,r?"readwrite":"readonly");let o=s.store;return i&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),r&&s.done]))[0]};return ne.set(t,s),s}Q=(e=>({...e,get:(t,n,i)=>ie(t,n)||e.get(t,n,i),has:(t,n)=>!!ie(t,n)||e.has(t,n)}))(Q);
205
- /**
206
- * @license
207
- * Copyright 2019 Google LLC
208
- *
209
- * Licensed under the Apache License, Version 2.0 (the "License");
210
- * you may not use this file except in compliance with the License.
211
- * You may obtain a copy of the License at
212
- *
213
- * http://www.apache.org/licenses/LICENSE-2.0
214
- *
215
- * Unless required by applicable law or agreed to in writing, software
216
- * distributed under the License is distributed on an "AS IS" BASIS,
217
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
218
- * See the License for the specific language governing permissions and
219
- * limitations under the License.
220
- */
221
- class re{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(function(e){const t=e.getComponent();return"VERSION"===(null==t?void 0:t.type)}(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null}).filter(e=>e).join(" ")}}const se="@firebase/app",oe="0.13.2",ae=new B("@firebase/app"),ce="@firebase/app-compat",le="@firebase/analytics-compat",ue="@firebase/analytics",he="@firebase/app-check-compat",de="@firebase/app-check",fe="@firebase/auth",pe="@firebase/auth-compat",ge="@firebase/database",me="@firebase/data-connect",ye="@firebase/database-compat",ve="@firebase/functions",we="@firebase/functions-compat",be="@firebase/installations",_e="@firebase/installations-compat",Se="@firebase/messaging",Ee="@firebase/messaging-compat",Te="@firebase/performance",Ie="@firebase/performance-compat",Ce="@firebase/remote-config",ke="@firebase/remote-config-compat",Ae="@firebase/storage",Re="@firebase/storage-compat",xe="@firebase/firestore",Ne="@firebase/ai",Oe="@firebase/firestore-compat",Le="firebase",Pe="[DEFAULT]",De={[se]:"fire-core",[ce]:"fire-core-compat",[ue]:"fire-analytics",[le]:"fire-analytics-compat",[de]:"fire-app-check",[he]:"fire-app-check-compat",[fe]:"fire-auth",[pe]:"fire-auth-compat",[ge]:"fire-rtdb",[me]:"fire-data-connect",[ye]:"fire-rtdb-compat",[ve]:"fire-fn",[we]:"fire-fn-compat",[be]:"fire-iid",[_e]:"fire-iid-compat",[Se]:"fire-fcm",[Ee]:"fire-fcm-compat",[Te]:"fire-perf",[Ie]:"fire-perf-compat",[Ce]:"fire-rc",[ke]:"fire-rc-compat",[Ae]:"fire-gcs",[Re]:"fire-gcs-compat",[xe]:"fire-fst",[Oe]:"fire-fst-compat",[Ne]:"fire-vertex","fire-js":"fire-js",[Le]:"fire-js-all"},Me=new Map,ze=new Map,Fe=new Map;function Ue(e,t){try{e.container.addComponent(t)}catch(n){ae.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function Ve(e){const t=e.name;if(Fe.has(t))return ae.debug(`There were multiple attempts to register component ${t}.`),!1;Fe.set(t,e);for(const t of Me.values())Ue(t,e);for(const t of ze.values())Ue(t,e);return!0}function Be(e,t){const n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function je(e){return null!=e&&void 0!==e.settings}
222
- /**
223
- * @license
224
- * Copyright 2019 Google LLC
225
- *
226
- * Licensed under the Apache License, Version 2.0 (the "License");
227
- * you may not use this file except in compliance with the License.
228
- * You may obtain a copy of the License at
229
- *
230
- * http://www.apache.org/licenses/LICENSE-2.0
231
- *
232
- * Unless required by applicable law or agreed to in writing, software
233
- * distributed under the License is distributed on an "AS IS" BASIS,
234
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
235
- * See the License for the specific language governing permissions and
236
- * limitations under the License.
237
- */const He=new S("app","Firebase",{"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."});
238
- /**
239
- * @license
240
- * Copyright 2019 Google LLC
241
- *
242
- * Licensed under the Apache License, Version 2.0 (the "License");
243
- * you may not use this file except in compliance with the License.
244
- * You may obtain a copy of the License at
245
- *
246
- * http://www.apache.org/licenses/LICENSE-2.0
247
- *
248
- * Unless required by applicable law or agreed to in writing, software
249
- * distributed under the License is distributed on an "AS IS" BASIS,
250
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
251
- * See the License for the specific language governing permissions and
252
- * limitations under the License.
253
- */
254
- class $e{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new O("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 He.create("app-deleted",{appName:this._name})}}
255
- /**
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 qe="11.10.0";function Ge(e,t={}){let n=e;if("object"!=typeof t){t={name:t}}const i=Object.assign({name:Pe,automaticDataCollectionEnabled:!0},t),r=i.name;if("string"!=typeof r||!r)throw He.create("bad-app-name",{appName:String(r)});if(n||(n=h()),!n)throw He.create("no-options");const s=Me.get(r);if(s){if(T(n,s.options)&&T(i,s.config))return s;throw He.create("duplicate-app",{appName:r})}const o=new D(r);for(const e of Fe.values())o.addComponent(e);const a=new $e(n,i,o);return Me.set(r,a),a}function Ke(e=Pe){const t=Me.get(e);if(!t&&e===Pe&&h())return Ge();if(!t)throw He.create("no-app",{appName:e});return t}function We(e,t,n){var i;let r=null!==(i=De[e])&&void 0!==i?i:e;n&&(r+=`-${n}`);const s=r.match(/\s|\//),o=t.match(/\s|\//);if(s||o){const e=[`Unable to register library "${r}" with version "${t}":`];return s&&e.push(`library name "${r}" contains illegal characters (whitespace or "/")`),s&&o&&e.push("and"),o&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void ae.warn(e.join(" "))}Ve(new O(`${r}-version`,()=>({library:r,version:t}),"VERSION"))}
271
- /**
272
- * @license
273
- * Copyright 2021 Google LLC
274
- *
275
- * Licensed under the Apache License, Version 2.0 (the "License");
276
- * you may not use this file except in compliance with the License.
277
- * You may obtain a copy of the License at
278
- *
279
- * http://www.apache.org/licenses/LICENSE-2.0
280
- *
281
- * Unless required by applicable law or agreed to in writing, software
282
- * distributed under the License is distributed on an "AS IS" BASIS,
283
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
284
- * See the License for the specific language governing permissions and
285
- * limitations under the License.
286
- */const Qe="firebase-heartbeat-store";let Je=null;function Ye(){return Je||(Je=function(e,t,{blocked:n,upgrade:i,blocking:r,terminated:s}={}){const o=indexedDB.open(e,t),a=X(o);return i&&o.addEventListener("upgradeneeded",e=>{i(X(o.result),e.oldVersion,e.newVersion,X(o.transaction),e)}),n&&o.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),a.then(e=>{s&&e.addEventListener("close",()=>s()),r&&e.addEventListener("versionchange",e=>r(e.oldVersion,e.newVersion,e))}).catch(()=>{}),a}("firebase-heartbeat-database",1,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(Qe)}catch(e){console.warn(e)}}}).catch(e=>{throw He.create("idb-open",{originalErrorMessage:e.message})})),Je}async function Xe(e,t){try{const n=(await Ye()).transaction(Qe,"readwrite"),i=n.objectStore(Qe);await i.put(t,Ze(e)),await n.done}catch(e){if(e instanceof _)ae.warn(e.message);else{const t=He.create("idb-set",{originalErrorMessage:null==e?void 0:e.message});ae.warn(t.message)}}}function Ze(e){return`${e.name}!${e.options.appId}`}
287
- /**
288
- * @license
289
- * Copyright 2021 Google LLC
290
- *
291
- * Licensed under the Apache License, Version 2.0 (the "License");
292
- * you may not use this file except in compliance with the License.
293
- * You may obtain a copy of the License at
294
- *
295
- * http://www.apache.org/licenses/LICENSE-2.0
296
- *
297
- * Unless required by applicable law or agreed to in writing, software
298
- * distributed under the License is distributed on an "AS IS" BASIS,
299
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
300
- * See the License for the specific language governing permissions and
301
- * limitations under the License.
302
- */class et{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new nt(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){var e,t;try{const n=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),i=tt();if(null==(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)&&(this._heartbeatsCache=await this._heartbeatsCachePromise,null==(null===(t=this._heartbeatsCache)||void 0===t?void 0:t.heartbeats)))return;if(this._heartbeatsCache.lastSentHeartbeatDate===i||this._heartbeatsCache.heartbeats.some(e=>e.date===i))return;if(this._heartbeatsCache.heartbeats.push({date:i,agent:n}),this._heartbeatsCache.heartbeats.length>30){const e=function(e){if(0===e.length)return-1;let t=0,n=e[0].date;for(let i=1;i<e.length;i++)e[i].date<n&&(n=e[i].date,t=i);return t}
303
- /**
304
- * @license
305
- * Copyright 2019 Google LLC
306
- *
307
- * Licensed under the Apache License, Version 2.0 (the "License");
308
- * you may not use this file except in compliance with the License.
309
- * You may obtain a copy of the License at
310
- *
311
- * http://www.apache.org/licenses/LICENSE-2.0
312
- *
313
- * Unless required by applicable law or agreed to in writing, software
314
- * distributed under the License is distributed on an "AS IS" BASIS,
315
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
316
- * See the License for the specific language governing permissions and
317
- * limitations under the License.
318
- */(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){ae.warn(e)}}async getHeartbeatsHeader(){var e;try{if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null==(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)||0===this._heartbeatsCache.heartbeats.length)return"";const t=tt(),{heartbeatsToSend:n,unsentEntries:i}=function(e,t=1024){const n=[];let i=e.slice();for(const r of e){const e=n.find(e=>e.agent===r.agent);if(e){if(e.dates.push(r.date),it(n)>t){e.dates.pop();break}}else if(n.push({agent:r.agent,dates:[r.date]}),it(n)>t){n.pop();break}i=i.slice(1)}return{heartbeatsToSend:n,unsentEntries:i}}(this._heartbeatsCache.heartbeats),r=o(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=t,i.length>0?(this._heartbeatsCache.heartbeats=i,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),r}catch(e){return ae.warn(e),""}}}function tt(){return(new Date).toISOString().substring(0,10)}class nt{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!function(){try{return"object"==typeof indexedDB}catch(e){return!1}}()&&new Promise((e,t)=>{try{let n=!0;const i="validate-browser-context-for-indexeddb-analytics-module",r=self.indexedDB.open(i);r.onsuccess=()=>{r.result.close(),n||self.indexedDB.deleteDatabase(i),e(!0)},r.onupgradeneeded=()=>{n=!1},r.onerror=()=>{var e;t((null===(e=r.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}}).then(()=>!0).catch(()=>!1)}async read(){if(await this._canUseIndexedDBPromise){const e=await async function(e){try{const t=(await Ye()).transaction(Qe),n=await t.objectStore(Qe).get(Ze(e));return await t.done,n}catch(e){if(e instanceof _)ae.warn(e.message);else{const t=He.create("idb-get",{originalErrorMessage:null==e?void 0:e.message});ae.warn(t.message)}}}(this.app);return(null==e?void 0:e.heartbeats)?e:{heartbeats:[]}}return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const n=await this.read();return Xe(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){var t;if(await this._canUseIndexedDBPromise){const n=await this.read();return Xe(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:[...n.heartbeats,...e.heartbeats]})}}}function it(e){return o(JSON.stringify({version:2,heartbeats:e})).length}var rt;rt="",Ve(new O("platform-logger",e=>new re(e),"PRIVATE")),Ve(new O("heartbeat",e=>new et(e),"PRIVATE")),We(se,oe,rt),We(se,oe,"esm2017"),We("fire-js","");var st,ot,at="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};
319
- /** @license
320
- Copyright The Closure Library Authors.
321
- SPDX-License-Identifier: Apache-2.0
322
- */(function(){var e;
323
- /** @license
324
-
325
- Copyright The Closure Library Authors.
326
- SPDX-License-Identifier: Apache-2.0
327
- */function t(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}function n(e,t,n){n||(n=0);var i=Array(16);if("string"==typeof t)for(var r=0;16>r;++r)i[r]=t.charCodeAt(n++)|t.charCodeAt(n++)<<8|t.charCodeAt(n++)<<16|t.charCodeAt(n++)<<24;else for(r=0;16>r;++r)i[r]=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24;t=e.g[0],n=e.g[1],r=e.g[2];var s=e.g[3],o=t+(s^n&(r^s))+i[0]+3614090360&4294967295;o=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=(n=(r=(s=(t=n+(o<<7&4294967295|o>>>25))+((o=s+(r^t&(n^r))+i[1]+3905402710&4294967295)<<12&4294967295|o>>>20))+((o=r+(n^s&(t^n))+i[2]+606105819&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^r&(s^t))+i[3]+3250441966&4294967295)<<22&4294967295|o>>>10))+((o=t+(s^n&(r^s))+i[4]+4118548399&4294967295)<<7&4294967295|o>>>25))+((o=s+(r^t&(n^r))+i[5]+1200080426&4294967295)<<12&4294967295|o>>>20))+((o=r+(n^s&(t^n))+i[6]+2821735955&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^r&(s^t))+i[7]+4249261313&4294967295)<<22&4294967295|o>>>10))+((o=t+(s^n&(r^s))+i[8]+1770035416&4294967295)<<7&4294967295|o>>>25))+((o=s+(r^t&(n^r))+i[9]+2336552879&4294967295)<<12&4294967295|o>>>20))+((o=r+(n^s&(t^n))+i[10]+4294925233&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^r&(s^t))+i[11]+2304563134&4294967295)<<22&4294967295|o>>>10))+((o=t+(s^n&(r^s))+i[12]+1804603682&4294967295)<<7&4294967295|o>>>25))+((o=s+(r^t&(n^r))+i[13]+4254626195&4294967295)<<12&4294967295|o>>>20))+((o=r+(n^s&(t^n))+i[14]+2792965006&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^r&(s^t))+i[15]+1236535329&4294967295)<<22&4294967295|o>>>10))+((o=t+(r^s&(n^r))+i[1]+4129170786&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^r&(t^n))+i[6]+3225465664&4294967295)<<9&4294967295|o>>>23))+((o=r+(t^n&(s^t))+i[11]+643717713&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(r^s))+i[0]+3921069994&4294967295)<<20&4294967295|o>>>12))+((o=t+(r^s&(n^r))+i[5]+3593408605&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^r&(t^n))+i[10]+38016083&4294967295)<<9&4294967295|o>>>23))+((o=r+(t^n&(s^t))+i[15]+3634488961&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(r^s))+i[4]+3889429448&4294967295)<<20&4294967295|o>>>12))+((o=t+(r^s&(n^r))+i[9]+568446438&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^r&(t^n))+i[14]+3275163606&4294967295)<<9&4294967295|o>>>23))+((o=r+(t^n&(s^t))+i[3]+4107603335&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(r^s))+i[8]+1163531501&4294967295)<<20&4294967295|o>>>12))+((o=t+(r^s&(n^r))+i[13]+2850285829&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^r&(t^n))+i[2]+4243563512&4294967295)<<9&4294967295|o>>>23))+((o=r+(t^n&(s^t))+i[7]+1735328473&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(r^s))+i[12]+2368359562&4294967295)<<20&4294967295|o>>>12))+((o=t+(n^r^s)+i[5]+4294588738&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^r)+i[8]+2272392833&4294967295)<<11&4294967295|o>>>21))+((o=r+(s^t^n)+i[11]+1839030562&4294967295)<<16&4294967295|o>>>16))+((o=n+(r^s^t)+i[14]+4259657740&4294967295)<<23&4294967295|o>>>9))+((o=t+(n^r^s)+i[1]+2763975236&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^r)+i[4]+1272893353&4294967295)<<11&4294967295|o>>>21))+((o=r+(s^t^n)+i[7]+4139469664&4294967295)<<16&4294967295|o>>>16))+((o=n+(r^s^t)+i[10]+3200236656&4294967295)<<23&4294967295|o>>>9))+((o=t+(n^r^s)+i[13]+681279174&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^r)+i[0]+3936430074&4294967295)<<11&4294967295|o>>>21))+((o=r+(s^t^n)+i[3]+3572445317&4294967295)<<16&4294967295|o>>>16))+((o=n+(r^s^t)+i[6]+76029189&4294967295)<<23&4294967295|o>>>9))+((o=t+(n^r^s)+i[9]+3654602809&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^r)+i[12]+3873151461&4294967295)<<11&4294967295|o>>>21))+((o=r+(s^t^n)+i[15]+530742520&4294967295)<<16&4294967295|o>>>16))+((o=n+(r^s^t)+i[2]+3299628645&4294967295)<<23&4294967295|o>>>9))+((o=t+(r^(n|~s))+i[0]+4096336452&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~r))+i[7]+1126891415&4294967295)<<10&4294967295|o>>>22))+((o=r+(t^(s|~n))+i[14]+2878612391&4294967295)<<15&4294967295|o>>>17))+((o=n+(s^(r|~t))+i[5]+4237533241&4294967295)<<21&4294967295|o>>>11))+((o=t+(r^(n|~s))+i[12]+1700485571&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~r))+i[3]+2399980690&4294967295)<<10&4294967295|o>>>22))+((o=r+(t^(s|~n))+i[10]+4293915773&4294967295)<<15&4294967295|o>>>17))+((o=n+(s^(r|~t))+i[1]+2240044497&4294967295)<<21&4294967295|o>>>11))+((o=t+(r^(n|~s))+i[8]+1873313359&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~r))+i[15]+4264355552&4294967295)<<10&4294967295|o>>>22))+((o=r+(t^(s|~n))+i[6]+2734768916&4294967295)<<15&4294967295|o>>>17))+((o=n+(s^(r|~t))+i[13]+1309151649&4294967295)<<21&4294967295|o>>>11))+((s=(t=n+((o=t+(r^(n|~s))+i[4]+4149444226&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~r))+i[11]+3174756917&4294967295)<<10&4294967295|o>>>22))^((r=s+((o=r+(t^(s|~n))+i[2]+718787259&4294967295)<<15&4294967295|o>>>17))|~t))+i[9]+3951481745&4294967295,e.g[0]=e.g[0]+t&4294967295,e.g[1]=e.g[1]+(r+(o<<21&4294967295|o>>>11))&4294967295,e.g[2]=e.g[2]+r&4294967295,e.g[3]=e.g[3]+s&4294967295}function i(e,t){this.h=t;for(var n=[],i=!0,r=e.length-1;0<=r;r--){var s=0|e[r];i&&s==t||(n[r]=s,i=!1)}this.g=n}!function(e,t){function n(){}n.prototype=t.prototype,e.D=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.C=function(e,n,i){for(var r=Array(arguments.length-2),s=2;s<arguments.length;s++)r[s-2]=arguments[s];return t.prototype[n].apply(e,r)}}(t,function(){this.blockSize=-1}),t.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0},t.prototype.u=function(e,t){void 0===t&&(t=e.length);for(var i=t-this.blockSize,r=this.B,s=this.h,o=0;o<t;){if(0==s)for(;o<=i;)n(this,e,o),o+=this.blockSize;if("string"==typeof e){for(;o<t;)if(r[s++]=e.charCodeAt(o++),s==this.blockSize){n(this,r),s=0;break}}else for(;o<t;)if(r[s++]=e[o++],s==this.blockSize){n(this,r),s=0;break}}this.h=s,this.o+=t},t.prototype.v=function(){var e=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;var n=8*this.o;for(t=e.length-8;t<e.length;++t)e[t]=255&n,n/=256;for(this.u(e),e=Array(16),t=n=0;4>t;++t)for(var i=0;32>i;i+=8)e[n++]=this.g[t]>>>i&255;return e};var r={};function s(e){return-128<=e&&128>e?function(e,t){var n=r;return Object.prototype.hasOwnProperty.call(n,e)?n[e]:n[e]=t(e)}(e,function(e){return new i([0|e],0>e?-1:0)}):new i([0|e],0>e?-1:0)}function o(e){if(isNaN(e)||!isFinite(e))return a;if(0>e)return d(o(-e));for(var t=[],n=1,r=0;e>=n;r++)t[r]=e/n|0,n*=4294967296;return new i(t,0)}var a=s(0),c=s(1),l=s(16777216);function u(e){if(0!=e.h)return!1;for(var t=0;t<e.g.length;t++)if(0!=e.g[t])return!1;return!0}function h(e){return-1==e.h}function d(e){for(var t=e.g.length,n=[],r=0;r<t;r++)n[r]=~e.g[r];return new i(n,~e.h).add(c)}function f(e,t){return e.add(d(t))}function p(e,t){for(;(65535&e[t])!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function g(e,t){this.g=e,this.h=t}function m(e,t){if(u(t))throw Error("division by zero");if(u(e))return new g(a,a);if(h(e))return t=m(d(e),t),new g(d(t.g),d(t.h));if(h(t))return t=m(e,d(t)),new g(d(t.g),t.h);if(30<e.g.length){if(h(e)||h(t))throw Error("slowDivide_ only works with positive integers.");for(var n=c,i=t;0>=i.l(e);)n=y(n),i=y(i);var r=v(n,1),s=v(i,1);for(i=v(i,2),n=v(n,2);!u(i);){var l=s.add(i);0>=l.l(e)&&(r=r.add(n),s=l),i=v(i,1),n=v(n,1)}return t=f(e,r.j(t)),new g(r,t)}for(r=a;0<=e.l(t);){for(n=Math.max(1,Math.floor(e.m()/t.m())),i=48>=(i=Math.ceil(Math.log(n)/Math.LN2))?1:Math.pow(2,i-48),l=(s=o(n)).j(t);h(l)||0<l.l(e);)l=(s=o(n-=i)).j(t);u(s)&&(s=c),r=r.add(s),e=f(e,l)}return new g(r,e)}function y(e){for(var t=e.g.length+1,n=[],r=0;r<t;r++)n[r]=e.i(r)<<1|e.i(r-1)>>>31;return new i(n,e.h)}function v(e,t){var n=t>>5;t%=32;for(var r=e.g.length-n,s=[],o=0;o<r;o++)s[o]=0<t?e.i(o+n)>>>t|e.i(o+n+1)<<32-t:e.i(o+n);return new i(s,e.h)}(e=i.prototype).m=function(){if(h(this))return-d(this).m();for(var e=0,t=1,n=0;n<this.g.length;n++){var i=this.i(n);e+=(0<=i?i:4294967296+i)*t,t*=4294967296}return e},e.toString=function(e){if(2>(e=e||10)||36<e)throw Error("radix out of range: "+e);if(u(this))return"0";if(h(this))return"-"+d(this).toString(e);for(var t=o(Math.pow(e,6)),n=this,i="";;){var r=m(n,t).g,s=((0<(n=f(n,r.j(t))).g.length?n.g[0]:n.h)>>>0).toString(e);if(u(n=r))return s+i;for(;6>s.length;)s="0"+s;i=s+i}},e.i=function(e){return 0>e?0:e<this.g.length?this.g[e]:this.h},e.l=function(e){return h(e=f(this,e))?-1:u(e)?0:1},e.abs=function(){return h(this)?d(this):this},e.add=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0,s=0;s<=t;s++){var o=r+(65535&this.i(s))+(65535&e.i(s)),a=(o>>>16)+(this.i(s)>>>16)+(e.i(s)>>>16);r=a>>>16,o&=65535,a&=65535,n[s]=a<<16|o}return new i(n,-2147483648&n[n.length-1]?-1:0)},e.j=function(e){if(u(this)||u(e))return a;if(h(this))return h(e)?d(this).j(d(e)):d(d(this).j(e));if(h(e))return d(this.j(d(e)));if(0>this.l(l)&&0>e.l(l))return o(this.m()*e.m());for(var t=this.g.length+e.g.length,n=[],r=0;r<2*t;r++)n[r]=0;for(r=0;r<this.g.length;r++)for(var s=0;s<e.g.length;s++){var c=this.i(r)>>>16,f=65535&this.i(r),g=e.i(s)>>>16,m=65535&e.i(s);n[2*r+2*s]+=f*m,p(n,2*r+2*s),n[2*r+2*s+1]+=c*m,p(n,2*r+2*s+1),n[2*r+2*s+1]+=f*g,p(n,2*r+2*s+1),n[2*r+2*s+2]+=c*g,p(n,2*r+2*s+2)}for(r=0;r<t;r++)n[r]=n[2*r+1]<<16|n[2*r];for(r=t;r<2*t;r++)n[r]=0;return new i(n,0)},e.A=function(e){return m(this,e).h},e.and=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r<t;r++)n[r]=this.i(r)&e.i(r);return new i(n,this.h&e.h)},e.or=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r<t;r++)n[r]=this.i(r)|e.i(r);return new i(n,this.h|e.h)},e.xor=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r<t;r++)n[r]=this.i(r)^e.i(r);return new i(n,this.h^e.h)},t.prototype.digest=t.prototype.v,t.prototype.reset=t.prototype.s,t.prototype.update=t.prototype.u,ot=t,i.prototype.add=i.prototype.add,i.prototype.multiply=i.prototype.j,i.prototype.modulo=i.prototype.A,i.prototype.compare=i.prototype.l,i.prototype.toNumber=i.prototype.m,i.prototype.toString=i.prototype.toString,i.prototype.getBits=i.prototype.i,i.fromNumber=o,i.fromString=function e(t,n){if(0==t.length)throw Error("number format error: empty string");if(2>(n=n||10)||36<n)throw Error("radix out of range: "+n);if("-"==t.charAt(0))return d(e(t.substring(1),n));if(0<=t.indexOf("-"))throw Error('number format error: interior "-" character');for(var i=o(Math.pow(n,8)),r=a,s=0;s<t.length;s+=8){var c=Math.min(8,t.length-s),l=parseInt(t.substring(s,s+c),n);8>c?(c=o(Math.pow(n,c)),r=r.j(c).add(o(l))):r=(r=r.j(i)).add(o(l))}return r},st=i}).apply(void 0!==at?at:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var ct,lt,ut,ht,dt,ft,pt,gt,mt="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};
328
- /** @license
329
- Copyright The Closure Library Authors.
330
- SPDX-License-Identifier: Apache-2.0
331
- */(function(){var e,t="function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,n){return e==Array.prototype||e==Object.prototype||(e[t]=n.value),e};var n=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof mt&&mt];for(var t=0;t<e.length;++t){var n=e[t];if(n&&n.Math==Math)return n}throw Error("Cannot find global object")}(this);!function(e,i){if(i)e:{var r=n;e=e.split(".");for(var s=0;s<e.length-1;s++){var o=e[s];if(!(o in r))break e;r=r[o]}(i=i(s=r[e=e[e.length-1]]))!=s&&null!=i&&t(r,e,{configurable:!0,writable:!0,value:i})}}("Array.prototype.values",function(e){return e||function(){return function(e,t){e instanceof String&&(e+="");var n=0,i=!1,r={next:function(){if(!i&&n<e.length){var r=n++;return{value:t(r,e[r]),done:!1}}return i=!0,{done:!0,value:void 0}}};return r[Symbol.iterator]=function(){return r},r}(this,function(e,t){return t})}});
332
- /** @license
333
-
334
- Copyright The Closure Library Authors.
335
- SPDX-License-Identifier: Apache-2.0
336
- */
337
- var i=i||{},r=this||self;function s(e){var t=typeof e;return"array"==(t="object"!=t?t:e?Array.isArray(e)?"array":t:"null")||"object"==t&&"number"==typeof e.length}function o(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}function a(e,t,n){return e.call.apply(e.bind,arguments)}function c(e,t,n){if(!e)throw Error();if(2<arguments.length){var i=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,i),e.apply(t,n)}}return function(){return e.apply(t,arguments)}}function l(e,t,n){return(l=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?a:c).apply(null,arguments)}function u(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function h(e,t){function n(){}n.prototype=t.prototype,e.aa=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Qb=function(e,n,i){for(var r=Array(arguments.length-2),s=2;s<arguments.length;s++)r[s-2]=arguments[s];return t.prototype[n].apply(e,r)}}function d(e){const t=e.length;if(0<t){const n=Array(t);for(let i=0;i<t;i++)n[i]=e[i];return n}return[]}function f(e,t){for(let t=1;t<arguments.length;t++){const n=arguments[t];if(s(n)){const t=e.length||0,i=n.length||0;e.length=t+i;for(let r=0;r<i;r++)e[t+r]=n[r]}else e.push(n)}}function p(e){return/^[\s\xa0]*$/.test(e)}function g(){var e=r.navigator;return e&&(e=e.userAgent)?e:""}function m(e){return m[" "](e),e}m[" "]=function(){};var y=!(-1==g().indexOf("Gecko")||-1!=g().toLowerCase().indexOf("webkit")&&-1==g().indexOf("Edge")||-1!=g().indexOf("Trident")||-1!=g().indexOf("MSIE")||-1!=g().indexOf("Edge"));function v(e,t,n){for(const i in e)t.call(n,e[i],i,e)}function w(e){const t={};for(const n in e)t[n]=e[n];return t}const b="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function _(e,t){let n,i;for(let t=1;t<arguments.length;t++){for(n in i=arguments[t],i)e[n]=i[n];for(let t=0;t<b.length;t++)n=b[t],Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}}function S(e){var t=1;e=e.split(":");const n=[];for(;0<t&&e.length;)n.push(e.shift()),t--;return e.length&&n.push(e.join(":")),n}function E(e){r.setTimeout(()=>{throw e},0)}function T(){var e=R;let t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}var I=new class{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return 0<this.h?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}(()=>new C,e=>e.reset());class C{constructor(){this.next=this.g=this.h=null}set(e,t){this.h=e,this.g=t,this.next=null}reset(){this.next=this.g=this.h=null}}let k,A=!1,R=new class{constructor(){this.h=this.g=null}add(e,t){const n=I.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}},x=()=>{const e=r.Promise.resolve(void 0);k=()=>{e.then(N)}};var N=()=>{for(var e;e=T();){try{e.h.call(e.g)}catch(e){E(e)}var t=I;t.j(e),100>t.h&&(t.h++,e.next=t.g,t.g=e)}A=!1};function O(){this.s=this.s,this.C=this.C}function L(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}O.prototype.s=!1,O.prototype.ma=function(){this.s||(this.s=!0,this.N())},O.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},L.prototype.h=function(){this.defaultPrevented=!0};var P=function(){if(!r.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{const e=()=>{};r.addEventListener("test",e,t),r.removeEventListener("test",e,t)}catch(e){}return e}();function D(e,t){if(L.call(this,e?e.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,e){var n=this.type=e.type,i=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;if(this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget){if(y){e:{try{m(t.nodeName);var r=!0;break e}catch(e){}r=!1}r||(t=null)}}else"mouseover"==n?t=e.fromElement:"mouseout"==n&&(t=e.toElement);this.relatedTarget=t,i?(this.clientX=void 0!==i.clientX?i.clientX:i.pageX,this.clientY=void 0!==i.clientY?i.clientY:i.pageY,this.screenX=i.screenX||0,this.screenY=i.screenY||0):(this.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||"",this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType="string"==typeof e.pointerType?e.pointerType:M[e.pointerType]||"",this.state=e.state,this.i=e,e.defaultPrevented&&D.aa.h.call(this)}}h(D,L);var M={2:"touch",3:"pen",4:"mouse"};D.prototype.h=function(){D.aa.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var z="closure_listenable_"+(1e6*Math.random()|0),F=0;function U(e,t,n,i,r){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!i,this.ha=r,this.key=++F,this.da=this.fa=!1}function V(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function B(e){this.src=e,this.g={},this.h=0}function j(e,t){var n=t.type;if(n in e.g){var i,r=e.g[n],s=Array.prototype.indexOf.call(r,t,void 0);(i=0<=s)&&Array.prototype.splice.call(r,s,1),i&&(V(t),0==e.g[n].length&&(delete e.g[n],e.h--))}}function H(e,t,n,i){for(var r=0;r<e.length;++r){var s=e[r];if(!s.da&&s.listener==t&&s.capture==!!n&&s.ha==i)return r}return-1}B.prototype.add=function(e,t,n,i,r){var s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);var o=H(e,t,i,r);return-1<o?(t=e[o],n||(t.fa=!1)):((t=new U(t,this.src,s,!!i,r)).fa=n,e.push(t)),t};var $="closure_lm_"+(1e6*Math.random()|0),q={};function G(e,t,n,i,r){if(Array.isArray(t)){for(var s=0;s<t.length;s++)G(e,t[s],n,i,r);return null}return n=Z(n),e&&e[z]?e.K(t,n,!!o(i)&&!!i.capture,r):function(e,t,n,i,r,s){if(!t)throw Error("Invalid event type");var a=o(r)?!!r.capture:!!r,c=Y(e);if(c||(e[$]=c=new B(e)),n=c.add(t,n,i,a,s),n.proxy)return n;if(i=function(){function e(n){return t.call(e.src,e.listener,n)}const t=J;return e}(),n.proxy=i,i.src=e,i.listener=n,e.addEventListener)P||(r=a),void 0===r&&(r=!1),e.addEventListener(t.toString(),i,r);else if(e.attachEvent)e.attachEvent(Q(t.toString()),i);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(i)}return n}(e,t,n,!1,i,r)}function K(e,t,n,i,r){if(Array.isArray(t))for(var s=0;s<t.length;s++)K(e,t[s],n,i,r);else i=o(i)?!!i.capture:!!i,n=Z(n),e&&e[z]?(e=e.i,(t=String(t).toString())in e.g&&(-1<(n=H(s=e.g[t],n,i,r))&&(V(s[n]),Array.prototype.splice.call(s,n,1),0==s.length&&(delete e.g[t],e.h--)))):e&&(e=Y(e))&&(t=e.g[t.toString()],e=-1,t&&(e=H(t,n,i,r)),(n=-1<e?t[e]:null)&&W(n))}function W(e){if("number"!=typeof e&&e&&!e.da){var t=e.src;if(t&&t[z])j(t.i,e);else{var n=e.type,i=e.proxy;t.removeEventListener?t.removeEventListener(n,i,e.capture):t.detachEvent?t.detachEvent(Q(n),i):t.addListener&&t.removeListener&&t.removeListener(i),(n=Y(t))?(j(n,e),0==n.h&&(n.src=null,t[$]=null)):V(e)}}}function Q(e){return e in q?q[e]:q[e]="on"+e}function J(e,t){if(e.da)e=!0;else{t=new D(t,this);var n=e.listener,i=e.ha||e.src;e.fa&&W(e),e=n.call(i,t)}return e}function Y(e){return(e=e[$])instanceof B?e:null}var X="__closure_events_fn_"+(1e9*Math.random()>>>0);function Z(e){return"function"==typeof e?e:(e[X]||(e[X]=function(t){return e.handleEvent(t)}),e[X])}function ee(){O.call(this),this.i=new B(this),this.M=this,this.F=null}function te(e,t){var n,i=e.F;if(i)for(n=[];i;i=i.F)n.push(i);if(e=e.M,i=t.type||t,"string"==typeof t)t=new L(t,e);else if(t instanceof L)t.target=t.target||e;else{var r=t;_(t=new L(i,e),r)}if(r=!0,n)for(var s=n.length-1;0<=s;s--){var o=t.g=n[s];r=ne(o,i,!0,t)&&r}if(r=ne(o=t.g=e,i,!0,t)&&r,r=ne(o,i,!1,t)&&r,n)for(s=0;s<n.length;s++)r=ne(o=t.g=n[s],i,!1,t)&&r}function ne(e,t,n,i){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();for(var r=!0,s=0;s<t.length;++s){var o=t[s];if(o&&!o.da&&o.capture==n){var a=o.listener,c=o.ha||o.src;o.fa&&j(e.i,o),r=!1!==a.call(c,i)&&r}}return r&&!i.defaultPrevented}function ie(e,t,n){if("function"==typeof e)n&&(e=l(e,n));else{if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=l(e.handleEvent,e)}return 2147483647<Number(t)?-1:r.setTimeout(e,t||0)}function re(e){e.g=ie(()=>{e.g=null,e.i&&(e.i=!1,re(e))},e.l);const t=e.h;e.h=null,e.m.apply(null,t)}h(ee,O),ee.prototype[z]=!0,ee.prototype.removeEventListener=function(e,t,n,i){K(this,e,t,n,i)},ee.prototype.N=function(){if(ee.aa.N.call(this),this.i){var e,t=this.i;for(e in t.g){for(var n=t.g[e],i=0;i<n.length;i++)V(n[i]);delete t.g[e],t.h--}}this.F=null},ee.prototype.K=function(e,t,n,i){return this.i.add(String(e),t,!1,n,i)},ee.prototype.L=function(e,t,n,i){return this.i.add(String(e),t,!0,n,i)};class se extends O{constructor(e,t){super(),this.m=e,this.l=t,this.h=null,this.i=!1,this.g=null}j(e){this.h=arguments,this.g?this.i=!0:re(this)}N(){super.N(),this.g&&(r.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function oe(e){O.call(this),this.h=e,this.g={}}h(oe,O);var ae=[];function ce(e){v(e.g,function(e,t){this.g.hasOwnProperty(t)&&W(e)},e),e.g={}}oe.prototype.N=function(){oe.aa.N.call(this),ce(this)},oe.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var le=r.JSON.stringify,ue=r.JSON.parse,he=class{stringify(e){return r.JSON.stringify(e,void 0)}parse(e){return r.JSON.parse(e,void 0)}};function de(){}function fe(e){return e.h||(e.h=e.i())}function pe(){}de.prototype.h=null;var ge={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function me(){L.call(this,"d")}function ye(){L.call(this,"c")}h(me,L),h(ye,L);var ve={},we=null;function be(){return we=we||new ee}function _e(e){L.call(this,ve.La,e)}function Se(e){const t=be();te(t,new _e(t))}function Ee(e,t){L.call(this,ve.STAT_EVENT,e),this.stat=t}function Te(e){const t=be();te(t,new Ee(t,e))}function Ie(e,t){L.call(this,ve.Ma,e),this.size=t}function Ce(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return r.setTimeout(function(){e()},t)}function ke(){this.g=!0}function Ae(e,t,n,i){e.info(function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{var n=JSON.parse(t);if(n)for(e=0;e<n.length;e++)if(Array.isArray(n[e])){var i=n[e];if(!(2>i.length)){var r=i[1];if(Array.isArray(r)&&!(1>r.length)){var s=r[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<r.length;o++)r[o]=""}}}return le(n)}catch(e){return t}}(e,n)+(i?" "+i:"")})}ve.La="serverreachability",h(_e,L),ve.STAT_EVENT="statevent",h(Ee,L),ve.Ma="timingevent",h(Ie,L),ke.prototype.xa=function(){this.g=!1},ke.prototype.info=function(){};var Re,xe={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},Ne={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"};function Oe(){}function Le(e,t,n,i){this.j=e,this.i=t,this.l=n,this.R=i||1,this.U=new oe(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 Pe}function Pe(){this.i=null,this.g="",this.h=!1}h(Oe,de),Oe.prototype.g=function(){return new XMLHttpRequest},Oe.prototype.i=function(){return{}},Re=new Oe;var De={},Me={};function ze(e,t,n){e.L=1,e.v=vt(rt(t)),e.m=n,e.P=!0,Fe(e,null)}function Fe(e,t){e.F=Date.now(),Be(e),e.A=rt(e.v);var n=e.A,i=e.R;Array.isArray(i)||(i=[String(i)]),Ot(n.i,"t",i),e.C=0,n=e.j.J,e.h=new Pe,e.g=bn(e.j,n?t:null,!e.m),0<e.O&&(e.M=new se(l(e.Y,e,e.g),e.O)),t=e.U,n=e.g,i=e.ca;var r="readystatechange";Array.isArray(r)||(r&&(ae[0]=r.toString()),r=ae);for(var s=0;s<r.length;s++){var o=G(n,r[s],i||t.handleEvent,!1,t.h||t);if(!o)break;t.g[o.key]=o}t=e.H?w(e.H):{},e.m?(e.u||(e.u="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ea(e.A,e.u,e.m,t)):(e.u="GET",e.g.ea(e.A,e.u,null,t)),Se(),function(e,t,n,i,r,s){e.info(function(){if(e.g)if(s)for(var o="",a=s.split("&"),c=0;c<a.length;c++){var l=a[c].split("=");if(1<l.length){var u=l[0];l=l[1];var h=u.split("_");o=2<=h.length&&"type"==h[1]?o+(u+"=")+l+"&":o+(u+"=redacted&")}}else o=null;else o=s;return"XMLHTTP REQ ("+i+") [attempt "+r+"]: "+t+"\n"+n+"\n"+o})}(e.i,e.u,e.A,e.l,e.R,e.m)}function Ue(e){return!!e.g&&("GET"==e.u&&2!=e.L&&e.j.Ca)}function Ve(e,t){var n=e.C,i=t.indexOf("\n",n);return-1==i?Me:(n=Number(t.substring(n,i)),isNaN(n)?De:(i+=1)+n>t.length?Me:(t=t.slice(i,i+n),e.C=i+n,t))}function Be(e){e.S=Date.now()+e.I,je(e,e.I)}function je(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=Ce(l(e.ba,e),t)}function He(e){e.B&&(r.clearTimeout(e.B),e.B=null)}function $e(e){0==e.j.G||e.J||gn(e.j,e)}function qe(e){He(e);var t=e.M;t&&"function"==typeof t.ma&&t.ma(),e.M=null,ce(e.U),e.g&&(t=e.g,e.g=null,t.abort(),t.ma())}function Ge(e,t){try{var n=e.j;if(0!=n.G&&(n.g==e||Ye(n.h,e)))if(!e.K&&Ye(n.h,e)&&3==n.G){try{var i=n.Da.g.parse(t)}catch(e){i=null}if(Array.isArray(i)&&3==i.length){var r=i;if(0==r[0]){e:if(!n.u){if(n.g){if(!(n.g.F+3e3<e.F))break e;pn(n),rn(n)}hn(n),Te(18)}}else n.za=r[1],0<n.za-n.T&&37500>r[2]&&n.F&&0==n.v&&!n.C&&(n.C=Ce(l(n.Za,n),6e3));if(1>=Je(n.h)&&n.ca){try{n.ca()}catch(e){}n.ca=void 0}}else yn(n,11)}else if((e.K||n.g==e)&&pn(n),!p(t))for(r=n.Da.g.parse(t),t=0;t<r.length;t++){let l=r[t];if(n.T=l[0],l=l[1],2==n.G)if("c"==l[0]){n.K=l[1],n.ia=l[2];const t=l[3];null!=t&&(n.la=t,n.j.info("VER="+n.la));const r=l[4];null!=r&&(n.Aa=r,n.j.info("SVER="+n.Aa));const u=l[5];null!=u&&"number"==typeof u&&0<u&&(i=1.5*u,n.L=i,n.j.info("backChannelRequestTimeoutMs_="+i)),i=n;const h=e.g;if(h){const e=h.g?h.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(e){var s=i.h;s.g||-1==e.indexOf("spdy")&&-1==e.indexOf("quic")&&-1==e.indexOf("h2")||(s.j=s.l,s.g=new Set,s.h&&(Xe(s,s.h),s.h=null))}if(i.D){const e=h.g?h.g.getResponseHeader("X-HTTP-Session-Id"):null;e&&(i.ya=e,yt(i.I,i.D,e))}}n.G=3,n.l&&n.l.ua(),n.ba&&(n.R=Date.now()-e.F,n.j.info("Handshake RTT: "+n.R+"ms"));var o=e;if((i=n).qa=wn(i,i.J?i.ia:null,i.W),o.K){Ze(i.h,o);var a=o,c=i.L;c&&(a.I=c),a.B&&(He(a),Be(a)),i.g=o}else un(i);0<n.i.length&&on(n)}else"stop"!=l[0]&&"close"!=l[0]||yn(n,7);else 3==n.G&&("stop"==l[0]||"close"==l[0]?"stop"==l[0]?yn(n,7):nn(n):"noop"!=l[0]&&n.l&&n.l.ta(l),n.v=0)}Se()}catch(e){}}Le.prototype.ca=function(e){e=e.target;const t=this.M;t&&3==Xt(e)?t.j():this.Y(e)},Le.prototype.Y=function(e){try{if(e==this.g)e:{const d=Xt(this.g);var t=this.g.Ba();this.g.Z();if(!(3>d)&&(3!=d||this.g&&(this.h.h||this.g.oa()||Zt(this.g)))){this.J||4!=d||7==t||Se(),He(this);var n=this.g.Z();this.X=n;t:if(Ue(this)){var i=Zt(this.g);e="";var s=i.length,o=4==Xt(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){qe(this),$e(this);var a="";break t}this.h.i=new r.TextDecoder}for(t=0;t<s;t++)this.h.h=!0,e+=this.h.i.decode(i[t],{stream:!(o&&t==s-1)});i.length=0,this.h.g+=e,this.C=0,a=this.h.g}else a=this.g.oa();if(this.o=200==n,function(e,t,n,i,r,s,o){e.info(function(){return"XMLHTTP RESP ("+i+") [ attempt "+r+"]: "+t+"\n"+n+"\n"+s+" "+o})}(this.i,this.u,this.A,this.l,this.R,d,n),this.o){if(this.T&&!this.K){t:{if(this.g){var c,l=this.g;if((c=l.g?l.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!p(c)){var u=c;break t}}u=null}if(!(n=u)){this.o=!1,this.s=3,Te(12),qe(this),$e(this);break e}Ae(this.i,this.l,n,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Ge(this,n)}if(this.P){let e;for(n=!0;!this.J&&this.C<a.length;){if(e=Ve(this,a),e==Me){4==d&&(this.s=4,Te(14),n=!1),Ae(this.i,this.l,null,"[Incomplete Response]");break}if(e==De){this.s=4,Te(15),Ae(this.i,this.l,a,"[Invalid Chunk]"),n=!1;break}Ae(this.i,this.l,e,null),Ge(this,e)}if(Ue(this)&&0!=this.C&&(this.h.g=this.h.g.slice(this.C),this.C=0),4!=d||0!=a.length||this.h.h||(this.s=1,Te(16),n=!1),this.o=this.o&&n,n){if(0<a.length&&!this.W){this.W=!0;var h=this.j;h.g==this&&h.ba&&!h.M&&(h.j.info("Great, no buffering proxy detected. Bytes received: "+a.length),dn(h),h.M=!0,Te(11))}}else Ae(this.i,this.l,a,"[Invalid Chunked Response]"),qe(this),$e(this)}else Ae(this.i,this.l,a,null),Ge(this,a);4==d&&qe(this),this.o&&!this.J&&(4==d?gn(this.j,this):(this.o=!1,Be(this)))}else(function(e){const t={};e=(e.g&&2<=Xt(e)&&e.g.getAllResponseHeaders()||"").split("\r\n");for(let i=0;i<e.length;i++){if(p(e[i]))continue;var n=S(e[i]);const r=n[0];if("string"!=typeof(n=n[1]))continue;n=n.trim();const s=t[r]||[];t[r]=s,s.push(n)}!function(e,t){for(const n in e)t.call(void 0,e[n],n,e)}(t,function(e){return e.join(", ")})})(this.g),400==n&&0<a.indexOf("Unknown SID")?(this.s=3,Te(12)):(this.s=0,Te(13)),qe(this),$e(this)}}}catch(e){}},Le.prototype.cancel=function(){this.J=!0,qe(this)},Le.prototype.ba=function(){this.B=null;const e=Date.now();0<=e-this.S?(function(e,t){e.info(function(){return"TIMEOUT: "+t})}(this.i,this.A),2!=this.L&&(Se(),Te(17)),qe(this),this.s=2,$e(this)):je(this,this.S-e)};var Ke=class{constructor(e,t){this.g=e,this.map=t}};function We(e){this.l=e||10,r.PerformanceNavigationTiming?e=0<(e=r.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):e=!!(r.chrome&&r.chrome.loadTimes&&r.chrome.loadTimes()&&r.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function Qe(e){return!!e.h||!!e.g&&e.g.size>=e.j}function Je(e){return e.h?1:e.g?e.g.size:0}function Ye(e,t){return e.h?e.h==t:!!e.g&&e.g.has(t)}function Xe(e,t){e.g?e.g.add(t):e.h=t}function Ze(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function et(e){if(null!=e.h)return e.i.concat(e.h.D);if(null!=e.g&&0!==e.g.size){let t=e.i;for(const n of e.g.values())t=t.concat(n.D);return t}return d(e.i)}function tt(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(s(e)||"string"==typeof e)Array.prototype.forEach.call(e,t,void 0);else for(var n=function(e){if(e.na&&"function"==typeof e.na)return e.na();if(!e.V||"function"!=typeof e.V){if("undefined"!=typeof Map&&e instanceof Map)return Array.from(e.keys());if(!("undefined"!=typeof Set&&e instanceof Set)){if(s(e)||"string"==typeof e){var t=[];e=e.length;for(var n=0;n<e;n++)t.push(n);return t}t=[],n=0;for(const i in e)t[n++]=i;return t}}}(e),i=function(e){if(e.V&&"function"==typeof e.V)return e.V();if("undefined"!=typeof Map&&e instanceof Map||"undefined"!=typeof Set&&e instanceof Set)return Array.from(e.values());if("string"==typeof e)return e.split("");if(s(e)){for(var t=[],n=e.length,i=0;i<n;i++)t.push(e[i]);return t}for(i in t=[],n=0,e)t[n++]=e[i];return t}(e),r=i.length,o=0;o<r;o++)t.call(void 0,i[o],n&&n[o],e)}We.prototype.cancel=function(){if(this.i=et(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(const e of this.g.values())e.cancel();this.g.clear()}};var nt=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function it(e){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,e instanceof it){this.h=e.h,st(this,e.j),this.o=e.o,this.g=e.g,ot(this,e.s),this.l=e.l;var t=e.i,n=new At;n.i=t.i,t.g&&(n.g=new Map(t.g),n.h=t.h),at(this,n),this.m=e.m}else e&&(t=String(e).match(nt))?(this.h=!1,st(this,t[1]||"",!0),this.o=wt(t[2]||""),this.g=wt(t[3]||"",!0),ot(this,t[4]),this.l=wt(t[5]||"",!0),at(this,t[6]||"",!0),this.m=wt(t[7]||"")):(this.h=!1,this.i=new At(null,this.h))}function rt(e){return new it(e)}function st(e,t,n){e.j=n?wt(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function ot(e,t){if(t){if(t=Number(t),isNaN(t)||0>t)throw Error("Bad port number "+t);e.s=t}else e.s=null}function at(e,t,n){t instanceof At?(e.i=t,function(e,t){t&&!e.j&&(Rt(e),e.i=null,e.g.forEach(function(e,t){var n=t.toLowerCase();t!=n&&(xt(this,t),Ot(this,n,e))},e)),e.j=t}(e.i,e.h)):(n||(t=bt(t,Ct)),e.i=new At(t,e.h))}function yt(e,t,n){e.i.set(t,n)}function vt(e){return yt(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function wt(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function bt(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,_t),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function _t(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}it.prototype.toString=function(){var e=[],t=this.j;t&&e.push(bt(t,Et,!0),":");var n=this.g;return(n||"file"==t)&&(e.push("//"),(t=this.o)&&e.push(bt(t,Et,!0),"@"),e.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.s)&&e.push(":",String(n))),(n=this.l)&&(this.g&&"/"!=n.charAt(0)&&e.push("/"),e.push(bt(n,"/"==n.charAt(0)?It:Tt,!0))),(n=this.i.toString())&&e.push("?",n),(n=this.m)&&e.push("#",bt(n,kt)),e.join("")};var St,Et=/[#\/\?@]/g,Tt=/[#\?:]/g,It=/[#\?]/g,Ct=/[#\?@]/g,kt=/#/g;function At(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function Rt(e){e.g||(e.g=new Map,e.h=0,e.i&&function(e,t){if(e){e=e.split("&");for(var n=0;n<e.length;n++){var i=e[n].indexOf("="),r=null;if(0<=i){var s=e[n].substring(0,i);r=e[n].substring(i+1)}else s=e[n];t(s,r?decodeURIComponent(r.replace(/\+/g," ")):"")}}}(e.i,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)}))}function xt(e,t){Rt(e),t=Lt(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function Nt(e,t){return Rt(e),t=Lt(e,t),e.g.has(t)}function Ot(e,t,n){xt(e,t),0<n.length&&(e.i=null,e.g.set(Lt(e,t),d(n)),e.h+=n.length)}function Lt(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function Pt(e,t,n,i,r){try{r&&(r.onload=null,r.onerror=null,r.onabort=null,r.ontimeout=null),i(n)}catch(e){}}function Dt(){this.g=new he}function Mt(e,t,n){const i=n||"";try{tt(e,function(e,n){let r=e;o(e)&&(r=le(e)),t.push(i+n+"="+encodeURIComponent(r))})}catch(e){throw t.push(i+"type="+encodeURIComponent("_badmap")),e}}function zt(e){this.l=e.Ub||null,this.j=e.eb||!1}function Ft(e,t){ee.call(this),this.D=e,this.o=t,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}function Ut(e){e.j.read().then(e.Pa.bind(e)).catch(e.ga.bind(e))}function Vt(e){e.readyState=4,e.l=null,e.j=null,e.v=null,Bt(e)}function Bt(e){e.onreadystatechange&&e.onreadystatechange.call(e)}function jt(e){let t="";return v(e,function(e,n){t+=n,t+=":",t+=e,t+="\r\n"}),t}function Ht(e,t,n){e:{for(i in n){var i=!1;break e}i=!0}i||(n=jt(n),"string"==typeof e?null!=n&&encodeURIComponent(String(n)):yt(e,t,n))}function $t(e){ee.call(this),this.headers=new Map,this.o=e||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}(e=At.prototype).add=function(e,t){Rt(this),this.i=null,e=Lt(this,e);var n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this},e.forEach=function(e,t){Rt(this),this.g.forEach(function(n,i){n.forEach(function(n){e.call(t,n,i,this)},this)},this)},e.na=function(){Rt(this);const e=Array.from(this.g.values()),t=Array.from(this.g.keys()),n=[];for(let i=0;i<t.length;i++){const r=e[i];for(let e=0;e<r.length;e++)n.push(t[i])}return n},e.V=function(e){Rt(this);let t=[];if("string"==typeof e)Nt(this,e)&&(t=t.concat(this.g.get(Lt(this,e))));else{e=Array.from(this.g.values());for(let n=0;n<e.length;n++)t=t.concat(e[n])}return t},e.set=function(e,t){return Rt(this),this.i=null,Nt(this,e=Lt(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},e.get=function(e,t){return e&&0<(e=this.V(e)).length?String(e[0]):t},e.toString=function(){if(this.i)return this.i;if(!this.g)return"";const e=[],t=Array.from(this.g.keys());for(var n=0;n<t.length;n++){var i=t[n];const s=encodeURIComponent(String(i)),o=this.V(i);for(i=0;i<o.length;i++){var r=s;""!==o[i]&&(r+="="+encodeURIComponent(String(o[i]))),e.push(r)}}return this.i=e.join("&")},h(zt,de),zt.prototype.g=function(){return new Ft(this.l,this.j)},zt.prototype.i=(St={},function(){return St}),h(Ft,ee),(e=Ft.prototype).open=function(e,t){if(0!=this.readyState)throw this.abort(),Error("Error reopening a connection");this.B=e,this.A=t,this.readyState=1,Bt(this)},e.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const t={headers:this.u,method:this.B,credentials:this.m,cache:void 0};e&&(t.body=e),(this.D||r).fetch(new Request(this.A,t)).then(this.Sa.bind(this),this.ga.bind(this))},e.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&&4!=this.readyState&&(this.g=!1,Vt(this)),this.readyState=0},e.Sa=function(e){if(this.g&&(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,Bt(this)),this.g&&(this.readyState=3,Bt(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(void 0!==r.ReadableStream&&"body"in e){if(this.j=e.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;Ut(this)}else e.text().then(this.Ra.bind(this),this.ga.bind(this))},e.Pa=function(e){if(this.g){if(this.o&&e.value)this.response.push(e.value);else if(!this.o){var t=e.value?e.value:new Uint8Array(0);(t=this.v.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?Vt(this):Bt(this),3==this.readyState&&Ut(this)}},e.Ra=function(e){this.g&&(this.response=this.responseText=e,Vt(this))},e.Qa=function(e){this.g&&(this.response=e,Vt(this))},e.ga=function(){this.g&&Vt(this)},e.setRequestHeader=function(e,t){this.u.append(e,t)},e.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},e.getAllResponseHeaders=function(){if(!this.h)return"";const e=[],t=this.h.entries();for(var n=t.next();!n.done;)n=n.value,e.push(n[0]+": "+n[1]),n=t.next();return e.join("\r\n")},Object.defineProperty(Ft.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}}),h($t,ee);var qt=/^https?$/i,Gt=["POST","PUT"];function Kt(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.m=5,Wt(e),Jt(e)}function Wt(e){e.A||(e.A=!0,te(e,"complete"),te(e,"error"))}function Qt(e){if(e.h&&void 0!==i&&(!e.v[1]||4!=Xt(e)||2!=e.Z()))if(e.u&&4==Xt(e))ie(e.Ea,0,e);else if(te(e,"readystatechange"),4==Xt(e)){e.h=!1;try{const i=e.Z();e:switch(i){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var t=!0;break e;default:t=!1}var n;if(!(n=t)){var s;if(s=0===i){var o=String(e.D).match(nt)[1]||null;!o&&r.self&&r.self.location&&(o=r.self.location.protocol.slice(0,-1)),s=!qt.test(o?o.toLowerCase():"")}n=s}if(n)te(e,"complete"),te(e,"success");else{e.m=6;try{var a=2<Xt(e)?e.g.statusText:""}catch(e){a=""}e.l=a+" ["+e.Z()+"]",Wt(e)}}finally{Jt(e)}}}function Jt(e,t){if(e.g){Yt(e);const n=e.g,i=e.v[0]?()=>{}:null;e.g=null,e.v=null,t||te(e,"ready");try{n.onreadystatechange=i}catch(e){}}}function Yt(e){e.I&&(r.clearTimeout(e.I),e.I=null)}function Xt(e){return e.g?e.g.readyState:0}function Zt(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.H){case"":case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}function en(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function tn(e){this.Aa=0,this.i=[],this.j=new ke,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=en("failFast",!1,e),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=en("baseRetryDelayMs",5e3,e),this.cb=en("retryDelaySeedMs",1e4,e),this.Wa=en("forwardChannelMaxRetries",2,e),this.wa=en("forwardChannelRequestTimeoutMs",2e4,e),this.pa=e&&e.xmlHttpFactory||void 0,this.Xa=e&&e.Tb||void 0,this.Ca=e&&e.useFetchStreams||!1,this.L=void 0,this.J=e&&e.supportsCrossDomainXhr||!1,this.K="",this.h=new We(e&&e.concurrentRequestLimit),this.Da=new Dt,this.P=e&&e.fastHandshake||!1,this.O=e&&e.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=e&&e.Rb||!1,e&&e.xa&&this.j.xa(),e&&e.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&e&&e.detectBufferingProxy||!1,this.ja=void 0,e&&e.longPollingTimeout&&0<e.longPollingTimeout&&(this.ja=e.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}function nn(e){if(sn(e),3==e.G){var t=e.U++,n=rt(e.I);if(yt(n,"SID",e.K),yt(n,"RID",t),yt(n,"TYPE","terminate"),cn(e,n),(t=new Le(e,e.j,t)).L=2,t.v=vt(rt(n)),n=!1,r.navigator&&r.navigator.sendBeacon)try{n=r.navigator.sendBeacon(t.v.toString(),"")}catch(e){}!n&&r.Image&&((new Image).src=t.v,n=!0),n||(t.g=bn(t.j,null),t.g.ea(t.v)),t.F=Date.now(),Be(t)}vn(e)}function rn(e){e.g&&(dn(e),e.g.cancel(),e.g=null)}function sn(e){rn(e),e.u&&(r.clearTimeout(e.u),e.u=null),pn(e),e.h.cancel(),e.s&&("number"==typeof e.s&&r.clearTimeout(e.s),e.s=null)}function on(e){if(!Qe(e.h)&&!e.s){e.s=!0;var t=e.Ga;k||x(),A||(k(),A=!0),R.add(t,e),e.B=0}}function an(e,t){var n;n=t?t.l:e.U++;const i=rt(e.I);yt(i,"SID",e.K),yt(i,"RID",n),yt(i,"AID",e.T),cn(e,i),e.m&&e.o&&Ht(i,e.m,e.o),n=new Le(e,e.j,n,e.B+1),null===e.m&&(n.H=e.o),t&&(e.i=t.D.concat(e.i)),t=ln(e,n,1e3),n.I=Math.round(.5*e.wa)+Math.round(.5*e.wa*Math.random()),Xe(e.h,n),ze(n,i,t)}function cn(e,t){e.H&&v(e.H,function(e,n){yt(t,n,e)}),e.l&&tt({},function(e,n){yt(t,n,e)})}function ln(e,t,n){n=Math.min(e.i.length,n);var i=e.l?l(e.l.Na,e.l,e):null;e:{var r=e.i;let t=-1;for(;;){const e=["count="+n];-1==t?0<n?(t=r[0].g,e.push("ofs="+t)):t=0:e.push("ofs="+t);let s=!0;for(let o=0;o<n;o++){let n=r[o].g;const a=r[o].map;if(n-=t,0>n)t=Math.max(0,r[o].g-100),s=!1;else try{Mt(a,e,"req"+n+"_")}catch(e){i&&i(a)}}if(s){i=e.join("&");break e}}}return e=e.i.splice(0,n),t.D=e,i}function un(e){if(!e.g&&!e.u){e.Y=1;var t=e.Fa;k||x(),A||(k(),A=!0),R.add(t,e),e.v=0}}function hn(e){return!(e.g||e.u||3<=e.v)&&(e.Y++,e.u=Ce(l(e.Fa,e),mn(e,e.v)),e.v++,!0)}function dn(e){null!=e.A&&(r.clearTimeout(e.A),e.A=null)}function fn(e){e.g=new Le(e,e.j,"rpc",e.Y),null===e.m&&(e.g.H=e.o),e.g.O=0;var t=rt(e.qa);yt(t,"RID","rpc"),yt(t,"SID",e.K),yt(t,"AID",e.T),yt(t,"CI",e.F?"0":"1"),!e.F&&e.ja&&yt(t,"TO",e.ja),yt(t,"TYPE","xmlhttp"),cn(e,t),e.m&&e.o&&Ht(t,e.m,e.o),e.L&&(e.g.I=e.L);var n=e.g;e=e.ia,n.L=1,n.v=vt(rt(t)),n.m=null,n.P=!0,Fe(n,e)}function pn(e){null!=e.C&&(r.clearTimeout(e.C),e.C=null)}function gn(e,t){var n=null;if(e.g==t){pn(e),dn(e),e.g=null;var i=2}else{if(!Ye(e.h,t))return;n=t.D,Ze(e.h,t),i=1}if(0!=e.G)if(t.o)if(1==i){n=t.m?t.m.length:0,t=Date.now()-t.F;var r=e.B;te(i=be(),new Ie(i,n)),on(e)}else un(e);else if(3==(r=t.s)||0==r&&0<t.X||!(1==i&&function(e,t){return!(Je(e.h)>=e.h.j-(e.s?1:0)||(e.s?(e.i=t.D.concat(e.i),0):1==e.G||2==e.G||e.B>=(e.Va?0:e.Wa)||(e.s=Ce(l(e.Ga,e,t),mn(e,e.B)),e.B++,0)))}(e,t)||2==i&&hn(e)))switch(n&&0<n.length&&(t=e.h,t.i=t.i.concat(n)),r){case 1:yn(e,5);break;case 4:yn(e,10);break;case 3:yn(e,6);break;default:yn(e,2)}}function mn(e,t){let n=e.Ta+Math.floor(Math.random()*e.cb);return e.isActive()||(n*=2),n*t}function yn(e,t){if(e.j.info("Error code "+t),2==t){var n=l(e.fb,e),i=e.Xa;const t=!i;i=new it(i||"//www.google.com/images/cleardot.gif"),r.location&&"http"==r.location.protocol||st(i,"https"),vt(i),t?function(e,t){const n=new ke;if(r.Image){const i=new Image;i.onload=u(Pt,n,"TestLoadImage: loaded",!0,t,i),i.onerror=u(Pt,n,"TestLoadImage: error",!1,t,i),i.onabort=u(Pt,n,"TestLoadImage: abort",!1,t,i),i.ontimeout=u(Pt,n,"TestLoadImage: timeout",!1,t,i),r.setTimeout(function(){i.ontimeout&&i.ontimeout()},1e4),i.src=e}else t(!1)}(i.toString(),n):function(e,t){new ke;const n=new AbortController,i=setTimeout(()=>{n.abort(),Pt(0,0,!1,t)},1e4);fetch(e,{signal:n.signal}).then(e=>{clearTimeout(i),e.ok?Pt(0,0,!0,t):Pt(0,0,!1,t)}).catch(()=>{clearTimeout(i),Pt(0,0,!1,t)})}(i.toString(),n)}else Te(2);e.G=0,e.l&&e.l.sa(t),vn(e),sn(e)}function vn(e){if(e.G=0,e.ka=[],e.l){const t=et(e.h);0==t.length&&0==e.i.length||(f(e.ka,t),f(e.ka,e.i),e.h.i.length=0,d(e.i),e.i.length=0),e.l.ra()}}function wn(e,t,n){var i=n instanceof it?rt(n):new it(n);if(""!=i.g)t&&(i.g=t+"."+i.g),ot(i,i.s);else{var s=r.location;i=s.protocol,t=t?t+"."+s.hostname:s.hostname,s=+s.port;var o=new it(null);i&&st(o,i),t&&(o.g=t),s&&ot(o,s),n&&(o.l=n),i=o}return n=e.D,t=e.ya,n&&t&&yt(i,n,t),yt(i,"VER",e.la),cn(e,i),i}function bn(e,t,n){if(t&&!e.J)throw Error("Can't create secondary domain capable XhrIo object.");return(t=e.Ca&&!e.pa?new $t(new zt({eb:n})):new $t(e.pa)).Ha(e.J),t}function _n(){}function Sn(){}function En(e,t){ee.call(this),this.g=new tn(t),this.l=e,this.h=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.g.o=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.va&&(e?e["X-WebChannel-Client-Profile"]=t.va:e={"X-WebChannel-Client-Profile":t.va}),this.g.S=e,(e=t&&t.Sb)&&!p(e)&&(this.g.m=e),this.v=t&&t.supportsCrossDomainXhr||!1,this.u=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!p(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&(t in(e=this.h)&&delete e[t])),this.j=new Cn(this)}function Tn(e){me.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){e:{for(const n in t){e=n;break e}e=void 0}(this.i=e)&&(e=this.i,t=null!==t&&e in t?t[e]:void 0),this.data=t}else this.data=e}function In(){ye.call(this),this.status=1}function Cn(e){this.g=e}(e=$t.prototype).Ha=function(e){this.J=e},e.ea=function(e,t,n,i){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+e);t=t?t.toUpperCase():"GET",this.D=e,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():Re.g(),this.v=this.o?fe(this.o):fe(Re),this.g.onreadystatechange=l(this.Ea,this);try{this.B=!0,this.g.open(t,String(e),!0),this.B=!1}catch(e){return void Kt(this,e)}if(e=n||"",n=new Map(this.headers),i)if(Object.getPrototypeOf(i)===Object.prototype)for(var s in i)n.set(s,i[s]);else{if("function"!=typeof i.keys||"function"!=typeof i.get)throw Error("Unknown input type for opt_headers: "+String(i));for(const e of i.keys())n.set(e,i.get(e))}i=Array.from(n.keys()).find(e=>"content-type"==e.toLowerCase()),s=r.FormData&&e instanceof r.FormData,!(0<=Array.prototype.indexOf.call(Gt,t,void 0))||i||s||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[e,t]of n)this.g.setRequestHeader(e,t);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{Yt(this),this.u=!0,this.g.send(e),this.u=!1}catch(e){Kt(this,e)}},e.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=e||7,te(this,"complete"),te(this,"abort"),Jt(this))},e.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Jt(this,!0)),$t.aa.N.call(this)},e.Ea=function(){this.s||(this.B||this.u||this.j?Qt(this):this.bb())},e.bb=function(){Qt(this)},e.isActive=function(){return!!this.g},e.Z=function(){try{return 2<Xt(this)?this.g.status:-1}catch(e){return-1}},e.oa=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},e.Oa=function(e){if(this.g){var t=this.g.responseText;return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),ue(t)}},e.Ba=function(){return this.m},e.Ka=function(){return"string"==typeof this.l?this.l:String(this.l)},(e=tn.prototype).la=8,e.G=1,e.connect=function(e,t,n,i){Te(0),this.W=e,this.H=t||{},n&&void 0!==i&&(this.H.OSID=n,this.H.OAID=i),this.F=this.X,this.I=wn(this,null,this.W),on(this)},e.Ga=function(e){if(this.s)if(this.s=null,1==this.G){if(!e){this.U=Math.floor(1e5*Math.random()),e=this.U++;const r=new Le(this,this.j,e);let s=this.o;if(this.S&&(s?(s=w(s),_(s,this.S)):s=this.S),null!==this.m||this.O||(r.H=s,s=null),this.P)e:{for(var t=0,n=0;n<this.i.length;n++){var i=this.i[n];if(void 0===(i="__data__"in i.map&&"string"==typeof(i=i.map.__data__)?i.length:void 0))break;if(4096<(t+=i)){t=n;break e}if(4096===t||n===this.i.length-1){t=n+1;break e}}t=1e3}else t=1e3;t=ln(this,r,t),yt(n=rt(this.I),"RID",e),yt(n,"CVER",22),this.D&&yt(n,"X-HTTP-Session-Id",this.D),cn(this,n),s&&(this.O?t="headers="+encodeURIComponent(String(jt(s)))+"&"+t:this.m&&Ht(n,this.m,s)),Xe(this.h,r),this.Ua&&yt(n,"TYPE","init"),this.P?(yt(n,"$req",t),yt(n,"SID","null"),r.T=!0,ze(r,n,null)):ze(r,n,t),this.G=2}}else 3==this.G&&(e?an(this,e):0==this.i.length||Qe(this.h)||an(this))},e.Fa=function(){if(this.u=null,fn(this),this.ba&&!(this.M||null==this.g||0>=this.R)){var e=2*this.R;this.j.info("BP detection timer enabled: "+e),this.A=Ce(l(this.ab,this),e)}},e.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,Te(10),rn(this),fn(this))},e.Za=function(){null!=this.C&&(this.C=null,rn(this),hn(this),Te(19))},e.fb=function(e){e?(this.j.info("Successfully pinged google.com"),Te(2)):(this.j.info("Failed to ping google.com"),Te(1))},e.isActive=function(){return!!this.l&&this.l.isActive(this)},(e=_n.prototype).ua=function(){},e.ta=function(){},e.sa=function(){},e.ra=function(){},e.isActive=function(){return!0},e.Na=function(){},Sn.prototype.g=function(e,t){return new En(e,t)},h(En,ee),En.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},En.prototype.close=function(){nn(this.g)},En.prototype.o=function(e){var t=this.g;if("string"==typeof e){var n={};n.__data__=e,e=n}else this.u&&((n={}).__data__=le(e),e=n);t.i.push(new Ke(t.Ya++,e)),3==t.G&&on(t)},En.prototype.N=function(){this.g.l=null,delete this.j,nn(this.g),delete this.g,En.aa.N.call(this)},h(Tn,me),h(In,ye),h(Cn,_n),Cn.prototype.ua=function(){te(this.g,"a")},Cn.prototype.ta=function(e){te(this.g,new Tn(e))},Cn.prototype.sa=function(e){te(this.g,new In)},Cn.prototype.ra=function(){te(this.g,"b")},Sn.prototype.createWebChannel=Sn.prototype.g,En.prototype.send=En.prototype.o,En.prototype.open=En.prototype.m,En.prototype.close=En.prototype.close,gt=function(){return new Sn},pt=function(){return be()},ft=ve,dt={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},xe.NO_ERROR=0,xe.TIMEOUT=8,xe.HTTP_ERROR=6,ht=xe,Ne.COMPLETE="complete",ut=Ne,pe.EventType=ge,ge.OPEN="a",ge.CLOSE="b",ge.ERROR="c",ge.MESSAGE="d",ee.prototype.listen=ee.prototype.K,lt=pe,$t.prototype.listenOnce=$t.prototype.L,$t.prototype.getLastError=$t.prototype.Ka,$t.prototype.getLastErrorCode=$t.prototype.Ba,$t.prototype.getStatus=$t.prototype.Z,$t.prototype.getResponseJson=$t.prototype.Oa,$t.prototype.getResponseText=$t.prototype.oa,$t.prototype.send=$t.prototype.ea,$t.prototype.setWithCredentials=$t.prototype.Ha,ct=$t}).apply(void 0!==mt?mt:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});const yt="@firebase/firestore",vt="4.8.0";
338
- /**
339
- * @license
340
- * Copyright 2017 Google LLC
341
- *
342
- * Licensed under the Apache License, Version 2.0 (the "License");
343
- * you may not use this file except in compliance with the License.
344
- * You may obtain a copy of the License at
345
- *
346
- * http://www.apache.org/licenses/LICENSE-2.0
347
- *
348
- * Unless required by applicable law or agreed to in writing, software
349
- * distributed under the License is distributed on an "AS IS" BASIS,
350
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
351
- * See the License for the specific language governing permissions and
352
- * limitations under the License.
353
- */class wt{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}wt.UNAUTHENTICATED=new wt(null),wt.GOOGLE_CREDENTIALS=new wt("google-credentials-uid"),wt.FIRST_PARTY=new wt("first-party-uid"),wt.MOCK_USER=new wt("mock-user");
354
- /**
355
- * @license
356
- * Copyright 2017 Google LLC
357
- *
358
- * Licensed under the Apache License, Version 2.0 (the "License");
359
- * you may not use this file except in compliance with the License.
360
- * You may obtain a copy of the License at
361
- *
362
- * http://www.apache.org/licenses/LICENSE-2.0
363
- *
364
- * Unless required by applicable law or agreed to in writing, software
365
- * distributed under the License is distributed on an "AS IS" BASIS,
366
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
367
- * See the License for the specific language governing permissions and
368
- * limitations under the License.
369
- */
370
- let bt="11.10.0";
371
- /**
372
- * @license
373
- * Copyright 2017 Google LLC
374
- *
375
- * Licensed under the Apache License, Version 2.0 (the "License");
376
- * you may not use this file except in compliance with the License.
377
- * You may obtain a copy of the License at
378
- *
379
- * http://www.apache.org/licenses/LICENSE-2.0
380
- *
381
- * Unless required by applicable law or agreed to in writing, software
382
- * distributed under the License is distributed on an "AS IS" BASIS,
383
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
384
- * See the License for the specific language governing permissions and
385
- * limitations under the License.
386
- */const _t=new B("@firebase/firestore");function St(){return _t.logLevel}function Et(e,...t){if(_t.logLevel<=M.DEBUG){const n=t.map(Ct);_t.debug(`Firestore (${bt}): ${e}`,...n)}}function Tt(e,...t){if(_t.logLevel<=M.ERROR){const n=t.map(Ct);_t.error(`Firestore (${bt}): ${e}`,...n)}}function It(e,...t){if(_t.logLevel<=M.WARN){const n=t.map(Ct);_t.warn(`Firestore (${bt}): ${e}`,...n)}}function Ct(e){if("string"==typeof e)return e;try{
387
- /**
388
- * @license
389
- * Copyright 2020 Google LLC
390
- *
391
- * Licensed under the Apache License, Version 2.0 (the "License");
392
- * you may not use this file except in compliance with the License.
393
- * You may obtain a copy of the License at
394
- *
395
- * http://www.apache.org/licenses/LICENSE-2.0
396
- *
397
- * Unless required by applicable law or agreed to in writing, software
398
- * distributed under the License is distributed on an "AS IS" BASIS,
399
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
400
- * See the License for the specific language governing permissions and
401
- * limitations under the License.
402
- */
403
- return function(e){return JSON.stringify(e)}(e)}catch(t){return e}}
404
- /**
405
- * @license
406
- * Copyright 2017 Google LLC
407
- *
408
- * Licensed under the Apache License, Version 2.0 (the "License");
409
- * you may not use this file except in compliance with the License.
410
- * You may obtain a copy of the License at
411
- *
412
- * http://www.apache.org/licenses/LICENSE-2.0
413
- *
414
- * Unless required by applicable law or agreed to in writing, software
415
- * distributed under the License is distributed on an "AS IS" BASIS,
416
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
417
- * See the License for the specific language governing permissions and
418
- * limitations under the License.
419
- */function kt(e,t,n){let i="Unexpected state";"string"==typeof t?i=t:n=t,At(e,i,n)}function At(e,t,n){let i=`FIRESTORE (${bt}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==n)try{i+=" CONTEXT: "+JSON.stringify(n)}catch(e){i+=" CONTEXT: "+n}throw Tt(i),new Error(i)}function Rt(e,t,n,i){let r="Unexpected state";"string"==typeof n?r=n:i=n,e||At(t,r,i)}function xt(e,t){return e}
420
- /**
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
- */const Nt={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 Ot extends _{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}
436
- /**
437
- * @license
438
- * Copyright 2017 Google LLC
439
- *
440
- * Licensed under the Apache License, Version 2.0 (the "License");
441
- * you may not use this file except in compliance with the License.
442
- * You may obtain a copy of the License at
443
- *
444
- * http://www.apache.org/licenses/LICENSE-2.0
445
- *
446
- * Unless required by applicable law or agreed to in writing, software
447
- * distributed under the License is distributed on an "AS IS" BASIS,
448
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
449
- * See the License for the specific language governing permissions and
450
- * limitations under the License.
451
- */class Lt{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}
452
- /**
453
- * @license
454
- * Copyright 2017 Google LLC
455
- *
456
- * Licensed under the Apache License, Version 2.0 (the "License");
457
- * you may not use this file except in compliance with the License.
458
- * You may obtain a copy of the License at
459
- *
460
- * http://www.apache.org/licenses/LICENSE-2.0
461
- *
462
- * Unless required by applicable law or agreed to in writing, software
463
- * distributed under the License is distributed on an "AS IS" BASIS,
464
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
465
- * See the License for the specific language governing permissions and
466
- * limitations under the License.
467
- */class Pt{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Dt{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(wt.UNAUTHENTICATED))}shutdown(){}}class Mt{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 zt{constructor(e){this.t=e,this.currentUser=wt.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){Rt(void 0===this.o,42304);let n=this.i;const i=e=>this.i!==n?(n=this.i,t(e)):Promise.resolve();let r=new Lt;this.o=()=>{this.i++,this.currentUser=this.u(),r.resolve(),r=new Lt,e.enqueueRetryable(()=>i(this.currentUser))};const s=()=>{const t=r;e.enqueueRetryable(async()=>{await t.promise,await i(this.currentUser)})},o=e=>{Et("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),s())};this.t.onInit(e=>o(e)),setTimeout(()=>{if(!this.auth){const e=this.t.getImmediate({optional:!0});e?o(e):(Et("FirebaseAuthCredentialsProvider","Auth not yet detected"),r.resolve(),r=new Lt)}},0),s()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(t=>this.i!==e?(Et("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(Rt("string"==typeof t.accessToken,31837,{l:t}),new Pt(t.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 Rt(null===e||"string"==typeof e,2055,{h:e}),new wt(e)}}class Ft{constructor(e,t,n){this.P=e,this.T=t,this.I=n,this.type="FirstParty",this.user=wt.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 Ut{constructor(e,t,n){this.P=e,this.T=t,this.I=n}getToken(){return Promise.resolve(new Ft(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(wt.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class Vt{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 Bt{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,je(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){Rt(void 0===this.o,3512);const n=e=>{null!=e.error&&Et("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);const n=e.token!==this.m;return this.m=e.token,Et("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable(()=>n(t))};const i=e=>{Et("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(e=>i(e)),setTimeout(()=>{if(!this.appCheck){const e=this.V.getImmediate({optional:!0});e?i(e):Et("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new Vt(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(Rt("string"==typeof e.token,44558,{tokenResult:e}),this.m=e.token,new Vt(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}
468
- /**
469
- * @license
470
- * Copyright 2020 Google LLC
471
- *
472
- * Licensed under the Apache License, Version 2.0 (the "License");
473
- * you may not use this file except in compliance with the License.
474
- * You may obtain a copy of the License at
475
- *
476
- * http://www.apache.org/licenses/LICENSE-2.0
477
- *
478
- * Unless required by applicable law or agreed to in writing, software
479
- * distributed under the License is distributed on an "AS IS" BASIS,
480
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
481
- * See the License for the specific language governing permissions and
482
- * limitations under the License.
483
- */function jt(e){const t="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&&"function"==typeof t.getRandomValues)t.getRandomValues(n);else for(let t=0;t<e;t++)n[t]=Math.floor(256*Math.random());return n}
484
- /**
485
- * @license
486
- * Copyright 2023 Google LLC
487
- *
488
- * Licensed under the Apache License, Version 2.0 (the "License");
489
- * you may not use this file except in compliance with the License.
490
- * You may obtain a copy of the License at
491
- *
492
- * http://www.apache.org/licenses/LICENSE-2.0
493
- *
494
- * Unless required by applicable law or agreed to in writing, software
495
- * distributed under the License is distributed on an "AS IS" BASIS,
496
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
497
- * See the License for the specific language governing permissions and
498
- * limitations under the License.
499
- */function Ht(){return new TextEncoder}
500
- /**
501
- * @license
502
- * Copyright 2017 Google LLC
503
- *
504
- * Licensed under the Apache License, Version 2.0 (the "License");
505
- * you may not use this file except in compliance with the License.
506
- * You may obtain a copy of the License at
507
- *
508
- * http://www.apache.org/licenses/LICENSE-2.0
509
- *
510
- * Unless required by applicable law or agreed to in writing, software
511
- * distributed under the License is distributed on an "AS IS" BASIS,
512
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
513
- * See the License for the specific language governing permissions and
514
- * limitations under the License.
515
- */class $t{static newId(){const e=62*Math.floor(256/62);let t="";for(;t.length<20;){const n=jt(40);for(let i=0;i<n.length;++i)t.length<20&&n[i]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(n[i]%62))}return t}}function qt(e,t){return e<t?-1:e>t?1:0}function Gt(e,t){let n=0;for(;n<e.length&&n<t.length;){const i=e.codePointAt(n),r=t.codePointAt(n);if(i!==r){if(i<128&&r<128)return qt(i,r);{const s=Ht(),o=Wt(s.encode(Kt(e,n)),s.encode(Kt(t,n)));return 0!==o?o:qt(i,r)}}n+=i>65535?2:1}return qt(e.length,t.length)}function Kt(e,t){return e.codePointAt(t)>65535?e.substring(t,t+2):e.substring(t,t+1)}function Wt(e,t){for(let n=0;n<e.length&&n<t.length;++n)if(e[n]!==t[n])return qt(e[n],t[n]);return qt(e.length,t.length)}function Qt(e,t,n){return e.length===t.length&&e.every((e,i)=>n(e,t[i]))}
516
- /**
517
- * @license
518
- * Copyright 2017 Google LLC
519
- *
520
- * Licensed under the Apache License, Version 2.0 (the "License");
521
- * you may not use this file except in compliance with the License.
522
- * You may obtain a copy of the License at
523
- *
524
- * http://www.apache.org/licenses/LICENSE-2.0
525
- *
526
- * Unless required by applicable law or agreed to in writing, software
527
- * distributed under the License is distributed on an "AS IS" BASIS,
528
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
529
- * See the License for the specific language governing permissions and
530
- * limitations under the License.
531
- */const Jt="__name__";class Yt{constructor(e,t,n){void 0===t?t=0:t>e.length&&kt(637,{offset:t,range:e.length}),void 0===n?n=e.length-t:n>e.length-t&&kt(1746,{length:n,range:e.length-t}),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===Yt.comparator(this,e)}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof Yt?e.forEach(e=>{t.push(e)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?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 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const n=Math.min(e.length,t.length);for(let i=0;i<n;i++){const n=Yt.compareSegments(e.get(i),t.get(i));if(0!==n)return n}return qt(e.length,t.length)}static compareSegments(e,t){const n=Yt.isNumericId(e),i=Yt.isNumericId(t);return n&&!i?-1:!n&&i?1:n&&i?Yt.extractNumericId(e).compare(Yt.extractNumericId(t)):Gt(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return st.fromString(e.substring(4,e.length-2))}}class Xt extends Yt{construct(e,t,n){return new Xt(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const n of e){if(n.indexOf("//")>=0)throw new Ot(Nt.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(e=>e.length>0))}return new Xt(t)}static emptyPath(){return new Xt([])}}const Zt=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class en extends Yt{construct(e,t,n){return new en(e,t,n)}static isValidIdentifier(e){return Zt.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),en.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===Jt}static keyField(){return new en([Jt])}static fromServerFormat(e){const t=[];let n="",i=0;const r=()=>{if(0===n.length)throw new Ot(Nt.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""};let s=!1;for(;i<e.length;){const t=e[i];if("\\"===t){if(i+1===e.length)throw new Ot(Nt.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const t=e[i+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new Ot(Nt.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=t,i+=2}else"`"===t?(s=!s,i++):"."!==t||s?(n+=t,i++):(r(),i++)}if(r(),s)throw new Ot(Nt.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new en(t)}static emptyPath(){return new en([])}}
532
- /**
533
- * @license
534
- * Copyright 2017 Google LLC
535
- *
536
- * Licensed under the Apache License, Version 2.0 (the "License");
537
- * you may not use this file except in compliance with the License.
538
- * You may obtain a copy of the License at
539
- *
540
- * http://www.apache.org/licenses/LICENSE-2.0
541
- *
542
- * Unless required by applicable law or agreed to in writing, software
543
- * distributed under the License is distributed on an "AS IS" BASIS,
544
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
545
- * See the License for the specific language governing permissions and
546
- * limitations under the License.
547
- */class tn{constructor(e){this.path=e}static fromPath(e){return new tn(Xt.fromString(e))}static fromName(e){return new tn(Xt.fromString(e).popFirst(5))}static empty(){return new tn(Xt.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 null!==e&&0===Xt.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return Xt.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new tn(new Xt(e.slice()))}}
548
- /**
549
- * @license
550
- * Copyright 2017 Google LLC
551
- *
552
- * Licensed under the Apache License, Version 2.0 (the "License");
553
- * you may not use this file except in compliance with the License.
554
- * You may obtain a copy of the License at
555
- *
556
- * http://www.apache.org/licenses/LICENSE-2.0
557
- *
558
- * Unless required by applicable law or agreed to in writing, software
559
- * distributed under the License is distributed on an "AS IS" BASIS,
560
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
561
- * See the License for the specific language governing permissions and
562
- * limitations under the License.
563
- */function nn(e,t,n){if(!n)throw new Ot(Nt.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function rn(e){if(!tn.isDocumentKey(e))throw new Ot(Nt.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function sn(e){if(tn.isDocumentKey(e))throw new Ot(Nt.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function on(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function an(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{const t=function(e){return e.constructor?e.constructor.name:null}(e);return t?`a custom ${t} object`:"an object"}}return"function"==typeof e?"a function":kt(12329,{type:typeof e})}function cn(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new Ot(Nt.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=an(e);throw new Ot(Nt.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}
564
- /**
565
- * @license
566
- * Copyright 2025 Google LLC
567
- *
568
- * Licensed under the Apache License, Version 2.0 (the "License");
569
- * you may not use this file except in compliance with the License.
570
- * You may obtain a copy of the License at
571
- *
572
- * http://www.apache.org/licenses/LICENSE-2.0
573
- *
574
- * Unless required by applicable law or agreed to in writing, software
575
- * distributed under the License is distributed on an "AS IS" BASIS,
576
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
577
- * See the License for the specific language governing permissions and
578
- * limitations under the License.
579
- */function ln(e,t){const n={typeString:e};return t&&(n.value=t),n}function un(e,t){if(!on(e))throw new Ot(Nt.INVALID_ARGUMENT,"JSON must be an object");let n;for(const i in t)if(t[i]){const r=t[i].typeString,s="value"in t[i]?{value:t[i].value}:void 0;if(!(i in e)){n=`JSON missing required field: '${i}'`;break}const o=e[i];if(r&&typeof o!==r){n=`JSON field '${i}' must be a ${r}.`;break}if(void 0!==s&&o!==s.value){n=`Expected '${i}' field to equal '${s.value}'`;break}}if(n)throw new Ot(Nt.INVALID_ARGUMENT,n);return!0}
580
- /**
581
- * @license
582
- * Copyright 2017 Google LLC
583
- *
584
- * Licensed under the Apache License, Version 2.0 (the "License");
585
- * you may not use this file except in compliance with the License.
586
- * You may obtain a copy of the License at
587
- *
588
- * http://www.apache.org/licenses/LICENSE-2.0
589
- *
590
- * Unless required by applicable law or agreed to in writing, software
591
- * distributed under the License is distributed on an "AS IS" BASIS,
592
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
593
- * See the License for the specific language governing permissions and
594
- * limitations under the License.
595
- */const hn=-62135596800,dn=1e6;class fn{static now(){return fn.fromMillis(Date.now())}static fromDate(e){return fn.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),n=Math.floor((e-1e3*t)*dn);return new fn(t,n)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new Ot(Nt.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new Ot(Nt.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<hn)throw new Ot(Nt.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new Ot(Nt.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/dn}_compareTo(e){return this.seconds===e.seconds?qt(this.nanoseconds,e.nanoseconds):qt(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{type:fn._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(un(e,fn._jsonSchema))return new fn(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-hn;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}fn._jsonSchemaVersion="firestore/timestamp/1.0",fn._jsonSchema={type:ln("string",fn._jsonSchemaVersion),seconds:ln("number"),nanoseconds:ln("number")};
596
- /**
597
- * @license
598
- * Copyright 2017 Google LLC
599
- *
600
- * Licensed under the Apache License, Version 2.0 (the "License");
601
- * you may not use this file except in compliance with the License.
602
- * You may obtain a copy of the License at
603
- *
604
- * http://www.apache.org/licenses/LICENSE-2.0
605
- *
606
- * Unless required by applicable law or agreed to in writing, software
607
- * distributed under the License is distributed on an "AS IS" BASIS,
608
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
609
- * See the License for the specific language governing permissions and
610
- * limitations under the License.
611
- */
612
- class pn{static fromTimestamp(e){return new pn(e)}static min(){return new pn(new fn(0,0))}static max(){return new pn(new fn(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}}
613
- /**
614
- * @license
615
- * Copyright 2021 Google LLC
616
- *
617
- * Licensed under the Apache License, Version 2.0 (the "License");
618
- * you may not use this file except in compliance with the License.
619
- * You may obtain a copy of the License at
620
- *
621
- * http://www.apache.org/licenses/LICENSE-2.0
622
- *
623
- * Unless required by applicable law or agreed to in writing, software
624
- * distributed under the License is distributed on an "AS IS" BASIS,
625
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
626
- * See the License for the specific language governing permissions and
627
- * limitations under the License.
628
- */function gn(e){return new mn(e.readTime,e.key,-1)}class mn{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new mn(pn.min(),tn.empty(),-1)}static max(){return new mn(pn.max(),tn.empty(),-1)}}function yn(e,t){let n=e.readTime.compareTo(t.readTime);return 0!==n?n:(n=tn.comparator(e.documentKey,t.documentKey),0!==n?n:qt(e.largestBatchId,t.largestBatchId)
629
- /**
630
- * @license
631
- * Copyright 2020 Google LLC
632
- *
633
- * Licensed under the Apache License, Version 2.0 (the "License");
634
- * you may not use this file except in compliance with the License.
635
- * You may obtain a copy of the License at
636
- *
637
- * http://www.apache.org/licenses/LICENSE-2.0
638
- *
639
- * Unless required by applicable law or agreed to in writing, software
640
- * distributed under the License is distributed on an "AS IS" BASIS,
641
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
642
- * See the License for the specific language governing permissions and
643
- * limitations under the License.
644
- */)}class vn{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}
645
- /**
646
- * @license
647
- * Copyright 2017 Google LLC
648
- *
649
- * Licensed under the Apache License, Version 2.0 (the "License");
650
- * you may not use this file except in compliance with the License.
651
- * You may obtain a copy of the License at
652
- *
653
- * http://www.apache.org/licenses/LICENSE-2.0
654
- *
655
- * Unless required by applicable law or agreed to in writing, software
656
- * distributed under the License is distributed on an "AS IS" BASIS,
657
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
658
- * See the License for the specific language governing permissions and
659
- * limitations under the License.
660
- */async function wn(e){if(e.code!==Nt.FAILED_PRECONDITION||"The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab."!==e.message)throw e;Et("LocalStore","Unexpectedly lost primary lease")}
661
- /**
662
- * @license
663
- * Copyright 2017 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 bn{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)},e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&kt(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new bn((n,i)=>{this.nextCallback=t=>{this.wrapSuccess(e,t).next(n,i)},this.catchCallback=e=>{this.wrapFailure(t,e).next(n,i)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{const t=e();return t instanceof bn?t:bn.resolve(t)}catch(e){return bn.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):bn.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):bn.reject(t)}static resolve(e){return new bn((t,n)=>{t(e)})}static reject(e){return new bn((t,n)=>{n(e)})}static waitFor(e){return new bn((t,n)=>{let i=0,r=0,s=!1;e.forEach(e=>{++i,e.next(()=>{++r,s&&r===i&&t()},e=>n(e))}),s=!0,r===i&&t()})}static or(e){let t=bn.resolve(!1);for(const n of e)t=t.next(e=>e?bn.resolve(e):n());return t}static forEach(e,t){const n=[];return e.forEach((e,i)=>{n.push(t.call(this,e,i))}),this.waitFor(n)}static mapArray(e,t){return new bn((n,i)=>{const r=e.length,s=new Array(r);let o=0;for(let a=0;a<r;a++){const c=a;t(e[c]).next(e=>{s[c]=e,++o,o===r&&n(s)},e=>i(e))}})}static doWhile(e,t){return new bn((n,i)=>{const r=()=>{!0===e()?t().next(()=>{r()},i):n()};r()})}}function _n(e){return"IndexedDbTransactionError"===e.name}
677
- /**
678
- * @license
679
- * Copyright 2018 Google LLC
680
- *
681
- * Licensed under the Apache License, Version 2.0 (the "License");
682
- * you may not use this file except in compliance with the License.
683
- * You may obtain a copy of the License at
684
- *
685
- * http://www.apache.org/licenses/LICENSE-2.0
686
- *
687
- * Unless required by applicable law or agreed to in writing, software
688
- * distributed under the License is distributed on an "AS IS" BASIS,
689
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
690
- * See the License for the specific language governing permissions and
691
- * limitations under the License.
692
- */class Sn{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this._e(e),this.ae=e=>t.writeSequenceNumber(e))}_e(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ae&&this.ae(e),e}}Sn.ue=-1;function En(e){return null==e}function Tn(e){return 0===e&&1/e==-1/0}function In(e,t){let n=t;const i=e.length;for(let t=0;t<i;t++){const i=e.charAt(t);switch(i){case"\0":n+="";break;case"":n+="";break;default:n+=i}}return n}function Cn(e){return e+""}
693
- /**
694
- * @license
695
- * Copyright 2017 Google LLC
696
- *
697
- * Licensed under the Apache License, Version 2.0 (the "License");
698
- * you may not use this file except in compliance with the License.
699
- * You may obtain a copy of the License at
700
- *
701
- * http://www.apache.org/licenses/LICENSE-2.0
702
- *
703
- * Unless required by applicable law or agreed to in writing, software
704
- * distributed under the License is distributed on an "AS IS" BASIS,
705
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
706
- * See the License for the specific language governing permissions and
707
- * limitations under the License.
708
- */function kn(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function An(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function Rn(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}
709
- /**
710
- * @license
711
- * Copyright 2017 Google LLC
712
- *
713
- * Licensed under the Apache License, Version 2.0 (the "License");
714
- * you may not use this file except in compliance with the License.
715
- * You may obtain a copy of the License at
716
- *
717
- * http://www.apache.org/licenses/LICENSE-2.0
718
- *
719
- * Unless required by applicable law or agreed to in writing, software
720
- * distributed under the License is distributed on an "AS IS" BASIS,
721
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
722
- * See the License for the specific language governing permissions and
723
- * limitations under the License.
724
- */class xn{constructor(e,t){this.comparator=e,this.root=t||On.EMPTY}insert(e,t){return new xn(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,On.BLACK,null,null))}remove(e){return new xn(this.comparator,this.root.remove(e,this.comparator).copy(null,null,On.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const n=this.comparator(e,t.key);if(0===n)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){const i=this.comparator(e,n.key);if(0===i)return t+n.left.size;i<0?n=n.left:(t+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,n)=>(e(t,n),!1))}toString(){const e=[];return this.inorderTraversal((t,n)=>(e.push(`${t}:${n}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Nn(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Nn(this.root,e,this.comparator,!1)}getReverseIterator(){return new Nn(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Nn(this.root,e,this.comparator,!0)}}class Nn{constructor(e,t,n,i){this.isReverse=i,this.nodeStack=[];let r=1;for(;!e.isEmpty();)if(r=t?n(e.key,t):1,t&&i&&(r*=-1),r<0)e=this.isReverse?e.left:e.right;else{if(0===r){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(0===this.nodeStack.length)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class On{constructor(e,t,n,i,r){this.key=e,this.value=t,this.color=null!=n?n:On.RED,this.left=null!=i?i:On.EMPTY,this.right=null!=r?r:On.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,i,r){return new On(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=i?i:this.left,null!=r?r:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,n){let i=this;const r=n(e,i.key);return i=r<0?i.copy(null,null,null,i.left.insert(e,t,n),null):0===r?i.copy(null,t,null,null,null):i.copy(null,null,null,null,i.right.insert(e,t,n)),i.fixUp()}removeMin(){if(this.left.isEmpty())return On.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let n,i=this;if(t(e,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(e,t),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),0===t(e,i.key)){if(i.right.isEmpty())return On.EMPTY;n=i.right.min(),i=i.copy(n.key,n.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(e,t))}return i.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,On.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,On.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 kt(43730,{key:this.key,value:this.value});if(this.right.isRed())throw kt(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw kt(27949);return e+(this.isRed()?0:1)}}On.EMPTY=null,On.RED=!0,On.BLACK=!1,On.EMPTY=new class{constructor(){this.size=0}get key(){throw kt(57766)}get value(){throw kt(16141)}get color(){throw kt(16727)}get left(){throw kt(29726)}get right(){throw kt(36894)}copy(e,t,n,i,r){return this}insert(e,t,n){return new On(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}};
725
- /**
726
- * @license
727
- * Copyright 2017 Google LLC
728
- *
729
- * Licensed under the Apache License, Version 2.0 (the "License");
730
- * you may not use this file except in compliance with the License.
731
- * You may obtain a copy of the License at
732
- *
733
- * http://www.apache.org/licenses/LICENSE-2.0
734
- *
735
- * Unless required by applicable law or agreed to in writing, software
736
- * distributed under the License is distributed on an "AS IS" BASIS,
737
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
738
- * See the License for the specific language governing permissions and
739
- * limitations under the License.
740
- */
741
- class Ln{constructor(e){this.comparator=e,this.data=new xn(this.comparator)}has(e){return null!==this.data.get(e)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,n)=>(e(t),!1))}forEachInRange(e,t){const n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){const i=n.getNext();if(this.comparator(i.key,e[1])>=0)return;t(i.key)}}forEachWhile(e,t){let n;for(n=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new Pn(this.data.getIterator())}getIteratorFrom(e){return new Pn(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(e=>{t=t.add(e)}),t}isEqual(e){if(!(e instanceof Ln))return!1;if(this.size!==e.size)return!1;const t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){const e=t.getNext().key,i=n.getNext().key;if(0!==this.comparator(e,i))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 Ln(this.comparator);return t.data=e,t}}class Pn{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}
742
- /**
743
- * @license
744
- * Copyright 2020 Google LLC
745
- *
746
- * Licensed under the Apache License, Version 2.0 (the "License");
747
- * you may not use this file except in compliance with the License.
748
- * You may obtain a copy of the License at
749
- *
750
- * http://www.apache.org/licenses/LICENSE-2.0
751
- *
752
- * Unless required by applicable law or agreed to in writing, software
753
- * distributed under the License is distributed on an "AS IS" BASIS,
754
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
755
- * See the License for the specific language governing permissions and
756
- * limitations under the License.
757
- */class Dn{constructor(e){this.fields=e,e.sort(en.comparator)}static empty(){return new Dn([])}unionWith(e){let t=new Ln(en.comparator);for(const e of this.fields)t=t.add(e);for(const n of e)t=t.add(n);return new Dn(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Qt(this.fields,e.fields,(e,t)=>e.isEqual(t))}}
758
- /**
759
- * @license
760
- * Copyright 2023 Google LLC
761
- *
762
- * Licensed under the Apache License, Version 2.0 (the "License");
763
- * you may not use this file except in compliance with the License.
764
- * You may obtain a copy of the License at
765
- *
766
- * http://www.apache.org/licenses/LICENSE-2.0
767
- *
768
- * Unless required by applicable law or agreed to in writing, software
769
- * distributed under the License is distributed on an "AS IS" BASIS,
770
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
771
- * See the License for the specific language governing permissions and
772
- * limitations under the License.
773
- */class Mn extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}
774
- /**
775
- * @license
776
- * Copyright 2020 Google LLC
777
- *
778
- * Licensed under the Apache License, Version 2.0 (the "License");
779
- * you may not use this file except in compliance with the License.
780
- * You may obtain a copy of the License at
781
- *
782
- * http://www.apache.org/licenses/LICENSE-2.0
783
- *
784
- * Unless required by applicable law or agreed to in writing, software
785
- * distributed under the License is distributed on an "AS IS" BASIS,
786
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
787
- * See the License for the specific language governing permissions and
788
- * limitations under the License.
789
- */class zn{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(e){try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&&e instanceof DOMException?new Mn("Invalid base64 string: "+e):e}}(e);return new zn(t)}static fromUint8Array(e){const t=function(e){let t="";for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(e);return new zn(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return e=this.binaryString,btoa(e);var e}toUint8Array(){return function(e){const t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}
790
- /**
791
- * @license
792
- * Copyright 2020 Google LLC
793
- *
794
- * Licensed under the Apache License, Version 2.0 (the "License");
795
- * you may not use this file except in compliance with the License.
796
- * You may obtain a copy of the License at
797
- *
798
- * http://www.apache.org/licenses/LICENSE-2.0
799
- *
800
- * Unless required by applicable law or agreed to in writing, software
801
- * distributed under the License is distributed on an "AS IS" BASIS,
802
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
803
- * See the License for the specific language governing permissions and
804
- * limitations under the License.
805
- */(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return qt(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}zn.EMPTY_BYTE_STRING=new zn("");const Fn=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Un(e){if(Rt(!!e,39018),"string"==typeof e){let t=0;const n=Fn.exec(e);if(Rt(!!n,46558,{timestamp:e}),n[1]){let e=n[1];e=(e+"000000000").substr(0,9),t=Number(e)}const i=new Date(e);return{seconds:Math.floor(i.getTime()/1e3),nanos:t}}return{seconds:Vn(e.seconds),nanos:Vn(e.nanos)}}function Vn(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function Bn(e){return"string"==typeof e?zn.fromBase64String(e):zn.fromUint8Array(e)}
806
- /**
807
- * @license
808
- * Copyright 2020 Google LLC
809
- *
810
- * Licensed under the Apache License, Version 2.0 (the "License");
811
- * you may not use this file except in compliance with the License.
812
- * You may obtain a copy of the License at
813
- *
814
- * http://www.apache.org/licenses/LICENSE-2.0
815
- *
816
- * Unless required by applicable law or agreed to in writing, software
817
- * distributed under the License is distributed on an "AS IS" BASIS,
818
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
819
- * See the License for the specific language governing permissions and
820
- * limitations under the License.
821
- */const jn="server_timestamp",Hn="__type__",$n="__previous_value__",qn="__local_write_time__";function Gn(e){var t,n;return(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{})[Hn])||void 0===n?void 0:n.stringValue)===jn}function Kn(e){const t=e.mapValue.fields[$n];return Gn(t)?Kn(t):t}function Wn(e){const t=Un(e.mapValue.fields[qn].timestampValue);return new fn(t.seconds,t.nanos)}
822
- /**
823
- * @license
824
- * Copyright 2017 Google LLC
825
- *
826
- * Licensed under the Apache License, Version 2.0 (the "License");
827
- * you may not use this file except in compliance with the License.
828
- * You may obtain a copy of the License at
829
- *
830
- * http://www.apache.org/licenses/LICENSE-2.0
831
- *
832
- * Unless required by applicable law or agreed to in writing, software
833
- * distributed under the License is distributed on an "AS IS" BASIS,
834
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
835
- * See the License for the specific language governing permissions and
836
- * limitations under the License.
837
- */class Qn{constructor(e,t,n,i,r,s,o,a,c,l){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=i,this.ssl=r,this.forceLongPolling=s,this.autoDetectLongPolling=o,this.longPollingOptions=a,this.useFetchStreams=c,this.isUsingEmulator=l}}const Jn="(default)";class Yn{constructor(e,t){this.projectId=e,this.database=t||Jn}static empty(){return new Yn("","")}get isDefaultDatabase(){return this.database===Jn}isEqual(e){return e instanceof Yn&&e.projectId===this.projectId&&e.database===this.database}}
838
- /**
839
- * @license
840
- * Copyright 2020 Google LLC
841
- *
842
- * Licensed under the Apache License, Version 2.0 (the "License");
843
- * you may not use this file except in compliance with the License.
844
- * You may obtain a copy of the License at
845
- *
846
- * http://www.apache.org/licenses/LICENSE-2.0
847
- *
848
- * Unless required by applicable law or agreed to in writing, software
849
- * distributed under the License is distributed on an "AS IS" BASIS,
850
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
851
- * See the License for the specific language governing permissions and
852
- * limitations under the License.
853
- */const Xn="__type__",Zn="__max__",ei={},ti="__vector__",ni="value";function ii(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?Gn(e)?4:function(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===Zn}
854
- /**
855
- * @license
856
- * Copyright 2017 Google LLC
857
- *
858
- * Licensed under the Apache License, Version 2.0 (the "License");
859
- * you may not use this file except in compliance with the License.
860
- * You may obtain a copy of the License at
861
- *
862
- * http://www.apache.org/licenses/LICENSE-2.0
863
- *
864
- * Unless required by applicable law or agreed to in writing, software
865
- * distributed under the License is distributed on an "AS IS" BASIS,
866
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
867
- * See the License for the specific language governing permissions and
868
- * limitations under the License.
869
- */(e)?9007199254740991:function(e){var t,n;return(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{})[Xn])||void 0===n?void 0:n.stringValue)===ti}(e)?10:11:kt(28295,{value:e})}function ri(e,t){if(e===t)return!0;const n=ii(e);if(n!==ii(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return Wn(e).isEqual(Wn(t));case 3:return function(e,t){if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;const n=Un(e.timestampValue),i=Un(t.timestampValue);return n.seconds===i.seconds&&n.nanos===i.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(e,t){return Bn(e.bytesValue).isEqual(Bn(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return Vn(e.geoPointValue.latitude)===Vn(t.geoPointValue.latitude)&&Vn(e.geoPointValue.longitude)===Vn(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return Vn(e.integerValue)===Vn(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){const n=Vn(e.doubleValue),i=Vn(t.doubleValue);return n===i?Tn(n)===Tn(i):isNaN(n)&&isNaN(i)}return!1}(e,t);case 9:return Qt(e.arrayValue.values||[],t.arrayValue.values||[],ri);case 10:case 11:return function(e,t){const n=e.mapValue.fields||{},i=t.mapValue.fields||{};if(kn(n)!==kn(i))return!1;for(const e in n)if(n.hasOwnProperty(e)&&(void 0===i[e]||!ri(n[e],i[e])))return!1;return!0}(e,t);default:return kt(52216,{left:e})}}function si(e,t){return void 0!==(e.values||[]).find(e=>ri(e,t))}function oi(e,t){if(e===t)return 0;const n=ii(e),i=ii(t);if(n!==i)return qt(n,i);switch(n){case 0:case 9007199254740991:return 0;case 1:return qt(e.booleanValue,t.booleanValue);case 2:return function(e,t){const n=Vn(e.integerValue||e.doubleValue),i=Vn(t.integerValue||t.doubleValue);return n<i?-1:n>i?1:n===i?0:isNaN(n)?isNaN(i)?0:-1:1}(e,t);case 3:return ai(e.timestampValue,t.timestampValue);case 4:return ai(Wn(e),Wn(t));case 5:return Gt(e.stringValue,t.stringValue);case 6:return function(e,t){const n=Bn(e),i=Bn(t);return n.compareTo(i)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){const n=e.split("/"),i=t.split("/");for(let e=0;e<n.length&&e<i.length;e++){const t=qt(n[e],i[e]);if(0!==t)return t}return qt(n.length,i.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){const n=qt(Vn(e.latitude),Vn(t.latitude));return 0!==n?n:qt(Vn(e.longitude),Vn(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return ci(e.arrayValue,t.arrayValue);case 10:return function(e,t){var n,i,r,s;const o=e.fields||{},a=t.fields||{},c=null===(n=o[ni])||void 0===n?void 0:n.arrayValue,l=null===(i=a[ni])||void 0===i?void 0:i.arrayValue,u=qt((null===(r=null==c?void 0:c.values)||void 0===r?void 0:r.length)||0,(null===(s=null==l?void 0:l.values)||void 0===s?void 0:s.length)||0);return 0!==u?u:ci(c,l)}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===ei&&t===ei)return 0;if(e===ei)return 1;if(t===ei)return-1;const n=e.fields||{},i=Object.keys(n),r=t.fields||{},s=Object.keys(r);i.sort(),s.sort();for(let e=0;e<i.length&&e<s.length;++e){const t=Gt(i[e],s[e]);if(0!==t)return t;const o=oi(n[i[e]],r[s[e]]);if(0!==o)return o}return qt(i.length,s.length)}(e.mapValue,t.mapValue);default:throw kt(23264,{le:n})}}function ai(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return qt(e,t);const n=Un(e),i=Un(t),r=qt(n.seconds,i.seconds);return 0!==r?r:qt(n.nanos,i.nanos)}function ci(e,t){const n=e.values||[],i=t.values||[];for(let e=0;e<n.length&&e<i.length;++e){const t=oi(n[e],i[e]);if(t)return t}return qt(n.length,i.length)}function li(e){return ui(e)}function ui(e){return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?function(e){const t=Un(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?function(e){return Bn(e).toBase64()}(e.bytesValue):"referenceValue"in e?function(e){return tn.fromName(e).toString()}(e.referenceValue):"geoPointValue"in e?function(e){return`geo(${e.latitude},${e.longitude})`}(e.geoPointValue):"arrayValue"in e?function(e){let t="[",n=!0;for(const i of e.values||[])n?n=!1:t+=",",t+=ui(i);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){const t=Object.keys(e.fields||{}).sort();let n="{",i=!0;for(const r of t)i?i=!1:n+=",",n+=`${r}:${ui(e.fields[r])}`;return n+"}"}(e.mapValue):kt(61005,{value:e})}function hi(e){switch(ii(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const t=Kn(e);return t?16+hi(t):16;case 5:return 2*e.stringValue.length;case 6:return Bn(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return function(e){return(e.values||[]).reduce((e,t)=>e+hi(t),0)}(e.arrayValue);case 10:case 11:return function(e){let t=0;return An(e.fields,(e,n)=>{t+=e.length+hi(n)}),t}(e.mapValue);default:throw kt(13486,{value:e})}}function di(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function fi(e){return!!e&&"integerValue"in e}function pi(e){return!!e&&"arrayValue"in e}function gi(e){return!!e&&"nullValue"in e}function mi(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function yi(e){return!!e&&"mapValue"in e}function vi(e){if(e.geoPointValue)return{geoPointValue:Object.assign({},e.geoPointValue)};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:Object.assign({},e.timestampValue)};if(e.mapValue){const t={mapValue:{fields:{}}};return An(e.mapValue.fields,(e,n)=>t.mapValue.fields[e]=vi(n)),t}if(e.arrayValue){const t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=vi(e.arrayValue.values[n]);return t}return Object.assign({},e)}class wi{constructor(e){this.value=e}static empty(){return new wi({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(t=(t.mapValue.fields||{})[e.get(n)],!yi(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=vi(t)}setAll(e){let t=en.emptyPath(),n={},i=[];e.forEach((e,r)=>{if(!t.isImmediateParentOf(r)){const e=this.getFieldsMap(t);this.applyChanges(e,n,i),n={},i=[],t=r.popLast()}e?n[r.lastSegment()]=vi(e):i.push(r.lastSegment())});const r=this.getFieldsMap(t);this.applyChanges(r,n,i)}delete(e){const t=this.field(e.popLast());yi(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return ri(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n<e.length;++n){let i=t.mapValue.fields[e.get(n)];yi(i)&&i.mapValue.fields||(i={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=i),t=i}return t.mapValue.fields}applyChanges(e,t,n){An(t,(t,n)=>e[t]=n);for(const t of n)delete e[t]}clone(){return new wi(vi(this.value))}}function bi(e){const t=[];return An(e.fields,(e,n)=>{const i=new en([e]);if(yi(n)){const e=bi(n.mapValue).fields;if(0===e.length)t.push(i);else for(const n of e)t.push(i.child(n))}else t.push(i)}),new Dn(t)
870
- /**
871
- * @license
872
- * Copyright 2017 Google LLC
873
- *
874
- * Licensed under the Apache License, Version 2.0 (the "License");
875
- * you may not use this file except in compliance with the License.
876
- * You may obtain a copy of the License at
877
- *
878
- * http://www.apache.org/licenses/LICENSE-2.0
879
- *
880
- * Unless required by applicable law or agreed to in writing, software
881
- * distributed under the License is distributed on an "AS IS" BASIS,
882
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
883
- * See the License for the specific language governing permissions and
884
- * limitations under the License.
885
- */}class _i{constructor(e,t,n,i,r,s,o){this.key=e,this.documentType=t,this.version=n,this.readTime=i,this.createTime=r,this.data=s,this.documentState=o}static newInvalidDocument(e){return new _i(e,0,pn.min(),pn.min(),pn.min(),wi.empty(),0)}static newFoundDocument(e,t,n,i){return new _i(e,1,t,pn.min(),n,i,0)}static newNoDocument(e,t){return new _i(e,2,t,pn.min(),pn.min(),wi.empty(),0)}static newUnknownDocument(e,t){return new _i(e,3,t,pn.min(),pn.min(),wi.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(pn.min())||2!==this.documentType&&0!==this.documentType||(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=wi.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=wi.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=pn.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(e){return e instanceof _i&&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 _i(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}})`}}
886
- /**
887
- * @license
888
- * Copyright 2022 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
- */class Si{constructor(e,t){this.position=e,this.inclusive=t}}function Ei(e,t,n){let i=0;for(let r=0;r<e.position.length;r++){const s=t[r],o=e.position[r];if(i=s.field.isKeyField()?tn.comparator(tn.fromName(o.referenceValue),n.key):oi(o,n.data.field(s.field)),"desc"===s.dir&&(i*=-1),0!==i)break}return i}function Ti(e,t){if(null===e)return null===t;if(null===t)return!1;if(e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!ri(e.position[n],t.position[n]))return!1;return!0}
902
- /**
903
- * @license
904
- * Copyright 2022 Google LLC
905
- *
906
- * Licensed under the Apache License, Version 2.0 (the "License");
907
- * you may not use this file except in compliance with the License.
908
- * You may obtain a copy of the License at
909
- *
910
- * http://www.apache.org/licenses/LICENSE-2.0
911
- *
912
- * Unless required by applicable law or agreed to in writing, software
913
- * distributed under the License is distributed on an "AS IS" BASIS,
914
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
915
- * See the License for the specific language governing permissions and
916
- * limitations under the License.
917
- */class Ii{constructor(e,t="asc"){this.field=e,this.dir=t}}function Ci(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}
918
- /**
919
- * @license
920
- * Copyright 2022 Google LLC
921
- *
922
- * Licensed under the Apache License, Version 2.0 (the "License");
923
- * you may not use this file except in compliance with the License.
924
- * You may obtain a copy of the License at
925
- *
926
- * http://www.apache.org/licenses/LICENSE-2.0
927
- *
928
- * Unless required by applicable law or agreed to in writing, software
929
- * distributed under the License is distributed on an "AS IS" BASIS,
930
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
931
- * See the License for the specific language governing permissions and
932
- * limitations under the License.
933
- */class ki{}class Ai extends ki{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(e,t,n){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,n):new Di(e,t,n):"array-contains"===t?new Ui(e,n):"in"===t?new Vi(e,n):"not-in"===t?new Bi(e,n):"array-contains-any"===t?new ji(e,n):new Ai(e,t,n)}static createKeyFieldInFilter(e,t,n){return"in"===t?new Mi(e,n):new zi(e,n)}matches(e){const t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(oi(t,this.value)):null!==t&&ii(this.value)===ii(t)&&this.matchesComparison(oi(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return kt(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class Ri extends ki{constructor(e,t){super(),this.filters=e,this.op=t,this.he=null}static create(e,t){return new Ri(e,t)}matches(e){return xi(this)?void 0===this.filters.find(t=>!t.matches(e)):void 0!==this.filters.find(t=>t.matches(e))}getFlattenedFilters(){return null!==this.he||(this.he=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.he}getFilters(){return Object.assign([],this.filters)}}function xi(e){return"and"===e.op}function Ni(e){return function(e){for(const t of e.filters)if(t instanceof Ri)return!1;return!0}(e)&&xi(e)}function Oi(e){if(e instanceof Ai)return e.field.canonicalString()+e.op.toString()+li(e.value);if(Ni(e))return e.filters.map(e=>Oi(e)).join(",");{const t=e.filters.map(e=>Oi(e)).join(",");return`${e.op}(${t})`}}function Li(e,t){return e instanceof Ai?function(e,t){return t instanceof Ai&&e.op===t.op&&e.field.isEqual(t.field)&&ri(e.value,t.value)}(e,t):e instanceof Ri?function(e,t){return t instanceof Ri&&e.op===t.op&&e.filters.length===t.filters.length&&e.filters.reduce((e,n,i)=>e&&Li(n,t.filters[i]),!0)}(e,t):void kt(19439)}function Pi(e){return e instanceof Ai?function(e){return`${e.field.canonicalString()} ${e.op} ${li(e.value)}`}(e):e instanceof Ri?function(e){return e.op.toString()+" {"+e.getFilters().map(Pi).join(" ,")+"}"}(e):"Filter"}class Di extends Ai{constructor(e,t,n){super(e,t,n),this.key=tn.fromName(n.referenceValue)}matches(e){const t=tn.comparator(e.key,this.key);return this.matchesComparison(t)}}class Mi extends Ai{constructor(e,t){super(e,"in",t),this.keys=Fi("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class zi extends Ai{constructor(e,t){super(e,"not-in",t),this.keys=Fi("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function Fi(e,t){var n;return((null===(n=t.arrayValue)||void 0===n?void 0:n.values)||[]).map(e=>tn.fromName(e.referenceValue))}class Ui extends Ai{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return pi(t)&&si(t.arrayValue,this.value)}}class Vi extends Ai{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return null!==t&&si(this.value.arrayValue,t)}}class Bi extends Ai{constructor(e,t){super(e,"not-in",t)}matches(e){if(si(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return null!==t&&void 0===t.nullValue&&!si(this.value.arrayValue,t)}}class ji extends Ai{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!pi(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>si(this.value.arrayValue,e))}}
934
- /**
935
- * @license
936
- * Copyright 2019 Google LLC
937
- *
938
- * Licensed under the Apache License, Version 2.0 (the "License");
939
- * you may not use this file except in compliance with the License.
940
- * You may obtain a copy of the License at
941
- *
942
- * http://www.apache.org/licenses/LICENSE-2.0
943
- *
944
- * Unless required by applicable law or agreed to in writing, software
945
- * distributed under the License is distributed on an "AS IS" BASIS,
946
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
947
- * See the License for the specific language governing permissions and
948
- * limitations under the License.
949
- */class Hi{constructor(e,t=null,n=[],i=[],r=null,s=null,o=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=i,this.limit=r,this.startAt=s,this.endAt=o,this.Pe=null}}function $i(e,t=null,n=[],i=[],r=null,s=null,o=null){return new Hi(e,t,n,i,r,s,o)}function qi(e){const t=xt(e);if(null===t.Pe){let e=t.path.canonicalString();null!==t.collectionGroup&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map(e=>Oi(e)).join(","),e+="|ob:",e+=t.orderBy.map(e=>function(e){return e.field.canonicalString()+e.dir}(e)).join(","),En(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map(e=>li(e)).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map(e=>li(e)).join(",")),t.Pe=e}return t.Pe}function Gi(e,t){if(e.limit!==t.limit)return!1;if(e.orderBy.length!==t.orderBy.length)return!1;for(let n=0;n<e.orderBy.length;n++)if(!Ci(e.orderBy[n],t.orderBy[n]))return!1;if(e.filters.length!==t.filters.length)return!1;for(let n=0;n<e.filters.length;n++)if(!Li(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!Ti(e.startAt,t.startAt)&&Ti(e.endAt,t.endAt)}function Ki(e){return tn.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}
950
- /**
951
- * @license
952
- * Copyright 2017 Google LLC
953
- *
954
- * Licensed under the Apache License, Version 2.0 (the "License");
955
- * you may not use this file except in compliance with the License.
956
- * You may obtain a copy of the License at
957
- *
958
- * http://www.apache.org/licenses/LICENSE-2.0
959
- *
960
- * Unless required by applicable law or agreed to in writing, software
961
- * distributed under the License is distributed on an "AS IS" BASIS,
962
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
963
- * See the License for the specific language governing permissions and
964
- * limitations under the License.
965
- */class Wi{constructor(e,t=null,n=[],i=[],r=null,s="F",o=null,a=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=i,this.limit=r,this.limitType=s,this.startAt=o,this.endAt=a,this.Te=null,this.Ie=null,this.de=null,this.startAt,this.endAt}}function Qi(e){return new Wi(e)}function Ji(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function Yi(e){return null!==e.collectionGroup}function Xi(e){const t=xt(e);if(null===t.Te){t.Te=[];const e=new Set;for(const n of t.explicitOrderBy)t.Te.push(n),e.add(n.field.canonicalString());const n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc",i=function(e){let t=new Ln(en.comparator);return e.filters.forEach(e=>{e.getFlattenedFilters().forEach(e=>{e.isInequality()&&(t=t.add(e.field))})}),t}(t);i.forEach(i=>{e.has(i.canonicalString())||i.isKeyField()||t.Te.push(new Ii(i,n))}),e.has(en.keyField().canonicalString())||t.Te.push(new Ii(en.keyField(),n))}return t.Te}function Zi(e){const t=xt(e);return t.Ie||(t.Ie=function(e,t){if("F"===e.limitType)return $i(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map(e=>{const t="desc"===e.dir?"asc":"desc";return new Ii(e.field,t)});const n=e.endAt?new Si(e.endAt.position,e.endAt.inclusive):null,i=e.startAt?new Si(e.startAt.position,e.startAt.inclusive):null;return $i(e.path,e.collectionGroup,t,e.filters,e.limit,n,i)}}(t,Xi(e))),t.Ie}function er(e,t){const n=e.filters.concat([t]);return new Wi(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function tr(e,t,n){return new Wi(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function nr(e,t){return Gi(Zi(e),Zi(t))&&e.limitType===t.limitType}function ir(e){return`${qi(Zi(e))}|lt:${e.limitType}`}function rr(e){return`Query(target=${function(e){let t=e.path.canonicalString();return null!==e.collectionGroup&&(t+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(t+=`, filters: [${e.filters.map(e=>Pi(e)).join(", ")}]`),En(e.limit)||(t+=", limit: "+e.limit),e.orderBy.length>0&&(t+=`, orderBy: [${e.orderBy.map(e=>function(e){return`${e.field.canonicalString()} (${e.dir})`}(e)).join(", ")}]`),e.startAt&&(t+=", startAt: ",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(e=>li(e)).join(",")),e.endAt&&(t+=", endAt: ",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(e=>li(e)).join(",")),`Target(${t})`}(Zi(e))}; limitType=${e.limitType})`}function sr(e,t){return t.isFoundDocument()&&function(e,t){const n=t.key.path;return null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n):tn.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n)}(e,t)&&function(e,t){for(const n of Xi(e))if(!n.field.isKeyField()&&null===t.data.field(n.field))return!1;return!0}(e,t)&&function(e,t){for(const n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&&function(e,t){return!(e.startAt&&!function(e,t,n){const i=Ei(e,t,n);return e.inclusive?i<=0:i<0}(e.startAt,Xi(e),t))&&!(e.endAt&&!function(e,t,n){const i=Ei(e,t,n);return e.inclusive?i>=0:i>0}(e.endAt,Xi(e),t))}(e,t)}function or(e){return(t,n)=>{let i=!1;for(const r of Xi(e)){const e=ar(r,t,n);if(0!==e)return e;i=i||r.field.isKeyField()}return 0}}function ar(e,t,n){const i=e.field.isKeyField()?tn.comparator(t.key,n.key):function(e,t,n){const i=t.data.field(e),r=n.data.field(e);return null!==i&&null!==r?oi(i,r):kt(42886)}(e.field,t,n);switch(e.dir){case"asc":return i;case"desc":return-1*i;default:return kt(19790,{direction:e.dir})}}
966
- /**
967
- * @license
968
- * Copyright 2017 Google LLC
969
- *
970
- * Licensed under the Apache License, Version 2.0 (the "License");
971
- * you may not use this file except in compliance with the License.
972
- * You may obtain a copy of the License at
973
- *
974
- * http://www.apache.org/licenses/LICENSE-2.0
975
- *
976
- * Unless required by applicable law or agreed to in writing, software
977
- * distributed under the License is distributed on an "AS IS" BASIS,
978
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
979
- * See the License for the specific language governing permissions and
980
- * limitations under the License.
981
- */class cr{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0!==n)for(const[t,i]of n)if(this.equalsFn(t,e))return i}has(e){return void 0!==this.get(e)}set(e,t){const n=this.mapKeyFn(e),i=this.inner[n];if(void 0===i)return this.inner[n]=[[e,t]],void this.innerSize++;for(let n=0;n<i.length;n++)if(this.equalsFn(i[n][0],e))return void(i[n]=[e,t]);i.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0===n)return!1;for(let i=0;i<n.length;i++)if(this.equalsFn(n[i][0],e))return 1===n.length?delete this.inner[t]:n.splice(i,1),this.innerSize--,!0;return!1}forEach(e){An(this.inner,(t,n)=>{for(const[t,i]of n)e(t,i)})}isEmpty(){return Rn(this.inner)}size(){return this.innerSize}}
982
- /**
983
- * @license
984
- * Copyright 2017 Google LLC
985
- *
986
- * Licensed under the Apache License, Version 2.0 (the "License");
987
- * you may not use this file except in compliance with the License.
988
- * You may obtain a copy of the License at
989
- *
990
- * http://www.apache.org/licenses/LICENSE-2.0
991
- *
992
- * Unless required by applicable law or agreed to in writing, software
993
- * distributed under the License is distributed on an "AS IS" BASIS,
994
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
995
- * See the License for the specific language governing permissions and
996
- * limitations under the License.
997
- */const lr=new xn(tn.comparator);function ur(){return lr}const hr=new xn(tn.comparator);function dr(...e){let t=hr;for(const n of e)t=t.insert(n.key,n);return t}function fr(e){let t=hr;return e.forEach((e,n)=>t=t.insert(e,n.overlayedDocument)),t}function pr(){return mr()}function gr(){return mr()}function mr(){return new cr(e=>e.toString(),(e,t)=>e.isEqual(t))}const yr=new xn(tn.comparator),vr=new Ln(tn.comparator);function wr(...e){let t=vr;for(const n of e)t=t.add(n);return t}const br=new Ln(qt);
998
- /**
999
- * @license
1000
- * Copyright 2020 Google LLC
1001
- *
1002
- * Licensed under the Apache License, Version 2.0 (the "License");
1003
- * you may not use this file except in compliance with the License.
1004
- * You may obtain a copy of the License at
1005
- *
1006
- * http://www.apache.org/licenses/LICENSE-2.0
1007
- *
1008
- * Unless required by applicable law or agreed to in writing, software
1009
- * distributed under the License is distributed on an "AS IS" BASIS,
1010
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1011
- * See the License for the specific language governing permissions and
1012
- * limitations under the License.
1013
- */
1014
- function _r(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Tn(t)?"-0":t}}function Sr(e){return{integerValue:""+e}}function Er(e,t){return function(e){return"number"==typeof e&&Number.isInteger(e)&&!Tn(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}
1015
- /**
1016
- * @license
1017
- * Copyright 2017 Google LLC
1018
- *
1019
- * Licensed under the Apache License, Version 2.0 (the "License");
1020
- * you may not use this file except in compliance with the License.
1021
- * You may obtain a copy of the License at
1022
- *
1023
- * http://www.apache.org/licenses/LICENSE-2.0
1024
- *
1025
- * Unless required by applicable law or agreed to in writing, software
1026
- * distributed under the License is distributed on an "AS IS" BASIS,
1027
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1028
- * See the License for the specific language governing permissions and
1029
- * limitations under the License.
1030
- */(t)?Sr(t):_r(e,t)}
1031
- /**
1032
- * @license
1033
- * Copyright 2018 Google LLC
1034
- *
1035
- * Licensed under the Apache License, Version 2.0 (the "License");
1036
- * you may not use this file except in compliance with the License.
1037
- * You may obtain a copy of the License at
1038
- *
1039
- * http://www.apache.org/licenses/LICENSE-2.0
1040
- *
1041
- * Unless required by applicable law or agreed to in writing, software
1042
- * distributed under the License is distributed on an "AS IS" BASIS,
1043
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1044
- * See the License for the specific language governing permissions and
1045
- * limitations under the License.
1046
- */class Tr{constructor(){this._=void 0}}function Ir(e,t,n){return e instanceof Ar?function(e,t){const n={fields:{[Hn]:{stringValue:jn},[qn]:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&Gn(t)&&(t=Kn(t)),t&&(n.fields[$n]=t),{mapValue:n}}(n,t):e instanceof Rr?xr(e,t):e instanceof Nr?Or(e,t):function(e,t){const n=kr(e,t),i=Pr(n)+Pr(e.Ee);return fi(n)&&fi(e.Ee)?Sr(i):_r(e.serializer,i)}(e,t)}function Cr(e,t,n){return e instanceof Rr?xr(e,t):e instanceof Nr?Or(e,t):n}function kr(e,t){return e instanceof Lr?function(e){return fi(e)||function(e){return!!e&&"doubleValue"in e}(e)}(t)?t:{integerValue:0}:null}class Ar extends Tr{}class Rr extends Tr{constructor(e){super(),this.elements=e}}function xr(e,t){const n=Dr(t);for(const t of e.elements)n.some(e=>ri(e,t))||n.push(t);return{arrayValue:{values:n}}}class Nr extends Tr{constructor(e){super(),this.elements=e}}function Or(e,t){let n=Dr(t);for(const t of e.elements)n=n.filter(e=>!ri(e,t));return{arrayValue:{values:n}}}class Lr extends Tr{constructor(e,t){super(),this.serializer=e,this.Ee=t}}function Pr(e){return Vn(e.integerValue||e.doubleValue)}function Dr(e){return pi(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class Mr{constructor(e,t){this.version=e,this.transformResults=t}}class zr{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new zr}static exists(e){return new zr(void 0,e)}static updateTime(e){return new zr(e)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function Fr(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class Ur{}function Vr(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new Jr(e.key,zr.none()):new qr(e.key,e.data,zr.none());{const n=e.data,i=wi.empty();let r=new Ln(en.comparator);for(let e of t.fields)if(!r.has(e)){let t=n.field(e);null===t&&e.length>1&&(e=e.popLast(),t=n.field(e)),null===t?i.delete(e):i.set(e,t),r=r.add(e)}return new Gr(e.key,i,new Dn(r.toArray()),zr.none())}}function Br(e,t,n){e instanceof qr?function(e,t,n){const i=e.value.clone(),r=Wr(e.fieldTransforms,t,n.transformResults);i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(e,t,n):e instanceof Gr?function(e,t,n){if(!Fr(e.precondition,t))return void t.convertToUnknownDocument(n.version);const i=Wr(e.fieldTransforms,t,n.transformResults),r=t.data;r.setAll(Kr(e)),r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):function(e,t,n){t.convertToNoDocument(n.version).setHasCommittedMutations()}(0,t,n)}function jr(e,t,n,i){return e instanceof qr?function(e,t,n,i){if(!Fr(e.precondition,t))return n;const r=e.value.clone(),s=Qr(e.fieldTransforms,i,t);return r.setAll(s),t.convertToFoundDocument(t.version,r).setHasLocalMutations(),null}(e,t,n,i):e instanceof Gr?function(e,t,n,i){if(!Fr(e.precondition,t))return n;const r=Qr(e.fieldTransforms,i,t),s=t.data;return s.setAll(Kr(e)),s.setAll(r),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null===n?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(e=>e.field))}(e,t,n,i):function(e,t,n){return Fr(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function Hr(e,t){let n=null;for(const i of e.fieldTransforms){const e=t.data.field(i.field),r=kr(i.transform,e||null);null!=r&&(null===n&&(n=wi.empty()),n.set(i.field,r))}return n||null}function $r(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&!!function(e,t){return void 0===e&&void 0===t||!(!e||!t)&&Qt(e,t,(e,t)=>function(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof Rr&&t instanceof Rr||e instanceof Nr&&t instanceof Nr?Qt(e.elements,t.elements,ri):e instanceof Lr&&t instanceof Lr?ri(e.Ee,t.Ee):e instanceof Ar&&t instanceof Ar}(e.transform,t.transform)}(e,t))}(e.fieldTransforms,t.fieldTransforms)&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class qr extends Ur{constructor(e,t,n,i=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=i,this.type=0}getFieldMask(){return null}}class Gr extends Ur{constructor(e,t,n,i,r=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=i,this.fieldTransforms=r,this.type=1}getFieldMask(){return this.fieldMask}}function Kr(e){const t=new Map;return e.fieldMask.fields.forEach(n=>{if(!n.isEmpty()){const i=e.data.field(n);t.set(n,i)}}),t}function Wr(e,t,n){const i=new Map;Rt(e.length===n.length,32656,{Ae:n.length,Re:e.length});for(let r=0;r<n.length;r++){const s=e[r],o=s.transform,a=t.data.field(s.field);i.set(s.field,Cr(o,a,n[r]))}return i}function Qr(e,t,n){const i=new Map;for(const r of e){const e=r.transform,s=n.data.field(r.field);i.set(r.field,Ir(e,s,t))}return i}class Jr extends Ur{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Yr extends Ur{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}
1047
- /**
1048
- * @license
1049
- * Copyright 2017 Google LLC
1050
- *
1051
- * Licensed under the Apache License, Version 2.0 (the "License");
1052
- * you may not use this file except in compliance with the License.
1053
- * You may obtain a copy of the License at
1054
- *
1055
- * http://www.apache.org/licenses/LICENSE-2.0
1056
- *
1057
- * Unless required by applicable law or agreed to in writing, software
1058
- * distributed under the License is distributed on an "AS IS" BASIS,
1059
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1060
- * See the License for the specific language governing permissions and
1061
- * limitations under the License.
1062
- */class Xr{constructor(e,t,n,i){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=i}applyToRemoteDocument(e,t){const n=t.mutationResults;for(let t=0;t<this.mutations.length;t++){const i=this.mutations[t];i.key.isEqual(e.key)&&Br(i,e,n[t])}}applyToLocalView(e,t){for(const n of this.baseMutations)n.key.isEqual(e.key)&&(t=jr(n,e,t,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(e.key)&&(t=jr(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const n=gr();return this.mutations.forEach(i=>{const r=e.get(i.key),s=r.overlayedDocument;let o=this.applyToLocalView(s,r.mutatedFields);o=t.has(i.key)?null:o;const a=Vr(s,o);null!==a&&n.set(i.key,a),s.isValidDocument()||s.convertToNoDocument(pn.min())}),n}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),wr())}isEqual(e){return this.batchId===e.batchId&&Qt(this.mutations,e.mutations,(e,t)=>$r(e,t))&&Qt(this.baseMutations,e.baseMutations,(e,t)=>$r(e,t))}}class Zr{constructor(e,t,n,i){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=i}static from(e,t,n){Rt(e.mutations.length===n.length,58842,{Ve:e.mutations.length,me:n.length});let i=yr;const r=e.mutations;for(let e=0;e<r.length;e++)i=i.insert(r[e].key,n[e].version);return new Zr(e,t,n,i)}}
1063
- /**
1064
- * @license
1065
- * Copyright 2022 Google LLC
1066
- *
1067
- * Licensed under the Apache License, Version 2.0 (the "License");
1068
- * you may not use this file except in compliance with the License.
1069
- * You may obtain a copy of the License at
1070
- *
1071
- * http://www.apache.org/licenses/LICENSE-2.0
1072
- *
1073
- * Unless required by applicable law or agreed to in writing, software
1074
- * distributed under the License is distributed on an "AS IS" BASIS,
1075
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1076
- * See the License for the specific language governing permissions and
1077
- * limitations under the License.
1078
- */class es{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return null!==e&&this.mutation===e.mutation}toString(){return`Overlay{\n largestBatchId: ${this.largestBatchId},\n mutation: ${this.mutation.toString()}\n }`}}
1079
- /**
1080
- * @license
1081
- * Copyright 2017 Google LLC
1082
- *
1083
- * Licensed under the Apache License, Version 2.0 (the "License");
1084
- * you may not use this file except in compliance with the License.
1085
- * You may obtain a copy of the License at
1086
- *
1087
- * http://www.apache.org/licenses/LICENSE-2.0
1088
- *
1089
- * Unless required by applicable law or agreed to in writing, software
1090
- * distributed under the License is distributed on an "AS IS" BASIS,
1091
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1092
- * See the License for the specific language governing permissions and
1093
- * limitations under the License.
1094
- */class ts{constructor(e,t){this.count=e,this.unchangedNames=t}}
1095
- /**
1096
- * @license
1097
- * Copyright 2017 Google LLC
1098
- *
1099
- * Licensed under the Apache License, Version 2.0 (the "License");
1100
- * you may not use this file except in compliance with the License.
1101
- * You may obtain a copy of the License at
1102
- *
1103
- * http://www.apache.org/licenses/LICENSE-2.0
1104
- *
1105
- * Unless required by applicable law or agreed to in writing, software
1106
- * distributed under the License is distributed on an "AS IS" BASIS,
1107
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1108
- * See the License for the specific language governing permissions and
1109
- * limitations under the License.
1110
- */var ns,is;function rs(e){if(void 0===e)return Tt("GRPC error has no .code"),Nt.UNKNOWN;switch(e){case ns.OK:return Nt.OK;case ns.CANCELLED:return Nt.CANCELLED;case ns.UNKNOWN:return Nt.UNKNOWN;case ns.DEADLINE_EXCEEDED:return Nt.DEADLINE_EXCEEDED;case ns.RESOURCE_EXHAUSTED:return Nt.RESOURCE_EXHAUSTED;case ns.INTERNAL:return Nt.INTERNAL;case ns.UNAVAILABLE:return Nt.UNAVAILABLE;case ns.UNAUTHENTICATED:return Nt.UNAUTHENTICATED;case ns.INVALID_ARGUMENT:return Nt.INVALID_ARGUMENT;case ns.NOT_FOUND:return Nt.NOT_FOUND;case ns.ALREADY_EXISTS:return Nt.ALREADY_EXISTS;case ns.PERMISSION_DENIED:return Nt.PERMISSION_DENIED;case ns.FAILED_PRECONDITION:return Nt.FAILED_PRECONDITION;case ns.ABORTED:return Nt.ABORTED;case ns.OUT_OF_RANGE:return Nt.OUT_OF_RANGE;case ns.UNIMPLEMENTED:return Nt.UNIMPLEMENTED;case ns.DATA_LOSS:return Nt.DATA_LOSS;default:return kt(39323,{code:e})}}(is=ns||(ns={}))[is.OK=0]="OK",is[is.CANCELLED=1]="CANCELLED",is[is.UNKNOWN=2]="UNKNOWN",is[is.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",is[is.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",is[is.NOT_FOUND=5]="NOT_FOUND",is[is.ALREADY_EXISTS=6]="ALREADY_EXISTS",is[is.PERMISSION_DENIED=7]="PERMISSION_DENIED",is[is.UNAUTHENTICATED=16]="UNAUTHENTICATED",is[is.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",is[is.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",is[is.ABORTED=10]="ABORTED",is[is.OUT_OF_RANGE=11]="OUT_OF_RANGE",is[is.UNIMPLEMENTED=12]="UNIMPLEMENTED",is[is.INTERNAL=13]="INTERNAL",is[is.UNAVAILABLE=14]="UNAVAILABLE",is[is.DATA_LOSS=15]="DATA_LOSS";
1111
- /**
1112
- * @license
1113
- * Copyright 2022 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
- */
1127
- const ss=new st([4294967295,4294967295],0);function os(e){const t=Ht().encode(e),n=new ot;return n.update(t),new Uint8Array(n.digest())}function as(e){const t=new DataView(e.buffer),n=t.getUint32(0,!0),i=t.getUint32(4,!0),r=t.getUint32(8,!0),s=t.getUint32(12,!0);return[new st([n,i],0),new st([r,s],0)]}class cs{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new ls(`Invalid padding: ${t}`);if(n<0)throw new ls(`Invalid hash count: ${n}`);if(e.length>0&&0===this.hashCount)throw new ls(`Invalid hash count: ${n}`);if(0===e.length&&0!==t)throw new ls(`Invalid padding when bitmap length is 0: ${t}`);this.fe=8*e.length-t,this.ge=st.fromNumber(this.fe)}pe(e,t,n){let i=e.add(t.multiply(st.fromNumber(n)));return 1===i.compare(ss)&&(i=new st([i.getBits(0),i.getBits(1)],0)),i.modulo(this.ge).toNumber()}ye(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.fe)return!1;const t=os(e),[n,i]=as(t);for(let e=0;e<this.hashCount;e++){const t=this.pe(n,i,e);if(!this.ye(t))return!1}return!0}static create(e,t,n){const i=e%8==0?0:8-e%8,r=new Uint8Array(Math.ceil(e/8)),s=new cs(r,i,t);return n.forEach(e=>s.insert(e)),s}insert(e){if(0===this.fe)return;const t=os(e),[n,i]=as(t);for(let e=0;e<this.hashCount;e++){const t=this.pe(n,i,e);this.we(t)}}we(e){const t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}}class ls extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}
1128
- /**
1129
- * @license
1130
- * Copyright 2017 Google LLC
1131
- *
1132
- * Licensed under the Apache License, Version 2.0 (the "License");
1133
- * you may not use this file except in compliance with the License.
1134
- * You may obtain a copy of the License at
1135
- *
1136
- * http://www.apache.org/licenses/LICENSE-2.0
1137
- *
1138
- * Unless required by applicable law or agreed to in writing, software
1139
- * distributed under the License is distributed on an "AS IS" BASIS,
1140
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1141
- * See the License for the specific language governing permissions and
1142
- * limitations under the License.
1143
- */class us{constructor(e,t,n,i,r){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=i,this.resolvedLimboDocuments=r}static createSynthesizedRemoteEventForCurrentChange(e,t,n){const i=new Map;return i.set(e,hs.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new us(pn.min(),i,new xn(qt),ur(),wr())}}class hs{constructor(e,t,n,i,r){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=i,this.removedDocuments=r}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new hs(n,t,wr(),wr(),wr())}}
1144
- /**
1145
- * @license
1146
- * Copyright 2017 Google LLC
1147
- *
1148
- * Licensed under the Apache License, Version 2.0 (the "License");
1149
- * you may not use this file except in compliance with the License.
1150
- * You may obtain a copy of the License at
1151
- *
1152
- * http://www.apache.org/licenses/LICENSE-2.0
1153
- *
1154
- * Unless required by applicable law or agreed to in writing, software
1155
- * distributed under the License is distributed on an "AS IS" BASIS,
1156
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1157
- * See the License for the specific language governing permissions and
1158
- * limitations under the License.
1159
- */class ds{constructor(e,t,n,i){this.Se=e,this.removedTargetIds=t,this.key=n,this.be=i}}class fs{constructor(e,t){this.targetId=e,this.De=t}}class ps{constructor(e,t,n=zn.EMPTY_BYTE_STRING,i=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=i}}class gs{constructor(){this.ve=0,this.Ce=vs(),this.Fe=zn.EMPTY_BYTE_STRING,this.Me=!1,this.xe=!0}get current(){return this.Me}get resumeToken(){return this.Fe}get Oe(){return 0!==this.ve}get Ne(){return this.xe}Be(e){e.approximateByteSize()>0&&(this.xe=!0,this.Fe=e)}Le(){let e=wr(),t=wr(),n=wr();return this.Ce.forEach((i,r)=>{switch(r){case 0:e=e.add(i);break;case 2:t=t.add(i);break;case 1:n=n.add(i);break;default:kt(38017,{changeType:r})}}),new hs(this.Fe,this.Me,e,t,n)}ke(){this.xe=!1,this.Ce=vs()}qe(e,t){this.xe=!0,this.Ce=this.Ce.insert(e,t)}Qe(e){this.xe=!0,this.Ce=this.Ce.remove(e)}$e(){this.ve+=1}Ue(){this.ve-=1,Rt(this.ve>=0,3241,{ve:this.ve})}Ke(){this.xe=!0,this.Me=!0}}class ms{constructor(e){this.We=e,this.Ge=new Map,this.ze=ur(),this.je=ys(),this.Je=ys(),this.He=new xn(qt)}Ye(e){for(const t of e.Se)e.be&&e.be.isFoundDocument()?this.Ze(t,e.be):this.Xe(t,e.key,e.be);for(const t of e.removedTargetIds)this.Xe(t,e.key,e.be)}et(e){this.forEachTarget(e,t=>{const n=this.tt(t);switch(e.state){case 0:this.nt(t)&&n.Be(e.resumeToken);break;case 1:n.Ue(),n.Oe||n.ke(),n.Be(e.resumeToken);break;case 2:n.Ue(),n.Oe||this.removeTarget(t);break;case 3:this.nt(t)&&(n.Ke(),n.Be(e.resumeToken));break;case 4:this.nt(t)&&(this.rt(t),n.Be(e.resumeToken));break;default:kt(56790,{state:e.state})}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Ge.forEach((e,n)=>{this.nt(n)&&t(n)})}it(e){const t=e.targetId,n=e.De.count,i=this.st(t);if(i){const r=i.target;if(Ki(r))if(0===n){const e=new tn(r.path);this.Xe(t,e,_i.newNoDocument(e,pn.min()))}else Rt(1===n,20013,{expectedCount:n});else{const i=this.ot(t);if(i!==n){const n=this._t(e),r=n?this.ut(n,e,i):1;if(0!==r){this.rt(t);const e=2===r?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.He=this.He.insert(t,e)}}}}}_t(e){const t=e.De.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:n="",padding:i=0},hashCount:r=0}=t;let s,o;try{s=Bn(n).toUint8Array()}catch(e){if(e instanceof Mn)return It("Decoding the base64 bloom filter in existence filter failed ("+e.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw e}try{o=new cs(s,i,r)}catch(e){return It(e instanceof ls?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===o.fe?null:o}ut(e,t,n){return t.De.count===n-this.ht(e,t.targetId)?0:2}ht(e,t){const n=this.We.getRemoteKeysForTarget(t);let i=0;return n.forEach(n=>{const r=this.We.lt(),s=`projects/${r.projectId}/databases/${r.database}/documents/${n.path.canonicalString()}`;e.mightContain(s)||(this.Xe(t,n,null),i++)}),i}Pt(e){const t=new Map;this.Ge.forEach((n,i)=>{const r=this.st(i);if(r){if(n.current&&Ki(r.target)){const t=new tn(r.target.path);this.Tt(t).has(i)||this.It(i,t)||this.Xe(i,t,_i.newNoDocument(t,e))}n.Ne&&(t.set(i,n.Le()),n.ke())}});let n=wr();this.Je.forEach((e,t)=>{let i=!0;t.forEachWhile(e=>{const t=this.st(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(i=!1,!1)}),i&&(n=n.add(e))}),this.ze.forEach((t,n)=>n.setReadTime(e));const i=new us(e,t,this.He,this.ze,n);return this.ze=ur(),this.je=ys(),this.Je=ys(),this.He=new xn(qt),i}Ze(e,t){if(!this.nt(e))return;const n=this.It(e,t.key)?2:0;this.tt(e).qe(t.key,n),this.ze=this.ze.insert(t.key,t),this.je=this.je.insert(t.key,this.Tt(t.key).add(e)),this.Je=this.Je.insert(t.key,this.dt(t.key).add(e))}Xe(e,t,n){if(!this.nt(e))return;const i=this.tt(e);this.It(e,t)?i.qe(t,1):i.Qe(t),this.Je=this.Je.insert(t,this.dt(t).delete(e)),this.Je=this.Je.insert(t,this.dt(t).add(e)),n&&(this.ze=this.ze.insert(t,n))}removeTarget(e){this.Ge.delete(e)}ot(e){const t=this.tt(e).Le();return this.We.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.tt(e).$e()}tt(e){let t=this.Ge.get(e);return t||(t=new gs,this.Ge.set(e,t)),t}dt(e){let t=this.Je.get(e);return t||(t=new Ln(qt),this.Je=this.Je.insert(e,t)),t}Tt(e){let t=this.je.get(e);return t||(t=new Ln(qt),this.je=this.je.insert(e,t)),t}nt(e){const t=null!==this.st(e);return t||Et("WatchChangeAggregator","Detected inactive target",e),t}st(e){const t=this.Ge.get(e);return t&&t.Oe?null:this.We.Et(e)}rt(e){this.Ge.set(e,new gs),this.We.getRemoteKeysForTarget(e).forEach(t=>{this.Xe(e,t,null)})}It(e,t){return this.We.getRemoteKeysForTarget(e).has(t)}}function ys(){return new xn(tn.comparator)}function vs(){return new xn(tn.comparator)}const ws={asc:"ASCENDING",desc:"DESCENDING"},bs={"<":"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"},_s={and:"AND",or:"OR"};class Ss{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function Es(e,t){return e.useProto3Json||En(t)?t:{value:t}}function Ts(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function Is(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function Cs(e,t){return Ts(e,t.toTimestamp())}function ks(e){return Rt(!!e,49232),pn.fromTimestamp(function(e){const t=Un(e);return new fn(t.seconds,t.nanos)}(e))}function As(e,t){return Rs(e,t).canonicalString()}function Rs(e,t){const n=function(e){return new Xt(["projects",e.projectId,"databases",e.database])}(e).child("documents");return void 0===t?n:n.child(t)}function xs(e){const t=Xt.fromString(e);return Rt(Ws(t),10190,{key:t.toString()}),t}function Ns(e,t){return As(e.databaseId,t.path)}function Os(e,t){const n=xs(t);if(n.get(1)!==e.databaseId.projectId)throw new Ot(Nt.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new Ot(Nt.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new tn(Ds(n))}function Ls(e,t){return As(e.databaseId,t)}function Ps(e){return new Xt(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function Ds(e){return Rt(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function Ms(e,t,n){return{name:Ns(e,t),fields:n.value.mapValue.fields}}function zs(e,t){return{documents:[Ls(e,t.path)]}}function Fs(e,t){const n={structuredQuery:{}},i=t.path;let r;null!==t.collectionGroup?(r=i,n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(r=i.popLast(),n.structuredQuery.from=[{collectionId:i.lastSegment()}]),n.parent=Ls(e,r);const s=function(e){if(0!==e.length)return Gs(Ri.create(e,"and"))}(t.filters);s&&(n.structuredQuery.where=s);const o=function(e){if(0!==e.length)return e.map(e=>function(e){return{field:$s(e.field),direction:Bs(e.dir)}}(e))}(t.orderBy);o&&(n.structuredQuery.orderBy=o);const a=Es(e,t.limit);return null!==a&&(n.structuredQuery.limit=a),t.startAt&&(n.structuredQuery.startAt=function(e){return{before:e.inclusive,values:e.position}}(t.startAt)),t.endAt&&(n.structuredQuery.endAt=function(e){return{before:!e.inclusive,values:e.position}}(t.endAt)),{Vt:n,parent:r}}function Us(e){let t=function(e){const t=xs(e);return 4===t.length?Xt.emptyPath():Ds(t)}(e.parent);const n=e.structuredQuery,i=n.from?n.from.length:0;let r=null;if(i>0){Rt(1===i,65062);const e=n.from[0];e.allDescendants?r=e.collectionId:t=t.child(e.collectionId)}let s=[];n.where&&(s=function(e){const t=Vs(e);return t instanceof Ri&&Ni(t)?t.getFilters():[t]}(n.where));let o=[];n.orderBy&&(o=function(e){return e.map(e=>function(e){return new Ii(qs(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))}(e))}(n.orderBy));let a=null;n.limit&&(a=function(e){let t;return t="object"==typeof e?e.value:e,En(t)?null:t}(n.limit));let c=null;n.startAt&&(c=function(e){const t=!!e.before,n=e.values||[];return new Si(n,t)}(n.startAt));let l=null;return n.endAt&&(l=function(e){const t=!e.before,n=e.values||[];return new Si(n,t)}(n.endAt)),function(e,t,n,i,r,s,o,a){return new Wi(e,t,n,i,r,s,o,a)}(t,r,o,s,a,"F",c,l)}function Vs(e){return void 0!==e.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":const t=qs(e.unaryFilter.field);return Ai.create(t,"==",{doubleValue:NaN});case"IS_NULL":const n=qs(e.unaryFilter.field);return Ai.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const i=qs(e.unaryFilter.field);return Ai.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const r=qs(e.unaryFilter.field);return Ai.create(r,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return kt(61313);default:return kt(60726)}}(e):void 0!==e.fieldFilter?function(e){return Ai.create(qs(e.fieldFilter.field),function(e){switch(e){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 kt(58110);default:return kt(50506)}}(e.fieldFilter.op),e.fieldFilter.value)}(e):void 0!==e.compositeFilter?function(e){return Ri.create(e.compositeFilter.filters.map(e=>Vs(e)),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return kt(1026)}}(e.compositeFilter.op))}(e):kt(30097,{filter:e})}function Bs(e){return ws[e]}function js(e){return bs[e]}function Hs(e){return _s[e]}function $s(e){return{fieldPath:e.canonicalString()}}function qs(e){return en.fromServerFormat(e.fieldPath)}function Gs(e){return e instanceof Ai?function(e){if("=="===e.op){if(mi(e.value))return{unaryFilter:{field:$s(e.field),op:"IS_NAN"}};if(gi(e.value))return{unaryFilter:{field:$s(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(mi(e.value))return{unaryFilter:{field:$s(e.field),op:"IS_NOT_NAN"}};if(gi(e.value))return{unaryFilter:{field:$s(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:$s(e.field),op:js(e.op),value:e.value}}}(e):e instanceof Ri?function(e){const t=e.getFilters().map(e=>Gs(e));return 1===t.length?t[0]:{compositeFilter:{op:Hs(e.op),filters:t}}}(e):kt(54877,{filter:e})}function Ks(e){const t=[];return e.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}function Ws(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}
1160
- /**
1161
- * @license
1162
- * Copyright 2017 Google LLC
1163
- *
1164
- * Licensed under the Apache License, Version 2.0 (the "License");
1165
- * you may not use this file except in compliance with the License.
1166
- * You may obtain a copy of the License at
1167
- *
1168
- * http://www.apache.org/licenses/LICENSE-2.0
1169
- *
1170
- * Unless required by applicable law or agreed to in writing, software
1171
- * distributed under the License is distributed on an "AS IS" BASIS,
1172
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1173
- * See the License for the specific language governing permissions and
1174
- * limitations under the License.
1175
- */class Qs{constructor(e,t,n,i,r=pn.min(),s=pn.min(),o=zn.EMPTY_BYTE_STRING,a=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=i,this.snapshotVersion=r,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o,this.expectedCount=a}withSequenceNumber(e){return new Qs(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new Qs(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new Qs(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new Qs(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}
1176
- /**
1177
- * @license
1178
- * Copyright 2017 Google LLC
1179
- *
1180
- * Licensed under the Apache License, Version 2.0 (the "License");
1181
- * you may not use this file except in compliance with the License.
1182
- * You may obtain a copy of the License at
1183
- *
1184
- * http://www.apache.org/licenses/LICENSE-2.0
1185
- *
1186
- * Unless required by applicable law or agreed to in writing, software
1187
- * distributed under the License is distributed on an "AS IS" BASIS,
1188
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1189
- * See the License for the specific language governing permissions and
1190
- * limitations under the License.
1191
- */class Js{constructor(e){this.gt=e}}function Ys(e){const t=Us({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?tr(t,t.limit,"L"):t}
1192
- /**
1193
- * @license
1194
- * Copyright 2019 Google LLC
1195
- *
1196
- * Licensed under the Apache License, Version 2.0 (the "License");
1197
- * you may not use this file except in compliance with the License.
1198
- * You may obtain a copy of the License at
1199
- *
1200
- * http://www.apache.org/licenses/LICENSE-2.0
1201
- *
1202
- * Unless required by applicable law or agreed to in writing, software
1203
- * distributed under the License is distributed on an "AS IS" BASIS,
1204
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1205
- * See the License for the specific language governing permissions and
1206
- * limitations under the License.
1207
- */class Xs{constructor(){this.Dn=new Zs}addToCollectionParentIndex(e,t){return this.Dn.add(t),bn.resolve()}getCollectionParents(e,t){return bn.resolve(this.Dn.getEntries(t))}addFieldIndex(e,t){return bn.resolve()}deleteFieldIndex(e,t){return bn.resolve()}deleteAllFieldIndexes(e){return bn.resolve()}createTargetIndexes(e,t){return bn.resolve()}getDocumentsMatchingTarget(e,t){return bn.resolve(null)}getIndexType(e,t){return bn.resolve(0)}getFieldIndexes(e,t){return bn.resolve([])}getNextCollectionGroupToUpdate(e){return bn.resolve(null)}getMinOffset(e,t){return bn.resolve(mn.min())}getMinOffsetFromCollectionGroup(e,t){return bn.resolve(mn.min())}updateCollectionGroup(e,t,n){return bn.resolve()}updateIndexEntries(e,t){return bn.resolve()}}class Zs{constructor(){this.index={}}add(e){const t=e.lastSegment(),n=e.popLast(),i=this.index[t]||new Ln(Xt.comparator),r=!i.has(n);return this.index[t]=i.add(n),r}has(e){const t=e.lastSegment(),n=e.popLast(),i=this.index[t];return i&&i.has(n)}getEntries(e){return(this.index[e]||new Ln(Xt.comparator)).toArray()}}
1208
- /**
1209
- * @license
1210
- * Copyright 2018 Google LLC
1211
- *
1212
- * Licensed under the Apache License, Version 2.0 (the "License");
1213
- * you may not use this file except in compliance with the License.
1214
- * You may obtain a copy of the License at
1215
- *
1216
- * http://www.apache.org/licenses/LICENSE-2.0
1217
- *
1218
- * Unless required by applicable law or agreed to in writing, software
1219
- * distributed under the License is distributed on an "AS IS" BASIS,
1220
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1221
- * See the License for the specific language governing permissions and
1222
- * limitations under the License.
1223
- */const eo={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},to=41943040;class no{static withCacheSize(e){return new no(e,no.DEFAULT_COLLECTION_PERCENTILE,no.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}}
1224
- /**
1225
- * @license
1226
- * Copyright 2017 Google LLC
1227
- *
1228
- * Licensed under the Apache License, Version 2.0 (the "License");
1229
- * you may not use this file except in compliance with the License.
1230
- * You may obtain a copy of the License at
1231
- *
1232
- * http://www.apache.org/licenses/LICENSE-2.0
1233
- *
1234
- * Unless required by applicable law or agreed to in writing, software
1235
- * distributed under the License is distributed on an "AS IS" BASIS,
1236
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1237
- * See the License for the specific language governing permissions and
1238
- * limitations under the License.
1239
- */no.DEFAULT_COLLECTION_PERCENTILE=10,no.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,no.DEFAULT=new no(to,no.DEFAULT_COLLECTION_PERCENTILE,no.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),no.DISABLED=new no(-1,0,0);
1240
- /**
1241
- * @license
1242
- * Copyright 2017 Google LLC
1243
- *
1244
- * Licensed under the Apache License, Version 2.0 (the "License");
1245
- * you may not use this file except in compliance with the License.
1246
- * You may obtain a copy of the License at
1247
- *
1248
- * http://www.apache.org/licenses/LICENSE-2.0
1249
- *
1250
- * Unless required by applicable law or agreed to in writing, software
1251
- * distributed under the License is distributed on an "AS IS" BASIS,
1252
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1253
- * See the License for the specific language governing permissions and
1254
- * limitations under the License.
1255
- */
1256
- class io{constructor(e){this._r=e}next(){return this._r+=2,this._r}static ar(){return new io(0)}static ur(){return new io(-1)}}
1257
- /**
1258
- * @license
1259
- * Copyright 2020 Google LLC
1260
- *
1261
- * Licensed under the Apache License, Version 2.0 (the "License");
1262
- * you may not use this file except in compliance with the License.
1263
- * You may obtain a copy of the License at
1264
- *
1265
- * http://www.apache.org/licenses/LICENSE-2.0
1266
- *
1267
- * Unless required by applicable law or agreed to in writing, software
1268
- * distributed under the License is distributed on an "AS IS" BASIS,
1269
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1270
- * See the License for the specific language governing permissions and
1271
- * limitations under the License.
1272
- */const ro="LruGarbageCollector";function so([e,t],[n,i]){const r=qt(e,n);return 0===r?qt(t,i):r}class oo{constructor(e){this.Tr=e,this.buffer=new Ln(so),this.Ir=0}dr(){return++this.Ir}Er(e){const t=[e,this.dr()];if(this.buffer.size<this.Tr)this.buffer=this.buffer.add(t);else{const e=this.buffer.last();so(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class ao{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Ar=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Rr(6e4)}stop(){this.Ar&&(this.Ar.cancel(),this.Ar=null)}get started(){return null!==this.Ar}Rr(e){Et(ro,`Garbage collection scheduled in ${e}ms`),this.Ar=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Ar=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){_n(e)?Et(ro,"Ignoring IndexedDB error during garbage collection: ",e):await wn(e)}await this.Rr(3e5)})}}class co{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.mr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return bn.resolve(Sn.ue);const n=new oo(t);return this.Vr.forEachTarget(e,e=>n.Er(e.sequenceNumber)).next(()=>this.Vr.gr(e,e=>n.Er(e))).next(()=>n.maxValue)}removeTargets(e,t,n){return this.Vr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return-1===this.params.cacheSizeCollectionThreshold?(Et("LruGarbageCollector","Garbage collection skipped; disabled"),bn.resolve(eo)):this.getCacheSize(e).next(n=>n<this.params.cacheSizeCollectionThreshold?(Et("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),eo):this.pr(e,t))}getCacheSize(e){return this.Vr.getCacheSize(e)}pr(e,t){let n,i,r,s,o,a,c;const l=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(t=>(t>this.params.maximumSequenceNumbersToCollect?(Et("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),i=this.params.maximumSequenceNumbersToCollect):i=t,s=Date.now(),this.nthSequenceNumber(e,i))).next(i=>(n=i,o=Date.now(),this.removeTargets(e,n,t))).next(t=>(r=t,a=Date.now(),this.removeOrphanedDocuments(e,n))).next(e=>(c=Date.now(),St()<=M.DEBUG&&Et("LruGarbageCollector",`LRU Garbage Collection\n\tCounted targets in ${s-l}ms\n\tDetermined least recently used ${i} in `+(o-s)+"ms\n"+`\tRemoved ${r} targets in `+(a-o)+"ms\n"+`\tRemoved ${e} documents in `+(c-a)+"ms\n"+`Total Duration: ${c-l}ms`),bn.resolve({didRun:!0,sequenceNumbersCollected:i,targetsRemoved:r,documentsRemoved:e})))}}
1273
- /**
1274
- * @license
1275
- * Copyright 2017 Google LLC
1276
- *
1277
- * Licensed under the Apache License, Version 2.0 (the "License");
1278
- * you may not use this file except in compliance with the License.
1279
- * You may obtain a copy of the License at
1280
- *
1281
- * http://www.apache.org/licenses/LICENSE-2.0
1282
- *
1283
- * Unless required by applicable law or agreed to in writing, software
1284
- * distributed under the License is distributed on an "AS IS" BASIS,
1285
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1286
- * See the License for the specific language governing permissions and
1287
- * limitations under the License.
1288
- */
1289
- class lo{constructor(){this.changes=new cr(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,_i.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const n=this.changes.get(t);return void 0!==n?bn.resolve(n):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}
1290
- /**
1291
- * @license
1292
- * Copyright 2017 Google LLC
1293
- *
1294
- * Licensed under the Apache License, Version 2.0 (the "License");
1295
- * you may not use this file except in compliance with the License.
1296
- * You may obtain a copy of the License at
1297
- *
1298
- * http://www.apache.org/licenses/LICENSE-2.0
1299
- *
1300
- * Unless required by applicable law or agreed to in writing, software
1301
- * distributed under the License is distributed on an "AS IS" BASIS,
1302
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1303
- * See the License for the specific language governing permissions and
1304
- * limitations under the License.
1305
- */
1306
- /**
1307
- * @license
1308
- * Copyright 2022 Google LLC
1309
- *
1310
- * Licensed under the Apache License, Version 2.0 (the "License");
1311
- * you may not use this file except in compliance with the License.
1312
- * You may obtain a copy of the License at
1313
- *
1314
- * http://www.apache.org/licenses/LICENSE-2.0
1315
- *
1316
- * Unless required by applicable law or agreed to in writing, software
1317
- * distributed under the License is distributed on an "AS IS" BASIS,
1318
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1319
- * See the License for the specific language governing permissions and
1320
- * limitations under the License.
1321
- */class uo{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}
1322
- /**
1323
- * @license
1324
- * Copyright 2017 Google LLC
1325
- *
1326
- * Licensed under the Apache License, Version 2.0 (the "License");
1327
- * you may not use this file except in compliance with the License.
1328
- * You may obtain a copy of the License at
1329
- *
1330
- * http://www.apache.org/licenses/LICENSE-2.0
1331
- *
1332
- * Unless required by applicable law or agreed to in writing, software
1333
- * distributed under the License is distributed on an "AS IS" BASIS,
1334
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1335
- * See the License for the specific language governing permissions and
1336
- * limitations under the License.
1337
- */class ho{constructor(e,t,n,i){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=i}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next(i=>(n=i,this.remoteDocumentCache.getEntry(e,t))).next(e=>(null!==n&&jr(n.mutation,e,Dn.empty(),fn.now()),e))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.getLocalViewOfDocuments(e,t,wr()).next(()=>t))}getLocalViewOfDocuments(e,t,n=wr()){const i=pr();return this.populateOverlays(e,i,t).next(()=>this.computeViews(e,t,i,n).next(e=>{let t=dr();return e.forEach((e,n)=>{t=t.insert(e,n.overlayedDocument)}),t}))}getOverlayedDocuments(e,t){const n=pr();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,wr()))}populateOverlays(e,t,n){const i=[];return n.forEach(e=>{t.has(e)||i.push(e)}),this.documentOverlayCache.getOverlays(e,i).next(e=>{e.forEach((e,n)=>{t.set(e,n)})})}computeViews(e,t,n,i){let r=ur();const s=mr(),o=mr();return t.forEach((e,t)=>{const o=n.get(t.key);i.has(t.key)&&(void 0===o||o.mutation instanceof Gr)?r=r.insert(t.key,t):void 0!==o?(s.set(t.key,o.mutation.getFieldMask()),jr(o.mutation,t,o.mutation.getFieldMask(),fn.now())):s.set(t.key,Dn.empty())}),this.recalculateAndSaveOverlays(e,r).next(e=>(e.forEach((e,t)=>s.set(e,t)),t.forEach((e,t)=>{var n;return o.set(e,new uo(t,null!==(n=s.get(e))&&void 0!==n?n:null))}),o))}recalculateAndSaveOverlays(e,t){const n=mr();let i=new xn((e,t)=>e-t),r=wr();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>{for(const r of e)r.keys().forEach(e=>{const s=t.get(e);if(null===s)return;let o=n.get(e)||Dn.empty();o=r.applyToLocalView(s,o),n.set(e,o);const a=(i.get(r.batchId)||wr()).add(e);i=i.insert(r.batchId,a)})}).next(()=>{const s=[],o=i.getReverseIterator();for(;o.hasNext();){const i=o.getNext(),a=i.key,c=i.value,l=gr();c.forEach(e=>{if(!r.has(e)){const i=Vr(t.get(e),n.get(e));null!==i&&l.set(e,i),r=r.add(e)}}),s.push(this.documentOverlayCache.saveOverlays(e,a,l))}return bn.waitFor(s)}).next(()=>n)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.recalculateAndSaveOverlays(e,t))}getDocumentsMatchingQuery(e,t,n,i){return function(e){return tn.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Yi(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,i):this.getDocumentsMatchingCollectionQuery(e,t,n,i)}getNextDocuments(e,t,n,i){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,i).next(r=>{const s=i-r.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,i-r.size):bn.resolve(pr());let o=-1,a=r;return s.next(t=>bn.forEach(t,(t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),r.get(t)?bn.resolve():this.remoteDocumentCache.getEntry(e,t).next(e=>{a=a.insert(t,e)}))).next(()=>this.populateOverlays(e,t,r)).next(()=>this.computeViews(e,a,t,wr())).next(e=>({batchId:o,changes:fr(e)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new tn(t)).next(e=>{let t=dr();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}getDocumentsMatchingCollectionGroupQuery(e,t,n,i){const r=t.collectionGroup;let s=dr();return this.indexManager.getCollectionParents(e,r).next(o=>bn.forEach(o,o=>{const a=function(e,t){return new Wi(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,o.child(r));return this.getDocumentsMatchingCollectionQuery(e,a,n,i).next(e=>{e.forEach((e,t)=>{s=s.insert(e,t)})})}).next(()=>s))}getDocumentsMatchingCollectionQuery(e,t,n,i){let r;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next(s=>(r=s,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,r,i))).next(e=>{r.forEach((t,n)=>{const i=n.getKey();null===e.get(i)&&(e=e.insert(i,_i.newInvalidDocument(i)))});let n=dr();return e.forEach((e,i)=>{const s=r.get(e);void 0!==s&&jr(s.mutation,i,Dn.empty(),fn.now()),sr(t,i)&&(n=n.insert(e,i))}),n})}}
1338
- /**
1339
- * @license
1340
- * Copyright 2020 Google LLC
1341
- *
1342
- * Licensed under the Apache License, Version 2.0 (the "License");
1343
- * you may not use this file except in compliance with the License.
1344
- * You may obtain a copy of the License at
1345
- *
1346
- * http://www.apache.org/licenses/LICENSE-2.0
1347
- *
1348
- * Unless required by applicable law or agreed to in writing, software
1349
- * distributed under the License is distributed on an "AS IS" BASIS,
1350
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1351
- * See the License for the specific language governing permissions and
1352
- * limitations under the License.
1353
- */class fo{constructor(e){this.serializer=e,this.Br=new Map,this.Lr=new Map}getBundleMetadata(e,t){return bn.resolve(this.Br.get(t))}saveBundleMetadata(e,t){return this.Br.set(t.id,function(e){return{id:e.id,version:e.version,createTime:ks(e.createTime)}}(t)),bn.resolve()}getNamedQuery(e,t){return bn.resolve(this.Lr.get(t))}saveNamedQuery(e,t){return this.Lr.set(t.name,function(e){return{name:e.name,query:Ys(e.bundledQuery),readTime:ks(e.readTime)}}(t)),bn.resolve()}}
1354
- /**
1355
- * @license
1356
- * Copyright 2022 Google LLC
1357
- *
1358
- * Licensed under the Apache License, Version 2.0 (the "License");
1359
- * you may not use this file except in compliance with the License.
1360
- * You may obtain a copy of the License at
1361
- *
1362
- * http://www.apache.org/licenses/LICENSE-2.0
1363
- *
1364
- * Unless required by applicable law or agreed to in writing, software
1365
- * distributed under the License is distributed on an "AS IS" BASIS,
1366
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1367
- * See the License for the specific language governing permissions and
1368
- * limitations under the License.
1369
- */class po{constructor(){this.overlays=new xn(tn.comparator),this.kr=new Map}getOverlay(e,t){return bn.resolve(this.overlays.get(t))}getOverlays(e,t){const n=pr();return bn.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&n.set(t,e)})).next(()=>n)}saveOverlays(e,t,n){return n.forEach((n,i)=>{this.wt(e,t,i)}),bn.resolve()}removeOverlaysForBatchId(e,t,n){const i=this.kr.get(n);return void 0!==i&&(i.forEach(e=>this.overlays=this.overlays.remove(e)),this.kr.delete(n)),bn.resolve()}getOverlaysForCollection(e,t,n){const i=pr(),r=t.length+1,s=new tn(t.child("")),o=this.overlays.getIteratorFrom(s);for(;o.hasNext();){const e=o.getNext().value,s=e.getKey();if(!t.isPrefixOf(s.path))break;s.path.length===r&&e.largestBatchId>n&&i.set(e.getKey(),e)}return bn.resolve(i)}getOverlaysForCollectionGroup(e,t,n,i){let r=new xn((e,t)=>e-t);const s=this.overlays.getIterator();for(;s.hasNext();){const e=s.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=r.get(e.largestBatchId);null===t&&(t=pr(),r=r.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}const o=pr(),a=r.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach((e,t)=>o.set(e,t)),!(o.size()>=i)););return bn.resolve(o)}wt(e,t,n){const i=this.overlays.get(n.key);if(null!==i){const e=this.kr.get(i.largestBatchId).delete(n.key);this.kr.set(i.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new es(t,n));let r=this.kr.get(t);void 0===r&&(r=wr(),this.kr.set(t,r)),this.kr.set(t,r.add(n.key))}}
1370
- /**
1371
- * @license
1372
- * Copyright 2024 Google LLC
1373
- *
1374
- * Licensed under the Apache License, Version 2.0 (the "License");
1375
- * you may not use this file except in compliance with the License.
1376
- * You may obtain a copy of the License at
1377
- *
1378
- * http://www.apache.org/licenses/LICENSE-2.0
1379
- *
1380
- * Unless required by applicable law or agreed to in writing, software
1381
- * distributed under the License is distributed on an "AS IS" BASIS,
1382
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1383
- * See the License for the specific language governing permissions and
1384
- * limitations under the License.
1385
- */class go{constructor(){this.sessionToken=zn.EMPTY_BYTE_STRING}getSessionToken(e){return bn.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,bn.resolve()}}
1386
- /**
1387
- * @license
1388
- * Copyright 2017 Google LLC
1389
- *
1390
- * Licensed under the Apache License, Version 2.0 (the "License");
1391
- * you may not use this file except in compliance with the License.
1392
- * You may obtain a copy of the License at
1393
- *
1394
- * http://www.apache.org/licenses/LICENSE-2.0
1395
- *
1396
- * Unless required by applicable law or agreed to in writing, software
1397
- * distributed under the License is distributed on an "AS IS" BASIS,
1398
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1399
- * See the License for the specific language governing permissions and
1400
- * limitations under the License.
1401
- */class mo{constructor(){this.qr=new Ln(yo.Qr),this.$r=new Ln(yo.Ur)}isEmpty(){return this.qr.isEmpty()}addReference(e,t){const n=new yo(e,t);this.qr=this.qr.add(n),this.$r=this.$r.add(n)}Kr(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.Wr(new yo(e,t))}Gr(e,t){e.forEach(e=>this.removeReference(e,t))}zr(e){const t=new tn(new Xt([])),n=new yo(t,e),i=new yo(t,e+1),r=[];return this.$r.forEachInRange([n,i],e=>{this.Wr(e),r.push(e.key)}),r}jr(){this.qr.forEach(e=>this.Wr(e))}Wr(e){this.qr=this.qr.delete(e),this.$r=this.$r.delete(e)}Jr(e){const t=new tn(new Xt([])),n=new yo(t,e),i=new yo(t,e+1);let r=wr();return this.$r.forEachInRange([n,i],e=>{r=r.add(e.key)}),r}containsKey(e){const t=new yo(e,0),n=this.qr.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}class yo{constructor(e,t){this.key=e,this.Hr=t}static Qr(e,t){return tn.comparator(e.key,t.key)||qt(e.Hr,t.Hr)}static Ur(e,t){return qt(e.Hr,t.Hr)||tn.comparator(e.key,t.key)}}
1402
- /**
1403
- * @license
1404
- * Copyright 2017 Google LLC
1405
- *
1406
- * Licensed under the Apache License, Version 2.0 (the "License");
1407
- * you may not use this file except in compliance with the License.
1408
- * You may obtain a copy of the License at
1409
- *
1410
- * http://www.apache.org/licenses/LICENSE-2.0
1411
- *
1412
- * Unless required by applicable law or agreed to in writing, software
1413
- * distributed under the License is distributed on an "AS IS" BASIS,
1414
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1415
- * See the License for the specific language governing permissions and
1416
- * limitations under the License.
1417
- */class vo{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.er=1,this.Yr=new Ln(yo.Qr)}checkEmpty(e){return bn.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,n,i){const r=this.er;this.er++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const s=new Xr(r,t,n,i);this.mutationQueue.push(s);for(const t of i)this.Yr=this.Yr.add(new yo(t.key,r)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return bn.resolve(s)}lookupMutationBatch(e,t){return bn.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){const n=t+1,i=this.Xr(n),r=i<0?0:i;return bn.resolve(this.mutationQueue.length>r?this.mutationQueue[r]:null)}getHighestUnacknowledgedBatchId(){return bn.resolve(0===this.mutationQueue.length?-1:this.er-1)}getAllMutationBatches(e){return bn.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const n=new yo(t,0),i=new yo(t,Number.POSITIVE_INFINITY),r=[];return this.Yr.forEachInRange([n,i],e=>{const t=this.Zr(e.Hr);r.push(t)}),bn.resolve(r)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new Ln(qt);return t.forEach(e=>{const t=new yo(e,0),i=new yo(e,Number.POSITIVE_INFINITY);this.Yr.forEachInRange([t,i],e=>{n=n.add(e.Hr)})}),bn.resolve(this.ei(n))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,i=n.length+1;let r=n;tn.isDocumentKey(r)||(r=r.child(""));const s=new yo(new tn(r),0);let o=new Ln(qt);return this.Yr.forEachWhile(e=>{const t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===i&&(o=o.add(e.Hr)),!0)},s),bn.resolve(this.ei(o))}ei(e){const t=[];return e.forEach(e=>{const n=this.Zr(e);null!==n&&t.push(n)}),t}removeMutationBatch(e,t){Rt(0===this.ti(t.batchId,"removed"),55003),this.mutationQueue.shift();let n=this.Yr;return bn.forEach(t.mutations,i=>{const r=new yo(i.key,t.batchId);return n=n.delete(r),this.referenceDelegate.markPotentiallyOrphaned(e,i.key)}).next(()=>{this.Yr=n})}rr(e){}containsKey(e,t){const n=new yo(t,0),i=this.Yr.firstAfterOrEqual(n);return bn.resolve(t.isEqual(i&&i.key))}performConsistencyCheck(e){return this.mutationQueue.length,bn.resolve()}ti(e,t){return this.Xr(e)}Xr(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Zr(e){const t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}
1418
- /**
1419
- * @license
1420
- * Copyright 2017 Google LLC
1421
- *
1422
- * Licensed under the Apache License, Version 2.0 (the "License");
1423
- * you may not use this file except in compliance with the License.
1424
- * You may obtain a copy of the License at
1425
- *
1426
- * http://www.apache.org/licenses/LICENSE-2.0
1427
- *
1428
- * Unless required by applicable law or agreed to in writing, software
1429
- * distributed under the License is distributed on an "AS IS" BASIS,
1430
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1431
- * See the License for the specific language governing permissions and
1432
- * limitations under the License.
1433
- */class wo{constructor(e){this.ni=e,this.docs=new xn(tn.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const n=t.key,i=this.docs.get(n),r=i?i.size:0,s=this.ni(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:s}),this.size+=s-r,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const n=this.docs.get(t);return bn.resolve(n?n.document.mutableCopy():_i.newInvalidDocument(t))}getEntries(e,t){let n=ur();return t.forEach(e=>{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():_i.newInvalidDocument(e))}),bn.resolve(n)}getDocumentsMatchingQuery(e,t,n,i){let r=ur();const s=t.path,o=new tn(s.child("__id-9223372036854775808__")),a=this.docs.getIteratorFrom(o);for(;a.hasNext();){const{key:e,value:{document:o}}=a.getNext();if(!s.isPrefixOf(e.path))break;e.path.length>s.length+1||yn(gn(o),n)<=0||(i.has(o.key)||sr(t,o))&&(r=r.insert(o.key,o.mutableCopy()))}return bn.resolve(r)}getAllFromCollectionGroup(e,t,n,i){kt(9500)}ri(e,t){return bn.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new bo(this)}getSize(e){return bn.resolve(this.size)}}class bo extends lo{constructor(e){super(),this.Or=e}applyChanges(e){const t=[];return this.changes.forEach((n,i)=>{i.isValidDocument()?t.push(this.Or.addEntry(e,i)):this.Or.removeEntry(n)}),bn.waitFor(t)}getFromCache(e,t){return this.Or.getEntry(e,t)}getAllFromCache(e,t){return this.Or.getEntries(e,t)}}
1434
- /**
1435
- * @license
1436
- * Copyright 2017 Google LLC
1437
- *
1438
- * Licensed under the Apache License, Version 2.0 (the "License");
1439
- * you may not use this file except in compliance with the License.
1440
- * You may obtain a copy of the License at
1441
- *
1442
- * http://www.apache.org/licenses/LICENSE-2.0
1443
- *
1444
- * Unless required by applicable law or agreed to in writing, software
1445
- * distributed under the License is distributed on an "AS IS" BASIS,
1446
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1447
- * See the License for the specific language governing permissions and
1448
- * limitations under the License.
1449
- */class _o{constructor(e){this.persistence=e,this.ii=new cr(e=>qi(e),Gi),this.lastRemoteSnapshotVersion=pn.min(),this.highestTargetId=0,this.si=0,this.oi=new mo,this.targetCount=0,this._i=io.ar()}forEachTarget(e,t){return this.ii.forEach((e,n)=>t(n)),bn.resolve()}getLastRemoteSnapshotVersion(e){return bn.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return bn.resolve(this.si)}allocateTargetId(e){return this.highestTargetId=this._i.next(),bn.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.si&&(this.si=t),bn.resolve()}hr(e){this.ii.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this._i=new io(t),this.highestTargetId=t),e.sequenceNumber>this.si&&(this.si=e.sequenceNumber)}addTargetData(e,t){return this.hr(t),this.targetCount+=1,bn.resolve()}updateTargetData(e,t){return this.hr(t),bn.resolve()}removeTargetData(e,t){return this.ii.delete(t.target),this.oi.zr(t.targetId),this.targetCount-=1,bn.resolve()}removeTargets(e,t,n){let i=0;const r=[];return this.ii.forEach((s,o)=>{o.sequenceNumber<=t&&null===n.get(o.targetId)&&(this.ii.delete(s),r.push(this.removeMatchingKeysForTargetId(e,o.targetId)),i++)}),bn.waitFor(r).next(()=>i)}getTargetCount(e){return bn.resolve(this.targetCount)}getTargetData(e,t){const n=this.ii.get(t)||null;return bn.resolve(n)}addMatchingKeys(e,t,n){return this.oi.Kr(t,n),bn.resolve()}removeMatchingKeys(e,t,n){this.oi.Gr(t,n);const i=this.persistence.referenceDelegate,r=[];return i&&t.forEach(t=>{r.push(i.markPotentiallyOrphaned(e,t))}),bn.waitFor(r)}removeMatchingKeysForTargetId(e,t){return this.oi.zr(t),bn.resolve()}getMatchingKeysForTargetId(e,t){const n=this.oi.Jr(t);return bn.resolve(n)}containsKey(e,t){return bn.resolve(this.oi.containsKey(t))}}
1450
- /**
1451
- * @license
1452
- * Copyright 2017 Google LLC
1453
- *
1454
- * Licensed under the Apache License, Version 2.0 (the "License");
1455
- * you may not use this file except in compliance with the License.
1456
- * You may obtain a copy of the License at
1457
- *
1458
- * http://www.apache.org/licenses/LICENSE-2.0
1459
- *
1460
- * Unless required by applicable law or agreed to in writing, software
1461
- * distributed under the License is distributed on an "AS IS" BASIS,
1462
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1463
- * See the License for the specific language governing permissions and
1464
- * limitations under the License.
1465
- */class So{constructor(e,t){this.ai={},this.overlays={},this.ui=new Sn(0),this.ci=!1,this.ci=!0,this.li=new go,this.referenceDelegate=e(this),this.hi=new _o(this),this.indexManager=new Xs,this.remoteDocumentCache=function(e){return new wo(e)}(e=>this.referenceDelegate.Pi(e)),this.serializer=new Js(t),this.Ti=new fo(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ci=!1,Promise.resolve()}get started(){return this.ci}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new po,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.ai[e.toKey()];return n||(n=new vo(t,this.referenceDelegate),this.ai[e.toKey()]=n),n}getGlobalsCache(){return this.li}getTargetCache(){return this.hi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ti}runTransaction(e,t,n){Et("MemoryPersistence","Starting transaction:",e);const i=new Eo(this.ui.next());return this.referenceDelegate.Ii(),n(i).next(e=>this.referenceDelegate.di(i).next(()=>e)).toPromise().then(e=>(i.raiseOnCommittedEvent(),e))}Ei(e,t){return bn.or(Object.values(this.ai).map(n=>()=>n.containsKey(e,t)))}}class Eo extends vn{constructor(e){super(),this.currentSequenceNumber=e}}class To{constructor(e){this.persistence=e,this.Ai=new mo,this.Ri=null}static Vi(e){return new To(e)}get mi(){if(this.Ri)return this.Ri;throw kt(60996)}addReference(e,t,n){return this.Ai.addReference(n,t),this.mi.delete(n.toString()),bn.resolve()}removeReference(e,t,n){return this.Ai.removeReference(n,t),this.mi.add(n.toString()),bn.resolve()}markPotentiallyOrphaned(e,t){return this.mi.add(t.toString()),bn.resolve()}removeTarget(e,t){this.Ai.zr(t.targetId).forEach(e=>this.mi.add(e.toString()));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.mi.add(e.toString()))}).next(()=>n.removeTargetData(e,t))}Ii(){this.Ri=new Set}di(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return bn.forEach(this.mi,n=>{const i=tn.fromPath(n);return this.fi(e,i).next(e=>{e||t.removeEntry(i,pn.min())})}).next(()=>(this.Ri=null,t.apply(e)))}updateLimboDocument(e,t){return this.fi(e,t).next(e=>{e?this.mi.delete(t.toString()):this.mi.add(t.toString())})}Pi(e){return 0}fi(e,t){return bn.or([()=>bn.resolve(this.Ai.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class Io{constructor(e,t){this.persistence=e,this.gi=new cr(e=>function(e){let t="";for(let n=0;n<e.length;n++)t.length>0&&(t=Cn(t)),t=In(e.get(n),t);return Cn(t)}(e.path),(e,t)=>e.isEqual(t)),this.garbageCollector=function(e,t){return new co(e,t)}(this,t)}static Vi(e,t){return new Io(e,t)}Ii(){}di(e){return bn.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}mr(e){const t=this.yr(e);return this.persistence.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}yr(e){let t=0;return this.gr(e,e=>{t++}).next(()=>t)}gr(e,t){return bn.forEach(this.gi,(n,i)=>this.Sr(e,n,i).next(e=>e?bn.resolve():t(i)))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0;const i=this.persistence.getRemoteDocumentCache(),r=i.newChangeBuffer();return i.ri(e,i=>this.Sr(e,i,t).next(e=>{e||(n++,r.removeEntry(i,pn.min()))})).next(()=>r.apply(e)).next(()=>n)}markPotentiallyOrphaned(e,t){return this.gi.set(t,e.currentSequenceNumber),bn.resolve()}removeTarget(e,t){const n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.gi.set(n,e.currentSequenceNumber),bn.resolve()}removeReference(e,t,n){return this.gi.set(n,e.currentSequenceNumber),bn.resolve()}updateLimboDocument(e,t){return this.gi.set(t,e.currentSequenceNumber),bn.resolve()}Pi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=hi(e.data.value)),t}Sr(e,t,n){return bn.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const e=this.gi.get(t);return bn.resolve(void 0!==e&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}
1466
- /**
1467
- * @license
1468
- * Copyright 2017 Google LLC
1469
- *
1470
- * Licensed under the Apache License, Version 2.0 (the "License");
1471
- * you may not use this file except in compliance with the License.
1472
- * You may obtain a copy of the License at
1473
- *
1474
- * http://www.apache.org/licenses/LICENSE-2.0
1475
- *
1476
- * Unless required by applicable law or agreed to in writing, software
1477
- * distributed under the License is distributed on an "AS IS" BASIS,
1478
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1479
- * See the License for the specific language governing permissions and
1480
- * limitations under the License.
1481
- */class Co{constructor(e,t,n,i){this.targetId=e,this.fromCache=t,this.Is=n,this.ds=i}static Es(e,t){let n=wr(),i=wr();for(const e of t.docChanges)switch(e.type){case 0:n=n.add(e.doc.key);break;case 1:i=i.add(e.doc.key)}return new Co(e,t.fromCache,n,i)}}
1482
- /**
1483
- * @license
1484
- * Copyright 2023 Google LLC
1485
- *
1486
- * Licensed under the Apache License, Version 2.0 (the "License");
1487
- * you may not use this file except in compliance with the License.
1488
- * You may obtain a copy of the License at
1489
- *
1490
- * http://www.apache.org/licenses/LICENSE-2.0
1491
- *
1492
- * Unless required by applicable law or agreed to in writing, software
1493
- * distributed under the License is distributed on an "AS IS" BASIS,
1494
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1495
- * See the License for the specific language governing permissions and
1496
- * limitations under the License.
1497
- */class ko{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}
1498
- /**
1499
- * @license
1500
- * Copyright 2019 Google LLC
1501
- *
1502
- * Licensed under the Apache License, Version 2.0 (the "License");
1503
- * you may not use this file except in compliance with the License.
1504
- * You may obtain a copy of the License at
1505
- *
1506
- * http://www.apache.org/licenses/LICENSE-2.0
1507
- *
1508
- * Unless required by applicable law or agreed to in writing, software
1509
- * distributed under the License is distributed on an "AS IS" BASIS,
1510
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1511
- * See the License for the specific language governing permissions and
1512
- * limitations under the License.
1513
- */class Ao{constructor(){this.As=!1,this.Rs=!1,this.Vs=100,this.fs=b()?8:function(e){const t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(n)}(w())>0?6:4}initialize(e,t){this.gs=e,this.indexManager=t,this.As=!0}getDocumentsMatchingQuery(e,t,n,i){const r={result:null};return this.ps(e,t).next(e=>{r.result=e}).next(()=>{if(!r.result)return this.ys(e,t,i,n).next(e=>{r.result=e})}).next(()=>{if(r.result)return;const n=new ko;return this.ws(e,t,n).next(i=>{if(r.result=i,this.Rs)return this.Ss(e,t,n,i.size)})}).next(()=>r.result)}Ss(e,t,n,i){return n.documentReadCount<this.Vs?(St()<=M.DEBUG&&Et("QueryEngine","SDK will not create cache indexes for query:",rr(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),bn.resolve()):(St()<=M.DEBUG&&Et("QueryEngine","Query:",rr(t),"scans",n.documentReadCount,"local documents and returns",i,"documents as results."),n.documentReadCount>this.fs*i?(St()<=M.DEBUG&&Et("QueryEngine","The SDK decides to create cache indexes for query:",rr(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,Zi(t))):bn.resolve())}ps(e,t){if(Ji(t))return bn.resolve(null);let n=Zi(t);return this.indexManager.getIndexType(e,n).next(i=>0===i?null:(null!==t.limit&&1===i&&(t=tr(t,null,"F"),n=Zi(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next(i=>{const r=wr(...i);return this.gs.getDocuments(e,r).next(i=>this.indexManager.getMinOffset(e,n).next(n=>{const s=this.bs(t,i);return this.Ds(t,s,r,n.readTime)?this.ps(e,tr(t,null,"F")):this.vs(e,s,t,n)}))})))}ys(e,t,n,i){return Ji(t)||i.isEqual(pn.min())?bn.resolve(null):this.gs.getDocuments(e,n).next(r=>{const s=this.bs(t,r);return this.Ds(t,s,n,i)?bn.resolve(null):(St()<=M.DEBUG&&Et("QueryEngine","Re-using previous result from %s to execute query: %s",i.toString(),rr(t)),this.vs(e,s,t,function(e,t){const n=e.toTimestamp().seconds,i=e.toTimestamp().nanoseconds+1,r=pn.fromTimestamp(1e9===i?new fn(n+1,0):new fn(n,i));return new mn(r,tn.empty(),t)}(i,-1)).next(e=>e))})}bs(e,t){let n=new Ln(or(e));return t.forEach((t,i)=>{sr(e,i)&&(n=n.add(i))}),n}Ds(e,t,n,i){if(null===e.limit)return!1;if(n.size!==t.size)return!0;const r="F"===e.limitType?t.last():t.first();return!!r&&(r.hasPendingWrites||r.version.compareTo(i)>0)}ws(e,t,n){return St()<=M.DEBUG&&Et("QueryEngine","Using full collection scan to execute query:",rr(t)),this.gs.getDocumentsMatchingQuery(e,t,mn.min(),n)}vs(e,t,n,i){return this.gs.getDocumentsMatchingQuery(e,n,i).next(e=>(t.forEach(t=>{e=e.insert(t.key,t)}),e))}}
1514
- /**
1515
- * @license
1516
- * Copyright 2020 Google LLC
1517
- *
1518
- * Licensed under the Apache License, Version 2.0 (the "License");
1519
- * you may not use this file except in compliance with the License.
1520
- * You may obtain a copy of the License at
1521
- *
1522
- * http://www.apache.org/licenses/LICENSE-2.0
1523
- *
1524
- * Unless required by applicable law or agreed to in writing, software
1525
- * distributed under the License is distributed on an "AS IS" BASIS,
1526
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1527
- * See the License for the specific language governing permissions and
1528
- * limitations under the License.
1529
- */const Ro="LocalStore";class xo{constructor(e,t,n,i){this.persistence=e,this.Cs=t,this.serializer=i,this.Fs=new xn(qt),this.Ms=new cr(e=>qi(e),Gi),this.xs=new Map,this.Os=e.getRemoteDocumentCache(),this.hi=e.getTargetCache(),this.Ti=e.getBundleCache(),this.Ns(n)}Ns(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new ho(this.Os,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Os.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.Fs))}}async function No(e,t){const n=xt(e);return await n.persistence.runTransaction("Handle user change","readonly",e=>{let i;return n.mutationQueue.getAllMutationBatches(e).next(r=>(i=r,n.Ns(t),n.mutationQueue.getAllMutationBatches(e))).next(t=>{const r=[],s=[];let o=wr();for(const e of i){r.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}for(const e of t){s.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}return n.localDocuments.getDocuments(e,o).next(e=>({Bs:e,removedBatchIds:r,addedBatchIds:s}))})})}function Oo(e){const t=xt(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.hi.getLastRemoteSnapshotVersion(e))}function Lo(e,t){const n=xt(e),i=t.snapshotVersion;let r=n.Fs;return n.persistence.runTransaction("Apply remote event","readwrite-primary",e=>{const s=n.Os.newChangeBuffer({trackRemovals:!0});r=n.Fs;const o=[];t.targetChanges.forEach((s,a)=>{const c=r.get(a);if(!c)return;o.push(n.hi.removeMatchingKeys(e,s.removedDocuments,a).next(()=>n.hi.addMatchingKeys(e,s.addedDocuments,a)));let l=c.withSequenceNumber(e.currentSequenceNumber);null!==t.targetMismatches.get(a)?l=l.withResumeToken(zn.EMPTY_BYTE_STRING,pn.min()).withLastLimboFreeSnapshotVersion(pn.min()):s.resumeToken.approximateByteSize()>0&&(l=l.withResumeToken(s.resumeToken,i)),r=r.insert(a,l),function(e,t,n){if(0===e.resumeToken.approximateByteSize())return!0;if(t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=3e8)return!0;return n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(c,l,s)&&o.push(n.hi.updateTargetData(e,l))});let a=ur(),c=wr();if(t.documentUpdates.forEach(i=>{t.resolvedLimboDocuments.has(i)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,i))}),o.push(function(e,t,n){let i=wr(),r=wr();return n.forEach(e=>i=i.add(e)),t.getEntries(e,i).next(e=>{let i=ur();return n.forEach((n,s)=>{const o=e.get(n);s.isFoundDocument()!==o.isFoundDocument()&&(r=r.add(n)),s.isNoDocument()&&s.version.isEqual(pn.min())?(t.removeEntry(n,s.readTime),i=i.insert(n,s)):!o.isValidDocument()||s.version.compareTo(o.version)>0||0===s.version.compareTo(o.version)&&o.hasPendingWrites?(t.addEntry(s),i=i.insert(n,s)):Et(Ro,"Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",s.version)}),{Ls:i,ks:r}})}(e,s,t.documentUpdates).next(e=>{a=e.Ls,c=e.ks})),!i.isEqual(pn.min())){const t=n.hi.getLastRemoteSnapshotVersion(e).next(t=>n.hi.setTargetsMetadata(e,e.currentSequenceNumber,i));o.push(t)}return bn.waitFor(o).next(()=>s.apply(e)).next(()=>n.localDocuments.getLocalViewOfDocuments(e,a,c)).next(()=>a)}).then(e=>(n.Fs=r,e))}function Po(e,t){const n=xt(e);return n.persistence.runTransaction("Get next mutation batch","readonly",e=>(void 0===t&&(t=-1),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t)))}async function Do(e,t,n){const i=xt(e),r=i.Fs.get(t),s=n?"readwrite":"readwrite-primary";try{n||await i.persistence.runTransaction("Release target",s,e=>i.persistence.referenceDelegate.removeTarget(e,r))}catch(e){if(!_n(e))throw e;Et(Ro,`Failed to update sequence numbers for target ${t}: ${e}`)}i.Fs=i.Fs.remove(t),i.Ms.delete(r.target)}function Mo(e,t,n){const i=xt(e);let r=pn.min(),s=wr();return i.persistence.runTransaction("Execute query","readwrite",e=>function(e,t,n){const i=xt(e),r=i.Ms.get(n);return void 0!==r?bn.resolve(i.Fs.get(r)):i.hi.getTargetData(t,n)}(i,e,Zi(t)).next(t=>{if(t)return r=t.lastLimboFreeSnapshotVersion,i.hi.getMatchingKeysForTargetId(e,t.targetId).next(e=>{s=e})}).next(()=>i.Cs.getDocumentsMatchingQuery(e,t,n?r:pn.min(),n?s:wr())).next(e=>(function(e,t,n){let i=e.xs.get(t)||pn.min();n.forEach((e,t)=>{t.readTime.compareTo(i)>0&&(i=t.readTime)}),e.xs.set(t,i)}(i,function(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}(t),e),{documents:e,qs:s})))}class zo{constructor(){this.activeTargetIds=br}Gs(e){this.activeTargetIds=this.activeTargetIds.add(e)}zs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class Fo{constructor(){this.Fo=new zo,this.Mo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.Fo.Gs(e),this.Mo[e]||"not-current"}updateQueryState(e,t,n){this.Mo[e]=t}removeLocalQueryTarget(e){this.Fo.zs(e)}isLocalQueryTarget(e){return this.Fo.activeTargetIds.has(e)}clearQueryState(e){delete this.Mo[e]}getAllActiveQueryTargets(){return this.Fo.activeTargetIds}isActiveQueryTarget(e){return this.Fo.activeTargetIds.has(e)}start(){return this.Fo=new zo,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}
1530
- /**
1531
- * @license
1532
- * Copyright 2019 Google LLC
1533
- *
1534
- * Licensed under the Apache License, Version 2.0 (the "License");
1535
- * you may not use this file except in compliance with the License.
1536
- * You may obtain a copy of the License at
1537
- *
1538
- * http://www.apache.org/licenses/LICENSE-2.0
1539
- *
1540
- * Unless required by applicable law or agreed to in writing, software
1541
- * distributed under the License is distributed on an "AS IS" BASIS,
1542
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1543
- * See the License for the specific language governing permissions and
1544
- * limitations under the License.
1545
- */class Uo{xo(e){}shutdown(){}}
1546
- /**
1547
- * @license
1548
- * Copyright 2019 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 Vo="ConnectivityMonitor";class Bo{constructor(){this.Oo=()=>this.No(),this.Bo=()=>this.Lo(),this.ko=[],this.qo()}xo(e){this.ko.push(e)}shutdown(){window.removeEventListener("online",this.Oo),window.removeEventListener("offline",this.Bo)}qo(){window.addEventListener("online",this.Oo),window.addEventListener("offline",this.Bo)}No(){Et(Vo,"Network connectivity changed: AVAILABLE");for(const e of this.ko)e(0)}Lo(){Et(Vo,"Network connectivity changed: UNAVAILABLE");for(const e of this.ko)e(1)}static C(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}
1562
- /**
1563
- * @license
1564
- * Copyright 2023 Google LLC
1565
- *
1566
- * Licensed under the Apache License, Version 2.0 (the "License");
1567
- * you may not use this file except in compliance with the License.
1568
- * You may obtain a copy of the License at
1569
- *
1570
- * http://www.apache.org/licenses/LICENSE-2.0
1571
- *
1572
- * Unless required by applicable law or agreed to in writing, software
1573
- * distributed under the License is distributed on an "AS IS" BASIS,
1574
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1575
- * See the License for the specific language governing permissions and
1576
- * limitations under the License.
1577
- */let jo=null;function Ho(){return null===jo?jo=268435456+Math.round(2147483648*Math.random()):jo++,"0x"+jo.toString(16)
1578
- /**
1579
- * @license
1580
- * Copyright 2020 Google LLC
1581
- *
1582
- * Licensed under the Apache License, Version 2.0 (the "License");
1583
- * you may not use this file except in compliance with the License.
1584
- * You may obtain a copy of the License at
1585
- *
1586
- * http://www.apache.org/licenses/LICENSE-2.0
1587
- *
1588
- * Unless required by applicable law or agreed to in writing, software
1589
- * distributed under the License is distributed on an "AS IS" BASIS,
1590
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1591
- * See the License for the specific language governing permissions and
1592
- * limitations under the License.
1593
- */}const $o="RestConnection",qo={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class Go{get Qo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),i=encodeURIComponent(this.databaseId.database);this.$o=t+"://"+e.host,this.Uo=`projects/${n}/databases/${i}`,this.Ko=this.databaseId.database===Jn?`project_id=${n}`:`project_id=${n}&database_id=${i}`}Wo(e,t,n,i,r){const s=Ho(),o=this.Go(e,t.toUriEncodedString());Et($o,`Sending RPC '${e}' ${s}:`,o,n);const a={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.Ko};this.zo(a,i,r);const{host:c}=new URL(o),l=p(c);return this.jo(e,o,a,n,l).then(t=>(Et($o,`Received RPC '${e}' ${s}: `,t),t),t=>{throw It($o,`RPC '${e}' ${s} failed with error: `,t,"url: ",o,"request:",n),t})}Jo(e,t,n,i,r,s){return this.Wo(e,t,n,i,r)}zo(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+bt,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((t,n)=>e[n]=t),n&&n.headers.forEach((t,n)=>e[n]=t)}Go(e,t){const n=qo[e];return`${this.$o}/v1/${t}:${n}`}terminate(){}}
1594
- /**
1595
- * @license
1596
- * Copyright 2017 Google LLC
1597
- *
1598
- * Licensed under the Apache License, Version 2.0 (the "License");
1599
- * you may not use this file except in compliance with the License.
1600
- * You may obtain a copy of the License at
1601
- *
1602
- * http://www.apache.org/licenses/LICENSE-2.0
1603
- *
1604
- * Unless required by applicable law or agreed to in writing, software
1605
- * distributed under the License is distributed on an "AS IS" BASIS,
1606
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1607
- * See the License for the specific language governing permissions and
1608
- * limitations under the License.
1609
- */class Ko{constructor(e){this.Ho=e.Ho,this.Yo=e.Yo}Zo(e){this.Xo=e}e_(e){this.t_=e}n_(e){this.r_=e}onMessage(e){this.i_=e}close(){this.Yo()}send(e){this.Ho(e)}s_(){this.Xo()}o_(){this.t_()}__(e){this.r_(e)}a_(e){this.i_(e)}}
1610
- /**
1611
- * @license
1612
- * Copyright 2017 Google LLC
1613
- *
1614
- * Licensed under the Apache License, Version 2.0 (the "License");
1615
- * you may not use this file except in compliance with the License.
1616
- * You may obtain a copy of the License at
1617
- *
1618
- * http://www.apache.org/licenses/LICENSE-2.0
1619
- *
1620
- * Unless required by applicable law or agreed to in writing, software
1621
- * distributed under the License is distributed on an "AS IS" BASIS,
1622
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1623
- * See the License for the specific language governing permissions and
1624
- * limitations under the License.
1625
- */const Wo="WebChannelConnection";class Qo extends Go{constructor(e){super(e),this.u_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}jo(e,t,n,i,r){const s=Ho();return new Promise((r,o)=>{const a=new ct;a.setWithCredentials(!0),a.listenOnce(ut.COMPLETE,()=>{try{switch(a.getLastErrorCode()){case ht.NO_ERROR:const t=a.getResponseJson();Et(Wo,`XHR for RPC '${e}' ${s} received:`,JSON.stringify(t)),r(t);break;case ht.TIMEOUT:Et(Wo,`RPC '${e}' ${s} timed out`),o(new Ot(Nt.DEADLINE_EXCEEDED,"Request time out"));break;case ht.HTTP_ERROR:const n=a.getStatus();if(Et(Wo,`RPC '${e}' ${s} failed with status:`,n,"response text:",a.getResponseText()),n>0){let e=a.getResponseJson();Array.isArray(e)&&(e=e[0]);const t=null==e?void 0:e.error;if(t&&t.status&&t.message){const e=function(e){const t=e.toLowerCase().replace(/_/g,"-");return Object.values(Nt).indexOf(t)>=0?t:Nt.UNKNOWN}(t.status);o(new Ot(e,t.message))}else o(new Ot(Nt.UNKNOWN,"Server responded with status "+a.getStatus()))}else o(new Ot(Nt.UNAVAILABLE,"Connection failed."));break;default:kt(9055,{c_:e,streamId:s,l_:a.getLastErrorCode(),h_:a.getLastError()})}}finally{Et(Wo,`RPC '${e}' ${s} completed.`)}});const c=JSON.stringify(i);Et(Wo,`RPC '${e}' ${s} sending request:`,i),a.send(t,"POST",c,n,15)})}P_(e,t,n){const i=Ho(),r=[this.$o,"/","google.firestore.v1.Firestore","/",e,"/channel"],s=gt(),o=pt(),a={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},c=this.longPollingOptions.timeoutSeconds;void 0!==c&&(a.longPollingTimeout=Math.round(1e3*c)),this.useFetchStreams&&(a.useFetchStreams=!0),this.zo(a.initMessageHeaders,t,n),a.encodeInitMessageHeaders=!0;const l=r.join("");Et(Wo,`Creating RPC '${e}' stream ${i}: ${l}`,a);const u=s.createWebChannel(l,a);this.T_(u);let h=!1,d=!1;const f=new Ko({Ho:t=>{d?Et(Wo,`Not sending because RPC '${e}' stream ${i} is closed:`,t):(h||(Et(Wo,`Opening RPC '${e}' stream ${i} transport.`),u.open(),h=!0),Et(Wo,`RPC '${e}' stream ${i} sending:`,t),u.send(t))},Yo:()=>u.close()}),p=(e,t,n)=>{e.listen(t,e=>{try{n(e)}catch(e){setTimeout(()=>{throw e},0)}})};return p(u,lt.EventType.OPEN,()=>{d||(Et(Wo,`RPC '${e}' stream ${i} transport opened.`),f.s_())}),p(u,lt.EventType.CLOSE,()=>{d||(d=!0,Et(Wo,`RPC '${e}' stream ${i} transport closed`),f.__(),this.I_(u))}),p(u,lt.EventType.ERROR,t=>{d||(d=!0,It(Wo,`RPC '${e}' stream ${i} transport errored. Name:`,t.name,"Message:",t.message),f.__(new Ot(Nt.UNAVAILABLE,"The operation could not be completed")))}),p(u,lt.EventType.MESSAGE,t=>{var n;if(!d){const r=t.data[0];Rt(!!r,16349);const s=r,o=(null==s?void 0:s.error)||(null===(n=s[0])||void 0===n?void 0:n.error);if(o){Et(Wo,`RPC '${e}' stream ${i} received error:`,o);const t=o.status;let n=function(e){const t=ns[e];if(void 0!==t)return rs(t)}(t),r=o.message;void 0===n&&(n=Nt.INTERNAL,r="Unknown error status: "+t+" with message "+o.message),d=!0,f.__(new Ot(n,r)),u.close()}else Et(Wo,`RPC '${e}' stream ${i} received:`,r),f.a_(r)}}),p(o,ft.STAT_EVENT,t=>{t.stat===dt.PROXY?Et(Wo,`RPC '${e}' stream ${i} detected buffering proxy`):t.stat===dt.NOPROXY&&Et(Wo,`RPC '${e}' stream ${i} detected no buffering proxy`)}),setTimeout(()=>{f.o_()},0),f}terminate(){this.u_.forEach(e=>e.close()),this.u_=[]}T_(e){this.u_.push(e)}I_(e){this.u_=this.u_.filter(t=>t===e)}}function Jo(){return"undefined"!=typeof document?document:null}
1626
- /**
1627
- * @license
1628
- * Copyright 2020 Google LLC
1629
- *
1630
- * Licensed under the Apache License, Version 2.0 (the "License");
1631
- * you may not use this file except in compliance with the License.
1632
- * You may obtain a copy of the License at
1633
- *
1634
- * http://www.apache.org/licenses/LICENSE-2.0
1635
- *
1636
- * Unless required by applicable law or agreed to in writing, software
1637
- * distributed under the License is distributed on an "AS IS" BASIS,
1638
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1639
- * See the License for the specific language governing permissions and
1640
- * limitations under the License.
1641
- */function Yo(e){return new Ss(e,!0)}
1642
- /**
1643
- * @license
1644
- * Copyright 2017 Google LLC
1645
- *
1646
- * Licensed under the Apache License, Version 2.0 (the "License");
1647
- * you may not use this file except in compliance with the License.
1648
- * You may obtain a copy of the License at
1649
- *
1650
- * http://www.apache.org/licenses/LICENSE-2.0
1651
- *
1652
- * Unless required by applicable law or agreed to in writing, software
1653
- * distributed under the License is distributed on an "AS IS" BASIS,
1654
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1655
- * See the License for the specific language governing permissions and
1656
- * limitations under the License.
1657
- */class Xo{constructor(e,t,n=1e3,i=1.5,r=6e4){this.Fi=e,this.timerId=t,this.d_=n,this.E_=i,this.A_=r,this.R_=0,this.V_=null,this.m_=Date.now(),this.reset()}reset(){this.R_=0}f_(){this.R_=this.A_}g_(e){this.cancel();const t=Math.floor(this.R_+this.p_()),n=Math.max(0,Date.now()-this.m_),i=Math.max(0,t-n);i>0&&Et("ExponentialBackoff",`Backing off for ${i} ms (base delay: ${this.R_} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.V_=this.Fi.enqueueAfterDelay(this.timerId,i,()=>(this.m_=Date.now(),e())),this.R_*=this.E_,this.R_<this.d_&&(this.R_=this.d_),this.R_>this.A_&&(this.R_=this.A_)}y_(){null!==this.V_&&(this.V_.skipDelay(),this.V_=null)}cancel(){null!==this.V_&&(this.V_.cancel(),this.V_=null)}p_(){return(Math.random()-.5)*this.R_}}
1658
- /**
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
- */const Zo="PersistentStream";class ea{constructor(e,t,n,i,r,s,o,a){this.Fi=e,this.w_=n,this.S_=i,this.connection=r,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.b_=0,this.D_=null,this.v_=null,this.stream=null,this.C_=0,this.F_=new Xo(e,t)}M_(){return 1===this.state||5===this.state||this.x_()}x_(){return 2===this.state||3===this.state}start(){this.C_=0,4!==this.state?this.auth():this.O_()}async stop(){this.M_()&&await this.close(0)}N_(){this.state=0,this.F_.reset()}B_(){this.x_()&&null===this.D_&&(this.D_=this.Fi.enqueueAfterDelay(this.w_,6e4,()=>this.L_()))}k_(e){this.q_(),this.stream.send(e)}async L_(){if(this.x_())return this.close(0)}q_(){this.D_&&(this.D_.cancel(),this.D_=null)}Q_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.Q_(),this.F_.cancel(),this.b_++,4!==e?this.F_.reset():t&&t.code===Nt.RESOURCE_EXHAUSTED?(Tt(t.toString()),Tt("Using maximum backoff delay to prevent overloading the backend."),this.F_.f_()):t&&t.code===Nt.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.U_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.n_(t)}U_(){}auth(){this.state=1;const e=this.K_(this.b_),t=this.b_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,n])=>{this.b_===t&&this.W_(e,n)},t=>{e(()=>{const e=new Ot(Nt.UNKNOWN,"Fetching auth token failed: "+t.message);return this.G_(e)})})}W_(e,t){const n=this.K_(this.b_);this.stream=this.z_(e,t),this.stream.Zo(()=>{n(()=>this.listener.Zo())}),this.stream.e_(()=>{n(()=>(this.state=2,this.v_=this.Fi.enqueueAfterDelay(this.S_,1e4,()=>(this.x_()&&(this.state=3),Promise.resolve())),this.listener.e_()))}),this.stream.n_(e=>{n(()=>this.G_(e))}),this.stream.onMessage(e=>{n(()=>1==++this.C_?this.j_(e):this.onNext(e))})}O_(){this.state=5,this.F_.g_(async()=>{this.state=0,this.start()})}G_(e){return Et(Zo,`close with error: ${e}`),this.stream=null,this.close(4,e)}K_(e){return t=>{this.Fi.enqueueAndForget(()=>this.b_===e?t():(Et(Zo,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class ta extends ea{constructor(e,t,n,i,r,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,i,s),this.serializer=r}z_(e,t){return this.connection.P_("Listen",e,t)}j_(e){return this.onNext(e)}onNext(e){this.F_.reset();const t=function(e,t){let n;if("targetChange"in t){t.targetChange;const i=function(e){return"NO_CHANGE"===e?0:"ADD"===e?1:"REMOVE"===e?2:"CURRENT"===e?3:"RESET"===e?4:kt(39313,{state:e})}(t.targetChange.targetChangeType||"NO_CHANGE"),r=t.targetChange.targetIds||[],s=function(e,t){return e.useProto3Json?(Rt(void 0===t||"string"==typeof t,58123),zn.fromBase64String(t||"")):(Rt(void 0===t||t instanceof Buffer||t instanceof Uint8Array,16193),zn.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),o=t.targetChange.cause,a=o&&function(e){const t=void 0===e.code?Nt.UNKNOWN:rs(e.code);return new Ot(t,e.message||"")}(o);n=new ps(i,r,s,a||null)}else if("documentChange"in t){t.documentChange;const i=t.documentChange;i.document,i.document.name,i.document.updateTime;const r=Os(e,i.document.name),s=ks(i.document.updateTime),o=i.document.createTime?ks(i.document.createTime):pn.min(),a=new wi({mapValue:{fields:i.document.fields}}),c=_i.newFoundDocument(r,s,o,a),l=i.targetIds||[],u=i.removedTargetIds||[];n=new ds(l,u,c.key,c)}else if("documentDelete"in t){t.documentDelete;const i=t.documentDelete;i.document;const r=Os(e,i.document),s=i.readTime?ks(i.readTime):pn.min(),o=_i.newNoDocument(r,s),a=i.removedTargetIds||[];n=new ds([],a,o.key,o)}else if("documentRemove"in t){t.documentRemove;const i=t.documentRemove;i.document;const r=Os(e,i.document),s=i.removedTargetIds||[];n=new ds([],s,r,null)}else{if(!("filter"in t))return kt(11601,{At:t});{t.filter;const e=t.filter;e.targetId;const{count:i=0,unchangedNames:r}=e,s=new ts(i,r),o=e.targetId;n=new fs(o,s)}}return n}(this.serializer,e),n=function(e){if(!("targetChange"in e))return pn.min();const t=e.targetChange;return t.targetIds&&t.targetIds.length?pn.min():t.readTime?ks(t.readTime):pn.min()}(e);return this.listener.J_(t,n)}H_(e){const t={};t.database=Ps(this.serializer),t.addTarget=function(e,t){let n;const i=t.target;if(n=Ki(i)?{documents:zs(e,i)}:{query:Fs(e,i).Vt},n.targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=Is(e,t.resumeToken);const i=Es(e,t.expectedCount);null!==i&&(n.expectedCount=i)}else if(t.snapshotVersion.compareTo(pn.min())>0){n.readTime=Ts(e,t.snapshotVersion.toTimestamp());const i=Es(e,t.expectedCount);null!==i&&(n.expectedCount=i)}return n}(this.serializer,e);const n=function(e,t){const n=function(e){switch(e){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return kt(28987,{purpose:e})}}(t.purpose);return null==n?null:{"goog-listen-tags":n}}(this.serializer,e);n&&(t.labels=n),this.k_(t)}Y_(e){const t={};t.database=Ps(this.serializer),t.removeTarget=e,this.k_(t)}}class na extends ea{constructor(e,t,n,i,r,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,i,s),this.serializer=r}get Z_(){return this.C_>0}start(){this.lastStreamToken=void 0,super.start()}U_(){this.Z_&&this.X_([])}z_(e,t){return this.connection.P_("Write",e,t)}j_(e){return Rt(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,Rt(!e.writeResults||0===e.writeResults.length,55816),this.listener.ea()}onNext(e){Rt(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.F_.reset();const t=function(e,t){return e&&e.length>0?(Rt(void 0!==t,14353),e.map(e=>function(e,t){let n=e.updateTime?ks(e.updateTime):ks(t);return n.isEqual(pn.min())&&(n=ks(t)),new Mr(n,e.transformResults||[])}(e,t))):[]}(e.writeResults,e.commitTime),n=ks(e.commitTime);return this.listener.ta(n,t)}na(){const e={};e.database=Ps(this.serializer),this.k_(e)}X_(e){const t={streamToken:this.lastStreamToken,writes:e.map(e=>function(e,t){let n;if(t instanceof qr)n={update:Ms(e,t.key,t.value)};else if(t instanceof Jr)n={delete:Ns(e,t.key)};else if(t instanceof Gr)n={update:Ms(e,t.key,t.data),updateMask:Ks(t.fieldMask)};else{if(!(t instanceof Yr))return kt(16599,{Rt:t.type});n={verify:Ns(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map(e=>function(e,t){const n=t.transform;if(n instanceof Ar)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof Rr)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof Nr)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Lr)return{fieldPath:t.field.canonicalString(),increment:n.Ee};throw kt(20930,{transform:t.transform})}(0,e))),t.precondition.isNone||(n.currentDocument=function(e,t){return void 0!==t.updateTime?{updateTime:Cs(e,t.updateTime)}:void 0!==t.exists?{exists:t.exists}:kt(27497)}(e,t.precondition)),n}(this.serializer,e))};this.k_(t)}}
1674
- /**
1675
- * @license
1676
- * Copyright 2017 Google LLC
1677
- *
1678
- * Licensed under the Apache License, Version 2.0 (the "License");
1679
- * you may not use this file except in compliance with the License.
1680
- * You may obtain a copy of the License at
1681
- *
1682
- * http://www.apache.org/licenses/LICENSE-2.0
1683
- *
1684
- * Unless required by applicable law or agreed to in writing, software
1685
- * distributed under the License is distributed on an "AS IS" BASIS,
1686
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1687
- * See the License for the specific language governing permissions and
1688
- * limitations under the License.
1689
- */class ia{}class ra extends ia{constructor(e,t,n,i){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=i,this.ra=!1}ia(){if(this.ra)throw new Ot(Nt.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,n,i){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([r,s])=>this.connection.Wo(e,Rs(t,n),i,r,s)).catch(e=>{throw"FirebaseError"===e.name?(e.code===Nt.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new Ot(Nt.UNKNOWN,e.toString())})}Jo(e,t,n,i,r){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,o])=>this.connection.Jo(e,Rs(t,n),i,s,o,r)).catch(e=>{throw"FirebaseError"===e.name?(e.code===Nt.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new Ot(Nt.UNKNOWN,e.toString())})}terminate(){this.ra=!0,this.connection.terminate()}}class sa{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.sa=0,this.oa=null,this._a=!0}aa(){0===this.sa&&(this.ua("Unknown"),this.oa=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.oa=null,this.ca("Backend didn't respond within 10 seconds."),this.ua("Offline"),Promise.resolve())))}la(e){"Online"===this.state?this.ua("Unknown"):(this.sa++,this.sa>=1&&(this.ha(),this.ca(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ua("Offline")))}set(e){this.ha(),this.sa=0,"Online"===e&&(this._a=!1),this.ua(e)}ua(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}ca(e){const t=`Could not reach Cloud Firestore backend. ${e}\nThis 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._a?(Tt(t),this._a=!1):Et("OnlineStateTracker",t)}ha(){null!==this.oa&&(this.oa.cancel(),this.oa=null)}}
1690
- /**
1691
- * @license
1692
- * Copyright 2017 Google LLC
1693
- *
1694
- * Licensed under the Apache License, Version 2.0 (the "License");
1695
- * you may not use this file except in compliance with the License.
1696
- * You may obtain a copy of the License at
1697
- *
1698
- * http://www.apache.org/licenses/LICENSE-2.0
1699
- *
1700
- * Unless required by applicable law or agreed to in writing, software
1701
- * distributed under the License is distributed on an "AS IS" BASIS,
1702
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1703
- * See the License for the specific language governing permissions and
1704
- * limitations under the License.
1705
- */const oa="RemoteStore";class aa{constructor(e,t,n,i,r){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Pa=[],this.Ta=new Map,this.Ia=new Set,this.da=[],this.Ea=r,this.Ea.xo(e=>{n.enqueueAndForget(async()=>{ma(this)&&(Et(oa,"Restarting streams for network reachability change."),await async function(e){const t=xt(e);t.Ia.add(4),await la(t),t.Aa.set("Unknown"),t.Ia.delete(4),await ca(t)}(this))})}),this.Aa=new sa(n,i)}}async function ca(e){if(ma(e))for(const t of e.da)await t(!0)}async function la(e){for(const t of e.da)await t(!1)}function ua(e,t){const n=xt(e);n.Ta.has(t.targetId)||(n.Ta.set(t.targetId,t),ga(n)?pa(n):Pa(n).x_()&&da(n,t))}function ha(e,t){const n=xt(e),i=Pa(n);n.Ta.delete(t),i.x_()&&fa(n,t),0===n.Ta.size&&(i.x_()?i.B_():ma(n)&&n.Aa.set("Unknown"))}function da(e,t){if(e.Ra.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(pn.min())>0){const n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}Pa(e).H_(t)}function fa(e,t){e.Ra.$e(t),Pa(e).Y_(t)}function pa(e){e.Ra=new ms({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),Et:t=>e.Ta.get(t)||null,lt:()=>e.datastore.serializer.databaseId}),Pa(e).start(),e.Aa.aa()}function ga(e){return ma(e)&&!Pa(e).M_()&&e.Ta.size>0}function ma(e){return 0===xt(e).Ia.size}function ya(e){e.Ra=void 0}async function va(e){e.Aa.set("Online")}async function wa(e){e.Ta.forEach((t,n)=>{da(e,t)})}async function ba(e,t){ya(e),ga(e)?(e.Aa.la(t),pa(e)):e.Aa.set("Unknown")}async function _a(e,t,n){if(e.Aa.set("Online"),t instanceof ps&&2===t.state&&t.cause)try{await async function(e,t){const n=t.cause;for(const i of t.targetIds)e.Ta.has(i)&&(await e.remoteSyncer.rejectListen(i,n),e.Ta.delete(i),e.Ra.removeTarget(i))}(e,t)}catch(n){Et(oa,"Failed to remove targets %s: %s ",t.targetIds.join(","),n),await Sa(e,n)}else if(t instanceof ds?e.Ra.Ye(t):t instanceof fs?e.Ra.it(t):e.Ra.et(t),!n.isEqual(pn.min()))try{const t=await Oo(e.localStore);n.compareTo(t)>=0&&await function(e,t){const n=e.Ra.Pt(t);return n.targetChanges.forEach((n,i)=>{if(n.resumeToken.approximateByteSize()>0){const r=e.Ta.get(i);r&&e.Ta.set(i,r.withResumeToken(n.resumeToken,t))}}),n.targetMismatches.forEach((t,n)=>{const i=e.Ta.get(t);if(!i)return;e.Ta.set(t,i.withResumeToken(zn.EMPTY_BYTE_STRING,i.snapshotVersion)),fa(e,t);const r=new Qs(i.target,t,n,i.sequenceNumber);da(e,r)}),e.remoteSyncer.applyRemoteEvent(n)}(e,n)}catch(t){Et(oa,"Failed to raise snapshot:",t),await Sa(e,t)}}async function Sa(e,t,n){if(!_n(t))throw t;e.Ia.add(1),await la(e),e.Aa.set("Offline"),n||(n=()=>Oo(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{Et(oa,"Retrying IndexedDB access"),await n(),e.Ia.delete(1),await ca(e)})}function Ea(e,t){return t().catch(n=>Sa(e,n,t))}async function Ta(e){const t=xt(e),n=Da(t);let i=t.Pa.length>0?t.Pa[t.Pa.length-1].batchId:-1;for(;Ia(t);)try{const e=await Po(t.localStore,i);if(null===e){0===t.Pa.length&&n.B_();break}i=e.batchId,Ca(t,e)}catch(e){await Sa(t,e)}ka(t)&&Aa(t)}function Ia(e){return ma(e)&&e.Pa.length<10}function Ca(e,t){e.Pa.push(t);const n=Da(e);n.x_()&&n.Z_&&n.X_(t.mutations)}function ka(e){return ma(e)&&!Da(e).M_()&&e.Pa.length>0}function Aa(e){Da(e).start()}async function Ra(e){Da(e).na()}async function xa(e){const t=Da(e);for(const n of e.Pa)t.X_(n.mutations)}async function Na(e,t,n){const i=e.Pa.shift(),r=Zr.from(i,t,n);await Ea(e,()=>e.remoteSyncer.applySuccessfulWrite(r)),await Ta(e)}async function Oa(e,t){t&&Da(e).Z_&&await async function(e,t){if(function(e){return function(e){switch(e){case Nt.OK:return kt(64938);case Nt.CANCELLED:case Nt.UNKNOWN:case Nt.DEADLINE_EXCEEDED:case Nt.RESOURCE_EXHAUSTED:case Nt.INTERNAL:case Nt.UNAVAILABLE:case Nt.UNAUTHENTICATED:return!1;case Nt.INVALID_ARGUMENT:case Nt.NOT_FOUND:case Nt.ALREADY_EXISTS:case Nt.PERMISSION_DENIED:case Nt.FAILED_PRECONDITION:case Nt.ABORTED:case Nt.OUT_OF_RANGE:case Nt.UNIMPLEMENTED:case Nt.DATA_LOSS:return!0;default:return kt(15467,{code:e})}}(e)&&e!==Nt.ABORTED}(t.code)){const n=e.Pa.shift();Da(e).N_(),await Ea(e,()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t)),await Ta(e)}}(e,t),ka(e)&&Aa(e)}async function La(e,t){const n=xt(e);n.asyncQueue.verifyOperationInProgress(),Et(oa,"RemoteStore received new credentials");const i=ma(n);n.Ia.add(3),await la(n),i&&n.Aa.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.Ia.delete(3),await ca(n)}function Pa(e){return e.Va||(e.Va=function(e,t,n){const i=xt(e);return i.ia(),new ta(t,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,n)
1706
- /**
1707
- * @license
1708
- * Copyright 2018 Google LLC
1709
- *
1710
- * Licensed under the Apache License, Version 2.0 (the "License");
1711
- * you may not use this file except in compliance with the License.
1712
- * You may obtain a copy of the License at
1713
- *
1714
- * http://www.apache.org/licenses/LICENSE-2.0
1715
- *
1716
- * Unless required by applicable law or agreed to in writing, software
1717
- * distributed under the License is distributed on an "AS IS" BASIS,
1718
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1719
- * See the License for the specific language governing permissions and
1720
- * limitations under the License.
1721
- */}(e.datastore,e.asyncQueue,{Zo:va.bind(null,e),e_:wa.bind(null,e),n_:ba.bind(null,e),J_:_a.bind(null,e)}),e.da.push(async t=>{t?(e.Va.N_(),ga(e)?pa(e):e.Aa.set("Unknown")):(await e.Va.stop(),ya(e))})),e.Va}function Da(e){return e.ma||(e.ma=function(e,t,n){const i=xt(e);return i.ia(),new na(t,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,n)}(e.datastore,e.asyncQueue,{Zo:()=>Promise.resolve(),e_:Ra.bind(null,e),n_:Oa.bind(null,e),ea:xa.bind(null,e),ta:Na.bind(null,e)}),e.da.push(async t=>{t?(e.ma.N_(),await Ta(e)):(await e.ma.stop(),e.Pa.length>0&&(Et(oa,`Stopping write stream with ${e.Pa.length} pending writes`),e.Pa=[]))})),e.ma
1722
- /**
1723
- * @license
1724
- * Copyright 2017 Google LLC
1725
- *
1726
- * Licensed under the Apache License, Version 2.0 (the "License");
1727
- * you may not use this file except in compliance with the License.
1728
- * You may obtain a copy of the License at
1729
- *
1730
- * http://www.apache.org/licenses/LICENSE-2.0
1731
- *
1732
- * Unless required by applicable law or agreed to in writing, software
1733
- * distributed under the License is distributed on an "AS IS" BASIS,
1734
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1735
- * See the License for the specific language governing permissions and
1736
- * limitations under the License.
1737
- */}class Ma{constructor(e,t,n,i,r){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=i,this.removalCallback=r,this.deferred=new Lt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(e=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,n,i,r){const s=Date.now()+n,o=new Ma(e,t,s,i,r);return o.start(n),o}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new Ot(Nt.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function za(e,t){if(Tt("AsyncQueue",`${t}: ${e}`),_n(e))return new Ot(Nt.UNAVAILABLE,`${t}: ${e}`);throw e}
1738
- /**
1739
- * @license
1740
- * Copyright 2017 Google LLC
1741
- *
1742
- * Licensed under the Apache License, Version 2.0 (the "License");
1743
- * you may not use this file except in compliance with the License.
1744
- * You may obtain a copy of the License at
1745
- *
1746
- * http://www.apache.org/licenses/LICENSE-2.0
1747
- *
1748
- * Unless required by applicable law or agreed to in writing, software
1749
- * distributed under the License is distributed on an "AS IS" BASIS,
1750
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1751
- * See the License for the specific language governing permissions and
1752
- * limitations under the License.
1753
- */class Fa{static emptySet(e){return new Fa(e.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||tn.comparator(t.key,n.key):(e,t)=>tn.comparator(e.key,t.key),this.keyedMap=dr(),this.sortedSet=new xn(this.comparator)}has(e){return null!=this.keyedMap.get(e)}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,n)=>(e(t),!1))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof Fa))return!1;if(this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){const e=t.getNext().key,i=n.getNext().key;if(!e.isEqual(i))return!1}return!0}toString(){const e=[];return this.forEach(t=>{e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"}copy(e,t){const n=new Fa;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}
1754
- /**
1755
- * @license
1756
- * Copyright 2017 Google LLC
1757
- *
1758
- * Licensed under the Apache License, Version 2.0 (the "License");
1759
- * you may not use this file except in compliance with the License.
1760
- * You may obtain a copy of the License at
1761
- *
1762
- * http://www.apache.org/licenses/LICENSE-2.0
1763
- *
1764
- * Unless required by applicable law or agreed to in writing, software
1765
- * distributed under the License is distributed on an "AS IS" BASIS,
1766
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1767
- * See the License for the specific language governing permissions and
1768
- * limitations under the License.
1769
- */class Ua{constructor(){this.fa=new xn(tn.comparator)}track(e){const t=e.doc.key,n=this.fa.get(t);n?0!==e.type&&3===n.type?this.fa=this.fa.insert(t,e):3===e.type&&1!==n.type?this.fa=this.fa.insert(t,{type:n.type,doc:e.doc}):2===e.type&&2===n.type?this.fa=this.fa.insert(t,{type:2,doc:e.doc}):2===e.type&&0===n.type?this.fa=this.fa.insert(t,{type:0,doc:e.doc}):1===e.type&&0===n.type?this.fa=this.fa.remove(t):1===e.type&&2===n.type?this.fa=this.fa.insert(t,{type:1,doc:n.doc}):0===e.type&&1===n.type?this.fa=this.fa.insert(t,{type:2,doc:e.doc}):kt(63341,{At:e,ga:n}):this.fa=this.fa.insert(t,e)}pa(){const e=[];return this.fa.inorderTraversal((t,n)=>{e.push(n)}),e}}class Va{constructor(e,t,n,i,r,s,o,a,c){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=i,this.mutatedKeys=r,this.fromCache=s,this.syncStateChanged=o,this.excludesMetadataChanges=a,this.hasCachedResults=c}static fromInitialDocuments(e,t,n,i,r){const s=[];return t.forEach(e=>{s.push({type:0,doc:e})}),new Va(e,t,Fa.emptySet(t),s,n,i,!0,!1,r)}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)&&nr(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==n[e].type||!t[e].doc.isEqual(n[e].doc))return!1;return!0}}
1770
- /**
1771
- * @license
1772
- * Copyright 2017 Google LLC
1773
- *
1774
- * Licensed under the Apache License, Version 2.0 (the "License");
1775
- * you may not use this file except in compliance with the License.
1776
- * You may obtain a copy of the License at
1777
- *
1778
- * http://www.apache.org/licenses/LICENSE-2.0
1779
- *
1780
- * Unless required by applicable law or agreed to in writing, software
1781
- * distributed under the License is distributed on an "AS IS" BASIS,
1782
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1783
- * See the License for the specific language governing permissions and
1784
- * limitations under the License.
1785
- */class Ba{constructor(){this.ya=void 0,this.wa=[]}Sa(){return this.wa.some(e=>e.ba())}}class ja{constructor(){this.queries=Ha(),this.onlineState="Unknown",this.Da=new Set}terminate(){!function(e,t){const n=xt(e),i=n.queries;n.queries=Ha(),i.forEach((e,n)=>{for(const e of n.wa)e.onError(t)})}(this,new Ot(Nt.ABORTED,"Firestore shutting down"))}}function Ha(){return new cr(e=>ir(e),nr)}async function $a(e,t){const n=xt(e);let i=3;const r=t.query;let s=n.queries.get(r);s?!s.Sa()&&t.ba()&&(i=2):(s=new Ba,i=t.ba()?0:1);try{switch(i){case 0:s.ya=await n.onListen(r,!0);break;case 1:s.ya=await n.onListen(r,!1);break;case 2:await n.onFirstRemoteStoreListen(r)}}catch(e){const n=za(e,`Initialization of query '${rr(t.query)}' failed`);return void t.onError(n)}n.queries.set(r,s),s.wa.push(t),t.va(n.onlineState),s.ya&&t.Ca(s.ya)&&Wa(n)}async function qa(e,t){const n=xt(e),i=t.query;let r=3;const s=n.queries.get(i);if(s){const e=s.wa.indexOf(t);e>=0&&(s.wa.splice(e,1),0===s.wa.length?r=t.ba()?0:1:!s.Sa()&&t.ba()&&(r=2))}switch(r){case 0:return n.queries.delete(i),n.onUnlisten(i,!0);case 1:return n.queries.delete(i),n.onUnlisten(i,!1);case 2:return n.onLastRemoteStoreUnlisten(i);default:return}}function Ga(e,t){const n=xt(e);let i=!1;for(const e of t){const t=e.query,r=n.queries.get(t);if(r){for(const t of r.wa)t.Ca(e)&&(i=!0);r.ya=e}}i&&Wa(n)}function Ka(e,t,n){const i=xt(e),r=i.queries.get(t);if(r)for(const e of r.wa)e.onError(n);i.queries.delete(t)}function Wa(e){e.Da.forEach(e=>{e.next()})}var Qa,Ja;(Ja=Qa||(Qa={})).Fa="default",Ja.Cache="cache";class Ya{constructor(e,t,n){this.query=e,this.Ma=t,this.xa=!1,this.Oa=null,this.onlineState="Unknown",this.options=n||{}}Ca(e){if(!this.options.includeMetadataChanges){const t=[];for(const n of e.docChanges)3!==n.type&&t.push(n);e=new Va(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.xa?this.Na(e)&&(this.Ma.next(e),t=!0):this.Ba(e,this.onlineState)&&(this.La(e),t=!0),this.Oa=e,t}onError(e){this.Ma.error(e)}va(e){this.onlineState=e;let t=!1;return this.Oa&&!this.xa&&this.Ba(this.Oa,e)&&(this.La(this.Oa),t=!0),t}Ba(e,t){if(!e.fromCache)return!0;if(!this.ba())return!0;const n="Offline"!==t;return(!this.options.ka||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}Na(e){if(e.docChanges.length>0)return!0;const t=this.Oa&&this.Oa.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}La(e){e=Va.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.xa=!0,this.Ma.next(e)}ba(){return this.options.source!==Qa.Cache}}
1786
- /**
1787
- * @license
1788
- * Copyright 2017 Google LLC
1789
- *
1790
- * Licensed under the Apache License, Version 2.0 (the "License");
1791
- * you may not use this file except in compliance with the License.
1792
- * You may obtain a copy of the License at
1793
- *
1794
- * http://www.apache.org/licenses/LICENSE-2.0
1795
- *
1796
- * Unless required by applicable law or agreed to in writing, software
1797
- * distributed under the License is distributed on an "AS IS" BASIS,
1798
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1799
- * See the License for the specific language governing permissions and
1800
- * limitations under the License.
1801
- */class Xa{constructor(e){this.key=e}}class Za{constructor(e){this.key=e}}class ec{constructor(e,t){this.query=e,this.Ha=t,this.Ya=null,this.hasCachedResults=!1,this.current=!1,this.Za=wr(),this.mutatedKeys=wr(),this.Xa=or(e),this.eu=new Fa(this.Xa)}get tu(){return this.Ha}nu(e,t){const n=t?t.ru:new Ua,i=t?t.eu:this.eu;let r=t?t.mutatedKeys:this.mutatedKeys,s=i,o=!1;const a="F"===this.query.limitType&&i.size===this.query.limit?i.last():null,c="L"===this.query.limitType&&i.size===this.query.limit?i.first():null;if(e.inorderTraversal((e,t)=>{const l=i.get(e),u=sr(this.query,t)?t:null,h=!!l&&this.mutatedKeys.has(l.key),d=!!u&&(u.hasLocalMutations||this.mutatedKeys.has(u.key)&&u.hasCommittedMutations);let f=!1;l&&u?l.data.isEqual(u.data)?h!==d&&(n.track({type:3,doc:u}),f=!0):this.iu(l,u)||(n.track({type:2,doc:u}),f=!0,(a&&this.Xa(u,a)>0||c&&this.Xa(u,c)<0)&&(o=!0)):!l&&u?(n.track({type:0,doc:u}),f=!0):l&&!u&&(n.track({type:1,doc:l}),f=!0,(a||c)&&(o=!0)),f&&(u?(s=s.add(u),r=d?r.add(e):r.delete(e)):(s=s.delete(e),r=r.delete(e)))}),null!==this.query.limit)for(;s.size>this.query.limit;){const e="F"===this.query.limitType?s.last():s.first();s=s.delete(e.key),r=r.delete(e.key),n.track({type:1,doc:e})}return{eu:s,ru:n,Ds:o,mutatedKeys:r}}iu(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,i){const r=this.eu;this.eu=e.eu,this.mutatedKeys=e.mutatedKeys;const s=e.ru.pa();s.sort((e,t)=>function(e,t){const n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return kt(20277,{At:e})}};return n(e)-n(t)}
1802
- /**
1803
- * @license
1804
- * Copyright 2020 Google LLC
1805
- *
1806
- * Licensed under the Apache License, Version 2.0 (the "License");
1807
- * you may not use this file except in compliance with the License.
1808
- * You may obtain a copy of the License at
1809
- *
1810
- * http://www.apache.org/licenses/LICENSE-2.0
1811
- *
1812
- * Unless required by applicable law or agreed to in writing, software
1813
- * distributed under the License is distributed on an "AS IS" BASIS,
1814
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1815
- * See the License for the specific language governing permissions and
1816
- * limitations under the License.
1817
- */(e.type,t.type)||this.Xa(e.doc,t.doc)),this.su(n),i=null!=i&&i;const o=t&&!i?this.ou():[],a=0===this.Za.size&&this.current&&!i?1:0,c=a!==this.Ya;return this.Ya=a,0!==s.length||c?{snapshot:new Va(this.query,e.eu,r,s,e.mutatedKeys,0===a,c,!1,!!n&&n.resumeToken.approximateByteSize()>0),_u:o}:{_u:o}}va(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({eu:this.eu,ru:new Ua,mutatedKeys:this.mutatedKeys,Ds:!1},!1)):{_u:[]}}au(e){return!this.Ha.has(e)&&!!this.eu.has(e)&&!this.eu.get(e).hasLocalMutations}su(e){e&&(e.addedDocuments.forEach(e=>this.Ha=this.Ha.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.Ha=this.Ha.delete(e)),this.current=e.current)}ou(){if(!this.current)return[];const e=this.Za;this.Za=wr(),this.eu.forEach(e=>{this.au(e.key)&&(this.Za=this.Za.add(e.key))});const t=[];return e.forEach(e=>{this.Za.has(e)||t.push(new Za(e))}),this.Za.forEach(n=>{e.has(n)||t.push(new Xa(n))}),t}uu(e){this.Ha=e.qs,this.Za=wr();const t=this.nu(e.documents);return this.applyChanges(t,!0)}cu(){return Va.fromInitialDocuments(this.query,this.eu,this.mutatedKeys,0===this.Ya,this.hasCachedResults)}}const tc="SyncEngine";class nc{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class ic{constructor(e){this.key=e,this.lu=!1}}class rc{constructor(e,t,n,i,r,s){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=i,this.currentUser=r,this.maxConcurrentLimboResolutions=s,this.hu={},this.Pu=new cr(e=>ir(e),nr),this.Tu=new Map,this.Iu=new Set,this.du=new xn(tn.comparator),this.Eu=new Map,this.Au=new mo,this.Ru={},this.Vu=new Map,this.mu=io.ur(),this.onlineState="Unknown",this.fu=void 0}get isPrimaryClient(){return!0===this.fu}}async function sc(e,t,n=!0){const i=Cc(e);let r;const s=i.Pu.get(t);return s?(i.sharedClientState.addLocalQueryTarget(s.targetId),r=s.view.cu()):r=await ac(i,t,n,!0),r}async function oc(e,t){const n=Cc(e);await ac(n,t,!0,!1)}async function ac(e,t,n,i){const r=await function(e,t){const n=xt(e);return n.persistence.runTransaction("Allocate target","readwrite",e=>{let i;return n.hi.getTargetData(e,t).next(r=>r?(i=r,bn.resolve(i)):n.hi.allocateTargetId(e).next(r=>(i=new Qs(t,r,"TargetPurposeListen",e.currentSequenceNumber),n.hi.addTargetData(e,i).next(()=>i))))}).then(e=>{const i=n.Fs.get(e.targetId);return(null===i||e.snapshotVersion.compareTo(i.snapshotVersion)>0)&&(n.Fs=n.Fs.insert(e.targetId,e),n.Ms.set(t,e.targetId)),e})}(e.localStore,Zi(t)),s=r.targetId,o=e.sharedClientState.addLocalQueryTarget(s,n);let a;return i&&(a=await async function(e,t,n,i,r){e.gu=(t,n,i)=>async function(e,t,n,i){let r=t.view.nu(n);r.Ds&&(r=await Mo(e.localStore,t.query,!1).then(({documents:e})=>t.view.nu(e,r)));const s=i&&i.targetChanges.get(t.targetId),o=i&&null!=i.targetMismatches.get(t.targetId),a=t.view.applyChanges(r,e.isPrimaryClient,s,o);return bc(e,t.targetId,a._u),a.snapshot}(e,t,n,i);const s=await Mo(e.localStore,t,!0),o=new ec(t,s.qs),a=o.nu(s.documents),c=hs.createSynthesizedTargetChangeForCurrentChange(n,i&&"Offline"!==e.onlineState,r),l=o.applyChanges(a,e.isPrimaryClient,c);bc(e,n,l._u);const u=new nc(t,n,o);return e.Pu.set(t,u),e.Tu.has(n)?e.Tu.get(n).push(t):e.Tu.set(n,[t]),l.snapshot}(e,t,s,"current"===o,r.resumeToken)),e.isPrimaryClient&&n&&ua(e.remoteStore,r),a}async function cc(e,t,n){const i=xt(e),r=i.Pu.get(t),s=i.Tu.get(r.targetId);if(s.length>1)return i.Tu.set(r.targetId,s.filter(e=>!nr(e,t))),void i.Pu.delete(t);i.isPrimaryClient?(i.sharedClientState.removeLocalQueryTarget(r.targetId),i.sharedClientState.isActiveQueryTarget(r.targetId)||await Do(i.localStore,r.targetId,!1).then(()=>{i.sharedClientState.clearQueryState(r.targetId),n&&ha(i.remoteStore,r.targetId),vc(i,r.targetId)}).catch(wn)):(vc(i,r.targetId),await Do(i.localStore,r.targetId,!0))}async function lc(e,t){const n=xt(e),i=n.Pu.get(t),r=n.Tu.get(i.targetId);n.isPrimaryClient&&1===r.length&&(n.sharedClientState.removeLocalQueryTarget(i.targetId),ha(n.remoteStore,i.targetId))}async function uc(e,t,n){const i=function(e){const t=xt(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=pc.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=gc.bind(null,t),t}(e);try{const e=await function(e,t){const n=xt(e),i=fn.now(),r=t.reduce((e,t)=>e.add(t.key),wr());let s,o;return n.persistence.runTransaction("Locally write mutations","readwrite",e=>{let a=ur(),c=wr();return n.Os.getEntries(e,r).next(e=>{a=e,a.forEach((e,t)=>{t.isValidDocument()||(c=c.add(e))})}).next(()=>n.localDocuments.getOverlayedDocuments(e,a)).next(r=>{s=r;const o=[];for(const e of t){const t=Hr(e,s.get(e.key).overlayedDocument);null!=t&&o.push(new Gr(e.key,t,bi(t.value.mapValue),zr.exists(!0)))}return n.mutationQueue.addMutationBatch(e,i,o,t)}).next(t=>{o=t;const i=t.applyToLocalDocumentSet(s,c);return n.documentOverlayCache.saveOverlays(e,t.batchId,i)})}).then(()=>({batchId:o.batchId,changes:fr(s)}))}(i.localStore,t);i.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let i=e.Ru[e.currentUser.toKey()];i||(i=new xn(qt)),i=i.insert(t,n),e.Ru[e.currentUser.toKey()]=i}(i,e.batchId,n),await Ec(i,e.changes),await Ta(i.remoteStore)}catch(e){const t=za(e,"Failed to persist write");n.reject(t)}}async function hc(e,t){const n=xt(e);try{const e=await Lo(n.localStore,t);t.targetChanges.forEach((e,t)=>{const i=n.Eu.get(t);i&&(Rt(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1,22616),e.addedDocuments.size>0?i.lu=!0:e.modifiedDocuments.size>0?Rt(i.lu,14607):e.removedDocuments.size>0&&(Rt(i.lu,42227),i.lu=!1))}),await Ec(n,e,t)}catch(e){await wn(e)}}function dc(e,t,n){const i=xt(e);if(i.isPrimaryClient&&0===n||!i.isPrimaryClient&&1===n){const e=[];i.Pu.forEach((n,i)=>{const r=i.view.va(t);r.snapshot&&e.push(r.snapshot)}),function(e,t){const n=xt(e);n.onlineState=t;let i=!1;n.queries.forEach((e,n)=>{for(const e of n.wa)e.va(t)&&(i=!0)}),i&&Wa(n)}(i.eventManager,t),e.length&&i.hu.J_(e),i.onlineState=t,i.isPrimaryClient&&i.sharedClientState.setOnlineState(t)}}async function fc(e,t,n){const i=xt(e);i.sharedClientState.updateQueryState(t,"rejected",n);const r=i.Eu.get(t),s=r&&r.key;if(s){let e=new xn(tn.comparator);e=e.insert(s,_i.newNoDocument(s,pn.min()));const n=wr().add(s),r=new us(pn.min(),new Map,new xn(qt),e,n);await hc(i,r),i.du=i.du.remove(s),i.Eu.delete(t),Sc(i)}else await Do(i.localStore,t,!1).then(()=>vc(i,t,n)).catch(wn)}async function pc(e,t){const n=xt(e),i=t.batch.batchId;try{const e=await function(e,t){const n=xt(e);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{const i=t.batch.keys(),r=n.Os.newChangeBuffer({trackRemovals:!0});return function(e,t,n,i){const r=n.batch,s=r.keys();let o=bn.resolve();return s.forEach(e=>{o=o.next(()=>i.getEntry(t,e)).next(t=>{const s=n.docVersions.get(e);Rt(null!==s,48541),t.version.compareTo(s)<0&&(r.applyToRemoteDocument(t,n),t.isValidDocument()&&(t.setReadTime(n.commitVersion),i.addEntry(t)))})}),o.next(()=>e.mutationQueue.removeMutationBatch(t,r))}(n,e,t,r).next(()=>r.apply(e)).next(()=>n.mutationQueue.performConsistencyCheck(e)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(e,i,t.batch.batchId)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=wr();for(let n=0;n<e.mutationResults.length;++n)e.mutationResults[n].transformResults.length>0&&(t=t.add(e.batch.mutations[n].key));return t}(t))).next(()=>n.localDocuments.getDocuments(e,i))})}(n.localStore,t);yc(n,i,null),mc(n,i),n.sharedClientState.updateMutationState(i,"acknowledged"),await Ec(n,e)}catch(e){await wn(e)}}async function gc(e,t,n){const i=xt(e);try{const e=await function(e,t){const n=xt(e);return n.persistence.runTransaction("Reject batch","readwrite-primary",e=>{let i;return n.mutationQueue.lookupMutationBatch(e,t).next(t=>(Rt(null!==t,37113),i=t.keys(),n.mutationQueue.removeMutationBatch(e,t))).next(()=>n.mutationQueue.performConsistencyCheck(e)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(e,i,t)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,i)).next(()=>n.localDocuments.getDocuments(e,i))})}(i.localStore,t);yc(i,t,n),mc(i,t),i.sharedClientState.updateMutationState(t,"rejected",n),await Ec(i,e)}catch(n){await wn(n)}}function mc(e,t){(e.Vu.get(t)||[]).forEach(e=>{e.resolve()}),e.Vu.delete(t)}function yc(e,t,n){const i=xt(e);let r=i.Ru[i.currentUser.toKey()];if(r){const e=r.get(t);e&&(n?e.reject(n):e.resolve(),r=r.remove(t)),i.Ru[i.currentUser.toKey()]=r}}function vc(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(const i of e.Tu.get(t))e.Pu.delete(i),n&&e.hu.pu(i,n);e.Tu.delete(t),e.isPrimaryClient&&e.Au.zr(t).forEach(t=>{e.Au.containsKey(t)||wc(e,t)})}function wc(e,t){e.Iu.delete(t.path.canonicalString());const n=e.du.get(t);null!==n&&(ha(e.remoteStore,n),e.du=e.du.remove(t),e.Eu.delete(n),Sc(e))}function bc(e,t,n){for(const i of n)i instanceof Xa?(e.Au.addReference(i.key,t),_c(e,i)):i instanceof Za?(Et(tc,"Document no longer in limbo: "+i.key),e.Au.removeReference(i.key,t),e.Au.containsKey(i.key)||wc(e,i.key)):kt(19791,{yu:i})}function _c(e,t){const n=t.key,i=n.path.canonicalString();e.du.get(n)||e.Iu.has(i)||(Et(tc,"New document in limbo: "+n),e.Iu.add(i),Sc(e))}function Sc(e){for(;e.Iu.size>0&&e.du.size<e.maxConcurrentLimboResolutions;){const t=e.Iu.values().next().value;e.Iu.delete(t);const n=new tn(Xt.fromString(t)),i=e.mu.next();e.Eu.set(i,new ic(n)),e.du=e.du.insert(n,i),ua(e.remoteStore,new Qs(Zi(Qi(n.path)),i,"TargetPurposeLimboResolution",Sn.ue))}}async function Ec(e,t,n){const i=xt(e),r=[],s=[],o=[];i.Pu.isEmpty()||(i.Pu.forEach((e,a)=>{o.push(i.gu(a,t,n).then(e=>{var t;if((e||n)&&i.isPrimaryClient){const r=e?!e.fromCache:null===(t=null==n?void 0:n.targetChanges.get(a.targetId))||void 0===t?void 0:t.current;i.sharedClientState.updateQueryState(a.targetId,r?"current":"not-current")}if(e){r.push(e);const t=Co.Es(a.targetId,e);s.push(t)}}))}),await Promise.all(o),i.hu.J_(r),await async function(e,t){const n=xt(e);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",e=>bn.forEach(t,t=>bn.forEach(t.Is,i=>n.persistence.referenceDelegate.addReference(e,t.targetId,i)).next(()=>bn.forEach(t.ds,i=>n.persistence.referenceDelegate.removeReference(e,t.targetId,i)))))}catch(e){if(!_n(e))throw e;Et(Ro,"Failed to update sequence numbers: "+e)}for(const e of t){const t=e.targetId;if(!e.fromCache){const e=n.Fs.get(t),i=e.snapshotVersion,r=e.withLastLimboFreeSnapshotVersion(i);n.Fs=n.Fs.insert(t,r)}}}(i.localStore,s))}async function Tc(e,t){const n=xt(e);if(!n.currentUser.isEqual(t)){Et(tc,"User change. New user:",t.toKey());const e=await No(n.localStore,t);n.currentUser=t,function(e,t){e.Vu.forEach(e=>{e.forEach(e=>{e.reject(new Ot(Nt.CANCELLED,t))})}),e.Vu.clear()}(n,"'waitForPendingWrites' promise is rejected due to a user change."),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await Ec(n,e.Bs)}}function Ic(e,t){const n=xt(e),i=n.Eu.get(t);if(i&&i.lu)return wr().add(i.key);{let e=wr();const i=n.Tu.get(t);if(!i)return e;for(const t of i){const i=n.Pu.get(t);e=e.unionWith(i.view.tu)}return e}}function Cc(e){const t=xt(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=hc.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=Ic.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=fc.bind(null,t),t.hu.J_=Ga.bind(null,t.eventManager),t.hu.pu=Ka.bind(null,t.eventManager),t}class kc{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Yo(e.databaseInfo.databaseId),this.sharedClientState=this.bu(e),this.persistence=this.Du(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Cu(e,this.localStore),this.indexBackfillerScheduler=this.Fu(e,this.localStore)}Cu(e,t){return null}Fu(e,t){return null}vu(e){return function(e,t,n,i){return new xo(e,t,n,i)}(this.persistence,new Ao,e.initialUser,this.serializer)}Du(e){return new So(To.Vi,this.serializer)}bu(e){return new Fo}async terminate(){var e,t;null===(e=this.gcScheduler)||void 0===e||e.stop(),null===(t=this.indexBackfillerScheduler)||void 0===t||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}kc.provider={build:()=>new kc};class Ac extends kc{constructor(e){super(),this.cacheSizeBytes=e}Cu(e,t){Rt(this.persistence.referenceDelegate instanceof Io,46915);const n=this.persistence.referenceDelegate.garbageCollector;return new ao(n,e.asyncQueue,t)}Du(e){const t=void 0!==this.cacheSizeBytes?no.withCacheSize(this.cacheSizeBytes):no.DEFAULT;return new So(e=>Io.Vi(e,t),this.serializer)}}class Rc{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=e=>dc(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=Tc.bind(null,this.syncEngine),await async function(e,t){const n=xt(e);t?(n.Ia.delete(2),await ca(n)):t||(n.Ia.add(2),await la(n),n.Aa.set("Unknown"))}(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new ja}createDatastore(e){const t=Yo(e.databaseInfo.databaseId),n=function(e){return new Qo(e)}(e.databaseInfo);return function(e,t,n,i){return new ra(e,t,n,i)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,i,r){return new aa(e,t,n,i,r)}(this.localStore,this.datastore,e.asyncQueue,e=>dc(this.syncEngine,e,0),Bo.C()?new Bo:new Uo)}createSyncEngine(e,t){return function(e,t,n,i,r,s,o){const a=new rc(e,t,n,i,r,s);return o&&(a.fu=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(e){const t=xt(e);Et(oa,"RemoteStore shutting down."),t.Ia.add(5),await la(t),t.Ea.shutdown(),t.Aa.set("Unknown")}(this.remoteStore),null===(e=this.datastore)||void 0===e||e.terminate(),null===(t=this.eventManager)||void 0===t||t.terminate()}}Rc.provider={build:()=>new Rc};
1818
- /**
1819
- * @license
1820
- * Copyright 2020 Google LLC
1821
- *
1822
- * Licensed under the Apache License, Version 2.0 (the "License");
1823
- * you may not use this file except in compliance with the License.
1824
- * You may obtain a copy of the License at
1825
- *
1826
- * http://www.apache.org/licenses/LICENSE-2.0
1827
- *
1828
- * Unless required by applicable law or agreed to in writing, software
1829
- * distributed under the License is distributed on an "AS IS" BASIS,
1830
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1831
- * See the License for the specific language governing permissions and
1832
- * limitations under the License.
1833
- */
1834
- /**
1835
- * @license
1836
- * Copyright 2017 Google LLC
1837
- *
1838
- * Licensed under the Apache License, Version 2.0 (the "License");
1839
- * you may not use this file except in compliance with the License.
1840
- * You may obtain a copy of the License at
1841
- *
1842
- * http://www.apache.org/licenses/LICENSE-2.0
1843
- *
1844
- * Unless required by applicable law or agreed to in writing, software
1845
- * distributed under the License is distributed on an "AS IS" BASIS,
1846
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1847
- * See the License for the specific language governing permissions and
1848
- * limitations under the License.
1849
- */
1850
- class xc{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.xu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.xu(this.observer.error,e):Tt("Uncaught Error in snapshot listener:",e.toString()))}Ou(){this.muted=!0}xu(e,t){setTimeout(()=>{this.muted||e(t)},0)}}
1851
- /**
1852
- * @license
1853
- * Copyright 2017 Google LLC
1854
- *
1855
- * Licensed under the Apache License, Version 2.0 (the "License");
1856
- * you may not use this file except in compliance with the License.
1857
- * You may obtain a copy of the License at
1858
- *
1859
- * http://www.apache.org/licenses/LICENSE-2.0
1860
- *
1861
- * Unless required by applicable law or agreed to in writing, software
1862
- * distributed under the License is distributed on an "AS IS" BASIS,
1863
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1864
- * See the License for the specific language governing permissions and
1865
- * limitations under the License.
1866
- */const Nc="FirestoreClient";class Oc{constructor(e,t,n,i,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=i,this.user=wt.UNAUTHENTICATED,this.clientId=$t.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=r,this.authCredentials.start(n,async e=>{Et(Nc,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(n,e=>(Et(Nc,"Received new app check token=",e),this.appCheckCredentialListener(e,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 Lt;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const n=za(t,"Failed to shutdown persistence");e.reject(n)}}),e.promise}}async function Lc(e,t){e.asyncQueue.verifyOperationInProgress(),Et(Nc,"Initializing OfflineComponentProvider");const n=e.configuration;await t.initialize(n);let i=n.initialUser;e.setCredentialChangeListener(async e=>{i.isEqual(e)||(await No(t.localStore,e),i=e)}),t.persistence.setDatabaseDeletedListener(()=>{It("Terminating Firestore due to IndexedDb database deletion"),e.terminate().then(()=>{Et("Terminating Firestore due to IndexedDb database deletion completed successfully")}).catch(e=>{It("Terminating Firestore due to IndexedDb database deletion failed",e)})}),e._offlineComponents=t}async function Pc(e,t){e.asyncQueue.verifyOperationInProgress();const n=await async function(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){Et(Nc,"Using user provided OfflineComponentProvider");try{await Lc(e,e._uninitializedComponentsProvider._offline)}catch(t){const n=t;if(!function(e){return"FirebaseError"===e.name?e.code===Nt.FAILED_PRECONDITION||e.code===Nt.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&e instanceof DOMException)||22===e.code||20===e.code||11===e.code}(n))throw n;It("Error using user provided cache. Falling back to memory cache: "+n),await Lc(e,new kc)}}else Et(Nc,"Using default OfflineComponentProvider"),await Lc(e,new Ac(void 0));return e._offlineComponents}(e);Et(Nc,"Initializing OnlineComponentProvider"),await t.initialize(n,e.configuration),e.setCredentialChangeListener(e=>La(t.remoteStore,e)),e.setAppCheckTokenChangeListener((e,n)=>La(t.remoteStore,n)),e._onlineComponents=t}async function Dc(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(Et(Nc,"Using user provided OnlineComponentProvider"),await Pc(e,e._uninitializedComponentsProvider._online)):(Et(Nc,"Using default OnlineComponentProvider"),await Pc(e,new Rc))),e._onlineComponents}async function Mc(e){const t=await Dc(e),n=t.eventManager;return n.onListen=sc.bind(null,t.syncEngine),n.onUnlisten=cc.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=oc.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=lc.bind(null,t.syncEngine),n}
1867
- /**
1868
- * @license
1869
- * Copyright 2023 Google LLC
1870
- *
1871
- * Licensed under the Apache License, Version 2.0 (the "License");
1872
- * you may not use this file except in compliance with the License.
1873
- * You may obtain a copy of the License at
1874
- *
1875
- * http://www.apache.org/licenses/LICENSE-2.0
1876
- *
1877
- * Unless required by applicable law or agreed to in writing, software
1878
- * distributed under the License is distributed on an "AS IS" BASIS,
1879
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1880
- * See the License for the specific language governing permissions and
1881
- * limitations under the License.
1882
- */
1883
- function zc(e){const t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t
1884
- /**
1885
- * @license
1886
- * Copyright 2020 Google LLC
1887
- *
1888
- * Licensed under the Apache License, Version 2.0 (the "License");
1889
- * you may not use this file except in compliance with the License.
1890
- * You may obtain a copy of the License at
1891
- *
1892
- * http://www.apache.org/licenses/LICENSE-2.0
1893
- *
1894
- * Unless required by applicable law or agreed to in writing, software
1895
- * distributed under the License is distributed on an "AS IS" BASIS,
1896
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1897
- * See the License for the specific language governing permissions and
1898
- * limitations under the License.
1899
- */}const Fc=new Map,Uc="firestore.googleapis.com",Vc=!0;
1900
- /**
1901
- * @license
1902
- * Copyright 2020 Google LLC
1903
- *
1904
- * Licensed under the Apache License, Version 2.0 (the "License");
1905
- * you may not use this file except in compliance with the License.
1906
- * You may obtain a copy of the License at
1907
- *
1908
- * http://www.apache.org/licenses/LICENSE-2.0
1909
- *
1910
- * Unless required by applicable law or agreed to in writing, software
1911
- * distributed under the License is distributed on an "AS IS" BASIS,
1912
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1913
- * See the License for the specific language governing permissions and
1914
- * limitations under the License.
1915
- */class Bc{constructor(e){var t,n;if(void 0===e.host){if(void 0!==e.ssl)throw new Ot(Nt.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=Uc,this.ssl=Vc}else this.host=e.host,this.ssl=null!==(t=e.ssl)&&void 0!==t?t:Vc;if(this.isUsingEmulator=void 0!==e.emulatorOptions,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,void 0===e.cacheSizeBytes)this.cacheSizeBytes=to;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new Ot(Nt.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}(function(e,t,n,i){if(!0===t&&!0===i)throw new Ot(Nt.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)})("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=zc(null!==(n=e.experimentalLongPollingOptions)&&void 0!==n?n:{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new Ot(Nt.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new Ot(Nt.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new Ot(Nt.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}
1916
- /**
1917
- * @license
1918
- * Copyright 2020 Google LLC
1919
- *
1920
- * Licensed under the Apache License, Version 2.0 (the "License");
1921
- * you may not use this file except in compliance with the License.
1922
- * You may obtain a copy of the License at
1923
- *
1924
- * http://www.apache.org/licenses/LICENSE-2.0
1925
- *
1926
- * Unless required by applicable law or agreed to in writing, software
1927
- * distributed under the License is distributed on an "AS IS" BASIS,
1928
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1929
- * See the License for the specific language governing permissions and
1930
- * limitations under the License.
1931
- */(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(e,t){return e.timeoutSeconds===t.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class jc{constructor(e,t,n,i){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=i,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Bc({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new Ot(Nt.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"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new Ot(Nt.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 Bc(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new Dt;switch(e.type){case"firstParty":return new Ut(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new Ot(Nt.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){const t=Fc.get(e);t&&(Et("ComponentProvider","Removing Datastore"),Fc.delete(e),t.terminate())}(this),Promise.resolve()}}function Hc(e,t,n,i={}){var r;e=cn(e,jc);const s=p(t),a=e._getSettings(),c=Object.assign(Object.assign({},a),{emulatorOptions:e._getEmulatorOptions()}),l=`${t}:${n}`;s&&(g(`https://${l}`),v("Firestore",!0)),a.host!==Uc&&a.host!==l&&It("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const u=Object.assign(Object.assign({},a),{host:l,ssl:s,emulatorOptions:i});if(!T(u,c)&&(e._setSettings(u),i.mockUserToken)){let t,n;if("string"==typeof i.mockUserToken)t=i.mockUserToken,n=wt.MOCK_USER;else{t=function(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=t||"demo-project",i=e.iat||0,r=e.sub||e.user_id;if(!r)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const s=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:i,exp:i+3600,auth_time:i,sub:r,user_id:r,firebase:{sign_in_provider:"custom",identities:{}}},e);return[o(JSON.stringify({alg:"none",type:"JWT"})),o(JSON.stringify(s)),""].join(".")}(i.mockUserToken,null===(r=e._app)||void 0===r?void 0:r.options.projectId);const s=i.mockUserToken.sub||i.mockUserToken.user_id;if(!s)throw new Ot(Nt.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new wt(s)}e._authCredentials=new Mt(new Pt(t,n))}}
1932
- /**
1933
- * @license
1934
- * Copyright 2020 Google LLC
1935
- *
1936
- * Licensed under the Apache License, Version 2.0 (the "License");
1937
- * you may not use this file except in compliance with the License.
1938
- * You may obtain a copy of the License at
1939
- *
1940
- * http://www.apache.org/licenses/LICENSE-2.0
1941
- *
1942
- * Unless required by applicable law or agreed to in writing, software
1943
- * distributed under the License is distributed on an "AS IS" BASIS,
1944
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1945
- * See the License for the specific language governing permissions and
1946
- * limitations under the License.
1947
- */class $c{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new $c(this.firestore,e,this._query)}}class qc{constructor(e,t,n){this.converter=t,this._key=n,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Gc(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new qc(this.firestore,e,this._key)}toJSON(){return{type:qc._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,n){if(un(t,qc._jsonSchema))return new qc(e,n||null,new tn(Xt.fromString(t.referencePath)))}}qc._jsonSchemaVersion="firestore/documentReference/1.0",qc._jsonSchema={type:ln("string",qc._jsonSchemaVersion),referencePath:ln("string")};class Gc extends $c{constructor(e,t,n){super(e,t,Qi(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new qc(this.firestore,null,new tn(e))}withConverter(e){return new Gc(this.firestore,e,this._path)}}function Kc(e,t,...n){if(e=N(e),nn("collection","path",t),e instanceof jc){const i=Xt.fromString(t,...n);return sn(i),new Gc(e,null,i)}{if(!(e instanceof qc||e instanceof Gc))throw new Ot(Nt.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const i=e._path.child(Xt.fromString(t,...n));return sn(i),new Gc(e.firestore,null,i)}}function Wc(e,t,...n){if(e=N(e),1===arguments.length&&(t=$t.newId()),nn("doc","path",t),e instanceof jc){const i=Xt.fromString(t,...n);return rn(i),new qc(e,null,new tn(i))}{if(!(e instanceof qc||e instanceof Gc))throw new Ot(Nt.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const i=e._path.child(Xt.fromString(t,...n));return rn(i),new qc(e.firestore,e instanceof Gc?e.converter:null,new tn(i))}}
1948
- /**
1949
- * @license
1950
- * Copyright 2020 Google LLC
1951
- *
1952
- * Licensed under the Apache License, Version 2.0 (the "License");
1953
- * you may not use this file except in compliance with the License.
1954
- * You may obtain a copy of the License at
1955
- *
1956
- * http://www.apache.org/licenses/LICENSE-2.0
1957
- *
1958
- * Unless required by applicable law or agreed to in writing, software
1959
- * distributed under the License is distributed on an "AS IS" BASIS,
1960
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1961
- * See the License for the specific language governing permissions and
1962
- * limitations under the License.
1963
- */const Qc="AsyncQueue";class Jc{constructor(e=Promise.resolve()){this.Zu=[],this.Xu=!1,this.ec=[],this.tc=null,this.nc=!1,this.rc=!1,this.sc=[],this.F_=new Xo(this,"async_queue_retry"),this.oc=()=>{const e=Jo();e&&Et(Qc,"Visibility state changed to "+e.visibilityState),this.F_.y_()},this._c=e;const t=Jo();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.oc)}get isShuttingDown(){return this.Xu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.ac(),this.uc(e)}enterRestrictedMode(e){if(!this.Xu){this.Xu=!0,this.rc=e||!1;const t=Jo();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.oc)}}enqueue(e){if(this.ac(),this.Xu)return new Promise(()=>{});const t=new Lt;return this.uc(()=>this.Xu&&this.rc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Zu.push(e),this.cc()))}async cc(){if(0!==this.Zu.length){try{await this.Zu[0](),this.Zu.shift(),this.F_.reset()}catch(e){if(!_n(e))throw e;Et(Qc,"Operation failed with retryable error: "+e)}this.Zu.length>0&&this.F_.g_(()=>this.cc())}}uc(e){const t=this._c.then(()=>(this.nc=!0,e().catch(e=>{throw this.tc=e,this.nc=!1,Tt("INTERNAL UNHANDLED ERROR: ",Yc(e)),e}).then(e=>(this.nc=!1,e))));return this._c=t,t}enqueueAfterDelay(e,t,n){this.ac(),this.sc.indexOf(e)>-1&&(t=0);const i=Ma.createAndSchedule(this,e,t,n,e=>this.lc(e));return this.ec.push(i),i}ac(){this.tc&&kt(47125,{hc:Yc(this.tc)})}verifyOperationInProgress(){}async Pc(){let e;do{e=this._c,await e}while(e!==this._c)}Tc(e){for(const t of this.ec)if(t.timerId===e)return!0;return!1}Ic(e){return this.Pc().then(()=>{this.ec.sort((e,t)=>e.targetTimeMs-t.targetTimeMs);for(const t of this.ec)if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.Pc()})}dc(e){this.sc.push(e)}lc(e){const t=this.ec.indexOf(e);this.ec.splice(t,1)}}function Yc(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t
1964
- /**
1965
- * @license
1966
- * Copyright 2017 Google LLC
1967
- *
1968
- * Licensed under the Apache License, Version 2.0 (the "License");
1969
- * you may not use this file except in compliance with the License.
1970
- * You may obtain a copy of the License at
1971
- *
1972
- * http://www.apache.org/licenses/LICENSE-2.0
1973
- *
1974
- * Unless required by applicable law or agreed to in writing, software
1975
- * distributed under the License is distributed on an "AS IS" BASIS,
1976
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1977
- * See the License for the specific language governing permissions and
1978
- * limitations under the License.
1979
- */}function Xc(e){return function(e,t){if("object"!=typeof e||null===e)return!1;const n=e;for(const e of t)if(e in n&&"function"==typeof n[e])return!0;return!1}
1980
- /**
1981
- * @license
1982
- * Copyright 2020 Google LLC
1983
- *
1984
- * Licensed under the Apache License, Version 2.0 (the "License");
1985
- * you may not use this file except in compliance with the License.
1986
- * You may obtain a copy of the License at
1987
- *
1988
- * http://www.apache.org/licenses/LICENSE-2.0
1989
- *
1990
- * Unless required by applicable law or agreed to in writing, software
1991
- * distributed under the License is distributed on an "AS IS" BASIS,
1992
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1993
- * See the License for the specific language governing permissions and
1994
- * limitations under the License.
1995
- */(e,["next","error","complete"])}class Zc extends jc{constructor(e,t,n,i){super(e,t,n,i),this.type="firestore",this._queue=new Jc,this._persistenceKey=(null==i?void 0:i.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new Jc(e),this._firestoreClient=void 0,await e}}}function el(e,t){const n="object"==typeof e?e:Ke(),i="string"==typeof e?e:Jn,r=Be(n,"firestore").getImmediate({identifier:i});if(!r._initialized){const e=(e=>{const t=u(e);if(!t)return;const n=t.lastIndexOf(":");if(n<=0||n+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const i=parseInt(t.substring(n+1),10);return"["===t[0]?[t.substring(1,n-1),i]:[t.substring(0,n),i]})("firestore");e&&Hc(r,...e)}return r}function tl(e){if(e._terminated)throw new Ot(Nt.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||function(e){var t,n,i;const r=e._freezeSettings(),s=function(e,t,n,i){return new Qn(e,t,n,i.host,i.ssl,i.experimentalForceLongPolling,i.experimentalAutoDetectLongPolling,zc(i.experimentalLongPollingOptions),i.useFetchStreams,i.isUsingEmulator)}(e._databaseId,(null===(t=e._app)||void 0===t?void 0:t.options.appId)||"",e._persistenceKey,r);e._componentsProvider||(null===(n=r.localCache)||void 0===n?void 0:n._offlineComponentProvider)&&(null===(i=r.localCache)||void 0===i?void 0:i._onlineComponentProvider)&&(e._componentsProvider={_offline:r.localCache._offlineComponentProvider,_online:r.localCache._onlineComponentProvider}),e._firestoreClient=new Oc(e._authCredentials,e._appCheckCredentials,e._queue,s,e._componentsProvider&&function(e){const t=null==e?void 0:e._online.build();return{_offline:null==e?void 0:e._offline.build(t),_online:t}}(e._componentsProvider))}
1996
- /**
1997
- * @license
1998
- * Copyright 2020 Google LLC
1999
- *
2000
- * Licensed under the Apache License, Version 2.0 (the "License");
2001
- * you may not use this file except in compliance with the License.
2002
- * You may obtain a copy of the License at
2003
- *
2004
- * http://www.apache.org/licenses/LICENSE-2.0
2005
- *
2006
- * Unless required by applicable law or agreed to in writing, software
2007
- * distributed under the License is distributed on an "AS IS" BASIS,
2008
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2009
- * See the License for the specific language governing permissions and
2010
- * limitations under the License.
2011
- */(e),e._firestoreClient}class nl{constructor(e){this._byteString=e}static fromBase64String(e){try{return new nl(zn.fromBase64String(e))}catch(e){throw new Ot(Nt.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new nl(zn.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)}toJSON(){return{type:nl._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(un(e,nl._jsonSchema))return nl.fromBase64String(e.bytes)}}nl._jsonSchemaVersion="firestore/bytes/1.0",nl._jsonSchema={type:ln("string",nl._jsonSchemaVersion),bytes:ln("string")};
2012
- /**
2013
- * @license
2014
- * Copyright 2020 Google LLC
2015
- *
2016
- * Licensed under the Apache License, Version 2.0 (the "License");
2017
- * you may not use this file except in compliance with the License.
2018
- * You may obtain a copy of the License at
2019
- *
2020
- * http://www.apache.org/licenses/LICENSE-2.0
2021
- *
2022
- * Unless required by applicable law or agreed to in writing, software
2023
- * distributed under the License is distributed on an "AS IS" BASIS,
2024
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2025
- * See the License for the specific language governing permissions and
2026
- * limitations under the License.
2027
- */
2028
- class il{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new Ot(Nt.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new en(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}function rl(){return new il(Jt)}
2029
- /**
2030
- * @license
2031
- * Copyright 2020 Google LLC
2032
- *
2033
- * Licensed under the Apache License, Version 2.0 (the "License");
2034
- * you may not use this file except in compliance with the License.
2035
- * You may obtain a copy of the License at
2036
- *
2037
- * http://www.apache.org/licenses/LICENSE-2.0
2038
- *
2039
- * Unless required by applicable law or agreed to in writing, software
2040
- * distributed under the License is distributed on an "AS IS" BASIS,
2041
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2042
- * See the License for the specific language governing permissions and
2043
- * limitations under the License.
2044
- */class sl{constructor(e){this._methodName=e}}
2045
- /**
2046
- * @license
2047
- * Copyright 2017 Google LLC
2048
- *
2049
- * Licensed under the Apache License, Version 2.0 (the "License");
2050
- * you may not use this file except in compliance with the License.
2051
- * You may obtain a copy of the License at
2052
- *
2053
- * http://www.apache.org/licenses/LICENSE-2.0
2054
- *
2055
- * Unless required by applicable law or agreed to in writing, software
2056
- * distributed under the License is distributed on an "AS IS" BASIS,
2057
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2058
- * See the License for the specific language governing permissions and
2059
- * limitations under the License.
2060
- */class ol{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new Ot(Nt.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new Ot(Nt.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}_compareTo(e){return qt(this._lat,e._lat)||qt(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:ol._jsonSchemaVersion}}static fromJSON(e){if(un(e,ol._jsonSchema))return new ol(e.latitude,e.longitude)}}ol._jsonSchemaVersion="firestore/geoPoint/1.0",ol._jsonSchema={type:ln("string",ol._jsonSchemaVersion),latitude:ln("number"),longitude:ln("number")};
2061
- /**
2062
- * @license
2063
- * Copyright 2024 Google LLC
2064
- *
2065
- * Licensed under the Apache License, Version 2.0 (the "License");
2066
- * you may not use this file except in compliance with the License.
2067
- * You may obtain a copy of the License at
2068
- *
2069
- * http://www.apache.org/licenses/LICENSE-2.0
2070
- *
2071
- * Unless required by applicable law or agreed to in writing, software
2072
- * distributed under the License is distributed on an "AS IS" BASIS,
2073
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2074
- * See the License for the specific language governing permissions and
2075
- * limitations under the License.
2076
- */
2077
- class al{constructor(e){this._values=(e||[]).map(e=>e)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(this._values,e._values)}toJSON(){return{type:al._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(un(e,al._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(e=>"number"==typeof e))return new al(e.vectorValues);throw new Ot(Nt.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}al._jsonSchemaVersion="firestore/vectorValue/1.0",al._jsonSchema={type:ln("string",al._jsonSchemaVersion),vectorValues:ln("object")};
2078
- /**
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
- */
2094
- const cl=/^__.*__$/;class ll{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new Gr(e,this.data,this.fieldMask,t,this.fieldTransforms):new qr(e,this.data,t,this.fieldTransforms)}}function ul(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw kt(40011,{Ec:e})}}class hl{constructor(e,t,n,i,r,s){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=i,void 0===r&&this.Ac(),this.fieldTransforms=r||[],this.fieldMask=s||[]}get path(){return this.settings.path}get Ec(){return this.settings.Ec}Rc(e){return new hl(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Vc(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),i=this.Rc({path:n,mc:!1});return i.fc(e),i}gc(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),i=this.Rc({path:n,mc:!1});return i.Ac(),i}yc(e){return this.Rc({path:void 0,mc:!0})}wc(e){return Sl(e,this.settings.methodName,this.settings.Sc||!1,this.path,this.settings.bc)}contains(e){return void 0!==this.fieldMask.find(t=>e.isPrefixOf(t))||void 0!==this.fieldTransforms.find(t=>e.isPrefixOf(t.field))}Ac(){if(this.path)for(let e=0;e<this.path.length;e++)this.fc(this.path.get(e))}fc(e){if(0===e.length)throw this.wc("Document fields must not be empty");if(ul(this.Ec)&&cl.test(e))throw this.wc('Document fields cannot begin and end with "__"')}}class dl{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Yo(e)}Dc(e,t,n,i=!1){return new hl({Ec:e,methodName:t,bc:n,path:en.emptyPath(),mc:!1,Sc:i},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function fl(e){const t=e._freezeSettings(),n=Yo(e._databaseId);return new dl(e._databaseId,!!t.ignoreUndefinedProperties,n)}function pl(e,t,n,i,r,s={}){const o=e.Dc(s.merge||s.mergeFields?2:0,t,n,r);vl("Data must be an object, but it was:",o,i);const a=ml(i,o);let c,l;if(s.merge)c=new Dn(o.fieldMask),l=o.fieldTransforms;else if(s.mergeFields){const e=[];for(const i of s.mergeFields){const r=wl(t,i,n);if(!o.contains(r))throw new Ot(Nt.INVALID_ARGUMENT,`Field '${r}' is specified in your field mask but missing from your input data.`);El(e,r)||e.push(r)}c=new Dn(e),l=o.fieldTransforms.filter(e=>c.covers(e.field))}else c=null,l=o.fieldTransforms;return new ll(new wi(a),c,l)}function gl(e,t){if(yl(e=N(e)))return vl("Unsupported field value:",t,e),ml(e,t);if(e instanceof sl)return function(e,t){if(!ul(t.Ec))throw t.wc(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.wc(`${e._methodName}() is not currently supported inside arrays`);const n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.mc&&4!==t.Ec)throw t.wc("Nested arrays are not supported");return function(e,t){const n=[];let i=0;for(const r of e){let e=gl(r,t.yc(i));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),i++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if(null===(e=N(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return Er(t.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){const n=fn.fromDate(e);return{timestampValue:Ts(t.serializer,n)}}if(e instanceof fn){const n=new fn(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:Ts(t.serializer,n)}}if(e instanceof ol)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof nl)return{bytesValue:Is(t.serializer,e._byteString)};if(e instanceof qc){const n=t.databaseId,i=e.firestore._databaseId;if(!i.isEqual(n))throw t.wc(`Document reference is for database ${i.projectId}/${i.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:As(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof al)return function(e,t){return{mapValue:{fields:{[Xn]:{stringValue:ti},[ni]:{arrayValue:{values:e.toArray().map(e=>{if("number"!=typeof e)throw t.wc("VectorValues must only contain numeric values.");return _r(t.serializer,e)})}}}}}}(e,t);throw t.wc(`Unsupported field value: ${an(e)}`)}(e,t)}function ml(e,t){const n={};return Rn(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):An(e,(e,i)=>{const r=gl(i,t.Vc(e));null!=r&&(n[e]=r)}),{mapValue:{fields:n}}}function yl(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof fn||e instanceof ol||e instanceof nl||e instanceof qc||e instanceof sl||e instanceof al)}function vl(e,t,n){if(!yl(n)||!on(n)){const i=an(n);throw"an object"===i?t.wc(e+" a custom object"):t.wc(e+" "+i)}}function wl(e,t,n){if((t=N(t))instanceof il)return t._internalPath;if("string"==typeof t)return _l(e,t);throw Sl("Field path arguments must be of type string or ",e,!1,void 0,n)}const bl=new RegExp("[~\\*/\\[\\]]");function _l(e,t,n){if(t.search(bl)>=0)throw Sl(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new il(...t.split("."))._internalPath}catch(i){throw Sl(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function Sl(e,t,n,i,r){const s=i&&!i.isEmpty(),o=void 0!==r;let a=`Function ${t}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(s||o)&&(c+=" (found",s&&(c+=` in field ${i}`),o&&(c+=` in document ${r}`),c+=")"),new Ot(Nt.INVALID_ARGUMENT,a+e+c)}function El(e,t){return e.some(e=>e.isEqual(t))}
2095
- /**
2096
- * @license
2097
- * Copyright 2020 Google LLC
2098
- *
2099
- * Licensed under the Apache License, Version 2.0 (the "License");
2100
- * you may not use this file except in compliance with the License.
2101
- * You may obtain a copy of the License at
2102
- *
2103
- * http://www.apache.org/licenses/LICENSE-2.0
2104
- *
2105
- * Unless required by applicable law or agreed to in writing, software
2106
- * distributed under the License is distributed on an "AS IS" BASIS,
2107
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2108
- * See the License for the specific language governing permissions and
2109
- * limitations under the License.
2110
- */class Tl{constructor(e,t,n,i,r){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=i,this._converter=r}get id(){return this._key.path.lastSegment()}get ref(){return new qc(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const e=new Il(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(Cl("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class Il extends Tl{data(){return super.data()}}function Cl(e,t){return"string"==typeof t?_l(e,t):t instanceof il?t._internalPath:t._delegate._internalPath}
2111
- /**
2112
- * @license
2113
- * Copyright 2020 Google LLC
2114
- *
2115
- * Licensed under the Apache License, Version 2.0 (the "License");
2116
- * you may not use this file except in compliance with the License.
2117
- * You may obtain a copy of the License at
2118
- *
2119
- * http://www.apache.org/licenses/LICENSE-2.0
2120
- *
2121
- * Unless required by applicable law or agreed to in writing, software
2122
- * distributed under the License is distributed on an "AS IS" BASIS,
2123
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2124
- * See the License for the specific language governing permissions and
2125
- * limitations under the License.
2126
- */function kl(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new Ot(Nt.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Al{}class Rl extends Al{}function xl(e,t,...n){let i=[];t instanceof Al&&i.push(t),i=i.concat(n),function(e){const t=e.filter(e=>e instanceof Ll).length,n=e.filter(e=>e instanceof Nl).length;if(t>1||t>0&&n>0)throw new Ot(Nt.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(...)))`.")}
2127
- /**
2128
- * @license
2129
- * Copyright 2020 Google LLC
2130
- *
2131
- * Licensed under the Apache License, Version 2.0 (the "License");
2132
- * you may not use this file except in compliance with the License.
2133
- * You may obtain a copy of the License at
2134
- *
2135
- * http://www.apache.org/licenses/LICENSE-2.0
2136
- *
2137
- * Unless required by applicable law or agreed to in writing, software
2138
- * distributed under the License is distributed on an "AS IS" BASIS,
2139
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2140
- * See the License for the specific language governing permissions and
2141
- * limitations under the License.
2142
- */(i);for(const t of i)e=t._apply(e);return e}class Nl extends Rl{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type="where"}static _create(e,t,n){return new Nl(e,t,n)}_apply(e){const t=this._parse(e);return Ml(e._query,t),new $c(e.firestore,e.converter,er(e._query,t))}_parse(e){const t=fl(e.firestore),n=function(e,t,n,i,r,s,o){let a;if(r.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new Ot(Nt.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){Dl(o,s);const t=[];for(const n of o)t.push(Pl(i,e,n));a={arrayValue:{values:t}}}else a=Pl(i,e,o)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||Dl(o,s),a=function(e,t,n,i=!1){return gl(n,e.Dc(i?4:3,t))}(n,t,o,"in"===s||"not-in"===s);return Ai.create(r,s,a)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value);return n}}function Ol(e,t,n){const i=t,r=Cl("where",e);return Nl._create(r,i,n)}class Ll extends Al{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new Ll(e,t)}_parse(e){const t=this._queryConstraints.map(t=>t._parse(e)).filter(e=>e.getFilters().length>0);return 1===t.length?t[0]:Ri.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){let n=e;const i=t.getFlattenedFilters();for(const e of i)Ml(n,e),n=er(n,e)}(e._query,t),new $c(e.firestore,e.converter,er(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}function Pl(e,t,n){if("string"==typeof(n=N(n))){if(""===n)throw new Ot(Nt.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Yi(t)&&-1!==n.indexOf("/"))throw new Ot(Nt.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const i=t.path.child(Xt.fromString(n));if(!tn.isDocumentKey(i))throw new Ot(Nt.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${i}' is not because it has an odd number of segments (${i.length}).`);return di(e,new tn(i))}if(n instanceof qc)return di(e,n._key);throw new Ot(Nt.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${an(n)}.`)}function Dl(e,t){if(!Array.isArray(e)||0===e.length)throw new Ot(Nt.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function Ml(e,t){const n=function(e,t){for(const n of e)for(const e of n.getFlattenedFilters())if(t.indexOf(e.op)>=0)return e.op;return null}(e.filters,function(e){switch(e){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(t.op));if(null!==n)throw n===t.op?new Ot(Nt.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new Ot(Nt.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}class zl{convertValue(e,t="none"){switch(ii(e)){case 0:return null;case 1:return e.booleanValue;case 2:return Vn(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(Bn(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 kt(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const n={};return An(e,(e,i)=>{n[e]=this.convertValue(i,t)}),n}convertVectorValue(e){var t,n,i;const r=null===(i=null===(n=null===(t=e.fields)||void 0===t?void 0:t[ni].arrayValue)||void 0===n?void 0:n.values)||void 0===i?void 0:i.map(e=>Vn(e.doubleValue));return new al(r)}convertGeoPoint(e){return new ol(Vn(e.latitude),Vn(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":const n=Kn(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(Wn(e));default:return null}}convertTimestamp(e){const t=Un(e);return new fn(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=Xt.fromString(e);Rt(Ws(n),9688,{name:e});const i=new Yn(n.get(1),n.get(3)),r=new tn(n.popFirst(5));return i.isEqual(t)||Tt(`Document ${r} contains a document reference within a different database (${i.projectId}/${i.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),r}}
2143
- /**
2144
- * @license
2145
- * Copyright 2020 Google LLC
2146
- *
2147
- * Licensed under the Apache License, Version 2.0 (the "License");
2148
- * you may not use this file except in compliance with the License.
2149
- * You may obtain a copy of the License at
2150
- *
2151
- * http://www.apache.org/licenses/LICENSE-2.0
2152
- *
2153
- * Unless required by applicable law or agreed to in writing, software
2154
- * distributed under the License is distributed on an "AS IS" BASIS,
2155
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2156
- * See the License for the specific language governing permissions and
2157
- * limitations under the License.
2158
- */class Fl{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class Ul extends Tl{constructor(e,t,n,i,r,s){super(e,t,n,i,s),this._firestore=e,this._firestoreImpl=e,this.metadata=r}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new Vl(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const n=this._document.data.field(Cl("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new Ot(Nt.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,t={};return t.type=Ul._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),e&&e.isValidDocument()&&e.isFoundDocument()?(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t):t}}Ul._jsonSchemaVersion="firestore/documentSnapshot/1.0",Ul._jsonSchema={type:ln("string",Ul._jsonSchemaVersion),bundleSource:ln("string","DocumentSnapshot"),bundleName:ln("string"),bundle:ln("string")};class Vl extends Ul{data(e={}){return super.data(e)}}class Bl{constructor(e,t,n,i){this._firestore=e,this._userDataWriter=t,this._snapshot=i,this.metadata=new Fl(i.hasPendingWrites,i.fromCache),this.query=n}get docs(){const e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(e,t){this._snapshot.docs.forEach(n=>{e.call(t,new Vl(this._firestore,this._userDataWriter,n.key,n,new Fl(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new Ot(Nt.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(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map(n=>{const i=new Vl(e._firestore,e._userDataWriter,n.doc.key,n.doc,new Fl(e._snapshot.mutatedKeys.has(n.doc.key),e._snapshot.fromCache),e.query.converter);return n.doc,{type:"added",doc:i,oldIndex:-1,newIndex:t++}})}{let n=e._snapshot.oldDocs;return e._snapshot.docChanges.filter(e=>t||3!==e.type).map(t=>{const i=new Vl(e._firestore,e._userDataWriter,t.doc.key,t.doc,new Fl(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter);let r=-1,s=-1;return 0!==t.type&&(r=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),1!==t.type&&(n=n.add(t.doc),s=n.indexOf(t.doc.key)),{type:jl(t.type),doc:i,oldIndex:r,newIndex:s}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new Ot(Nt.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=Bl._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=$t.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],n=[],i=[];return this.docs.forEach(e=>{null!==e._document&&(t.push(e._document),n.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,"previous")),i.push(e.ref.path))}),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function jl(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return kt(61501,{type:e})}}
2159
- /**
2160
- * @license
2161
- * Copyright 2020 Google LLC
2162
- *
2163
- * Licensed under the Apache License, Version 2.0 (the "License");
2164
- * you may not use this file except in compliance with the License.
2165
- * You may obtain a copy of the License at
2166
- *
2167
- * http://www.apache.org/licenses/LICENSE-2.0
2168
- *
2169
- * Unless required by applicable law or agreed to in writing, software
2170
- * distributed under the License is distributed on an "AS IS" BASIS,
2171
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2172
- * See the License for the specific language governing permissions and
2173
- * limitations under the License.
2174
- */function Hl(e){e=cn(e,qc);const t=cn(e.firestore,Zc);return function(e,t,n={}){const i=new Lt;return e.asyncQueue.enqueueAndForget(async()=>function(e,t,n,i,r){const s=new xc({next:a=>{s.Ou(),t.enqueueAndForget(()=>qa(e,o));const c=a.docs.has(n);!c&&a.fromCache?r.reject(new Ot(Nt.UNAVAILABLE,"Failed to get document because the client is offline.")):c&&a.fromCache&&i&&"server"===i.source?r.reject(new Ot(Nt.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.)')):r.resolve(a)},error:e=>r.reject(e)}),o=new Ya(Qi(n.path),s,{includeMetadataChanges:!0,ka:!0});return $a(e,o)}(await Mc(e),e.asyncQueue,t,n,i)),i.promise}(tl(t),e._key).then(n=>Wl(t,e,n))}Bl._jsonSchemaVersion="firestore/querySnapshot/1.0",Bl._jsonSchema={type:ln("string",Bl._jsonSchemaVersion),bundleSource:ln("string","QuerySnapshot"),bundleName:ln("string"),bundle:ln("string")};class $l extends zl{constructor(e){super(),this.firestore=e}convertBytes(e){return new nl(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new qc(this.firestore,null,t)}}function ql(e){e=cn(e,$c);const t=cn(e.firestore,Zc),n=tl(t),i=new $l(t);return kl(e._query),function(e,t,n={}){const i=new Lt;return e.asyncQueue.enqueueAndForget(async()=>function(e,t,n,i,r){const s=new xc({next:n=>{s.Ou(),t.enqueueAndForget(()=>qa(e,o)),n.fromCache&&"server"===i.source?r.reject(new Ot(Nt.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.)')):r.resolve(n)},error:e=>r.reject(e)}),o=new Ya(n,s,{includeMetadataChanges:!0,ka:!0});return $a(e,o)}(await Mc(e),e.asyncQueue,t,n,i)),i.promise}(n,e._query).then(n=>new Bl(t,i,e,n))}function Gl(e,t,n){e=cn(e,qc);const i=cn(e.firestore,Zc),r=function(e,t,n){let i;return i=e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,i}(e.converter,t,n);return function(e,t){return function(e,t){const n=new Lt;return e.asyncQueue.enqueueAndForget(async()=>uc(await function(e){return Dc(e).then(e=>e.syncEngine)}(e),t,n)),n.promise}(tl(e),t)}(i,[pl(fl(i),"setDoc",e._key,r,null!==e.converter,n).toMutation(e._key,zr.none())])}function Kl(e,...t){var n,i,r;e=N(e);let s={includeMetadataChanges:!1,source:"default"},o=0;"object"!=typeof t[o]||Xc(t[o])||(s=t[o++]);const a={includeMetadataChanges:s.includeMetadataChanges,source:s.source};if(Xc(t[o])){const e=t[o];t[o]=null===(n=e.next)||void 0===n?void 0:n.bind(e),t[o+1]=null===(i=e.error)||void 0===i?void 0:i.bind(e),t[o+2]=null===(r=e.complete)||void 0===r?void 0:r.bind(e)}let c,l,u;if(e instanceof qc)l=cn(e.firestore,Zc),u=Qi(e._key.path),c={next:n=>{t[o]&&t[o](Wl(l,e,n))},error:t[o+1],complete:t[o+2]};else{const n=cn(e,$c);l=cn(n.firestore,Zc),u=n._query;const i=new $l(l);c={next:e=>{t[o]&&t[o](new Bl(l,i,n,e))},error:t[o+1],complete:t[o+2]},kl(e._query)}return function(e,t,n,i){const r=new xc(i),s=new Ya(t,r,n);return e.asyncQueue.enqueueAndForget(async()=>$a(await Mc(e),s)),()=>{r.Ou(),e.asyncQueue.enqueueAndForget(async()=>qa(await Mc(e),s))}}(tl(l),u,a,c)}function Wl(e,t,n){const i=n.docs.get(t._key),r=new $l(e);return new Ul(e,r,t._key,i,new Fl(n.hasPendingWrites,n.fromCache),t.converter)}!function(e,t=!0){!function(e){bt=e}(qe),Ve(new O("firestore",(e,{instanceIdentifier:n,options:i})=>{const r=e.getProvider("app").getImmediate(),s=new Zc(new zt(e.getProvider("auth-internal")),new Bt(r,e.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new Ot(Nt.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Yn(e.options.projectId,t)}(r,n),r);return i=Object.assign({useFetchStreams:t},i),s._setSettings(i),s},"PUBLIC").setMultipleInstances(!0)),We(yt,vt,e),We(yt,vt,"esm2017")}();
2175
- /**
2176
- * @license
2177
- * Copyright 2020 Google LLC
2178
- *
2179
- * Licensed under the Apache License, Version 2.0 (the "License");
2180
- * you may not use this file except in compliance with the License.
2181
- * You may obtain a copy of the License at
2182
- *
2183
- * http://www.apache.org/licenses/LICENSE-2.0
2184
- *
2185
- * Unless required by applicable law or agreed to in writing, software
2186
- * distributed under the License is distributed on an "AS IS" BASIS,
2187
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2188
- * See the License for the specific language governing permissions and
2189
- * limitations under the License.
2190
- */
2191
- We("firebase","11.10.0","app");class Ql{constructor(){}static getInstance(){return Ql.instance||(Ql.instance=new Ql),Ql.instance}setEnv(e){switch(e){case"production":case"prod":this.env="prod";break;default:this.env="dev"}}get firebase(){return"prod"===this.env?Yl.firebase:Jl.firebase}get api(){return"prod"===this.env?Yl.api:Jl.api}get config(){return"prod"===this.env?Yl.config:Jl.config}}const Jl={firebase:{apiKey:"AIzaSyDfjBWzpmzb-mhGN8VSURxzLg6nkzmKUD8",authDomain:"fittingroom-dev-5d248.firebaseapp.com",projectId:"fittingroom-dev-5d248",storageBucket:"fittingroom-dev-5d248.appspot.com",messagingSenderId:"2298664147",appId:"1:2298664147:web:340bda75cd5d25f3997026"},api:{url:"https://tfr.dev.thefittingroom.xyz"},config:{avatarTimeout:Number("120000"),vtoTimeout:Number("120000")}},Yl={firebase:{apiKey:"AIzaSyA3kQ6w1vkA9l9lgY0nNACVPXe-QmP5T1Y",authDomain:"fittingroom-prod.firebaseapp.com",projectId:"fittingroom-prod",storageBucket:"fittingroom-prod.appspot.com",messagingSenderId:"965656825574",appId:"1:965656825574:web:933493cddc73213bd43527"},api:{url:"https://tfr.p.thefittingroom.xyz"},config:{avatarTimeout:Number("120000"),vtoTimeout:Number("120000")}};var Xl=1e3,Zl=6e4,eu=36e5,tu="millisecond",nu="second",iu="minute",ru="hour",su="day",ou="week",au="month",cu="quarter",lu="year",uu="date",hu="Invalid Date",du=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,fu=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,pu={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}},gu=function(e,t,n){var i=String(e);return!i||i.length>=t?e:""+Array(t+1-i.length).join(n)+e},mu={s:gu,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),i=Math.floor(n/60),r=n%60;return(t<=0?"+":"-")+gu(i,2,"0")+":"+gu(r,2,"0")},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var i=12*(n.year()-t.year())+(n.month()-t.month()),r=t.clone().add(i,au),s=n-r<0,o=t.clone().add(i+(s?-1:1),au);return+(-(i+(n-r)/(s?r-o:o-r))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:au,y:lu,w:ou,d:su,D:uu,h:ru,m:iu,s:nu,ms:tu,Q:cu}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},yu="en",vu={};vu[yu]=pu;var wu="$isDayjsObject",bu=function(e){return e instanceof Tu||!(!e||!e[wu])},_u=function e(t,n,i){var r;if(!t)return yu;if("string"==typeof t){var s=t.toLowerCase();vu[s]&&(r=s),n&&(vu[s]=n,r=s);var o=t.split("-");if(!r&&o.length>1)return e(o[0])}else{var a=t.name;vu[a]=t,r=a}return!i&&r&&(yu=r),r||!i&&yu},Su=function(e,t){if(bu(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new Tu(n)},Eu=mu;Eu.l=_u,Eu.i=bu,Eu.w=function(e,t){return Su(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var Tu=function(){function e(e){this.$L=_u(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[wu]=!0}var t=e.prototype;return t.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(Eu.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var i=t.match(du);if(i){var r=i[2]-1||0,s=(i[7]||"0").substring(0,3);return n?new Date(Date.UTC(i[1],r,i[3]||1,i[4]||0,i[5]||0,i[6]||0,s)):new Date(i[1],r,i[3]||1,i[4]||0,i[5]||0,i[6]||0,s)}}return new Date(t)}(e),this.init()},t.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},t.$utils=function(){return Eu},t.isValid=function(){return!(this.$d.toString()===hu)},t.isSame=function(e,t){var n=Su(e);return this.startOf(t)<=n&&n<=this.endOf(t)},t.isAfter=function(e,t){return Su(e)<this.startOf(t)},t.isBefore=function(e,t){return this.endOf(t)<Su(e)},t.$g=function(e,t,n){return Eu.u(e)?this[t]:this.set(n,e)},t.unix=function(){return Math.floor(this.valueOf()/1e3)},t.valueOf=function(){return this.$d.getTime()},t.startOf=function(e,t){var n=this,i=!!Eu.u(t)||t,r=Eu.p(e),s=function(e,t){var r=Eu.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return i?r:r.endOf(su)},o=function(e,t){return Eu.w(n.toDate()[e].apply(n.toDate("s"),(i?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},a=this.$W,c=this.$M,l=this.$D,u="set"+(this.$u?"UTC":"");switch(r){case lu:return i?s(1,0):s(31,11);case au:return i?s(1,c):s(0,c+1);case ou:var h=this.$locale().weekStart||0,d=(a<h?a+7:a)-h;return s(i?l-d:l+(6-d),c);case su:case uu:return o(u+"Hours",0);case ru:return o(u+"Minutes",1);case iu:return o(u+"Seconds",2);case nu:return o(u+"Milliseconds",3);default:return this.clone()}},t.endOf=function(e){return this.startOf(e,!1)},t.$set=function(e,t){var n,i=Eu.p(e),r="set"+(this.$u?"UTC":""),s=(n={},n[su]=r+"Date",n[uu]=r+"Date",n[au]=r+"Month",n[lu]=r+"FullYear",n[ru]=r+"Hours",n[iu]=r+"Minutes",n[nu]=r+"Seconds",n[tu]=r+"Milliseconds",n)[i],o=i===su?this.$D+(t-this.$W):t;if(i===au||i===lu){var a=this.clone().set(uu,1);a.$d[s](o),a.init(),this.$d=a.set(uu,Math.min(this.$D,a.daysInMonth())).$d}else s&&this.$d[s](o);return this.init(),this},t.set=function(e,t){return this.clone().$set(e,t)},t.get=function(e){return this[Eu.p(e)]()},t.add=function(e,t){var n,i=this;e=Number(e);var r=Eu.p(t),s=function(t){var n=Su(i);return Eu.w(n.date(n.date()+Math.round(t*e)),i)};if(r===au)return this.set(au,this.$M+e);if(r===lu)return this.set(lu,this.$y+e);if(r===su)return s(1);if(r===ou)return s(7);var o=(n={},n[iu]=Zl,n[ru]=eu,n[nu]=Xl,n)[r]||1,a=this.$d.getTime()+e*o;return Eu.w(a,this)},t.subtract=function(e,t){return this.add(-1*e,t)},t.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||hu;var i=e||"YYYY-MM-DDTHH:mm:ssZ",r=Eu.z(this),s=this.$H,o=this.$m,a=this.$M,c=n.weekdays,l=n.months,u=n.meridiem,h=function(e,n,r,s){return e&&(e[n]||e(t,i))||r[n].slice(0,s)},d=function(e){return Eu.s(s%12||12,e,"0")},f=u||function(e,t,n){var i=e<12?"AM":"PM";return n?i.toLowerCase():i};return i.replace(fu,function(e,i){return i||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return Eu.s(t.$y,4,"0");case"M":return a+1;case"MM":return Eu.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,l,3);case"MMMM":return h(l,a);case"D":return t.$D;case"DD":return Eu.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return h(n.weekdaysMin,t.$W,c,2);case"ddd":return h(n.weekdaysShort,t.$W,c,3);case"dddd":return c[t.$W];case"H":return String(s);case"HH":return Eu.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return f(s,o,!0);case"A":return f(s,o,!1);case"m":return String(o);case"mm":return Eu.s(o,2,"0");case"s":return String(t.$s);case"ss":return Eu.s(t.$s,2,"0");case"SSS":return Eu.s(t.$ms,3,"0");case"Z":return r}return null}(e)||r.replace(":","")})},t.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},t.diff=function(e,t,n){var i,r=this,s=Eu.p(t),o=Su(e),a=(o.utcOffset()-this.utcOffset())*Zl,c=this-o,l=function(){return Eu.m(r,o)};switch(s){case lu:i=l()/12;break;case au:i=l();break;case cu:i=l()/3;break;case ou:i=(c-a)/6048e5;break;case su:i=(c-a)/864e5;break;case ru:i=c/eu;break;case iu:i=c/Zl;break;case nu:i=c/Xl;break;default:i=c}return n?i:Eu.a(i)},t.daysInMonth=function(){return this.endOf(au).$D},t.$locale=function(){return vu[this.$L]},t.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),i=_u(e,t,!0);return i&&(n.$L=i),n},t.clone=function(){return Eu.w(this.$d,this)},t.toDate=function(){return new Date(this.valueOf())},t.toJSON=function(){return this.isValid()?this.toISOString():null},t.toISOString=function(){return this.$d.toISOString()},t.toString=function(){return this.$d.toUTCString()},e}(),Iu=Tu.prototype;function Cu(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}function ku(){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."}}Su.prototype=Iu,[["$ms",tu],["$s",nu],["$m",iu],["$H",ru],["$W",su],["$M",au],["$y",lu],["$D",uu]].forEach(function(e){Iu[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),Su.extend=function(e,t){return e.$i||(e(t,Tu,Su),e.$i=!0),Su},Su.locale=_u,Su.isDayjs=bu,Su.unix=function(e){return Su(1e3*e)},Su.en=vu[yu],Su.Ls=vu,Su.p={},"function"==typeof SuppressedError&&SuppressedError;const Au=ku,Ru=new S("auth","Firebase",{"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."}),xu="auth/user-disabled",Nu=new B("@firebase/auth");function Ou(e,...t){Nu.logLevel<=M.ERROR&&Nu.error(`Auth (${qe}): ${e}`,...t)}
2192
- /**
2193
- * @license
2194
- * Copyright 2020 Google LLC
2195
- *
2196
- * Licensed under the Apache License, Version 2.0 (the "License");
2197
- * you may not use this file except in compliance with the License.
2198
- * You may obtain a copy of the License at
2199
- *
2200
- * http://www.apache.org/licenses/LICENSE-2.0
2201
- *
2202
- * Unless required by applicable law or agreed to in writing, software
2203
- * distributed under the License is distributed on an "AS IS" BASIS,
2204
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2205
- * See the License for the specific language governing permissions and
2206
- * limitations under the License.
2207
- */function Lu(e,...t){throw zu(e,...t)}function Pu(e,...t){return zu(e,...t)}function Du(e,t,n){const i=Object.assign(Object.assign({},Au()),{[t]:n});return new S("auth","Firebase",i).create(t,{appName:e.name})}function Mu(e){return Du(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function zu(e,...t){if("string"!=typeof e){const n=t[0],i=[...t.slice(1)];return i[0]&&(i[0].appName=e.name),e._errorFactory.create(n,...i)}return Ru.create(e,...t)}function Fu(e,t,...n){if(!e)throw zu(t,...n)}function Uu(e){const t="INTERNAL ASSERTION FAILED: "+e;throw Ou(t),new Error(t)}function Vu(e,t){e||Uu(t)}
2208
- /**
2209
- * @license
2210
- * Copyright 2020 Google LLC
2211
- *
2212
- * Licensed under the Apache License, Version 2.0 (the "License");
2213
- * you may not use this file except in compliance with the License.
2214
- * You may obtain a copy of the License at
2215
- *
2216
- * http://www.apache.org/licenses/LICENSE-2.0
2217
- *
2218
- * Unless required by applicable law or agreed to in writing, software
2219
- * distributed under the License is distributed on an "AS IS" BASIS,
2220
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2221
- * See the License for the specific language governing permissions and
2222
- * limitations under the License.
2223
- */function Bu(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.href)||""}function ju(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.protocol)||null}
2224
- /**
2225
- * @license
2226
- * Copyright 2020 Google LLC
2227
- *
2228
- * Licensed under the Apache License, Version 2.0 (the "License");
2229
- * you may not use this file except in compliance with the License.
2230
- * You may obtain a copy of the License at
2231
- *
2232
- * http://www.apache.org/licenses/LICENSE-2.0
2233
- *
2234
- * Unless required by applicable law or agreed to in writing, software
2235
- * distributed under the License is distributed on an "AS IS" BASIS,
2236
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2237
- * See the License for the specific language governing permissions and
2238
- * limitations under the License.
2239
- */function Hu(){return"undefined"==typeof navigator||!navigator||!("onLine"in navigator)||"boolean"!=typeof navigator.onLine||"http:"!==ju()&&"https:"!==ju()&&!function(){const e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}()&&!("connection"in navigator)||navigator.onLine}
2240
- /**
2241
- * @license
2242
- * Copyright 2020 Google LLC
2243
- *
2244
- * Licensed under the Apache License, Version 2.0 (the "License");
2245
- * you may not use this file except in compliance with the License.
2246
- * You may obtain a copy of the License at
2247
- *
2248
- * http://www.apache.org/licenses/LICENSE-2.0
2249
- *
2250
- * Unless required by applicable law or agreed to in writing, software
2251
- * distributed under the License is distributed on an "AS IS" BASIS,
2252
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2253
- * See the License for the specific language governing permissions and
2254
- * limitations under the License.
2255
- */
2256
- class $u{constructor(e,t){this.shortDelay=e,this.longDelay=t,Vu(t>e,"Short delay should be less than long delay!"),this.isMobile="undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(w())||"object"==typeof navigator&&"ReactNative"===navigator.product}get(){return Hu()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}
2257
- /**
2258
- * @license
2259
- * Copyright 2020 Google LLC
2260
- *
2261
- * Licensed under the Apache License, Version 2.0 (the "License");
2262
- * you may not use this file except in compliance with the License.
2263
- * You may obtain a copy of the License at
2264
- *
2265
- * http://www.apache.org/licenses/LICENSE-2.0
2266
- *
2267
- * Unless required by applicable law or agreed to in writing, software
2268
- * distributed under the License is distributed on an "AS IS" BASIS,
2269
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2270
- * See the License for the specific language governing permissions and
2271
- * limitations under the License.
2272
- */function qu(e,t){Vu(e.emulator,"Emulator should always be set here");const{url:n}=e.emulator;return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}
2273
- /**
2274
- * @license
2275
- * Copyright 2020 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 Gu{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:"undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch:"undefined"!=typeof fetch?fetch:void Uu("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){return this.headersImpl?this.headersImpl:"undefined"!=typeof self&&"Headers"in self?self.Headers:"undefined"!=typeof globalThis&&globalThis.Headers?globalThis.Headers:"undefined"!=typeof Headers?Headers:void Uu("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){return this.responseImpl?this.responseImpl:"undefined"!=typeof self&&"Response"in self?self.Response:"undefined"!=typeof globalThis&&globalThis.Response?globalThis.Response:"undefined"!=typeof Response?Response:void Uu("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}
2289
- /**
2290
- * @license
2291
- * Copyright 2020 Google LLC
2292
- *
2293
- * Licensed under the Apache License, Version 2.0 (the "License");
2294
- * you may not use this file except in compliance with the License.
2295
- * You may obtain a copy of the License at
2296
- *
2297
- * http://www.apache.org/licenses/LICENSE-2.0
2298
- *
2299
- * Unless required by applicable law or agreed to in writing, software
2300
- * distributed under the License is distributed on an "AS IS" BASIS,
2301
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2302
- * See the License for the specific language governing permissions and
2303
- * limitations under the License.
2304
- */const Ku={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"},Wu=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],Qu=new $u(3e4,6e4);
2305
- /**
2306
- * @license
2307
- * Copyright 2020 Google LLC
2308
- *
2309
- * Licensed under the Apache License, Version 2.0 (the "License");
2310
- * you may not use this file except in compliance with the License.
2311
- * You may obtain a copy of the License at
2312
- *
2313
- * http://www.apache.org/licenses/LICENSE-2.0
2314
- *
2315
- * Unless required by applicable law or agreed to in writing, software
2316
- * distributed under the License is distributed on an "AS IS" BASIS,
2317
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2318
- * See the License for the specific language governing permissions and
2319
- * limitations under the License.
2320
- */function Ju(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function Yu(e,t,n,i,r={}){return Xu(e,r,async()=>{let r={},s={};i&&("GET"===t?s=i:r={body:JSON.stringify(i)});const o=C(Object.assign({key:e.config.apiKey},s)).slice(1),a=await e._getAdditionalHeaders();a["Content-Type"]="application/json",e.languageCode&&(a["X-Firebase-Locale"]=e.languageCode);const c=Object.assign({method:t,headers:a},r);return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||(c.referrerPolicy="no-referrer"),e.emulatorConfig&&p(e.emulatorConfig.host)&&(c.credentials="include"),Gu.fetch()(await eh(e,e.config.apiHost,n,o),c)})}async function Xu(e,t,n){e._canInitEmulator=!1;const i=Object.assign(Object.assign({},Ku),t);try{const t=new nh(e),r=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();const s=await r.json();if("needConfirmation"in s)throw ih(e,"account-exists-with-different-credential",s);if(r.ok&&!("errorMessage"in s))return s;{const t=r.ok?s.errorMessage:s.error.message,[n,o]=t.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw ih(e,"credential-already-in-use",s);if("EMAIL_EXISTS"===n)throw ih(e,"email-already-in-use",s);if("USER_DISABLED"===n)throw ih(e,"user-disabled",s);const a=i[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw Du(e,a,o);Lu(e,a)}}catch(t){if(t instanceof _)throw t;Lu(e,"network-request-failed",{message:String(t)})}}async function Zu(e,t,n,i,r={}){const s=await Yu(e,t,n,i,r);return"mfaPendingCredential"in s&&Lu(e,"multi-factor-auth-required",{_serverResponse:s}),s}async function eh(e,t,n,i){const r=`${t}${n}?${i}`,s=e,o=s.config.emulator?qu(e.config,r):`${e.config.apiScheme}://${r}`;if(Wu.includes(n)&&(await s._persistenceManagerAvailable,"COOKIE"===s._getPersistenceType())){return s._getPersistence()._getFinalTarget(o).toString()}return o}function th(e){switch(e){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class nh{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(Pu(this.auth,"network-request-failed")),Qu.get())})}}function ih(e,t,n){const i={appName:e.name};n.email&&(i.email=n.email),n.phoneNumber&&(i.phoneNumber=n.phoneNumber);const r=Pu(e,t,i);return r.customData._tokenResponse=n,r}function rh(e){return void 0!==e&&void 0!==e.enterprise}class sh{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],void 0===e.recaptchaKey)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||0===this.recaptchaEnforcementState.length)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return th(t.enforcementState);return null}isProviderEnabled(e){return"ENFORCE"===this.getProviderEnforcementState(e)||"AUDIT"===this.getProviderEnforcementState(e)}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function oh(e,t){return Yu(e,"POST","/v1/accounts:lookup",t)}
2321
- /**
2322
- * @license
2323
- * Copyright 2020 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
- */function ah(e){if(e)try{const t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}function ch(e){return 1e3*Number(e)}function lh(e){const[t,n,i]=e.split(".");if(void 0===t||void 0===n||void 0===i)return Ou("JWT malformed, contained fewer than 3 sections"),null;try{const e=a(n);return e?JSON.parse(e):(Ou("Failed to decode base64 JWT payload"),null)}catch(e){return Ou("Caught error parsing JWT payload as JSON",null==e?void 0:e.toString()),null}}function uh(e){const t=lh(e);return Fu(t,"internal-error"),Fu(void 0!==t.exp,"internal-error"),Fu(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat)}
2337
- /**
2338
- * @license
2339
- * Copyright 2020 Google LLC
2340
- *
2341
- * Licensed under the Apache License, Version 2.0 (the "License");
2342
- * you may not use this file except in compliance with the License.
2343
- * You may obtain a copy of the License at
2344
- *
2345
- * http://www.apache.org/licenses/LICENSE-2.0
2346
- *
2347
- * Unless required by applicable law or agreed to in writing, software
2348
- * distributed under the License is distributed on an "AS IS" BASIS,
2349
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2350
- * See the License for the specific language governing permissions and
2351
- * limitations under the License.
2352
- */async function hh(e,t,n=!1){if(n)return t;try{return await t}catch(t){throw t instanceof _&&function({code:e}){return"auth/user-disabled"===e||"auth/user-token-expired"===e}
2353
- /**
2354
- * @license
2355
- * Copyright 2020 Google LLC
2356
- *
2357
- * Licensed under the Apache License, Version 2.0 (the "License");
2358
- * you may not use this file except in compliance with the License.
2359
- * You may obtain a copy of the License at
2360
- *
2361
- * http://www.apache.org/licenses/LICENSE-2.0
2362
- *
2363
- * Unless required by applicable law or agreed to in writing, software
2364
- * distributed under the License is distributed on an "AS IS" BASIS,
2365
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2366
- * See the License for the specific language governing permissions and
2367
- * limitations under the License.
2368
- */(t)&&e.auth.currentUser===e&&await e.auth.signOut(),t}}class dh{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,null!==this.timerId&&clearTimeout(this.timerId))}getInterval(e){var t;if(e){const e=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),e}{this.errorBackoff=3e4;const e=(null!==(t=this.user.stsTokenManager.expirationTime)&&void 0!==t?t:0)-Date.now()-3e5;return Math.max(0,e)}}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){return void("auth/network-request-failed"===(null==e?void 0:e.code)&&this.schedule(!0))}this.schedule()}}
2369
- /**
2370
- * @license
2371
- * Copyright 2020 Google LLC
2372
- *
2373
- * Licensed under the Apache License, Version 2.0 (the "License");
2374
- * you may not use this file except in compliance with the License.
2375
- * You may obtain a copy of the License at
2376
- *
2377
- * http://www.apache.org/licenses/LICENSE-2.0
2378
- *
2379
- * Unless required by applicable law or agreed to in writing, software
2380
- * distributed under the License is distributed on an "AS IS" BASIS,
2381
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2382
- * See the License for the specific language governing permissions and
2383
- * limitations under the License.
2384
- */class fh{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=ah(this.lastLoginAt),this.creationTime=ah(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}
2385
- /**
2386
- * @license
2387
- * Copyright 2019 Google LLC
2388
- *
2389
- * Licensed under the Apache License, Version 2.0 (the "License");
2390
- * you may not use this file except in compliance with the License.
2391
- * You may obtain a copy of the License at
2392
- *
2393
- * http://www.apache.org/licenses/LICENSE-2.0
2394
- *
2395
- * Unless required by applicable law or agreed to in writing, software
2396
- * distributed under the License is distributed on an "AS IS" BASIS,
2397
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2398
- * See the License for the specific language governing permissions and
2399
- * limitations under the License.
2400
- */async function ph(e){var t;const n=e.auth,i=await e.getIdToken(),r=await hh(e,oh(n,{idToken:i}));Fu(null==r?void 0:r.users.length,n,"internal-error");const s=r.users[0];e._notifyReloadListener(s);const o=(null===(t=s.providerUserInfo)||void 0===t?void 0:t.length)?gh(s.providerUserInfo):[],a=(c=e.providerData,l=o,[...c.filter(e=>!l.some(t=>t.providerId===e.providerId)),...l]);var c,l;const u=e.isAnonymous,h=!(e.email&&s.passwordHash||(null==a?void 0:a.length)),d=!!u&&h,f={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:a,metadata:new fh(s.createdAt,s.lastLoginAt),isAnonymous:d};Object.assign(e,f)}function gh(e){return e.map(e=>{var{providerId:t}=e,n=Cu(e,["providerId"]);return{providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}})}
2401
- /**
2402
- * @license
2403
- * Copyright 2020 Google LLC
2404
- *
2405
- * Licensed under the Apache License, Version 2.0 (the "License");
2406
- * you may not use this file except in compliance with the License.
2407
- * You may obtain a copy of the License at
2408
- *
2409
- * http://www.apache.org/licenses/LICENSE-2.0
2410
- *
2411
- * Unless required by applicable law or agreed to in writing, software
2412
- * distributed under the License is distributed on an "AS IS" BASIS,
2413
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2414
- * See the License for the specific language governing permissions and
2415
- * limitations under the License.
2416
- */
2417
- /**
2418
- * @license
2419
- * Copyright 2020 Google LLC
2420
- *
2421
- * Licensed under the Apache License, Version 2.0 (the "License");
2422
- * you may not use this file except in compliance with the License.
2423
- * You may obtain a copy of the License at
2424
- *
2425
- * http://www.apache.org/licenses/LICENSE-2.0
2426
- *
2427
- * Unless required by applicable law or agreed to in writing, software
2428
- * distributed under the License is distributed on an "AS IS" BASIS,
2429
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2430
- * See the License for the specific language governing permissions and
2431
- * limitations under the License.
2432
- */
2433
- class mh{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){Fu(e.idToken,"internal-error"),Fu(void 0!==e.idToken,"internal-error"),Fu(void 0!==e.refreshToken,"internal-error");const t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):uh(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){Fu(0!==e.length,"internal-error");const t=uh(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return t||!this.accessToken||this.isExpired?(Fu(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null):this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:n,refreshToken:i,expiresIn:r}=await async function(e,t){const n=await Xu(e,{},async()=>{const n=C({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:i,apiKey:r}=e.config,s=await eh(e,i,"/v1/token",`key=${r}`),o=await e._getAdditionalHeaders();o["Content-Type"]="application/x-www-form-urlencoded";const a={method:"POST",headers:o,body:n};return e.emulatorConfig&&p(e.emulatorConfig.host)&&(a.credentials="include"),Gu.fetch()(s,a)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}(e,t);this.updateTokensAndExpiration(n,i,Number(r))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(e,t){const{refreshToken:n,accessToken:i,expirationTime:r}=t,s=new mh;return n&&(Fu("string"==typeof n,"internal-error",{appName:e}),s.refreshToken=n),i&&(Fu("string"==typeof i,"internal-error",{appName:e}),s.accessToken=i),r&&(Fu("number"==typeof r,"internal-error",{appName:e}),s.expirationTime=r),s}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 mh,this.toJSON())}_performRefresh(){return Uu("not implemented")}}
2434
- /**
2435
- * @license
2436
- * Copyright 2020 Google LLC
2437
- *
2438
- * Licensed under the Apache License, Version 2.0 (the "License");
2439
- * you may not use this file except in compliance with the License.
2440
- * You may obtain a copy of the License at
2441
- *
2442
- * http://www.apache.org/licenses/LICENSE-2.0
2443
- *
2444
- * Unless required by applicable law or agreed to in writing, software
2445
- * distributed under the License is distributed on an "AS IS" BASIS,
2446
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2447
- * See the License for the specific language governing permissions and
2448
- * limitations under the License.
2449
- */function yh(e,t){Fu("string"==typeof e||void 0===e,"internal-error",{appName:t})}class vh{constructor(e){var{uid:t,auth:n,stsTokenManager:i}=e,r=Cu(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new dh(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=n,this.stsTokenManager=i,this.accessToken=i.accessToken,this.displayName=r.displayName||null,this.email=r.email||null,this.emailVerified=r.emailVerified||!1,this.phoneNumber=r.phoneNumber||null,this.photoURL=r.photoURL||null,this.isAnonymous=r.isAnonymous||!1,this.tenantId=r.tenantId||null,this.providerData=r.providerData?[...r.providerData]:[],this.metadata=new fh(r.createdAt||void 0,r.lastLoginAt||void 0)}async getIdToken(e){const t=await hh(this,this.stsTokenManager.getToken(this.auth,e));return Fu(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return async function(e,t=!1){const n=N(e),i=await n.getIdToken(t),r=lh(i);Fu(r&&r.exp&&r.auth_time&&r.iat,n.auth,"internal-error");const s="object"==typeof r.firebase?r.firebase:void 0,o=null==s?void 0:s.sign_in_provider;return{claims:r,token:i,authTime:ah(ch(r.auth_time)),issuedAtTime:ah(ch(r.iat)),expirationTime:ah(ch(r.exp)),signInProvider:o||null,signInSecondFactor:(null==s?void 0:s.sign_in_second_factor)||null}}(this,e)}reload(){return async function(e){const t=N(e);await ph(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}(this)}_assign(e){this!==e&&(Fu(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(e=>Object.assign({},e)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new vh(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){Fu(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let n=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),n=!0),t&&await ph(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(je(this.auth.app))return Promise.reject(Mu(this.auth));const e=await this.getIdToken();return await hh(this,
2450
- /**
2451
- * @license
2452
- * Copyright 2020 Google LLC
2453
- *
2454
- * Licensed under the Apache License, Version 2.0 (the "License");
2455
- * you may not use this file except in compliance with the License.
2456
- * You may obtain a copy of the License at
2457
- *
2458
- * http://www.apache.org/licenses/LICENSE-2.0
2459
- *
2460
- * Unless required by applicable law or agreed to in writing, software
2461
- * distributed under the License is distributed on an "AS IS" BASIS,
2462
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2463
- * See the License for the specific language governing permissions and
2464
- * limitations under the License.
2465
- */
2466
- async function(e,t){return Yu(e,"POST","/v1/accounts:delete",t)}(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 n,i,r,s,o,a,c,l;const u=null!==(n=t.displayName)&&void 0!==n?n:void 0,h=null!==(i=t.email)&&void 0!==i?i:void 0,d=null!==(r=t.phoneNumber)&&void 0!==r?r:void 0,f=null!==(s=t.photoURL)&&void 0!==s?s:void 0,p=null!==(o=t.tenantId)&&void 0!==o?o:void 0,g=null!==(a=t._redirectEventId)&&void 0!==a?a:void 0,m=null!==(c=t.createdAt)&&void 0!==c?c:void 0,y=null!==(l=t.lastLoginAt)&&void 0!==l?l:void 0,{uid:v,emailVerified:w,isAnonymous:b,providerData:_,stsTokenManager:S}=t;Fu(v&&S,e,"internal-error");const E=mh.fromJSON(this.name,S);Fu("string"==typeof v,e,"internal-error"),yh(u,e.name),yh(h,e.name),Fu("boolean"==typeof w,e,"internal-error"),Fu("boolean"==typeof b,e,"internal-error"),yh(d,e.name),yh(f,e.name),yh(p,e.name),yh(g,e.name),yh(m,e.name),yh(y,e.name);const T=new vh({uid:v,auth:e,email:h,emailVerified:w,displayName:u,isAnonymous:b,photoURL:f,phoneNumber:d,tenantId:p,stsTokenManager:E,createdAt:m,lastLoginAt:y});return _&&Array.isArray(_)&&(T.providerData=_.map(e=>Object.assign({},e))),g&&(T._redirectEventId=g),T}static async _fromIdTokenResponse(e,t,n=!1){const i=new mh;i.updateFromServerResponse(t);const r=new vh({uid:t.localId,auth:e,stsTokenManager:i,isAnonymous:n});return await ph(r),r}static async _fromGetAccountInfoResponse(e,t,n){const i=t.users[0];Fu(void 0!==i.localId,"internal-error");const r=void 0!==i.providerUserInfo?gh(i.providerUserInfo):[],s=!(i.email&&i.passwordHash||(null==r?void 0:r.length)),o=new mh;o.updateFromIdToken(n);const a=new vh({uid:i.localId,auth:e,stsTokenManager:o,isAnonymous:s}),c={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:r,metadata:new fh(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash||(null==r?void 0:r.length))};return Object.assign(a,c),a}}
2467
- /**
2468
- * @license
2469
- * Copyright 2020 Google LLC
2470
- *
2471
- * Licensed under the Apache License, Version 2.0 (the "License");
2472
- * you may not use this file except in compliance with the License.
2473
- * You may obtain a copy of the License at
2474
- *
2475
- * http://www.apache.org/licenses/LICENSE-2.0
2476
- *
2477
- * Unless required by applicable law or agreed to in writing, software
2478
- * distributed under the License is distributed on an "AS IS" BASIS,
2479
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2480
- * See the License for the specific language governing permissions and
2481
- * limitations under the License.
2482
- */const wh=new Map;function bh(e){Vu(e instanceof Function,"Expected a class definition");let t=wh.get(e);return t?(Vu(t instanceof e,"Instance stored in cache mismatched with class"),t):(t=new e,wh.set(e,t),t)}
2483
- /**
2484
- * @license
2485
- * Copyright 2019 Google LLC
2486
- *
2487
- * Licensed under the Apache License, Version 2.0 (the "License");
2488
- * you may not use this file except in compliance with the License.
2489
- * You may obtain a copy of the License at
2490
- *
2491
- * http://www.apache.org/licenses/LICENSE-2.0
2492
- *
2493
- * Unless required by applicable law or agreed to in writing, software
2494
- * distributed under the License is distributed on an "AS IS" BASIS,
2495
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2496
- * See the License for the specific language governing permissions and
2497
- * limitations under the License.
2498
- */class _h{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 void 0===t?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}_h.type="NONE";const Sh=_h;
2499
- /**
2500
- * @license
2501
- * Copyright 2019 Google LLC
2502
- *
2503
- * Licensed under the Apache License, Version 2.0 (the "License");
2504
- * you may not use this file except in compliance with the License.
2505
- * You may obtain a copy of the License at
2506
- *
2507
- * http://www.apache.org/licenses/LICENSE-2.0
2508
- *
2509
- * Unless required by applicable law or agreed to in writing, software
2510
- * distributed under the License is distributed on an "AS IS" BASIS,
2511
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2512
- * See the License for the specific language governing permissions and
2513
- * limitations under the License.
2514
- */function Eh(e,t,n){return`firebase:${e}:${t}:${n}`}class Th{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;const{config:i,name:r}=this.auth;this.fullUserKey=Eh(this.userKey,i.apiKey,r),this.fullPersistenceKey=Eh("persistence",i.apiKey,r),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("string"==typeof e){const t=await oh(this.auth,{idToken:e}).catch(()=>{});return t?vh._fromGetAccountInfoResponse(this.auth,t,e):null}return vh._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();return await this.removeCurrentUser(),this.persistence=e,t?this.setCurrentUser(t):void 0}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,n="authUser"){if(!t.length)return new Th(bh(Sh),e,n);const i=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e);let r=i[0]||bh(Sh);const s=Eh(n,e.config.apiKey,e.name);let o=null;for(const n of t)try{const t=await n._get(s);if(t){let i;if("string"==typeof t){const n=await oh(e,{idToken:t}).catch(()=>{});if(!n)break;i=await vh._fromGetAccountInfoResponse(e,n,t)}else i=vh._fromJSON(e,t);n!==r&&(o=i),r=n;break}}catch(e){}const a=i.filter(e=>e._shouldAllowMigration);return r._shouldAllowMigration&&a.length?(r=a[0],o&&await r._set(s,o.toJSON()),await Promise.all(t.map(async e=>{if(e!==r)try{await e._remove(s)}catch(e){}})),new Th(r,e,n)):new Th(r,e,n)}}
2515
- /**
2516
- * @license
2517
- * Copyright 2020 Google LLC
2518
- *
2519
- * Licensed under the Apache License, Version 2.0 (the "License");
2520
- * you may not use this file except in compliance with the License.
2521
- * You may obtain a copy of the License at
2522
- *
2523
- * http://www.apache.org/licenses/LICENSE-2.0
2524
- *
2525
- * Unless required by applicable law or agreed to in writing, software
2526
- * distributed under the License is distributed on an "AS IS" BASIS,
2527
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2528
- * See the License for the specific language governing permissions and
2529
- * limitations under the License.
2530
- */function Ih(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(Rh(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(Ch(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(Nh(t))return"Blackberry";if(Oh(t))return"Webos";if(kh(t))return"Safari";if((t.includes("chrome/")||Ah(t))&&!t.includes("edge/"))return"Chrome";if(xh(t))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=e.match(t);if(2===(null==n?void 0:n.length))return n[1]}return"Other"}function Ch(e=w()){return/firefox\//i.test(e)}function kh(e=w()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function Ah(e=w()){return/crios\//i.test(e)}function Rh(e=w()){return/iemobile/i.test(e)}function xh(e=w()){return/android/i.test(e)}function Nh(e=w()){return/blackberry/i.test(e)}function Oh(e=w()){return/webos/i.test(e)}function Lh(e=w()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function Ph(){return function(){const e=w();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0}()&&10===document.documentMode}function Dh(e=w()){return Lh(e)||xh(e)||Oh(e)||Nh(e)||/windows phone/i.test(e)||Rh(e)}
2531
- /**
2532
- * @license
2533
- * Copyright 2020 Google LLC
2534
- *
2535
- * Licensed under the Apache License, Version 2.0 (the "License");
2536
- * you may not use this file except in compliance with the License.
2537
- * You may obtain a copy of the License at
2538
- *
2539
- * http://www.apache.org/licenses/LICENSE-2.0
2540
- *
2541
- * Unless required by applicable law or agreed to in writing, software
2542
- * distributed under the License is distributed on an "AS IS" BASIS,
2543
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2544
- * See the License for the specific language governing permissions and
2545
- * limitations under the License.
2546
- */function Mh(e,t=[]){let n;switch(e){case"Browser":n=Ih(w());break;case"Worker":n=`${Ih(w())}-${e}`;break;default:n=e}const i=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${qe}/${i}`}
2547
- /**
2548
- * @license
2549
- * Copyright 2022 Google LLC
2550
- *
2551
- * Licensed under the Apache License, Version 2.0 (the "License");
2552
- * you may not use this file except in compliance with the License.
2553
- * You may obtain a copy of the License at
2554
- *
2555
- * http://www.apache.org/licenses/LICENSE-2.0
2556
- *
2557
- * Unless required by applicable law or agreed to in writing, software
2558
- * distributed under the License is distributed on an "AS IS" BASIS,
2559
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2560
- * See the License for the specific language governing permissions and
2561
- * limitations under the License.
2562
- */class zh{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const n=t=>new Promise((n,i)=>{try{n(e(t))}catch(e){i(e)}});n.onAbort=t,this.queue.push(n);const i=this.queue.length-1;return()=>{this.queue[i]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const n of this.queue)await n(e),n.onAbort&&t.push(n.onAbort)}catch(e){t.reverse();for(const e of t)try{e()}catch(e){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:null==e?void 0:e.message})}}}
2563
- /**
2564
- * @license
2565
- * Copyright 2023 Google LLC
2566
- *
2567
- * Licensed under the Apache License, Version 2.0 (the "License");
2568
- * you may not use this file except in compliance with the License.
2569
- * You may obtain a copy of the License at
2570
- *
2571
- * http://www.apache.org/licenses/LICENSE-2.0
2572
- *
2573
- * Unless required by applicable law or agreed to in writing, software
2574
- * distributed under the License is distributed on an "AS IS" BASIS,
2575
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2576
- * See the License for the specific language governing permissions and
2577
- * limitations under the License.
2578
- */class Fh{constructor(e){var t,n,i,r;const s=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=null!==(t=s.minPasswordLength)&&void 0!==t?t:6,s.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=s.maxPasswordLength),void 0!==s.containsLowercaseCharacter&&(this.customStrengthOptions.containsLowercaseLetter=s.containsLowercaseCharacter),void 0!==s.containsUppercaseCharacter&&(this.customStrengthOptions.containsUppercaseLetter=s.containsUppercaseCharacter),void 0!==s.containsNumericCharacter&&(this.customStrengthOptions.containsNumericCharacter=s.containsNumericCharacter),void 0!==s.containsNonAlphanumericCharacter&&(this.customStrengthOptions.containsNonAlphanumericCharacter=s.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,"ENFORCEMENT_STATE_UNSPECIFIED"===this.enforcementState&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=null!==(i=null===(n=e.allowedNonAlphanumericCharacters)||void 0===n?void 0:n.join(""))&&void 0!==i?i:"",this.forceUpgradeOnSignin=null!==(r=e.forceUpgradeOnSignin)&&void 0!==r&&r,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,n,i,r,s,o;const a={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,a),this.validatePasswordCharacterOptions(e,a),a.isValid&&(a.isValid=null===(t=a.meetsMinPasswordLength)||void 0===t||t),a.isValid&&(a.isValid=null===(n=a.meetsMaxPasswordLength)||void 0===n||n),a.isValid&&(a.isValid=null===(i=a.containsLowercaseLetter)||void 0===i||i),a.isValid&&(a.isValid=null===(r=a.containsUppercaseLetter)||void 0===r||r),a.isValid&&(a.isValid=null===(s=a.containsNumericCharacter)||void 0===s||s),a.isValid&&(a.isValid=null===(o=a.containsNonAlphanumericCharacter)||void 0===o||o),a}validatePasswordLengthOptions(e,t){const n=this.customStrengthOptions.minPasswordLength,i=this.customStrengthOptions.maxPasswordLength;n&&(t.meetsMinPasswordLength=e.length>=n),i&&(t.meetsMaxPasswordLength=e.length<=i)}validatePasswordCharacterOptions(e,t){let n;this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);for(let i=0;i<e.length;i++)n=e.charAt(i),this.updatePasswordCharacterOptionsStatuses(t,n>="a"&&n<="z",n>="A"&&n<="Z",n>="0"&&n<="9",this.allowedNonAlphanumericCharacters.includes(n))}updatePasswordCharacterOptionsStatuses(e,t,n,i,r){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=n)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=i)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=r))}}
2579
- /**
2580
- * @license
2581
- * Copyright 2020 Google LLC
2582
- *
2583
- * Licensed under the Apache License, Version 2.0 (the "License");
2584
- * you may not use this file except in compliance with the License.
2585
- * You may obtain a copy of the License at
2586
- *
2587
- * http://www.apache.org/licenses/LICENSE-2.0
2588
- *
2589
- * Unless required by applicable law or agreed to in writing, software
2590
- * distributed under the License is distributed on an "AS IS" BASIS,
2591
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2592
- * See the License for the specific language governing permissions and
2593
- * limitations under the License.
2594
- */class Uh{constructor(e,t,n,i){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=n,this.config=i,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Bh(this),this.idTokenSubscription=new Bh(this),this.beforeStateQueue=new zh(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=Ru,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=i.sdkClientVersion,this._persistenceManagerAvailable=new Promise(e=>this._resolvePersistenceManagerAvailable=e)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=bh(t)),this._initializationPromise=this.queue(async()=>{var n,i,r;if(!this._deleted&&(this.persistenceManager=await Th.create(this,e),null===(n=this._resolvePersistenceManagerAvailable)||void 0===n||n.call(this),!this._deleted)){if(null===(i=this._popupRedirectResolver)||void 0===i?void 0:i._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(t),this.lastNotifiedUid=(null===(r=this.currentUser)||void 0===r?void 0:r.uid)||null,this._deleted||(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();return this.currentUser||e?this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(e,!0):void 0}async initializeCurrentUserFromIdToken(e){try{const t=await oh(this,{idToken:e}),n=await vh._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(n)}catch(e){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",e),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if(je(this.app)){const e=this.app.settings.authIdToken;return e?new Promise(t=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(e).then(t,t))}):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let i=n,r=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const n=null===(t=this.redirectUser)||void 0===t?void 0:t._redirectEventId,s=null==i?void 0:i._redirectEventId,o=await this.tryRedirectSignIn(e);n&&n!==s||!(null==o?void 0:o.user)||(i=o.user,r=!0)}if(!i)return this.directlySetCurrentUser(null);if(!i._redirectEventId){if(r)try{await this.beforeStateQueue.runMiddleware(i)}catch(e){i=n,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(e))}return i?this.reloadAndSetCurrentUserOrClear(i):this.directlySetCurrentUser(null)}return Fu(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===i._redirectEventId?this.directlySetCurrentUser(i):this.reloadAndSetCurrentUserOrClear(i)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch(e){await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await ph(e)}catch(e){if("auth/network-request-failed"!==(null==e?void 0:e.code))return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;const e=navigator;return e.languages&&e.languages[0]||e.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(je(this.app))return Promise.reject(Mu(this));const t=e?N(e):null;return t&&Fu(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&&Fu(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 je(this.app)?Promise.reject(Mu(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return je(this.app)?Promise.reject(Mu(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(bh(e))})}_getRecaptchaConfig(){return null==this.tenantId?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 null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await async function(e,t={}){return Yu(e,"GET","/v2/passwordPolicy",Ju(e,t))}
2595
- /**
2596
- * @license
2597
- * Copyright 2023 Google LLC
2598
- *
2599
- * Licensed under the Apache License, Version 2.0 (the "License");
2600
- * you may not use this file except in compliance with the License.
2601
- * You may obtain a copy of the License at
2602
- *
2603
- * http://www.apache.org/licenses/LICENSE-2.0
2604
- *
2605
- * Unless required by applicable law or agreed to in writing, software
2606
- * distributed under the License is distributed on an "AS IS" BASIS,
2607
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2608
- * See the License for the specific language governing permissions and
2609
- * limitations under the License.
2610
- */(this),t=new Fh(e);null===this.tenantId?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new S("auth","Firebase",e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const n=this.onAuthStateChanged(()=>{n(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:await this.currentUser.getIdToken()};null!=this.tenantId&&(t.tenantId=this.tenantId),await async function(e,t){return Yu(e,"POST","/v2/accounts:revokeToken",Ju(e,t))}(this,t)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null===(e=this._currentUser)||void 0===e?void 0:e.toJSON()}}async _setRedirectUser(e,t){const n=await this.getOrInitRedirectPersistenceManager(t);return null===e?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&bh(e)||this._popupRedirectResolver;Fu(t,this,"argument-error"),this.redirectPersistenceManager=await Th.create(this,[bh(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,n;return this._isInitialized&&await this.queue(async()=>{}),(null===(t=this._currentUser)||void 0===t?void 0:t._redirectEventId)===e?this._currentUser:(null===(n=this.redirectUser)||void 0===n?void 0:n._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const n=null!==(t=null===(e=this.currentUser)||void 0===e?void 0:e.uid)&&void 0!==t?t:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,n,i){if(this._deleted)return()=>{};const r="function"==typeof t?t:t.next.bind(t);let s=!1;const o=this._isInitialized?Promise.resolve():this._initializationPromise;if(Fu(o,this,"internal-error"),o.then(()=>{s||r(this.currentUser)}),"function"==typeof t){const r=e.addObserver(t,n,i);return()=>{s=!0,r()}}{const n=e.addObserver(t);return()=>{s=!0,n()}}}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 Fu(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=Mh(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const n=await(null===(e=this.heartbeatServiceProvider.getImmediate({optional:!0}))||void 0===e?void 0:e.getHeartbeatsHeader());n&&(t["X-Firebase-Client"]=n);const i=await this._getAppCheckToken();return i&&(t["X-Firebase-AppCheck"]=i),t}async _getAppCheckToken(){var e;if(je(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const t=await(null===(e=this.appCheckServiceProvider.getImmediate({optional:!0}))||void 0===e?void 0:e.getToken());return(null==t?void 0:t.error)&&function(e,...t){Nu.logLevel<=M.WARN&&Nu.warn(`Auth (${qe}): ${e}`,...t)}(`Error while retrieving App Check token: ${t.error}`),null==t?void 0:t.token}}function Vh(e){return N(e)}class Bh{constructor(e){this.auth=e,this.observer=null,this.addObserver=function(e,t){const n=new R(e,t);return n.subscribe.bind(n)}(e=>this.observer=e)}get next(){return Fu(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}
2611
- /**
2612
- * @license
2613
- * Copyright 2020 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
- */let jh={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function Hh(e){return jh.loadJS(e)}class $h{constructor(){this.enterprise=new qh}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class qh{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}const Gh="NO_RECAPTCHA";class Kh{constructor(e){this.type="recaptcha-enterprise",this.auth=Vh(e)}async verify(e="verify",t=!1){async function n(e){if(!t){if(null==e.tenantId&&null!=e._agentRecaptchaConfig)return e._agentRecaptchaConfig.siteKey;if(null!=e.tenantId&&void 0!==e._tenantRecaptchaConfigs[e.tenantId])return e._tenantRecaptchaConfigs[e.tenantId].siteKey}return new Promise(async(t,n)=>{(async function(e,t){return Yu(e,"GET","/v2/recaptchaConfig",Ju(e,t))})(e,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(i=>{if(void 0!==i.recaptchaKey){const n=new sh(i);return null==e.tenantId?e._agentRecaptchaConfig=n:e._tenantRecaptchaConfigs[e.tenantId]=n,t(n.siteKey)}n(new Error("recaptcha Enterprise site key undefined"))}).catch(e=>{n(e)})})}function i(t,n,i){const r=window.grecaptcha;rh(r)?r.enterprise.ready(()=>{r.enterprise.execute(t,{action:e}).then(e=>{n(e)}).catch(()=>{n(Gh)})}):i(Error("No reCAPTCHA enterprise script loaded."))}if(this.auth.settings.appVerificationDisabledForTesting){return(new $h).execute("siteKey",{action:"verify"})}return new Promise((e,r)=>{n(this.auth).then(n=>{if(!t&&rh(window.grecaptcha))i(n,e,r);else{if("undefined"==typeof window)return void r(new Error("RecaptchaVerifier is only supported in browser"));let t=jh.recaptchaEnterpriseScript;0!==t.length&&(t+=n),Hh(t).then(()=>{i(n,e,r)}).catch(e=>{r(e)})}}).catch(e=>{r(e)})})}}async function Wh(e,t,n,i=!1,r=!1){const s=new Kh(e);let o;if(r)o=Gh;else try{o=await s.verify(n)}catch(e){o=await s.verify(n,!0)}const a=Object.assign({},t);if("mfaSmsEnrollment"===n||"mfaSmsSignIn"===n){if("phoneEnrollmentInfo"in a){const e=a.phoneEnrollmentInfo.phoneNumber,t=a.phoneEnrollmentInfo.recaptchaToken;Object.assign(a,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:t,captchaResponse:o,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in a){const e=a.phoneSignInInfo.recaptchaToken;Object.assign(a,{phoneSignInInfo:{recaptchaToken:e,captchaResponse:o,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return a}return i?Object.assign(a,{captchaResp:o}):Object.assign(a,{captchaResponse:o}),Object.assign(a,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(a,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),a}async function Qh(e,t,n,i,r){var s;if(null===(s=e._getRecaptchaConfig())||void 0===s?void 0:s.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const r=await Wh(e,t,n,"getOobCode"===n);return i(e,r)}return i(e,t).catch(async r=>{if("auth/missing-recaptcha-token"===r.code){console.log(`${n} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const r=await Wh(e,t,n,"getOobCode"===n);return i(e,r)}return Promise.reject(r)})}
2627
- /**
2628
- * @license
2629
- * Copyright 2020 Google LLC
2630
- *
2631
- * Licensed under the Apache License, Version 2.0 (the "License");
2632
- * you may not use this file except in compliance with the License.
2633
- * You may obtain a copy of the License at
2634
- *
2635
- * http://www.apache.org/licenses/LICENSE-2.0
2636
- *
2637
- * Unless required by applicable law or agreed to in writing, software
2638
- * distributed under the License is distributed on an "AS IS" BASIS,
2639
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2640
- * See the License for the specific language governing permissions and
2641
- * limitations under the License.
2642
- */function Jh(e,t,n){const i=Vh(e);Fu(/^https?:\/\//.test(t),i,"invalid-emulator-scheme");const r=Yh(t),{host:s,port:o}=function(e){const t=Yh(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};const i=n[2].split("@").pop()||"",r=/^(\[[^\]]+\])(:|$)/.exec(i);if(r){const e=r[1];return{host:e,port:Xh(i.substr(e.length+1))}}{const[e,t]=i.split(":");return{host:e,port:Xh(t)}}}(t),a=null===o?"":`:${o}`,c={url:`${r}//${s}${a}/`},l=Object.freeze({host:s,port:o,protocol:r.replace(":",""),options:Object.freeze({disableWarnings:!1})});if(!i._canInitEmulator)return Fu(i.config.emulator&&i.emulatorConfig,i,"emulator-config-failed"),void Fu(T(c,i.config.emulator)&&T(l,i.emulatorConfig),i,"emulator-config-failed");i.config.emulator=c,i.emulatorConfig=l,i.settings.appVerificationDisabledForTesting=!0,p(s)?(g(`${r}//${s}${a}`),v("Auth",!0)):function(){function e(){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)}"undefined"!=typeof console&&"function"==typeof console.info&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials.");"undefined"!=typeof window&&"undefined"!=typeof document&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",e):e())}
2643
- /**
2644
- * @license
2645
- * Copyright 2020 Google LLC
2646
- *
2647
- * Licensed under the Apache License, Version 2.0 (the "License");
2648
- * you may not use this file except in compliance with the License.
2649
- * You may obtain a copy of the License at
2650
- *
2651
- * http://www.apache.org/licenses/LICENSE-2.0
2652
- *
2653
- * Unless required by applicable law or agreed to in writing, software
2654
- * distributed under the License is distributed on an "AS IS" BASIS,
2655
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2656
- * See the License for the specific language governing permissions and
2657
- * limitations under the License.
2658
- */()}function Yh(e){const t=e.indexOf(":");return t<0?"":e.substr(0,t+1)}function Xh(e){if(!e)return null;const t=Number(e);return isNaN(t)?null:t}class Zh{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return Uu("not implemented")}_getIdTokenResponse(e){return Uu("not implemented")}_linkToIdToken(e,t){return Uu("not implemented")}_getReauthenticationResolver(e){return Uu("not implemented")}}
2659
- /**
2660
- * @license
2661
- * Copyright 2020 Google LLC
2662
- *
2663
- * Licensed under the Apache License, Version 2.0 (the "License");
2664
- * you may not use this file except in compliance with the License.
2665
- * You may obtain a copy of the License at
2666
- *
2667
- * http://www.apache.org/licenses/LICENSE-2.0
2668
- *
2669
- * Unless required by applicable law or agreed to in writing, software
2670
- * distributed under the License is distributed on an "AS IS" BASIS,
2671
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2672
- * See the License for the specific language governing permissions and
2673
- * limitations under the License.
2674
- */async function ed(e,t){return Yu(e,"POST","/v1/accounts:signUp",t)}
2675
- /**
2676
- * @license
2677
- * Copyright 2020 Google LLC
2678
- *
2679
- * Licensed under the Apache License, Version 2.0 (the "License");
2680
- * you may not use this file except in compliance with the License.
2681
- * You may obtain a copy of the License at
2682
- *
2683
- * http://www.apache.org/licenses/LICENSE-2.0
2684
- *
2685
- * Unless required by applicable law or agreed to in writing, software
2686
- * distributed under the License is distributed on an "AS IS" BASIS,
2687
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2688
- * See the License for the specific language governing permissions and
2689
- * limitations under the License.
2690
- */async function td(e,t){return Zu(e,"POST","/v1/accounts:signInWithPassword",Ju(e,t))}async function nd(e,t){return async function(e,t){return Yu(e,"POST","/v1/accounts:sendOobCode",Ju(e,t))}(e,t)}
2691
- /**
2692
- * @license
2693
- * Copyright 2020 Google LLC
2694
- *
2695
- * Licensed under the Apache License, Version 2.0 (the "License");
2696
- * you may not use this file except in compliance with the License.
2697
- * You may obtain a copy of the License at
2698
- *
2699
- * http://www.apache.org/licenses/LICENSE-2.0
2700
- *
2701
- * Unless required by applicable law or agreed to in writing, software
2702
- * distributed under the License is distributed on an "AS IS" BASIS,
2703
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2704
- * See the License for the specific language governing permissions and
2705
- * limitations under the License.
2706
- */
2707
- /**
2708
- * @license
2709
- * Copyright 2020 Google LLC
2710
- *
2711
- * Licensed under the Apache License, Version 2.0 (the "License");
2712
- * you may not use this file except in compliance with the License.
2713
- * You may obtain a copy of the License at
2714
- *
2715
- * http://www.apache.org/licenses/LICENSE-2.0
2716
- *
2717
- * Unless required by applicable law or agreed to in writing, software
2718
- * distributed under the License is distributed on an "AS IS" BASIS,
2719
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2720
- * See the License for the specific language governing permissions and
2721
- * limitations under the License.
2722
- */
2723
- class id extends Zh{constructor(e,t,n,i=null){super("password",n),this._email=e,this._password=t,this._tenantId=i}static _fromEmailAndPassword(e,t){return new id(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new id(e,t,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t="string"==typeof e?JSON.parse(e):e;if((null==t?void 0:t.email)&&(null==t?void 0:t.password)){if("password"===t.signInMethod)return this._fromEmailAndPassword(t.email,t.password);if("emailLink"===t.signInMethod)return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":return Qh(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signInWithPassword",td);case"emailLink":return async function(e,t){return Zu(e,"POST","/v1/accounts:signInWithEmailLink",Ju(e,t))}(e,{email:this._email,oobCode:this._password});default:Lu(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return Qh(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",ed);case"emailLink":return async function(e,t){return Zu(e,"POST","/v1/accounts:signInWithEmailLink",Ju(e,t))}(e,{idToken:t,email:this._email,oobCode:this._password});default:Lu(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}
2724
- /**
2725
- * @license
2726
- * Copyright 2020 Google LLC
2727
- *
2728
- * Licensed under the Apache License, Version 2.0 (the "License");
2729
- * you may not use this file except in compliance with the License.
2730
- * You may obtain a copy of the License at
2731
- *
2732
- * http://www.apache.org/licenses/LICENSE-2.0
2733
- *
2734
- * Unless required by applicable law or agreed to in writing, software
2735
- * distributed under the License is distributed on an "AS IS" BASIS,
2736
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2737
- * See the License for the specific language governing permissions and
2738
- * limitations under the License.
2739
- */async function rd(e,t){return Zu(e,"POST","/v1/accounts:signInWithIdp",Ju(e,t))}
2740
- /**
2741
- * @license
2742
- * Copyright 2020 Google LLC
2743
- *
2744
- * Licensed under the Apache License, Version 2.0 (the "License");
2745
- * you may not use this file except in compliance with the License.
2746
- * You may obtain a copy of the License at
2747
- *
2748
- * http://www.apache.org/licenses/LICENSE-2.0
2749
- *
2750
- * Unless required by applicable law or agreed to in writing, software
2751
- * distributed under the License is distributed on an "AS IS" BASIS,
2752
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2753
- * See the License for the specific language governing permissions and
2754
- * limitations under the License.
2755
- */class sd extends Zh{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new sd(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):Lu("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="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:i}=t,r=Cu(t,["providerId","signInMethod"]);if(!n||!i)return null;const s=new sd(n,i);return s.idToken=r.idToken||void 0,s.accessToken=r.accessToken||void 0,s.secret=r.secret,s.nonce=r.nonce,s.pendingToken=r.pendingToken||null,s}_getIdTokenResponse(e){return rd(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,rd(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,rd(e,t)}buildRequest(){const e={requestUri:"http://localhost",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=C(t)}return e}}
2756
- /**
2757
- * @license
2758
- * Copyright 2020 Google LLC
2759
- *
2760
- * Licensed under the Apache License, Version 2.0 (the "License");
2761
- * you may not use this file except in compliance with the License.
2762
- * You may obtain a copy of the License at
2763
- *
2764
- * http://www.apache.org/licenses/LICENSE-2.0
2765
- *
2766
- * Unless required by applicable law or agreed to in writing, software
2767
- * distributed under the License is distributed on an "AS IS" BASIS,
2768
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2769
- * See the License for the specific language governing permissions and
2770
- * limitations under the License.
2771
- */class od{constructor(e){var t,n,i,r,s,o;const a=k(A(e)),c=null!==(t=a.apiKey)&&void 0!==t?t:null,l=null!==(n=a.oobCode)&&void 0!==n?n:null,u=function(e){switch(e){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}}(null!==(i=a.mode)&&void 0!==i?i:null);Fu(c&&l&&u,"argument-error"),this.apiKey=c,this.operation=u,this.code=l,this.continueUrl=null!==(r=a.continueUrl)&&void 0!==r?r:null,this.languageCode=null!==(s=a.lang)&&void 0!==s?s:null,this.tenantId=null!==(o=a.tenantId)&&void 0!==o?o:null}static parseLink(e){const t=function(e){const t=k(A(e)).link,n=t?k(A(t)).deep_link_id:null,i=k(A(e)).deep_link_id;return(i?k(A(i)).link:null)||i||n||t||e}(e);try{return new od(t)}catch(e){return null}}}
2772
- /**
2773
- * @license
2774
- * Copyright 2020 Google LLC
2775
- *
2776
- * Licensed under the Apache License, Version 2.0 (the "License");
2777
- * you may not use this file except in compliance with the License.
2778
- * You may obtain a copy of the License at
2779
- *
2780
- * http://www.apache.org/licenses/LICENSE-2.0
2781
- *
2782
- * Unless required by applicable law or agreed to in writing, software
2783
- * distributed under the License is distributed on an "AS IS" BASIS,
2784
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2785
- * See the License for the specific language governing permissions and
2786
- * limitations under the License.
2787
- */class ad{constructor(){this.providerId=ad.PROVIDER_ID}static credential(e,t){return id._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const n=od.parseLink(t);return Fu(n,"argument-error"),id._fromEmailAndCode(e,n.code,n.tenantId)}}ad.PROVIDER_ID="password",ad.EMAIL_PASSWORD_SIGN_IN_METHOD="password",ad.EMAIL_LINK_SIGN_IN_METHOD="emailLink";
2788
- /**
2789
- * @license
2790
- * Copyright 2020 Google LLC
2791
- *
2792
- * Licensed under the Apache License, Version 2.0 (the "License");
2793
- * you may not use this file except in compliance with the License.
2794
- * You may obtain a copy of the License at
2795
- *
2796
- * http://www.apache.org/licenses/LICENSE-2.0
2797
- *
2798
- * Unless required by applicable law or agreed to in writing, software
2799
- * distributed under the License is distributed on an "AS IS" BASIS,
2800
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2801
- * See the License for the specific language governing permissions and
2802
- * limitations under the License.
2803
- */
2804
- class cd{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}}
2805
- /**
2806
- * @license
2807
- * Copyright 2019 Google LLC
2808
- *
2809
- * Licensed under the Apache License, Version 2.0 (the "License");
2810
- * you may not use this file except in compliance with the License.
2811
- * You may obtain a copy of the License at
2812
- *
2813
- * http://www.apache.org/licenses/LICENSE-2.0
2814
- *
2815
- * Unless required by applicable law or agreed to in writing, software
2816
- * distributed under the License is distributed on an "AS IS" BASIS,
2817
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2818
- * See the License for the specific language governing permissions and
2819
- * limitations under the License.
2820
- */class ld extends cd{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}
2821
- /**
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
- */class ud extends ld{constructor(){super("facebook.com")}static credential(e){return sd._fromParams({providerId:ud.PROVIDER_ID,signInMethod:ud.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return ud.credentialFromTaggedObject(e)}static credentialFromError(e){return ud.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return ud.credential(e.oauthAccessToken)}catch(e){return null}}}ud.FACEBOOK_SIGN_IN_METHOD="facebook.com",ud.PROVIDER_ID="facebook.com";
2837
- /**
2838
- * @license
2839
- * Copyright 2020 Google LLC
2840
- *
2841
- * Licensed under the Apache License, Version 2.0 (the "License");
2842
- * you may not use this file except in compliance with the License.
2843
- * You may obtain a copy of the License at
2844
- *
2845
- * http://www.apache.org/licenses/LICENSE-2.0
2846
- *
2847
- * Unless required by applicable law or agreed to in writing, software
2848
- * distributed under the License is distributed on an "AS IS" BASIS,
2849
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2850
- * See the License for the specific language governing permissions and
2851
- * limitations under the License.
2852
- */
2853
- class hd extends ld{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return sd._fromParams({providerId:hd.PROVIDER_ID,signInMethod:hd.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return hd.credentialFromTaggedObject(e)}static credentialFromError(e){return hd.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return hd.credential(t,n)}catch(e){return null}}}hd.GOOGLE_SIGN_IN_METHOD="google.com",hd.PROVIDER_ID="google.com";
2854
- /**
2855
- * @license
2856
- * Copyright 2020 Google LLC
2857
- *
2858
- * Licensed under the Apache License, Version 2.0 (the "License");
2859
- * you may not use this file except in compliance with the License.
2860
- * You may obtain a copy of the License at
2861
- *
2862
- * http://www.apache.org/licenses/LICENSE-2.0
2863
- *
2864
- * Unless required by applicable law or agreed to in writing, software
2865
- * distributed under the License is distributed on an "AS IS" BASIS,
2866
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2867
- * See the License for the specific language governing permissions and
2868
- * limitations under the License.
2869
- */
2870
- class dd extends ld{constructor(){super("github.com")}static credential(e){return sd._fromParams({providerId:dd.PROVIDER_ID,signInMethod:dd.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return dd.credentialFromTaggedObject(e)}static credentialFromError(e){return dd.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return dd.credential(e.oauthAccessToken)}catch(e){return null}}}dd.GITHUB_SIGN_IN_METHOD="github.com",dd.PROVIDER_ID="github.com";
2871
- /**
2872
- * @license
2873
- * Copyright 2020 Google LLC
2874
- *
2875
- * Licensed under the Apache License, Version 2.0 (the "License");
2876
- * you may not use this file except in compliance with the License.
2877
- * You may obtain a copy of the License at
2878
- *
2879
- * http://www.apache.org/licenses/LICENSE-2.0
2880
- *
2881
- * Unless required by applicable law or agreed to in writing, software
2882
- * distributed under the License is distributed on an "AS IS" BASIS,
2883
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2884
- * See the License for the specific language governing permissions and
2885
- * limitations under the License.
2886
- */
2887
- class fd extends ld{constructor(){super("twitter.com")}static credential(e,t){return sd._fromParams({providerId:fd.PROVIDER_ID,signInMethod:fd.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return fd.credentialFromTaggedObject(e)}static credentialFromError(e){return fd.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return fd.credential(t,n)}catch(e){return null}}}fd.TWITTER_SIGN_IN_METHOD="twitter.com",fd.PROVIDER_ID="twitter.com";
2888
- /**
2889
- * @license
2890
- * Copyright 2020 Google LLC
2891
- *
2892
- * Licensed under the Apache License, Version 2.0 (the "License");
2893
- * you may not use this file except in compliance with the License.
2894
- * You may obtain a copy of the License at
2895
- *
2896
- * http://www.apache.org/licenses/LICENSE-2.0
2897
- *
2898
- * Unless required by applicable law or agreed to in writing, software
2899
- * distributed under the License is distributed on an "AS IS" BASIS,
2900
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2901
- * See the License for the specific language governing permissions and
2902
- * limitations under the License.
2903
- */
2904
- class pd{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,n,i=!1){const r=await vh._fromIdTokenResponse(e,n,i),s=gd(n);return new pd({user:r,providerId:s,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);const i=gd(n);return new pd({user:e,providerId:i,_tokenResponse:n,operationType:t})}}function gd(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}
2905
- /**
2906
- * @license
2907
- * Copyright 2020 Google LLC
2908
- *
2909
- * Licensed under the Apache License, Version 2.0 (the "License");
2910
- * you may not use this file except in compliance with the License.
2911
- * You may obtain a copy of the License at
2912
- *
2913
- * http://www.apache.org/licenses/LICENSE-2.0
2914
- *
2915
- * Unless required by applicable law or agreed to in writing, software
2916
- * distributed under the License is distributed on an "AS IS" BASIS,
2917
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2918
- * See the License for the specific language governing permissions and
2919
- * limitations under the License.
2920
- */class md extends _{constructor(e,t,n,i){var r;super(t.code,t.message),this.operationType=n,this.user=i,Object.setPrototypeOf(this,md.prototype),this.customData={appName:e.name,tenantId:null!==(r=e.tenantId)&&void 0!==r?r:void 0,_serverResponse:t.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(e,t,n,i){return new md(e,t,n,i)}}function yd(e,t,n,i){return("reauthenticate"===t?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(n=>{if("auth/multi-factor-auth-required"===n.code)throw md._fromErrorAndOperation(e,n,t,i);throw n})}
2921
- /**
2922
- * @license
2923
- * Copyright 2020 Google LLC
2924
- *
2925
- * Licensed under the Apache License, Version 2.0 (the "License");
2926
- * you may not use this file except in compliance with the License.
2927
- * You may obtain a copy of the License at
2928
- *
2929
- * http://www.apache.org/licenses/LICENSE-2.0
2930
- *
2931
- * Unless required by applicable law or agreed to in writing, software
2932
- * distributed under the License is distributed on an "AS IS" BASIS,
2933
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2934
- * See the License for the specific language governing permissions and
2935
- * limitations under the License.
2936
- */
2937
- async function vd(e,t,n=!1){if(je(e.app))return Promise.reject(Mu(e));const i="signIn",r=await yd(e,i,t),s=await pd._fromIdTokenResponse(e,i,r);return n||await e._updateCurrentUser(s.user),s}
2938
- /**
2939
- * @license
2940
- * Copyright 2020 Google LLC
2941
- *
2942
- * Licensed under the Apache License, Version 2.0 (the "License");
2943
- * you may not use this file except in compliance with the License.
2944
- * You may obtain a copy of the License at
2945
- *
2946
- * http://www.apache.org/licenses/LICENSE-2.0
2947
- *
2948
- * Unless required by applicable law or agreed to in writing, software
2949
- * distributed under the License is distributed on an "AS IS" BASIS,
2950
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2951
- * See the License for the specific language governing permissions and
2952
- * limitations under the License.
2953
- */
2954
- async function wd(e){const t=Vh(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function bd(e,t,n){await async function(e,t){return Yu(e,"POST","/v1/accounts:resetPassword",Ju(e,t))}(N(e),{oobCode:t,newPassword:n}).catch(async t=>{throw"auth/password-does-not-meet-requirements"===t.code&&wd(e),t})}function _d(e,t,n){return je(e.app)?Promise.reject(Mu(e)):async function(e,t){return vd(Vh(e),t)}(N(e),ad.credential(t,n)).catch(async t=>{throw"auth/password-does-not-meet-requirements"===t.code&&wd(e),t})}const Sd="__sak";
2955
- /**
2956
- * @license
2957
- * Copyright 2019 Google LLC
2958
- *
2959
- * Licensed under the Apache License, Version 2.0 (the "License");
2960
- * you may not use this file except in compliance with the License.
2961
- * You may obtain a copy of the License at
2962
- *
2963
- * http://www.apache.org/licenses/LICENSE-2.0
2964
- *
2965
- * Unless required by applicable law or agreed to in writing, software
2966
- * distributed under the License is distributed on an "AS IS" BASIS,
2967
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2968
- * See the License for the specific language governing permissions and
2969
- * limitations under the License.
2970
- */class Ed{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(Sd,"1"),this.storage.removeItem(Sd),Promise.resolve(!0)):Promise.resolve(!1)}catch(e){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()}}
2971
- /**
2972
- * @license
2973
- * Copyright 2020 Google LLC
2974
- *
2975
- * Licensed under the Apache License, Version 2.0 (the "License");
2976
- * you may not use this file except in compliance with the License.
2977
- * You may obtain a copy of the License at
2978
- *
2979
- * http://www.apache.org/licenses/LICENSE-2.0
2980
- *
2981
- * Unless required by applicable law or agreed to in writing, software
2982
- * distributed under the License is distributed on an "AS IS" BASIS,
2983
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2984
- * See the License for the specific language governing permissions and
2985
- * limitations under the License.
2986
- */class Td extends Ed{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=Dh(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const n=this.storage.getItem(t),i=this.localCache[t];n!==i&&e(t,i,n)}}onStorageEvent(e,t=!1){if(!e.key)return void this.forAllChangedKeys((e,t,n)=>{this.notifyListeners(e,n)});const n=e.key;t?this.detachListener():this.stopPolling();const i=()=>{const e=this.storage.getItem(n);(t||this.localCache[n]!==e)&&this.notifyListeners(n,e)},r=this.storage.getItem(n);Ph()&&r!==e.newValue&&e.newValue!==e.oldValue?setTimeout(i,10):i()}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const e of Array.from(n))e(t?JSON.parse(t):t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:n}),!0)})},1e3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){0===Object.keys(this.listeners).length&&(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),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&(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]}}Td.type="LOCAL";const Id=Td;
2987
- /**
2988
- * @license
2989
- * Copyright 2020 Google LLC
2990
- *
2991
- * Licensed under the Apache License, Version 2.0 (the "License");
2992
- * you may not use this file except in compliance with the License.
2993
- * You may obtain a copy of the License at
2994
- *
2995
- * http://www.apache.org/licenses/LICENSE-2.0
2996
- *
2997
- * Unless required by applicable law or agreed to in writing, software
2998
- * distributed under the License is distributed on an "AS IS" BASIS,
2999
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3000
- * See the License for the specific language governing permissions and
3001
- * limitations under the License.
3002
- */class Cd extends Ed{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}Cd.type="SESSION";const kd=Cd;
3003
- /**
3004
- * @license
3005
- * Copyright 2019 Google LLC
3006
- *
3007
- * Licensed under the Apache License, Version 2.0 (the "License");
3008
- * you may not use this file except in compliance with the License.
3009
- * You may obtain a copy of the License at
3010
- *
3011
- * http://www.apache.org/licenses/LICENSE-2.0
3012
- *
3013
- * Unless required by applicable law or agreed to in writing, software
3014
- * distributed under the License is distributed on an "AS IS" BASIS,
3015
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3016
- * See the License for the specific language governing permissions and
3017
- * limitations under the License.
3018
- */
3019
- /**
3020
- * @license
3021
- * Copyright 2019 Google LLC
3022
- *
3023
- * Licensed under the Apache License, Version 2.0 (the "License");
3024
- * you may not use this file except in compliance with the License.
3025
- * You may obtain a copy of the License at
3026
- *
3027
- * http://www.apache.org/licenses/LICENSE-2.0
3028
- *
3029
- * Unless required by applicable law or agreed to in writing, software
3030
- * distributed under the License is distributed on an "AS IS" BASIS,
3031
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3032
- * See the License for the specific language governing permissions and
3033
- * limitations under the License.
3034
- */
3035
- class Ad{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(t=>t.isListeningto(e));if(t)return t;const n=new Ad(e);return this.receivers.push(n),n}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:n,eventType:i,data:r}=t.data,s=this.handlersMap[i];if(!(null==s?void 0:s.size))return;t.ports[0].postMessage({status:"ack",eventId:n,eventType:i});const o=Array.from(s).map(async e=>e(t.origin,r)),a=await function(e){return Promise.all(e.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}}))}(o);t.ports[0].postMessage({status:"done",eventId:n,eventType:i,response:a})}_subscribe(e,t){0===Object.keys(this.handlersMap).length&&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&&0!==this.handlersMap[e].size||delete this.handlersMap[e],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}
3036
- /**
3037
- * @license
3038
- * Copyright 2020 Google LLC
3039
- *
3040
- * Licensed under the Apache License, Version 2.0 (the "License");
3041
- * you may not use this file except in compliance with the License.
3042
- * You may obtain a copy of the License at
3043
- *
3044
- * http://www.apache.org/licenses/LICENSE-2.0
3045
- *
3046
- * Unless required by applicable law or agreed to in writing, software
3047
- * distributed under the License is distributed on an "AS IS" BASIS,
3048
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3049
- * See the License for the specific language governing permissions and
3050
- * limitations under the License.
3051
- */
3052
- function Rd(e="",t=10){let n="";for(let e=0;e<t;e++)n+=Math.floor(10*Math.random());return e+n}
3053
- /**
3054
- * @license
3055
- * Copyright 2019 Google LLC
3056
- *
3057
- * Licensed under the Apache License, Version 2.0 (the "License");
3058
- * you may not use this file except in compliance with the License.
3059
- * You may obtain a copy of the License at
3060
- *
3061
- * http://www.apache.org/licenses/LICENSE-2.0
3062
- *
3063
- * Unless required by applicable law or agreed to in writing, software
3064
- * distributed under the License is distributed on an "AS IS" BASIS,
3065
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3066
- * See the License for the specific language governing permissions and
3067
- * limitations under the License.
3068
- */Ad.receivers=[];class xd{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,n=50){const i="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!i)throw new Error("connection_unavailable");let r,s;return new Promise((o,a)=>{const c=Rd("",20);i.port1.start();const l=setTimeout(()=>{a(new Error("unsupported_event"))},n);s={messageChannel:i,onMessage(e){const t=e;if(t.data.eventId===c)switch(t.data.status){case"ack":clearTimeout(l),r=setTimeout(()=>{a(new Error("timeout"))},3e3);break;case"done":clearTimeout(r),o(t.data.response);break;default:clearTimeout(l),clearTimeout(r),a(new Error("invalid_response"))}}},this.handlers.add(s),i.port1.addEventListener("message",s.onMessage),this.target.postMessage({eventType:e,eventId:c,data:t},[i.port2])}).finally(()=>{s&&this.removeMessageHandler(s)})}}
3069
- /**
3070
- * @license
3071
- * Copyright 2020 Google LLC
3072
- *
3073
- * Licensed under the Apache License, Version 2.0 (the "License");
3074
- * you may not use this file except in compliance with the License.
3075
- * You may obtain a copy of the License at
3076
- *
3077
- * http://www.apache.org/licenses/LICENSE-2.0
3078
- *
3079
- * Unless required by applicable law or agreed to in writing, software
3080
- * distributed under the License is distributed on an "AS IS" BASIS,
3081
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3082
- * See the License for the specific language governing permissions and
3083
- * limitations under the License.
3084
- */function Nd(){return window}
3085
- /**
3086
- * @license
3087
- * Copyright 2020 Google LLC.
3088
- *
3089
- * Licensed under the Apache License, Version 2.0 (the "License");
3090
- * you may not use this file except in compliance with the License.
3091
- * You may obtain a copy of the License at
3092
- *
3093
- * http://www.apache.org/licenses/LICENSE-2.0
3094
- *
3095
- * Unless required by applicable law or agreed to in writing, software
3096
- * distributed under the License is distributed on an "AS IS" BASIS,
3097
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3098
- * See the License for the specific language governing permissions and
3099
- * limitations under the License.
3100
- */
3101
- function Od(){return void 0!==Nd().WorkerGlobalScope&&"function"==typeof Nd().importScripts}
3102
- /**
3103
- * @license
3104
- * Copyright 2019 Google LLC
3105
- *
3106
- * Licensed under the Apache License, Version 2.0 (the "License");
3107
- * you may not use this file except in compliance with the License.
3108
- * You may obtain a copy of the License at
3109
- *
3110
- * http://www.apache.org/licenses/LICENSE-2.0
3111
- *
3112
- * Unless required by applicable law or agreed to in writing, software
3113
- * distributed under the License is distributed on an "AS IS" BASIS,
3114
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3115
- * See the License for the specific language governing permissions and
3116
- * limitations under the License.
3117
- */
3118
- const Ld="firebaseLocalStorageDb",Pd="firebaseLocalStorage",Dd="fbase_key";class Md{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 zd(e,t){return e.transaction([Pd],t?"readwrite":"readonly").objectStore(Pd)}function Fd(){const e=indexedDB.open(Ld,1);return new Promise((t,n)=>{e.addEventListener("error",()=>{n(e.error)}),e.addEventListener("upgradeneeded",()=>{const t=e.result;try{t.createObjectStore(Pd,{keyPath:Dd})}catch(e){n(e)}}),e.addEventListener("success",async()=>{const n=e.result;n.objectStoreNames.contains(Pd)?t(n):(n.close(),await function(){const e=indexedDB.deleteDatabase(Ld);return new Md(e).toPromise()}(),t(await Fd()))})})}async function Ud(e,t,n){const i=zd(e,!0).put({[Dd]:t,value:n});return new Md(i).toPromise()}function Vd(e,t){const n=zd(e,!0).delete(t);return new Md(n).toPromise()}class Bd{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=await Fd()),this.db}async _withRetries(e){let t=0;for(;;)try{const t=await this._openDb();return await e(t)}catch(e){if(t++>3)throw e;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Od()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Ad._getInstance(Od()?self:null),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 async function(){if(!(null===navigator||void 0===navigator?void 0:navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch(e){return null}}(),!this.activeServiceWorker)return;this.sender=new xd(this.activeServiceWorker);const n=await this.sender._send("ping",{},800);n&&(null===(e=n[0])||void 0===e?void 0:e.fulfilled)&&(null===(t=n[0])||void 0===t?void 0:t.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){var t;if(this.sender&&this.activeServiceWorker&&((null===(t=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===t?void 0:t.controller)||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch(t){}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await Fd();return await Ud(e,Sd,"1"),await Vd(e,Sd),!0}catch(e){}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(n=>Ud(n,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(t=>async function(e,t){const n=zd(e,!1).get(t),i=await new Md(n).toPromise();return void 0===i?null:i.value}(t,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Vd(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(e=>{const t=zd(e,!1).getAll();return new Md(t).toPromise()});if(!e)return[];if(0!==this.pendingWrites)return[];const t=[],n=new Set;if(0!==e.length)for(const{fbase_key:i,value:r}of e)n.add(i),JSON.stringify(this.localCache[i])!==JSON.stringify(r)&&(this.notifyListeners(i,r),t.push(i));for(const e of Object.keys(this.localCache))this.localCache[e]&&!n.has(e)&&(this.notifyListeners(e,null),t.push(e));return t}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const e of Array.from(n))e(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){0===Object.keys(this.listeners).length&&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),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&this.stopPolling()}}Bd.type="LOCAL";const jd=Bd;new $u(3e4,6e4);
3119
- /**
3120
- * @license
3121
- * Copyright 2019 Google LLC
3122
- *
3123
- * Licensed under the Apache License, Version 2.0 (the "License");
3124
- * you may not use this file except in compliance with the License.
3125
- * You may obtain a copy of the License at
3126
- *
3127
- * http://www.apache.org/licenses/LICENSE-2.0
3128
- *
3129
- * Unless required by applicable law or agreed to in writing, software
3130
- * distributed under the License is distributed on an "AS IS" BASIS,
3131
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3132
- * See the License for the specific language governing permissions and
3133
- * limitations under the License.
3134
- */
3135
- class Hd extends Zh{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return rd(e,this._buildIdpRequest())}_linkToIdToken(e,t){return rd(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return rd(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 $d(e){return vd(e.auth,new Hd(e),e.bypassAuthState)}function qd(e){const{auth:t,user:n}=e;return Fu(n,t,"internal-error"),
3136
- /**
3137
- * @license
3138
- * Copyright 2019 Google LLC
3139
- *
3140
- * Licensed under the Apache License, Version 2.0 (the "License");
3141
- * you may not use this file except in compliance with the License.
3142
- * You may obtain a copy of the License at
3143
- *
3144
- * http://www.apache.org/licenses/LICENSE-2.0
3145
- *
3146
- * Unless required by applicable law or agreed to in writing, software
3147
- * distributed under the License is distributed on an "AS IS" BASIS,
3148
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3149
- * See the License for the specific language governing permissions and
3150
- * limitations under the License.
3151
- */
3152
- async function(e,t,n=!1){const{auth:i}=e;if(je(i.app))return Promise.reject(Mu(i));const r="reauthenticate";try{const s=await hh(e,yd(i,r,t,e),n);Fu(s.idToken,i,"internal-error");const o=lh(s.idToken);Fu(o,i,"internal-error");const{sub:a}=o;return Fu(e.uid===a,i,"user-mismatch"),pd._forOperation(e,r,s)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&Lu(i,"user-mismatch"),e}}(n,new Hd(e),e.bypassAuthState)}async function Gd(e){const{auth:t,user:n}=e;return Fu(n,t,"internal-error"),async function(e,t,n=!1){const i=await hh(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return pd._forOperation(e,"link",i)}(n,new Hd(e),e.bypassAuthState)}
3153
- /**
3154
- * @license
3155
- * Copyright 2020 Google LLC
3156
- *
3157
- * Licensed under the Apache License, Version 2.0 (the "License");
3158
- * you may not use this file except in compliance with the License.
3159
- * You may obtain a copy of the License at
3160
- *
3161
- * http://www.apache.org/licenses/LICENSE-2.0
3162
- *
3163
- * Unless required by applicable law or agreed to in writing, software
3164
- * distributed under the License is distributed on an "AS IS" BASIS,
3165
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3166
- * See the License for the specific language governing permissions and
3167
- * limitations under the License.
3168
- */class Kd{constructor(e,t,n,i,r=!1){this.auth=e,this.resolver=n,this.user=i,this.bypassAuthState=r,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(e){this.reject(e)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:n,postBody:i,tenantId:r,error:s,type:o}=e;if(s)return void this.reject(s);const a={auth:this.auth,requestUri:t,sessionId:n,tenantId:r||void 0,postBody:i||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(o)(a))}catch(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return $d;case"linkViaPopup":case"linkViaRedirect":return Gd;case"reauthViaPopup":case"reauthViaRedirect":return qd;default:Lu(this.auth,"internal-error")}}resolve(e){Vu(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Vu(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()}}
3169
- /**
3170
- * @license
3171
- * Copyright 2020 Google LLC
3172
- *
3173
- * Licensed under the Apache License, Version 2.0 (the "License");
3174
- * you may not use this file except in compliance with the License.
3175
- * You may obtain a copy of the License at
3176
- *
3177
- * http://www.apache.org/licenses/LICENSE-2.0
3178
- *
3179
- * Unless required by applicable law or agreed to in writing, software
3180
- * distributed under the License is distributed on an "AS IS" BASIS,
3181
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3182
- * See the License for the specific language governing permissions and
3183
- * limitations under the License.
3184
- */const Wd=new $u(2e3,1e4);class Qd extends Kd{constructor(e,t,n,i,r){super(e,t,i,r),this.provider=n,this.authWindow=null,this.pollId=null,Qd.currentPopupAction&&Qd.currentPopupAction.cancel(),Qd.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return Fu(e,this.auth,"internal-error"),e}async onExecution(){Vu(1===this.filter.length,"Popup operations only handle one event");const e=Rd();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(e=>{this.reject(e)}),this.resolver._isIframeWebStorageSupported(this.auth,e=>{e||this.reject(Pu(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return(null===(e=this.authWindow)||void 0===e?void 0:e.associatedEvent)||null}cancel(){this.reject(Pu(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Qd.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,n;(null===(n=null===(t=this.authWindow)||void 0===t?void 0:t.window)||void 0===n?void 0:n.closed)?this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Pu(this.auth,"popup-closed-by-user"))},8e3):this.pollId=window.setTimeout(e,Wd.get())};e()}}Qd.currentPopupAction=null;
3185
- /**
3186
- * @license
3187
- * Copyright 2020 Google LLC
3188
- *
3189
- * Licensed under the Apache License, Version 2.0 (the "License");
3190
- * you may not use this file except in compliance with the License.
3191
- * You may obtain a copy of the License at
3192
- *
3193
- * http://www.apache.org/licenses/LICENSE-2.0
3194
- *
3195
- * Unless required by applicable law or agreed to in writing, software
3196
- * distributed under the License is distributed on an "AS IS" BASIS,
3197
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3198
- * See the License for the specific language governing permissions and
3199
- * limitations under the License.
3200
- */
3201
- const Jd="pendingRedirect",Yd=new Map;class Xd extends Kd{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=Yd.get(this.auth._key());if(!e){try{const t=await async function(e,t){const n=function(e){return Eh(Jd,e.config.apiKey,e.name)}(t),i=function(e){return bh(e._redirectPersistence)}(e);if(!await i._isAvailable())return!1;const r="true"===await i._get(n);return await i._remove(n),r}(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(t)}catch(t){e=()=>Promise.reject(t)}Yd.set(this.auth._key(),e)}return this.bypassAuthState||Yd.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"!==e.type){if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}function Zd(e,t){Yd.set(e._key(),t)}async function ef(e,t,n=!1){if(je(e.app))return Promise.reject(Mu(e));const i=Vh(e),r=
3202
- /**
3203
- * @license
3204
- * Copyright 2021 Google LLC
3205
- *
3206
- * Licensed under the Apache License, Version 2.0 (the "License");
3207
- * you may not use this file except in compliance with the License.
3208
- * You may obtain a copy of the License at
3209
- *
3210
- * http://www.apache.org/licenses/LICENSE-2.0
3211
- *
3212
- * Unless required by applicable law or agreed to in writing, software
3213
- * distributed under the License is distributed on an "AS IS" BASIS,
3214
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3215
- * See the License for the specific language governing permissions and
3216
- * limitations under the License.
3217
- */
3218
- function(e,t){return t?bh(t):(Fu(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}(i,t),s=new Xd(i,r,n),o=await s.execute();return o&&!n&&(delete o.user._redirectEventId,await i._persistUserIfCurrent(o.user),await i._setRedirectUser(null,t)),o}
3219
- /**
3220
- * @license
3221
- * Copyright 2020 Google LLC
3222
- *
3223
- * Licensed under the Apache License, Version 2.0 (the "License");
3224
- * you may not use this file except in compliance with the License.
3225
- * You may obtain a copy of the License at
3226
- *
3227
- * http://www.apache.org/licenses/LICENSE-2.0
3228
- *
3229
- * Unless required by applicable law or agreed to in writing, software
3230
- * distributed under the License is distributed on an "AS IS" BASIS,
3231
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3232
- * See the License for the specific language governing permissions and
3233
- * limitations under the License.
3234
- */class tf{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(n=>{this.isEventForConsumer(e,n)&&(t=!0,this.sendToConsumer(e,n),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!function(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return rf(e);default:return!1}}
3235
- /**
3236
- * @license
3237
- * Copyright 2020 Google LLC
3238
- *
3239
- * Licensed under the Apache License, Version 2.0 (the "License");
3240
- * you may not use this file except in compliance with the License.
3241
- * You may obtain a copy of the License at
3242
- *
3243
- * http://www.apache.org/licenses/LICENSE-2.0
3244
- *
3245
- * Unless required by applicable law or agreed to in writing, software
3246
- * distributed under the License is distributed on an "AS IS" BASIS,
3247
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3248
- * See the License for the specific language governing permissions and
3249
- * limitations under the License.
3250
- */(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var n;if(e.error&&!rf(e)){const i=(null===(n=e.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error";t.onError(Pu(this.auth,i))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const n=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(nf(e))}saveEventToCache(e){this.cachedEventUids.add(nf(e)),this.lastProcessedEventTime=Date.now()}}function nf(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function rf({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}
3251
- /**
3252
- * @license
3253
- * Copyright 2020 Google LLC
3254
- *
3255
- * Licensed under the Apache License, Version 2.0 (the "License");
3256
- * you may not use this file except in compliance with the License.
3257
- * You may obtain a copy of the License at
3258
- *
3259
- * http://www.apache.org/licenses/LICENSE-2.0
3260
- *
3261
- * Unless required by applicable law or agreed to in writing, software
3262
- * distributed under the License is distributed on an "AS IS" BASIS,
3263
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3264
- * See the License for the specific language governing permissions and
3265
- * limitations under the License.
3266
- */
3267
- const sf=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,of=/^https?/;async function af(e){if(e.config.emulator)return;const{authorizedDomains:t}=await async function(e,t={}){return Yu(e,"GET","/v1/projects",t)}(e);for(const e of t)try{if(cf(e))return}catch(e){}Lu(e,"unauthorized-domain")}function cf(e){const t=Bu(),{protocol:n,hostname:i}=new URL(t);if(e.startsWith("chrome-extension://")){const r=new URL(e);return""===r.hostname&&""===i?"chrome-extension:"===n&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):"chrome-extension:"===n&&r.hostname===i}if(!of.test(n))return!1;if(sf.test(e))return i===e;const r=e.replace(/\./g,"\\.");return new RegExp("^(.+\\."+r+"|"+r+")$","i").test(i)}
3268
- /**
3269
- * @license
3270
- * Copyright 2020 Google LLC.
3271
- *
3272
- * Licensed under the Apache License, Version 2.0 (the "License");
3273
- * you may not use this file except in compliance with the License.
3274
- * You may obtain a copy of the License at
3275
- *
3276
- * http://www.apache.org/licenses/LICENSE-2.0
3277
- *
3278
- * Unless required by applicable law or agreed to in writing, software
3279
- * distributed under the License is distributed on an "AS IS" BASIS,
3280
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3281
- * See the License for the specific language governing permissions and
3282
- * limitations under the License.
3283
- */const lf=new $u(3e4,6e4);function uf(){const e=Nd().___jsl;if(null==e?void 0:e.H)for(const t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let t=0;t<e.CP.length;t++)e.CP[t]=null}function hf(e){return new Promise((t,n)=>{var i,r,s;function o(){uf(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{uf(),n(Pu(e,"network-request-failed"))},timeout:lf.get()})}if(null===(r=null===(i=Nd().gapi)||void 0===i?void 0:i.iframes)||void 0===r?void 0:r.Iframe)t(gapi.iframes.getContext());else{if(!(null===(s=Nd().gapi)||void 0===s?void 0:s.load)){const t=`__${"iframefcb"}${Math.floor(1e6*Math.random())}`;return Nd()[t]=()=>{gapi.load?o():n(Pu(e,"network-request-failed"))},Hh(`${jh.gapiScript}?onload=${t}`).catch(e=>n(e))}o()}}).catch(e=>{throw df=null,e})}let df=null;
3284
- /**
3285
- * @license
3286
- * Copyright 2020 Google LLC.
3287
- *
3288
- * Licensed under the Apache License, Version 2.0 (the "License");
3289
- * you may not use this file except in compliance with the License.
3290
- * You may obtain a copy of the License at
3291
- *
3292
- * http://www.apache.org/licenses/LICENSE-2.0
3293
- *
3294
- * Unless required by applicable law or agreed to in writing, software
3295
- * distributed under the License is distributed on an "AS IS" BASIS,
3296
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3297
- * See the License for the specific language governing permissions and
3298
- * limitations under the License.
3299
- */
3300
- const ff=new $u(5e3,15e3),pf={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},gf=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function mf(e){const t=e.config;Fu(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?qu(t,"emulator/auth/iframe"):`https://${e.config.authDomain}/__/auth/iframe`,i={apiKey:t.apiKey,appName:e.name,v:qe},r=gf.get(e.config.apiHost);r&&(i.eid=r);const s=e._getFrameworks();return s.length&&(i.fw=s.join(",")),`${n}?${C(i).slice(1)}`}async function yf(e){const t=await function(e){return df=df||hf(e),df}(e),n=Nd().gapi;return Fu(n,e,"internal-error"),t.open({where:document.body,url:mf(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:pf,dontclear:!0},t=>new Promise(async(n,i)=>{await t.restyle({setHideOnLeave:!1});const r=Pu(e,"network-request-failed"),s=Nd().setTimeout(()=>{i(r)},ff.get());function o(){Nd().clearTimeout(s),n(t)}t.ping(o).then(o,()=>{i(r)})}))}
3301
- /**
3302
- * @license
3303
- * Copyright 2020 Google LLC.
3304
- *
3305
- * Licensed under the Apache License, Version 2.0 (the "License");
3306
- * you may not use this file except in compliance with the License.
3307
- * You may obtain a copy of the License at
3308
- *
3309
- * http://www.apache.org/licenses/LICENSE-2.0
3310
- *
3311
- * Unless required by applicable law or agreed to in writing, software
3312
- * distributed under the License is distributed on an "AS IS" BASIS,
3313
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3314
- * See the License for the specific language governing permissions and
3315
- * limitations under the License.
3316
- */const vf={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class wf{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}function bf(e,t,n,i=500,r=600){const s=Math.max((window.screen.availHeight-r)/2,0).toString(),o=Math.max((window.screen.availWidth-i)/2,0).toString();let a="";const c=Object.assign(Object.assign({},vf),{width:i.toString(),height:r.toString(),top:s,left:o}),l=w().toLowerCase();n&&(a=Ah(l)?"_blank":n),Ch(l)&&(t=t||"http://localhost",c.scrollbars="yes");const u=Object.entries(c).reduce((e,[t,n])=>`${e}${t}=${n},`,"");if(function(e=w()){var t;return Lh(e)&&!!(null===(t=window.navigator)||void 0===t?void 0:t.standalone)}(l)&&"_self"!==a)return function(e,t){const n=document.createElement("a");n.href=e,n.target=t;const i=document.createEvent("MouseEvent");i.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(i)}
3317
- /**
3318
- * @license
3319
- * Copyright 2021 Google LLC
3320
- *
3321
- * Licensed under the Apache License, Version 2.0 (the "License");
3322
- * you may not use this file except in compliance with the License.
3323
- * You may obtain a copy of the License at
3324
- *
3325
- * http://www.apache.org/licenses/LICENSE-2.0
3326
- *
3327
- * Unless required by applicable law or agreed to in writing, software
3328
- * distributed under the License is distributed on an "AS IS" BASIS,
3329
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3330
- * See the License for the specific language governing permissions and
3331
- * limitations under the License.
3332
- */(t||"",a),new wf(null);const h=window.open(t||"",a,u);Fu(h,e,"popup-blocked");try{h.focus()}catch(e){}return new wf(h)}const _f="__/auth/handler",Sf="emulator/auth/handler",Ef=encodeURIComponent("fac");async function Tf(e,t,n,i,r,s){Fu(e.config.authDomain,e,"auth-domain-config-required"),Fu(e.config.apiKey,e,"invalid-api-key");const o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:i,v:qe,eventId:r};if(t instanceof cd){t.setDefaultLanguage(e.languageCode),o.providerId=t.providerId||"",function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}(t.getCustomParameters())||(o.customParameters=JSON.stringify(t.getCustomParameters()));for(const[e,t]of Object.entries({}))o[e]=t}if(t instanceof ld){const e=t.getScopes().filter(e=>""!==e);e.length>0&&(o.scopes=e.join(","))}e.tenantId&&(o.tid=e.tenantId);const a=o;for(const e of Object.keys(a))void 0===a[e]&&delete a[e];const c=await e._getAppCheckToken(),l=c?`#${Ef}=${encodeURIComponent(c)}`:"";return`${function({config:e}){if(!e.emulator)return`https://${e.authDomain}/${_f}`;return qu(e,Sf)}
3333
- /**
3334
- * @license
3335
- * Copyright 2020 Google LLC
3336
- *
3337
- * Licensed under the Apache License, Version 2.0 (the "License");
3338
- * you may not use this file except in compliance with the License.
3339
- * You may obtain a copy of the License at
3340
- *
3341
- * http://www.apache.org/licenses/LICENSE-2.0
3342
- *
3343
- * Unless required by applicable law or agreed to in writing, software
3344
- * distributed under the License is distributed on an "AS IS" BASIS,
3345
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3346
- * See the License for the specific language governing permissions and
3347
- * limitations under the License.
3348
- */(e)}?${C(a).slice(1)}${l}`}const If="webStorageSupport";const Cf=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=kd,this._completeRedirectFn=ef,this._overrideRedirectResult=Zd}async _openPopup(e,t,n,i){var r;Vu(null===(r=this.eventManagers[e._key()])||void 0===r?void 0:r.manager,"_initialize() not called before _openPopup()");return bf(e,await Tf(e,t,n,Bu(),i),Rd())}async _openRedirect(e,t,n,i){await this._originValidation(e);return function(e){Nd().location.href=e}(await Tf(e,t,n,Bu(),i)),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:e,promise:n}=this.eventManagers[t];return e?Promise.resolve(e):(Vu(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n.catch(()=>{delete this.eventManagers[t]}),n}async initAndGetManager(e){const t=await yf(e),n=new tf(e);return t.register("authEvent",t=>{Fu(null==t?void 0:t.authEvent,e,"invalid-auth-event");return{status:n.onEvent(t.authEvent)?"ACK":"ERROR"}},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:n},this.iframes[e._key()]=t,n}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(If,{type:If},n=>{var i;const r=null===(i=null==n?void 0:n[0])||void 0===i?void 0:i[If];void 0!==r&&t(!!r),Lu(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=af(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return Dh()||kh()||Lh()}};var kf="@firebase/auth",Af="1.10.8";
3349
- /**
3350
- * @license
3351
- * Copyright 2020 Google LLC
3352
- *
3353
- * Licensed under the Apache License, Version 2.0 (the "License");
3354
- * you may not use this file except in compliance with the License.
3355
- * You may obtain a copy of the License at
3356
- *
3357
- * http://www.apache.org/licenses/LICENSE-2.0
3358
- *
3359
- * Unless required by applicable law or agreed to in writing, software
3360
- * distributed under the License is distributed on an "AS IS" BASIS,
3361
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3362
- * See the License for the specific language governing permissions and
3363
- * limitations under the License.
3364
- */
3365
- class Rf{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),(null===(e=this.auth.currentUser)||void 0===e?void 0:e.uid)||null}async getToken(e){if(this.assertAuthConfigured(),await this.auth._initializationPromise,!this.auth.currentUser)return null;return{accessToken:await this.auth.currentUser.getIdToken(e)}}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(t=>{e((null==t?void 0:t.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(){Fu(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}
3366
- /**
3367
- * @license
3368
- * Copyright 2020 Google LLC
3369
- *
3370
- * Licensed under the Apache License, Version 2.0 (the "License");
3371
- * you may not use this file except in compliance with the License.
3372
- * You may obtain a copy of the License at
3373
- *
3374
- * http://www.apache.org/licenses/LICENSE-2.0
3375
- *
3376
- * Unless required by applicable law or agreed to in writing, software
3377
- * distributed under the License is distributed on an "AS IS" BASIS,
3378
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3379
- * See the License for the specific language governing permissions and
3380
- * limitations under the License.
3381
- */
3382
- /**
3383
- * @license
3384
- * Copyright 2021 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
- */
3398
- const xf=d("authIdTokenMaxAge")||300;let Nf=null;function Of(e=Ke()){const t=Be(e,"auth");if(t.isInitialized())return t.getImmediate();const n=function(e,t){const n=Be(e,"auth");if(n.isInitialized()){const e=n.getImmediate();if(T(n.getOptions(),null!=t?t:{}))return e;Lu(e,"already-initialized")}return n.initialize({options:t})}(e,{popupRedirectResolver:Cf,persistence:[jd,Id,kd]}),i=d("authTokenSyncURL");if(i&&"boolean"==typeof isSecureContext&&isSecureContext){const e=new URL(i,location.origin);if(location.origin===e.origin){const t=(r=e.toString(),async e=>{const t=e&&await e.getIdTokenResult(),n=t&&((new Date).getTime()-Date.parse(t.issuedAtTime))/1e3;if(n&&n>xf)return;const i=null==t?void 0:t.token;Nf!==i&&(Nf=i,await fetch(r,{method:i?"POST":"DELETE",headers:i?{Authorization:`Bearer ${i}`}:{}}))});!function(e,t,n){N(e).beforeAuthStateChanged(t,n)}(n,t,()=>t(n.currentUser)),function(e,t,n,i){N(e).onIdTokenChanged(t,n,i)}(n,e=>t(e))}}var r;const s=u("auth");return s&&Jh(n,`http://${s}`),n}var Lf;jh={loadJS:e=>new Promise((t,n)=>{const i=document.createElement("script");var r,s;i.setAttribute("src",e),i.onload=t,i.onerror=e=>{const t=Pu("internal-error");t.customData=e,n(t)},i.type="text/javascript",i.charset="UTF-8",(null!==(s=null===(r=document.getElementsByTagName("head"))||void 0===r?void 0:r[0])&&void 0!==s?s:document).appendChild(i)}),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="},Lf="Browser",Ve(new O("auth",(e,{options:t})=>{const n=e.getProvider("app").getImmediate(),i=e.getProvider("heartbeat"),r=e.getProvider("app-check-internal"),{apiKey:s,authDomain:o}=n.options;Fu(s&&!s.includes(":"),"invalid-api-key",{appName:n.name});const a={apiKey:s,authDomain:o,clientPlatform:Lf,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:Mh(Lf)},c=new Uh(n,i,r,a);return function(e,t){const n=(null==t?void 0:t.persistence)||[],i=(Array.isArray(n)?n:[n]).map(bh);(null==t?void 0:t.errorMap)&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(i,null==t?void 0:t.popupRedirectResolver)}(c,t),c},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{e.getProvider("auth-internal").initialize()})),Ve(new O("auth-internal",e=>(e=>new Rf(e))(Vh(e.getProvider("auth").getImmediate())),"PRIVATE").setInstantiationMode("EXPLICIT")),We(kf,Af,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}(Lf)),We(kf,Af,"esm2017");class Pf extends Error{constructor(){super("Avatar not created"),this.name="AvatarNotCreatedError"}}class Df extends Error{constructor(){super("user not logged in"),this.name="UserNotLoggedInError"}}class Mf extends Error{constructor(){super("no colorway size assets found"),this.name="NoColorwaySizeAssetsFoundError"}}class zf extends Error{constructor(){super("brand user id not set"),this.name="BrandUserIdNotSetError"}}class Ff extends Error{constructor(){super("no frames found"),this.name="NoFramesFoundError"}}class Uf extends Error{constructor(){super("no styles found"),this.name="NoStylesFoundError"}}const Vf="avatar not created";class Bf{constructor(e,t){this.firestore=e,this.brandUserId=null,this.auth=Of(t),this.auth.setPersistence(Id)}get id(){var e;return null===(e=this.user)||void 0===e?void 0:e.uid}async onInit(e){this.auth.onAuthStateChanged(t=>{this.setUser(t),t&&(this.logUserLogin(e,t),this.setBrandUserId(t.uid))}),await this.auth.authStateReady();const t=this.auth.currentUser;return this.setUser(t),this.setBrandUserId(null==t?void 0:t.uid),Boolean(t)}setUser(e){this.user=e}async logUserLogin(e,t){var n,i,r,s,o;try{const a=Wc(this.firestore,"user_logging",t.uid),c=await Hl(a),l=new Date,u=c.exists?c.data():null,h=null===(i=null===(n=null==u?void 0:u.brands)||void 0===n?void 0:n[e])||void 0===i?void 0:i.last_login;if(h&&Su(l).diff(Su(1e3*h.seconds),"seconds")<=10080)return;const d=null!==(o=null===(s=null===(r=null==u?void 0:u.brands)||void 0===r?void 0:r[e])||void 0===s?void 0:s.logins)&&void 0!==o?o:[];d.push(l);const f={brands:{[e]:{brand_id:e,last_login:l,logins:d}},last_brand_id:e,created_at:c.exists()?c.data().created_at:l,updated_at:l};await Gl(a,f,{merge:!0})}catch(e){console.error("LOGGING ERROR:",e)}}setBrandUserId(e){this.brandUserId=e}async getToken(){var e;if(!(null===(e=this.user)||void 0===e?void 0:e.uid))throw new Df;return await this.user.getIdToken()}get userId(){var e;if(!(null===(e=this.user)||void 0===e?void 0:e.uid))throw new Df;return this.user.uid}async getUserProfile(){var e;if(!(null===(e=this.user)||void 0===e?void 0:e.uid))throw new Df;return(await Hl(Wc(this.firestore,"users",this.id))).data()}watchUserProfileForChanges(e){let t;const n=xl(Kc(this.firestore,"users"),Ol(rl(),"==",this.id));return t=Kl(n,t=>e(t.docs[0].data())),()=>t()}watchUserProfileForFrames(e){let t;const n=xl(Kc(this.firestore,"users"),Ol(rl(),"==",this.id));return new Promise(i=>{t=Kl(n,async n=>{await e(n)&&(t(),i(n.docs[0].data()))})})}async login(e,t){this.auth.currentUser&&await this.auth.signOut();const n=await _d(this.auth,e,t);this.setUser(n.user)}async logout(){await this.auth.signOut(),this.setUser(null)}async sendPasswordResetEmail(e){await async function(e,t){const n=Vh(e),i={requestType:"PASSWORD_RESET",email:t,clientType:"CLIENT_TYPE_WEB"};await Qh(n,i,"getOobCode",nd)}(this.auth,e)}async confirmPasswordReset(e,t){await bd(this.auth,e,t)}}class jf{constructor(){this.promisefyOnSnapshot=(e,t)=>{let n;return{promise:new Promise(i=>{n=Kl(e,e=>{i(e),t&&n()})}),unsubscribe:()=>n()}};const e=Ge(Ql.getInstance().firebase);this.firestore=el(e),this.user=new Bf(this.firestore,e)}onInit(e){return this.user.onInit(e)}query(e,t,n=!0){const i=xl(Kc(this.firestore,e),t);return this.promisefyOnSnapshot(i,n)}getDocs(e,t){return ql(xl(Kc(this.firestore,e),...t))}async getDoc(e,t){const n=Wc(this.firestore,e,t),i=await Hl(n);return i.exists()?i.data():null}}const Hf=e=>{if(e.code===xu)throw new Error("account has been disabled");throw new Error(e.message)};class $f{static get endpoint(){return Ql.getInstance().api.url}static async Fetch({user:e,endpointPath:t,method:n,body:i,useToken:r=!0}){const s=this.getUrl(t,r),o={method:n,headers:await this.getHeaders(e,r),credentials:"omit"};i&&(o.body=JSON.stringify(i));const a=await fetch(s,o);if(a.ok)return a;if(500===a.status)throw new Error(a.statusText);const c=await a.json();return Promise.reject(c)}static getUrl(e,t){return t?`${this.endpoint}/v1${e}`:this.endpoint+e}static async getHeaders(e,t){if(!t)return{"Content-Type":"application/json"};return{"Content-Type":"application/json",Authorization:`Bearer ${await e.getToken()}`}}static Get(e,t,n){return this.Fetch({user:e,endpointPath:t,method:"GET",body:null,useToken:n})}static Post(e,t,n=null,i){return this.Fetch({user:e,endpointPath:t,method:"POST",body:n,useToken:i})}static Put(e,t,n,i){return this.Fetch({user:e,endpointPath:t,method:"PUT",body:n,useToken:i})}static Patch(e,t,n,i){return this.Fetch({user:e,endpointPath:t,method:"PATCH",body:n,useToken:i})}static Delete(e,t,n,i){return this.Fetch({user:e,endpointPath:t,method:"DELETE",body:n,useToken:i})}}const qf=e=>{const t=new Image;return t.src=e,new Promise(e=>{t.onerror=()=>e(!1),t.onload=()=>e(!0)})};class Gf{constructor(e,t){this.brandId=e,this.firebase=t,this.measurementLocations=new Map}get user(){return this.firebase.user}get isLoggedIn(){return!this.firebase||Boolean(this.user.id)}async onInit(){return await this.getMeasurementLocations(),this.firebase.onInit(this.brandId)}async getRecommendedSizes(e){var t,n;if(!this.isLoggedIn)throw new Df;try{const i=await $f.Get(this.user,`/styles/${e}/recommendation`),r=await i.json();return(null===(t=null==r?void 0:r.fits)||void 0===t?void 0:t.length)&&(null===(n=null==r?void 0:r.recommended_size)||void 0===n?void 0:n.id)?r:null}catch(e){if((null==e?void 0:e.error)===Vf)throw new Pf;throw e}}async submitTelephoneNumber(e){const t=e.replace(/[^\+0-9]/g,""),n=await $f.Post(this.user,"/ios-app-link",{phone_number:t},!1);console.log(n)}async getColorwaySizeAssetFromSku(e){const t=await this.getColorwaySizeAssets(null,[e]);if(!(null==t?void 0:t.size))throw new Mf;return Array.from(t.values())[0]}async getColorwaySizeAssetFromBrandStyleId(e){const t=await this.getColorwaySizeAssets(e);if(!(null==t?void 0:t.size))throw new Mf;return Array.from(t.values())[0]}async getMeasurementLocationsFromSku(e,t=[]){console.log({sku:e});const n=await this.getColorwaySizeAssetFromSku(e);if(!n)throw new Error("No colorway size asset found for sku");const i=await this.getStyle(n.style_id);if(!i)throw new Error("Style category not found for style id");const r=await this.getGetTaxonomy(i.style_garment_category_id);if(!r)throw new Error("Taxonomy not found for style garment category id");return(t.length?r.measurement_locations.female.filter(e=>t.includes(e)):r.measurement_locations.female).map(e=>this.measurementLocations.has(e)?this.measurementLocations.get(e):{name:e,sort_order:1/0}).sort((e,t)=>e.sort_order<t.sort_order?-1:0).map(e=>e.name)}async getMeasurementLocationsFromBrandStyleId(e,t=[]){const n=await this.getColorwaySizeAssetFromBrandStyleId(e);if(!n)throw new Error("No colorway size asset found for brand style id");const i=await this.getStyle(n.style_id);if(!i)throw new Error("Style category not found for style id");const r=await this.getGetTaxonomy(i.style_garment_category_id);if(!r)throw new Error("Taxonomy not found for style garment category id");return(t.length?r.measurement_locations.female.filter(e=>t.includes(e)):r.measurement_locations.female).map(e=>this.measurementLocations.has(e)?this.measurementLocations.get(e):{name:e,sort_order:1/0}).sort((e,t)=>e.sort_order<t.sort_order?-1:0).map(e=>e.name)}async getStyleByBrandStyleId(e){var t,n;try{const i=[Ol("brand_id","==",this.brandId)];i.push(Ol("brand_style_id","==",e));return null===(n=null===(t=(await this.firebase.getDocs("styles",i)).docs)||void 0===t?void 0:t[0])||void 0===n?void 0:n.data()}catch(e){return Hf(e)}}async getColorwaySizeAssets(e,t){const n=[Ol("brand_id","==",this.brandId)];e&&n.push(Ol("style_id","==",e)),(null==t?void 0:t.length)>0&&n.push(Ol("sku","in",t));try{const e=await this.firebase.getDocs("colorway_size_assets",n),t=new Map;return e.forEach(e=>{const n=e.data();t.set(n.id,n)}),t}catch(e){return Hf(e)}}async getStyle(e){try{return await this.firebase.getDoc("styles",String(e))}catch(e){return Hf(e)}}getMeasurementLocationName(e){return this.measurementLocations.has(e)?this.measurementLocations.get(e).name:e}getMeasurementLocationSortOrder(e){return this.measurementLocations.has(e)?this.measurementLocations.get(e).sort_order:1/0}async tryOn(e,t){if(!this.isLoggedIn)throw new Df;const n=await this.getColorwaySizeAssetSkuFromStyleIdAndSizeId(e,t);try{return await this.getColorwaySizeAssetFrames(n)}catch(e){if(!(e instanceof Ff))throw e;return this.requestThenGetColorwaySizeAssetFrames(n)}}async getColorwaySizeAssetSkuFromStyleIdAndSizeId(e,t){var n,i,r;try{const s=[Ol("brand_id","==",this.brandId)];s.push(Ol("style_id","==",e)),s.push(Ol("size_id","==",t));return null===(r=null===(i=null===(n=(await this.firebase.getDocs("colorway_size_assets",s)).docs)||void 0===n?void 0:n[0])||void 0===i?void 0:i.data())||void 0===r?void 0:r.sku}catch(e){return Hf(e)}}async getGetTaxonomy(e){try{return await this.firebase.getDoc("style_garment_categories",String(e))}catch(e){return Hf(e)}}async getMeasurementLocations(){(await this.fetchMeasurementLocations()).forEach(e=>{this.measurementLocations.set(e.name,{name:e.garment_label,sort_order:e.sort_order})})}async fetchMeasurementLocations(){try{return(await this.firebase.getDocs("measurement_locations",[])).docs.map(e=>e.data())}catch(e){return Hf(e)}}async requestThenGetColorwaySizeAssetFrames(e){const[t,n]=await(i=this.getColorwaySizeAssetFromSku(e),i.then(e=>[null,e]).catch(e=>[e]));var i;if(t)throw t;try{try{this.requestColorwaySizeAssetFrames(n.id)}catch(e){}return this.awaitColorwaySizeAssetFrames(e)}catch(t){if((null==t?void 0:t.error)===Vf)throw new Pf;throw new Uf}}async awaitColorwaySizeAssetFrames(e){var t,n,i,r;if(!this.isLoggedIn)throw new Df;const s=await this.user.watchUserProfileForFrames(async t=>{var n,i,r,s;const o=null===(s=null===(r=null===(i=null===(n=t.docs[0].data())||void 0===n?void 0:n.vto)||void 0===i?void 0:i[this.brandId])||void 0===r?void 0:r[e])||void 0===s?void 0:s.frames;return!!(null==o?void 0:o.length)&&qf(o[0])});if(!(null===(r=null===(i=null===(n=null===(t=null==s?void 0:s.vto)||void 0===t?void 0:t[this.brandId])||void 0===n?void 0:n[e])||void 0===i?void 0:i.frames)||void 0===r?void 0:r.length))throw new Ff;return s.vto[this.brandId][e].frames}async requestColorwaySizeAssetFrames(e){if(!this.isLoggedIn)throw new Df;if(!this.user.brandUserId)throw new zf;await $f.Post(this.user,`/colorway-size-assets/${e}/frames`,{brand_user_id:String(this.user.brandUserId)})}async getColorwaySizeAssetFrames(e){var t,n,i;const r=await this.user.getUserProfile(),s=(null===(i=null===(n=null===(t=null==r?void 0:r.vto)||void 0===t?void 0:t[this.brandId])||void 0===n?void 0:n[e])||void 0===i?void 0:i.frames)||[];if(!s.length)throw new Ff;if(!await qf(s[0]))throw new Ff;return s}}var Kf;!function(e){e.ACROSS_BACK="across_back",e.ACROSS_FRONT="across_front",e.ACROSS_SHOULDER="across_shoulder",e.ANKLE="ankle",e.ARMEYE="arm_eye",e.ARM_LENGTH_FROM_SHOULDER="arm_length_from_shoulder",e.BACK_CROTCH_LENGTH="back_crotch_length",e.BACK_NECK_TO_EBLOW="back_neck_to_elbow",e.BELOW_KNEE="below_knee",e.BICEP="bicep",e.BUST="bust",e.BUST_POINT_TO_BUST_POINT="bust_point_to_bust_point",e.CALF="calf",e.CB_NECK_TO_WAIST="cb_neck_to_waist",e.CB_NECK_TO_WRIST="cb_neck_to_wrist",e.CF_NECK_TO_WAIST="cf_neck_to_waist",e.ELBOW="elbow",e.FOREARM="forearm",e.FRONT_CROTCH_LENGTH="front_crotch_length",e.HIGH_HIP_PLACEMENT_FROM_WAIST="high_hip_placement",e.HIGH_HIP="high_hip",e.HSP_TO_ACROSS_BACK="hsp_to_across_back",e.HSP_TO_ACROSS_FRONT="hsp_to_across_front",e.HSP_TO_BUST_POINT="hsp_to_bust_point",e.HSP_TO_LOW_HIP_POSITION="hsp_to_low_hip_position",e.HSP_TO_WAIST_POSITION="hsp_to_waist_position",e.INSEAM="inseam",e.KNEE="knee",e.LOW_HIP="low_hip",e.LOW_HIP_PLACEMENT_FROM_WAIST="low_hip_placement",e.MID_NECK="mid_neck",e.NECK_AT_BASE="neck_base",e.SHOULDER_DROP="shoulder_drop",e.SHOULDER_TO_SHOULDER="shoulder_to_shoulder",e.SIDE_WAIST_TO_FLOOR="side_waist_to_floor",e.SIDE_WAIST_TO_KNEE="side_waist_to_knee",e.THIGH="thigh",e.TOTAL_RISE_LENGTH="total_rise_length",e.UNDER_BUST="under_bust",e.VERTICAL_TRUNK="vertical_trunk",e.WAIST="waist",e.WRIST="wrist"}(Kf||(Kf={}));const Wf={[Kf.ACROSS_BACK]:"Across back",[Kf.ACROSS_FRONT]:"Across front",[Kf.ACROSS_SHOULDER]:"Across shoulder",[Kf.ANKLE]:"Ankle",[Kf.ARMEYE]:"Armeye",[Kf.ARM_LENGTH_FROM_SHOULDER]:"Arm length from shoulder",[Kf.BACK_CROTCH_LENGTH]:"Back crotch length",[Kf.BACK_NECK_TO_EBLOW]:"Back neck to eblow",[Kf.BELOW_KNEE]:"Below knee",[Kf.BICEP]:"Bicep",[Kf.BUST]:"Chest/Bust",[Kf.BUST_POINT_TO_BUST_POINT]:"Bust point to bust point",[Kf.CALF]:"Calf",[Kf.CB_NECK_TO_WAIST]:"Cb neck to waist",[Kf.CB_NECK_TO_WRIST]:"Cb neck to wrist",[Kf.CF_NECK_TO_WAIST]:"Cf neck to waist",[Kf.ELBOW]:"Elbow",[Kf.FOREARM]:"Forearm",[Kf.FRONT_CROTCH_LENGTH]:"Front crotch length",[Kf.HIGH_HIP_PLACEMENT_FROM_WAIST]:"High hip placement from waist",[Kf.HIGH_HIP]:"High hip",[Kf.HSP_TO_ACROSS_BACK]:"Hsp to across back",[Kf.HSP_TO_ACROSS_FRONT]:"Hsp to across front",[Kf.HSP_TO_BUST_POINT]:"Hsp to bust point",[Kf.HSP_TO_LOW_HIP_POSITION]:"Hsp to low hip position",[Kf.HSP_TO_WAIST_POSITION]:"Hsp to waist position",[Kf.INSEAM]:"Inseam",[Kf.KNEE]:"Knee",[Kf.LOW_HIP]:"Low hip",[Kf.LOW_HIP_PLACEMENT_FROM_WAIST]:"Low hip placement from waist",[Kf.MID_NECK]:"Mid neck",[Kf.NECK_AT_BASE]:"Neck at base",[Kf.SHOULDER_DROP]:"Shoulder drop",[Kf.SHOULDER_TO_SHOULDER]:"Shoulder to shoulder",[Kf.SIDE_WAIST_TO_FLOOR]:"Side waist to floor",[Kf.SIDE_WAIST_TO_KNEE]:"Side waist to knee",[Kf.THIGH]:"Thigh",[Kf.TOTAL_RISE_LENGTH]:"Total rise length",[Kf.UNDER_BUST]:"Under bust",[Kf.VERTICAL_TRUNK]:"Vertical trunk",[Kf.WAIST]:"Waist",[Kf.WRIST]:"Wrist"};var Qf;!function(e){e.BLOUSES="blouses",e.COATS="coats",e.DRESSES="dresses",e.JACKETS="jackets",e.PANTS="pants",e.PUFFERS_AND_PARKAS="puffer_and_parkas",e.SHORTS="shorts",e.SKIRTS="skirts",e.SWEATERS="sweaters",e.T_SHIRTS_AND_TANKS="t_shirts_and_tanks"}(Qf||(Qf={}));const Jf={[Qf.BLOUSES]:[Kf.BUST,Kf.ACROSS_SHOULDER,Kf.WAIST,Kf.LOW_HIP,Kf.HIGH_HIP],[Qf.COATS]:[Kf.BUST,Kf.ACROSS_SHOULDER,Kf.WAIST,Kf.LOW_HIP,Kf.HIGH_HIP],[Qf.DRESSES]:[Kf.LOW_HIP,Kf.BUST,Kf.ACROSS_SHOULDER,Kf.WAIST],[Qf.JACKETS]:[Kf.BUST,Kf.ACROSS_SHOULDER,Kf.WAIST,Kf.LOW_HIP,Kf.HIGH_HIP],[Qf.PANTS]:[Kf.LOW_HIP,Kf.WAIST,Kf.THIGH,Kf.INSEAM],[Qf.PUFFERS_AND_PARKAS]:[Kf.BUST,Kf.ACROSS_SHOULDER,Kf.WAIST,Kf.LOW_HIP,Kf.HIGH_HIP],[Qf.SHORTS]:[Kf.LOW_HIP,Kf.WAIST,Kf.THIGH,Kf.INSEAM],[Qf.SKIRTS]:[Kf.LOW_HIP,Kf.WAIST],[Qf.SWEATERS]:[Kf.BUST,Kf.ACROSS_SHOULDER,Kf.WAIST,Kf.LOW_HIP,Kf.HIGH_HIP],[Qf.T_SHIRTS_AND_TANKS]:[Kf.BUST,Kf.ACROSS_SHOULDER,Kf.WAIST,Kf.LOW_HIP,Kf.HIGH_HIP]},Yf={activewear:"Active Wear",dresses:"Dresses",jackets_and_coats:"Jackets and Coats",jeans:"Jeans",jumpsuits_and_rompers:"Jumpsuits and Rompers",pants_and_shorts:"Pants and Shorts",skirts:"Skirts",suits_and_tailoring:"Suits and Tailoring",sweaters:"Sweaters",tops:"Tops"},Xf={a_line:"A Line",a_line_flared:"A Line Flared",blazers:"Blazers",bodycon:"Bodycon",bodysuits:"Bodysuits",boiler_suits:"Boiler Suits",bootcut:"Bootcut",cardigans:"Cardigans",cigarette:"Cigarette",corsets_and_bustiers:"Corsets and Bustiers",crewnecks:"Crewnecks",culottes:"Culottes",denim:"Denim",denim_jackets:"Denim Jackets",denim_shorts:"Denim Shorts",fit_and_flare:"Fit and Flare",flared:"Flared",hoodies_and_zipups:"Hoodies and Zipups",joggers:"Joggers",jumpsuits:"Jumpsuits",knit:"Knit",leggings:"Leggings",mom:"Mom",overalls:"Overalls",parkas:"Parkas",peacoats:"Peacoats",pencil:"Pencil",pleated:"Pleated",polos:"Polos",puffer_jackets:"Puffer Jackets",raincoats:"Raincoats",relaxed:"Relaxed",rompers:"Rompers",shackets:"Shackets",shirt:"Shirt",shirts_and_blouses:"Shirts and Blouses",skater:"Skater",skinny:"Skinny",slim:"Slim",slip:"Slip",sports_bras:"Sports Bras",straight:"Straight",suit_jackets:"Suit Jackets",suit_skirts:"Suit Skirts",suit_trousers:"Suit Trousers",suit_vests:"Suit Vests",sweatshirts:"Sweatshirts",t_shirts:"T-Shirts",tank_tops_and_camisoles:"Tank Tops and Camisoles",tapered:"Tapered",trench_coats:"Trench Coats",trousers:"Trousers",turtlenecks:"Turtleneck",unitards:"Unitards",v_necks:"V-Necks",wide_leg:"Wide Leg",wrap:"Wrap"},Zf={activewear:{leggings:Qf.PANTS,joggers:Qf.PANTS,sweatshirts:Qf.SWEATERS},dresses:{a_line:Qf.DRESSES,bodycon:Qf.DRESSES,fit_and_flare:Qf.DRESSES,knit:Qf.DRESSES,shirt:Qf.DRESSES,slip:Qf.DRESSES,straight:Qf.DRESSES,wrap:Qf.DRESSES},jackets_and_coats:{denim_jackets:Qf.JACKETS,parkas:Qf.PUFFERS_AND_PARKAS,peacoats:Qf.COATS,puffer_jackets:Qf.PUFFERS_AND_PARKAS,raincoats:Qf.COATS,rompers:Qf.COATS,shackets:Qf.JACKETS,trench_coats:Qf.COATS},jeans:{bootcut:Qf.PANTS,flared:Qf.PANTS,mom:Qf.PANTS,relaxed:Qf.PANTS,skinny:Qf.PANTS,slim:Qf.PANTS,straight:Qf.PANTS,tapered:Qf.PANTS,wide_leg:Qf.PANTS},jumpsuits_and_rompers:{boiler_suits:Qf.DRESSES,denim:Qf.DRESSES,jumpsuits:Qf.DRESSES,overalls:Qf.DRESSES,rompers:Qf.DRESSES,unitards:Qf.DRESSES},pants_and_shorts:{cigarette:Qf.PANTS,culottes:Qf.SHORTS,denim_shorts:Qf.SHORTS,flared:Qf.PANTS,joggers:Qf.PANTS,leggings:Qf.PANTS,skinny:Qf.PANTS,wide_leg:Qf.PANTS},skirts:{a_line_flared:Qf.SKIRTS,denim:Qf.SKIRTS,knit:Qf.SKIRTS,pencil:Qf.SKIRTS,pleated:Qf.SKIRTS,skater:Qf.SKIRTS,slip:Qf.SKIRTS,wrap:Qf.SKIRTS},suits_and_tailoring:{blazers:Qf.JACKETS,suit_jackets:Qf.JACKETS,suit_skirts:Qf.SKIRTS,suit_trousers:Qf.PANTS,suit_vests:Qf.SWEATERS,trousers:Qf.PANTS},sweaters:{cardigans:Qf.SWEATERS,crewnecks:Qf.SWEATERS,hoodies_and_zipups:Qf.SWEATERS,sweatshirts:Qf.SWEATERS,turtlenecks:Qf.SWEATERS,v_necks:Qf.SWEATERS},tops:{bodysuits:Qf.BLOUSES,corsets_and_bustiers:Qf.BLOUSES,polos:Qf.T_SHIRTS_AND_TANKS,shirts_and_blouses:Qf.BLOUSES,t_shirts:Qf.T_SHIRTS_AND_TANKS,tank_tops_and_camisoles:Qf.T_SHIRTS_AND_TANKS}};var ep;!function(e){e.TOO_TIGHT="too_tight",e.TIGHT="tight",e.SLIGHTLY_TIGHT="slightly_tight",e.PERFECT_FIT="perfect_fit",e.SLIGHTLY_LOOSE="slightly_loose",e.LOOSE="loose",e.OVERSIZED="oversized",e.TOO_SHORT="too_short",e.SHORT="short",e.SLIGHTLY_SHORT="slightly_short",e.SLIGHTLY_LONG="slightly_long",e.LONG="long",e.TOO_LONG="too_long"}(ep||(ep={}));const tp={[ep.TOO_TIGHT]:"Too Tight",[ep.TIGHT]:"Tight",[ep.SLIGHTLY_TIGHT]:"Slightly Tight",[ep.PERFECT_FIT]:"Perfect Fit",[ep.SLIGHTLY_LOOSE]:"Slightly Loose",[ep.LOOSE]:"Loose",[ep.OVERSIZED]:"Oversized",[ep.TOO_SHORT]:"Too Short",[ep.SHORT]:"Short",[ep.SLIGHTLY_SHORT]:"Slightly Short",[ep.SLIGHTLY_LONG]:"Slightly Long",[ep.LONG]:"Long",[ep.TOO_LONG]:"Too Long"};var np;!function(e){e.NOT_CREATED="NOT_CREATED",e.CREATED="CREATED",e.PENDING="PENDING"}(np||(np={}));var ip=Object.freeze({__proto__:null,get AvatarState(){return np},Categories:["activewear","dresses","jackets_and_coats","jeans","jumpsuits_and_rompers","pants_and_shorts","skirts","suits_and_tailoring","sweaters","tops"],CategoryNames:Yf,get Classification(){return Qf},ClassificationLocations:Jf,get Fit(){return ep},FitNames:tp,get MeasurementLocation(){return Kf},MeasurementLocationName:Wf,SubcategoryNames:Xf,Taxonomy:Zf});class rp{constructor(e){this.vtoMainDivId=e,this.isInit=!1,this.currentSliderValue=0,this.slider=null}init(){if(this.isInit)return;const e=document.getElementById(this.vtoMainDivId);if(!e)throw new Error(`Element with id ${this.vtoMainDivId} not found`);e.innerHTML='\n <div class="tfr-slider-wrapper">\n <img id="tfr-tryon-image" src="" />\n <input type="range" id="tfr-slider" />\n </div>\n ';const t=document.getElementById("tfr-tryon-image");this.slider=n("tfr-slider",(e,n)=>{console.debug("slider change",e,n),t.src=n,this.currentSliderValue=parseInt(e.value)}),this.isInit=!0}onNewFramesReady(e){if(this.isInit||this.init(),Array.isArray(e)&&e.length>0){const t=Math.min(this.currentSliderValue,e.length-1),n=this.slider.Load(e,t);if(n instanceof Error)return void console.error(n);const i=document.getElementById("tfr-slider");if(i&&this.currentSliderValue<e.length){i.value=this.currentSliderValue.toString();document.getElementById("tfr-tryon-image").src=e[this.currentSliderValue]}}}}var sp="Back to sign in",op="Click here to download the app",ap="Don't have an account?",cp="Whoops! Looks like you don't have an avatar yet.",lp="Email address",up="Please enter a valid email address.",hp="Enter your email address, we will send you a link to reset your password.",dp="Forgot password?",fp="Have an account? Sign in",pp="Your avatar is loading...",gp="Unfortunately, that size is not available for try on.",mp="or",yp="Password",vp="Please enter a valid password (at least 7 characters).",wp="Return to Catalog Page",bp="Return to Product Page",_p="Return to site",Sp="Please return to The Fitting Room app to create your avatar.",Ep="Scan to download the app",Tp="Send",Ip="Sign back in",Cp="Sign in",kp="Something went wrong. Try again!",Ap="You have successfully logged out!",Rp="The Fitting Room",xp="Username or password is empty.",Np="Username or password is incorrect.",Op="End size uncertainty with",Lp="Our technology captures your precise measurements, and considers things like fabric stretch and your individual physique to find your perfect fit every time.";function Pp(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var i=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===n&&i.firstChild?i.insertBefore(r,i.firstChild):i.appendChild(r),r.styleSheet?r.styleSheet.cssText=e:r.appendChild(document.createTextNode(e))}}Pp(".tfr-c-white{color:var(--tfr-white)}.tfr-c-brand{color:var(--tfr-brand-color)}.tfr-c-brand-bg{background-color:var(--tfr-brand-color)}.tfr-c-black{color:var(--tfr-black)}.tfr-c-black-o5{color:rgba(0,0,0,.5)}.tfr-c-red{color:var(--tfr-red)}");Pp('#fit-title{margin-bottom:20px;margin-top:-30px}#fit-subtitle,#fit-title{color:#209da7;font-size:24px;font-weight:700}#fit-subtitle{position:absolute;right:17px;top:100px}#fit-subtitle-mobile{color:#7d7d7d;font-size:24px;font-weight:700;margin-top:20px}#fit-outline-container{display:flex;justify-content:center}#fit-outline-inner{position:relative}#fit-outline-inner,#tfr-fit-outline-img{width:184px}#fit-outline-inner,#fit-outline-inner-left,#fit-outline-inner-right,#tfr-fit-outline-img{height:701px}#fit-outline-inner-left,#fit-outline-inner-right{position:relative;width:260px}#fit-outline-container .fit-outline-line{display:block}.fit-outline-line{background:#000;height:1px;position:absolute}.fit-outline-line-text{border-bottom:1px solid #000;font-size:24px;position:absolute}.fit-outline-line-chest-text{left:-11px;text-align:right;top:163px;width:254px}.fit-outline-line-n-waist-text{left:-11px;text-align:right;top:208px;width:254px}.fit-outline-line-p-waist-text{right:-10px;text-align:left;top:233px;width:253px}.fit-outline-line-h-hip-text{left:-3px;text-align:right;top:255px;width:246px}.fit-outline-line-l-hip-text{left:-3px;text-align:right;top:302px;width:246px}.fit-outline-line-thigh-text{right:3px;text-align:left;top:341px;width:240px}.fit-outline-line-chest{left:42px;top:194px;width:99px}.fit-outline-line-n-waist{left:50px;top:239px;width:83px}.fit-outline-line-p-waist{left:45px;top:264px;width:93px}.fit-outline-line-h-hip{left:30px;top:286px;width:122px}.fit-outline-line-l-hip{left:21px;top:333px;width:141px}.fit-outline-line-thigh-l{left:27px;top:372px;width:60px}.fit-outline-line-thigh-r{left:95px;top:372px;width:61px}#fit-line-container{position:relative;width:100%}#fit-line-text-container{align-items:center;display:flex;justify-content:space-between}.fit-line-item{font-weight:700;width:110px}.fit-line-item .light-text{font-weight:500}.fit-line-item-green{color:#209da7}#fit-line{display:flex;justify-content:space-around;margin-bottom:4px;margin-top:30px}#fit-line-1,#fit-line-2,#fit-line-3,#fit-line-4,#fit-line-5,#fit-line-6,#fit-line-7{background:#000;height:2px;position:relative;width:110px}#fit-line-3,#fit-line-4,#fit-line-5{background:#209da7}#fit-line-1:before,#fit-line-2:before,#fit-line-3:before,#fit-line-5:before,#fit-line-6:before,#fit-line-7:before{background:#000;border-radius:50%;content:"";height:12px;position:absolute;top:-5px;width:12px}#fit-line-1:before,#fit-line-2:before,#fit-line-3:before{left:0}#fit-line-5:before,#fit-line-6:before,#fit-line-7:before{right:0}#fit-line-1:before,#fit-line-2:before,#fit-line-6:before,#fit-line-7:before{background:#000}#fit-line-3:before,#fit-line-5:before{background:#209da7}#fit-line-2:before,#fit-line-6:before{display:none}#fit-line-1:after,#fit-line-2:after,#fit-line-3:after,#fit-line-4:after,#fit-line-5:after,#fit-line-6:after,#fit-line-7:after{border-left:2px dashed #000;content:"";display:block;height:20px;left:50%;position:absolute;top:-20px}#fit-line-3:after,#fit-line-4:after,#fit-line-5:after{border-left:2px dashed #209da7}#fit-line-texts{display:flex;justify-content:space-between;padding:0 70px}#fit-line-texts div:nth-of-type(2){color:#209da7}.margin-top-10{margin-top:10px}.desktop-hidden{display:none}#cta-link{cursor:pointer;font-size:20px;margin:auto;text-decoration:underline;width:150px}.powered-by{align-items:center;display:flex;justify-content:center;margin-top:10px}@media screen and (max-width:599px){#fit-outline-inner,#fit-outline-inner-left,#fit-outline-inner-right{height:400px}#fit-outline-inner{flex-shrink:0;overflow:hidden}#fit-title{margin-top:0}#fit-outline-container{margin-top:-50px;transform:scale(.7)}.fit-line-item{font-size:10px;font-weight:500}.fit-outline-line-text{font-size:16px;line-height:31px}.fit-outline-line-chest-text,.fit-outline-line-n-waist-text{left:-11px;width:auto}.fit-outline-line-p-waist-text{right:-10px;width:auto}.fit-outline-line-h-hip-text,.fit-outline-line-l-hip-text{left:-3px;width:auto}.fit-outline-line-thigh-text{right:3px;width:auto}#fit-line{margin-top:10px}#fit-line-texts{font-size:12px;padding:0 15px}#cta-section{margin-top:-30px}#fit-line-2:before,#fit-line-6:before,.desktop-hidden{display:block}#fit-line-1:after,#fit-line-2:after,#fit-line-3:after,#fit-line-4:after,#fit-line-5:after,#fit-line-6:after,#fit-line-7:after,.mobile-hidden{display:none}}');Pp(".tfr-home-button-container{display:flex;flex-wrap:wrap;margin:20px}.tfr-home-button-container>button{border:0;cursor:pointer;height:60px;margin:20px;width:200px}.tfr-home-button-container>button:hover{background-color:#e6e6e6}[data-tfr=hidden]{display:none}.tfr-modal{background-color:rgba(0,0,0,.53);display:flex;height:100%;left:0;position:fixed;top:0;width:100%;z-index:10000}.tfr-modal-content{margin:0 auto;text-align:center;width:90%}.tfr-modal-content-flex{align-items:center;display:flex}.tfr-modal-content-container{background-color:#fff;border:1px solid #434343;border-radius:0;box-shadow:0 6px 6px #00000029;line-height:normal;max-height:100vh;max-width:850px;overflow:auto;width:100%}#tfr-close-container{padding-right:10px}.tfr-close-container{text-align:end}.tfr-close{color:#aaa;font-size:28px;font-weight:700;height:50px;width:50px}.tfr-close:focus,.tfr-close:hover{color:#000;text-decoration:none}.tfr-cursor:hover{cursor:pointer}.tfr-underline{text-decoration:underline}.tfr-standard-button{border:0;border-radius:3px;color:#fff;height:43px;width:138px}.tfr-logo-container{align-items:center;display:flex}.tfr-modal-title-logo-container{align-items:center;display:flex;justify-content:center}.tfr-girl-clothes{display:inline-block;height:316px;width:253px}.tfr-t-a-center{text-align:center}.tfr-w-70-p{width:70%}.tfr-w-80-p{width:80%}.tfr-w-85-p{width:85%}.tfr-w-150{width:150px}.tfr-h-150{height:150px}.tfr-d-none{display:none}.tfr-d-block{display:block}.tfr-d-flex{display:flex}.tfr-how-it-works-item{align-items:center;display:flex;justify-items:center}.tfr-try-on-content{margin-left:60px}#tfr-tryon-image{max-width:30vw}.progress-bar{background-color:#fff;border:1px solid #bdbdbd;height:10px;margin:15px auto 0;width:55%}.progress-bar-fill{animation-duration:120s;animation-name:progress;background-color:#209da7;color:#fff;display:block;font-size:16px;height:100%;text-align:center;transition:width .6s linear}#tfr-video{height:100%;max-height:350px;max-width:350px}.tfr-logo-box{display:flex;margin:auto;max-height:400px;max-width:860px;padding:20px}.tfr-flex,.tfr-logo-box{align-items:center;justify-content:center}.tfr-qr-code{width:200px}.tfr-space-above{margin-top:10px}.tfr-max-w-600{margin:auto;max-width:600px}#tfr-qr-border-box{align-items:center;border:2px solid var(--tfr-brand-color);border-radius:16px;display:flex;flex-direction:column;height:350px;justify-content:center;margin-left:20px;padding:0 30px;width:300px}.tfr-mobile-logo{height:60px}#email-input,#password-input{font-size:16px}.tfr-door-icon,.tfr-user-icon{color:#209da7}.tfr-logged-in,.tfr-toggle-closed{display:none}.tfr-flex{display:flex}.tfr-gap{gap:4px}.tfr-items-center{align-items:center}.tfr-mb-2{margin-bottom:8px}#tfr-logged-out-overlay-container{position:relative}#tfr-logged-out-overlay{align-items:center;background:hsla(0,0%,100%,.8);bottom:0;display:flex;font-size:16px;font-weight:700;justify-content:center;left:0;line-height:16px;position:absolute;right:0;text-align:center;top:0}.tfr-slider-wrapper{align-items:center;display:flex;flex-direction:column}#tfr-slider{accent-color:var(--tfr-brand-color)}");Pp("input{border:none;box-shadow:none!important;width:100%}input:focus,select:focus,textarea:focus{border:none;outline:none}.tfr-fieldset{margin-left:auto;margin-right:auto;width:65%}.tfr-fieldset,.tfr-fieldset-inline{border-color:rgba(0,0,0,.5);border-radius:10px;border-width:1px;padding:5px 10px 10px;text-align:left}.tfr-fieldset-inline{margin-right:10px;width:250px}.tfr-fieldset-err{border-color:red}");Pp(".lds-ellipsis{display:inline-block;height:80px;position:relative;width:80px}.lds-ellipsis div{animation-timing-function:cubic-bezier(0,1,1,0);background:var(--tfr-brand-color);border-radius:50%;display:block;height:13px;position:absolute;top:33px;width:13px}.lds-ellipsis div:first-child{animation:lds-ellipsis1 .6s infinite;left:8px}.lds-ellipsis div:nth-child(2){animation:lds-ellipsis2 .6s infinite;left:8px}.lds-ellipsis div:nth-child(3){animation:lds-ellipsis2 .6s infinite;left:32px}.lds-ellipsis div:nth-child(4){animation:lds-ellipsis3 .6s infinite;left:56px}@keyframes lds-ellipsis1{0%{transform:scale(0)}to{transform:scale(1)}}@keyframes lds-ellipsis3{0%{transform:scale(1)}to{transform:scale(0)}}@keyframes lds-ellipsis2{0%{transform:translate(0)}to{transform:translate(24px)}}");Pp("@media screen and (max-width:702px){.tfr-modal-title-logo-container{display:flex;flex-direction:column}}@media screen and (min-width:600px){.tfr-modal-content-container{border-radius:10px;height:auto;margin:auto;width:100%}}@media screen and (max-width:599px){#tfr-size-recommendations{width:calc(100vw - 30px)!important}.tfr-mobile-small-text{font-size:12px}.tfr-mobile-hidden{display:none}.tfr-modal-content{overflow:hidden}.tfr-modal-content-container{max-height:none;max-width:100vw;min-height:100vh;min-width:100vw}.trf-logo-title{margin-bottom:10px}.tfr-modal-content-flex{overflow:auto}}@media screen and (max-width:500px){.tfr-fieldset{width:90%}.tfr-how-it-works-item{flex-direction:column}.tfr-try-on-content{margin-left:0;margin-top:20px}}@media screen and (max-height:800px){.tfr-video-responsive{height:280px!important}}");Pp('#tfr-size-recommendations{align-items:center;background-color:var(--tfr-main-bg-color);border:var(--tfr-main-border-width) solid var(--tfr-main-border-color);border-radius:var(--tfr-main-border-radius);color:var(--tfr-dark);display:flex;flex-direction:column;font-family:var(--tfr-main-font);justify-content:center;padding:var(--tfr-main-v-padding) var(--tfr-main-h-padding);width:var(--tfr-main-width)}#tfr-size-recommendations-container{align-items:center;display:none;flex-direction:column;justify-content:center;position:relative;width:100%}#tfr-size-rec-select-container{align-items:center;display:none;flex-direction:column;font-size:13px;width:100%}#tfr-size-rec-title{align-items:center;display:flex;font-family:var(--tfr-title-font);margin-bottom:8px}#tfr-size-rec-title-toggle{color:var(--tfr-grey);cursor:pointer;position:absolute;right:0;top:0;transition:all .3s ease}.tfr-chevron-up{transform:rotate(180deg) scaleY(.6)}.tfr-chevron-down{transform:rotate(0deg) scaleY(.6)}#tfr-info-icon{cursor:pointer}#tfr-size-rec-subtitle{border-bottom:2px solid #000;font-size:18px;font-weight:700;text-align:center;width:100%}#tfr-size-rec-title{font-size:14px}#tfr-size-rec-table{display:flex;flex-direction:column;font-size:12px;padding:0 10px;width:100%}.tfr-size-rec-table-row:first-of-type{border-top-width:0}.tfr-size-rec-table-row{align-items:center;border-top:var(--tfr-main-border-width) solid var(--tfr-main-border-color);display:flex;font-family:var(--tfr-row-font);justify-content:center;min-height:40px}.tfr-size-rec-table-cell-left,.tfr-size-rec-table-cell-right{flex:1 1 0px}.tfr-size-rec-table-cell-left{flex-grow:1;padding-left:8px;padding-right:8px;text-align:right}.tfr-size-rec-table-cell-right{flex-grow:1;padding-left:8px;padding-right:8px;text-align:left}.tfr-size-rec-table-cell-right.perfect{color:var(--tfr-brand-color)}#tfr-size-rec-size{display:inline-block}#tfr-size-rec-size>.tfr-size-rec-login-cta{font-weight:500;margin-left:10px}.tfr-size-rec-login-cta,.tfr-size-rec-table-cell-right{font-size:12px}.tfr-size-rec-login-cta{color:var(--tfr-muted);display:flex;width:150px}#tfr-size-rec-action-login,#tfr-size-rec-action-logout{display:none;font-family:var(--tfr-cta-font)}#tfr-size-rec-action{cursor:pointer;font-size:16px;text-decoration:underline}#tfr-size-rec-select{background-color:var(--tfr-size-selector-bg-color);border-color:var(--tfr-size-selector-border-color);border-radius:var(--tfr-size-selector-button-radius);border-style:solid;border-width:var(--tfr-size-selector-border-width);box-shadow:var(--tfr-size-selector-button-shadow);color:var(--tfr-size-selector-text-color);display:none;font-size:var(--tfr-size-selector-font-size);font-weight:var(--tfr-size-selector-font-weight);margin-bottom:20px;margin-top:10px}#tfr-size-rec-select,.tfr-size-rec-select-button{align-items:center;height:var(--tfr-size-selector-button-height);justify-content:center}.tfr-size-rec-select-button{cursor:pointer;display:flex;transition:all .15s ease-in;width:80px}.tfr-size-rec-select-button:hover:not(.active):not(.tfr-disabled){background-color:var(--tfr-size-selector-bg-color-hover);opacity:.7}.tfr-size-rec-select-button.active{background-color:var(--tfr-size-selector-bg-color-active);border-color:var(--tfr-size-selector-button-active-border-color);border-style:solid;border-width:var(--tfr-size-selector-button-active-border-width);height:var(--tfr-size-selector-button-active-height)}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:first-of-type{border-bottom-left-radius:var(--tfr-size-selector-button-radius);border-top-left-radius:var(--tfr-size-selector-button-radius)}.tfr-size-rec-select-button.active,.tfr-size-rec-select-button:last-of-type{border-bottom-right-radius:var(--tfr-size-selector-button-radius);border-top-right-radius:var(--tfr-size-selector-button-radius)}.tfr-powered-by{align-items:center;display:flex;font-size:10px;margin-top:10px}.tfr-powered-by-logo{margin:0 4px}.tfr-powered-by-logo,.tfr-powered-by-logo img,.tfr-powered-by-logo svg{height:24px;width:12px}.tfr-powered-by-text-bold{font-weight:700}#tfr-size-recommendation-error{color:#8d0000;display:none}#tfr-sign-in-nav{margin-bottom:80px}.tfr-disabled{cursor:default}#tfr-login-to-view{cursor:pointer}.tfr-try-on-button{align-items:center;background-color:var(--tfr-size-selector-bg-color-active);border-color:var(--tfr-size-selector-border-color);border-radius:var(--tfr-size-selector-button-radius);border-style:solid;border-width:var(--tfr-size-selector-border-width);box-shadow:var(--tfr-size-selector-button-shadow);color:var(--tfr-size-selector-text-color);cursor:pointer;display:flex;font-size:var(--tfr-size-selector-font-size);font-weight:var(--tfr-size-selector-font-weight);height:var(--tfr-size-selector-button-height);justify-content:center;margin-bottom:10px;margin-top:20px;max-width:200px;position:relative;transition:all .15s ease-in;width:100%}.tfr-try-on-button.loading,.tfr-try-on-button:disabled{cursor:not-allowed;opacity:.7}.tfr-try-on-button.hide{display:none}.tfr-try-on-button.loading:after{animation:spin 1s linear infinite;border:2px solid var(--tfr-size-selector-text-color);border-radius:50%;border-top:2px solid transparent;content:"";height:16px;margin-left:8px;position:absolute;width:16px}@keyframes spin{to{transform:rotate(1turn)}}');Pp(".tfr-mt-10{margin-top:10px}.tfr-mt-20{margin-top:20px}.tfr-mt-15{margin-top:15px}.tfr-mt-30{margin-top:30px}.mt-40{margin-top:40px}.tfr-mb-40{margin-bottom:40px}.tfr-mb-20{margin-bottom:20px}.tfr-mr-10{margin-right:10px}.tfr-mr-15{margin-right:15px}.tfr-mt-50{margin-top:50px}.tfr-mt-60{margin-top:60px}.tfr-mb-60{margin-bottom:60px}.tfr-mr-20{margin-right:20px}.tfr-mt-15-p{margin-top:15%}.tfr-mb-13-p{margin-bottom:13%}.tfr-m-h-auto{margin-left:auto;margin-right:auto}.tfr-pt-20{padding-top:20px}.tfr-pb-50{padding-bottom:50px}.tfr-p-20{padding:20px 10px}.tfr-pr-20{padding-right:20px}.tfr-pl-20{padding-left:20px}.tfr-pb-7-p{padding-bottom:7%}");Pp(".flag-container{bottom:0;left:0;padding:1px;right:0;right:auto;top:0}.flag-container:hover{cursor:pointer}.selected-flag{align-items:center;display:flex;height:100%;padding:0 6px 0 8px;position:relative;z-index:1}.flag.bd{background-position:-418px 0;height:12px}.arrow{border-left:6px solid transparent;border-right:6px solid transparent;border-top:6px solid #555;height:0;margin-left:6px;width:0}.arrow-up{border-bottom:6px solid #555;border-top:none}.country-list{-webkit-overflow-scrolling:touch;background-color:#fff;border-radius:5px;box-shadow:0 8px 10px 1px rgba(57,64,78,.7),0 3px 14px 2px rgba(57,64,78,.7),0 5px 5px -3px rgba(57,64,78,.7);cursor:pointer;display:none;font-size:16px;line-height:18px;list-style:none;margin:0 0 0 -1px;max-height:500px;overflow:auto;padding:0;position:absolute;text-align:left;top:50%;transform:translateY(-50%);white-space:nowrap;width:100%;width:auto;z-index:2}.country-list.active{display:inline-block}.country{outline:0;padding:5px 26px 5px 15px}.country-list .divider{border-bottom:1px solid rgba(0,0,0,.12);margin-bottom:5px;padding-bottom:5px}.country.highlight{background-color:#c7cace}.flag-box{display:inline-block;width:20px}.country-name,.flag-box{margin-right:6px}.country-name,.dial-code,.flag-box{vertical-align:middle}");Pp(".tfr-title-font{font-family:Poppins,sans-serif}.tfr-body-font{font-family:Roboto,sans-serif}.tfr-light-24-300{font-size:24px;font-weight:300}.tfr-light-24-500{font-size:24px;font-weight:500}.tfr-light-22-300{font-size:22px;font-weight:300}.tfr-light-16-300{font-size:16px;font-weight:300}.tfr-medium-16-default{font-size:16px}.tfr-12-default{font-size:12px}.tfr-14-default{font-size:14px}.tfr-16-default{font-size:16px}.tfr-24-bold{font-size:24px;font-weight:700}");Pp(":root{--tfr-brand-color:#209da7;--tfr-black:#000;--tfr-red:red;--tfr-white:#fff;--tfr-muted:#a7a7a7;--tfr-dark:#121212;--tfr-grey:#878787;--tfr-light-grey:#dbdcdc;--tfr-dark-grey:#3f3f3f;--tfr-main-border-color:hsla(0,0%,7%,.55);--tfr-main-border-radius:0;--tfr-main-border-width:1px;--tfr-main-bg-color:inherit;--tfr-main-width:440px;--tfr-main-v-padding:14px;--tfr-main-h-padding:20px;--tfr-main-font:inherit;--tfr-title-font:var(--tfr-main-font);--tfr-subtitle-font:var(--tfr-main-font);--tfr-row-font:var(--tfr-main-font);--tfr-cta-font:var(--tfr-main-font);--tfr-size-selector-text-color:var(--tfr-white);--tfr-size-selector-font-size:14px;--tfr-size-selector-font-weight:400;--tfr-size-selector-border-color:transparent;--tfr-size-selector-border-width:0;--tfr-size-selector-bg-color:var(--tfr-grey);--tfr-size-selector-bg-color-hover:var(--tfr-dark-grey);--tfr-size-selector-bg-color-active:var(--tfr-dark);--tfr-size-selector-button-height:35px;--tfr-size-selector-button-active-height:45px;--tfr-size-selector-button-active-border-color:transparent;--tfr-size-selector-button-active-border-width:0;--tfr-size-selector-button-radius:8px;--tfr-size-selector-button-shadow:0 4px 4px 0 rgba(0,0,0,.3)}");const Dp='\n<svg class="tfr-door-icon" width="68" height="124" viewBox="0 0 68 124" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M0.911938 0L67.4819 17.09V106.49L0.911938 123.51V0Z" fill="currentColor">\n </path>\n <path d="M52.8019 64.44C54.7791 64.44 56.3819 62.4387 56.3819 59.97C56.3819 57.5013 54.7791 55.5 52.8019 55.5C50.8248 55.5 49.2219 57.5013 49.2219 59.97C49.2219 62.4387 50.8248 64.44 52.8019 64.44Z" fill="white">\n</path>\n</svg>',Mp='<svg class="tfr-user-icon" width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <g clip-path="url(#clip0_82_11365)">\n <path fill-rule="evenodd" clip-rule="evenodd"\n d="M4.3125 4.78125C4.3125 3.02084 5.73959 1.59375 7.5 1.59375C9.26041 1.59375 10.6875 3.02084 10.6875 4.78125C10.6875 6.54166 9.26041 7.96875 7.5 7.96875C5.73959 7.96875 4.3125 6.54166 4.3125 4.78125ZM9.625 4.78125C9.625 3.60764 8.6736 2.65625 7.5 2.65625C6.32639 2.65625 5.375 3.60764 5.375 4.78125C5.375 5.95485 6.32639 6.90625 7.5 6.90625C8.6736 6.90625 9.625 5.95485 9.625 4.78125Z"\n fill="currentColor" fill-opacity="0.7" />\n <path fill-rule="evenodd" clip-rule="evenodd"\n d="M2.1875 13.1634C2.1875 10.5693 4.58181 8.5 7.5 8.5C10.4182 8.5 12.8125 10.5693 12.8125 13.1634C12.8125 16.1539 2.1875 16.1539 2.1875 13.1634ZM11.75 13.1634C11.75 11.1933 9.86303 9.5625 7.5 9.5625C5.13697 9.5625 3.25 11.1933 3.25 13.1634C3.25 13.7564 4.45689 14.126 5.96113 14.2721L6.31312 14.3019C7.08543 14.3577 7.91457 14.3577 8.68688 14.3019L9.03887 14.2721C10.5431 14.126 11.75 13.7564 11.75 13.1634Z"\n fill="currentColor" fill-opacity="0.7" />\n </g>\n <defs>\n <clipPath id="clip0_82_11365">\n <rect width="16" height="16" fill="white" />\n </clipPath>\n </defs>\n</svg>',zp=e=>({Hook:()=>{const t=document.querySelector(".progress-bar-fill");!function(e,t){let n=0;const i=e/200;t.style.width=n+"%";const r=setInterval(()=>{n>=100?clearInterval(r):(n+=.5,t.style.width=n+"%")},i)}(e.timeoutMS,t)},Unhook:()=>{},Body:()=>`\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black tfr-mt-60" > ${pp} </div>\n <div class="progress-bar">\n <span class="progress-bar-fill"></span>\n </div>\n `,useFullModalContent:!0}),Fp=e=>{const t=document.getElementById(e),n=document.querySelector("body");if(!t)throw new Error(`element with id ${e} not found`);let i;const r=e=>e?`\n <div class="tfr-modal-title-logo-container">\n <div tfr-element="true" class="trf-logo-title tfr-title-font tfr-light-24-300 tfr-c-black tfr-mr-10">${Op}</div>\n <div tfr-element="true" class="tfr-logo-container">\n <div class="tfr-mr-15">\n <svg width="26" height="47" viewBox="0 0 68 124" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M0.911938 0L67.4819 17.09V106.49L0.911938 123.51V0Z" fill="#209DA7">\n </path>\n <path d="M52.8019 64.44C54.7791 64.44 56.3819 62.4387 56.3819 59.97C56.3819 57.5013 54.7791 55.5 52.8019 55.5C50.8248 55.5 49.2219 57.5013 49.2219 59.97C49.2219 62.4387 50.8248 64.44 52.8019 64.44Z" fill="white">\n </path>\n </svg>\n </div>\n <div tfr-element="true" class="tfr-title-font tfr-light-24-500 tfr-c-black tfr-mr-10">${Rp}</div>\n </div>\n </div>\n `:"",s=()=>{n.style.overflow="auto",i&&(i.Unhook(),l()),t.style.display="none"},o=e=>{"Escape"===e.key&&s()},a=e=>{const n=t.querySelector("#tfr-modal-background");e.target===n&&(console.debug("container close"),s())},c=()=>{t.querySelector("#tfr-close-container").addEventListener("click",s),document.addEventListener("keydown",o),document.addEventListener("click",a)},l=()=>{var n;const i=t.querySelector("#tfr-close-container");i?i.removeEventListener("click",s):(console.error("#tfr-close-container not found on unhook"),console.debug(null===(n=document.getElementById(e))||void 0===n?void 0:n.innerHTML)),document.removeEventListener("keydown",o),document.removeEventListener("click",a)};return{open:e=>{var s,o;n.style.overflow="hidden",i&&i.Unhook(),t.innerHTML=(s=e.Body(),o=e.useFullModalContent,console.log({useFullModalContent:o}),`\n <div class="tfr-modal" id="tfr-modal-background">\n <div class="tfr-modal-content-container tfr-p-20">\n <div class="tfr-close-container">\n <span id="tfr-close-container" class="tfr-close tfr-cursor">&times;</span>\n </div>\n\n <div class="tfr-modal-content-flex">\n <div class="tfr-modal-content">\n ${r(o)}\n ${s}\n </div>\n </div>\n </div>\n </div>\n `),c(),e.Hook(),t.style.display="block",i=e},close:s,Content:()=>i}},Up=e=>{const t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),n=()=>{e.onSignInNav()},i=()=>{window.open("https://apps.apple.com/us/app/the-fitting-room-3d-body-scan/id1577417373","_blank")},r=()=>{window.open("https://play.google.com/store/apps/details?id=com.thefittingroom.marketplace","_blank")},s="https://assets.dev.thefittingroom.xyz/images/";return{Hook:()=>{var e,s,o;if(t||(document.getElementById("tfr-sign-in-nav").style.marginBottom="0"),t){document.getElementById("tfr-video").classList.add("tfr-video-responsive")}null===(e=document.getElementById("tfr-sign-in-nav"))||void 0===e||e.addEventListener("click",n),null===(s=document.getElementById("tfr-app-store"))||void 0===s||s.addEventListener("click",i),null===(o=document.getElementById("tfr-google-play"))||void 0===o||o.addEventListener("click",r)},Unhook:()=>{var e,t,s;null===(e=document.getElementById("tfr-sign-in-nav"))||void 0===e||e.removeEventListener("click",n),null===(t=document.getElementById("tfr-app-store"))||void 0===t||t.removeEventListener("click",i),null===(s=document.getElementById("tfr-google-play"))||void 0===s||s.removeEventListener("click",r)},Body:()=>`\n <div tfr-element="true">\n <div tfr-element="true" class="tfr-title-font tfr-light-16-300 tfr-mt-10">${Lp}</div>\n \n </div>\n <div tfr-element="true" class="tfr-logo-box">\n <video id="tfr-video" controls loop autoplay playsinline>\n <source src="https://assets.dev.thefittingroom.xyz/videos/the-fitting-room.mp4" />\n </video>\n\n ${t?"":`<div id="tfr-qr-border-box">\n <div tfr-element="true" class="tfr-title-font tfr-24-bold">${Ep}</div>\n \n <img src="${s}qr.png" class="tfr-qr-code" />\n\n <div id="tfr-sign-in-nav" tfr-element="true" class="tfr-body-font tfr-mt-20 tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor">${fp}</div>\n </div>`}\n </div>\n\n ${t?`<div tfr-element="true" class="tfr-title-font tfr-light-16-300 tfr-mt-10 tfr-max-w-600">${op}</div>\n\n <div tfr-element="true" class="tfr-flex tfr-space-above">\n <img class="tfr-mobile-logo" src="${s}apple.png" id="tfr-app-store" />\n <img class="tfr-mobile-logo" src="${s}google.png" id="tfr-google-play" />\n </div>\n \n <div id="tfr-sign-in-nav" tfr-element="true" class="tfr-body-font tfr-mt-20 tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor">${fp}</div>\n `:""}\n `,useFullModalContent:!0}};class Vp{constructor(e,t,n,i){this.signIn=t,this.forgotPassword=n,this.submitTel=i,this.manager=Fp(e)}close(){this.manager.close()}onSignOut(){this.manager.open((e=>{const t=()=>{e.onNavSignIn("")},n=()=>{e.onClose()};return{Hook:()=>{var e,i;null===(e=document.getElementById("tfr-sign-in"))||void 0===e||e.addEventListener("click",t),null===(i=document.getElementById("tfr-close"))||void 0===i||i.addEventListener("click",n)},Unhook:()=>{var e,i;null===(e=document.getElementById("tfr-sign-in"))||void 0===e||e.removeEventListener("click",t),null===(i=document.getElementById("tfr-close"))||void 0===i||i.removeEventListener("click",n)},Body:()=>`\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-mt-15-p tfr-mb-13-p">${Ap}</div>\n <div class="tfr-t-a-center">\n <span id="tfr-sign-in" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-20">${Ip}</span>\n <span id="tfr-close" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor" >${_p}</span>\n </div>\n `,useFullModalContent:!0}})({onNavSignIn:()=>this.toSignIn(),onClose:()=>this.close()}))}onNotCreated(){this.manager.open({Body:()=>`\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black tfr-mt-60">${cp}</div>\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black tfr-mb-60">${Sp}</div>\n `,Hook:()=>{},Unhook:()=>{},useFullModalContent:!0})}onLoading(){this.manager.open(zp({timeoutMS:1e4}))}toScan(){this.manager.open(Up({onSignInNav:()=>this.toSignIn(),onTelSubmit:e=>this.submitTel(e)}))}toSignIn(){this.manager.open((e=>{const{email:t}=e,n=t=>{t.preventDefault();const n=document.getElementById("email-input").value,i=document.getElementById("password-input").value;s(),e.onSignIn(n,i,o)},i=()=>{const t=document.getElementById("email-input").value;e.onNavForgotPassword(t)},r=()=>{e.onNavScanCode()},s=()=>{document.querySelectorAll(".tfr-fieldset-element").forEach(e=>{e.classList.remove("tfr-fieldset-err")}),document.querySelectorAll(".tfr-label-element").forEach(e=>{e.classList.remove("tfr-c-red")});const e=document.querySelector("#tfr-form-error");e.classList.remove("tfr-d-block"),e.innerHTML=""},o=e=>{document.querySelectorAll(".tfr-fieldset-element").forEach(e=>{e.classList.add("tfr-fieldset-err")}),document.querySelectorAll(".tfr-label-element").forEach(e=>{e.classList.add("tfr-c-red")});const t=document.querySelector("#tfr-form-error");t.innerHTML=e||"Something went wrong",t.classList.add("tfr-d-block")};return{Hook:()=>{var e,t,s,o;null===(e=document.getElementById("tfr-sign-in-form"))||void 0===e||e.addEventListener("submit",n),null===(t=document.getElementById("tfr-sign-in"))||void 0===t||t.addEventListener("click",n),null===(s=document.getElementById("tfr-forgot-password"))||void 0===s||s.addEventListener("click",i),null===(o=document.getElementById("tfr-scan-code"))||void 0===o||o.addEventListener("click",r)},Unhook:()=>{var e,t,s,o;null===(e=document.getElementById("tfr-sign-in-form"))||void 0===e||e.removeEventListener("submit",n),null===(t=document.getElementById("tfr-sign-in"))||void 0===t||t.removeEventListener("click",n),null===(s=document.getElementById("tfr-forgot-password"))||void 0===s||s.removeEventListener("click",i),null===(o=document.getElementById("tfr-scan-code"))||void 0===o||o.removeEventListener("click",r)},Body:()=>`\n <form id="tfr-sign-in-form">\n <div class="tfr-title-font tfr-light-22-300 tfr-mt-10">${Cp}</div>\n\n <fieldset class="tfr-fieldset-element tfr-fieldset tfr-mt-20">\n <legend tfr-element="true" class="tfr-label-element tfr-body-font tfr-14-default tfr-c-black-o5">${lp}</legend>\n <input tfr-element="true" type="email" id="email-input" value="${t||""}" />\n </fieldset>\n\n <fieldset class="tfr-fieldset-element tfr-fieldset tfr-mt-20">\n <legend tfr-element="true" class="tfr-label-element tfr-body-font tfr-14-default tfr-c-black-o5">${yp}</legend>\n <input tfr-element="true" type="password" id="password-input" />\n </fieldset>\n\n <div tfr-element="true" class="tfr-body-font tfr-12-default tfr-c-red tfr-mt-10 tfr-d-none" id="tfr-form-error"></div>\n\n <div class="tfr-mt-20">\n <span id="tfr-forgot-password" tfr-element="true" class="tfr-body-font tfr-14-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-15">${dp}</span>\n <span id="tfr-scan-code" tfr-element="true" class="tfr-body-font tfr-14-default tfr-c-black-o5 tfr-underline tfr-cursor">${ap}</span>\n </div>\n\n <button id="tfr-sign-in" tfr-element="true" class="tfr-standard-button tfr-c-brand-bg tfr-c-whitetfr-title-font tfr-medium-16-default tfr-cursor tfr-mt-30" id="sign-in-button" type="submit">\n ${Cp}\n </button>\n </form>\n `,useFullModalContent:!0}})({onSignIn:this.signIn,onNavForgotPassword:()=>this.toForgotPassword(),onNavScanCode:()=>this.toScan()}))}toForgotPassword(){this.manager.open((e=>{const t=()=>{const t=document.getElementById("tfr-email").value;e.onNavSignIn(t)},n=()=>{const t=document.getElementById("tfr-email").value;e.onPasswordReset(t)};return{Hook:()=>{var e,i;null===(e=document.getElementById("tfr-send-password-reset"))||void 0===e||e.addEventListener("click",n),null===(i=document.getElementById("tfr-back-to-signin"))||void 0===i||i.addEventListener("click",t)},Unhook:()=>{var e,i;null===(e=document.getElementById("tfr-send-password-reset"))||void 0===e||e.removeEventListener("click",n),null===(i=document.getElementById("tfr-back-to-signin"))||void 0===i||i.removeEventListener("click",t)},Body:()=>`\n <div tfr-element="true" class="tfr-title-font tfr-light-16-300 tfr-mt-20 tfr-w-70-p tfr-m-h-auto">${hp}</div>\n <fieldset class="tfr-fieldset-element tfr-fieldset tfr-mt-30">\n <legend tfr-element="true" class="tfr-label-element tfr-body-font tfr-14-default tfr-c-black-o5">${lp}</legend>\n <input tfr-element="true" type="email" id="tfr-email" />\n </fieldset>\n <div tfr-element="true" class="tfr-body-font tfr-12-default tfr-c-red tfr-mt-10 tfr-d-none" id="error-msg"></div>\n <div id="tfr-back-to-signin" tfr-element="true" class="tfr-body-font tfr-12-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mt-30">${sp}</div>\n <button id="tfr-send-password-reset" tfr-element="true" class="tfr-standard-button tfr-c-brand-bg tfr-c-whitetfr-title-font tfr-medium-16-default tfr-cursor tfr-mt-30">\n ${Tp}\n </button>\n `,useFullModalContent:!0}})({onNavSignIn:()=>this.toSignIn(),onPasswordReset:this.forgotPassword}))}toPasswordReset(){}onTryOn(e){this.manager.open((e=>{let t=()=>{};const i=()=>{e.onNavBack()},r=()=>{e.onClose()};return{Hook:()=>{var s,o;const a=document.getElementById("tfr-tryon-image"),c=n("tfr-slider",(e,t)=>{console.debug("slider change",e,t),a.src=t});if(Array.isArray(e.frames)&&e.frames.length>0){const n=c.Load(e.frames);if(n instanceof Error)return void console.error(n);t=n}null===(s=document.getElementById("tfr-back"))||void 0===s||s.addEventListener("click",i),null===(o=document.getElementById("tfr-close"))||void 0===o||o.addEventListener("click",r)},Unhook:()=>{var e,n;t(),null===(e=document.getElementById("tfr-back"))||void 0===e||e.removeEventListener("click",i),null===(n=document.getElementById("tfr-close"))||void 0===n||n.removeEventListener("click",r)},Body:()=>'\n <div class="tfr-slider-wrapper">\n\t\t\t\t<img id="tfr-tryon-image" src="" />\n\t\t\t\t<input type="range" id="tfr-slider" />\n\t\t\t\t</div>\n ',useFullModalContent:!0}})({frames:e,onClose:()=>this.close(),onNavBack:()=>this.navBack()}))}onError(e){this.manager.open((e=>{const{error:t}=e,n=()=>{e.onNavBack()},i=()=>{e.onClose()};return{Hook:()=>{var e,t;null===(e=document.getElementById("tfr-back"))||void 0===e||e.addEventListener("click",n),null===(t=document.getElementById("tfr-close"))||void 0===t||t.addEventListener("click",i)},Unhook:()=>{var e,t;null===(e=document.getElementById("tfr-back"))||void 0===e||e.removeEventListener("click",n),null===(t=document.getElementById("tfr-close"))||void 0===t||t.removeEventListener("click",i)},Body:()=>(t||console.error("ErrorModal: No error provided"),`\n <div class="tfr-mt-15-p tfr-mb-13-p">\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black">${t||kp}</div>\n </div>\n\n <div class="tfr-t-a-center">\n <span id="tfr-back" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-20">${wp}</span>\n <span id="tfr-close" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor" id="returnToSite">${bp}</span>\n </div>\n `),useFullModalContent:!0}})({error:e,onClose:()=>this.close(),onNavBack:()=>this.navBack()}))}onSizeError(e,t){this.manager.open((e=>{const t=()=>{e.onNavBack()},n=()=>{e.onClose()};return{Hook:()=>{var e,i;null===(e=document.getElementById("tfr-back"))||void 0===e||e.addEventListener("click",t),null===(i=document.getElementById("tfr-close"))||void 0===i||i.addEventListener("click",n)},Unhook:()=>{var e,i;null===(e=document.getElementById("tfr-back"))||void 0===e||e.removeEventListener("click",t),null===(i=document.getElementById("tfr-close"))||void 0===i||i.removeEventListener("click",n)},Body:()=>{var t,n,i;return console.debug("rendering size error modal",e),`\n <div class="tfr-mt-15-p tfr-mb-13-p">\n <div tfr-element="true" class="tfr-title-font tfr-light-22-300 tfr-c-black">\n\t\t\t\t\t\t\t${gp} ${null===(t=e.sizes)||void 0===t?void 0:t.recommended} ${mp} ${null===(i=null===(n=e.sizes)||void 0===n?void 0:n.available)||void 0===i?void 0:i.join(" or ")}\n\t\t\t\t\t\t</div>\n </div>\n\n <div class="tfr-t-a-center">\n <span id="tfr-back" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor tfr-mr-20">${wp}</span>\n <span id="tfr-close" tfr-element="true" class="tfr-body-font tfr-16-default tfr-c-black-o5 tfr-underline tfr-cursor">${bp}</span>\n </div>\n `},useFullModalContent:!0}})({sizes:{recommended:e,available:t},onClose:()=>this.close(),onNavBack:()=>this.navBack()}))}toFitInfo(){this.manager.open((e=>{const t=()=>e.onSignInNav();return{Hook:()=>{document.getElementById("cta-link").addEventListener("click",t)},Unhook:()=>{document.getElementById("cta-link").removeEventListener("click",t)},Body:()=>`\n <div>\n <div id="fit-title">Fit Scale</div>\n\n <div id="fit-line-container">\n <div id="fit-line-text-container">\n <div class="fit-line-item mobile-hidden">Too Tight</div>\n\n <div class="fit-line-item">\n <div>Tight <span class="light-text">or</span><br /> More fitted</div>\n\n <div class="desktop-hidden margin-top-10">Too Tight</div>\n </div>\n\n <div class="fit-line-item fit-line-item-green">Slightly tight <br /><span class="light-text">or</span> Fitted</div>\n <div class="fit-line-item fit-line-item-green">Perfect Fit</div>\n <div class="fit-line-item fit-line-item-green">Slightly loose <br /><span class="light-text">or</span> Less fitted</div>\n\n <div class="fit-line-item">\n <div>Loose <span class="light-text">or</span><br /> Not fitted</div>\n\n <div class="desktop-hidden margin-top-10">Oversized</div>\n </div>\n\n <div class="fit-line-item mobile-hidden">Oversized</div>\n </div>\n\n <div id="fit-line">\n <div id="fit-line-1" class="mobile-hidden">&nbsp;</div>\n <div id="fit-line-2">&nbsp;</div>\n <div id="fit-line-3">&nbsp;</div>\n <div id="fit-line-4">&nbsp;</div>\n <div id="fit-line-5">&nbsp;</div>\n <div id="fit-line-6">&nbsp;</div>\n <div id="fit-line-7" class="mobile-hidden">&nbsp;</div>\n </div>\n\n <div id="fit-line-texts">\n <div>Poor Fit</div>\n <div>Acceptable Fit</div>\n <div>Poor Fit</div>\n </div>\n </div>\n\n <div id="fit-subtitle-mobile" class="desktop-hidden">Measurement&nbsp;Points</div>\n\n <div id="fit-outline-container">\n <div id="fit-outline-inner-left">\n <div class="fit-outline-line-text fit-outline-line-p-waist-text">Pant&nbsp;Waist</div>\n <div class="fit-outline-line-text fit-outline-line-thigh-text">Thigh</div>\n </div>\n\n <div id="fit-outline-inner">\n <div class="fit-outline-line fit-outline-line-chest"></div>\n <div class="fit-outline-line fit-outline-line-n-waist"></div>\n <div class="fit-outline-line fit-outline-line-p-waist"></div>\n <div class="fit-outline-line fit-outline-line-h-hip"></div>\n <div class="fit-outline-line fit-outline-line-l-hip"></div>\n <div class="fit-outline-line fit-outline-line-thigh-l"></div>\n <div class="fit-outline-line fit-outline-line-thigh-r"></div>\n\n <img id="tfr-fit-outline-img" src="https://assets.dev.thefittingroom.xyz/images/fit-outline.png" />\n </div>\n\n <div id="fit-outline-inner-right">\n <div id="fit-subtitle" class="mobile-hidden">Measurement&nbsp;Points</div>\n\n <div class="fit-outline-line-text fit-outline-line-chest-text">Chest/Bust</div>\n <div class="fit-outline-line-text fit-outline-line-n-waist-text">Natural&nbsp;Waist</div>\n <div class="fit-outline-line-text fit-outline-line-h-hip-text">High&nbsp;Hip</div>\n <div class="fit-outline-line-text fit-outline-line-l-hip-text">Low&nbsp;Hip</div>\n </div>\n </div>\n </div>\n\n <div id="cta-section">\n <div id="cta-link">Sign Up or Login</div>\n\n <div class="powered-by">\n <div>Powered by</div>\n <div class="tfr-powered-by-logo">${Dp}</div>\n <div class="tfr-powered-by-text-bold">The Fitting Room</div>\n </div>\n </div>\n `,useFullModalContent:!1}})({onSignInNav:()=>this.toScan(),onClose:()=>this.close()}))}navBack(){window.history.back()}}class Bp{constructor(e,t,n,i,r){this.onSignInClick=t,this.onSignOutClick=n,this.onFitInfoClick=i,this.onTryOnClick=r,this._sku="",this._styleId=null,this.tfrLoggedInElements=[],this.tfrLoggedOutElements=[],this.tfrToggleOpenElements=[],this.tfrToggleClosedElements=[],this.isCollapsed=!1,this.redraw=null,this.init(e)}get sku(){return this._sku}setSku(e){this._sku=e}get styleId(){return this._styleId}setStyleId(e){this._styleId=e}setIsLoggedIn(e){this.tfrSizeRecSelectContainer.style.display="flex",this.tfrSizeRecSelect.style.display="flex",this.tfrSizeHowItFits.style.display="block",e?(this.tfrSizeHowItFits.style.opacity="1",this.tfrSizeRecSelect.style.opacity="1",this.tfrLoggedInElements.forEach(e=>e.style.display="block"),this.tfrLoggedOutElements.forEach(e=>e.style.display="none"),this.tfrSizeRecActionLogin.style.display="none",this.tfrSizeRecActionLogout.style.display="block",this.tfrSizeRecTitle.style.display="flex",this.isCollapsed=!1,this.tfrSizeRecTitleToggle.classList.add("tfr-chevron-up"),this.tfrSizeRecTitleToggle.classList.remove("tfr-chevron-down"),this.tfrSizeRecSelectContainer.style.display="flex",this.tfrSizeRecSelectContainer.style.opacity="1"):(this.tfrSizeHowItFits.style.opacity="0.4",this.tfrSizeRecSelect.style.opacity="0.4",this.tfrLoggedInElements.forEach(e=>e.style.display="none"),this.tfrLoggedOutElements.forEach(e=>e.style.display="block"),this.tfrSizeRecActionLogin.style.display="block",this.tfrSizeRecActionLogout.style.display="none",this.tfrSizeRecTitle.style.display="flex",this.tfrSizeRecommendationError.style.display="none",this.tfrSizeRecommendationError.innerHTML="",this.renderSizeRecSelectLoggedOut())}setLoading(e){e?(this.tfrSizeRecLoading.style.display="block",this.tfrSizeRecommendationsContainer.style.display="none"):(this.tfrSizeRecLoading.style.display="none",this.tfrSizeRecommendationsContainer.style.display="flex")}setGarmentLocations(e){e&&e.length?this.renderGarmentLocations(e):this.tfrSizeRecTitle.style.display="none"}setRecommendedSize({recommended:e,sizes:t}){this.renderSizeRec(e,t)}hide(){this.sizeRecMainDiv&&(this.sizeRecMainDiv.style.display="none")}show(){this.sizeRecMainDiv&&(this.sizeRecMainDiv.style.display="block")}init(e){const t=document.getElementById(e);if(!t)throw new Error("Size rec main div not found");this.sizeRecMainDiv=t,this.render(t),this.setElements(),this.bindEvents()}setElements(){this.tfrSizeHowItFits=document.getElementById("tfr-size-how-it-fits"),this.tfrSizeRecTitle=document.getElementById("tfr-size-rec-title"),this.tfrInfoIcon=document.getElementById("tfr-info-icon"),this.tfrLoginToView=document.getElementById("tfr-login-to-view"),this.tfrSizeRecActionLogin=document.getElementById("tfr-size-rec-action-login"),this.tfrSizeRecActionLogout=document.getElementById("tfr-size-rec-action-logout"),this.tfrSizeRecTable=document.getElementById("tfr-size-rec-table"),this.tfrSizeRecommendationError=document.getElementById("tfr-size-recommendation-error"),this.tfrSizeRecSize=document.getElementById("tfr-size-rec-size"),this.tfrSizeRecSelect=document.getElementById("tfr-size-rec-select"),this.tfrSizeRecLoading=document.getElementById("tfr-size-rec-loading"),this.tfrSizeRecTitleToggle=document.getElementById("tfr-size-rec-title-toggle"),this.tfrSizeRecSelectContainer=document.getElementById("tfr-size-rec-select-container"),this.tfrSizeRecommendationsContainer=document.getElementById("tfr-size-recommendations-container"),this.tfrLoggedInElements=document.querySelectorAll(".tfr-logged-in"),this.tfrLoggedOutElements=document.querySelectorAll(".tfr-logged-out"),this.tfrToggleOpenElements=document.querySelectorAll(".tfr-toggle-open"),this.tfrToggleClosedElements=document.querySelectorAll(".tfr-toggle-closed")}bindEvents(){this.tfrSizeRecActionLogin.addEventListener("click",this.onSignInClick),this.tfrSizeRecActionLogout.addEventListener("click",this.onSignOutClick),this.tfrSizeRecSelect.addEventListener("click",this.onSizeRecSelectClick.bind(this)),this.tfrSizeRecTitleToggle.addEventListener("click",this.toggletSizeRecSelectContainer.bind(this)),this.tfrInfoIcon.addEventListener("click",this.onFitInfoClick),this.tfrLoginToView.addEventListener("click",this.onSignInClick);const e=document.getElementById("tfr-try-on-button");e&&e.addEventListener("click",async()=>{if(e.classList.contains("loading"))return;const t=document.querySelector(".tfr-size-rec-select-button.active");if(!t)return;const n=Number(t.getAttribute("data-size-id"));if(Number.isNaN(n))return;e.classList.add("loading");const i=e.textContent;e.textContent=" ",e.setAttribute("disabled","true");try{const e=Array.from(document.querySelectorAll(".tfr-size-rec-select-button")),i=e.indexOf(t);if(null!==this.styleId){try{await this.onTryOnClick(this.styleId,n,!0)}catch(e){console.error(`Error trying on active size ${n}:`,e)}if(i>0){const t=e[i-1];await this._preloadNeighborVTO(t)}if(i>=0&&i<e.length-1){const t=e[i+1];await this._preloadNeighborVTO(t)}}}catch(e){console.error("Error during sequential try-on process:",e)}finally{e.classList.remove("loading"),e.textContent=i,e.removeAttribute("disabled")}})}async _preloadNeighborVTO(e){var t;const n=Number(e.getAttribute("data-size-id"));if(!Number.isNaN(n))try{await this.onTryOnClick(this.styleId,n,!1)}catch(i){const r=(null===(t=e.textContent)||void 0===t?void 0:t.trim())||"N/A";console.error(`Error pre-loading try-on for size ${n} (button: ${r}):`,i)}}onSizeRecSelectClick(e){const t=e.target;if(!t.classList.contains("tfr-size-rec-select-button")||t.classList.contains("tfr-disabled"))return;e.preventDefault();const n=Number(t.getAttribute("data-index"));if(Number.isNaN(n))return;const i=document.querySelectorAll(".tfr-size-rec-select-button");i.forEach(e=>e.classList.remove("active")),i.item(n).classList.add("active"),this.redraw(n);const r=Number(t.getAttribute("data-size-id"));Number.isNaN(r)||this.onTryOnClick(this.styleId,r,!0)}renderSizeRec(e,t){this.tfrSizeRecSize.innerHTML=`&nbsp;${e}`;const n=t.findIndex(({size:t})=>t===e);this.redraw=e=>this.renderSizeRecTable(t,e),this.redraw(n),this.renderSizeRecSelect(t,n)}renderSizeRecTable(e,t){const{locations:n}=e[t],i=n.map(({location:e,fit:t,isPerfect:n})=>this.renderSizeRecTableRow(e,t,n)).join("");this.tfrSizeRecTable.innerHTML=i}renderSizeRecSelect(e,t){const n=e.map(({size:e})=>e).map((n,i)=>`<div class="tfr-size-rec-select-button ${i===t?"active":""}" data-index="${i}" data-size-id="${e[i].size_id}">${n}</div>`).join("");this.tfrSizeRecSelect.innerHTML=n}renderSizeRecSelectLoggedOut(){const e=['<div class="tfr-size-rec-select-button tfr-disabled">M</div>','<div class="tfr-size-rec-select-button tfr-disabled active">L</div>','<div class="tfr-size-rec-select-button tfr-disabled">XL</div>'].join("");this.tfrSizeRecSelect.innerHTML=e}renderSizeRecTableRow(e,t,n=!1){return`<div class="tfr-size-rec-table-row">\n <div class="tfr-size-rec-table-cell-left">${e}</div>\n <div class="tfr-size-rec-table-cell-right ${n?"perfect":""}">\n ${t}\n </div>\n </div>`}renderGarmentLocations(e){const t=e.map((e,t)=>this.renderSizeRecTableRow(e,this.randomFit(t),!0)).join(""),n=`<div id="tfr-logged-out-overlay-container">\n <div id="tfr-logged-out-overlay">\n Login to reveal how this item will fit specifically at each area of your body in different sizes\n </div>\n <div>\n ${t}\n </div>\n </div>`;this.tfrSizeRecTable.innerHTML=n}randomFit(e){const t=["Slightly Tight","Perfect Fit","Perfect Fit","Slightly Loose","Perfect Fit"];return t[e%t.length]}toggletSizeRecSelectContainer(){this.isCollapsed?(this.isCollapsed=!1,this.tfrSizeRecTitleToggle.classList.add("tfr-chevron-up"),this.tfrSizeRecTitleToggle.classList.remove("tfr-chevron-down"),this.tfrToggleOpenElements.forEach(e=>e.style.display="block"),this.tfrToggleClosedElements.forEach(e=>e.style.display="none")):(this.isCollapsed=!0,this.tfrSizeRecTitleToggle.classList.remove("tfr-chevron-up"),this.tfrSizeRecTitleToggle.classList.add("tfr-chevron-down"),this.tfrToggleOpenElements.forEach(e=>e.style.display="none"),this.tfrToggleClosedElements.forEach(e=>e.style.display="block"))}render(e){const t=`<div id="tfr-size-recommendations">\n <div id="tfr-size-rec-loading">\n <div class="lds-ellipsis">\n <div></div>\n <div></div>\n <div></div>\n <div></div>\n </div>\n </div>\n <div id="tfr-size-recommendations-container">\n <div id="tfr-size-rec-title-toggle" class="tfr-chevron-up">v</div>\n\n <div class="tfr-logged-out">\n <div class="tfr-flex tfr-gap tfr-mb-2 tfr-mobile-small-text">\n <div>Uncertain&nbsp;of&nbsp;your&nbsp;size?</div>\n \n <div class="tfr-toggle-closed">\n <div class="tfr-flex tfr-items-center">\n <div>Try</div>\n <div class="tfr-powered-by-logo">${Dp}</div>\n <div class="tfr-powered-by-text-bold">The&nbsp;Fitting&nbsp;Room</div>\n </div>\n </div>\n\n <div class="tfr-toggle-open">\n <div id="tfr-login-to-view" class="tfr-flex tfr-items-center">\n ${Mp} Login to view\n </div>\n </div>\n </div>\n </div>\n\n <div class="tfr-logged-in">\n <div id="tfr-size-rec-title">\n Recommended Size:\n <div id="tfr-size-rec-size">\n <div class="tfr-size-rec-login-cta">\n ${Mp} Sign up to view\n </div>\n </div>\n </div>\n </div>\n\n <div class="tfr-toggle-open" style="width: 100%">\n <div id="tfr-size-rec-select-container">\n <div id="tfr-size-how-it-fits">Select size to see how it fits:</div>\n\n <div id="tfr-size-rec-select"></div>\n\n <div id="tfr-size-rec-subtitle">\n How it fits\n <span id="tfr-info-icon"><svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">\n<rect width="13" height="13" fill="url(#pattern0_641_1375)"/>\n<defs>\n<pattern id="pattern0_641_1375" patternContentUnits="objectBoundingBox" width="1" height="1">\n<use xlink:href="#image0_641_1375" transform="scale(0.00793651)"/>\n</pattern>\n<image id="image0_641_1375" width="126" height="126" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAH4AAAB+CAYAAADiI6WIAAAAAXNSR0IArs4c6QAADKtJREFUeF7tnc2S2zYSgLuh9VwzeYJVniDjJ7Asb06p8mhqj6nKDFN7j/wEkp/A4/MeqMllj9L4umWJfgIrT2D5CaK9ZlfATlOkLWn0g8aPCJLSJakxSIL4uhvdjQaIULFfKx42AeCiIcRflYImgDpXAE0E+n8ASP+25YcwUwrmgDAXAHMFOEOE2ULK358AzP8dXU2rNFRY5pdpxcNzAGgJFM8Q1IVScAEA9Dcfv7lCmCLgVCr5AQCmSXQ18/GgY9yzdOD/Fg9bEsWlUqqFkIIu7KcApoiYSCXvk+gqKawjBg8uBfgcNih141GjDYZv7RLS/kSCuiuDEAQLnsz4w1zbBcTrnfOyLSp/189QYH8h5YdQp4PgwC+1O4XdCVi7OSIzkKBehyYAwYAn4AqxpxS0OKNaorZBCUDh4Cn8aiDGFQa+KZtBCEBh4LM5vA+Av5ZIa112tVABKAR8Ox7eAOCbiszhNsKQOoHvry/vbG5icu1RwdfQrOsyObr2Hw18Kx7eiJOW7xOEo2q/d/AFzeWUTJkCpvn2qQScK7n4LM7O/pB//vmfJLqarxJI+3h29k1jsUjz+FKl6d8mKnUhV/P8uvpr1Q5vJUgK/9b6aHXLLRd7BU+mXQBOIF8gcd377H556lQhJkouKGnidNBIMFA0nqFSrSOlimcS1HOfsb838GkiBnDoy4FTAIkQOFpISSlSp6APyWe2AthqAF4/9MNX3oHgR77Sv17At+NhN/PaD40h698VwEwBDgDk22PD3tXRXAgQsPdl6Zf1VvsbZ1m/vsNbprdyDr4dDyk277nsKGk3NER/8vNLWg4N9vf87t2lkLLr2gr4gO8UvGvoZQG+KYk//PbumVzIvksBcA3fGXiX0MsKfJsA/G8hB66mAJfwnYB3CH0uAftJdPk2WHtu0DHKYbjyAVzBtwbvCjppuVp6saUtZ9onE2loi9gDBVRMYvVzAd8KvCPoldTyPVFAVyydX8vaQPVqHF3dmkqQMfgsTqfkjPFvGZ75TVQYd87jhaT9CDixnfuzJI9RrZ8ReEcZuVGWoDhq8sUjT9atl6lsjB9Sy1RpZPqbS1BPTaZHNviswx9t0rCZA/fa9G2rdF07vu89FPvbJGgow0fwWQrEBt+Oh7c2xRMn6I/F1h4+3o6jy1cchWCBzwooyDwZ/U7Qdw+bLXyp8Cb5Rb+gQxu87bx+gn5YVyzhs+Z7bfDtwSg2jUFP0A9Dz1vYwKdcyCTqPNd5mhZ4GxNfJPTmP//VAgHskBPVWfPTP/7+WWcAfbSxgY8Cb3Rq+A6CtzTxo3HUufIxODr3LCt4erd2PKJaBpNQj0z+d4e8/IPgTU18lpxhhxk6QHXblBl8WvUD+NEsyXPYy98LPtP2T7oDvdKO5WgY3F/rkjKDpxfMxp9yJuz0bqb1O9c99oI31faH4sZuCCtsZQefwafcPu1BYP0OOXo7wVto+2AcdSJWLz01rgJ4GpoX8WhiUtSxL5e/E7yJtoe26FIV8KYmf5/WbwVvqu1S4E1SwHagXQajKuBtTP4urd8K3lTbJ1HnO09W2+i2VQJvYfK3Tr2PwJtqu2qIVmhVsFUDb1gDsTWufwTeJEt3yIM0UlcHF1UNvKnWS4H95PpybRl8C/gRxe3bz4LbASNEbaeuVhG8odbPxhvT8Bp4k5uGqu0ODEawtzAJ7zadvDXwRk6dEJ3J9cv7YEepgh0zUVBAvB3ffC3WWAcf88w8xe2hefIV5Lz1lZ7Ho0/MPP58HHW+zW/2BbyJFIUWt9cFOr1n++6+B5JXq7dq7r+Abw/u34BSXc7gHVoI4Nzr1JY3AlnR6x+sq1bM/RfwL+LRR8U4G/bk1LGG3EtjrpNHB0hMos5T6kwK3iRpUwYzn4ZzDWAXh6I8axVZgaMrJS/u7n9VUrF200hQ31KRRgr+RTzsqOXpFdq/Mpj5Ksbxq4BMzL3KorAUPHd+XzUZ2pJSQMOqg88yeawpOg/rlho/GE1YR4puxIQFMNV6ZB3AGyhtWom71Ph4RN6hdnlPbi60Rr/ARnUAbzBNp/E8tuLhhQCkui7tX+4gaF9QUMM6gDeZ5+HsSRO5iZsyZevqAH7po40+cT7mQBYbuSFBmeL3GoEfZh920LKtKLCLXOdgM9mv9aSCGtUHPDPriniL7cGILS3vr8txOFFtwC+PgeckqgbIDeVCLbrYZlTqAp7r2dN0jewcfYC1dbtmkrqAN4jMZmTqWR4hhQLjn34sbCcpx12oEXg6JZyz1W2G7XikOINZlhie3qlG4OkgJdYSLRv8OOoc3GHLESSfbesCPsu+shT4BH6L5BV9MIKJMnAt9wn8CbyenJ1Mvd44HbuVd40/OXfHRnr4eSYLNadwrgKm3qB0jh/HZ8dnTg/LYfEt6uLVG6ywTvkp2xLtnDmB3658acqWu21K9xy14vW9Pgkc7tI6AIxOy7IVmONNltbZhRgkLUUeWsixJHUx9dwV1rQQg7ukBwCP9lpzYByzbV3At7mbXRuiRcWW3JUdKEssXwfwJjE8RWan8uqSz/EGFntZXk3vzd18V5a6uzpoPNexy4tlT1uoSq/xvF3O61uozDZNprsuj+mscZ9VdY038c/WNk2aOAgUEoRebVt18CZH0+W7nCt9MELVwXPj90cHI6SlO2ZHoQRt7qsM3sTMrzrltocfPToxkTsP+2xfZfAmZn51T8TmcWes7dKhZ/GqDd7uaLqNAw6Ze7AAKIv3PImujD5s61Pbq1xebZC0oeFYO8W60keaVlXjuU4dUd/c+vb4EGPuzpqAtb6K4LnVNin0LSeQPgZvcGJiqHvmqwjeRNu3HU237UMFtB2H9mFpn4lDUhXiXF818CbanrGhDxCufYrM5adJtL9r6tupy+9fNfDcdfdsHPQ+TUKNTSULQL0aR1eskxZ9CkGVwJvE7bu0nf6+cwMke6l2STCIL0xWTeMtvu+78xuAO8Gban1Ijl5VNJ5bCZ0L/r5jZ/dueTbUegoggjD5VQDfjoddMPjE6GbCZnNK3QveaCEgIJNfdvCmX5jcN7fnAnDwkIN2fP8GgPcBg+zms2y7VWHFGmUGn9VI0ImjrC+C7fPkV7X+IPisA+y4PntIoTX4ZQbfjkd0jHyHG/Xoft/3IHh6cCse3gjeOWpf+itBvU6iqz73BVy0Lyv4djzsA2DPZAx0PyChBZ46YO7opVm9QuCXEbwN9EMOHcvU541tHI3M2Tg6/LKBt4Gua+K1nbtVKbEx+UXBNzGXRVxjAz0dW+Yn3LVNfT4YFl5+eouizH4RMHWfaQsdAG/H0devSOo8lw2evHwE/Mj8yuFaX07wvw6HLfTMxD/l7nFgg8+8fNpoSTEma+l2QxJHElTE7bCONJehTRYm04nT7JAtfz/uvG7k3G0Opmkuf+M+lOShmr21teIygLPpo8Wiy9pjbU4SN9L4FU+/K8zyyKsvMAdQr0NazrWBeujaLPdOMbqNtQQJ2E+iy9eHnrfr363A003b8X3voarLRYJmkM39ldR+0vIGYsz6zNsOarbQ6bbW4B3Dn6HA/vvryztTSQ7xOldavoyK7DQ9Hx8n4B3Dp9vR3E+OX5D1+rrCRX6QQuy50HKX0J1pfD4QDs1+ekuFkCiVpntLJQCugbuG7hy8B81fFYC3SXQ10tW2Itr5AO4DuhfwvuBnIFMfYCHlh1BCwGU8DlQlc224dr5XRiVgN4ncf/XL2Ry/2XuS/gVgbJPh2zciNA0IxEERQkCwG0Jcg1IdV/P3lnedq4boTH5++cGH9fIGnjpLIQwCTnzBzweENvwjYiKVpEFKXGcDCTS9jkDxTCnVQoALHzBW3memPCe2vILP4J8LEBTrd30O1sa9ZwphhoBTRJgtpPw9nyqoBHxTMDKw508Azv8L0BSUXEHxPYJqKoKsjMqfDF8XbyVIcmi9lqx5B5+/PS3pImDPt/YbjnYIl82lwm7yy3FyGEcDn5t+gdgDBTchjHQofaC9CGqZtzha1vKo4E/a/0jU5lJgNykgU1kI+JP2p5H0UebyXVatMPAr2t+sk/kvwqxvg184+LoIAAGHhuj7isu5/kow4CsqABSSjVRDDEIBno9zcOBXBYCSJiUNAWcScAAgaX3BazzO1fTgwa++0A+/vXu2kPKG0qMB5wHmgDhQAkehaXfQc7yu5C6FgHLk/lOnh/qUp4rLAnv1fYI19YcGPQ8JUTS+RxICpS7S9KplLdue584z0FOFmCi5oBXCIM24ztiVGvy2F2zFw4snjcY3kgSBcuxKNRHgXAKc03/3LJ2mWTMEmFHZMiDOKc8vAWf4l8Z0/NOPn3UGtCxt/g+79EmQczmdsgAAAABJRU5ErkJggg=="/>\n</defs>\n</svg>\n</span>\n </div>\n\n <div id="tfr-size-rec-table"></div>\n\n <div id="tfr-try-on-button" class="tfr-try-on-button">Try On</div>\n </div>\n </div>\n\n <div id="tfr-size-rec-action">\n <div id="tfr-size-rec-action-login">Sign up or login</div>\n <div id="tfr-size-rec-action-logout">Log out</div>\n </div>\n\n <div class="tfr-toggle-open">\n <div class="tfr-powered-by">\n <div>Powered by</div>\n <div class="tfr-powered-by-logo">${Dp}</div>\n <div class="tfr-powered-by-text-bold">The Fitting Room</div>\n </div>\n </div>\n </div>\n </div>\n <div id="tfr-size-recommendation-error"></div>`;e.innerHTML=t}}class jp{constructor(e,t,n,i,r,s,o){this.tfrShop=n,this.onSignInClick=i,this.onSignOutClick=r,this.onFitInfoClick=s,this.onTryOnClick=o,this.perfectFits=[ip.Fit.PERFECT_FIT,ip.Fit.SLIGHTLY_LOOSE,ip.Fit.SLIGHTLY_TIGHT],this.setCssVariables(t),this.sizeRecComponent=new Bp(e,this.onSignInClick,this.onSignOutClick,this.onFitInfoClick,this.onTryOnClick)}get sku(){return this.sizeRecComponent.sku}setSku(e){this.sizeRecComponent.setSku(e)}get styleId(){return this.sizeRecComponent.styleId}setStyleId(e){this.sizeRecComponent.setStyleId(e)}setIsLoggedIn(e){this.sizeRecComponent.setIsLoggedIn(e)}async setGarmentLocations(e=[]){this.sizeRecComponent.setLoading(!0);const t=e.length>0?e:await this.getGarmentLocations(e);console.debug("locations",t),console.debug("filledLocations",e),t&&t.length>0&&(this.sizeRecComponent.show(),this.sizeRecComponent.setGarmentLocations(t)),this.sizeRecComponent.setLoading(!1)}async recommendSize(){this.sizeRecComponent.setLoading(!0);const e=await this.getRecommendedSize();if(!e)return console.error("No sizes found for sku"),void this.sizeRecComponent.setLoading(!1);this.sizeRecComponent.show(),this.sizeRecComponent.setRecommendedSize(e),this.sizeRecComponent.setLoading(!1)}async getGarmentLocations(e){try{return await this.tfrShop.getMeasurementLocationsFromSku(this.sku,e)}catch(t){try{const t=await this.tfrShop.getStyleByBrandStyleId(this.sku);if(!t)return console.error("Style not found for brand style ID:",this.sku),this.sizeRecComponent.hide(),null;return await this.tfrShop.getMeasurementLocationsFromBrandStyleId(t.id,e)}catch(e){return console.error(e),this.sizeRecComponent.hide(),null}}}async getRecommendedSize(){try{const e=await this.tfrShop.getColorwaySizeAssetFromSku(this.sku),t=await this.getRecommendedSizes(String(e.style_id));return this.setStyleId(e.style_id),t}catch(e){try{const e=await this.tfrShop.getStyleByBrandStyleId(this.sku);if(!e)return console.error("Style not found for brand style ID:",this.sku),this.sizeRecComponent.hide(),null;const t=await this.getRecommendedSizes(String(e.id));return this.setStyleId(e.id),t}catch(e){return console.error(e),this.sizeRecComponent.hide(),null}}}async getRecommendedSizes(e){const t=await this.tfrShop.getRecommendedSizes(e);return t?{recommended:t.recommended_size.size_value.name,sizes:t.fits.map(e=>({size:t.available_sizes.find(t=>t.id===e.size_id).size_value.name,size_id:e.size_id,locations:e.measurement_location_fits.map(e=>({fit:"string"==typeof e.fit_label&&e.fit_label?e.fit_label:ip.FitNames[e.fit],isPerfect:this.perfectFits.includes(e.fit),location:this.tfrShop.getMeasurementLocationName(e.measurement_location),sortOrder:this.tfrShop.getMeasurementLocationSortOrder(e.measurement_location)})).sort((e,t)=>e.sortOrder<t.sortOrder?-1:1)}))}:null}setCssVariables(e){const t=document.querySelector(":root");e.brandColor&&t.style.setProperty("--tfr-brand-color",e.brandColor),e.black&&t.style.setProperty("--tfr-black",e.black),e.red&&t.style.setProperty("--tfr-red",e.red),e.white&&t.style.setProperty("--tfr-white",e.white),e.muted&&t.style.setProperty("--tfr-muted",e.muted),e.dark&&t.style.setProperty("--tfr-dark",e.dark),e.grey&&t.style.setProperty("--tfr-grey",e.grey),e.lightGrey&&t.style.setProperty("--tfr-light-grey",e.lightGrey),e.mainBorderColor&&t.style.setProperty("--tfr-main-border-color",e.mainBorderColor),e.mainBorderRadius&&t.style.setProperty("--tfr-main-border-radius",e.mainBorderRadius),e.mainBorderWidth&&t.style.setProperty("--tfr-main-border-width",e.mainBorderWidth),e.mainBgColor&&t.style.setProperty("--tfr-main-bg-color",e.mainBgColor),e.mainWidth&&t.style.setProperty("--tfr-main-width",e.mainWidth),e.mainVPadding&&t.style.setProperty("--tfr-main-v-padding",e.mainVPadding),e.mainHPadding&&t.style.setProperty("--tfr-main-h-padding",e.mainHPadding),e.mainFont&&t.style.setProperty("--tfr-main-font",e.mainFont),e.titleFont&&t.style.setProperty("--tfr-title-font",e.titleFont),e.subtitleFont&&t.style.setProperty("--tfr-subtitle-font",e.subtitleFont),e.rowFont&&t.style.setProperty("--tfr-row-font",e.rowFont),e.ctaFont&&t.style.setProperty("--tfr-cta-font",e.ctaFont),e.sizeSelectorTextColor&&t.style.setProperty("--tfr-size-selector-text-color",e.sizeSelectorTextColor),e.sizeSelectorFontSize&&t.style.setProperty("--tfr-size-selector-font-size",e.sizeSelectorFontSize),e.sizeSelectorFontWeight&&t.style.setProperty("--tfr-size-selector-font-weight",e.sizeSelectorFontWeight),e.sizeSelectorBgColor&&t.style.setProperty("--tfr-size-selector-bg-color",e.sizeSelectorBgColor),e.sizeSelectorBorderColor&&t.style.setProperty("--tfr-size-selector-border-color",e.sizeSelectorBorderColor),e.sizeSelectorBorderWidth&&t.style.setProperty("--tfr-size-selector-border-width",e.sizeSelectorBorderWidth),e.sizeSelectorBgColorHover&&t.style.setProperty("--tfr-size-selector-bg-color-hover",e.sizeSelectorBgColorHover),e.sizeSelectorBgColorActive&&t.style.setProperty("--tfr-size-selector-bg-color-active",e.sizeSelectorBgColorActive),e.sizeSelectorButtonHeight&&t.style.setProperty("--tfr-size-selector-button-height",e.sizeSelectorButtonHeight),e.sizeSelectorButtonActiveHeight&&t.style.setProperty("--tfr-size-selector-button-active-height",e.sizeSelectorButtonActiveHeight),e.sizeSelectorButtonActiveBorderColor&&t.style.setProperty("--tfr-size-selector-button-active-border-color",e.sizeSelectorButtonActiveBorderColor),e.sizeSelectorButtonActiveBorderWidth&&t.style.setProperty("--tfr-size-selector-button-active-border-width",e.sizeSelectorButtonActiveBorderWidth),e.sizeSelectorButtonRadius&&t.style.setProperty("--tfr-size-selector-button-radius",e.sizeSelectorButtonRadius),e.sizeSelectorButtonShadow&&t.style.setProperty("--tfr-size-selector-button-shadow",e.sizeSelectorButtonShadow)}}var Hp;!function(e){e.NOT_CREATED="NOT_CREATED",e.CREATED="CREATED",e.PENDING="PENDING"}(Hp||(Hp={}));class $p{constructor(e,t,n,i,r={},s,o){this.shopId=e,this.hooks=r,this.isLoggedIn=!1,this.unsub=null;const a=o||("undefined"!=typeof process?process.env.NODE_ENV:"dev");console.log("tfr-env",a),this.tfrModal=new Vp(t,this.signIn.bind(this),this.forgotPassword.bind(this),this.submitTel.bind(this)),this.tfrShop=((e,t="dev")=>("dev"!==t&&"development"!==t||console.warn("TfrShop is in development mode"),Ql.getInstance().setEnv(t),new Gf(e,new jf)))(Number(this.shopId),a),this.tfrSizeRec=new jp(n,s,this.tfrShop,this.onSignInClick.bind(this),this.signOut.bind(this),this.onFitInfoClick.bind(this),this.onTryOnClick.bind(this)),i&&(this.vtoComponent=new rp(i))}get shop(){return this.tfrShop}get sku(){return this.tfrSizeRec.sku}async setSku(e){var t,n;this.tfrSizeRec.setSku(e);const i=await this.getStyle(this.sku);i?(this.style=i,i.is_published?console.log(`style ${i.id} is published`):(document.getElementById("tfr-size-recommendations").style.display="none",console.log(`style ${i.id} is not published`)),console.log(`style ${i.id} virtual try on is disabled`),i.is_vto?null===(t=document.getElementById("tfr-try-on-button"))||void 0===t||t.classList.remove("hide"):null===(n=document.getElementById("tfr-try-on-button"))||void 0===n||n.classList.add("hide"),this.isLoggedIn?this.tfrSizeRec.recommendSize():this.setGarmentLocations(i)):document.getElementById("tfr-size-recommendations").style.display="none"}async onInit(){var e,t;return this.isLoggedIn=await this.tfrShop.onInit(),this.tfrSizeRec.setIsLoggedIn(this.isLoggedIn),this.isLoggedIn?((null===(e=this.hooks)||void 0===e?void 0:e.onLogin)&&this.hooks.onLogin(),this.subscribeToProfileChanges()):((null===(t=this.hooks)||void 0===t?void 0:t.onLogout)&&this.hooks.onLogout(),this.unsubscribeFromProfileChanges()),this.isLoggedIn}close(){this.tfrModal.close()}async signOut(){var e;await this.tfrShop.user.logout(),(null===(e=this.hooks)||void 0===e?void 0:e.onLogout)&&this.hooks.onLogout(),this.isLoggedIn=!1,this.tfrSizeRec.setIsLoggedIn(!1),this.setGarmentLocations(this.style),this.unsubscribeFromProfileChanges()}async signIn(e,t,n){var i;if(0==e.length||0==t.length)return n(xp);if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/.test(e))return n(up);if(!(e=>!!e.match(/^.{7,}$/))(t))return n(vp);try{await this.tfrShop.user.login(e,t),(null===(i=this.hooks)||void 0===i?void 0:i.onLogin)&&this.hooks.onLogin(),this.tfrModal.close(),this.isLoggedIn=!0,this.tfrSizeRec.setIsLoggedIn(!0),this.tfrSizeRec.recommendSize(),this.subscribeToProfileChanges()}catch(e){return n(Np)}}setBrandUserId(e){this.tfrShop.user.setBrandUserId(e)}async submitTel(e){try{await this.tfrShop.submitTelephoneNumber(e),this.tfrModal.toSignIn()}catch(e){this.tfrModal.onError(kp)}}async forgotPassword(e){await this.tfrShop.user.sendPasswordResetEmail(e),this.tfrModal.toSignIn()}async passwordReset(e,t){await this.tfrShop.user.confirmPasswordReset(e,t),this.tfrModal.toPasswordReset()}async getMeasurementLocationsFromSku(e){return this.tfrShop.getMeasurementLocationsFromSku(e)}onSignInClick(){this.tfrModal.toScan()}onFitInfoClick(){this.tfrModal.toFitInfo()}async onTryOnClick(e,t,n=!0){if(!this.vtoComponent)return console.error("VtoComponent is not initialized. Please check if the vtoMainDivId is correct.");const i=await this.shop.tryOn(e,t);if(n)try{this.vtoComponent.init(),this.vtoComponent.onNewFramesReady(i)}catch(e){console.error("Error initializing VTO:",e),this.tfrModal.onError(kp)}}onUserProfileChange(e){var t,n,i,r;switch(e.avatar_status){case Hp.NOT_CREATED:(null===(t=this.hooks)||void 0===t?void 0:t.onError)&&this.hooks.onError(cp),this.tfrModal.onNotCreated();break;case Hp.PENDING:(null===(n=this.hooks)||void 0===n?void 0:n.onLoading)&&this.hooks.onLoading();break;case Hp.CREATED:(null===(i=this.hooks)||void 0===i?void 0:i.onLoadingComplete)&&this.hooks.onLoadingComplete();break;default:(null===(r=this.hooks)||void 0===r?void 0:r.onError)&&this.hooks.onError(kp),this.tfrModal.onError(kp)}}subscribeToProfileChanges(){this.unsub||(this.unsub=this.tfrShop.user.watchUserProfileForChanges(e=>this.onUserProfileChange(e)))}unsubscribeFromProfileChanges(){this.unsub&&(this.unsub(),this.unsub=null)}async setGarmentLocations(e){var t,n;const i=(null===(n=null===(t=null==e?void 0:e.sizes)||void 0===t?void 0:t[0])||void 0===n?void 0:n.garment_measurements.map(e=>e.measurement_location))||[];this.tfrSizeRec.setGarmentLocations(i)}async getStyle(e){try{const t=await this.tfrShop.getColorwaySizeAssetFromSku(e);return await this.tfrShop.getStyle(t.style_id)}catch(t){try{return await this.tfrShop.getStyleByBrandStyleId(e)}catch(e){return null}}}}const qp=async({shopId:e,modalDivId:t,sizeRecMainDivId:n,vtoMainDivId:i,hooks:r={},cssVariables:s={},env:o="dev"})=>{const a=new $p(e,t,n,i,r,s,o);return await a.onInit(),a};export{n as InitImageSlider,qp as initFittingRoom};
3399
- //# sourceMappingURL=index.min.js.map