@entropic-bond/firebase 1.13.26 → 1.13.28
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.
|
@@ -1,53 +1,44 @@
|
|
|
1
|
-
(function(Ue,or){typeof exports=="object"&&typeof module<"u"?or(exports):typeof define=="function"&&define.amd?define(["exports"],or):(Ue=typeof globalThis<"u"?globalThis:Ue||self,or(Ue["entropic-bond-firebase"]={}))})(this,function(Ue){"use strict";const or=()=>{};const dc=function(n){const e=[];let t=0;for(let r=0;r<n.length;r++){let s=n.charCodeAt(r);s<128?e[t++]=s:s<2048?(e[t++]=s>>6|192,e[t++]=s&63|128):(s&64512)===55296&&r+1<n.length&&(n.charCodeAt(r+1)&64512)===56320?(s=65536+((s&1023)<<10)+(n.charCodeAt(++r)&1023),e[t++]=s>>18|240,e[t++]=s>>12&63|128,e[t++]=s>>6&63|128,e[t++]=s&63|128):(e[t++]=s>>12|224,e[t++]=s>>6&63|128,e[t++]=s&63|128)}return e},fp=function(n){const e=[];let t=0,r=0;for(;t<n.length;){const s=n[t++];if(s<128)e[r++]=String.fromCharCode(s);else if(s>191&&s<224){const i=n[t++];e[r++]=String.fromCharCode((s&31)<<6|i&63)}else if(s>239&&s<365){const i=n[t++],a=n[t++],c=n[t++],l=((s&7)<<18|(i&63)<<12|(a&63)<<6|c&63)-65536;e[r++]=String.fromCharCode(55296+(l>>10)),e[r++]=String.fromCharCode(56320+(l&1023))}else{const i=n[t++],a=n[t++];e[r++]=String.fromCharCode((s&15)<<12|(i&63)<<6|a&63)}}return e.join("")},fc={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(n,e){if(!Array.isArray(n))throw Error("encodeByteArray takes an array as a parameter");this.init_();const t=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let s=0;s<n.length;s+=3){const i=n[s],a=s+1<n.length,c=a?n[s+1]:0,l=s+2<n.length,d=l?n[s+2]:0,f=i>>2,m=(i&3)<<4|c>>4;let _=(c&15)<<2|d>>6,R=d&63;l||(R=64,a||(_=64)),r.push(t[f],t[m],t[_],t[R])}return r.join("")},encodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(n):this.encodeByteArray(dc(n),e)},decodeString(n,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(n):fp(this.decodeStringToByteArray(n,e))},decodeStringToByteArray(n,e){this.init_();const t=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let s=0;s<n.length;){const i=t[n.charAt(s++)],c=s<n.length?t[n.charAt(s)]:0;++s;const d=s<n.length?t[n.charAt(s)]:64;++s;const m=s<n.length?t[n.charAt(s)]:64;if(++s,i==null||c==null||d==null||m==null)throw new pp;const _=i<<2|c>>4;if(r.push(_),d!==64){const R=c<<4&240|d>>2;if(r.push(R),m!==64){const S=d<<6&192|m;r.push(S)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let n=0;n<this.ENCODED_VALS.length;n++)this.byteToCharMap_[n]=this.ENCODED_VALS.charAt(n),this.charToByteMap_[this.byteToCharMap_[n]]=n,this.byteToCharMapWebSafe_[n]=this.ENCODED_VALS_WEBSAFE.charAt(n),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[n]]=n,n>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(n)]=n,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(n)]=n)}}};class pp extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const mp=function(n){const e=dc(n);return fc.encodeByteArray(e,!0)},cs=function(n){return mp(n).replace(/\./g,"")},pc=function(n){try{return fc.decodeString(n,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function gp(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}const _p=()=>gp().__FIREBASE_DEFAULTS__,yp=()=>{if(typeof process>"u"||typeof process.env>"u")return;const n=process.env.__FIREBASE_DEFAULTS__;if(n)return JSON.parse(n)},Ep=()=>{if(typeof document>"u")return;let n;try{n=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=n&&pc(n[1]);return e&&JSON.parse(e)},us=()=>{try{return or()||_p()||yp()||Ep()}catch(n){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${n}`);return}},mc=n=>us()?.emulatorHosts?.[n],ji=n=>{const e=mc(n);if(!e)return;const t=e.lastIndexOf(":");if(t<=0||t+1===e.length)throw new Error(`Invalid host ${e} with no separate hostname and port!`);const r=parseInt(e.substring(t+1),10);return e[0]==="["?[e.substring(1,t-1),r]:[e.substring(0,t),r]},gc=()=>us()?.config,_c=n=>us()?.[`_${n}`];class Tp{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,r))}}}function tt(n){try{return(n.startsWith("http://")||n.startsWith("https://")?new URL(n).hostname:n).endsWith(".cloudworkstations.dev")}catch{return!1}}async function ls(n){return(await fetch(n,{credentials:"include"})).ok}function yc(n,e){if(n.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const t={alg:"none",type:"JWT"},r=e||"demo-project",s=n.iat||0,i=n.sub||n.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const a={iss:`https://securetoken.google.com/${r}`,aud:r,iat:s,exp:s+3600,auth_time:s,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}},...n};return[cs(JSON.stringify(t)),cs(JSON.stringify(a)),""].join(".")}const ar={};function wp(){const n={prod:[],emulator:[]};for(const e of Object.keys(ar))ar[e]?n.emulator.push(e):n.prod.push(e);return n}function Ip(n){let e=document.getElementById(n),t=!1;return e||(e=document.createElement("div"),e.setAttribute("id",n),t=!0),{created:t,element:e}}let Ec=!1;function hs(n,e){if(typeof window>"u"||typeof document>"u"||!tt(window.location.host)||ar[n]===e||ar[n]||Ec)return;ar[n]=e;function t(_){return`__firebase__banner__${_}`}const r="__firebase__banner",i=wp().prod.length>0;function a(){const _=document.getElementById(r);_&&_.remove()}function c(_){_.style.display="flex",_.style.background="#7faaf0",_.style.position="fixed",_.style.bottom="5px",_.style.left="5px",_.style.padding=".5em",_.style.borderRadius="5px",_.style.alignItems="center"}function l(_,R){_.setAttribute("width","24"),_.setAttribute("id",R),_.setAttribute("height","24"),_.setAttribute("viewBox","0 0 24 24"),_.setAttribute("fill","none"),_.style.marginLeft="-6px"}function d(){const _=document.createElement("span");return _.style.cursor="pointer",_.style.marginLeft="16px",_.style.fontSize="24px",_.innerHTML=" ×",_.onclick=()=>{Ec=!0,a()},_}function f(_,R){_.setAttribute("id",R),_.innerText="Learn more",_.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",_.setAttribute("target","__blank"),_.style.paddingLeft="5px",_.style.textDecoration="underline"}function m(){const _=Ip(r),R=t("text"),S=document.getElementById(R)||document.createElement("span"),N=t("learnmore"),k=document.getElementById(N)||document.createElement("a"),U=t("preprendIcon"),$=document.getElementById(U)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(_.created){const j=_.element;c(j),f(k,N);const Q=d();l($,U),j.append($,S,k,Q),document.body.appendChild(j)}i?(S.innerText="Preview backend disconnected.",$.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
<
|
|
6
|
-
<rect width="24" height="24" fill="white"/>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<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"/>
|
|
10
|
-
</g>
|
|
11
|
-
<
|
|
12
|
-
<
|
|
13
|
-
<rect width="24" height="24" fill="white"/>
|
|
14
|
-
|
|
15
|
-
</defs>`,S.innerText="Preview backend running in this workspace."),S.setAttribute("id",R)}document.readyState==="loading"?window.addEventListener("DOMContentLoaded",m):m()}function ve(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function vp(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(ve())}function Ap(){const n=us()?.forceEnvironment;if(n==="node")return!0;if(n==="browser")return!1;try{return Object.prototype.toString.call(global.process)==="[object process]"}catch{return!1}}function Rp(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function bp(){const n=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof n=="object"&&n.id!==void 0}function Pp(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function Cp(){const n=ve();return n.indexOf("MSIE ")>=0||n.indexOf("Trident/")>=0}function Sp(){return!Ap()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function kp(){try{return typeof indexedDB=="object"}catch{return!1}}function Np(){return new Promise((n,e)=>{try{let t=!0;const r="validate-browser-context-for-indexeddb-analytics-module",s=self.indexedDB.open(r);s.onsuccess=()=>{s.result.close(),t||self.indexedDB.deleteDatabase(r),n(!0)},s.onupgradeneeded=()=>{t=!1},s.onerror=()=>{e(s.error?.message||"")}}catch(t){e(t)}})}const Dp="FirebaseError";class He extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name=Dp,Object.setPrototypeOf(this,He.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,cr.prototype.create)}}class cr{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){const r=t[0]||{},s=`${this.service}/${e}`,i=this.errors[e],a=i?Op(i,r):"Error",c=`${this.serviceName}: ${a} (${s}).`;return new He(s,c,r)}}function Op(n,e){return n.replace(Vp,(t,r)=>{const s=e[r];return s!=null?String(s):`<${r}?>`})}const Vp=/\{\$([^}]+)}/g;function Lp(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}function en(n,e){if(n===e)return!0;const t=Object.keys(n),r=Object.keys(e);for(const s of t){if(!r.includes(s))return!1;const i=n[s],a=e[s];if(Tc(i)&&Tc(a)){if(!en(i,a))return!1}else if(i!==a)return!1}for(const s of r)if(!t.includes(s))return!1;return!0}function Tc(n){return n!==null&&typeof n=="object"}function ur(n){const e=[];for(const[t,r]of Object.entries(n))Array.isArray(r)?r.forEach(s=>{e.push(encodeURIComponent(t)+"="+encodeURIComponent(s))}):e.push(encodeURIComponent(t)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function lr(n){const e={};return n.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[s,i]=r.split("=");e[decodeURIComponent(s)]=decodeURIComponent(i)}}),e}function hr(n){const e=n.indexOf("?");if(!e)return"";const t=n.indexOf("#",e);return n.substring(e,t>0?t:void 0)}function Mp(n,e){const t=new xp(n,e);return t.subscribe.bind(t)}class xp{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let s;if(e===void 0&&t===void 0&&r===void 0)throw new Error("Missing Observer.");Up(e,["next","error","complete"])?s=e:s={next:e,error:t,complete:r},s.next===void 0&&(s.next=$i),s.error===void 0&&(s.error=$i),s.complete===void 0&&(s.complete=$i);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?s.error(this.finalError):s.complete()}catch{}}),this.observers.push(s),i}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function Up(n,e){if(typeof n!="object"||n===null)return!1;for(const t of e)if(t in n&&typeof n[t]=="function")return!0;return!1}function $i(){}function Y(n){return n&&n._delegate?n._delegate:n}class _t{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}const tn="[DEFAULT]";class Fp{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const r=new Tp;if(this.instancesDeferred.set(t,r),this.isInitialized(t)||this.shouldAutoInitialize())try{const s=this.getOrInitializeService({instanceIdentifier:t});s&&r.resolve(s)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){const t=this.normalizeInstanceIdentifier(e?.identifier),r=e?.optional??!1;if(this.isInitialized(t)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:t})}catch(s){if(r)return null;throw s}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(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(qp(e))try{this.getOrInitializeService({instanceIdentifier:tn})}catch{}for(const[t,r]of this.instancesDeferred.entries()){const s=this.normalizeInstanceIdentifier(t);try{const i=this.getOrInitializeService({instanceIdentifier:s});r.resolve(i)}catch{}}}}clearInstance(e=tn){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(t=>"INTERNAL"in t).map(t=>t.INTERNAL.delete()),...e.filter(t=>"_delete"in t).map(t=>t._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=tn){return this.instances.has(e)}getOptions(e=tn){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const s=this.getOrInitializeService({instanceIdentifier:r,options:t});for(const[i,a]of this.instancesDeferred.entries()){const c=this.normalizeInstanceIdentifier(i);r===c&&a.resolve(s)}return s}onInit(e,t){const r=this.normalizeInstanceIdentifier(t),s=this.onInitCallbacks.get(r)??new Set;s.add(e),this.onInitCallbacks.set(r,s);const i=this.instances.get(r);return i&&e(i,r),()=>{s.delete(e)}}invokeOnInitCallbacks(e,t){const r=this.onInitCallbacks.get(t);if(r)for(const s of r)try{s(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:Bp(e),options:t}),this.instances.set(e,r),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=tn){return this.component?this.component.multipleInstances?e:tn:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function Bp(n){return n===tn?void 0:n}function qp(n){return n.instantiationMode==="EAGER"}class jp{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 Fp(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}var W;(function(n){n[n.DEBUG=0]="DEBUG",n[n.VERBOSE=1]="VERBOSE",n[n.INFO=2]="INFO",n[n.WARN=3]="WARN",n[n.ERROR=4]="ERROR",n[n.SILENT=5]="SILENT"})(W||(W={}));const $p={debug:W.DEBUG,verbose:W.VERBOSE,info:W.INFO,warn:W.WARN,error:W.ERROR,silent:W.SILENT},zp=W.INFO,Wp={[W.DEBUG]:"log",[W.VERBOSE]:"log",[W.INFO]:"info",[W.WARN]:"warn",[W.ERROR]:"error"},Hp=(n,e,...t)=>{if(e<n.logLevel)return;const r=new Date().toISOString(),s=Wp[e];if(s)console[s](`[${r}] ${n.name}:`,...t);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class zi{constructor(e){this.name=e,this._logLevel=zp,this._logHandler=Hp,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in W))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?$p[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,W.DEBUG,...e),this._logHandler(this,W.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,W.VERBOSE,...e),this._logHandler(this,W.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,W.INFO,...e),this._logHandler(this,W.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,W.WARN,...e),this._logHandler(this,W.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,W.ERROR,...e),this._logHandler(this,W.ERROR,...e)}}const Gp=(n,e)=>e.some(t=>n instanceof t);let wc,Ic;function Kp(){return wc||(wc=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Qp(){return Ic||(Ic=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const vc=new WeakMap,Wi=new WeakMap,Ac=new WeakMap,Hi=new WeakMap,Gi=new WeakMap;function Yp(n){const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("success",i),n.removeEventListener("error",a)},i=()=>{t(Ct(n.result)),s()},a=()=>{r(n.error),s()};n.addEventListener("success",i),n.addEventListener("error",a)});return e.then(t=>{t instanceof IDBCursor&&vc.set(t,n)}).catch(()=>{}),Gi.set(e,n),e}function Jp(n){if(Wi.has(n))return;const e=new Promise((t,r)=>{const s=()=>{n.removeEventListener("complete",i),n.removeEventListener("error",a),n.removeEventListener("abort",a)},i=()=>{t(),s()},a=()=>{r(n.error||new DOMException("AbortError","AbortError")),s()};n.addEventListener("complete",i),n.addEventListener("error",a),n.addEventListener("abort",a)});Wi.set(n,e)}let Ki={get(n,e,t){if(n instanceof IDBTransaction){if(e==="done")return Wi.get(n);if(e==="objectStoreNames")return n.objectStoreNames||Ac.get(n);if(e==="store")return t.objectStoreNames[1]?void 0:t.objectStore(t.objectStoreNames[0])}return Ct(n[e])},set(n,e,t){return n[e]=t,!0},has(n,e){return n instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in n}};function Xp(n){Ki=n(Ki)}function Zp(n){return n===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...t){const r=n.call(Qi(this),e,...t);return Ac.set(r,e.sort?e.sort():[e]),Ct(r)}:Qp().includes(n)?function(...e){return n.apply(Qi(this),e),Ct(vc.get(this))}:function(...e){return Ct(n.apply(Qi(this),e))}}function em(n){return typeof n=="function"?Zp(n):(n instanceof IDBTransaction&&Jp(n),Gp(n,Kp())?new Proxy(n,Ki):n)}function Ct(n){if(n instanceof IDBRequest)return Yp(n);if(Hi.has(n))return Hi.get(n);const e=em(n);return e!==n&&(Hi.set(n,e),Gi.set(e,n)),e}const Qi=n=>Gi.get(n);function tm(n,e,{blocked:t,upgrade:r,blocking:s,terminated:i}={}){const a=indexedDB.open(n,e),c=Ct(a);return r&&a.addEventListener("upgradeneeded",l=>{r(Ct(a.result),l.oldVersion,l.newVersion,Ct(a.transaction),l)}),t&&a.addEventListener("blocked",l=>t(l.oldVersion,l.newVersion,l)),c.then(l=>{i&&l.addEventListener("close",()=>i()),s&&l.addEventListener("versionchange",d=>s(d.oldVersion,d.newVersion,d))}).catch(()=>{}),c}const nm=["get","getKey","getAll","getAllKeys","count"],rm=["put","add","delete","clear"],Yi=new Map;function Rc(n,e){if(!(n instanceof IDBDatabase&&!(e in n)&&typeof e=="string"))return;if(Yi.get(e))return Yi.get(e);const t=e.replace(/FromIndex$/,""),r=e!==t,s=rm.includes(t);if(!(t in(r?IDBIndex:IDBObjectStore).prototype)||!(s||nm.includes(t)))return;const i=async function(a,...c){const l=this.transaction(a,s?"readwrite":"readonly");let d=l.store;return r&&(d=d.index(c.shift())),(await Promise.all([d[t](...c),s&&l.done]))[0]};return Yi.set(e,i),i}Xp(n=>({...n,get:(e,t,r)=>Rc(e,t)||n.get(e,t,r),has:(e,t)=>!!Rc(e,t)||n.has(e,t)}));class sm{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(t=>{if(im(t)){const r=t.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(t=>t).join(" ")}}function im(n){return n.getComponent()?.type==="VERSION"}const Ji="@firebase/app",bc="0.14.9";const yt=new zi("@firebase/app"),om="@firebase/app-compat",am="@firebase/analytics-compat",cm="@firebase/analytics",um="@firebase/app-check-compat",lm="@firebase/app-check",hm="@firebase/auth",dm="@firebase/auth-compat",fm="@firebase/database",pm="@firebase/data-connect",mm="@firebase/database-compat",gm="@firebase/functions",_m="@firebase/functions-compat",ym="@firebase/installations",Em="@firebase/installations-compat",Tm="@firebase/messaging",wm="@firebase/messaging-compat",Im="@firebase/performance",vm="@firebase/performance-compat",Am="@firebase/remote-config",Rm="@firebase/remote-config-compat",bm="@firebase/storage",Pm="@firebase/storage-compat",Cm="@firebase/firestore",Sm="@firebase/ai",km="@firebase/firestore-compat",Nm="firebase",Dm="12.10.0";const Xi="[DEFAULT]",Om={[Ji]:"fire-core",[om]:"fire-core-compat",[cm]:"fire-analytics",[am]:"fire-analytics-compat",[lm]:"fire-app-check",[um]:"fire-app-check-compat",[hm]:"fire-auth",[dm]:"fire-auth-compat",[fm]:"fire-rtdb",[pm]:"fire-data-connect",[mm]:"fire-rtdb-compat",[gm]:"fire-fn",[_m]:"fire-fn-compat",[ym]:"fire-iid",[Em]:"fire-iid-compat",[Tm]:"fire-fcm",[wm]:"fire-fcm-compat",[Im]:"fire-perf",[vm]:"fire-perf-compat",[Am]:"fire-rc",[Rm]:"fire-rc-compat",[bm]:"fire-gcs",[Pm]:"fire-gcs-compat",[Cm]:"fire-fst",[km]:"fire-fst-compat",[Sm]:"fire-vertex","fire-js":"fire-js",[Nm]:"fire-js-all"};const ds=new Map,Vm=new Map,Zi=new Map;function Pc(n,e){try{n.container.addComponent(e)}catch(t){yt.debug(`Component ${e.name} failed to register with FirebaseApp ${n.name}`,t)}}function St(n){const e=n.name;if(Zi.has(e))return yt.debug(`There were multiple attempts to register component ${e}.`),!1;Zi.set(e,n);for(const t of ds.values())Pc(t,n);for(const t of Vm.values())Pc(t,n);return!0}function dr(n,e){const t=n.container.getProvider("heartbeat").getImmediate({optional:!0});return t&&t.triggerHeartbeat(),n.container.getProvider(e)}function Ae(n){return n==null?!1:n.settings!==void 0}const Lm={"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."},kt=new cr("app","Firebase",Lm);class Mm{constructor(e,t,r){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new _t("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 kt.create("app-deleted",{appName:this._name})}}const nn=Dm;function Cc(n,e={}){let t=n;typeof e!="object"&&(e={name:e});const r={name:Xi,automaticDataCollectionEnabled:!0,...e},s=r.name;if(typeof s!="string"||!s)throw kt.create("bad-app-name",{appName:String(s)});if(t||(t=gc()),!t)throw kt.create("no-options");const i=ds.get(s);if(i){if(en(t,i.options)&&en(r,i.config))return i;throw kt.create("duplicate-app",{appName:s})}const a=new jp(s);for(const l of Zi.values())a.addComponent(l);const c=new Mm(t,r,a);return ds.set(s,c),c}function fs(n=Xi){const e=ds.get(n);if(!e&&n===Xi&&gc())return Cc();if(!e)throw kt.create("no-app",{appName:n});return e}function je(n,e,t){let r=Om[n]??n;t&&(r+=`-${t}`);const s=r.match(/\s|\//),i=e.match(/\s|\//);if(s||i){const a=[`Unable to register library "${r}" with version "${e}":`];s&&a.push(`library name "${r}" contains illegal characters (whitespace or "/")`),s&&i&&a.push("and"),i&&a.push(`version name "${e}" contains illegal characters (whitespace or "/")`),yt.warn(a.join(" "));return}St(new _t(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}const xm="firebase-heartbeat-database",Um=1,fr="firebase-heartbeat-store";let eo=null;function Sc(){return eo||(eo=tm(xm,Um,{upgrade:(n,e)=>{switch(e){case 0:try{n.createObjectStore(fr)}catch(t){console.warn(t)}}}}).catch(n=>{throw kt.create("idb-open",{originalErrorMessage:n.message})})),eo}async function Fm(n){try{const t=(await Sc()).transaction(fr),r=await t.objectStore(fr).get(Nc(n));return await t.done,r}catch(e){if(e instanceof He)yt.warn(e.message);else{const t=kt.create("idb-get",{originalErrorMessage:e?.message});yt.warn(t.message)}}}async function kc(n,e){try{const r=(await Sc()).transaction(fr,"readwrite");await r.objectStore(fr).put(e,Nc(n)),await r.done}catch(t){if(t instanceof He)yt.warn(t.message);else{const r=kt.create("idb-set",{originalErrorMessage:t?.message});yt.warn(r.message)}}}function Nc(n){return`${n.name}!${n.options.appId}`}const Bm=1024,qm=30;class jm{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new zm(t),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){try{const t=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=Dc();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(s=>s.date===r))return;if(this._heartbeatsCache.heartbeats.push({date:r,agent:t}),this._heartbeatsCache.heartbeats.length>qm){const s=Wm(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(s,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){yt.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";const e=Dc(),{heartbeatsToSend:t,unsentEntries:r}=$m(this._heartbeatsCache.heartbeats),s=cs(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),s}catch(e){return yt.warn(e),""}}}function Dc(){return new Date().toISOString().substring(0,10)}function $m(n,e=Bm){const t=[];let r=n.slice();for(const s of n){const i=t.find(a=>a.agent===s.agent);if(i){if(i.dates.push(s.date),Oc(t)>e){i.dates.pop();break}}else if(t.push({agent:s.agent,dates:[s.date]}),Oc(t)>e){t.pop();break}r=r.slice(1)}return{heartbeatsToSend:t,unsentEntries:r}}class zm{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return kp()?Np().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const t=await Fm(this.app);return t?.heartbeats?t:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return kc(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return kc(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function Oc(n){return cs(JSON.stringify({version:2,heartbeats:n})).length}function Wm(n){if(n.length===0)return-1;let e=0,t=n[0].date;for(let r=1;r<n.length;r++)n[r].date<t&&(t=n[r].date,e=r);return e}function Hm(n){St(new _t("platform-logger",e=>new sm(e),"PRIVATE")),St(new _t("heartbeat",e=>new jm(e),"PRIVATE")),je(Ji,bc,n),je(Ji,bc,"esm2020"),je("fire-js","")}Hm("");var Vc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var Nt,Lc;(function(){var n;function e(w,g){function E(){}E.prototype=g.prototype,w.F=g.prototype,w.prototype=new E,w.prototype.constructor=w,w.D=function(I,T,A){for(var y=Array(arguments.length-2),Me=2;Me<arguments.length;Me++)y[Me-2]=arguments[Me];return g.prototype[T].apply(I,y)}}function t(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}e(r,t),r.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function s(w,g,E){E||(E=0);const I=Array(16);if(typeof g=="string")for(var T=0;T<16;++T)I[T]=g.charCodeAt(E++)|g.charCodeAt(E++)<<8|g.charCodeAt(E++)<<16|g.charCodeAt(E++)<<24;else for(T=0;T<16;++T)I[T]=g[E++]|g[E++]<<8|g[E++]<<16|g[E++]<<24;g=w.g[0],E=w.g[1],T=w.g[2];let A=w.g[3],y;y=g+(A^E&(T^A))+I[0]+3614090360&4294967295,g=E+(y<<7&4294967295|y>>>25),y=A+(T^g&(E^T))+I[1]+3905402710&4294967295,A=g+(y<<12&4294967295|y>>>20),y=T+(E^A&(g^E))+I[2]+606105819&4294967295,T=A+(y<<17&4294967295|y>>>15),y=E+(g^T&(A^g))+I[3]+3250441966&4294967295,E=T+(y<<22&4294967295|y>>>10),y=g+(A^E&(T^A))+I[4]+4118548399&4294967295,g=E+(y<<7&4294967295|y>>>25),y=A+(T^g&(E^T))+I[5]+1200080426&4294967295,A=g+(y<<12&4294967295|y>>>20),y=T+(E^A&(g^E))+I[6]+2821735955&4294967295,T=A+(y<<17&4294967295|y>>>15),y=E+(g^T&(A^g))+I[7]+4249261313&4294967295,E=T+(y<<22&4294967295|y>>>10),y=g+(A^E&(T^A))+I[8]+1770035416&4294967295,g=E+(y<<7&4294967295|y>>>25),y=A+(T^g&(E^T))+I[9]+2336552879&4294967295,A=g+(y<<12&4294967295|y>>>20),y=T+(E^A&(g^E))+I[10]+4294925233&4294967295,T=A+(y<<17&4294967295|y>>>15),y=E+(g^T&(A^g))+I[11]+2304563134&4294967295,E=T+(y<<22&4294967295|y>>>10),y=g+(A^E&(T^A))+I[12]+1804603682&4294967295,g=E+(y<<7&4294967295|y>>>25),y=A+(T^g&(E^T))+I[13]+4254626195&4294967295,A=g+(y<<12&4294967295|y>>>20),y=T+(E^A&(g^E))+I[14]+2792965006&4294967295,T=A+(y<<17&4294967295|y>>>15),y=E+(g^T&(A^g))+I[15]+1236535329&4294967295,E=T+(y<<22&4294967295|y>>>10),y=g+(T^A&(E^T))+I[1]+4129170786&4294967295,g=E+(y<<5&4294967295|y>>>27),y=A+(E^T&(g^E))+I[6]+3225465664&4294967295,A=g+(y<<9&4294967295|y>>>23),y=T+(g^E&(A^g))+I[11]+643717713&4294967295,T=A+(y<<14&4294967295|y>>>18),y=E+(A^g&(T^A))+I[0]+3921069994&4294967295,E=T+(y<<20&4294967295|y>>>12),y=g+(T^A&(E^T))+I[5]+3593408605&4294967295,g=E+(y<<5&4294967295|y>>>27),y=A+(E^T&(g^E))+I[10]+38016083&4294967295,A=g+(y<<9&4294967295|y>>>23),y=T+(g^E&(A^g))+I[15]+3634488961&4294967295,T=A+(y<<14&4294967295|y>>>18),y=E+(A^g&(T^A))+I[4]+3889429448&4294967295,E=T+(y<<20&4294967295|y>>>12),y=g+(T^A&(E^T))+I[9]+568446438&4294967295,g=E+(y<<5&4294967295|y>>>27),y=A+(E^T&(g^E))+I[14]+3275163606&4294967295,A=g+(y<<9&4294967295|y>>>23),y=T+(g^E&(A^g))+I[3]+4107603335&4294967295,T=A+(y<<14&4294967295|y>>>18),y=E+(A^g&(T^A))+I[8]+1163531501&4294967295,E=T+(y<<20&4294967295|y>>>12),y=g+(T^A&(E^T))+I[13]+2850285829&4294967295,g=E+(y<<5&4294967295|y>>>27),y=A+(E^T&(g^E))+I[2]+4243563512&4294967295,A=g+(y<<9&4294967295|y>>>23),y=T+(g^E&(A^g))+I[7]+1735328473&4294967295,T=A+(y<<14&4294967295|y>>>18),y=E+(A^g&(T^A))+I[12]+2368359562&4294967295,E=T+(y<<20&4294967295|y>>>12),y=g+(E^T^A)+I[5]+4294588738&4294967295,g=E+(y<<4&4294967295|y>>>28),y=A+(g^E^T)+I[8]+2272392833&4294967295,A=g+(y<<11&4294967295|y>>>21),y=T+(A^g^E)+I[11]+1839030562&4294967295,T=A+(y<<16&4294967295|y>>>16),y=E+(T^A^g)+I[14]+4259657740&4294967295,E=T+(y<<23&4294967295|y>>>9),y=g+(E^T^A)+I[1]+2763975236&4294967295,g=E+(y<<4&4294967295|y>>>28),y=A+(g^E^T)+I[4]+1272893353&4294967295,A=g+(y<<11&4294967295|y>>>21),y=T+(A^g^E)+I[7]+4139469664&4294967295,T=A+(y<<16&4294967295|y>>>16),y=E+(T^A^g)+I[10]+3200236656&4294967295,E=T+(y<<23&4294967295|y>>>9),y=g+(E^T^A)+I[13]+681279174&4294967295,g=E+(y<<4&4294967295|y>>>28),y=A+(g^E^T)+I[0]+3936430074&4294967295,A=g+(y<<11&4294967295|y>>>21),y=T+(A^g^E)+I[3]+3572445317&4294967295,T=A+(y<<16&4294967295|y>>>16),y=E+(T^A^g)+I[6]+76029189&4294967295,E=T+(y<<23&4294967295|y>>>9),y=g+(E^T^A)+I[9]+3654602809&4294967295,g=E+(y<<4&4294967295|y>>>28),y=A+(g^E^T)+I[12]+3873151461&4294967295,A=g+(y<<11&4294967295|y>>>21),y=T+(A^g^E)+I[15]+530742520&4294967295,T=A+(y<<16&4294967295|y>>>16),y=E+(T^A^g)+I[2]+3299628645&4294967295,E=T+(y<<23&4294967295|y>>>9),y=g+(T^(E|~A))+I[0]+4096336452&4294967295,g=E+(y<<6&4294967295|y>>>26),y=A+(E^(g|~T))+I[7]+1126891415&4294967295,A=g+(y<<10&4294967295|y>>>22),y=T+(g^(A|~E))+I[14]+2878612391&4294967295,T=A+(y<<15&4294967295|y>>>17),y=E+(A^(T|~g))+I[5]+4237533241&4294967295,E=T+(y<<21&4294967295|y>>>11),y=g+(T^(E|~A))+I[12]+1700485571&4294967295,g=E+(y<<6&4294967295|y>>>26),y=A+(E^(g|~T))+I[3]+2399980690&4294967295,A=g+(y<<10&4294967295|y>>>22),y=T+(g^(A|~E))+I[10]+4293915773&4294967295,T=A+(y<<15&4294967295|y>>>17),y=E+(A^(T|~g))+I[1]+2240044497&4294967295,E=T+(y<<21&4294967295|y>>>11),y=g+(T^(E|~A))+I[8]+1873313359&4294967295,g=E+(y<<6&4294967295|y>>>26),y=A+(E^(g|~T))+I[15]+4264355552&4294967295,A=g+(y<<10&4294967295|y>>>22),y=T+(g^(A|~E))+I[6]+2734768916&4294967295,T=A+(y<<15&4294967295|y>>>17),y=E+(A^(T|~g))+I[13]+1309151649&4294967295,E=T+(y<<21&4294967295|y>>>11),y=g+(T^(E|~A))+I[4]+4149444226&4294967295,g=E+(y<<6&4294967295|y>>>26),y=A+(E^(g|~T))+I[11]+3174756917&4294967295,A=g+(y<<10&4294967295|y>>>22),y=T+(g^(A|~E))+I[2]+718787259&4294967295,T=A+(y<<15&4294967295|y>>>17),y=E+(A^(T|~g))+I[9]+3951481745&4294967295,w.g[0]=w.g[0]+g&4294967295,w.g[1]=w.g[1]+(T+(y<<21&4294967295|y>>>11))&4294967295,w.g[2]=w.g[2]+T&4294967295,w.g[3]=w.g[3]+A&4294967295}r.prototype.v=function(w,g){g===void 0&&(g=w.length);const E=g-this.blockSize,I=this.C;let T=this.h,A=0;for(;A<g;){if(T==0)for(;A<=E;)s(this,w,A),A+=this.blockSize;if(typeof w=="string"){for(;A<g;)if(I[T++]=w.charCodeAt(A++),T==this.blockSize){s(this,I),T=0;break}}else for(;A<g;)if(I[T++]=w[A++],T==this.blockSize){s(this,I),T=0;break}}this.h=T,this.o+=g},r.prototype.A=function(){var w=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);w[0]=128;for(var g=1;g<w.length-8;++g)w[g]=0;g=this.o*8;for(var E=w.length-8;E<w.length;++E)w[E]=g&255,g/=256;for(this.v(w),w=Array(16),g=0,E=0;E<4;++E)for(let I=0;I<32;I+=8)w[g++]=this.g[E]>>>I&255;return w};function i(w,g){var E=c;return Object.prototype.hasOwnProperty.call(E,w)?E[w]:E[w]=g(w)}function a(w,g){this.h=g;const E=[];let I=!0;for(let T=w.length-1;T>=0;T--){const A=w[T]|0;I&&A==g||(E[T]=A,I=!1)}this.g=E}var c={};function l(w){return-128<=w&&w<128?i(w,function(g){return new a([g|0],g<0?-1:0)}):new a([w|0],w<0?-1:0)}function d(w){if(isNaN(w)||!isFinite(w))return m;if(w<0)return k(d(-w));const g=[];let E=1;for(let I=0;w>=E;I++)g[I]=w/E|0,E*=4294967296;return new a(g,0)}function f(w,g){if(w.length==0)throw Error("number format error: empty string");if(g=g||10,g<2||36<g)throw Error("radix out of range: "+g);if(w.charAt(0)=="-")return k(f(w.substring(1),g));if(w.indexOf("-")>=0)throw Error('number format error: interior "-" character');const E=d(Math.pow(g,8));let I=m;for(let A=0;A<w.length;A+=8){var T=Math.min(8,w.length-A);const y=parseInt(w.substring(A,A+T),g);T<8?(T=d(Math.pow(g,T)),I=I.j(T).add(d(y))):(I=I.j(E),I=I.add(d(y)))}return I}var m=l(0),_=l(1),R=l(16777216);n=a.prototype,n.m=function(){if(N(this))return-k(this).m();let w=0,g=1;for(let E=0;E<this.g.length;E++){const I=this.i(E);w+=(I>=0?I:4294967296+I)*g,g*=4294967296}return w},n.toString=function(w){if(w=w||10,w<2||36<w)throw Error("radix out of range: "+w);if(S(this))return"0";if(N(this))return"-"+k(this).toString(w);const g=d(Math.pow(w,6));var E=this;let I="";for(;;){const T=Q(E,g).g;E=U(E,T.j(g));let A=((E.g.length>0?E.g[0]:E.h)>>>0).toString(w);if(E=T,S(E))return A+I;for(;A.length<6;)A="0"+A;I=A+I}},n.i=function(w){return w<0?0:w<this.g.length?this.g[w]:this.h};function S(w){if(w.h!=0)return!1;for(let g=0;g<w.g.length;g++)if(w.g[g]!=0)return!1;return!0}function N(w){return w.h==-1}n.l=function(w){return w=U(this,w),N(w)?-1:S(w)?0:1};function k(w){const g=w.g.length,E=[];for(let I=0;I<g;I++)E[I]=~w.g[I];return new a(E,~w.h).add(_)}n.abs=function(){return N(this)?k(this):this},n.add=function(w){const g=Math.max(this.g.length,w.g.length),E=[];let I=0;for(let T=0;T<=g;T++){let A=I+(this.i(T)&65535)+(w.i(T)&65535),y=(A>>>16)+(this.i(T)>>>16)+(w.i(T)>>>16);I=y>>>16,A&=65535,y&=65535,E[T]=y<<16|A}return new a(E,E[E.length-1]&-2147483648?-1:0)};function U(w,g){return w.add(k(g))}n.j=function(w){if(S(this)||S(w))return m;if(N(this))return N(w)?k(this).j(k(w)):k(k(this).j(w));if(N(w))return k(this.j(k(w)));if(this.l(R)<0&&w.l(R)<0)return d(this.m()*w.m());const g=this.g.length+w.g.length,E=[];for(var I=0;I<2*g;I++)E[I]=0;for(I=0;I<this.g.length;I++)for(let T=0;T<w.g.length;T++){const A=this.i(I)>>>16,y=this.i(I)&65535,Me=w.i(T)>>>16,Tn=w.i(T)&65535;E[2*I+2*T]+=y*Tn,$(E,2*I+2*T),E[2*I+2*T+1]+=A*Tn,$(E,2*I+2*T+1),E[2*I+2*T+1]+=y*Me,$(E,2*I+2*T+1),E[2*I+2*T+2]+=A*Me,$(E,2*I+2*T+2)}for(w=0;w<g;w++)E[w]=E[2*w+1]<<16|E[2*w];for(w=g;w<2*g;w++)E[w]=0;return new a(E,0)};function $(w,g){for(;(w[g]&65535)!=w[g];)w[g+1]+=w[g]>>>16,w[g]&=65535,g++}function j(w,g){this.g=w,this.h=g}function Q(w,g){if(S(g))throw Error("division by zero");if(S(w))return new j(m,m);if(N(w))return g=Q(k(w),g),new j(k(g.g),k(g.h));if(N(g))return g=Q(w,k(g)),new j(k(g.g),g.h);if(w.g.length>30){if(N(w)||N(g))throw Error("slowDivide_ only works with positive integers.");for(var E=_,I=g;I.l(w)<=0;)E=_e(E),I=_e(I);var T=re(E,1),A=re(I,1);for(I=re(I,2),E=re(E,2);!S(I);){var y=A.add(I);y.l(w)<=0&&(T=T.add(E),A=y),I=re(I,1),E=re(E,1)}return g=U(w,T.j(g)),new j(T,g)}for(T=m;w.l(g)>=0;){for(E=Math.max(1,Math.floor(w.m()/g.m())),I=Math.ceil(Math.log(E)/Math.LN2),I=I<=48?1:Math.pow(2,I-48),A=d(E),y=A.j(g);N(y)||y.l(w)>0;)E-=I,A=d(E),y=A.j(g);S(A)&&(A=_),T=T.add(A),w=U(w,y)}return new j(T,w)}n.B=function(w){return Q(this,w).h},n.and=function(w){const g=Math.max(this.g.length,w.g.length),E=[];for(let I=0;I<g;I++)E[I]=this.i(I)&w.i(I);return new a(E,this.h&w.h)},n.or=function(w){const g=Math.max(this.g.length,w.g.length),E=[];for(let I=0;I<g;I++)E[I]=this.i(I)|w.i(I);return new a(E,this.h|w.h)},n.xor=function(w){const g=Math.max(this.g.length,w.g.length),E=[];for(let I=0;I<g;I++)E[I]=this.i(I)^w.i(I);return new a(E,this.h^w.h)};function _e(w){const g=w.g.length+1,E=[];for(let I=0;I<g;I++)E[I]=w.i(I)<<1|w.i(I-1)>>>31;return new a(E,w.h)}function re(w,g){const E=g>>5;g%=32;const I=w.g.length-E,T=[];for(let A=0;A<I;A++)T[A]=g>0?w.i(A+E)>>>g|w.i(A+E+1)<<32-g:w.i(A+E);return new a(T,w.h)}r.prototype.digest=r.prototype.A,r.prototype.reset=r.prototype.u,r.prototype.update=r.prototype.v,Lc=r,a.prototype.add=a.prototype.add,a.prototype.multiply=a.prototype.j,a.prototype.modulo=a.prototype.B,a.prototype.compare=a.prototype.l,a.prototype.toNumber=a.prototype.m,a.prototype.toString=a.prototype.toString,a.prototype.getBits=a.prototype.i,a.fromNumber=d,a.fromString=f,Nt=a}).apply(typeof Vc<"u"?Vc:typeof self<"u"?self:typeof window<"u"?window:{});var ps=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};var Mc,pr,xc,ms,to,Uc,Fc,Bc;(function(){var n,e=Object.defineProperty;function t(o){o=[typeof globalThis=="object"&&globalThis,o,typeof window=="object"&&window,typeof self=="object"&&self,typeof ps=="object"&&ps];for(var u=0;u<o.length;++u){var h=o[u];if(h&&h.Math==Math)return h}throw Error("Cannot find global object")}var r=t(this);function s(o,u){if(u)e:{var h=r;o=o.split(".");for(var p=0;p<o.length-1;p++){var v=o[p];if(!(v in h))break e;h=h[v]}o=o[o.length-1],p=h[o],u=u(p),u!=p&&u!=null&&e(h,o,{configurable:!0,writable:!0,value:u})}}s("Symbol.dispose",function(o){return o||Symbol("Symbol.dispose")}),s("Array.prototype.values",function(o){return o||function(){return this[Symbol.iterator]()}}),s("Object.entries",function(o){return o||function(u){var h=[],p;for(p in u)Object.prototype.hasOwnProperty.call(u,p)&&h.push([p,u[p]]);return h}});var i=i||{},a=this||self;function c(o){var u=typeof o;return u=="object"&&o!=null||u=="function"}function l(o,u,h){return o.call.apply(o.bind,arguments)}function d(o,u,h){return d=l,d.apply(null,arguments)}function f(o,u){var h=Array.prototype.slice.call(arguments,1);return function(){var p=h.slice();return p.push.apply(p,arguments),o.apply(this,p)}}function m(o,u){function h(){}h.prototype=u.prototype,o.Z=u.prototype,o.prototype=new h,o.prototype.constructor=o,o.Ob=function(p,v,b){for(var O=Array(arguments.length-2),z=2;z<arguments.length;z++)O[z-2]=arguments[z];return u.prototype[v].apply(p,O)}}var _=typeof AsyncContext<"u"&&typeof AsyncContext.Snapshot=="function"?o=>o&&AsyncContext.Snapshot.wrap(o):o=>o;function R(o){const u=o.length;if(u>0){const h=Array(u);for(let p=0;p<u;p++)h[p]=o[p];return h}return[]}function S(o,u){for(let p=1;p<arguments.length;p++){const v=arguments[p];var h=typeof v;if(h=h!="object"?h:v?Array.isArray(v)?"array":h:"null",h=="array"||h=="object"&&typeof v.length=="number"){h=o.length||0;const b=v.length||0;o.length=h+b;for(let O=0;O<b;O++)o[h+O]=v[O]}else o.push(v)}}class N{constructor(u,h){this.i=u,this.j=h,this.h=0,this.g=null}get(){let u;return this.h>0?(this.h--,u=this.g,this.g=u.next,u.next=null):u=this.i(),u}}function k(o){a.setTimeout(()=>{throw o},0)}function U(){var o=w;let u=null;return o.g&&(u=o.g,o.g=o.g.next,o.g||(o.h=null),u.next=null),u}class ${constructor(){this.h=this.g=null}add(u,h){const p=j.get();p.set(u,h),this.h?this.h.next=p:this.g=p,this.h=p}}var j=new N(()=>new Q,o=>o.reset());class Q{constructor(){this.next=this.g=this.h=null}set(u,h){this.h=u,this.g=h,this.next=null}reset(){this.next=this.g=this.h=null}}let _e,re=!1,w=new $,g=()=>{const o=Promise.resolve(void 0);_e=()=>{o.then(E)}};function E(){for(var o;o=U();){try{o.h.call(o.g)}catch(h){k(h)}var u=j;u.j(o),u.h<100&&(u.h++,o.next=u.g,u.g=o)}re=!1}function I(){this.u=this.u,this.C=this.C}I.prototype.u=!1,I.prototype.dispose=function(){this.u||(this.u=!0,this.N())},I.prototype[Symbol.dispose]=function(){this.dispose()},I.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function T(o,u){this.type=o,this.g=this.target=u,this.defaultPrevented=!1}T.prototype.h=function(){this.defaultPrevented=!0};var A=function(){if(!a.addEventListener||!Object.defineProperty)return!1;var o=!1,u=Object.defineProperty({},"passive",{get:function(){o=!0}});try{const h=()=>{};a.addEventListener("test",h,u),a.removeEventListener("test",h,u)}catch{}return o}();function y(o){return/^[\s\xa0]*$/.test(o)}function Me(o,u){T.call(this,o?o.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,o&&this.init(o,u)}m(Me,T),Me.prototype.init=function(o,u){const h=this.type=o.type,p=o.changedTouches&&o.changedTouches.length?o.changedTouches[0]:null;this.target=o.target||o.srcElement,this.g=u,u=o.relatedTarget,u||(h=="mouseover"?u=o.fromElement:h=="mouseout"&&(u=o.toElement)),this.relatedTarget=u,p?(this.clientX=p.clientX!==void 0?p.clientX:p.pageX,this.clientY=p.clientY!==void 0?p.clientY:p.pageY,this.screenX=p.screenX||0,this.screenY=p.screenY||0):(this.clientX=o.clientX!==void 0?o.clientX:o.pageX,this.clientY=o.clientY!==void 0?o.clientY:o.pageY,this.screenX=o.screenX||0,this.screenY=o.screenY||0),this.button=o.button,this.key=o.key||"",this.ctrlKey=o.ctrlKey,this.altKey=o.altKey,this.shiftKey=o.shiftKey,this.metaKey=o.metaKey,this.pointerId=o.pointerId||0,this.pointerType=o.pointerType,this.state=o.state,this.i=o,o.defaultPrevented&&Me.Z.h.call(this)},Me.prototype.h=function(){Me.Z.h.call(this);const o=this.i;o.preventDefault?o.preventDefault():o.returnValue=!1};var Tn="closure_listenable_"+(Math.random()*1e6|0),eA=0;function tA(o,u,h,p,v){this.listener=o,this.proxy=null,this.src=u,this.type=h,this.capture=!!p,this.ha=v,this.key=++eA,this.da=this.fa=!1}function Pi(o){o.da=!0,o.listener=null,o.proxy=null,o.src=null,o.ha=null}function Ci(o,u,h){for(const p in o)u.call(h,o[p],p,o)}function nA(o,u){for(const h in o)u.call(void 0,o[h],h,o)}function hf(o){const u={};for(const h in o)u[h]=o[h];return u}const df="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function ff(o,u){let h,p;for(let v=1;v<arguments.length;v++){p=arguments[v];for(h in p)o[h]=p[h];for(let b=0;b<df.length;b++)h=df[b],Object.prototype.hasOwnProperty.call(p,h)&&(o[h]=p[h])}}function Si(o){this.src=o,this.g={},this.h=0}Si.prototype.add=function(o,u,h,p,v){const b=o.toString();o=this.g[b],o||(o=this.g[b]=[],this.h++);const O=$a(o,u,p,v);return O>-1?(u=o[O],h||(u.fa=!1)):(u=new tA(u,this.src,b,!!p,v),u.fa=h,o.push(u)),u};function ja(o,u){const h=u.type;if(h in o.g){var p=o.g[h],v=Array.prototype.indexOf.call(p,u,void 0),b;(b=v>=0)&&Array.prototype.splice.call(p,v,1),b&&(Pi(u),o.g[h].length==0&&(delete o.g[h],o.h--))}}function $a(o,u,h,p){for(let v=0;v<o.length;++v){const b=o[v];if(!b.da&&b.listener==u&&b.capture==!!h&&b.ha==p)return v}return-1}var za="closure_lm_"+(Math.random()*1e6|0),Wa={};function pf(o,u,h,p,v){if(Array.isArray(u)){for(let b=0;b<u.length;b++)pf(o,u[b],h,p,v);return null}return h=_f(h),o&&o[Tn]?o.J(u,h,c(p)?!!p.capture:!1,v):rA(o,u,h,!1,p,v)}function rA(o,u,h,p,v,b){if(!u)throw Error("Invalid event type");const O=c(v)?!!v.capture:!!v;let z=Ga(o);if(z||(o[za]=z=new Si(o)),h=z.add(u,h,p,O,b),h.proxy)return h;if(p=sA(),h.proxy=p,p.src=o,p.listener=h,o.addEventListener)A||(v=O),v===void 0&&(v=!1),o.addEventListener(u.toString(),p,v);else if(o.attachEvent)o.attachEvent(gf(u.toString()),p);else if(o.addListener&&o.removeListener)o.addListener(p);else throw Error("addEventListener and attachEvent are unavailable.");return h}function sA(){function o(h){return u.call(o.src,o.listener,h)}const u=iA;return o}function mf(o,u,h,p,v){if(Array.isArray(u))for(var b=0;b<u.length;b++)mf(o,u[b],h,p,v);else p=c(p)?!!p.capture:!!p,h=_f(h),o&&o[Tn]?(o=o.i,b=String(u).toString(),b in o.g&&(u=o.g[b],h=$a(u,h,p,v),h>-1&&(Pi(u[h]),Array.prototype.splice.call(u,h,1),u.length==0&&(delete o.g[b],o.h--)))):o&&(o=Ga(o))&&(u=o.g[u.toString()],o=-1,u&&(o=$a(u,h,p,v)),(h=o>-1?u[o]:null)&&Ha(h))}function Ha(o){if(typeof o!="number"&&o&&!o.da){var u=o.src;if(u&&u[Tn])ja(u.i,o);else{var h=o.type,p=o.proxy;u.removeEventListener?u.removeEventListener(h,p,o.capture):u.detachEvent?u.detachEvent(gf(h),p):u.addListener&&u.removeListener&&u.removeListener(p),(h=Ga(u))?(ja(h,o),h.h==0&&(h.src=null,u[za]=null)):Pi(o)}}}function gf(o){return o in Wa?Wa[o]:Wa[o]="on"+o}function iA(o,u){if(o.da)o=!0;else{u=new Me(u,this);const h=o.listener,p=o.ha||o.src;o.fa&&Ha(o),o=h.call(p,u)}return o}function Ga(o){return o=o[za],o instanceof Si?o:null}var Ka="__closure_events_fn_"+(Math.random()*1e9>>>0);function _f(o){return typeof o=="function"?o:(o[Ka]||(o[Ka]=function(u){return o.handleEvent(u)}),o[Ka])}function Ce(){I.call(this),this.i=new Si(this),this.M=this,this.G=null}m(Ce,I),Ce.prototype[Tn]=!0,Ce.prototype.removeEventListener=function(o,u,h,p){mf(this,o,u,h,p)};function Ne(o,u){var h,p=o.G;if(p)for(h=[];p;p=p.G)h.push(p);if(o=o.M,p=u.type||u,typeof u=="string")u=new T(u,o);else if(u instanceof T)u.target=u.target||o;else{var v=u;u=new T(p,o),ff(u,v)}v=!0;let b,O;if(h)for(O=h.length-1;O>=0;O--)b=u.g=h[O],v=ki(b,p,!0,u)&&v;if(b=u.g=o,v=ki(b,p,!0,u)&&v,v=ki(b,p,!1,u)&&v,h)for(O=0;O<h.length;O++)b=u.g=h[O],v=ki(b,p,!1,u)&&v}Ce.prototype.N=function(){if(Ce.Z.N.call(this),this.i){var o=this.i;for(const u in o.g){const h=o.g[u];for(let p=0;p<h.length;p++)Pi(h[p]);delete o.g[u],o.h--}}this.G=null},Ce.prototype.J=function(o,u,h,p){return this.i.add(String(o),u,!1,h,p)},Ce.prototype.K=function(o,u,h,p){return this.i.add(String(o),u,!0,h,p)};function ki(o,u,h,p){if(u=o.i.g[String(u)],!u)return!0;u=u.concat();let v=!0;for(let b=0;b<u.length;++b){const O=u[b];if(O&&!O.da&&O.capture==h){const z=O.listener,me=O.ha||O.src;O.fa&&ja(o.i,O),v=z.call(me,p)!==!1&&v}}return v&&!p.defaultPrevented}function oA(o,u){if(typeof o!="function")if(o&&typeof o.handleEvent=="function")o=d(o.handleEvent,o);else throw Error("Invalid listener argument");return Number(u)>2147483647?-1:a.setTimeout(o,u||0)}function yf(o){o.g=oA(()=>{o.g=null,o.i&&(o.i=!1,yf(o))},o.l);const u=o.h;o.h=null,o.m.apply(null,u)}class aA extends I{constructor(u,h){super(),this.m=u,this.l=h,this.h=null,this.i=!1,this.g=null}j(u){this.h=arguments,this.g?this.i=!0:yf(this)}N(){super.N(),this.g&&(a.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Hr(o){I.call(this),this.h=o,this.g={}}m(Hr,I);var Ef=[];function Tf(o){Ci(o.g,function(u,h){this.g.hasOwnProperty(h)&&Ha(u)},o),o.g={}}Hr.prototype.N=function(){Hr.Z.N.call(this),Tf(this)},Hr.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var Qa=a.JSON.stringify,cA=a.JSON.parse,uA=class{stringify(o){return a.JSON.stringify(o,void 0)}parse(o){return a.JSON.parse(o,void 0)}};function wf(){}function If(){}var Gr={OPEN:"a",hb:"b",ERROR:"c",tb:"d"};function Ya(){T.call(this,"d")}m(Ya,T);function Ja(){T.call(this,"c")}m(Ja,T);var wn={},vf=null;function Ni(){return vf=vf||new Ce}wn.Ia="serverreachability";function Af(o){T.call(this,wn.Ia,o)}m(Af,T);function Kr(o){const u=Ni();Ne(u,new Af(u))}wn.STAT_EVENT="statevent";function Rf(o,u){T.call(this,wn.STAT_EVENT,o),this.stat=u}m(Rf,T);function De(o){const u=Ni();Ne(u,new Rf(u,o))}wn.Ja="timingevent";function bf(o,u){T.call(this,wn.Ja,o),this.size=u}m(bf,T);function Qr(o,u){if(typeof o!="function")throw Error("Fn must not be null and must be a function");return a.setTimeout(function(){o()},u)}function Yr(){this.g=!0}Yr.prototype.ua=function(){this.g=!1};function lA(o,u,h,p,v,b){o.info(function(){if(o.g)if(b){var O="",z=b.split("&");for(let Z=0;Z<z.length;Z++){var me=z[Z].split("=");if(me.length>1){const ye=me[0];me=me[1];const gt=ye.split("_");O=gt.length>=2&>[1]=="type"?O+(ye+"="+me+"&"):O+(ye+"=redacted&")}}}else O=null;else O=b;return"XMLHTTP REQ ("+p+") [attempt "+v+"]: "+u+`
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
`+h+`
|
|
19
|
-
|
|
20
|
-
`,h);return p==-1?Za:(h=Number(u.substring(h,p)),isNaN(h)?kf:(p+=1,p+h>u.length?Za:(u=u.slice(p,p+h),o.C=p+h,u)))}Kt.prototype.cancel=function(){this.K=!0,In(this)};function Oi(o){o.T=Date.now()+o.H,Of(o,o.H)}function Of(o,u){if(o.D!=null)throw Error("WatchDog timer not null");o.D=Qr(d(o.aa,o),u)}function tc(o){o.D&&(a.clearTimeout(o.D),o.D=null)}Kt.prototype.aa=function(){this.D=null;const o=Date.now();o-this.T>=0?(dA(this.i,this.B),this.M!=2&&(Kr(),De(17)),In(this),this.m=2,Xr(this)):Of(this,this.T-o)};function Xr(o){o.j.I==0||o.K||sp(o.j,o)}function In(o){tc(o);var u=o.O;u&&typeof u.dispose=="function"&&u.dispose(),o.O=null,Tf(o.V),o.g&&(u=o.g,o.g=null,u.abort(),u.dispose())}function nc(o,u){try{var h=o.j;if(h.I!=0&&(h.g==o||rc(h.h,o))){if(!o.L&&rc(h.h,o)&&h.I==3){try{var p=h.Ba.g.parse(u)}catch{p=null}if(Array.isArray(p)&&p.length==3){var v=p;if(v[0]==0){e:if(!h.v){if(h.g)if(h.g.F+3e3<o.F)Fi(h),xi(h);else break e;uc(h),De(18)}}else h.xa=v[1],0<h.xa-h.K&&v[2]<37500&&h.F&&h.A==0&&!h.C&&(h.C=Qr(d(h.Va,h),6e3));Mf(h.h)<=1&&h.ta&&(h.ta=void 0)}else An(h,11)}else if((o.L||h.g==o)&&Fi(h),!y(u))for(v=h.Ba.g.parse(u),u=0;u<v.length;u++){let Z=v[u];const ye=Z[0];if(!(ye<=h.K))if(h.K=ye,Z=Z[1],h.I==2)if(Z[0]=="c"){h.M=Z[1],h.ba=Z[2];const gt=Z[3];gt!=null&&(h.ka=gt,h.j.info("VER="+h.ka));const Rn=Z[4];Rn!=null&&(h.za=Rn,h.j.info("SVER="+h.za));const Xt=Z[5];Xt!=null&&typeof Xt=="number"&&Xt>0&&(p=1.5*Xt,h.O=p,h.j.info("backChannelRequestTimeoutMs_="+p)),p=h;const Zt=o.g;if(Zt){const qi=Zt.g?Zt.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(qi){var b=p.h;b.g||qi.indexOf("spdy")==-1&&qi.indexOf("quic")==-1&&qi.indexOf("h2")==-1||(b.j=b.l,b.g=new Set,b.h&&(sc(b,b.h),b.h=null))}if(p.G){const hc=Zt.g?Zt.g.getResponseHeader("X-HTTP-Session-Id"):null;hc&&(p.wa=hc,ne(p.J,p.G,hc))}}h.I=3,h.l&&h.l.ra(),h.aa&&(h.T=Date.now()-o.F,h.j.info("Handshake RTT: "+h.T+"ms")),p=h;var O=o;if(p.na=ap(p,p.L?p.ba:null,p.W),O.L){xf(p.h,O);var z=O,me=p.O;me&&(z.H=me),z.D&&(tc(z),Oi(z)),p.g=O}else np(p);h.i.length>0&&Ui(h)}else Z[0]!="stop"&&Z[0]!="close"||An(h,7);else h.I==3&&(Z[0]=="stop"||Z[0]=="close"?Z[0]=="stop"?An(h,7):cc(h):Z[0]!="noop"&&h.l&&h.l.qa(Z),h.A=0)}}Kr(4)}catch{}}var _A=class{constructor(o,u){this.g=o,this.map=u}};function Vf(o){this.l=o||10,a.PerformanceNavigationTiming?(o=a.performance.getEntriesByType("navigation"),o=o.length>0&&(o[0].nextHopProtocol=="hq"||o[0].nextHopProtocol=="h2")):o=!!(a.chrome&&a.chrome.loadTimes&&a.chrome.loadTimes()&&a.chrome.loadTimes().wasFetchedViaSpdy),this.j=o?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function Lf(o){return o.h?!0:o.g?o.g.size>=o.j:!1}function Mf(o){return o.h?1:o.g?o.g.size:0}function rc(o,u){return o.h?o.h==u:o.g?o.g.has(u):!1}function sc(o,u){o.g?o.g.add(u):o.h=u}function xf(o,u){o.h&&o.h==u?o.h=null:o.g&&o.g.has(u)&&o.g.delete(u)}Vf.prototype.cancel=function(){if(this.i=Uf(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(const o of this.g.values())o.cancel();this.g.clear()}};function Uf(o){if(o.h!=null)return o.i.concat(o.h.G);if(o.g!=null&&o.g.size!==0){let u=o.i;for(const h of o.g.values())u=u.concat(h.G);return u}return R(o.i)}var Ff=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function yA(o,u){if(o){o=o.split("&");for(let h=0;h<o.length;h++){const p=o[h].indexOf("=");let v,b=null;p>=0?(v=o[h].substring(0,p),b=o[h].substring(p+1)):v=o[h],u(v,b?decodeURIComponent(b.replace(/\+/g," ")):"")}}}function Qt(o){this.g=this.o=this.j="",this.u=null,this.m=this.h="",this.l=!1;let u;o instanceof Qt?(this.l=o.l,Zr(this,o.j),this.o=o.o,this.g=o.g,es(this,o.u),this.h=o.h,ic(this,Wf(o.i)),this.m=o.m):o&&(u=String(o).match(Ff))?(this.l=!1,Zr(this,u[1]||"",!0),this.o=ts(u[2]||""),this.g=ts(u[3]||"",!0),es(this,u[4]),this.h=ts(u[5]||"",!0),ic(this,u[6]||"",!0),this.m=ts(u[7]||"")):(this.l=!1,this.i=new rs(null,this.l))}Qt.prototype.toString=function(){const o=[];var u=this.j;u&&o.push(ns(u,Bf,!0),":");var h=this.g;return(h||u=="file")&&(o.push("//"),(u=this.o)&&o.push(ns(u,Bf,!0),"@"),o.push(Jr(h).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),h=this.u,h!=null&&o.push(":",String(h))),(h=this.h)&&(this.g&&h.charAt(0)!="/"&&o.push("/"),o.push(ns(h,h.charAt(0)=="/"?wA:TA,!0))),(h=this.i.toString())&&o.push("?",h),(h=this.m)&&o.push("#",ns(h,vA)),o.join("")},Qt.prototype.resolve=function(o){const u=mt(this);let h=!!o.j;h?Zr(u,o.j):h=!!o.o,h?u.o=o.o:h=!!o.g,h?u.g=o.g:h=o.u!=null;var p=o.h;if(h)es(u,o.u);else if(h=!!o.h){if(p.charAt(0)!="/")if(this.g&&!this.h)p="/"+p;else{var v=u.h.lastIndexOf("/");v!=-1&&(p=u.h.slice(0,v+1)+p)}if(v=p,v==".."||v==".")p="";else if(v.indexOf("./")!=-1||v.indexOf("/.")!=-1){p=v.lastIndexOf("/",0)==0,v=v.split("/");const b=[];for(let O=0;O<v.length;){const z=v[O++];z=="."?p&&O==v.length&&b.push(""):z==".."?((b.length>1||b.length==1&&b[0]!="")&&b.pop(),p&&O==v.length&&b.push("")):(b.push(z),p=!0)}p=b.join("/")}else p=v}return h?u.h=p:h=o.i.toString()!=="",h?ic(u,Wf(o.i)):h=!!o.m,h&&(u.m=o.m),u};function mt(o){return new Qt(o)}function Zr(o,u,h){o.j=h?ts(u,!0):u,o.j&&(o.j=o.j.replace(/:$/,""))}function es(o,u){if(u){if(u=Number(u),isNaN(u)||u<0)throw Error("Bad port number "+u);o.u=u}else o.u=null}function ic(o,u,h){u instanceof rs?(o.i=u,AA(o.i,o.l)):(h||(u=ns(u,IA)),o.i=new rs(u,o.l))}function ne(o,u,h){o.i.set(u,h)}function Vi(o){return ne(o,"zx",Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),o}function ts(o,u){return o?u?decodeURI(o.replace(/%25/g,"%2525")):decodeURIComponent(o):""}function ns(o,u,h){return typeof o=="string"?(o=encodeURI(o).replace(u,EA),h&&(o=o.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),o):null}function EA(o){return o=o.charCodeAt(0),"%"+(o>>4&15).toString(16)+(o&15).toString(16)}var Bf=/[#\/\?@]/g,TA=/[#\?:]/g,wA=/[#\?]/g,IA=/[#\?@]/g,vA=/#/g;function rs(o,u){this.h=this.g=null,this.i=o||null,this.j=!!u}function vn(o){o.g||(o.g=new Map,o.h=0,o.i&&yA(o.i,function(u,h){o.add(decodeURIComponent(u.replace(/\+/g," ")),h)}))}n=rs.prototype,n.add=function(o,u){vn(this),this.i=null,o=nr(this,o);let h=this.g.get(o);return h||this.g.set(o,h=[]),h.push(u),this.h+=1,this};function qf(o,u){vn(o),u=nr(o,u),o.g.has(u)&&(o.i=null,o.h-=o.g.get(u).length,o.g.delete(u))}function jf(o,u){return vn(o),u=nr(o,u),o.g.has(u)}n.forEach=function(o,u){vn(this),this.g.forEach(function(h,p){h.forEach(function(v){o.call(u,v,p,this)},this)},this)};function $f(o,u){vn(o);let h=[];if(typeof u=="string")jf(o,u)&&(h=h.concat(o.g.get(nr(o,u))));else for(o=Array.from(o.g.values()),u=0;u<o.length;u++)h=h.concat(o[u]);return h}n.set=function(o,u){return vn(this),this.i=null,o=nr(this,o),jf(this,o)&&(this.h-=this.g.get(o).length),this.g.set(o,[u]),this.h+=1,this},n.get=function(o,u){return o?(o=$f(this,o),o.length>0?String(o[0]):u):u};function zf(o,u,h){qf(o,u),h.length>0&&(o.i=null,o.g.set(nr(o,u),R(h)),o.h+=h.length)}n.toString=function(){if(this.i)return this.i;if(!this.g)return"";const o=[],u=Array.from(this.g.keys());for(let p=0;p<u.length;p++){var h=u[p];const v=Jr(h);h=$f(this,h);for(let b=0;b<h.length;b++){let O=v;h[b]!==""&&(O+="="+Jr(h[b])),o.push(O)}}return this.i=o.join("&")};function Wf(o){const u=new rs;return u.i=o.i,o.g&&(u.g=new Map(o.g),u.h=o.h),u}function nr(o,u){return u=String(u),o.j&&(u=u.toLowerCase()),u}function AA(o,u){u&&!o.j&&(vn(o),o.i=null,o.g.forEach(function(h,p){const v=p.toLowerCase();p!=v&&(qf(this,p),zf(this,v,h))},o)),o.j=u}function RA(o,u){const h=new Yr;if(a.Image){const p=new Image;p.onload=f(Yt,h,"TestLoadImage: loaded",!0,u,p),p.onerror=f(Yt,h,"TestLoadImage: error",!1,u,p),p.onabort=f(Yt,h,"TestLoadImage: abort",!1,u,p),p.ontimeout=f(Yt,h,"TestLoadImage: timeout",!1,u,p),a.setTimeout(function(){p.ontimeout&&p.ontimeout()},1e4),p.src=o}else u(!1)}function bA(o,u){const h=new Yr,p=new AbortController,v=setTimeout(()=>{p.abort(),Yt(h,"TestPingServer: timeout",!1,u)},1e4);fetch(o,{signal:p.signal}).then(b=>{clearTimeout(v),b.ok?Yt(h,"TestPingServer: ok",!0,u):Yt(h,"TestPingServer: server error",!1,u)}).catch(()=>{clearTimeout(v),Yt(h,"TestPingServer: error",!1,u)})}function Yt(o,u,h,p,v){try{v&&(v.onload=null,v.onerror=null,v.onabort=null,v.ontimeout=null),p(h)}catch{}}function PA(){this.g=new uA}function oc(o){this.i=o.Sb||null,this.h=o.ab||!1}m(oc,wf),oc.prototype.g=function(){return new Li(this.i,this.h)};function Li(o,u){Ce.call(this),this.H=o,this.o=u,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F="GET",this.D="",this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}m(Li,Ce),n=Li.prototype,n.open=function(o,u){if(this.readyState!=0)throw this.abort(),Error("Error reopening a connection");this.F=o,this.D=u,this.readyState=1,is(this)},n.send=function(o){if(this.readyState!=1)throw this.abort(),Error("need to call open() first. ");if(this.v.signal.aborted)throw this.abort(),Error("Request was aborted.");this.g=!0;const u={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};o&&(u.body=o),(this.H||a).fetch(new Request(this.D,u)).then(this.Pa.bind(this),this.ga.bind(this))},n.abort=function(){this.response=this.responseText="",this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,ss(this)),this.readyState=0},n.Pa=function(o){if(this.g&&(this.l=o,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=o.headers,this.readyState=2,is(this)),this.g&&(this.readyState=3,is(this),this.g)))if(this.responseType==="arraybuffer")o.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(typeof a.ReadableStream<"u"&&"body"in o){if(this.j=o.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.B=new TextDecoder;Hf(this)}else o.text().then(this.Oa.bind(this),this.ga.bind(this))};function Hf(o){o.j.read().then(o.Ma.bind(o)).catch(o.ga.bind(o))}n.Ma=function(o){if(this.g){if(this.o&&o.value)this.response.push(o.value);else if(!this.o){var u=o.value?o.value:new Uint8Array(0);(u=this.B.decode(u,{stream:!o.done}))&&(this.response=this.responseText+=u)}o.done?ss(this):is(this),this.readyState==3&&Hf(this)}},n.Oa=function(o){this.g&&(this.response=this.responseText=o,ss(this))},n.Na=function(o){this.g&&(this.response=o,ss(this))},n.ga=function(){this.g&&ss(this)};function ss(o){o.readyState=4,o.l=null,o.j=null,o.B=null,is(o)}n.setRequestHeader=function(o,u){this.A.append(o,u)},n.getResponseHeader=function(o){return this.h&&this.h.get(o.toLowerCase())||""},n.getAllResponseHeaders=function(){if(!this.h)return"";const o=[],u=this.h.entries();for(var h=u.next();!h.done;)h=h.value,o.push(h[0]+": "+h[1]),h=u.next();return o.join(`\r
|
|
21
|
-
`)};
|
|
22
|
-
`
|
|
23
|
-
`);for(let p=0;p<o.length;p++){if(y(o[p]))continue;var h=pA(o[p]);const v=h[0];if(h=h[1],typeof h!="string")continue;h=h.trim();const b=u[v]||[];u[v]=b,b.push(h)}nA(u,function(p){return p.join(", ")})}n.ya=function(){return this.o},n.Ha=function(){return typeof this.l=="string"?this.l:String(this.l)};function os(o,u,h){return h&&h.internalChannelParams&&h.internalChannelParams[o]||u}function Xf(o){this.za=0,this.i=[],this.j=new Yr,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=os("failFast",!1,o),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=os("baseRetryDelayMs",5e3,o),this.Za=os("retryDelaySeedMs",1e4,o),this.Ta=os("forwardChannelMaxRetries",2,o),this.va=os("forwardChannelRequestTimeoutMs",2e4,o),this.ma=o&&o.xmlHttpFactory||void 0,this.Ua=o&&o.Rb||void 0,this.Aa=o&&o.useFetchStreams||!1,this.O=void 0,this.L=o&&o.supportsCrossDomainXhr||!1,this.M="",this.h=new Vf(o&&o.concurrentRequestLimit),this.Ba=new PA,this.S=o&&o.fastHandshake||!1,this.R=o&&o.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=o&&o.Pb||!1,o&&o.ua&&this.j.ua(),o&&o.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&o&&o.detectBufferingProxy||!1,this.ia=void 0,o&&o.longPollingTimeout&&o.longPollingTimeout>0&&(this.ia=o.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}n=Xf.prototype,n.ka=8,n.I=1,n.connect=function(o,u,h,p){De(0),this.W=o,this.H=u||{},h&&p!==void 0&&(this.H.OSID=h,this.H.OAID=p),this.F=this.X,this.J=ap(this,null,this.W),Ui(this)};function cc(o){if(Zf(o),o.I==3){var u=o.V++,h=mt(o.J);if(ne(h,"SID",o.M),ne(h,"RID",u),ne(h,"TYPE","terminate"),as(o,h),u=new Kt(o,o.j,u),u.M=2,u.A=Vi(mt(h)),h=!1,a.navigator&&a.navigator.sendBeacon)try{h=a.navigator.sendBeacon(u.A.toString(),"")}catch{}!h&&a.Image&&(new Image().src=u.A,h=!0),h||(u.g=cp(u.j,null),u.g.ea(u.A)),u.F=Date.now(),Oi(u)}op(o)}function xi(o){o.g&&(lc(o),o.g.cancel(),o.g=null)}function Zf(o){xi(o),o.v&&(a.clearTimeout(o.v),o.v=null),Fi(o),o.h.cancel(),o.m&&(typeof o.m=="number"&&a.clearTimeout(o.m),o.m=null)}function Ui(o){if(!Lf(o.h)&&!o.m){o.m=!0;var u=o.Ea;_e||g(),re||(_e(),re=!0),w.add(u,o),o.D=0}}function NA(o,u){return Mf(o.h)>=o.h.j-(o.m?1:0)?!1:o.m?(o.i=u.G.concat(o.i),!0):o.I==1||o.I==2||o.D>=(o.Sa?0:o.Ta)?!1:(o.m=Qr(d(o.Ea,o,u),ip(o,o.D)),o.D++,!0)}n.Ea=function(o){if(this.m)if(this.m=null,this.I==1){if(!o){this.V=Math.floor(Math.random()*1e5),o=this.V++;const v=new Kt(this,this.j,o);let b=this.o;if(this.U&&(b?(b=hf(b),ff(b,this.U)):b=this.U),this.u!==null||this.R||(v.J=b,b=null),this.S)e:{for(var u=0,h=0;h<this.i.length;h++){t:{var p=this.i[h];if("__data__"in p.map&&(p=p.map.__data__,typeof p=="string")){p=p.length;break t}p=void 0}if(p===void 0)break;if(u+=p,u>4096){u=h;break e}if(u===4096||h===this.i.length-1){u=h+1;break e}}u=1e3}else u=1e3;u=tp(this,v,u),h=mt(this.J),ne(h,"RID",o),ne(h,"CVER",22),this.G&&ne(h,"X-HTTP-Session-Id",this.G),as(this,h),b&&(this.R?u="headers="+Jr(Gf(b))+"&"+u:this.u&&ac(h,this.u,b)),sc(this.h,v),this.Ra&&ne(h,"TYPE","init"),this.S?(ne(h,"$req",u),ne(h,"SID","null"),v.U=!0,ec(v,h,null)):ec(v,h,u),this.I=2}}else this.I==3&&(o?ep(this,o):this.i.length==0||Lf(this.h)||ep(this))};function ep(o,u){var h;u?h=u.l:h=o.V++;const p=mt(o.J);ne(p,"SID",o.M),ne(p,"RID",h),ne(p,"AID",o.K),as(o,p),o.u&&o.o&&ac(p,o.u,o.o),h=new Kt(o,o.j,h,o.D+1),o.u===null&&(h.J=o.o),u&&(o.i=u.G.concat(o.i)),u=tp(o,h,1e3),h.H=Math.round(o.va*.5)+Math.round(o.va*.5*Math.random()),sc(o.h,h),ec(h,p,u)}function as(o,u){o.H&&Ci(o.H,function(h,p){ne(u,p,h)}),o.l&&Ci({},function(h,p){ne(u,p,h)})}function tp(o,u,h){h=Math.min(o.i.length,h);const p=o.l?d(o.l.Ka,o.l,o):null;e:{var v=o.i;let z=-1;for(;;){const me=["count="+h];z==-1?h>0?(z=v[0].g,me.push("ofs="+z)):z=0:me.push("ofs="+z);let Z=!0;for(let ye=0;ye<h;ye++){var b=v[ye].g;const gt=v[ye].map;if(b-=z,b<0)z=Math.max(0,v[ye].g-100),Z=!1;else try{b="req"+b+"_"||"";try{var O=gt instanceof Map?gt:Object.entries(gt);for(const[Rn,Xt]of O){let Zt=Xt;c(Xt)&&(Zt=Qa(Xt)),me.push(b+Rn+"="+encodeURIComponent(Zt))}}catch(Rn){throw me.push(b+"type="+encodeURIComponent("_badmap")),Rn}}catch{p&&p(gt)}}if(Z){O=me.join("&");break e}}O=void 0}return o=o.i.splice(0,h),u.G=o,O}function np(o){if(!o.g&&!o.v){o.Y=1;var u=o.Da;_e||g(),re||(_e(),re=!0),w.add(u,o),o.A=0}}function uc(o){return o.g||o.v||o.A>=3?!1:(o.Y++,o.v=Qr(d(o.Da,o),ip(o,o.A)),o.A++,!0)}n.Da=function(){if(this.v=null,rp(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var o=4*this.T;this.j.info("BP detection timer enabled: "+o),this.B=Qr(d(this.Wa,this),o)}},n.Wa=function(){this.B&&(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.P=!0,De(10),xi(this),rp(this))};function lc(o){o.B!=null&&(a.clearTimeout(o.B),o.B=null)}function rp(o){o.g=new Kt(o,o.j,"rpc",o.Y),o.u===null&&(o.g.J=o.o),o.g.P=0;var u=mt(o.na);ne(u,"RID","rpc"),ne(u,"SID",o.M),ne(u,"AID",o.K),ne(u,"CI",o.F?"0":"1"),!o.F&&o.ia&&ne(u,"TO",o.ia),ne(u,"TYPE","xmlhttp"),as(o,u),o.u&&o.o&&ac(u,o.u,o.o),o.O&&(o.g.H=o.O);var h=o.g;o=o.ba,h.M=1,h.A=Vi(mt(u)),h.u=null,h.R=!0,Nf(h,o)}n.Va=function(){this.C!=null&&(this.C=null,xi(this),uc(this),De(19))};function Fi(o){o.C!=null&&(a.clearTimeout(o.C),o.C=null)}function sp(o,u){var h=null;if(o.g==u){Fi(o),lc(o),o.g=null;var p=2}else if(rc(o.h,u))h=u.G,xf(o.h,u),p=1;else return;if(o.I!=0){if(u.o)if(p==1){h=u.u?u.u.length:0,u=Date.now()-u.F;var v=o.D;p=Ni(),Ne(p,new bf(p,h)),Ui(o)}else np(o);else if(v=u.m,v==3||v==0&&u.X>0||!(p==1&&NA(o,u)||p==2&&uc(o)))switch(h&&h.length>0&&(u=o.h,u.i=u.i.concat(h)),v){case 1:An(o,5);break;case 4:An(o,10);break;case 3:An(o,6);break;default:An(o,2)}}}function ip(o,u){let h=o.Qa+Math.floor(Math.random()*o.Za);return o.isActive()||(h*=2),h*u}function An(o,u){if(o.j.info("Error code "+u),u==2){var h=d(o.bb,o),p=o.Ua;const v=!p;p=new Qt(p||"//www.google.com/images/cleardot.gif"),a.location&&a.location.protocol=="http"||Zr(p,"https"),Vi(p),v?RA(p.toString(),h):bA(p.toString(),h)}else De(2);o.I=0,o.l&&o.l.pa(u),op(o),Zf(o)}n.bb=function(o){o?(this.j.info("Successfully pinged google.com"),De(2)):(this.j.info("Failed to ping google.com"),De(1))};function op(o){if(o.I=0,o.ja=[],o.l){const u=Uf(o.h);(u.length!=0||o.i.length!=0)&&(S(o.ja,u),S(o.ja,o.i),o.h.i.length=0,R(o.i),o.i.length=0),o.l.oa()}}function ap(o,u,h){var p=h instanceof Qt?mt(h):new Qt(h);if(p.g!="")u&&(p.g=u+"."+p.g),es(p,p.u);else{var v=a.location;p=v.protocol,u=u?u+"."+v.hostname:v.hostname,v=+v.port;const b=new Qt(null);p&&Zr(b,p),u&&(b.g=u),v&&es(b,v),h&&(b.h=h),p=b}return h=o.G,u=o.wa,h&&u&&ne(p,h,u),ne(p,"VER",o.ka),as(o,p),p}function cp(o,u,h){if(u&&!o.L)throw Error("Can't create secondary domain capable XhrIo object.");return u=o.Aa&&!o.ma?new oe(new oc({ab:h})):new oe(o.ma),u.Fa(o.L),u}n.isActive=function(){return!!this.l&&this.l.isActive(this)};function up(){}n=up.prototype,n.ra=function(){},n.qa=function(){},n.pa=function(){},n.oa=function(){},n.isActive=function(){return!0},n.Ka=function(){};function Bi(){}Bi.prototype.g=function(o,u){return new qe(o,u)};function qe(o,u){Ce.call(this),this.g=new Xf(u),this.l=o,this.h=u&&u.messageUrlParams||null,o=u&&u.messageHeaders||null,u&&u.clientProtocolHeaderRequired&&(o?o["X-Client-Protocol"]="webchannel":o={"X-Client-Protocol":"webchannel"}),this.g.o=o,o=u&&u.initMessageHeaders||null,u&&u.messageContentType&&(o?o["X-WebChannel-Content-Type"]=u.messageContentType:o={"X-WebChannel-Content-Type":u.messageContentType}),u&&u.sa&&(o?o["X-WebChannel-Client-Profile"]=u.sa:o={"X-WebChannel-Client-Profile":u.sa}),this.g.U=o,(o=u&&u.Qb)&&!y(o)&&(this.g.u=o),this.A=u&&u.supportsCrossDomainXhr||!1,this.v=u&&u.sendRawJson||!1,(u=u&&u.httpSessionIdParam)&&!y(u)&&(this.g.G=u,o=this.h,o!==null&&u in o&&(o=this.h,u in o&&delete o[u])),this.j=new rr(this)}m(qe,Ce),qe.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},qe.prototype.close=function(){cc(this.g)},qe.prototype.o=function(o){var u=this.g;if(typeof o=="string"){var h={};h.__data__=o,o=h}else this.v&&(h={},h.__data__=Qa(o),o=h);u.i.push(new _A(u.Ya++,o)),u.I==3&&Ui(u)},qe.prototype.N=function(){this.g.l=null,delete this.j,cc(this.g),delete this.g,qe.Z.N.call(this)};function lp(o){Ya.call(this),o.__headers__&&(this.headers=o.__headers__,this.statusCode=o.__status__,delete o.__headers__,delete o.__status__);var u=o.__sm__;if(u){e:{for(const h in u){o=h;break e}o=void 0}(this.i=o)&&(o=this.i,u=u!==null&&o in u?u[o]:void 0),this.data=u}else this.data=o}m(lp,Ya);function hp(){Ja.call(this),this.status=1}m(hp,Ja);function rr(o){this.g=o}m(rr,up),rr.prototype.ra=function(){Ne(this.g,"a")},rr.prototype.qa=function(o){Ne(this.g,new lp(o))},rr.prototype.pa=function(o){Ne(this.g,new hp)},rr.prototype.oa=function(){Ne(this.g,"b")},Bi.prototype.createWebChannel=Bi.prototype.g,qe.prototype.send=qe.prototype.o,qe.prototype.open=qe.prototype.m,qe.prototype.close=qe.prototype.close,Bc=function(){return new Bi},Fc=function(){return Ni()},Uc=wn,to={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},Di.NO_ERROR=0,Di.TIMEOUT=8,Di.HTTP_ERROR=6,ms=Di,Pf.COMPLETE="complete",xc=Pf,If.EventType=Gr,Gr.OPEN="a",Gr.CLOSE="b",Gr.ERROR="c",Gr.MESSAGE="d",Ce.prototype.listen=Ce.prototype.J,pr=If,oe.prototype.listenOnce=oe.prototype.K,oe.prototype.getLastError=oe.prototype.Ha,oe.prototype.getLastErrorCode=oe.prototype.ya,oe.prototype.getStatus=oe.prototype.ca,oe.prototype.getResponseJson=oe.prototype.La,oe.prototype.getResponseText=oe.prototype.la,oe.prototype.send=oe.prototype.ea,oe.prototype.setWithCredentials=oe.prototype.Fa,Mc=oe}).apply(typeof ps<"u"?ps:typeof self<"u"?self:typeof window<"u"?window:{});class Re{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}Re.UNAUTHENTICATED=new Re(null),Re.GOOGLE_CREDENTIALS=new Re("google-credentials-uid"),Re.FIRST_PARTY=new Re("first-party-uid"),Re.MOCK_USER=new Re("mock-user");let bn="12.10.0";function Gm(n){bn=n}const rn=new zi("@firebase/firestore");function Pn(){return rn.logLevel}function V(n,...e){if(rn.logLevel<=W.DEBUG){const t=e.map(no);rn.debug(`Firestore (${bn}): ${n}`,...t)}}function Et(n,...e){if(rn.logLevel<=W.ERROR){const t=e.map(no);rn.error(`Firestore (${bn}): ${n}`,...t)}}function sn(n,...e){if(rn.logLevel<=W.WARN){const t=e.map(no);rn.warn(`Firestore (${bn}): ${n}`,...t)}}function no(n){if(typeof n=="string")return n;try{return function(t){return JSON.stringify(t)}(n)}catch{return n}}function x(n,e,t){let r="Unexpected state";typeof e=="string"?r=e:t=e,qc(n,r,t)}function qc(n,e,t){let r=`FIRESTORE (${bn}) INTERNAL ASSERTION FAILED: ${e} (ID: ${n.toString(16)})`;if(t!==void 0)try{r+=" CONTEXT: "+JSON.stringify(t)}catch{r+=" CONTEXT: "+t}throw Et(r),new Error(r)}function J(n,e,t,r){let s="Unexpected state";typeof t=="string"?s=t:r=t,n||qc(e,s,r)}function F(n,e){return n}const P={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class D extends He{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class nt{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class jc{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Km{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(Re.UNAUTHENTICATED))}shutdown(){}}class Qm{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 Ym{constructor(e){this.t=e,this.currentUser=Re.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){J(this.o===void 0,42304);let r=this.i;const s=l=>this.i!==r?(r=this.i,t(l)):Promise.resolve();let i=new nt;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new nt,e.enqueueRetryable(()=>s(this.currentUser))};const a=()=>{const l=i;e.enqueueRetryable(async()=>{await l.promise,await s(this.currentUser)})},c=l=>{V("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=l,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit(l=>c(l)),setTimeout(()=>{if(!this.auth){const l=this.t.getImmediate({optional:!0});l?c(l):(V("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new nt)}},0),a()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(r=>this.i!==e?(V("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):r?(J(typeof r.accessToken=="string",31837,{l:r}),new jc(r.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return J(e===null||typeof e=="string",2055,{h:e}),new Re(e)}}class Jm{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=Re.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);const e=this.A();return e&&this.R.set("Authorization",e),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class Xm{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new Jm(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(Re.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class $c{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 Zm{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Ae(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){J(this.o===void 0,3512);const r=i=>{i.error!=null&&V("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${i.error.message}`);const a=i.token!==this.m;return this.m=i.token,V("FirebaseAppCheckTokenProvider",`Received ${a?"new":"existing"} token.`),a?t(i.token):Promise.resolve()};this.o=i=>{e.enqueueRetryable(()=>r(i))};const s=i=>{V("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=i,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(i=>s(i)),setTimeout(()=>{if(!this.appCheck){const i=this.V.getImmediate({optional:!0});i?s(i):V("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new $c(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(t=>t?(J(typeof t.token=="string",44558,{tokenResult:t}),this.m=t.token,new $c(t.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}function eg(n){const e=typeof self<"u"&&(self.crypto||self.msCrypto),t=new Uint8Array(n);if(e&&typeof e.getRandomValues=="function")e.getRandomValues(t);else for(let r=0;r<n;r++)t[r]=Math.floor(256*Math.random());return t}class ro{static newId(){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",t=62*Math.floor(4.129032258064516);let r="";for(;r.length<20;){const s=eg(40);for(let i=0;i<s.length;++i)r.length<20&&s[i]<t&&(r+=e.charAt(s[i]%62))}return r}}function H(n,e){return n<e?-1:n>e?1:0}function so(n,e){const t=Math.min(n.length,e.length);for(let r=0;r<t;r++){const s=n.charAt(r),i=e.charAt(r);if(s!==i)return io(s)===io(i)?H(s,i):io(s)?1:-1}return H(n.length,e.length)}const tg=55296,ng=57343;function io(n){const e=n.charCodeAt(0);return e>=tg&&e<=ng}function Cn(n,e,t){return n.length===e.length&&n.every((r,s)=>t(r,e[s]))}const zc="__name__";class rt{constructor(e,t,r){t===void 0?t=0:t>e.length&&x(637,{offset:t,range:e.length}),r===void 0?r=e.length-t:r>e.length-t&&x(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return rt.comparator(this,e)===0}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof rt?e.forEach(r=>{t.push(r)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const i=rt.compareSegments(e.get(s),t.get(s));if(i!==0)return i}return H(e.length,t.length)}static compareSegments(e,t){const r=rt.isNumericId(e),s=rt.isNumericId(t);return r&&!s?-1:!r&&s?1:r&&s?rt.extractNumericId(e).compare(rt.extractNumericId(t)):so(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Nt.fromString(e.substring(4,e.length-2))}}class X extends rt{construct(e,t,r){return new X(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const r of e){if(r.indexOf("//")>=0)throw new D(P.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter(s=>s.length>0))}return new X(t)}static emptyPath(){return new X([])}}const rg=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class Ee extends rt{construct(e,t,r){return new Ee(e,t,r)}static isValidIdentifier(e){return rg.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),Ee.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===zc}static keyField(){return new Ee([zc])}static fromServerFormat(e){const t=[];let r="",s=0;const i=()=>{if(r.length===0)throw new D(P.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""};let a=!1;for(;s<e.length;){const c=e[s];if(c==="\\"){if(s+1===e.length)throw new D(P.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const l=e[s+1];if(l!=="\\"&&l!=="."&&l!=="`")throw new D(P.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=l,s+=2}else c==="`"?(a=!a,s++):c!=="."||a?(r+=c,s++):(i(),s++)}if(i(),a)throw new D(P.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new Ee(t)}static emptyPath(){return new Ee([])}}class L{constructor(e){this.path=e}static fromPath(e){return new L(X.fromString(e))}static fromName(e){return new L(X.fromString(e).popFirst(5))}static empty(){return new L(X.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&X.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return X.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new L(new X(e.slice()))}}function Wc(n,e,t){if(!t)throw new D(P.INVALID_ARGUMENT,`Function ${n}() cannot be called with an empty ${e}.`)}function sg(n,e,t,r){if(e===!0&&r===!0)throw new D(P.INVALID_ARGUMENT,`${n} and ${t} cannot be used together.`)}function Hc(n){if(!L.isDocumentKey(n))throw new D(P.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${n} has ${n.length}.`)}function Gc(n){if(L.isDocumentKey(n))throw new D(P.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${n} has ${n.length}.`)}function Kc(n){return typeof n=="object"&&n!==null&&(Object.getPrototypeOf(n)===Object.prototype||Object.getPrototypeOf(n)===null)}function gs(n){if(n===void 0)return"undefined";if(n===null)return"null";if(typeof n=="string")return n.length>20&&(n=`${n.substring(0,20)}...`),JSON.stringify(n);if(typeof n=="number"||typeof n=="boolean")return""+n;if(typeof n=="object"){if(n instanceof Array)return"an array";{const e=function(r){return r.constructor?r.constructor.name:null}(n);return e?`a custom ${e} object`:"an object"}}return typeof n=="function"?"a function":x(12329,{type:typeof n})}function Ge(n,e){if("_delegate"in n&&(n=n._delegate),!(n instanceof e)){if(e.name===n.constructor.name)throw new D(P.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const t=gs(n);throw new D(P.INVALID_ARGUMENT,`Expected type '${e.name}', but it was: ${t}`)}}return n}function ig(n,e){if(e<=0)throw new D(P.INVALID_ARGUMENT,`Function ${n}() requires a positive number, but it was: ${e}.`)}function ue(n,e){const t={typeString:n};return e&&(t.value=e),t}function mr(n,e){if(!Kc(n))throw new D(P.INVALID_ARGUMENT,"JSON must be an object");let t;for(const r in e)if(e[r]){const s=e[r].typeString,i="value"in e[r]?{value:e[r].value}:void 0;if(!(r in n)){t=`JSON missing required field: '${r}'`;break}const a=n[r];if(s&&typeof a!==s){t=`JSON field '${r}' must be a ${s}.`;break}if(i!==void 0&&a!==i.value){t=`Expected '${r}' field to equal '${i.value}'`;break}}if(t)throw new D(P.INVALID_ARGUMENT,t);return!0}const Qc=-62135596800,Yc=1e6;class ee{static now(){return ee.fromMillis(Date.now())}static fromDate(e){return ee.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*Yc);return new ee(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new D(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new D(P.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<Qc)throw new D(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new D(P.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/Yc}_compareTo(e){return this.seconds===e.seconds?H(this.nanoseconds,e.nanoseconds):H(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:ee._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(mr(e,ee._jsonSchema))return new ee(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-Qc;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}ee._jsonSchemaVersion="firestore/timestamp/1.0",ee._jsonSchema={type:ue("string",ee._jsonSchemaVersion),seconds:ue("number"),nanoseconds:ue("number")};class B{static fromTimestamp(e){return new B(e)}static min(){return new B(new ee(0,0))}static max(){return new B(new ee(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}}const gr=-1;function og(n,e){const t=n.toTimestamp().seconds,r=n.toTimestamp().nanoseconds+1,s=B.fromTimestamp(r===1e9?new ee(t+1,0):new ee(t,r));return new Dt(s,L.empty(),e)}function ag(n){return new Dt(n.readTime,n.key,gr)}class Dt{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new Dt(B.min(),L.empty(),gr)}static max(){return new Dt(B.max(),L.empty(),gr)}}function cg(n,e){let t=n.readTime.compareTo(e.readTime);return t!==0?t:(t=L.comparator(n.documentKey,e.documentKey),t!==0?t:H(n.largestBatchId,e.largestBatchId))}const ug="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class lg{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}async function Sn(n){if(n.code!==P.FAILED_PRECONDITION||n.message!==ug)throw n;V("LocalStore","Unexpectedly lost primary lease")}class C{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(t=>{this.isDone=!0,this.result=t,this.nextCallback&&this.nextCallback(t)},t=>{this.isDone=!0,this.error=t,this.catchCallback&&this.catchCallback(t)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&x(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new C((r,s)=>{this.nextCallback=i=>{this.wrapSuccess(e,i).next(r,s)},this.catchCallback=i=>{this.wrapFailure(t,i).next(r,s)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{const t=e();return t instanceof C?t:C.resolve(t)}catch(t){return C.reject(t)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):C.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):C.reject(t)}static resolve(e){return new C((t,r)=>{t(e)})}static reject(e){return new C((t,r)=>{r(e)})}static waitFor(e){return new C((t,r)=>{let s=0,i=0,a=!1;e.forEach(c=>{++s,c.next(()=>{++i,a&&i===s&&t()},l=>r(l))}),a=!0,i===s&&t()})}static or(e){let t=C.resolve(!1);for(const r of e)t=t.next(s=>s?C.resolve(s):r());return t}static forEach(e,t){const r=[];return e.forEach((s,i)=>{r.push(t.call(this,s,i))}),this.waitFor(r)}static mapArray(e,t){return new C((r,s)=>{const i=e.length,a=new Array(i);let c=0;for(let l=0;l<i;l++){const d=l;t(e[d]).next(f=>{a[d]=f,++c,c===i&&r(a)},f=>s(f))}})}static doWhile(e,t){return new C((r,s)=>{const i=()=>{e()===!0?t().next(()=>{i()},s):r()};i()})}}function hg(n){const e=n.match(/Android ([\d.]+)/i),t=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(t)}function kn(n){return n.name==="IndexedDbTransactionError"}class _s{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=r=>this.ae(r),this.ue=r=>t.writeSequenceNumber(r))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ue&&this.ue(e),e}}_s.ce=-1;const oo=-1;function ys(n){return n==null}function Es(n){return n===0&&1/n==-1/0}function dg(n){return typeof n=="number"&&Number.isInteger(n)&&!Es(n)&&n<=Number.MAX_SAFE_INTEGER&&n>=Number.MIN_SAFE_INTEGER}const Jc="";function fg(n){let e="";for(let t=0;t<n.length;t++)e.length>0&&(e=Xc(e)),e=pg(n.get(t),e);return Xc(e)}function pg(n,e){let t=e;const r=n.length;for(let s=0;s<r;s++){const i=n.charAt(s);switch(i){case"\0":t+="";break;case Jc:t+="";break;default:t+=i}}return t}function Xc(n){return n+Jc+""}function Zc(n){let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e++;return e}function Ot(n,e){for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&e(t,n[t])}function mg(n,e){const t=[];for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&t.push(e(n[r],r,n));return t}function eu(n){for(const e in n)if(Object.prototype.hasOwnProperty.call(n,e))return!1;return!0}class se{constructor(e,t){this.comparator=e,this.root=t||Te.EMPTY}insert(e,t){return new se(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,Te.BLACK,null,null))}remove(e){return new se(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Te.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const r=this.comparator(e,t.key);if(r===0)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){const s=this.comparator(e,r.key);if(s===0)return t+r.left.size;s<0?r=r.left:(t+=r.left.size+1,r=r.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,r)=>(e(t,r),!1))}toString(){const e=[];return this.inorderTraversal((t,r)=>(e.push(`${t}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Ts(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Ts(this.root,e,this.comparator,!1)}getReverseIterator(){return new Ts(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Ts(this.root,e,this.comparator,!0)}}class Ts{constructor(e,t,r,s){this.isReverse=s,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?r(e.key,t):1,t&&s&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class Te{constructor(e,t,r,s,i){this.key=e,this.value=t,this.color=r??Te.RED,this.left=s??Te.EMPTY,this.right=i??Te.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,s,i){return new Te(e??this.key,t??this.value,r??this.color,s??this.left,i??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,r){let s=this;const i=r(e,s.key);return s=i<0?s.copy(null,null,null,s.left.insert(e,t,r),null):i===0?s.copy(null,t,null,null,null):s.copy(null,null,null,null,s.right.insert(e,t,r)),s.fixUp()}removeMin(){if(this.left.isEmpty())return Te.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let r,s=this;if(t(e,s.key)<0)s.left.isEmpty()||s.left.isRed()||s.left.left.isRed()||(s=s.moveRedLeft()),s=s.copy(null,null,null,s.left.remove(e,t),null);else{if(s.left.isRed()&&(s=s.rotateRight()),s.right.isEmpty()||s.right.isRed()||s.right.left.isRed()||(s=s.moveRedRight()),t(e,s.key)===0){if(s.right.isEmpty())return Te.EMPTY;r=s.right.min(),s=s.copy(r.key,r.value,null,null,s.right.removeMin())}s=s.copy(null,null,null,null,s.right.remove(e,t))}return s.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,Te.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,Te.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw x(43730,{key:this.key,value:this.value});if(this.right.isRed())throw x(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw x(27949);return e+(this.isRed()?0:1)}}Te.EMPTY=null,Te.RED=!0,Te.BLACK=!1,Te.EMPTY=new class{constructor(){this.size=0}get key(){throw x(57766)}get value(){throw x(16141)}get color(){throw x(16727)}get left(){throw x(29726)}get right(){throw x(36894)}copy(e,t,r,s,i){return this}insert(e,t,r){return new Te(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class fe{constructor(e){this.comparator=e,this.data=new se(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,r)=>(e(t),!1))}forEachInRange(e,t){const r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){const s=r.getNext();if(this.comparator(s.key,e[1])>=0)return;t(s.key)}}forEachWhile(e,t){let r;for(r=t!==void 0?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new tu(this.data.getIterator())}getIteratorFrom(e){return new tu(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(r=>{t=t.add(r)}),t}isEqual(e){if(!(e instanceof fe)||this.size!==e.size)return!1;const t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){const s=t.getNext().key,i=r.getNext().key;if(this.comparator(s,i)!==0)return!1}return!0}toArray(){const e=[];return this.forEach(t=>{e.push(t)}),e}toString(){const e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){const t=new fe(this.comparator);return t.data=e,t}}class tu{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class Fe{constructor(e){this.fields=e,e.sort(Ee.comparator)}static empty(){return new Fe([])}unionWith(e){let t=new fe(Ee.comparator);for(const r of this.fields)t=t.add(r);for(const r of e)t=t.add(r);return new Fe(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Cn(this.fields,e.fields,(t,r)=>t.isEqual(r))}}class nu extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class we{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(s){try{return atob(s)}catch(i){throw typeof DOMException<"u"&&i instanceof DOMException?new nu("Invalid base64 string: "+i):i}}(e);return new we(t)}static fromUint8Array(e){const t=function(s){let i="";for(let a=0;a<s.length;++a)i+=String.fromCharCode(s[a]);return i}(e);return new we(t)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(t){return btoa(t)}(this.binaryString)}toUint8Array(){return function(t){const r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return H(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}we.EMPTY_BYTE_STRING=new we("");const gg=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Vt(n){if(J(!!n,39018),typeof n=="string"){let e=0;const t=gg.exec(n);if(J(!!t,46558,{timestamp:n}),t[1]){let s=t[1];s=(s+"000000000").substr(0,9),e=Number(s)}const r=new Date(n);return{seconds:Math.floor(r.getTime()/1e3),nanos:e}}return{seconds:ae(n.seconds),nanos:ae(n.nanos)}}function ae(n){return typeof n=="number"?n:typeof n=="string"?Number(n):0}function Lt(n){return typeof n=="string"?we.fromBase64String(n):we.fromUint8Array(n)}const ru="server_timestamp",su="__type__",iu="__previous_value__",ou="__local_write_time__";function ws(n){return(n?.mapValue?.fields||{})[su]?.stringValue===ru}function Is(n){const e=n.mapValue.fields[iu];return ws(e)?Is(e):e}function _r(n){const e=Vt(n.mapValue.fields[ou].timestampValue);return new ee(e.seconds,e.nanos)}class _g{constructor(e,t,r,s,i,a,c,l,d,f,m){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=s,this.ssl=i,this.forceLongPolling=a,this.autoDetectLongPolling=c,this.longPollingOptions=l,this.useFetchStreams=d,this.isUsingEmulator=f,this.apiKey=m}}const vs="(default)";class yr{constructor(e,t){this.projectId=e,this.database=t||vs}static empty(){return new yr("","")}get isDefaultDatabase(){return this.database===vs}isEqual(e){return e instanceof yr&&e.projectId===this.projectId&&e.database===this.database}}function yg(n,e){if(!Object.prototype.hasOwnProperty.apply(n.options,["projectId"]))throw new D(P.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new yr(n.options.projectId,e)}const au="__type__",Eg="__max__",As={mapValue:{}},cu="__vector__",Rs="value";function Mt(n){return"nullValue"in n?0:"booleanValue"in n?1:"integerValue"in n||"doubleValue"in n?2:"timestampValue"in n?3:"stringValue"in n?5:"bytesValue"in n?6:"referenceValue"in n?7:"geoPointValue"in n?8:"arrayValue"in n?9:"mapValue"in n?ws(n)?4:wg(n)?9007199254740991:Tg(n)?10:11:x(28295,{value:n})}function st(n,e){if(n===e)return!0;const t=Mt(n);if(t!==Mt(e))return!1;switch(t){case 0:case 9007199254740991:return!0;case 1:return n.booleanValue===e.booleanValue;case 4:return _r(n).isEqual(_r(e));case 3:return function(s,i){if(typeof s.timestampValue=="string"&&typeof i.timestampValue=="string"&&s.timestampValue.length===i.timestampValue.length)return s.timestampValue===i.timestampValue;const a=Vt(s.timestampValue),c=Vt(i.timestampValue);return a.seconds===c.seconds&&a.nanos===c.nanos}(n,e);case 5:return n.stringValue===e.stringValue;case 6:return function(s,i){return Lt(s.bytesValue).isEqual(Lt(i.bytesValue))}(n,e);case 7:return n.referenceValue===e.referenceValue;case 8:return function(s,i){return ae(s.geoPointValue.latitude)===ae(i.geoPointValue.latitude)&&ae(s.geoPointValue.longitude)===ae(i.geoPointValue.longitude)}(n,e);case 2:return function(s,i){if("integerValue"in s&&"integerValue"in i)return ae(s.integerValue)===ae(i.integerValue);if("doubleValue"in s&&"doubleValue"in i){const a=ae(s.doubleValue),c=ae(i.doubleValue);return a===c?Es(a)===Es(c):isNaN(a)&&isNaN(c)}return!1}(n,e);case 9:return Cn(n.arrayValue.values||[],e.arrayValue.values||[],st);case 10:case 11:return function(s,i){const a=s.mapValue.fields||{},c=i.mapValue.fields||{};if(Zc(a)!==Zc(c))return!1;for(const l in a)if(a.hasOwnProperty(l)&&(c[l]===void 0||!st(a[l],c[l])))return!1;return!0}(n,e);default:return x(52216,{left:n})}}function Er(n,e){return(n.values||[]).find(t=>st(t,e))!==void 0}function Nn(n,e){if(n===e)return 0;const t=Mt(n),r=Mt(e);if(t!==r)return H(t,r);switch(t){case 0:case 9007199254740991:return 0;case 1:return H(n.booleanValue,e.booleanValue);case 2:return function(i,a){const c=ae(i.integerValue||i.doubleValue),l=ae(a.integerValue||a.doubleValue);return c<l?-1:c>l?1:c===l?0:isNaN(c)?isNaN(l)?0:-1:1}(n,e);case 3:return uu(n.timestampValue,e.timestampValue);case 4:return uu(_r(n),_r(e));case 5:return so(n.stringValue,e.stringValue);case 6:return function(i,a){const c=Lt(i),l=Lt(a);return c.compareTo(l)}(n.bytesValue,e.bytesValue);case 7:return function(i,a){const c=i.split("/"),l=a.split("/");for(let d=0;d<c.length&&d<l.length;d++){const f=H(c[d],l[d]);if(f!==0)return f}return H(c.length,l.length)}(n.referenceValue,e.referenceValue);case 8:return function(i,a){const c=H(ae(i.latitude),ae(a.latitude));return c!==0?c:H(ae(i.longitude),ae(a.longitude))}(n.geoPointValue,e.geoPointValue);case 9:return lu(n.arrayValue,e.arrayValue);case 10:return function(i,a){const c=i.fields||{},l=a.fields||{},d=c[Rs]?.arrayValue,f=l[Rs]?.arrayValue,m=H(d?.values?.length||0,f?.values?.length||0);return m!==0?m:lu(d,f)}(n.mapValue,e.mapValue);case 11:return function(i,a){if(i===As.mapValue&&a===As.mapValue)return 0;if(i===As.mapValue)return 1;if(a===As.mapValue)return-1;const c=i.fields||{},l=Object.keys(c),d=a.fields||{},f=Object.keys(d);l.sort(),f.sort();for(let m=0;m<l.length&&m<f.length;++m){const _=so(l[m],f[m]);if(_!==0)return _;const R=Nn(c[l[m]],d[f[m]]);if(R!==0)return R}return H(l.length,f.length)}(n.mapValue,e.mapValue);default:throw x(23264,{he:t})}}function uu(n,e){if(typeof n=="string"&&typeof e=="string"&&n.length===e.length)return H(n,e);const t=Vt(n),r=Vt(e),s=H(t.seconds,r.seconds);return s!==0?s:H(t.nanos,r.nanos)}function lu(n,e){const t=n.values||[],r=e.values||[];for(let s=0;s<t.length&&s<r.length;++s){const i=Nn(t[s],r[s]);if(i)return i}return H(t.length,r.length)}function Dn(n){return ao(n)}function ao(n){return"nullValue"in n?"null":"booleanValue"in n?""+n.booleanValue:"integerValue"in n?""+n.integerValue:"doubleValue"in n?""+n.doubleValue:"timestampValue"in n?function(t){const r=Vt(t);return`time(${r.seconds},${r.nanos})`}(n.timestampValue):"stringValue"in n?n.stringValue:"bytesValue"in n?function(t){return Lt(t).toBase64()}(n.bytesValue):"referenceValue"in n?function(t){return L.fromName(t).toString()}(n.referenceValue):"geoPointValue"in n?function(t){return`geo(${t.latitude},${t.longitude})`}(n.geoPointValue):"arrayValue"in n?function(t){let r="[",s=!0;for(const i of t.values||[])s?s=!1:r+=",",r+=ao(i);return r+"]"}(n.arrayValue):"mapValue"in n?function(t){const r=Object.keys(t.fields||{}).sort();let s="{",i=!0;for(const a of r)i?i=!1:s+=",",s+=`${a}:${ao(t.fields[a])}`;return s+"}"}(n.mapValue):x(61005,{value:n})}function bs(n){switch(Mt(n)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const e=Is(n);return e?16+bs(e):16;case 5:return 2*n.stringValue.length;case 6:return Lt(n.bytesValue).approximateByteSize();case 7:return n.referenceValue.length;case 9:return function(r){return(r.values||[]).reduce((s,i)=>s+bs(i),0)}(n.arrayValue);case 10:case 11:return function(r){let s=0;return Ot(r.fields,(i,a)=>{s+=i.length+bs(a)}),s}(n.mapValue);default:throw x(13486,{value:n})}}function Ps(n,e){return{referenceValue:`projects/${n.projectId}/databases/${n.database}/documents/${e.path.canonicalString()}`}}function co(n){return!!n&&"integerValue"in n}function uo(n){return!!n&&"arrayValue"in n}function hu(n){return!!n&&"nullValue"in n}function du(n){return!!n&&"doubleValue"in n&&isNaN(Number(n.doubleValue))}function Cs(n){return!!n&&"mapValue"in n}function Tg(n){return(n?.mapValue?.fields||{})[au]?.stringValue===cu}function Tr(n){if(n.geoPointValue)return{geoPointValue:{...n.geoPointValue}};if(n.timestampValue&&typeof n.timestampValue=="object")return{timestampValue:{...n.timestampValue}};if(n.mapValue){const e={mapValue:{fields:{}}};return Ot(n.mapValue.fields,(t,r)=>e.mapValue.fields[t]=Tr(r)),e}if(n.arrayValue){const e={arrayValue:{values:[]}};for(let t=0;t<(n.arrayValue.values||[]).length;++t)e.arrayValue.values[t]=Tr(n.arrayValue.values[t]);return e}return{...n}}function wg(n){return(((n.mapValue||{}).fields||{}).__type__||{}).stringValue===Eg}class Se{constructor(e){this.value=e}static empty(){return new Se({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(t=(t.mapValue.fields||{})[e.get(r)],!Cs(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Tr(t)}setAll(e){let t=Ee.emptyPath(),r={},s=[];e.forEach((a,c)=>{if(!t.isImmediateParentOf(c)){const l=this.getFieldsMap(t);this.applyChanges(l,r,s),r={},s=[],t=c.popLast()}a?r[c.lastSegment()]=Tr(a):s.push(c.lastSegment())});const i=this.getFieldsMap(t);this.applyChanges(i,r,s)}delete(e){const t=this.field(e.popLast());Cs(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return st(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let s=t.mapValue.fields[e.get(r)];Cs(s)&&s.mapValue.fields||(s={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=s),t=s}return t.mapValue.fields}applyChanges(e,t,r){Ot(t,(s,i)=>e[s]=i);for(const s of r)delete e[s]}clone(){return new Se(Tr(this.value))}}function fu(n){const e=[];return Ot(n.fields,(t,r)=>{const s=new Ee([t]);if(Cs(r)){const i=fu(r.mapValue).fields;if(i.length===0)e.push(s);else for(const a of i)e.push(s.child(a))}else e.push(s)}),new Fe(e)}class be{constructor(e,t,r,s,i,a,c){this.key=e,this.documentType=t,this.version=r,this.readTime=s,this.createTime=i,this.data=a,this.documentState=c}static newInvalidDocument(e){return new be(e,0,B.min(),B.min(),B.min(),Se.empty(),0)}static newFoundDocument(e,t,r,s){return new be(e,1,t,B.min(),r,s,0)}static newNoDocument(e,t){return new be(e,2,t,B.min(),B.min(),Se.empty(),0)}static newUnknownDocument(e,t){return new be(e,3,t,B.min(),B.min(),Se.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(B.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Se.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Se.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=B.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(e){return e instanceof be&&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 be(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}})`}}class On{constructor(e,t){this.position=e,this.inclusive=t}}function pu(n,e,t){let r=0;for(let s=0;s<n.position.length;s++){const i=e[s],a=n.position[s];if(i.field.isKeyField()?r=L.comparator(L.fromName(a.referenceValue),t.key):r=Nn(a,t.data.field(i.field)),i.dir==="desc"&&(r*=-1),r!==0)break}return r}function mu(n,e){if(n===null)return e===null;if(e===null||n.inclusive!==e.inclusive||n.position.length!==e.position.length)return!1;for(let t=0;t<n.position.length;t++)if(!st(n.position[t],e.position[t]))return!1;return!0}class wr{constructor(e,t="asc"){this.field=e,this.dir=t}}function Ig(n,e){return n.dir===e.dir&&n.field.isEqual(e.field)}class gu{}class le extends gu{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?t==="in"||t==="not-in"?this.createKeyFieldInFilter(e,t,r):new Ag(e,t,r):t==="array-contains"?new Pg(e,r):t==="in"?new Cg(e,r):t==="not-in"?new Sg(e,r):t==="array-contains-any"?new kg(e,r):new le(e,t,r)}static createKeyFieldInFilter(e,t,r){return t==="in"?new Rg(e,r):new bg(e,r)}matches(e){const t=e.data.field(this.field);return this.op==="!="?t!==null&&t.nullValue===void 0&&this.matchesComparison(Nn(t,this.value)):t!==null&&Mt(this.value)===Mt(t)&&this.matchesComparison(Nn(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return e===0;case"!=":return e!==0;case">":return e>0;case">=":return e>=0;default:return x(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class Ke extends gu{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new Ke(e,t)}matches(e){return _u(this)?this.filters.find(t=>!t.matches(e))===void 0:this.filters.find(t=>t.matches(e))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function _u(n){return n.op==="and"}function yu(n){return vg(n)&&_u(n)}function vg(n){for(const e of n.filters)if(e instanceof Ke)return!1;return!0}function lo(n){if(n instanceof le)return n.field.canonicalString()+n.op.toString()+Dn(n.value);if(yu(n))return n.filters.map(e=>lo(e)).join(",");{const e=n.filters.map(t=>lo(t)).join(",");return`${n.op}(${e})`}}function Eu(n,e){return n instanceof le?function(r,s){return s instanceof le&&r.op===s.op&&r.field.isEqual(s.field)&&st(r.value,s.value)}(n,e):n instanceof Ke?function(r,s){return s instanceof Ke&&r.op===s.op&&r.filters.length===s.filters.length?r.filters.reduce((i,a,c)=>i&&Eu(a,s.filters[c]),!0):!1}(n,e):void x(19439)}function Tu(n){return n instanceof le?function(t){return`${t.field.canonicalString()} ${t.op} ${Dn(t.value)}`}(n):n instanceof Ke?function(t){return t.op.toString()+" {"+t.getFilters().map(Tu).join(" ,")+"}"}(n):"Filter"}class Ag extends le{constructor(e,t,r){super(e,t,r),this.key=L.fromName(r.referenceValue)}matches(e){const t=L.comparator(e.key,this.key);return this.matchesComparison(t)}}class Rg extends le{constructor(e,t){super(e,"in",t),this.keys=wu("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class bg extends le{constructor(e,t){super(e,"not-in",t),this.keys=wu("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function wu(n,e){return(e.arrayValue?.values||[]).map(t=>L.fromName(t.referenceValue))}class Pg extends le{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return uo(t)&&Er(t.arrayValue,this.value)}}class Cg extends le{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return t!==null&&Er(this.value.arrayValue,t)}}class Sg extends le{constructor(e,t){super(e,"not-in",t)}matches(e){if(Er(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!Er(this.value.arrayValue,t)}}class kg extends le{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!uo(t)||!t.arrayValue.values)&&t.arrayValue.values.some(r=>Er(this.value.arrayValue,r))}}class Ng{constructor(e,t=null,r=[],s=[],i=null,a=null,c=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=s,this.limit=i,this.startAt=a,this.endAt=c,this.Te=null}}function Iu(n,e=null,t=[],r=[],s=null,i=null,a=null){return new Ng(n,e,t,r,s,i,a)}function ho(n){const e=F(n);if(e.Te===null){let t=e.path.canonicalString();e.collectionGroup!==null&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(r=>lo(r)).join(","),t+="|ob:",t+=e.orderBy.map(r=>function(i){return i.field.canonicalString()+i.dir}(r)).join(","),ys(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(r=>Dn(r)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(r=>Dn(r)).join(",")),e.Te=t}return e.Te}function fo(n,e){if(n.limit!==e.limit||n.orderBy.length!==e.orderBy.length)return!1;for(let t=0;t<n.orderBy.length;t++)if(!Ig(n.orderBy[t],e.orderBy[t]))return!1;if(n.filters.length!==e.filters.length)return!1;for(let t=0;t<n.filters.length;t++)if(!Eu(n.filters[t],e.filters[t]))return!1;return n.collectionGroup===e.collectionGroup&&!!n.path.isEqual(e.path)&&!!mu(n.startAt,e.startAt)&&mu(n.endAt,e.endAt)}function po(n){return L.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}class on{constructor(e,t=null,r=[],s=[],i=null,a="F",c=null,l=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=s,this.limit=i,this.limitType=a,this.startAt=c,this.endAt=l,this.Ie=null,this.Ee=null,this.Re=null,this.startAt,this.endAt}}function Dg(n,e,t,r,s,i,a,c){return new on(n,e,t,r,s,i,a,c)}function Ss(n){return new on(n)}function vu(n){return n.filters.length===0&&n.limit===null&&n.startAt==null&&n.endAt==null&&(n.explicitOrderBy.length===0||n.explicitOrderBy.length===1&&n.explicitOrderBy[0].field.isKeyField())}function Og(n){return L.isDocumentKey(n.path)&&n.collectionGroup===null&&n.filters.length===0}function mo(n){return n.collectionGroup!==null}function Vn(n){const e=F(n);if(e.Ie===null){e.Ie=[];const t=new Set;for(const i of e.explicitOrderBy)e.Ie.push(i),t.add(i.field.canonicalString());const r=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(function(a){let c=new fe(Ee.comparator);return a.filters.forEach(l=>{l.getFlattenedFilters().forEach(d=>{d.isInequality()&&(c=c.add(d.field))})}),c})(e).forEach(i=>{t.has(i.canonicalString())||i.isKeyField()||e.Ie.push(new wr(i,r))}),t.has(Ee.keyField().canonicalString())||e.Ie.push(new wr(Ee.keyField(),r))}return e.Ie}function it(n){const e=F(n);return e.Ee||(e.Ee=Au(e,Vn(n))),e.Ee}function Vg(n){const e=F(n);return e.Re||(e.Re=Au(e,n.explicitOrderBy)),e.Re}function Au(n,e){if(n.limitType==="F")return Iu(n.path,n.collectionGroup,e,n.filters,n.limit,n.startAt,n.endAt);{e=e.map(s=>{const i=s.dir==="desc"?"asc":"desc";return new wr(s.field,i)});const t=n.endAt?new On(n.endAt.position,n.endAt.inclusive):null,r=n.startAt?new On(n.startAt.position,n.startAt.inclusive):null;return Iu(n.path,n.collectionGroup,e,n.filters,n.limit,t,r)}}function go(n,e){const t=n.filters.concat([e]);return new on(n.path,n.collectionGroup,n.explicitOrderBy.slice(),t,n.limit,n.limitType,n.startAt,n.endAt)}function Lg(n,e){const t=n.explicitOrderBy.concat([e]);return new on(n.path,n.collectionGroup,t,n.filters.slice(),n.limit,n.limitType,n.startAt,n.endAt)}function ks(n,e,t){return new on(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),e,t,n.startAt,n.endAt)}function Mg(n,e){return new on(n.path,n.collectionGroup,n.explicitOrderBy.slice(),n.filters.slice(),n.limit,n.limitType,e,n.endAt)}function Ns(n,e){return fo(it(n),it(e))&&n.limitType===e.limitType}function Ru(n){return`${ho(it(n))}|lt:${n.limitType}`}function Ln(n){return`Query(target=${function(t){let r=t.path.canonicalString();return t.collectionGroup!==null&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map(s=>Tu(s)).join(", ")}]`),ys(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map(s=>function(a){return`${a.field.canonicalString()} (${a.dir})`}(s)).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map(s=>Dn(s)).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map(s=>Dn(s)).join(",")),`Target(${r})`}(it(n))}; limitType=${n.limitType})`}function Ds(n,e){return e.isFoundDocument()&&function(r,s){const i=s.key.path;return r.collectionGroup!==null?s.key.hasCollectionId(r.collectionGroup)&&r.path.isPrefixOf(i):L.isDocumentKey(r.path)?r.path.isEqual(i):r.path.isImmediateParentOf(i)}(n,e)&&function(r,s){for(const i of Vn(r))if(!i.field.isKeyField()&&s.data.field(i.field)===null)return!1;return!0}(n,e)&&function(r,s){for(const i of r.filters)if(!i.matches(s))return!1;return!0}(n,e)&&function(r,s){return!(r.startAt&&!function(a,c,l){const d=pu(a,c,l);return a.inclusive?d<=0:d<0}(r.startAt,Vn(r),s)||r.endAt&&!function(a,c,l){const d=pu(a,c,l);return a.inclusive?d>=0:d>0}(r.endAt,Vn(r),s))}(n,e)}function xg(n){return n.collectionGroup||(n.path.length%2==1?n.path.lastSegment():n.path.get(n.path.length-2))}function bu(n){return(e,t)=>{let r=!1;for(const s of Vn(n)){const i=Ug(s,e,t);if(i!==0)return i;r=r||s.field.isKeyField()}return 0}}function Ug(n,e,t){const r=n.field.isKeyField()?L.comparator(e.key,t.key):function(i,a,c){const l=a.data.field(i),d=c.data.field(i);return l!==null&&d!==null?Nn(l,d):x(42886)}(n.field,e,t);switch(n.dir){case"asc":return r;case"desc":return-1*r;default:return x(19790,{direction:n.dir})}}class an{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r!==void 0){for(const[s,i]of r)if(this.equalsFn(s,e))return i}}has(e){return this.get(e)!==void 0}set(e,t){const r=this.mapKeyFn(e),s=this.inner[r];if(s===void 0)return this.inner[r]=[[e,t]],void this.innerSize++;for(let i=0;i<s.length;i++)if(this.equalsFn(s[i][0],e))return void(s[i]=[e,t]);s.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),r=this.inner[t];if(r===void 0)return!1;for(let s=0;s<r.length;s++)if(this.equalsFn(r[s][0],e))return r.length===1?delete this.inner[t]:r.splice(s,1),this.innerSize--,!0;return!1}forEach(e){Ot(this.inner,(t,r)=>{for(const[s,i]of r)e(s,i)})}isEmpty(){return eu(this.inner)}size(){return this.innerSize}}const Fg=new se(L.comparator);function Tt(){return Fg}const Pu=new se(L.comparator);function Ir(...n){let e=Pu;for(const t of n)e=e.insert(t.key,t);return e}function Cu(n){let e=Pu;return n.forEach((t,r)=>e=e.insert(t,r.overlayedDocument)),e}function cn(){return vr()}function Su(){return vr()}function vr(){return new an(n=>n.toString(),(n,e)=>n.isEqual(e))}const Bg=new se(L.comparator),qg=new fe(L.comparator);function G(...n){let e=qg;for(const t of n)e=e.add(t);return e}const jg=new fe(H);function $g(){return jg}function _o(n,e){if(n.useProto3Json){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:Es(e)?"-0":e}}function ku(n){return{integerValue:""+n}}function zg(n,e){return dg(e)?ku(e):_o(n,e)}class Os{constructor(){this._=void 0}}function Wg(n,e,t){return n instanceof Vs?function(s,i){const a={fields:{[su]:{stringValue:ru},[ou]:{timestampValue:{seconds:s.seconds,nanos:s.nanoseconds}}}};return i&&ws(i)&&(i=Is(i)),i&&(a.fields[iu]=i),{mapValue:a}}(t,e):n instanceof Ar?Du(n,e):n instanceof Rr?Ou(n,e):function(s,i){const a=Nu(s,i),c=Vu(a)+Vu(s.Ae);return co(a)&&co(s.Ae)?ku(c):_o(s.serializer,c)}(n,e)}function Hg(n,e,t){return n instanceof Ar?Du(n,e):n instanceof Rr?Ou(n,e):t}function Nu(n,e){return n instanceof Ls?function(r){return co(r)||function(i){return!!i&&"doubleValue"in i}(r)}(e)?e:{integerValue:0}:null}class Vs extends Os{}class Ar extends Os{constructor(e){super(),this.elements=e}}function Du(n,e){const t=Lu(e);for(const r of n.elements)t.some(s=>st(s,r))||t.push(r);return{arrayValue:{values:t}}}class Rr extends Os{constructor(e){super(),this.elements=e}}function Ou(n,e){let t=Lu(e);for(const r of n.elements)t=t.filter(s=>!st(s,r));return{arrayValue:{values:t}}}class Ls extends Os{constructor(e,t){super(),this.serializer=e,this.Ae=t}}function Vu(n){return ae(n.integerValue||n.doubleValue)}function Lu(n){return uo(n)&&n.arrayValue.values?n.arrayValue.values.slice():[]}function Gg(n,e){return n.field.isEqual(e.field)&&function(r,s){return r instanceof Ar&&s instanceof Ar||r instanceof Rr&&s instanceof Rr?Cn(r.elements,s.elements,st):r instanceof Ls&&s instanceof Ls?st(r.Ae,s.Ae):r instanceof Vs&&s instanceof Vs}(n.transform,e.transform)}class Kg{constructor(e,t){this.version=e,this.transformResults=t}}class $e{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new $e}static exists(e){return new $e(void 0,e)}static updateTime(e){return new $e(e)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function Ms(n,e){return n.updateTime!==void 0?e.isFoundDocument()&&e.version.isEqual(n.updateTime):n.exists===void 0||n.exists===e.isFoundDocument()}class xs{}function Mu(n,e){if(!n.hasLocalMutations||e&&e.fields.length===0)return null;if(e===null)return n.isNoDocument()?new Us(n.key,$e.none()):new Pr(n.key,n.data,$e.none());{const t=n.data,r=Se.empty();let s=new fe(Ee.comparator);for(let i of e.fields)if(!s.has(i)){let a=t.field(i);a===null&&i.length>1&&(i=i.popLast(),a=t.field(i)),a===null?r.delete(i):r.set(i,a),s=s.add(i)}return new xt(n.key,r,new Fe(s.toArray()),$e.none())}}function Qg(n,e,t){n instanceof Pr?function(s,i,a){const c=s.value.clone(),l=Fu(s.fieldTransforms,i,a.transformResults);c.setAll(l),i.convertToFoundDocument(a.version,c).setHasCommittedMutations()}(n,e,t):n instanceof xt?function(s,i,a){if(!Ms(s.precondition,i))return void i.convertToUnknownDocument(a.version);const c=Fu(s.fieldTransforms,i,a.transformResults),l=i.data;l.setAll(Uu(s)),l.setAll(c),i.convertToFoundDocument(a.version,l).setHasCommittedMutations()}(n,e,t):function(s,i,a){i.convertToNoDocument(a.version).setHasCommittedMutations()}(0,e,t)}function br(n,e,t,r){return n instanceof Pr?function(i,a,c,l){if(!Ms(i.precondition,a))return c;const d=i.value.clone(),f=Bu(i.fieldTransforms,l,a);return d.setAll(f),a.convertToFoundDocument(a.version,d).setHasLocalMutations(),null}(n,e,t,r):n instanceof xt?function(i,a,c,l){if(!Ms(i.precondition,a))return c;const d=Bu(i.fieldTransforms,l,a),f=a.data;return f.setAll(Uu(i)),f.setAll(d),a.convertToFoundDocument(a.version,f).setHasLocalMutations(),c===null?null:c.unionWith(i.fieldMask.fields).unionWith(i.fieldTransforms.map(m=>m.field))}(n,e,t,r):function(i,a,c){return Ms(i.precondition,a)?(a.convertToNoDocument(a.version).setHasLocalMutations(),null):c}(n,e,t)}function Yg(n,e){let t=null;for(const r of n.fieldTransforms){const s=e.data.field(r.field),i=Nu(r.transform,s||null);i!=null&&(t===null&&(t=Se.empty()),t.set(r.field,i))}return t||null}function xu(n,e){return n.type===e.type&&!!n.key.isEqual(e.key)&&!!n.precondition.isEqual(e.precondition)&&!!function(r,s){return r===void 0&&s===void 0||!(!r||!s)&&Cn(r,s,(i,a)=>Gg(i,a))}(n.fieldTransforms,e.fieldTransforms)&&(n.type===0?n.value.isEqual(e.value):n.type!==1||n.data.isEqual(e.data)&&n.fieldMask.isEqual(e.fieldMask))}class Pr extends xs{constructor(e,t,r,s=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=s,this.type=0}getFieldMask(){return null}}class xt extends xs{constructor(e,t,r,s,i=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=s,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function Uu(n){const e=new Map;return n.fieldMask.fields.forEach(t=>{if(!t.isEmpty()){const r=n.data.field(t);e.set(t,r)}}),e}function Fu(n,e,t){const r=new Map;J(n.length===t.length,32656,{Ve:t.length,de:n.length});for(let s=0;s<t.length;s++){const i=n[s],a=i.transform,c=e.data.field(i.field);r.set(i.field,Hg(a,c,t[s]))}return r}function Bu(n,e,t){const r=new Map;for(const s of n){const i=s.transform,a=t.data.field(s.field);r.set(s.field,Wg(i,a,e))}return r}class Us extends xs{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class Jg extends xs{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class Xg{constructor(e,t,r,s){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=s}applyToRemoteDocument(e,t){const r=t.mutationResults;for(let s=0;s<this.mutations.length;s++){const i=this.mutations[s];i.key.isEqual(e.key)&&Qg(i,e,r[s])}}applyToLocalView(e,t){for(const r of this.baseMutations)r.key.isEqual(e.key)&&(t=br(r,e,t,this.localWriteTime));for(const r of this.mutations)r.key.isEqual(e.key)&&(t=br(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const r=Su();return this.mutations.forEach(s=>{const i=e.get(s.key),a=i.overlayedDocument;let c=this.applyToLocalView(a,i.mutatedFields);c=t.has(s.key)?null:c;const l=Mu(a,c);l!==null&&r.set(s.key,l),a.isValidDocument()||a.convertToNoDocument(B.min())}),r}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),G())}isEqual(e){return this.batchId===e.batchId&&Cn(this.mutations,e.mutations,(t,r)=>xu(t,r))&&Cn(this.baseMutations,e.baseMutations,(t,r)=>xu(t,r))}}class yo{constructor(e,t,r,s){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=s}static from(e,t,r){J(e.mutations.length===r.length,58842,{me:e.mutations.length,fe:r.length});let s=function(){return Bg}();const i=e.mutations;for(let a=0;a<i.length;a++)s=s.insert(i[a].key,r[a].version);return new yo(e,t,r,s)}}class Zg{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}`}}class e_{constructor(e,t,r){this.alias=e,this.aggregateType=t,this.fieldPath=r}}class t_{constructor(e,t){this.count=e,this.unchangedNames=t}}var he,K;function n_(n){switch(n){case P.OK:return x(64938);case P.CANCELLED:case P.UNKNOWN:case P.DEADLINE_EXCEEDED:case P.RESOURCE_EXHAUSTED:case P.INTERNAL:case P.UNAVAILABLE:case P.UNAUTHENTICATED:return!1;case P.INVALID_ARGUMENT:case P.NOT_FOUND:case P.ALREADY_EXISTS:case P.PERMISSION_DENIED:case P.FAILED_PRECONDITION:case P.ABORTED:case P.OUT_OF_RANGE:case P.UNIMPLEMENTED:case P.DATA_LOSS:return!0;default:return x(15467,{code:n})}}function qu(n){if(n===void 0)return Et("GRPC error has no .code"),P.UNKNOWN;switch(n){case he.OK:return P.OK;case he.CANCELLED:return P.CANCELLED;case he.UNKNOWN:return P.UNKNOWN;case he.DEADLINE_EXCEEDED:return P.DEADLINE_EXCEEDED;case he.RESOURCE_EXHAUSTED:return P.RESOURCE_EXHAUSTED;case he.INTERNAL:return P.INTERNAL;case he.UNAVAILABLE:return P.UNAVAILABLE;case he.UNAUTHENTICATED:return P.UNAUTHENTICATED;case he.INVALID_ARGUMENT:return P.INVALID_ARGUMENT;case he.NOT_FOUND:return P.NOT_FOUND;case he.ALREADY_EXISTS:return P.ALREADY_EXISTS;case he.PERMISSION_DENIED:return P.PERMISSION_DENIED;case he.FAILED_PRECONDITION:return P.FAILED_PRECONDITION;case he.ABORTED:return P.ABORTED;case he.OUT_OF_RANGE:return P.OUT_OF_RANGE;case he.UNIMPLEMENTED:return P.UNIMPLEMENTED;case he.DATA_LOSS:return P.DATA_LOSS;default:return x(39323,{code:n})}}(K=he||(he={}))[K.OK=0]="OK",K[K.CANCELLED=1]="CANCELLED",K[K.UNKNOWN=2]="UNKNOWN",K[K.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",K[K.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",K[K.NOT_FOUND=5]="NOT_FOUND",K[K.ALREADY_EXISTS=6]="ALREADY_EXISTS",K[K.PERMISSION_DENIED=7]="PERMISSION_DENIED",K[K.UNAUTHENTICATED=16]="UNAUTHENTICATED",K[K.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",K[K.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",K[K.ABORTED=10]="ABORTED",K[K.OUT_OF_RANGE=11]="OUT_OF_RANGE",K[K.UNIMPLEMENTED=12]="UNIMPLEMENTED",K[K.INTERNAL=13]="INTERNAL",K[K.UNAVAILABLE=14]="UNAVAILABLE",K[K.DATA_LOSS=15]="DATA_LOSS";function r_(){return new TextEncoder}const s_=new Nt([4294967295,4294967295],0);function ju(n){const e=r_().encode(n),t=new Lc;return t.update(e),new Uint8Array(t.digest())}function $u(n){const e=new DataView(n.buffer),t=e.getUint32(0,!0),r=e.getUint32(4,!0),s=e.getUint32(8,!0),i=e.getUint32(12,!0);return[new Nt([t,r],0),new Nt([s,i],0)]}class Eo{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new Cr(`Invalid padding: ${t}`);if(r<0)throw new Cr(`Invalid hash count: ${r}`);if(e.length>0&&this.hashCount===0)throw new Cr(`Invalid hash count: ${r}`);if(e.length===0&&t!==0)throw new Cr(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=Nt.fromNumber(this.ge)}ye(e,t,r){let s=e.add(t.multiply(Nt.fromNumber(r)));return s.compare(s_)===1&&(s=new Nt([s.getBits(0),s.getBits(1)],0)),s.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.ge===0)return!1;const t=ju(e),[r,s]=$u(t);for(let i=0;i<this.hashCount;i++){const a=this.ye(r,s,i);if(!this.we(a))return!1}return!0}static create(e,t,r){const s=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),a=new Eo(i,s,t);return r.forEach(c=>a.insert(c)),a}insert(e){if(this.ge===0)return;const t=ju(e),[r,s]=$u(t);for(let i=0;i<this.hashCount;i++){const a=this.ye(r,s,i);this.be(a)}}be(e){const t=Math.floor(e/8),r=e%8;this.bitmap[t]|=1<<r}}class Cr extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class Fs{constructor(e,t,r,s,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=s,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,r){const s=new Map;return s.set(e,Sr.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new Fs(B.min(),s,new se(H),Tt(),G())}}class Sr{constructor(e,t,r,s,i){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=s,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new Sr(r,t,G(),G(),G())}}class Bs{constructor(e,t,r,s){this.Se=e,this.removedTargetIds=t,this.key=r,this.De=s}}class zu{constructor(e,t){this.targetId=e,this.Ce=t}}class Wu{constructor(e,t,r=we.EMPTY_BYTE_STRING,s=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=s}}class Hu{constructor(){this.ve=0,this.Fe=Gu(),this.Me=we.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return this.ve!==0}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=G(),t=G(),r=G();return this.Fe.forEach((s,i)=>{switch(i){case 0:e=e.add(s);break;case 2:t=t.add(s);break;case 1:r=r.add(s);break;default:x(38017,{changeType:i})}}),new Sr(this.Me,this.xe,e,t,r)}Ke(){this.Oe=!1,this.Fe=Gu()}qe(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}Ue(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}$e(){this.ve+=1}We(){this.ve-=1,J(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}}class i_{constructor(e){this.Ge=e,this.ze=new Map,this.je=Tt(),this.He=qs(),this.Je=qs(),this.Ze=new se(H)}Xe(e){for(const t of e.Se)e.De&&e.De.isFoundDocument()?this.Ye(t,e.De):this.et(t,e.key,e.De);for(const t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,t=>{const r=this.nt(t);switch(e.state){case 0:this.rt(t)&&r.Le(e.resumeToken);break;case 1:r.We(),r.Ne||r.Ke(),r.Le(e.resumeToken);break;case 2:r.We(),r.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(r.Qe(),r.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),r.Le(e.resumeToken));break;default:x(56790,{state:e.state})}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach((r,s)=>{this.rt(s)&&t(s)})}st(e){const t=e.targetId,r=e.Ce.count,s=this.ot(t);if(s){const i=s.target;if(po(i))if(r===0){const a=new L(i.path);this.et(t,a,be.newNoDocument(a,B.min()))}else J(r===1,20013,{expectedCount:r});else{const a=this._t(t);if(a!==r){const c=this.ut(e),l=c?this.ct(c,e,a):1;if(l!==0){this.it(t);const d=l===2?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.Ze=this.Ze.insert(t,d)}}}}}ut(e){const t=e.Ce.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:r="",padding:s=0},hashCount:i=0}=t;let a,c;try{a=Lt(r).toUint8Array()}catch(l){if(l instanceof nu)return sn("Decoding the base64 bloom filter in existence filter failed ("+l.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw l}try{c=new Eo(a,s,i)}catch(l){return sn(l instanceof Cr?"BloomFilter error: ":"Applying bloom filter failed: ",l),null}return c.ge===0?null:c}ct(e,t,r){return t.Ce.count===r-this.Pt(e,t.targetId)?0:2}Pt(e,t){const r=this.Ge.getRemoteKeysForTarget(t);let s=0;return r.forEach(i=>{const a=this.Ge.ht(),c=`projects/${a.projectId}/databases/${a.database}/documents/${i.path.canonicalString()}`;e.mightContain(c)||(this.et(t,i,null),s++)}),s}Tt(e){const t=new Map;this.ze.forEach((i,a)=>{const c=this.ot(a);if(c){if(i.current&&po(c.target)){const l=new L(c.target.path);this.It(l).has(a)||this.Et(a,l)||this.et(a,l,be.newNoDocument(l,e))}i.Be&&(t.set(a,i.ke()),i.Ke())}});let r=G();this.Je.forEach((i,a)=>{let c=!0;a.forEachWhile(l=>{const d=this.ot(l);return!d||d.purpose==="TargetPurposeLimboResolution"||(c=!1,!1)}),c&&(r=r.add(i))}),this.je.forEach((i,a)=>a.setReadTime(e));const s=new Fs(e,t,this.Ze,this.je,r);return this.je=Tt(),this.He=qs(),this.Je=qs(),this.Ze=new se(H),s}Ye(e,t){if(!this.rt(e))return;const r=this.Et(e,t.key)?2:0;this.nt(e).qe(t.key,r),this.je=this.je.insert(t.key,t),this.He=this.He.insert(t.key,this.It(t.key).add(e)),this.Je=this.Je.insert(t.key,this.Rt(t.key).add(e))}et(e,t,r){if(!this.rt(e))return;const s=this.nt(e);this.Et(e,t)?s.qe(t,1):s.Ue(t),this.Je=this.Je.insert(t,this.Rt(t).delete(e)),this.Je=this.Je.insert(t,this.Rt(t).add(e)),r&&(this.je=this.je.insert(t,r))}removeTarget(e){this.ze.delete(e)}_t(e){const t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.nt(e).$e()}nt(e){let t=this.ze.get(e);return t||(t=new Hu,this.ze.set(e,t)),t}Rt(e){let t=this.Je.get(e);return t||(t=new fe(H),this.Je=this.Je.insert(e,t)),t}It(e){let t=this.He.get(e);return t||(t=new fe(H),this.He=this.He.insert(e,t)),t}rt(e){const t=this.ot(e)!==null;return t||V("WatchChangeAggregator","Detected inactive target",e),t}ot(e){const t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new Hu),this.Ge.getRemoteKeysForTarget(e).forEach(t=>{this.et(e,t,null)})}Et(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function qs(){return new se(L.comparator)}function Gu(){return new se(L.comparator)}const o_={asc:"ASCENDING",desc:"DESCENDING"},a_={"<":"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"},c_={and:"AND",or:"OR"};class u_{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function To(n,e){return n.useProto3Json||ys(e)?e:{value:e}}function js(n,e){return n.useProto3Json?`${new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+e.nanoseconds).slice(-9)}Z`:{seconds:""+e.seconds,nanos:e.nanoseconds}}function Ku(n,e){return n.useProto3Json?e.toBase64():e.toUint8Array()}function l_(n,e){return js(n,e.toTimestamp())}function ot(n){return J(!!n,49232),B.fromTimestamp(function(t){const r=Vt(t);return new ee(r.seconds,r.nanos)}(n))}function wo(n,e){return Io(n,e).canonicalString()}function Io(n,e){const t=function(s){return new X(["projects",s.projectId,"databases",s.database])}(n).child("documents");return e===void 0?t:t.child(e)}function Qu(n){const e=X.fromString(n);return J(nl(e),10190,{key:e.toString()}),e}function vo(n,e){return wo(n.databaseId,e.path)}function Ao(n,e){const t=Qu(e);if(t.get(1)!==n.databaseId.projectId)throw new D(P.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+t.get(1)+" vs "+n.databaseId.projectId);if(t.get(3)!==n.databaseId.database)throw new D(P.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+t.get(3)+" vs "+n.databaseId.database);return new L(Ju(t))}function Yu(n,e){return wo(n.databaseId,e)}function h_(n){const e=Qu(n);return e.length===4?X.emptyPath():Ju(e)}function Ro(n){return new X(["projects",n.databaseId.projectId,"databases",n.databaseId.database]).canonicalString()}function Ju(n){return J(n.length>4&&n.get(4)==="documents",29091,{key:n.toString()}),n.popFirst(5)}function Xu(n,e,t){return{name:vo(n,e),fields:t.value.mapValue.fields}}function d_(n,e){let t;if("targetChange"in e){e.targetChange;const r=function(d){return d==="NO_CHANGE"?0:d==="ADD"?1:d==="REMOVE"?2:d==="CURRENT"?3:d==="RESET"?4:x(39313,{state:d})}(e.targetChange.targetChangeType||"NO_CHANGE"),s=e.targetChange.targetIds||[],i=function(d,f){return d.useProto3Json?(J(f===void 0||typeof f=="string",58123),we.fromBase64String(f||"")):(J(f===void 0||f instanceof Buffer||f instanceof Uint8Array,16193),we.fromUint8Array(f||new Uint8Array))}(n,e.targetChange.resumeToken),a=e.targetChange.cause,c=a&&function(d){const f=d.code===void 0?P.UNKNOWN:qu(d.code);return new D(f,d.message||"")}(a);t=new Wu(r,s,i,c||null)}else if("documentChange"in e){e.documentChange;const r=e.documentChange;r.document,r.document.name,r.document.updateTime;const s=Ao(n,r.document.name),i=ot(r.document.updateTime),a=r.document.createTime?ot(r.document.createTime):B.min(),c=new Se({mapValue:{fields:r.document.fields}}),l=be.newFoundDocument(s,i,a,c),d=r.targetIds||[],f=r.removedTargetIds||[];t=new Bs(d,f,l.key,l)}else if("documentDelete"in e){e.documentDelete;const r=e.documentDelete;r.document;const s=Ao(n,r.document),i=r.readTime?ot(r.readTime):B.min(),a=be.newNoDocument(s,i),c=r.removedTargetIds||[];t=new Bs([],c,a.key,a)}else if("documentRemove"in e){e.documentRemove;const r=e.documentRemove;r.document;const s=Ao(n,r.document),i=r.removedTargetIds||[];t=new Bs([],i,s,null)}else{if(!("filter"in e))return x(11601,{Vt:e});{e.filter;const r=e.filter;r.targetId;const{count:s=0,unchangedNames:i}=r,a=new t_(s,i),c=r.targetId;t=new zu(c,a)}}return t}function f_(n,e){let t;if(e instanceof Pr)t={update:Xu(n,e.key,e.value)};else if(e instanceof Us)t={delete:vo(n,e.key)};else if(e instanceof xt)t={update:Xu(n,e.key,e.data),updateMask:I_(e.fieldMask)};else{if(!(e instanceof Jg))return x(16599,{dt:e.type});t={verify:vo(n,e.key)}}return e.fieldTransforms.length>0&&(t.updateTransforms=e.fieldTransforms.map(r=>function(i,a){const c=a.transform;if(c instanceof Vs)return{fieldPath:a.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(c instanceof Ar)return{fieldPath:a.field.canonicalString(),appendMissingElements:{values:c.elements}};if(c instanceof Rr)return{fieldPath:a.field.canonicalString(),removeAllFromArray:{values:c.elements}};if(c instanceof Ls)return{fieldPath:a.field.canonicalString(),increment:c.Ae};throw x(20930,{transform:a.transform})}(0,r))),e.precondition.isNone||(t.currentDocument=function(s,i){return i.updateTime!==void 0?{updateTime:l_(s,i.updateTime)}:i.exists!==void 0?{exists:i.exists}:x(27497)}(n,e.precondition)),t}function p_(n,e){return n&&n.length>0?(J(e!==void 0,14353),n.map(t=>function(s,i){let a=s.updateTime?ot(s.updateTime):ot(i);return a.isEqual(B.min())&&(a=ot(i)),new Kg(a,s.transformResults||[])}(t,e))):[]}function m_(n,e){return{documents:[Yu(n,e.path)]}}function Zu(n,e){const t={structuredQuery:{}},r=e.path;let s;e.collectionGroup!==null?(s=r,t.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(s=r.popLast(),t.structuredQuery.from=[{collectionId:r.lastSegment()}]),t.parent=Yu(n,s);const i=function(d){if(d.length!==0)return tl(Ke.create(d,"and"))}(e.filters);i&&(t.structuredQuery.where=i);const a=function(d){if(d.length!==0)return d.map(f=>function(_){return{field:Ut(_.field),direction:E_(_.dir)}}(f))}(e.orderBy);a&&(t.structuredQuery.orderBy=a);const c=To(n,e.limit);return c!==null&&(t.structuredQuery.limit=c),e.startAt&&(t.structuredQuery.startAt=function(d){return{before:d.inclusive,values:d.position}}(e.startAt)),e.endAt&&(t.structuredQuery.endAt=function(d){return{before:!d.inclusive,values:d.position}}(e.endAt)),{ft:t,parent:s}}function g_(n,e,t,r){const{ft:s,parent:i}=Zu(n,e),a={},c=[];let l=0;return t.forEach(d=>{const f="aggregate_"+l++;a[f]=d.alias,d.aggregateType==="count"?c.push({alias:f,count:{}}):d.aggregateType==="avg"?c.push({alias:f,avg:{field:Ut(d.fieldPath)}}):d.aggregateType==="sum"&&c.push({alias:f,sum:{field:Ut(d.fieldPath)}})}),{request:{structuredAggregationQuery:{aggregations:c,structuredQuery:s.structuredQuery},parent:s.parent},gt:a,parent:i}}function __(n){let e=h_(n.parent);const t=n.structuredQuery,r=t.from?t.from.length:0;let s=null;if(r>0){J(r===1,65062);const f=t.from[0];f.allDescendants?s=f.collectionId:e=e.child(f.collectionId)}let i=[];t.where&&(i=function(m){const _=el(m);return _ instanceof Ke&&yu(_)?_.getFilters():[_]}(t.where));let a=[];t.orderBy&&(a=function(m){return m.map(_=>function(S){return new wr(Mn(S.field),function(k){switch(k){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(S.direction))}(_))}(t.orderBy));let c=null;t.limit&&(c=function(m){let _;return _=typeof m=="object"?m.value:m,ys(_)?null:_}(t.limit));let l=null;t.startAt&&(l=function(m){const _=!!m.before,R=m.values||[];return new On(R,_)}(t.startAt));let d=null;return t.endAt&&(d=function(m){const _=!m.before,R=m.values||[];return new On(R,_)}(t.endAt)),Dg(e,s,a,i,c,"F",l,d)}function y_(n,e){const t=function(s){switch(s){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return x(28987,{purpose:s})}}(e.purpose);return t==null?null:{"goog-listen-tags":t}}function el(n){return n.unaryFilter!==void 0?function(t){switch(t.unaryFilter.op){case"IS_NAN":const r=Mn(t.unaryFilter.field);return le.create(r,"==",{doubleValue:NaN});case"IS_NULL":const s=Mn(t.unaryFilter.field);return le.create(s,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const i=Mn(t.unaryFilter.field);return le.create(i,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const a=Mn(t.unaryFilter.field);return le.create(a,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return x(61313);default:return x(60726)}}(n):n.fieldFilter!==void 0?function(t){return le.create(Mn(t.fieldFilter.field),function(s){switch(s){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return x(58110);default:return x(50506)}}(t.fieldFilter.op),t.fieldFilter.value)}(n):n.compositeFilter!==void 0?function(t){return Ke.create(t.compositeFilter.filters.map(r=>el(r)),function(s){switch(s){case"AND":return"and";case"OR":return"or";default:return x(1026)}}(t.compositeFilter.op))}(n):x(30097,{filter:n})}function E_(n){return o_[n]}function T_(n){return a_[n]}function w_(n){return c_[n]}function Ut(n){return{fieldPath:n.canonicalString()}}function Mn(n){return Ee.fromServerFormat(n.fieldPath)}function tl(n){return n instanceof le?function(t){if(t.op==="=="){if(du(t.value))return{unaryFilter:{field:Ut(t.field),op:"IS_NAN"}};if(hu(t.value))return{unaryFilter:{field:Ut(t.field),op:"IS_NULL"}}}else if(t.op==="!="){if(du(t.value))return{unaryFilter:{field:Ut(t.field),op:"IS_NOT_NAN"}};if(hu(t.value))return{unaryFilter:{field:Ut(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Ut(t.field),op:T_(t.op),value:t.value}}}(n):n instanceof Ke?function(t){const r=t.getFilters().map(s=>tl(s));return r.length===1?r[0]:{compositeFilter:{op:w_(t.op),filters:r}}}(n):x(54877,{filter:n})}function I_(n){const e=[];return n.fields.forEach(t=>e.push(t.canonicalString())),{fieldPaths:e}}function nl(n){return n.length>=4&&n.get(0)==="projects"&&n.get(2)==="databases"}function rl(n){return!!n&&typeof n._toProto=="function"&&n._protoValueType==="ProtoValue"}class Ft{constructor(e,t,r,s,i=B.min(),a=B.min(),c=we.EMPTY_BYTE_STRING,l=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=s,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=c,this.expectedCount=l}withSequenceNumber(e){return new Ft(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new Ft(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new Ft(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new Ft(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class v_{constructor(e){this.yt=e}}function A_(n){const e=__({parent:n.parent,structuredQuery:n.structuredQuery});return n.limitType==="LAST"?ks(e,e.limit,"L"):e}class R_{constructor(){this.Sn=new b_}addToCollectionParentIndex(e,t){return this.Sn.add(t),C.resolve()}getCollectionParents(e,t){return C.resolve(this.Sn.getEntries(t))}addFieldIndex(e,t){return C.resolve()}deleteFieldIndex(e,t){return C.resolve()}deleteAllFieldIndexes(e){return C.resolve()}createTargetIndexes(e,t){return C.resolve()}getDocumentsMatchingTarget(e,t){return C.resolve(null)}getIndexType(e,t){return C.resolve(0)}getFieldIndexes(e,t){return C.resolve([])}getNextCollectionGroupToUpdate(e){return C.resolve(null)}getMinOffset(e,t){return C.resolve(Dt.min())}getMinOffsetFromCollectionGroup(e,t){return C.resolve(Dt.min())}updateCollectionGroup(e,t,r){return C.resolve()}updateIndexEntries(e,t){return C.resolve()}}class b_{constructor(){this.index={}}add(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t]||new fe(X.comparator),i=!s.has(r);return this.index[t]=s.add(r),i}has(e){const t=e.lastSegment(),r=e.popLast(),s=this.index[t];return s&&s.has(r)}getEntries(e){return(this.index[e]||new fe(X.comparator)).toArray()}}const sl={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},il=41943040;class Oe{static withCacheSize(e){return new Oe(e,Oe.DEFAULT_COLLECTION_PERCENTILE,Oe.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}Oe.DEFAULT_COLLECTION_PERCENTILE=10,Oe.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Oe.DEFAULT=new Oe(il,Oe.DEFAULT_COLLECTION_PERCENTILE,Oe.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Oe.DISABLED=new Oe(-1,0,0);class xn{constructor(e){this.sr=e}next(){return this.sr+=2,this.sr}static _r(){return new xn(0)}static ar(){return new xn(-1)}}const ol="LruGarbageCollector",P_=1048576;function al([n,e],[t,r]){const s=H(n,t);return s===0?H(e,r):s}class C_{constructor(e){this.Pr=e,this.buffer=new fe(al),this.Tr=0}Ir(){return++this.Tr}Er(e){const t=[e,this.Ir()];if(this.buffer.size<this.Pr)this.buffer=this.buffer.add(t);else{const r=this.buffer.last();al(t,r)<0&&(this.buffer=this.buffer.delete(r).add(t))}}get maxValue(){return this.buffer.last()[0]}}class S_{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Rr=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Ar(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return this.Rr!==null}Ar(e){V(ol,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(t){kn(t)?V(ol,"Ignoring IndexedDB error during garbage collection: ",t):await Sn(t)}await this.Ar(3e5)})}}class k_{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.dr(e).next(r=>Math.floor(t/100*r))}nthSequenceNumber(e,t){if(t===0)return C.resolve(_s.ce);const r=new C_(t);return this.Vr.forEachTarget(e,s=>r.Er(s.sequenceNumber)).next(()=>this.Vr.mr(e,s=>r.Er(s))).next(()=>r.maxValue)}removeTargets(e,t,r){return this.Vr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(V("LruGarbageCollector","Garbage collection skipped; disabled"),C.resolve(sl)):this.getCacheSize(e).next(r=>r<this.params.cacheSizeCollectionThreshold?(V("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),sl):this.gr(e,t))}getCacheSize(e){return this.Vr.getCacheSize(e)}gr(e,t){let r,s,i,a,c,l,d;const f=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(m=>(m>this.params.maximumSequenceNumbersToCollect?(V("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${m}`),s=this.params.maximumSequenceNumbersToCollect):s=m,a=Date.now(),this.nthSequenceNumber(e,s))).next(m=>(r=m,c=Date.now(),this.removeTargets(e,r,t))).next(m=>(i=m,l=Date.now(),this.removeOrphanedDocuments(e,r))).next(m=>(d=Date.now(),Pn()<=W.DEBUG&&V("LruGarbageCollector",`LRU Garbage Collection
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
Removed ${i} targets in `+(l-c)+`ms
|
|
30
|
-
Removed ${m} documents in `+(d-l)+`ms
|
|
31
|
-
Total Duration: ${d-f}ms`),C.resolve({didRun:!0,sequenceNumbersCollected:s,targetsRemoved:i,documentsRemoved:m})))}}function N_(n,e){return new k_(n,e)}class D_{constructor(){this.changes=new an(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,be.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const r=this.changes.get(t);return r!==void 0?C.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class O_{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class V_{constructor(e,t,r,s){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=s}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next(s=>(r=s,this.remoteDocumentCache.getEntry(e,t))).next(s=>(r!==null&&br(r.mutation,s,Fe.empty(),ee.now()),s))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(r=>this.getLocalViewOfDocuments(e,r,G()).next(()=>r))}getLocalViewOfDocuments(e,t,r=G()){const s=cn();return this.populateOverlays(e,s,t).next(()=>this.computeViews(e,t,s,r).next(i=>{let a=Ir();return i.forEach((c,l)=>{a=a.insert(c,l.overlayedDocument)}),a}))}getOverlayedDocuments(e,t){const r=cn();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,G()))}populateOverlays(e,t,r){const s=[];return r.forEach(i=>{t.has(i)||s.push(i)}),this.documentOverlayCache.getOverlays(e,s).next(i=>{i.forEach((a,c)=>{t.set(a,c)})})}computeViews(e,t,r,s){let i=Tt();const a=vr(),c=function(){return vr()}();return t.forEach((l,d)=>{const f=r.get(d.key);s.has(d.key)&&(f===void 0||f.mutation instanceof xt)?i=i.insert(d.key,d):f!==void 0?(a.set(d.key,f.mutation.getFieldMask()),br(f.mutation,d,f.mutation.getFieldMask(),ee.now())):a.set(d.key,Fe.empty())}),this.recalculateAndSaveOverlays(e,i).next(l=>(l.forEach((d,f)=>a.set(d,f)),t.forEach((d,f)=>c.set(d,new O_(f,a.get(d)??null))),c))}recalculateAndSaveOverlays(e,t){const r=vr();let s=new se((a,c)=>a-c),i=G();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(a=>{for(const c of a)c.keys().forEach(l=>{const d=t.get(l);if(d===null)return;let f=r.get(l)||Fe.empty();f=c.applyToLocalView(d,f),r.set(l,f);const m=(s.get(c.batchId)||G()).add(l);s=s.insert(c.batchId,m)})}).next(()=>{const a=[],c=s.getReverseIterator();for(;c.hasNext();){const l=c.getNext(),d=l.key,f=l.value,m=Su();f.forEach(_=>{if(!i.has(_)){const R=Mu(t.get(_),r.get(_));R!==null&&m.set(_,R),i=i.add(_)}}),a.push(this.documentOverlayCache.saveOverlays(e,d,m))}return C.waitFor(a)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(r=>this.recalculateAndSaveOverlays(e,r))}getDocumentsMatchingQuery(e,t,r,s){return Og(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):mo(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,s):this.getDocumentsMatchingCollectionQuery(e,t,r,s)}getNextDocuments(e,t,r,s){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,s).next(i=>{const a=s-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,s-i.size):C.resolve(cn());let c=gr,l=i;return a.next(d=>C.forEach(d,(f,m)=>(c<m.largestBatchId&&(c=m.largestBatchId),i.get(f)?C.resolve():this.remoteDocumentCache.getEntry(e,f).next(_=>{l=l.insert(f,_)}))).next(()=>this.populateOverlays(e,d,i)).next(()=>this.computeViews(e,l,d,G())).next(f=>({batchId:c,changes:Cu(f)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new L(t)).next(r=>{let s=Ir();return r.isFoundDocument()&&(s=s.insert(r.key,r)),s})}getDocumentsMatchingCollectionGroupQuery(e,t,r,s){const i=t.collectionGroup;let a=Ir();return this.indexManager.getCollectionParents(e,i).next(c=>C.forEach(c,l=>{const d=function(m,_){return new on(_,null,m.explicitOrderBy.slice(),m.filters.slice(),m.limit,m.limitType,m.startAt,m.endAt)}(t,l.child(i));return this.getDocumentsMatchingCollectionQuery(e,d,r,s).next(f=>{f.forEach((m,_)=>{a=a.insert(m,_)})})}).next(()=>a))}getDocumentsMatchingCollectionQuery(e,t,r,s){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next(a=>(i=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,i,s))).next(a=>{i.forEach((l,d)=>{const f=d.getKey();a.get(f)===null&&(a=a.insert(f,be.newInvalidDocument(f)))});let c=Ir();return a.forEach((l,d)=>{const f=i.get(l);f!==void 0&&br(f.mutation,d,Fe.empty(),ee.now()),Ds(t,d)&&(c=c.insert(l,d))}),c})}}class L_{constructor(e){this.serializer=e,this.Nr=new Map,this.Br=new Map}getBundleMetadata(e,t){return C.resolve(this.Nr.get(t))}saveBundleMetadata(e,t){return this.Nr.set(t.id,function(s){return{id:s.id,version:s.version,createTime:ot(s.createTime)}}(t)),C.resolve()}getNamedQuery(e,t){return C.resolve(this.Br.get(t))}saveNamedQuery(e,t){return this.Br.set(t.name,function(s){return{name:s.name,query:A_(s.bundledQuery),readTime:ot(s.readTime)}}(t)),C.resolve()}}class M_{constructor(){this.overlays=new se(L.comparator),this.Lr=new Map}getOverlay(e,t){return C.resolve(this.overlays.get(t))}getOverlays(e,t){const r=cn();return C.forEach(t,s=>this.getOverlay(e,s).next(i=>{i!==null&&r.set(s,i)})).next(()=>r)}saveOverlays(e,t,r){return r.forEach((s,i)=>{this.bt(e,t,i)}),C.resolve()}removeOverlaysForBatchId(e,t,r){const s=this.Lr.get(r);return s!==void 0&&(s.forEach(i=>this.overlays=this.overlays.remove(i)),this.Lr.delete(r)),C.resolve()}getOverlaysForCollection(e,t,r){const s=cn(),i=t.length+1,a=new L(t.child("")),c=this.overlays.getIteratorFrom(a);for(;c.hasNext();){const l=c.getNext().value,d=l.getKey();if(!t.isPrefixOf(d.path))break;d.path.length===i&&l.largestBatchId>r&&s.set(l.getKey(),l)}return C.resolve(s)}getOverlaysForCollectionGroup(e,t,r,s){let i=new se((d,f)=>d-f);const a=this.overlays.getIterator();for(;a.hasNext();){const d=a.getNext().value;if(d.getKey().getCollectionGroup()===t&&d.largestBatchId>r){let f=i.get(d.largestBatchId);f===null&&(f=cn(),i=i.insert(d.largestBatchId,f)),f.set(d.getKey(),d)}}const c=cn(),l=i.getIterator();for(;l.hasNext()&&(l.getNext().value.forEach((d,f)=>c.set(d,f)),!(c.size()>=s)););return C.resolve(c)}bt(e,t,r){const s=this.overlays.get(r.key);if(s!==null){const a=this.Lr.get(s.largestBatchId).delete(r.key);this.Lr.set(s.largestBatchId,a)}this.overlays=this.overlays.insert(r.key,new Zg(t,r));let i=this.Lr.get(t);i===void 0&&(i=G(),this.Lr.set(t,i)),this.Lr.set(t,i.add(r.key))}}class x_{constructor(){this.sessionToken=we.EMPTY_BYTE_STRING}getSessionToken(e){return C.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,C.resolve()}}class bo{constructor(){this.kr=new fe(ge.Kr),this.qr=new fe(ge.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(e,t){const r=new ge(e,t);this.kr=this.kr.add(r),this.qr=this.qr.add(r)}$r(e,t){e.forEach(r=>this.addReference(r,t))}removeReference(e,t){this.Wr(new ge(e,t))}Qr(e,t){e.forEach(r=>this.removeReference(r,t))}Gr(e){const t=new L(new X([])),r=new ge(t,e),s=new ge(t,e+1),i=[];return this.qr.forEachInRange([r,s],a=>{this.Wr(a),i.push(a.key)}),i}zr(){this.kr.forEach(e=>this.Wr(e))}Wr(e){this.kr=this.kr.delete(e),this.qr=this.qr.delete(e)}jr(e){const t=new L(new X([])),r=new ge(t,e),s=new ge(t,e+1);let i=G();return this.qr.forEachInRange([r,s],a=>{i=i.add(a.key)}),i}containsKey(e){const t=new ge(e,0),r=this.kr.firstAfterOrEqual(t);return r!==null&&e.isEqual(r.key)}}class ge{constructor(e,t){this.key=e,this.Hr=t}static Kr(e,t){return L.comparator(e.key,t.key)||H(e.Hr,t.Hr)}static Ur(e,t){return H(e.Hr,t.Hr)||L.comparator(e.key,t.key)}}class U_{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Yn=1,this.Jr=new fe(ge.Kr)}checkEmpty(e){return C.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,r,s){const i=this.Yn;this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const a=new Xg(i,t,r,s);this.mutationQueue.push(a);for(const c of s)this.Jr=this.Jr.add(new ge(c.key,i)),this.indexManager.addToCollectionParentIndex(e,c.key.path.popLast());return C.resolve(a)}lookupMutationBatch(e,t){return C.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){const r=t+1,s=this.Xr(r),i=s<0?0:s;return C.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return C.resolve(this.mutationQueue.length===0?oo:this.Yn-1)}getAllMutationBatches(e){return C.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const r=new ge(t,0),s=new ge(t,Number.POSITIVE_INFINITY),i=[];return this.Jr.forEachInRange([r,s],a=>{const c=this.Zr(a.Hr);i.push(c)}),C.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new fe(H);return t.forEach(s=>{const i=new ge(s,0),a=new ge(s,Number.POSITIVE_INFINITY);this.Jr.forEachInRange([i,a],c=>{r=r.add(c.Hr)})}),C.resolve(this.Yr(r))}getAllMutationBatchesAffectingQuery(e,t){const r=t.path,s=r.length+1;let i=r;L.isDocumentKey(i)||(i=i.child(""));const a=new ge(new L(i),0);let c=new fe(H);return this.Jr.forEachWhile(l=>{const d=l.key.path;return!!r.isPrefixOf(d)&&(d.length===s&&(c=c.add(l.Hr)),!0)},a),C.resolve(this.Yr(c))}Yr(e){const t=[];return e.forEach(r=>{const s=this.Zr(r);s!==null&&t.push(s)}),t}removeMutationBatch(e,t){J(this.ei(t.batchId,"removed")===0,55003),this.mutationQueue.shift();let r=this.Jr;return C.forEach(t.mutations,s=>{const i=new ge(s.key,t.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,s.key)}).next(()=>{this.Jr=r})}nr(e){}containsKey(e,t){const r=new ge(t,0),s=this.Jr.firstAfterOrEqual(r);return C.resolve(t.isEqual(s&&s.key))}performConsistencyCheck(e){return this.mutationQueue.length,C.resolve()}ei(e,t){return this.Xr(e)}Xr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Zr(e){const t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class F_{constructor(e){this.ti=e,this.docs=function(){return new se(L.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const r=t.key,s=this.docs.get(r),i=s?s.size:0,a=this.ti(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const r=this.docs.get(t);return C.resolve(r?r.document.mutableCopy():be.newInvalidDocument(t))}getEntries(e,t){let r=Tt();return t.forEach(s=>{const i=this.docs.get(s);r=r.insert(s,i?i.document.mutableCopy():be.newInvalidDocument(s))}),C.resolve(r)}getDocumentsMatchingQuery(e,t,r,s){let i=Tt();const a=t.path,c=new L(a.child("__id-9223372036854775808__")),l=this.docs.getIteratorFrom(c);for(;l.hasNext();){const{key:d,value:{document:f}}=l.getNext();if(!a.isPrefixOf(d.path))break;d.path.length>a.length+1||cg(ag(f),r)<=0||(s.has(f.key)||Ds(t,f))&&(i=i.insert(f.key,f.mutableCopy()))}return C.resolve(i)}getAllFromCollectionGroup(e,t,r,s){x(9500)}ni(e,t){return C.forEach(this.docs,r=>t(r))}newChangeBuffer(e){return new B_(this)}getSize(e){return C.resolve(this.size)}}class B_ extends D_{constructor(e){super(),this.Mr=e}applyChanges(e){const t=[];return this.changes.forEach((r,s)=>{s.isValidDocument()?t.push(this.Mr.addEntry(e,s)):this.Mr.removeEntry(r)}),C.waitFor(t)}getFromCache(e,t){return this.Mr.getEntry(e,t)}getAllFromCache(e,t){return this.Mr.getEntries(e,t)}}class q_{constructor(e){this.persistence=e,this.ri=new an(t=>ho(t),fo),this.lastRemoteSnapshotVersion=B.min(),this.highestTargetId=0,this.ii=0,this.si=new bo,this.targetCount=0,this.oi=xn._r()}forEachTarget(e,t){return this.ri.forEach((r,s)=>t(s)),C.resolve()}getLastRemoteSnapshotVersion(e){return C.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return C.resolve(this.ii)}allocateTargetId(e){return this.highestTargetId=this.oi.next(),C.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.ii&&(this.ii=t),C.resolve()}lr(e){this.ri.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this.oi=new xn(t),this.highestTargetId=t),e.sequenceNumber>this.ii&&(this.ii=e.sequenceNumber)}addTargetData(e,t){return this.lr(t),this.targetCount+=1,C.resolve()}updateTargetData(e,t){return this.lr(t),C.resolve()}removeTargetData(e,t){return this.ri.delete(t.target),this.si.Gr(t.targetId),this.targetCount-=1,C.resolve()}removeTargets(e,t,r){let s=0;const i=[];return this.ri.forEach((a,c)=>{c.sequenceNumber<=t&&r.get(c.targetId)===null&&(this.ri.delete(a),i.push(this.removeMatchingKeysForTargetId(e,c.targetId)),s++)}),C.waitFor(i).next(()=>s)}getTargetCount(e){return C.resolve(this.targetCount)}getTargetData(e,t){const r=this.ri.get(t)||null;return C.resolve(r)}addMatchingKeys(e,t,r){return this.si.$r(t,r),C.resolve()}removeMatchingKeys(e,t,r){this.si.Qr(t,r);const s=this.persistence.referenceDelegate,i=[];return s&&t.forEach(a=>{i.push(s.markPotentiallyOrphaned(e,a))}),C.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.si.Gr(t),C.resolve()}getMatchingKeysForTargetId(e,t){const r=this.si.jr(t);return C.resolve(r)}containsKey(e,t){return C.resolve(this.si.containsKey(t))}}class cl{constructor(e,t){this._i={},this.overlays={},this.ai=new _s(0),this.ui=!1,this.ui=!0,this.ci=new x_,this.referenceDelegate=e(this),this.li=new q_(this),this.indexManager=new R_,this.remoteDocumentCache=function(s){return new F_(s)}(r=>this.referenceDelegate.hi(r)),this.serializer=new v_(t),this.Pi=new L_(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new M_,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this._i[e.toKey()];return r||(r=new U_(t,this.referenceDelegate),this._i[e.toKey()]=r),r}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(e,t,r){V("MemoryPersistence","Starting transaction:",e);const s=new j_(this.ai.next());return this.referenceDelegate.Ti(),r(s).next(i=>this.referenceDelegate.Ii(s).next(()=>i)).toPromise().then(i=>(s.raiseOnCommittedEvent(),i))}Ei(e,t){return C.or(Object.values(this._i).map(r=>()=>r.containsKey(e,t)))}}class j_ extends lg{constructor(e){super(),this.currentSequenceNumber=e}}class Po{constructor(e){this.persistence=e,this.Ri=new bo,this.Ai=null}static Vi(e){return new Po(e)}get di(){if(this.Ai)return this.Ai;throw x(60996)}addReference(e,t,r){return this.Ri.addReference(r,t),this.di.delete(r.toString()),C.resolve()}removeReference(e,t,r){return this.Ri.removeReference(r,t),this.di.add(r.toString()),C.resolve()}markPotentiallyOrphaned(e,t){return this.di.add(t.toString()),C.resolve()}removeTarget(e,t){this.Ri.Gr(t.targetId).forEach(s=>this.di.add(s.toString()));const r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(s=>{s.forEach(i=>this.di.add(i.toString()))}).next(()=>r.removeTargetData(e,t))}Ti(){this.Ai=new Set}Ii(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return C.forEach(this.di,r=>{const s=L.fromPath(r);return this.mi(e,s).next(i=>{i||t.removeEntry(s,B.min())})}).next(()=>(this.Ai=null,t.apply(e)))}updateLimboDocument(e,t){return this.mi(e,t).next(r=>{r?this.di.delete(t.toString()):this.di.add(t.toString())})}hi(e){return 0}mi(e,t){return C.or([()=>C.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class $s{constructor(e,t){this.persistence=e,this.fi=new an(r=>fg(r.path),(r,s)=>r.isEqual(s)),this.garbageCollector=N_(this,t)}static Vi(e,t){return new $s(e,t)}Ti(){}Ii(e){return C.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}dr(e){const t=this.pr(e);return this.persistence.getTargetCache().getTargetCount(e).next(r=>t.next(s=>r+s))}pr(e){let t=0;return this.mr(e,r=>{t++}).next(()=>t)}mr(e,t){return C.forEach(this.fi,(r,s)=>this.wr(e,r,s).next(i=>i?C.resolve():t(s)))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0;const s=this.persistence.getRemoteDocumentCache(),i=s.newChangeBuffer();return s.ni(e,a=>this.wr(e,a,t).next(c=>{c||(r++,i.removeEntry(a,B.min()))})).next(()=>i.apply(e)).next(()=>r)}markPotentiallyOrphaned(e,t){return this.fi.set(t,e.currentSequenceNumber),C.resolve()}removeTarget(e,t){const r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),C.resolve()}removeReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),C.resolve()}updateLimboDocument(e,t){return this.fi.set(t,e.currentSequenceNumber),C.resolve()}hi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=bs(e.data.value)),t}wr(e,t,r){return C.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const s=this.fi.get(t);return C.resolve(s!==void 0&&s>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class Co{constructor(e,t,r,s){this.targetId=e,this.fromCache=t,this.Ts=r,this.Is=s}static Es(e,t){let r=G(),s=G();for(const i of t.docChanges)switch(i.type){case 0:r=r.add(i.doc.key);break;case 1:s=s.add(i.doc.key)}return new Co(e,t.fromCache,r,s)}}class $_{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class z_{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=function(){return Sp()?8:hg(ve())>0?6:4}()}initialize(e,t){this.fs=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,r,s){const i={result:null};return this.gs(e,t).next(a=>{i.result=a}).next(()=>{if(!i.result)return this.ps(e,t,s,r).next(a=>{i.result=a})}).next(()=>{if(i.result)return;const a=new $_;return this.ys(e,t,a).next(c=>{if(i.result=c,this.As)return this.ws(e,t,a,c.size)})}).next(()=>i.result)}ws(e,t,r,s){return r.documentReadCount<this.Vs?(Pn()<=W.DEBUG&&V("QueryEngine","SDK will not create cache indexes for query:",Ln(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),C.resolve()):(Pn()<=W.DEBUG&&V("QueryEngine","Query:",Ln(t),"scans",r.documentReadCount,"local documents and returns",s,"documents as results."),r.documentReadCount>this.ds*s?(Pn()<=W.DEBUG&&V("QueryEngine","The SDK decides to create cache indexes for query:",Ln(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,it(t))):C.resolve())}gs(e,t){if(vu(t))return C.resolve(null);let r=it(t);return this.indexManager.getIndexType(e,r).next(s=>s===0?null:(t.limit!==null&&s===1&&(t=ks(t,null,"F"),r=it(t)),this.indexManager.getDocumentsMatchingTarget(e,r).next(i=>{const a=G(...i);return this.fs.getDocuments(e,a).next(c=>this.indexManager.getMinOffset(e,r).next(l=>{const d=this.bs(t,c);return this.Ss(t,d,a,l.readTime)?this.gs(e,ks(t,null,"F")):this.Ds(e,d,t,l)}))})))}ps(e,t,r,s){return vu(t)||s.isEqual(B.min())?C.resolve(null):this.fs.getDocuments(e,r).next(i=>{const a=this.bs(t,i);return this.Ss(t,a,r,s)?C.resolve(null):(Pn()<=W.DEBUG&&V("QueryEngine","Re-using previous result from %s to execute query: %s",s.toString(),Ln(t)),this.Ds(e,a,t,og(s,gr)).next(c=>c))})}bs(e,t){let r=new fe(bu(e));return t.forEach((s,i)=>{Ds(e,i)&&(r=r.add(i))}),r}Ss(e,t,r,s){if(e.limit===null)return!1;if(r.size!==t.size)return!0;const i=e.limitType==="F"?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(s)>0)}ys(e,t,r){return Pn()<=W.DEBUG&&V("QueryEngine","Using full collection scan to execute query:",Ln(t)),this.fs.getDocumentsMatchingQuery(e,t,Dt.min(),r)}Ds(e,t,r,s){return this.fs.getDocumentsMatchingQuery(e,r,s).next(i=>(t.forEach(a=>{i=i.insert(a.key,a)}),i))}}const So="LocalStore",W_=3e8;class H_{constructor(e,t,r,s){this.persistence=e,this.Cs=t,this.serializer=s,this.vs=new se(H),this.Fs=new an(i=>ho(i),fo),this.Ms=new Map,this.xs=e.getRemoteDocumentCache(),this.li=e.getTargetCache(),this.Pi=e.getBundleCache(),this.Os(r)}Os(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new V_(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.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.vs))}}function G_(n,e,t,r){return new H_(n,e,t,r)}async function ul(n,e){const t=F(n);return await t.persistence.runTransaction("Handle user change","readonly",r=>{let s;return t.mutationQueue.getAllMutationBatches(r).next(i=>(s=i,t.Os(e),t.mutationQueue.getAllMutationBatches(r))).next(i=>{const a=[],c=[];let l=G();for(const d of s){a.push(d.batchId);for(const f of d.mutations)l=l.add(f.key)}for(const d of i){c.push(d.batchId);for(const f of d.mutations)l=l.add(f.key)}return t.localDocuments.getDocuments(r,l).next(d=>({Ns:d,removedBatchIds:a,addedBatchIds:c}))})})}function K_(n,e){const t=F(n);return t.persistence.runTransaction("Acknowledge batch","readwrite-primary",r=>{const s=e.batch.keys(),i=t.xs.newChangeBuffer({trackRemovals:!0});return function(c,l,d,f){const m=d.batch,_=m.keys();let R=C.resolve();return _.forEach(S=>{R=R.next(()=>f.getEntry(l,S)).next(N=>{const k=d.docVersions.get(S);J(k!==null,48541),N.version.compareTo(k)<0&&(m.applyToRemoteDocument(N,d),N.isValidDocument()&&(N.setReadTime(d.commitVersion),f.addEntry(N)))})}),R.next(()=>c.mutationQueue.removeMutationBatch(l,m))}(t,r,e,i).next(()=>i.apply(r)).next(()=>t.mutationQueue.performConsistencyCheck(r)).next(()=>t.documentOverlayCache.removeOverlaysForBatchId(r,s,e.batch.batchId)).next(()=>t.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(r,function(c){let l=G();for(let d=0;d<c.mutationResults.length;++d)c.mutationResults[d].transformResults.length>0&&(l=l.add(c.batch.mutations[d].key));return l}(e))).next(()=>t.localDocuments.getDocuments(r,s))})}function ll(n){const e=F(n);return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.li.getLastRemoteSnapshotVersion(t))}function Q_(n,e){const t=F(n),r=e.snapshotVersion;let s=t.vs;return t.persistence.runTransaction("Apply remote event","readwrite-primary",i=>{const a=t.xs.newChangeBuffer({trackRemovals:!0});s=t.vs;const c=[];e.targetChanges.forEach((f,m)=>{const _=s.get(m);if(!_)return;c.push(t.li.removeMatchingKeys(i,f.removedDocuments,m).next(()=>t.li.addMatchingKeys(i,f.addedDocuments,m)));let R=_.withSequenceNumber(i.currentSequenceNumber);e.targetMismatches.get(m)!==null?R=R.withResumeToken(we.EMPTY_BYTE_STRING,B.min()).withLastLimboFreeSnapshotVersion(B.min()):f.resumeToken.approximateByteSize()>0&&(R=R.withResumeToken(f.resumeToken,r)),s=s.insert(m,R),function(N,k,U){return N.resumeToken.approximateByteSize()===0||k.snapshotVersion.toMicroseconds()-N.snapshotVersion.toMicroseconds()>=W_?!0:U.addedDocuments.size+U.modifiedDocuments.size+U.removedDocuments.size>0}(_,R,f)&&c.push(t.li.updateTargetData(i,R))});let l=Tt(),d=G();if(e.documentUpdates.forEach(f=>{e.resolvedLimboDocuments.has(f)&&c.push(t.persistence.referenceDelegate.updateLimboDocument(i,f))}),c.push(Y_(i,a,e.documentUpdates).next(f=>{l=f.Bs,d=f.Ls})),!r.isEqual(B.min())){const f=t.li.getLastRemoteSnapshotVersion(i).next(m=>t.li.setTargetsMetadata(i,i.currentSequenceNumber,r));c.push(f)}return C.waitFor(c).next(()=>a.apply(i)).next(()=>t.localDocuments.getLocalViewOfDocuments(i,l,d)).next(()=>l)}).then(i=>(t.vs=s,i))}function Y_(n,e,t){let r=G(),s=G();return t.forEach(i=>r=r.add(i)),e.getEntries(n,r).next(i=>{let a=Tt();return t.forEach((c,l)=>{const d=i.get(c);l.isFoundDocument()!==d.isFoundDocument()&&(s=s.add(c)),l.isNoDocument()&&l.version.isEqual(B.min())?(e.removeEntry(c,l.readTime),a=a.insert(c,l)):!d.isValidDocument()||l.version.compareTo(d.version)>0||l.version.compareTo(d.version)===0&&d.hasPendingWrites?(e.addEntry(l),a=a.insert(c,l)):V(So,"Ignoring outdated watch update for ",c,". Current version:",d.version," Watch version:",l.version)}),{Bs:a,Ls:s}})}function J_(n,e){const t=F(n);return t.persistence.runTransaction("Get next mutation batch","readonly",r=>(e===void 0&&(e=oo),t.mutationQueue.getNextMutationBatchAfterBatchId(r,e)))}function X_(n,e){const t=F(n);return t.persistence.runTransaction("Allocate target","readwrite",r=>{let s;return t.li.getTargetData(r,e).next(i=>i?(s=i,C.resolve(s)):t.li.allocateTargetId(r).next(a=>(s=new Ft(e,a,"TargetPurposeListen",r.currentSequenceNumber),t.li.addTargetData(r,s).next(()=>s))))}).then(r=>{const s=t.vs.get(r.targetId);return(s===null||r.snapshotVersion.compareTo(s.snapshotVersion)>0)&&(t.vs=t.vs.insert(r.targetId,r),t.Fs.set(e,r.targetId)),r})}async function ko(n,e,t){const r=F(n),s=r.vs.get(e),i=t?"readwrite":"readwrite-primary";try{t||await r.persistence.runTransaction("Release target",i,a=>r.persistence.referenceDelegate.removeTarget(a,s))}catch(a){if(!kn(a))throw a;V(So,`Failed to update sequence numbers for target ${e}: ${a}`)}r.vs=r.vs.remove(e),r.Fs.delete(s.target)}function hl(n,e,t){const r=F(n);let s=B.min(),i=G();return r.persistence.runTransaction("Execute query","readwrite",a=>function(l,d,f){const m=F(l),_=m.Fs.get(f);return _!==void 0?C.resolve(m.vs.get(_)):m.li.getTargetData(d,f)}(r,a,it(e)).next(c=>{if(c)return s=c.lastLimboFreeSnapshotVersion,r.li.getMatchingKeysForTargetId(a,c.targetId).next(l=>{i=l})}).next(()=>r.Cs.getDocumentsMatchingQuery(a,e,t?s:B.min(),t?i:G())).next(c=>(Z_(r,xg(e),c),{documents:c,ks:i})))}function Z_(n,e,t){let r=n.Ms.get(e)||B.min();t.forEach((s,i)=>{i.readTime.compareTo(r)>0&&(r=i.readTime)}),n.Ms.set(e,r)}class dl{constructor(){this.activeTargetIds=$g()}Qs(e){this.activeTargetIds=this.activeTargetIds.add(e)}Gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class ey{constructor(){this.vo=new dl,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.vo.Qs(e),this.Fo[e]||"not-current"}updateQueryState(e,t,r){this.Fo[e]=t}removeLocalQueryTarget(e){this.vo.Gs(e)}isLocalQueryTarget(e){return this.vo.activeTargetIds.has(e)}clearQueryState(e){delete this.Fo[e]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(e){return this.vo.activeTargetIds.has(e)}start(){return this.vo=new dl,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class ty{Mo(e){}shutdown(){}}const fl="ConnectivityMonitor";class pl{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(e){this.Lo.push(e)}shutdown(){window.removeEventListener("online",this.xo),window.removeEventListener("offline",this.No)}ko(){window.addEventListener("online",this.xo),window.addEventListener("offline",this.No)}Oo(){V(fl,"Network connectivity changed: AVAILABLE");for(const e of this.Lo)e(0)}Bo(){V(fl,"Network connectivity changed: UNAVAILABLE");for(const e of this.Lo)e(1)}static v(){return typeof window<"u"&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}}let zs=null;function No(){return zs===null?zs=function(){return 268435456+Math.round(2147483648*Math.random())}():zs++,"0x"+zs.toString(16)}const Do="RestConnection",ny={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class ry{get Ko(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),s=encodeURIComponent(this.databaseId.database);this.qo=t+"://"+e.host,this.Uo=`projects/${r}/databases/${s}`,this.$o=this.databaseId.database===vs?`project_id=${r}`:`project_id=${r}&database_id=${s}`}Wo(e,t,r,s,i){const a=No(),c=this.Qo(e,t.toUriEncodedString());V(Do,`Sending RPC '${e}' ${a}:`,c,r);const l={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(l,s,i);const{host:d}=new URL(c),f=tt(d);return this.zo(e,c,l,r,f).then(m=>(V(Do,`Received RPC '${e}' ${a}: `,m),m),m=>{throw sn(Do,`RPC '${e}' ${a} failed with error: `,m,"url: ",c,"request:",r),m})}jo(e,t,r,s,i,a){return this.Wo(e,t,r,s,i)}Go(e,t,r){e["X-Goog-Api-Client"]=function(){return"gl-js/ fire/"+bn}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((s,i)=>e[i]=s),r&&r.headers.forEach((s,i)=>e[i]=s)}Qo(e,t){const r=ny[e];let s=`${this.qo}/v1/${t}:${r}`;return this.databaseInfo.apiKey&&(s=`${s}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),s}terminate(){}}class sy{constructor(e){this.Ho=e.Ho,this.Jo=e.Jo}Zo(e){this.Xo=e}Yo(e){this.e_=e}t_(e){this.n_=e}onMessage(e){this.r_=e}close(){this.Jo()}send(e){this.Ho(e)}i_(){this.Xo()}s_(){this.e_()}o_(e){this.n_(e)}__(e){this.r_(e)}}const Pe="WebChannelConnection",kr=(n,e,t)=>{n.listen(e,r=>{try{t(r)}catch(s){setTimeout(()=>{throw s},0)}})};class Un extends ry{constructor(e){super(e),this.a_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static u_(){if(!Un.c_){const e=Fc();kr(e,Uc.STAT_EVENT,t=>{t.stat===to.PROXY?V(Pe,"STAT_EVENT: detected buffering proxy"):t.stat===to.NOPROXY&&V(Pe,"STAT_EVENT: detected no buffering proxy")}),Un.c_=!0}}zo(e,t,r,s,i){const a=No();return new Promise((c,l)=>{const d=new Mc;d.setWithCredentials(!0),d.listenOnce(xc.COMPLETE,()=>{try{switch(d.getLastErrorCode()){case ms.NO_ERROR:const m=d.getResponseJson();V(Pe,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(m)),c(m);break;case ms.TIMEOUT:V(Pe,`RPC '${e}' ${a} timed out`),l(new D(P.DEADLINE_EXCEEDED,"Request time out"));break;case ms.HTTP_ERROR:const _=d.getStatus();if(V(Pe,`RPC '${e}' ${a} failed with status:`,_,"response text:",d.getResponseText()),_>0){let R=d.getResponseJson();Array.isArray(R)&&(R=R[0]);const S=R?.error;if(S&&S.status&&S.message){const N=function(U){const $=U.toLowerCase().replace(/_/g,"-");return Object.values(P).indexOf($)>=0?$:P.UNKNOWN}(S.status);l(new D(N,S.message))}else l(new D(P.UNKNOWN,"Server responded with status "+d.getStatus()))}else l(new D(P.UNAVAILABLE,"Connection failed."));break;default:x(9055,{l_:e,streamId:a,h_:d.getLastErrorCode(),P_:d.getLastError()})}}finally{V(Pe,`RPC '${e}' ${a} completed.`)}});const f=JSON.stringify(s);V(Pe,`RPC '${e}' ${a} sending request:`,s),d.send(t,"POST",f,r,15)})}T_(e,t,r){const s=No(),i=[this.qo,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=this.createWebChannelTransport(),c={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},l=this.longPollingOptions.timeoutSeconds;l!==void 0&&(c.longPollingTimeout=Math.round(1e3*l)),this.useFetchStreams&&(c.useFetchStreams=!0),this.Go(c.initMessageHeaders,t,r),c.encodeInitMessageHeaders=!0;const d=i.join("");V(Pe,`Creating RPC '${e}' stream ${s}: ${d}`,c);const f=a.createWebChannel(d,c);this.I_(f);let m=!1,_=!1;const R=new sy({Ho:S=>{_?V(Pe,`Not sending because RPC '${e}' stream ${s} is closed:`,S):(m||(V(Pe,`Opening RPC '${e}' stream ${s} transport.`),f.open(),m=!0),V(Pe,`RPC '${e}' stream ${s} sending:`,S),f.send(S))},Jo:()=>f.close()});return kr(f,pr.EventType.OPEN,()=>{_||(V(Pe,`RPC '${e}' stream ${s} transport opened.`),R.i_())}),kr(f,pr.EventType.CLOSE,()=>{_||(_=!0,V(Pe,`RPC '${e}' stream ${s} transport closed`),R.o_(),this.E_(f))}),kr(f,pr.EventType.ERROR,S=>{_||(_=!0,sn(Pe,`RPC '${e}' stream ${s} transport errored. Name:`,S.name,"Message:",S.message),R.o_(new D(P.UNAVAILABLE,"The operation could not be completed")))}),kr(f,pr.EventType.MESSAGE,S=>{if(!_){const N=S.data[0];J(!!N,16349);const k=N,U=k?.error||k[0]?.error;if(U){V(Pe,`RPC '${e}' stream ${s} received error:`,U);const $=U.status;let j=function(re){const w=he[re];if(w!==void 0)return qu(w)}($),Q=U.message;$==="NOT_FOUND"&&Q.includes("database")&&Q.includes("does not exist")&&Q.includes(this.databaseId.database)&&sn(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),j===void 0&&(j=P.INTERNAL,Q="Unknown error status: "+$+" with message "+U.message),_=!0,R.o_(new D(j,Q)),f.close()}else V(Pe,`RPC '${e}' stream ${s} received:`,N),R.__(N)}}),Un.u_(),setTimeout(()=>{R.s_()},0),R}terminate(){this.a_.forEach(e=>e.close()),this.a_=[]}I_(e){this.a_.push(e)}E_(e){this.a_=this.a_.filter(t=>t===e)}Go(e,t,r){super.Go(e,t,r),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return Bc()}}function iy(n){return new Un(n)}function Oo(){return typeof document<"u"?document:null}function Ws(n){return new u_(n,!0)}Un.c_=!1;class ml{constructor(e,t,r=1e3,s=1.5,i=6e4){this.Ci=e,this.timerId=t,this.R_=r,this.A_=s,this.V_=i,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(e){this.cancel();const t=Math.floor(this.d_+this.y_()),r=Math.max(0,Date.now()-this.f_),s=Math.max(0,t-r);s>0&&V("ExponentialBackoff",`Backing off for ${s} ms (base delay: ${this.d_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,s,()=>(this.f_=Date.now(),e())),this.d_*=this.A_,this.d_<this.R_&&(this.d_=this.R_),this.d_>this.V_&&(this.d_=this.V_)}w_(){this.m_!==null&&(this.m_.skipDelay(),this.m_=null)}cancel(){this.m_!==null&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.d_}}const gl="PersistentStream";class _l{constructor(e,t,r,s,i,a,c,l){this.Ci=e,this.b_=r,this.S_=s,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=c,this.listener=l,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new ml(e,t)}x_(){return this.state===1||this.state===5||this.O_()}O_(){return this.state===2||this.state===3}start(){this.F_=0,this.state!==4?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&this.C_===null&&(this.C_=this.Ci.enqueueAfterDelay(this.b_,6e4,()=>this.k_()))}K_(e){this.q_(),this.stream.send(e)}async k_(){if(this.O_())return this.close(0)}q_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.U_(),this.M_.cancel(),this.D_++,e!==4?this.M_.reset():t&&t.code===P.RESOURCE_EXHAUSTED?(Et(t.toString()),Et("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):t&&t.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),this.stream!==null&&(this.W_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.t_(t)}W_(){}auth(){this.state=1;const e=this.Q_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([r,s])=>{this.D_===t&&this.G_(r,s)},r=>{e(()=>{const s=new D(P.UNKNOWN,"Fetching auth token failed: "+r.message);return this.z_(s)})})}G_(e,t){const r=this.Q_(this.D_);this.stream=this.j_(e,t),this.stream.Zo(()=>{r(()=>this.listener.Zo())}),this.stream.Yo(()=>{r(()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.S_,1e4,()=>(this.O_()&&(this.state=3),Promise.resolve())),this.listener.Yo()))}),this.stream.t_(s=>{r(()=>this.z_(s))}),this.stream.onMessage(s=>{r(()=>++this.F_==1?this.H_(s):this.onNext(s))})}N_(){this.state=5,this.M_.p_(async()=>{this.state=0,this.start()})}z_(e){return V(gl,`close with error: ${e}`),this.stream=null,this.close(4,e)}Q_(e){return t=>{this.Ci.enqueueAndForget(()=>this.D_===e?t():(V(gl,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class oy extends _l{constructor(e,t,r,s,i,a){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,s,a),this.serializer=i}j_(e,t){return this.connection.T_("Listen",e,t)}H_(e){return this.onNext(e)}onNext(e){this.M_.reset();const t=d_(this.serializer,e),r=function(i){if(!("targetChange"in i))return B.min();const a=i.targetChange;return a.targetIds&&a.targetIds.length?B.min():a.readTime?ot(a.readTime):B.min()}(e);return this.listener.J_(t,r)}Z_(e){const t={};t.database=Ro(this.serializer),t.addTarget=function(i,a){let c;const l=a.target;if(c=po(l)?{documents:m_(i,l)}:{query:Zu(i,l).ft},c.targetId=a.targetId,a.resumeToken.approximateByteSize()>0){c.resumeToken=Ku(i,a.resumeToken);const d=To(i,a.expectedCount);d!==null&&(c.expectedCount=d)}else if(a.snapshotVersion.compareTo(B.min())>0){c.readTime=js(i,a.snapshotVersion.toTimestamp());const d=To(i,a.expectedCount);d!==null&&(c.expectedCount=d)}return c}(this.serializer,e);const r=y_(this.serializer,e);r&&(t.labels=r),this.K_(t)}X_(e){const t={};t.database=Ro(this.serializer),t.removeTarget=e,this.K_(t)}}class ay extends _l{constructor(e,t,r,s,i,a){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,s,a),this.serializer=i}get Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(e,t){return this.connection.T_("Write",e,t)}H_(e){return J(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,J(!e.writeResults||e.writeResults.length===0,55816),this.listener.ta()}onNext(e){J(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();const t=p_(e.writeResults,e.commitTime),r=ot(e.commitTime);return this.listener.na(r,t)}ra(){const e={};e.database=Ro(this.serializer),this.K_(e)}ea(e){const t={streamToken:this.lastStreamToken,writes:e.map(r=>f_(this.serializer,r))};this.K_(t)}}class cy{}class uy extends cy{constructor(e,t,r,s){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=s,this.ia=!1}sa(){if(this.ia)throw new D(P.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,r,s){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,a])=>this.connection.Wo(e,Io(t,r),s,i,a)).catch(i=>{throw i.name==="FirebaseError"?(i.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),i):new D(P.UNKNOWN,i.toString())})}jo(e,t,r,s,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([a,c])=>this.connection.jo(e,Io(t,r),s,a,c,i)).catch(a=>{throw a.name==="FirebaseError"?(a.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),a):new D(P.UNKNOWN,a.toString())})}terminate(){this.ia=!0,this.connection.terminate()}}function ly(n,e,t,r){return new uy(n,e,t,r)}class hy{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){this.oa===0&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve())))}ha(e){this.state==="Online"?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca("Offline")))}set(e){this.Pa(),this.oa=0,e==="Online"&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){const t=`Could not reach Cloud Firestore backend. ${e}
|
|
32
|
-
This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.aa?(Et(t),this.aa=!1):V("OnlineStateTracker",t)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}}const un="RemoteStore";class dy{constructor(e,t,r,s,i){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Ta=[],this.Ia=new Map,this.Ea=new Set,this.Ra=[],this.Aa=i,this.Aa.Mo(a=>{r.enqueueAndForget(async()=>{ln(this)&&(V(un,"Restarting streams for network reachability change."),await async function(l){const d=F(l);d.Ea.add(4),await Nr(d),d.Va.set("Unknown"),d.Ea.delete(4),await Hs(d)}(this))})}),this.Va=new hy(r,s)}}async function Hs(n){if(ln(n))for(const e of n.Ra)await e(!0)}async function Nr(n){for(const e of n.Ra)await e(!1)}function yl(n,e){const t=F(n);t.Ia.has(e.targetId)||(t.Ia.set(e.targetId,e),xo(t)?Mo(t):Fn(t).O_()&&Lo(t,e))}function Vo(n,e){const t=F(n),r=Fn(t);t.Ia.delete(e),r.O_()&&El(t,e),t.Ia.size===0&&(r.O_()?r.L_():ln(t)&&t.Va.set("Unknown"))}function Lo(n,e){if(n.da.$e(e.targetId),e.resumeToken.approximateByteSize()>0||e.snapshotVersion.compareTo(B.min())>0){const t=n.remoteSyncer.getRemoteKeysForTarget(e.targetId).size;e=e.withExpectedCount(t)}Fn(n).Z_(e)}function El(n,e){n.da.$e(e),Fn(n).X_(e)}function Mo(n){n.da=new i_({getRemoteKeysForTarget:e=>n.remoteSyncer.getRemoteKeysForTarget(e),At:e=>n.Ia.get(e)||null,ht:()=>n.datastore.serializer.databaseId}),Fn(n).start(),n.Va.ua()}function xo(n){return ln(n)&&!Fn(n).x_()&&n.Ia.size>0}function ln(n){return F(n).Ea.size===0}function Tl(n){n.da=void 0}async function fy(n){n.Va.set("Online")}async function py(n){n.Ia.forEach((e,t)=>{Lo(n,e)})}async function my(n,e){Tl(n),xo(n)?(n.Va.ha(e),Mo(n)):n.Va.set("Unknown")}async function gy(n,e,t){if(n.Va.set("Online"),e instanceof Wu&&e.state===2&&e.cause)try{await async function(s,i){const a=i.cause;for(const c of i.targetIds)s.Ia.has(c)&&(await s.remoteSyncer.rejectListen(c,a),s.Ia.delete(c),s.da.removeTarget(c))}(n,e)}catch(r){V(un,"Failed to remove targets %s: %s ",e.targetIds.join(","),r),await Gs(n,r)}else if(e instanceof Bs?n.da.Xe(e):e instanceof zu?n.da.st(e):n.da.tt(e),!t.isEqual(B.min()))try{const r=await ll(n.localStore);t.compareTo(r)>=0&&await function(i,a){const c=i.da.Tt(a);return c.targetChanges.forEach((l,d)=>{if(l.resumeToken.approximateByteSize()>0){const f=i.Ia.get(d);f&&i.Ia.set(d,f.withResumeToken(l.resumeToken,a))}}),c.targetMismatches.forEach((l,d)=>{const f=i.Ia.get(l);if(!f)return;i.Ia.set(l,f.withResumeToken(we.EMPTY_BYTE_STRING,f.snapshotVersion)),El(i,l);const m=new Ft(f.target,l,d,f.sequenceNumber);Lo(i,m)}),i.remoteSyncer.applyRemoteEvent(c)}(n,t)}catch(r){V(un,"Failed to raise snapshot:",r),await Gs(n,r)}}async function Gs(n,e,t){if(!kn(e))throw e;n.Ea.add(1),await Nr(n),n.Va.set("Offline"),t||(t=()=>ll(n.localStore)),n.asyncQueue.enqueueRetryable(async()=>{V(un,"Retrying IndexedDB access"),await t(),n.Ea.delete(1),await Hs(n)})}function wl(n,e){return e().catch(t=>Gs(n,t,e))}async function Ks(n){const e=F(n),t=Bt(e);let r=e.Ta.length>0?e.Ta[e.Ta.length-1].batchId:oo;for(;_y(e);)try{const s=await J_(e.localStore,r);if(s===null){e.Ta.length===0&&t.L_();break}r=s.batchId,yy(e,s)}catch(s){await Gs(e,s)}Il(e)&&vl(e)}function _y(n){return ln(n)&&n.Ta.length<10}function yy(n,e){n.Ta.push(e);const t=Bt(n);t.O_()&&t.Y_&&t.ea(e.mutations)}function Il(n){return ln(n)&&!Bt(n).x_()&&n.Ta.length>0}function vl(n){Bt(n).start()}async function Ey(n){Bt(n).ra()}async function Ty(n){const e=Bt(n);for(const t of n.Ta)e.ea(t.mutations)}async function wy(n,e,t){const r=n.Ta.shift(),s=yo.from(r,e,t);await wl(n,()=>n.remoteSyncer.applySuccessfulWrite(s)),await Ks(n)}async function Iy(n,e){e&&Bt(n).Y_&&await async function(r,s){if(function(a){return n_(a)&&a!==P.ABORTED}(s.code)){const i=r.Ta.shift();Bt(r).B_(),await wl(r,()=>r.remoteSyncer.rejectFailedWrite(i.batchId,s)),await Ks(r)}}(n,e),Il(n)&&vl(n)}async function Al(n,e){const t=F(n);t.asyncQueue.verifyOperationInProgress(),V(un,"RemoteStore received new credentials");const r=ln(t);t.Ea.add(3),await Nr(t),r&&t.Va.set("Unknown"),await t.remoteSyncer.handleCredentialChange(e),t.Ea.delete(3),await Hs(t)}async function vy(n,e){const t=F(n);e?(t.Ea.delete(2),await Hs(t)):e||(t.Ea.add(2),await Nr(t),t.Va.set("Unknown"))}function Fn(n){return n.ma||(n.ma=function(t,r,s){const i=F(t);return i.sa(),new oy(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)}(n.datastore,n.asyncQueue,{Zo:fy.bind(null,n),Yo:py.bind(null,n),t_:my.bind(null,n),J_:gy.bind(null,n)}),n.Ra.push(async e=>{e?(n.ma.B_(),xo(n)?Mo(n):n.Va.set("Unknown")):(await n.ma.stop(),Tl(n))})),n.ma}function Bt(n){return n.fa||(n.fa=function(t,r,s){const i=F(t);return i.sa(),new ay(r,i.connection,i.authCredentials,i.appCheckCredentials,i.serializer,s)}(n.datastore,n.asyncQueue,{Zo:()=>Promise.resolve(),Yo:Ey.bind(null,n),t_:Iy.bind(null,n),ta:Ty.bind(null,n),na:wy.bind(null,n)}),n.Ra.push(async e=>{e?(n.fa.B_(),await Ks(n)):(await n.fa.stop(),n.Ta.length>0&&(V(un,`Stopping write stream with ${n.Ta.length} pending writes`),n.Ta=[]))})),n.fa}class Uo{constructor(e,t,r,s,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=s,this.removalCallback=i,this.deferred=new nt,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(a=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,s,i){const a=Date.now()+r,c=new Uo(e,t,a,s,i);return c.start(r),c}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new D(P.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>this.timerHandle!==null?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function Fo(n,e){if(Et("AsyncQueue",`${e}: ${n}`),kn(n))return new D(P.UNAVAILABLE,`${e}: ${n}`);throw n}class Bn{static emptySet(e){return new Bn(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||L.comparator(t.key,r.key):(t,r)=>L.comparator(t.key,r.key),this.keyedMap=Ir(),this.sortedSet=new se(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,r)=>(e(t),!1))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof Bn)||this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){const s=t.getNext().key,i=r.getNext().key;if(!s.isEqual(i))return!1}return!0}toString(){const e=[];return this.forEach(t=>{e.push(t.toString())}),e.length===0?"DocumentSet ()":`DocumentSet (
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`entropic-bond-firebase`]={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=()=>void 0,n=function(e){let t=[],n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=i&63|128):(i&64512)==55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)==56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t},r=function(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){let a=e[n++];t[r++]=String.fromCharCode((i&31)<<6|a&63)}else if(i>239&&i<365){let a=e[n++],o=e[n++],s=e[n++],c=((i&7)<<18|(a&63)<<12|(o&63)<<6|s&63)-65536;t[r++]=String.fromCharCode(55296+(c>>10)),t[r++]=String.fromCharCode(56320+(c&1023))}else{let a=e[n++],o=e[n++];t[r++]=String.fromCharCode((i&15)<<12|(a&63)<<6|o&63)}}return t.join(``)},i={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`,get ENCODED_VALS(){return this.ENCODED_VALS_BASE+`+/=`},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+`-_.`},HAS_NATIVE_SUPPORT:typeof atob==`function`,encodeByteArray(e,t){if(!Array.isArray(e))throw Error(`encodeByteArray takes an array as a parameter`);this.init_();let n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let t=0;t<e.length;t+=3){let i=e[t],a=t+1<e.length,o=a?e[t+1]:0,s=t+2<e.length,c=s?e[t+2]:0,l=i>>2,u=(i&3)<<4|o>>4,d=(o&15)<<2|c>>6,f=c&63;s||(f=64,a||(d=64)),r.push(n[l],n[u],n[d],n[f])}return r.join(``)},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(n(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):r(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();let n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let t=0;t<e.length;){let i=n[e.charAt(t++)],o=t<e.length?n[e.charAt(t)]:0;++t;let s=t<e.length?n[e.charAt(t)]:64;++t;let c=t<e.length?n[e.charAt(t)]:64;if(++t,i==null||o==null||s==null||c==null)throw new a;let l=i<<2|o>>4;if(r.push(l),s!==64){let e=o<<4&240|s>>2;if(r.push(e),c!==64){let e=s<<6&192|c;r.push(e)}}}return r},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)}}},a=class extends Error{constructor(){super(...arguments),this.name=`DecodeBase64StringError`}},o=function(e){let t=n(e);return i.encodeByteArray(t,!0)},s=function(e){return o(e).replace(/\./g,``)},c=function(e){try{return i.decodeString(e,!0)}catch(e){console.error(`base64Decode failed: `,e)}return null};function l(){if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global;throw Error(`Unable to locate global object.`)}var u=()=>l().__FIREBASE_DEFAULTS__,d=()=>{if(typeof process>`u`||process.env===void 0)return;let e=process.env.__FIREBASE_DEFAULTS__;if(e)return JSON.parse(e)},f=()=>{if(typeof document>`u`)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}let t=e&&c(e[1]);return t&&JSON.parse(t)},p=()=>{try{return t()||u()||d()||f()}catch(e){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);return}},m=e=>p()?.emulatorHosts?.[e],h=e=>{let t=m(e);if(!t)return;let n=t.lastIndexOf(`:`);if(n<=0||n+1===t.length)throw Error(`Invalid host ${t} with no separate hostname and port!`);let r=parseInt(t.substring(n+1),10);return t[0]===`[`?[t.substring(1,n-1),r]:[t.substring(0,n),r]},g=()=>p()?.config,ee=e=>p()?.[`_${e}`],te=class{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),typeof e==`function`&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,n))}}};function ne(e,t){if(e.uid)throw Error(`The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.`);let n={alg:`none`,type:`JWT`},r=t||`demo-project`,i=e.iat||0,a=e.sub||e.user_id;if(!a)throw Error(`mockUserToken must contain 'sub' or 'user_id' field!`);let o={iss:`https://securetoken.google.com/${r}`,aud:r,iat:i,exp:i+3600,auth_time:i,sub:a,user_id:a,firebase:{sign_in_provider:`custom`,identities:{}},...e};return[s(JSON.stringify(n)),s(JSON.stringify(o)),``].join(`.`)}function re(){return typeof navigator<`u`&&typeof navigator.userAgent==`string`?navigator.userAgent:``}function ie(){return typeof window<`u`&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(re())}function ae(){let e=p()?.forceEnvironment;if(e===`node`)return!0;if(e===`browser`)return!1;try{return Object.prototype.toString.call(global.process)===`[object process]`}catch{return!1}}function oe(){return typeof navigator<`u`&&navigator.userAgent===`Cloudflare-Workers`}function se(){let e=typeof chrome==`object`?chrome.runtime:typeof browser==`object`?browser.runtime:void 0;return typeof e==`object`&&e.id!==void 0}function ce(){return typeof navigator==`object`&&navigator.product===`ReactNative`}function le(){let e=re();return e.indexOf(`MSIE `)>=0||e.indexOf(`Trident/`)>=0}function ue(){return!ae()&&!!navigator.userAgent&&navigator.userAgent.includes(`Safari`)&&!navigator.userAgent.includes(`Chrome`)}function de(){try{return typeof indexedDB==`object`}catch{return!1}}function fe(){return new Promise((e,t)=>{try{let n=!0,r=`validate-browser-context-for-indexeddb-analytics-module`,i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{t(i.error?.message||``)}}catch(e){t(e)}})}var pe=`FirebaseError`,me=class e extends Error{constructor(t,n,r){super(n),this.code=t,this.customData=r,this.name=pe,Object.setPrototypeOf(this,e.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,he.prototype.create)}},he=class{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){let n=t[0]||{},r=`${this.service}/${e}`,i=this.errors[e],a=i?ge(i,n):`Error`;return new me(r,`${this.serviceName}: ${a} (${r}).`,n)}};function ge(e,t){return e.replace(_e,(e,n)=>{let r=t[n];return r==null?`<${n}?>`:String(r)})}var _e=/\{\$([^}]+)}/g;function ve(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function ye(e,t){if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);for(let i of n){if(!r.includes(i))return!1;let n=e[i],a=t[i];if(be(n)&&be(a)){if(!ye(n,a))return!1}else if(n!==a)return!1}for(let e of r)if(!n.includes(e))return!1;return!0}function be(e){return typeof e==`object`&&!!e}function xe(e){let t=[];for(let[n,r]of Object.entries(e))Array.isArray(r)?r.forEach(e=>{t.push(encodeURIComponent(n)+`=`+encodeURIComponent(e))}):t.push(encodeURIComponent(n)+`=`+encodeURIComponent(r));return t.length?`&`+t.join(`&`):``}function Se(e){let t={};return e.replace(/^\?/,``).split(`&`).forEach(e=>{if(e){let[n,r]=e.split(`=`);t[decodeURIComponent(n)]=decodeURIComponent(r)}}),t}function Ce(e){let t=e.indexOf(`?`);if(!t)return``;let n=e.indexOf(`#`,t);return e.substring(t,n>0?n:void 0)}function we(e,t){let n=new Te(e,t);return n.subscribe.bind(n)}var Te=class{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 r;if(e===void 0&&t===void 0&&n===void 0)throw Error(`Missing Observer.`);r=Ee(e,[`next`,`error`,`complete`])?e:{next:e,error:t,complete:n},r.next===void 0&&(r.next=De),r.error===void 0&&(r.error=De),r.complete===void 0&&(r.complete=De);let i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch{}}),this.observers.push(r),i}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],--this.observerCount,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(e){typeof console<`u`&&console.error&&console.error(e)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}};function Ee(e,t){if(typeof e!=`object`||!e)return!1;for(let n of t)if(n in e&&typeof e[n]==`function`)return!0;return!1}function De(){}function _(e){return e&&e._delegate?e._delegate:e}function Oe(e){try{return(e.startsWith(`http://`)||e.startsWith(`https://`)?new URL(e).hostname:e).endsWith(`.cloudworkstations.dev`)}catch{return!1}}async function ke(e){return(await fetch(e,{credentials:`include`})).ok}var Ae=class{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}},je=`[DEFAULT]`,Me=class{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){let t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){let e=new te;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{let n=this.getOrInitializeService({instanceIdentifier:t});n&&e.resolve(n)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){let t=this.normalizeInstanceIdentifier(e?.identifier),n=e?.optional??!1;if(this.isInitialized(t)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:t})}catch(e){if(n)return null;throw e}else if(n)return null;else throw Error(`Service ${this.name} is not available`)}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if(Pe(e))try{this.getOrInitializeService({instanceIdentifier:je})}catch{}for(let[e,t]of this.instancesDeferred.entries()){let n=this.normalizeInstanceIdentifier(e);try{let e=this.getOrInitializeService({instanceIdentifier:n});t.resolve(e)}catch{}}}}clearInstance(e=je){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){let 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 this.component!=null}isInitialized(e=je){return this.instances.has(e)}getOptions(e=je){return this.instancesOptions.get(e)||{}}initialize(e={}){let{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`);let r=this.getOrInitializeService({instanceIdentifier:n,options:t});for(let[e,t]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(e)&&t.resolve(r);return r}onInit(e,t){let n=this.normalizeInstanceIdentifier(t),r=this.onInitCallbacks.get(n)??new Set;r.add(e),this.onInitCallbacks.set(n,r);let i=this.instances.get(n);return i&&e(i,n),()=>{r.delete(e)}}invokeOnInitCallbacks(e,t){let n=this.onInitCallbacks.get(t);if(n)for(let r of n)try{r(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:Ne(e),options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch{}return n||null}normalizeInstanceIdentifier(e=je){return this.component?this.component.multipleInstances?e:je:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!==`EXPLICIT`}};function Ne(e){return e===je?void 0:e}function Pe(e){return e.instantiationMode===`EAGER`}var Fe=class{constructor(e){this.name=e,this.providers=new Map}addComponent(e){let t=this.getProvider(e.name);if(t.isComponentSet())throw 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);let t=new Me(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}},Ie=[],v;(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`})(v||={});var Le={debug:v.DEBUG,verbose:v.VERBOSE,info:v.INFO,warn:v.WARN,error:v.ERROR,silent:v.SILENT},Re=v.INFO,ze={[v.DEBUG]:`log`,[v.VERBOSE]:`log`,[v.INFO]:`info`,[v.WARN]:`warn`,[v.ERROR]:`error`},Be=(e,t,...n)=>{if(t<e.logLevel)return;let r=new Date().toISOString(),i=ze[t];if(i)console[i](`[${r}] ${e.name}:`,...n);else throw Error(`Attempted to log a message with an invalid logType (value: ${t})`)},Ve=class{constructor(e){this.name=e,this._logLevel=Re,this._logHandler=Be,this._userLogHandler=null,Ie.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in v))throw TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e==`string`?Le[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!=`function`)throw 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,v.DEBUG,...e),this._logHandler(this,v.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,v.VERBOSE,...e),this._logHandler(this,v.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,v.INFO,...e),this._logHandler(this,v.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,v.WARN,...e),this._logHandler(this,v.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,v.ERROR,...e),this._logHandler(this,v.ERROR,...e)}},He=(e,t)=>t.some(t=>e instanceof t),Ue,We;function Ge(){return Ue||=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]}function Ke(){return We||=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey]}var qe=new WeakMap,Je=new WeakMap,Ye=new WeakMap,Xe=new WeakMap,Ze=new WeakMap;function Qe(e){let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`success`,i),e.removeEventListener(`error`,a)},i=()=>{t(it(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener(`success`,i),e.addEventListener(`error`,a)});return t.then(t=>{t instanceof IDBCursor&&qe.set(t,e)}).catch(()=>{}),Ze.set(t,e),t}function $e(e){if(Je.has(e))return;let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`complete`,i),e.removeEventListener(`error`,a),e.removeEventListener(`abort`,a)},i=()=>{t(),r()},a=()=>{n(e.error||new DOMException(`AbortError`,`AbortError`)),r()};e.addEventListener(`complete`,i),e.addEventListener(`error`,a),e.addEventListener(`abort`,a)});Je.set(e,t)}var et={get(e,t,n){if(e instanceof IDBTransaction){if(t===`done`)return Je.get(e);if(t===`objectStoreNames`)return e.objectStoreNames||Ye.get(e);if(t===`store`)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return it(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t===`done`||t===`store`)?!0:t in e}};function tt(e){et=e(et)}function nt(e){return e===IDBDatabase.prototype.transaction&&!(`objectStoreNames`in IDBTransaction.prototype)?function(t,...n){let r=e.call(at(this),t,...n);return Ye.set(r,t.sort?t.sort():[t]),it(r)}:Ke().includes(e)?function(...t){return e.apply(at(this),t),it(qe.get(this))}:function(...t){return it(e.apply(at(this),t))}}function rt(e){return typeof e==`function`?nt(e):(e instanceof IDBTransaction&&$e(e),He(e,Ge())?new Proxy(e,et):e)}function it(e){if(e instanceof IDBRequest)return Qe(e);if(Xe.has(e))return Xe.get(e);let t=rt(e);return t!==e&&(Xe.set(e,t),Ze.set(t,e)),t}var at=e=>Ze.get(e);function ot(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){let o=indexedDB.open(e,t),s=it(o);return r&&o.addEventListener(`upgradeneeded`,e=>{r(it(o.result),e.oldVersion,e.newVersion,it(o.transaction),e)}),n&&o.addEventListener(`blocked`,e=>n(e.oldVersion,e.newVersion,e)),s.then(e=>{a&&e.addEventListener(`close`,()=>a()),i&&e.addEventListener(`versionchange`,e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}var st=[`get`,`getKey`,`getAll`,`getAllKeys`,`count`],ct=[`put`,`add`,`delete`,`clear`],lt=new Map;function ut(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t==`string`))return;if(lt.get(t))return lt.get(t);let n=t.replace(/FromIndex$/,``),r=t!==n,i=ct.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||st.includes(n)))return;let a=async function(e,...t){let a=this.transaction(e,i?`readwrite`:`readonly`),o=a.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&a.done]))[0]};return lt.set(t,a),a}tt(e=>({...e,get:(t,n,r)=>ut(t,n)||e.get(t,n,r),has:(t,n)=>!!ut(t,n)||e.has(t,n)}));var dt=class{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(ft(e)){let t=e.getImmediate();return`${t.library}/${t.version}`}else return null}).filter(e=>e).join(` `)}};function ft(e){return e.getComponent()?.type===`VERSION`}var pt=`@firebase/app`,mt=`0.15.0`,ht=new Ve(`@firebase/app`),gt=`@firebase/app-compat`,_t=`@firebase/analytics-compat`,vt=`@firebase/analytics`,yt=`@firebase/app-check-compat`,bt=`@firebase/app-check`,xt=`@firebase/auth`,St=`@firebase/auth-compat`,Ct=`@firebase/database`,wt=`@firebase/data-connect`,Tt=`@firebase/database-compat`,Et=`@firebase/functions`,Dt=`@firebase/functions-compat`,Ot=`@firebase/installations`,kt=`@firebase/installations-compat`,At=`@firebase/messaging`,jt=`@firebase/messaging-compat`,Mt=`@firebase/performance`,Nt=`@firebase/performance-compat`,Pt=`@firebase/remote-config`,Ft=`@firebase/remote-config-compat`,It=`@firebase/storage`,Lt=`@firebase/storage-compat`,Rt=`@firebase/firestore`,zt=`@firebase/ai`,Bt=`@firebase/firestore-compat`,Vt=`firebase`,Ht=`12.15.0`,Ut=`[DEFAULT]`,Wt={[pt]:`fire-core`,[gt]:`fire-core-compat`,[vt]:`fire-analytics`,[_t]:`fire-analytics-compat`,[bt]:`fire-app-check`,[yt]:`fire-app-check-compat`,[xt]:`fire-auth`,[St]:`fire-auth-compat`,[Ct]:`fire-rtdb`,[wt]:`fire-data-connect`,[Tt]:`fire-rtdb-compat`,[Et]:`fire-fn`,[Dt]:`fire-fn-compat`,[Ot]:`fire-iid`,[kt]:`fire-iid-compat`,[At]:`fire-fcm`,[jt]:`fire-fcm-compat`,[Mt]:`fire-perf`,[Nt]:`fire-perf-compat`,[Pt]:`fire-rc`,[Ft]:`fire-rc-compat`,[It]:`fire-gcs`,[Lt]:`fire-gcs-compat`,[Rt]:`fire-fst`,[Bt]:`fire-fst-compat`,[zt]:`fire-vertex`,"fire-js":`fire-js`,[Vt]:`fire-js-all`},Gt=new Map,Kt=new Map,qt=new Map;function Jt(e,t){try{e.container.addComponent(t)}catch(n){ht.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function Yt(e){let t=e.name;if(qt.has(t))return ht.debug(`There were multiple attempts to register component ${t}.`),!1;qt.set(t,e);for(let t of Gt.values())Jt(t,e);for(let t of Kt.values())Jt(t,e);return!0}function Xt(e,t){let n=e.container.getProvider(`heartbeat`).getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function y(e){return e==null?!1:e.settings!==void 0}var Zt=new he(`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.`}),Qt=class{constructor(e,t,n){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new Ae(`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 Zt.create(`app-deleted`,{appName:this._name})}},$t=Ht;function en(e,t={}){let n=e;typeof t!=`object`&&(t={name:t});let r={name:Ut,automaticDataCollectionEnabled:!0,...t},i=r.name;if(typeof i!=`string`||!i)throw Zt.create(`bad-app-name`,{appName:String(i)});if(n||=g(),!n)throw Zt.create(`no-options`);let a=Gt.get(i);if(a){if(ye(n,a.options)&&ye(r,a.config))return a;throw Zt.create(`duplicate-app`,{appName:i})}let o=new Fe(i);for(let e of qt.values())o.addComponent(e);let s=new Qt(n,r,o);return Gt.set(i,s),s}function tn(e=Ut){let t=Gt.get(e);if(!t&&e===`[DEFAULT]`&&g())return en();if(!t)throw Zt.create(`no-app`,{appName:e});return t}function nn(e,t,n){let r=Wt[e]??e;n&&(r+=`-${n}`);let i=r.match(/\s|\//),a=t.match(/\s|\//);if(i||a){let e=[`Unable to register library "${r}" with version "${t}":`];i&&e.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&a&&e.push(`and`),a&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),ht.warn(e.join(` `));return}Yt(new Ae(`${r}-version`,()=>({library:r,version:t}),`VERSION`))}var rn=`firebase-heartbeat-database`,an=1,on=`firebase-heartbeat-store`,sn=null;function cn(){return sn||=ot(rn,an,{upgrade:(e,t)=>{switch(t){case 0:try{e.createObjectStore(on)}catch(e){console.warn(e)}}}}).catch(e=>{throw Zt.create(`idb-open`,{originalErrorMessage:e.message})}),sn}async function ln(e){try{let t=(await cn()).transaction(on),n=await t.objectStore(on).get(dn(e));return await t.done,n}catch(e){if(e instanceof me)ht.warn(e.message);else{let t=Zt.create(`idb-get`,{originalErrorMessage:e?.message});ht.warn(t.message)}}}async function un(e,t){try{let n=(await cn()).transaction(on,`readwrite`);await n.objectStore(on).put(t,dn(e)),await n.done}catch(e){if(e instanceof me)ht.warn(e.message);else{let t=Zt.create(`idb-set`,{originalErrorMessage:e?.message});ht.warn(t.message)}}}function dn(e){return`${e.name}!${e.options.appId}`}var fn=1024,pn=30,mn=class{constructor(e){this.container=e,this._heartbeatsCache=null;let t=this.container.getProvider(`app`).getImmediate();this._storage=new _n(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){try{let e=this.container.getProvider(`platform-logger`).getImmediate().getPlatformInfoString(),t=hn();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===t||this._heartbeatsCache.heartbeats.some(e=>e.date===t))return;if(this._heartbeatsCache.heartbeats.push({date:t,agent:e}),this._heartbeatsCache.heartbeats.length>pn){let e=yn(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){ht.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return``;let e=hn(),{heartbeatsToSend:t,unsentEntries:n}=gn(this._heartbeatsCache.heartbeats),r=s(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,n.length>0?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),r}catch(e){return ht.warn(e),``}}};function hn(){return new Date().toISOString().substring(0,10)}function gn(e,t=fn){let n=[],r=e.slice();for(let i of e){let e=n.find(e=>e.agent===i.agent);if(!e){if(n.push({agent:i.agent,dates:[i.date]}),vn(n)>t){n.pop();break}}else if(e.dates.push(i.date),vn(n)>t){e.dates.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}var _n=class{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return de()?fe().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){let e=await ln(this.app);return e?.heartbeats?e:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){let t=await this.read();return un(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){let t=await this.read();return un(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:[...t.heartbeats,...e.heartbeats]})}else return}};function vn(e){return s(JSON.stringify({version:2,heartbeats:e})).length}function yn(e){if(e.length===0)return-1;let t=0,n=e[0].date;for(let r=1;r<e.length;r++)e[r].date<n&&(n=e[r].date,t=r);return t}function bn(e){Yt(new Ae(`platform-logger`,e=>new dt(e),`PRIVATE`)),Yt(new Ae(`heartbeat`,e=>new mn(e),`PRIVATE`)),nn(pt,mt,e),nn(pt,mt,`esm2020`),nn(`fire-js`,``)}bn(``);var xn=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},Sn={},Cn,wn;(function(){var e;function t(e,t){function n(){}n.prototype=t.prototype,e.F=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.D=function(e,n,r){for(var i=Array(arguments.length-2),a=2;a<arguments.length;a++)i[a-2]=arguments[a];return t.prototype[n].apply(e,i)}}function n(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=[,,,,],this.C=Array(this.blockSize),this.o=this.h=0,this.u()}t(r,n),r.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function i(e,t,n){n||=0;let r=Array(16);if(typeof t==`string`)for(var i=0;i<16;++i)r[i]=t.charCodeAt(n++)|t.charCodeAt(n++)<<8|t.charCodeAt(n++)<<16|t.charCodeAt(n++)<<24;else for(i=0;i<16;++i)r[i]=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24;t=e.g[0],n=e.g[1],i=e.g[2];let a=e.g[3],o;o=t+(a^n&(i^a))+r[0]+3614090360&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[1]+3905402710&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[2]+606105819&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[3]+3250441966&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(a^n&(i^a))+r[4]+4118548399&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[5]+1200080426&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[6]+2821735955&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[7]+4249261313&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(a^n&(i^a))+r[8]+1770035416&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[9]+2336552879&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[10]+4294925233&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[11]+2304563134&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(a^n&(i^a))+r[12]+1804603682&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[13]+4254626195&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[14]+2792965006&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[15]+1236535329&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(i^a&(n^i))+r[1]+4129170786&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[6]+3225465664&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[11]+643717713&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[0]+3921069994&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^a&(n^i))+r[5]+3593408605&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[10]+38016083&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[15]+3634488961&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[4]+3889429448&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^a&(n^i))+r[9]+568446438&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[14]+3275163606&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[3]+4107603335&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[8]+1163531501&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^a&(n^i))+r[13]+2850285829&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[2]+4243563512&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[7]+1735328473&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[12]+2368359562&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(n^i^a)+r[5]+4294588738&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[8]+2272392833&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[11]+1839030562&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[14]+4259657740&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(n^i^a)+r[1]+2763975236&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[4]+1272893353&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[7]+4139469664&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[10]+3200236656&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(n^i^a)+r[13]+681279174&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[0]+3936430074&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[3]+3572445317&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[6]+76029189&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(n^i^a)+r[9]+3654602809&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[12]+3873151461&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[15]+530742520&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[2]+3299628645&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(i^(n|~a))+r[0]+4096336452&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[7]+1126891415&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[14]+2878612391&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[5]+4237533241&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~a))+r[12]+1700485571&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[3]+2399980690&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[10]+4293915773&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[1]+2240044497&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~a))+r[8]+1873313359&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[15]+4264355552&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[6]+2734768916&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[13]+1309151649&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~a))+r[4]+4149444226&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[11]+3174756917&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[2]+718787259&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[9]+3951481745&4294967295,e.g[0]=e.g[0]+t&4294967295,e.g[1]=e.g[1]+(i+(o<<21&4294967295|o>>>11))&4294967295,e.g[2]=e.g[2]+i&4294967295,e.g[3]=e.g[3]+a&4294967295}r.prototype.v=function(e,t){t===void 0&&(t=e.length);let n=t-this.blockSize,r=this.C,a=this.h,o=0;for(;o<t;){if(a==0)for(;o<=n;)i(this,e,o),o+=this.blockSize;if(typeof e==`string`){for(;o<t;)if(r[a++]=e.charCodeAt(o++),a==this.blockSize){i(this,r),a=0;break}}else for(;o<t;)if(r[a++]=e[o++],a==this.blockSize){i(this,r),a=0;break}}this.h=a,this.o+=t},r.prototype.A=function(){var e=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;t=this.o*8;for(var n=e.length-8;n<e.length;++n)e[n]=t&255,t/=256;for(this.v(e),e=Array(16),t=0,n=0;n<4;++n)for(let r=0;r<32;r+=8)e[t++]=this.g[n]>>>r&255;return e};function a(e,t){var n=s;return Object.prototype.hasOwnProperty.call(n,e)?n[e]:n[e]=t(e)}function o(e,t){this.h=t;let n=[],r=!0;for(let i=e.length-1;i>=0;i--){let a=e[i]|0;r&&a==t||(n[i]=a,r=!1)}this.g=n}var s={};function c(e){return-128<=e&&e<128?a(e,function(e){return new o([e|0],e<0?-1:0)}):new o([e|0],e<0?-1:0)}function l(e){if(isNaN(e)||!isFinite(e))return d;if(e<0)return g(l(-e));let t=[],n=1;for(let r=0;e>=n;r++)t[r]=e/n|0,n*=4294967296;return new o(t,0)}function u(e,t){if(e.length==0)throw Error(`number format error: empty string`);if(t||=10,t<2||36<t)throw Error(`radix out of range: `+t);if(e.charAt(0)==`-`)return g(u(e.substring(1),t));if(e.indexOf(`-`)>=0)throw Error(`number format error: interior "-" character`);let n=l(t**8),r=d;for(let a=0;a<e.length;a+=8){var i=Math.min(8,e.length-a);let o=parseInt(e.substring(a,a+i),t);i<8?(i=l(t**+i),r=r.j(i).add(l(o))):(r=r.j(n),r=r.add(l(o)))}return r}var d=c(0),f=c(1),p=c(16777216);e=o.prototype,e.m=function(){if(h(this))return-g(this).m();let e=0,t=1;for(let n=0;n<this.g.length;n++){let r=this.i(n);e+=(r>=0?r:4294967296+r)*t,t*=4294967296}return e},e.toString=function(e){if(e||=10,e<2||36<e)throw Error(`radix out of range: `+e);if(m(this))return`0`;if(h(this))return`-`+g(this).toString(e);let t=l(e**6);var n=this;let r=``;for(;;){let i=re(n,t).g;n=ee(n,i.j(t));let a=((n.g.length>0?n.g[0]:n.h)>>>0).toString(e);if(n=i,m(n))return a+r;for(;a.length<6;)a=`0`+a;r=a+r}},e.i=function(e){return e<0?0:e<this.g.length?this.g[e]:this.h};function m(e){if(e.h!=0)return!1;for(let t=0;t<e.g.length;t++)if(e.g[t]!=0)return!1;return!0}function h(e){return e.h==-1}e.l=function(e){return e=ee(this,e),h(e)?-1:+!m(e)};function g(e){let t=e.g.length,n=[];for(let r=0;r<t;r++)n[r]=~e.g[r];return new o(n,~e.h).add(f)}e.abs=function(){return h(this)?g(this):this},e.add=function(e){let t=Math.max(this.g.length,e.g.length),n=[],r=0;for(let i=0;i<=t;i++){let t=r+(this.i(i)&65535)+(e.i(i)&65535),a=(t>>>16)+(this.i(i)>>>16)+(e.i(i)>>>16);r=a>>>16,t&=65535,a&=65535,n[i]=a<<16|t}return new o(n,n[n.length-1]&-2147483648?-1:0)};function ee(e,t){return e.add(g(t))}e.j=function(e){if(m(this)||m(e))return d;if(h(this))return h(e)?g(this).j(g(e)):g(g(this).j(e));if(h(e))return g(this.j(g(e)));if(this.l(p)<0&&e.l(p)<0)return l(this.m()*e.m());let t=this.g.length+e.g.length,n=[];for(var r=0;r<2*t;r++)n[r]=0;for(r=0;r<this.g.length;r++)for(let t=0;t<e.g.length;t++){let i=this.i(r)>>>16,a=this.i(r)&65535,o=e.i(t)>>>16,s=e.i(t)&65535;n[2*r+2*t]+=a*s,te(n,2*r+2*t),n[2*r+2*t+1]+=i*s,te(n,2*r+2*t+1),n[2*r+2*t+1]+=a*o,te(n,2*r+2*t+1),n[2*r+2*t+2]+=i*o,te(n,2*r+2*t+2)}for(e=0;e<t;e++)n[e]=n[2*e+1]<<16|n[2*e];for(e=t;e<2*t;e++)n[e]=0;return new o(n,0)};function te(e,t){for(;(e[t]&65535)!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function ne(e,t){this.g=e,this.h=t}function re(e,t){if(m(t))throw Error(`division by zero`);if(m(e))return new ne(d,d);if(h(e))return t=re(g(e),t),new ne(g(t.g),g(t.h));if(h(t))return t=re(e,g(t)),new ne(g(t.g),t.h);if(e.g.length>30){if(h(e)||h(t))throw Error(`slowDivide_ only works with positive integers.`);for(var n=f,r=t;r.l(e)<=0;)n=ie(n),r=ie(r);var i=ae(n,1),a=ae(r,1);for(r=ae(r,2),n=ae(n,2);!m(r);){var o=a.add(r);o.l(e)<=0&&(i=i.add(n),a=o),r=ae(r,1),n=ae(n,1)}return t=ee(e,i.j(t)),new ne(i,t)}for(i=d;e.l(t)>=0;){for(n=Math.max(1,Math.floor(e.m()/t.m())),r=Math.ceil(Math.log(n)/Math.LN2),r=r<=48?1:2**(r-48),a=l(n),o=a.j(t);h(o)||o.l(e)>0;)n-=r,a=l(n),o=a.j(t);m(a)&&(a=f),i=i.add(a),e=ee(e,o)}return new ne(i,e)}e.B=function(e){return re(this,e).h},e.and=function(e){let t=Math.max(this.g.length,e.g.length),n=[];for(let r=0;r<t;r++)n[r]=this.i(r)&e.i(r);return new o(n,this.h&e.h)},e.or=function(e){let t=Math.max(this.g.length,e.g.length),n=[];for(let r=0;r<t;r++)n[r]=this.i(r)|e.i(r);return new o(n,this.h|e.h)},e.xor=function(e){let t=Math.max(this.g.length,e.g.length),n=[];for(let r=0;r<t;r++)n[r]=this.i(r)^e.i(r);return new o(n,this.h^e.h)};function ie(e){let t=e.g.length+1,n=[];for(let r=0;r<t;r++)n[r]=e.i(r)<<1|e.i(r-1)>>>31;return new o(n,e.h)}function ae(e,t){let n=t>>5;t%=32;let r=e.g.length-n,i=[];for(let a=0;a<r;a++)i[a]=t>0?e.i(a+n)>>>t|e.i(a+n+1)<<32-t:e.i(a+n);return new o(i,e.h)}r.prototype.digest=r.prototype.A,r.prototype.reset=r.prototype.u,r.prototype.update=r.prototype.v,wn=Sn.Md5=r,o.prototype.add=o.prototype.add,o.prototype.multiply=o.prototype.j,o.prototype.modulo=o.prototype.B,o.prototype.compare=o.prototype.l,o.prototype.toNumber=o.prototype.m,o.prototype.toString=o.prototype.toString,o.prototype.getBits=o.prototype.i,o.fromNumber=l,o.fromString=u,Cn=Sn.Integer=o}).apply(xn===void 0?typeof self<`u`?self:typeof window<`u`?window:{}:xn);var Tn=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},En={},Dn,On,kn,An,jn,Mn,Nn,Pn;(function(){var e,t=Object.defineProperty;function n(e){e=[typeof globalThis==`object`&&globalThis,e,typeof window==`object`&&window,typeof self==`object`&&self,typeof Tn==`object`&&Tn];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`)}var r=n(this);function i(e,n){if(n)a:{var i=r;e=e.split(`.`);for(var a=0;a<e.length-1;a++){var o=e[a];if(!(o in i))break a;i=i[o]}e=e[e.length-1],a=i[e],n=n(a),n!=a&&n!=null&&t(i,e,{configurable:!0,writable:!0,value:n})}}i(`Symbol.dispose`,function(e){return e||Symbol(`Symbol.dispose`)}),i(`Array.prototype.values`,function(e){return e||function(){return this[Symbol.iterator]()}}),i(`Object.entries`,function(e){return e||function(e){var t=[],n;for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push([n,e[n]]);return t}});var a=a||{},o=this||self;function s(e){var t=typeof e;return t==`object`&&e!=null||t==`function`}function c(e,t,n){return e.call.apply(e.bind,arguments)}function l(e,t,n){return l=c,l.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 d(e,t){function n(){}n.prototype=t.prototype,e.Z=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Ob=function(e,n,r){for(var i=Array(arguments.length-2),a=2;a<arguments.length;a++)i[a-2]=arguments[a];return t.prototype[n].apply(e,i)}}var f=typeof AsyncContext<`u`&&typeof AsyncContext.Snapshot==`function`?e=>e&&AsyncContext.Snapshot.wrap(e):e=>e;function p(e){let t=e.length;if(t>0){let n=Array(t);for(let r=0;r<t;r++)n[r]=e[r];return n}return[]}function m(e,t){for(let t=1;t<arguments.length;t++){let r=arguments[t];var n=typeof r;if(n=n==`object`?r?Array.isArray(r)?`array`:n:`null`:n,n==`array`||n==`object`&&typeof r.length==`number`){n=e.length||0;let t=r.length||0;e.length=n+t;for(let i=0;i<t;i++)e[n+i]=r[i]}else e.push(r)}}class h{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return this.h>0?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}function g(e){o.setTimeout(()=>{throw e},0)}function ee(){var e=oe;let t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}class te{constructor(){this.h=this.g=null}add(e,t){let n=ne.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}}var ne=new h(()=>new re,e=>e.reset());class re{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 ie,ae=!1,oe=new te,se=()=>{let e=Promise.resolve(void 0);ie=()=>{e.then(ce)}};function ce(){for(var e;e=ee();){try{e.h.call(e.g)}catch(e){g(e)}var t=ne;t.j(e),t.h<100&&(t.h++,e.next=t.g,t.g=e)}ae=!1}function le(){this.u=this.u,this.C=this.C}le.prototype.u=!1,le.prototype.dispose=function(){this.u||(this.u=!0,this.N())},le.prototype[Symbol.dispose]=function(){this.dispose()},le.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function ue(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}ue.prototype.h=function(){this.defaultPrevented=!0};var de=function(){if(!o.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{let e=()=>{};o.addEventListener(`test`,e,t),o.removeEventListener(`test`,e,t)}catch{}return e}();function fe(e){return/^[\s\xa0]*$/.test(e)}function pe(e,t){ue.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&&this.init(e,t)}d(pe,ue),pe.prototype.init=function(e,t){let n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget,t||(n==`mouseover`?t=e.fromElement:n==`mouseout`&&(t=e.toElement)),this.relatedTarget=t,r?(this.clientX=r.clientX===void 0?r.pageX:r.clientX,this.clientY=r.clientY===void 0?r.pageY:r.clientY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=e.clientX===void 0?e.pageX:e.clientX,this.clientY=e.clientY===void 0?e.pageY:e.clientY,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=e.pointerType,this.state=e.state,this.i=e,e.defaultPrevented&&pe.Z.h.call(this)},pe.prototype.h=function(){pe.Z.h.call(this);let e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var me=`closure_listenable_`+(Math.random()*1e6|0),he=0;function ge(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ha=i,this.key=++he,this.da=this.fa=!1}function _e(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function ve(e,t,n){for(let r in e)t.call(n,e[r],r,e)}function ye(e,t){for(let n in e)t.call(void 0,e[n],n,e)}function be(e){let t={};for(let n in e)t[n]=e[n];return t}let xe=`constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf`.split(` `);function Se(e,t){let n,r;for(let t=1;t<arguments.length;t++){for(n in r=arguments[t],r)e[n]=r[n];for(let t=0;t<xe.length;t++)n=xe[t],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function Ce(e){this.src=e,this.g={},this.h=0}Ce.prototype.add=function(e,t,n,r,i){let a=e.toString();e=this.g[a],e||(e=this.g[a]=[],this.h++);let o=Te(e,t,r,i);return o>-1?(t=e[o],n||(t.fa=!1)):(t=new ge(t,this.src,a,!!r,i),t.fa=n,e.push(t)),t};function we(e,t){let n=t.type;if(n in e.g){var r=e.g[n],i=Array.prototype.indexOf.call(r,t,void 0),a;(a=i>=0)&&Array.prototype.splice.call(r,i,1),a&&(_e(t),e.g[n].length==0&&(delete e.g[n],e.h--))}}function Te(e,t,n,r){for(let i=0;i<e.length;++i){let a=e[i];if(!a.da&&a.listener==t&&a.capture==!!n&&a.ha==r)return i}return-1}var Ee=`closure_lm_`+(Math.random()*1e6|0),De={};function _(e,t,n,r,i){if(r&&r.once)return Ae(e,t,n,r,i);if(Array.isArray(t)){for(let a=0;a<t.length;a++)_(e,t[a],n,r,i);return null}return n=v(n),e&&e[me]?e.J(t,n,s(r)?!!r.capture:!!r,i):Oe(e,t,n,!1,r,i)}function Oe(e,t,n,r,i,a){if(!t)throw Error(`Invalid event type`);let o=s(i)?!!i.capture:!!i,c=Fe(e);if(c||(e[Ee]=c=new Ce(e)),n=c.add(t,n,r,o,a),n.proxy)return n;if(r=ke(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)de||(i=o),i===void 0&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(Ne(t.toString()),r);else if(e.addListener&&e.removeListener)e.addListener(r);else throw Error(`addEventListener and attachEvent are unavailable.`);return n}function ke(){function e(n){return t.call(e.src,e.listener,n)}let t=Pe;return e}function Ae(e,t,n,r,i){if(Array.isArray(t)){for(let a=0;a<t.length;a++)Ae(e,t[a],n,r,i);return null}return n=v(n),e&&e[me]?e.K(t,n,s(r)?!!r.capture:!!r,i):Oe(e,t,n,!0,r,i)}function je(e,t,n,r,i){if(Array.isArray(t))for(var a=0;a<t.length;a++)je(e,t[a],n,r,i);else r=s(r)?!!r.capture:!!r,n=v(n),e&&e[me]?(e=e.i,a=String(t).toString(),a in e.g&&(t=e.g[a],n=Te(t,n,r,i),n>-1&&(_e(t[n]),Array.prototype.splice.call(t,n,1),t.length==0&&(delete e.g[a],e.h--)))):(e&&=Fe(e))&&(t=e.g[t.toString()],e=-1,t&&(e=Te(t,n,r,i)),(n=e>-1?t[e]:null)&&Me(n))}function Me(e){if(typeof e!=`number`&&e&&!e.da){var t=e.src;if(t&&t[me])we(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(Ne(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=Fe(t))?(we(n,e),n.h==0&&(n.src=null,t[Ee]=null)):_e(e)}}}function Ne(e){return e in De?De[e]:De[e]=`on`+e}function Pe(e,t){if(e.da)e=!0;else{t=new pe(t,this);let n=e.listener,r=e.ha||e.src;e.fa&&Me(e),e=n.call(r,t)}return e}function Fe(e){return e=e[Ee],e instanceof Ce?e:null}var Ie=`__closure_events_fn_`+(Math.random()*1e9>>>0);function v(e){return typeof e==`function`?e:(e[Ie]||(e[Ie]=function(t){return e.handleEvent(t)}),e[Ie])}function Le(){le.call(this),this.i=new Ce(this),this.M=this,this.G=null}d(Le,le),Le.prototype[me]=!0,Le.prototype.removeEventListener=function(e,t,n,r){je(this,e,t,n,r)};function Re(e,t){var n,r=e.G;if(r)for(n=[];r;r=r.G)n.push(r);if(e=e.M,r=t.type||t,typeof t==`string`)t=new ue(t,e);else if(t instanceof ue)t.target=t.target||e;else{var i=t;t=new ue(r,e),Se(t,i)}i=!0;let a,o;if(n)for(o=n.length-1;o>=0;o--)a=t.g=n[o],i=ze(a,r,!0,t)&&i;if(a=t.g=e,i=ze(a,r,!0,t)&&i,i=ze(a,r,!1,t)&&i,n)for(o=0;o<n.length;o++)a=t.g=n[o],i=ze(a,r,!1,t)&&i}Le.prototype.N=function(){if(Le.Z.N.call(this),this.i){var e=this.i;for(let t in e.g){let n=e.g[t];for(let e=0;e<n.length;e++)_e(n[e]);delete e.g[t],e.h--}}this.G=null},Le.prototype.J=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},Le.prototype.K=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};function ze(e,t,n,r){if(t=e.i.g[String(t)],!t)return!0;t=t.concat();let i=!0;for(let a=0;a<t.length;++a){let o=t[a];if(o&&!o.da&&o.capture==n){let t=o.listener,n=o.ha||o.src;o.fa&&we(e.i,o),i=t.call(n,r)!==!1&&i}}return i&&!r.defaultPrevented}function Be(e,t){if(typeof e!=`function`)if(e&&typeof e.handleEvent==`function`)e=l(e.handleEvent,e);else throw Error(`Invalid listener argument`);return Number(t)>2147483647?-1:o.setTimeout(e,t||0)}function Ve(e){e.g=Be(()=>{e.g=null,e.i&&(e.i=!1,Ve(e))},e.l);let t=e.h;e.h=null,e.m.apply(null,t)}class He extends le{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:Ve(this)}N(){super.N(),this.g&&(o.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Ue(e){le.call(this),this.h=e,this.g={}}d(Ue,le);var We=[];function Ge(e){ve(e.g,function(e,t){this.g.hasOwnProperty(t)&&Me(e)},e),e.g={}}Ue.prototype.N=function(){Ue.Z.N.call(this),Ge(this)},Ue.prototype.handleEvent=function(){throw Error(`EventHandler.handleEvent not implemented`)};var Ke=o.JSON.stringify,qe=o.JSON.parse,Je=class{stringify(e){return o.JSON.stringify(e,void 0)}parse(e){return o.JSON.parse(e,void 0)}};function Ye(){}function Xe(){}var Ze={OPEN:`a`,hb:`b`,ERROR:`c`,tb:`d`};function Qe(){ue.call(this,`d`)}d(Qe,ue);function $e(){ue.call(this,`c`)}d($e,ue);var et={},tt=null;function nt(){return tt||=new Le}et.Ia=`serverreachability`;function rt(e){ue.call(this,et.Ia,e)}d(rt,ue);function it(e){let t=nt();Re(t,new rt(t))}et.STAT_EVENT=`statevent`;function at(e,t){ue.call(this,et.STAT_EVENT,e),this.stat=t}d(at,ue);function ot(e){let t=nt();Re(t,new at(t,e))}et.Ja=`timingevent`;function st(e,t){ue.call(this,et.Ja,e),this.size=t}d(st,ue);function ct(e,t){if(typeof e!=`function`)throw Error(`Fn must not be null and must be a function`);return o.setTimeout(function(){e()},t)}function lt(){this.g=!0}lt.prototype.ua=function(){this.g=!1};function ut(e,t,n,r,i,a){e.info(function(){if(e.g)if(a){var o=``,s=a.split(`&`);for(let e=0;e<s.length;e++){var c=s[e].split(`=`);if(c.length>1){let e=c[0];c=c[1];let t=e.split(`_`);o=t.length>=2&&t[1]==`type`?o+(e+`=`+c+`&`):o+(e+`=redacted&`)}}}else o=null;else o=a;return`XMLHTTP REQ (`+r+`) [attempt `+i+`]: `+t+`
|
|
2
|
+
`+n+`
|
|
3
|
+
`+o})}function dt(e,t,n,r,i,a,o){e.info(function(){return`XMLHTTP RESP (`+r+`) [ attempt `+i+`]: `+t+`
|
|
4
|
+
`+n+`
|
|
5
|
+
`+a+` `+o})}function ft(e,t,n,r){e.info(function(){return`XMLHTTP TEXT (`+t+`): `+mt(e,n)+(r?` `+r:``)})}function pt(e,t){e.info(function(){return`TIMEOUT: `+t})}lt.prototype.info=function(){};function mt(e,t){if(!e.g)return t;if(!t)return null;try{let a=JSON.parse(t);if(a){for(e=0;e<a.length;e++)if(Array.isArray(a[e])){var n=a[e];if(!(n.length<2)){var r=n[1];if(Array.isArray(r)&&!(r.length<1)){var i=r[0];if(i!=`noop`&&i!=`stop`&&i!=`close`)for(let e=1;e<r.length;e++)r[e]=``}}}}return Ke(a)}catch{return t}}var ht={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},gt={ib:`complete`,Fb:`success`,ERROR:`error`,Ga:`abort`,xb:`ready`,yb:`readystatechange`,TIMEOUT:`timeout`,sb:`incrementaldata`,wb:`progress`,lb:`downloadprogress`,Nb:`uploadprogress`},_t;function vt(){}d(vt,Ye),vt.prototype.g=function(){return new XMLHttpRequest},_t=new vt;function yt(e){return encodeURIComponent(String(e))}function bt(e){var t=1;e=e.split(`:`);let n=[];for(;t>0&&e.length;)n.push(e.shift()),t--;return e.length&&n.push(e.join(`:`)),n}function xt(e,t,n,r){this.j=e,this.i=t,this.l=n,this.S=r||1,this.V=new Ue(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new St}function St(){this.i=null,this.g=``,this.h=!1}var Ct={},wt={};function Tt(e,t,n){e.M=1,e.A=Zt(qt(t)),e.u=n,e.R=!0,Et(e,null)}function Et(e,t){e.F=Date.now(),At(e),e.B=qt(e.A);var n=e.B,r=e.S;Array.isArray(r)||(r=[String(r)]),fn(n.i,`t`,r),e.C=0,n=e.j.L,e.h=new St,e.g=rr(e.j,n?t:null,!e.u),e.P>0&&(e.O=new He(l(e.Y,e,e.g),e.P)),t=e.V,n=e.g,r=e.ba;var i=`readystatechange`;Array.isArray(i)||(i&&(We[0]=i.toString()),i=We);for(let e=0;e<i.length;e++){let a=_(n,i[e],r||t.handleEvent,!1,t.h||t);if(!a)break;t.g[a.key]=a}t=e.J?be(e.J):{},e.u?(e.v||=`POST`,t[`Content-Type`]=`application/x-www-form-urlencoded`,e.g.ea(e.B,e.v,e.u,t)):(e.v=`GET`,e.g.ea(e.B,e.v,null,t)),it(),ut(e.i,e.v,e.B,e.l,e.S,e.u)}xt.prototype.ba=function(e){e=e.target;let t=this.O;t&&zn(e)==3?t.j():this.Y(e)},xt.prototype.Y=function(e){try{if(e==this.g)a:{let s=zn(this.g),c=this.g.ya(),l=this.g.ca();if(!(s<3)&&(s!=3||this.g&&(this.h.h||this.g.la()||Bn(this.g)))){this.K||s!=4||c==7||it(c==8||l<=0?3:2),Mt(this);var t=this.g.ca();this.X=t;var n=Dt(this);if(this.o=t==200,dt(this.i,this.v,this.B,this.l,this.S,s,t),this.o){if(this.U&&!this.L){b:{if(this.g){var r,i=this.g;if((r=i.g?i.g.getResponseHeader(`X-HTTP-Initial-Response`):null)&&!fe(r)){var a=r;break b}}a=null}if(e=a)ft(this.i,this.l,e,`Initial handshake response via X-HTTP-Initial-Response`),this.L=!0,Ft(this,e);else{this.o=!1,this.m=3,ot(12),Pt(this),Nt(this);break a}}if(this.R){e=!0;let t;for(;!this.K&&this.C<n.length;)if(t=kt(this,n),t==wt){s==4&&(this.m=4,ot(14),e=!1),ft(this.i,this.l,null,`[Incomplete Response]`);break}else if(t==Ct){this.m=4,ot(15),ft(this.i,this.l,n,`[Invalid Chunk]`),e=!1;break}else ft(this.i,this.l,t,null),Ft(this,t);if(Ot(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),s!=4||n.length!=0||this.h.h||(this.m=1,ot(16),e=!1),this.o=this.o&&e,!e)ft(this.i,this.l,n,`[Invalid Chunked Response]`),Pt(this),Nt(this);else if(n.length>0&&!this.W){this.W=!0;var o=this.j;o.g==this&&o.aa&&!o.P&&(o.j.info(`Great, no buffering proxy detected. Bytes received: `+n.length),Xn(o),o.P=!0,ot(11))}}else ft(this.i,this.l,n,null),Ft(this,n);s==4&&Pt(this),this.o&&!this.K&&(s==4?Qn(this.j,this):(this.o=!1,At(this)))}else T(this.g),t==400&&n.indexOf(`Unknown SID`)>0?(this.m=3,ot(12)):(this.m=0,ot(13)),Pt(this),Nt(this)}}}catch{}};function Dt(e){if(!Ot(e))return e.g.la();let t=Bn(e.g);if(t===``)return``;let n=``,r=t.length,i=zn(e.g)==4;if(!e.h.i){if(typeof TextDecoder>`u`)return Pt(e),Nt(e),``;e.h.i=new o.TextDecoder}for(let a=0;a<r;a++)e.h.h=!0,n+=e.h.i.decode(t[a],{stream:!(i&&a==r-1)});return t.length=0,e.h.g+=n,e.C=0,e.h.g}function Ot(e){return e.g?e.v==`GET`&&e.M!=2&&e.j.Aa:!1}function kt(e,t){var n=e.C,r=t.indexOf(`
|
|
6
|
+
`,n);return r==-1?wt:(n=Number(t.substring(n,r)),isNaN(n)?Ct:(r+=1,r+n>t.length?wt:(t=t.slice(r,r+n),e.C=r+n,t)))}xt.prototype.cancel=function(){this.K=!0,Pt(this)};function At(e){e.T=Date.now()+e.H,jt(e,e.H)}function jt(e,t){if(e.D!=null)throw Error(`WatchDog timer not null`);e.D=ct(l(e.aa,e),t)}function Mt(e){e.D&&=(o.clearTimeout(e.D),null)}xt.prototype.aa=function(){this.D=null;let e=Date.now();e-this.T>=0?(pt(this.i,this.B),this.M!=2&&(it(),ot(17)),Pt(this),this.m=2,Nt(this)):jt(this,this.T-e)};function Nt(e){e.j.I==0||e.K||Qn(e.j,e)}function Pt(e){Mt(e);var t=e.O;t&&typeof t.dispose==`function`&&t.dispose(),e.O=null,Ge(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.dispose())}function Ft(e,t){try{var n=e.j;if(n.I!=0&&(n.g==e||Bt(n.h,e))){if(!e.L&&Bt(n.h,e)&&n.I==3){try{var r=n.Ba.g.parse(t)}catch{r=null}if(Array.isArray(r)&&r.length==3){var i=r;if(i[0]==0){a:if(!n.v){if(n.g)if(n.g.F+3e3<e.F)k(n),Wn(n);else break a;Yn(n),ot(18)}}else n.xa=i[1],0<n.xa-n.K&&i[2]<37500&&n.F&&n.A==0&&!n.C&&(n.C=ct(l(n.Va,n),6e3));zt(n.h)<=1&&n.ta&&(n.ta=void 0)}else er(n,11)}else if((e.L||n.g==e)&&k(n),!fe(t))for(i=n.Ba.g.parse(t),t=0;t<i.length;t++){let l=i[t],u=l[0];if(!(u<=n.K))if(n.K=u,l=l[1],n.I==2)if(l[0]==`c`){n.M=l[1],n.ba=l[2];let t=l[3];t!=null&&(n.ka=t,n.j.info(`VER=`+n.ka));let i=l[4];i!=null&&(n.za=i,n.j.info(`SVER=`+n.za));let u=l[5];u!=null&&typeof u==`number`&&u>0&&(r=1.5*u,n.O=r,n.j.info(`backChannelRequestTimeoutMs_=`+r)),r=n;let d=e.g;if(d){let e=d.g?d.g.getResponseHeader(`X-Client-Wire-Protocol`):null;if(e){var a=r.h;a.g||e.indexOf(`spdy`)==-1&&e.indexOf(`quic`)==-1&&e.indexOf(`h2`)==-1||(a.j=a.l,a.g=new Set,a.h&&=(Vt(a,a.h),null))}if(r.G){let e=d.g?d.g.getResponseHeader(`X-HTTP-Session-Id`):null;e&&(r.wa=e,y(r.J,r.G,e))}}n.I=3,n.l&&n.l.ra(),n.aa&&(n.T=Date.now()-e.F,n.j.info(`Handshake RTT: `+n.T+`ms`)),r=n;var o=e;if(r.na=nr(r,r.L?r.ba:null,r.W),o.L){Ht(r.h,o);var s=o,c=r.O;c&&(s.H=c),s.D&&(Mt(s),At(s)),r.g=o}else Jn(r);n.i.length>0&&Kn(n)}else l[0]!=`stop`&&l[0]!=`close`||er(n,7);else n.I==3&&(l[0]==`stop`||l[0]==`close`?l[0]==`stop`?er(n,7):Un(n):l[0]!=`noop`&&n.l&&n.l.qa(l),n.A=0)}}it(4)}catch{}}var It=class{constructor(e,t){this.g=e,this.map=t}};function Lt(e){this.l=e||10,o.PerformanceNavigationTiming?(e=o.performance.getEntriesByType(`navigation`),e=e.length>0&&(e[0].nextHopProtocol==`hq`||e[0].nextHopProtocol==`h2`)):e=!!(o.chrome&&o.chrome.loadTimes&&o.chrome.loadTimes()&&o.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function Rt(e){return e.h?!0:e.g?e.g.size>=e.j:!1}function zt(e){return e.h?1:e.g?e.g.size:0}function Bt(e,t){return e.h?e.h==t:e.g?e.g.has(t):!1}function Vt(e,t){e.g?e.g.add(t):e.h=t}function Ht(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}Lt.prototype.cancel=function(){if(this.i=Ut(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(let e of this.g.values())e.cancel();this.g.clear()}};function Ut(e){if(e.h!=null)return e.i.concat(e.h.G);if(e.g!=null&&e.g.size!==0){let t=e.i;for(let n of e.g.values())t=t.concat(n.G);return t}return p(e.i)}var Wt=RegExp(`^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$`);function Gt(e,t){if(e){e=e.split(`&`);for(let n=0;n<e.length;n++){let r=e[n].indexOf(`=`),i,a=null;r>=0?(i=e[n].substring(0,r),a=e[n].substring(r+1)):i=e[n],t(i,a?decodeURIComponent(a.replace(/\+/g,` `)):``)}}}function Kt(e){this.g=this.o=this.j=``,this.u=null,this.m=this.h=``,this.l=!1;let t;e instanceof Kt?(this.l=e.l,Jt(this,e.j),this.o=e.o,this.g=e.g,Yt(this,e.u),this.h=e.h,Xt(this,pn(e.i)),this.m=e.m):e&&(t=String(e).match(Wt))?(this.l=!1,Jt(this,t[1]||``,!0),this.o=Qt(t[2]||``),this.g=Qt(t[3]||``,!0),Yt(this,t[4]),this.h=Qt(t[5]||``,!0),Xt(this,t[6]||``,!0),this.m=Qt(t[7]||``)):(this.l=!1,this.i=new sn(null,this.l))}Kt.prototype.toString=function(){let e=[];var t=this.j;t&&e.push($t(t,tn,!0),`:`);var n=this.g;return(n||t==`file`)&&(e.push(`//`),(t=this.o)&&e.push($t(t,tn,!0),`@`),e.push(yt(n).replace(/%25([0-9a-fA-F]{2})/g,`%$1`)),n=this.u,n!=null&&e.push(`:`,String(n))),(n=this.h)&&(this.g&&n.charAt(0)!=`/`&&e.push(`/`),e.push($t(n,n.charAt(0)==`/`?rn:nn,!0))),(n=this.i.toString())&&e.push(`?`,n),(n=this.m)&&e.push(`#`,$t(n,on)),e.join(``)},Kt.prototype.resolve=function(e){let t=qt(this),n=!!e.j;n?Jt(t,e.j):n=!!e.o,n?t.o=e.o:n=!!e.g,n?t.g=e.g:n=e.u!=null;var r=e.h;if(n)Yt(t,e.u);else if(n=!!e.h){if(r.charAt(0)!=`/`)if(this.g&&!this.h)r=`/`+r;else{var i=t.h.lastIndexOf(`/`);i!=-1&&(r=t.h.slice(0,i+1)+r)}if(i=r,i==`..`||i==`.`)r=``;else if(i.indexOf(`./`)!=-1||i.indexOf(`/.`)!=-1){r=i.lastIndexOf(`/`,0)==0,i=i.split(`/`);let e=[];for(let t=0;t<i.length;){let n=i[t++];n==`.`?r&&t==i.length&&e.push(``):n==`..`?((e.length>1||e.length==1&&e[0]!=``)&&e.pop(),r&&t==i.length&&e.push(``)):(e.push(n),r=!0)}r=e.join(`/`)}else r=i}return n?t.h=r:n=e.i.toString()!==``,n?Xt(t,pn(e.i)):n=!!e.m,n&&(t.m=e.m),t};function qt(e){return new Kt(e)}function Jt(e,t,n){e.j=n?Qt(t,!0):t,e.j&&=e.j.replace(/:$/,``)}function Yt(e,t){if(t){if(t=Number(t),isNaN(t)||t<0)throw Error(`Bad port number `+t);e.u=t}else e.u=null}function Xt(e,t,n){t instanceof sn?(e.i=t,hn(e.i,e.l)):(n||(t=$t(t,an)),e.i=new sn(t,e.l))}function y(e,t,n){e.i.set(t,n)}function Zt(e){return y(e,`zx`,Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),e}function Qt(e,t){return e?t?decodeURI(e.replace(/%25/g,`%2525`)):decodeURIComponent(e):``}function $t(e,t,n){return typeof e==`string`?(e=encodeURI(e).replace(t,en),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,`%$1`)),e):null}function en(e){return e=e.charCodeAt(0),`%`+(e>>4&15).toString(16)+(e&15).toString(16)}var tn=/[#\/\?@]/g,nn=/[#\?:]/g,rn=/[#\?]/g,an=/[#\?@]/g,on=/#/g;function sn(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function cn(e){e.g||(e.g=new Map,e.h=0,e.i&&Gt(e.i,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g,` `)),n)}))}e=sn.prototype,e.add=function(e,t){cn(this),this.i=null,e=mn(this,e);let n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this};function ln(e,t){cn(e),t=mn(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function un(e,t){return cn(e),t=mn(e,t),e.g.has(t)}e.forEach=function(e,t){cn(this),this.g.forEach(function(n,r){n.forEach(function(n){e.call(t,n,r,this)},this)},this)};function dn(e,t){cn(e);let n=[];if(typeof t==`string`)un(e,t)&&(n=n.concat(e.g.get(mn(e,t))));else for(e=Array.from(e.g.values()),t=0;t<e.length;t++)n=n.concat(e[t]);return n}e.set=function(e,t){return cn(this),this.i=null,e=mn(this,e),un(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?(e=dn(this,e),e.length>0?String(e[0]):t):t};function fn(e,t,n){ln(e,t),n.length>0&&(e.i=null,e.g.set(mn(e,t),p(n)),e.h+=n.length)}e.toString=function(){if(this.i)return this.i;if(!this.g)return``;let e=[],t=Array.from(this.g.keys());for(let r=0;r<t.length;r++){var n=t[r];let i=yt(n);n=dn(this,n);for(let t=0;t<n.length;t++){let r=i;n[t]!==``&&(r+=`=`+yt(n[t])),e.push(r)}}return this.i=e.join(`&`)};function pn(e){let t=new sn;return t.i=e.i,e.g&&(t.g=new Map(e.g),t.h=e.h),t}function mn(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function hn(e,t){t&&!e.j&&(cn(e),e.i=null,e.g.forEach(function(e,t){let n=t.toLowerCase();t!=n&&(ln(this,t),fn(this,n,e))},e)),e.j=t}function gn(e,t){let n=new lt;if(o.Image){let r=new Image;r.onload=u(vn,n,`TestLoadImage: loaded`,!0,t,r),r.onerror=u(vn,n,`TestLoadImage: error`,!1,t,r),r.onabort=u(vn,n,`TestLoadImage: abort`,!1,t,r),r.ontimeout=u(vn,n,`TestLoadImage: timeout`,!1,t,r),o.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}function _n(e,t){let n=new lt,r=new AbortController,i=setTimeout(()=>{r.abort(),vn(n,`TestPingServer: timeout`,!1,t)},1e4);fetch(e,{signal:r.signal}).then(e=>{clearTimeout(i),e.ok?vn(n,`TestPingServer: ok`,!0,t):vn(n,`TestPingServer: server error`,!1,t)}).catch(()=>{clearTimeout(i),vn(n,`TestPingServer: error`,!1,t)})}function vn(e,t,n,r,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),r(n)}catch{}}function yn(){this.g=new Je}function bn(e){this.i=e.Sb||null,this.h=e.ab||!1}d(bn,Ye),bn.prototype.g=function(){return new xn(this.i,this.h)};function xn(e,t){Le.call(this),this.H=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.A=new Headers,this.h=null,this.F=`GET`,this.D=``,this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}d(xn,Le),e=xn.prototype,e.open=function(e,t){if(this.readyState!=0)throw this.abort(),Error(`Error reopening a connection`);this.F=e,this.D=t,this.readyState=1,wn(this)},e.send=function(e){if(this.readyState!=1)throw this.abort(),Error(`need to call open() first. `);if(this.v.signal.aborted)throw this.abort(),Error(`Request was aborted.`);this.g=!0;let t={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};e&&(t.body=e),(this.H||o).fetch(new Request(this.D,t)).then(this.Pa.bind(this),this.ga.bind(this))},e.abort=function(){this.response=this.responseText=``,this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel(`Request was aborted.`).catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,Cn(this)),this.readyState=0},e.Pa=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,wn(this)),this.g&&(this.readyState=3,wn(this),this.g)))if(this.responseType===`arraybuffer`)e.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(o.ReadableStream!==void 0&&`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.B=new TextDecoder;Sn(this)}else e.text().then(this.Oa.bind(this),this.ga.bind(this))};function Sn(e){e.j.read().then(e.Ma.bind(e)).catch(e.ga.bind(e))}e.Ma=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;(t=this.B.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?Cn(this):wn(this),this.readyState==3&&Sn(this)}},e.Oa=function(e){this.g&&(this.response=this.responseText=e,Cn(this))},e.Na=function(e){this.g&&(this.response=e,Cn(this))},e.ga=function(){this.g&&Cn(this)};function Cn(e){e.readyState=4,e.l=null,e.j=null,e.B=null,wn(e)}e.setRequestHeader=function(e,t){this.A.append(e,t)},e.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||``},e.getAllResponseHeaders=function(){if(!this.h)return``;let 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
|
|
7
|
+
`)};function wn(e){e.onreadystatechange&&e.onreadystatechange.call(e)}Object.defineProperty(xn.prototype,"withCredentials",{get:function(){return this.m===`include`},set:function(e){this.m=e?`include`:`same-origin`}});function b(e){let t=``;return ve(e,function(e,n){t+=n,t+=`:`,t+=e,t+=`\r
|
|
8
|
+
`}),t}function x(e,t,n){a:{for(r in n){var r=!1;break a}r=!0}r||(n=b(n),typeof e==`string`||y(e,t,n))}function S(e){Le.call(this),this.headers=new Map,this.L=e||null,this.h=!1,this.g=null,this.D=``,this.o=0,this.l=``,this.j=this.B=this.v=this.A=!1,this.m=null,this.F=``,this.H=!1}d(S,Le);var C=/^https?$/i,w=[`POST`,`PUT`];e=S.prototype,e.Fa=function(e){this.H=e},e.ea=function(e,t,n,r){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.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():_t.g(),this.g.onreadystatechange=f(l(this.Ca,this));try{this.B=!0,this.g.open(t,String(e),!0),this.B=!1}catch(e){Fn(this,e);return}if(e=n||``,n=new Map(this.headers),r)if(Object.getPrototypeOf(r)===Object.prototype)for(var i in r)n.set(i,r[i]);else if(typeof r.keys==`function`&&typeof r.get==`function`)for(let e of r.keys())n.set(e,r.get(e));else throw Error(`Unknown input type for opt_headers: `+String(r));r=Array.from(n.keys()).find(e=>e.toLowerCase()==`content-type`),i=o.FormData&&e instanceof o.FormData,!(Array.prototype.indexOf.call(w,t,void 0)>=0)||r||i||n.set(`Content-Type`,`application/x-www-form-urlencoded;charset=utf-8`);for(let[e,t]of n)this.g.setRequestHeader(e,t);this.F&&(this.g.responseType=this.F),`withCredentials`in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&=(clearTimeout(this.m),null),this.v=!0,this.g.send(e),this.v=!1}catch(e){Fn(this,e)}};function Fn(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.o=5,In(e),Rn(e)}function In(e){e.A||(e.A=!0,Re(e,`complete`),Re(e,`error`))}e.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=e||7,Re(this,`complete`),Re(this,`abort`),Rn(this))},e.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Rn(this,!0)),S.Z.N.call(this)},e.Ca=function(){this.u||(this.B||this.v||this.j?Ln(this):this.Xa())},e.Xa=function(){Ln(this)};function Ln(e){if(e.h&&a!==void 0){if(e.v&&zn(e)==4)setTimeout(e.Ca.bind(e),0);else if(Re(e,`readystatechange`),zn(e)==4){e.h=!1;try{let a=e.ca();a:switch(a){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var t=!0;break a;default:t=!1}var n;if(!(n=t)){var r;if(r=a===0){let t=String(e.D).match(Wt)[1]||null;!t&&o.self&&o.self.location&&(t=o.self.location.protocol.slice(0,-1)),r=!C.test(t?t.toLowerCase():``)}n=r}if(n)Re(e,`complete`),Re(e,`success`);else{e.o=6;try{var i=zn(e)>2?e.g.statusText:``}catch{i=``}e.l=i+` [`+e.ca()+`]`,In(e)}}finally{Rn(e)}}}}function Rn(e,t){if(e.g){e.m&&=(clearTimeout(e.m),null);let n=e.g;e.g=null,t||Re(e,`ready`);try{n.onreadystatechange=null}catch{}}}e.isActive=function(){return!!this.g};function zn(e){return e.g?e.g.readyState:0}e.ca=function(){try{return zn(this)>2?this.g.status:-1}catch{return-1}},e.la=function(){try{return this.g?this.g.responseText:``}catch{return``}},e.La=function(e){if(this.g){var t=this.g.responseText;return e&&t.indexOf(e)==0&&(t=t.substring(e.length)),qe(t)}};function Bn(e){try{if(!e.g)return null;if(`response`in e.g)return e.g.response;switch(e.F){case``:case`text`:return e.g.responseText;case`arraybuffer`:if(`mozResponseArrayBuffer`in e.g)return e.g.mozResponseArrayBuffer}return null}catch{return null}}function T(e){let t={};e=(e.g&&zn(e)>=2&&e.g.getAllResponseHeaders()||``).split(`\r
|
|
9
|
+
`);for(let r=0;r<e.length;r++){if(fe(e[r]))continue;var n=bt(e[r]);let i=n[0];if(n=n[1],typeof n!=`string`)continue;n=n.trim();let a=t[i]||[];t[i]=a,a.push(n)}ye(t,function(e){return e.join(`, `)})}e.ya=function(){return this.o},e.Ha=function(){return typeof this.l==`string`?this.l:String(this.l)};function Vn(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function Hn(e){this.za=0,this.i=[],this.j=new lt,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=Vn(`failFast`,!1,e),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=Vn(`baseRetryDelayMs`,5e3,e),this.Za=Vn(`retryDelaySeedMs`,1e4,e),this.Ta=Vn(`forwardChannelMaxRetries`,2,e),this.va=Vn(`forwardChannelRequestTimeoutMs`,2e4,e),this.ma=e&&e.xmlHttpFactory||void 0,this.Ua=e&&e.Rb||void 0,this.Aa=e&&e.useFetchStreams||!1,this.O=void 0,this.L=e&&e.supportsCrossDomainXhr||!1,this.M=``,this.h=new Lt(e&&e.concurrentRequestLimit),this.Ba=new yn,this.S=e&&e.fastHandshake||!1,this.R=e&&e.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=e&&e.Pb||!1,e&&e.ua&&this.j.ua(),e&&e.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&e&&e.detectBufferingProxy||!1,this.ia=void 0,e&&e.longPollingTimeout&&e.longPollingTimeout>0&&(this.ia=e.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}e=Hn.prototype,e.ka=8,e.I=1,e.connect=function(e,t,n,r){ot(0),this.W=e,this.H=t||{},n&&r!==void 0&&(this.H.OSID=n,this.H.OAID=r),this.F=this.X,this.J=nr(this,null,this.W),Kn(this)};function Un(e){if(Gn(e),e.I==3){var t=e.V++,n=qt(e.J);if(y(n,`SID`,e.M),y(n,`RID`,t),y(n,`TYPE`,`terminate`),D(e,n),t=new xt(e,e.j,t),t.M=2,t.A=Zt(qt(n)),n=!1,o.navigator&&o.navigator.sendBeacon)try{n=o.navigator.sendBeacon(t.A.toString(),``)}catch{}!n&&o.Image&&(new Image().src=t.A,n=!0),n||(t.g=rr(t.j,null),t.g.ea(t.A)),t.F=Date.now(),At(t)}tr(e)}function Wn(e){e.g&&=(Xn(e),e.g.cancel(),null)}function Gn(e){Wn(e),e.v&&=(o.clearTimeout(e.v),null),k(e),e.h.cancel(),e.m&&=(typeof e.m==`number`&&o.clearTimeout(e.m),null)}function Kn(e){if(!Rt(e.h)&&!e.m){e.m=!0;var t=e.Ea;ie||se(),ae||=(ie(),!0),oe.add(t,e),e.D=0}}function qn(e,t){return zt(e.h)>=e.h.j-+!!e.m?!1:e.m?(e.i=t.G.concat(e.i),!0):e.I==1||e.I==2||e.D>=(e.Sa?0:e.Ta)?!1:(e.m=ct(l(e.Ea,e,t),$n(e,e.D)),e.D++,!0)}e.Ea=function(e){if(this.m)if(this.m=null,this.I==1){if(!e){this.V=Math.floor(Math.random()*1e5),e=this.V++;let i=new xt(this,this.j,e),a=this.o;if(this.U&&(a?(a=be(a),Se(a,this.U)):a=this.U),this.u!==null||this.R||(i.J=a,a=null),this.S)a:{for(var t=0,n=0;n<this.i.length;n++){b:{var r=this.i[n];if(`__data__`in r.map&&(r=r.map.__data__,typeof r==`string`)){r=r.length;break b}r=void 0}if(r===void 0)break;if(t+=r,t>4096){t=n;break a}if(t===4096||n===this.i.length-1){t=n+1;break a}}t=1e3}else t=1e3;t=O(this,i,t),n=qt(this.J),y(n,`RID`,e),y(n,`CVER`,22),this.G&&y(n,`X-HTTP-Session-Id`,this.G),D(this,n),a&&(this.R?t=`headers=`+yt(b(a))+`&`+t:this.u&&x(n,this.u,a)),Vt(this.h,i),this.Ra&&y(n,`TYPE`,`init`),this.S?(y(n,`$req`,t),y(n,`SID`,`null`),i.U=!0,Tt(i,n,null)):Tt(i,n,t),this.I=2}}else this.I==3&&(e?E(this,e):this.i.length==0||Rt(this.h)||E(this))};function E(e,t){var n=t?t.l:e.V++;let r=qt(e.J);y(r,`SID`,e.M),y(r,`RID`,n),y(r,`AID`,e.K),D(e,r),e.u&&e.o&&x(r,e.u,e.o),n=new xt(e,e.j,n,e.D+1),e.u===null&&(n.J=e.o),t&&(e.i=t.G.concat(e.i)),t=O(e,n,1e3),n.H=Math.round(e.va*.5)+Math.round(e.va*.5*Math.random()),Vt(e.h,n),Tt(n,r,t)}function D(e,t){e.H&&ve(e.H,function(e,n){y(t,n,e)}),e.l&&ve({},function(e,n){y(t,n,e)})}function O(e,t,n){n=Math.min(e.i.length,n);let r=e.l?l(e.l.Ka,e.l,e):null;a:{var i=e.i;let t=-1;for(;;){let e=[`count=`+n];t==-1?n>0?(t=i[0].g,e.push(`ofs=`+t)):t=0:e.push(`ofs=`+t);let c=!0;for(let l=0;l<n;l++){var a=i[l].g;let n=i[l].map;if(a-=t,a<0)t=Math.max(0,i[l].g-100),c=!1;else try{a=`req`+a+`_`||``;try{var o=n instanceof Map?n:Object.entries(n);for(let[t,n]of o){let r=n;s(n)&&(r=Ke(n)),e.push(a+t+`=`+encodeURIComponent(r))}}catch(t){throw e.push(a+`type=_badmap`),t}}catch{r&&r(n)}}if(c){o=e.join(`&`);break a}}o=void 0}return e=e.i.splice(0,n),t.G=e,o}function Jn(e){if(!e.g&&!e.v){e.Y=1;var t=e.Da;ie||se(),ae||=(ie(),!0),oe.add(t,e),e.A=0}}function Yn(e){return e.g||e.v||e.A>=3?!1:(e.Y++,e.v=ct(l(e.Da,e),$n(e,e.A)),e.A++,!0)}e.Da=function(){if(this.v=null,Zn(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var e=4*this.T;this.j.info(`BP detection timer enabled: `+e),this.B=ct(l(this.Wa,this),e)}},e.Wa=function(){this.B&&(this.B=null,this.j.info(`BP detection timeout reached.`),this.j.info(`Buffering proxy detected and switch to long-polling!`),this.F=!1,this.P=!0,ot(10),Wn(this),Zn(this))};function Xn(e){e.B!=null&&(o.clearTimeout(e.B),e.B=null)}function Zn(e){e.g=new xt(e,e.j,`rpc`,e.Y),e.u===null&&(e.g.J=e.o),e.g.P=0;var t=qt(e.na);y(t,`RID`,`rpc`),y(t,`SID`,e.M),y(t,`AID`,e.K),y(t,`CI`,e.F?`0`:`1`),!e.F&&e.ia&&y(t,`TO`,e.ia),y(t,`TYPE`,`xmlhttp`),D(e,t),e.u&&e.o&&x(t,e.u,e.o),e.O&&(e.g.H=e.O);var n=e.g;e=e.ba,n.M=1,n.A=Zt(qt(t)),n.u=null,n.R=!0,Et(n,e)}e.Va=function(){this.C!=null&&(this.C=null,Wn(this),Yn(this),ot(19))};function k(e){e.C!=null&&(o.clearTimeout(e.C),e.C=null)}function Qn(e,t){var n=null;if(e.g==t){k(e),Xn(e),e.g=null;var r=2}else if(Bt(e.h,t))n=t.G,Ht(e.h,t),r=1;else return;if(e.I!=0){if(t.o)if(r==1){n=t.u?t.u.length:0,t=Date.now()-t.F;var i=e.D;r=nt(),Re(r,new st(r,n)),Kn(e)}else Jn(e);else if(i=t.m,i==3||i==0&&t.X>0||!(r==1&&qn(e,t)||r==2&&Yn(e)))switch(n&&n.length>0&&(t=e.h,t.i=t.i.concat(n)),i){case 1:er(e,5);break;case 4:er(e,10);break;case 3:er(e,6);break;default:er(e,2)}}}function $n(e,t){let n=e.Qa+Math.floor(Math.random()*e.Za);return e.isActive()||(n*=2),n*t}function er(e,t){if(e.j.info(`Error code `+t),t==2){var n=l(e.bb,e),r=e.Ua;let t=!r;r=new Kt(r||`//www.google.com/images/cleardot.gif`),o.location&&o.location.protocol==`http`||Jt(r,`https`),Zt(r),t?gn(r.toString(),n):_n(r.toString(),n)}else ot(2);e.I=0,e.l&&e.l.pa(t),tr(e),Gn(e)}e.bb=function(e){e?(this.j.info(`Successfully pinged google.com`),ot(2)):(this.j.info(`Failed to ping google.com`),ot(1))};function tr(e){if(e.I=0,e.ja=[],e.l){let t=Ut(e.h);(t.length!=0||e.i.length!=0)&&(m(e.ja,t),m(e.ja,e.i),e.h.i.length=0,p(e.i),e.i.length=0),e.l.oa()}}function nr(e,t,n){var r=n instanceof Kt?qt(n):new Kt(n);if(r.g!=``)t&&(r.g=t+`.`+r.g),Yt(r,r.u);else{var i=o.location;r=i.protocol,t=t?t+`.`+i.hostname:i.hostname,i=+i.port;let e=new Kt(null);r&&Jt(e,r),t&&(e.g=t),i&&Yt(e,i),n&&(e.h=n),r=e}return n=e.G,t=e.wa,n&&t&&y(r,n,t),y(r,`VER`,e.ka),D(e,r),r}function rr(e,t,n){if(t&&!e.L)throw Error(`Can't create secondary domain capable XhrIo object.`);return t=e.Aa&&!e.ma?new S(new bn({ab:n})):new S(e.ma),t.Fa(e.L),t}e.isActive=function(){return!!this.l&&this.l.isActive(this)};function ir(){}e=ir.prototype,e.ra=function(){},e.qa=function(){},e.pa=function(){},e.oa=function(){},e.isActive=function(){return!0},e.Ka=function(){};function ar(){}ar.prototype.g=function(e,t){return new or(e,t)};function or(e,t){Le.call(this),this.g=new Hn(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.sa&&(e?e[`X-WebChannel-Client-Profile`]=t.sa:e={"X-WebChannel-Client-Profile":t.sa}),this.g.U=e,(e=t&&t.Qb)&&!fe(e)&&(this.g.u=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t&&=t.httpSessionIdParam)&&!fe(t)&&(this.g.G=t,e=this.h,e!==null&&t in e&&(e=this.h,t in e&&delete e[t])),this.j=new lr(this)}d(or,Le),or.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},or.prototype.close=function(){Un(this.g)},or.prototype.o=function(e){var t=this.g;if(typeof e==`string`){var n={};n.__data__=e,e=n}else this.v&&(n={},n.__data__=Ke(e),e=n);t.i.push(new It(t.Ya++,e)),t.I==3&&Kn(t)},or.prototype.N=function(){this.g.l=null,delete this.j,Un(this.g),delete this.g,or.Z.N.call(this)};function sr(e){Qe.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){a:{for(let n in t){e=n;break a}e=void 0}(this.i=e)&&(e=this.i,t=t!==null&&e in t?t[e]:void 0),this.data=t}else this.data=e}d(sr,Qe);function cr(){$e.call(this),this.status=1}d(cr,$e);function lr(e){this.g=e}d(lr,ir),lr.prototype.ra=function(){Re(this.g,`a`)},lr.prototype.qa=function(e){Re(this.g,new sr(e))},lr.prototype.pa=function(e){Re(this.g,new cr)},lr.prototype.oa=function(){Re(this.g,`b`)},ar.prototype.createWebChannel=ar.prototype.g,or.prototype.send=or.prototype.o,or.prototype.open=or.prototype.m,or.prototype.close=or.prototype.close,Pn=En.createWebChannelTransport=function(){return new ar},Nn=En.getStatEventTarget=function(){return nt()},Mn=En.Event=et,jn=En.Stat={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},ht.NO_ERROR=0,ht.TIMEOUT=8,ht.HTTP_ERROR=6,An=En.ErrorCode=ht,gt.COMPLETE=`complete`,kn=En.EventType=gt,Xe.EventType=Ze,Ze.OPEN=`a`,Ze.CLOSE=`b`,Ze.ERROR=`c`,Ze.MESSAGE=`d`,Le.prototype.listen=Le.prototype.J,On=En.WebChannel=Xe,En.FetchXmlHttpFactory=bn,S.prototype.listenOnce=S.prototype.K,S.prototype.getLastError=S.prototype.Ha,S.prototype.getLastErrorCode=S.prototype.ya,S.prototype.getStatus=S.prototype.ca,S.prototype.getResponseJson=S.prototype.La,S.prototype.getResponseText=S.prototype.la,S.prototype.send=S.prototype.ea,S.prototype.setWithCredentials=S.prototype.Fa,Dn=En.XhrIo=S}).apply(Tn===void 0?typeof self<`u`?self:typeof window<`u`?window:{}:Tn);var b=class e{static FOLD_CASE=1;static LITERAL=2;static CLASS_NL=4;static DOT_NL=8;static ONE_LINE=16;static NON_GREEDY=32;static PERL_X=64;static UNICODE_GROUPS=128;static WAS_DOLLAR=256;static MATCH_NL=e.CLASS_NL|e.DOT_NL;static PERL=e.CLASS_NL|e.ONE_LINE|e.PERL_X|e.UNICODE_GROUPS;static POSIX=0;static UNANCHORED=0;static ANCHOR_START=1;static ANCHOR_BOTH=2},x=class{static CODES=new Map([[`\x07`,7],[`\b`,8],[` `,9],[`
|
|
10
|
+
`,10],[`\v`,11],[`\f`,12],[`\r`,13],[` `,32],[`"`,34],[`$`,36],[`&`,38],[`(`,40],[`)`,41],[`*`,42],[`+`,43],[`-`,45],[`.`,46],[`0`,48],[`1`,49],[`2`,50],[`3`,51],[`4`,52],[`5`,53],[`6`,54],[`7`,55],[`8`,56],[`9`,57],[`:`,58],[`<`,60],[`>`,62],[`?`,63],[`A`,65],[`B`,66],[`C`,67],[`F`,70],[`P`,80],[`Q`,81],[`U`,85],[`Z`,90],[`[`,91],[`\\`,92],[`]`,93],[`^`,94],[`_`,95],[`a`,97],[`b`,98],[`f`,102],[`i`,105],[`m`,109],[`n`,110],[`r`,114],[`s`,115],[`t`,116],[`v`,118],[`x`,120],[`z`,122],[`{`,123],[`|`,124],[`}`,125]]);static toUpperCase(e){let t=String.fromCodePoint(e).toUpperCase();if(t.length>1)return e;let n=String.fromCodePoint(t.codePointAt(0)).toLowerCase();return n.length>1||n.codePointAt(0)!==e?e:t.codePointAt(0)}static toLowerCase(e){let t=String.fromCodePoint(e).toLowerCase();if(t.length>1)return e;let n=String.fromCodePoint(t.codePointAt(0)).toUpperCase();return n.length>1||n.codePointAt(0)!==e?e:t.codePointAt(0)}},S=class e{static CASE_ORBIT=new Map([[75,107],[107,8490],[8490,75],[83,115],[115,383],[383,83],[181,924],[924,956],[956,181],[197,229],[229,8491],[8491,197],[452,453],[453,454],[454,452],[455,456],[456,457],[457,455],[458,459],[459,460],[460,458],[497,498],[498,499],[499,497],[837,921],[921,953],[953,8126],[8126,837],[914,946],[946,976],[976,914],[917,949],[949,1013],[1013,917],[920,952],[952,977],[977,1012],[1012,920],[922,954],[954,1008],[1008,922],[928,960],[960,982],[982,928],[929,961],[961,1009],[1009,929],[931,962],[962,963],[963,931],[934,966],[966,981],[981,934],[937,969],[969,8486],[8486,937],[1042,1074],[1074,7296],[7296,1042],[1044,1076],[1076,7297],[7297,1044],[1054,1086],[1086,7298],[7298,1054],[1057,1089],[1089,7299],[7299,1057],[1058,1090],[1090,7300],[7300,7301],[7301,1058],[1066,1098],[1098,7302],[7302,1066],[1122,1123],[1123,7303],[7303,1122],[7304,42570],[42570,42571],[42571,7304],[7776,7777],[7777,7835],[7835,7776],[223,7838],[7838,223],[8064,8072],[8072,8064],[8065,8073],[8073,8065],[8066,8074],[8074,8066],[8067,8075],[8075,8067],[8068,8076],[8076,8068],[8069,8077],[8077,8069],[8070,8078],[8078,8070],[8071,8079],[8079,8071],[8080,8088],[8088,8080],[8081,8089],[8089,8081],[8082,8090],[8090,8082],[8083,8091],[8091,8083],[8084,8092],[8092,8084],[8085,8093],[8093,8085],[8086,8094],[8094,8086],[8087,8095],[8095,8087],[8096,8104],[8104,8096],[8097,8105],[8105,8097],[8098,8106],[8106,8098],[8099,8107],[8107,8099],[8100,8108],[8108,8100],[8101,8109],[8109,8101],[8102,8110],[8110,8102],[8103,8111],[8111,8103],[8115,8124],[8124,8115],[8131,8140],[8140,8131],[912,8147],[8147,912],[944,8163],[8163,944],[8179,8188],[8188,8179],[64261,64262],[64262,64261],[66560,66600],[66600,66560],[66561,66601],[66601,66561],[66562,66602],[66602,66562],[66563,66603],[66603,66563],[66564,66604],[66604,66564],[66565,66605],[66605,66565],[66566,66606],[66606,66566],[66567,66607],[66607,66567],[66568,66608],[66608,66568],[66569,66609],[66609,66569],[66570,66610],[66610,66570],[66571,66611],[66611,66571],[66572,66612],[66612,66572],[66573,66613],[66613,66573],[66574,66614],[66614,66574],[66575,66615],[66615,66575],[66576,66616],[66616,66576],[66577,66617],[66617,66577],[66578,66618],[66618,66578],[66579,66619],[66619,66579],[66580,66620],[66620,66580],[66581,66621],[66621,66581],[66582,66622],[66622,66582],[66583,66623],[66623,66583],[66584,66624],[66624,66584],[66585,66625],[66625,66585],[66586,66626],[66626,66586],[66587,66627],[66627,66587],[66588,66628],[66628,66588],[66589,66629],[66629,66589],[66590,66630],[66630,66590],[66591,66631],[66631,66591],[66592,66632],[66632,66592],[66593,66633],[66633,66593],[66594,66634],[66634,66594],[66595,66635],[66635,66595],[66596,66636],[66636,66596],[66597,66637],[66637,66597],[66598,66638],[66638,66598],[66599,66639],[66639,66599],[66736,66776],[66776,66736],[66737,66777],[66777,66737],[66738,66778],[66778,66738],[66739,66779],[66779,66739],[66740,66780],[66780,66740],[66741,66781],[66781,66741],[66742,66782],[66782,66742],[66743,66783],[66783,66743],[66744,66784],[66784,66744],[66745,66785],[66785,66745],[66746,66786],[66786,66746],[66747,66787],[66787,66747],[66748,66788],[66788,66748],[66749,66789],[66789,66749],[66750,66790],[66790,66750],[66751,66791],[66791,66751],[66752,66792],[66792,66752],[66753,66793],[66793,66753],[66754,66794],[66794,66754],[66755,66795],[66795,66755],[66756,66796],[66796,66756],[66757,66797],[66797,66757],[66758,66798],[66798,66758],[66759,66799],[66799,66759],[66760,66800],[66800,66760],[66761,66801],[66801,66761],[66762,66802],[66802,66762],[66763,66803],[66803,66763],[66764,66804],[66804,66764],[66765,66805],[66805,66765],[66766,66806],[66806,66766],[66767,66807],[66807,66767],[66768,66808],[66808,66768],[66769,66809],[66809,66769],[66770,66810],[66810,66770],[66771,66811],[66811,66771],[66928,66967],[66967,66928],[66929,66968],[66968,66929],[66930,66969],[66969,66930],[66931,66970],[66970,66931],[66932,66971],[66971,66932],[66933,66972],[66972,66933],[66934,66973],[66973,66934],[66935,66974],[66974,66935],[66936,66975],[66975,66936],[66937,66976],[66976,66937],[66938,66977],[66977,66938],[66940,66979],[66979,66940],[66941,66980],[66980,66941],[66942,66981],[66981,66942],[66943,66982],[66982,66943],[66944,66983],[66983,66944],[66945,66984],[66984,66945],[66946,66985],[66985,66946],[66947,66986],[66986,66947],[66948,66987],[66987,66948],[66949,66988],[66988,66949],[66950,66989],[66989,66950],[66951,66990],[66990,66951],[66952,66991],[66991,66952],[66953,66992],[66992,66953],[66954,66993],[66993,66954],[66956,66995],[66995,66956],[66957,66996],[66996,66957],[66958,66997],[66997,66958],[66959,66998],[66998,66959],[66960,66999],[66999,66960],[66961,67e3],[67e3,66961],[66962,67001],[67001,66962],[66964,67003],[67003,66964],[66965,67004],[67004,66965],[68736,68800],[68800,68736],[68737,68801],[68801,68737],[68738,68802],[68802,68738],[68739,68803],[68803,68739],[68740,68804],[68804,68740],[68741,68805],[68805,68741],[68742,68806],[68806,68742],[68743,68807],[68807,68743],[68744,68808],[68808,68744],[68745,68809],[68809,68745],[68746,68810],[68810,68746],[68747,68811],[68811,68747],[68748,68812],[68812,68748],[68749,68813],[68813,68749],[68750,68814],[68814,68750],[68751,68815],[68815,68751],[68752,68816],[68816,68752],[68753,68817],[68817,68753],[68754,68818],[68818,68754],[68755,68819],[68819,68755],[68756,68820],[68820,68756],[68757,68821],[68821,68757],[68758,68822],[68822,68758],[68759,68823],[68823,68759],[68760,68824],[68824,68760],[68761,68825],[68825,68761],[68762,68826],[68826,68762],[68763,68827],[68827,68763],[68764,68828],[68828,68764],[68765,68829],[68829,68765],[68766,68830],[68830,68766],[68767,68831],[68831,68767],[68768,68832],[68832,68768],[68769,68833],[68833,68769],[68770,68834],[68834,68770],[68771,68835],[68835,68771],[68772,68836],[68836,68772],[68773,68837],[68837,68773],[68774,68838],[68838,68774],[68775,68839],[68839,68775],[68776,68840],[68840,68776],[68777,68841],[68841,68777],[68778,68842],[68842,68778],[68779,68843],[68843,68779],[68780,68844],[68844,68780],[68781,68845],[68845,68781],[68782,68846],[68846,68782],[68783,68847],[68847,68783],[68784,68848],[68848,68784],[68785,68849],[68849,68785],[68786,68850],[68850,68786],[71840,71872],[71872,71840],[71841,71873],[71873,71841],[71842,71874],[71874,71842],[71843,71875],[71875,71843],[71844,71876],[71876,71844],[71845,71877],[71877,71845],[71846,71878],[71878,71846],[71847,71879],[71879,71847],[71848,71880],[71880,71848],[71849,71881],[71881,71849],[71850,71882],[71882,71850],[71851,71883],[71883,71851],[71852,71884],[71884,71852],[71853,71885],[71885,71853],[71854,71886],[71886,71854],[71855,71887],[71887,71855],[71856,71888],[71888,71856],[71857,71889],[71889,71857],[71858,71890],[71890,71858],[71859,71891],[71891,71859],[71860,71892],[71892,71860],[71861,71893],[71893,71861],[71862,71894],[71894,71862],[71863,71895],[71895,71863],[71864,71896],[71896,71864],[71865,71897],[71897,71865],[71866,71898],[71898,71866],[71867,71899],[71899,71867],[71868,71900],[71900,71868],[71869,71901],[71901,71869],[71870,71902],[71902,71870],[71871,71903],[71903,71871],[93760,93792],[93792,93760],[93761,93793],[93793,93761],[93762,93794],[93794,93762],[93763,93795],[93795,93763],[93764,93796],[93796,93764],[93765,93797],[93797,93765],[93766,93798],[93798,93766],[93767,93799],[93799,93767],[93768,93800],[93800,93768],[93769,93801],[93801,93769],[93770,93802],[93802,93770],[93771,93803],[93803,93771],[93772,93804],[93804,93772],[93773,93805],[93805,93773],[93774,93806],[93806,93774],[93775,93807],[93807,93775],[93776,93808],[93808,93776],[93777,93809],[93809,93777],[93778,93810],[93810,93778],[93779,93811],[93811,93779],[93780,93812],[93812,93780],[93781,93813],[93813,93781],[93782,93814],[93814,93782],[93783,93815],[93815,93783],[93784,93816],[93816,93784],[93785,93817],[93817,93785],[93786,93818],[93818,93786],[93787,93819],[93819,93787],[93788,93820],[93820,93788],[93789,93821],[93821,93789],[93790,93822],[93822,93790],[93791,93823],[93823,93791],[125184,125218],[125218,125184],[125185,125219],[125219,125185],[125186,125220],[125220,125186],[125187,125221],[125221,125187],[125188,125222],[125222,125188],[125189,125223],[125223,125189],[125190,125224],[125224,125190],[125191,125225],[125225,125191],[125192,125226],[125226,125192],[125193,125227],[125227,125193],[125194,125228],[125228,125194],[125195,125229],[125229,125195],[125196,125230],[125230,125196],[125197,125231],[125231,125197],[125198,125232],[125232,125198],[125199,125233],[125233,125199],[125200,125234],[125234,125200],[125201,125235],[125235,125201],[125202,125236],[125236,125202],[125203,125237],[125237,125203],[125204,125238],[125238,125204],[125205,125239],[125239,125205],[125206,125240],[125240,125206],[125207,125241],[125241,125207],[125208,125242],[125242,125208],[125209,125243],[125243,125209],[125210,125244],[125244,125210],[125211,125245],[125245,125211],[125212,125246],[125246,125212],[125213,125247],[125247,125213],[125214,125248],[125248,125214],[125215,125249],[125249,125215],[125216,125250],[125250,125216],[125217,125251],[125251,125217]]);static C=[[0,31,1],[127,159,1],[173,888,715],[889,896,7],[897,899,1],[907,909,2],[930,1328,398],[1367,1368,1],[1419,1420,1],[1424,1480,56],[1481,1487,1],[1515,1518,1],[1525,1541,1],[1564,1757,193],[1806,1807,1],[1867,1868,1],[1970,1983,1],[2043,2044,1],[2094,2095,1],[2111,2140,29],[2141,2143,2],[2155,2159,1],[2191,2199,1],[2274,2436,162],[2445,2446,1],[2449,2450,1],[2473,2481,8],[2483,2485,1],[2490,2491,1],[2501,2502,1],[2505,2506,1],[2511,2518,1],[2520,2523,1],[2526,2532,6],[2533,2559,26],[2560,2564,4],[2571,2574,1],[2577,2578,1],[2601,2609,8],[2612,2618,3],[2619,2621,2],[2627,2630,1],[2633,2634,1],[2638,2640,1],[2642,2648,1],[2653,2655,2],[2656,2661,1],[2679,2688,1],[2692,2702,10],[2706,2729,23],[2737,2740,3],[2746,2747,1],[2758,2766,4],[2767,2769,2],[2770,2783,1],[2788,2789,1],[2802,2808,1],[2816,2820,4],[2829,2830,1],[2833,2834,1],[2857,2865,8],[2868,2874,6],[2875,2885,10],[2886,2889,3],[2890,2894,4],[2895,2900,1],[2904,2907,1],[2910,2916,6],[2917,2936,19],[2937,2945,1],[2948,2955,7],[2956,2957,1],[2961,2966,5],[2967,2968,1],[2971,2973,2],[2976,2978,1],[2981,2983,1],[2987,2989,1],[3002,3005,1],[3011,3013,1],[3017,3022,5],[3023,3025,2],[3026,3030,1],[3032,3045,1],[3067,3071,1],[3085,3089,4],[3113,3130,17],[3131,3141,10],[3145,3150,5],[3151,3156,1],[3159,3163,4],[3164,3166,2],[3167,3172,5],[3173,3184,11],[3185,3190,1],[3213,3217,4],[3241,3252,11],[3258,3259,1],[3269,3273,4],[3278,3284,1],[3287,3292,1],[3295,3300,5],[3301,3312,11],[3316,3327,1],[3341,3345,4],[3397,3401,4],[3408,3411,1],[3428,3429,1],[3456,3460,4],[3479,3481,1],[3506,3516,10],[3518,3519,1],[3527,3529,1],[3531,3534,1],[3541,3543,2],[3552,3557,1],[3568,3569,1],[3573,3584,1],[3643,3646,1],[3676,3712,1],[3715,3717,2],[3723,3748,25],[3750,3774,24],[3775,3781,6],[3783,3791,8],[3802,3803,1],[3808,3839,1],[3912,3949,37],[3950,3952,1],[3992,4029,37],[4045,4059,14],[4060,4095,1],[4294,4296,2],[4297,4300,1],[4302,4303,1],[4681,4686,5],[4687,4695,8],[4697,4702,5],[4703,4745,42],[4750,4751,1],[4785,4790,5],[4791,4799,8],[4801,4806,5],[4807,4823,16],[4881,4886,5],[4887,4955,68],[4956,4989,33],[4990,4991,1],[5018,5023,1],[5110,5111,1],[5118,5119,1],[5789,5791,1],[5881,5887,1],[5910,5918,1],[5943,5951,1],[5972,5983,1],[5997,6001,4],[6004,6015,1],[6110,6111,1],[6122,6127,1],[6138,6143,1],[6158,6170,12],[6171,6175,1],[6265,6271,1],[6315,6319,1],[6390,6399,1],[6431,6444,13],[6445,6447,1],[6460,6463,1],[6465,6467,1],[6510,6511,1],[6517,6527,1],[6572,6575,1],[6602,6607,1],[6619,6621,1],[6684,6685,1],[6751,6781,30],[6782,6794,12],[6795,6799,1],[6810,6815,1],[6830,6831,1],[6863,6911,1],[6989,6991,1],[7039,7156,117],[7157,7163,1],[7224,7226,1],[7242,7244,1],[7305,7311,1],[7355,7356,1],[7368,7375,1],[7419,7423,1],[7958,7959,1],[7966,7967,1],[8006,8007,1],[8014,8015,1],[8024,8030,2],[8062,8063,1],[8117,8133,16],[8148,8149,1],[8156,8176,20],[8177,8181,4],[8191,8203,12],[8204,8207,1],[8234,8238,1],[8288,8303,1],[8306,8307,1],[8335,8349,14],[8350,8351,1],[8385,8399,1],[8433,8447,1],[8588,8591,1],[9255,9279,1],[9291,9311,1],[11124,11125,1],[11158,11508,350],[11509,11512,1],[11558,11560,2],[11561,11564,1],[11566,11567,1],[11624,11630,1],[11633,11646,1],[11671,11679,1],[11687,11743,8],[11870,11903,1],[11930,12020,90],[12021,12031,1],[12246,12271,1],[12352,12439,87],[12440,12544,104],[12545,12548,1],[12592,12687,95],[12772,12782,1],[12831,42125,29294],[42126,42127,1],[42183,42191,1],[42540,42559,1],[42744,42751,1],[42955,42959,1],[42962,42964,2],[42970,42993,1],[43053,43055,1],[43066,43071,1],[43128,43135,1],[43206,43213,1],[43226,43231,1],[43348,43358,1],[43389,43391,1],[43470,43482,12],[43483,43485,1],[43519,43575,56],[43576,43583,1],[43598,43599,1],[43610,43611,1],[43715,43738,1],[43767,43776,1],[43783,43784,1],[43791,43792,1],[43799,43807,1],[43815,43823,8],[43884,43887,1],[44014,44015,1],[44026,44031,1],[55204,55215,1],[55239,55242,1],[55292,63743,1],[64110,64111,1],[64218,64255,1],[64263,64274,1],[64280,64284,1],[64311,64317,6],[64319,64325,3],[64451,64466,1],[64912,64913,1],[64968,64974,1],[64976,65007,1],[65050,65055,1],[65107,65127,20],[65132,65135,1],[65141,65277,136],[65278,65280,1],[65471,65473,1],[65480,65481,1],[65488,65489,1],[65496,65497,1],[65501,65503,1],[65511,65519,8],[65520,65531,1],[65534,65535,1],[65548,65575,27],[65595,65598,3],[65614,65615,1],[65630,65663,1],[65787,65791,1],[65795,65798,1],[65844,65846,1],[65935,65949,14],[65950,65951,1],[65953,65999,1],[66046,66175,1],[66205,66207,1],[66257,66271,1],[66300,66303,1],[66340,66348,1],[66379,66383,1],[66427,66431,1],[66462,66500,38],[66501,66503,1],[66518,66559,1],[66718,66719,1],[66730,66735,1],[66772,66775,1],[66812,66815,1],[66856,66863,1],[66916,66926,1],[66939,66955,16],[66963,66966,3],[66978,66994,16],[67002,67005,3],[67006,67071,1],[67383,67391,1],[67414,67423,1],[67432,67455,1],[67462,67505,43],[67515,67583,1],[67590,67591,1],[67593,67638,45],[67641,67643,1],[67645,67646,1],[67670,67743,73],[67744,67750,1],[67760,67807,1],[67827,67830,3],[67831,67834,1],[67868,67870,1],[67898,67902,1],[67904,67967,1],[68024,68027,1],[68048,68049,1],[68100,68103,3],[68104,68107,1],[68116,68120,4],[68150,68151,1],[68155,68158,1],[68169,68175,1],[68185,68191,1],[68256,68287,1],[68327,68330,1],[68343,68351,1],[68406,68408,1],[68438,68439,1],[68467,68471,1],[68498,68504,1],[68509,68520,1],[68528,68607,1],[68681,68735,1],[68787,68799,1],[68851,68857,1],[68904,68911,1],[68922,69215,1],[69247,69290,43],[69294,69295,1],[69298,69372,1],[69416,69423,1],[69466,69487,1],[69514,69551,1],[69580,69599,1],[69623,69631,1],[69710,69713,1],[69750,69758,1],[69821,69827,6],[69828,69839,1],[69865,69871,1],[69882,69887,1],[69941,69960,19],[69961,69967,1],[70007,70015,1],[70112,70133,21],[70134,70143,1],[70162,70210,48],[70211,70271,1],[70279,70281,2],[70286,70302,16],[70314,70319,1],[70379,70383,1],[70394,70399,1],[70404,70413,9],[70414,70417,3],[70418,70441,23],[70449,70452,3],[70458,70469,11],[70470,70473,3],[70474,70478,4],[70479,70481,2],[70482,70486,1],[70488,70492,1],[70500,70501,1],[70509,70511,1],[70517,70655,1],[70748,70754,6],[70755,70783,1],[70856,70863,1],[70874,71039,1],[71094,71095,1],[71134,71167,1],[71237,71247,1],[71258,71263,1],[71277,71295,1],[71354,71359,1],[71370,71423,1],[71451,71452,1],[71468,71471,1],[71495,71679,1],[71740,71839,1],[71923,71934,1],[71943,71944,1],[71946,71947,1],[71956,71959,3],[71990,71993,3],[71994,72007,13],[72008,72015,1],[72026,72095,1],[72104,72105,1],[72152,72153,1],[72165,72191,1],[72264,72271,1],[72355,72367,1],[72441,72447,1],[72458,72703,1],[72713,72759,46],[72774,72783,1],[72813,72815,1],[72848,72849,1],[72872,72887,15],[72888,72959,1],[72967,72970,3],[73015,73017,1],[73019,73022,3],[73032,73039,1],[73050,73055,1],[73062,73065,3],[73103,73106,3],[73113,73119,1],[73130,73439,1],[73465,73471,1],[73489,73531,42],[73532,73533,1],[73562,73647,1],[73649,73663,1],[73714,73726,1],[74650,74751,1],[74863,74869,6],[74870,74879,1],[75076,77711,1],[77811,77823,1],[78896,78911,1],[78934,82943,1],[83527,92159,1],[92729,92735,1],[92767,92778,11],[92779,92781,1],[92863,92874,11],[92875,92879,1],[92910,92911,1],[92918,92927,1],[92998,93007,1],[93018,93026,8],[93048,93052,1],[93072,93759,1],[93851,93951,1],[94027,94030,1],[94088,94094,1],[94112,94175,1],[94181,94191,1],[94194,94207,1],[100344,100351,1],[101590,101631,1],[101641,110575,1],[110580,110588,8],[110591,110883,292],[110884,110897,1],[110899,110927,1],[110931,110932,1],[110934,110947,1],[110952,110959,1],[111356,113663,1],[113771,113775,1],[113789,113791,1],[113801,113807,1],[113818,113819,1],[113824,118527,1],[118574,118575,1],[118599,118607,1],[118724,118783,1],[119030,119039,1],[119079,119080,1],[119155,119162,1],[119275,119295,1],[119366,119487,1],[119508,119519,1],[119540,119551,1],[119639,119647,1],[119673,119807,1],[119893,119965,72],[119968,119969,1],[119971,119972,1],[119975,119976,1],[119981,119994,13],[119996,120004,8],[120070,120075,5],[120076,120085,9],[120093,120122,29],[120127,120133,6],[120135,120137,1],[120145,120486,341],[120487,120780,293],[120781,121484,703],[121485,121498,1],[121504,121520,16],[121521,122623,1],[122655,122660,1],[122667,122879,1],[122887,122905,18],[122906,122914,8],[122917,122923,6],[122924,122927,1],[122990,123022,1],[123024,123135,1],[123181,123183,1],[123198,123199,1],[123210,123213,1],[123216,123535,1],[123567,123583,1],[123642,123646,1],[123648,124111,1],[124154,124895,1],[124903,124908,5],[124911,124927,16],[125125,125126,1],[125143,125183,1],[125260,125263,1],[125274,125277,1],[125280,126064,1],[126133,126208,1],[126270,126463,1],[126468,126496,28],[126499,126501,2],[126502,126504,2],[126515,126520,5],[126522,126524,2],[126525,126529,1],[126531,126534,1],[126536,126540,2],[126544,126547,3],[126549,126550,1],[126552,126560,2],[126563,126565,2],[126566,126571,5],[126579,126589,5],[126591,126602,11],[126620,126624,1],[126628,126634,6],[126652,126703,1],[126706,126975,1],[127020,127023,1],[127124,127135,1],[127151,127152,1],[127168,127184,16],[127222,127231,1],[127406,127461,1],[127491,127503,1],[127548,127551,1],[127561,127567,1],[127570,127583,1],[127590,127743,1],[128728,128731,1],[128749,128751,1],[128765,128767,1],[128887,128890,1],[128986,128991,1],[129004,129007,1],[129009,129023,1],[129036,129039,1],[129096,129103,1],[129114,129119,1],[129160,129167,1],[129198,129199,1],[129202,129279,1],[129620,129631,1],[129646,129647,1],[129661,129663,1],[129673,129679,1],[129726,129734,8],[129735,129741,1],[129756,129759,1],[129769,129775,1],[129785,129791,1],[129939,129995,56],[129996,130031,1],[130042,131071,1],[173792,173823,1],[177978,177983,1],[178206,178207,1],[183970,183983,1],[191457,191471,1],[192094,194559,1],[195102,196607,1],[201547,201551,1],[205744,917759,1],[918e3,1114111,1]];static Cc=[[0,31,1],[127,159,1]];static Cf=[[173,1536,1363],[1537,1541,1],[1564,1757,193],[1807,2192,385],[2193,2274,81],[6158,8203,2045],[8204,8207,1],[8234,8238,1],[8288,8292,1],[8294,8303,1],[65279,65529,250],[65530,65531,1],[69821,69837,16],[78896,78911,1],[113824,113827,1],[119155,119162,1],[917505,917536,31],[917537,917631,1]];static Co=[[57344,63743,1],[983040,1048573,1],[1048576,1114109,1]];static Cs=[[55296,57343,1]];static L=[[65,90,1],[97,122,1],[170,181,11],[186,192,6],[193,214,1],[216,246,1],[248,705,1],[710,721,1],[736,740,1],[748,750,2],[880,884,1],[886,887,1],[890,893,1],[895,902,7],[904,906,1],[908,910,2],[911,929,1],[931,1013,1],[1015,1153,1],[1162,1327,1],[1329,1366,1],[1369,1376,7],[1377,1416,1],[1488,1514,1],[1519,1522,1],[1568,1610,1],[1646,1647,1],[1649,1747,1],[1749,1765,16],[1766,1774,8],[1775,1786,11],[1787,1788,1],[1791,1808,17],[1810,1839,1],[1869,1957,1],[1969,1994,25],[1995,2026,1],[2036,2037,1],[2042,2048,6],[2049,2069,1],[2074,2084,10],[2088,2112,24],[2113,2136,1],[2144,2154,1],[2160,2183,1],[2185,2190,1],[2208,2249,1],[2308,2361,1],[2365,2384,19],[2392,2401,1],[2417,2432,1],[2437,2444,1],[2447,2448,1],[2451,2472,1],[2474,2480,1],[2482,2486,4],[2487,2489,1],[2493,2510,17],[2524,2525,1],[2527,2529,1],[2544,2545,1],[2556,2565,9],[2566,2570,1],[2575,2576,1],[2579,2600,1],[2602,2608,1],[2610,2611,1],[2613,2614,1],[2616,2617,1],[2649,2652,1],[2654,2674,20],[2675,2676,1],[2693,2701,1],[2703,2705,1],[2707,2728,1],[2730,2736,1],[2738,2739,1],[2741,2745,1],[2749,2768,19],[2784,2785,1],[2809,2821,12],[2822,2828,1],[2831,2832,1],[2835,2856,1],[2858,2864,1],[2866,2867,1],[2869,2873,1],[2877,2908,31],[2909,2911,2],[2912,2913,1],[2929,2947,18],[2949,2954,1],[2958,2960,1],[2962,2965,1],[2969,2970,1],[2972,2974,2],[2975,2979,4],[2980,2984,4],[2985,2986,1],[2990,3001,1],[3024,3077,53],[3078,3084,1],[3086,3088,1],[3090,3112,1],[3114,3129,1],[3133,3160,27],[3161,3162,1],[3165,3168,3],[3169,3200,31],[3205,3212,1],[3214,3216,1],[3218,3240,1],[3242,3251,1],[3253,3257,1],[3261,3293,32],[3294,3296,2],[3297,3313,16],[3314,3332,18],[3333,3340,1],[3342,3344,1],[3346,3386,1],[3389,3406,17],[3412,3414,1],[3423,3425,1],[3450,3455,1],[3461,3478,1],[3482,3505,1],[3507,3515,1],[3517,3520,3],[3521,3526,1],[3585,3632,1],[3634,3635,1],[3648,3654,1],[3713,3714,1],[3716,3718,2],[3719,3722,1],[3724,3747,1],[3749,3751,2],[3752,3760,1],[3762,3763,1],[3773,3776,3],[3777,3780,1],[3782,3804,22],[3805,3807,1],[3840,3904,64],[3905,3911,1],[3913,3948,1],[3976,3980,1],[4096,4138,1],[4159,4176,17],[4177,4181,1],[4186,4189,1],[4193,4197,4],[4198,4206,8],[4207,4208,1],[4213,4225,1],[4238,4256,18],[4257,4293,1],[4295,4301,6],[4304,4346,1],[4348,4680,1],[4682,4685,1],[4688,4694,1],[4696,4698,2],[4699,4701,1],[4704,4744,1],[4746,4749,1],[4752,4784,1],[4786,4789,1],[4792,4798,1],[4800,4802,2],[4803,4805,1],[4808,4822,1],[4824,4880,1],[4882,4885,1],[4888,4954,1],[4992,5007,1],[5024,5109,1],[5112,5117,1],[5121,5740,1],[5743,5759,1],[5761,5786,1],[5792,5866,1],[5873,5880,1],[5888,5905,1],[5919,5937,1],[5952,5969,1],[5984,5996,1],[5998,6e3,1],[6016,6067,1],[6103,6108,5],[6176,6264,1],[6272,6276,1],[6279,6312,1],[6314,6320,6],[6321,6389,1],[6400,6430,1],[6480,6509,1],[6512,6516,1],[6528,6571,1],[6576,6601,1],[6656,6678,1],[6688,6740,1],[6823,6917,94],[6918,6963,1],[6981,6988,1],[7043,7072,1],[7086,7087,1],[7098,7141,1],[7168,7203,1],[7245,7247,1],[7258,7293,1],[7296,7304,1],[7312,7354,1],[7357,7359,1],[7401,7404,1],[7406,7411,1],[7413,7414,1],[7418,7424,6],[7425,7615,1],[7680,7957,1],[7960,7965,1],[7968,8005,1],[8008,8013,1],[8016,8023,1],[8025,8031,2],[8032,8061,1],[8064,8116,1],[8118,8124,1],[8126,8130,4],[8131,8132,1],[8134,8140,1],[8144,8147,1],[8150,8155,1],[8160,8172,1],[8178,8180,1],[8182,8188,1],[8305,8319,14],[8336,8348,1],[8450,8455,5],[8458,8467,1],[8469,8473,4],[8474,8477,1],[8484,8490,2],[8491,8493,1],[8495,8505,1],[8508,8511,1],[8517,8521,1],[8526,8579,53],[8580,11264,2684],[11265,11492,1],[11499,11502,1],[11506,11507,1],[11520,11557,1],[11559,11565,6],[11568,11623,1],[11631,11648,17],[11649,11670,1],[11680,11686,1],[11688,11694,1],[11696,11702,1],[11704,11710,1],[11712,11718,1],[11720,11726,1],[11728,11734,1],[11736,11742,1],[11823,12293,470],[12294,12337,43],[12338,12341,1],[12347,12348,1],[12353,12438,1],[12445,12447,1],[12449,12538,1],[12540,12543,1],[12549,12591,1],[12593,12686,1],[12704,12735,1],[12784,12799,1],[13312,19903,1],[19968,42124,1],[42192,42237,1],[42240,42508,1],[42512,42527,1],[42538,42539,1],[42560,42606,1],[42623,42653,1],[42656,42725,1],[42775,42783,1],[42786,42888,1],[42891,42954,1],[42960,42961,1],[42963,42965,2],[42966,42969,1],[42994,43009,1],[43011,43013,1],[43015,43018,1],[43020,43042,1],[43072,43123,1],[43138,43187,1],[43250,43255,1],[43259,43261,2],[43262,43274,12],[43275,43301,1],[43312,43334,1],[43360,43388,1],[43396,43442,1],[43471,43488,17],[43489,43492,1],[43494,43503,1],[43514,43518,1],[43520,43560,1],[43584,43586,1],[43588,43595,1],[43616,43638,1],[43642,43646,4],[43647,43695,1],[43697,43701,4],[43702,43705,3],[43706,43709,1],[43712,43714,2],[43739,43741,1],[43744,43754,1],[43762,43764,1],[43777,43782,1],[43785,43790,1],[43793,43798,1],[43808,43814,1],[43816,43822,1],[43824,43866,1],[43868,43881,1],[43888,44002,1],[44032,55203,1],[55216,55238,1],[55243,55291,1],[63744,64109,1],[64112,64217,1],[64256,64262,1],[64275,64279,1],[64285,64287,2],[64288,64296,1],[64298,64310,1],[64312,64316,1],[64318,64320,2],[64321,64323,2],[64324,64326,2],[64327,64433,1],[64467,64829,1],[64848,64911,1],[64914,64967,1],[65008,65019,1],[65136,65140,1],[65142,65276,1],[65313,65338,1],[65345,65370,1],[65382,65470,1],[65474,65479,1],[65482,65487,1],[65490,65495,1],[65498,65500,1],[65536,65547,1],[65549,65574,1],[65576,65594,1],[65596,65597,1],[65599,65613,1],[65616,65629,1],[65664,65786,1],[66176,66204,1],[66208,66256,1],[66304,66335,1],[66349,66368,1],[66370,66377,1],[66384,66421,1],[66432,66461,1],[66464,66499,1],[66504,66511,1],[66560,66717,1],[66736,66771,1],[66776,66811,1],[66816,66855,1],[66864,66915,1],[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1],[67072,67382,1],[67392,67413,1],[67424,67431,1],[67456,67461,1],[67463,67504,1],[67506,67514,1],[67584,67589,1],[67592,67594,2],[67595,67637,1],[67639,67640,1],[67644,67647,3],[67648,67669,1],[67680,67702,1],[67712,67742,1],[67808,67826,1],[67828,67829,1],[67840,67861,1],[67872,67897,1],[67968,68023,1],[68030,68031,1],[68096,68112,16],[68113,68115,1],[68117,68119,1],[68121,68149,1],[68192,68220,1],[68224,68252,1],[68288,68295,1],[68297,68324,1],[68352,68405,1],[68416,68437,1],[68448,68466,1],[68480,68497,1],[68608,68680,1],[68736,68786,1],[68800,68850,1],[68864,68899,1],[69248,69289,1],[69296,69297,1],[69376,69404,1],[69415,69424,9],[69425,69445,1],[69488,69505,1],[69552,69572,1],[69600,69622,1],[69635,69687,1],[69745,69746,1],[69749,69763,14],[69764,69807,1],[69840,69864,1],[69891,69926,1],[69956,69959,3],[69968,70002,1],[70006,70019,13],[70020,70066,1],[70081,70084,1],[70106,70108,2],[70144,70161,1],[70163,70187,1],[70207,70208,1],[70272,70278,1],[70280,70282,2],[70283,70285,1],[70287,70301,1],[70303,70312,1],[70320,70366,1],[70405,70412,1],[70415,70416,1],[70419,70440,1],[70442,70448,1],[70450,70451,1],[70453,70457,1],[70461,70480,19],[70493,70497,1],[70656,70708,1],[70727,70730,1],[70751,70753,1],[70784,70831,1],[70852,70853,1],[70855,71040,185],[71041,71086,1],[71128,71131,1],[71168,71215,1],[71236,71296,60],[71297,71338,1],[71352,71424,72],[71425,71450,1],[71488,71494,1],[71680,71723,1],[71840,71903,1],[71935,71942,1],[71945,71948,3],[71949,71955,1],[71957,71958,1],[71960,71983,1],[71999,72001,2],[72096,72103,1],[72106,72144,1],[72161,72163,2],[72192,72203,11],[72204,72242,1],[72250,72272,22],[72284,72329,1],[72349,72368,19],[72369,72440,1],[72704,72712,1],[72714,72750,1],[72768,72818,50],[72819,72847,1],[72960,72966,1],[72968,72969,1],[72971,73008,1],[73030,73056,26],[73057,73061,1],[73063,73064,1],[73066,73097,1],[73112,73440,328],[73441,73458,1],[73474,73476,2],[73477,73488,1],[73490,73523,1],[73648,73728,80],[73729,74649,1],[74880,75075,1],[77712,77808,1],[77824,78895,1],[78913,78918,1],[82944,83526,1],[92160,92728,1],[92736,92766,1],[92784,92862,1],[92880,92909,1],[92928,92975,1],[92992,92995,1],[93027,93047,1],[93053,93071,1],[93760,93823,1],[93952,94026,1],[94032,94099,67],[94100,94111,1],[94176,94177,1],[94179,94208,29],[94209,100343,1],[100352,101589,1],[101632,101640,1],[110576,110579,1],[110581,110587,1],[110589,110590,1],[110592,110882,1],[110898,110928,30],[110929,110930,1],[110933,110948,15],[110949,110951,1],[110960,111355,1],[113664,113770,1],[113776,113788,1],[113792,113800,1],[113808,113817,1],[119808,119892,1],[119894,119964,1],[119966,119967,1],[119970,119973,3],[119974,119977,3],[119978,119980,1],[119982,119993,1],[119995,119997,2],[119998,120003,1],[120005,120069,1],[120071,120074,1],[120077,120084,1],[120086,120092,1],[120094,120121,1],[120123,120126,1],[120128,120132,1],[120134,120138,4],[120139,120144,1],[120146,120485,1],[120488,120512,1],[120514,120538,1],[120540,120570,1],[120572,120596,1],[120598,120628,1],[120630,120654,1],[120656,120686,1],[120688,120712,1],[120714,120744,1],[120746,120770,1],[120772,120779,1],[122624,122654,1],[122661,122666,1],[122928,122989,1],[123136,123180,1],[123191,123197,1],[123214,123536,322],[123537,123565,1],[123584,123627,1],[124112,124139,1],[124896,124902,1],[124904,124907,1],[124909,124910,1],[124912,124926,1],[124928,125124,1],[125184,125251,1],[125259,126464,1205],[126465,126467,1],[126469,126495,1],[126497,126498,1],[126500,126503,3],[126505,126514,1],[126516,126519,1],[126521,126523,2],[126530,126535,5],[126537,126541,2],[126542,126543,1],[126545,126546,1],[126548,126551,3],[126553,126561,2],[126562,126564,2],[126567,126570,1],[126572,126578,1],[126580,126583,1],[126585,126588,1],[126590,126592,2],[126593,126601,1],[126603,126619,1],[126625,126627,1],[126629,126633,1],[126635,126651,1],[131072,173791,1],[173824,177977,1],[177984,178205,1],[178208,183969,1],[183984,191456,1],[191472,192093,1],[194560,195101,1],[196608,201546,1],[201552,205743,1]];static foldL=[[837,837,1]];static Ll=[[97,122,1],[181,223,42],[224,246,1],[248,255,1],[257,311,2],[312,328,2],[329,375,2],[378,382,2],[383,384,1],[387,389,2],[392,396,4],[397,402,5],[405,409,4],[410,411,1],[414,417,3],[419,421,2],[424,426,2],[427,429,2],[432,436,4],[438,441,3],[442,445,3],[446,447,1],[454,460,3],[462,476,2],[477,495,2],[496,499,3],[501,505,4],[507,563,2],[564,569,1],[572,575,3],[576,578,2],[583,591,2],[592,659,1],[661,687,1],[881,883,2],[887,891,4],[892,893,1],[912,940,28],[941,974,1],[976,977,1],[981,983,1],[985,1007,2],[1008,1011,1],[1013,1019,3],[1020,1072,52],[1073,1119,1],[1121,1153,2],[1163,1215,2],[1218,1230,2],[1231,1327,2],[1376,1416,1],[4304,4346,1],[4349,4351,1],[5112,5117,1],[7296,7304,1],[7424,7467,1],[7531,7543,1],[7545,7578,1],[7681,7829,2],[7830,7837,1],[7839,7935,2],[7936,7943,1],[7952,7957,1],[7968,7975,1],[7984,7991,1],[8e3,8005,1],[8016,8023,1],[8032,8039,1],[8048,8061,1],[8064,8071,1],[8080,8087,1],[8096,8103,1],[8112,8116,1],[8118,8119,1],[8126,8130,4],[8131,8132,1],[8134,8135,1],[8144,8147,1],[8150,8151,1],[8160,8167,1],[8178,8180,1],[8182,8183,1],[8458,8462,4],[8463,8467,4],[8495,8505,5],[8508,8509,1],[8518,8521,1],[8526,8580,54],[11312,11359,1],[11361,11365,4],[11366,11372,2],[11377,11379,2],[11380,11382,2],[11383,11387,1],[11393,11491,2],[11492,11500,8],[11502,11507,5],[11520,11557,1],[11559,11565,6],[42561,42605,2],[42625,42651,2],[42787,42799,2],[42800,42801,1],[42803,42865,2],[42866,42872,1],[42874,42876,2],[42879,42887,2],[42892,42894,2],[42897,42899,2],[42900,42901,1],[42903,42921,2],[42927,42933,6],[42935,42947,2],[42952,42954,2],[42961,42969,2],[42998,43002,4],[43824,43866,1],[43872,43880,1],[43888,43967,1],[64256,64262,1],[64275,64279,1],[65345,65370,1],[66600,66639,1],[66776,66811,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1],[68800,68850,1],[71872,71903,1],[93792,93823,1],[119834,119859,1],[119886,119892,1],[119894,119911,1],[119938,119963,1],[119990,119993,1],[119995,119997,2],[119998,120003,1],[120005,120015,1],[120042,120067,1],[120094,120119,1],[120146,120171,1],[120198,120223,1],[120250,120275,1],[120302,120327,1],[120354,120379,1],[120406,120431,1],[120458,120485,1],[120514,120538,1],[120540,120545,1],[120572,120596,1],[120598,120603,1],[120630,120654,1],[120656,120661,1],[120688,120712,1],[120714,120719,1],[120746,120770,1],[120772,120777,1],[120779,122624,1845],[122625,122633,1],[122635,122654,1],[122661,122666,1],[125218,125251,1]];static foldLl=[[65,90,1],[192,214,1],[216,222,1],[256,302,2],[306,310,2],[313,327,2],[330,376,2],[377,381,2],[385,386,1],[388,390,2],[391,393,2],[394,395,1],[398,401,1],[403,404,1],[406,408,1],[412,413,1],[415,416,1],[418,422,2],[423,425,2],[428,430,2],[431,433,2],[434,435,1],[437,439,2],[440,444,4],[452,453,1],[455,456,1],[458,459,1],[461,475,2],[478,494,2],[497,498,1],[500,502,2],[503,504,1],[506,562,2],[570,571,1],[573,574,1],[577,579,2],[580,582,1],[584,590,2],[837,880,43],[882,886,4],[895,902,7],[904,906,1],[908,910,2],[911,913,2],[914,929,1],[931,939,1],[975,984,9],[986,1006,2],[1012,1015,3],[1017,1018,1],[1021,1071,1],[1120,1152,2],[1162,1216,2],[1217,1229,2],[1232,1326,2],[1329,1366,1],[4256,4293,1],[4295,4301,6],[5024,5109,1],[7312,7354,1],[7357,7359,1],[7680,7828,2],[7838,7934,2],[7944,7951,1],[7960,7965,1],[7976,7983,1],[7992,7999,1],[8008,8013,1],[8025,8031,2],[8040,8047,1],[8072,8079,1],[8088,8095,1],[8104,8111,1],[8120,8124,1],[8136,8140,1],[8152,8155,1],[8168,8172,1],[8184,8188,1],[8486,8490,4],[8491,8498,7],[8579,11264,2685],[11265,11311,1],[11360,11362,2],[11363,11364,1],[11367,11373,2],[11374,11376,1],[11378,11381,3],[11390,11392,1],[11394,11490,2],[11499,11501,2],[11506,42560,31054],[42562,42604,2],[42624,42650,2],[42786,42798,2],[42802,42862,2],[42873,42877,2],[42878,42886,2],[42891,42893,2],[42896,42898,2],[42902,42922,2],[42923,42926,1],[42928,42932,1],[42934,42948,2],[42949,42951,1],[42953,42960,7],[42966,42968,2],[42997,65313,22316],[65314,65338,1],[66560,66599,1],[66736,66771,1],[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[68736,68786,1],[71840,71871,1],[93760,93791,1],[125184,125217,1]];static Lm=[[688,705,1],[710,721,1],[736,740,1],[748,750,2],[884,890,6],[1369,1600,231],[1765,1766,1],[2036,2037,1],[2042,2074,32],[2084,2088,4],[2249,2417,168],[3654,3782,128],[4348,6103,1755],[6211,6823,612],[7288,7293,1],[7468,7530,1],[7544,7579,35],[7580,7615,1],[8305,8319,14],[8336,8348,1],[11388,11389,1],[11631,11823,192],[12293,12337,44],[12338,12341,1],[12347,12445,98],[12446,12540,94],[12541,12542,1],[40981,42232,1251],[42233,42237,1],[42508,42623,115],[42652,42653,1],[42775,42783,1],[42864,42888,24],[42994,42996,1],[43e3,43001,1],[43471,43494,23],[43632,43741,109],[43763,43764,1],[43868,43871,1],[43881,65392,21511],[65438,65439,1],[67456,67461,1],[67463,67504,1],[67506,67514,1],[92992,92995,1],[94099,94111,1],[94176,94177,1],[94179,110576,16397],[110577,110579,1],[110581,110587,1],[110589,110590,1],[122928,122989,1],[123191,123197,1],[124139,125259,1120]];static Lo=[[170,186,16],[443,448,5],[449,451,1],[660,1488,828],[1489,1514,1],[1519,1522,1],[1568,1599,1],[1601,1610,1],[1646,1647,1],[1649,1747,1],[1749,1774,25],[1775,1786,11],[1787,1788,1],[1791,1808,17],[1810,1839,1],[1869,1957,1],[1969,1994,25],[1995,2026,1],[2048,2069,1],[2112,2136,1],[2144,2154,1],[2160,2183,1],[2185,2190,1],[2208,2248,1],[2308,2361,1],[2365,2384,19],[2392,2401,1],[2418,2432,1],[2437,2444,1],[2447,2448,1],[2451,2472,1],[2474,2480,1],[2482,2486,4],[2487,2489,1],[2493,2510,17],[2524,2525,1],[2527,2529,1],[2544,2545,1],[2556,2565,9],[2566,2570,1],[2575,2576,1],[2579,2600,1],[2602,2608,1],[2610,2611,1],[2613,2614,1],[2616,2617,1],[2649,2652,1],[2654,2674,20],[2675,2676,1],[2693,2701,1],[2703,2705,1],[2707,2728,1],[2730,2736,1],[2738,2739,1],[2741,2745,1],[2749,2768,19],[2784,2785,1],[2809,2821,12],[2822,2828,1],[2831,2832,1],[2835,2856,1],[2858,2864,1],[2866,2867,1],[2869,2873,1],[2877,2908,31],[2909,2911,2],[2912,2913,1],[2929,2947,18],[2949,2954,1],[2958,2960,1],[2962,2965,1],[2969,2970,1],[2972,2974,2],[2975,2979,4],[2980,2984,4],[2985,2986,1],[2990,3001,1],[3024,3077,53],[3078,3084,1],[3086,3088,1],[3090,3112,1],[3114,3129,1],[3133,3160,27],[3161,3162,1],[3165,3168,3],[3169,3200,31],[3205,3212,1],[3214,3216,1],[3218,3240,1],[3242,3251,1],[3253,3257,1],[3261,3293,32],[3294,3296,2],[3297,3313,16],[3314,3332,18],[3333,3340,1],[3342,3344,1],[3346,3386,1],[3389,3406,17],[3412,3414,1],[3423,3425,1],[3450,3455,1],[3461,3478,1],[3482,3505,1],[3507,3515,1],[3517,3520,3],[3521,3526,1],[3585,3632,1],[3634,3635,1],[3648,3653,1],[3713,3714,1],[3716,3718,2],[3719,3722,1],[3724,3747,1],[3749,3751,2],[3752,3760,1],[3762,3763,1],[3773,3776,3],[3777,3780,1],[3804,3807,1],[3840,3904,64],[3905,3911,1],[3913,3948,1],[3976,3980,1],[4096,4138,1],[4159,4176,17],[4177,4181,1],[4186,4189,1],[4193,4197,4],[4198,4206,8],[4207,4208,1],[4213,4225,1],[4238,4352,114],[4353,4680,1],[4682,4685,1],[4688,4694,1],[4696,4698,2],[4699,4701,1],[4704,4744,1],[4746,4749,1],[4752,4784,1],[4786,4789,1],[4792,4798,1],[4800,4802,2],[4803,4805,1],[4808,4822,1],[4824,4880,1],[4882,4885,1],[4888,4954,1],[4992,5007,1],[5121,5740,1],[5743,5759,1],[5761,5786,1],[5792,5866,1],[5873,5880,1],[5888,5905,1],[5919,5937,1],[5952,5969,1],[5984,5996,1],[5998,6e3,1],[6016,6067,1],[6108,6176,68],[6177,6210,1],[6212,6264,1],[6272,6276,1],[6279,6312,1],[6314,6320,6],[6321,6389,1],[6400,6430,1],[6480,6509,1],[6512,6516,1],[6528,6571,1],[6576,6601,1],[6656,6678,1],[6688,6740,1],[6917,6963,1],[6981,6988,1],[7043,7072,1],[7086,7087,1],[7098,7141,1],[7168,7203,1],[7245,7247,1],[7258,7287,1],[7401,7404,1],[7406,7411,1],[7413,7414,1],[7418,8501,1083],[8502,8504,1],[11568,11623,1],[11648,11670,1],[11680,11686,1],[11688,11694,1],[11696,11702,1],[11704,11710,1],[11712,11718,1],[11720,11726,1],[11728,11734,1],[11736,11742,1],[12294,12348,54],[12353,12438,1],[12447,12449,2],[12450,12538,1],[12543,12549,6],[12550,12591,1],[12593,12686,1],[12704,12735,1],[12784,12799,1],[13312,19903,1],[19968,40980,1],[40982,42124,1],[42192,42231,1],[42240,42507,1],[42512,42527,1],[42538,42539,1],[42606,42656,50],[42657,42725,1],[42895,42999,104],[43003,43009,1],[43011,43013,1],[43015,43018,1],[43020,43042,1],[43072,43123,1],[43138,43187,1],[43250,43255,1],[43259,43261,2],[43262,43274,12],[43275,43301,1],[43312,43334,1],[43360,43388,1],[43396,43442,1],[43488,43492,1],[43495,43503,1],[43514,43518,1],[43520,43560,1],[43584,43586,1],[43588,43595,1],[43616,43631,1],[43633,43638,1],[43642,43646,4],[43647,43695,1],[43697,43701,4],[43702,43705,3],[43706,43709,1],[43712,43714,2],[43739,43740,1],[43744,43754,1],[43762,43777,15],[43778,43782,1],[43785,43790,1],[43793,43798,1],[43808,43814,1],[43816,43822,1],[43968,44002,1],[44032,55203,1],[55216,55238,1],[55243,55291,1],[63744,64109,1],[64112,64217,1],[64285,64287,2],[64288,64296,1],[64298,64310,1],[64312,64316,1],[64318,64320,2],[64321,64323,2],[64324,64326,2],[64327,64433,1],[64467,64829,1],[64848,64911,1],[64914,64967,1],[65008,65019,1],[65136,65140,1],[65142,65276,1],[65382,65391,1],[65393,65437,1],[65440,65470,1],[65474,65479,1],[65482,65487,1],[65490,65495,1],[65498,65500,1],[65536,65547,1],[65549,65574,1],[65576,65594,1],[65596,65597,1],[65599,65613,1],[65616,65629,1],[65664,65786,1],[66176,66204,1],[66208,66256,1],[66304,66335,1],[66349,66368,1],[66370,66377,1],[66384,66421,1],[66432,66461,1],[66464,66499,1],[66504,66511,1],[66640,66717,1],[66816,66855,1],[66864,66915,1],[67072,67382,1],[67392,67413,1],[67424,67431,1],[67584,67589,1],[67592,67594,2],[67595,67637,1],[67639,67640,1],[67644,67647,3],[67648,67669,1],[67680,67702,1],[67712,67742,1],[67808,67826,1],[67828,67829,1],[67840,67861,1],[67872,67897,1],[67968,68023,1],[68030,68031,1],[68096,68112,16],[68113,68115,1],[68117,68119,1],[68121,68149,1],[68192,68220,1],[68224,68252,1],[68288,68295,1],[68297,68324,1],[68352,68405,1],[68416,68437,1],[68448,68466,1],[68480,68497,1],[68608,68680,1],[68864,68899,1],[69248,69289,1],[69296,69297,1],[69376,69404,1],[69415,69424,9],[69425,69445,1],[69488,69505,1],[69552,69572,1],[69600,69622,1],[69635,69687,1],[69745,69746,1],[69749,69763,14],[69764,69807,1],[69840,69864,1],[69891,69926,1],[69956,69959,3],[69968,70002,1],[70006,70019,13],[70020,70066,1],[70081,70084,1],[70106,70108,2],[70144,70161,1],[70163,70187,1],[70207,70208,1],[70272,70278,1],[70280,70282,2],[70283,70285,1],[70287,70301,1],[70303,70312,1],[70320,70366,1],[70405,70412,1],[70415,70416,1],[70419,70440,1],[70442,70448,1],[70450,70451,1],[70453,70457,1],[70461,70480,19],[70493,70497,1],[70656,70708,1],[70727,70730,1],[70751,70753,1],[70784,70831,1],[70852,70853,1],[70855,71040,185],[71041,71086,1],[71128,71131,1],[71168,71215,1],[71236,71296,60],[71297,71338,1],[71352,71424,72],[71425,71450,1],[71488,71494,1],[71680,71723,1],[71935,71942,1],[71945,71948,3],[71949,71955,1],[71957,71958,1],[71960,71983,1],[71999,72001,2],[72096,72103,1],[72106,72144,1],[72161,72163,2],[72192,72203,11],[72204,72242,1],[72250,72272,22],[72284,72329,1],[72349,72368,19],[72369,72440,1],[72704,72712,1],[72714,72750,1],[72768,72818,50],[72819,72847,1],[72960,72966,1],[72968,72969,1],[72971,73008,1],[73030,73056,26],[73057,73061,1],[73063,73064,1],[73066,73097,1],[73112,73440,328],[73441,73458,1],[73474,73476,2],[73477,73488,1],[73490,73523,1],[73648,73728,80],[73729,74649,1],[74880,75075,1],[77712,77808,1],[77824,78895,1],[78913,78918,1],[82944,83526,1],[92160,92728,1],[92736,92766,1],[92784,92862,1],[92880,92909,1],[92928,92975,1],[93027,93047,1],[93053,93071,1],[93952,94026,1],[94032,94208,176],[94209,100343,1],[100352,101589,1],[101632,101640,1],[110592,110882,1],[110898,110928,30],[110929,110930,1],[110933,110948,15],[110949,110951,1],[110960,111355,1],[113664,113770,1],[113776,113788,1],[113792,113800,1],[113808,113817,1],[122634,123136,502],[123137,123180,1],[123214,123536,322],[123537,123565,1],[123584,123627,1],[124112,124138,1],[124896,124902,1],[124904,124907,1],[124909,124910,1],[124912,124926,1],[124928,125124,1],[126464,126467,1],[126469,126495,1],[126497,126498,1],[126500,126503,3],[126505,126514,1],[126516,126519,1],[126521,126523,2],[126530,126535,5],[126537,126541,2],[126542,126543,1],[126545,126546,1],[126548,126551,3],[126553,126561,2],[126562,126564,2],[126567,126570,1],[126572,126578,1],[126580,126583,1],[126585,126588,1],[126590,126592,2],[126593,126601,1],[126603,126619,1],[126625,126627,1],[126629,126633,1],[126635,126651,1],[131072,173791,1],[173824,177977,1],[177984,178205,1],[178208,183969,1],[183984,191456,1],[191472,192093,1],[194560,195101,1],[196608,201546,1],[201552,205743,1]];static Lt=[[453,459,3],[498,8072,7574],[8073,8079,1],[8088,8095,1],[8104,8111,1],[8124,8140,16],[8188,8188,1]];static foldLt=[[452,454,2],[455,457,2],[458,460,2],[497,499,2],[8064,8071,1],[8080,8087,1],[8096,8103,1],[8115,8131,16],[8179,8179,1]];static Lu=[[65,90,1],[192,214,1],[216,222,1],[256,310,2],[313,327,2],[330,376,2],[377,381,2],[385,386,1],[388,390,2],[391,393,2],[394,395,1],[398,401,1],[403,404,1],[406,408,1],[412,413,1],[415,416,1],[418,422,2],[423,425,2],[428,430,2],[431,433,2],[434,435,1],[437,439,2],[440,444,4],[452,461,3],[463,475,2],[478,494,2],[497,500,3],[502,504,1],[506,562,2],[570,571,1],[573,574,1],[577,579,2],[580,582,1],[584,590,2],[880,882,2],[886,895,9],[902,904,2],[905,906,1],[908,910,2],[911,913,2],[914,929,1],[931,939,1],[975,978,3],[979,980,1],[984,1006,2],[1012,1015,3],[1017,1018,1],[1021,1071,1],[1120,1152,2],[1162,1216,2],[1217,1229,2],[1232,1326,2],[1329,1366,1],[4256,4293,1],[4295,4301,6],[5024,5109,1],[7312,7354,1],[7357,7359,1],[7680,7828,2],[7838,7934,2],[7944,7951,1],[7960,7965,1],[7976,7983,1],[7992,7999,1],[8008,8013,1],[8025,8031,2],[8040,8047,1],[8120,8123,1],[8136,8139,1],[8152,8155,1],[8168,8172,1],[8184,8187,1],[8450,8455,5],[8459,8461,1],[8464,8466,1],[8469,8473,4],[8474,8477,1],[8484,8490,2],[8491,8493,1],[8496,8499,1],[8510,8511,1],[8517,8579,62],[11264,11311,1],[11360,11362,2],[11363,11364,1],[11367,11373,2],[11374,11376,1],[11378,11381,3],[11390,11392,1],[11394,11490,2],[11499,11501,2],[11506,42560,31054],[42562,42604,2],[42624,42650,2],[42786,42798,2],[42802,42862,2],[42873,42877,2],[42878,42886,2],[42891,42893,2],[42896,42898,2],[42902,42922,2],[42923,42926,1],[42928,42932,1],[42934,42948,2],[42949,42951,1],[42953,42960,7],[42966,42968,2],[42997,65313,22316],[65314,65338,1],[66560,66599,1],[66736,66771,1],[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[68736,68786,1],[71840,71871,1],[93760,93791,1],[119808,119833,1],[119860,119885,1],[119912,119937,1],[119964,119966,2],[119967,119973,3],[119974,119977,3],[119978,119980,1],[119982,119989,1],[120016,120041,1],[120068,120069,1],[120071,120074,1],[120077,120084,1],[120086,120092,1],[120120,120121,1],[120123,120126,1],[120128,120132,1],[120134,120138,4],[120139,120144,1],[120172,120197,1],[120224,120249,1],[120276,120301,1],[120328,120353,1],[120380,120405,1],[120432,120457,1],[120488,120512,1],[120546,120570,1],[120604,120628,1],[120662,120686,1],[120720,120744,1],[120778,125184,4406],[125185,125217,1]];static Upper=this.Lu;static foldLu=[[97,122,1],[181,223,42],[224,246,1],[248,255,1],[257,303,2],[307,311,2],[314,328,2],[331,375,2],[378,382,2],[383,384,1],[387,389,2],[392,396,4],[402,405,3],[409,410,1],[414,417,3],[419,421,2],[424,429,5],[432,436,4],[438,441,3],[445,447,2],[453,454,1],[456,457,1],[459,460,1],[462,476,2],[477,495,2],[498,499,1],[501,505,4],[507,543,2],[547,563,2],[572,575,3],[576,578,2],[583,591,2],[592,596,1],[598,599,1],[601,603,2],[604,608,4],[609,613,2],[614,616,2],[617,620,1],[623,625,2],[626,629,3],[637,640,3],[642,643,1],[647,652,1],[658,669,11],[670,837,167],[881,883,2],[887,891,4],[892,893,1],[940,943,1],[945,974,1],[976,977,1],[981,983,1],[985,1007,2],[1008,1011,1],[1013,1019,3],[1072,1119,1],[1121,1153,2],[1163,1215,2],[1218,1230,2],[1231,1327,2],[1377,1414,1],[4304,4346,1],[4349,4351,1],[5112,5117,1],[7296,7304,1],[7545,7549,4],[7566,7681,115],[7683,7829,2],[7835,7841,6],[7843,7935,2],[7936,7943,1],[7952,7957,1],[7968,7975,1],[7984,7991,1],[8e3,8005,1],[8017,8023,2],[8032,8039,1],[8048,8061,1],[8112,8113,1],[8126,8144,18],[8145,8160,15],[8161,8165,4],[8526,8580,54],[11312,11359,1],[11361,11365,4],[11366,11372,2],[11379,11382,3],[11393,11491,2],[11500,11502,2],[11507,11520,13],[11521,11557,1],[11559,11565,6],[42561,42605,2],[42625,42651,2],[42787,42799,2],[42803,42863,2],[42874,42876,2],[42879,42887,2],[42892,42897,5],[42899,42900,1],[42903,42921,2],[42933,42947,2],[42952,42954,2],[42961,42967,6],[42969,42998,29],[43859,43888,29],[43889,43967,1],[65345,65370,1],[66600,66639,1],[66776,66811,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1],[68800,68850,1],[71872,71903,1],[93792,93823,1],[125218,125251,1]];static M=[[768,879,1],[1155,1161,1],[1425,1469,1],[1471,1473,2],[1474,1476,2],[1477,1479,2],[1552,1562,1],[1611,1631,1],[1648,1750,102],[1751,1756,1],[1759,1764,1],[1767,1768,1],[1770,1773,1],[1809,1840,31],[1841,1866,1],[1958,1968,1],[2027,2035,1],[2045,2070,25],[2071,2073,1],[2075,2083,1],[2085,2087,1],[2089,2093,1],[2137,2139,1],[2200,2207,1],[2250,2273,1],[2275,2307,1],[2362,2364,1],[2366,2383,1],[2385,2391,1],[2402,2403,1],[2433,2435,1],[2492,2494,2],[2495,2500,1],[2503,2504,1],[2507,2509,1],[2519,2530,11],[2531,2558,27],[2561,2563,1],[2620,2622,2],[2623,2626,1],[2631,2632,1],[2635,2637,1],[2641,2672,31],[2673,2677,4],[2689,2691,1],[2748,2750,2],[2751,2757,1],[2759,2761,1],[2763,2765,1],[2786,2787,1],[2810,2815,1],[2817,2819,1],[2876,2878,2],[2879,2884,1],[2887,2888,1],[2891,2893,1],[2901,2903,1],[2914,2915,1],[2946,3006,60],[3007,3010,1],[3014,3016,1],[3018,3021,1],[3031,3072,41],[3073,3076,1],[3132,3134,2],[3135,3140,1],[3142,3144,1],[3146,3149,1],[3157,3158,1],[3170,3171,1],[3201,3203,1],[3260,3262,2],[3263,3268,1],[3270,3272,1],[3274,3277,1],[3285,3286,1],[3298,3299,1],[3315,3328,13],[3329,3331,1],[3387,3388,1],[3390,3396,1],[3398,3400,1],[3402,3405,1],[3415,3426,11],[3427,3457,30],[3458,3459,1],[3530,3535,5],[3536,3540,1],[3542,3544,2],[3545,3551,1],[3570,3571,1],[3633,3636,3],[3637,3642,1],[3655,3662,1],[3761,3764,3],[3765,3772,1],[3784,3790,1],[3864,3865,1],[3893,3897,2],[3902,3903,1],[3953,3972,1],[3974,3975,1],[3981,3991,1],[3993,4028,1],[4038,4139,101],[4140,4158,1],[4182,4185,1],[4190,4192,1],[4194,4196,1],[4199,4205,1],[4209,4212,1],[4226,4237,1],[4239,4250,11],[4251,4253,1],[4957,4959,1],[5906,5909,1],[5938,5940,1],[5970,5971,1],[6002,6003,1],[6068,6099,1],[6109,6155,46],[6156,6157,1],[6159,6277,118],[6278,6313,35],[6432,6443,1],[6448,6459,1],[6679,6683,1],[6741,6750,1],[6752,6780,1],[6783,6832,49],[6833,6862,1],[6912,6916,1],[6964,6980,1],[7019,7027,1],[7040,7042,1],[7073,7085,1],[7142,7155,1],[7204,7223,1],[7376,7378,1],[7380,7400,1],[7405,7412,7],[7415,7417,1],[7616,7679,1],[8400,8432,1],[11503,11505,1],[11647,11744,97],[11745,11775,1],[12330,12335,1],[12441,12442,1],[42607,42610,1],[42612,42621,1],[42654,42655,1],[42736,42737,1],[43010,43014,4],[43019,43043,24],[43044,43047,1],[43052,43136,84],[43137,43188,51],[43189,43205,1],[43232,43249,1],[43263,43302,39],[43303,43309,1],[43335,43347,1],[43392,43395,1],[43443,43456,1],[43493,43561,68],[43562,43574,1],[43587,43596,9],[43597,43643,46],[43644,43645,1],[43696,43698,2],[43699,43700,1],[43703,43704,1],[43710,43711,1],[43713,43755,42],[43756,43759,1],[43765,43766,1],[44003,44010,1],[44012,44013,1],[64286,65024,738],[65025,65039,1],[65056,65071,1],[66045,66272,227],[66422,66426,1],[68097,68099,1],[68101,68102,1],[68108,68111,1],[68152,68154,1],[68159,68325,166],[68326,68900,574],[68901,68903,1],[69291,69292,1],[69373,69375,1],[69446,69456,1],[69506,69509,1],[69632,69634,1],[69688,69702,1],[69744,69747,3],[69748,69759,11],[69760,69762,1],[69808,69818,1],[69826,69888,62],[69889,69890,1],[69927,69940,1],[69957,69958,1],[70003,70016,13],[70017,70018,1],[70067,70080,1],[70089,70092,1],[70094,70095,1],[70188,70199,1],[70206,70209,3],[70367,70378,1],[70400,70403,1],[70459,70460,1],[70462,70468,1],[70471,70472,1],[70475,70477,1],[70487,70498,11],[70499,70502,3],[70503,70508,1],[70512,70516,1],[70709,70726,1],[70750,70832,82],[70833,70851,1],[71087,71093,1],[71096,71104,1],[71132,71133,1],[71216,71232,1],[71339,71351,1],[71453,71467,1],[71724,71738,1],[71984,71989,1],[71991,71992,1],[71995,71998,1],[72e3,72002,2],[72003,72145,142],[72146,72151,1],[72154,72160,1],[72164,72193,29],[72194,72202,1],[72243,72249,1],[72251,72254,1],[72263,72273,10],[72274,72283,1],[72330,72345,1],[72751,72758,1],[72760,72767,1],[72850,72871,1],[72873,72886,1],[73009,73014,1],[73018,73020,2],[73021,73023,2],[73024,73029,1],[73031,73098,67],[73099,73102,1],[73104,73105,1],[73107,73111,1],[73459,73462,1],[73472,73473,1],[73475,73524,49],[73525,73530,1],[73534,73538,1],[78912,78919,7],[78920,78933,1],[92912,92916,1],[92976,92982,1],[94031,94033,2],[94034,94087,1],[94095,94098,1],[94180,94192,12],[94193,113821,19628],[113822,118528,4706],[118529,118573,1],[118576,118598,1],[119141,119145,1],[119149,119154,1],[119163,119170,1],[119173,119179,1],[119210,119213,1],[119362,119364,1],[121344,121398,1],[121403,121452,1],[121461,121476,15],[121499,121503,1],[121505,121519,1],[122880,122886,1],[122888,122904,1],[122907,122913,1],[122915,122916,1],[122918,122922,1],[123023,123184,161],[123185,123190,1],[123566,123628,62],[123629,123631,1],[124140,124143,1],[125136,125142,1],[125252,125258,1],[917760,917999,1]];static foldM=[[921,953,32],[8126,8126,1]];static Mc=[[2307,2363,56],[2366,2368,1],[2377,2380,1],[2382,2383,1],[2434,2435,1],[2494,2496,1],[2503,2504,1],[2507,2508,1],[2519,2563,44],[2622,2624,1],[2691,2750,59],[2751,2752,1],[2761,2763,2],[2764,2818,54],[2819,2878,59],[2880,2887,7],[2888,2891,3],[2892,2903,11],[3006,3007,1],[3009,3010,1],[3014,3016,1],[3018,3020,1],[3031,3073,42],[3074,3075,1],[3137,3140,1],[3202,3203,1],[3262,3264,2],[3265,3268,1],[3271,3272,1],[3274,3275,1],[3285,3286,1],[3315,3330,15],[3331,3390,59],[3391,3392,1],[3398,3400,1],[3402,3404,1],[3415,3458,43],[3459,3535,76],[3536,3537,1],[3544,3551,1],[3570,3571,1],[3902,3903,1],[3967,4139,172],[4140,4145,5],[4152,4155,3],[4156,4182,26],[4183,4194,11],[4195,4196,1],[4199,4205,1],[4227,4228,1],[4231,4236,1],[4239,4250,11],[4251,4252,1],[5909,5940,31],[6070,6078,8],[6079,6085,1],[6087,6088,1],[6435,6438,1],[6441,6443,1],[6448,6449,1],[6451,6456,1],[6681,6682,1],[6741,6743,2],[6753,6755,2],[6756,6765,9],[6766,6770,1],[6916,6965,49],[6971,6973,2],[6974,6977,1],[6979,6980,1],[7042,7073,31],[7078,7079,1],[7082,7143,61],[7146,7148,1],[7150,7154,4],[7155,7204,49],[7205,7211,1],[7220,7221,1],[7393,7415,22],[12334,12335,1],[43043,43044,1],[43047,43136,89],[43137,43188,51],[43189,43203,1],[43346,43347,1],[43395,43444,49],[43445,43450,5],[43451,43454,3],[43455,43456,1],[43567,43568,1],[43571,43572,1],[43597,43643,46],[43645,43755,110],[43758,43759,1],[43765,44003,238],[44004,44006,2],[44007,44009,2],[44010,44012,2],[69632,69634,2],[69762,69808,46],[69809,69810,1],[69815,69816,1],[69932,69957,25],[69958,70018,60],[70067,70069,1],[70079,70080,1],[70094,70188,94],[70189,70190,1],[70194,70195,1],[70197,70368,171],[70369,70370,1],[70402,70403,1],[70462,70463,1],[70465,70468,1],[70471,70472,1],[70475,70477,1],[70487,70498,11],[70499,70709,210],[70710,70711,1],[70720,70721,1],[70725,70832,107],[70833,70834,1],[70841,70843,2],[70844,70846,1],[70849,71087,238],[71088,71089,1],[71096,71099,1],[71102,71216,114],[71217,71218,1],[71227,71228,1],[71230,71340,110],[71342,71343,1],[71350,71456,106],[71457,71462,5],[71724,71726,1],[71736,71984,248],[71985,71989,1],[71991,71992,1],[71997,72e3,3],[72002,72145,143],[72146,72147,1],[72156,72159,1],[72164,72249,85],[72279,72280,1],[72343,72751,408],[72766,72873,107],[72881,72884,3],[73098,73102,1],[73107,73108,1],[73110,73461,351],[73462,73475,13],[73524,73525,1],[73534,73535,1],[73537,94033,20496],[94034,94087,1],[94192,94193,1],[119141,119142,1],[119149,119154,1]];static Me=[[1160,1161,1],[6846,8413,1567],[8414,8416,1],[8418,8420,1],[42608,42610,1]];static Mn=[[768,879,1],[1155,1159,1],[1425,1469,1],[1471,1473,2],[1474,1476,2],[1477,1479,2],[1552,1562,1],[1611,1631,1],[1648,1750,102],[1751,1756,1],[1759,1764,1],[1767,1768,1],[1770,1773,1],[1809,1840,31],[1841,1866,1],[1958,1968,1],[2027,2035,1],[2045,2070,25],[2071,2073,1],[2075,2083,1],[2085,2087,1],[2089,2093,1],[2137,2139,1],[2200,2207,1],[2250,2273,1],[2275,2306,1],[2362,2364,2],[2369,2376,1],[2381,2385,4],[2386,2391,1],[2402,2403,1],[2433,2492,59],[2497,2500,1],[2509,2530,21],[2531,2558,27],[2561,2562,1],[2620,2625,5],[2626,2631,5],[2632,2635,3],[2636,2637,1],[2641,2672,31],[2673,2677,4],[2689,2690,1],[2748,2753,5],[2754,2757,1],[2759,2760,1],[2765,2786,21],[2787,2810,23],[2811,2815,1],[2817,2876,59],[2879,2881,2],[2882,2884,1],[2893,2901,8],[2902,2914,12],[2915,2946,31],[3008,3021,13],[3072,3076,4],[3132,3134,2],[3135,3136,1],[3142,3144,1],[3146,3149,1],[3157,3158,1],[3170,3171,1],[3201,3260,59],[3263,3270,7],[3276,3277,1],[3298,3299,1],[3328,3329,1],[3387,3388,1],[3393,3396,1],[3405,3426,21],[3427,3457,30],[3530,3538,8],[3539,3540,1],[3542,3633,91],[3636,3642,1],[3655,3662,1],[3761,3764,3],[3765,3772,1],[3784,3790,1],[3864,3865,1],[3893,3897,2],[3953,3966,1],[3968,3972,1],[3974,3975,1],[3981,3991,1],[3993,4028,1],[4038,4141,103],[4142,4144,1],[4146,4151,1],[4153,4154,1],[4157,4158,1],[4184,4185,1],[4190,4192,1],[4209,4212,1],[4226,4229,3],[4230,4237,7],[4253,4957,704],[4958,4959,1],[5906,5908,1],[5938,5939,1],[5970,5971,1],[6002,6003,1],[6068,6069,1],[6071,6077,1],[6086,6089,3],[6090,6099,1],[6109,6155,46],[6156,6157,1],[6159,6277,118],[6278,6313,35],[6432,6434,1],[6439,6440,1],[6450,6457,7],[6458,6459,1],[6679,6680,1],[6683,6742,59],[6744,6750,1],[6752,6754,2],[6757,6764,1],[6771,6780,1],[6783,6832,49],[6833,6845,1],[6847,6862,1],[6912,6915,1],[6964,6966,2],[6967,6970,1],[6972,6978,6],[7019,7027,1],[7040,7041,1],[7074,7077,1],[7080,7081,1],[7083,7085,1],[7142,7144,2],[7145,7149,4],[7151,7153,1],[7212,7219,1],[7222,7223,1],[7376,7378,1],[7380,7392,1],[7394,7400,1],[7405,7412,7],[7416,7417,1],[7616,7679,1],[8400,8412,1],[8417,8421,4],[8422,8432,1],[11503,11505,1],[11647,11744,97],[11745,11775,1],[12330,12333,1],[12441,12442,1],[42607,42612,5],[42613,42621,1],[42654,42655,1],[42736,42737,1],[43010,43014,4],[43019,43045,26],[43046,43052,6],[43204,43205,1],[43232,43249,1],[43263,43302,39],[43303,43309,1],[43335,43345,1],[43392,43394,1],[43443,43446,3],[43447,43449,1],[43452,43453,1],[43493,43561,68],[43562,43566,1],[43569,43570,1],[43573,43574,1],[43587,43596,9],[43644,43696,52],[43698,43700,1],[43703,43704,1],[43710,43711,1],[43713,43756,43],[43757,43766,9],[44005,44008,3],[44013,64286,20273],[65024,65039,1],[65056,65071,1],[66045,66272,227],[66422,66426,1],[68097,68099,1],[68101,68102,1],[68108,68111,1],[68152,68154,1],[68159,68325,166],[68326,68900,574],[68901,68903,1],[69291,69292,1],[69373,69375,1],[69446,69456,1],[69506,69509,1],[69633,69688,55],[69689,69702,1],[69744,69747,3],[69748,69759,11],[69760,69761,1],[69811,69814,1],[69817,69818,1],[69826,69888,62],[69889,69890,1],[69927,69931,1],[69933,69940,1],[70003,70016,13],[70017,70070,53],[70071,70078,1],[70089,70092,1],[70095,70191,96],[70192,70193,1],[70196,70198,2],[70199,70206,7],[70209,70367,158],[70371,70378,1],[70400,70401,1],[70459,70460,1],[70464,70502,38],[70503,70508,1],[70512,70516,1],[70712,70719,1],[70722,70724,1],[70726,70750,24],[70835,70840,1],[70842,70847,5],[70848,70850,2],[70851,71090,239],[71091,71093,1],[71100,71101,1],[71103,71104,1],[71132,71133,1],[71219,71226,1],[71229,71231,2],[71232,71339,107],[71341,71344,3],[71345,71349,1],[71351,71453,102],[71454,71455,1],[71458,71461,1],[71463,71467,1],[71727,71735,1],[71737,71738,1],[71995,71996,1],[71998,72003,5],[72148,72151,1],[72154,72155,1],[72160,72193,33],[72194,72202,1],[72243,72248,1],[72251,72254,1],[72263,72273,10],[72274,72278,1],[72281,72283,1],[72330,72342,1],[72344,72345,1],[72752,72758,1],[72760,72765,1],[72767,72850,83],[72851,72871,1],[72874,72880,1],[72882,72883,1],[72885,72886,1],[73009,73014,1],[73018,73020,2],[73021,73023,2],[73024,73029,1],[73031,73104,73],[73105,73109,4],[73111,73459,348],[73460,73472,12],[73473,73526,53],[73527,73530,1],[73536,73538,2],[78912,78919,7],[78920,78933,1],[92912,92916,1],[92976,92982,1],[94031,94095,64],[94096,94098,1],[94180,113821,19641],[113822,118528,4706],[118529,118573,1],[118576,118598,1],[119143,119145,1],[119163,119170,1],[119173,119179,1],[119210,119213,1],[119362,119364,1],[121344,121398,1],[121403,121452,1],[121461,121476,15],[121499,121503,1],[121505,121519,1],[122880,122886,1],[122888,122904,1],[122907,122913,1],[122915,122916,1],[122918,122922,1],[123023,123184,161],[123185,123190,1],[123566,123628,62],[123629,123631,1],[124140,124143,1],[125136,125142,1],[125252,125258,1],[917760,917999,1]];static foldMn=[[921,953,32],[8126,8126,1]];static N=[[48,57,1],[178,179,1],[185,188,3],[189,190,1],[1632,1641,1],[1776,1785,1],[1984,1993,1],[2406,2415,1],[2534,2543,1],[2548,2553,1],[2662,2671,1],[2790,2799,1],[2918,2927,1],[2930,2935,1],[3046,3058,1],[3174,3183,1],[3192,3198,1],[3302,3311,1],[3416,3422,1],[3430,3448,1],[3558,3567,1],[3664,3673,1],[3792,3801,1],[3872,3891,1],[4160,4169,1],[4240,4249,1],[4969,4988,1],[5870,5872,1],[6112,6121,1],[6128,6137,1],[6160,6169,1],[6470,6479,1],[6608,6618,1],[6784,6793,1],[6800,6809,1],[6992,7001,1],[7088,7097,1],[7232,7241,1],[7248,7257,1],[8304,8308,4],[8309,8313,1],[8320,8329,1],[8528,8578,1],[8581,8585,1],[9312,9371,1],[9450,9471,1],[10102,10131,1],[11517,12295,778],[12321,12329,1],[12344,12346,1],[12690,12693,1],[12832,12841,1],[12872,12879,1],[12881,12895,1],[12928,12937,1],[12977,12991,1],[42528,42537,1],[42726,42735,1],[43056,43061,1],[43216,43225,1],[43264,43273,1],[43472,43481,1],[43504,43513,1],[43600,43609,1],[44016,44025,1],[65296,65305,1],[65799,65843,1],[65856,65912,1],[65930,65931,1],[66273,66299,1],[66336,66339,1],[66369,66378,9],[66513,66517,1],[66720,66729,1],[67672,67679,1],[67705,67711,1],[67751,67759,1],[67835,67839,1],[67862,67867,1],[68028,68029,1],[68032,68047,1],[68050,68095,1],[68160,68168,1],[68221,68222,1],[68253,68255,1],[68331,68335,1],[68440,68447,1],[68472,68479,1],[68521,68527,1],[68858,68863,1],[68912,68921,1],[69216,69246,1],[69405,69414,1],[69457,69460,1],[69573,69579,1],[69714,69743,1],[69872,69881,1],[69942,69951,1],[70096,70105,1],[70113,70132,1],[70384,70393,1],[70736,70745,1],[70864,70873,1],[71248,71257,1],[71360,71369,1],[71472,71483,1],[71904,71922,1],[72016,72025,1],[72784,72812,1],[73040,73049,1],[73120,73129,1],[73552,73561,1],[73664,73684,1],[74752,74862,1],[92768,92777,1],[92864,92873,1],[93008,93017,1],[93019,93025,1],[93824,93846,1],[119488,119507,1],[119520,119539,1],[119648,119672,1],[120782,120831,1],[123200,123209,1],[123632,123641,1],[124144,124153,1],[125127,125135,1],[125264,125273,1],[126065,126123,1],[126125,126127,1],[126129,126132,1],[126209,126253,1],[126255,126269,1],[127232,127244,1],[130032,130041,1]];static Nd=[[48,57,1],[1632,1641,1],[1776,1785,1],[1984,1993,1],[2406,2415,1],[2534,2543,1],[2662,2671,1],[2790,2799,1],[2918,2927,1],[3046,3055,1],[3174,3183,1],[3302,3311,1],[3430,3439,1],[3558,3567,1],[3664,3673,1],[3792,3801,1],[3872,3881,1],[4160,4169,1],[4240,4249,1],[6112,6121,1],[6160,6169,1],[6470,6479,1],[6608,6617,1],[6784,6793,1],[6800,6809,1],[6992,7001,1],[7088,7097,1],[7232,7241,1],[7248,7257,1],[42528,42537,1],[43216,43225,1],[43264,43273,1],[43472,43481,1],[43504,43513,1],[43600,43609,1],[44016,44025,1],[65296,65305,1],[66720,66729,1],[68912,68921,1],[69734,69743,1],[69872,69881,1],[69942,69951,1],[70096,70105,1],[70384,70393,1],[70736,70745,1],[70864,70873,1],[71248,71257,1],[71360,71369,1],[71472,71481,1],[71904,71913,1],[72016,72025,1],[72784,72793,1],[73040,73049,1],[73120,73129,1],[73552,73561,1],[92768,92777,1],[92864,92873,1],[93008,93017,1],[120782,120831,1],[123200,123209,1],[123632,123641,1],[124144,124153,1],[125264,125273,1],[130032,130041,1]];static Nl=[[5870,5872,1],[8544,8578,1],[8581,8584,1],[12295,12321,26],[12322,12329,1],[12344,12346,1],[42726,42735,1],[65856,65908,1],[66369,66378,9],[66513,66517,1],[74752,74862,1]];static No=[[178,179,1],[185,188,3],[189,190,1],[2548,2553,1],[2930,2935,1],[3056,3058,1],[3192,3198,1],[3416,3422,1],[3440,3448,1],[3882,3891,1],[4969,4988,1],[6128,6137,1],[6618,8304,1686],[8308,8313,1],[8320,8329,1],[8528,8543,1],[8585,9312,727],[9313,9371,1],[9450,9471,1],[10102,10131,1],[11517,12690,1173],[12691,12693,1],[12832,12841,1],[12872,12879,1],[12881,12895,1],[12928,12937,1],[12977,12991,1],[43056,43061,1],[65799,65843,1],[65909,65912,1],[65930,65931,1],[66273,66299,1],[66336,66339,1],[67672,67679,1],[67705,67711,1],[67751,67759,1],[67835,67839,1],[67862,67867,1],[68028,68029,1],[68032,68047,1],[68050,68095,1],[68160,68168,1],[68221,68222,1],[68253,68255,1],[68331,68335,1],[68440,68447,1],[68472,68479,1],[68521,68527,1],[68858,68863,1],[69216,69246,1],[69405,69414,1],[69457,69460,1],[69573,69579,1],[69714,69733,1],[70113,70132,1],[71482,71483,1],[71914,71922,1],[72794,72812,1],[73664,73684,1],[93019,93025,1],[93824,93846,1],[119488,119507,1],[119520,119539,1],[119648,119672,1],[125127,125135,1],[126065,126123,1],[126125,126127,1],[126129,126132,1],[126209,126253,1],[126255,126269,1],[127232,127244,1]];static P=[[33,35,1],[37,42,1],[44,47,1],[58,59,1],[63,64,1],[91,93,1],[95,123,28],[125,161,36],[167,171,4],[182,183,1],[187,191,4],[894,903,9],[1370,1375,1],[1417,1418,1],[1470,1472,2],[1475,1478,3],[1523,1524,1],[1545,1546,1],[1548,1549,1],[1563,1565,2],[1566,1567,1],[1642,1645,1],[1748,1792,44],[1793,1805,1],[2039,2041,1],[2096,2110,1],[2142,2404,262],[2405,2416,11],[2557,2678,121],[2800,3191,391],[3204,3572,368],[3663,3674,11],[3675,3844,169],[3845,3858,1],[3860,3898,38],[3899,3901,1],[3973,4048,75],[4049,4052,1],[4057,4058,1],[4170,4175,1],[4347,4960,613],[4961,4968,1],[5120,5742,622],[5787,5788,1],[5867,5869,1],[5941,5942,1],[6100,6102,1],[6104,6106,1],[6144,6154,1],[6468,6469,1],[6686,6687,1],[6816,6822,1],[6824,6829,1],[7002,7008,1],[7037,7038,1],[7164,7167,1],[7227,7231,1],[7294,7295,1],[7360,7367,1],[7379,8208,829],[8209,8231,1],[8240,8259,1],[8261,8273,1],[8275,8286,1],[8317,8318,1],[8333,8334,1],[8968,8971,1],[9001,9002,1],[10088,10101,1],[10181,10182,1],[10214,10223,1],[10627,10648,1],[10712,10715,1],[10748,10749,1],[11513,11516,1],[11518,11519,1],[11632,11776,144],[11777,11822,1],[11824,11855,1],[11858,11869,1],[12289,12291,1],[12296,12305,1],[12308,12319,1],[12336,12349,13],[12448,12539,91],[42238,42239,1],[42509,42511,1],[42611,42622,11],[42738,42743,1],[43124,43127,1],[43214,43215,1],[43256,43258,1],[43260,43310,50],[43311,43359,48],[43457,43469,1],[43486,43487,1],[43612,43615,1],[43742,43743,1],[43760,43761,1],[44011,64830,20819],[64831,65040,209],[65041,65049,1],[65072,65106,1],[65108,65121,1],[65123,65128,5],[65130,65131,1],[65281,65283,1],[65285,65290,1],[65292,65295,1],[65306,65307,1],[65311,65312,1],[65339,65341,1],[65343,65371,28],[65373,65375,2],[65376,65381,1],[65792,65794,1],[66463,66512,49],[66927,67671,744],[67871,67903,32],[68176,68184,1],[68223,68336,113],[68337,68342,1],[68409,68415,1],[68505,68508,1],[69293,69461,168],[69462,69465,1],[69510,69513,1],[69703,69709,1],[69819,69820,1],[69822,69825,1],[69952,69955,1],[70004,70005,1],[70085,70088,1],[70093,70107,14],[70109,70111,1],[70200,70205,1],[70313,70731,418],[70732,70735,1],[70746,70747,1],[70749,70854,105],[71105,71127,1],[71233,71235,1],[71264,71276,1],[71353,71484,131],[71485,71486,1],[71739,72004,265],[72005,72006,1],[72162,72255,93],[72256,72262,1],[72346,72348,1],[72350,72354,1],[72448,72457,1],[72769,72773,1],[72816,72817,1],[73463,73464,1],[73539,73551,1],[73727,74864,1137],[74865,74868,1],[77809,77810,1],[92782,92783,1],[92917,92983,66],[92984,92987,1],[92996,93847,851],[93848,93850,1],[94178,113823,19645],[121479,121483,1],[125278,125279,1]];static Pc=[[95,8255,8160],[8256,8276,20],[65075,65076,1],[65101,65103,1],[65343,65343,1]];static Pd=[[45,1418,1373],[1470,5120,3650],[6150,8208,2058],[8209,8213,1],[11799,11802,3],[11834,11835,1],[11840,11869,29],[12316,12336,20],[12448,65073,52625],[65074,65112,38],[65123,65293,170],[69293,69293,1]];static Pe=[[41,93,52],[125,3899,3774],[3901,5788,1887],[8262,8318,56],[8334,8969,635],[8971,9002,31],[10089,10101,2],[10182,10215,33],[10217,10223,2],[10628,10648,2],[10713,10715,2],[10749,11811,1062],[11813,11817,2],[11862,11868,2],[12297,12305,2],[12309,12315,2],[12318,12319,1],[64830,65048,218],[65078,65092,2],[65096,65114,18],[65116,65118,2],[65289,65341,52],[65373,65379,3]];static Pf=[[187,8217,8030],[8221,8250,29],[11779,11781,2],[11786,11789,3],[11805,11809,4]];static Pi=[[171,8216,8045],[8219,8220,1],[8223,8249,26],[11778,11780,2],[11785,11788,3],[11804,11808,4]];static Po=[[33,35,1],[37,39,1],[42,46,2],[47,58,11],[59,63,4],[64,92,28],[161,167,6],[182,183,1],[191,894,703],[903,1370,467],[1371,1375,1],[1417,1472,55],[1475,1478,3],[1523,1524,1],[1545,1546,1],[1548,1549,1],[1563,1565,2],[1566,1567,1],[1642,1645,1],[1748,1792,44],[1793,1805,1],[2039,2041,1],[2096,2110,1],[2142,2404,262],[2405,2416,11],[2557,2678,121],[2800,3191,391],[3204,3572,368],[3663,3674,11],[3675,3844,169],[3845,3858,1],[3860,3973,113],[4048,4052,1],[4057,4058,1],[4170,4175,1],[4347,4960,613],[4961,4968,1],[5742,5867,125],[5868,5869,1],[5941,5942,1],[6100,6102,1],[6104,6106,1],[6144,6149,1],[6151,6154,1],[6468,6469,1],[6686,6687,1],[6816,6822,1],[6824,6829,1],[7002,7008,1],[7037,7038,1],[7164,7167,1],[7227,7231,1],[7294,7295,1],[7360,7367,1],[7379,8214,835],[8215,8224,9],[8225,8231,1],[8240,8248,1],[8251,8254,1],[8257,8259,1],[8263,8273,1],[8275,8277,2],[8278,8286,1],[11513,11516,1],[11518,11519,1],[11632,11776,144],[11777,11782,5],[11783,11784,1],[11787,11790,3],[11791,11798,1],[11800,11801,1],[11803,11806,3],[11807,11818,11],[11819,11822,1],[11824,11833,1],[11836,11839,1],[11841,11843,2],[11844,11855,1],[11858,11860,1],[12289,12291,1],[12349,12539,190],[42238,42239,1],[42509,42511,1],[42611,42622,11],[42738,42743,1],[43124,43127,1],[43214,43215,1],[43256,43258,1],[43260,43310,50],[43311,43359,48],[43457,43469,1],[43486,43487,1],[43612,43615,1],[43742,43743,1],[43760,43761,1],[44011,65040,21029],[65041,65046,1],[65049,65072,23],[65093,65094,1],[65097,65100,1],[65104,65106,1],[65108,65111,1],[65119,65121,1],[65128,65130,2],[65131,65281,150],[65282,65283,1],[65285,65287,1],[65290,65294,2],[65295,65306,11],[65307,65311,4],[65312,65340,28],[65377,65380,3],[65381,65792,411],[65793,65794,1],[66463,66512,49],[66927,67671,744],[67871,67903,32],[68176,68184,1],[68223,68336,113],[68337,68342,1],[68409,68415,1],[68505,68508,1],[69461,69465,1],[69510,69513,1],[69703,69709,1],[69819,69820,1],[69822,69825,1],[69952,69955,1],[70004,70005,1],[70085,70088,1],[70093,70107,14],[70109,70111,1],[70200,70205,1],[70313,70731,418],[70732,70735,1],[70746,70747,1],[70749,70854,105],[71105,71127,1],[71233,71235,1],[71264,71276,1],[71353,71484,131],[71485,71486,1],[71739,72004,265],[72005,72006,1],[72162,72255,93],[72256,72262,1],[72346,72348,1],[72350,72354,1],[72448,72457,1],[72769,72773,1],[72816,72817,1],[73463,73464,1],[73539,73551,1],[73727,74864,1137],[74865,74868,1],[77809,77810,1],[92782,92783,1],[92917,92983,66],[92984,92987,1],[92996,93847,851],[93848,93850,1],[94178,113823,19645],[121479,121483,1],[125278,125279,1]];static Ps=[[40,91,51],[123,3898,3775],[3900,5787,1887],[8218,8222,4],[8261,8317,56],[8333,8968,635],[8970,9001,31],[10088,10100,2],[10181,10214,33],[10216,10222,2],[10627,10647,2],[10712,10714,2],[10748,11810,1062],[11812,11816,2],[11842,11861,19],[11863,11867,2],[12296,12304,2],[12308,12314,2],[12317,64831,52514],[65047,65077,30],[65079,65091,2],[65095,65113,18],[65115,65117,2],[65288,65339,51],[65371,65375,4],[65378,65378,1]];static S=[[36,43,7],[60,62,1],[94,96,2],[124,126,2],[162,166,1],[168,169,1],[172,174,2],[175,177,1],[180,184,4],[215,247,32],[706,709,1],[722,735,1],[741,747,1],[749,751,2],[752,767,1],[885,900,15],[901,1014,113],[1154,1421,267],[1422,1423,1],[1542,1544,1],[1547,1550,3],[1551,1758,207],[1769,1789,20],[1790,2038,248],[2046,2047,1],[2184,2546,362],[2547,2554,7],[2555,2801,246],[2928,3059,131],[3060,3066,1],[3199,3407,208],[3449,3647,198],[3841,3843,1],[3859,3861,2],[3862,3863,1],[3866,3871,1],[3892,3896,2],[4030,4037,1],[4039,4044,1],[4046,4047,1],[4053,4056,1],[4254,4255,1],[5008,5017,1],[5741,6107,366],[6464,6622,158],[6623,6655,1],[7009,7018,1],[7028,7036,1],[8125,8127,2],[8128,8129,1],[8141,8143,1],[8157,8159,1],[8173,8175,1],[8189,8190,1],[8260,8274,14],[8314,8316,1],[8330,8332,1],[8352,8384,1],[8448,8449,1],[8451,8454,1],[8456,8457,1],[8468,8470,2],[8471,8472,1],[8478,8483,1],[8485,8489,2],[8494,8506,12],[8507,8512,5],[8513,8516,1],[8522,8525,1],[8527,8586,59],[8587,8592,5],[8593,8967,1],[8972,9e3,1],[9003,9254,1],[9280,9290,1],[9372,9449,1],[9472,10087,1],[10132,10180,1],[10183,10213,1],[10224,10626,1],[10649,10711,1],[10716,10747,1],[10750,11123,1],[11126,11157,1],[11159,11263,1],[11493,11498,1],[11856,11857,1],[11904,11929,1],[11931,12019,1],[12032,12245,1],[12272,12287,1],[12292,12306,14],[12307,12320,13],[12342,12343,1],[12350,12351,1],[12443,12444,1],[12688,12689,1],[12694,12703,1],[12736,12771,1],[12783,12800,17],[12801,12830,1],[12842,12871,1],[12880,12896,16],[12897,12927,1],[12938,12976,1],[12992,13311,1],[19904,19967,1],[42128,42182,1],[42752,42774,1],[42784,42785,1],[42889,42890,1],[43048,43051,1],[43062,43065,1],[43639,43641,1],[43867,43882,15],[43883,64297,20414],[64434,64450,1],[64832,64847,1],[64975,65020,45],[65021,65023,1],[65122,65124,2],[65125,65126,1],[65129,65284,155],[65291,65308,17],[65309,65310,1],[65342,65344,2],[65372,65374,2],[65504,65510,1],[65512,65518,1],[65532,65533,1],[65847,65855,1],[65913,65929,1],[65932,65934,1],[65936,65948,1],[65952,66e3,48],[66001,66044,1],[67703,67704,1],[68296,71487,3191],[73685,73713,1],[92988,92991,1],[92997,113820,20823],[118608,118723,1],[118784,119029,1],[119040,119078,1],[119081,119140,1],[119146,119148,1],[119171,119172,1],[119180,119209,1],[119214,119274,1],[119296,119361,1],[119365,119552,187],[119553,119638,1],[120513,120539,26],[120571,120597,26],[120629,120655,26],[120687,120713,26],[120745,120771,26],[120832,121343,1],[121399,121402,1],[121453,121460,1],[121462,121475,1],[121477,121478,1],[123215,123647,432],[126124,126128,4],[126254,126704,450],[126705,126976,271],[126977,127019,1],[127024,127123,1],[127136,127150,1],[127153,127167,1],[127169,127183,1],[127185,127221,1],[127245,127405,1],[127462,127490,1],[127504,127547,1],[127552,127560,1],[127568,127569,1],[127584,127589,1],[127744,128727,1],[128732,128748,1],[128752,128764,1],[128768,128886,1],[128891,128985,1],[128992,129003,1],[129008,129024,16],[129025,129035,1],[129040,129095,1],[129104,129113,1],[129120,129159,1],[129168,129197,1],[129200,129201,1],[129280,129619,1],[129632,129645,1],[129648,129660,1],[129664,129672,1],[129680,129725,1],[129727,129733,1],[129742,129755,1],[129760,129768,1],[129776,129784,1],[129792,129938,1],[129940,129994,1]];static Sc=[[36,162,126],[163,165,1],[1423,1547,124],[2046,2047,1],[2546,2547,1],[2555,2801,246],[3065,3647,582],[6107,8352,2245],[8353,8384,1],[43064,65020,21956],[65129,65284,155],[65504,65505,1],[65509,65510,1],[73693,73696,1],[123647,126128,2481]];static Sk=[[94,96,2],[168,175,7],[180,184,4],[706,709,1],[722,735,1],[741,747,1],[749,751,2],[752,767,1],[885,900,15],[901,2184,1283],[8125,8127,2],[8128,8129,1],[8141,8143,1],[8157,8159,1],[8173,8175,1],[8189,8190,1],[12443,12444,1],[42752,42774,1],[42784,42785,1],[42889,42890,1],[43867,43882,15],[43883,64434,20551],[64435,64450,1],[65342,65344,2],[65507,127995,62488],[127996,127999,1]];static Sm=[[43,60,17],[61,62,1],[124,126,2],[172,177,5],[215,247,32],[1014,1542,528],[1543,1544,1],[8260,8274,14],[8314,8316,1],[8330,8332,1],[8472,8512,40],[8513,8516,1],[8523,8592,69],[8593,8596,1],[8602,8603,1],[8608,8614,3],[8622,8654,32],[8655,8658,3],[8660,8692,32],[8693,8959,1],[8992,8993,1],[9084,9115,31],[9116,9139,1],[9180,9185,1],[9655,9665,10],[9720,9727,1],[9839,10176,337],[10177,10180,1],[10183,10213,1],[10224,10239,1],[10496,10626,1],[10649,10711,1],[10716,10747,1],[10750,11007,1],[11056,11076,1],[11079,11084,1],[64297,65122,825],[65124,65126,1],[65291,65308,17],[65309,65310,1],[65372,65374,2],[65506,65513,7],[65514,65516,1],[120513,120539,26],[120571,120597,26],[120629,120655,26],[120687,120713,26],[120745,120771,26],[126704,126705,1]];static So=[[166,169,3],[174,176,2],[1154,1421,267],[1422,1550,128],[1551,1758,207],[1769,1789,20],[1790,2038,248],[2554,2928,374],[3059,3064,1],[3066,3199,133],[3407,3449,42],[3841,3843,1],[3859,3861,2],[3862,3863,1],[3866,3871,1],[3892,3896,2],[4030,4037,1],[4039,4044,1],[4046,4047,1],[4053,4056,1],[4254,4255,1],[5008,5017,1],[5741,6464,723],[6622,6655,1],[7009,7018,1],[7028,7036,1],[8448,8449,1],[8451,8454,1],[8456,8457,1],[8468,8470,2],[8471,8478,7],[8479,8483,1],[8485,8489,2],[8494,8506,12],[8507,8522,15],[8524,8525,1],[8527,8586,59],[8587,8597,10],[8598,8601,1],[8604,8607,1],[8609,8610,1],[8612,8613,1],[8615,8621,1],[8623,8653,1],[8656,8657,1],[8659,8661,2],[8662,8691,1],[8960,8967,1],[8972,8991,1],[8994,9e3,1],[9003,9083,1],[9085,9114,1],[9140,9179,1],[9186,9254,1],[9280,9290,1],[9372,9449,1],[9472,9654,1],[9656,9664,1],[9666,9719,1],[9728,9838,1],[9840,10087,1],[10132,10175,1],[10240,10495,1],[11008,11055,1],[11077,11078,1],[11085,11123,1],[11126,11157,1],[11159,11263,1],[11493,11498,1],[11856,11857,1],[11904,11929,1],[11931,12019,1],[12032,12245,1],[12272,12287,1],[12292,12306,14],[12307,12320,13],[12342,12343,1],[12350,12351,1],[12688,12689,1],[12694,12703,1],[12736,12771,1],[12783,12800,17],[12801,12830,1],[12842,12871,1],[12880,12896,16],[12897,12927,1],[12938,12976,1],[12992,13311,1],[19904,19967,1],[42128,42182,1],[43048,43051,1],[43062,43063,1],[43065,43639,574],[43640,43641,1],[64832,64847,1],[64975,65021,46],[65022,65023,1],[65508,65512,4],[65517,65518,1],[65532,65533,1],[65847,65855,1],[65913,65929,1],[65932,65934,1],[65936,65948,1],[65952,66e3,48],[66001,66044,1],[67703,67704,1],[68296,71487,3191],[73685,73692,1],[73697,73713,1],[92988,92991,1],[92997,113820,20823],[118608,118723,1],[118784,119029,1],[119040,119078,1],[119081,119140,1],[119146,119148,1],[119171,119172,1],[119180,119209,1],[119214,119274,1],[119296,119361,1],[119365,119552,187],[119553,119638,1],[120832,121343,1],[121399,121402,1],[121453,121460,1],[121462,121475,1],[121477,121478,1],[123215,126124,2909],[126254,126976,722],[126977,127019,1],[127024,127123,1],[127136,127150,1],[127153,127167,1],[127169,127183,1],[127185,127221,1],[127245,127405,1],[127462,127490,1],[127504,127547,1],[127552,127560,1],[127568,127569,1],[127584,127589,1],[127744,127994,1],[128e3,128727,1],[128732,128748,1],[128752,128764,1],[128768,128886,1],[128891,128985,1],[128992,129003,1],[129008,129024,16],[129025,129035,1],[129040,129095,1],[129104,129113,1],[129120,129159,1],[129168,129197,1],[129200,129201,1],[129280,129619,1],[129632,129645,1],[129648,129660,1],[129664,129672,1],[129680,129725,1],[129727,129733,1],[129742,129755,1],[129760,129768,1],[129776,129784,1],[129792,129938,1],[129940,129994,1]];static Z=[[32,160,128],[5760,8192,2432],[8193,8202,1],[8232,8233,1],[8239,8287,48],[12288,12288,1]];static Zl=[[8232,8232,1]];static Zp=[[8233,8233,1]];static Zs=[[32,160,128],[5760,8192,2432],[8193,8202,1],[8239,8287,48],[12288,12288,1]];static Adlam=[[125184,125259,1],[125264,125273,1],[125278,125279,1]];static Ahom=[[71424,71450,1],[71453,71467,1],[71472,71494,1]];static Anatolian_Hieroglyphs=[[82944,83526,1]];static Arabic=[[1536,1540,1],[1542,1547,1],[1549,1562,1],[1564,1566,1],[1568,1599,1],[1601,1610,1],[1622,1647,1],[1649,1756,1],[1758,1791,1],[1872,1919,1],[2160,2190,1],[2192,2193,1],[2200,2273,1],[2275,2303,1],[64336,64450,1],[64467,64829,1],[64832,64911,1],[64914,64967,1],[64975,65008,33],[65009,65023,1],[65136,65140,1],[65142,65276,1],[69216,69246,1],[69373,69375,1],[126464,126467,1],[126469,126495,1],[126497,126498,1],[126500,126503,3],[126505,126514,1],[126516,126519,1],[126521,126523,2],[126530,126535,5],[126537,126541,2],[126542,126543,1],[126545,126546,1],[126548,126551,3],[126553,126561,2],[126562,126564,2],[126567,126570,1],[126572,126578,1],[126580,126583,1],[126585,126588,1],[126590,126592,2],[126593,126601,1],[126603,126619,1],[126625,126627,1],[126629,126633,1],[126635,126651,1],[126704,126705,1]];static Armenian=[[1329,1366,1],[1369,1418,1],[1421,1423,1],[64275,64279,1]];static Avestan=[[68352,68405,1],[68409,68415,1]];static Balinese=[[6912,6988,1],[6992,7038,1]];static Bamum=[[42656,42743,1],[92160,92728,1]];static Bassa_Vah=[[92880,92909,1],[92912,92917,1]];static Batak=[[7104,7155,1],[7164,7167,1]];static Bengali=[[2432,2435,1],[2437,2444,1],[2447,2448,1],[2451,2472,1],[2474,2480,1],[2482,2486,4],[2487,2489,1],[2492,2500,1],[2503,2504,1],[2507,2510,1],[2519,2524,5],[2525,2527,2],[2528,2531,1],[2534,2558,1]];static Bhaiksuki=[[72704,72712,1],[72714,72758,1],[72760,72773,1],[72784,72812,1]];static Bopomofo=[[746,747,1],[12549,12591,1],[12704,12735,1]];static Brahmi=[[69632,69709,1],[69714,69749,1],[69759,69759,1]];static Braille=[[10240,10495,1]];static Buginese=[[6656,6683,1],[6686,6687,1]];static Buhid=[[5952,5971,1]];static Canadian_Aboriginal=[[5120,5759,1],[6320,6389,1],[72368,72383,1]];static Carian=[[66208,66256,1]];static Caucasian_Albanian=[[66864,66915,1],[66927,66927,1]];static Chakma=[[69888,69940,1],[69942,69959,1]];static Cham=[[43520,43574,1],[43584,43597,1],[43600,43609,1],[43612,43615,1]];static Cherokee=[[5024,5109,1],[5112,5117,1],[43888,43967,1]];static Chorasmian=[[69552,69579,1]];static Common=[[0,64,1],[91,96,1],[123,169,1],[171,185,1],[187,191,1],[215,247,32],[697,735,1],[741,745,1],[748,767,1],[884,894,10],[901,903,2],[1541,1548,7],[1563,1567,4],[1600,1757,157],[2274,2404,130],[2405,3647,1242],[4053,4056,1],[4347,5867,1520],[5868,5869,1],[5941,5942,1],[6146,6147,1],[6149,7379,1230],[7393,7401,8],[7402,7404,1],[7406,7411,1],[7413,7415,1],[7418,8192,774],[8193,8203,1],[8206,8292,1],[8294,8304,1],[8308,8318,1],[8320,8334,1],[8352,8384,1],[8448,8485,1],[8487,8489,1],[8492,8497,1],[8499,8525,1],[8527,8543,1],[8585,8587,1],[8592,9254,1],[9280,9290,1],[9312,10239,1],[10496,11123,1],[11126,11157,1],[11159,11263,1],[11776,11869,1],[12272,12292,1],[12294,12296,2],[12297,12320,1],[12336,12343,1],[12348,12351,1],[12443,12444,1],[12448,12539,91],[12540,12688,148],[12689,12703,1],[12736,12771,1],[12783,12832,49],[12833,12895,1],[12927,13007,1],[13055,13144,89],[13145,13311,1],[19904,19967,1],[42752,42785,1],[42888,42890,1],[43056,43065,1],[43310,43471,161],[43867,43882,15],[43883,64830,20947],[64831,65040,209],[65041,65049,1],[65072,65106,1],[65108,65126,1],[65128,65131,1],[65279,65281,2],[65282,65312,1],[65339,65344,1],[65371,65381,1],[65392,65438,46],[65439,65504,65],[65505,65510,1],[65512,65518,1],[65529,65533,1],[65792,65794,1],[65799,65843,1],[65847,65855,1],[65936,65948,1],[66e3,66044,1],[66273,66299,1],[113824,113827,1],[118608,118723,1],[118784,119029,1],[119040,119078,1],[119081,119142,1],[119146,119162,1],[119171,119172,1],[119180,119209,1],[119214,119274,1],[119488,119507,1],[119520,119539,1],[119552,119638,1],[119648,119672,1],[119808,119892,1],[119894,119964,1],[119966,119967,1],[119970,119973,3],[119974,119977,3],[119978,119980,1],[119982,119993,1],[119995,119997,2],[119998,120003,1],[120005,120069,1],[120071,120074,1],[120077,120084,1],[120086,120092,1],[120094,120121,1],[120123,120126,1],[120128,120132,1],[120134,120138,4],[120139,120144,1],[120146,120485,1],[120488,120779,1],[120782,120831,1],[126065,126132,1],[126209,126269,1],[126976,127019,1],[127024,127123,1],[127136,127150,1],[127153,127167,1],[127169,127183,1],[127185,127221,1],[127232,127405,1],[127462,127487,1],[127489,127490,1],[127504,127547,1],[127552,127560,1],[127568,127569,1],[127584,127589,1],[127744,128727,1],[128732,128748,1],[128752,128764,1],[128768,128886,1],[128891,128985,1],[128992,129003,1],[129008,129024,16],[129025,129035,1],[129040,129095,1],[129104,129113,1],[129120,129159,1],[129168,129197,1],[129200,129201,1],[129280,129619,1],[129632,129645,1],[129648,129660,1],[129664,129672,1],[129680,129725,1],[129727,129733,1],[129742,129755,1],[129760,129768,1],[129776,129784,1],[129792,129938,1],[129940,129994,1],[130032,130041,1],[917505,917536,31],[917537,917631,1]];static foldCommon=[[924,956,32]];static Coptic=[[994,1007,1],[11392,11507,1],[11513,11519,1]];static Cuneiform=[[73728,74649,1],[74752,74862,1],[74864,74868,1],[74880,75075,1]];static Cypriot=[[67584,67589,1],[67592,67594,2],[67595,67637,1],[67639,67640,1],[67644,67647,3]];static Cypro_Minoan=[[77712,77810,1]];static Cyrillic=[[1024,1156,1],[1159,1327,1],[7296,7304,1],[7467,7544,77],[11744,11775,1],[42560,42655,1],[65070,65071,1],[122928,122989,1],[123023,123023,1]];static Deseret=[[66560,66639,1]];static Devanagari=[[2304,2384,1],[2389,2403,1],[2406,2431,1],[43232,43263,1],[72448,72457,1]];static Dives_Akuru=[[71936,71942,1],[71945,71948,3],[71949,71955,1],[71957,71958,1],[71960,71989,1],[71991,71992,1],[71995,72006,1],[72016,72025,1]];static Dogra=[[71680,71739,1]];static Duployan=[[113664,113770,1],[113776,113788,1],[113792,113800,1],[113808,113817,1],[113820,113823,1]];static Egyptian_Hieroglyphs=[[77824,78933,1]];static Elbasan=[[66816,66855,1]];static Elymaic=[[69600,69622,1]];static Ethiopic=[[4608,4680,1],[4682,4685,1],[4688,4694,1],[4696,4698,2],[4699,4701,1],[4704,4744,1],[4746,4749,1],[4752,4784,1],[4786,4789,1],[4792,4798,1],[4800,4802,2],[4803,4805,1],[4808,4822,1],[4824,4880,1],[4882,4885,1],[4888,4954,1],[4957,4988,1],[4992,5017,1],[11648,11670,1],[11680,11686,1],[11688,11694,1],[11696,11702,1],[11704,11710,1],[11712,11718,1],[11720,11726,1],[11728,11734,1],[11736,11742,1],[43777,43782,1],[43785,43790,1],[43793,43798,1],[43808,43814,1],[43816,43822,1],[124896,124902,1],[124904,124907,1],[124909,124910,1],[124912,124926,1]];static Georgian=[[4256,4293,1],[4295,4301,6],[4304,4346,1],[4348,4351,1],[7312,7354,1],[7357,7359,1],[11520,11557,1],[11559,11565,6]];static Glagolitic=[[11264,11359,1],[122880,122886,1],[122888,122904,1],[122907,122913,1],[122915,122916,1],[122918,122922,1]];static Gothic=[[66352,66378,1]];static Grantha=[[70400,70403,1],[70405,70412,1],[70415,70416,1],[70419,70440,1],[70442,70448,1],[70450,70451,1],[70453,70457,1],[70460,70468,1],[70471,70472,1],[70475,70477,1],[70480,70487,7],[70493,70499,1],[70502,70508,1],[70512,70516,1]];static Greek=[[880,883,1],[885,887,1],[890,893,1],[895,900,5],[902,904,2],[905,906,1],[908,910,2],[911,929,1],[931,993,1],[1008,1023,1],[7462,7466,1],[7517,7521,1],[7526,7530,1],[7615,7936,321],[7937,7957,1],[7960,7965,1],[7968,8005,1],[8008,8013,1],[8016,8023,1],[8025,8031,2],[8032,8061,1],[8064,8116,1],[8118,8132,1],[8134,8147,1],[8150,8155,1],[8157,8175,1],[8178,8180,1],[8182,8190,1],[8486,43877,35391],[65856,65934,1],[65952,119296,53344],[119297,119365,1]];static foldGreek=[[181,837,656]];static Gujarati=[[2689,2691,1],[2693,2701,1],[2703,2705,1],[2707,2728,1],[2730,2736,1],[2738,2739,1],[2741,2745,1],[2748,2757,1],[2759,2761,1],[2763,2765,1],[2768,2784,16],[2785,2787,1],[2790,2801,1],[2809,2815,1]];static Gunjala_Gondi=[[73056,73061,1],[73063,73064,1],[73066,73102,1],[73104,73105,1],[73107,73112,1],[73120,73129,1]];static Gurmukhi=[[2561,2563,1],[2565,2570,1],[2575,2576,1],[2579,2600,1],[2602,2608,1],[2610,2611,1],[2613,2614,1],[2616,2617,1],[2620,2622,2],[2623,2626,1],[2631,2632,1],[2635,2637,1],[2641,2649,8],[2650,2652,1],[2654,2662,8],[2663,2678,1]];static Han=[[11904,11929,1],[11931,12019,1],[12032,12245,1],[12293,12295,2],[12321,12329,1],[12344,12347,1],[13312,19903,1],[19968,40959,1],[63744,64109,1],[64112,64217,1],[94178,94179,1],[94192,94193,1],[131072,173791,1],[173824,177977,1],[177984,178205,1],[178208,183969,1],[183984,191456,1],[191472,192093,1],[194560,195101,1],[196608,201546,1],[201552,205743,1]];static Hangul=[[4352,4607,1],[12334,12335,1],[12593,12686,1],[12800,12830,1],[12896,12926,1],[43360,43388,1],[44032,55203,1],[55216,55238,1],[55243,55291,1],[65440,65470,1],[65474,65479,1],[65482,65487,1],[65490,65495,1],[65498,65500,1]];static Hanifi_Rohingya=[[68864,68903,1],[68912,68921,1]];static Hanunoo=[[5920,5940,1]];static Hatran=[[67808,67826,1],[67828,67829,1],[67835,67839,1]];static Hebrew=[[1425,1479,1],[1488,1514,1],[1519,1524,1],[64285,64310,1],[64312,64316,1],[64318,64320,2],[64321,64323,2],[64324,64326,2],[64327,64335,1]];static Hiragana=[[12353,12438,1],[12445,12447,1],[110593,110879,1],[110898,110928,30],[110929,110930,1],[127488,127488,1]];static Imperial_Aramaic=[[67648,67669,1],[67671,67679,1]];static Inherited=[[768,879,1],[1157,1158,1],[1611,1621,1],[1648,2385,737],[2386,2388,1],[6832,6862,1],[7376,7378,1],[7380,7392,1],[7394,7400,1],[7405,7412,7],[7416,7417,1],[7616,7679,1],[8204,8205,1],[8400,8432,1],[12330,12333,1],[12441,12442,1],[65024,65039,1],[65056,65069,1],[66045,66272,227],[70459,118528,48069],[118529,118573,1],[118576,118598,1],[119143,119145,1],[119163,119170,1],[119173,119179,1],[119210,119213,1],[917760,917999,1]];static foldInherited=[[921,953,32],[8126,8126,1]];static Inscriptional_Pahlavi=[[68448,68466,1],[68472,68479,1]];static Inscriptional_Parthian=[[68416,68437,1],[68440,68447,1]];static Javanese=[[43392,43469,1],[43472,43481,1],[43486,43487,1]];static Kaithi=[[69760,69826,1],[69837,69837,1]];static Kannada=[[3200,3212,1],[3214,3216,1],[3218,3240,1],[3242,3251,1],[3253,3257,1],[3260,3268,1],[3270,3272,1],[3274,3277,1],[3285,3286,1],[3293,3294,1],[3296,3299,1],[3302,3311,1],[3313,3315,1]];static Katakana=[[12449,12538,1],[12541,12543,1],[12784,12799,1],[13008,13054,1],[13056,13143,1],[65382,65391,1],[65393,65437,1],[110576,110579,1],[110581,110587,1],[110589,110590,1],[110592,110880,288],[110881,110882,1],[110933,110948,15],[110949,110951,1]];static Kawi=[[73472,73488,1],[73490,73530,1],[73534,73561,1]];static Kayah_Li=[[43264,43309,1],[43311,43311,1]];static Kharoshthi=[[68096,68099,1],[68101,68102,1],[68108,68115,1],[68117,68119,1],[68121,68149,1],[68152,68154,1],[68159,68168,1],[68176,68184,1]];static Khitan_Small_Script=[[94180,101120,6940],[101121,101589,1]];static Khmer=[[6016,6109,1],[6112,6121,1],[6128,6137,1],[6624,6655,1]];static Khojki=[[70144,70161,1],[70163,70209,1]];static Khudawadi=[[70320,70378,1],[70384,70393,1]];static Lao=[[3713,3714,1],[3716,3718,2],[3719,3722,1],[3724,3747,1],[3749,3751,2],[3752,3773,1],[3776,3780,1],[3782,3784,2],[3785,3790,1],[3792,3801,1],[3804,3807,1]];static Latin=[[65,90,1],[97,122,1],[170,186,16],[192,214,1],[216,246,1],[248,696,1],[736,740,1],[7424,7461,1],[7468,7516,1],[7522,7525,1],[7531,7543,1],[7545,7614,1],[7680,7935,1],[8305,8319,14],[8336,8348,1],[8490,8491,1],[8498,8526,28],[8544,8584,1],[11360,11391,1],[42786,42887,1],[42891,42954,1],[42960,42961,1],[42963,42965,2],[42966,42969,1],[42994,43007,1],[43824,43866,1],[43868,43876,1],[43878,43881,1],[64256,64262,1],[65313,65338,1],[65345,65370,1],[67456,67461,1],[67463,67504,1],[67506,67514,1],[122624,122654,1],[122661,122666,1]];static Lepcha=[[7168,7223,1],[7227,7241,1],[7245,7247,1]];static Limbu=[[6400,6430,1],[6432,6443,1],[6448,6459,1],[6464,6468,4],[6469,6479,1]];static Linear_A=[[67072,67382,1],[67392,67413,1],[67424,67431,1]];static Linear_B=[[65536,65547,1],[65549,65574,1],[65576,65594,1],[65596,65597,1],[65599,65613,1],[65616,65629,1],[65664,65786,1]];static Lisu=[[42192,42239,1],[73648,73648,1]];static Lycian=[[66176,66204,1]];static Lydian=[[67872,67897,1],[67903,67903,1]];static Mahajani=[[69968,70006,1]];static Makasar=[[73440,73464,1]];static Malayalam=[[3328,3340,1],[3342,3344,1],[3346,3396,1],[3398,3400,1],[3402,3407,1],[3412,3427,1],[3430,3455,1]];static Mandaic=[[2112,2139,1],[2142,2142,1]];static Manichaean=[[68288,68326,1],[68331,68342,1]];static Marchen=[[72816,72847,1],[72850,72871,1],[72873,72886,1]];static Masaram_Gondi=[[72960,72966,1],[72968,72969,1],[72971,73014,1],[73018,73020,2],[73021,73023,2],[73024,73031,1],[73040,73049,1]];static Medefaidrin=[[93760,93850,1]];static Meetei_Mayek=[[43744,43766,1],[43968,44013,1],[44016,44025,1]];static Mende_Kikakui=[[124928,125124,1],[125127,125142,1]];static Meroitic_Cursive=[[68e3,68023,1],[68028,68047,1],[68050,68095,1]];static Meroitic_Hieroglyphs=[[67968,67999,1]];static Miao=[[93952,94026,1],[94031,94087,1],[94095,94111,1]];static Modi=[[71168,71236,1],[71248,71257,1]];static Mongolian=[[6144,6145,1],[6148,6150,2],[6151,6169,1],[6176,6264,1],[6272,6314,1],[71264,71276,1]];static Mro=[[92736,92766,1],[92768,92777,1],[92782,92783,1]];static Multani=[[70272,70278,1],[70280,70282,2],[70283,70285,1],[70287,70301,1],[70303,70313,1]];static Myanmar=[[4096,4255,1],[43488,43518,1],[43616,43647,1]];static Nabataean=[[67712,67742,1],[67751,67759,1]];static Nag_Mundari=[[124112,124153,1]];static Nandinagari=[[72096,72103,1],[72106,72151,1],[72154,72164,1]];static New_Tai_Lue=[[6528,6571,1],[6576,6601,1],[6608,6618,1],[6622,6623,1]];static Newa=[[70656,70747,1],[70749,70753,1]];static Nko=[[1984,2042,1],[2045,2047,1]];static Nushu=[[94177,110960,16783],[110961,111355,1]];static Nyiakeng_Puachue_Hmong=[[123136,123180,1],[123184,123197,1],[123200,123209,1],[123214,123215,1]];static Ogham=[[5760,5788,1]];static Ol_Chiki=[[7248,7295,1]];static Old_Hungarian=[[68736,68786,1],[68800,68850,1],[68858,68863,1]];static Old_Italic=[[66304,66339,1],[66349,66351,1]];static Old_North_Arabian=[[68224,68255,1]];static Old_Permic=[[66384,66426,1]];static Old_Persian=[[66464,66499,1],[66504,66517,1]];static Old_Sogdian=[[69376,69415,1]];static Old_South_Arabian=[[68192,68223,1]];static Old_Turkic=[[68608,68680,1]];static Old_Uyghur=[[69488,69513,1]];static Oriya=[[2817,2819,1],[2821,2828,1],[2831,2832,1],[2835,2856,1],[2858,2864,1],[2866,2867,1],[2869,2873,1],[2876,2884,1],[2887,2888,1],[2891,2893,1],[2901,2903,1],[2908,2909,1],[2911,2915,1],[2918,2935,1]];static Osage=[[66736,66771,1],[66776,66811,1]];static Osmanya=[[66688,66717,1],[66720,66729,1]];static Pahawh_Hmong=[[92928,92997,1],[93008,93017,1],[93019,93025,1],[93027,93047,1],[93053,93071,1]];static Palmyrene=[[67680,67711,1]];static Pau_Cin_Hau=[[72384,72440,1]];static Phags_Pa=[[43072,43127,1]];static Phoenician=[[67840,67867,1],[67871,67871,1]];static Psalter_Pahlavi=[[68480,68497,1],[68505,68508,1],[68521,68527,1]];static Rejang=[[43312,43347,1],[43359,43359,1]];static Runic=[[5792,5866,1],[5870,5880,1]];static Samaritan=[[2048,2093,1],[2096,2110,1]];static Saurashtra=[[43136,43205,1],[43214,43225,1]];static Sharada=[[70016,70111,1]];static Shavian=[[66640,66687,1]];static Siddham=[[71040,71093,1],[71096,71133,1]];static SignWriting=[[120832,121483,1],[121499,121503,1],[121505,121519,1]];static Sinhala=[[3457,3459,1],[3461,3478,1],[3482,3505,1],[3507,3515,1],[3517,3520,3],[3521,3526,1],[3530,3535,5],[3536,3540,1],[3542,3544,2],[3545,3551,1],[3558,3567,1],[3570,3572,1],[70113,70132,1]];static Sogdian=[[69424,69465,1]];static Sora_Sompeng=[[69840,69864,1],[69872,69881,1]];static Soyombo=[[72272,72354,1]];static Sundanese=[[7040,7103,1],[7360,7367,1]];static Syloti_Nagri=[[43008,43052,1]];static Syriac=[[1792,1805,1],[1807,1866,1],[1869,1871,1],[2144,2154,1]];static Tagalog=[[5888,5909,1],[5919,5919,1]];static Tagbanwa=[[5984,5996,1],[5998,6e3,1],[6002,6003,1]];static Tai_Le=[[6480,6509,1],[6512,6516,1]];static Tai_Tham=[[6688,6750,1],[6752,6780,1],[6783,6793,1],[6800,6809,1],[6816,6829,1]];static Tai_Viet=[[43648,43714,1],[43739,43743,1]];static Takri=[[71296,71353,1],[71360,71369,1]];static Tamil=[[2946,2947,1],[2949,2954,1],[2958,2960,1],[2962,2965,1],[2969,2970,1],[2972,2974,2],[2975,2979,4],[2980,2984,4],[2985,2986,1],[2990,3001,1],[3006,3010,1],[3014,3016,1],[3018,3021,1],[3024,3031,7],[3046,3066,1],[73664,73713,1],[73727,73727,1]];static Tangsa=[[92784,92862,1],[92864,92873,1]];static Tangut=[[94176,94208,32],[94209,100343,1],[100352,101119,1],[101632,101640,1]];static Telugu=[[3072,3084,1],[3086,3088,1],[3090,3112,1],[3114,3129,1],[3132,3140,1],[3142,3144,1],[3146,3149,1],[3157,3158,1],[3160,3162,1],[3165,3168,3],[3169,3171,1],[3174,3183,1],[3191,3199,1]];static Thaana=[[1920,1969,1]];static Thai=[[3585,3642,1],[3648,3675,1]];static Tibetan=[[3840,3911,1],[3913,3948,1],[3953,3991,1],[3993,4028,1],[4030,4044,1],[4046,4052,1],[4057,4058,1]];static Tifinagh=[[11568,11623,1],[11631,11632,1],[11647,11647,1]];static Tirhuta=[[70784,70855,1],[70864,70873,1]];static Toto=[[123536,123566,1]];static Ugaritic=[[66432,66461,1],[66463,66463,1]];static Vai=[[42240,42539,1]];static Vithkuqi=[[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1]];static Wancho=[[123584,123641,1],[123647,123647,1]];static Warang_Citi=[[71840,71922,1],[71935,71935,1]];static Yezidi=[[69248,69289,1],[69291,69293,1],[69296,69297,1]];static Yi=[[40960,42124,1],[42128,42182,1]];static Zanabazar_Square=[[72192,72263,1]];static CATEGORIES=new Map([[`C`,e.C],[`Cc`,e.Cc],[`Cf`,e.Cf],[`Co`,e.Co],[`Cs`,e.Cs],[`L`,e.L],[`Ll`,e.Ll],[`Lm`,e.Lm],[`Lo`,e.Lo],[`Lt`,e.Lt],[`Lu`,e.Lu],[`M`,e.M],[`Mc`,e.Mc],[`Me`,e.Me],[`Mn`,e.Mn],[`N`,e.N],[`Nd`,e.Nd],[`Nl`,e.Nl],[`No`,e.No],[`P`,e.P],[`Pc`,e.Pc],[`Pd`,e.Pd],[`Pe`,e.Pe],[`Pf`,e.Pf],[`Pi`,e.Pi],[`Po`,e.Po],[`Ps`,e.Ps],[`S`,e.S],[`Sc`,e.Sc],[`Sk`,e.Sk],[`Sm`,e.Sm],[`So`,e.So],[`Z`,e.Z],[`Zl`,e.Zl],[`Zp`,e.Zp],[`Zs`,e.Zs]]);static SCRIPTS=new Map([[`Adlam`,e.Adlam],[`Ahom`,e.Ahom],[`Anatolian_Hieroglyphs`,e.Anatolian_Hieroglyphs],[`Arabic`,e.Arabic],[`Armenian`,e.Armenian],[`Avestan`,e.Avestan],[`Balinese`,e.Balinese],[`Bamum`,e.Bamum],[`Bassa_Vah`,e.Bassa_Vah],[`Batak`,e.Batak],[`Bengali`,e.Bengali],[`Bhaiksuki`,e.Bhaiksuki],[`Bopomofo`,e.Bopomofo],[`Brahmi`,e.Brahmi],[`Braille`,e.Braille],[`Buginese`,e.Buginese],[`Buhid`,e.Buhid],[`Canadian_Aboriginal`,e.Canadian_Aboriginal],[`Carian`,e.Carian],[`Caucasian_Albanian`,e.Caucasian_Albanian],[`Chakma`,e.Chakma],[`Cham`,e.Cham],[`Cherokee`,e.Cherokee],[`Chorasmian`,e.Chorasmian],[`Common`,e.Common],[`Coptic`,e.Coptic],[`Cuneiform`,e.Cuneiform],[`Cypriot`,e.Cypriot],[`Cypro_Minoan`,e.Cypro_Minoan],[`Cyrillic`,e.Cyrillic],[`Deseret`,e.Deseret],[`Devanagari`,e.Devanagari],[`Dives_Akuru`,e.Dives_Akuru],[`Dogra`,e.Dogra],[`Duployan`,e.Duployan],[`Egyptian_Hieroglyphs`,e.Egyptian_Hieroglyphs],[`Elbasan`,e.Elbasan],[`Elymaic`,e.Elymaic],[`Ethiopic`,e.Ethiopic],[`Georgian`,e.Georgian],[`Glagolitic`,e.Glagolitic],[`Gothic`,e.Gothic],[`Grantha`,e.Grantha],[`Greek`,e.Greek],[`Gujarati`,e.Gujarati],[`Gunjala_Gondi`,e.Gunjala_Gondi],[`Gurmukhi`,e.Gurmukhi],[`Han`,e.Han],[`Hangul`,e.Hangul],[`Hanifi_Rohingya`,e.Hanifi_Rohingya],[`Hanunoo`,e.Hanunoo],[`Hatran`,e.Hatran],[`Hebrew`,e.Hebrew],[`Hiragana`,e.Hiragana],[`Imperial_Aramaic`,e.Imperial_Aramaic],[`Inherited`,e.Inherited],[`Inscriptional_Pahlavi`,e.Inscriptional_Pahlavi],[`Inscriptional_Parthian`,e.Inscriptional_Parthian],[`Javanese`,e.Javanese],[`Kaithi`,e.Kaithi],[`Kannada`,e.Kannada],[`Katakana`,e.Katakana],[`Kawi`,e.Kawi],[`Kayah_Li`,e.Kayah_Li],[`Kharoshthi`,e.Kharoshthi],[`Khitan_Small_Script`,e.Khitan_Small_Script],[`Khmer`,e.Khmer],[`Khojki`,e.Khojki],[`Khudawadi`,e.Khudawadi],[`Lao`,e.Lao],[`Latin`,e.Latin],[`Lepcha`,e.Lepcha],[`Limbu`,e.Limbu],[`Linear_A`,e.Linear_A],[`Linear_B`,e.Linear_B],[`Lisu`,e.Lisu],[`Lycian`,e.Lycian],[`Lydian`,e.Lydian],[`Mahajani`,e.Mahajani],[`Makasar`,e.Makasar],[`Malayalam`,e.Malayalam],[`Mandaic`,e.Mandaic],[`Manichaean`,e.Manichaean],[`Marchen`,e.Marchen],[`Masaram_Gondi`,e.Masaram_Gondi],[`Medefaidrin`,e.Medefaidrin],[`Meetei_Mayek`,e.Meetei_Mayek],[`Mende_Kikakui`,e.Mende_Kikakui],[`Meroitic_Cursive`,e.Meroitic_Cursive],[`Meroitic_Hieroglyphs`,e.Meroitic_Hieroglyphs],[`Miao`,e.Miao],[`Modi`,e.Modi],[`Mongolian`,e.Mongolian],[`Mro`,e.Mro],[`Multani`,e.Multani],[`Myanmar`,e.Myanmar],[`Nabataean`,e.Nabataean],[`Nag_Mundari`,e.Nag_Mundari],[`Nandinagari`,e.Nandinagari],[`New_Tai_Lue`,e.New_Tai_Lue],[`Newa`,e.Newa],[`Nko`,e.Nko],[`Nushu`,e.Nushu],[`Nyiakeng_Puachue_Hmong`,e.Nyiakeng_Puachue_Hmong],[`Ogham`,e.Ogham],[`Ol_Chiki`,e.Ol_Chiki],[`Old_Hungarian`,e.Old_Hungarian],[`Old_Italic`,e.Old_Italic],[`Old_North_Arabian`,e.Old_North_Arabian],[`Old_Permic`,e.Old_Permic],[`Old_Persian`,e.Old_Persian],[`Old_Sogdian`,e.Old_Sogdian],[`Old_South_Arabian`,e.Old_South_Arabian],[`Old_Turkic`,e.Old_Turkic],[`Old_Uyghur`,e.Old_Uyghur],[`Oriya`,e.Oriya],[`Osage`,e.Osage],[`Osmanya`,e.Osmanya],[`Pahawh_Hmong`,e.Pahawh_Hmong],[`Palmyrene`,e.Palmyrene],[`Pau_Cin_Hau`,e.Pau_Cin_Hau],[`Phags_Pa`,e.Phags_Pa],[`Phoenician`,e.Phoenician],[`Psalter_Pahlavi`,e.Psalter_Pahlavi],[`Rejang`,e.Rejang],[`Runic`,e.Runic],[`Samaritan`,e.Samaritan],[`Saurashtra`,e.Saurashtra],[`Sharada`,e.Sharada],[`Shavian`,e.Shavian],[`Siddham`,e.Siddham],[`SignWriting`,e.SignWriting],[`Sinhala`,e.Sinhala],[`Sogdian`,e.Sogdian],[`Sora_Sompeng`,e.Sora_Sompeng],[`Soyombo`,e.Soyombo],[`Sundanese`,e.Sundanese],[`Syloti_Nagri`,e.Syloti_Nagri],[`Syriac`,e.Syriac],[`Tagalog`,e.Tagalog],[`Tagbanwa`,e.Tagbanwa],[`Tai_Le`,e.Tai_Le],[`Tai_Tham`,e.Tai_Tham],[`Tai_Viet`,e.Tai_Viet],[`Takri`,e.Takri],[`Tamil`,e.Tamil],[`Tangsa`,e.Tangsa],[`Tangut`,e.Tangut],[`Telugu`,e.Telugu],[`Thaana`,e.Thaana],[`Thai`,e.Thai],[`Tibetan`,e.Tibetan],[`Tifinagh`,e.Tifinagh],[`Tirhuta`,e.Tirhuta],[`Toto`,e.Toto],[`Ugaritic`,e.Ugaritic],[`Vai`,e.Vai],[`Vithkuqi`,e.Vithkuqi],[`Wancho`,e.Wancho],[`Warang_Citi`,e.Warang_Citi],[`Yezidi`,e.Yezidi],[`Yi`,e.Yi],[`Zanabazar_Square`,e.Zanabazar_Square]]);static FOLD_CATEGORIES=new Map([[`L`,e.foldL],[`Ll`,e.foldLl],[`Lt`,e.foldLt],[`Lu`,e.foldLu],[`M`,e.foldM],[`Mn`,e.foldMn]]);static FOLD_SCRIPT=new Map([[`Common`,e.foldCommon],[`Greek`,e.foldGreek],[`Inherited`,e.foldInherited]])},C=class{static MAX_RUNE=1114111;static MAX_ASCII=127;static MAX_LATIN1=255;static MAX_BMP=65535;static MIN_FOLD=65;static MAX_FOLD=125251;static is32(e,t){let n=0,r=e.length;for(;n<r;){let i=n+Math.floor((r-n)/2),a=e[i];if(a[0]<=t&&t<=a[1])return(t-a[0])%a[2]===0;t<a[0]?r=i:n=i+1}return!1}static is(e,t){if(t<=this.MAX_LATIN1){for(let n of e)if(!(t>n[1]))return t<n[0]?!1:(t-n[0])%n[2]===0;return!1}return e.length>0&&t>=e[0][0]&&this.is32(e,t)}static isUpper(e){if(e<=this.MAX_LATIN1){let t=String.fromCodePoint(e);return t.toUpperCase()===t&&t.toLowerCase()!==t}return this.is(S.Upper,e)}static isPrint(e){return e<=this.MAX_LATIN1?e>=32&&e<127||e>=161&&e!==173:this.is(S.L,e)||this.is(S.M,e)||this.is(S.N,e)||this.is(S.P,e)||this.is(S.S,e)}static simpleFold(e){if(S.CASE_ORBIT.has(e))return S.CASE_ORBIT.get(e);let t=x.toLowerCase(e);return t===e?x.toUpperCase(e):t}static equalsIgnoreCase(e,t){if(e<0||t<0||e===t)return!0;if(e<=this.MAX_ASCII&&t<=this.MAX_ASCII)return x.CODES.get(`A`)<=e&&e<=x.CODES.get(`Z`)&&(e|=32),x.CODES.get(`A`)<=t&&t<=x.CODES.get(`Z`)&&(t|=32),e===t;for(let n=this.simpleFold(e);n!==e;n=this.simpleFold(n))if(n===t)return!0;return!1}},w=class{static METACHARACTERS=`\\.+*?()|[]{}^$`;static EMPTY_BEGIN_LINE=1;static EMPTY_END_LINE=2;static EMPTY_BEGIN_TEXT=4;static EMPTY_END_TEXT=8;static EMPTY_WORD_BOUNDARY=16;static EMPTY_NO_WORD_BOUNDARY=32;static EMPTY_ALL=-1;static emptyInts(){return[]}static isalnum(e){return x.CODES.get(`0`)<=e&&e<=x.CODES.get(`9`)||x.CODES.get(`a`)<=e&&e<=x.CODES.get(`z`)||x.CODES.get(`A`)<=e&&e<=x.CODES.get(`Z`)}static unhex(e){return x.CODES.get(`0`)<=e&&e<=x.CODES.get(`9`)?e-x.CODES.get(`0`):x.CODES.get(`a`)<=e&&e<=x.CODES.get(`f`)?e-x.CODES.get(`a`)+10:x.CODES.get(`A`)<=e&&e<=x.CODES.get(`F`)?e-x.CODES.get(`A`)+10:-1}static escapeRune(e){let t=``;if(C.isPrint(e))this.METACHARACTERS.indexOf(String.fromCodePoint(e))>=0&&(t+=`\\`),t+=String.fromCodePoint(e);else switch(e){case x.CODES.get(`"`):t+=`\\"`;break;case x.CODES.get(`\\`):t+=`\\\\`;break;case x.CODES.get(` `):t+=`\\t`;break;case x.CODES.get(`
|
|
11
|
+
`):t+=`\\n`;break;case x.CODES.get(`\r`):t+=`\\r`;break;case x.CODES.get(`\b`):t+=`\\b`;break;case x.CODES.get(`\f`):t+=`\\f`;break;default:{let n=e.toString(16);e<256?(t+=`\\x`,n.length===1&&(t+=`0`),t+=n):t+=`\\x{${n}}`;break}}return t}static stringToRunes(e){return String(e).split(``).map(e=>e.codePointAt(0))}static runeToString(e){return String.fromCodePoint(e)}static isWordRune(e){return x.CODES.get(`a`)<=e&&e<=x.CODES.get(`z`)||x.CODES.get(`A`)<=e&&e<=x.CODES.get(`Z`)||x.CODES.get(`0`)<=e&&e<=x.CODES.get(`9`)||e===x.CODES.get(`_`)}static emptyOpContext(e,t){let n=0;return e<0&&(n|=this.EMPTY_BEGIN_TEXT|this.EMPTY_BEGIN_LINE),e===x.CODES.get(`
|
|
12
|
+
`)&&(n|=this.EMPTY_BEGIN_LINE),t<0&&(n|=this.EMPTY_END_TEXT|this.EMPTY_END_LINE),t===x.CODES.get(`
|
|
13
|
+
`)&&(n|=this.EMPTY_END_LINE),this.isWordRune(e)===this.isWordRune(t)?n|=this.EMPTY_NO_WORD_BOUNDARY:n|=this.EMPTY_WORD_BOUNDARY,n}static quoteMeta(e){return e.split(``).map(e=>this.METACHARACTERS.indexOf(e)>=0?`\\${e}`:e).join(``)}static charCount(e){return e>C.MAX_BMP?2:1}static stringToUtf8ByteArray(e){if(globalThis.TextEncoder)return Array.from(new TextEncoder().encode(e));{let t=[],n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=i&63|128):(i&64512)==55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)==56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t}}static utf8ByteArrayToString(e){if(globalThis.TextDecoder)return new TextDecoder(`utf-8`).decode(new Uint8Array(e));{let t=[],n=0,r=0;for(;n<e.length;){let i=e[n++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){let a=e[n++];t[r++]=String.fromCharCode((i&31)<<6|a&63)}else if(i>239&&i<365){let a=e[n++],o=e[n++],s=e[n++],c=((i&7)<<18|(a&63)<<12|(o&63)<<6|s&63)-65536;t[r++]=String.fromCharCode(55296+(c>>10)),t[r++]=String.fromCharCode(56320+(c&1023))}else{let a=e[n++],o=e[n++];t[r++]=String.fromCharCode((i&15)<<12|(a&63)<<6|o&63)}}return t.join(``)}}},Fn=(e=[],t=0)=>{let n={};for(let r=0;r<e.length;r++){let i=e[r],a=t+r;n[i]=a,n[a]=i}return Object.freeze(n)},In=class e{static Encoding=Fn([`UTF_16`,`UTF_8`]);getEncoding(){throw Error(`not implemented`)}isUTF8Encoding(){return this.getEncoding()===e.Encoding.UTF_8}isUTF16Encoding(){return this.getEncoding()===e.Encoding.UTF_16}},Ln=class extends In{constructor(e=null){super(),this.bytes=e}getEncoding(){return In.Encoding.UTF_8}asCharSequence(){return w.utf8ByteArrayToString(this.bytes)}asBytes(){return this.bytes}length(){return this.bytes.length}},Rn=class extends In{constructor(e=null){super(),this.charSequence=e}getEncoding(){return In.Encoding.UTF_16}asCharSequence(){return this.charSequence}asBytes(){return this.charSequence.toString().split(``).map(e=>e.codePointAt(0))}length(){return this.charSequence.length}},zn=class{static utf16(e){return new Rn(e)}static utf8(e){return Array.isArray(e)?new Ln(e):new Ln(w.stringToUtf8ByteArray(e))}},Bn=class extends Error{constructor(e){super(e),this.name=`RE2JSException`}},T=class extends Bn{constructor(e,t=null){let n=`error parsing regexp: ${e}`;t&&(n+=`: \`${t}\``),super(n),this.name=`RE2JSSyntaxException`,this.message=n,this.error=e,this.input=t}getDescription(){return this.error}getPattern(){return this.input}},Vn=class extends Bn{constructor(e){super(e),this.name=`RE2JSCompileException`}},Hn=class extends Bn{constructor(e){super(e),this.name=`RE2JSGroupException`}},Un=class extends Bn{constructor(e){super(e),this.name=`RE2JSFlagsException`}},Wn=class{static quoteReplacement(e){return e.indexOf(`\\`)<0&&e.indexOf(`$`)<0?e:e.split(``).map(e=>{let t=e.codePointAt(0);return t===x.CODES[`\\`]||t===x.CODES.$?`\\${e}`:e}).join(``)}constructor(e,t){if(e===null)throw Error(`pattern is null`);this.patternInput=e;let n=this.patternInput.re2();this.patternGroupCount=n.numberOfCapturingGroups(),this.groups=[],this.namedGroups=n.namedGroups,t instanceof In?this.resetMatcherInput(t):Array.isArray(t)?this.resetMatcherInput(zn.utf8(t)):this.resetMatcherInput(zn.utf16(t))}pattern(){return this.patternInput}reset(){return this.matcherInputLength=this.matcherInput.length(),this.appendPos=0,this.hasMatch=!1,this.hasGroups=!1,this.anchorFlag=0,this}resetMatcherInput(e){if(e===null)throw Error(`input is null`);return this.matcherInput=e,this.reset(),this}start(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new Hn(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e]}end(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new Hn(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e+1]}group(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new Hn(`group '${e}' not found`);e=t}let t=this.start(e),n=this.end(e);return t<0&&n<0?null:this.substring(t,n)}groupCount(){return this.patternGroupCount}loadGroup(e){if(e<0||e>this.patternGroupCount)throw new Hn(`Group index out of bounds: ${e}`);if(!this.hasMatch)throw new Hn(`perhaps no match attempted`);if(e===0||this.hasGroups)return;let t=this.groups[1]+1;t>this.matcherInputLength&&(t=this.matcherInputLength);let n=this.patternInput.re2().matchMachineInput(this.matcherInput,this.groups[0],t,this.anchorFlag,1+this.patternGroupCount);if(!n[0])throw new Hn(`inconsistency in matching group data`);this.groups=n[1],this.hasGroups=!0}matches(){return this.genMatch(0,b.ANCHOR_BOTH)}lookingAt(){return this.genMatch(0,b.ANCHOR_START)}find(e=null){if(e!==null){if(e<0||e>this.matcherInputLength)throw new Hn(`start index out of bounds: ${e}`);return this.reset(),this.genMatch(e,0)}return e=0,this.hasMatch&&(e=this.groups[1],this.groups[0]===this.groups[1]&&e++),this.genMatch(e,b.UNANCHORED)}genMatch(e,t){let n=this.patternInput.re2().matchMachineInput(this.matcherInput,e,this.matcherInputLength,t,1);return n[0]?(this.groups=n[1],this.hasMatch=!0,this.hasGroups=!1,this.anchorFlag=t,!0):!1}substring(e,t){return this.matcherInput.isUTF8Encoding()?w.utf8ByteArrayToString(this.matcherInput.asBytes().slice(e,t)):this.matcherInput.asCharSequence().substring(e,t).toString()}inputLength(){return this.matcherInputLength}appendReplacement(e,t=!1){let n=``,r=this.start(),i=this.end();return this.appendPos<r&&(n+=this.substring(this.appendPos,r)),this.appendPos=i,n+=t?this.appendReplacementInternalPerl(e):this.appendReplacementInternal(e),n}appendReplacementInternal(e){let t=``,n=0,r=e.length;for(let i=0;i<r-1;i++){if(e.codePointAt(i)===x.CODES.get(`\\`)){n<i&&(t+=e.substring(n,i)),i++,n=i;continue}if(e.codePointAt(i)===x.CODES.get(`$`)){let a=e.codePointAt(i+1);if(x.CODES.get(`0`)<=a&&a<=x.CODES.get(`9`)){let o=a-x.CODES.get(`0`);for(n<i&&(t+=e.substring(n,i)),i+=2;i<r&&(a=e.codePointAt(i),!(a<x.CODES.get(`0`)||a>x.CODES.get(`9`)||o*10+a-x.CODES.get(`0`)>this.patternGroupCount));i++)o=o*10+a-x.CODES.get(`0`);if(o>this.patternGroupCount)throw new Hn(`n > number of groups: ${o}`);let s=this.group(o);s!==null&&(t+=s),n=i,i--;continue}else if(a===x.CODES.get(`{`)){n<i&&(t+=e.substring(n,i)),i++;let r=i+1;for(;r<e.length&&e.codePointAt(r)!==x.CODES.get(`}`)&&e.codePointAt(r)!==x.CODES.get(` `);)r++;if(r===e.length||e.codePointAt(r)!==x.CODES.get(`}`))throw new Hn(`named capture group is missing trailing '}'`);let a=e.substring(i+1,r);t+=this.group(a),n=r+1}}}return n<r&&(t+=e.substring(n,r)),t}appendReplacementInternalPerl(e){let t=``,n=0,r=e.length;for(let i=0;i<r-1;i++)if(e.codePointAt(i)===x.CODES.get(`$`)){let a=e.codePointAt(i+1);if(x.CODES.get(`$`)===a){n<i&&(t+=e.substring(n,i)),t+=`$`,i++,n=i+1;continue}else if(x.CODES.get(`&`)===a){n<i&&(t+=e.substring(n,i));let r=this.group(0);r===null?t+=`$&`:t+=r,i++,n=i+1;continue}else if(x.CODES.get(`1`)<=a&&a<=x.CODES.get(`9`)){let o=a-x.CODES.get(`0`);for(n<i&&(t+=e.substring(n,i)),i+=2;i<r&&(a=e.codePointAt(i),!(a<x.CODES.get(`0`)||a>x.CODES.get(`9`)||o*10+a-x.CODES.get(`0`)>this.patternGroupCount));i++)o=o*10+a-x.CODES.get(`0`);if(o>this.patternGroupCount){t+=`$${o}`,n=i,i--;continue}let s=this.group(o);s!==null&&(t+=s),n=i,i--;continue}else if(a===x.CODES.get(`<`)){n<i&&(t+=e.substring(n,i)),i++;let r=i+1;for(;r<e.length&&e.codePointAt(r)!==x.CODES.get(`>`)&&e.codePointAt(r)!==x.CODES.get(` `);)r++;if(r===e.length||e.codePointAt(r)!==x.CODES.get(`>`)){t+=e.substring(i-1,r+1),n=r+1;continue}let a=e.substring(i+1,r);Object.prototype.hasOwnProperty.call(this.namedGroups,a)?t+=this.group(a):t+=`$<${a}>`,n=r+1}}return n<r&&(t+=e.substring(n,r)),t}appendTail(){return this.substring(this.appendPos,this.matcherInputLength)}replaceAll(e,t=!1){return this.replace(e,!0,t)}replaceFirst(e,t=!1){return this.replace(e,!1,t)}replace(e,t=!0,n=!1){let r=``;for(this.reset();this.find()&&(r+=this.appendReplacement(e,n),t););return r+=this.appendTail(),r}},Gn=class{static EOF(){return-8}canCheckPrefix(){return!0}endPos(){return this.end}},Kn=class extends Gn{constructor(e,t=0,n=e.length){super(),this.bytes=e,this.start=t,this.end=n}step(e){if(e+=this.start,e>=this.end)return Gn.EOF();let t=this.bytes[e++]&255;return t&128?(t&224)==192?(t&=31,e>=this.end?Gn.EOF():(t=t<<6|this.bytes[e++]&63,t<<3|2)):(t&240)==224?(t&=15,e+1>=this.end?Gn.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|3)):(t&=7,e+2>=this.end?Gn.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|4)):t<<3|1}index(e,t){t+=this.start;let n=this.indexOf(this.bytes,e.prefixUTF8,t);return n<0?n:n-t}context(e){e+=this.start;let t=-1;if(e>this.start&&e<=this.end){let n=e-1;if(t=this.bytes[n--],t>=128){let r=e-4;for(r<this.start&&(r=this.start);n>=r&&(this.bytes[n]&192)==128;)n--;n<this.start&&(n=this.start),t=this.step(n)>>3}}let n=e<this.end?this.step(e)>>3:-1;return w.emptyOpContext(t,n)}indexOf(e,t,n=0){let r=t.length;if(r===0)return-1;let i=e.length;for(let a=n;a<=i-r;a++)for(let n=0;n<r&&e[a+n]===t[n];n++)if(n===r-1)return a;return-1}},qn=class extends Gn{constructor(e,t=0,n=e.length){super(),this.charSequence=e,this.start=t,this.end=n}step(e){if(e+=this.start,e<this.end){let t=this.charSequence.codePointAt(e);return t<<3|w.charCount(t)}else return Gn.EOF()}index(e,t){t+=this.start;let n=this.charSequence.indexOf(e.prefix,t);return n<0?n:n-t}context(e){e+=this.start;let t=e>0&&e<=this.charSequence.length?this.charSequence.codePointAt(e-1):-1,n=e<this.charSequence.length?this.charSequence.codePointAt(e):-1;return w.emptyOpContext(t,n)}},E=class{static fromUTF8(e,t=0,n=e.length){return new Kn(e,t,n)}static fromUTF16(e,t=0,n=e.length){return new qn(e,t,n)}},D=class e{static Op=Fn([`NO_MATCH`,`EMPTY_MATCH`,`LITERAL`,`CHAR_CLASS`,`ANY_CHAR_NOT_NL`,`ANY_CHAR`,`BEGIN_LINE`,`END_LINE`,`BEGIN_TEXT`,`END_TEXT`,`WORD_BOUNDARY`,`NO_WORD_BOUNDARY`,`CAPTURE`,`STAR`,`PLUS`,`QUEST`,`REPEAT`,`CONCAT`,`ALTERNATE`,`LEFT_PAREN`,`VERTICAL_BAR`]);static isPseudoOp(t){return t>=e.Op.LEFT_PAREN}static emptySubs(){return[]}static quoteIfHyphen(e){return e===x.CODES.get(`-`)?`\\`:``}static fromRegexp(t){let n=new e(t.op);return n.flags=t.flags,n.subs=t.subs,n.runes=t.runes,n.cap=t.cap,n.min=t.min,n.max=t.max,n.name=t.name,n.namedGroups=t.namedGroups,n}constructor(t){this.op=t,this.flags=0,this.subs=e.emptySubs(),this.runes=null,this.min=0,this.max=0,this.cap=0,this.name=null,this.namedGroups={}}reinit(){this.flags=0,this.subs=e.emptySubs(),this.runes=null,this.cap=0,this.min=0,this.max=0,this.name=null,this.namedGroups={}}toString(){return this.appendTo()}appendTo(){let t=``;switch(this.op){case e.Op.NO_MATCH:t+=`[^\\x00-\\x{10FFFF}]`;break;case e.Op.EMPTY_MATCH:t+=`(?:)`;break;case e.Op.STAR:case e.Op.PLUS:case e.Op.QUEST:case e.Op.REPEAT:{let n=this.subs[0];switch(n.op>e.Op.CAPTURE||n.op===e.Op.LITERAL&&n.runes.length>1?t+=`(?:${n.appendTo()})`:t+=n.appendTo(),this.op){case e.Op.STAR:t+=`*`;break;case e.Op.PLUS:t+=`+`;break;case e.Op.QUEST:t+=`?`;break;case e.Op.REPEAT:t+=`{${this.min}`,this.min!==this.max&&(t+=`,`,this.max>=0&&(t+=this.max)),t+=`}`;break}(this.flags&b.NON_GREEDY)!==0&&(t+=`?`);break}case e.Op.CONCAT:for(let n of this.subs)n.op===e.Op.ALTERNATE?t+=`(?:${n.appendTo()})`:t+=n.appendTo();break;case e.Op.ALTERNATE:{let e=``;for(let n of this.subs)t+=e,e=`|`,t+=n.appendTo();break}case e.Op.LITERAL:(this.flags&b.FOLD_CASE)!==0&&(t+=`(?i:`);for(let e of this.runes)t+=w.escapeRune(e);(this.flags&b.FOLD_CASE)!==0&&(t+=`)`);break;case e.Op.ANY_CHAR_NOT_NL:t+=`(?-s:.)`;break;case e.Op.ANY_CHAR:t+=`(?s:.)`;break;case e.Op.CAPTURE:this.name===null||this.name.length===0?t+=`(`:t+=`(?P<${this.name}>`,this.subs[0].op!==e.Op.EMPTY_MATCH&&(t+=this.subs[0].appendTo()),t+=`)`;break;case e.Op.BEGIN_TEXT:t+=`\\A`;break;case e.Op.END_TEXT:(this.flags&b.WAS_DOLLAR)===0?t+=`\\z`:t+=`(?-m:$)`;break;case e.Op.BEGIN_LINE:t+=`^`;break;case e.Op.END_LINE:t+=`$`;break;case e.Op.WORD_BOUNDARY:t+=`\\b`;break;case e.Op.NO_WORD_BOUNDARY:t+=`\\B`;break;case e.Op.CHAR_CLASS:if(this.runes.length%2!=0){t+=`[invalid char class]`;break}if(t+=`[`,this.runes.length===0)t+=`^\\x00-\\x{10FFFF}`;else if(this.runes[0]===0&&this.runes[this.runes.length-1]===C.MAX_RUNE){t+=`^`;for(let n=1;n<this.runes.length-1;n+=2){let r=this.runes[n]+1,i=this.runes[n+1]-1;t+=e.quoteIfHyphen(r),t+=w.escapeRune(r),r!==i&&(t+=`-`,t+=e.quoteIfHyphen(i),t+=w.escapeRune(i))}}else for(let n=0;n<this.runes.length;n+=2){let r=this.runes[n],i=this.runes[n+1];t+=e.quoteIfHyphen(r),t+=w.escapeRune(r),r!==i&&(t+=`-`,t+=e.quoteIfHyphen(i),t+=w.escapeRune(i))}t+=`]`;break;default:t+=this.op;break}return t}maxCap(){let t=0;if(this.op===e.Op.CAPTURE&&(t=this.cap),this.subs!==null)for(let e of this.subs){let n=e.maxCap();t<n&&(t=n)}return t}equals(t){if(!(t!==null&&t instanceof e)||this.op!==t.op)return!1;switch(this.op){case e.Op.END_TEXT:if((this.flags&b.WAS_DOLLAR)!==(t.flags&b.WAS_DOLLAR))return!1;break;case e.Op.LITERAL:case e.Op.CHAR_CLASS:if(this.runes===null&&t.runes===null)break;if(this.runes===null||t.runes===null||this.runes.length!==t.runes.length)return!1;for(let e=0;e<this.runes.length;e++)if(this.runes[e]!==t.runes[e])return!1;break;case e.Op.ALTERNATE:case e.Op.CONCAT:if(this.subs.length!==t.subs.length)return!1;for(let e=0;e<this.subs.length;++e)if(!this.subs[e].equals(t.subs[e]))return!1;break;case e.Op.STAR:case e.Op.PLUS:case e.Op.QUEST:if((this.flags&b.NON_GREEDY)!==(t.flags&b.NON_GREEDY)||!this.subs[0].equals(t.subs[0]))return!1;break;case e.Op.REPEAT:if((this.flags&b.NON_GREEDY)!==(t.flags&b.NON_GREEDY)||this.min!==t.min||this.max!==t.max||!this.subs[0].equals(t.subs[0]))return!1;break;case e.Op.CAPTURE:if(this.cap!==t.cap||(this.name===null?t.name!==null:this.name!==t.name)||!this.subs[0].equals(t.subs[0]))return!1;break}return!0}},O=class e{static ALT=1;static ALT_MATCH=2;static CAPTURE=3;static EMPTY_WIDTH=4;static FAIL=5;static MATCH=6;static NOP=7;static RUNE=8;static RUNE1=9;static RUNE_ANY=10;static RUNE_ANY_NOT_NL=11;static isRuneOp(t){return e.RUNE<=t&&t<=e.RUNE_ANY_NOT_NL}static escapeRunes(e){let t=`"`;for(let n of e)t+=w.escapeRune(n);return t+=`"`,t}constructor(e){this.op=e,this.out=0,this.arg=0,this.runes=null}matchRune(e){if(this.runes.length===1){let t=this.runes[0];return(this.arg&b.FOLD_CASE)===0?e===t:C.equalsIgnoreCase(t,e)}for(let t=0;t<this.runes.length&&t<=8;t+=2){if(e<this.runes[t])return!1;if(e<=this.runes[t+1])return!0}let t=0,n=this.runes.length/2|0;for(;t<n;){let r=t+((n-t)/2|0);if(this.runes[2*r]<=e){if(e<=this.runes[2*r+1])return!0;t=r+1}else n=r}return!1}toString(){switch(this.op){case e.ALT:return`alt -> ${this.out}, ${this.arg}`;case e.ALT_MATCH:return`altmatch -> ${this.out}, ${this.arg}`;case e.CAPTURE:return`cap ${this.arg} -> ${this.out}`;case e.EMPTY_WIDTH:return`empty ${this.arg} -> ${this.out}`;case e.MATCH:return`match`;case e.FAIL:return`fail`;case e.NOP:return`nop -> ${this.out}`;case e.RUNE:return this.runes===null?`rune <null>`:[`rune `,e.escapeRunes(this.runes),(this.arg&b.FOLD_CASE)===0?``:`/i`,` -> `,this.out].join(``);case e.RUNE1:return`rune1 ${e.escapeRunes(this.runes)} -> ${this.out}`;case e.RUNE_ANY:return`any -> ${this.out}`;case e.RUNE_ANY_NOT_NL:return`anynotnl -> ${this.out}`;default:throw Error(`unhandled case in Inst.toString`)}}},Jn=class{constructor(){this.inst=[],this.start=0,this.numCap=2}getInst(e){return this.inst[e]}numInst(){return this.inst.length}addInst(e){this.inst.push(new O(e))}skipNop(e){let t=this.inst[e];for(;t.op===O.NOP||t.op===O.CAPTURE;)t=this.inst[e],e=t.out;return t}prefix(){let e=``,t=this.skipNop(this.start);if(!O.isRuneOp(t.op)||t.runes.length!==1)return[t.op===O.MATCH,e];for(;O.isRuneOp(t.op)&&t.runes.length===1&&(t.arg&b.FOLD_CASE)===0;)e+=String.fromCodePoint(t.runes[0]),t=this.skipNop(t.out);return[t.op===O.MATCH,e]}startCond(){let e=0,t=this.start;loop:for(;;){let n=this.inst[t];switch(n.op){case O.EMPTY_WIDTH:e|=n.arg;break;case O.FAIL:return-1;case O.CAPTURE:case O.NOP:break;default:break loop}t=n.out}return e}next(e){let t=this.inst[e>>1];return e&1?t.arg:t.out}patch(e,t){for(;e!==0;){let n=this.inst[e>>1];e&1?(e=n.arg,n.arg=t):(e=n.out,n.out=t)}}append(e,t){if(e===0)return t;if(t===0)return e;let n=e;for(;;){let e=this.next(n);if(e===0)break;n=e}let r=this.inst[n>>1];return n&1?r.arg=t:r.out=t,e}toString(){let e=``;for(let t=0;t<this.inst.length;t++){let n=e.length;e+=t,t===this.start&&(e+=`*`),e+=` `.substring(e.length-n),e+=this.inst[t],e+=`
|
|
14
|
+
`}return e}},Yn=class{constructor(e=0,t=0,n=!1){this.i=e,this.out=t,this.nullable=n}},Xn=class e{static ANY_RUNE_NOT_NL(){return[0,x.CODES.get(`
|
|
15
|
+
`)-1,x.CODES.get(`
|
|
16
|
+
`)+1,C.MAX_RUNE]}static ANY_RUNE(){return[0,C.MAX_RUNE]}static compileRegexp(t){let n=new e,r=n.compile(t);return n.prog.patch(r.out,n.newInst(O.MATCH).i),n.prog.start=r.i,n.prog}constructor(){this.prog=new Jn,this.newInst(O.FAIL)}newInst(e){return this.prog.addInst(e),new Yn(this.prog.numInst()-1,0,!0)}nop(){let e=this.newInst(O.NOP);return e.out=e.i<<1,e}fail(){return new Yn}cap(e){let t=this.newInst(O.CAPTURE);return t.out=t.i<<1,this.prog.getInst(t.i).arg=e,this.prog.numCap<e+1&&(this.prog.numCap=e+1),t}cat(e,t){return e.i===0||t.i===0?this.fail():(this.prog.patch(e.out,t.i),new Yn(e.i,t.out,e.nullable&&t.nullable))}alt(e,t){if(e.i===0)return t;if(t.i===0)return e;let n=this.newInst(O.ALT),r=this.prog.getInst(n.i);return r.out=e.i,r.arg=t.i,n.out=this.prog.append(e.out,t.out),n.nullable=e.nullable||t.nullable,n}loop(e,t){let n=this.newInst(O.ALT),r=this.prog.getInst(n.i);return t?(r.arg=e.i,n.out=n.i<<1):(r.out=e.i,n.out=n.i<<1|1),this.prog.patch(e.out,n.i),n}quest(e,t){let n=this.newInst(O.ALT),r=this.prog.getInst(n.i);return t?(r.arg=e.i,n.out=n.i<<1):(r.out=e.i,n.out=n.i<<1|1),n.out=this.prog.append(n.out,e.out),n}star(e,t){return e.nullable?this.quest(this.plus(e,t),t):this.loop(e,t)}plus(e,t){return new Yn(e.i,this.loop(e,t).out,e.nullable)}empty(e){let t=this.newInst(O.EMPTY_WIDTH);return this.prog.getInst(t.i).arg=e,t.out=t.i<<1,t}rune(e,t){let n=this.newInst(O.RUNE);n.nullable=!1;let r=this.prog.getInst(n.i);return r.runes=e,t&=b.FOLD_CASE,(e.length!==1||C.simpleFold(e[0])===e[0])&&(t&=~b.FOLD_CASE),r.arg=t,n.out=n.i<<1,(t&b.FOLD_CASE)===0&&e.length===1||e.length===2&&e[0]===e[1]?r.op=O.RUNE1:e.length===2&&e[0]===0&&e[1]===C.MAX_RUNE?r.op=O.RUNE_ANY:e.length===4&&e[0]===0&&e[1]===x.CODES.get(`
|
|
17
|
+
`)-1&&e[2]===x.CODES.get(`
|
|
18
|
+
`)+1&&e[3]===C.MAX_RUNE&&(r.op=O.RUNE_ANY_NOT_NL),n}compile(t){switch(t.op){case D.Op.NO_MATCH:return this.fail();case D.Op.EMPTY_MATCH:return this.nop();case D.Op.LITERAL:if(t.runes.length===0)return this.nop();{let e=null;for(let n of t.runes){let r=this.rune([n],t.flags);e=e===null?r:this.cat(e,r)}return e}case D.Op.CHAR_CLASS:return this.rune(t.runes,t.flags);case D.Op.ANY_CHAR_NOT_NL:return this.rune(e.ANY_RUNE_NOT_NL(),0);case D.Op.ANY_CHAR:return this.rune(e.ANY_RUNE(),0);case D.Op.BEGIN_LINE:return this.empty(w.EMPTY_BEGIN_LINE);case D.Op.END_LINE:return this.empty(w.EMPTY_END_LINE);case D.Op.BEGIN_TEXT:return this.empty(w.EMPTY_BEGIN_TEXT);case D.Op.END_TEXT:return this.empty(w.EMPTY_END_TEXT);case D.Op.WORD_BOUNDARY:return this.empty(w.EMPTY_WORD_BOUNDARY);case D.Op.NO_WORD_BOUNDARY:return this.empty(w.EMPTY_NO_WORD_BOUNDARY);case D.Op.CAPTURE:{let e=this.cap(t.cap<<1),n=this.compile(t.subs[0]),r=this.cap(t.cap<<1|1);return this.cat(this.cat(e,n),r)}case D.Op.STAR:return this.star(this.compile(t.subs[0]),(t.flags&b.NON_GREEDY)!==0);case D.Op.PLUS:return this.plus(this.compile(t.subs[0]),(t.flags&b.NON_GREEDY)!==0);case D.Op.QUEST:return this.quest(this.compile(t.subs[0]),(t.flags&b.NON_GREEDY)!==0);case D.Op.CONCAT:if(t.subs.length===0)return this.nop();{let e=null;for(let n of t.subs){let t=this.compile(n);e=e===null?t:this.cat(e,t)}return e}case D.Op.ALTERNATE:if(t.subs.length===0)return this.nop();{let e=null;for(let n of t.subs){let t=this.compile(n);e=e===null?t:this.alt(e,t)}return e}default:throw new Vn(`regexp: unhandled case in compile`)}}},Zn=class e{static simplify(t){if(t===null)return null;switch(t.op){case D.Op.CAPTURE:case D.Op.CONCAT:case D.Op.ALTERNATE:{let n=t;for(let r=0;r<t.subs.length;r++){let i=t.subs[r],a=e.simplify(i);n===t&&a!==i&&(n=D.fromRegexp(t),n.runes=null,n.subs=t.subs.slice(0,t.subs.length)),n!==t&&(n.subs[r]=a)}return n}case D.Op.STAR:case D.Op.PLUS:case D.Op.QUEST:{let n=e.simplify(t.subs[0]);return e.simplify1(t.op,t.flags,n,t)}case D.Op.REPEAT:{if(t.min===0&&t.max===0)return new D(D.Op.EMPTY_MATCH);let n=e.simplify(t.subs[0]);if(t.max===-1){if(t.min===0)return e.simplify1(D.Op.STAR,t.flags,n,null);if(t.min===1)return e.simplify1(D.Op.PLUS,t.flags,n,null);let r=new D(D.Op.CONCAT),i=[];for(let e=0;e<t.min-1;e++)i.push(n);return i.push(e.simplify1(D.Op.PLUS,t.flags,n,null)),r.subs=i.slice(0),r}if(t.min===1&&t.max===1)return n;let r=null;if(t.min>0){r=[];for(let e=0;e<t.min;e++)r.push(n)}if(t.max>t.min){let i=e.simplify1(D.Op.QUEST,t.flags,n,null);for(let r=t.min+1;r<t.max;r++){let r=new D(D.Op.CONCAT);r.subs=[n,i],i=e.simplify1(D.Op.QUEST,t.flags,r,null)}if(r===null)return i;r.push(i)}if(r!==null){let e=new D(D.Op.CONCAT);return e.subs=r.slice(0),e}return new D(D.Op.NO_MATCH)}}return t}static simplify1(e,t,n,r){return n.op===D.Op.EMPTY_MATCH||e===n.op&&(t&b.NON_GREEDY)===(n.flags&b.NON_GREEDY)?n:r!==null&&r.op===e&&(r.flags&b.NON_GREEDY)===(t&b.NON_GREEDY)&&n===r.subs[0]?r:(r=new D(e),r.flags=t,r.subs=[n],r)}},k=class{constructor(e,t){this.sign=e,this.cls=t}},Qn=[48,57],$n=[9,10,12,13,32,32],er=[48,57,65,90,95,95,97,122],tr=new Map([[`\\d`,new k(1,Qn)],[`\\D`,new k(-1,Qn)],[`\\s`,new k(1,$n)],[`\\S`,new k(-1,$n)],[`\\w`,new k(1,er)],[`\\W`,new k(-1,er)]]),nr=[48,57,65,90,97,122],rr=[65,90,97,122],ir=[0,127],ar=[9,9,32,32],or=[0,31,127,127],sr=[48,57],cr=[33,126],lr=[97,122],ur=[32,126],dr=[33,47,58,64,91,96,123,126],fr=[9,13,32,32],pr=[65,90],mr=[48,57,65,90,95,95,97,122],hr=[48,57,65,70,97,102],gr=new Map([[`[:alnum:]`,new k(1,nr)],[`[:^alnum:]`,new k(-1,nr)],[`[:alpha:]`,new k(1,rr)],[`[:^alpha:]`,new k(-1,rr)],[`[:ascii:]`,new k(1,ir)],[`[:^ascii:]`,new k(-1,ir)],[`[:blank:]`,new k(1,ar)],[`[:^blank:]`,new k(-1,ar)],[`[:cntrl:]`,new k(1,or)],[`[:^cntrl:]`,new k(-1,or)],[`[:digit:]`,new k(1,sr)],[`[:^digit:]`,new k(-1,sr)],[`[:graph:]`,new k(1,cr)],[`[:^graph:]`,new k(-1,cr)],[`[:lower:]`,new k(1,lr)],[`[:^lower:]`,new k(-1,lr)],[`[:print:]`,new k(1,ur)],[`[:^print:]`,new k(-1,ur)],[`[:punct:]`,new k(1,dr)],[`[:^punct:]`,new k(-1,dr)],[`[:space:]`,new k(1,fr)],[`[:^space:]`,new k(-1,fr)],[`[:upper:]`,new k(1,pr)],[`[:^upper:]`,new k(-1,pr)],[`[:word:]`,new k(1,mr)],[`[:^word:]`,new k(-1,mr)],[`[:xdigit:]`,new k(1,hr)],[`[:^xdigit:]`,new k(-1,hr)]]),_r=class e{static charClassToString(e,t){let n=`[`;for(let r=0;r<t;r+=2){r>0&&(n+=` `);let t=e[r],i=e[r+1];t===i?n+=`0x${t.toString(16)}`:n+=`0x${t.toString(16)}-0x${i.toString(16)}`}return n+=`]`,n}static cmp(e,t,n,r){let i=e[t]-n;return i===0?r-e[t+1]:i}static qsortIntPair(t,n,r){let i=((n+r)/2|0)&-2,a=t[i],o=t[i+1],s=n,c=r;for(;s<=c;){for(;s<r&&e.cmp(t,s,a,o)<0;)s+=2;for(;c>n&&e.cmp(t,c,a,o)>0;)c-=2;if(s<=c){if(s!==c){let e=t[s];t[s]=t[c],t[c]=e,e=t[s+1],t[s+1]=t[c+1],t[c+1]=e}s+=2,c-=2}}n<c&&e.qsortIntPair(t,n,c),s<r&&e.qsortIntPair(t,s,r)}constructor(e=w.emptyInts()){this.r=e,this.len=e.length}toArray(){return this.len===this.r.length?this.r:this.r.slice(0,this.len)}cleanClass(){if(this.len<4)return this;e.qsortIntPair(this.r,0,this.len-2);let t=2;for(let e=2;e<this.len;e+=2){let n=this.r[e],r=this.r[e+1];if(n<=this.r[t-1]+1){r>this.r[t-1]&&(this.r[t-1]=r);continue}this.r[t]=n,this.r[t+1]=r,t+=2}return this.len=t,this}appendLiteral(e,t){return(t&b.FOLD_CASE)===0?this.appendRange(e,e):this.appendFoldedRange(e,e)}appendRange(e,t){if(this.len>0){for(let n=2;n<=4;n+=2)if(this.len>=n){let r=this.r[this.len-n],i=this.r[this.len-n+1];if(e<=i+1&&r<=t+1)return e<r&&(this.r[this.len-n]=e),t>i&&(this.r[this.len-n+1]=t),this}}return this.r[this.len++]=e,this.r[this.len++]=t,this}appendFoldedRange(e,t){if(e<=C.MIN_FOLD&&t>=C.MAX_FOLD||t<C.MIN_FOLD||e>C.MAX_FOLD)return this.appendRange(e,t);e<C.MIN_FOLD&&(this.appendRange(e,C.MIN_FOLD-1),e=C.MIN_FOLD),t>C.MAX_FOLD&&(this.appendRange(C.MAX_FOLD+1,t),t=C.MAX_FOLD);for(let n=e;n<=t;n++){this.appendRange(n,n);for(let e=C.simpleFold(n);e!==n;e=C.simpleFold(e))this.appendRange(e,e)}return this}appendClass(e){for(let t=0;t<e.length;t+=2)this.appendRange(e[t],e[t+1]);return this}appendFoldedClass(e){for(let t=0;t<e.length;t+=2)this.appendFoldedRange(e[t],e[t+1]);return this}appendNegatedClass(e){let t=0;for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1];t<=r-1&&this.appendRange(t,r-1),t=i+1}return t<=C.MAX_RUNE&&this.appendRange(t,C.MAX_RUNE),this}appendTable(e){for(let t of e){let e=t[0],n=t[1],r=t[2];if(r===1){this.appendRange(e,n);continue}for(let t=e;t<=n;t+=r)this.appendRange(t,t)}return this}appendNegatedTable(e){let t=0;for(let n of e){let e=n[0],r=n[1],i=n[2];if(i===1){t<=e-1&&this.appendRange(t,e-1),t=r+1;continue}for(let n=e;n<=r;n+=i)t<=n-1&&this.appendRange(t,n-1),t=n+1}return t<=C.MAX_RUNE&&this.appendRange(t,C.MAX_RUNE),this}appendTableWithSign(e,t){return t<0?this.appendNegatedTable(e):this.appendTable(e)}negateClass(){let e=0,t=0;for(let n=0;n<this.len;n+=2){let r=this.r[n],i=this.r[n+1];e<=r-1&&(this.r[t]=e,this.r[t+1]=r-1,t+=2),e=i+1}return this.len=t,e<=C.MAX_RUNE&&(this.r[this.len++]=e,this.r[this.len++]=C.MAX_RUNE),this}appendClassWithSign(e,t){return t<0?this.appendNegatedClass(e):this.appendClass(e)}appendGroup(t,n){let r=t.cls;return n&&(r=new e().appendFoldedClass(r).cleanClass().toArray()),this.appendClassWithSign(r,t.sign)}toString(){return e.charClassToString(this.r,this.len)}},vr=class e{static of(t,n){return new e(t,n)}constructor(e,t){this.first=e,this.second=t}},yr=class{constructor(e){this.str=e,this.position=0}pos(){return this.position}rewindTo(e){this.position=e}more(){return this.position<this.str.length}peek(){return this.str.codePointAt(this.position)}skip(e){this.position+=e}skipString(e){this.position+=e.length}pop(){let e=this.str.codePointAt(this.position);return this.position+=w.charCount(e),e}lookingAt(e){return this.rest().startsWith(e)}rest(){return this.str.substring(this.position)}from(e){return this.str.substring(e,this.position)}toString(){return this.rest()}},br=class e{static ERR_INTERNAL_ERROR=`regexp/syntax: internal error`;static ERR_INVALID_CHAR_RANGE=`invalid character class range`;static ERR_INVALID_ESCAPE=`invalid escape sequence`;static ERR_INVALID_NAMED_CAPTURE=`invalid named capture`;static ERR_INVALID_PERL_OP=`invalid or unsupported Perl syntax`;static ERR_INVALID_REPEAT_OP=`invalid nested repetition operator`;static ERR_INVALID_REPEAT_SIZE=`invalid repeat count`;static ERR_MISSING_BRACKET=`missing closing ]`;static ERR_MISSING_PAREN=`missing closing )`;static ERR_MISSING_REPEAT_ARGUMENT=`missing argument to repetition operator`;static ERR_TRAILING_BACKSLASH=`trailing backslash at end of expression`;static ERR_DUPLICATE_NAMED_CAPTURE=`duplicate capture group name`;static ANY_TABLE(){return[[0,C.MAX_RUNE,1]]}static unicodeTable(t){return t===`Any`?vr.of(e.ANY_TABLE(),e.ANY_TABLE()):S.CATEGORIES.has(t)?vr.of(S.CATEGORIES.get(t),S.FOLD_CATEGORIES.get(t)):S.SCRIPTS.has(t)?vr.of(S.SCRIPTS.get(t),S.FOLD_SCRIPT.get(t)):null}static minFoldRune(e){if(e<C.MIN_FOLD||e>C.MAX_FOLD)return e;let t=e,n=e;for(e=C.simpleFold(e);e!==n;e=C.simpleFold(e))t>e&&(t=e);return t}static leadingRegexp(e){if(e.op===D.Op.EMPTY_MATCH)return null;if(e.op===D.Op.CONCAT&&e.subs.length>0){let t=e.subs[0];return t.op===D.Op.EMPTY_MATCH?null:t}return e}static literalRegexp(e,t){let n=new D(D.Op.LITERAL);return n.flags=t,n.runes=w.stringToRunes(e),n}static parse(t,n){return new e(t,n).parseInternal()}static parseRepeat(t){let n=t.pos();if(!t.more()||!t.lookingAt(`{`))return-1;t.skip(1);let r=e.parseInt(t);if(r===-1||!t.more())return-1;let i;if(!t.lookingAt(`,`))i=r;else{if(t.skip(1),!t.more())return-1;if(t.lookingAt(`}`))i=-1;else if((i=e.parseInt(t))===-1)return-1}if(!t.more()||!t.lookingAt(`}`))return-1;if(t.skip(1),r<0||r>1e3||i===-2||i>1e3||i>=0&&r>i)throw new T(e.ERR_INVALID_REPEAT_SIZE,t.from(n));return r<<16|i&C.MAX_BMP}static isValidCaptureName(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n!==x.CODES.get(`_`)&&!w.isalnum(n))return!1}return!0}static parseInt(e){let t=e.pos();for(;e.more()&&e.peek()>=x.CODES.get(`0`)&&e.peek()<=x.CODES.get(`9`);)e.skip(1);let n=e.from(t);return n.length===0||n.length>1&&n.codePointAt(0)===x.CODES.get(`0`)?-1:n.length>8?-2:parseFloat(n,10)}static isCharClass(e){return e.op===D.Op.LITERAL&&e.runes.length===1||e.op===D.Op.CHAR_CLASS||e.op===D.Op.ANY_CHAR_NOT_NL||e.op===D.Op.ANY_CHAR}static matchRune(e,t){switch(e.op){case D.Op.LITERAL:return e.runes.length===1&&e.runes[0]===t;case D.Op.CHAR_CLASS:for(let n=0;n<e.runes.length;n+=2)if(e.runes[n]<=t&&t<=e.runes[n+1])return!0;return!1;case D.Op.ANY_CHAR_NOT_NL:return t!==x.CODES.get(`
|
|
19
|
+
`);case D.Op.ANY_CHAR:return!0}return!1}static mergeCharClass(t,n){switch(t.op){case D.Op.ANY_CHAR:break;case D.Op.ANY_CHAR_NOT_NL:e.matchRune(n,x.CODES.get(`
|
|
20
|
+
`))&&(t.op=D.Op.ANY_CHAR);break;case D.Op.CHAR_CLASS:n.op===D.Op.LITERAL?t.runes=new _r(t.runes).appendLiteral(n.runes[0],n.flags).toArray():t.runes=new _r(t.runes).appendClass(n.runes).toArray();break;case D.Op.LITERAL:if(n.runes[0]===t.runes[0]&&n.flags===t.flags)break;t.op=D.Op.CHAR_CLASS,t.runes=new _r().appendLiteral(t.runes[0],t.flags).appendLiteral(n.runes[0],n.flags).toArray();break}}static parseEscape(t){let n=t.pos();if(t.skip(1),!t.more())throw new T(e.ERR_TRAILING_BACKSLASH);let r=t.pop();bigswitch:switch(r){case x.CODES.get(`1`):case x.CODES.get(`2`):case x.CODES.get(`3`):case x.CODES.get(`4`):case x.CODES.get(`5`):case x.CODES.get(`6`):case x.CODES.get(`7`):if(!t.more()||t.peek()<x.CODES.get(`0`)||t.peek()>x.CODES.get(`7`))break;case x.CODES.get(`0`):{let e=r-x.CODES.get(`0`);for(let n=1;n<3&&!(!t.more()||t.peek()<x.CODES.get(`0`)||t.peek()>x.CODES.get(`7`));n++)e=e*8+t.peek()-x.CODES.get(`0`),t.skip(1);return e}case x.CODES.get(`x`):{if(!t.more())break;if(r=t.pop(),r===x.CODES.get(`{`)){let e=0,n=0;for(;;){if(!t.more())break bigswitch;if(r=t.pop(),r===x.CODES.get(`}`))break;let i=w.unhex(r);if(i<0||(n=n*16+i,n>C.MAX_RUNE))break bigswitch;e++}if(e===0)break bigswitch;return n}let e=w.unhex(r);if(!t.more())break;r=t.pop();let n=w.unhex(r);if(e<0||n<0)break;return e*16+n}case x.CODES.get(`a`):return x.CODES.get(`\x07`);case x.CODES.get(`f`):return x.CODES.get(`\f`);case x.CODES.get(`n`):return x.CODES.get(`
|
|
21
|
+
`);case x.CODES.get(`r`):return x.CODES.get(`\r`);case x.CODES.get(`t`):return x.CODES.get(` `);case x.CODES.get(`v`):return x.CODES.get(`\v`);default:if(!w.isalnum(r))return r;break}throw new T(e.ERR_INVALID_ESCAPE,t.from(n))}static parseClassChar(t,n){if(!t.more())throw new T(e.ERR_MISSING_BRACKET,t.from(n));return t.lookingAt(`\\`)?e.parseEscape(t):t.pop()}static concatRunes(e,t){return[...e,...t]}constructor(e,t=0){this.wholeRegexp=e,this.flags=t,this.numCap=0,this.namedGroups={},this.stack=[],this.free=null}newRegexp(e){let t=this.free;return t!==null&&t.subs!==null&&t.subs.length>0?(this.free=t.subs[0],t.reinit(),t.op=e):t=new D(e),t}reuse(e){e.subs!==null&&e.subs.length>0&&(e.subs[0]=this.free),this.free=e}pop(){return this.stack.pop()}popToPseudo(){let e=this.stack.length,t=e;for(;t>0&&!D.isPseudoOp(this.stack[t-1].op);)t--;let n=this.stack.slice(t,e);return this.stack=this.stack.slice(0,t),n}push(e){if(e.op===D.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]===e.runes[1]){if(this.maybeConcat(e.runes[0],this.flags&~b.FOLD_CASE))return null;e.op=D.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags&~b.FOLD_CASE}else if(e.op===D.Op.CHAR_CLASS&&e.runes.length===4&&e.runes[0]===e.runes[1]&&e.runes[2]===e.runes[3]&&C.simpleFold(e.runes[0])===e.runes[2]&&C.simpleFold(e.runes[2])===e.runes[0]||e.op===D.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]+1===e.runes[1]&&C.simpleFold(e.runes[0])===e.runes[1]&&C.simpleFold(e.runes[1])===e.runes[0]){if(this.maybeConcat(e.runes[0],this.flags|b.FOLD_CASE))return null;e.op=D.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags|b.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(e),e}maybeConcat(t,n){let r=this.stack.length;if(r<2)return!1;let i=this.stack[r-1],a=this.stack[r-2];return i.op!==D.Op.LITERAL||a.op!==D.Op.LITERAL||(i.flags&b.FOLD_CASE)!==(a.flags&b.FOLD_CASE)?!1:(a.runes=e.concatRunes(a.runes,i.runes),t>=0?(i.runes=[t],i.flags=n,!0):(this.pop(),this.reuse(i),!1))}newLiteral(t,n){let r=this.newRegexp(D.Op.LITERAL);return r.flags=n,(n&b.FOLD_CASE)!==0&&(t=e.minFoldRune(t)),r.runes=[t],r}literal(e){this.push(this.newLiteral(e,this.flags))}op(e){let t=this.newRegexp(e);return t.flags=this.flags,this.push(t)}repeat(t,n,r,i,a,o){let s=this.flags;if((s&b.PERL_X)!==0&&(a.more()&&a.lookingAt(`?`)&&(a.skip(1),s^=b.NON_GREEDY),o!==-1))throw new T(e.ERR_INVALID_REPEAT_OP,a.from(o));let c=this.stack.length;if(c===0)throw new T(e.ERR_MISSING_REPEAT_ARGUMENT,a.from(i));let l=this.stack[c-1];if(D.isPseudoOp(l.op))throw new T(e.ERR_MISSING_REPEAT_ARGUMENT,a.from(i));let u=this.newRegexp(t);u.min=n,u.max=r,u.flags=s,u.subs=[l],this.stack[c-1]=u}concat(){this.maybeConcat(-1,0);let e=this.popToPseudo();return e.length===0?this.push(this.newRegexp(D.Op.EMPTY_MATCH)):this.push(this.collapse(e,D.Op.CONCAT))}alternate(){let e=this.popToPseudo();return e.length>0&&this.cleanAlt(e[e.length-1]),e.length===0?this.push(this.newRegexp(D.Op.NO_MATCH)):this.push(this.collapse(e,D.Op.ALTERNATE))}cleanAlt(e){e.op===D.Op.CHAR_CLASS&&(e.runes=new _r(e.runes).cleanClass().toArray(),e.runes.length===2&&e.runes[0]===0&&e.runes[1]===C.MAX_RUNE?(e.runes=null,e.op=D.Op.ANY_CHAR):e.runes.length===4&&e.runes[0]===0&&e.runes[1]===x.CODES.get(`
|
|
22
|
+
`)-1&&e.runes[2]===x.CODES.get(`
|
|
23
|
+
`)+1&&e.runes[3]===C.MAX_RUNE&&(e.runes=null,e.op=D.Op.ANY_CHAR_NOT_NL))}collapse(e,t){if(e.length===1)return e[0];let n=0;for(let r of e)n+=r.op===t?r.subs.length:1;let r=Array(n).fill(null),i=0;for(let n of e)n.op===t?(r.splice(i,n.subs.length,...n.subs),i+=n.subs.length,this.reuse(n)):r[i++]=n;let a=this.newRegexp(t);if(a.subs=r,t===D.Op.ALTERNATE&&(a.subs=this.factor(a.subs),a.subs.length===1)){let e=a;a=a.subs[0],this.reuse(e)}return a}factor(t){if(t.length<2)return t;let n=0,r=t.length,i=0,a=null,o=0,s=0,c=0;for(let e=0;e<=r;e++){let l=null,u=0,d=0;if(e<r){let r=t[n+e];if(r.op===D.Op.CONCAT&&r.subs.length>0&&(r=r.subs[0]),r.op===D.Op.LITERAL&&(l=r.runes,u=r.runes.length,d=r.flags&b.FOLD_CASE),d===s){let e=0;for(;e<o&&e<u&&a[e]===l[e];)e++;if(e>0){o=e;continue}}}if(e!==c)if(e===c+1)t[i++]=t[n+c];else{let r=this.newRegexp(D.Op.LITERAL);r.flags=s,r.runes=a.slice(0,o);for(let r=c;r<e;r++)t[n+r]=this.removeLeadingString(t[n+r],o);let l=this.collapse(t.slice(n+c,n+e),D.Op.ALTERNATE),u=this.newRegexp(D.Op.CONCAT);u.subs=[r,l],t[i++]=u}c=e,a=l,o=u,s=d}r=i,n=0,c=0,i=0;let l=null;for(let a=0;a<=r;a++){let o=null;if(!(a<r&&(o=e.leadingRegexp(t[n+a]),l!==null&&l.equals(o)&&(e.isCharClass(l)||l.op===D.Op.REPEAT&&l.min===l.max&&e.isCharClass(l.subs[0]))))){if(a!==c)if(a===c+1)t[i++]=t[n+c];else{let e=l;for(let e=c;e<a;e++){let r=e!==c;t[n+e]=this.removeLeadingRegexp(t[n+e],r)}let r=this.collapse(t.slice(n+c,n+a),D.Op.ALTERNATE),o=this.newRegexp(D.Op.CONCAT);o.subs=[e,r],t[i++]=o}c=a,l=o}}r=i,n=0,c=0,i=0;for(let a=0;a<=r;a++)if(!(a<r&&e.isCharClass(t[n+a]))){if(a!==c)if(a===c+1)t[i++]=t[n+c];else{let r=c;for(let e=c+1;e<a;e++){let i=t[n+r],a=t[n+e];(i.op<a.op||i.op===a.op&&(i.runes===null?0:i.runes.length)<(a.runes===null?0:a.runes.length))&&(r=e)}let o=t[n+c];t[n+c]=t[n+r],t[n+r]=o;for(let r=c+1;r<a;r++)e.mergeCharClass(t[n+c],t[n+r]),this.reuse(t[n+r]);this.cleanAlt(t[n+c]),t[i++]=t[n+c]}a<r&&(t[i++]=t[n+a]),c=a+1}r=i,n=0,c=0,i=0;for(let e=0;e<r;++e)e+1<r&&t[n+e].op===D.Op.EMPTY_MATCH&&t[n+e+1].op===D.Op.EMPTY_MATCH||(t[i++]=t[n+e]);return r=i,n=0,t.slice(n,r)}removeLeadingString(e,t){if(e.op===D.Op.CONCAT&&e.subs.length>0){let n=this.removeLeadingString(e.subs[0],t);if(e.subs[0]=n,n.op===D.Op.EMPTY_MATCH)switch(this.reuse(n),e.subs.length){case 0:case 1:e.op=D.Op.EMPTY_MATCH,e.subs=null;break;case 2:{let t=e;e=e.subs[1],this.reuse(t);break}default:e.subs=e.subs.slice(1,e.subs.length);break}return e}return e.op===D.Op.LITERAL&&(e.runes=e.runes.slice(t,e.runes.length),e.runes.length===0&&(e.op=D.Op.EMPTY_MATCH)),e}removeLeadingRegexp(e,t){if(e.op===D.Op.CONCAT&&e.subs.length>0){switch(t&&this.reuse(e.subs[0]),e.subs=e.subs.slice(1,e.subs.length),e.subs.length){case 0:e.op=D.Op.EMPTY_MATCH,e.subs=D.emptySubs();break;case 1:{let t=e;e=e.subs[0],this.reuse(t);break}}return e}return t&&this.reuse(e),this.newRegexp(D.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&b.LITERAL)!==0)return e.literalRegexp(this.wholeRegexp,this.flags);let t=-1,n=-1,r=-1,i=new yr(this.wholeRegexp);for(;i.more();){let a=-1;bigswitch:switch(i.peek()){case x.CODES.get(`(`):if((this.flags&b.PERL_X)!==0&&i.lookingAt(`(?`)){this.parsePerlFlags(i);break}this.op(D.Op.LEFT_PAREN).cap=++this.numCap,i.skip(1);break;case x.CODES.get(`|`):this.parseVerticalBar(),i.skip(1);break;case x.CODES.get(`)`):this.parseRightParen(),i.skip(1);break;case x.CODES.get(`^`):(this.flags&b.ONE_LINE)===0?this.op(D.Op.BEGIN_LINE):this.op(D.Op.BEGIN_TEXT),i.skip(1);break;case x.CODES.get(`$`):(this.flags&b.ONE_LINE)===0?this.op(D.Op.END_LINE):this.op(D.Op.END_TEXT).flags|=b.WAS_DOLLAR,i.skip(1);break;case x.CODES.get(`.`):(this.flags&b.DOT_NL)===0?this.op(D.Op.ANY_CHAR_NOT_NL):this.op(D.Op.ANY_CHAR),i.skip(1);break;case x.CODES.get(`[`):this.parseClass(i);break;case x.CODES.get(`*`):case x.CODES.get(`+`):case x.CODES.get(`?`):{a=i.pos();let e=null;switch(i.pop()){case x.CODES.get(`*`):e=D.Op.STAR;break;case x.CODES.get(`+`):e=D.Op.PLUS;break;case x.CODES.get(`?`):e=D.Op.QUEST;break}this.repeat(e,n,r,a,i,t);break}case x.CODES.get(`{`):{a=i.pos();let o=e.parseRepeat(i);if(o<0){i.rewindTo(a),this.literal(i.pop());break}n=o>>16,r=(o&C.MAX_BMP)<<16>>16,this.repeat(D.Op.REPEAT,n,r,a,i,t);break}case x.CODES.get(`\\`):{let t=i.pos();if(i.skip(1),(this.flags&b.PERL_X)!==0&&i.more())switch(i.pop()){case x.CODES.get(`A`):this.op(D.Op.BEGIN_TEXT);break bigswitch;case x.CODES.get(`b`):this.op(D.Op.WORD_BOUNDARY);break bigswitch;case x.CODES.get(`B`):this.op(D.Op.NO_WORD_BOUNDARY);break bigswitch;case x.CODES.get(`C`):throw new T(e.ERR_INVALID_ESCAPE,`\\C`);case x.CODES.get(`Q`):{let e=i.rest(),t=e.indexOf(`\\E`);t>=0&&(e=e.substring(0,t)),i.skipString(e),i.skipString(`\\E`);let n=0;for(;n<e.length;){let t=e.codePointAt(n);this.literal(t),n+=w.charCount(t)}break bigswitch}case x.CODES.get(`z`):this.op(D.Op.END_TEXT);break bigswitch;default:i.rewindTo(t);break}let n=this.newRegexp(D.Op.CHAR_CLASS);if(n.flags=this.flags,i.lookingAt(`\\p`)||i.lookingAt(`\\P`)){let e=new _r;if(this.parseUnicodeClass(i,e)){n.runes=e.toArray(),this.push(n);break bigswitch}}let r=new _r;if(this.parsePerlClassEscape(i,r)){n.runes=r.toArray(),this.push(n);break bigswitch}i.rewindTo(t),this.reuse(n),this.literal(e.parseEscape(i));break}default:this.literal(i.pop());break}t=a}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length!==1)throw new T(e.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(t){let n=t.pos(),r=t.rest();if(r.startsWith(`(?P<`)||r.startsWith(`(?<`)){let n=r.charAt(2)===`P`?4:3,i=r.indexOf(`>`);if(i<0)throw new T(e.ERR_INVALID_NAMED_CAPTURE,r);let a=r.substring(n,i);if(t.skipString(a),t.skip(n+1),!e.isValidCaptureName(a))throw new T(e.ERR_INVALID_NAMED_CAPTURE,r.substring(0,i+1));let o=this.op(D.Op.LEFT_PAREN);if(o.cap=++this.numCap,this.namedGroups[a])throw new T(e.ERR_DUPLICATE_NAMED_CAPTURE,a);this.namedGroups[a]=this.numCap,o.name=a;return}t.skip(2);let i=this.flags,a=1,o=!1;loop:for(;t.more();){let e=t.pop();switch(e){case x.CODES.get(`i`):i|=b.FOLD_CASE,o=!0;break;case x.CODES.get(`m`):i&=~b.ONE_LINE,o=!0;break;case x.CODES.get(`s`):i|=b.DOT_NL,o=!0;break;case x.CODES.get(`U`):i|=b.NON_GREEDY,o=!0;break;case x.CODES.get(`-`):if(a<0)break loop;a=-1,i=~i,o=!1;break;case x.CODES.get(`:`):case x.CODES.get(`)`):if(a<0){if(!o)break loop;i=~i}e===x.CODES.get(`:`)&&this.op(D.Op.LEFT_PAREN),this.flags=i;return;default:break loop}}throw new T(e.ERR_INVALID_PERL_OP,t.from(n))}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(D.Op.VERTICAL_BAR)}swapVerticalBar(){let t=this.stack.length;if(t>=3&&this.stack[t-2].op===D.Op.VERTICAL_BAR&&e.isCharClass(this.stack[t-1])&&e.isCharClass(this.stack[t-3])){let n=this.stack[t-1],r=this.stack[t-3];if(n.op>r.op){let e=r;r=n,n=e,this.stack[t-3]=r}return e.mergeCharClass(r,n),this.reuse(n),this.pop(),!0}if(t>=2){let e=this.stack[t-1],n=this.stack[t-2];if(n.op===D.Op.VERTICAL_BAR)return t>=3&&this.cleanAlt(this.stack[t-3]),this.stack[t-2]=e,this.stack[t-1]=n,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new T(e.ERR_INTERNAL_ERROR,`stack underflow`);let t=this.pop(),n=this.pop();if(n.op!==D.Op.LEFT_PAREN)throw new T(e.ERR_MISSING_PAREN,this.wholeRegexp);this.flags=n.flags,n.cap===0?this.push(t):(n.op=D.Op.CAPTURE,n.subs=[t],this.push(n))}parsePerlClassEscape(e,t){let n=e.pos();if((this.flags&b.PERL_X)===0||!e.more()||e.pop()!==x.CODES.get(`\\`)||!e.more())return!1;e.pop();let r=e.from(n),i=tr.has(r)?tr.get(r):null;return i===null?!1:(t.appendGroup(i,(this.flags&b.FOLD_CASE)!==0),!0)}parseNamedClass(t,n){let r=t.rest(),i=r.indexOf(`:]`);if(i<0)return!1;let a=r.substring(0,i+2);t.skipString(a);let o=gr.has(a)?gr.get(a):null;if(o===null)throw new T(e.ERR_INVALID_CHAR_RANGE,a);return n.appendGroup(o,(this.flags&b.FOLD_CASE)!==0),!0}parseUnicodeClass(t,n){let r=t.pos();if((this.flags&b.UNICODE_GROUPS)===0||!t.lookingAt(`\\p`)&&!t.lookingAt(`\\P`))return!1;t.skip(1);let i=1,a=t.pop();if(a===x.CODES.get(`P`)&&(i=-1),!t.more())throw t.rewindTo(r),new T(e.ERR_INVALID_CHAR_RANGE,t.rest());a=t.pop();let o;if(a!==x.CODES.get(`{`))o=w.runeToString(a);else{let n=t.rest(),i=n.indexOf(`}`);if(i<0)throw t.rewindTo(r),new T(e.ERR_INVALID_CHAR_RANGE,t.rest());o=n.substring(0,i),t.skipString(o),t.skip(1)}o.length!==0&&o.codePointAt(0)===x.CODES.get(`^`)&&(i=0-i,o=o.substring(1));let s=e.unicodeTable(o);if(s===null)throw new T(e.ERR_INVALID_CHAR_RANGE,t.from(r));let c=s.first,l=s.second;if((this.flags&b.FOLD_CASE)===0||l===null)n.appendTableWithSign(c,i);else{let e=new _r().appendTable(c).appendTable(l).cleanClass().toArray();n.appendClassWithSign(e,i)}return!0}parseClass(t){let n=t.pos();t.skip(1);let r=this.newRegexp(D.Op.CHAR_CLASS);r.flags=this.flags;let i=new _r,a=1;t.more()&&t.lookingAt(`^`)&&(a=-1,t.skip(1),(this.flags&b.CLASS_NL)===0&&i.appendRange(x.CODES.get(`
|
|
24
|
+
`),x.CODES.get(`
|
|
25
|
+
`)));let o=!0;for(;!t.more()||t.peek()!==x.CODES.get(`]`)||o;){if(t.more()&&t.lookingAt(`-`)&&(this.flags&b.PERL_X)===0&&!o){let r=t.rest();if(r===`-`||!r.startsWith(`-]`))throw t.rewindTo(n),new T(e.ERR_INVALID_CHAR_RANGE,t.rest())}o=!1;let r=t.pos();if(t.lookingAt(`[:`)){if(this.parseNamedClass(t,i))continue;t.rewindTo(r)}if(this.parseUnicodeClass(t,i)||this.parsePerlClassEscape(t,i))continue;t.rewindTo(r);let a=e.parseClassChar(t,n),s=a;if(t.more()&&t.lookingAt(`-`)){if(t.skip(1),t.more()&&t.lookingAt(`]`))t.skip(-1);else if(s=e.parseClassChar(t,n),s<a)throw new T(e.ERR_INVALID_CHAR_RANGE,t.from(r))}(this.flags&b.FOLD_CASE)===0?i.appendRange(a,s):i.appendFoldedRange(a,s)}t.skip(1),i.cleanClass(),a<0&&i.negateClass(),r.runes=i.toArray(),this.push(r)}},xr=class{constructor(){this.inst=null,this.cap=[]}},Sr=class{constructor(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}contains(e){let t=this.sparse[e];return t<this.size&&this.densePcs[t]===e}isEmpty(){return this.size===0}add(e){let t=this.size++;return this.sparse[e]=t,this.denseThreads[t]=null,this.densePcs[t]=e,t}clear(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}toString(){let e=`{`;for(let t=0;t<this.size;t++)t!==0&&(e+=`, `),e+=this.densePcs[t];return e+=`}`,e}},Cr=class e{static fromRE2(t){let n=new e;return n.prog=t.prog,n.re2=t,n.q0=new Sr(n.prog.numInst()),n.q1=new Sr(n.prog.numInst()),n.pool=[],n.poolSize=0,n.matched=!1,n.matchcap=Array(n.prog.numCap<2?2:n.prog.numCap).fill(0),n.ncap=0,n}static fromMachine(t){let n=new e;return n.re2=t.re2,n.prog=t.prog,n.q0=t.q0,n.q1=t.q1,n.pool=t.pool,n.poolSize=t.poolSize,n.matched=t.matched,n.matchcap=t.matchcap,n.ncap=t.ncap,n}init(e){this.ncap=e,e>this.matchcap.length?this.initNewCap(e):this.resetCap(e)}resetCap(e){for(let t=0;t<this.poolSize;t++){let n=this.pool[t];n.cap=Array(e).fill(0)}}initNewCap(e){for(let t=0;t<this.poolSize;t++){let n=this.pool[t];n.cap=Array(e).fill(0)}this.matchcap=Array(e).fill(0)}submatches(){return this.ncap===0?w.emptyInts():this.matchcap.slice(0,this.ncap)}alloc(e){let t;return this.poolSize>0?(this.poolSize--,t=this.pool[this.poolSize]):t=new xr,t.inst=e,t}freeQueue(e,t=0){let n=e.size-t,r=this.poolSize+n;this.pool.length<r&&(this.pool=this.pool.slice(0,Math.max(this.pool.length*2,r)));for(let n=t;n<e.size;n++){let t=e.denseThreads[n];t!==null&&(this.pool[this.poolSize]=t,this.poolSize++)}e.clear()}freeThread(e){this.pool.length<=this.poolSize&&(this.pool=this.pool.slice(0,this.pool.length*2)),this.pool[this.poolSize]=e,this.poolSize++}match(e,t,n){let r=this.re2.cond;if(r===w.EMPTY_ALL||(n===b.ANCHOR_START||n===b.ANCHOR_BOTH)&&t!==0)return!1;this.matched=!1,this.matchcap=Array(this.prog.numCap).fill(-1);let i=this.q0,a=this.q1,o=e.step(t),s=o>>3,c=o&7,l=-1,u=0;o!==Gn.EOF()&&(o=e.step(t+c),l=o>>3,u=o&7);let d;for(d=t===0?w.emptyOpContext(-1,s):e.context(t);;){if(i.isEmpty()){if((r&w.EMPTY_BEGIN_TEXT)!==0&&t!==0||this.matched)break;if(this.re2.prefix.length!==0&&l!==this.re2.prefixRune&&e.canCheckPrefix()){let n=e.index(this.re2,t);if(n<0)break;t+=n,o=e.step(t),s=o>>3,c=o&7,o=e.step(t+c),l=o>>3,u=o&7}}!this.matched&&(t===0||n===b.UNANCHORED)&&(this.ncap>0&&(this.matchcap[0]=t),this.add(i,this.prog.start,t,this.matchcap,d,null));let f=t+c;if(d=e.context(f),this.step(i,a,t,f,s,d,n,t===e.endPos()),c===0||this.ncap===0&&this.matched)break;t+=c,s=l,c=u,s!==-1&&(o=e.step(t+c),l=o>>3,u=o&7);let p=i;i=a,a=p}return this.freeQueue(a),this.matched}step(e,t,n,r,i,a,o,s){let c=this.re2.longest;for(let l=0;l<e.size;l++){let u=e.denseThreads[l];if(u===null)continue;if(c&&this.matched&&this.ncap>0&&this.matchcap[0]<u.cap[0]){this.freeThread(u);continue}let d=u.inst,f=!1;switch(d.op){case O.MATCH:if(o===b.ANCHOR_BOTH&&!s)break;this.ncap>0&&(!c||!this.matched||this.matchcap[1]<n)&&(u.cap[1]=n,this.matchcap=u.cap.slice(0,this.ncap)),c||this.freeQueue(e,l+1),this.matched=!0;break;case O.RUNE:f=d.matchRune(i);break;case O.RUNE1:f=i===d.runes[0];break;case O.RUNE_ANY:f=!0;break;case O.RUNE_ANY_NOT_NL:f=i!==x.CODES.get(`
|
|
26
|
+
`);break;default:throw Error(`bad inst`)}f&&(u=this.add(t,d.out,r,u.cap,a,u)),u!==null&&(this.freeThread(u),e.denseThreads[l]=null)}e.clear()}add(e,t,n,r,i,a){if(t===0||e.contains(t))return a;let o=e.add(t),s=this.prog.inst[t];switch(s.op){case O.FAIL:break;case O.ALT:case O.ALT_MATCH:a=this.add(e,s.out,n,r,i,a),a=this.add(e,s.arg,n,r,i,a);break;case O.EMPTY_WIDTH:(s.arg&~i)===0&&(a=this.add(e,s.out,n,r,i,a));break;case O.NOP:a=this.add(e,s.out,n,r,i,a);break;case O.CAPTURE:if(s.arg<this.ncap){let t=r[s.arg];r[s.arg]=n,this.add(e,s.out,n,r,i,null),r[s.arg]=t}else a=this.add(e,s.out,n,r,i,a);break;case O.MATCH:case O.RUNE:case O.RUNE1:case O.RUNE_ANY:case O.RUNE_ANY_NOT_NL:a===null?a=this.alloc(s):a.inst=s,this.ncap>0&&a.cap!==r&&(a.cap=r.slice(0,this.ncap)),e.denseThreads[o]=a,a=null;break;default:throw Error(`unhandled`)}return a}},wr=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}compareAndSet(e,t){return this.value===e?(this.value=t,!0):!1}},Tr=class e{static initTest(t){let n=e.compile(t),r=new e(n.expr,n.prog,n.numSubexp,n.longest);return r.cond=n.cond,r.prefix=n.prefix,r.prefixUTF8=n.prefixUTF8,r.prefixComplete=n.prefixComplete,r.prefixRune=n.prefixRune,r}static compile(t){return e.compileImpl(t,b.PERL,!1)}static compilePOSIX(t){return e.compileImpl(t,b.POSIX,!0)}static compileImpl(t,n,r){let i=br.parse(t,n),a=i.maxCap();i=Zn.simplify(i);let o=Xn.compileRegexp(i),s=new e(t,o,a,r),[c,l]=o.prefix();return s.prefixComplete=c,s.prefix=l,s.prefixUTF8=w.stringToUtf8ByteArray(s.prefix),s.prefix.length>0&&(s.prefixRune=s.prefix.codePointAt(0)),s.namedGroups=i.namedGroups,s}static match(t,n){return e.compile(t).match(n)}constructor(e,t,n=0,r=0){this.expr=e,this.prog=t,this.numSubexp=n,this.longest=r,this.cond=t.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.pooled=new wr}numberOfCapturingGroups(){return this.numSubexp}get(){let e;do e=this.pooled.get();while(e&&!this.pooled.compareAndSet(e,e.next));return e}reset(){this.pooled.set(null)}put(e,t){let n=this.pooled.get();do n=this.pooled.get(),!t&&n&&(e=Cr.fromMachine(e),t=!0),e.next!==n&&(e.next=n);while(!this.pooled.compareAndSet(n,e))}toString(){return this.expr}doExecute(e,t,n,r){let i=this.get(),a=!1;i?i.next!==null&&(i=Cr.fromMachine(i),a=!0):(i=Cr.fromRE2(this),a=!0),i.init(r);let o=i.match(e,t,n)?i.submatches():null;return this.put(i,a),o}match(e){return this.doExecute(E.fromUTF16(e),0,b.UNANCHORED,0)!==null}matchWithGroup(e,t,n,r,i){return e instanceof In||(e=zn.utf16(e)),this.matchMachineInput(e,t,n,r,i)}matchMachineInput(e,t,n,r,i){if(t>n)return[!1,null];let a=e.isUTF16Encoding()?E.fromUTF16(e.asCharSequence(),0,n):E.fromUTF8(e.asBytes(),0,n),o=this.doExecute(a,t,r,2*i);return o===null?[!1,null]:[!0,o]}matchUTF8(e){return this.doExecute(E.fromUTF8(e),0,b.UNANCHORED,0)!==null}replaceAll(e,t){return this.replaceAllFunc(e,()=>t,2*e.length+1)}replaceFirst(e,t){return this.replaceAllFunc(e,()=>t,1)}replaceAllFunc(e,t,n){let r=0,i=0,a=``,o=E.fromUTF16(e),s=0;for(;i<=e.length;){let c=this.doExecute(o,i,b.UNANCHORED,2);if(c===null||c.length===0)break;a+=e.substring(r,c[0]),(c[1]>r||c[0]===0)&&(a+=t(e.substring(c[0],c[1])),s++),r=c[1];let l=o.step(i)&7;if(i+l>c[1]?i+=l:i+1>c[1]?i++:i=c[1],s>=n)break}return a+=e.substring(r),a}pad(e){if(e===null)return null;let t=(1+this.numSubexp)*2;if(e.length<t){let n=Array(t).fill(-1);for(let t=0;t<e.length;t++)n[t]=e[t];e=n}return e}allMatches(e,t,n=e=>e){let r=[],i=e.endPos();t<0&&(t=i+1);let a=0,o=0,s=-1;for(;o<t&&a<=i;){let t=this.doExecute(e,a,b.UNANCHORED,this.prog.numCap);if(t===null||t.length===0)break;let c=!0;if(t[1]===a){t[0]===s&&(c=!1);let n=e.step(a);n<0?a=i+1:a+=n&7}else a=t[1];s=t[1],c&&(r.push(n(this.pad(t))),o++)}return r}findUTF8(e){let t=this.doExecute(E.fromUTF8(e),0,b.UNANCHORED,2);return t===null?null:e.slice(t[0],t[1])}findUTF8Index(e){let t=this.doExecute(E.fromUTF8(e),0,b.UNANCHORED,2);return t===null?null:t.slice(0,2)}find(e){let t=this.doExecute(E.fromUTF16(e),0,b.UNANCHORED,2);return t===null?``:e.substring(t[0],t[1])}findIndex(e){return this.doExecute(E.fromUTF16(e),0,b.UNANCHORED,2)}findUTF8Submatch(e){let t=this.doExecute(E.fromUTF8(e),0,b.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r<n.length;r++)2*r<t.length&&t[2*r]>=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n}findUTF8SubmatchIndex(e){return this.pad(this.doExecute(E.fromUTF8(e),0,b.UNANCHORED,this.prog.numCap))}findSubmatch(e){let t=this.doExecute(E.fromUTF16(e),0,b.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r<n.length;r++)2*r<t.length&&t[2*r]>=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n}findSubmatchIndex(e){return this.pad(this.doExecute(E.fromUTF16(e),0,b.UNANCHORED,this.prog.numCap))}findAllUTF8(e,t){let n=this.allMatches(E.fromUTF8(e),t,t=>e.slice(t[0],t[1]));return n.length===0?null:n}findAllUTF8Index(e,t){let n=this.allMatches(E.fromUTF8(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAll(e,t){let n=this.allMatches(E.fromUTF16(e),t,t=>e.substring(t[0],t[1]));return n.length===0?null:n}findAllIndex(e,t){let n=this.allMatches(E.fromUTF16(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAllUTF8Submatch(e,t){let n=this.allMatches(E.fromUTF8(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r<n.length;r++)t[2*r]>=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllUTF8SubmatchIndex(e,t){let n=this.allMatches(E.fromUTF8(e),t);return n.length===0?null:n}findAllSubmatch(e,t){let n=this.allMatches(E.fromUTF16(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r<n.length;r++)t[2*r]>=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllSubmatchIndex(e,t){let n=this.allMatches(E.fromUTF16(e),t);return n.length===0?null:n}},Er=class e{static CASE_INSENSITIVE=1;static DOTALL=2;static MULTILINE=4;static DISABLE_UNICODE_GROUPS=8;static LONGEST_MATCH=16;static quote(e){return w.quoteMeta(e)}static compile(t,n=0){let r=t;if((n&e.CASE_INSENSITIVE)!==0&&(r=`(?i)${r}`),(n&e.DOTALL)!==0&&(r=`(?s)${r}`),(n&e.MULTILINE)!==0&&(r=`(?m)${r}`),(n&~(e.MULTILINE|e.DOTALL|e.CASE_INSENSITIVE|e.DISABLE_UNICODE_GROUPS|e.LONGEST_MATCH))!==0)throw new Un(`Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH`);let i=b.PERL;(n&e.DISABLE_UNICODE_GROUPS)!==0&&(i&=~b.UNICODE_GROUPS);let a=new e(t,n);return a.re2Input=Tr.compileImpl(r,i,(n&e.LONGEST_MATCH)!==0),a}static matches(t,n){return e.compile(t).matcher(n).matches()}static initTest(t,n,r){if(t==null)throw Error(`pattern is null`);if(r==null)throw Error(`re2 is null`);let i=new e(t,n);return i.re2Input=r,i}constructor(e,t){this.patternInput=e,this.flagsInput=t}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(e){return this.matcher(e).matches()}matcher(e){return Array.isArray(e)&&(e=zn.utf8(e)),new Wn(this,e)}split(e,t=0){let n=this.matcher(e),r=[],i=0,a=0;for(;n.find();){if(a===0&&n.end()===0){a=n.end();continue}if(t>0&&r.length===t-1)break;if(a===n.start()){if(t===0){i+=1,a=n.end();continue}}else for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.start())),a=n.end()}if(t===0&&a!==n.inputLength()){for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.inputLength()))}return(t!==0||r.length===0)&&r.push(n.substring(a,n.inputLength())),r}toString(){return this.patternInput}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(e){return this===e?!0:e===null||this.constructor!==e.constructor?!1:this.flagsInput===e.flagsInput&&this.patternInput===e.patternInput}},Dr=class{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?`uid:`+this.uid:`anonymous-user`}isEqual(e){return e.uid===this.uid}};Dr.UNAUTHENTICATED=new Dr(null),Dr.GOOGLE_CREDENTIALS=new Dr(`google-credentials-uid`),Dr.FIRST_PARTY=new Dr(`first-party-uid`),Dr.MOCK_USER=new Dr(`mock-user`);var Or=`12.15.0`;function kr(e){Or=e}var Ar=new Ve(`@firebase/firestore`);function jr(){return Ar.logLevel}function A(e,...t){if(Ar.logLevel<=v.DEBUG){let n=t.map(Pr);Ar.debug(`Firestore (${Or}): ${e}`,...n)}}function Mr(e,...t){if(Ar.logLevel<=v.ERROR){let n=t.map(Pr);Ar.error(`Firestore (${Or}): ${e}`,...n)}}function Nr(e,...t){if(Ar.logLevel<=v.WARN){let n=t.map(Pr);Ar.warn(`Firestore (${Or}): ${e}`,...n)}}function Pr(e){if(typeof e==`string`)return e;try{return function(e){return JSON.stringify(e)}(e)}catch{return e}}function j(e,t,n){let r=`Unexpected state`;typeof t==`string`?r=t:n=t,Fr(e,r,n)}function Fr(e,t,n){let r=`FIRESTORE (${Or}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(n!==void 0)try{r+=` CONTEXT: `+JSON.stringify(n)}catch{r+=` CONTEXT: `+n}throw Mr(r),Error(r)}function M(e,t,n,r){let i=`Unexpected state`;typeof n==`string`?i=n:r=n,e||Fr(t,i,r)}function N(e,t){return e}var P={OK:`ok`,CANCELLED:`cancelled`,UNKNOWN:`unknown`,INVALID_ARGUMENT:`invalid-argument`,DEADLINE_EXCEEDED:`deadline-exceeded`,NOT_FOUND:`not-found`,ALREADY_EXISTS:`already-exists`,PERMISSION_DENIED:`permission-denied`,UNAUTHENTICATED:`unauthenticated`,RESOURCE_EXHAUSTED:`resource-exhausted`,FAILED_PRECONDITION:`failed-precondition`,ABORTED:`aborted`,OUT_OF_RANGE:`out-of-range`,UNIMPLEMENTED:`unimplemented`,INTERNAL:`internal`,UNAVAILABLE:`unavailable`,DATA_LOSS:`data-loss`},F=class extends me{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}},Ir=class{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}},Lr=class{constructor(e,t){this.user=t,this.type=`OAuth`,this.headers=new Map,this.headers.set(`Authorization`,`Bearer ${e}`)}},Rr=class{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(Dr.UNAUTHENTICATED)))}shutdown(){}},zr=class{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}},Br=class{constructor(e){this.t=e,this.currentUser=Dr.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){M(this.o===void 0,42304);let n=this.i,r=e=>this.i===n?Promise.resolve():(n=this.i,t(e)),i=new Ir;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new Ir,e.enqueueRetryable((()=>r(this.currentUser)))};let a=()=>{let t=i;e.enqueueRetryable((async()=>{await t.promise,await r(this.currentUser)}))},o=e=>{A(`FirebaseAuthCredentialsProvider`,`Auth detected`),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit((e=>o(e))),setTimeout((()=>{if(!this.auth){let e=this.t.getImmediate({optional:!0});e?o(e):(A(`FirebaseAuthCredentialsProvider`,`Auth not yet detected`),i.resolve(),i=new Ir)}}),0),a()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((t=>this.i===e?t?(M(typeof t.accessToken==`string`,31837,{l:t}),new Lr(t.accessToken,this.currentUser)):null:(A(`FirebaseAuthCredentialsProvider`,`getToken aborted due to token change.`),this.getToken()))):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){let e=this.auth&&this.auth.getUid();return M(e===null||typeof e==`string`,2055,{h:e}),new Dr(e)}},Vr=class{constructor(e,t,n){this.T=e,this.P=t,this.R=n,this.type=`FirstParty`,this.user=Dr.FIRST_PARTY,this.I=new Map}A(){return this.R?this.R():null}get headers(){this.I.set(`X-Goog-AuthUser`,this.T);let e=this.A();return e&&this.I.set(`Authorization`,e),this.P&&this.I.set(`X-Goog-Iam-Authorization-Token`,this.P),this.I}},Hr=class{constructor(e,t,n){this.T=e,this.P=t,this.R=n}getToken(){return Promise.resolve(new Vr(this.T,this.P,this.R))}start(e,t){e.enqueueRetryable((()=>t(Dr.FIRST_PARTY)))}shutdown(){}invalidateToken(){}},Ur=class{constructor(e){this.value=e,this.type=`AppCheck`,this.headers=new Map,e&&e.length>0&&this.headers.set(`x-firebase-appcheck`,this.value)}},Wr=class{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,y(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){M(this.o===void 0,3512);let n=e=>{e.error!=null&&A(`FirebaseAppCheckTokenProvider`,`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);let n=e.token!==this.m;return this.m=e.token,A(`FirebaseAppCheckTokenProvider`,`Received ${n?`new`:`existing`} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable((()=>n(t)))};let r=e=>{A(`FirebaseAppCheckTokenProvider`,`AppCheck detected`),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((e=>r(e))),setTimeout((()=>{if(!this.appCheck){let e=this.V.getImmediate({optional:!0});e?r(e):A(`FirebaseAppCheckTokenProvider`,`AppCheck not yet detected`)}}),0)}getToken(){if(this.p)return Promise.resolve(new Ur(this.p));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((e=>e?(M(typeof e.token==`string`,44558,{tokenResult:e}),this.m=e.token,new Ur(e.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}};function Gr(e){let t=typeof self<`u`&&(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&&typeof t.getRandomValues==`function`)t.getRandomValues(n);else for(let t=0;t<e;t++)n[t]=Math.floor(256*Math.random());return n}var Kr=class{static newId(){let e=``;for(;e.length<20;){let t=Gr(40);for(let n=0;n<t.length;++n)e.length<20&&t[n]<248&&(e+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(t[n]%62))}return e}};function I(e,t){return e<t?-1:+(e>t)}function qr(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e.charAt(r),i=t.charAt(r);if(n!==i)return Xr(n)===Xr(i)?I(n,i):Xr(n)?1:-1}return I(e.length,t.length)}var Jr=55296,Yr=57343;function Xr(e){let t=e.charCodeAt(0);return t>=Jr&&t<=Yr}function Zr(e,t,n){return e.length===t.length&&e.every(((e,r)=>n(e,t[r])))}var Qr=`__name__`,$r=class e{constructor(e,t,n){t===void 0?t=0:t>e.length&&j(637,{offset:t,range:e.length}),n===void 0?n=e.length-t:n>e.length-t&&j(1746,{length:n,range:e.length-t}),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(t){return e.comparator(this,t)===0}child(t){let n=this.segments.slice(this.offset,this.limit());return t instanceof e?t.forEach((e=>{n.push(e)})):n.push(t),this.construct(n)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,n){let r=Math.min(t.length,n.length);for(let i=0;i<r;i++){let r=e.compareSegments(t.get(i),n.get(i));if(r!==0)return r}return I(t.length,n.length)}static compareSegments(t,n){let r=e.isNumericId(t),i=e.isNumericId(n);return r&&!i?-1:!r&&i?1:r&&i?e.extractNumericId(t).compare(e.extractNumericId(n)):qr(t,n)}static isNumericId(e){return e.startsWith(`__id`)&&e.endsWith(`__`)}static extractNumericId(e){return Cn.fromString(e.substring(4,e.length-2))}},L=class e extends $r{construct(t,n,r){return new e(t,n,r)}canonicalString(){return this.toArray().join(`/`)}toString(){return this.canonicalString()}toStringWithLeadingSlash(){return`/${this.canonicalString()}`}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join(`/`)}static fromString(...t){let n=[];for(let e of t){if(e.indexOf(`//`)>=0)throw new F(P.INVALID_ARGUMENT,`Invalid segment (${e}). Paths must not contain // in them.`);n.push(...e.split(`/`).filter((e=>e.length>0)))}return new e(n)}static emptyPath(){return new e([])}},ei=/^[_a-zA-Z][_a-zA-Z0-9]*$/,ti=class e extends $r{construct(t,n,r){return new e(t,n,r)}static isValidIdentifier(e){return ei.test(e)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`"),e.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(`.`)}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===Qr}static keyField(){return new e([Qr])}static fromServerFormat(t){let n=[],r=``,i=0,a=()=>{if(r.length===0)throw new F(P.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);n.push(r),r=``},o=!1;for(;i<t.length;){let e=t[i];if(e===`\\`){if(i+1===t.length)throw new F(P.INVALID_ARGUMENT,`Path has trailing escape character: `+t);let e=t[i+1];if(e!==`\\`&&e!==`.`&&e!=="`")throw new F(P.INVALID_ARGUMENT,`Path has invalid escape sequence: `+t);r+=e,i+=2}else e==="`"?(o=!o,i++):e!==`.`||o?(r+=e,i++):(a(),i++)}if(a(),o)throw new F(P.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)}static emptyPath(){return new e([])}},R=class e{constructor(e){this.path=e}static fromPath(t){return new e(L.fromString(t))}static fromName(t){return new e(L.fromString(t).popFirst(5))}static empty(){return new e(L.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&L.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return L.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(t){return new e(new L(t.slice()))}};function ni(e,t,n){if(!n)throw new F(P.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function ri(e,t,n,r){if(!0===t&&!0===r)throw new F(P.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function ii(e){if(!R.isDocumentKey(e))throw new F(P.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function ai(e){if(R.isDocumentKey(e))throw new F(P.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function oi(e){return typeof e==`object`&&!!e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}function si(e){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e==`string`)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if(typeof e==`number`||typeof e==`boolean`)return``+e;if(typeof e==`object`){if(e instanceof Array)return`an array`;{let t=function(e){return e.constructor?e.constructor.name:null}(e);return t?`a custom ${t} object`:`an object`}}return typeof e==`function`?`a function`:j(12329,{type:typeof e})}function ci(e,t){if(`_delegate`in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new F(P.INVALID_ARGUMENT,`Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?`);{let n=si(e);throw new F(P.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function li(e,t){if(t<=0)throw new F(P.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}function ui(e,t){let n={typeString:e};return t&&(n.value=t),n}function di(e,t){if(!oi(e))throw new F(P.INVALID_ARGUMENT,`JSON must be an object`);let n;for(let r in t)if(t[r]){let i=t[r].typeString,a=`value`in t[r]?{value:t[r].value}:void 0;if(!(r in e)){n=`JSON missing required field: '${r}'`;break}let o=e[r];if(i&&typeof o!==i){n=`JSON field '${r}' must be a ${i}.`;break}if(a!==void 0&&o!==a.value){n=`Expected '${r}' field to equal '${a.value}'`;break}}if(n)throw new F(P.INVALID_ARGUMENT,n);return!0}var fi=-62135596800,pi=1e6,mi=class e{static now(){return e.fromMillis(Date.now())}static fromDate(t){return e.fromMillis(t.getTime())}static fromMillis(t){let n=Math.floor(t/1e3);return new e(n,Math.floor((t-1e3*n)*pi))}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0||t>=1e9)throw new F(P.INVALID_ARGUMENT,`Timestamp nanoseconds out of range: `+t);if(e<fi||e>=253402300800)throw new F(P.INVALID_ARGUMENT,`Timestamp seconds out of range: `+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/pi}_compareTo(e){return this.seconds===e.seconds?I(this.nanoseconds,e.nanoseconds):I(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:e._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(t){if(di(t,e._jsonSchema))return new e(t.seconds,t.nanoseconds)}valueOf(){let e=this.seconds-fi;return String(e).padStart(12,`0`)+`.`+String(this.nanoseconds).padStart(9,`0`)}};mi._jsonSchemaVersion=`firestore/timestamp/1.0`,mi._jsonSchema={type:ui(`string`,mi._jsonSchemaVersion),seconds:ui(`number`),nanoseconds:ui(`number`)};var z=class e{static fromTimestamp(t){return new e(t)}static min(){return new e(new mi(0,0))}static max(){return new e(new mi(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}},hi=-1,gi=class{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}};gi.UNKNOWN_ID=-1;function _i(e,t){let n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1;return new yi(z.fromTimestamp(r===1e9?new mi(n+1,0):new mi(n,r)),R.empty(),t)}function vi(e){return new yi(e.readTime,e.key,hi)}var yi=class e{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new e(z.min(),R.empty(),hi)}static max(){return new e(z.max(),R.empty(),hi)}};function bi(e,t){let n=e.readTime.compareTo(t.readTime);return n===0?(n=R.comparator(e.documentKey,t.documentKey),n===0?I(e.largestBatchId,t.largestBatchId):n):n}var xi=`The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.`,Si=class{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}};async function Ci(e){if(e.code!==P.FAILED_PRECONDITION||e.message!==xi)throw e;A(`LocalStore`,`Unexpectedly lost primary lease`)}var B=class e{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(t,n){return this.callbackAttached&&j(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(t,this.result):new e(((e,r)=>{this.nextCallback=n=>{this.wrapSuccess(t,n).next(e,r)},this.catchCallback=t=>{this.wrapFailure(n,t).next(e,r)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(t){try{let n=t();return n instanceof e?n:e.resolve(n)}catch(t){return e.reject(t)}}wrapSuccess(t,n){return t?this.wrapUserFunction((()=>t(n))):e.resolve(n)}wrapFailure(t,n){return t?this.wrapUserFunction((()=>t(n))):e.reject(n)}static resolve(t){return new e(((e,n)=>{e(t)}))}static reject(t){return new e(((e,n)=>{n(t)}))}static waitFor(t){return new e(((e,n)=>{let r=0,i=0,a=!1;t.forEach((t=>{++r,t.next((()=>{++i,a&&i===r&&e()}),(e=>n(e)))})),a=!0,i===r&&e()}))}static or(t){let n=e.resolve(!1);for(let r of t)n=n.next((t=>t?e.resolve(t):r()));return n}static forEach(e,t){let n=[];return e.forEach(((e,r)=>{n.push(t.call(this,e,r))})),this.waitFor(n)}static mapArray(t,n){return new e(((e,r)=>{let i=t.length,a=Array(i),o=0;for(let s=0;s<i;s++){let c=s;n(t[c]).next((t=>{a[c]=t,++o,o===i&&e(a)}),(e=>r(e)))}}))}static doWhile(t,n){return new e(((e,r)=>{let i=()=>{!0===t()?n().next((()=>{i()}),r):e()};i()}))}};function wi(e){let t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(`.`).slice(0,2).join(`.`):`-1`;return Number(n)}function Ti(e){return e.name===`IndexedDbTransactionError`}var Ei=class{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.ae(e),this.ue=e=>t.writeSequenceNumber(e))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this.ue&&this.ue(e),e}};Ei.ce=-1;var Di=-1;function Oi(e){return e==null}function ki(e){return e===0&&1/e==-1/0}function Ai(e){return typeof e==`number`&&Number.isInteger(e)&&!ki(e)&&e<=2**53-1&&e>=-(2**53-1)}function ji(e){return typeof e==`string`}var Mi=``;function Ni(e){let t=``;for(let n=0;n<e.length;n++)t.length>0&&(t=Fi(t)),t=Pi(e.get(n),t);return Fi(t)}function Pi(e,t){let n=t,r=e.length;for(let t=0;t<r;t++){let r=e.charAt(t);switch(r){case`\0`:n+=``;break;case Mi:n+=``;break;default:n+=r}}return n}function Fi(e){return e+``}var V=class e{constructor(e,t){this.comparator=e,this.root=t||Li.EMPTY}insert(t,n){return new e(this.comparator,this.root.insert(t,n,this.comparator).copy(null,null,Li.BLACK,null,null))}remove(t){return new e(this.comparator,this.root.remove(t,this.comparator).copy(null,null,Li.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let n=this.comparator(e,t.key);if(n===0)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){let r=this.comparator(e,n.key);if(r===0)return t+n.left.size;r<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(){let e=[];return this.inorderTraversal(((t,n)=>(e.push(`${t}:${n}`),!1))),`{${e.join(`, `)}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Ii(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Ii(this.root,e,this.comparator,!1)}getReverseIterator(){return new Ii(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Ii(this.root,e,this.comparator,!0)}},Ii=class{constructor(e,t,n,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?n(e.key,t):1,t&&r&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}},Li=class e{constructor(t,n,r,i,a){this.key=t,this.value=n,this.color=r??e.RED,this.left=i??e.EMPTY,this.right=a??e.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,n,r,i,a){return new e(t??this.key,n??this.value,r??this.color,i??this.left,a??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 r=this,i=n(e,r.key);return r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):i===0?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n)),r.fixUp()}removeMin(){if(this.left.isEmpty())return e.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,n){let r,i=this;if(n(t,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(t,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),n(t,i.key)===0){if(i.right.isEmpty())return e.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,n))}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(){let t=this.copy(null,null,e.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){let t=this.copy(null,null,e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){let 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(){return 2**this.check()<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw j(43730,{key:this.key,value:this.value});if(this.right.isRed())throw j(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw j(27949);return e+ +!this.isRed()}};Li.EMPTY=null,Li.RED=!0,Li.BLACK=!1,Li.EMPTY=new class{constructor(){this.size=0}get key(){throw j(57766)}get value(){throw j(16141)}get color(){throw j(16727)}get left(){throw j(29726)}get right(){throw j(36894)}copy(e,t,n,r,i){return this}insert(e,t,n){return new Li(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}};var Ri=class e{constructor(e){this.comparator=e,this.data=new V(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal(((t,n)=>(e(t),!1)))}forEachInRange(e,t){let n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){let r=n.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}forEachWhile(e,t){let n;for(n=t===void 0?this.data.getIterator():this.data.getIteratorFrom(t);n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new zi(this.data.getIterator())}getIteratorFrom(e){return new zi(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(t){if(!(t instanceof e)||this.size!==t.size)return!1;let n=this.data.getIterator(),r=t.data.getIterator();for(;n.hasNext();){let e=n.getNext().key,t=r.getNext().key;if(this.comparator(e,t)!==0)return!1}return!0}toArray(){let e=[];return this.forEach((t=>{e.push(t)})),e}toString(){let e=[];return this.forEach((t=>e.push(t))),`SortedSet(`+e.toString()+`)`}copy(t){let n=new e(this.comparator);return n.data=t,n}},zi=class{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}},Bi=class e{constructor(e){this.fields=e,e.sort(ti.comparator)}static empty(){return new e([])}unionWith(t){let n=new Ri(ti.comparator);for(let e of this.fields)n=n.add(e);for(let e of t)n=n.add(e);return new e(n.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Zr(this.fields,e.fields,((e,t)=>e.isEqual(t)))}};function Vi(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function Hi(e,t){for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function Ui(e,t){let n=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(t(e[r],r,e));return n}function Wi(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}var Gi=class extends Error{constructor(){super(...arguments),this.name=`Base64DecodeError`}},Ki=class e{constructor(e){this.binaryString=e}static fromBase64String(t){return new e(function(e){try{return atob(e)}catch(e){throw typeof DOMException<`u`&&e instanceof DOMException?new Gi(`Invalid base64 string: `+e):e}}(t))}static fromUint8Array(t){return new e(function(e){let t=``;for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(t))}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(e){return btoa(e)}(this.binaryString)}toUint8Array(){return function(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return I(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}};Ki.EMPTY_BYTE_STRING=new Ki(``);var qi=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Ji(e){if(M(!!e,39018),typeof e==`string`){let t=0,n=qi.exec(e);if(M(!!n,46558,{timestamp:e}),n[1]){let e=n[1];e=(e+`000000000`).substr(0,9),t=Number(e)}let r=new Date(e);return{seconds:Math.floor(r.getTime()/1e3),nanos:t}}return{seconds:H(e.seconds),nanos:H(e.nanos)}}function H(e){return typeof e==`number`?e:typeof e==`string`?Number(e):0}function Yi(e){return typeof e==`string`?Ki.fromBase64String(e):Ki.fromUint8Array(e)}var Xi=`server_timestamp`,Zi=`__type__`,Qi=`__previous_value__`,$i=`__local_write_time__`;function ea(e){return(e?.mapValue?.fields||{})[Zi]?.stringValue===Xi}function ta(e){let t=e.mapValue.fields[Qi];return ea(t)?ta(t):t}function na(e){let t=Ji(e.mapValue.fields[$i].timestampValue);return new mi(t.seconds,t.nanos)}var ra=class{constructor(e,t,n,r,i,a,o,s,c,l,u){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=a,this.autoDetectLongPolling=o,this.longPollingOptions=s,this.useFetchStreams=c,this.isUsingEmulator=l,this.apiKey=u}},ia=`(default)`,aa=class e{constructor(e,t){this.projectId=e,this.database=t||ia}static empty(){return new e(``,``)}get isDefaultDatabase(){return this.database===ia}isEqual(t){return t instanceof e&&t.projectId===this.projectId&&t.database===this.database}};function oa(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,[`projectId`]))throw new F(P.INVALID_ARGUMENT,`"projectId" not provided in firebase.initializeApp.`);return new aa(e.options.projectId,t)}var sa=`__type__`,ca=`__max__`,la={mapValue:{fields:{__type__:{stringValue:ca}}}},ua=`__vector__`,da=`value`,fa={nullValue:`NULL_VALUE`},pa={booleanValue:!0},ma={booleanValue:!1};function ha(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?ea(e)?4:Fa(e)?9007199254740991:Ma(e)?10:11:j(28295,{value:e})}function ga(e,t,n){if(e===t)return!0;let r=ha(e);if(r!==ha(t))return!1;switch(r){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return na(e).isEqual(na(t));case 3:return function(e,t){if(typeof e.timestampValue==`string`&&typeof t.timestampValue==`string`&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;let n=Ji(e.timestampValue),r=Ji(t.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(e,t){return Yi(e.bytesValue).isEqual(Yi(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return H(e.geoPointValue.latitude)===H(t.geoPointValue.latitude)&&H(e.geoPointValue.longitude)===H(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t,n){if(`integerValue`in e&&`integerValue`in t)return H(e.integerValue)===H(t.integerValue);let r,i;if(`doubleValue`in e&&`doubleValue`in t)r=H(e.doubleValue),i=H(t.doubleValue);else{if(!n?.Ee)return!1;r=H(e.integerValue??e.doubleValue),i=H(t.integerValue??t.doubleValue)}return r===i?!!n?.he||ki(r)===ki(i):!!(n===void 0||n.Te)&&isNaN(r)&&isNaN(i)}(e,t,n);case 9:return Zr(e.arrayValue.values||[],t.arrayValue.values||[],((e,t)=>ga(e,t,n)));case 10:case 11:return function(e,t,n){let r=e.mapValue.fields||{},i=t.mapValue.fields||{};if(Vi(r)!==Vi(i))return!1;for(let e in r)if(r.hasOwnProperty(e)&&(i[e]===void 0||!ga(r[e],i[e],n)))return!1;return!0}(e,t,n);default:return j(52216,{left:e})}}function _a(e,t){return(e.values||[]).find((e=>ga(e,t)))!==void 0}function va(e,t){if(e===t)return 0;let n=ha(e),r=ha(t);if(n!==r)return I(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return I(e.booleanValue,t.booleanValue);case 2:return function(e,t){let n=H(e.integerValue||e.doubleValue),r=H(t.integerValue||t.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(e,t);case 3:return ya(e.timestampValue,t.timestampValue);case 4:return ya(na(e),na(t));case 5:return qr(e.stringValue,t.stringValue);case 6:return function(e,t){let n=Yi(e),r=Yi(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){let n=e.split(`/`),r=t.split(`/`);for(let e=0;e<n.length&&e<r.length;e++){let t=I(n[e],r[e]);if(t!==0)return t}return I(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){let n=I(H(e.latitude),H(t.latitude));return n===0?I(H(e.longitude),H(t.longitude)):n}(e.geoPointValue,t.geoPointValue);case 9:return ba(e.arrayValue,t.arrayValue);case 10:return function(e,t){let n=e.fields||{},r=t.fields||{},i=n[da]?.arrayValue,a=r[da]?.arrayValue,o=I(i?.values?.length||0,a?.values?.length||0);return o===0?ba(i,a):o}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===la.mapValue&&t===la.mapValue)return 0;if(e===la.mapValue)return 1;if(t===la.mapValue)return-1;let n=e.fields||{},r=Object.keys(n),i=t.fields||{},a=Object.keys(i);r.sort(),a.sort();for(let e=0;e<r.length&&e<a.length;++e){let t=qr(r[e],a[e]);if(t!==0)return t;let o=va(n[r[e]],i[a[e]]);if(o!==0)return o}return I(r.length,a.length)}(e.mapValue,t.mapValue);default:throw j(23264,{Pe:n})}}function ya(e,t){if(typeof e==`string`&&typeof t==`string`&&e.length===t.length)return I(e,t);let n=Ji(e),r=Ji(t),i=I(n.seconds,r.seconds);return i===0?I(n.nanos,r.nanos):i}function ba(e,t){let n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){let t=va(n[e],r[e]);if(t!==void 0&&t!==0)return t}return I(n.length,r.length)}function xa(e){return Sa(e)}function Sa(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){let t=Ji(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):`stringValue`in e?e.stringValue:`bytesValue`in e?function(e){return Yi(e).toBase64()}(e.bytesValue):`referenceValue`in e?function(e){return R.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(let r of e.values||[])n?n=!1:t+=`,`,t+=Sa(r);return t+`]`}(e.arrayValue):`mapValue`in e?function(e){let t=Object.keys(e.fields||{}).sort(),n=`{`,r=!0;for(let i of t)r?r=!1:n+=`,`,n+=`${i}:${Sa(e.fields[i])}`;return n+`}`}(e.mapValue):j(61005,{value:e})}function Ca(e){switch(ha(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let t=ta(e);return t?16+Ca(t):16;case 5:return 2*e.stringValue.length;case 6:return Yi(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return function(e){return(e.values||[]).reduce(((e,t)=>e+Ca(t)),0)}(e.arrayValue);case 10:case 11:return function(e){let t=0;return Hi(e.fields,((e,n)=>{t+=e.length+Ca(n)})),t}(e.mapValue);default:throw j(13486,{value:e})}}function wa(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Ta(e){return!!e&&`integerValue`in e}function Ea(e){return!!e&&`doubleValue`in e}function Da(e){return Ta(e)||Ea(e)}function Oa(e){return!!e&&`arrayValue`in e}function ka(e){return!!e&&`nullValue`in e}function Aa(e){return!!e&&`doubleValue`in e&&isNaN(Number(e.doubleValue))}function ja(e){return!!e&&`mapValue`in e}function Ma(e){return(e?.mapValue?.fields||{})[sa]?.stringValue===ua}function Na(e){return(e?.mapValue?.fields||{})[da]?.arrayValue}function Pa(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&typeof e.timestampValue==`object`)return{timestampValue:{...e.timestampValue}};if(e.mapValue){let t={mapValue:{fields:{}}};return Hi(e.mapValue.fields,((e,n)=>t.mapValue.fields[e]=Pa(n))),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=Pa(e.arrayValue.values[n]);return t}return{...e}}function Fa(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===ca}var Ia=class e{constructor(e){this.value=e}static empty(){return new e({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)],!ja(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Pa(t)}setAll(e){let t=ti.emptyPath(),n={},r=[];e.forEach(((e,i)=>{if(!t.isImmediateParentOf(i)){let e=this.getFieldsMap(t);this.applyChanges(e,n,r),n={},r=[],t=i.popLast()}e?n[i.lastSegment()]=Pa(e):r.push(i.lastSegment())}));let i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){let t=this.field(e.popLast());ja(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return ga(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 r=t.mapValue.fields[e.get(n)];ja(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){Hi(t,((t,n)=>e[t]=n));for(let t of n)delete e[t]}clone(){return new e(Pa(this.value))}};function La(e){let t=[];return Hi(e.fields,((e,n)=>{let r=new ti([e]);if(ja(n)){let e=La(n.mapValue).fields;if(e.length===0)t.push(r);else for(let n of e)t.push(r.child(n))}else t.push(r)})),new Bi(t)}function Ra(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:ki(t)?`-0`:t}}function za(e){return{integerValue:``+e}}function Ba(e,t,n){return Number.isInteger(t)&&n?.preferIntegers||Ai(t)?za(t):Ra(e,t)}var Va=class{constructor(){this._=void 0}};function Ha(e,t,n){return e instanceof Ga?function(e,t){let n={fields:{[Zi]:{stringValue:Xi},[$i]:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&ea(t)&&(t=ta(t)),t&&(n.fields[Qi]=t),{mapValue:n}}(n,t):e instanceof Ka?qa(e,t):e instanceof Ja?Ya(e,t):e instanceof Za?function(e,t){let n=Wa(e,t),r=to(n)+to(e.Re);return Ta(n)&&Ta(e.Re)?za(r):Ra(e.serializer,r)}(e,t):e instanceof Qa?function(e,t){return eo(e,t,Math.min)}(e,t):e instanceof $a?function(e,t){return eo(e,t,Math.max)}(e,t):void 0}function Ua(e,t,n){return e instanceof Ka?qa(e,t):e instanceof Ja?Ya(e,t):n}function Wa(e,t){return e instanceof Za?Da(t)?t:{integerValue:0}:null}var Ga=class extends Va{},Ka=class extends Va{constructor(e){super(),this.elements=e}};function qa(e,t){let n=no(t);for(let t of e.elements)n.some((e=>ga(e,t)))||n.push(t);return{arrayValue:{values:n}}}var Ja=class extends Va{constructor(e){super(),this.elements=e}};function Ya(e,t){let n=no(t);for(let t of e.elements)n=n.filter((e=>!ga(e,t)));return{arrayValue:{values:n}}}var Xa=class extends Va{constructor(e,t){super(),this.serializer=e,this.Re=t}},Za=class extends Xa{},Qa=class extends Xa{},$a=class extends Xa{};function eo(e,t,n){if(!Da(t))return e.Re;let r=n(to(t),to(e.Re));return Ta(t)&&Ta(e.Re)?za(r):Ra(e.serializer,r)}function to(e){return H(e.integerValue||e.doubleValue)}function no(e){return Oa(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}function ro(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof Ka&&t instanceof Ka||e instanceof Ja&&t instanceof Ja?Zr(e.elements,t.elements,ga):e instanceof Za&&t instanceof Za||e instanceof Qa&&t instanceof Qa||e instanceof $a&&t instanceof $a?ga(e.Re,t.Re):e instanceof Ga&&t instanceof Ga}(e.transform,t.transform)}var io=class{constructor(e,t){this.version=e,this.transformResults=t}},ao=class e{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new e}static exists(t){return new e(void 0,t)}static updateTime(t){return new e(t)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}};function oo(e,t){return e.updateTime===void 0?e.exists===void 0||e.exists===t.isFoundDocument():t.isFoundDocument()&&t.version.isEqual(e.updateTime)}var so=class{};function co(e,t){if(!e.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return e.isNoDocument()?new yo(e.key,ao.none()):new mo(e.key,e.data,ao.none());{let n=e.data,r=Ia.empty(),i=new Ri(ti.comparator);for(let e of t.fields)if(!i.has(e)){let t=n.field(e);t===null&&e.length>1&&(e=e.popLast(),t=n.field(e)),t===null?r.delete(e):r.set(e,t),i=i.add(e)}return new ho(e.key,r,new Bi(i.toArray()),ao.none())}}function lo(e,t,n){e instanceof mo?function(e,t,n){let r=e.value.clone(),i=_o(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof ho?function(e,t,n){if(!oo(e.precondition,t))return void t.convertToUnknownDocument(n.version);let r=_o(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(go(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(e,t,n):function(e,t,n){t.convertToNoDocument(n.version).setHasCommittedMutations()}(0,t,n)}function uo(e,t,n,r){return e instanceof mo?function(e,t,n,r){if(!oo(e.precondition,t))return n;let i=e.value.clone(),a=vo(e.fieldTransforms,r,t);return i.setAll(a),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof ho?function(e,t,n,r){if(!oo(e.precondition,t))return n;let i=vo(e.fieldTransforms,r,t),a=t.data;return a.setAll(go(e)),a.setAll(i),t.convertToFoundDocument(t.version,a).setHasLocalMutations(),n===null?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map((e=>e.field)))}(e,t,n,r):function(e,t,n){return oo(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function fo(e,t){let n=null;for(let r of e.fieldTransforms){let e=t.data.field(r.field),i=Wa(r.transform,e||null);i!=null&&(n===null&&(n=Ia.empty()),n.set(r.field,i))}return n||null}function po(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&!!function(e,t){return e===void 0&&t===void 0||!(!e||!t)&&Zr(e,t,((e,t)=>ro(e,t)))}(e.fieldTransforms,t.fieldTransforms)&&(e.type===0?e.value.isEqual(t.value):e.type!==1||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}var mo=class extends so{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}},ho=class extends so{constructor(e,t,n,r,i=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=r,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}};function go(e){let t=new Map;return e.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){let r=e.data.field(n);t.set(n,r)}})),t}function _o(e,t,n){let r=new Map;M(e.length===n.length,32656,{Ie:n.length,Ae:e.length});for(let i=0;i<n.length;i++){let a=e[i],o=a.transform,s=t.data.field(a.field);r.set(a.field,Ua(o,s,n[i]))}return r}function vo(e,t,n){let r=new Map;for(let i of e){let e=i.transform,a=n.data.field(i.field);r.set(i.field,Ha(e,a,t))}return r}var yo=class extends so{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}},bo=class extends so{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}},xo=class{constructor(e,t,n){this.alias=e,this.aggregateType=t,this.fieldPath=n}},So=class{constructor(e,t){this.position=e,this.inclusive=t}};function Co(e,t,n){let r=0;for(let i=0;i<e.position.length;i++){let a=t[i],o=e.position[i];if(r=a.field.isKeyField()?R.comparator(R.fromName(o.referenceValue),n.key):va(o,n.data.field(a.field)),a.dir===`desc`&&(r*=-1),r!==0)break}return r}function wo(e,t){if(e===null)return t===null;if(t===null||e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!ga(e.position[n],t.position[n]))return!1;return!0}var To=class{},Eo=class e extends To{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(t,n,r){return t.isKeyField()?n===`in`||n===`not-in`?this.createKeyFieldInFilter(t,n,r):new Po(t,n,r):n===`array-contains`?new Ro(t,r):n===`in`?new zo(t,r):n===`not-in`?new Bo(t,r):n===`array-contains-any`?new Vo(t,r):new e(t,n,r)}static createKeyFieldInFilter(e,t,n){return t===`in`?new Fo(e,n):new Io(e,n)}matches(e){let t=e.data.field(this.field);return this.op===`!=`?t!==null&&t.nullValue===void 0&&this.matchesComparison(va(t,this.value)):t!==null&&ha(this.value)===ha(t)&&this.matchesComparison(va(t,this.value))}matchesComparison(e){switch(this.op){case`<`:return e<0;case`<=`:return e<=0;case`==`:return e===0;case`!=`:return e!==0;case`>`:return e>0;case`>=`:return e>=0;default:return j(47266,{operator:this.op})}}isInequality(){return[`<`,`<=`,`>`,`>=`,`!=`,`not-in`].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}},Do=class e extends To{constructor(e,t){super(),this.filters=e,this.op=t,this.Ve=null}static create(t,n){return new e(t,n)}matches(e){return Oo(this)?this.filters.find((t=>!t.matches(e)))===void 0:this.filters.find((t=>t.matches(e)))!==void 0}getFlattenedFilters(){return this.Ve!==null||(this.Ve=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.Ve}getFilters(){return Object.assign([],this.filters)}};function Oo(e){return e.op===`and`}function ko(e){return Ao(e)&&Oo(e)}function Ao(e){for(let t of e.filters)if(t instanceof Do)return!1;return!0}function jo(e){if(e instanceof Eo)return e.field.canonicalString()+e.op.toString()+xa(e.value);if(ko(e))return e.filters.map((e=>jo(e))).join(`,`);{let t=e.filters.map((e=>jo(e))).join(`,`);return`${e.op}(${t})`}}function Mo(e,t){return e instanceof Eo?function(e,t){return t instanceof Eo&&e.op===t.op&&e.field.isEqual(t.field)&&ga(e.value,t.value)}(e,t):e instanceof Do?function(e,t){return t instanceof Do&&e.op===t.op&&e.filters.length===t.filters.length?e.filters.reduce(((e,n,r)=>e&&Mo(n,t.filters[r])),!0):!1}(e,t):void j(19439)}function No(e){return e instanceof Eo?function(e){return`${e.field.canonicalString()} ${e.op} ${xa(e.value)}`}(e):e instanceof Do?function(e){return e.op.toString()+` {`+e.getFilters().map(No).join(` ,`)+`}`}(e):`Filter`}var Po=class extends Eo{constructor(e,t,n){super(e,t,n),this.key=R.fromName(n.referenceValue)}matches(e){let t=R.comparator(e.key,this.key);return this.matchesComparison(t)}},Fo=class extends Eo{constructor(e,t){super(e,`in`,t),this.keys=Lo(`in`,t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}},Io=class extends Eo{constructor(e,t){super(e,`not-in`,t),this.keys=Lo(`not-in`,t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}};function Lo(e,t){return(t.arrayValue?.values||[]).map((e=>R.fromName(e.referenceValue)))}var Ro=class extends Eo{constructor(e,t){super(e,`array-contains`,t)}matches(e){let t=e.data.field(this.field);return Oa(t)&&_a(t.arrayValue,this.value)}},zo=class extends Eo{constructor(e,t){super(e,`in`,t)}matches(e){let t=e.data.field(this.field);return t!==null&&_a(this.value.arrayValue,t)}},Bo=class extends Eo{constructor(e,t){super(e,`not-in`,t)}matches(e){if(_a(this.value.arrayValue,{nullValue:`NULL_VALUE`}))return!1;let t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!_a(this.value.arrayValue,t)}},Vo=class extends Eo{constructor(e,t){super(e,`array-contains-any`,t)}matches(e){let t=e.data.field(this.field);return!(!Oa(t)||!t.arrayValue.values)&&t.arrayValue.values.some((e=>_a(this.value.arrayValue,e)))}},Ho=class{constructor(e,t=`asc`){this.field=e,this.dir=t}};function Uo(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}var Wo=class e{constructor(e,t,n,r,i,a,o){this.key=e,this.documentType=t,this.version=n,this.readTime=r,this.createTime=i,this.data=a,this.documentState=o}static newInvalidDocument(t){return new e(t,0,z.min(),z.min(),z.min(),Ia.empty(),0)}static newFoundDocument(t,n,r,i){return new e(t,1,n,z.min(),r,i,0)}static newNoDocument(t,n){return new e(t,2,n,z.min(),z.min(),Ia.empty(),0)}static newUnknownDocument(t,n){return new e(t,3,n,z.min(),z.min(),Ia.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(z.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Ia.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Ia.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=z.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(t){return t instanceof e&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new e(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}})`}},Go=class{constructor(e,t=null,n=[],r=[],i=null,a=null,o=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=a,this.endAt=o,this.de=null}};function Ko(e,t=null,n=[],r=[],i=null,a=null,o=null){return new Go(e,t,n,r,i,a,o)}function qo(e){let t=N(e);if(t.de===null){let e=t.path.canonicalString();t.collectionGroup!==null&&(e+=`|cg:`+t.collectionGroup),e+=`|f:`,e+=t.filters.map((e=>jo(e))).join(`,`),e+=`|ob:`,e+=t.orderBy.map((e=>function(e){return e.field.canonicalString()+e.dir}(e))).join(`,`),Oi(t.limit)||(e+=`|l:`,e+=t.limit),t.startAt&&(e+=`|lb:`,e+=t.startAt.inclusive?`b:`:`a:`,e+=t.startAt.position.map((e=>xa(e))).join(`,`)),t.endAt&&(e+=`|ub:`,e+=t.endAt.inclusive?`a:`:`b:`,e+=t.endAt.position.map((e=>xa(e))).join(`,`)),t.de=e}return t.de}function Jo(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let n=0;n<e.orderBy.length;n++)if(!Uo(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(!Mo(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!wo(e.startAt,t.startAt)&&wo(e.endAt,t.endAt)}function Yo(e){return!!e.isCorePipeline}function Xo(e){return!!e.path&&R.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}var Zo=class{constructor(e,t=null,n=[],r=[],i=null,a=`F`,o=null,s=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=a,this.startAt=o,this.endAt=s,this.fe=null,this.me=null,this.pe=null,this.startAt,this.endAt}};function Qo(e,t,n,r,i,a,o,s){return new Zo(e,t,n,r,i,a,o,s)}function $o(e){return new Zo(e)}function es(e){return e.filters.length===0&&e.limit===null&&e.startAt==null&&e.endAt==null&&(e.explicitOrderBy.length===0||e.explicitOrderBy.length===1&&e.explicitOrderBy[0].field.isKeyField())}function ts(e){return R.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}function ns(e){return e.collectionGroup!==null}function rs(e){let t=N(e);if(t.fe===null){t.fe=[];let e=new Set;for(let n of t.explicitOrderBy)t.fe.push(n),e.add(n.field.canonicalString());let n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:`asc`;(function(e){let t=new Ri(ti.comparator);return e.filters.forEach((e=>{e.getFlattenedFilters().forEach((e=>{e.isInequality()&&(t=t.add(e.field))}))})),t})(t).forEach((r=>{e.has(r.canonicalString())||r.isKeyField()||t.fe.push(new Ho(r,n))})),e.has(ti.keyField().canonicalString())||t.fe.push(new Ho(ti.keyField(),n))}return t.fe}function is(e){let t=N(e);return t.me||=os(t,rs(e)),t.me}function as(e){let t=N(e);return t.pe||=os(t,e.explicitOrderBy),t.pe}function os(e,t){if(e.limitType===`F`)return Ko(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map((e=>{let t=e.dir===`desc`?`asc`:`desc`;return new Ho(e.field,t)}));let n=e.endAt?new So(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new So(e.startAt.position,e.startAt.inclusive):null;return Ko(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function ss(e,t){let n=e.filters.concat([t]);return new Zo(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function cs(e,t){let n=e.explicitOrderBy.concat([t]);return new Zo(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}function ls(e,t,n){return new Zo(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function us(e,t){return new Zo(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)}function ds(e,t){return Jo(is(e),is(t))&&e.limitType===t.limitType}function fs(e){return`Query(target=${function(e){let t=e.path.canonicalString();return e.collectionGroup!==null&&(t+=` collectionGroup=`+e.collectionGroup),e.filters.length>0&&(t+=`, filters: [${e.filters.map((e=>No(e))).join(`, `)}]`),Oi(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=>xa(e))).join(`,`)),e.endAt&&(t+=`, endAt: `,t+=e.endAt.inclusive?`a:`:`b:`,t+=e.endAt.position.map((e=>xa(e))).join(`,`)),`Target(${t})`}(is(e))}; limitType=${e.limitType})`}function ps(e,t){return t.isFoundDocument()&&function(e,t){let n=t.key.path;return e.collectionGroup===null?R.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n):t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n)}(e,t)&&function(e,t){for(let n of rs(e))if(!n.field.isKeyField()&&t.data.field(n.field)===null)return!1;return!0}(e,t)&&function(e,t){for(let n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&&function(e,t){return!(e.startAt&&!function(e,t,n){let r=Co(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,rs(e),t)||e.endAt&&!function(e,t,n){let r=Co(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,rs(e),t))}(e,t)}function ms(e){return(t,n)=>{let r=!1;for(let i of rs(e)){let e=hs(i,t,n);if(e!==0)return e;r||=i.field.isKeyField()}return 0}}function hs(e,t,n){let r=e.field.isKeyField()?R.comparator(t.key,n.key):function(e,t,n){let r=t.data.field(e),i=n.data.field(e);return r!==null&&i!==null?va(r,i):j(42886)}(e.field,t,n);switch(e.dir){case`asc`:return r;case`desc`:return-1*r;default:return j(19790,{direction:e.dir})}}var gs=class{constructor(e,t){this.count=e,this.unchangedNames=t}},_s,U;function vs(e){switch(e){case P.OK:return j(64938);case P.CANCELLED:case P.UNKNOWN:case P.DEADLINE_EXCEEDED:case P.RESOURCE_EXHAUSTED:case P.INTERNAL:case P.UNAVAILABLE:case P.UNAUTHENTICATED:return!1;case P.INVALID_ARGUMENT:case P.NOT_FOUND:case P.ALREADY_EXISTS:case P.PERMISSION_DENIED:case P.FAILED_PRECONDITION:case P.ABORTED:case P.OUT_OF_RANGE:case P.UNIMPLEMENTED:case P.DATA_LOSS:return!0;default:return j(15467,{code:e})}}function ys(e){if(e===void 0)return Mr(`GRPC error has no .code`),P.UNKNOWN;switch(e){case _s.OK:return P.OK;case _s.CANCELLED:return P.CANCELLED;case _s.UNKNOWN:return P.UNKNOWN;case _s.DEADLINE_EXCEEDED:return P.DEADLINE_EXCEEDED;case _s.RESOURCE_EXHAUSTED:return P.RESOURCE_EXHAUSTED;case _s.INTERNAL:return P.INTERNAL;case _s.UNAVAILABLE:return P.UNAVAILABLE;case _s.UNAUTHENTICATED:return P.UNAUTHENTICATED;case _s.INVALID_ARGUMENT:return P.INVALID_ARGUMENT;case _s.NOT_FOUND:return P.NOT_FOUND;case _s.ALREADY_EXISTS:return P.ALREADY_EXISTS;case _s.PERMISSION_DENIED:return P.PERMISSION_DENIED;case _s.FAILED_PRECONDITION:return P.FAILED_PRECONDITION;case _s.ABORTED:return P.ABORTED;case _s.OUT_OF_RANGE:return P.OUT_OF_RANGE;case _s.UNIMPLEMENTED:return P.UNIMPLEMENTED;case _s.DATA_LOSS:return P.DATA_LOSS;default:return j(39323,{code:e})}}(U=_s||={})[U.OK=0]=`OK`,U[U.CANCELLED=1]=`CANCELLED`,U[U.UNKNOWN=2]=`UNKNOWN`,U[U.INVALID_ARGUMENT=3]=`INVALID_ARGUMENT`,U[U.DEADLINE_EXCEEDED=4]=`DEADLINE_EXCEEDED`,U[U.NOT_FOUND=5]=`NOT_FOUND`,U[U.ALREADY_EXISTS=6]=`ALREADY_EXISTS`,U[U.PERMISSION_DENIED=7]=`PERMISSION_DENIED`,U[U.UNAUTHENTICATED=16]=`UNAUTHENTICATED`,U[U.RESOURCE_EXHAUSTED=8]=`RESOURCE_EXHAUSTED`,U[U.FAILED_PRECONDITION=9]=`FAILED_PRECONDITION`,U[U.ABORTED=10]=`ABORTED`,U[U.OUT_OF_RANGE=11]=`OUT_OF_RANGE`,U[U.UNIMPLEMENTED=12]=`UNIMPLEMENTED`,U[U.INTERNAL=13]=`INTERNAL`,U[U.UNAVAILABLE=14]=`UNAVAILABLE`,U[U.DATA_LOSS=15]=`DATA_LOSS`;var bs=class{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),n=this.inner[t];if(n!==void 0){for(let[t,r]of n)if(this.equalsFn(t,e))return r}}has(e){return this.get(e)!==void 0}set(e,t){let n=this.mapKeyFn(e),r=this.inner[n];if(r===void 0)return this.inner[n]=[[e,t]],void this.innerSize++;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],e))return void(r[n]=[e,t]);r.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),n=this.inner[t];if(n===void 0)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return n.length===1?delete this.inner[t]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(e){Hi(this.inner,((t,n)=>{for(let[t,r]of n)e(t,r)}))}isEmpty(){return Wi(this.inner)}size(){return this.innerSize}},xs=new V(R.comparator);function Ss(){return xs}var Cs=new V(R.comparator);function ws(...e){let t=Cs;for(let n of e)t=t.insert(n.key,n);return t}function Ts(e){let t=Cs;return e.forEach(((e,n)=>t=t.insert(e,n.overlayedDocument))),t}function Es(){return Os()}function Ds(){return Os()}function Os(){return new bs((e=>e.toString()),((e,t)=>e.isEqual(t)))}var ks=new V(R.comparator),As=new Ri(R.comparator);function W(...e){let t=As;for(let n of e)t=t.add(n);return t}var js=new Ri(I);function Ms(){return js}var Ns=null;function Ps(){return new TextEncoder}var Fs=new Cn([4294967295,4294967295],0);function Is(e){let t=Ps().encode(e),n=new wn;return n.update(t),new Uint8Array(n.digest())}function Ls(e){let t=new DataView(e.buffer),n=t.getUint32(0,!0),r=t.getUint32(4,!0),i=t.getUint32(8,!0),a=t.getUint32(12,!0);return[new Cn([n,r],0),new Cn([i,a],0)]}var Rs=class e{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new zs(`Invalid padding: ${t}`);if(n<0||e.length>0&&this.hashCount===0)throw new zs(`Invalid hash count: ${n}`);if(e.length===0&&t!==0)throw new zs(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.ye=Cn.fromNumber(this.ge)}we(e,t,n){let r=e.add(t.multiply(Cn.fromNumber(n)));return r.compare(Fs)===1&&(r=new Cn([r.getBits(0),r.getBits(1)],0)),r.modulo(this.ye).toNumber()}be(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.ge===0)return!1;let[t,n]=Ls(Is(e));for(let e=0;e<this.hashCount;e++){let r=this.we(t,n,e);if(!this.be(r))return!1}return!0}static create(t,n,r){let i=t%8==0?0:8-t%8,a=new e(new Uint8Array(Math.ceil(t/8)),i,n);return r.forEach((e=>a.insert(e))),a}insert(e){if(this.ge===0)return;let[t,n]=Ls(Is(e));for(let e=0;e<this.hashCount;e++){let r=this.we(t,n,e);this.ve(r)}}ve(e){let t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}},zs=class extends Error{constructor(){super(...arguments),this.name=`BloomFilterError`}},Bs=class e{constructor(e,t,n,r,i,a){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.augmentedDocumentUpdates=i,this.resolvedLimboDocuments=a}static createSynthesizedRemoteEventForCurrentChange(t,n,r){let i=new Map;return i.set(t,Vs.createSynthesizedTargetChangeForCurrentChange(t,n,r)),new e(z.min(),i,new V(I),Ss(),Ss(),W())}},Vs=class e{constructor(e,t,n,r,i){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(t,n,r){return new e(r,n,W(),W(),W())}},Hs=class{constructor(e,t,n,r){this.Se=e,this.removedTargetIds=t,this.key=n,this.De=r}},Us=class{constructor(e,t){this.targetId=e,this.xe=t}},Ws=class{constructor(e,t,n=Ki.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}},Gs=class{constructor(e){this.targetId=e,this.Ce=0,this.Fe=Ys(),this.Oe=Ki.EMPTY_BYTE_STRING,this.Me=!1,this.Ne=!0}get current(){return this.Me}get resumeToken(){return this.Oe}get Le(){return this.Ce!==0}get Be(){return this.Ne}Ue(e){e.approximateByteSize()>0&&(this.Ne=!0,this.Oe=e)}ke(){let e=W(),t=W(),n=W();return this.Fe.forEach(((r,i)=>{switch(i){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:j(38017,{changeType:i})}})),new Vs(this.Oe,this.Me,e,t,n)}qe(){this.Ne=!1,this.Fe=Ys()}$e(e,t){this.Ne=!0,this.Fe=this.Fe.insert(e,t)}Ke(e){this.Ne=!0,this.Fe=this.Fe.remove(e)}We(){this.Ce+=1}Qe(){--this.Ce,M(this.Ce>=0,3241,{Ce:this.Ce,targetId:this.targetId})}Ge(){this.Ne=!0,this.Me=!0}},Ks=`WatchChangeAggregator`,qs=class{constructor(e){this.ze=e,this.je=new Map,this.He=Ss(),this.Je=Js(),this.Ye=Ss(),this.Ze=Js(),this.Xe=new V(I)}et(e){for(let t of e.Se)e.De&&e.De.isFoundDocument()?this.tt(t,e.De):this.nt(t,e.key,e.De);for(let t of e.removedTargetIds)this.nt(t,e.key,e.De)}rt(e){this.forEachTarget(e,(t=>{let n=this.je.get(t);if(n)switch(e.state){case 0:this.it(t)&&n.Ue(e.resumeToken);break;case 1:n.Qe(),n.Le||n.qe(),n.Ue(e.resumeToken);break;case 2:n.Qe(),n.Le||this.removeTarget(t);break;case 3:this.it(t)&&(n.Ge(),n.Ue(e.resumeToken));break;case 4:this.it(t)&&(this.st(t),n.Ue(e.resumeToken));break;default:j(56790,{state:e.state})}else A(Ks,`handleTargetChange received targetChange for untracked target ID (${t}) with state (${e.state})`)}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.je.forEach(((e,n)=>{this.it(n)&&t(n)}))}_t(e){return Yo(e)?e.getPipelineSourceType()===`documents`&&e.getPipelineDocuments()?.length===1:Xo(e)}ot(e){let t=e.targetId,n=e.xe.count,r=this.ut(t);if(r){let i=r.target;if(this._t(i))if(n===0){let e=new R(Yo(i)?L.fromString(i.getPipelineDocuments()[0]):i.path);this.nt(t,e,Wo.newNoDocument(e,z.min()))}else M(n===1,20013,`Single document existence filter with count: `+n);else{let r=this.ct(t);if(r!==n){let n=this.lt(e),i=n?this.Et(n,e,r):1;if(i!==0){this.st(t);let e=i===2?`TargetPurposeExistenceFilterMismatchBloom`:`TargetPurposeExistenceFilterMismatch`;this.Xe=this.Xe.insert(t,e)}Ns?.u(function(e,t,n,r,i){let a={localCacheCount:e,existenceFilterCount:t.count,databaseId:n.database,projectId:n.projectId},o=t.unchangedNames;return o&&(a.bloomFilter={applied:i===0,hashCount:o?.hashCount??0,bitmapLength:o?.bits?.bitmap?.length??0,padding:o?.bits?.padding??0,mightContain:e=>r?.mightContain(e)??!1}),a}(r,e.xe,this.ze.Tt(),n,i))}}}}lt(e){let t=e.xe.unchangedNames;if(!t||!t.bits)return null;let{bits:{bitmap:n=``,padding:r=0},hashCount:i=0}=t,a,o;try{a=Yi(n).toUint8Array()}catch(e){if(e instanceof Gi)return Nr(`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 Rs(a,r,i)}catch(e){return Nr(e instanceof zs?`BloomFilter error: `:`Applying bloom filter failed: `,e),null}return o.ge===0?null:o}Et(e,t,n){return t.xe.count===n-this.Pt(e,t.targetId)?0:2}Pt(e,t){let n=this.ze.getRemoteKeysForTarget(t),r=0;return n.forEach((n=>{let i=this.ze.Tt(),a=`projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;e.mightContain(a)||(this.nt(t,n,null),r++)})),r}Rt(e){let t=new Map;this.je.forEach(((n,r)=>{let i=this.ut(r);if(i){if(n.current&&this._t(i.target)){let t=new R(Yo(i.target)?L.fromString(i.target.getPipelineDocuments()[0]):i.target.path);this.It(t).has(r)||this.At(r,t)||this.nt(r,t,Wo.newNoDocument(t,e))}n.Be&&(t.set(r,n.ke()),n.qe())}}));let n=W();this.Ze.forEach(((e,t)=>{let r=!0;t.forEachWhile((e=>{let t=this.ut(e);return!t||t.purpose===`TargetPurposeLimboResolution`||(r=!1,!1)})),r&&(n=n.add(e))})),this.He.forEach(((t,n)=>n.setReadTime(e))),this.Ye.forEach(((t,n)=>n.setReadTime(e)));let r=new Bs(e,t,this.Xe,this.He,this.Ye,n);return this.He=Ss(),this.Je=Js(),this.Ye=Ss(),this.Ze=Js(),this.Xe=new V(I),r}tt(e,t){let n=this.je.get(e);if(!n||!this.it(e))return void A(Ks,`addDocumentToTarget received document for unknown inactive target (${e})`);let r=this.At(e,t.key)?2:0;n.$e(t.key,r),Yo(this.ut(e).target)&&this.ut(e).target.getPipelineFlavor()!==`exact`?this.Ye=this.Ye.insert(t.key,t):this.He=this.He.insert(t.key,t),this.Je=this.Je.insert(t.key,this.It(t.key).add(e)),this.Ze=this.Ze.insert(t.key,this.Vt(t.key).add(e))}nt(e,t,n){let r=this.je.get(e);r&&this.it(e)?(this.At(e,t)?r.$e(t,1):r.Ke(t),this.Ze=this.Ze.insert(t,this.Vt(t).delete(e)),this.Ze=this.Ze.insert(t,this.Vt(t).add(e)),n&&(Yo(this.ut(e).target)&&this.ut(e).target.getPipelineFlavor()!==`exact`?this.Ye=this.Ye.insert(t,n):this.He=this.He.insert(t,n))):A(Ks,`removeDocumentFromTarget received document for unknown or inactive target (${e})`)}removeTarget(e){this.je.delete(e)}ct(e){let t=this.je.get(e);if(!t)return 0;let n=t.ke();return this.ze.getRemoteKeysForTarget(e).size+n.addedDocuments.size-n.removedDocuments.size}We(e){let t=this.je.get(e);t||(A(Ks,`recordPendingTargetRequest set up tracking for target ID ${e}`),t=new Gs(e),this.je.set(e,t)),t.We()}Vt(e){let t=this.Ze.get(e);return t||(t=new Ri(I),this.Ze=this.Ze.insert(e,t)),t}It(e){let t=this.Je.get(e);return t||(t=new Ri(I),this.Je=this.Je.insert(e,t)),t}it(e){let t=this.ut(e)!==null;return t||A(Ks,`Detected inactive target`,e),t}ut(e){let t=this.je.get(e);return t===void 0||t.Le?null:this.ze.dt(e)}st(e){this.je.set(e,new Gs(e)),this.ze.getRemoteKeysForTarget(e).forEach((t=>{this.nt(e,t,null)}))}At(e,t){return this.ze.getRemoteKeysForTarget(e).has(t)}};function Js(){return new V(R.comparator)}function Ys(){return new V(R.comparator)}var Xs={asc:`ASCENDING`,desc:`DESCENDING`},Zs={"<":`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`},Qs={and:`AND`,or:`OR`},$s=class{constructor(e,t){this.databaseId=e,this.useProto3Json=t}};function ec(e,t){return e.useProto3Json||Oi(t)?t:{value:t}}function tc(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 nc(e){let t=Ji(e);return new mi(t.seconds,t.nanos)}function rc(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function ic(e,t){return tc(e,t.toTimestamp())}function ac(e){return M(!!e,49232),z.fromTimestamp(nc(e))}function oc(e,t){return sc(e,t).canonicalString()}function sc(e,t){let n=function(e){return new L([`projects`,e.projectId,`databases`,e.database])}(e).child(`documents`);return t===void 0?n:n.child(t)}function cc(e){let t=L.fromString(e);return M(Nc(t),10190,{key:t.toString()}),t}function lc(e,t){return oc(e.databaseId,t.path)}function uc(e,t){let n=cc(t);if(n.get(1)!==e.databaseId.projectId)throw new F(P.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 F(P.INVALID_ARGUMENT,`Tried to deserialize key from different database: `+n.get(3)+` vs `+e.databaseId.database);return new R(mc(n))}function dc(e,t){return oc(e.databaseId,t)}function fc(e){let t=cc(e);return t.length===4?L.emptyPath():mc(t)}function pc(e){return new L([`projects`,e.databaseId.projectId,`databases`,e.databaseId.database]).canonicalString()}function mc(e){return M(e.length>4&&e.get(4)===`documents`,29091,{key:e.toString()}),e.popFirst(5)}function hc(e,t,n){return{name:lc(e,t),fields:n.value.mapValue.fields}}function gc(e,t){let n;if(`targetChange`in t){t.targetChange;let r=function(e){return e===`NO_CHANGE`?0:e===`ADD`?1:e===`REMOVE`?2:e===`CURRENT`?3:e===`RESET`?4:j(39313,{state:e})}(t.targetChange.targetChangeType||`NO_CHANGE`),i=t.targetChange.targetIds||[],a=function(e,t){return e.useProto3Json?(M(t===void 0||typeof t==`string`,58123),Ki.fromBase64String(t||``)):(M(t===void 0||t instanceof Buffer||t instanceof Uint8Array,16193),Ki.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),o=t.targetChange.cause;n=new Ws(r,i,a,o&&function(e){return new F(e.code===void 0?P.UNKNOWN:ys(e.code),e.message||``)}(o)||null)}else if(`documentChange`in t){t.documentChange;let r=t.documentChange;r.document,r.document.name,r.document.updateTime;let i=uc(e,r.document.name),a=ac(r.document.updateTime),o=r.document.createTime?ac(r.document.createTime):z.min(),s=new Ia({mapValue:{fields:r.document.fields}}),c=Wo.newFoundDocument(i,a,o,s);n=new Hs(r.targetIds||[],r.removedTargetIds||[],c.key,c)}else if(`documentDelete`in t){t.documentDelete;let r=t.documentDelete;r.document;let i=uc(e,r.document),a=r.readTime?ac(r.readTime):z.min(),o=Wo.newNoDocument(i,a);n=new Hs([],r.removedTargetIds||[],o.key,o)}else if(`documentRemove`in t){t.documentRemove;let r=t.documentRemove;r.document;let i=uc(e,r.document);n=new Hs([],r.removedTargetIds||[],i,null)}else{if(!(`filter`in t))return j(11601,{ft:t});{t.filter;let e=t.filter;e.targetId;let{count:r=0,unchangedNames:i}=e,a=new gs(r,i),o=e.targetId;n=new Us(o,a)}}return n}function _c(e,t){let n;if(t instanceof mo)n={update:hc(e,t.key,t.value)};else if(t instanceof yo)n={delete:lc(e,t.key)};else if(t instanceof ho)n={update:hc(e,t.key,t.data),updateMask:Mc(t.fieldMask)};else{if(!(t instanceof bo))return j(16599,{gt:t.type});n={verify:lc(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map((e=>function(e,t){let n=t.transform;if(n instanceof Ga)return{fieldPath:t.field.canonicalString(),setToServerValue:`REQUEST_TIME`};if(n instanceof Ka)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof Ja)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Za)return{fieldPath:t.field.canonicalString(),increment:n.Re};if(n instanceof Qa)return{fieldPath:t.field.canonicalString(),minimum:n.Re};if(n instanceof $a)return{fieldPath:t.field.canonicalString(),maximum:n.Re};throw j(20930,{transform:t.transform})}(0,e)))),t.precondition.isNone||(n.currentDocument=function(e,t){return t.updateTime===void 0?t.exists===void 0?j(27497):{exists:t.exists}:{updateTime:ic(e,t.updateTime)}}(e,t.precondition)),n}function vc(e,t){return e&&e.length>0?(M(t!==void 0,14353),e.map((e=>function(e,t){let n=e.updateTime?ac(e.updateTime):ac(t);return n.isEqual(z.min())&&(n=ac(t)),new io(n,e.transformResults||[])}(e,t)))):[]}function yc(e,t){return{documents:[dc(e,t.path)]}}function bc(e,t){let n={structuredQuery:{}},r=t.path,i;t.collectionGroup===null?(i=r.popLast(),n.structuredQuery.from=[{collectionId:r.lastSegment()}]):(i=r,n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]),n.parent=dc(e,i);let a=function(e){if(e.length!==0)return jc(Do.create(e,`and`))}(t.filters);a&&(n.structuredQuery.where=a);let o=function(e){if(e.length!==0)return e.map((e=>function(e){return{field:kc(e.field),direction:Ec(e.dir)}}(e)))}(t.orderBy);o&&(n.structuredQuery.orderBy=o);let s=ec(e,t.limit);return s!==null&&(n.structuredQuery.limit=s),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)),{yt:n,parent:i}}function xc(e,t,n,r){let{yt:i,parent:a}=bc(e,t),o={},s=[],c=0;return n.forEach((e=>{let t=r?e.alias:`aggregate_`+c++;o[t]=e.alias,e.aggregateType===`count`?s.push({alias:t,count:{}}):e.aggregateType===`avg`?s.push({alias:t,avg:{field:kc(e.fieldPath)}}):e.aggregateType===`sum`&&s.push({alias:t,sum:{field:kc(e.fieldPath)}})})),{request:{structuredAggregationQuery:{aggregations:s,structuredQuery:i.structuredQuery},parent:i.parent},wt:o,parent:a}}function Sc(e){let t=fc(e.parent),n=e.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){M(r===1,65062);let e=n.from[0];e.allDescendants?i=e.collectionId:t=t.child(e.collectionId)}let a=[];n.where&&(a=function(e){let t=Tc(e);return t instanceof Do&&ko(t)?t.getFilters():[t]}(n.where));let o=[];n.orderBy&&(o=function(e){return e.map((e=>function(e){return new Ho(Ac(e.field),function(e){switch(e){case`ASCENDING`:return`asc`;case`DESCENDING`:return`desc`;default:return}}(e.direction))}(e)))}(n.orderBy));let s=null;n.limit&&(s=function(e){let t;return t=typeof e==`object`?e.value:e,Oi(t)?null:t}(n.limit));let c=null;n.startAt&&(c=function(e){let t=!!e.before;return new So(e.values||[],t)}(n.startAt));let l=null;return n.endAt&&(l=function(e){let t=!e.before;return new So(e.values||[],t)}(n.endAt)),Qo(t,i,o,a,s,`F`,c,l)}function Cc(e,t){let 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 j(28987,{purpose:e})}}(t.purpose);return n==null?null:{"goog-listen-tags":n}}function wc(e,t){return{structuredPipeline:{pipeline:{stages:t.stages.map((t=>t._toProto(e)))}}}}function Tc(e){return e.unaryFilter===void 0?e.fieldFilter===void 0?e.compositeFilter===void 0?j(30097,{filter:e}):function(e){return Do.create(e.compositeFilter.filters.map((e=>Tc(e))),function(e){switch(e){case`AND`:return`and`;case`OR`:return`or`;default:return j(1026)}}(e.compositeFilter.op))}(e):function(e){return Eo.create(Ac(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 j(58110);default:return j(50506)}}(e.fieldFilter.op),e.fieldFilter.value)}(e):function(e){switch(e.unaryFilter.op){case`IS_NAN`:let t=Ac(e.unaryFilter.field);return Eo.create(t,`==`,{doubleValue:NaN});case`IS_NULL`:let n=Ac(e.unaryFilter.field);return Eo.create(n,`==`,{nullValue:`NULL_VALUE`});case`IS_NOT_NAN`:let r=Ac(e.unaryFilter.field);return Eo.create(r,`!=`,{doubleValue:NaN});case`IS_NOT_NULL`:let i=Ac(e.unaryFilter.field);return Eo.create(i,`!=`,{nullValue:`NULL_VALUE`});case`OPERATOR_UNSPECIFIED`:return j(61313);default:return j(60726)}}(e)}function Ec(e){return Xs[e]}function Dc(e){return Zs[e]}function Oc(e){return Qs[e]}function kc(e){return{fieldPath:e.canonicalString()}}function Ac(e){return ti.fromServerFormat(e.fieldPath)}function jc(e){return e instanceof Eo?function(e){if(e.op===`==`){if(Aa(e.value))return{unaryFilter:{field:kc(e.field),op:`IS_NAN`}};if(ka(e.value))return{unaryFilter:{field:kc(e.field),op:`IS_NULL`}}}else if(e.op===`!=`){if(Aa(e.value))return{unaryFilter:{field:kc(e.field),op:`IS_NOT_NAN`}};if(ka(e.value))return{unaryFilter:{field:kc(e.field),op:`IS_NOT_NULL`}}}return{fieldFilter:{field:kc(e.field),op:Dc(e.op),value:e.value}}}(e):e instanceof Do?function(e){let t=e.getFilters().map((e=>jc(e)));return t.length===1?t[0]:{compositeFilter:{op:Oc(e.op),filters:t}}}(e):j(54877,{filter:e})}function Mc(e){let t=[];return e.fields.forEach((e=>t.push(e.canonicalString()))),{fieldPaths:t}}function Nc(e){return e.length>=4&&e.get(0)===`projects`&&e.get(2)===`databases`}function Pc(e){return!!e&&typeof e._toProto==`function`&&e._protoValueType===`ProtoValue`}function Fc(e,t){let n={fields:{}};return t.forEach(((t,r)=>{if(typeof r!=`string`)throw Error(`Cannot encode map with non-string key: ${r}`);n.fields[r]=t._toProto(e)})),{mapValue:n}}function Ic(e){return{stringValue:e}}function Lc(e){return new $s(e,!0)}var Rc=class e{constructor(e){this._byteString=e}static fromBase64String(t){try{return new e(Ki.fromBase64String(t))}catch(e){throw new F(P.INVALID_ARGUMENT,`Failed to construct data from Base64 string: `+e)}}static fromUint8Array(t){return new e(Ki.fromUint8Array(t))}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:e._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(t){if(di(t,e._jsonSchema))return e.fromBase64String(t.bytes)}};Rc._jsonSchemaVersion=`firestore/bytes/1.0`,Rc._jsonSchema={type:ui(`string`,Rc._jsonSchemaVersion),bytes:ui(`string`)};var zc=class{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new F(P.INVALID_ARGUMENT,`Invalid field name at argument $(i + 1). Field names must not be empty.`);this._internalPath=new ti(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}};function Bc(){return new zc(Qr)}var Vc=class{constructor(e){this._methodName=e}},Hc=class e{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new F(P.INVALID_ARGUMENT,`Latitude must be a number between -90 and 90, but was: `+e);if(!isFinite(t)||t<-180||t>180)throw new F(P.INVALID_ARGUMENT,`Longitude must be a number between -180 and 180, but was: `+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return I(this._lat,e._lat)||I(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:e._jsonSchemaVersion}}static fromJSON(t){if(di(t,e._jsonSchema))return new e(t.latitude,t.longitude)}};function Uc(e){let t={};return e.timeoutSeconds!==void 0&&(t.timeoutSeconds=e.timeoutSeconds),t}Hc._jsonSchemaVersion=`firestore/geoPoint/1.0`,Hc._jsonSchema={type:ui(`string`,Hc._jsonSchemaVersion),latitude:ui(`number`),longitude:ui(`number`)};var Wc=class{bt(e){}shutdown(){}},Gc=`ConnectivityMonitor`,Kc=class{constructor(){this.vt=()=>this.St(),this.Dt=()=>this.xt(),this.Ct=[],this.Ft()}bt(e){this.Ct.push(e)}shutdown(){window.removeEventListener(`online`,this.vt),window.removeEventListener(`offline`,this.Dt)}Ft(){window.addEventListener(`online`,this.vt),window.addEventListener(`offline`,this.Dt)}St(){A(Gc,`Network connectivity changed: AVAILABLE`);for(let e of this.Ct)e(0)}xt(){A(Gc,`Network connectivity changed: UNAVAILABLE`);for(let e of this.Ct)e(1)}static C(){return typeof window<`u`&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}},qc=null;function Jc(){return qc===null?qc=function(){return 268435456+Math.round(2147483648*Math.random())}():qc++,`0x`+qc.toString(16)}var Yc=`RestConnection`,Xc={BatchGetDocuments:`batchGet`,Commit:`commit`,RunQuery:`runQuery`,RunAggregationQuery:`runAggregationQuery`,ExecutePipeline:`executePipeline`},Zc=class{get Ot(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;let t=e.ssl?`https`:`http`,n=encodeURIComponent(this.databaseId.projectId),r=encodeURIComponent(this.databaseId.database);this.Mt=t+`://`+e.host,this.Nt=`projects/${n}/databases/${r}`,this.Lt=this.databaseId.database===ia?`project_id=${n}`:`project_id=${n}&database_id=${r}`}Bt(e,t,n,r,i){let a=Jc(),o=this.Ut(e,t.toUriEncodedString());A(Yc,`Sending RPC '${e}' ${a}:`,o,n);let s={"google-cloud-resource-prefix":this.Nt,"x-goog-request-params":this.Lt};this.kt(s,r,i);let{host:c}=new URL(o),l=Oe(c);return this.qt(e,o,s,n,l).then((t=>(A(Yc,`Received RPC '${e}' ${a}: `,t),t)),(t=>{throw Nr(Yc,`RPC '${e}' ${a} failed with error: `,t,`url: `,o,`request:`,n),t}))}$t(e,t,n,r,i,a){return this.Bt(e,t,n,r,i)}kt(e,t,n){e[`X-Goog-Api-Client`]=function(){return`gl-js/ fire/`+Or}(),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))}Ut(e,t){let n=Xc[e],r=`${this.Mt}/v1/${t}:${n}`;return this.databaseInfo.apiKey&&(r=`${r}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),r}terminate(){}},Qc=class{constructor(e){this.Kt=e.Kt,this.Wt=e.Wt}Qt(e){this.Gt=e}zt(e){this.jt=e}Ht(e){this.Jt=e}onMessage(e){this.Yt=e}close(){this.Wt()}send(e){this.Kt(e)}Zt(){this.Gt()}Xt(){this.jt()}en(e){this.Jt(e)}tn(e){this.Yt(e)}},$c=`WebChannelConnection`,el=(e,t,n)=>{e.listen(t,(e=>{try{n(e)}catch(e){setTimeout((()=>{throw e}),0)}}))},tl=class e extends Zc{constructor(e){super(e),this.nn=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static rn(){e.sn||=(el(Nn(),Mn.STAT_EVENT,(e=>{e.stat===jn.PROXY?A($c,`STAT_EVENT: detected buffering proxy`):e.stat===jn.NOPROXY&&A($c,`STAT_EVENT: detected no buffering proxy`)})),!0)}qt(e,t,n,r,i){let a=Jc();return new Promise(((i,o)=>{let s=new Dn;s.setWithCredentials(!0),s.listenOnce(kn.COMPLETE,(()=>{try{switch(s.getLastErrorCode()){case An.NO_ERROR:let t=s.getResponseJson();A($c,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(t)),i(t);break;case An.TIMEOUT:A($c,`RPC '${e}' ${a} timed out`),o(new F(P.DEADLINE_EXCEEDED,`Request time out`));break;case An.HTTP_ERROR:let n=s.getStatus();if(A($c,`RPC '${e}' ${a} failed with status:`,n,`response text:`,s.getResponseText()),n>0){let e=s.getResponseJson();Array.isArray(e)&&(e=e[0]);let t=e?.error;t&&t.status&&t.message?o(new F(function(e){let t=e.toLowerCase().replace(/_/g,`-`);return Object.values(P).indexOf(t)>=0?t:P.UNKNOWN}(t.status),t.message)):o(new F(P.UNKNOWN,`Server responded with status `+s.getStatus()))}else o(new F(P.UNAVAILABLE,`Connection failed.`));break;default:j(9055,{_n:e,streamId:a,an:s.getLastErrorCode(),un:s.getLastError()})}}finally{A($c,`RPC '${e}' ${a} completed.`)}}));let c=JSON.stringify(r);A($c,`RPC '${e}' ${a} sending request:`,r),s.send(t,`POST`,c,n,15)}))}cn(t,n,r){let i=Jc(),a=[this.Mt,`/`,`google.firestore.v1.Firestore`,`/`,t,`/channel`],o=this.createWebChannelTransport(),s={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;c!==void 0&&(s.longPollingTimeout=Math.round(1e3*c)),this.useFetchStreams&&(s.useFetchStreams=!0),this.kt(s.initMessageHeaders,n,r),s.encodeInitMessageHeaders=!0;let l=a.join(``);A($c,`Creating RPC '${t}' stream ${i}: ${l}`,s);let u=o.createWebChannel(l,s);this.En(u);let d=!1,f=!1,p=new Qc({Kt:e=>{f?A($c,`Not sending because RPC '${t}' stream ${i} is closed:`,e):(d||=(A($c,`Opening RPC '${t}' stream ${i} transport.`),u.open(),!0),A($c,`RPC '${t}' stream ${i} sending:`,e),u.send(e))},Wt:()=>u.close()});return el(u,On.EventType.OPEN,(()=>{f||(A($c,`RPC '${t}' stream ${i} transport opened.`),p.Zt())})),el(u,On.EventType.CLOSE,(()=>{f||(f=!0,A($c,`RPC '${t}' stream ${i} transport closed`),p.en(),this.hn(u))})),el(u,On.EventType.ERROR,(e=>{f||(f=!0,Nr($c,`RPC '${t}' stream ${i} transport errored. Name:`,e.name,`Message:`,e.message),p.en(new F(P.UNAVAILABLE,`The operation could not be completed`)))})),el(u,On.EventType.MESSAGE,(e=>{if(!f){let n=e.data[0];M(!!n,16349);let r=n,a=r?.error||r[0]?.error;if(a){A($c,`RPC '${t}' stream ${i} received error:`,a);let e=a.status,n=function(e){let t=_s[e];if(t!==void 0)return ys(t)}(e),r=a.message;e===`NOT_FOUND`&&r.includes(`database`)&&r.includes(`does not exist`)&&r.includes(this.databaseId.database)&&Nr(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),n===void 0&&(n=P.INTERNAL,r=`Unknown error status: `+e+` with message `+a.message),f=!0,p.en(new F(n,r)),u.close()}else A($c,`RPC '${t}' stream ${i} received:`,n),p.tn(n)}})),e.rn(),setTimeout((()=>{p.Xt()}),0),p}terminate(){this.nn.forEach((e=>e.close())),this.nn=[]}En(e){this.nn.push(e)}hn(e){this.nn=this.nn.filter((t=>t===e))}kt(e,t,n){super.kt(e,t,n),this.databaseInfo.apiKey&&(e[`x-goog-api-key`]=this.databaseInfo.apiKey)}createWebChannelTransport(){return Pn()}};function nl(e){return new tl(e)}tl.sn=!1;var rl=class{constructor(e,t,n=1e3,r=1.5,i=6e4){this.Tn=e,this.timerId=t,this.Pn=n,this.Rn=r,this.In=i,this.An=0,this.Vn=null,this.dn=Date.now(),this.reset()}reset(){this.An=0}fn(){this.An=this.In}mn(e){this.cancel();let t=Math.floor(this.An+this.pn()),n=Math.max(0,Date.now()-this.dn),r=Math.max(0,t-n);r>0&&A(`ExponentialBackoff`,`Backing off for ${r} ms (base delay: ${this.An} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.Vn=this.Tn.enqueueAfterDelay(this.timerId,r,(()=>(this.dn=Date.now(),e()))),this.An*=this.Rn,this.An<this.Pn&&(this.An=this.Pn),this.An>this.In&&(this.An=this.In)}gn(){this.Vn!==null&&(this.Vn.skipDelay(),this.Vn=null)}cancel(){this.Vn!==null&&(this.Vn.cancel(),this.Vn=null)}pn(){return(Math.random()-.5)*this.An}},il=`PersistentStream`,al=class{constructor(e,t,n,r,i,a,o,s){this.Tn=e,this.yn=n,this.wn=r,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=o,this.listener=s,this.state=0,this.bn=0,this.vn=null,this.Sn=null,this.stream=null,this.Dn=0,this.xn=new rl(e,t)}Cn(){return this.state===1||this.state===5||this.Fn()}Fn(){return this.state===2||this.state===3}start(){this.Dn=0,this.state===4?this.On():this.auth()}async stop(){this.Cn()&&await this.close(0)}Mn(){this.state=0,this.xn.reset()}Nn(){this.Fn()&&this.vn===null&&(this.vn=this.Tn.enqueueAfterDelay(this.yn,6e4,(()=>this.Ln())))}Bn(e){this.Un(),this.stream.send(e)}async Ln(){if(this.Fn())return this.close(0)}Un(){this.vn&&=(this.vn.cancel(),null)}kn(){this.Sn&&=(this.Sn.cancel(),null)}async close(e,t){this.Un(),this.kn(),this.xn.cancel(),this.bn++,e===4?t&&t.code===P.RESOURCE_EXHAUSTED?(Mr(t.toString()),Mr(`Using maximum backoff delay to prevent overloading the backend.`),this.xn.fn()):t&&t.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()):this.xn.reset(),this.stream!==null&&(this.qn(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Ht(t)}qn(){}auth(){this.state=1;let e=this.$n(this.bn),t=this.bn;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([e,n])=>{this.bn===t&&this.Kn(e,n)}),(t=>{e((()=>{let e=new F(P.UNKNOWN,`Fetching auth token failed: `+t.message);return this.Wn(e)}))}))}Kn(e,t){let n=this.$n(this.bn);this.stream=this.Qn(e,t),this.stream.Qt((()=>{n((()=>this.listener.Qt()))})),this.stream.zt((()=>{n((()=>(this.state=2,this.Sn=this.Tn.enqueueAfterDelay(this.wn,1e4,(()=>(this.Fn()&&(this.state=3),Promise.resolve()))),this.listener.zt())))})),this.stream.Ht((e=>{n((()=>this.Wn(e)))})),this.stream.onMessage((e=>{n((()=>++this.Dn==1?this.Gn(e):this.onNext(e)))}))}On(){this.state=5,this.xn.mn((async()=>{this.state=0,this.start()}))}Wn(e){return A(il,`close with error: ${e}`),this.stream=null,this.close(4,e)}$n(e){return t=>{this.Tn.enqueueAndForget((()=>this.bn===e?t():(A(il,`stream callback skipped by getCloseGuardedDispatcher.`),Promise.resolve())))}}},ol=class extends al{constructor(e,t,n,r,i,a){super(e,`listen_stream_connection_backoff`,`listen_stream_idle`,`health_check_timeout`,t,n,r,a),this.serializer=i}Qn(e,t){return this.connection.cn(`Listen`,e,t)}Gn(e){return this.onNext(e)}onNext(e){this.xn.reset();let t=gc(this.serializer,e),n=function(e){if(!(`targetChange`in e))return z.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?z.min():t.readTime?ac(t.readTime):z.min()}(e);return this.listener.zn(t,n)}jn(e){let t={};t.database=pc(this.serializer),t.addTarget=function(e,t){let n,r=t.target;if(n=Yo(r)?{pipelineQuery:wc(e,r)}:Xo(r)?{documents:yc(e,r)}:{query:bc(e,r).yt},n.targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=rc(e,t.resumeToken);let r=ec(e,t.expectedCount);r!==null&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(z.min())>0){n.readTime=tc(e,t.snapshotVersion.toTimestamp());let r=ec(e,t.expectedCount);r!==null&&(n.expectedCount=r)}return n}(this.serializer,e);let n=Cc(this.serializer,e);n&&(t.labels=n),this.Bn(t)}Hn(e){let t={};t.database=pc(this.serializer),t.removeTarget=e,this.Bn(t)}},sl=class extends al{constructor(e,t,n,r,i,a){super(e,`write_stream_connection_backoff`,`write_stream_idle`,`health_check_timeout`,t,n,r,a),this.serializer=i}get Jn(){return this.Dn>0}start(){this.lastStreamToken=void 0,super.start()}qn(){this.Jn&&this.Yn([])}Qn(e,t){return this.connection.cn(`Write`,e,t)}Gn(e){return M(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,M(!e.writeResults||e.writeResults.length===0,55816),this.listener.Zn()}onNext(e){M(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.xn.reset();let t=vc(e.writeResults,e.commitTime),n=ac(e.commitTime);return this.listener.Xn(n,t)}er(){let e={};e.database=pc(this.serializer),this.Bn(e)}Yn(e){let t={streamToken:this.lastStreamToken,writes:e.map((e=>_c(this.serializer,e)))};this.Bn(t)}},cl=class{},ll=class extends cl{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=r,this.tr=!1}nr(){if(this.tr)throw new F(P.FAILED_PRECONDITION,`The client has already been terminated.`)}Bt(e,t,n,r){return this.nr(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,a])=>this.connection.Bt(e,sc(t,n),r,i,a))).catch((e=>{throw e.name===`FirebaseError`?(e.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new F(P.UNKNOWN,e.toString())}))}$t(e,t,n,r,i){return this.nr(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,o])=>this.connection.$t(e,sc(t,n),r,a,o,i))).catch((e=>{throw e.name===`FirebaseError`?(e.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new F(P.UNKNOWN,e.toString())}))}terminate(){this.tr=!0,this.connection.terminate()}};function ul(e,t,n,r){return new ll(e,t,n,r)}var dl=`ComponentProvider`,fl=new Map;function pl(e,t,n,r,i){return new ra(e,t,n,i.host,i.ssl,i.experimentalForceLongPolling,i.experimentalAutoDetectLongPolling,Uc(i.experimentalLongPollingOptions),i.useFetchStreams,i.isUsingEmulator,r)}var ml={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},hl=41943040,gl=class e{static withCacheSize(t){return new e(t,e.DEFAULT_COLLECTION_PERCENTILE,e.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}};gl.DEFAULT_COLLECTION_PERCENTILE=10,gl.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,gl.DEFAULT=new gl(hl,gl.DEFAULT_COLLECTION_PERCENTILE,gl.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),gl.DISABLED=new gl(-1,0,0);var _l=`LruGarbageCollector`,vl=1048576;function yl([e,t],[n,r]){let i=I(e,n);return i===0?I(t,r):i}var bl=class{constructor(e){this.rr=e,this.buffer=new Ri(yl),this.ir=0}sr(){return++this.ir}_r(e){let t=[e,this.sr()];if(this.buffer.size<this.rr)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();yl(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}},xl=class{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.ar=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.ur(6e4)}stop(){this.ar&&=(this.ar.cancel(),null)}get started(){return this.ar!==null}ur(e){A(_l,`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){Ti(e)?A(_l,`Ignoring IndexedDB error during garbage collection: `,e):await Ci(e)}await this.ur(3e5)}))}},Sl=class{constructor(e,t){this.cr=e,this.params=t}calculateTargetCount(e,t){return this.cr.lr(e).next((e=>Math.floor(t/100*e)))}nthSequenceNumber(e,t){if(t===0)return B.resolve(Ei.ce);let n=new bl(t);return this.cr.forEachTarget(e,(e=>n._r(e.sequenceNumber))).next((()=>this.cr.Er(e,(e=>n._r(e))))).next((()=>n.maxValue))}removeTargets(e,t,n){return this.cr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.cr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(A(`LruGarbageCollector`,`Garbage collection skipped; disabled`),B.resolve(ml)):this.getCacheSize(e).next((n=>n<this.params.cacheSizeCollectionThreshold?(A(`LruGarbageCollector`,`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),ml):this.hr(e,t)))}getCacheSize(e){return this.cr.getCacheSize(e)}hr(e,t){let n,r,i,a,o,s,c,l=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((t=>(t>this.params.maximumSequenceNumbersToCollect?(A(`LruGarbageCollector`,`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),r=this.params.maximumSequenceNumbersToCollect):r=t,a=Date.now(),this.nthSequenceNumber(e,r)))).next((r=>(n=r,o=Date.now(),this.removeTargets(e,n,t)))).next((t=>(i=t,s=Date.now(),this.removeOrphanedDocuments(e,n)))).next((e=>(c=Date.now(),jr()<=v.DEBUG&&A(`LruGarbageCollector`,`LRU Garbage Collection\n\tCounted targets in ${a-l}ms\n\tDetermined least recently used ${r} in `+(o-a)+`ms
|
|
27
|
+
\tRemoved ${i} targets in `+(s-o)+`ms
|
|
28
|
+
\tRemoved ${e} documents in `+(c-s)+`ms
|
|
29
|
+
Total Duration: ${c-l}ms`),B.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e}))))}};function Cl(e,t){return new Sl(e,t)}var wl=`firestore.googleapis.com`,Tl=!0,El=class{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new F(P.INVALID_ARGUMENT,`Can't provide ssl option if host option is not set`);this.host=wl,this.ssl=Tl}else this.host=e.host,this.ssl=e.ssl??Tl;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=hl;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<vl)throw new F(P.INVALID_ARGUMENT,`cacheSizeBytes must be at least 1048576`);this.cacheSizeBytes=e.cacheSizeBytes}ri(`experimentalForceLongPolling`,e.experimentalForceLongPolling,`experimentalAutoDetectLongPolling`,e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=Uc(e.experimentalLongPollingOptions??{}),function(e){if(e.timeoutSeconds!==void 0){if(isNaN(e.timeoutSeconds))throw new F(P.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new F(P.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new F(P.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(e,t){return e.timeoutSeconds===t.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}},Dl=class{constructor(e,t,n,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=r,this.type=`firestore-lite`,this._persistenceKey=`(lite)`,this._settings=new El({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask=`notTerminated`}get app(){if(!this._app)throw new F(P.FAILED_PRECONDITION,`Firestore was not initialized using the Firebase SDK. 'app' is not available`);return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!==`notTerminated`}_setSettings(e){if(this._settingsFrozen)throw new F(P.FAILED_PRECONDITION,`Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.`);this._settings=new El(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=function(e){if(!e)return new Rr;switch(e.type){case`firstParty`:return new Hr(e.sessionIndex||`0`,e.iamToken||null,e.authTokenFactory||null);case`provider`:return e.client;default:throw new F(P.INVALID_ARGUMENT,`makeAuthCredentialsProvider failed due to invalid credential type`)}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask===`notTerminated`&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask===`notTerminated`?await this._terminate():this._terminateTask=`notTerminated`}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){let t=fl.get(e);t&&(A(dl,`Removing Datastore`),fl.delete(e),t.terminate())}(this),Promise.resolve()}};function Ol(e,t,n,r={}){e=ci(e,Dl);let i=Oe(t),a=e._getSettings(),o={...a,emulatorOptions:e._getEmulatorOptions()},s=`${t}:${n}`;i&&ke(`https://${s}`),a.host!==wl&&a.host!==s&&Nr(`Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.`);let c={...a,host:s,ssl:i,emulatorOptions:r};if(!ye(c,o)&&(e._setSettings(c),r.mockUserToken)){let t,n;if(typeof r.mockUserToken==`string`)t=r.mockUserToken,n=Dr.MOCK_USER;else{t=ne(r.mockUserToken,e._app?.options.projectId);let i=r.mockUserToken.sub||r.mockUserToken.user_id;if(!i)throw new F(P.INVALID_ARGUMENT,`mockUserToken must contain 'sub' or 'user_id' field!`);n=new Dr(i)}e._authCredentials=new zr(new Lr(t,n))}}var kl=class e{constructor(e,t,n){this.converter=t,this._query=n,this.type=`query`,this.firestore=e}withConverter(t){return new e(this.firestore,t,this._query)}},Al=class e{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 jl(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new e(this.firestore,t,this._key)}toJSON(){return{type:e._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(t,n,r){if(di(n,e._jsonSchema))return new e(t,r||null,new R(L.fromString(n.referencePath)))}};Al._jsonSchemaVersion=`firestore/documentReference/1.0`,Al._jsonSchema={type:ui(`string`,Al._jsonSchemaVersion),referencePath:ui(`string`)};var jl=class e extends kl{constructor(e,t,n){super(e,t,$o(n)),this._path=n,this.type=`collection`}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new Al(this.firestore,null,new R(e))}withConverter(t){return new e(this.firestore,t,this._path)}};function Ml(e,t,...n){if(e=_(e),ni(`collection`,`path`,t),e instanceof Dl){let r=L.fromString(t,...n);return ai(r),new jl(e,null,r)}{if(!(e instanceof Al||e instanceof jl))throw new F(P.INVALID_ARGUMENT,`Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore`);let r=e._path.child(L.fromString(t,...n));return ai(r),new jl(e.firestore,null,r)}}function Nl(e,t,...n){if(e=_(e),arguments.length===1&&(t=Kr.newId()),ni(`doc`,`path`,t),e instanceof Dl){let r=L.fromString(t,...n);return ii(r),new Al(e,null,new R(r))}{if(!(e instanceof Al||e instanceof jl))throw new F(P.INVALID_ARGUMENT,`Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore`);let r=e._path.child(L.fromString(t,...n));return ii(r),new Al(e.firestore,e instanceof jl?e.converter:null,new R(r))}}var Pl=class e{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:e._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(t){if(di(t,e._jsonSchema)){if(Array.isArray(t.vectorValues)&&t.vectorValues.every((e=>typeof e==`number`)))return new e(t.vectorValues);throw new F(P.INVALID_ARGUMENT,`Expected 'vectorValues' field to be a number array`)}}};Pl._jsonSchemaVersion=`firestore/vectorValue/1.0`,Pl._jsonSchema={type:ui(`string`,Pl._jsonSchemaVersion),vectorValues:ui(`object`)};var Fl=/^__.*__$/,Il=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return this.fieldMask===null?new mo(e,this.data,t,this.fieldTransforms):new ho(e,this.data,this.fieldMask,t,this.fieldTransforms)}},Ll=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new ho(e,this.data,this.fieldMask,t,this.fieldTransforms)}};function Rl(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw j(40011,{dataSource:e})}}var zl=class e{constructor(e,t,n,r,i,a){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,i===void 0&&this.validatePath(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(t){return new e({...this.settings,...t},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){let t=this.path?.child(e),n=this.contextWith({path:t,arrayElement:!1});return n.validatePathSegment(e),n}childContextForFieldPath(e){let t=this.path?.child(e),n=this.contextWith({path:t,arrayElement:!1});return n.validatePath(),n}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return eu(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find((t=>e.isPrefixOf(t)))!==void 0||this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))!==void 0}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(e.length===0)throw this.createError(`Document fields must not be empty`);if(Rl(this.dataSource)&&Fl.test(e))throw this.createError(`Document fields cannot begin and end with "__"`)}},Bl=class{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Lc(e)}createContext(e,t,n,r=!1){return new zl({dataSource:e,methodName:t,targetDoc:n,path:ti.emptyPath(),arrayElement:!1,hasConverter:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function Vl(e){let t=e._freezeSettings(),n=Lc(e._databaseId);return new Bl(e._databaseId,!!t.ignoreUndefinedProperties,n)}function Hl(e,t,n,r,i,a={}){let o=e.createContext(a.merge||a.mergeFields?2:0,t,n,i);Xl(`Data must be an object, but it was:`,o,r);let s=Jl(r,o),c,l;if(a.merge)c=new Bi(o.fieldMask),l=o.fieldTransforms;else if(a.mergeFields){let e=[];for(let r of a.mergeFields){let i=Zl(t,r,n);if(!o.contains(i))throw new F(P.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);tu(e,i)||e.push(i)}c=new Bi(e),l=o.fieldTransforms.filter((e=>c.covers(e.field)))}else c=null,l=o.fieldTransforms;return new Il(new Ia(s),c,l)}var Ul=class e extends Vc{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(t){return t instanceof e}};function Wl(e,t,n,r){let i=e.createContext(1,t,n);Xl(`Data must be an object, but it was:`,i,r);let a=[],o=Ia.empty();return Hi(r,((e,r)=>{let s=$l(t,e,n);r=_(r);let c=i.childContextForFieldPath(s);if(r instanceof Ul)a.push(s);else{let e=ql(r,c);e!=null&&(a.push(s),o.set(s,e))}})),new Ll(o,new Bi(a),i.fieldTransforms)}function Gl(e,t,n,r,i,a){let o=e.createContext(1,t,n),s=[Zl(t,r,n)],c=[i];if(a.length%2!=0)throw new F(P.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<a.length;e+=2)s.push(Zl(t,a[e])),c.push(a[e+1]);let l=[],u=Ia.empty();for(let e=s.length-1;e>=0;--e)if(!tu(l,s[e])){let t=s[e],n=c[e];n=_(n);let r=o.childContextForFieldPath(t);if(n instanceof Ul)l.push(t);else{let e=ql(n,r);e!=null&&(l.push(t),u.set(t,e))}}return new Ll(u,new Bi(l),o.fieldTransforms)}function Kl(e,t,n,r=!1){return ql(n,e.createContext(r?4:3,t))}function ql(e,t,n){if(Yl(e=_(e)))return Xl(`Unsupported field value:`,t,e),Jl(e,t);if(e instanceof Vc)return function(e,t){if(!Rl(t.dataSource))throw t.createError(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.createError(`${e._methodName}() is not currently supported inside arrays`);let n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(e===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.arrayElement&&t.dataSource!==4)throw t.createError(`Nested arrays are not supported`);return function(e,t){let n=[],r=0;for(let i of e){let e=ql(i,t.childContextForArray(r));e??={nullValue:`NULL_VALUE`},n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t,n){if((e=_(e))===null)return{nullValue:`NULL_VALUE`};if(typeof e==`number`)return Ba(t.serializer,e,n);if(typeof e==`boolean`)return{booleanValue:e};if(typeof e==`string`)return{stringValue:e};if(e instanceof Date){let n=mi.fromDate(e);return{timestampValue:tc(t.serializer,n)}}if(e instanceof mi){let n=new mi(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:tc(t.serializer,n)}}if(e instanceof Hc)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Rc)return{bytesValue:rc(t.serializer,e._byteString)};if(e instanceof Al){let n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.createError(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:oc(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof Pl)return function(e,t){let n=e instanceof Pl?e.toArray():e;return{mapValue:{fields:{[sa]:{stringValue:ua},[da]:{arrayValue:{values:n.map((e=>{if(typeof e!=`number`)throw t.createError(`VectorValues must only contain numeric values.`);return Ra(t.serializer,e)}))}}}}}}(e,t);if(Pc(e))return e._toProto(t.serializer);throw t.createError(`Unsupported field value: ${si(e)}`)}(e,t,n)}function Jl(e,t){let n={};return Wi(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):Hi(e,((e,r)=>{let i=ql(r,t.childContextForField(e));i!=null&&(n[e]=i)})),{mapValue:{fields:n}}}function Yl(e){return!(typeof e!=`object`||!e||e instanceof Array||e instanceof Date||e instanceof mi||e instanceof Hc||e instanceof Rc||e instanceof Al||e instanceof Vc||e instanceof Pl||Pc(e))}function Xl(e,t,n){if(!Yl(n)||!oi(n)){let r=si(n);throw r===`an object`?t.createError(e+` a custom object`):t.createError(e+` `+r)}}function Zl(e,t,n){if((t=_(t))instanceof zc)return t._internalPath;if(typeof t==`string`)return $l(e,t);throw eu(`Field path arguments must be of type string or `,e,!1,void 0,n)}var Ql=RegExp(`[~\\*/\\[\\]]`);function $l(e,t,n){if(t.search(Ql)>=0)throw eu(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new zc(...t.split(`.`))._internalPath}catch{throw eu(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function eu(e,t,n,r,i){let a=r&&!r.isEmpty(),o=i!==void 0,s=`Function ${t}() called with invalid data`;n&&(s+=" (via `toFirestore()`)"),s+=`. `;let c=``;return(a||o)&&(c+=` (found`,a&&(c+=` in field ${r}`),o&&(c+=` in document ${i}`),c+=`)`),new F(P.INVALID_ARGUMENT,s+e+c)}function tu(e,t){return e.some((e=>e.isEqual(t)))}function nu(e){return typeof e._readUserData==`function`}var ru=class e{constructor(e){this.optionDefinitions=e}_getKnownOptions(t,n){let r=Ia.empty();for(let i in this.optionDefinitions)if(this.optionDefinitions.hasOwnProperty(i)){let a=this.optionDefinitions[i];if(i in t){let o=t[i],s;a.nestedOptions&&oi(o)?s={mapValue:{fields:new e(a.nestedOptions).getOptionsProto(n,o)}}:o&&(s=ql(o,n)??void 0),s&&r.set(ti.fromServerFormat(a.serverName),s)}}return r}getOptionsProto(e,t,n){let r=this._getKnownOptions(t,e);if(n){let t=new Map(Ui(n,((t,n)=>[ti.fromServerFormat(n),t===void 0?null:ql(t,e)])));r.setAll(t)}return r.value.mapValue.fields??{}}};function iu(e){return typeof e==`object`&&!!e&&!!(`nullValue`in e&&(e.nullValue===null||e.nullValue===`NULL_VALUE`)||`booleanValue`in e&&(e.booleanValue===null||typeof e.booleanValue==`boolean`)||`integerValue`in e&&(e.integerValue===null||typeof e.integerValue==`number`||typeof e.integerValue==`string`)||`doubleValue`in e&&(e.doubleValue===null||typeof e.doubleValue==`number`)||`timestampValue`in e&&(e.timestampValue===null||function(e){return typeof e==`object`&&!!e&&`seconds`in e&&(e.seconds===null||typeof e.seconds==`number`||typeof e.seconds==`string`)&&`nanos`in e&&(e.nanos===null||typeof e.nanos==`number`)}(e.timestampValue))||`stringValue`in e&&(e.stringValue===null||typeof e.stringValue==`string`)||`bytesValue`in e&&(e.bytesValue===null||e.bytesValue instanceof Uint8Array)||`referenceValue`in e&&(e.referenceValue===null||typeof e.referenceValue==`string`)||`geoPointValue`in e&&(e.geoPointValue===null||function(e){return typeof e==`object`&&!!e&&`latitude`in e&&(e.latitude===null||typeof e.latitude==`number`)&&`longitude`in e&&(e.longitude===null||typeof e.longitude==`number`)}(e.geoPointValue))||`arrayValue`in e&&(e.arrayValue===null||function(e){return typeof e==`object`&&!!e&&!(!(`values`in e)||e.values!==null&&!Array.isArray(e.values))}(e.arrayValue))||`mapValue`in e&&(e.mapValue===null||function(e){return typeof e==`object`&&!!e&&!(!(`fields`in e)||e.fields!==null&&!oi(e.fields))}(e.mapValue))||`fieldReferenceValue`in e&&(e.fieldReferenceValue===null||typeof e.fieldReferenceValue==`string`)||`functionValue`in e&&(e.functionValue===null||function(e){return typeof e==`object`&&!!e&&!(!(`name`in e)||e.name!==null&&typeof e.name!=`string`||!(`args`in e)||e.args!==null&&!Array.isArray(e.args))}(e.functionValue))||`pipelineValue`in e&&(e.pipelineValue===null||function(e){return typeof e==`object`&&!!e&&!(!(`stages`in e)||e.stages!==null&&!Array.isArray(e.stages))}(e.pipelineValue)))}function au(e){return new Pl(e)}function G(e){let t;return e instanceof cu?e:(t=oi(e)?Cu(e):e instanceof Array?wu(e):vu(e,void 0),t)}function ou(e){if(e instanceof cu)return e;if(e instanceof Pl)return _u(e);if(Array.isArray(e))return _u(au(e));throw Error(`Unsupported value: `+typeof e)}function su(e){return ji(e)?mu(e):G(e)}var cu=class{constructor(){this._protoValueType=`ProtoValue`}add(e){return new K(`add`,[this,G(e)],`add`)}asBoolean(){if(this instanceof yu)return this;if(this instanceof gu)return new xu(this);if(this instanceof pu)return new Su(this);if(this instanceof K)return new bu(this);throw new F(`invalid-argument`,`Conversion of type ${typeof this} to BooleanExpression not supported.`)}subtract(e){return new K(`subtract`,[this,G(e)],`subtract`)}multiply(e){return new K(`multiply`,[this,G(e)],`multiply`)}divide(e){return new K(`divide`,[this,G(e)],`divide`)}mod(e){return new K(`mod`,[this,G(e)],`mod`)}equal(e){return new K(`equal`,[this,G(e)],`equal`).asBoolean()}notEqual(e){return new K(`not_equal`,[this,G(e)],`notEqual`).asBoolean()}lessThan(e){return new K(`less_than`,[this,G(e)],`lessThan`).asBoolean()}lessThanOrEqual(e){return new K(`less_than_or_equal`,[this,G(e)],`lessThanOrEqual`).asBoolean()}greaterThan(e){return new K(`greater_than`,[this,G(e)],`greaterThan`).asBoolean()}greaterThanOrEqual(e){return new K(`greater_than_or_equal`,[this,G(e)],`greaterThanOrEqual`).asBoolean()}arrayConcat(e,...t){let n=[e,...t].map((e=>G(e)));return new K(`array_concat`,[this,...n],`arrayConcat`)}arrayContains(e){return new K(`array_contains`,[this,G(e)],`arrayContains`).asBoolean()}arrayContainsAll(e){let t=Array.isArray(e)?new fu(e.map(G),`arrayContainsAll`):e;return new K(`array_contains_all`,[this,t],`arrayContainsAll`).asBoolean()}arrayContainsAny(e){let t=Array.isArray(e)?new fu(e.map(G),`arrayContainsAny`):e;return new K(`array_contains_any`,[this,t],`arrayContainsAny`).asBoolean()}arrayReverse(){return new K(`array_reverse`,[this])}arrayLength(){return new K(`array_length`,[this],`arrayLength`)}equalAny(e){let t=Array.isArray(e)?new fu(e.map(G),`equalAny`):e;return new K(`equal_any`,[this,t],`equalAny`).asBoolean()}notEqualAny(e){let t=Array.isArray(e)?new fu(e.map(G),`notEqualAny`):e;return new K(`not_equal_any`,[this,t],`notEqualAny`).asBoolean()}exists(){return new K(`exists`,[this],`exists`).asBoolean()}charLength(){return new K(`char_length`,[this],`charLength`)}like(e){return new K(`like`,[this,G(e)],`like`).asBoolean()}regexContains(e){return new K(`regex_contains`,[this,G(e)],`regexContains`).asBoolean()}regexFind(e){return new K(`regex_find`,[this,G(e)],`regexFind`)}regexFindAll(e){return new K(`regex_find_all`,[this,G(e)],`regexFindAll`)}regexMatch(e){return new K(`regex_match`,[this,G(e)],`regexMatch`).asBoolean()}stringContains(e){return new K(`string_contains`,[this,G(e)],`stringContains`).asBoolean()}startsWith(e){return new K(`starts_with`,[this,G(e)],`startsWith`).asBoolean()}endsWith(e){return new K(`ends_with`,[this,G(e)],`endsWith`).asBoolean()}toLower(){return new K(`to_lower`,[this],`toLower`)}toUpper(){return new K(`to_upper`,[this],`toUpper`)}trim(e){let t=[this];return e&&t.push(G(e)),new K(`trim`,t,`trim`)}ltrim(e){let t=[this];return e&&t.push(G(e)),new K(`ltrim`,t,`ltrim`)}rtrim(e){let t=[this];return e&&t.push(G(e)),new K(`rtrim`,t,`rtrim`)}type(){return new K(`type`,[this])}isType(e){return new K(`is_type`,[this,_u(e)],`isType`).asBoolean()}stringConcat(e,...t){let n=[e,...t].map(G);return new K(`string_concat`,[this,...n],`stringConcat`)}stringIndexOf(e){return new K(`string_index_of`,[this,G(e)],`stringIndexOf`)}stringRepeat(e){return new K(`string_repeat`,[this,G(e)],`stringRepeat`)}stringReplaceAll(e,t){return new K(`string_replace_all`,[this,G(e),G(t)],`stringReplaceAll`)}stringReplaceOne(e,t){return new K(`string_replace_one`,[this,G(e),G(t)],`stringReplaceOne`)}concat(e,...t){let n=[e,...t].map(G);return new K(`concat`,[this,...n],`concat`)}reverse(){return new K(`reverse`,[this],`reverse`)}arrayFilter(e,t){return new K(`array_filter`,[this,G(e),t],`arrayFilter`)}arrayTransform(e,t){return new K(`array_transform`,[this,G(e),t],`arrayTransform`)}arrayTransformWithIndex(e,t,n){return new K(`array_transform`,[this,G(e),G(t),n],`arrayTransformWithIndex`)}arraySlice(e,t){let n=[this,G(e)];return t!==void 0&&n.push(G(t)),new K(`array_slice`,n,`arraySlice`)}arrayFirst(){return new K(`array_first`,[this],`arrayFirst`)}arrayFirstN(e){return new K(`array_first_n`,[this,G(e)],`arrayFirstN`)}arrayLast(){return new K(`array_last`,[this],`arrayLast`)}arrayLastN(e){return new K(`array_last_n`,[this,G(e)],`arrayLastN`)}arrayMaximum(){return new K(`maximum`,[this],`arrayMaximum`)}arrayMaximumN(e){return new K(`maximum_n`,[this,G(e)],`arrayMaximumN`)}arrayMinimum(){return new K(`minimum`,[this],`arrayMinimum`)}arrayMinimumN(e){return new K(`minimum_n`,[this,G(e)],`arrayMinimumN`)}arrayIndexOf(e){return new K(`array_index_of`,[this,G(e),G(`first`)],`arrayIndexOf`)}arrayLastIndexOf(e){return new K(`array_index_of`,[this,G(e),G(`last`)],`arrayLastIndexOf`)}arrayIndexOfAll(e){return new K(`array_index_of_all`,[this,G(e)],`arrayIndexOfAll`)}byteLength(){return new K(`byte_length`,[this],`byteLength`)}ceil(){return new K(`ceil`,[this])}floor(){return new K(`floor`,[this])}abs(){return new K(`abs`,[this])}exp(){return new K(`exp`,[this])}mapGet(e){return new K(`map_get`,[this,_u(e)],`mapGet`)}mapSet(e,t,...n){return new K(`map_set`,[this,G(e),G(t),...n.map(G)],`mapSet`)}mapKeys(){return new K(`map_keys`,[this],`mapKeys`)}mapValues(){return new K(`map_values`,[this],`mapValues`)}mapEntries(){return new K(`map_entries`,[this],`mapEntries`)}getField(e){return new K(`get_field`,[this,G(e)],`get_field`)}count(){return lu._create(`count`,[this],`count`)}sum(){return lu._create(`sum`,[this],`sum`)}average(){return lu._create(`average`,[this],`average`)}minimum(){return lu._create(`minimum`,[this],`minimum`)}maximum(){return lu._create(`maximum`,[this],`maximum`)}first(){return lu._create(`first`,[this],`first`)}last(){return lu._create(`last`,[this],`last`)}arrayAgg(){return lu._create(`array_agg`,[this],`arrayAgg`)}arrayAggDistinct(){return lu._create(`array_agg_distinct`,[this],`arrayAggDistinct`)}countDistinct(){return lu._create(`count_distinct`,[this],`countDistinct`)}logicalMaximum(e,...t){let n=[e,...t];return new K(`maximum`,[this,...n.map(G)],`logicalMaximum`)}logicalMinimum(e,...t){let n=[e,...t];return new K(`minimum`,[this,...n.map(G)],`minimum`)}vectorLength(){return new K(`vector_length`,[this],`vectorLength`)}cosineDistance(e){return new K(`cosine_distance`,[this,ou(e)],`cosineDistance`)}dotProduct(e){return new K(`dot_product`,[this,ou(e)],`dotProduct`)}euclideanDistance(e){return new K(`euclidean_distance`,[this,ou(e)],`euclideanDistance`)}unixMicrosToTimestamp(){return new K(`unix_micros_to_timestamp`,[this],`unixMicrosToTimestamp`)}timestampToUnixMicros(){return new K(`timestamp_to_unix_micros`,[this],`timestampToUnixMicros`)}unixMillisToTimestamp(){return new K(`unix_millis_to_timestamp`,[this],`unixMillisToTimestamp`)}timestampToUnixMillis(){return new K(`timestamp_to_unix_millis`,[this],`timestampToUnixMillis`)}unixSecondsToTimestamp(){return new K(`unix_seconds_to_timestamp`,[this],`unixSecondsToTimestamp`)}timestampToUnixSeconds(){return new K(`timestamp_to_unix_seconds`,[this],`timestampToUnixSeconds`)}timestampAdd(e,t){return new K(`timestamp_add`,[this,G(e),G(t)],`timestampAdd`)}timestampSubtract(e,t){return new K(`timestamp_subtract`,[this,G(e),G(t)],`timestampSubtract`)}timestampDiff(e,t){return new K(`timestamp_diff`,[this,su(e),G(t)],`timestampDiff`)}timestampExtract(e,t){let n=[this,G(e)];return t&&n.push(G(t)),new K(`timestamp_extract`,n,`timestampExtract`)}documentId(){return new K(`document_id`,[this],`documentId`)}parent(){return new K(`parent`,[this],`parent`)}substring(e,t){let n=G(e);return new K(`substring`,t===void 0?[this,n]:[this,n,G(t)],`substring`)}arrayGet(e){return new K(`array_get`,[this,G(e)],`arrayGet`)}isError(){return new K(`is_error`,[this],`isError`).asBoolean()}ifError(e){let t=new K(`if_error`,[this,G(e)],`ifError`);return e instanceof yu?t.asBoolean():t}isAbsent(){return new K(`is_absent`,[this],`isAbsent`).asBoolean()}mapRemove(e){return new K(`map_remove`,[this,G(e)],`mapRemove`)}mapMerge(e,...t){let n=G(e),r=t.map(G);return new K(`map_merge`,[this,n,...r],`mapMerge`)}pow(e){return new K(`pow`,[this,G(e)])}trunc(e){return e===void 0?new K(`trunc`,[this]):new K(`trunc`,[this,G(e)],`trunc`)}round(e){return e===void 0?new K(`round`,[this]):new K(`round`,[this,G(e)],`round`)}collectionId(){return new K(`collection_id`,[this])}length(){return new K(`length`,[this])}ln(){return new K(`ln`,[this])}sqrt(){return new K(`sqrt`,[this])}stringReverse(){return new K(`string_reverse`,[this])}ifAbsent(e){return new K(`if_absent`,[this,G(e)],`ifAbsent`)}ifNull(e){return new K(`if_null`,[this,G(e)],`ifNull`)}coalesce(e,...t){return new K(`coalesce`,[this,G(e),...t.map(G)],`coalesce`)}join(e){return new K(`join`,[this,G(e)],`join`)}log10(){return new K(`log10`,[this])}arraySum(){return new K(`sum`,[this])}split(e){return new K(`split`,[this,G(e)])}timestampTruncate(e,t){let n=[this,G(e)];return t&&n.push(G(t)),new K(`timestamp_trunc`,n)}ascending(){return Tu(this)}descending(){return Eu(this)}as(e){return new du(this,e,`as`)}},lu=class e{constructor(e,t){this.name=e,this.params=t,this.exprType=`AggregateFunction`,this._protoValueType=`ProtoValue`}static _create(t,n,r){let i=new e(t,n);return i._methodName=r,i}as(e){return new uu(this,e,`as`)}_toProto(e){return{functionValue:{name:this.name,args:this.params.map((t=>t._toProto(e)))}}}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach((t=>t._readUserData(e)))}},uu=class{constructor(e,t,n){this.aggregate=e,this.alias=t,this._methodName=n}_readUserData(e){this.aggregate._readUserData(e)}},du=class{constructor(e,t,n){this.expr=e,this.alias=t,this._methodName=n,this.exprType=`AliasedExpression`,this.selectable=!0}_readUserData(e){this.expr._readUserData(e)}},fu=class extends cu{constructor(e,t){super(),this.Rr=e,this._methodName=t,this.expressionType=`ListOfExpressions`}_toProto(e){return{arrayValue:{values:this.Rr.map((t=>t._toProto(e)))}}}_readUserData(e){this.Rr.forEach((t=>t._readUserData(e)))}},pu=class extends cu{constructor(e,t){super(),this.fieldPath=e,this._methodName=t,this.expressionType=`Field`,this.selectable=!0}get _fieldPath(){return this.fieldPath}get fieldName(){return this.fieldPath.canonicalString()}get alias(){return this.fieldName}get expr(){return this}geoDistance(e){return new K(`geo_distance`,[this,G(e)],`geoDistance`)}_toProto(e){return{fieldReferenceValue:this.fieldPath.canonicalString()}}_readUserData(e){}};function mu(e){return hu(e,`field`)}function hu(e,t){return new pu(typeof e==`string`?Qr===e?Bc()._internalPath:Zl(`field`,e):e._internalPath,t)}var gu=class e extends cu{constructor(e,t){super(),this.value=e,this._methodName=t,this.expressionType=`Constant`}static _fromProto(t){let n=new e(t,void 0);return n._protoValue=t,n}_toProto(e){return M(this._protoValue!==void 0,237),this._protoValue}_getValue(){return this._protoValue}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,iu(this._protoValue)||(this._protoValue=ql(this.value,e))}};function _u(e,t){return vu(e,`constant`)}function vu(e,t){let n=new gu(e,t);return typeof e==`boolean`?new xu(n):n}var K=class extends cu{constructor(e,t,n,r){super(),this.name=e,this.params=t,this.expressionType=`Function`,this._optionsProto=void 0,n!==void 0&&(this._methodName=n),r!==void 0&&(this._options=r)}get _optionsUtil(){return new ru({})}_toProto(e){let t={functionValue:{name:this.name,args:this.params.map((t=>t._toProto(e)))}};return this._optionsProto&&(t.functionValue.options=this._optionsProto),t}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach((t=>t._readUserData(e))),this._options&&(this._optionsProto=this._optionsUtil.getOptionsProto(e,this._options))}},yu=class e extends cu{get _methodName(){return this._expr._methodName}countIf(){return lu._create(`count_if`,[this],`countIf`)}not(){return new K(`not`,[this],`not`).asBoolean()}conditional(e,t){return new K(`conditional`,[this,e,t],`conditional`)}ifError(t){let n=G(t),r=new K(`if_error`,[this,n],`ifError`);return n instanceof e?r.asBoolean():r}_toProto(e){return this._expr._toProto(e)}_readUserData(e){this._expr._readUserData(e)}},bu=class extends yu{constructor(e){super(),this._expr=e,this.expressionType=`Function`}},xu=class extends yu{constructor(e){super(),this._expr=e,this.expressionType=`Constant`}_getValue(){return this._expr._getValue()}},Su=class extends yu{constructor(e){super(),this._expr=e,this.expressionType=`Field`}};function Cu(e,t){let n=[];for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];n.push(_u(t)),n.push(G(r))}return new K(`map`,n,`map`)}function wu(e){return function(e,t){return new K(`array`,e.map((e=>G(e))),t)}(e,`array`)}function Tu(e){return new Du(su(e),`ascending`,`ascending`)}function Eu(e){return new Du(su(e),`descending`,`descending`)}var Du=class{constructor(e,t,n){this.expr=e,this.direction=t,this._methodName=n,this._protoValueType=`ProtoValue`}_toProto(e){return{mapValue:{fields:{direction:Ic(this.direction),expression:this.expr._toProto(e)}}}}_readUserData(e){this.expr._readUserData(e)}},Ou=class{constructor(e){this.optionsProto=void 0,{rawOptions:this.rawOptions,...this.knownOptions}=e}_readUserData(e){this.optionsProto=this._optionsUtil.getOptionsProto(e,this.knownOptions,this.rawOptions)}_toProto(e){return{name:this._name,options:this.optionsProto}}},ku=class extends Ou{get _name(){return`add_fields`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.fields=e}_toProto(e){return{...super._toProto(e),args:[Fc(e,this.fields)]}}_readUserData(e){super._readUserData(e),Hu(this.fields,e)}},Au=class extends Ou{get _name(){return`aggregate`}get _optionsUtil(){return new ru({})}constructor(e,t,n){super(n),this.groups=e,this.accumulators=t}_toProto(e){return{...super._toProto(e),args:[Fc(e,this.accumulators),Fc(e,this.groups)]}}_readUserData(e){super._readUserData(e),Hu(this.groups,e),Hu(this.accumulators,e)}},ju=class extends Ou{get _name(){return`distinct`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.groups=e}_toProto(e){return{...super._toProto(e),args:[Fc(e,this.groups)]}}_readUserData(e){super._readUserData(e),Hu(this.groups,e)}},Mu=class extends Ou{get _name(){return`collection`}get _optionsUtil(){return new ru({forceIndex:{serverName:`force_index`}})}constructor(e,t){super(t),this.Vr=e.startsWith(`/`)?e:`/`+e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:this.Vr}]}}_readUserData(e){super._readUserData(e)}},Nu=class extends Ou{get _name(){return`collection_group`}get _optionsUtil(){return new ru({forceIndex:{serverName:`force_index`}})}constructor(e,t){super(t),this.collectionId=e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:``},{stringValue:this.collectionId}]}}_readUserData(e){super._readUserData(e)}},Pu=class extends Ou{get _name(){return`database`}get _optionsUtil(){return new ru({})}_toProto(e){return{...super._toProto(e)}}_readUserData(e){super._readUserData(e)}},Fu=class extends Ou{get _name(){return`documents`}get _optionsUtil(){return new ru({})}constructor(e,t){if(super(t),!e||e.length===0)throw new F(P.INVALID_ARGUMENT,`Empty document paths are not allowed in DocumentsSource`);let n=e.map((e=>e.startsWith(`/`)?e:`/`+e)),r=new Set(n);if(r.size!==n.length)throw new F(P.INVALID_ARGUMENT,`Duplicate document paths are not allowed in DocumentsSource`);this.dr=n,this.mr=r}_toProto(e){return{...super._toProto(e),args:this.dr.map((e=>({referenceValue:e})))}}_readUserData(e){super._readUserData(e)}},Iu=class extends Ou{get _name(){return`where`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.condition=e}_toProto(e){return{...super._toProto(e),args:[this.condition._toProto(e)]}}_readUserData(e){super._readUserData(e),Hu(this.condition,e)}},Lu=class extends Ou{get _name(){return`limit`}get _optionsUtil(){return new ru({})}constructor(e,t){M(!isNaN(e)&&e!==1/0&&e!==-1/0,34860),super(t),this.limit=e}_toProto(e){return{...super._toProto(e),args:[Ba(e,this.limit)]}}},Ru=class extends Ou{get _name(){return`offset`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.offset=e}_toProto(e){return{...super._toProto(e),args:[Ba(e,this.offset)]}}},zu=class extends Ou{get _name(){return`select`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.selections=e}_toProto(e){return{...super._toProto(e),args:[Fc(e,this.selections)]}}_readUserData(e){super._readUserData(e),Hu(this.selections,e)}},Bu=class extends Ou{get _name(){return`sort`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.orderings=e}_toProto(e){return{...super._toProto(e),args:this.orderings.map((t=>t._toProto(e)))}}_readUserData(e){super._readUserData(e),Hu(this.orderings,e)}},Vu=class e extends Ou{get _name(){return`replace_with`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.map=e}_toProto(t){return{...super._toProto(t),args:[this.map._toProto(t),Ic(e.pr)]}}_readUserData(e){super._readUserData(e),Hu(this.map,e)}};Vu.pr=`full_replace`;function Hu(e,t){return nu(e)?e._readUserData(t):Array.isArray(e)||e instanceof Map?e.forEach((e=>e._readUserData(t))):Object.values(e).forEach((e=>e._readUserData(t))),e}var Uu=class{constructor(e,t,n){this.serializer=e,this.stages=t,this.listenOptions=n,this.isCorePipeline=!0}getPipelineCollection(){return Gu(this)}getPipelineCollectionGroup(){return Ku(this)}getPipelineCollectionId(){return qu(this)}getPipelineDocuments(){return Ju(this)}getPipelineFlavor(){return function(e){let t=`exact`;return e.stages.forEach(((n,r)=>{n._name!==ju.name&&n._name!==Au.name||(t=`keyless`),n._name===zu.name&&t===`exact`&&(t=`augmented`),n._name===ku.name&&r<e.stages.length-1&&t===`exact`&&(t=`augmented`)})),t}(this)}getPipelineSourceType(){return Wu(this)}};function Wu(e){let t=e.stages[0];return t instanceof Mu||t instanceof Nu||t instanceof Pu||t instanceof Fu?t._name:`unknown`}function Gu(e){if(Wu(e)===`collection`)return e.stages[0].Vr}function Ku(e){if(Wu(e)===`collection_group`)return e.stages[0].collectionId}function qu(e){switch(Wu(e)){case`collection`:return L.fromString(Gu(e)).lastSegment();case`collection_group`:return Ku(e);default:return}}function Ju(e){if(Wu(e)===`documents`)return e.stages[0].dr}var Yu=class e{constructor(e,t,n,r){this._db=e,this.userDataReader=t,this._userDataWriter=n,this.stages=r}wr(e,t){let n=this.userDataReader.createContext(3,e);return nu(t)?t._readUserData(n):t.forEach((e=>e._readUserData(n))),t}where(t){let n=this.stages.map((e=>e));return this.wr(`where`,t),n.push(new Iu(t,{})),new e(this._db,this.userDataReader,this._userDataWriter,n)}limit(t){let n=this.stages.map((e=>e));return n.push(new Lu(t,{})),new e(this._db,this.userDataReader,this._userDataWriter,n)}sort(t,...n){let r=this.stages.map((e=>e));return`orderings`in t?r.push(new Bu(this.wr(`sort`,t.orderings),{})):r.push(new Bu(this.wr(`sort`,[t,...n]),{})),new e(this._db,this.userDataReader,this._userDataWriter,r)}br(e){return{pipeline:{stages:this.stages.map((t=>t._toProto(e)))}}}},q=class e{constructor(e,t){this.type=e,this.value=t}static vr(){return new e(`ERROR`,void 0)}static Sr(){return new e(`UNSET`,void 0)}static Dr(){return new e(`NULL`,fa)}static newValue(t){return ka(t)?new e(`NULL`,fa):function(e){return!!e&&`booleanValue`in e}(t)?new e(`BOOLEAN`,t):Ta(t)?new e(`INT`,t):Ea(t)?new e(`DOUBLE`,t):function(e){return!!e&&`timestampValue`in e&&!!e.timestampValue}(t)?new e(`TIMESTAMP`,t):function(e){return!!e&&`stringValue`in e}(t)?new e(`STRING`,t):function(e){return!!e&&`bytesValue`in e}(t)?new e(`BYTES`,t):t.referenceValue?new e(`REFERENCE`,t):t.geoPointValue?new e(`GEO_POINT`,t):Oa(t)?new e(`ARRAY`,t):Ma(t)?new e(`VECTOR`,t):ja(t)?new e(`MAP`,t):new e(`ERROR`,void 0)}Cr(){return this.type===`ERROR`||this.type===`UNSET`}Fr(){return this.type===`NULL`}};function Xu(e){if(!e.Cr())return e.value}function Zu(e){return e instanceof yu?e._expr:e}function J(e){if((e=Zu(e))instanceof pu)return new Qu(e);if(e instanceof gu)return new $u(e);if(e instanceof fu)return new ed(e);if(e instanceof K){if(e.name===`add`)return new sd(e);if(e.name===`subtract`)return new cd(e);if(e.name===`multiply`)return new ld(e);if(e.name===`divide`)return new ud(e);if(e.name===`mod`)return new dd(e);if(e.name===`and`)return new fd(e);if(e.name===`equal`)return new Od(e);if(e.name===`not_equal`)return new kd(e);if(e.name===`less_than`)return new Ad(e);if(e.name===`less_than_or_equal`)return new jd(e);if(e.name===`greater_than`)return new Md(e);if(e.name===`greater_than_or_equal`)return new Nd(e);if(e.name===`array_concat`)return new Pd(e);if(e.name===`array_reverse`)return new Fd(e);if(e.name===`array_contains`)return new Id(e);if(e.name===`array_contains_all`)return new Ld(e);if(e.name===`array_contains_any`)return new Rd(e);if(e.name===`array_length`)return new zd(e);if(e.name===`array_element`)return new Bd(e);if(e.name===`equal_any`)return new gd(e);if(e.name===`not_equal_any`)return new _d(e);if(e.name===`is_nan`)return new vd(e);if(e.name===`is_not_nan`)return new yd(e);if(e.name===`is_null`)return new bd(e);if(e.name===`is_not_null`)return new xd(e);if(e.name===`is_error`)return new Sd(e);if(e.name===`exists`)return new Cd(e);if(e.name===`not`)return new pd(e);if(e.name===`or`)return new md(e);if(e.name===`xor`)return new hd(e);if(e.name===`conditional`)return new wd(e);if(e.name===`maximum`)return new Td(e);if(e.name===`minimum`)return new Ed(e);if(e.name===`reverse`)return new Vd(e);if(e.name===`replace_first`)return new Hd(e);if(e.name===`replace_all`)return new Ud(e);if(e.name===`char_length`)return new Wd(e);if(e.name===`byte_length`)return new Gd(e);if(e.name===`like`)return new qd(e);if(e.name===`regex_contains`)return new Jd(e);if(e.name===`regex_match`)return new Yd(e);if(e.name===`string_contains`)return new Xd(e);if(e.name===`starts_with`)return new Zd(e);if(e.name===`ends_with`)return new Qd(e);if(e.name===`to_lower`)return new $d(e);if(e.name===`to_upper`)return new ef(e);if(e.name===`trim`)return new tf(e);if(e.name===`string_concat`)return new nf(e);if(e.name===`map_get`)return new rf(e);if(e.name===`cosine_distance`)return new of(e);if(e.name===`dot_product`)return new sf(e);if(e.name===`euclidean_distance`)return new cf(e);if(e.name===`vector_length`)return new lf(e);if(e.name===`unix_micros_to_timestamp`)return new wf(e);if(e.name===`timestamp_to_unix_micros`)return new Of(e);if(e.name===`unix_millis_to_timestamp`)return new Tf(e);if(e.name===`timestamp_to_unix_millis`)return new kf(e);if(e.name===`unix_seconds_to_timestamp`)return new Ef(e);if(e.name===`timestamp_to_unix_seconds`)return new Af(e);if(e.name===`timestamp_add`)return new Mf(e);if(e.name===`timestamp_subtract`)return new Nf(e)}throw Error(`Unknown Expr : ${e}`)}var Qu=class{constructor(e){this.expr=e}evaluate(e,t){if(this.expr.fieldName===Qr)return q.newValue({referenceValue:lc(e.serializer,t.key)});if(this.expr.fieldName===`__update_time__`)return q.newValue({timestampValue:ic(e.serializer,t.version)});if(this.expr.fieldName===`__create_time__`)return q.newValue({timestampValue:ic(e.serializer,t.createTime)});let n=t.data.field(this.expr._fieldPath);return n?ea(n)?q.newValue(function(e,t){if(e.serverTimestampBehavior===`estimate`)return{timestampValue:ic(e.serializer,z.fromTimestamp(na(t)))};if(e.serverTimestampBehavior===`previous`){let e=ta(t);if(e)return e}return{nullValue:`NULL_VALUE`}}(e,n)):q.newValue(n):q.Sr()}},$u=class{constructor(e){this.expr=e}evaluate(e,t){return q.newValue(this.expr._getValue())}},ed=class{constructor(e){this.expr=e}evaluate(e,t){let n=this.expr.Rr.map((n=>J(n).evaluate(e,t)));return n.some((e=>e.Cr()))?q.vr():q.newValue({arrayValue:{values:n.map((e=>e.value))}})}};function td(e){return Ea(e)?Number(e.doubleValue):Number(e.integerValue)}function nd(e){return BigInt(e.integerValue)}var rd=BigInt(`0x7fffffffffffffff`),id=-BigInt(`0x8000000000000000`),ad=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length>=2,24778);let n=J(this.expr.params[0]).evaluate(e,t),r=J(this.expr.params[1]).evaluate(e,t),i=this.Or(n,r);for(let n of this.expr.params.slice(2)){let r=J(n).evaluate(e,t);i=this.Or(i,r)}return i}Or(e,t){if(e.Cr()||t.Cr())return q.vr();if(e.Fr()||t.Fr())return q.Dr();let n=e.value,r=t.value;if(!Ea(n)&&!Ta(n)||!Ea(r)&&!Ta(r))return q.vr();if(Ea(n)||Ea(r)){let e=this.Mr(n,r);return e?q.newValue(e):q.vr()}if(Ta(n)&&Ta(r)){let e=this.Nr(n,r);return e===void 0?q.vr():typeof e==`number`?q.newValue({doubleValue:e}):e<id||e>rd?q.vr():q.newValue({integerValue:`${e}`})}return q.vr()}};function od(e,t){return ha(e)===ha(t)?Aa(e)||Aa(t)?`NOT_EQ`:ka(e)&&ka(t)?`EQ`:ka(e)||ka(t)?`NULL`:Oa(e)&&Oa(t)?function(e,t){if(e.values?.length!==t.values?.length)return`NOT_EQ`;let n=!1;for(let r=0;r<(e.values?.length??0);r++){let i=e.values[r],a=t.values[r];switch(od(i,a)){case`EQ`:break;case`NOT_EQ`:case`TYPE_MISMATCH`:return`NOT_EQ`;case`NULL`:n=!0;break;default:j(44609,{Lr:i,Br:a})}}return n?`NULL`:`EQ`}(e.arrayValue,t.arrayValue):Ma(e)&&Ma(t)||ja(e)&&ja(t)?function(e,t){let n=e.fields||{},r=t.fields||{};if(Vi(n)!==Vi(r))return`NOT_EQ`;let i=!1;for(let e in n)if(n.hasOwnProperty(e)){if(r[e]===void 0)return`NOT_EQ`;switch(od(n[e],r[e])){case`NOT_EQ`:case`TYPE_MISMATCH`:return`NOT_EQ`;case`NULL`:i=!0}}return i?`NULL`:`EQ`}(e.mapValue,t.mapValue):function(e,t){return ga(e,t,{Te:!1,Ee:!0,he:!0})}(e,t)?`EQ`:`NOT_EQ`:`TYPE_MISMATCH`}var sd=class extends ad{Nr(e,t){return nd(e)+nd(t)}Mr(e,t){return{doubleValue:td(e)+td(t)}}},cd=class extends ad{constructor(e){super(e),this.expr=e}Nr(e,t){return nd(e)-nd(t)}Mr(e,t){return{doubleValue:td(e)-td(t)}}},ld=class extends ad{constructor(e){super(e),this.expr=e}Nr(e,t){return nd(e)*nd(t)}Mr(e,t){return{doubleValue:td(e)*td(t)}}},ud=class extends ad{constructor(e){super(e),this.expr=e}Nr(e,t){let n=nd(t);if(n!==BigInt(0))return nd(e)/n}Mr(e,t){let n=td(t);return n===0?{doubleValue:ki(n)?-1/0:1/0}:{doubleValue:td(e)/n}}},dd=class extends ad{constructor(e){super(e),this.expr=e}Nr(e,t){let n=nd(t);if(n!==BigInt(0))return nd(e)%n}Mr(e,t){let n=td(t);if(n!==0)return{doubleValue:td(e)%n}}},fd=class{constructor(e){this.expr=e}evaluate(e,t){let n=!1,r=!1;for(let i of this.expr.params){let a=J(i).evaluate(e,t);switch(a.type){case`BOOLEAN`:if(!a.value?.booleanValue)return q.newValue(ma);break;case`NULL`:r=!0;break;default:n=!0}}return n?q.vr():r?q.Dr():q.newValue(pa)}},pd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,9634);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`BOOLEAN`:return q.newValue({booleanValue:!n.value?.booleanValue});case`NULL`:return q.Dr();default:return q.vr()}}},md=class{constructor(e){this.expr=e}evaluate(e,t){let n=!1,r=!1;for(let i of this.expr.params){let a=J(i).evaluate(e,t);switch(a.type){case`BOOLEAN`:if(a.value?.booleanValue)return q.newValue(pa);break;case`NULL`:r=!0;break;default:n=!0}}return n?q.vr():r?q.Dr():q.newValue(ma)}},hd=class e{constructor(e){this.expr=e}evaluate(t,n){let r=!1,i=!1;for(let a of this.expr.params){let o=J(a).evaluate(t,n);switch(o.type){case`BOOLEAN`:r=e.xor(r,!!o.value?.booleanValue);break;case`NULL`:i=!0;break;default:return q.vr()}}return i?q.Dr():q.newValue({booleanValue:r})}static xor(e,t){return(e||t)&&!(e&&t)}},gd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,55094);let n=!1,r=J(this.expr.params[0]).evaluate(e,t);switch(r.type){case`NULL`:n=!0;break;case`ERROR`:case`UNSET`:return q.vr()}let i=J(this.expr.params[1]).evaluate(e,t);switch(i.type){case`ARRAY`:break;case`NULL`:n=!0;break;default:return q.vr()}if(n)return q.Dr();for(let e of i.value?.arrayValue?.values??[])switch(ka(r.value)&&ka(e)?`EQ`:od(r.value,e)){case`EQ`:return q.newValue(pa);case`NOT_EQ`:case`TYPE_MISMATCH`:break;case`NULL`:n=!0;break;default:j(44608,{value:r.value,candidate:e})}return n?q.Dr():q.newValue(ma)}},_d=class{constructor(e){this.expr=e}evaluate(e,t){return new pd(new K(`not`,[new K(`equal_any`,this.expr.params)])).evaluate(e,t)}},vd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,23322);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`INT`:return q.newValue(ma);case`DOUBLE`:return q.newValue({booleanValue:isNaN(td(n.value))});case`NULL`:return q.Dr();default:return q.vr()}}},yd=class{constructor(e){this.expr=e}evaluate(e,t){return M(this.expr.params.length===1,50406),new pd(new K(`not`,[new K(`is_nan`,this.expr.params)])).evaluate(e,t)}},bd=class{constructor(e){this.expr=e}evaluate(e,t){switch(M(this.expr.params.length===1,23123),J(this.expr.params[0]).evaluate(e,t).type){case`NULL`:return q.newValue(pa);case`UNSET`:case`ERROR`:return q.vr();default:return q.newValue(ma)}}},xd=class{constructor(e){this.expr=e}evaluate(e,t){return M(this.expr.params.length===1,23167),new pd(new K(`not`,[new K(`is_null`,this.expr.params)])).evaluate(e,t)}},Sd=class{constructor(e){this.expr=e}evaluate(e,t){return M(this.expr.params.length===1,5228),J(this.expr.params[0]).evaluate(e,t).type===`ERROR`?q.newValue(pa):q.newValue(ma)}},Cd=class{constructor(e){this.expr=e}evaluate(e,t){switch(M(this.expr.params.length===1,6877),J(this.expr.params[0]).evaluate(e,t).type){case`ERROR`:return q.vr();case`UNSET`:return q.newValue(ma);default:return q.newValue(pa)}}},wd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===3,11706);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`BOOLEAN`:return n.value?.booleanValue?J(this.expr.params[1]).evaluate(e,t):J(this.expr.params[2]).evaluate(e,t);case`NULL`:return J(this.expr.params[2]).evaluate(e,t);default:return q.vr()}}},Td=class{constructor(e){this.expr=e}evaluate(e,t){let n=this.expr.params.map((n=>J(n).evaluate(e,t))),r;for(let e of n)switch(e.type){case`ERROR`:case`UNSET`:case`NULL`:continue;default:r=r===void 0||va(e.value,r.value)>0?e:r}return r===void 0?q.Dr():r}},Ed=class{constructor(e){this.expr=e}evaluate(e,t){let n=this.expr.params.map((n=>J(n).evaluate(e,t))),r;for(let e of n)switch(e.type){case`ERROR`:case`UNSET`:case`NULL`:continue;default:r=r===void 0||va(e.value,r.value)<0?e:r}return r===void 0?q.Dr():r}},Dd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,31033,`${this.expr.name}() function should have exactly 2 params`);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`ERROR`:case`UNSET`:return q.vr()}let r=J(this.expr.params[1]).evaluate(e,t);switch(r.type){case`ERROR`:case`UNSET`:return q.vr()}return this.Ur(n,r)}},Od=class extends Dd{constructor(e){super(e),this.expr=e}Ur(e,t){if(e.Fr()&&t.Fr())return q.newValue(pa);if(e.Fr()||t.Fr()||Aa(e.value)||Aa(t.value)||ha(e.value)!==ha(t.value))return q.newValue(ma);switch(od(e.value,t.value)){case`EQ`:return q.newValue(pa);case`NOT_EQ`:return q.newValue(ma);case`NULL`:return q.Dr();default:j(44615,{left:e,right:t})}}},kd=class extends Dd{constructor(e){super(e),this.expr=e}Ur(e,t){switch(od(e.value,t.value)){case`EQ`:return q.newValue(ma);case`NOT_EQ`:case`TYPE_MISMATCH`:return q.newValue(pa);case`NULL`:return q.Dr();default:j(44614,{left:e,right:t})}}},Ad=class extends Dd{constructor(e){super(e),this.expr=e}Ur(e,t){return ha(e.value)!==ha(t.value)||Aa(e.value)||Aa(t.value)?q.newValue(ma):q.newValue({booleanValue:va(e.value,t.value)<0})}},jd=class extends Dd{constructor(e){super(e),this.expr=e}Ur(e,t){return ha(e.value)!==ha(t.value)||Aa(e.value)||Aa(t.value)?q.newValue(ma):od(e.value,t.value)===`EQ`?q.newValue(pa):q.newValue({booleanValue:va(e.value,t.value)<0})}},Md=class extends Dd{constructor(e){super(e),this.expr=e}Ur(e,t){return ha(e.value)!==ha(t.value)||Aa(e.value)||Aa(t.value)?q.newValue(ma):q.newValue({booleanValue:va(e.value,t.value)>0})}},Nd=class extends Dd{constructor(e){super(e),this.expr=e}Ur(e,t){return ha(e.value)!==ha(t.value)||Aa(e.value)||Aa(t.value)?q.newValue(ma):od(e.value,t.value)===`EQ`?q.newValue(pa):q.newValue({booleanValue:va(e.value,t.value)>0})}},Pd=class{constructor(e){this.expr=e}evaluate(e,t){throw Error(`Unimplemented`)}},Fd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,216);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`NULL`:return q.Dr();case`ARRAY`:{let e=n.value.arrayValue?.values??[];return q.newValue({arrayValue:{values:[...e].reverse()}})}default:return q.vr()}}},Id=class{constructor(e){this.expr=e}evaluate(e,t){return M(this.expr.params.length===2,52884),new gd(new K(`eq_any`,[this.expr.params[1],this.expr.params[0]])).evaluate(e,t)}},Ld=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,1392);let n=!1,r=J(this.expr.params[0]).evaluate(e,t);switch(r.type){case`ARRAY`:break;case`NULL`:n=!0;break;default:return q.vr()}let i=J(this.expr.params[1]).evaluate(e,t);switch(i.type){case`ARRAY`:break;case`NULL`:n=!0;break;default:return q.vr()}if(n)return q.Dr();let a=i.value?.arrayValue?.values??[],o=r.value?.arrayValue?.values??[];for(let e of a){let t=!1;n=!1;for(let r of o){switch(ka(e)&&ka(r)?`EQ`:od(e,r)){case`EQ`:t=!0;break;case`NOT_EQ`:case`TYPE_MISMATCH`:break;case`NULL`:n=!0;break;default:j(44613,{value:r,search:e})}if(t)break}if(!t)return q.newValue(ma)}return q.newValue(pa)}},Rd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,2680);let n=!1,r=J(this.expr.params[0]).evaluate(e,t);switch(r.type){case`ARRAY`:break;case`NULL`:n=!0;break;default:return q.vr()}let i=J(this.expr.params[1]).evaluate(e,t);switch(i.type){case`ARRAY`:break;case`NULL`:n=!0;break;default:return q.vr()}if(n)return q.Dr();let a=i.value?.arrayValue?.values??[],o=r.value?.arrayValue?.values??[];for(let e of o)for(let t of a)switch(ka(e)&&ka(t)?`EQ`:od(e,t)){case`EQ`:return q.newValue(pa);case`NOT_EQ`:case`TYPE_MISMATCH`:break;case`NULL`:n=!0;break;default:j(44608,{value:e,search:t})}return n?q.Dr():q.newValue(ma)}},zd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,38605);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`NULL`:return q.Dr();case`ARRAY`:return q.newValue({integerValue:`${n.value?.arrayValue?.values?.length??0}`});default:return q.vr()}}},Bd=class{constructor(e){this.expr=e}evaluate(e,t){throw Error(`Unimplemented`)}},Vd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,1508);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`NULL`:return q.Dr();case`BYTES`:{let e=n.value?.bytesValue;if(typeof e==`string`){let t=Ki.fromBase64String(e).toUint8Array();return t.reverse(),q.newValue({bytesValue:Ki.fromUint8Array(t).toBase64()})}return q.newValue({bytesValue:new Uint8Array(e).reverse()})}case`STRING`:{let e=n.value?.stringValue,t=new Intl.__PRIVATE_Segmenter(void 0,{granularity:`grapheme`}).segment(e),r=Array.from(t,(e=>e.segment)).reverse();return q.newValue({stringValue:r.join(``)})}default:return q.vr()}}},Hd=class{constructor(e){this.expr=e}evaluate(e,t){throw Error(`Unimplemented`)}},Ud=class{constructor(e){this.expr=e}evaluate(e,t){throw Error(`Unimplemented`)}},Wd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,19400);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`NULL`:return q.Dr();case`STRING`:{let e=function(e){let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(r===void 0)return;if(r<=65535)if(r>=55296&&r<=57343)if(r<=56319){let r=e.codePointAt(n+1);r!==void 0&&r>=56320&&r<=57343?(t+=1,n++):t+=1}else t+=1;else t+=1;else{if(!(r<=1114111))return;t+=1,n++}}return t}(n.value.stringValue);return e===void 0?q.vr():q.newValue({integerValue:e})}default:return q.vr()}}},Gd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,8486);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`BYTES`:{let e=n.value?.bytesValue;return typeof e==`string`?q.newValue({integerValue:Ki.fromBase64String(e).toUint8Array().length}):q.newValue({integerValue:new Uint8Array(e).length})}case`STRING`:{let e=function(e){let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(r===void 0)return;if(r>=55296&&r<=57343){if(!(r<=56319))return;{let r=e.codePointAt(n+1);if(r===void 0||!(r>=56320&&r<=57343))return;t+=4,n++}}else if(r<=127)t+=1;else if(r<=2047)t+=2;else if(r<=65535)t+=3;else{if(!(r<=1114111))return;t+=4,n++}}return t}(n.value?.stringValue);return e===void 0?q.vr():q.newValue({integerValue:e})}case`NULL`:return q.Dr();default:return q.vr()}}},Kd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,39773,`${this.expr.name}() function should have exactly two parameters`);let n=!1,r=J(this.expr.params[0]).evaluate(e,t);switch(r.type){case`STRING`:break;case`NULL`:n=!0;break;default:return q.vr()}let i=J(this.expr.params[1]).evaluate(e,t);switch(i.type){case`STRING`:break;case`NULL`:n=!0;break;default:return q.vr()}return n?q.Dr():this.kr(r.value?.stringValue,i.value?.stringValue)}},qd=class extends Kd{kr(e,t){try{let n=function(e){let t=``;for(let n=0;n<e.length;n++){let r=e.charAt(n);switch(r){case`_`:t+=`.`;break;case`%`:t+=`.*`;break;case`\\`:case`.`:case`*`:case`?`:case`+`:case`^`:case`$`:case`|`:case`(`:case`)`:case`[`:case`]`:case`{`:case`}`:t+=`\\`+r;break;default:t+=r}}return`^`+t+`$`}(t),r=Er.compile(n);return q.newValue({booleanValue:r.matches(e)})}catch(e){return Nr(`Invalid LIKE pattern converted to regex: ${t}, returning error. Error: ${e}`),q.vr()}}},Jd=class extends Kd{kr(e,t){try{let n=Er.compile(t);return q.newValue({booleanValue:n.matcher(e).find()})}catch{return Nr(`Invalid regex pattern found in regex_contains: ${t}, returning error`),q.vr()}}},Yd=class extends Kd{kr(e,t){try{return q.newValue({booleanValue:Er.compile(t).matches(e)})}catch{return Nr(`Invalid regex pattern found in regex_match: ${t}, returning error`),q.vr()}}},Xd=class extends Kd{kr(e,t){return q.newValue({booleanValue:e.includes(t)})}},Zd=class extends Kd{kr(e,t){return q.newValue({booleanValue:e.startsWith(t)})}},Qd=class extends Kd{kr(e,t){return q.newValue({booleanValue:e.endsWith(t)})}},$d=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,29079);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`STRING`:return q.newValue({stringValue:n.value?.stringValue?.toLowerCase()});case`NULL`:return q.Dr();default:return q.vr()}}},ef=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,60487);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`STRING`:return q.newValue({stringValue:n.value?.stringValue?.toUpperCase()});case`NULL`:return q.Dr();default:return q.vr()}}},tf=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,28544);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`STRING`:return q.newValue({stringValue:n.value?.stringValue?.trim()});case`NULL`:return q.Dr();default:return q.vr()}}},nf=class{constructor(e){this.expr=e}evaluate(e,t){let n=this.expr.params.map((n=>J(n).evaluate(e,t))),r=``,i=!1;for(let e of n)switch(e.type){case`STRING`:r+=e.value.stringValue;break;case`NULL`:i=!0;break;default:return q.vr()}return i?q.Dr():q.newValue({stringValue:r})}},rf=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,4483);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`UNSET`:return q.Sr();case`MAP`:break;default:return q.vr()}let r=J(this.expr.params[1]).evaluate(e,t);if(r.type!==`STRING`)return q.vr();let i=n.value?.mapValue?.fields?.[r.value?.stringValue];return i===void 0?q.Sr():q.newValue(i)}},af=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,25231,`${this.expr.name}() function should have exactly 2 params`);let n=!1,r=J(this.expr.params[0]).evaluate(e,t);switch(r.type){case`VECTOR`:break;case`NULL`:n=!0;break;default:return q.vr()}let i=J(this.expr.params[1]).evaluate(e,t);switch(i.type){case`VECTOR`:break;case`NULL`:n=!0;break;default:return q.vr()}if(n)return q.Dr();let a=Na(r.value),o=Na(i.value);if(a===void 0||o===void 0||a.values?.length!==o.values?.length)return q.vr();let s=this.qr(a,o);return s===void 0||isNaN(s)?q.vr():q.newValue({doubleValue:s})}},of=class extends af{qr(e,t){let n=e?.values??[],r=t?.values??[];if(n.length===0)return;let i=0,a=0,o=0;for(let e=0;e<n.length;e++){if(!Da(n[e])||!Da(r[e]))return;let t=td(n[e]),s=td(r[e]);i+=t*s,a+=t*t,o+=s*s}let s=Math.sqrt(a)*Math.sqrt(o);if(s!==0)return 1-Math.max(-1,Math.min(1,i/s))}},sf=class extends af{qr(e,t){let n=e?.values??[],r=t?.values??[];if(n.length===0)return 0;let i=0;for(let e=0;e<n.length;e++){if(!Da(n[e])||!Da(r[e]))return;i+=td(n[e])*td(r[e])}return i}},cf=class extends af{qr(e,t){let n=e?.values??[],r=t?.values??[];if(n.length===0)return 0;let i=0;for(let e=0;e<n.length;e++){if(!Da(n[e])||!Da(r[e]))return;let t=td(n[e]),a=td(r[e]);i+=(t-a)**2}return Math.sqrt(i)}},lf=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,39044);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`VECTOR`:{let e=Na(n.value);return q.newValue({integerValue:e?.values?.length??0})}case`NULL`:return q.Dr();default:return q.vr()}}},uf=BigInt(-62135596800),df=BigInt(253402300799),ff=BigInt(1e3),pf=BigInt(1e6),mf=uf*ff,hf=df*ff+BigInt(999),gf=uf*pf,_f=df*pf+BigInt(999999);function vf(e){return e>=gf&&e<=_f}function yf(e){return e>=uf&&e<=df}function bf(e,t){let n=BigInt(e);return!(n<uf||n>df)&&!(t<0||t>=1e9)&&(n!==uf||t===0)&&!(n===df&&t>999999999)}function xf(e,t){return t<0?{seconds:e-1,nanos:t+1e9}:{seconds:e,nanos:t}}function Sf(e){return BigInt(e.seconds)*pf+BigInt(Math.trunc(e.nanoseconds/1e3))}var Cf=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,49262,`${this.expr.name}() function should have exactly one parameter`);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`INT`:return this.toTimestamp(BigInt(n.value.integerValue));case`NULL`:return q.Dr();default:return q.vr()}}},wf=class extends Cf{toTimestamp(e){if(!vf(e))return q.vr();let t=Number(e/pf),n=Number(e%pf*BigInt(1e3)),r=xf(t,n);return t=r.seconds,n=r.nanos,bf(t,n)?q.newValue({timestampValue:{seconds:t,nanos:n}}):q.vr()}},Tf=class extends Cf{toTimestamp(e){if(!function(e){return e>=mf&&e<=hf}(e))return q.vr();let t=Number(e/ff),n=Number(e%ff*BigInt(1e6)),r=xf(t,n);return t=r.seconds,n=r.nanos,bf(t,n)?q.newValue({timestampValue:{seconds:t,nanos:n}}):q.vr()}},Ef=class extends Cf{toTimestamp(e){if(!yf(e))return q.vr();let t=Number(e);return q.newValue({timestampValue:{seconds:t,nanos:0}})}},Df=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,1265,`${this.expr.name}() function should have exactly one parameter`);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`TIMESTAMP`:break;case`NULL`:return q.Dr();default:return q.vr()}let r=nc(n.value.timestampValue);return bf(r.seconds,r.nanoseconds)?this.$r(r):q.vr()}},Of=class extends Df{$r(e){let t=Sf(e);return vf(t)?q.newValue({integerValue:`${t.toString()}`}):q.vr()}},kf=class extends Df{$r(e){let t=Sf(e),n=t/BigInt(1e3),r=t%BigInt(1e3);return n>BigInt(0)||r===BigInt(0)?q.newValue({integerValue:n.toString()}):q.newValue({integerValue:(n-BigInt(1)).toString()})}},Af=class extends Df{$r(e){let t=BigInt(e.seconds);return yf(t)?q.newValue({integerValue:t.toString()}):q.vr()}},jf=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===3,2775,`${this.expr.name}() function should have exactly 3 parameters`);let n=!1,r=J(this.expr.params[0]).evaluate(e,t);switch(r.type){case`TIMESTAMP`:break;case`NULL`:n=!0;break;default:return q.vr()}let i=J(this.expr.params[1]).evaluate(e,t),a;switch(i.type){case`STRING`:if(a=function(e){switch(e){case`microsecond`:return`microsecond`;case`millisecond`:return`millisecond`;case`second`:return`second`;case`minute`:return`minute`;case`hour`:return`hour`;case`day`:return`day`;default:return}}(i.value.stringValue),a===void 0)return q.vr();break;case`NULL`:n=!0;break;default:return q.vr()}let o=J(this.expr.params[2]).evaluate(e,t);switch(o.type){case`INT`:break;case`NULL`:n=!0;break;default:return q.vr()}if(n)return q.Dr();let s=BigInt(o.value.integerValue),c;try{switch(a){case`microsecond`:c=s;break;case`millisecond`:c=s*BigInt(1e3);break;case`second`:c=s*BigInt(1e6);break;case`minute`:c=s*BigInt(6e7);break;case`hour`:c=s*BigInt(36e8);break;case`day`:c=s*BigInt(864e8);break;default:return q.vr()}if(a!==`microsecond`&&s!==BigInt(0)&&c/s!==BigInt(this.Kr(a)))return q.vr()}catch(e){return Nr(`Error during timestamp arithmetic: ${e}`),q.vr()}let l=nc(r.value.timestampValue);if(!bf(l.seconds,l.nanoseconds))return q.vr();let u=Sf(l),d=this.Wr(u,c);if(!vf(d))return q.vr();let f=Number(d/pf),p=d%pf,m=Number((p<0?p+pf:p)*BigInt(1e3)),h=p<0?f-1:f;return bf(h,m)?q.newValue({timestampValue:{seconds:h,nanos:m}}):q.vr()}Kr(e){switch(e){case`millisecond`:return 1e3;case`second`:return 1e6;case`minute`:return 6e7;case`hour`:return 36e8;case`day`:return 864e8;default:return 1}}},Mf=class extends jf{Wr(e,t){return e+t}},Nf=class extends jf{Wr(e,t){return e-t}};function Pf(e){if((e=Zu(e))instanceof pu)return`fld(${e.fieldName})`;if(e instanceof gu)return`cst(${function(e){return e===null?`null`:typeof e==`number`?e.toString():typeof e==`string`?`"${e}"`:e instanceof Al?`ref(${e.path})`:e instanceof Pl?`vec(${JSON.stringify(e)})`:JSON.stringify(e)}(e.value)})`;if(e instanceof K)return`fn(${e.name},[${e.params.map(Pf).join(`,`)}])`;if(e.expressionType===`ListOfExpressions`)return`list([${e.Rr.map(Pf).join(`,`)}])`;throw Error(`Unrecognized expr ${JSON.stringify(e,null,2)}`)}function Ff(e){if(e instanceof ku)return`${e._name}(${If(e.fields)})`;if(e instanceof Au){let t=`${e._name}(${If(e.accumulators)})`;return e.groups.size>0&&(t+=`grouping(${If(e.groups)})`),t}if(e instanceof ju)return`${e._name}(${If(e.groups)})`;if(e instanceof Mu)return`${e._name}(${e.Vr})`;if(e instanceof Nu)return`${e._name}(${e.collectionId})`;if(e instanceof Pu)return`${e._name}()`;if(e instanceof Fu)return`${e._name}(${e.dr.sort()})`;if(e instanceof Iu)return`${e._name}(${Pf(e.condition)})`;if(e instanceof Lu)return`${e._name}(${e.limit})`;if(e instanceof Bu)return`${e._name}(${function(e){return e.map((e=>`${Pf(e.expr)}${e.direction}`)).join(`,`)}(e.orderings)})`;throw Error(`Unrecognized stage ${e._name}`)}function If(e){return`${Array.from(e.entries()).sort().map((([e,t])=>`${e}=${Pf(t)}`)).join(`,`)}`}function Lf(e){return e.stages.map((e=>Ff(e))).join(`|`)}function Rf(e,t){return Lf(e)===Lf(t)}function zf(e){return e instanceof Uu}function Bf(e){return zf(e)?Lf(e):fs(e)}function Vf(e){return zf(e)?Lf(e):function(e){return`${qo(is(e))}|lt:${e.limitType}`}(e)}function Hf(e,t){return e instanceof Uu&&t instanceof Uu?Rf(e,t):!(e instanceof Uu&&!(t instanceof Uu)||!(e instanceof Uu)&&t instanceof Uu)&&ds(e,t)}function Uf(e){return Yo(e)?Lf(e):qo(e)}function Wf(e,t){return e instanceof Uu&&t instanceof Uu?Rf(e,t):!(e instanceof Uu&&!(t instanceof Uu)||!(e instanceof Uu)&&t instanceof Uu)&&Jo(e,t)}function Gf(e,t){let n=function(e){let t=!1,n=[];for(let r of e)if(r instanceof Bu)if(t=!0,r.orderings.some((e=>e.expr instanceof pu&&e.expr.fieldName===Qr)))n.push(r);else{let e=r.orderings.map((e=>e));e.push(mu(Qr).ascending()),n.push(new Bu(e,{}))}else r instanceof Lu&&(t||=(n.push(new Bu([mu(Qr).ascending()],{})),!0)),n.push(r);return t||n.push(new Bu([mu(Qr).ascending()],{})),n}(e.stages);if(e.userDataReader){let t=e.userDataReader.createContext(3,`toCorePipeline`);n.forEach((e=>e._readUserData(t)))}return new Uu(e.userDataReader.serializer,n,t)}var Kf=class{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){let n=t.mutationResults;for(let t=0;t<this.mutations.length;t++){let r=this.mutations[t];r.key.isEqual(e.key)&&lo(r,e,n[t])}}applyToLocalView(e,t){for(let n of this.baseMutations)n.key.isEqual(e.key)&&(t=uo(n,e,t,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(e.key)&&(t=uo(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let n=Ds();return this.mutations.forEach((r=>{let i=e.get(r.key),a=i.overlayedDocument,o=this.applyToLocalView(a,i.mutatedFields);o=t.has(r.key)?null:o;let s=co(a,o);s!==null&&n.set(r.key,s),a.isValidDocument()||a.convertToNoDocument(z.min())})),n}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),W())}isEqual(e){return this.batchId===e.batchId&&Zr(this.mutations,e.mutations,((e,t)=>po(e,t)))&&Zr(this.baseMutations,e.baseMutations,((e,t)=>po(e,t)))}},qf=class e{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(t,n,r){M(t.mutations.length===r.length,58842,{Qr:t.mutations.length,Gr:r.length});let i=function(){return ks}(),a=t.mutations;for(let e=0;e<a.length;e++)i=i.insert(a[e].key,r[e].version);return new e(t,n,r,i)}},Jf=class{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{\n largestBatchId: ${this.largestBatchId},\n mutation: ${this.mutation.toString()}\n }`}},Yf=class e{constructor(e,t,n,r,i=z.min(),a=z.min(),o=Ki.EMPTY_BYTE_STRING,s=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=o,this.expectedCount=s}withSequenceNumber(t){return new e(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(t,n){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,t,null)}withExpectedCount(t){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,t)}withLastLimboFreeSnapshotVersion(t){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken,this.expectedCount)}},Xf=class{constructor(e){this.zr=e}};function Zf(e){let t=Sc({parent:e.parent,structuredQuery:e.structuredQuery});return e.limitType===`LAST`?ls(t,t.limit,`L`):t}var Qf=class{constructor(){}Yr(e,t){this.Zr(e,t),t.Xr()}Zr(e,t){if(`nullValue`in e)this.ei(t,5);else if(`booleanValue`in e)this.ei(t,10),t.ti(+!!e.booleanValue);else if(`integerValue`in e)this.ei(t,15),t.ti(H(e.integerValue));else if(`doubleValue`in e){let n=H(e.doubleValue);isNaN(n)?this.ei(t,13):(this.ei(t,15),ki(n)?t.ti(0):t.ti(n))}else if(`timestampValue`in e){let n=e.timestampValue;this.ei(t,20),typeof n==`string`&&(n=Ji(n)),t.ni(`${n.seconds||``}`),t.ti(n.nanos||0)}else if(`stringValue`in e)this.ri(e.stringValue,t),this.ii(t);else if(`bytesValue`in e)this.ei(t,30),t.si(Yi(e.bytesValue)),this.ii(t);else if(`referenceValue`in e)this._i(e.referenceValue,t);else if(`geoPointValue`in e){let n=e.geoPointValue;this.ei(t,45),t.ti(n.latitude||0),t.ti(n.longitude||0)}else`mapValue`in e?Fa(e)?this.ei(t,2**53-1):Ma(e)?this.oi(e.mapValue,t):(this.ai(e.mapValue,t),this.ii(t)):`arrayValue`in e?(this.ui(e.arrayValue,t),this.ii(t)):j(19022,{ci:e})}ri(e,t){this.ei(t,25),this.li(e,t)}li(e,t){t.ni(e)}ai(e,t){let n=e.fields||{};this.ei(t,55);for(let e of Object.keys(n))this.ri(e,t),this.Zr(n[e],t)}oi(e,t){let n=e.fields||{};this.ei(t,53);let r=da,i=n[r].arrayValue?.values?.length||0;this.ei(t,15),t.ti(H(i)),this.ri(r,t),this.Zr(n[r],t)}ui(e,t){let n=e.values||[];this.ei(t,50);for(let e of n)this.Zr(e,t)}_i(e,t){this.ei(t,37),R.fromName(e).path.forEach((e=>{this.ei(t,60),this.li(e,t)}))}ei(e,t){e.ti(t)}ii(e){e.ti(2)}};Qf.Ei=new Qf;var $f=class{constructor(){this.Hi=new ep}addToCollectionParentIndex(e,t){return this.Hi.add(t),B.resolve()}getCollectionParents(e,t){return B.resolve(this.Hi.getEntries(t))}addFieldIndex(e,t){return B.resolve()}deleteFieldIndex(e,t){return B.resolve()}deleteAllFieldIndexes(e){return B.resolve()}createTargetIndexes(e,t){return B.resolve()}getDocumentsMatchingTarget(e,t){return B.resolve(null)}getIndexType(e,t){return B.resolve(0)}getFieldIndexes(e,t){return B.resolve([])}getNextCollectionGroupToUpdate(e){return B.resolve(null)}getMinOffset(e,t){return B.resolve(yi.min())}getMinOffsetFromCollectionGroup(e,t){return B.resolve(yi.min())}updateCollectionGroup(e,t,n){return B.resolve()}updateIndexEntries(e,t){return B.resolve()}},ep=class{constructor(){this.index={}}add(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new Ri(L.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}has(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}getEntries(e){return(this.index[e]||new Ri(L.comparator)).toArray()}},tp=class e{constructor(e){this.Ds=e}next(){return this.Ds+=2,this.Ds}static xs(){return new e(0)}static Cs(){return new e(-1)}};function np(e,t){let n=t;for(let t of e.stages)n=ap({serializer:e.serializer,serverTimestampBehavior:e.listenOptions?.serverTimestampBehavior},t,n);return n}function rp(e,t){return np(e,[t]).length>0}function ip(e,t){return zf(e)?rp(e,t):ps(e,t)}function ap(e,t,n){if(t instanceof Mu)return function(e,t,n){return n.filter((e=>e.isFoundDocument()&&`/${e.key.getCollectionPath().canonicalString()}`===t.Vr))}(0,t,n);if(t instanceof Iu)return function(e,t,n){return n.filter((n=>{let r=Xu(J(t.condition).evaluate(e,n));return r!==void 0&&ga(r,pa)}))}(e,t,n);if(t instanceof Nu)return function(e,t,n){return n.filter((e=>e.isFoundDocument()&&e.key.getCollectionPath().lastSegment()===t.collectionId))}(0,t,n);if(t instanceof Pu)return function(e,t,n){return n.filter((e=>e.isFoundDocument()))}(0,0,n);if(t instanceof Fu)return function(e,t,n){return n.filter((e=>e.isFoundDocument()&&t.mr.has(e.key.path.toStringWithLeadingSlash())))}(0,t,n);if(t instanceof Lu)return function(e,t,n){return n.slice(0,t.limit)}(0,t,n);if(t instanceof Bu)return function(e,t,n){let r=t.orderings.map((e=>({ks:J(e.expr),direction:e.direction})));return[...n].sort(((t,n)=>{for(let{ks:i,direction:a}of r){let r=Xu(i.evaluate(e,t)),o=Xu(i.evaluate(e,n)),s=va(r??fa,o??fa);if(s!==0)return a===`ascending`?s:-s}return 0}))}(e,t,n);throw Error(`Unknown stage: ${t._name}`)}function op(e){let t=function(e){for(let t=e.stages.length-1;t>=0;t--){let n=e.stages[t];if(n instanceof Bu)return n.orderings}throw Error(`Pipeline must contain at least one Sort stage`)}(e);return(n,r)=>{for(let i of t){let t=Xu(J(i.expr).evaluate({serializer:e.serializer},n)),a=Xu(J(i.expr).evaluate({serializer:e.serializer},r)),o=va(t||fa,a||fa);if(o!==0)return i.direction===`ascending`?o:-o}return 0}}function sp(e){for(let t=e.stages.length-1;t>=0;t--){let n=e.stages[t];if(n instanceof Lu)return{limit:n.limit}}}var cp=class{constructor(){this.changes=new bs((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,Wo.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let n=this.changes.get(t);return n===void 0?this.getFromCache(e,t):B.resolve(n)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}},lp=class{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}},up=class{constructor(e,t,n,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=r}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next((r=>(n=r,this.remoteDocumentCache.getEntry(e,t)))).next((e=>(n!==null&&uo(n.mutation,e,Bi.empty(),mi.now()),e)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.getLocalViewOfDocuments(e,t,W()).next((()=>t))))}getLocalViewOfDocuments(e,t,n=W()){let r=Es();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,n).next((e=>{let t=ws();return e.forEach(((e,n)=>{t=t.insert(e,n.overlayedDocument)})),t}))))}getOverlayedDocuments(e,t){let n=Es();return this.populateOverlays(e,n,t).next((()=>this.computeViews(e,t,n,W())))}populateOverlays(e,t,n){let r=[];return n.forEach((e=>{t.has(e)||r.push(e)})),this.documentOverlayCache.getOverlays(e,r).next((e=>{e.forEach(((e,n)=>{t.set(e,n)}))}))}computeViews(e,t,n,r){let i=Ss(),a=Os(),o=function(){return Os()}();return t.forEach(((e,t)=>{let o=n.get(t.key);r.has(t.key)&&(o===void 0||o.mutation instanceof ho)?i=i.insert(t.key,t):o===void 0?a.set(t.key,Bi.empty()):(a.set(t.key,o.mutation.getFieldMask()),uo(o.mutation,t,o.mutation.getFieldMask(),mi.now()))})),this.recalculateAndSaveOverlays(e,i).next((e=>(e.forEach(((e,t)=>a.set(e,t))),t.forEach(((e,t)=>o.set(e,new lp(t,a.get(e)??null)))),o)))}recalculateAndSaveOverlays(e,t){let n=Os(),r=new V(((e,t)=>e-t)),i=W();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((e=>{for(let i of e)i.keys().forEach((e=>{let a=t.get(e);if(a===null)return;let o=n.get(e)||Bi.empty();o=i.applyToLocalView(a,o),n.set(e,o);let s=(r.get(i.batchId)||W()).add(e);r=r.insert(i.batchId,s)}))})).next((()=>{let a=[],o=r.getReverseIterator();for(;o.hasNext();){let r=o.getNext(),s=r.key,c=r.value,l=Ds();c.forEach((e=>{if(!i.has(e)){let r=co(t.get(e),n.get(e));r!==null&&l.set(e,r),i=i.add(e)}})),a.push(this.documentOverlayCache.saveOverlays(e,s,l))}return B.waitFor(a)})).next((()=>n))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.recalculateAndSaveOverlays(e,t)))}getDocumentsMatchingQuery(e,t,n,r){return zf(t)?this.getDocumentsMatchingPipeline(e,t,n,r):ts(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):ns(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,r):this.getDocumentsMatchingCollectionQuery(e,t,n,r)}getNextDocuments(e,t,n,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next((i=>{let a=r-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-i.size):B.resolve(Es()),o=hi,s=i;return a.next((t=>B.forEach(t,((t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),i.get(t)?B.resolve():this.remoteDocumentCache.getEntry(e,t).next((e=>{s=s.insert(t,e)}))))).next((()=>this.populateOverlays(e,t,i))).next((()=>this.computeViews(e,s,t,W()))).next((e=>({batchId:o,changes:Ts(e)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new R(t)).next((e=>{let t=ws();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t}))}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){let i=t.collectionGroup,a=ws();return this.indexManager.getCollectionParents(e,i).next((o=>B.forEach(o,(o=>{let s=function(e,t){return new Zo(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,o.child(i));return this.getDocumentsMatchingCollectionQuery(e,s,n,r).next((e=>{e.forEach(((e,t)=>{a=a.insert(e,t)}))}))})).next((()=>a))))}getDocumentsMatchingCollectionQuery(e,t,n,r){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next((a=>(i=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,i,r)))).next((e=>this.retrieveMatchingLocalDocuments(i,e,(e=>ps(t,e)))))}getDocumentsMatchingPipeline(e,t,n,r){if(Wu(t)===`collection_group`){let i=Ku(t),a=ws();return this.indexManager.getCollectionParents(e,i).next((o=>B.forEach(o,(o=>{let s=function(e,t){let n=e.stages.map((e=>e instanceof Nu?new Mu(t.canonicalString(),{}):e));return new Uu(e.serializer,n)}(t,o.child(i));return this.getDocumentsMatchingPipeline(e,s,n,r).next((e=>{e.forEach(((e,t)=>{a=a.insert(e,t)}))}))})).next((()=>a))))}{let i;return this.getOverlaysForPipeline(e,t,n.largestBatchId).next((a=>{switch(i=a,Wu(t)){case`collection`:return this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,i,r);case`documents`:let a=W();for(let e of Ju(t))a=a.add(R.fromPath(e));return this.remoteDocumentCache.getEntries(e,a);case`database`:return this.remoteDocumentCache.getAllEntries(e);default:throw new F(`invalid-argument`,`Invalid pipeline source to execute offline: ${Lf(t)}`)}})).next((e=>this.retrieveMatchingLocalDocuments(i,e,(e=>rp(t,e)))))}}retrieveMatchingLocalDocuments(e,t,n){e.forEach(((e,n)=>{let r=n.getKey();t.get(r)===null&&(t=t.insert(r,Wo.newInvalidDocument(r)))}));let r=ws();return t.forEach(((t,i)=>{let a=e.get(t);a!==void 0&&uo(a.mutation,i,Bi.empty(),mi.now()),n(i)&&(r=r.insert(t,i))})),r}getOverlaysForPipeline(e,t,n){switch(Wu(t)){case`collection`:return this.documentOverlayCache.getOverlaysForCollection(e,L.fromString(Gu(t)),n);case`collection_group`:throw new F(`invalid-argument`,`Unexpected collection group pipeline: ${Lf(t)}`);case`documents`:return this.documentOverlayCache.getOverlays(e,Ju(t).map((e=>R.fromPath(e))));case`database`:return this.documentOverlayCache.getAllOverlays(e,n);default:throw new F(`invalid-argument`,`Failed to get overlays for pipeline: ${Lf(t)}`)}}},dp=class{constructor(e){this.serializer=e,this.Hs=new Map,this.Js=new Map}getBundleMetadata(e,t){return B.resolve(this.Hs.get(t))}saveBundleMetadata(e,t){return this.Hs.set(t.id,function(e){return{id:e.id,version:e.version,createTime:ac(e.createTime)}}(t)),B.resolve()}getNamedQuery(e,t){return B.resolve(this.Js.get(t))}saveNamedQuery(e,t){return this.Js.set(t.name,function(e){return{name:e.name,query:Zf(e.bundledQuery),readTime:ac(e.readTime)}}(t)),B.resolve()}},fp=class{constructor(){this.overlays=new V(R.comparator),this.Ys=new Map}getOverlay(e,t){return B.resolve(this.overlays.get(t))}getOverlays(e,t){let n=Es();return B.forEach(t,(t=>this.getOverlay(e,t).next((e=>{e!==null&&n.set(t,e)})))).next((()=>n))}getAllOverlays(e,t){let n=Es();return this.overlays.forEach(((e,r)=>{r.largestBatchId>t&&n.set(e,r)})),B.resolve(n)}saveOverlays(e,t,n){return n.forEach(((n,r)=>{this.Hr(e,t,r)})),B.resolve()}removeOverlaysForBatchId(e,t,n){let r=this.Ys.get(n);return r!==void 0&&(r.forEach((e=>this.overlays=this.overlays.remove(e))),this.Ys.delete(n)),B.resolve()}getOverlaysForCollection(e,t,n){let r=Es(),i=t.length+1,a=new R(t.child(``)),o=this.overlays.getIteratorFrom(a);for(;o.hasNext();){let e=o.getNext().value,a=e.getKey();if(!t.isPrefixOf(a.path))break;a.path.length===i&&e.largestBatchId>n&&r.set(e.getKey(),e)}return B.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new V(((e,t)=>e-t)),a=this.overlays.getIterator();for(;a.hasNext();){let e=a.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=i.get(e.largestBatchId);t===null&&(t=Es(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let o=Es(),s=i.getIterator();for(;s.hasNext()&&(s.getNext().value.forEach(((e,t)=>o.set(e,t))),!(o.size()>=r)););return B.resolve(o)}Hr(e,t,n){let r=this.overlays.get(n.key);if(r!==null){let e=this.Ys.get(r.largestBatchId).delete(n.key);this.Ys.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new Jf(t,n));let i=this.Ys.get(t);i===void 0&&(i=W(),this.Ys.set(t,i)),this.Ys.set(t,i.add(n.key))}},pp=class{constructor(){this.sessionToken=Ki.EMPTY_BYTE_STRING}getSessionToken(e){return B.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,B.resolve()}},mp=class{constructor(){this.Zs=new Ri(hp.Xs),this.e_=new Ri(hp.t_)}isEmpty(){return this.Zs.isEmpty()}addReference(e,t){let n=new hp(e,t);this.Zs=this.Zs.add(n),this.e_=this.e_.add(n)}n_(e,t){e.forEach((e=>this.addReference(e,t)))}removeReference(e,t){this.r_(new hp(e,t))}i_(e,t){e.forEach((e=>this.removeReference(e,t)))}s_(e){let t=new R(new L([])),n=new hp(t,e),r=new hp(t,e+1),i=[];return this.e_.forEachInRange([n,r],(e=>{this.r_(e),i.push(e.key)})),i}__(){this.Zs.forEach((e=>this.r_(e)))}r_(e){this.Zs=this.Zs.delete(e),this.e_=this.e_.delete(e)}o_(e){let t=new R(new L([])),n=new hp(t,e),r=new hp(t,e+1),i=W();return this.e_.forEachInRange([n,r],(e=>{i=i.add(e.key)})),i}containsKey(e){let t=new hp(e,0),n=this.Zs.firstAfterOrEqual(t);return n!==null&&e.isEqual(n.key)}},hp=class{constructor(e,t){this.key=e,this.a_=t}static Xs(e,t){return R.comparator(e.key,t.key)||I(e.a_,t.a_)}static t_(e,t){return I(e.a_,t.a_)||R.comparator(e.key,t.key)}},gp=class{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.gs=1,this.u_=new Ri(hp.Xs)}checkEmpty(e){return B.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,n,r){let i=this.gs;this.gs++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let a=new Kf(i,t,n,r);this.mutationQueue.push(a);for(let t of r)this.u_=this.u_.add(new hp(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return B.resolve(a)}lookupMutationBatch(e,t){return B.resolve(this.c_(t))}getNextMutationBatchAfterBatchId(e,t){let n=t+1,r=this.l_(n),i=r<0?0:r;return B.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return B.resolve(this.mutationQueue.length===0?Di:this.gs-1)}getAllMutationBatches(e){return B.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let n=new hp(t,0),r=new hp(t,1/0),i=[];return this.u_.forEachInRange([n,r],(e=>{let t=this.c_(e.a_);i.push(t)})),B.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new Ri(I);return t.forEach((e=>{let t=new hp(e,0),r=new hp(e,1/0);this.u_.forEachInRange([t,r],(e=>{n=n.add(e.a_)}))})),B.resolve(this.E_(n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=n;R.isDocumentKey(i)||(i=i.child(``));let a=new hp(new R(i),0),o=new Ri(I);return this.u_.forEachWhile((e=>{let t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.a_)),!0)}),a),B.resolve(this.E_(o))}E_(e){let t=[];return e.forEach((e=>{let n=this.c_(e);n!==null&&t.push(n)})),t}removeMutationBatch(e,t){M(this.h_(t.batchId,`removed`)===0,55003),this.mutationQueue.shift();let n=this.u_;return B.forEach(t.mutations,(r=>{let i=new hp(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)})).next((()=>{this.u_=n}))}bs(e){}containsKey(e,t){let n=new hp(t,0),r=this.u_.firstAfterOrEqual(n);return B.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,B.resolve()}h_(e,t){return this.l_(e)}l_(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}c_(e){let t=this.l_(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}},_p=class{constructor(e){this.T_=e,this.docs=function(){return new V(R.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let n=t.key,r=this.docs.get(n),i=r?r.size:0,a=this.T_(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let n=this.docs.get(t);return B.resolve(n?n.document.mutableCopy():Wo.newInvalidDocument(t))}getEntries(e,t){let n=Ss();return t.forEach((e=>{let t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():Wo.newInvalidDocument(e))})),B.resolve(n)}getAllEntries(e){let t=Ss();return this.docs.forEach(((e,n)=>{t=t.insert(e,n.document)})),B.resolve(t)}getDocumentsMatchingQuery(e,t,n,r){let i,a;zf(t)?(i=L.fromString(Gu(t)),a=e=>rp(t,e)):(i=t.path,a=e=>ps(t,e));let o=Ss(),s=new R(i.child(`__id-9223372036854775808__`)),c=this.docs.getIteratorFrom(s);for(;c.hasNext();){let{key:e,value:{document:t}}=c.getNext();if(!i.isPrefixOf(e.path))break;e.path.length>i.length+1||bi(vi(t),n)<=0||(r.has(t.key)||a(t))&&(o=o.insert(t.key,t.mutableCopy()))}return B.resolve(o)}getAllFromCollectionGroup(e,t,n,r){j(9500)}P_(e,t){return B.forEach(this.docs,(e=>t(e)))}newChangeBuffer(e){return new vp(this)}getSize(e){return B.resolve(this.size)}},vp=class extends cp{constructor(e){super(),this.zs=e}applyChanges(e){let t=[];return this.changes.forEach(((n,r)=>{r.isValidDocument()?t.push(this.zs.addEntry(e,r)):this.zs.removeEntry(n)})),B.waitFor(t)}getFromCache(e,t){return this.zs.getEntry(e,t)}getAllFromCache(e,t){return this.zs.getEntries(e,t)}},yp=class{constructor(e){this.persistence=e,this.R_=new bs((e=>Uf(e)),Wf),this.lastRemoteSnapshotVersion=z.min(),this.highestTargetId=0,this.I_=0,this.A_=new mp,this.targetCount=0,this.V_=tp.xs()}forEachTarget(e,t){return this.R_.forEach(((e,n)=>t(n))),B.resolve()}getLastRemoteSnapshotVersion(e){return B.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return B.resolve(this.I_)}allocateTargetId(e){return this.highestTargetId=this.V_.next(),B.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.I_&&(this.I_=t),B.resolve()}Ms(e){this.R_.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.V_=new tp(t),this.highestTargetId=t),e.sequenceNumber>this.I_&&(this.I_=e.sequenceNumber)}addTargetData(e,t){return this.Ms(t),this.targetCount+=1,B.resolve()}updateTargetData(e,t){return this.Ms(t),B.resolve()}removeTargetData(e,t){return this.R_.delete(t.target),this.A_.s_(t.targetId),--this.targetCount,B.resolve()}removeTargets(e,t,n){let r=0,i=[];return this.R_.forEach(((a,o)=>{o.sequenceNumber<=t&&n.get(o.targetId)===null&&(this.R_.delete(a),i.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)})),B.waitFor(i).next((()=>r))}getTargetCount(e){return B.resolve(this.targetCount)}getTargetData(e,t){let n=this.R_.get(t)||null;return B.resolve(n)}addMatchingKeys(e,t,n){return this.A_.n_(t,n),B.resolve()}removeMatchingKeys(e,t,n){this.A_.i_(t,n);let r=this.persistence.referenceDelegate,i=[];return r&&t.forEach((t=>{i.push(r.markPotentiallyOrphaned(e,t))})),B.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.A_.s_(t),B.resolve()}getMatchingKeysForTargetId(e,t){let n=this.A_.o_(t);return B.resolve(n)}containsKey(e,t){return B.resolve(this.A_.containsKey(t))}},bp=class{constructor(e,t){this.d_={},this.overlays={},this.f_=new Ei(0),this.m_=!1,this.m_=!0,this.p_=new pp,this.referenceDelegate=e(this),this.g_=new yp(this),this.indexManager=new $f,this.remoteDocumentCache=function(e){return new _p(e)}((e=>this.referenceDelegate.y_(e))),this.serializer=new Xf(t),this.w_=new dp(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.m_=!1,Promise.resolve()}get started(){return this.m_}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new fp,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.d_[e.toKey()];return n||(n=new gp(t,this.referenceDelegate),this.d_[e.toKey()]=n),n}getGlobalsCache(){return this.p_}getTargetCache(){return this.g_}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.w_}runTransaction(e,t,n){A(`MemoryPersistence`,`Starting transaction:`,e);let r=new xp(this.f_.next());return this.referenceDelegate.b_(),n(r).next((e=>this.referenceDelegate.v_(r).next((()=>e)))).toPromise().then((e=>(r.raiseOnCommittedEvent(),e)))}S_(e,t){return B.or(Object.values(this.d_).map((n=>()=>n.containsKey(e,t))))}},xp=class extends Si{constructor(e){super(),this.currentSequenceNumber=e}},Sp=class e{constructor(e){this.persistence=e,this.D_=new mp,this.x_=null}static C_(t){return new e(t)}get F_(){if(this.x_)return this.x_;throw j(60996)}addReference(e,t,n){return this.D_.addReference(n,t),this.F_.delete(n.toString()),B.resolve()}removeReference(e,t,n){return this.D_.removeReference(n,t),this.F_.add(n.toString()),B.resolve()}markPotentiallyOrphaned(e,t){return this.F_.add(t.toString()),B.resolve()}removeTarget(e,t){this.D_.s_(t.targetId).forEach((e=>this.F_.add(e.toString())));let n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next((e=>{e.forEach((e=>this.F_.add(e.toString())))})).next((()=>n.removeTargetData(e,t)))}b_(){this.x_=new Set}v_(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return B.forEach(this.F_,(n=>{let r=R.fromPath(n);return this.O_(e,r).next((e=>{e||t.removeEntry(r,z.min())}))})).next((()=>(this.x_=null,t.apply(e))))}updateLimboDocument(e,t){return this.O_(e,t).next((e=>{e?this.F_.delete(t.toString()):this.F_.add(t.toString())}))}y_(e){return 0}O_(e,t){return B.or([()=>B.resolve(this.D_.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.S_(e,t)])}},Cp=class e{constructor(e,t){this.persistence=e,this.M_=new bs((e=>Ni(e.path)),((e,t)=>e.isEqual(t))),this.garbageCollector=Cl(this,t)}static C_(t,n){return new e(t,n)}b_(){}v_(e){return B.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}lr(e){let t=this.Ls(e);return this.persistence.getTargetCache().getTargetCount(e).next((e=>t.next((t=>e+t))))}Ls(e){let t=0;return this.Er(e,(e=>{t++})).next((()=>t))}Er(e,t){return B.forEach(this.M_,((n,r)=>this.Us(e,n,r).next((e=>e?B.resolve():t(r)))))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0,r=this.persistence.getRemoteDocumentCache(),i=r.newChangeBuffer();return r.P_(e,(r=>this.Us(e,r,t).next((e=>{e||(n++,i.removeEntry(r,z.min()))})))).next((()=>i.apply(e))).next((()=>n))}markPotentiallyOrphaned(e,t){return this.M_.set(t,e.currentSequenceNumber),B.resolve()}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.M_.set(n,e.currentSequenceNumber),B.resolve()}removeReference(e,t,n){return this.M_.set(n,e.currentSequenceNumber),B.resolve()}updateLimboDocument(e,t){return this.M_.set(t,e.currentSequenceNumber),B.resolve()}y_(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Ca(e.data.value)),t}Us(e,t,n){return B.or([()=>this.persistence.S_(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.M_.get(t);return B.resolve(e!==void 0&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}},wp=class e{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.wo=n,this.bo=r}static vo(t,n){let r=W(),i=W();for(let e of n.docChanges)switch(e.type){case 0:r=r.add(e.doc.key);break;case 1:i=i.add(e.doc.key)}return new e(t,n.fromCache,r,i)}};function Tp(e,t){return R.comparator(e.key,t.key)}var Ep=class{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}},Dp=class{constructor(){this.So=!1,this.Do=!1,this.xo=100,this.Co=function(){return ue()?8:wi(re())>0?6:4}()}initialize(e,t){this.Fo=e,this.indexManager=t,this.So=!0}getDocumentsMatchingQuery(e,t,n,r){let i={result:null};return this.Oo(e,t).next((e=>{i.result=e})).next((()=>{if(!i.result)return this.Mo(e,t,r,n).next((e=>{i.result=e}))})).next((()=>{if(i.result)return;let n=new Ep;return this.No(e,t,n).next((r=>{if(i.result=r,this.Do)return this.Lo(e,t,n,r.size)}))})).next((()=>i.result))}Lo(e,t,n,r){return zf(t)?B.resolve():n.documentReadCount<this.xo?(jr()<=v.DEBUG&&A(`QueryEngine`,`SDK will not create cache indexes for query:`,fs(t),`since it only creates cache indexes for collection contains`,`more than or equal to`,this.xo,`documents`),B.resolve()):(jr()<=v.DEBUG&&A(`QueryEngine`,`Query:`,fs(t),`scans`,n.documentReadCount,`local documents and returns`,r,`documents as results.`),n.documentReadCount>this.Co*r?(jr()<=v.DEBUG&&A(`QueryEngine`,`The SDK decides to create cache indexes for query:`,fs(t),`as using cache indexes may help improve performance.`),this.indexManager.createTargetIndexes(e,is(t))):B.resolve())}Oo(e,t){if(zf(t))return B.resolve(null);let n=t;if(es(n))return B.resolve(null);let r=is(n);return this.indexManager.getIndexType(e,r).next((t=>t===0?null:(n.limit!==null&&t===1&&(n=ls(n,null,`F`),r=is(n)),this.indexManager.getDocumentsMatchingTarget(e,r).next((t=>{let i=W(...t);return this.Fo.getDocuments(e,i).next((t=>this.indexManager.getMinOffset(e,r).next((r=>{let a=this.Bo(n,t);return this.Uo(n,a,i,r.readTime)?this.Oo(e,ls(n,null,`F`)):this.ko(e,a,n,r)}))))})))))}Mo(e,t,n,r){return(zf(t)?function(e){for(let t of e.stages){if(t instanceof Lu||t instanceof Ru)return!1;if(t instanceof Iu){if(t.condition instanceof bu&&t.condition._expr.name===`exists`&&t.condition._expr.params[0]instanceof pu&&t.condition._expr.params[0].fieldName===Qr)continue;return!1}}return!0}(t):es(t))||r.isEqual(z.min())?B.resolve(null):this.Fo.getDocuments(e,n).next((i=>{let a=this.Bo(t,i);return this.Uo(t,a,n,r)?B.resolve(null):(jr()<=v.DEBUG&&A(`QueryEngine`,`Re-using previous result from %s to execute query: %s`,r.toString(),Bf(t)),this.ko(e,a,t,_i(r,hi)).next((e=>e)))}))}Bo(e,t){let n,r;return zf(e)?(n=new Ri(Tp),r=t=>rp(e,t)):(n=new Ri(ms(e)),r=t=>ps(e,t)),t.forEach(((e,t)=>{r(t)&&(n=n.add(t))})),n}Uo(e,t,n,r){if(zf(e))return function(e){return e.stages.some((e=>e instanceof Lu||e instanceof Ru))}(e);if(e.limit===null)return!1;if(n.size!==t.size)return!0;let i=e.limitType===`F`?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}No(e,t,n){return jr()<=v.DEBUG&&A(`QueryEngine`,`Using full collection scan to execute query:`,Bf(t)),this.Fo.getDocumentsMatchingQuery(e,t,yi.min(),n)}ko(e,t,n,r){return this.Fo.getDocumentsMatchingQuery(e,n,r).next((e=>(t.forEach((t=>{e=e.insert(t.key,t)})),e)))}},Op=`LocalStore`,kp=3e8,Ap=class{constructor(e,t,n,r){this.persistence=e,this.qo=t,this.serializer=r,this.$o=new V(I),this.Ko=new bs((e=>Uf(e)),Wf),this.Wo=new Map,this.Qo=e.getRemoteDocumentCache(),this.g_=e.getTargetCache(),this.w_=e.getBundleCache(),this.Go(n)}Go(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new up(this.Qo,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Qo.setIndexManager(this.indexManager),this.qo.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction(`Collect garbage`,`readwrite-primary`,(t=>e.collect(t,this.$o)))}};function jp(e,t,n,r){return new Ap(e,t,n,r)}async function Mp(e,t){let n=N(e);return await n.persistence.runTransaction(`Handle user change`,`readonly`,(e=>{let r;return n.mutationQueue.getAllMutationBatches(e).next((i=>(r=i,n.Go(t),n.mutationQueue.getAllMutationBatches(e)))).next((t=>{let i=[],a=[],o=W();for(let e of r){i.push(e.batchId);for(let t of e.mutations)o=o.add(t.key)}for(let e of t){a.push(e.batchId);for(let t of e.mutations)o=o.add(t.key)}return n.localDocuments.getDocuments(e,o).next((e=>({zo:e,removedBatchIds:i,addedBatchIds:a})))}))}))}function Np(e,t){let n=N(e);return n.persistence.runTransaction(`Acknowledge batch`,`readwrite-primary`,(e=>{let r=t.batch.keys(),i=n.Qo.newChangeBuffer({trackRemovals:!0});return function(e,t,n,r){let i=n.batch,a=i.keys(),o=B.resolve();return a.forEach((e=>{o=o.next((()=>r.getEntry(t,e))).next((t=>{let a=n.docVersions.get(e);M(a!==null,48541),t.version.compareTo(a)<0&&(i.applyToRemoteDocument(t,n),t.isValidDocument()&&(t.setReadTime(n.commitVersion),r.addEntry(t)))}))})),o.next((()=>e.mutationQueue.removeMutationBatch(t,i)))}(n,e,t,i).next((()=>i.apply(e))).next((()=>n.mutationQueue.performConsistencyCheck(e))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=W();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,r)))}))}function Pp(e){let t=N(e);return t.persistence.runTransaction(`Get last remote snapshot version`,`readonly`,(e=>t.g_.getLastRemoteSnapshotVersion(e)))}function Fp(e,t){let n=N(e),r=t.snapshotVersion,i=n.$o;return n.persistence.runTransaction(`Apply remote event`,`readwrite-primary`,(e=>{let a=n.Qo.newChangeBuffer({trackRemovals:!0});i=n.$o;let o=[];t.targetChanges.forEach(((a,s)=>{let c=i.get(s);if(!c)return;o.push(n.g_.removeMatchingKeys(e,a.removedDocuments,s).next((()=>n.g_.addMatchingKeys(e,a.addedDocuments,s))));let l=c.withSequenceNumber(e.currentSequenceNumber);t.targetMismatches.get(s)===null?a.resumeToken.approximateByteSize()>0&&(l=l.withResumeToken(a.resumeToken,r)):l=l.withResumeToken(Ki.EMPTY_BYTE_STRING,z.min()).withLastLimboFreeSnapshotVersion(z.min()),i=i.insert(s,l),function(e,t,n){return e.resumeToken.approximateByteSize()===0||t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=kp?!0:n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(c,l,a)&&o.push(n.g_.updateTargetData(e,l))}));let s=Ss(),c=W();if(t.documentUpdates.forEach((r=>{t.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))})),o.push(Ip(e,a,t.documentUpdates).next((e=>{s=e.jo,c=e.Ho}))),!r.isEqual(z.min())){let t=n.g_.getLastRemoteSnapshotVersion(e).next((t=>n.g_.setTargetsMetadata(e,e.currentSequenceNumber,r)));o.push(t)}return B.waitFor(o).next((()=>a.apply(e))).next((()=>n.localDocuments.getLocalViewOfDocuments(e,s,c))).next((()=>s))})).then((e=>(n.$o=i,e)))}function Ip(e,t,n){let r=W(),i=W();return n.forEach((e=>r=r.add(e))),t.getEntries(e,r).next((e=>{let r=Ss();return n.forEach(((n,a)=>{let o=e.get(n);a.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),a.isNoDocument()&&a.version.isEqual(z.min())?(t.removeEntry(n,a.readTime),r=r.insert(n,a)):!o.isValidDocument()||a.version.compareTo(o.version)>0||a.version.compareTo(o.version)===0&&o.hasPendingWrites?(t.addEntry(a),r=r.insert(n,a)):A(Op,`Ignoring outdated watch update for `,n,`. Current version:`,o.version,` Watch version:`,a.version)})),{jo:r,Ho:i}}))}function Lp(e,t){let n=N(e);return n.persistence.runTransaction(`Get next mutation batch`,`readonly`,(e=>(t===void 0&&(t=Di),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t))))}function Rp(e,t){let n=N(e);return n.persistence.runTransaction(`Allocate target`,`readwrite`,(e=>{let r;return n.g_.getTargetData(e,t).next((i=>i?(r=i,B.resolve(r)):n.g_.allocateTargetId(e).next((i=>(r=new Yf(t,i,`TargetPurposeListen`,e.currentSequenceNumber),n.g_.addTargetData(e,r).next((()=>r)))))))})).then((e=>{let r=n.$o.get(e.targetId);return(r===null||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.$o=n.$o.insert(e.targetId,e),n.Ko.set(t,e.targetId)),e}))}async function zp(e,t,n){let r=N(e),i=r.$o.get(t),a=n?`readwrite`:`readwrite-primary`;try{n||await r.persistence.runTransaction(`Release target`,a,(e=>r.persistence.referenceDelegate.removeTarget(e,i)))}catch(e){if(!Ti(e))throw e;A(Op,`Failed to update sequence numbers for target ${t}: ${e}`)}r.$o=r.$o.remove(t),r.Ko.delete(i.target)}function Bp(e,t,n){let r=N(e),i=z.min(),a=W();return r.persistence.runTransaction(`Execute query`,`readwrite`,(e=>function(e,t,n){let r=N(e),i=r.Ko.get(n);return i===void 0?r.g_.getTargetData(t,n):B.resolve(r.$o.get(i))}(r,e,zf(t)?t:is(t)).next((t=>{if(t)return i=t.lastLimboFreeSnapshotVersion,r.g_.getMatchingKeysForTargetId(e,t.targetId).next((e=>{a=e}))})).next((()=>r.qo.getDocumentsMatchingQuery(e,t,n?i:z.min(),n?a:W()))).next((e=>(Vp(r,e),{documents:e,Jo:a})))))}function Vp(e,t){t.forEach(((t,n)=>{let r=n.key.getCollectionGroup(),i=e.Wo.get(r)||z.min();n.readTime.compareTo(i)>0&&e.Wo.set(r,n.readTime)}))}var Hp=class{constructor(){this.activeTargetIds=Ms()}na(e){this.activeTargetIds=this.activeTargetIds.add(e)}ra(e){this.activeTargetIds=this.activeTargetIds.delete(e)}ta(){let e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}},Up=class{constructor(){this.Ua=new Hp,this.ka={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.Ua.na(e),this.ka[e]||`not-current`}updateQueryState(e,t,n){this.ka[e]=t}removeLocalQueryTarget(e){this.Ua.ra(e)}isLocalQueryTarget(e){return this.Ua.activeTargetIds.has(e)}clearQueryState(e){delete this.ka[e]}getAllActiveQueryTargets(){return this.Ua.activeTargetIds}isActiveQueryTarget(e){return this.Ua.activeTargetIds.has(e)}start(){return this.Ua=new Hp,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}};function Wp(){return typeof document<`u`?document:null}var Gp=class{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state=`Unknown`,this.qa=0,this.$a=null,this.Ka=!0}Wa(){this.qa===0&&(this.Qa(`Unknown`),this.$a=this.asyncQueue.enqueueAfterDelay(`online_state_timeout`,1e4,(()=>(this.$a=null,this.Ga(`Backend didn't respond within 10 seconds.`),this.Qa(`Offline`),Promise.resolve()))))}za(e){this.state===`Online`?this.Qa(`Unknown`):(this.qa++,this.qa>=1&&(this.ja(),this.Ga(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.Qa(`Offline`)))}set(e){this.ja(),this.qa=0,e===`Online`&&(this.Ka=!1),this.Qa(e)}Qa(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}Ga(e){let 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.Ka?(Mr(t),this.Ka=!1):A(`OnlineStateTracker`,t)}ja(){this.$a!==null&&(this.$a.cancel(),this.$a=null)}},Kp=`RemoteStore`,qp=class{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Ha=[],this.Ja=new Map,this.Ya=new Map,this.Za=new Map,this.Xa=new tp(1e3),this.eu=new tp(1001),this.tu=new Set,this.nu=[],this.ru=i,this.ru.bt((e=>{n.enqueueAndForget((async()=>{rm(this)&&(A(Kp,`Restarting streams for network reachability change.`),await async function(e){let t=N(e);t.tu.add(4),await Yp(t),t.iu.set(`Unknown`),t.tu.delete(4),await Jp(t)}(this))}))})),this.iu=new Gp(n,r)}};async function Jp(e){if(rm(e))for(let t of e.nu)await t(!0)}async function Yp(e){for(let t of e.nu)await t(!1)}function Xp(e,t){return e.Ya.get(t)||void 0}function Zp(e,t){let n=N(e),r=Xp(n,t.targetId);if(r!==void 0&&n.Ja.has(r))return;let i=function(e,t){let n=Xp(e,t);n!==void 0&&e.Za.delete(n);let r=function(e,t){return t%2==0?e.Xa.next():e.eu.next()}(e,t);return e.Ya.set(t,r),e.Za.set(r,t),r}(n,t.targetId);A(Kp,`remoteStoreListen mapping SDK target ID to remote`,t.targetId,i);let a=new Yf(t.target,i,t.purpose,t.sequenceNumber,t.snapshotVersion,t.lastLimboFreeSnapshotVersion,t.resumeToken);n.Ja.set(i,a),nm(n)?tm(n):Sm(n).Fn()&&$p(n,a)}function Qp(e,t){let n=N(e),r=Sm(n),i=Xp(n,t);A(Kp,`remoteStoreUnlisten removing mapping of SDK target ID to remote`,t,i),n.Ja.delete(i),n.Ya.delete(t),n.Za.delete(i),r.Fn()&&em(n,i),n.Ja.size===0&&(r.Fn()?r.Nn():rm(n)&&n.iu.set(`Unknown`))}function $p(e,t){if(e.su.We(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(z.min())>0){let n=e.Za.get(t.targetId);if(n===void 0)return void A(Kp,`SDK target ID not found for remote ID: `+t.targetId);let r=e.remoteSyncer.getRemoteKeysForTarget(n).size;t=t.withExpectedCount(r)}Sm(e).jn(t)}function em(e,t){e.su.We(t),Sm(e).Hn(t)}function tm(e){e.su=new qs({getRemoteKeysForTarget:t=>{let n=e.Za.get(t);return n===void 0?W():e.remoteSyncer.getRemoteKeysForTarget(n)},dt:t=>e.Ja.get(t)||null,Tt:()=>e.datastore.serializer.databaseId}),Sm(e).start(),e.iu.Wa()}function nm(e){return rm(e)&&!Sm(e).Cn()&&e.Ja.size>0}function rm(e){return N(e).tu.size===0}function im(e){e.su=void 0}async function am(e){e.iu.set(`Online`)}async function om(e){e.Ja.forEach(((t,n)=>{$p(e,t)}))}async function sm(e,t){im(e),nm(e)?(e.iu.za(t),tm(e)):e.iu.set(`Unknown`)}async function cm(e,t,n){if(e.iu.set(`Online`),t instanceof Ws&&t.state===2&&t.cause)try{await async function(e,t){let n=t.cause;for(let r of t.targetIds){if(e.Ja.has(r)){let t=e.Za.get(r);t!==void 0&&(await e.remoteSyncer.rejectListen(t,n),e.Ya.delete(t),e.Za.delete(r)),e.Ja.delete(r)}e.su.removeTarget(r)}}(e,t)}catch(n){A(Kp,`Failed to remove targets %s: %s `,t.targetIds.join(`,`),n),await lm(e,n)}else if(t instanceof Hs?e.su.et(t):t instanceof Us?e.su.ot(t):e.su.rt(t),!n.isEqual(z.min()))try{let t=await Pp(e.localStore);n.compareTo(t)>=0&&await function(e,t){let n=e.su.Rt(t);n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){let i=e.Ja.get(r);i&&e.Ja.set(r,i.withResumeToken(n.resumeToken,t))}})),n.targetMismatches.forEach(((t,n)=>{let r=e.Ja.get(t);r&&(e.Ja.set(t,r.withResumeToken(Ki.EMPTY_BYTE_STRING,r.snapshotVersion)),em(e,t),$p(e,new Yf(r.target,t,n,r.sequenceNumber)))}));let r=function(e,t){let n=new Map;t.targetChanges.forEach(((t,r)=>{let i=e.Za.get(r);i!==void 0&&n.set(i,t)}));let r=new V(I);return t.targetMismatches.forEach(((t,n)=>{let i=e.Za.get(t);i!==void 0&&(r=r.insert(i,n))})),new Bs(t.snapshotVersion,n,r,t.documentUpdates,t.augmentedDocumentUpdates,t.resolvedLimboDocuments)}(e,n);return e.remoteSyncer.applyRemoteEvent(r)}(e,n)}catch(t){A(Kp,`Failed to raise snapshot:`,t),await lm(e,t)}}async function lm(e,t,n){if(!Ti(t))throw t;e.tu.add(1),await Yp(e),e.iu.set(`Offline`),n||=()=>Pp(e.localStore),e.asyncQueue.enqueueRetryable((async()=>{A(Kp,`Retrying IndexedDB access`),await n(),e.tu.delete(1),await Jp(e)}))}function um(e,t){return t().catch((n=>lm(e,n,t)))}async function dm(e){let t=N(e),n=Cm(t),r=t.Ha.length>0?t.Ha[t.Ha.length-1].batchId:Di;for(;fm(t);)try{let e=await Lp(t.localStore,r);if(e===null){t.Ha.length===0&&n.Nn();break}r=e.batchId,pm(t,e)}catch(e){await lm(t,e)}mm(t)&&hm(t)}function fm(e){return rm(e)&&e.Ha.length<10}function pm(e,t){e.Ha.push(t);let n=Cm(e);n.Fn()&&n.Jn&&n.Yn(t.mutations)}function mm(e){return rm(e)&&!Cm(e).Cn()&&e.Ha.length>0}function hm(e){Cm(e).start()}async function gm(e){Cm(e).er()}async function _m(e){let t=Cm(e);for(let n of e.Ha)t.Yn(n.mutations)}async function vm(e,t,n){let r=e.Ha.shift(),i=qf.from(r,t,n);await um(e,(()=>e.remoteSyncer.applySuccessfulWrite(i))),await dm(e)}async function ym(e,t){t&&Cm(e).Jn&&await async function(e,t){if(function(e){return vs(e)&&e!==P.ABORTED}(t.code)){let n=e.Ha.shift();Cm(e).Mn(),await um(e,(()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t))),await dm(e)}}(e,t),mm(e)&&hm(e)}async function bm(e,t){let n=N(e);n.asyncQueue.verifyOperationInProgress(),A(Kp,`RemoteStore received new credentials`);let r=rm(n);n.tu.add(3),await Yp(n),r&&n.iu.set(`Unknown`),await n.remoteSyncer.handleCredentialChange(t),n.tu.delete(3),await Jp(n)}async function xm(e,t){let n=N(e);t?(n.tu.delete(2),await Jp(n)):t||(n.tu.add(2),await Yp(n),n.iu.set(`Unknown`))}function Sm(e){return e._u||(e._u=function(e,t,n){let r=N(e);return r.nr(),new ol(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Qt:am.bind(null,e),zt:om.bind(null,e),Ht:sm.bind(null,e),zn:cm.bind(null,e)}),e.nu.push((async t=>{t?(e._u.Mn(),nm(e)?tm(e):e.iu.set(`Unknown`)):(await e._u.stop(),im(e))}))),e._u}function Cm(e){return e.ou||(e.ou=function(e,t,n){let r=N(e);return r.nr(),new sl(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Qt:()=>Promise.resolve(),zt:gm.bind(null,e),Ht:ym.bind(null,e),Zn:_m.bind(null,e),Xn:vm.bind(null,e)}),e.nu.push((async t=>{t?(e.ou.Mn(),await dm(e)):(await e.ou.stop(),e.Ha.length>0&&(A(Kp,`Stopping write stream with ${e.Ha.length} pending writes`),e.Ha=[]))}))),e.ou}var wm=class e{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new Ir,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((e=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(t,n,r,i,a){let o=new e(t,n,Date.now()+r,i,a);return o.start(r),o}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new F(P.CANCELLED,`Operation cancelled`+(e?`: `+e:``))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle===null?Promise.resolve():(this.clearTimeout(),this.op().then((e=>this.deferred.resolve(e))))))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}};function Tm(e,t){if(Mr(`AsyncQueue`,`${t}: ${e}`),Ti(e))return new F(P.UNAVAILABLE,`${t}: ${e}`);throw e}var Em=class e{static emptySet(t){return new e(t.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||R.comparator(t.key,n.key):(e,t)=>R.comparator(e.key,t.key),this.keyedMap=ws(),this.sortedSet=new V(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){let 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){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(t){if(!(t instanceof e)||this.size!==t.size)return!1;let n=this.sortedSet.getIterator(),r=t.sortedSet.getIterator();for(;n.hasNext();){let e=n.getNext().key,t=r.getNext().key;if(!e.isEqual(t))return!1}return!0}toString(){let e=[];return this.forEach((t=>{e.push(t.toString())})),e.length===0?`DocumentSet ()`:`DocumentSet (
|
|
33
30
|
`+e.join(`
|
|
34
31
|
`)+`
|
|
35
|
-
)`}copy(e,t){const r=new Bn;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}class Rl{constructor(){this.ga=new se(L.comparator)}track(e){const t=e.doc.key,r=this.ga.get(t);r?e.type!==0&&r.type===3?this.ga=this.ga.insert(t,e):e.type===3&&r.type!==1?this.ga=this.ga.insert(t,{type:r.type,doc:e.doc}):e.type===2&&r.type===2?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):e.type===2&&r.type===0?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):e.type===1&&r.type===0?this.ga=this.ga.remove(t):e.type===1&&r.type===2?this.ga=this.ga.insert(t,{type:1,doc:r.doc}):e.type===0&&r.type===1?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):x(63341,{Vt:e,pa:r}):this.ga=this.ga.insert(t,e)}ya(){const e=[];return this.ga.inorderTraversal((t,r)=>{e.push(r)}),e}}class qn{constructor(e,t,r,s,i,a,c,l,d){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=s,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=c,this.excludesMetadataChanges=l,this.hasCachedResults=d}static fromInitialDocuments(e,t,r,s,i){const a=[];return t.forEach(c=>{a.push({type:0,doc:c})}),new qn(e,t,Bn.emptySet(t),a,r,s,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Ns(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++)if(t[s].type!==r[s].type||!t[s].doc.isEqual(r[s].doc))return!1;return!0}}class Ay{constructor(){this.wa=void 0,this.ba=[]}Sa(){return this.ba.some(e=>e.Da())}}class Ry{constructor(){this.queries=bl(),this.onlineState="Unknown",this.Ca=new Set}terminate(){(function(t,r){const s=F(t),i=s.queries;s.queries=bl(),i.forEach((a,c)=>{for(const l of c.ba)l.onError(r)})})(this,new D(P.ABORTED,"Firestore shutting down"))}}function bl(){return new an(n=>Ru(n),Ns)}async function Bo(n,e){const t=F(n);let r=3;const s=e.query;let i=t.queries.get(s);i?!i.Sa()&&e.Da()&&(r=2):(i=new Ay,r=e.Da()?0:1);try{switch(r){case 0:i.wa=await t.onListen(s,!0);break;case 1:i.wa=await t.onListen(s,!1);break;case 2:await t.onFirstRemoteStoreListen(s)}}catch(a){const c=Fo(a,`Initialization of query '${Ln(e.query)}' failed`);return void e.onError(c)}t.queries.set(s,i),i.ba.push(e),e.va(t.onlineState),i.wa&&e.Fa(i.wa)&&jo(t)}async function qo(n,e){const t=F(n),r=e.query;let s=3;const i=t.queries.get(r);if(i){const a=i.ba.indexOf(e);a>=0&&(i.ba.splice(a,1),i.ba.length===0?s=e.Da()?0:1:!i.Sa()&&e.Da()&&(s=2))}switch(s){case 0:return t.queries.delete(r),t.onUnlisten(r,!0);case 1:return t.queries.delete(r),t.onUnlisten(r,!1);case 2:return t.onLastRemoteStoreUnlisten(r);default:return}}function by(n,e){const t=F(n);let r=!1;for(const s of e){const i=s.query,a=t.queries.get(i);if(a){for(const c of a.ba)c.Fa(s)&&(r=!0);a.wa=s}}r&&jo(t)}function Py(n,e,t){const r=F(n),s=r.queries.get(e);if(s)for(const i of s.ba)i.onError(t);r.queries.delete(e)}function jo(n){n.Ca.forEach(e=>{e.next()})}var $o,Pl;(Pl=$o||($o={})).Ma="default",Pl.Cache="cache";class zo{constructor(e,t,r){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState="Unknown",this.options=r||{}}Fa(e){if(!this.options.includeMetadataChanges){const r=[];for(const s of e.docChanges)s.type!==3&&r.push(s);e=new qn(e.query,e.docs,e.oldDocs,r,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){if(!e.fromCache||!this.Da())return!0;const r=t!=="Offline";return(!this.options.Ka||!r)&&(!e.docs.isEmpty()||e.hasCachedResults||t==="Offline")}Ba(e){if(e.docChanges.length>0)return!0;const t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&this.options.includeMetadataChanges===!0}ka(e){e=qn.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==$o.Cache}}class Cl{constructor(e){this.key=e}}class Sl{constructor(e){this.key=e}}class Cy{constructor(e,t){this.query=e,this.Za=t,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=G(),this.mutatedKeys=G(),this.eu=bu(e),this.tu=new Bn(this.eu)}get nu(){return this.Za}ru(e,t){const r=t?t.iu:new Rl,s=t?t.tu:this.tu;let i=t?t.mutatedKeys:this.mutatedKeys,a=s,c=!1;const l=this.query.limitType==="F"&&s.size===this.query.limit?s.last():null,d=this.query.limitType==="L"&&s.size===this.query.limit?s.first():null;if(e.inorderTraversal((f,m)=>{const _=s.get(f),R=Ds(this.query,m)?m:null,S=!!_&&this.mutatedKeys.has(_.key),N=!!R&&(R.hasLocalMutations||this.mutatedKeys.has(R.key)&&R.hasCommittedMutations);let k=!1;_&&R?_.data.isEqual(R.data)?S!==N&&(r.track({type:3,doc:R}),k=!0):this.su(_,R)||(r.track({type:2,doc:R}),k=!0,(l&&this.eu(R,l)>0||d&&this.eu(R,d)<0)&&(c=!0)):!_&&R?(r.track({type:0,doc:R}),k=!0):_&&!R&&(r.track({type:1,doc:_}),k=!0,(l||d)&&(c=!0)),k&&(R?(a=a.add(R),i=N?i.add(f):i.delete(f)):(a=a.delete(f),i=i.delete(f)))}),this.query.limit!==null)for(;a.size>this.query.limit;){const f=this.query.limitType==="F"?a.last():a.first();a=a.delete(f.key),i=i.delete(f.key),r.track({type:1,doc:f})}return{tu:a,iu:r,Ss:c,mutatedKeys:i}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,s){const i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;const a=e.iu.ya();a.sort((f,m)=>function(R,S){const N=k=>{switch(k){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return x(20277,{Vt:k})}};return N(R)-N(S)}(f.type,m.type)||this.eu(f.doc,m.doc)),this.ou(r),s=s??!1;const c=t&&!s?this._u():[],l=this.Ya.size===0&&this.current&&!s?1:0,d=l!==this.Xa;return this.Xa=l,a.length!==0||d?{snapshot:new qn(this.query,e.tu,i,a,e.mutatedKeys,l===0,d,!1,!!r&&r.resumeToken.approximateByteSize()>0),au:c}:{au:c}}va(e){return this.current&&e==="Offline"?(this.current=!1,this.applyChanges({tu:this.tu,iu:new Rl,mutatedKeys:this.mutatedKeys,Ss:!1},!1)):{au:[]}}uu(e){return!this.Za.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach(t=>this.Za=this.Za.add(t)),e.modifiedDocuments.forEach(t=>{}),e.removedDocuments.forEach(t=>this.Za=this.Za.delete(t)),this.current=e.current)}_u(){if(!this.current)return[];const e=this.Ya;this.Ya=G(),this.tu.forEach(r=>{this.uu(r.key)&&(this.Ya=this.Ya.add(r.key))});const t=[];return e.forEach(r=>{this.Ya.has(r)||t.push(new Sl(r))}),this.Ya.forEach(r=>{e.has(r)||t.push(new Cl(r))}),t}cu(e){this.Za=e.ks,this.Ya=G();const t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return qn.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Xa===0,this.hasCachedResults)}}const Wo="SyncEngine";class Sy{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class ky{constructor(e){this.key=e,this.hu=!1}}class Ny{constructor(e,t,r,s,i,a){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=s,this.currentUser=i,this.maxConcurrentLimboResolutions=a,this.Pu={},this.Tu=new an(c=>Ru(c),Ns),this.Iu=new Map,this.Eu=new Set,this.Ru=new se(L.comparator),this.Au=new Map,this.Vu=new bo,this.du={},this.mu=new Map,this.fu=xn.ar(),this.onlineState="Unknown",this.gu=void 0}get isPrimaryClient(){return this.gu===!0}}async function Dy(n,e,t=!0){const r=xl(n);let s;const i=r.Tu.get(e);return i?(r.sharedClientState.addLocalQueryTarget(i.targetId),s=i.view.lu()):s=await kl(r,e,t,!0),s}async function Oy(n,e){const t=xl(n);await kl(t,e,!0,!1)}async function kl(n,e,t,r){const s=await X_(n.localStore,it(e)),i=s.targetId,a=n.sharedClientState.addLocalQueryTarget(i,t);let c;return r&&(c=await Vy(n,e,i,a==="current",s.resumeToken)),n.isPrimaryClient&&t&&yl(n.remoteStore,s),c}async function Vy(n,e,t,r,s){n.pu=(m,_,R)=>async function(N,k,U,$){let j=k.view.ru(U);j.Ss&&(j=await hl(N.localStore,k.query,!1).then(({documents:w})=>k.view.ru(w,j)));const Q=$&&$.targetChanges.get(k.targetId),_e=$&&$.targetMismatches.get(k.targetId)!=null,re=k.view.applyChanges(j,N.isPrimaryClient,Q,_e);return Ml(N,k.targetId,re.au),re.snapshot}(n,m,_,R);const i=await hl(n.localStore,e,!0),a=new Cy(e,i.ks),c=a.ru(i.documents),l=Sr.createSynthesizedTargetChangeForCurrentChange(t,r&&n.onlineState!=="Offline",s),d=a.applyChanges(c,n.isPrimaryClient,l);Ml(n,t,d.au);const f=new Sy(e,t,a);return n.Tu.set(e,f),n.Iu.has(t)?n.Iu.get(t).push(e):n.Iu.set(t,[e]),d.snapshot}async function Ly(n,e,t){const r=F(n),s=r.Tu.get(e),i=r.Iu.get(s.targetId);if(i.length>1)return r.Iu.set(s.targetId,i.filter(a=>!Ns(a,e))),void r.Tu.delete(e);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(s.targetId),r.sharedClientState.isActiveQueryTarget(s.targetId)||await ko(r.localStore,s.targetId,!1).then(()=>{r.sharedClientState.clearQueryState(s.targetId),t&&Vo(r.remoteStore,s.targetId),Ho(r,s.targetId)}).catch(Sn)):(Ho(r,s.targetId),await ko(r.localStore,s.targetId,!0))}async function My(n,e){const t=F(n),r=t.Tu.get(e),s=t.Iu.get(r.targetId);t.isPrimaryClient&&s.length===1&&(t.sharedClientState.removeLocalQueryTarget(r.targetId),Vo(t.remoteStore,r.targetId))}async function xy(n,e,t){const r=zy(n);try{const s=await function(a,c){const l=F(a),d=ee.now(),f=c.reduce((R,S)=>R.add(S.key),G());let m,_;return l.persistence.runTransaction("Locally write mutations","readwrite",R=>{let S=Tt(),N=G();return l.xs.getEntries(R,f).next(k=>{S=k,S.forEach((U,$)=>{$.isValidDocument()||(N=N.add(U))})}).next(()=>l.localDocuments.getOverlayedDocuments(R,S)).next(k=>{m=k;const U=[];for(const $ of c){const j=Yg($,m.get($.key).overlayedDocument);j!=null&&U.push(new xt($.key,j,fu(j.value.mapValue),$e.exists(!0)))}return l.mutationQueue.addMutationBatch(R,d,U,c)}).next(k=>{_=k;const U=k.applyToLocalDocumentSet(m,N);return l.documentOverlayCache.saveOverlays(R,k.batchId,U)})}).then(()=>({batchId:_.batchId,changes:Cu(m)}))}(r.localStore,e);r.sharedClientState.addPendingMutation(s.batchId),function(a,c,l){let d=a.du[a.currentUser.toKey()];d||(d=new se(H)),d=d.insert(c,l),a.du[a.currentUser.toKey()]=d}(r,s.batchId,t),await Dr(r,s.changes),await Ks(r.remoteStore)}catch(s){const i=Fo(s,"Failed to persist write");t.reject(i)}}async function Nl(n,e){const t=F(n);try{const r=await Q_(t.localStore,e);e.targetChanges.forEach((s,i)=>{const a=t.Au.get(i);a&&(J(s.addedDocuments.size+s.modifiedDocuments.size+s.removedDocuments.size<=1,22616),s.addedDocuments.size>0?a.hu=!0:s.modifiedDocuments.size>0?J(a.hu,14607):s.removedDocuments.size>0&&(J(a.hu,42227),a.hu=!1))}),await Dr(t,r,e)}catch(r){await Sn(r)}}function Dl(n,e,t){const r=F(n);if(r.isPrimaryClient&&t===0||!r.isPrimaryClient&&t===1){const s=[];r.Tu.forEach((i,a)=>{const c=a.view.va(e);c.snapshot&&s.push(c.snapshot)}),function(a,c){const l=F(a);l.onlineState=c;let d=!1;l.queries.forEach((f,m)=>{for(const _ of m.ba)_.va(c)&&(d=!0)}),d&&jo(l)}(r.eventManager,e),s.length&&r.Pu.J_(s),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}async function Uy(n,e,t){const r=F(n);r.sharedClientState.updateQueryState(e,"rejected",t);const s=r.Au.get(e),i=s&&s.key;if(i){let a=new se(L.comparator);a=a.insert(i,be.newNoDocument(i,B.min()));const c=G().add(i),l=new Fs(B.min(),new Map,new se(H),a,c);await Nl(r,l),r.Ru=r.Ru.remove(i),r.Au.delete(e),Go(r)}else await ko(r.localStore,e,!1).then(()=>Ho(r,e,t)).catch(Sn)}async function Fy(n,e){const t=F(n),r=e.batch.batchId;try{const s=await K_(t.localStore,e);Vl(t,r,null),Ol(t,r),t.sharedClientState.updateMutationState(r,"acknowledged"),await Dr(t,s)}catch(s){await Sn(s)}}async function By(n,e,t){const r=F(n);try{const s=await function(a,c){const l=F(a);return l.persistence.runTransaction("Reject batch","readwrite-primary",d=>{let f;return l.mutationQueue.lookupMutationBatch(d,c).next(m=>(J(m!==null,37113),f=m.keys(),l.mutationQueue.removeMutationBatch(d,m))).next(()=>l.mutationQueue.performConsistencyCheck(d)).next(()=>l.documentOverlayCache.removeOverlaysForBatchId(d,f,c)).next(()=>l.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(d,f)).next(()=>l.localDocuments.getDocuments(d,f))})}(r.localStore,e);Vl(r,e,t),Ol(r,e),r.sharedClientState.updateMutationState(e,"rejected",t),await Dr(r,s)}catch(s){await Sn(s)}}function Ol(n,e){(n.mu.get(e)||[]).forEach(t=>{t.resolve()}),n.mu.delete(e)}function Vl(n,e,t){const r=F(n);let s=r.du[r.currentUser.toKey()];if(s){const i=s.get(e);i&&(t?i.reject(t):i.resolve(),s=s.remove(e)),r.du[r.currentUser.toKey()]=s}}function Ho(n,e,t=null){n.sharedClientState.removeLocalQueryTarget(e);for(const r of n.Iu.get(e))n.Tu.delete(r),t&&n.Pu.yu(r,t);n.Iu.delete(e),n.isPrimaryClient&&n.Vu.Gr(e).forEach(r=>{n.Vu.containsKey(r)||Ll(n,r)})}function Ll(n,e){n.Eu.delete(e.path.canonicalString());const t=n.Ru.get(e);t!==null&&(Vo(n.remoteStore,t),n.Ru=n.Ru.remove(e),n.Au.delete(t),Go(n))}function Ml(n,e,t){for(const r of t)r instanceof Cl?(n.Vu.addReference(r.key,e),qy(n,r)):r instanceof Sl?(V(Wo,"Document no longer in limbo: "+r.key),n.Vu.removeReference(r.key,e),n.Vu.containsKey(r.key)||Ll(n,r.key)):x(19791,{wu:r})}function qy(n,e){const t=e.key,r=t.path.canonicalString();n.Ru.get(t)||n.Eu.has(r)||(V(Wo,"New document in limbo: "+t),n.Eu.add(r),Go(n))}function Go(n){for(;n.Eu.size>0&&n.Ru.size<n.maxConcurrentLimboResolutions;){const e=n.Eu.values().next().value;n.Eu.delete(e);const t=new L(X.fromString(e)),r=n.fu.next();n.Au.set(r,new ky(t)),n.Ru=n.Ru.insert(t,r),yl(n.remoteStore,new Ft(it(Ss(t.path)),r,"TargetPurposeLimboResolution",_s.ce))}}async function Dr(n,e,t){const r=F(n),s=[],i=[],a=[];r.Tu.isEmpty()||(r.Tu.forEach((c,l)=>{a.push(r.pu(l,e,t).then(d=>{if((d||t)&&r.isPrimaryClient){const f=d?!d.fromCache:t?.targetChanges.get(l.targetId)?.current;r.sharedClientState.updateQueryState(l.targetId,f?"current":"not-current")}if(d){s.push(d);const f=Co.Es(l.targetId,d);i.push(f)}}))}),await Promise.all(a),r.Pu.J_(s),await async function(l,d){const f=F(l);try{await f.persistence.runTransaction("notifyLocalViewChanges","readwrite",m=>C.forEach(d,_=>C.forEach(_.Ts,R=>f.persistence.referenceDelegate.addReference(m,_.targetId,R)).next(()=>C.forEach(_.Is,R=>f.persistence.referenceDelegate.removeReference(m,_.targetId,R)))))}catch(m){if(!kn(m))throw m;V(So,"Failed to update sequence numbers: "+m)}for(const m of d){const _=m.targetId;if(!m.fromCache){const R=f.vs.get(_),S=R.snapshotVersion,N=R.withLastLimboFreeSnapshotVersion(S);f.vs=f.vs.insert(_,N)}}}(r.localStore,i))}async function jy(n,e){const t=F(n);if(!t.currentUser.isEqual(e)){V(Wo,"User change. New user:",e.toKey());const r=await ul(t.localStore,e);t.currentUser=e,function(i,a){i.mu.forEach(c=>{c.forEach(l=>{l.reject(new D(P.CANCELLED,a))})}),i.mu.clear()}(t,"'waitForPendingWrites' promise is rejected due to a user change."),t.sharedClientState.handleUserChange(e,r.removedBatchIds,r.addedBatchIds),await Dr(t,r.Ns)}}function $y(n,e){const t=F(n),r=t.Au.get(e);if(r&&r.hu)return G().add(r.key);{let s=G();const i=t.Iu.get(e);if(!i)return s;for(const a of i){const c=t.Tu.get(a);s=s.unionWith(c.view.nu)}return s}}function xl(n){const e=F(n);return e.remoteStore.remoteSyncer.applyRemoteEvent=Nl.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=$y.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=Uy.bind(null,e),e.Pu.J_=by.bind(null,e.eventManager),e.Pu.yu=Py.bind(null,e.eventManager),e}function zy(n){const e=F(n);return e.remoteStore.remoteSyncer.applySuccessfulWrite=Fy.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=By.bind(null,e),e}class Qs{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Ws(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){return G_(this.persistence,new z_,e.initialUser,this.serializer)}Cu(e){return new cl(Po.Vi,this.serializer)}Du(e){return new ey}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}Qs.provider={build:()=>new Qs};class Wy extends Qs{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){J(this.persistence.referenceDelegate instanceof $s,46915);const r=this.persistence.referenceDelegate.garbageCollector;return new S_(r,e.asyncQueue,t)}Cu(e){const t=this.cacheSizeBytes!==void 0?Oe.withCacheSize(this.cacheSizeBytes):Oe.DEFAULT;return new cl(r=>$s.Vi(r,t),this.serializer)}}class Ko{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=r=>Dl(this.syncEngine,r,1),this.remoteStore.remoteSyncer.handleCredentialChange=jy.bind(null,this.syncEngine),await vy(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new Ry}()}createDatastore(e){const t=Ws(e.databaseInfo.databaseId),r=iy(e.databaseInfo);return ly(e.authCredentials,e.appCheckCredentials,r,t)}createRemoteStore(e){return function(r,s,i,a,c){return new dy(r,s,i,a,c)}(this.localStore,this.datastore,e.asyncQueue,t=>Dl(this.syncEngine,t,0),function(){return pl.v()?new pl:new ty}())}createSyncEngine(e,t){return function(s,i,a,c,l,d,f){const m=new Ny(s,i,a,c,l,d);return f&&(m.gu=!0),m}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await async function(t){const r=F(t);V(un,"RemoteStore shutting down."),r.Ea.add(5),await Nr(r),r.Aa.shutdown(),r.Va.set("Unknown")}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}Ko.provider={build:()=>new Ko};class Qo{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):Et("Uncaught Error in snapshot listener:",e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout(()=>{this.muted||e(t)},0)}}const qt="FirestoreClient";class Hy{constructor(e,t,r,s,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this._databaseInfo=s,this.user=Re.UNAUTHENTICATED,this.clientId=ro.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,async a=>{V(qt,"Received user=",a.uid),await this.authCredentialListener(a),this.user=a}),this.appCheckCredentials.start(r,a=>(V(qt,"Received new app check token=",a),this.appCheckCredentialListener(a,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();const e=new nt;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const r=Fo(t,"Failed to shutdown persistence");e.reject(r)}}),e.promise}}async function Yo(n,e){n.asyncQueue.verifyOperationInProgress(),V(qt,"Initializing OfflineComponentProvider");const t=n.configuration;await e.initialize(t);let r=t.initialUser;n.setCredentialChangeListener(async s=>{r.isEqual(s)||(await ul(e.localStore,s),r=s)}),e.persistence.setDatabaseDeletedListener(()=>n.terminate()),n._offlineComponents=e}async function Ul(n,e){n.asyncQueue.verifyOperationInProgress();const t=await Gy(n);V(qt,"Initializing OnlineComponentProvider"),await e.initialize(t,n.configuration),n.setCredentialChangeListener(r=>Al(e.remoteStore,r)),n.setAppCheckTokenChangeListener((r,s)=>Al(e.remoteStore,s)),n._onlineComponents=e}async function Gy(n){if(!n._offlineComponents)if(n._uninitializedComponentsProvider){V(qt,"Using user provided OfflineComponentProvider");try{await Yo(n,n._uninitializedComponentsProvider._offline)}catch(e){const t=e;if(!function(s){return s.name==="FirebaseError"?s.code===P.FAILED_PRECONDITION||s.code===P.UNIMPLEMENTED:!(typeof DOMException<"u"&&s instanceof DOMException)||s.code===22||s.code===20||s.code===11}(t))throw t;sn("Error using user provided cache. Falling back to memory cache: "+t),await Yo(n,new Qs)}}else V(qt,"Using default OfflineComponentProvider"),await Yo(n,new Wy(void 0));return n._offlineComponents}async function Jo(n){return n._onlineComponents||(n._uninitializedComponentsProvider?(V(qt,"Using user provided OnlineComponentProvider"),await Ul(n,n._uninitializedComponentsProvider._online)):(V(qt,"Using default OnlineComponentProvider"),await Ul(n,new Ko))),n._onlineComponents}function Ky(n){return Jo(n).then(e=>e.syncEngine)}function Qy(n){return Jo(n).then(e=>e.datastore)}async function Ys(n){const e=await Jo(n),t=e.eventManager;return t.onListen=Dy.bind(null,e.syncEngine),t.onUnlisten=Ly.bind(null,e.syncEngine),t.onFirstRemoteStoreListen=Oy.bind(null,e.syncEngine),t.onLastRemoteStoreUnlisten=My.bind(null,e.syncEngine),t}function Yy(n,e,t,r){const s=new Qo(r),i=new zo(e,s,t);return n.asyncQueue.enqueueAndForget(async()=>Bo(await Ys(n),i)),()=>{s.Nu(),n.asyncQueue.enqueueAndForget(async()=>qo(await Ys(n),i))}}function Jy(n,e,t={}){const r=new nt;return n.asyncQueue.enqueueAndForget(async()=>function(i,a,c,l,d){const f=new Qo({next:_=>{f.Nu(),a.enqueueAndForget(()=>qo(i,m));const R=_.docs.has(c);!R&&_.fromCache?d.reject(new D(P.UNAVAILABLE,"Failed to get document because the client is offline.")):R&&_.fromCache&&l&&l.source==="server"?d.reject(new D(P.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):d.resolve(_)},error:_=>d.reject(_)}),m=new zo(Ss(c.path),f,{includeMetadataChanges:!0,Ka:!0});return Bo(i,m)}(await Ys(n),n.asyncQueue,e,t,r)),r.promise}function Xy(n,e,t={}){const r=new nt;return n.asyncQueue.enqueueAndForget(async()=>function(i,a,c,l,d){const f=new Qo({next:_=>{f.Nu(),a.enqueueAndForget(()=>qo(i,m)),_.fromCache&&l.source==="server"?d.reject(new D(P.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):d.resolve(_)},error:_=>d.reject(_)}),m=new zo(c,f,{includeMetadataChanges:!0,Ka:!0});return Bo(i,m)}(await Ys(n),n.asyncQueue,e,t,r)),r.promise}function Zy(n,e,t){const r=new nt;return n.asyncQueue.enqueueAndForget(async()=>{try{const s=await Qy(n);r.resolve(async function(a,c,l){const d=F(a),{request:f,gt:m,parent:_}=g_(d.serializer,Vg(c),l);d.connection.Ko||delete f.parent;const R=(await d.jo("RunAggregationQuery",d.serializer.databaseId,_,f,1)).filter(N=>!!N.result);J(R.length===1,64727);const S=R[0].result?.aggregateFields;return Object.keys(S).reduce((N,k)=>(N[m[k]]=S[k],N),{})}(s,e,t))}catch(s){r.reject(s)}}),r.promise}function eE(n,e){const t=new nt;return n.asyncQueue.enqueueAndForget(async()=>xy(await Ky(n),e,t)),t.promise}function Fl(n){const e={};return n.timeoutSeconds!==void 0&&(e.timeoutSeconds=n.timeoutSeconds),e}const tE="ComponentProvider",Bl=new Map;function nE(n,e,t,r,s){return new _g(n,e,t,s.host,s.ssl,s.experimentalForceLongPolling,s.experimentalAutoDetectLongPolling,Fl(s.experimentalLongPollingOptions),s.useFetchStreams,s.isUsingEmulator,r)}const ql="firestore.googleapis.com",jl=!0;class $l{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new D(P.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=ql,this.ssl=jl}else this.host=e.host,this.ssl=e.ssl??jl;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=il;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<P_)throw new D(P.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}sg("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=Fl(e.experimentalLongPollingOptions??{}),function(r){if(r.timeoutSeconds!==void 0){if(isNaN(r.timeoutSeconds))throw new D(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (must not be NaN)`);if(r.timeoutSeconds<5)throw new D(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (minimum allowed value is 5)`);if(r.timeoutSeconds>30)throw new D(P.INVALID_ARGUMENT,`invalid long polling timeout: ${r.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(r,s){return r.timeoutSeconds===s.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class Js{constructor(e,t,r,s){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=s,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new $l({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new D(P.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!=="notTerminated"}_setSettings(e){if(this._settingsFrozen)throw new D(P.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new $l(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=function(r){if(!r)return new Km;switch(r.type){case"firstParty":return new Xm(r.sessionIndex||"0",r.iamToken||null,r.authTokenFactory||null);case"provider":return r.client;default:throw new D(P.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask==="notTerminated"&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask==="notTerminated"?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(t){const r=Bl.get(t);r&&(V(tE,"Removing Datastore"),Bl.delete(t),r.terminate())}(this),Promise.resolve()}}function zl(n,e,t,r={}){n=Ge(n,Js);const s=tt(e),i=n._getSettings(),a={...i,emulatorOptions:n._getEmulatorOptions()},c=`${e}:${t}`;s&&(ls(`https://${c}`),hs("Firestore",!0)),i.host!==ql&&i.host!==c&&sn("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const l={...i,host:c,ssl:s,emulatorOptions:r};if(!en(l,a)&&(n._setSettings(l),r.mockUserToken)){let d,f;if(typeof r.mockUserToken=="string")d=r.mockUserToken,f=Re.MOCK_USER;else{d=yc(r.mockUserToken,n._app?.options.projectId);const m=r.mockUserToken.sub||r.mockUserToken.user_id;if(!m)throw new D(P.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");f=new Re(m)}n._authCredentials=new Qm(new jc(d,f))}}class at{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new at(this.firestore,e,this._query)}}class de{constructor(e,t,r){this.converter=t,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new jt(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new de(this.firestore,e,this._key)}toJSON(){return{type:de._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(mr(t,de._jsonSchema))return new de(e,r||null,new L(X.fromString(t.referencePath)))}}de._jsonSchemaVersion="firestore/documentReference/1.0",de._jsonSchema={type:ue("string",de._jsonSchemaVersion),referencePath:ue("string")};class jt extends at{constructor(e,t,r){super(e,t,Ss(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new de(this.firestore,null,new L(e))}withConverter(e){return new jt(this.firestore,e,this._path)}}function Wl(n,e,...t){if(n=Y(n),Wc("collection","path",e),n instanceof Js){const r=X.fromString(e,...t);return Gc(r),new jt(n,null,r)}{if(!(n instanceof de||n instanceof jt))throw new D(P.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(X.fromString(e,...t));return Gc(r),new jt(n.firestore,null,r)}}function Xs(n,e,...t){if(n=Y(n),arguments.length===1&&(e=ro.newId()),Wc("doc","path",e),n instanceof Js){const r=X.fromString(e,...t);return Hc(r),new de(n,null,new L(r))}{if(!(n instanceof de||n instanceof jt))throw new D(P.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=n._path.child(X.fromString(e,...t));return Hc(r),new de(n.firestore,n instanceof jt?n.converter:null,new L(r))}}const Hl="AsyncQueue";class Gl{constructor(e=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new ml(this,"async_queue_retry"),this._c=()=>{const r=Oo();r&&V(Hl,"Visibility state changed to "+r.visibilityState),this.M_.w_()},this.ac=e;const t=Oo();t&&typeof t.addEventListener=="function"&&t.addEventListener("visibilitychange",this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;const t=Oo();t&&typeof t.removeEventListener=="function"&&t.removeEventListener("visibilitychange",this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise(()=>{});const t=new nt;return this.cc(()=>this.ec&&this.sc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Yu.push(e),this.lc()))}async lc(){if(this.Yu.length!==0){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(e){if(!kn(e))throw e;V(Hl,"Operation failed with retryable error: "+e)}this.Yu.length>0&&this.M_.p_(()=>this.lc())}}cc(e){const t=this.ac.then(()=>(this.rc=!0,e().catch(r=>{throw this.nc=r,this.rc=!1,Et("INTERNAL UNHANDLED ERROR: ",Kl(r)),r}).then(r=>(this.rc=!1,r))));return this.ac=t,t}enqueueAfterDelay(e,t,r){this.uc(),this.oc.indexOf(e)>-1&&(t=0);const s=Uo.createAndSchedule(this,e,t,r,i=>this.hc(i));return this.tc.push(s),s}uc(){this.nc&&x(47125,{Pc:Kl(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do e=this.ac,await e;while(e!==this.ac)}Ic(e){for(const t of this.tc)if(t.timerId===e)return!0;return!1}Ec(e){return this.Tc().then(()=>{this.tc.sort((t,r)=>t.targetTimeMs-r.targetTimeMs);for(const t of this.tc)if(t.skipDelay(),e!=="all"&&t.timerId===e)break;return this.Tc()})}Rc(e){this.oc.push(e)}hc(e){const t=this.tc.indexOf(e);this.tc.splice(t,1)}}function Kl(n){let e=n.message||"";return n.stack&&(e=n.stack.includes(n.message)?n.stack:n.message+`
|
|
36
|
-
`+n.stack),e}class $t extends Js{constructor(e,t,r,s){super(e,t,r,s),this.type="firestore",this._queue=new Gl,this._persistenceKey=s?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new Gl(e),this._firestoreClient=void 0,await e}}}function rE(n,e){const t=typeof n=="object"?n:fs(),r=typeof n=="string"?n:vs,s=dr(t,"firestore").getImmediate({identifier:r});if(!s._initialized){const i=ji("firestore");i&&zl(s,...i)}return s}function jn(n){if(n._terminated)throw new D(P.FAILED_PRECONDITION,"The client has already been terminated.");return n._firestoreClient||sE(n),n._firestoreClient}function sE(n){const e=n._freezeSettings(),t=nE(n._databaseId,n._app?.options.appId||"",n._persistenceKey,n._app?.options.apiKey,e);n._componentsProvider||e.localCache?._offlineComponentProvider&&e.localCache?._onlineComponentProvider&&(n._componentsProvider={_offline:e.localCache._offlineComponentProvider,_online:e.localCache._onlineComponentProvider}),n._firestoreClient=new Hy(n._authCredentials,n._appCheckCredentials,n._queue,t,n._componentsProvider&&function(s){const i=s?._online.build();return{_offline:s?._offline.build(i),_online:i}}(n._componentsProvider))}class ze{constructor(e){this._byteString=e}static fromBase64String(e){try{return new ze(we.fromBase64String(e))}catch(t){throw new D(P.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}}static fromUint8Array(e){return new ze(we.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:ze._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(mr(e,ze._jsonSchema))return ze.fromBase64String(e.bytes)}}ze._jsonSchemaVersion="firestore/bytes/1.0",ze._jsonSchema={type:ue("string",ze._jsonSchemaVersion),bytes:ue("string")};class Xo{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new D(P.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new Ee(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class Zo{constructor(e){this._methodName=e}}class ct{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new D(P.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new D(P.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return H(this._lat,e._lat)||H(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:ct._jsonSchemaVersion}}static fromJSON(e){if(mr(e,ct._jsonSchema))return new ct(e.latitude,e.longitude)}}ct._jsonSchemaVersion="firestore/geoPoint/1.0",ct._jsonSchema={type:ue("string",ct._jsonSchemaVersion),latitude:ue("number"),longitude:ue("number")};class Qe{constructor(e){this._values=(e||[]).map(t=>t)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(r,s){if(r.length!==s.length)return!1;for(let i=0;i<r.length;++i)if(r[i]!==s[i])return!1;return!0}(this._values,e._values)}toJSON(){return{type:Qe._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(mr(e,Qe._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(t=>typeof t=="number"))return new Qe(e.vectorValues);throw new D(P.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}Qe._jsonSchemaVersion="firestore/vectorValue/1.0",Qe._jsonSchema={type:ue("string",Qe._jsonSchemaVersion),vectorValues:ue("object")};const iE=/^__.*__$/;class oE{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return this.fieldMask!==null?new xt(e,this.data,this.fieldMask,t,this.fieldTransforms):new Pr(e,this.data,t,this.fieldTransforms)}}class Ql{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new xt(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function Yl(n){switch(n){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw x(40011,{dataSource:n})}}class ea{constructor(e,t,r,s,i,a){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=s,i===void 0&&this.validatePath(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new ea({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){const t=this.path?.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePathSegment(e),r}childContextForFieldPath(e){const t=this.path?.child(e),r=this.contextWith({path:t,arrayElement:!1});return r.validatePath(),r}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return ei(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find(t=>e.isPrefixOf(t))!==void 0||this.fieldTransforms.find(t=>e.isPrefixOf(t.field))!==void 0}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(e.length===0)throw this.createError("Document fields must not be empty");if(Yl(this.dataSource)&&iE.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class aE{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||Ws(e)}createContext(e,t,r,s=!1){return new ea({dataSource:e,methodName:t,targetDoc:r,path:Ee.emptyPath(),arrayElement:!1,hasConverter:s},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function ta(n){const e=n._freezeSettings(),t=Ws(n._databaseId);return new aE(n._databaseId,!!e.ignoreUndefinedProperties,t)}function cE(n,e,t,r,s,i={}){const a=n.createContext(i.merge||i.mergeFields?2:0,e,t,s);na("Data must be an object, but it was:",a,r);const c=Xl(r,a);let l,d;if(i.merge)l=new Fe(a.fieldMask),d=a.fieldTransforms;else if(i.mergeFields){const f=[];for(const m of i.mergeFields){const _=hn(e,m,t);if(!a.contains(_))throw new D(P.INVALID_ARGUMENT,`Field '${_}' is specified in your field mask but missing from your input data.`);th(f,_)||f.push(_)}l=new Fe(f),d=a.fieldTransforms.filter(m=>l.covers(m.field))}else l=null,d=a.fieldTransforms;return new oE(new Se(c),l,d)}class Zs extends Zo{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof Zs}}function uE(n,e,t,r){const s=n.createContext(1,e,t);na("Data must be an object, but it was:",s,r);const i=[],a=Se.empty();Ot(r,(l,d)=>{const f=eh(e,l,t);d=Y(d);const m=s.childContextForFieldPath(f);if(d instanceof Zs)i.push(f);else{const _=Or(d,m);_!=null&&(i.push(f),a.set(f,_))}});const c=new Fe(i);return new Ql(a,c,s.fieldTransforms)}function lE(n,e,t,r,s,i){const a=n.createContext(1,e,t),c=[hn(e,r,t)],l=[s];if(i.length%2!=0)throw new D(P.INVALID_ARGUMENT,`Function ${e}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let _=0;_<i.length;_+=2)c.push(hn(e,i[_])),l.push(i[_+1]);const d=[],f=Se.empty();for(let _=c.length-1;_>=0;--_)if(!th(d,c[_])){const R=c[_];let S=l[_];S=Y(S);const N=a.childContextForFieldPath(R);if(S instanceof Zs)d.push(R);else{const k=Or(S,N);k!=null&&(d.push(R),f.set(R,k))}}const m=new Fe(d);return new Ql(f,m,a.fieldTransforms)}function Jl(n,e,t,r=!1){return Or(t,n.createContext(r?4:3,e))}function Or(n,e){if(Zl(n=Y(n)))return na("Unsupported field value:",e,n),Xl(n,e);if(n instanceof Zo)return function(r,s){if(!Yl(s.dataSource))throw s.createError(`${r._methodName}() can only be used with update() and set()`);if(!s.path)throw s.createError(`${r._methodName}() is not currently supported inside arrays`);const i=r._toFieldTransform(s);i&&s.fieldTransforms.push(i)}(n,e),null;if(n===void 0&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),n instanceof Array){if(e.settings.arrayElement&&e.dataSource!==4)throw e.createError("Nested arrays are not supported");return function(r,s){const i=[];let a=0;for(const c of r){let l=Or(c,s.childContextForArray(a));l==null&&(l={nullValue:"NULL_VALUE"}),i.push(l),a++}return{arrayValue:{values:i}}}(n,e)}return function(r,s){if((r=Y(r))===null)return{nullValue:"NULL_VALUE"};if(typeof r=="number")return zg(s.serializer,r);if(typeof r=="boolean")return{booleanValue:r};if(typeof r=="string")return{stringValue:r};if(r instanceof Date){const i=ee.fromDate(r);return{timestampValue:js(s.serializer,i)}}if(r instanceof ee){const i=new ee(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:js(s.serializer,i)}}if(r instanceof ct)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof ze)return{bytesValue:Ku(s.serializer,r._byteString)};if(r instanceof de){const i=s.databaseId,a=r.firestore._databaseId;if(!a.isEqual(i))throw s.createError(`Document reference is for database ${a.projectId}/${a.database} but should be for database ${i.projectId}/${i.database}`);return{referenceValue:wo(r.firestore._databaseId||s.databaseId,r._key.path)}}if(r instanceof Qe)return function(a,c){const l=a instanceof Qe?a.toArray():a;return{mapValue:{fields:{[au]:{stringValue:cu},[Rs]:{arrayValue:{values:l.map(f=>{if(typeof f!="number")throw c.createError("VectorValues must only contain numeric values.");return _o(c.serializer,f)})}}}}}}(r,s);if(rl(r))return r._toProto(s.serializer);throw s.createError(`Unsupported field value: ${gs(r)}`)}(n,e)}function Xl(n,e){const t={};return eu(n)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):Ot(n,(r,s)=>{const i=Or(s,e.childContextForField(r));i!=null&&(t[r]=i)}),{mapValue:{fields:t}}}function Zl(n){return!(typeof n!="object"||n===null||n instanceof Array||n instanceof Date||n instanceof ee||n instanceof ct||n instanceof ze||n instanceof de||n instanceof Zo||n instanceof Qe||rl(n))}function na(n,e,t){if(!Zl(t)||!Kc(t)){const r=gs(t);throw r==="an object"?e.createError(n+" a custom object"):e.createError(n+" "+r)}}function hn(n,e,t){if((e=Y(e))instanceof Xo)return e._internalPath;if(typeof e=="string")return eh(n,e);throw ei("Field path arguments must be of type string or ",n,!1,void 0,t)}const hE=new RegExp("[~\\*/\\[\\]]");function eh(n,e,t){if(e.search(hE)>=0)throw ei(`Invalid field path (${e}). Paths must not contain '~', '*', '/', '[', or ']'`,n,!1,void 0,t);try{return new Xo(...e.split("."))._internalPath}catch{throw ei(`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,n,!1,void 0,t)}}function ei(n,e,t,r,s){const i=r&&!r.isEmpty(),a=s!==void 0;let c=`Function ${e}() called with invalid data`;t&&(c+=" (via `toFirestore()`)"),c+=". ";let l="";return(i||a)&&(l+=" (found",i&&(l+=` in field ${r}`),a&&(l+=` in document ${s}`),l+=")"),new D(P.INVALID_ARGUMENT,c+n+l)}function th(n,e){return n.some(t=>t.isEqual(e))}class dE{convertValue(e,t="none"){switch(Mt(e)){case 0:return null;case 1:return e.booleanValue;case 2:return ae(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(Lt(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 x(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return Ot(e,(s,i)=>{r[s]=this.convertValue(i,t)}),r}convertVectorValue(e){const t=e.fields?.[Rs].arrayValue?.values?.map(r=>ae(r.doubleValue));return new Qe(t)}convertGeoPoint(e){return new ct(ae(e.latitude),ae(e.longitude))}convertArray(e,t){return(e.values||[]).map(r=>this.convertValue(r,t))}convertServerTimestamp(e,t){switch(t){case"previous":const r=Is(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(_r(e));default:return null}}convertTimestamp(e){const t=Vt(e);return new ee(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=X.fromString(e);J(nl(r),9688,{name:e});const s=new yr(r.get(1),r.get(3)),i=new L(r.popFirst(5));return s.isEqual(t)||Et(`Document ${i} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}}class ti extends dE{constructor(e){super(),this.firestore=e}convertBytes(e){return new ze(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new de(this.firestore,null,t)}}const nh="@firebase/firestore",rh="4.12.0";function sh(n){return function(t,r){if(typeof t!="object"||t===null)return!1;const s=t;for(const i of r)if(i in s&&typeof s[i]=="function")return!0;return!1}(n,["next","error","complete"])}class fE{constructor(e="count",t){this._internalFieldPath=t,this.type="AggregateField",this.aggregateType=e}}class pE{constructor(e,t,r){this._userDataWriter=t,this._data=r,this.type="AggregateQuerySnapshot",this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}_fieldsProto(){return new Se({mapValue:{fields:this._data}}).clone().value.mapValue.fields}}class ra{constructor(e,t,r,s,i){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=s,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new de(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){const e=new mE(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){const t=this._document.data.field(hn("DocumentSnapshot.get",e));if(t!==null)return this._userDataWriter.convertValue(t)}}}class mE extends ra{data(){return super.data()}}function ih(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new D(P.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class sa{}class ni extends sa{}function oh(n,e,...t){let r=[];e instanceof sa&&r.push(e),r=r.concat(t),function(i){const a=i.filter(l=>l instanceof $n).length,c=i.filter(l=>l instanceof Vr).length;if(a>1||a>0&&c>0)throw new D(P.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(const s of r)n=s._apply(n);return n}class Vr extends ni{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new Vr(e,t,r)}_apply(e){const t=this._parse(e);return hh(e._query,t),new at(e.firestore,e.converter,go(e._query,t))}_parse(e){const t=ta(e.firestore);return function(i,a,c,l,d,f,m){let _;if(d.isKeyField()){if(f==="array-contains"||f==="array-contains-any")throw new D(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${f}' queries on documentId().`);if(f==="in"||f==="not-in"){lh(m,f);const S=[];for(const N of m)S.push(uh(l,i,N));_={arrayValue:{values:S}}}else _=uh(l,i,m)}else f!=="in"&&f!=="not-in"&&f!=="array-contains-any"||lh(m,f),_=Jl(c,a,m,f==="in"||f==="not-in");return le.create(d,f,_)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}function ah(n,e,t){const r=e,s=hn("where",n);return Vr._create(s,r,t)}class $n extends sa{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new $n(e,t)}_parse(e){const t=this._queryConstraints.map(r=>r._parse(e)).filter(r=>r.getFilters().length>0);return t.length===1?t[0]:Ke.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return t.getFilters().length===0?e:(function(s,i){let a=s;const c=i.getFlattenedFilters();for(const l of c)hh(a,l),a=go(a,l)}(e._query,t),new at(e.firestore,e.converter,go(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type==="and"?"and":"or"}}function gE(...n){return n.forEach(e=>dh("or",e)),$n._create("or",n)}function _E(...n){return n.forEach(e=>dh("and",e)),$n._create("and",n)}class ia extends ni{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new ia(e,t)}_apply(e){const t=function(s,i,a){if(s.startAt!==null)throw new D(P.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(s.endAt!==null)throw new D(P.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new wr(i,a)}(e._query,this._field,this._direction);return new at(e.firestore,e.converter,Lg(e._query,t))}}function yE(n,e="asc"){const t=e,r=hn("orderBy",n);return ia._create(r,t)}class oa extends ni{constructor(e,t,r){super(),this.type=e,this._limit=t,this._limitType=r}static _create(e,t,r){return new oa(e,t,r)}_apply(e){return new at(e.firestore,e.converter,ks(e._query,this._limit,this._limitType))}}function ch(n){return ig("limit",n),oa._create("limit",n,"F")}class aa extends ni{constructor(e,t,r){super(),this.type=e,this._docOrFields=t,this._inclusive=r}static _create(e,t,r){return new aa(e,t,r)}_apply(e){const t=TE(e,this.type,this._docOrFields,this._inclusive);return new at(e.firestore,e.converter,Mg(e._query,t))}}function EE(...n){return aa._create("startAfter",n,!1)}function TE(n,e,t,r){if(t[0]=Y(t[0]),t[0]instanceof ra)return function(i,a,c,l,d){if(!l)throw new D(P.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${c}().`);const f=[];for(const m of Vn(i))if(m.field.isKeyField())f.push(Ps(a,l.key));else{const _=l.data.field(m.field);if(ws(_))throw new D(P.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+m.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(_===null){const R=m.field.canonicalString();throw new D(P.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${R}' (used as the orderBy) does not exist.`)}f.push(_)}return new On(f,d)}(n._query,n.firestore._databaseId,e,t[0]._document,r);{const s=ta(n.firestore);return function(a,c,l,d,f,m){const _=a.explicitOrderBy;if(f.length>_.length)throw new D(P.INVALID_ARGUMENT,`Too many arguments provided to ${d}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const R=[];for(let S=0;S<f.length;S++){const N=f[S];if(_[S].field.isKeyField()){if(typeof N!="string")throw new D(P.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${d}(), but got a ${typeof N}`);if(!mo(a)&&N.indexOf("/")!==-1)throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${d}() must be a plain document ID, but '${N}' contains a slash.`);const k=a.path.child(X.fromString(N));if(!L.isDocumentKey(k))throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${d}() must result in a valid document path, but '${k}' is not because it contains an odd number of segments.`);const U=new L(k);R.push(Ps(c,U))}else{const k=Jl(l,d,N);R.push(k)}}return new On(R,m)}(n._query,n.firestore._databaseId,s,e,t,r)}}function uh(n,e,t){if(typeof(t=Y(t))=="string"){if(t==="")throw new D(P.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!mo(e)&&t.indexOf("/")!==-1)throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${t}' contains a '/' character.`);const r=e.path.child(X.fromString(t));if(!L.isDocumentKey(r))throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Ps(n,new L(r))}if(t instanceof de)return Ps(n,t._key);throw new D(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${gs(t)}.`)}function lh(n,e){if(!Array.isArray(n)||n.length===0)throw new D(P.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${e.toString()}' filters.`)}function hh(n,e){const t=function(s,i){for(const a of s)for(const c of a.getFlattenedFilters())if(i.indexOf(c.op)>=0)return c.op;return null}(n.filters,function(s){switch(s){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(t!==null)throw t===e.op?new D(P.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${e.op.toString()}' filter.`):new D(P.INVALID_ARGUMENT,`Invalid query. You cannot use '${e.op.toString()}' filters with '${t.toString()}' filters.`)}function dh(n,e){if(!(e instanceof Vr||e instanceof $n))throw new D(P.INVALID_ARGUMENT,`Function ${n}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}function wE(n,e,t){let r;return r=n?t&&(t.merge||t.mergeFields)?n.toFirestore(e,t):n.toFirestore(e):e,r}function IE(){return new fE("count")}function vE(n){return AE(n,{count:IE()})}function AE(n,e){const t=Ge(n.firestore,$t),r=jn(t),s=mg(e,(i,a)=>new e_(a,i.aggregateType,i._internalFieldPath));return Zy(r,n._query,s).then(i=>function(c,l,d){const f=new ti(c);return new pE(l,f,d)}(t,n,i))}class Lr{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class dn extends ra{constructor(e,t,r,s,i,a){super(e,t,r,s,a),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new ri(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const r=this._document.data.field(hn("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new D(P.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=dn._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?t:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t)}}dn._jsonSchemaVersion="firestore/documentSnapshot/1.0",dn._jsonSchema={type:ue("string",dn._jsonSchemaVersion),bundleSource:ue("string","DocumentSnapshot"),bundleName:ue("string"),bundle:ue("string")};class ri extends dn{data(e={}){return super.data(e)}}class fn{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new Lr(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){const e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach(r=>{e.call(t,new ri(this._firestore,this._userDataWriter,r.key,r,new Lr(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new D(P.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(s,i){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map(c=>{const l=new ri(s._firestore,s._userDataWriter,c.doc.key,c.doc,new Lr(s._snapshot.mutatedKeys.has(c.doc.key),s._snapshot.fromCache),s.query.converter);return c.doc,{type:"added",doc:l,oldIndex:-1,newIndex:a++}})}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter(c=>i||c.type!==3).map(c=>{const l=new ri(s._firestore,s._userDataWriter,c.doc.key,c.doc,new Lr(s._snapshot.mutatedKeys.has(c.doc.key),s._snapshot.fromCache),s.query.converter);let d=-1,f=-1;return c.type!==0&&(d=a.indexOf(c.doc.key),a=a.delete(c.doc.key)),c.type!==1&&(a=a.add(c.doc),f=a.indexOf(c.doc.key)),{type:RE(c.type),doc:l,oldIndex:d,newIndex:f}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new D(P.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=fn._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=ro.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],r=[],s=[];return this.docs.forEach(i=>{i._document!==null&&(t.push(i._document),r.push(this._userDataWriter.convertObjectMap(i._document.data.value.mapValue.fields,"previous")),s.push(i.ref.path))}),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function RE(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return x(61501,{type:n})}}fn._jsonSchemaVersion="firestore/querySnapshot/1.0",fn._jsonSchema={type:ue("string",fn._jsonSchemaVersion),bundleSource:ue("string","QuerySnapshot"),bundleName:ue("string"),bundle:ue("string")};class bE{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=ta(e)}set(e,t,r){this._verifyNotCommitted();const s=ca(e,this._firestore),i=wE(s.converter,t,r),a=cE(this._dataReader,"WriteBatch.set",s._key,i,s.converter!==null,r);return this._mutations.push(a.toMutation(s._key,$e.none())),this}update(e,t,r,...s){this._verifyNotCommitted();const i=ca(e,this._firestore);let a;return a=typeof(t=Y(t))=="string"||t instanceof Xo?lE(this._dataReader,"WriteBatch.update",i._key,t,r,s):uE(this._dataReader,"WriteBatch.update",i._key,t),this._mutations.push(a.toMutation(i._key,$e.exists(!0))),this}delete(e){this._verifyNotCommitted();const t=ca(e,this._firestore);return this._mutations=this._mutations.concat(new Us(t._key,$e.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new D(P.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function ca(n,e){if((n=Y(n)).firestore!==e)throw new D(P.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return n}function PE(n){n=Ge(n,de);const e=Ge(n.firestore,$t),t=jn(e);return Jy(t,n._key).then(r=>mh(e,n,r))}function CE(n){n=Ge(n,at);const e=Ge(n.firestore,$t),t=jn(e),r=new ti(e);return ih(n._query),Xy(t,n._query).then(s=>new fn(e,r,n,s))}function SE(n){return ph(Ge(n.firestore,$t),[new Us(n._key,$e.none())])}function fh(n,...e){n=Y(n);let t={includeMetadataChanges:!1,source:"default"},r=0;typeof e[r]!="object"||sh(e[r])||(t=e[r++]);const s={includeMetadataChanges:t.includeMetadataChanges,source:t.source};if(sh(e[r])){const d=e[r];e[r]=d.next?.bind(d),e[r+1]=d.error?.bind(d),e[r+2]=d.complete?.bind(d)}let i,a,c;if(n instanceof de)a=Ge(n.firestore,$t),c=Ss(n._key.path),i={next:d=>{e[r]&&e[r](mh(a,n,d))},error:e[r+1],complete:e[r+2]};else{const d=Ge(n,at);a=Ge(d.firestore,$t),c=d._query;const f=new ti(a);i={next:m=>{e[r]&&e[r](new fn(a,f,d,m))},error:e[r+1],complete:e[r+2]},ih(n._query)}const l=jn(a);return Yy(l,c,s,i)}function ph(n,e){const t=jn(n);return eE(t,e)}function mh(n,e,t){const r=t.docs.get(e._key),s=new ti(n);return new dn(n,s,e._key,r,new Lr(t.hasPendingWrites,t.fromCache),e.converter)}function kE(n){return n=Ge(n,$t),jn(n),new bE(n,e=>ph(n,e))}(function(e,t=!0){Gm(nn),St(new _t("firestore",(r,{instanceIdentifier:s,options:i})=>{const a=r.getProvider("app").getImmediate(),c=new $t(new Ym(r.getProvider("auth-internal")),new Zm(a,r.getProvider("app-check-internal")),yg(a,s),a);return i={useFetchStreams:t,...i},c._setSettings(i),c},"PUBLIC").setMultipleInstances(!0)),je(nh,rh,e),je(nh,rh,"esm2020")})();class gh{constructor(){this.subscribers=new Set}subscribe(e){return this.subscribers.add(e),()=>this.unsubscribe(e)}unsubscribe(e){this.subscribers.delete(e)}notify(e){this.subscribers.forEach(t=>t(e))}get subscribersCount(){return this.subscribers.size}}const Ie=[];for(let n=0;n<256;++n)Ie.push((n+256).toString(16).slice(1));function NE(n,e=0){return(Ie[n[e+0]]+Ie[n[e+1]]+Ie[n[e+2]]+Ie[n[e+3]]+"-"+Ie[n[e+4]]+Ie[n[e+5]]+"-"+Ie[n[e+6]]+Ie[n[e+7]]+"-"+Ie[n[e+8]]+Ie[n[e+9]]+"-"+Ie[n[e+10]]+Ie[n[e+11]]+Ie[n[e+12]]+Ie[n[e+13]]+Ie[n[e+14]]+Ie[n[e+15]]).toLowerCase()}let ua;const DE=new Uint8Array(16);function OE(){if(!ua){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");ua=crypto.getRandomValues.bind(crypto)}return ua(DE)}const VE=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),_h={randomUUID:VE};function LE(n,e,t){n=n||{};const r=n.random??n.rng?.()??OE();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=r[6]&15|64,r[8]=r[8]&63|128,NE(r)}function ME(n,e,t){return _h.randomUUID&&!n?_h.randomUUID():LE(n)}var xE=Object.defineProperty,UE=(n,e,t,r)=>{for(var s=void 0,i=n.length-1,a;i>=0;i--)(a=n[i])&&(s=a(e,t,s)||s);return s&&xE(e,t,s),s},ce;const yh=(ce=class{static registerFactory(n,e,t,r=!1){this._factoryMap[n]={factory:e,annotation:t,isLegacy:r}}static classFactory(n){if(!n)throw new Error("You should provide a class name.");if(!this._factoryMap[n])throw new Error(`You should register class ${n} prior to use.`);return this._factoryMap[n].factory}static registeredClasses(){return Object.entries(this._factoryMap).filter(([,n])=>!n.isLegacy).map(([n])=>n)}static registeredClassesAndLegacyNames(){return Object.keys(this._factoryMap)}static classesExtending(n){return Object.entries(this._factoryMap).filter(([,e])=>new e.factory instanceof n&&!e.isLegacy).map(([e])=>e)}static annotations(n){if(n instanceof ce?n=n.className:typeof n=="string"||(n=new n().className),!this._factoryMap[n])throw new Error(`You should register class ${n} prior to use.`);return this._factoryMap[n].annotation}constructor(n=ME()){this._id=n}get className(){return this.__className}setId(n){this._id=n}get id(){return this._id}afterDeserialize(){}beforeSerialize(){}getPersistentProperties(){return this._persistentProperties?this._persistentProperties.map(n=>({...n,name:n.name.slice(1)})):[]}getPropInfo(n){const e=this.getPersistentProperties().find(t=>t.name===n);if(!e)throw new Error(`Property "${n}" has not been registered.`);return e}isRequired(n){return this.getPropInfo(n).validator!=null}isPropValueValid(n){const e=this.getPropInfo(n);return e.validator?e.validator(this[e.name],e,this):!0}clone(n){const e=n.toObject();return delete e.id,this.fromObject(e)}fromObject(n){return this.fromObj(n),this.afterDeserialize(),this}fromObj(n){return this._persistentProperties?(this._persistentProperties.forEach(e=>{const t=this.removeUnderscore(e),r=n[t];r!=null&&(this[e.name]=this.fromDeepObject(r))}),this):this}toObject(){const n={},e=this.toObj(n);return this.pushDocument(n,this.className,e),{...e,__rootCollections:n}}toObj(n){if(!this._persistentProperties)return{};this.beforeSerialize();const e={};if(!this.className)throw new Error(`You should register \`${this.constructor.name||this.toString()||"this"}\` class prior to streaming it.`);return this._persistentProperties.forEach(t=>{const r=this[t.name],s=this.removeUnderscore(t);r!=null&&(t.isReference?e[s]=this.toReferenceObj(t,n):e[s]=this.toDeepObj(r,n),t.searchableArray&&(e[ce.searchableArrayNameFor(s)]=r.map(i=>i.id)))}),e.__className=this.className,e}static searchableArrayNameFor(n){return`__${n}_searchable`}fromDeepObject(n){if(n==null)return n;if(Array.isArray(n))return n.map(e=>this.fromDeepObject(e));if(n.__documentReference){const e=n,t=ce.createInstance(e);return t.__documentReference=n.__documentReference,t}if(n.__className)return ce.createInstance(n);if(typeof n=="object"){const e={};return Object.entries(n).forEach(([t,r])=>e[t]=this.fromDeepObject(r)),e}return n}toDeepObj(n,e){if(n!=null){if(Array.isArray(n))return n.map(t=>this.toDeepObj(t,e));if(n.__documentReference)return n;if(n instanceof ce)return n.toObj(e);if(typeof n=="object"){const t={};return Object.entries(n).forEach(([r,s])=>t[r]=this.toDeepObj(s,e)),t}return n}}static collectionPath(n,e,t){let r;return typeof e.storeInCollection=="function"?r=e.storeInCollection(n,e,t):r=e.storeInCollection??n.className,r}toReferenceObj(n,e){const t=this[n.name];return Array.isArray(t)?t.map(r=>(n.isPureReference||this.pushDocument(e,ce.collectionPath(r,n),r),this.buildRefObject(r,ce.collectionPath(r,n),n.cachedProps))):(n.isPureReference||this.pushDocument(e,ce.collectionPath(t,n),t),this.buildRefObject(t,ce.collectionPath(t,n),n.cachedProps))}buildRefObject(n,e,t){const r=t?.reduce((s,i)=>(n[i]!==void 0&&(s[i]=n[i]),s),{});return{id:n.id,__className:n.className||n.__className,__documentReference:{storedInCollection:e},...r}}pushDocument(n,e,t){if("__documentReference"in t&&t.__documentReference)return;n[e]||(n[e]=[]);const r=this.toDeepObj(t,n);n[e].push(r)}removeUnderscore(n){return n.name.slice(1)}static createReference(n){const e=ce.createInstance(n);return e.__documentReference=n.__documentReference||{storedInCollection:e.className},e}static createInstance(n){if(typeof n=="string")return new(ce.classFactory(n));try{return new(ce.classFactory(n.__className))().fromObject(n)}catch(e){const t=Object.entries(n).filter(([r,s])=>s!=null&&typeof s!="function").map(([r,s])=>`${r}: ${s}`).join(`,
|
|
37
|
-
`);throw new Error(`${e}
|
|
38
|
-
-----> Class name not found in object:
|
|
39
|
-
{
|
|
40
|
-
${t}
|
|
41
|
-
}
|
|
42
|
-
`)}}static propInfo(n,e){return ce.createInstance(n).getPropInfo(e)}static propType(n){if(n.typeName)return Array.isArray(n.typeName)?"undefined[]":n.typeName??"undefined";const e=ce.createInstance(n.ownerClassName())[n.name];if(Array.isArray(e)){if(e.length===0)return"undefined[]";const t=e[0];return t instanceof ce?t.className+"[]":typeof t+"[]"}else return e instanceof ce?e.className:typeof e}static getSystemRegisteredReferencesWithCachedProps(){return ce.registeredClasses().reduce((n,e)=>{const t=ce.createInstance(e).getPersistentProperties().filter(r=>r.cachedProps);return t.length>0&&(n[e]=t),n},{})}},ce._factoryMap={},ce);UE([zn],yh.prototype,"_id");let pe=yh;function zn(n,e){return FE()(n,e)}function FE(n){return function(e,t){Object.getOwnPropertyDescriptor(e,"_persistentProperties")||(e._persistentProperties?e._persistentProperties=[...e._persistentProperties]:e._persistentProperties=[]);const r=e._persistentProperties.find(s=>s.name===t);r?Object.assign(r,n):e._persistentProperties.push({name:t,ownerClassName:()=>e.className,...n})}}function BE(n,e){return t=>{pe.registerFactory(n,t,e),t.prototype.__className=n}}const Eh=class dp{constructor(e,t,r){if(r){if(!(t instanceof pe))throw new Error(dp.error.persistentNeedForSubCollection);this.collectionName=`${t.className}/${t.id}/${r}`}else this.collectionName=t instanceof pe?t.className:t;this._stream=e}findById(e,t){return new Promise((r,s)=>{this._stream.findById(e,this.collectionName).then(i=>{i?(t?t.fromObject(i):t=pe.createInstance(i),r(t)):r(void 0)}).catch(i=>s(i))})}save(e){const t=e.toObject();return this.collectionName!==t.__className&&(t.__rootCollections[this.collectionName]=t.__rootCollections[t.__className],delete t.__rootCollections[t.__className]),new Promise((r,s)=>{this._stream.save(t.__rootCollections).then(()=>r()).catch(i=>s(i))})}delete(e){return new Promise((t,r)=>{this._stream.delete(e,this.collectionName).then(()=>t()).catch(s=>r(s))})}find(){return new qE(this)}query(e={},t){if(t){const r=t instanceof pe?t.className:t;e.operations||(e.operations=[]),e.operations.push({property:"__className",operator:"==",value:r})}return this.mapToInstance(()=>this._stream.find(this.preprocessQueryObject(e),this.collectionName))}count(e){return this._stream.count(e,this.collectionName)}next(e){return this.mapToInstance(()=>this._stream.next(e))}onDocumentChange(e,t){return this._stream.onDocumentChange(this.collectionName,e,r=>t(wt.toPersistentDocumentChange(r)))}onCollectionChange(e,t){return this._stream.onCollectionChange(this.preprocessQueryObject(e.getQueryObject()),this.collectionName,r=>t(r.map(s=>wt.toPersistentDocumentChange(s))))}onCollectionTemplateChange(e,t){return this._stream.onDocumentTemplateChange(e,r=>t(wt.toPersistentDocumentChange(r)))}mapToInstance(e){return new Promise((t,r)=>{e().then(s=>t(s.map(i=>pe.createInstance(i)))).catch(s=>r(s))})}preprocessQueryObject(e){if(Object.values(e).length===0)return e;const t=e.operations?.map(r=>{const s=r.value[0]??r.value;return wt.isArrayOperator(r.operator)&&s instanceof pe?{property:pe.searchableArrayNameFor(r.property),operator:r.operator,value:Array.isArray(r.value)?r.value.map(i=>i.id):s.id,aggregate:r.aggregate}:{property:r.property,operator:r.operator,value:r.value instanceof pe?{id:r.value.id}:r.value,aggregate:r.aggregate}})??[];return{...e,operations:t}}};Eh.error={persistentNeedForSubCollection:"The document parameter for a sub-collection should be a Persistent instace",invalidQueryOrder:"Cannot add where calls after or calls"};let si=Eh;class qE{constructor(e){this.queryObject={operations:[]},this.model=e}where(e,t,r,s){if(this.queryObject.operations?.at(-1)?.aggregate&&!s)throw new Error(si.error.invalidQueryOrder);return this.queryObject.operations?.push({property:e,operator:t,value:r,aggregate:s}),this}whereDeepProp(e,t,r,s){if(this.queryObject.operations?.at(-1)?.aggregate&&!s)throw new Error(si.error.invalidQueryOrder);const i=e.split(".");let a={},c=i.length>1?a:r;return i.slice(1).forEach((l,d)=>{a[l]=d<i.length-2?{}:r,a=a[l]}),this.queryObject.operations?.push({property:i[0],operator:t,value:c,aggregate:s}),this}and(e,t,r){return this.where(e,t,r)}andDeepProp(e,t,r){return this.whereDeepProp(e,t,r)}or(e,t,r){return this.where(e,t,r,!0)}orDeepProp(e,t,r){return this.whereDeepProp(e,t,r,!0)}instanceOf(e){const t=e instanceof pe?e.className:e;return this.queryObject.operations?.push({property:"__className",operator:"==",value:t}),this}get(e){return e&&(this.queryObject.limit=e),this.model.query(this.queryObject)}limit(e){return this.queryObject.limit=e,this}orderBy(e,t="asc"){return this.queryObject.sort={propertyName:e,order:t},this}orderByDeepProp(e,t="asc"){return this.queryObject.sort={propertyName:e,order:t},this}count(){return this.model.count(this.queryObject)}getQueryObject(){return this.queryObject}getQueryModel(){return this.model}}const Th=class sr{constructor(){}static useDataSource(e){this._dataSource=e}static get dataSource(){return sr._dataSource}static getModel(e){if(!sr._dataSource)throw new Error(this.error.shouldBeRegistered);return new si(sr._dataSource,e)}static getModelForSubCollection(e,t){if(!sr._dataSource)throw new Error(this.error.shouldBeRegistered);return new si(sr._dataSource,e,t)}static async populate(e){if(!e)return;const t=async r=>{const s=r;if(!s.__documentReference)return r;const i=await this.getModel(s.__documentReference.storedInCollection).findById(s.id,r);return i&&(i.__documentReference=void 0),i};return Array.isArray(e)?(await Promise.all(e.map(r=>t(r)))).filter(r=>r):t(e)}static isPopulated(e){return Array.isArray(e)?e.reduce((t,r)=>t&&r.__documentReference===void 0,!0):e.__documentReference===void 0}};Th.error={shouldBeRegistered:"You should register a data source before using the data Store."};let jE=Th;class la{constructor(e){this._resolveCollectionPaths=()=>{throw new Error("The method collectionsMatchingTemplate has not been implemented in the concrete data source")},this._disabledChangeListeners=new Set,this._collectionsToWatch={},e&&(this._beforeUpdate=e.beforeUpdateDocument,this._afterUpdate=e.afterUpdateDocument,this._afterDocumentChange=e.afterDocumentChange,this._beforeDocumentChange=e.beforeDocumentChange,this._beforeQueryOwnerCollection=e.beforeQueryOwnerCollection),this.installUpdaters()}installUpdaters(){const e=pe.getSystemRegisteredReferencesWithCachedProps();this._collectionsToWatch={},Object.entries(e).forEach(([t,r])=>{r.forEach(s=>{s.typeName&&(Array.isArray(s.typeName)?s.typeName:[s?.typeName??t]).map(i=>pe.collectionPath(pe.createInstance(i),s)).forEach(i=>{this._collectionsToWatch[i]||(this._collectionsToWatch[i]=[]),this._collectionsToWatch[i].find(a=>a.name===s.name&&a.ownerClassName()===s.ownerClassName())||this._collectionsToWatch[i].push(s)})})})}set beforeDocumentChange(e){this._beforeDocumentChange=e}set afterDocumentChange(e){this._afterDocumentChange=e}set beforeUpdateDocument(e){this._beforeUpdate=e}set afterUpdateDocument(e){this._afterUpdate=e}set beforeQueryOwnerCollection(e){this._beforeQueryOwnerCollection=e}set resolveCollectionPaths(e){this._resolveCollectionPaths=e}get collectionsToWatch(){return this._collectionsToWatch}updateProps(e,t){const r=this._collectionsToWatch[e];return r?this.onDocumentChange(t,r):Promise.resolve()}async onDocumentChange(e,t){const r=wt.toPersistentDocumentChange(e);this._beforeDocumentChange?.(r,t);const s={};e.type!=="update"||!r.before||r.after?.id&&this._disabledChangeListeners.has(r.after?.id)||(await Promise.all(t.map(async i=>{const a=la.ownerCollectionPath(pe.createInstance(i.ownerClassName()),i,r.params),c=await this._resolveCollectionPaths(a);await Promise.all(c.map(async l=>{const d=jE.getModel(l);let f=d.find(),m=!1;i.cachedProps?.forEach(R=>{const S=r.before[R],N=r.after[R];S!==N&&(m=!0)}),m&&(i.searchableArray?f=f.where(i.name,"contains",r.before):f=f.where(i.name,"==",r.before)),f=this._beforeQueryOwnerCollection?.(f)??f;const _=await f.get();return s[l]={totalDocumentsToUpdate:_.length,updatedDocuments:[],documentsToUpdate:_.map(R=>R.name??R.id)},Promise.all([_.map(async R=>{let S=!1;if(i.cachedProps?.forEach(N=>{const k=r.before[N],U=r.after[N];k!==U&&(S=!0)}),S){if(i.searchableArray){const N=R[i.name].findIndex(k=>k.id===r.before.id);R[i.name][N]=r.after}else R[`_${i.name}`]=r.after;this._beforeUpdate?.(R,i),this.disableChangeListener(R),await d.save(R),this.enableChangeListener(R),s[l]?.updatedDocuments.push(R.id),this._afterUpdate?.(R,i)}else return Promise.resolve()})])}))})),this._afterDocumentChange?.(s,t))}disableChangeListener(e){this._disabledChangeListeners.add(e.id)}enableChangeListener(e){this._disabledChangeListeners.delete(e.id)}static ownerCollectionPath(e,t,r){let s;return typeof t.ownerCollection=="function"?s=t.ownerCollection(e,t,r):s=t.ownerCollection??e.className,s}}class wt{constructor(){this._cachedPropsUpdater=void 0}installCachedPropsUpdater(e){return this._cachedPropsUpdater=new la(e),this._cachedPropsUpdater.resolveCollectionPaths=this.resolveCollectionPaths.bind(this),this._cachedPropsUpdater}get cachedPropsUpdater(){return this._cachedPropsUpdater}static toPropertyPathOperations(e){return e?e.map(t=>{if(wt.isArrayOperator(t.operator)&&t.value[0]instanceof pe)return{property:pe.searchableArrayNameFor(t.property),operator:t.operator,value:t.value.map(i=>i.id),aggregate:t.aggregate};const[r,s]=this.toPropertyPathValue(t.value);return{property:`${String(t.property)}${r?"."+r:""}`,operator:t.operator,value:s,aggregate:t.aggregate}}):[]}static isArrayOperator(e){return e==="containsAny"||e==="contains"}static toPersistentDocumentChange(e){return{...e,before:e.before&&pe.createInstance(e.before),after:e.after&&pe.createInstance(e.after)}}static toPropertyPathValue(e){if(typeof e=="object"&&!Array.isArray(e)){const t=Object.keys(e)[0],[r,s]=this.toPropertyPathValue(e[t]);return[`${t}${r?"."+r:""}`,s]}else return[void 0,e]}static isStringMatchingTemplate(e,t){const r=e.split("/"),s=t.split("/");if(s.length>r.length)return!1;for(let i=0;i<s.length;i++){const a=r[i],c=s[i];if(!(a.startsWith("{")&&a.endsWith("}")||a.startsWith("${")&&a.endsWith("}"))&&a!==c)return!1}for(let i=s.length;i<r.length;i++){const a=r[i];if(!(a.startsWith("{")&&a.endsWith("}")||a.startsWith("${")&&a.endsWith("}")))return!1}return!0}static extractTemplateParams(e,t){const r=t.split("/"),s=e.split("/"),i={};if(s.length>r.length)return i;for(let a=0;a<s.length;a++){const c=r[a],l=s[a];if(c.startsWith("{")&&c.endsWith("}"))i[c.slice(1,-1)]=l;else if(c.startsWith("${")&&c.endsWith("}"))i[c.slice(2,-1)]=l;else if(c!==l)return{}}for(let a=s.length;a<r.length;a++){const c=r[a];if(!(c.startsWith("{")&&c.endsWith("}")||c.startsWith("${")&&c.endsWith("}")))return{}}return i}}const wh=class ir{static registerCloudStorage(e,t){ir._cloudStorageFactoryMap[e]=t}static createInstance(e){const t=ir._cloudStorageFactoryMap[e];if(!t)throw new Error(`You should register the ${e} cloud storage provider prior to use it`);return t()}get className(){return this.__className}static useCloudStorage(e){ir._defaultCloudStorage=e}static get defaultCloudStorage(){if(!ir._defaultCloudStorage)throw new Error("You should define a default cloud storage provider prior to use it");return ir._defaultCloudStorage}};wh._cloudStorageFactoryMap={};let Wn=wh;function Ih(n,e){return Wn.registerCloudStorage(n,e),t=>{t.prototype.__className=n}}var $E=(n,e,t,r)=>{for(var s=e,i=n.length-1,a;i>=0;i--)(a=n[i])&&(s=a(s)||s);return s};let ha=class extends Wn{constructor(n=""){super(),this._simulateDelay=0,this._pendingPromises=[],this.mockFileSystem={},this._pathToMockFiles=n}simulateDelay(n){return this._simulateDelay=n,this}resolveWithDelay(n){if(this._simulateDelay<=0)return Promise.resolve(n);const e=new Promise(t=>{setTimeout(()=>t(n),this._simulateDelay)});return this._pendingPromises.push(e),e.finally(()=>this._pendingPromises=this._pendingPromises.filter(t=>t===e)),e}save(n,e){const t=n;this._onProgress&&this._onProgress(0,100),this.mockFileSystem[n]=JSON.stringify(e),this._onProgress&&this._onProgress(100,100);const r=e instanceof File?e.name:t;return this.resolveWithDelay(r)}uploadControl(){return{resume:()=>{},pause:()=>{},cancel:()=>{},onProgress:n=>this._onProgress=n}}getUrl(n){return Promise.resolve(this._pathToMockFiles+n)}delete(n){return delete this.mockFileSystem[n],this.resolveWithDelay()}};ha=$E([Ih("MockCloudStorage",()=>new ha)],ha);var zE=Object.defineProperty,WE=Object.getOwnPropertyDescriptor,Hn=(n,e,t,r)=>{for(var s=r>1?void 0:r?WE(e,t):e,i=n.length-1,a;i>=0;i--)(a=n[i])&&(s=(r?a(e,t,s):a(s))||s);return r&&s&&zE(e,t,s),s};let pn=class extends pe{constructor(){super(...arguments),this._onChange=new gh}async save({data:n,fileName:e,progress:t,cloudStorageProvider:r}={}){const s=n||this._pendingData;s&&(this._reference&&await this.delete(),this.provider=r||Wn.defaultCloudStorage,this._originalFileName=e||(s instanceof File?s.name:void 0),this._reference=await this.provider.save(this.id,s,t),this._url=await this.provider.getUrl(this._reference),this._pendingData=void 0,this._onChange.notify({event:0,storedFile:this}))}uploadControl(){return this.provider.uploadControl()}async delete(){if(!this._reference)throw new Error("Cannot delete a not stored file");await this.provider.delete(this._reference),this._reference=void 0,this._url=void 0,this._onChange.notify({event:2,storedFile:this})}set provider(n){this._provider=n,this._cloudStorageProviderName=n.className}get provider(){if(!this._provider)try{this._provider=Wn.createInstance(this._cloudStorageProviderName)}catch{this._provider=Wn.defaultCloudStorage}return this._provider}get url(){return this._url}get mimeType(){return this._mimeType}setDataToStore(n){return this._pendingData=n,this._originalFileName=n instanceof File?n.name:void 0,this._mimeType=n instanceof Blob?n.type:void 0,this._onChange.notify({event:1,pendingData:n,storedFile:this}),this}get originalFileName(){return this._originalFileName}onChange(n){return this._onChange.subscribe(n)}};Hn([zn],pn.prototype,"_reference",2),Hn([zn],pn.prototype,"_url",2),Hn([zn],pn.prototype,"_cloudStorageProviderName",2),Hn([zn],pn.prototype,"_originalFileName",2),Hn([zn],pn.prototype,"_mimeType",2),pn=Hn([BE("StoredFile")],pn);class vh{}const Ah=class xe extends vh{constructor(){if(super(),this._onAuthStateChange=new gh,!xe._authService)throw new Error(xe.error.shouldBeRegistered);xe._authService.onAuthStateChange(e=>this.authStateChanged(e))}static useAuthService(e){xe._authService!=e&&(xe._authService=e,this._instance=void 0)}static get instance(){return this._instance||(this._instance=new this)}signUp(e){return xe._authService.signUp(e)}login(e){return xe._authService.login(e)}logout(){return xe._authService.logout()}resetEmailPassword(e){return xe._authService.resetEmailPassword(e)}resendVerificationEmail(e,t,r){return xe._authService.resendVerificationEmail(e,t,r)}refreshToken(){return xe._authService.refreshToken()}onAuthStateChange(e){return this._onAuthStateChange.subscribe(e)}removeAuthStateChange(e){this._onAuthStateChange.unsubscribe(e)}linkAdditionalProvider(e){return xe._authService.linkAdditionalProvider(e)}unlinkProvider(e){return xe._authService.unlinkProvider(e)}authStateChanged(e){this._onAuthStateChange.notify(e)}};Ah.error={shouldBeRegistered:"You should register an auth service before using Auth."},Ah._instance=void 0;function ii(n){return n?n.replace(/([-_ ][\w])/g,e=>e.toUpperCase().replace("-","").replace("_","").replace(" ","")):""}var HE="firebase",GE="12.10.0";je(HE,GE,"app");function Rh(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const KE=Rh,bh=new cr("auth","Firebase",Rh());const oi=new zi("@firebase/auth");function QE(n,...e){oi.logLevel<=W.WARN&&oi.warn(`Auth (${nn}): ${n}`,...e)}function ai(n,...e){oi.logLevel<=W.ERROR&&oi.error(`Auth (${nn}): ${n}`,...e)}function We(n,...e){throw fa(n,...e)}function Ye(n,...e){return fa(n,...e)}function da(n,e,t){const r={...KE(),[e]:t};return new cr("auth","Firebase",r).create(e,{appName:n.name})}function ut(n){return da(n,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function Ph(n,e,t){const r=t;if(!(e instanceof r))throw r.name!==e.constructor.name&&We(n,"argument-error"),da(n,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function fa(n,...e){if(typeof n!="string"){const t=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=n.name),n._errorFactory.create(t,...r)}return bh.create(n,...e)}function M(n,e,...t){if(!n)throw fa(e,...t)}function It(n){const e="INTERNAL ASSERTION FAILED: "+n;throw ai(e),new Error(e)}function vt(n,e){n||It(e)}function pa(){return typeof self<"u"&&self.location?.href||""}function YE(){return Ch()==="http:"||Ch()==="https:"}function Ch(){return typeof self<"u"&&self.location?.protocol||null}function JE(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(YE()||bp()||"connection"in navigator)?navigator.onLine:!0}function XE(){if(typeof navigator>"u")return null;const n=navigator;return n.languages&&n.languages[0]||n.language||null}class Mr{constructor(e,t){this.shortDelay=e,this.longDelay=t,vt(t>e,"Short delay should be less than long delay!"),this.isMobile=vp()||Pp()}get(){return JE()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function ma(n,e){vt(n.emulator,"Emulator should always be set here");const{url:t}=n.emulator;return e?`${t}${e.startsWith("/")?e.slice(1):e}`:t}class Sh{static initialize(e,t,r){this.fetchImpl=e,t&&(this.headersImpl=t),r&&(this.responseImpl=r)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;It("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;It("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;It("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const ZE={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"};const eT=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],tT=new Mr(3e4,6e4);function At(n,e){return n.tenantId&&!e.tenantId?{...e,tenantId:n.tenantId}:e}async function Je(n,e,t,r,s={}){return kh(n,s,async()=>{let i={},a={};r&&(e==="GET"?a=r:i={body:JSON.stringify(r)});const c=ur({key:n.config.apiKey,...a}).slice(1),l=await n._getAdditionalHeaders();l["Content-Type"]="application/json",n.languageCode&&(l["X-Firebase-Locale"]=n.languageCode);const d={method:e,headers:l,...i};return Rp()||(d.referrerPolicy="no-referrer"),n.emulatorConfig&&tt(n.emulatorConfig.host)&&(d.credentials="include"),Sh.fetch()(await Nh(n,n.config.apiHost,t,c),d)})}async function kh(n,e,t){n._canInitEmulator=!1;const r={...ZE,...e};try{const s=new rT(n),i=await Promise.race([t(),s.promise]);s.clearNetworkTimeout();const a=await i.json();if("needConfirmation"in a)throw ci(n,"account-exists-with-different-credential",a);if(i.ok&&!("errorMessage"in a))return a;{const c=i.ok?a.errorMessage:a.error.message,[l,d]=c.split(" : ");if(l==="FEDERATED_USER_ID_ALREADY_LINKED")throw ci(n,"credential-already-in-use",a);if(l==="EMAIL_EXISTS")throw ci(n,"email-already-in-use",a);if(l==="USER_DISABLED")throw ci(n,"user-disabled",a);const f=r[l]||l.toLowerCase().replace(/[_\s]+/g,"-");if(d)throw da(n,f,d);We(n,f)}}catch(s){if(s instanceof He)throw s;We(n,"network-request-failed",{message:String(s)})}}async function xr(n,e,t,r,s={}){const i=await Je(n,e,t,r,s);return"mfaPendingCredential"in i&&We(n,"multi-factor-auth-required",{_serverResponse:i}),i}async function Nh(n,e,t,r){const s=`${e}${t}?${r}`,i=n,a=i.config.emulator?ma(n.config,s):`${n.config.apiScheme}://${s}`;return eT.includes(t)&&(await i._persistenceManagerAvailable,i._getPersistenceType()==="COOKIE")?i._getPersistence()._getFinalTarget(a).toString():a}function nT(n){switch(n){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class rT{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((t,r)=>{this.timer=setTimeout(()=>r(Ye(this.auth,"network-request-failed")),tT.get())})}}function ci(n,e,t){const r={appName:n.name};t.email&&(r.email=t.email),t.phoneNumber&&(r.phoneNumber=t.phoneNumber);const s=Ye(n,e,r);return s.customData._tokenResponse=t,s}function Dh(n){return n!==void 0&&n.enterprise!==void 0}class sT{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return nT(t.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function iT(n,e){return Je(n,"GET","/v2/recaptchaConfig",At(n,e))}async function oT(n,e){return Je(n,"POST","/v1/accounts:delete",e)}async function aT(n,e){return Je(n,"POST","/v1/accounts:update",e)}async function ui(n,e){return Je(n,"POST","/v1/accounts:lookup",e)}function Ur(n){if(n)try{const e=new Date(Number(n));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function cT(n,e=!1){const t=Y(n),r=await t.getIdToken(e),s=_a(r);M(s&&s.exp&&s.auth_time&&s.iat,t.auth,"internal-error");const i=typeof s.firebase=="object"?s.firebase:void 0,a=i?.sign_in_provider;return{claims:s,token:r,authTime:Ur(ga(s.auth_time)),issuedAtTime:Ur(ga(s.iat)),expirationTime:Ur(ga(s.exp)),signInProvider:a||null,signInSecondFactor:i?.sign_in_second_factor||null}}function ga(n){return Number(n)*1e3}function _a(n){const[e,t,r]=n.split(".");if(e===void 0||t===void 0||r===void 0)return ai("JWT malformed, contained fewer than 3 sections"),null;try{const s=pc(t);return s?JSON.parse(s):(ai("Failed to decode base64 JWT payload"),null)}catch(s){return ai("Caught error parsing JWT payload as JSON",s?.toString()),null}}function Oh(n){const e=_a(n);return M(e,"internal-error"),M(typeof e.exp<"u","internal-error"),M(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}async function Gn(n,e,t=!1){if(t)return e;try{return await e}catch(r){throw r instanceof He&&uT(r)&&n.auth.currentUser===n&&await n.auth.signOut(),r}}function uT({code:n}){return n==="auth/user-disabled"||n==="auth/user-token-expired"}class lT{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){if(e){const t=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),t}else{this.errorBackoff=3e4;const r=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,r)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){e?.code==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}class ya{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Ur(this.lastLoginAt),this.creationTime=Ur(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function Fr(n){const e=n.auth,t=await n.getIdToken(),r=await Gn(n,ui(e,{idToken:t}));M(r?.users.length,e,"internal-error");const s=r.users[0];n._notifyReloadListener(s);const i=s.providerUserInfo?.length?Vh(s.providerUserInfo):[],a=dT(n.providerData,i),c=n.isAnonymous,l=!(n.email&&s.passwordHash)&&!a?.length,d=c?l:!1,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 ya(s.createdAt,s.lastLoginAt),isAnonymous:d};Object.assign(n,f)}async function hT(n){const e=Y(n);await Fr(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function dT(n,e){return[...n.filter(r=>!e.some(s=>s.providerId===r.providerId)),...e]}function Vh(n){return n.map(({providerId:e,...t})=>({providerId:e,uid:t.rawId||"",displayName:t.displayName||null,email:t.email||null,phoneNumber:t.phoneNumber||null,photoURL:t.photoUrl||null}))}async function fT(n,e){const t=await kh(n,{},async()=>{const r=ur({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:s,apiKey:i}=n.config,a=await Nh(n,s,"/v1/token",`key=${i}`),c=await n._getAdditionalHeaders();c["Content-Type"]="application/x-www-form-urlencoded";const l={method:"POST",headers:c,body:r};return n.emulatorConfig&&tt(n.emulatorConfig.host)&&(l.credentials="include"),Sh.fetch()(a,l)});return{accessToken:t.access_token,expiresIn:t.expires_in,refreshToken:t.refresh_token}}async function pT(n,e){return Je(n,"POST","/v2/accounts:revokeToken",At(n,e))}class Kn{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){M(e.idToken,"internal-error"),M(typeof e.idToken<"u","internal-error"),M(typeof e.refreshToken<"u","internal-error");const t="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):Oh(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){M(e.length!==0,"internal-error");const t=Oh(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(M(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:r,refreshToken:s,expiresIn:i}=await fT(e,t);this.updateTokensAndExpiration(r,s,Number(i))}updateTokensAndExpiration(e,t,r){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,t){const{refreshToken:r,accessToken:s,expirationTime:i}=t,a=new Kn;return r&&(M(typeof r=="string","internal-error",{appName:e}),a.refreshToken=r),s&&(M(typeof s=="string","internal-error",{appName:e}),a.accessToken=s),i&&(M(typeof i=="number","internal-error",{appName:e}),a.expirationTime=i),a}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Kn,this.toJSON())}_performRefresh(){return It("not implemented")}}function zt(n,e){M(typeof n=="string"||typeof n>"u","internal-error",{appName:e})}class Xe{constructor({uid:e,auth:t,stsTokenManager:r,...s}){this.providerId="firebase",this.proactiveRefresh=new lT(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=s.displayName||null,this.email=s.email||null,this.emailVerified=s.emailVerified||!1,this.phoneNumber=s.phoneNumber||null,this.photoURL=s.photoURL||null,this.isAnonymous=s.isAnonymous||!1,this.tenantId=s.tenantId||null,this.providerData=s.providerData?[...s.providerData]:[],this.metadata=new ya(s.createdAt||void 0,s.lastLoginAt||void 0)}async getIdToken(e){const t=await Gn(this,this.stsTokenManager.getToken(this.auth,e));return M(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return cT(this,e)}reload(){return hT(this)}_assign(e){this!==e&&(M(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(t=>({...t})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new Xe({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return t.metadata._copy(this.metadata),t}_onReload(e){M(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),t&&await Fr(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Ae(this.auth.app))return Promise.reject(ut(this.auth));const e=await this.getIdToken();return await Gn(this,oT(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{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=>({...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){const r=t.displayName??void 0,s=t.email??void 0,i=t.phoneNumber??void 0,a=t.photoURL??void 0,c=t.tenantId??void 0,l=t._redirectEventId??void 0,d=t.createdAt??void 0,f=t.lastLoginAt??void 0,{uid:m,emailVerified:_,isAnonymous:R,providerData:S,stsTokenManager:N}=t;M(m&&N,e,"internal-error");const k=Kn.fromJSON(this.name,N);M(typeof m=="string",e,"internal-error"),zt(r,e.name),zt(s,e.name),M(typeof _=="boolean",e,"internal-error"),M(typeof R=="boolean",e,"internal-error"),zt(i,e.name),zt(a,e.name),zt(c,e.name),zt(l,e.name),zt(d,e.name),zt(f,e.name);const U=new Xe({uid:m,auth:e,email:s,emailVerified:_,displayName:r,isAnonymous:R,photoURL:a,phoneNumber:i,tenantId:c,stsTokenManager:k,createdAt:d,lastLoginAt:f});return S&&Array.isArray(S)&&(U.providerData=S.map($=>({...$}))),l&&(U._redirectEventId=l),U}static async _fromIdTokenResponse(e,t,r=!1){const s=new Kn;s.updateFromServerResponse(t);const i=new Xe({uid:t.localId,auth:e,stsTokenManager:s,isAnonymous:r});return await Fr(i),i}static async _fromGetAccountInfoResponse(e,t,r){const s=t.users[0];M(s.localId!==void 0,"internal-error");const i=s.providerUserInfo!==void 0?Vh(s.providerUserInfo):[],a=!(s.email&&s.passwordHash)&&!i?.length,c=new Kn;c.updateFromIdToken(r);const l=new Xe({uid:s.localId,auth:e,stsTokenManager:c,isAnonymous:a}),d={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:i,metadata:new ya(s.createdAt,s.lastLoginAt),isAnonymous:!(s.email&&s.passwordHash)&&!i?.length};return Object.assign(l,d),l}}const Lh=new Map;function Rt(n){vt(n instanceof Function,"Expected a class definition");let e=Lh.get(n);return e?(vt(e instanceof n,"Instance stored in cache mismatched with class"),e):(e=new n,Lh.set(n,e),e)}class Mh{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}Mh.type="NONE";const xh=Mh;function li(n,e,t){return`firebase:${n}:${e}:${t}`}class Qn{constructor(e,t,r){this.persistence=e,this.auth=t,this.userKey=r;const{config:s,name:i}=this.auth;this.fullUserKey=li(this.userKey,s.apiKey,i),this.fullPersistenceKey=li("persistence",s.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e=="string"){const t=await ui(this.auth,{idToken:e}).catch(()=>{});return t?Xe._fromGetAccountInfoResponse(this.auth,t,e):null}return Xe._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,r="authUser"){if(!t.length)return new Qn(Rt(xh),e,r);const s=(await Promise.all(t.map(async d=>{if(await d._isAvailable())return d}))).filter(d=>d);let i=s[0]||Rt(xh);const a=li(r,e.config.apiKey,e.name);let c=null;for(const d of t)try{const f=await d._get(a);if(f){let m;if(typeof f=="string"){const _=await ui(e,{idToken:f}).catch(()=>{});if(!_)break;m=await Xe._fromGetAccountInfoResponse(e,_,f)}else m=Xe._fromJSON(e,f);d!==i&&(c=m),i=d;break}}catch{}const l=s.filter(d=>d._shouldAllowMigration);return!i._shouldAllowMigration||!l.length?new Qn(i,e,r):(i=l[0],c&&await i._set(a,c.toJSON()),await Promise.all(t.map(async d=>{if(d!==i)try{await d._remove(a)}catch{}})),new Qn(i,e,r))}}function Uh(n){const e=n.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(jh(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(Fh(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(zh(e))return"Blackberry";if(Wh(e))return"Webos";if(Bh(e))return"Safari";if((e.includes("chrome/")||qh(e))&&!e.includes("edge/"))return"Chrome";if($h(e))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=n.match(t);if(r?.length===2)return r[1]}return"Other"}function Fh(n=ve()){return/firefox\//i.test(n)}function Bh(n=ve()){const e=n.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function qh(n=ve()){return/crios\//i.test(n)}function jh(n=ve()){return/iemobile/i.test(n)}function $h(n=ve()){return/android/i.test(n)}function zh(n=ve()){return/blackberry/i.test(n)}function Wh(n=ve()){return/webos/i.test(n)}function Ea(n=ve()){return/iphone|ipad|ipod/i.test(n)||/macintosh/i.test(n)&&/mobile/i.test(n)}function mT(n=ve()){return Ea(n)&&!!window.navigator?.standalone}function gT(){return Cp()&&document.documentMode===10}function Hh(n=ve()){return Ea(n)||$h(n)||Wh(n)||zh(n)||/windows phone/i.test(n)||jh(n)}function Gh(n,e=[]){let t;switch(n){case"Browser":t=Uh(ve());break;case"Worker":t=`${Uh(ve())}-${n}`;break;default:t=n}const r=e.length?e.join(","):"FirebaseCore-web";return`${t}/JsCore/${nn}/${r}`}class _T{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const r=i=>new Promise((a,c)=>{try{const l=e(i);a(l)}catch(l){c(l)}});r.onAbort=t,this.queue.push(r);const s=this.queue.length-1;return()=>{this.queue[s]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const r of this.queue)await r(e),r.onAbort&&t.push(r.onAbort)}catch(r){t.reverse();for(const s of t)try{s()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r?.message})}}}async function yT(n,e={}){return Je(n,"GET","/v2/passwordPolicy",At(n,e))}const ET=6;class TT{constructor(e){const t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??ET,t.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=t.maxPasswordLength),t.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=t.containsLowercaseCharacter),t.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=t.containsUppercaseCharacter),t.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=t.containsNumericCharacter),t.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=t.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=e.allowedNonAlphanumericCharacters?.join("")??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){const t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&(t.isValid=t.meetsMinPasswordLength??!0),t.isValid&&(t.isValid=t.meetsMaxPasswordLength??!0),t.isValid&&(t.isValid=t.containsLowercaseLetter??!0),t.isValid&&(t.isValid=t.containsUppercaseLetter??!0),t.isValid&&(t.isValid=t.containsNumericCharacter??!0),t.isValid&&(t.isValid=t.containsNonAlphanumericCharacter??!0),t}validatePasswordLengthOptions(e,t){const r=this.customStrengthOptions.minPasswordLength,s=this.customStrengthOptions.maxPasswordLength;r&&(t.meetsMinPasswordLength=e.length>=r),s&&(t.meetsMaxPasswordLength=e.length<=s)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let r;for(let s=0;s<e.length;s++)r=e.charAt(s),this.updatePasswordCharacterOptionsStatuses(t,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,t,r,s,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=s)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}class wT{constructor(e,t,r,s){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=r,this.config=s,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Kh(this),this.idTokenSubscription=new Kh(this),this.beforeStateQueue=new _T(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=bh,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=s.sdkClientVersion,this._persistenceManagerAvailable=new Promise(i=>this._resolvePersistenceManagerAvailable=i)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=Rt(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await Qn.create(this,e),this._resolvePersistenceManagerAvailable?.(),!this._deleted)){if(this._popupRedirectResolver?._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=this.currentUser?.uid||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const t=await ui(this,{idToken:e}),r=await Xe._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(r)}catch(t){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",t),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(Ae(this.app)){const i=this.app.settings.authIdToken;return i?new Promise(a=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(i).then(a,a))}):this.directlySetCurrentUser(null)}const t=await this.assertedPersistence.getCurrentUser();let r=t,s=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const i=this.redirectUser?._redirectEventId,a=r?._redirectEventId,c=await this.tryRedirectSignIn(e);(!i||i===a)&&c?.user&&(r=c.user,s=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(s)try{await this.beforeStateQueue.runMiddleware(r)}catch(i){r=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(i))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return M(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await Fr(e)}catch(t){if(t?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=XE()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(Ae(this.app))return Promise.reject(ut(this));const t=e?Y(e):null;return t&&M(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&&M(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 Ae(this.app)?Promise.reject(ut(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Ae(this.app)?Promise.reject(ut(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(Rt(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await yT(this),t=new TT(e);this.tenantId===null?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new cr("auth","Firebase",e())}onAuthStateChanged(e,t,r){return this.registerStateListener(this.authStateSubscription,e,t,r)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,r){return this.registerStateListener(this.idTokenSubscription,e,t,r)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:t};this.tenantId!=null&&(r.tenantId=this.tenantId),await pT(this,r)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,t){const r=await this.getOrInitRedirectPersistenceManager(t);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&Rt(e)||this._popupRedirectResolver;M(t,this,"argument-error"),this.redirectPersistenceManager=await Qn.create(this,[Rt(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){return this._isInitialized&&await this.queue(async()=>{}),this._currentUser?._redirectEventId===e?this._currentUser:this.redirectUser?._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(){if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const e=this.currentUser?.uid??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,r,s){if(this._deleted)return()=>{};const i=typeof t=="function"?t:t.next.bind(t);let a=!1;const c=this._isInitialized?Promise.resolve():this._initializationPromise;if(M(c,this,"internal-error"),c.then(()=>{a||i(this.currentUser)}),typeof t=="function"){const l=e.addObserver(t,r,s);return()=>{a=!0,l()}}else{const l=e.addObserver(t);return()=>{a=!0,l()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return M(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=Gh(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const t=await this.heartbeatServiceProvider.getImmediate({optional:!0})?.getHeartbeatsHeader();t&&(e["X-Firebase-Client"]=t);const r=await this._getAppCheckToken();return r&&(e["X-Firebase-AppCheck"]=r),e}async _getAppCheckToken(){if(Ae(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&QE(`Error while retrieving App Check token: ${e.error}`),e?.token}}function lt(n){return Y(n)}class Kh{constructor(e){this.auth=e,this.observer=null,this.addObserver=Mp(t=>this.observer=t)}get next(){return M(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let hi={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function IT(n){hi=n}function Qh(n){return hi.loadJS(n)}function vT(){return hi.recaptchaEnterpriseScript}function AT(){return hi.gapiScript}function RT(n){return`__${n}${Math.floor(Math.random()*1e6)}`}class bT{constructor(){this.enterprise=new PT}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class PT{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}const CT="recaptcha-enterprise",Yh="NO_RECAPTCHA";class ST{constructor(e){this.type=CT,this.auth=lt(e)}async verify(e="verify",t=!1){async function r(i){if(!t){if(i.tenantId==null&&i._agentRecaptchaConfig!=null)return i._agentRecaptchaConfig.siteKey;if(i.tenantId!=null&&i._tenantRecaptchaConfigs[i.tenantId]!==void 0)return i._tenantRecaptchaConfigs[i.tenantId].siteKey}return new Promise(async(a,c)=>{iT(i,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(l=>{if(l.recaptchaKey===void 0)c(new Error("recaptcha Enterprise site key undefined"));else{const d=new sT(l);return i.tenantId==null?i._agentRecaptchaConfig=d:i._tenantRecaptchaConfigs[i.tenantId]=d,a(d.siteKey)}}).catch(l=>{c(l)})})}function s(i,a,c){const l=window.grecaptcha;Dh(l)?l.enterprise.ready(()=>{l.enterprise.execute(i,{action:e}).then(d=>{a(d)}).catch(()=>{a(Yh)})}):c(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new bT().execute("siteKey",{action:"verify"}):new Promise((i,a)=>{r(this.auth).then(c=>{if(!t&&Dh(window.grecaptcha))s(c,i,a);else{if(typeof window>"u"){a(new Error("RecaptchaVerifier is only supported in browser"));return}let l=vT();l.length!==0&&(l+=c),Qh(l).then(()=>{s(c,i,a)}).catch(d=>{a(d)})}}).catch(c=>{a(c)})})}}async function Jh(n,e,t,r=!1,s=!1){const i=new ST(n);let a;if(s)a=Yh;else try{a=await i.verify(t)}catch{a=await i.verify(t,!0)}const c={...e};if(t==="mfaSmsEnrollment"||t==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in c){const l=c.phoneEnrollmentInfo.phoneNumber,d=c.phoneEnrollmentInfo.recaptchaToken;Object.assign(c,{phoneEnrollmentInfo:{phoneNumber:l,recaptchaToken:d,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in c){const l=c.phoneSignInInfo.recaptchaToken;Object.assign(c,{phoneSignInInfo:{recaptchaToken:l,captchaResponse:a,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return c}return r?Object.assign(c,{captchaResp:a}):Object.assign(c,{captchaResponse:a}),Object.assign(c,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(c,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),c}async function di(n,e,t,r,s){if(n._getRecaptchaConfig()?.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const i=await Jh(n,e,t,t==="getOobCode");return r(n,i)}else return r(n,e).catch(async i=>{if(i.code==="auth/missing-recaptcha-token"){console.log(`${t} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const a=await Jh(n,e,t,t==="getOobCode");return r(n,a)}else return Promise.reject(i)})}function kT(n,e){const t=dr(n,"auth");if(t.isInitialized()){const s=t.getImmediate(),i=t.getOptions();if(en(i,e??{}))return s;We(s,"already-initialized")}return t.initialize({options:e})}function NT(n,e){const t=e?.persistence||[],r=(Array.isArray(t)?t:[t]).map(Rt);e?.errorMap&&n._updateErrorMap(e.errorMap),n._initializeWithPersistence(r,e?.popupRedirectResolver)}function Xh(n,e,t){const r=lt(n);M(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const s=!1,i=Zh(e),{host:a,port:c}=DT(e),l=c===null?"":`:${c}`,d={url:`${i}//${a}${l}/`},f=Object.freeze({host:a,port:c,protocol:i.replace(":",""),options:Object.freeze({disableWarnings:s})});if(!r._canInitEmulator){M(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),M(en(d,r.config.emulator)&&en(f,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=d,r.emulatorConfig=f,r.settings.appVerificationDisabledForTesting=!0,tt(a)?(ls(`${i}//${a}${l}`),hs("Auth",!0)):OT()}function Zh(n){const e=n.indexOf(":");return e<0?"":n.substr(0,e+1)}function DT(n){const e=Zh(n),t=/(\/\/)?([^?#/]+)/.exec(n.substr(e.length));if(!t)return{host:"",port:null};const r=t[2].split("@").pop()||"",s=/^(\[[^\]]+\])(:|$)/.exec(r);if(s){const i=s[1];return{host:i,port:ed(r.substr(i.length+1))}}else{const[i,a]=r.split(":");return{host:i,port:ed(a)}}}function ed(n){if(!n)return null;const e=Number(n);return isNaN(e)?null:e}function OT(){function n(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",n):n())}class Ta{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return It("not implemented")}_getIdTokenResponse(e){return It("not implemented")}_linkToIdToken(e,t){return It("not implemented")}_getReauthenticationResolver(e){return It("not implemented")}}async function VT(n,e){return Je(n,"POST","/v1/accounts:signUp",e)}async function LT(n,e){return xr(n,"POST","/v1/accounts:signInWithPassword",At(n,e))}async function td(n,e){return Je(n,"POST","/v1/accounts:sendOobCode",At(n,e))}async function MT(n,e){return td(n,e)}async function xT(n,e){return td(n,e)}async function UT(n,e){return xr(n,"POST","/v1/accounts:signInWithEmailLink",At(n,e))}async function FT(n,e){return xr(n,"POST","/v1/accounts:signInWithEmailLink",At(n,e))}class Br extends Ta{constructor(e,t,r,s=null){super("password",r),this._email=e,this._password=t,this._tenantId=s}static _fromEmailAndPassword(e,t){return new Br(e,t,"password")}static _fromEmailAndCode(e,t,r=null){return new Br(e,t,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e;if(t?.email&&t?.password){if(t.signInMethod==="password")return this._fromEmailAndPassword(t.email,t.password);if(t.signInMethod==="emailLink")return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":const t={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return di(e,t,"signInWithPassword",LT);case"emailLink":return UT(e,{email:this._email,oobCode:this._password});default:We(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":const r={idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return di(e,r,"signUpPassword",VT);case"emailLink":return FT(e,{idToken:t,email:this._email,oobCode:this._password});default:We(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function Yn(n,e){return xr(n,"POST","/v1/accounts:signInWithIdp",At(n,e))}const BT="http://localhost";class mn extends Ta{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new mn(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):We("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t=typeof e=="string"?JSON.parse(e):e,{providerId:r,signInMethod:s,...i}=t;if(!r||!s)return null;const a=new mn(r,s);return a.idToken=i.idToken||void 0,a.accessToken=i.accessToken||void 0,a.secret=i.secret,a.nonce=i.nonce,a.pendingToken=i.pendingToken||null,a}_getIdTokenResponse(e){const t=this.buildRequest();return Yn(e,t)}_linkToIdToken(e,t){const r=this.buildRequest();return r.idToken=t,Yn(e,r)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,Yn(e,t)}buildRequest(){const e={requestUri:BT,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=ur(t)}return e}}function qT(n){switch(n){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function jT(n){const e=lr(hr(n)).link,t=e?lr(hr(e)).deep_link_id:null,r=lr(hr(n)).deep_link_id;return(r?lr(hr(r)).link:null)||r||t||e||n}class wa{constructor(e){const t=lr(hr(e)),r=t.apiKey??null,s=t.oobCode??null,i=qT(t.mode??null);M(r&&s&&i,"argument-error"),this.apiKey=r,this.operation=i,this.code=s,this.continueUrl=t.continueUrl??null,this.languageCode=t.lang??null,this.tenantId=t.tenantId??null}static parseLink(e){const t=jT(e);try{return new wa(t)}catch{return null}}}class Jn{constructor(){this.providerId=Jn.PROVIDER_ID}static credential(e,t){return Br._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const r=wa.parseLink(t);return M(r,"argument-error"),Br._fromEmailAndCode(e,r.code,r.tenantId)}}Jn.PROVIDER_ID="password",Jn.EMAIL_PASSWORD_SIGN_IN_METHOD="password",Jn.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class fi{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}}class qr extends fi{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class ht extends qr{constructor(){super("facebook.com")}static credential(e){return mn._fromParams({providerId:ht.PROVIDER_ID,signInMethod:ht.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return ht.credentialFromTaggedObject(e)}static credentialFromError(e){return ht.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return ht.credential(e.oauthAccessToken)}catch{return null}}}ht.FACEBOOK_SIGN_IN_METHOD="facebook.com",ht.PROVIDER_ID="facebook.com";class dt extends qr{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return mn._fromParams({providerId:dt.PROVIDER_ID,signInMethod:dt.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return dt.credentialFromTaggedObject(e)}static credentialFromError(e){return dt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:r}=e;if(!t&&!r)return null;try{return dt.credential(t,r)}catch{return null}}}dt.GOOGLE_SIGN_IN_METHOD="google.com",dt.PROVIDER_ID="google.com";class Wt extends qr{constructor(){super("github.com")}static credential(e){return mn._fromParams({providerId:Wt.PROVIDER_ID,signInMethod:Wt.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Wt.credentialFromTaggedObject(e)}static credentialFromError(e){return Wt.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return Wt.credential(e.oauthAccessToken)}catch{return null}}}Wt.GITHUB_SIGN_IN_METHOD="github.com",Wt.PROVIDER_ID="github.com";class Ze extends qr{constructor(){super("twitter.com")}static credential(e,t){return mn._fromParams({providerId:Ze.PROVIDER_ID,signInMethod:Ze.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return Ze.credentialFromTaggedObject(e)}static credentialFromError(e){return Ze.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:r}=e;if(!t||!r)return null;try{return Ze.credential(t,r)}catch{return null}}}Ze.TWITTER_SIGN_IN_METHOD="twitter.com",Ze.PROVIDER_ID="twitter.com";async function nd(n,e){return xr(n,"POST","/v1/accounts:signUp",At(n,e))}class bt{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,r,s=!1){const i=await Xe._fromIdTokenResponse(e,r,s),a=rd(r);return new bt({user:i,providerId:a,_tokenResponse:r,operationType:t})}static async _forOperation(e,t,r){await e._updateTokensIfNecessary(r,!0);const s=rd(r);return new bt({user:e,providerId:s,_tokenResponse:r,operationType:t})}}function rd(n){return n.providerId?n.providerId:"phoneNumber"in n?"phone":null}async function $T(n){if(Ae(n.app))return Promise.reject(ut(n));const e=lt(n);if(await e._initializationPromise,e.currentUser?.isAnonymous)return new bt({user:e.currentUser,providerId:null,operationType:"signIn"});const t=await nd(e,{returnSecureToken:!0}),r=await bt._fromIdTokenResponse(e,"signIn",t,!0);return await e._updateCurrentUser(r.user),r}class pi extends He{constructor(e,t,r,s){super(t.code,t.message),this.operationType=r,this.user=s,Object.setPrototypeOf(this,pi.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:t.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,t,r,s){return new pi(e,t,r,s)}}function sd(n,e,t,r){return(e==="reauthenticate"?t._getReauthenticationResolver(n):t._getIdTokenResponse(n)).catch(i=>{throw i.code==="auth/multi-factor-auth-required"?pi._fromErrorAndOperation(n,i,e,r):i})}function id(n){return new Set(n.map(({providerId:e})=>e).filter(e=>!!e))}async function zT(n,e){const t=Y(n);await HT(!0,t,e);const{providerUserInfo:r}=await aT(t.auth,{idToken:await t.getIdToken(),deleteProvider:[e]}),s=id(r||[]);return t.providerData=t.providerData.filter(i=>s.has(i.providerId)),s.has("phone")||(t.phoneNumber=null),await t.auth._persistUserIfCurrent(t),t}async function WT(n,e,t=!1){const r=await Gn(n,e._linkToIdToken(n.auth,await n.getIdToken()),t);return bt._forOperation(n,"link",r)}async function HT(n,e,t){await Fr(e);const r=id(e.providerData);M(r.has(t)===n,e.auth,"no-such-provider")}async function GT(n,e,t=!1){const{auth:r}=n;if(Ae(r.app))return Promise.reject(ut(r));const s="reauthenticate";try{const i=await Gn(n,sd(r,s,e,n),t);M(i.idToken,r,"internal-error");const a=_a(i.idToken);M(a,r,"internal-error");const{sub:c}=a;return M(n.uid===c,r,"user-mismatch"),bt._forOperation(n,s,i)}catch(i){throw i?.code==="auth/user-not-found"&&We(r,"user-mismatch"),i}}async function od(n,e,t=!1){if(Ae(n.app))return Promise.reject(ut(n));const r="signIn",s=await sd(n,r,e),i=await bt._fromIdTokenResponse(n,r,s);return t||await n._updateCurrentUser(i.user),i}async function KT(n,e){return od(lt(n),e)}function QT(n,e,t){M(t.url?.length>0,n,"invalid-continue-uri"),M(typeof t.dynamicLinkDomain>"u"||t.dynamicLinkDomain.length>0,n,"invalid-dynamic-link-domain"),M(typeof t.linkDomain>"u"||t.linkDomain.length>0,n,"invalid-hosting-link-domain"),e.continueUrl=t.url,e.dynamicLinkDomain=t.dynamicLinkDomain,e.linkDomain=t.linkDomain,e.canHandleCodeInApp=t.handleCodeInApp,t.iOS&&(M(t.iOS.bundleId.length>0,n,"missing-ios-bundle-id"),e.iOSBundleId=t.iOS.bundleId),t.android&&(M(t.android.packageName.length>0,n,"missing-android-pkg-name"),e.androidInstallApp=t.android.installApp,e.androidMinimumVersionCode=t.android.minimumVersion,e.androidPackageName=t.android.packageName)}async function ad(n){const e=lt(n);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}async function YT(n,e,t){const r=lt(n);await di(r,{requestType:"PASSWORD_RESET",email:e,clientType:"CLIENT_TYPE_WEB"},"getOobCode",xT)}async function JT(n,e,t){if(Ae(n.app))return Promise.reject(ut(n));const r=lt(n),a=await di(r,{returnSecureToken:!0,email:e,password:t,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",nd).catch(l=>{throw l.code==="auth/password-does-not-meet-requirements"&&ad(n),l}),c=await bt._fromIdTokenResponse(r,"signIn",a);return await r._updateCurrentUser(c.user),c}function cd(n,e,t){return Ae(n.app)?Promise.reject(ut(n)):KT(Y(n),Jn.credential(e,t)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&ad(n),r})}async function ud(n,e){const t=Y(n),s={requestType:"VERIFY_EMAIL",idToken:await n.getIdToken()};e&&QT(t.auth,s,e);const{email:i}=await MT(t.auth,s);i!==n.email&&await n.reload()}async function XT(n,e){return Je(n,"POST","/v1/accounts:update",e)}async function ZT(n,{displayName:e,photoURL:t}){if(e===void 0&&t===void 0)return;const r=Y(n),i={idToken:await r.getIdToken(),displayName:e,photoUrl:t,returnSecureToken:!0},a=await Gn(r,XT(r.auth,i));r.displayName=a.displayName||null,r.photoURL=a.photoUrl||null;const c=r.providerData.find(({providerId:l})=>l==="password");c&&(c.displayName=r.displayName,c.photoURL=r.photoURL),await r._updateTokensIfNecessary(a)}function ew(n,e,t,r){return Y(n).onIdTokenChanged(e,t,r)}function tw(n,e,t){return Y(n).beforeAuthStateChanged(e,t)}const mi="__sak";class ld{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(mi,"1"),this.storage.removeItem(mi),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}const nw=1e3,rw=10;class hd extends ld{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=Hh(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const r=this.storage.getItem(t),s=this.localCache[t];r!==s&&e(t,s,r)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((a,c,l)=>{this.notifyListeners(a,l)});return}const r=e.key;t?this.detachListener():this.stopPolling();const s=()=>{const a=this.storage.getItem(r);!t&&this.localCache[r]===a||this.notifyListeners(r,a)},i=this.storage.getItem(r);gT()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(s,rw):s()}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:r}),!0)})},nw)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}hd.type="LOCAL";const sw=hd;class dd extends ld{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}dd.type="SESSION";const fd=dd;function iw(n){return Promise.all(n.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(t){return{fulfilled:!1,reason:t}}}))}class gi{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(s=>s.isListeningto(e));if(t)return t;const r=new gi(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:r,eventType:s,data:i}=t.data,a=this.handlersMap[s];if(!a?.size)return;t.ports[0].postMessage({status:"ack",eventId:r,eventType:s});const c=Array.from(a).map(async d=>d(t.origin,i)),l=await iw(c);t.ports[0].postMessage({status:"done",eventId:r,eventType:s,response:l})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),(!t||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}gi.receivers=[];function Ia(n="",e=10){let t="";for(let r=0;r<e;r++)t+=Math.floor(Math.random()*10);return n+t}class ow{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,r=50){const s=typeof MessageChannel<"u"?new MessageChannel:null;if(!s)throw new Error("connection_unavailable");let i,a;return new Promise((c,l)=>{const d=Ia("",20);s.port1.start();const f=setTimeout(()=>{l(new Error("unsupported_event"))},r);a={messageChannel:s,onMessage(m){const _=m;if(_.data.eventId===d)switch(_.data.status){case"ack":clearTimeout(f),i=setTimeout(()=>{l(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),c(_.data.response);break;default:clearTimeout(f),clearTimeout(i),l(new Error("invalid_response"));break}}},this.handlers.add(a),s.port1.addEventListener("message",a.onMessage),this.target.postMessage({eventType:e,eventId:d,data:t},[s.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}}function ft(){return window}function aw(n){ft().location.href=n}function pd(){return typeof ft().WorkerGlobalScope<"u"&&typeof ft().importScripts=="function"}async function cw(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function uw(){return navigator?.serviceWorker?.controller||null}function lw(){return pd()?self:null}const md="firebaseLocalStorageDb",hw=1,_i="firebaseLocalStorage",gd="fbase_key";class jr{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 yi(n,e){return n.transaction([_i],e?"readwrite":"readonly").objectStore(_i)}function dw(){const n=indexedDB.deleteDatabase(md);return new jr(n).toPromise()}function va(){const n=indexedDB.open(md,hw);return new Promise((e,t)=>{n.addEventListener("error",()=>{t(n.error)}),n.addEventListener("upgradeneeded",()=>{const r=n.result;try{r.createObjectStore(_i,{keyPath:gd})}catch(s){t(s)}}),n.addEventListener("success",async()=>{const r=n.result;r.objectStoreNames.contains(_i)?e(r):(r.close(),await dw(),e(await va()))})})}async function _d(n,e,t){const r=yi(n,!0).put({[gd]:e,value:t});return new jr(r).toPromise()}async function fw(n,e){const t=yi(n,!1).get(e),r=await new jr(t).toPromise();return r===void 0?null:r.value}function yd(n,e){const t=yi(n,!0).delete(e);return new jr(t).toPromise()}const pw=800,mw=3;class Ed{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db?this.db:(this.db=await va(),this.db)}async _withRetries(e){let t=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(t++>mw)throw r;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return pd()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=gi._getInstance(lw()),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){if(this.activeServiceWorker=await cw(),!this.activeServiceWorker)return;this.sender=new ow(this.activeServiceWorker);const e=await this.sender._send("ping",{},800);e&&e[0]?.fulfilled&&e[0]?.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||uw()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await va();return await _d(e,mi,"1"),await yd(e,mi),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(r=>_d(r,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(r=>fw(r,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>yd(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(s=>{const i=yi(s,!1).getAll();return new jr(i).toPromise()});if(!e)return[];if(this.pendingWrites!==0)return[];const t=[],r=new Set;if(e.length!==0)for(const{fbase_key:s,value:i}of e)r.add(s),JSON.stringify(this.localCache[s])!==JSON.stringify(i)&&(this.notifyListeners(s,i),t.push(s));for(const s of Object.keys(this.localCache))this.localCache[s]&&!r.has(s)&&(this.notifyListeners(s,null),t.push(s));return t}notifyListeners(e,t){this.localCache[e]=t;const r=this.listeners[e];if(r)for(const s of Array.from(r))s(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),pw)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&this.stopPolling()}}Ed.type="LOCAL";const gw=Ed;new Mr(3e4,6e4);function Aa(n,e){return e?Rt(e):(M(n._popupRedirectResolver,n,"argument-error"),n._popupRedirectResolver)}class Ra extends Ta{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return Yn(e,this._buildIdpRequest())}_linkToIdToken(e,t){return Yn(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return Yn(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 _w(n){return od(n.auth,new Ra(n),n.bypassAuthState)}function yw(n){const{auth:e,user:t}=n;return M(t,e,"internal-error"),GT(t,new Ra(n),n.bypassAuthState)}async function Ew(n){const{auth:e,user:t}=n;return M(t,e,"internal-error"),WT(t,new Ra(n),n.bypassAuthState)}class Td{constructor(e,t,r,s,i=!1){this.auth=e,this.resolver=r,this.user=s,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:r,postBody:s,tenantId:i,error:a,type:c}=e;if(a){this.reject(a);return}const l={auth:this.auth,requestUri:t,sessionId:r,tenantId:i||void 0,postBody:s||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(c)(l))}catch(d){this.reject(d)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return _w;case"linkViaPopup":case"linkViaRedirect":return Ew;case"reauthViaPopup":case"reauthViaRedirect":return yw;default:We(this.auth,"internal-error")}}resolve(e){vt(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){vt(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()}}const Tw=new Mr(2e3,1e4);async function ba(n,e,t){if(Ae(n.app))return Promise.reject(Ye(n,"operation-not-supported-in-this-environment"));const r=lt(n);Ph(n,e,fi);const s=Aa(r,t);return new Ht(r,"signInViaPopup",e,s).executeNotNull()}async function wd(n,e,t){const r=Y(n);Ph(r.auth,e,fi);const s=Aa(r.auth,t);return new Ht(r.auth,"linkViaPopup",e,s,r).executeNotNull()}class Ht extends Td{constructor(e,t,r,s,i){super(e,t,s,i),this.provider=r,this.authWindow=null,this.pollId=null,Ht.currentPopupAction&&Ht.currentPopupAction.cancel(),Ht.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return M(e,this.auth,"internal-error"),e}async onExecution(){vt(this.filter.length===1,"Popup operations only handle one event");const e=Ia();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(t=>{this.reject(t)}),this.resolver._isIframeWebStorageSupported(this.auth,t=>{t||this.reject(Ye(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(Ye(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,Ht.currentPopupAction=null}pollUserCancellation(){const e=()=>{if(this.authWindow?.window?.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(Ye(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,Tw.get())};e()}}Ht.currentPopupAction=null;const ww="pendingRedirect",Ei=new Map;class Iw extends Td{constructor(e,t,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,r),this.eventId=null}async execute(){let e=Ei.get(this.auth._key());if(!e){try{const r=await vw(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(t){e=()=>Promise.reject(t)}Ei.set(this.auth._key(),e)}return this.bypassAuthState||Ei.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function vw(n,e){const t=bw(e),r=Rw(n);if(!await r._isAvailable())return!1;const s=await r._get(t)==="true";return await r._remove(t),s}function Aw(n,e){Ei.set(n._key(),e)}function Rw(n){return Rt(n._redirectPersistence)}function bw(n){return li(ww,n.config.apiKey,n.name)}async function Pw(n,e,t=!1){if(Ae(n.app))return Promise.reject(ut(n));const r=lt(n),s=Aa(r,e),a=await new Iw(r,s,t).execute();return a&&!t&&(delete a.user._redirectEventId,await r._persistUserIfCurrent(a.user),await r._setRedirectUser(null,e)),a}const Cw=10*60*1e3;class Sw{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(t=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!kw(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){if(e.error&&!vd(e)){const r=e.error.code?.split("auth/")[1]||"internal-error";t.onError(Ye(this.auth,r))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const r=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=Cw&&this.cachedEventUids.clear(),this.cachedEventUids.has(Id(e))}saveEventToCache(e){this.cachedEventUids.add(Id(e)),this.lastProcessedEventTime=Date.now()}}function Id(n){return[n.type,n.eventId,n.sessionId,n.tenantId].filter(e=>e).join("-")}function vd({type:n,error:e}){return n==="unknown"&&e?.code==="auth/no-auth-event"}function kw(n){switch(n.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return vd(n);default:return!1}}async function Nw(n,e={}){return Je(n,"GET","/v1/projects",e)}const Dw=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Ow=/^https?/;async function Vw(n){if(n.config.emulator)return;const{authorizedDomains:e}=await Nw(n);for(const t of e)try{if(Lw(t))return}catch{}We(n,"unauthorized-domain")}function Lw(n){const e=pa(),{protocol:t,hostname:r}=new URL(e);if(n.startsWith("chrome-extension://")){const a=new URL(n);return a.hostname===""&&r===""?t==="chrome-extension:"&&n.replace("chrome-extension://","")===e.replace("chrome-extension://",""):t==="chrome-extension:"&&a.hostname===r}if(!Ow.test(t))return!1;if(Dw.test(n))return r===n;const s=n.replace(/\./g,"\\.");return new RegExp("^(.+\\."+s+"|"+s+")$","i").test(r)}const Mw=new Mr(3e4,6e4);function Ad(){const n=ft().___jsl;if(n?.H){for(const e of Object.keys(n.H))if(n.H[e].r=n.H[e].r||[],n.H[e].L=n.H[e].L||[],n.H[e].r=[...n.H[e].L],n.CP)for(let t=0;t<n.CP.length;t++)n.CP[t]=null}}function xw(n){return new Promise((e,t)=>{function r(){Ad(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{Ad(),t(Ye(n,"network-request-failed"))},timeout:Mw.get()})}if(ft().gapi?.iframes?.Iframe)e(gapi.iframes.getContext());else if(ft().gapi?.load)r();else{const s=RT("iframefcb");return ft()[s]=()=>{gapi.load?r():t(Ye(n,"network-request-failed"))},Qh(`${AT()}?onload=${s}`).catch(i=>t(i))}}).catch(e=>{throw Ti=null,e})}let Ti=null;function Uw(n){return Ti=Ti||xw(n),Ti}const Fw=new Mr(5e3,15e3),Bw="__/auth/iframe",qw="emulator/auth/iframe",jw={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},$w=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function zw(n){const e=n.config;M(e.authDomain,n,"auth-domain-config-required");const t=e.emulator?ma(e,qw):`https://${n.config.authDomain}/${Bw}`,r={apiKey:e.apiKey,appName:n.name,v:nn},s=$w.get(n.config.apiHost);s&&(r.eid=s);const i=n._getFrameworks();return i.length&&(r.fw=i.join(",")),`${t}?${ur(r).slice(1)}`}async function Ww(n){const e=await Uw(n),t=ft().gapi;return M(t,n,"internal-error"),e.open({where:document.body,url:zw(n),messageHandlersFilter:t.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:jw,dontclear:!0},r=>new Promise(async(s,i)=>{await r.restyle({setHideOnLeave:!1});const a=Ye(n,"network-request-failed"),c=ft().setTimeout(()=>{i(a)},Fw.get());function l(){ft().clearTimeout(c),s(r)}r.ping(l).then(l,()=>{i(a)})}))}const Hw={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},Gw=500,Kw=600,Qw="_blank",Yw="http://localhost";class Rd{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function Jw(n,e,t,r=Gw,s=Kw){const i=Math.max((window.screen.availHeight-s)/2,0).toString(),a=Math.max((window.screen.availWidth-r)/2,0).toString();let c="";const l={...Hw,width:r.toString(),height:s.toString(),top:i,left:a},d=ve().toLowerCase();t&&(c=qh(d)?Qw:t),Fh(d)&&(e=e||Yw,l.scrollbars="yes");const f=Object.entries(l).reduce((_,[R,S])=>`${_}${R}=${S},`,"");if(mT(d)&&c!=="_self")return Xw(e||"",c),new Rd(null);const m=window.open(e||"",c,f);M(m,n,"popup-blocked");try{m.focus()}catch{}return new Rd(m)}function Xw(n,e){const t=document.createElement("a");t.href=n,t.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),t.dispatchEvent(r)}const Zw="__/auth/handler",eI="emulator/auth/handler",tI=encodeURIComponent("fac");async function bd(n,e,t,r,s,i){M(n.config.authDomain,n,"auth-domain-config-required"),M(n.config.apiKey,n,"invalid-api-key");const a={apiKey:n.config.apiKey,appName:n.name,authType:t,redirectUrl:r,v:nn,eventId:s};if(e instanceof fi){e.setDefaultLanguage(n.languageCode),a.providerId=e.providerId||"",Lp(e.getCustomParameters())||(a.customParameters=JSON.stringify(e.getCustomParameters()));for(const[f,m]of Object.entries({}))a[f]=m}if(e instanceof qr){const f=e.getScopes().filter(m=>m!=="");f.length>0&&(a.scopes=f.join(","))}n.tenantId&&(a.tid=n.tenantId);const c=a;for(const f of Object.keys(c))c[f]===void 0&&delete c[f];const l=await n._getAppCheckToken(),d=l?`#${tI}=${encodeURIComponent(l)}`:"";return`${nI(n)}?${ur(c).slice(1)}${d}`}function nI({config:n}){return n.emulator?ma(n,eI):`https://${n.authDomain}/${Zw}`}const Pa="webStorageSupport";class rI{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=fd,this._completeRedirectFn=Pw,this._overrideRedirectResult=Aw}async _openPopup(e,t,r,s){vt(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()");const i=await bd(e,t,r,pa(),s);return Jw(e,i,Ia())}async _openRedirect(e,t,r,s){await this._originValidation(e);const i=await bd(e,t,r,pa(),s);return aw(i),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:s,promise:i}=this.eventManagers[t];return s?Promise.resolve(s):(vt(i,"If manager is not set, promise should be"),i)}const r=this.initAndGetManager(e);return this.eventManagers[t]={promise:r},r.catch(()=>{delete this.eventManagers[t]}),r}async initAndGetManager(e){const t=await Ww(e),r=new Sw(e);return t.register("authEvent",s=>(M(s?.authEvent,e,"invalid-auth-event"),{status:r.onEvent(s.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=t,r}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(Pa,{type:Pa},s=>{const i=s?.[0]?.[Pa];i!==void 0&&t(!!i),We(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=Vw(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return Hh()||Bh()||Ea()}}const sI=rI;var Pd="@firebase/auth",Cd="1.12.1";class iI{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){return this.assertAuthConfigured(),this.auth.currentUser?.uid||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(r=>{e(r?.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(){M(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function oI(n){switch(n){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function aI(n){St(new _t("auth",(e,{options:t})=>{const r=e.getProvider("app").getImmediate(),s=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:a,authDomain:c}=r.options;M(a&&!a.includes(":"),"invalid-api-key",{appName:r.name});const l={apiKey:a,authDomain:c,clientPlatform:n,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:Gh(n)},d=new wT(r,s,i,l);return NT(d,t),d},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,r)=>{e.getProvider("auth-internal").initialize()})),St(new _t("auth-internal",e=>{const t=lt(e.getProvider("auth").getImmediate());return(r=>new iI(r))(t)},"PRIVATE").setInstantiationMode("EXPLICIT")),je(Pd,Cd,oI(n)),je(Pd,Cd,"esm2020")}const cI=5*60,uI=_c("authIdTokenMaxAge")||cI;let Sd=null;const lI=n=>async e=>{const t=e&&await e.getIdTokenResult(),r=t&&(new Date().getTime()-Date.parse(t.issuedAtTime))/1e3;if(r&&r>uI)return;const s=t?.token;Sd!==s&&(Sd=s,await fetch(n,{method:s?"POST":"DELETE",headers:s?{Authorization:`Bearer ${s}`}:{}}))};function hI(n=fs()){const e=dr(n,"auth");if(e.isInitialized())return e.getImmediate();const t=kT(n,{popupRedirectResolver:sI,persistence:[gw,sw,fd]}),r=_c("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const i=new URL(r,location.origin);if(location.origin===i.origin){const a=lI(i.toString());tw(t,a,()=>a(t.currentUser)),ew(t,c=>a(c))}}const s=mc("auth");return s&&Xh(t,`http://${s}`),t}function dI(){return document.getElementsByTagName("head")?.[0]??document}IT({loadJS(n){return new Promise((e,t)=>{const r=document.createElement("script");r.setAttribute("src",n),r.onload=e,r.onerror=s=>{const i=Ye("internal-error");i.customData=s,t(i)},r.type="text/javascript",r.charset="UTF-8",dI().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="}),aI("Browser");const kd="firebasestorage.googleapis.com",Nd="storageBucket",fI=2*60*1e3,pI=10*60*1e3,mI=1e3;class ie extends He{constructor(e,t,r=0){super(Ca(e),`Firebase Storage: ${t} (${Ca(e)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,ie.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return Ca(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}
|
|
43
|
-
${this.customData.serverResponse}`:this.message=this._baseMessage}}var te;(function(n){n.UNKNOWN="unknown",n.OBJECT_NOT_FOUND="object-not-found",n.BUCKET_NOT_FOUND="bucket-not-found",n.PROJECT_NOT_FOUND="project-not-found",n.QUOTA_EXCEEDED="quota-exceeded",n.UNAUTHENTICATED="unauthenticated",n.UNAUTHORIZED="unauthorized",n.UNAUTHORIZED_APP="unauthorized-app",n.RETRY_LIMIT_EXCEEDED="retry-limit-exceeded",n.INVALID_CHECKSUM="invalid-checksum",n.CANCELED="canceled",n.INVALID_EVENT_NAME="invalid-event-name",n.INVALID_URL="invalid-url",n.INVALID_DEFAULT_BUCKET="invalid-default-bucket",n.NO_DEFAULT_BUCKET="no-default-bucket",n.CANNOT_SLICE_BLOB="cannot-slice-blob",n.SERVER_FILE_WRONG_SIZE="server-file-wrong-size",n.NO_DOWNLOAD_URL="no-download-url",n.INVALID_ARGUMENT="invalid-argument",n.INVALID_ARGUMENT_COUNT="invalid-argument-count",n.APP_DELETED="app-deleted",n.INVALID_ROOT_OPERATION="invalid-root-operation",n.INVALID_FORMAT="invalid-format",n.INTERNAL_ERROR="internal-error",n.UNSUPPORTED_ENVIRONMENT="unsupported-environment"})(te||(te={}));function Ca(n){return"storage/"+n}function Sa(){const n="An unknown error occurred, please check the error payload for server response.";return new ie(te.UNKNOWN,n)}function gI(n){return new ie(te.OBJECT_NOT_FOUND,"Object '"+n+"' does not exist.")}function _I(n){return new ie(te.QUOTA_EXCEEDED,"Quota for bucket '"+n+"' exceeded, please view quota on https://firebase.google.com/pricing/.")}function yI(){const n="User is not authenticated, please authenticate using Firebase Authentication and try again.";return new ie(te.UNAUTHENTICATED,n)}function EI(){return new ie(te.UNAUTHORIZED_APP,"This app does not have permission to access Firebase Storage on this project.")}function TI(n){return new ie(te.UNAUTHORIZED,"User does not have permission to access '"+n+"'.")}function Dd(){return new ie(te.RETRY_LIMIT_EXCEEDED,"Max retry time for operation exceeded, please try again.")}function Od(){return new ie(te.CANCELED,"User canceled the upload/download.")}function wI(n){return new ie(te.INVALID_URL,"Invalid URL '"+n+"'.")}function II(n){return new ie(te.INVALID_DEFAULT_BUCKET,"Invalid default bucket '"+n+"'.")}function vI(){return new ie(te.NO_DEFAULT_BUCKET,"No default bucket found. Did you set the '"+Nd+"' property when initializing the app?")}function Vd(){return new ie(te.CANNOT_SLICE_BLOB,"Cannot slice blob for upload. Please retry the upload.")}function AI(){return new ie(te.SERVER_FILE_WRONG_SIZE,"Server recorded incorrect upload file size, please retry the upload.")}function RI(){return new ie(te.NO_DOWNLOAD_URL,"The given file does not have any download URLs.")}function bI(n){return new ie(te.UNSUPPORTED_ENVIRONMENT,`${n} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function ka(n){return new ie(te.INVALID_ARGUMENT,n)}function Ld(){return new ie(te.APP_DELETED,"The Firebase app was deleted.")}function PI(n){return new ie(te.INVALID_ROOT_OPERATION,"The operation '"+n+"' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').")}function $r(n,e){return new ie(te.INVALID_FORMAT,"String does not match format '"+n+"': "+e)}function zr(n){throw new ie(te.INTERNAL_ERROR,"Internal error: "+n)}class Be{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){const e=encodeURIComponent;return"/b/"+e(this.bucket)+"/o/"+e(this.path)}bucketOnlyServerUrl(){return"/b/"+encodeURIComponent(this.bucket)+"/o"}static makeFromBucketSpec(e,t){let r;try{r=Be.makeFromUrl(e,t)}catch{return new Be(e,"")}if(r.path==="")return r;throw II(e)}static makeFromUrl(e,t){let r=null;const s="([A-Za-z0-9.\\-_]+)";function i(Q){Q.path.charAt(Q.path.length-1)==="/"&&(Q.path_=Q.path_.slice(0,-1))}const a="(/(.*))?$",c=new RegExp("^gs://"+s+a,"i"),l={bucket:1,path:3};function d(Q){Q.path_=decodeURIComponent(Q.path)}const f="v[A-Za-z0-9_]+",m=t.replace(/[.]/g,"\\."),_="(/([^?#]*).*)?$",R=new RegExp(`^https?://${m}/${f}/b/${s}/o${_}`,"i"),S={bucket:1,path:3},N=t===kd?"(?:storage.googleapis.com|storage.cloud.google.com)":t,k="([^?#]*)",U=new RegExp(`^https?://${N}/${s}/${k}`,"i"),j=[{regex:c,indices:l,postModify:i},{regex:R,indices:S,postModify:d},{regex:U,indices:{bucket:1,path:2},postModify:d}];for(let Q=0;Q<j.length;Q++){const _e=j[Q],re=_e.regex.exec(e);if(re){const w=re[_e.indices.bucket];let g=re[_e.indices.path];g||(g=""),r=new Be(w,g),_e.postModify(r);break}}if(r==null)throw wI(e);return r}}class CI{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}}function SI(n,e,t){let r=1,s=null,i=null,a=!1,c=0;function l(){return c===2}let d=!1;function f(...k){d||(d=!0,e.apply(null,k))}function m(k){s=setTimeout(()=>{s=null,n(R,l())},k)}function _(){i&&clearTimeout(i)}function R(k,...U){if(d){_();return}if(k){_(),f.call(null,k,...U);return}if(l()||a){_(),f.call(null,k,...U);return}r<64&&(r*=2);let j;c===1?(c=2,j=0):j=(r+Math.random())*1e3,m(j)}let S=!1;function N(k){S||(S=!0,_(),!d&&(s!==null?(k||(c=2),clearTimeout(s),m(0)):k||(c=1)))}return m(0),i=setTimeout(()=>{a=!0,N(!0)},t),N}function kI(n){n(!1)}function NI(n){return n!==void 0}function DI(n){return typeof n=="function"}function OI(n){return typeof n=="object"&&!Array.isArray(n)}function wi(n){return typeof n=="string"||n instanceof String}function Md(n){return Na()&&n instanceof Blob}function Na(){return typeof Blob<"u"}function xd(n,e,t,r){if(r<e)throw ka(`Invalid value for '${n}'. Expected ${e} or greater.`);if(r>t)throw ka(`Invalid value for '${n}'. Expected ${t} or less.`)}function Xn(n,e,t){let r=e;return t==null&&(r=`https://${e}`),`${t}://${r}/v0${n}`}function Ud(n){const e=encodeURIComponent;let t="?";for(const r in n)if(n.hasOwnProperty(r)){const s=e(r)+"="+e(n[r]);t=t+s+"&"}return t=t.slice(0,-1),t}var gn;(function(n){n[n.NO_ERROR=0]="NO_ERROR",n[n.NETWORK_ERROR=1]="NETWORK_ERROR",n[n.ABORT=2]="ABORT"})(gn||(gn={}));function Fd(n,e){const t=n>=500&&n<600,s=[408,429].indexOf(n)!==-1,i=e.indexOf(n)!==-1;return t||s||i}class VI{constructor(e,t,r,s,i,a,c,l,d,f,m,_=!0,R=!1){this.url_=e,this.method_=t,this.headers_=r,this.body_=s,this.successCodes_=i,this.additionalRetryCodes_=a,this.callback_=c,this.errorCallback_=l,this.timeout_=d,this.progressCallback_=f,this.connectionFactory_=m,this.retry=_,this.isUsingEmulator=R,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((S,N)=>{this.resolve_=S,this.reject_=N,this.start_()})}start_(){const e=(r,s)=>{if(s){r(!1,new Ii(!1,null,!0));return}const i=this.connectionFactory_();this.pendingConnection_=i;const a=c=>{const l=c.loaded,d=c.lengthComputable?c.total:-1;this.progressCallback_!==null&&this.progressCallback_(l,d)};this.progressCallback_!==null&&i.addUploadProgressListener(a),i.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&i.removeUploadProgressListener(a),this.pendingConnection_=null;const c=i.getErrorCode()===gn.NO_ERROR,l=i.getStatus();if(!c||Fd(l,this.additionalRetryCodes_)&&this.retry){const f=i.getErrorCode()===gn.ABORT;r(!1,new Ii(!1,null,f));return}const d=this.successCodes_.indexOf(l)!==-1;r(!0,new Ii(d,i))})},t=(r,s)=>{const i=this.resolve_,a=this.reject_,c=s.connection;if(s.wasSuccessCode)try{const l=this.callback_(c,c.getResponse());NI(l)?i(l):i()}catch(l){a(l)}else if(c!==null){const l=Sa();l.serverResponse=c.getErrorText(),this.errorCallback_?a(this.errorCallback_(c,l)):a(l)}else if(s.canceled){const l=this.appDelete_?Ld():Od();a(l)}else{const l=Dd();a(l)}};this.canceled_?t(!1,new Ii(!1,null,!0)):this.backoffId_=SI(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&kI(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}}class Ii{constructor(e,t,r){this.wasSuccessCode=e,this.connection=t,this.canceled=!!r}}function LI(n,e){e!==null&&e.length>0&&(n.Authorization="Firebase "+e)}function MI(n,e){n["X-Firebase-Storage-Version"]="webjs/"+(e??"AppManager")}function xI(n,e){e&&(n["X-Firebase-GMPID"]=e)}function UI(n,e){e!==null&&(n["X-Firebase-AppCheck"]=e)}function FI(n,e,t,r,s,i,a=!0,c=!1){const l=Ud(n.urlParams),d=n.url+l,f=Object.assign({},n.headers);return xI(f,e),LI(f,t),MI(f,i),UI(f,r),new VI(d,n.method,f,n.body,n.successCodes,n.additionalRetryCodes,n.handler,n.errorHandler,n.timeout,n.progressCallback,s,a,c)}function BI(){return typeof BlobBuilder<"u"?BlobBuilder:typeof WebKitBlobBuilder<"u"?WebKitBlobBuilder:void 0}function qI(...n){const e=BI();if(e!==void 0){const t=new e;for(let r=0;r<n.length;r++)t.append(n[r]);return t.getBlob()}else{if(Na())return new Blob(n);throw new ie(te.UNSUPPORTED_ENVIRONMENT,"This browser doesn't seem to support creating Blobs")}}function jI(n,e,t){return n.webkitSlice?n.webkitSlice(e,t):n.mozSlice?n.mozSlice(e,t):n.slice?n.slice(e,t):null}function $I(n){if(typeof atob>"u")throw bI("base-64");return atob(n)}const pt={RAW:"raw",BASE64:"base64",BASE64URL:"base64url",DATA_URL:"data_url"};class Da{constructor(e,t){this.data=e,this.contentType=t||null}}function zI(n,e){switch(n){case pt.RAW:return new Da(Bd(e));case pt.BASE64:case pt.BASE64URL:return new Da(qd(n,e));case pt.DATA_URL:return new Da(HI(e),GI(e))}throw Sa()}function Bd(n){const e=[];for(let t=0;t<n.length;t++){let r=n.charCodeAt(t);if(r<=127)e.push(r);else if(r<=2047)e.push(192|r>>6,128|r&63);else if((r&64512)===55296)if(!(t<n.length-1&&(n.charCodeAt(t+1)&64512)===56320))e.push(239,191,189);else{const i=r,a=n.charCodeAt(++t);r=65536|(i&1023)<<10|a&1023,e.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}else(r&64512)===56320?e.push(239,191,189):e.push(224|r>>12,128|r>>6&63,128|r&63)}return new Uint8Array(e)}function WI(n){let e;try{e=decodeURIComponent(n)}catch{throw $r(pt.DATA_URL,"Malformed data URL.")}return Bd(e)}function qd(n,e){switch(n){case pt.BASE64:{const s=e.indexOf("-")!==-1,i=e.indexOf("_")!==-1;if(s||i)throw $r(n,"Invalid character '"+(s?"-":"_")+"' found: is it base64url encoded?");break}case pt.BASE64URL:{const s=e.indexOf("+")!==-1,i=e.indexOf("/")!==-1;if(s||i)throw $r(n,"Invalid character '"+(s?"+":"/")+"' found: is it base64 encoded?");e=e.replace(/-/g,"+").replace(/_/g,"/");break}}let t;try{t=$I(e)}catch(s){throw s.message.includes("polyfill")?s:$r(n,"Invalid character found")}const r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}class jd{constructor(e){this.base64=!1,this.contentType=null;const t=e.match(/^data:([^,]+)?,/);if(t===null)throw $r(pt.DATA_URL,"Must be formatted 'data:[<mediatype>][;base64],<data>");const r=t[1]||null;r!=null&&(this.base64=KI(r,";base64"),this.contentType=this.base64?r.substring(0,r.length-7):r),this.rest=e.substring(e.indexOf(",")+1)}}function HI(n){const e=new jd(n);return e.base64?qd(pt.BASE64,e.rest):WI(e.rest)}function GI(n){return new jd(n).contentType}function KI(n,e){return n.length>=e.length?n.substring(n.length-e.length)===e:!1}class Gt{constructor(e,t){let r=0,s="";Md(e)?(this.data_=e,r=e.size,s=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),r=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),r=e.length),this.size_=r,this.type_=s}size(){return this.size_}type(){return this.type_}slice(e,t){if(Md(this.data_)){const r=this.data_,s=jI(r,e,t);return s===null?null:new Gt(s)}else{const r=new Uint8Array(this.data_.buffer,e,t-e);return new Gt(r,!0)}}static getBlob(...e){if(Na()){const t=e.map(r=>r instanceof Gt?r.data_:r);return new Gt(qI.apply(null,t))}else{const t=e.map(a=>wi(a)?zI(pt.RAW,a).data:a.data_);let r=0;t.forEach(a=>{r+=a.byteLength});const s=new Uint8Array(r);let i=0;return t.forEach(a=>{for(let c=0;c<a.length;c++)s[i++]=a[c]}),new Gt(s,!0)}}uploadData(){return this.data_}}function $d(n){let e;try{e=JSON.parse(n)}catch{return null}return OI(e)?e:null}function QI(n){if(n.length===0)return null;const e=n.lastIndexOf("/");return e===-1?"":n.slice(0,e)}function YI(n,e){const t=e.split("/").filter(r=>r.length>0).join("/");return n.length===0?t:n+"/"+t}function zd(n){const e=n.lastIndexOf("/",n.length-2);return e===-1?n:n.slice(e+1)}function JI(n,e){return e}class ke{constructor(e,t,r,s){this.server=e,this.local=t||e,this.writable=!!r,this.xform=s||JI}}let vi=null;function XI(n){return!wi(n)||n.length<2?n:zd(n)}function Wd(){if(vi)return vi;const n=[];n.push(new ke("bucket")),n.push(new ke("generation")),n.push(new ke("metageneration")),n.push(new ke("name","fullPath",!0));function e(i,a){return XI(a)}const t=new ke("name");t.xform=e,n.push(t);function r(i,a){return a!==void 0?Number(a):a}const s=new ke("size");return s.xform=r,n.push(s),n.push(new ke("timeCreated")),n.push(new ke("updated")),n.push(new ke("md5Hash",null,!0)),n.push(new ke("cacheControl",null,!0)),n.push(new ke("contentDisposition",null,!0)),n.push(new ke("contentEncoding",null,!0)),n.push(new ke("contentLanguage",null,!0)),n.push(new ke("contentType",null,!0)),n.push(new ke("metadata","customMetadata",!0)),vi=n,vi}function ZI(n,e){function t(){const r=n.bucket,s=n.fullPath,i=new Be(r,s);return e._makeStorageReference(i)}Object.defineProperty(n,"ref",{get:t})}function ev(n,e,t){const r={};r.type="file";const s=t.length;for(let i=0;i<s;i++){const a=t[i];r[a.local]=a.xform(r,e[a.server])}return ZI(r,n),r}function Hd(n,e,t){const r=$d(e);return r===null?null:ev(n,r,t)}function tv(n,e,t,r){const s=$d(e);if(s===null||!wi(s.downloadTokens))return null;const i=s.downloadTokens;if(i.length===0)return null;const a=encodeURIComponent;return i.split(",").map(d=>{const f=n.bucket,m=n.fullPath,_="/b/"+a(f)+"/o/"+a(m),R=Xn(_,t,r),S=Ud({alt:"media",token:d});return R+S})[0]}function Gd(n,e){const t={},r=e.length;for(let s=0;s<r;s++){const i=e[s];i.writable&&(t[i.server]=n[i.local])}return JSON.stringify(t)}class _n{constructor(e,t,r,s){this.url=e,this.method=t,this.handler=r,this.timeout=s,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}}function Pt(n){if(!n)throw Sa()}function Oa(n,e){function t(r,s){const i=Hd(n,s,e);return Pt(i!==null),i}return t}function nv(n,e){function t(r,s){const i=Hd(n,s,e);return Pt(i!==null),tv(i,s,n.host,n._protocol)}return t}function Wr(n){function e(t,r){let s;return t.getStatus()===401?t.getErrorText().includes("Firebase App Check token is invalid")?s=EI():s=yI():t.getStatus()===402?s=_I(n.bucket):t.getStatus()===403?s=TI(n.path):s=r,s.status=t.getStatus(),s.serverResponse=r.serverResponse,s}return e}function Va(n){const e=Wr(n);function t(r,s){let i=e(r,s);return r.getStatus()===404&&(i=gI(n.path)),i.serverResponse=s.serverResponse,i}return t}function rv(n,e,t){const r=e.fullServerUrl(),s=Xn(r,n.host,n._protocol),i="GET",a=n.maxOperationRetryTime,c=new _n(s,i,Oa(n,t),a);return c.errorHandler=Va(e),c}function sv(n,e,t){const r=e.fullServerUrl(),s=Xn(r,n.host,n._protocol),i="GET",a=n.maxOperationRetryTime,c=new _n(s,i,nv(n,t),a);return c.errorHandler=Va(e),c}function iv(n,e){const t=e.fullServerUrl(),r=Xn(t,n.host,n._protocol),s="DELETE",i=n.maxOperationRetryTime;function a(l,d){}const c=new _n(r,s,a,i);return c.successCodes=[200,204],c.errorHandler=Va(e),c}function ov(n,e){return n&&n.contentType||e&&e.type()||"application/octet-stream"}function Kd(n,e,t){const r=Object.assign({},t);return r.fullPath=n.path,r.size=e.size(),r.contentType||(r.contentType=ov(null,e)),r}function av(n,e,t,r,s){const i=e.bucketOnlyServerUrl(),a={"X-Goog-Upload-Protocol":"multipart"};function c(){let j="";for(let Q=0;Q<2;Q++)j=j+Math.random().toString().slice(2);return j}const l=c();a["Content-Type"]="multipart/related; boundary="+l;const d=Kd(e,r,s),f=Gd(d,t),m="--"+l+`\r
|
|
32
|
+
)`}copy(t,n){let r=new e;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r}},Dm=class{constructor(){this.au=new V(R.comparator)}track(e){let t=e.doc.key,n=this.au.get(t);n?e.type!==0&&n.type===3?this.au=this.au.insert(t,e):e.type===3&&n.type!==1?this.au=this.au.insert(t,{type:n.type,doc:e.doc}):e.type===2&&n.type===2?this.au=this.au.insert(t,{type:2,doc:e.doc}):e.type===2&&n.type===0?this.au=this.au.insert(t,{type:0,doc:e.doc}):e.type===1&&n.type===0?this.au=this.au.remove(t):e.type===1&&n.type===2?this.au=this.au.insert(t,{type:1,doc:n.doc}):e.type===0&&n.type===1?this.au=this.au.insert(t,{type:2,doc:e.doc}):j(63341,{ft:e,uu:n}):this.au=this.au.insert(t,e)}cu(){let e=[];return this.au.inorderTraversal(((t,n)=>{e.push(n)})),e}},Om=class e{constructor(e,t,n,r,i,a,o,s,c){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=o,this.excludesMetadataChanges=s,this.hasCachedResults=c}static fromInitialDocuments(t,n,r,i,a){let o=[];return n.forEach((e=>{o.push({type:0,doc:e})})),new e(t,n,Em.emptySet(n),o,r,i,!0,!1,a)}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)&&Hf(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let 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}},km=class{constructor(){this.lu=void 0,this.Eu=[]}hu(){return this.Eu.some((e=>e.Tu()))}},Am=class{constructor(){this.queries=jm(),this.onlineState=`Unknown`,this.Pu=new Set}terminate(){(function(e,t){let n=N(e),r=n.queries;n.queries=jm(),r.forEach(((e,n)=>{for(let e of n.Eu)e.onError(t)}))})(this,new F(P.ABORTED,`Firestore shutting down`))}};function jm(){return new bs((e=>Vf(e)),Hf)}async function Mm(e,t){let n=N(e),r=3,i=t.query,a=n.queries.get(i);a?!a.hu()&&t.Tu()&&(r=2):(a=new km,r=+!t.Tu());try{switch(r){case 0:a.lu=await n.onListen(i,!0);break;case 1:a.lu=await n.onListen(i,!1);break;case 2:await n.onFirstRemoteStoreListen(i)}}catch(e){let n=Tm(e,`Initialization of query '${zf(t.query)?Lf(t.query):fs(t.query)}' failed`);t.onError(n);return}n.queries.set(i,a),a.Eu.push(t),t.Ru(n.onlineState),a.lu&&t.Iu(a.lu)&&Im(n)}async function Nm(e,t){let n=N(e),r=t.query,i=3,a=n.queries.get(r);if(a){let e=a.Eu.indexOf(t);e>=0&&(a.Eu.splice(e,1),a.Eu.length===0?i=+!t.Tu():!a.hu()&&t.Tu()&&(i=2))}switch(i){case 0:return n.queries.delete(r),n.onUnlisten(r,!0);case 1:return n.queries.delete(r),n.onUnlisten(r,!1);case 2:return n.onLastRemoteStoreUnlisten(r);default:return}}function Pm(e,t){let n=N(e),r=!1;for(let e of t){let t=e.query,i=n.queries.get(t);if(i){for(let t of i.Eu)t.Iu(e)&&(r=!0);i.lu=e}}r&&Im(n)}function Fm(e,t,n){let r=N(e),i=r.queries.get(t);if(i)for(let e of i.Eu)e.onError(n);r.queries.delete(t)}function Im(e){e.Pu.forEach((e=>{e.next()}))}var Lm;(function(e){e.Default=`default`,e.Cache=`cache`})(Lm||={});var Rm=class{constructor(e,t,n){this.query=e,this.Au=t,this.Vu=!1,this.du=null,this.onlineState=`Unknown`,this.options=n||{}}Iu(e){if(!this.options.includeMetadataChanges){let t=[];for(let n of e.docChanges)n.type!==3&&t.push(n);e=new Om(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Vu?this.fu(e)&&(this.Au.next(e),t=!0):this.mu(e,this.onlineState)&&(this.pu(e),t=!0),this.du=e,t}onError(e){this.Au.error(e)}Ru(e){this.onlineState=e;let t=!1;return this.du&&!this.Vu&&this.mu(this.du,e)&&(this.pu(this.du),t=!0),t}mu(e,t){if(!e.fromCache||!this.Tu())return!0;let n=t!==`Offline`;return(!this.options.waitForSyncWhenOnline||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||t===`Offline`)}fu(e){if(e.docChanges.length>0)return!0;let t=this.du&&this.du.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}pu(e){e=Om.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Vu=!0,this.Au.next(e)}Tu(){return this.options.source!==Lm.Cache}},zm=class{constructor(e){this.key=e}},Bm=class{constructor(e){this.key=e}},Vm=class{constructor(e,t){this.query=e,this.Ou=t,this.Mu=null,this.hasCachedResults=!1,this.current=!1,this.Nu=W(),this.mutatedKeys=W(),this.Lu=zf(e)?op(e):ms(e),this.Bu=new Em(this.Lu)}get Uu(){return this.Ou}ku(e,t){let n=t?t.qu:new Dm,r=t?t.Bu:this.Bu,i=t?t.mutatedKeys:this.mutatedKeys,a=r,o=!1,[s,c]=this.$u(this.query,r);e.inorderTraversal(((e,t)=>{let l=r.get(e),u=ip(this.query,t)?t:null,d=!!l&&this.mutatedKeys.has(l.key),f=!!u&&(u.hasLocalMutations||this.mutatedKeys.has(u.key)&&u.hasCommittedMutations),p=!1;l&&u?l.data.isEqual(u.data)?d!==f&&(n.track({type:3,doc:u}),p=!0):this.Ku(l,u)||(n.track({type:2,doc:u}),p=!0,(s&&this.Lu(u,s)>0||c&&this.Lu(u,c)<0)&&(o=!0)):!l&&u?(n.track({type:0,doc:u}),p=!0):l&&!u&&(n.track({type:1,doc:l}),p=!0,(s||c)&&(o=!0)),p&&(u?(a=a.add(u),i=f?i.add(e):i.delete(e)):(a=a.delete(e),i=i.delete(e)))}));let l=this.Wu(this.query);if(l)if(zf(this.query)){let e=[];a.forEach((t=>e.push(t)));let t=np(this.query,e),r=new Em(op(this.query));for(let e of t)r=r.add(e);a.forEach((e=>{r.has(e.key)||(i=i.delete(e.key),n.track({type:1,doc:e}))})),a=r}else{let e=this.Qu(this.query);for(;a.size>l;){let t=e===`F`?a.last():a.first();a=a.delete(t.key),i=i.delete(t.key),n.track({type:1,doc:t})}}return{Bu:a,qu:n,Uo:o,mutatedKeys:i}}Wu(e){return zf(e)?sp(e)?.limit:e.limit||void 0}Qu(e){if(zf(e)){let t=sp(e);return t&&t.limit<0?`L`:`F`}return e.limitType}$u(e,t){if(zf(e)){let n=sp(e)?.limit;return[t.size===n?t.last():null,null]}return[e.limitType===`F`&&t.size===this.Wu(this.query)?t.last():null,e.limitType===`L`&&t.size===this.Wu(this.query)?t.first():null]}Ku(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){let i=this.Bu;this.Bu=e.Bu,this.mutatedKeys=e.mutatedKeys;let a=e.qu.cu();a.sort(((e,t)=>function(e,t){let n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return j(20277,{ft:e})}};return n(e)-n(t)}(e.type,t.type)||this.Lu(e.doc,t.doc))),this.Gu(n),r??=!1;let o=t&&!r?this.zu():[],s=this.Nu.size===0&&this.current&&!r?1:0,c=s!==this.Mu;return this.Mu=s,a.length!==0||c?{snapshot:new Om(this.query,e.Bu,i,a,e.mutatedKeys,s===0,c,!1,!!n&&n.resumeToken.approximateByteSize()>0),ju:o}:{ju:o}}Ru(e){return this.current&&e===`Offline`?(this.current=!1,this.applyChanges({Bu:this.Bu,qu:new Dm,mutatedKeys:this.mutatedKeys,Uo:!1},!1)):{ju:[]}}Hu(e){return!this.Ou.has(e)&&!!this.Bu.has(e)&&!this.Bu.get(e).hasLocalMutations}Gu(e){e&&(e.addedDocuments.forEach((e=>this.Ou=this.Ou.add(e))),e.modifiedDocuments.forEach((e=>{})),e.removedDocuments.forEach((e=>this.Ou=this.Ou.delete(e))),this.current=e.current)}zu(){if(!this.current)return[];let e=this.Nu;this.Nu=W(),this.Bu.forEach((e=>{this.Hu(e.key)&&(this.Nu=this.Nu.add(e.key))}));let t=[];return e.forEach((e=>{this.Nu.has(e)||t.push(new Bm(e))})),this.Nu.forEach((n=>{e.has(n)||t.push(new zm(n))})),t}Ju(e){this.Ou=e.Jo,this.Nu=W();let t=this.ku(e.documents);return this.applyChanges(t,!0)}Yu(){return Om.fromInitialDocuments(this.query,this.Bu,this.mutatedKeys,this.Mu===0,this.hasCachedResults)}},Hm=`SyncEngine`,Um=class{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}},Wm=class{constructor(e){this.key=e,this.Zu=!1}},Gm=class{constructor(e,t,n,r,i,a){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=a,this.Xu={},this.ec=new bs((e=>Vf(e)),Hf),this.tc=new Map,this.nc=new Set,this.rc=new V(R.comparator),this.sc=new Map,this._c=new mp,this.oc={},this.ac=new Map,this.uc=tp.Cs(),this.onlineState=`Unknown`,this.cc=void 0}get isPrimaryClient(){return!0===this.cc}};async function Km(e,t,n=!0){let r=mh(e),i,a=r.ec.get(t);return a?(r.sharedClientState.addLocalQueryTarget(a.targetId),i=a.view.Yu()):i=await Jm(r,t,n,!0),i}async function qm(e,t){await Jm(mh(e),t,!0,!1)}async function Jm(e,t,n,r){let i=await Rp(e.localStore,zf(t)?t:is(t)),a=i.targetId,o=e.sharedClientState.addLocalQueryTarget(a,n),s;return r&&(s=await Ym(e,t,a,o===`current`,i.resumeToken)),e.isPrimaryClient&&n&&Zp(e.remoteStore,i),s}async function Ym(e,t,n,r,i){e.lc=(t,n,r)=>async function(e,t,n,r){let i=t.view.ku(n);i.Uo&&(i=await Bp(e.localStore,t.query,!1).then((({documents:e})=>t.view.ku(e,i))));let a=r&&r.targetChanges.get(t.targetId),o=r&&r.targetMismatches.get(t.targetId)!=null,s=t.view.applyChanges(i,e.isPrimaryClient,a,o);return ch(e,t.targetId,s.ju),s.snapshot}(e,t,n,r);let a=await Bp(e.localStore,t,!0),o=new Vm(t,a.Jo),s=o.ku(a.documents),c=Vs.createSynthesizedTargetChangeForCurrentChange(n,r&&e.onlineState!==`Offline`,i),l=o.applyChanges(s,e.isPrimaryClient,c);ch(e,n,l.ju);let u=new Um(t,n,o);return e.ec.set(t,u),e.tc.has(n)?e.tc.get(n).push(t):e.tc.set(n,[t]),l.snapshot}async function Xm(e,t,n){let r=N(e),i=r.ec.get(t),a=r.tc.get(i.targetId);if(a.length>1)return r.tc.set(i.targetId,a.filter((e=>!Hf(e,t)))),void r.ec.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)||await zp(r.localStore,i.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(i.targetId),n&&Qp(r.remoteStore,i.targetId),oh(r,i.targetId)})).catch(Ci)):(oh(r,i.targetId),await zp(r.localStore,i.targetId,!0))}async function Zm(e,t){let n=N(e),r=n.ec.get(t),i=n.tc.get(r.targetId);n.isPrimaryClient&&i.length===1&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),Qp(n.remoteStore,r.targetId))}async function Qm(e,t,n){let r=hh(e);try{let e=await function(e,t){let n=N(e),r=mi.now(),i=t.reduce(((e,t)=>e.add(t.key)),W()),a,o;return n.persistence.runTransaction(`Locally write mutations`,`readwrite`,(e=>{let s=Ss(),c=W();return n.Qo.getEntries(e,i).next((e=>{s=e,s.forEach(((e,t)=>{t.isValidDocument()||(c=c.add(e))}))})).next((()=>n.localDocuments.getOverlayedDocuments(e,s))).next((i=>{a=i;let o=[];for(let e of t){let t=fo(e,a.get(e.key).overlayedDocument);t!=null&&o.push(new ho(e.key,t,La(t.value.mapValue),ao.exists(!0)))}return n.mutationQueue.addMutationBatch(e,r,o,t)})).next((t=>{o=t;let r=t.applyToLocalDocumentSet(a,c);return n.documentOverlayCache.saveOverlays(e,t.batchId,r)}))})).then((()=>({batchId:o.batchId,changes:Ts(a)})))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.oc[e.currentUser.toKey()];r||=new V(I),r=r.insert(t,n),e.oc[e.currentUser.toKey()]=r}(r,e.batchId,n),await dh(r,e.changes),await dm(r.remoteStore)}catch(e){let t=Tm(e,`Failed to persist write`);n.reject(t)}}async function $m(e,t){let n=N(e);try{let e=await Fp(n.localStore,t);t.targetChanges.forEach(((e,t)=>{let r=n.sc.get(t);r&&(M(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1,22616),e.addedDocuments.size>0?r.Zu=!0:e.modifiedDocuments.size>0?M(r.Zu,14607):e.removedDocuments.size>0&&(M(r.Zu,42227),r.Zu=!1))})),await dh(n,e,t)}catch(e){await Ci(e)}}function eh(e,t,n){let r=N(e);if(r.isPrimaryClient&&n===0||!r.isPrimaryClient&&n===1){let e=[];r.ec.forEach(((n,r)=>{let i=r.view.Ru(t);i.snapshot&&e.push(i.snapshot)})),function(e,t){let n=N(e);n.onlineState=t;let r=!1;n.queries.forEach(((e,n)=>{for(let e of n.Eu)e.Ru(t)&&(r=!0)})),r&&Im(n)}(r.eventManager,t),e.length&&r.Xu.zn(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function th(e,t,n){let r=N(e);r.sharedClientState.updateQueryState(t,`rejected`,n);let i=r.sc.get(t),a=i&&i.key;if(a){let e=new V(R.comparator);e=e.insert(a,Wo.newNoDocument(a,z.min()));let n=W().add(a);await $m(r,new Bs(z.min(),new Map,new V(I),e,Ss(),n)),r.rc=r.rc.remove(a),r.sc.delete(t),uh(r)}else await zp(r.localStore,t,!1).then((()=>oh(r,t,n))).catch(Ci)}async function nh(e,t){let n=N(e),r=t.batch.batchId;try{let e=await Np(n.localStore,t);ah(n,r,null),ih(n,r),n.sharedClientState.updateMutationState(r,`acknowledged`),await dh(n,e)}catch(e){await Ci(e)}}async function rh(e,t,n){let r=N(e);try{let e=await function(e,t){let n=N(e);return n.persistence.runTransaction(`Reject batch`,`readwrite-primary`,(e=>{let r;return n.mutationQueue.lookupMutationBatch(e,t).next((t=>(M(t!==null,37113),r=t.keys(),n.mutationQueue.removeMutationBatch(e,t)))).next((()=>n.mutationQueue.performConsistencyCheck(e))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,r))).next((()=>n.localDocuments.getDocuments(e,r)))}))}(r.localStore,t);ah(r,t,n),ih(r,t),r.sharedClientState.updateMutationState(t,`rejected`,n),await dh(r,e)}catch(e){await Ci(e)}}function ih(e,t){(e.ac.get(t)||[]).forEach((e=>{e.resolve()})),e.ac.delete(t)}function ah(e,t,n){let r=N(e),i=r.oc[r.currentUser.toKey()];if(i){let e=i.get(t);e&&(n?e.reject(n):e.resolve(),i=i.remove(t)),r.oc[r.currentUser.toKey()]=i}}function oh(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(let r of e.tc.get(t))e.ec.delete(r),n&&e.Xu.Ec(r,n);e.tc.delete(t),e.isPrimaryClient&&e._c.s_(t).forEach((t=>{e._c.containsKey(t)||sh(e,t)}))}function sh(e,t){e.nc.delete(t.path.canonicalString());let n=e.rc.get(t);n!==null&&(Qp(e.remoteStore,n),e.rc=e.rc.remove(t),e.sc.delete(n),uh(e))}function ch(e,t,n){for(let r of n)r instanceof zm?(e._c.addReference(r.key,t),lh(e,r)):r instanceof Bm?(A(Hm,`Document no longer in limbo: `+r.key),e._c.removeReference(r.key,t),e._c.containsKey(r.key)||sh(e,r.key)):j(19791,{hc:r})}function lh(e,t){let n=t.key,r=n.path.canonicalString();e.rc.get(n)||e.nc.has(r)||(A(Hm,`New document in limbo: `+n),e.nc.add(r),uh(e))}function uh(e){for(;e.nc.size>0&&e.rc.size<e.maxConcurrentLimboResolutions;){let t=e.nc.values().next().value;e.nc.delete(t);let n=new R(L.fromString(t)),r=e.uc.next();e.sc.set(r,new Wm(n)),e.rc=e.rc.insert(n,r),Zp(e.remoteStore,new Yf(is($o(n.path)),r,`TargetPurposeLimboResolution`,Ei.ce))}}async function dh(e,t,n){let r=N(e),i=[],a=[],o=[];r.ec.isEmpty()||(r.ec.forEach(((e,s)=>{o.push(r.lc(s,t,n).then((e=>{if((e||n)&&r.isPrimaryClient){let t=e?!e.fromCache:n?.targetChanges.get(s.targetId)?.current;r.sharedClientState.updateQueryState(s.targetId,t?`current`:`not-current`)}if(e){i.push(e);let t=wp.vo(s.targetId,e);a.push(t)}})))})),await Promise.all(o),r.Xu.zn(i),await async function(e,t){let n=N(e);try{await n.persistence.runTransaction(`notifyLocalViewChanges`,`readwrite`,(e=>B.forEach(t,(t=>B.forEach(t.wo,(r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=>B.forEach(t.bo,(r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!Ti(e))throw e;A(Op,`Failed to update sequence numbers: `+e)}for(let e of t){let t=e.targetId;if(!e.fromCache){let e=n.$o.get(t),r=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(r);n.$o=n.$o.insert(t,i)}}}(r.localStore,a))}async function fh(e,t){let n=N(e);if(!n.currentUser.isEqual(t)){A(Hm,`User change. New user:`,t.toKey());let e=await Mp(n.localStore,t);n.currentUser=t,function(e,t){e.ac.forEach((e=>{e.forEach((e=>{e.reject(new F(P.CANCELLED,t))}))})),e.ac.clear()}(n,`'waitForPendingWrites' promise is rejected due to a user change.`),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await dh(n,e.zo)}}function ph(e,t){let n=N(e),r=n.sc.get(t);if(r&&r.Zu)return W().add(r.key);{let e=W(),r=n.tc.get(t);if(!r)return e;for(let t of r??[]){let r=n.ec.get(t);e=e.unionWith(r.view.Uu)}return e}}function mh(e){let t=N(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=$m.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=ph.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=th.bind(null,t),t.Xu.zn=Pm.bind(null,t.eventManager),t.Xu.Ec=Fm.bind(null,t.eventManager),t}function hh(e){let t=N(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=nh.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=rh.bind(null,t),t}var gh=class{constructor(){this.kind=`memory`,this.synchronizeTabs=!1}async initialize(e){this.serializer=Lc(e.databaseInfo.databaseId),this.sharedClientState=this.Rc(e),this.persistence=this.Ic(e),await this.persistence.start(),this.localStore=this.Ac(e),this.gcScheduler=this.Vc(e,this.localStore),this.indexBackfillerScheduler=this.dc(e,this.localStore)}Vc(e,t){return null}dc(e,t){return null}Ac(e){return jp(this.persistence,new Dp,e.initialUser,this.serializer)}Ic(e){return new bp(Sp.C_,this.serializer)}Rc(e){return new Up}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}};gh.provider={build:()=>new gh};var _h=class extends gh{constructor(e){super(),this.cacheSizeBytes=e}Vc(e,t){M(this.persistence.referenceDelegate instanceof Cp,46915);let n=this.persistence.referenceDelegate.garbageCollector;return new xl(n,e.asyncQueue,t)}Ic(e){let t=this.cacheSizeBytes===void 0?gl.DEFAULT:gl.withCacheSize(this.cacheSizeBytes);return new bp((e=>Cp.C_(e,t)),this.serializer)}},vh=class{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=>eh(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=fh.bind(null,this.syncEngine),await xm(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new Am}()}createDatastore(e){let t=Lc(e.databaseInfo.databaseId),n=nl(e.databaseInfo);return ul(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,r,i){return new qp(e,t,n,r,i)}(this.localStore,this.datastore,e.asyncQueue,(e=>eh(this.syncEngine,e,0)),function(){return Kc.C()?new Kc:new Wc}())}createSyncEngine(e,t){return function(e,t,n,r,i,a,o){let s=new Gm(e,t,n,r,i,a);return o&&(s.cc=!0),s}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await async function(e){let t=N(e);A(Kp,`RemoteStore shutting down.`),t.tu.add(5),await Yp(t),t.ru.shutdown(),t.iu.set(`Unknown`)}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}};vh.provider={build:()=>new vh};var yh=class{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.mc(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.mc(this.observer.error,e):Mr(`Uncaught Error in snapshot listener:`,e.toString()))}gc(){this.muted=!0}mc(e,t){setTimeout((()=>{this.muted||e(t)}),0)}},bh=`FirestoreClient`,xh=class{constructor(e,t,n,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this._databaseInfo=r,this.user=Dr.UNAUTHENTICATED,this.clientId=Kr.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,(async e=>{A(bh,`Received user=`,e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=>(A(bh,`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();let e=new Ir;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){let n=Tm(t,`Failed to shutdown persistence`);e.reject(n)}})),e.promise}};async function Sh(e,t){e.asyncQueue.verifyOperationInProgress(),A(bh,`Initializing OfflineComponentProvider`);let n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=>{r.isEqual(e)||(await Mp(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e._offlineComponents=t}async function Ch(e,t){e.asyncQueue.verifyOperationInProgress();let n=await wh(e);A(bh,`Initializing OnlineComponentProvider`),await t.initialize(n,e.configuration),e.setCredentialChangeListener((e=>bm(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=>bm(t.remoteStore,n))),e._onlineComponents=t}async function wh(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){A(bh,`Using user provided OfflineComponentProvider`);try{await Sh(e,e._uninitializedComponentsProvider._offline)}catch(t){let n=t;if(!function(e){return e.name===`FirebaseError`?e.code===P.FAILED_PRECONDITION||e.code===P.UNIMPLEMENTED:!(typeof DOMException<`u`&&e instanceof DOMException)||e.code===22||e.code===20||e.code===11}(n))throw n;Nr(`Error using user provided cache. Falling back to memory cache: `+n),await Sh(e,new gh)}}else A(bh,`Using default OfflineComponentProvider`),await Sh(e,new _h(void 0));return e._offlineComponents}async function Th(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(A(bh,`Using user provided OnlineComponentProvider`),await Ch(e,e._uninitializedComponentsProvider._online)):(A(bh,`Using default OnlineComponentProvider`),await Ch(e,new vh))),e._onlineComponents}function Eh(e){return Th(e).then((e=>e.syncEngine))}function Dh(e){return Th(e).then((e=>e.datastore))}async function Oh(e){let t=await Th(e),n=t.eventManager;return n.onListen=Km.bind(null,t.syncEngine),n.onUnlisten=Xm.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=qm.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=Zm.bind(null,t.syncEngine),n}function kh(e,t,n,r){let i=new yh(r),a=new Rm(t,i,n);return e.asyncQueue.enqueueAndForget((async()=>Mm(await Oh(e),a))),()=>{i.gc(),e.asyncQueue.enqueueAndForget((async()=>Nm(await Oh(e),a)))}}function Ah(e,t,n={}){let r=new Ir;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new yh({next:s=>{a.gc(),t.enqueueAndForget((()=>Nm(e,o)));let c=s.docs.has(n);!c&&s.fromCache?i.reject(new F(P.UNAVAILABLE,`Failed to get document because the client is offline.`)):c&&s.fromCache&&r&&r.source===`server`?i.reject(new F(P.UNAVAILABLE,`Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)`)):i.resolve(s)},error:e=>i.reject(e)}),o=new Rm($o(n.path),a,{includeMetadataChanges:!0,waitForSyncWhenOnline:!0});return Mm(e,o)}(await Oh(e),e.asyncQueue,t,n,r))),r.promise}function jh(e,t,n={}){let r=new Ir;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new yh({next:n=>{a.gc(),t.enqueueAndForget((()=>Nm(e,o))),n.fromCache&&r.source===`server`?i.reject(new F(P.UNAVAILABLE,`Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)`)):i.resolve(n)},error:e=>i.reject(e)}),o=new Rm(n instanceof Yu?Gf(n):n,a,{includeMetadataChanges:!0,waitForSyncWhenOnline:!0});return Mm(e,o)}(await Oh(e),e.asyncQueue,t,n,r))),r.promise}function Mh(e,t,n){let r=new Ir;return e.asyncQueue.enqueueAndForget((async()=>{try{let i=await Dh(e);r.resolve(async function(e,t,n){let r=N(e),{request:i,wt:a,parent:o}=xc(r.serializer,as(t),n);r.connection.Ot||delete i.parent;let s=(await r.$t(`RunAggregationQuery`,r.serializer.databaseId,o,i,1)).filter((e=>!!e.result));M(s.length===1,64727);let c=s[0].result?.aggregateFields;return Object.keys(c).reduce(((e,t)=>(e[a[t]]=c[t],e)),{})}(i,t,n))}catch(e){r.reject(e)}})),r.promise}function Nh(e,t){let n=new Ir;return e.asyncQueue.enqueueAndForget((async()=>Qm(await Eh(e),t,n))),n.promise}var Ph=`AsyncQueue`,Fh=class{constructor(e=Promise.resolve()){this.qc=[],this.$c=!1,this.Kc=[],this.Wc=null,this.Qc=!1,this.Gc=!1,this.zc=[],this.xn=new rl(this,`async_queue_retry`),this.jc=()=>{let e=Wp();e&&A(Ph,`Visibility state changed to `+e.visibilityState),this.xn.gn()},this.Hc=e;let t=Wp();t&&typeof t.addEventListener==`function`&&t.addEventListener(`visibilitychange`,this.jc)}get isShuttingDown(){return this.$c}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Jc(),this.Yc(e)}enterRestrictedMode(e){if(!this.$c){this.$c=!0,this.Gc=e||!1;let t=Wp();t&&typeof t.removeEventListener==`function`&&t.removeEventListener(`visibilitychange`,this.jc)}}enqueue(e){if(this.Jc(),this.$c)return new Promise((()=>{}));let t=new Ir;return this.Yc((()=>this.$c&&this.Gc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.qc.push(e),this.Zc())))}async Zc(){if(this.qc.length!==0){try{await this.qc[0](),this.qc.shift(),this.xn.reset()}catch(e){if(!Ti(e))throw e;A(Ph,`Operation failed with retryable error: `+e)}this.qc.length>0&&this.xn.mn((()=>this.Zc()))}}Yc(e){let t=this.Hc.then((()=>(this.Qc=!0,e().catch((e=>{throw this.Wc=e,this.Qc=!1,Mr(`INTERNAL UNHANDLED ERROR: `,Ih(e)),e})).then((e=>(this.Qc=!1,e))))));return this.Hc=t,t}enqueueAfterDelay(e,t,n){this.Jc(),this.zc.indexOf(e)>-1&&(t=0);let r=wm.createAndSchedule(this,e,t,n,(e=>this.Xc(e)));return this.Kc.push(r),r}Jc(){this.Wc&&j(47125,{el:Ih(this.Wc)})}verifyOperationInProgress(){}async tl(){let e;do e=this.Hc,await e;while(e!==this.Hc)}nl(e){for(let t of this.Kc)if(t.timerId===e)return!0;return!1}rl(e){return this.tl().then((()=>{this.Kc.sort(((e,t)=>e.targetTimeMs-t.targetTimeMs));for(let t of this.Kc)if(t.skipDelay(),e!==`all`&&t.timerId===e)break;return this.tl()}))}il(e){this.zc.push(e)}Xc(e){let t=this.Kc.indexOf(e);this.Kc.splice(t,1)}};function Ih(e){let t=e.message||``;return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+`
|
|
33
|
+
`+e.stack),t}var Lh=class extends Dl{constructor(e,t,n,r){super(e,t,n,r),this.type=`firestore`,this._queue=new Fh,this._persistenceKey=r?.name||`[DEFAULT]`}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new Fh(e),this._firestoreClient=void 0,await e}}};function Rh(e,t){let n=typeof e==`object`?e:tn(),r=typeof e==`string`?e:t||ia,i=Xt(n,`firestore`).getImmediate({identifier:r});if(!i._initialized){let e=h(`firestore`);e&&Ol(i,...e)}return i}function zh(e){if(e._terminated)throw new F(P.FAILED_PRECONDITION,`The client has already been terminated.`);return e._firestoreClient||Bh(e),e._firestoreClient}function Bh(e){let t=e._freezeSettings(),n=pl(e._databaseId,e._app?.options.appId||``,e._persistenceKey,e._app?.options.apiKey,t);e._componentsProvider||t.localCache?._offlineComponentProvider&&t.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:t.localCache._offlineComponentProvider,_online:t.localCache._onlineComponentProvider}),e._firestoreClient=new xh(e._authCredentials,e._appCheckCredentials,e._queue,n,e._componentsProvider&&function(e){let t=e?._online.build();return{_offline:e?._offline.build(t),_online:t}}(e._componentsProvider))}var Vh=class{convertValue(e,t=`none`){switch(ha(e)){case 0:return null;case 1:return e.booleanValue;case 2:return H(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(Yi(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 j(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t=`none`){let n={};return Hi(e,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertVectorValue(e){let t=e.fields?.[da].arrayValue?.values?.map((e=>H(e.doubleValue)));return new Pl(t)}convertGeoPoint(e){return new Hc(H(e.latitude),H(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=>this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case`previous`:let n=ta(e);return n==null?null:this.convertValue(n,t);case`estimate`:return this.convertTimestamp(na(e));default:return null}}convertTimestamp(e){let t=Ji(e);return new mi(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=L.fromString(e);M(Nc(n),9688,{name:e});let r=new aa(n.get(1),n.get(3)),i=new R(n.popFirst(5));return r.isEqual(t)||Mr(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}},Hh=class extends Vh{constructor(e){super(),this.firestore=e}convertBytes(e){return new Rc(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new Al(this.firestore,null,t)}},Uh=`@firebase/firestore`,Wh=`4.16.0`;function Gh(e){return function(e,t){if(typeof e!=`object`||!e)return!1;let n=e;for(let e of t)if(e in n&&typeof n[e]==`function`)return!0;return!1}(e,[`next`,`error`,`complete`])}var Kh=class{constructor(e=`count`,t){this._internalFieldPath=t,this.type=`AggregateField`,this.aggregateType=e}},qh=class{constructor(e,t,n){this._userDataWriter=t,this._data=n,this.type=`AggregateQuerySnapshot`,this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}_fieldsProto(){return new Ia({mapValue:{fields:this._data}}).clone().value.mapValue.fields}},Jh=class{constructor(e,t,n,r,i){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new Al(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new Yh(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){let t=this._document.data.field(Zl(`DocumentSnapshot.get`,e));if(t!==null)return this._userDataWriter.convertValue(t)}}},Yh=class extends Jh{data(){return super.data()}};function Xh(e){if(e.limitType===`L`&&e.explicitOrderBy.length===0)throw new F(P.UNIMPLEMENTED,`limitToLast() queries require specifying at least one orderBy() clause`)}var Zh=class{},Qh=class extends Zh{};function $h(e,t,...n){let r=[];t instanceof Zh&&r.push(t),r=r.concat(n),function(e){let t=e.filter((e=>e instanceof ng)).length,n=e.filter((e=>e instanceof eg)).length;if(t>1||t>0&&n>0)throw new F(P.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(let t of r)e=t._apply(e);return e}var eg=class e extends Qh{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type=`where`}static _create(t,n,r){return new e(t,n,r)}_apply(e){let t=this._parse(e);return mg(e._query,t),new kl(e.firestore,e.converter,ss(e._query,t))}_parse(e){let t=Vl(e.firestore);return function(e,t,n,r,i,a,o){let s;if(i.isKeyField()){if(a===`array-contains`||a===`array-contains-any`)throw new F(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${a}' queries on documentId().`);if(a===`in`||a===`not-in`){pg(o,a);let t=[];for(let n of o)t.push(fg(r,e,n));s={arrayValue:{values:t}}}else s=fg(r,e,o)}else a!==`in`&&a!==`not-in`&&a!==`array-contains-any`||pg(o,a),s=Kl(n,t,o,a===`in`||a===`not-in`);return Eo.create(i,a,s)}(e._query,`where`,t,e.firestore._databaseId,this._field,this._op,this._value)}};function tg(e,t,n){let r=t,i=Zl(`where`,e);return eg._create(i,r,n)}var ng=class e extends Zh{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(t,n){return new e(t,n)}_parse(e){let t=this._queryConstraints.map((t=>t._parse(e))).filter((e=>e.getFilters().length>0));return t.length===1?t[0]:Do.create(t,this._getOperator())}_apply(e){let t=this._parse(e);return t.getFilters().length===0?e:(function(e,t){let n=e,r=t.getFlattenedFilters();for(let e of r)mg(n,e),n=ss(n,e)}(e._query,t),new kl(e.firestore,e.converter,ss(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type===`and`?`and`:`or`}};function rg(...e){return e.forEach((e=>hg(`or`,e))),ng._create(`or`,e)}function ig(...e){return e.forEach((e=>hg(`and`,e))),ng._create(`and`,e)}var ag=class e extends Qh{constructor(e,t){super(),this._field=e,this._direction=t,this.type=`orderBy`}static _create(t,n){return new e(t,n)}_apply(e){let t=function(e,t,n){if(e.startAt!==null)throw new F(P.INVALID_ARGUMENT,`Invalid query. You must not call startAt() or startAfter() before calling orderBy().`);if(e.endAt!==null)throw new F(P.INVALID_ARGUMENT,`Invalid query. You must not call endAt() or endBefore() before calling orderBy().`);return new Ho(t,n)}(e._query,this._field,this._direction);return new kl(e.firestore,e.converter,cs(e._query,t))}};function og(e,t=`asc`){let n=t,r=Zl(`orderBy`,e);return ag._create(r,n)}var sg=class e extends Qh{constructor(e,t,n){super(),this.type=e,this._limit=t,this._limitType=n}static _create(t,n,r){return new e(t,n,r)}_apply(e){return new kl(e.firestore,e.converter,ls(e._query,this._limit,this._limitType))}};function cg(e){return li(`limit`,e),sg._create(`limit`,e,`F`)}var lg=class e extends Qh{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(t,n,r){return new e(t,n,r)}_apply(e){let t=dg(e,this.type,this._docOrFields,this._inclusive);return new kl(e.firestore,e.converter,us(e._query,t))}};function ug(...e){return lg._create(`startAfter`,e,!1)}function dg(e,t,n,r){if(n[0]=_(n[0]),n[0]instanceof Jh)return function(e,t,n,r,i){if(!r)throw new F(P.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);let a=[];for(let n of rs(e))if(n.field.isKeyField())a.push(wa(t,r.key));else{let e=r.data.field(n.field);if(ea(e))throw new F(P.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field "`+n.field+`" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)`);if(e===null){let e=n.field.canonicalString();throw new F(P.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${e}' (used as the orderBy) does not exist.`)}a.push(e)}return new So(a,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);{let i=Vl(e.firestore);return function(e,t,n,r,i,a){let o=e.explicitOrderBy;if(i.length>o.length)throw new F(P.INVALID_ARGUMENT,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);let s=[];for(let a=0;a<i.length;a++){let c=i[a];if(o[a].field.isKeyField()){if(typeof c!=`string`)throw new F(P.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);if(!ns(e)&&c.indexOf(`/`)!==-1)throw new F(P.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);let n=e.path.child(L.fromString(c));if(!R.isDocumentKey(n))throw new F(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);let i=new R(n);s.push(wa(t,i))}else{let e=Kl(n,r,c);s.push(e)}}return new So(s,a)}(e._query,e.firestore._databaseId,i,t,n,r)}}function fg(e,t,n){if(typeof(n=_(n))==`string`){if(n===``)throw new F(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.`);if(!ns(t)&&n.indexOf(`/`)!==-1)throw new F(P.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);let r=t.path.child(L.fromString(n));if(!R.isDocumentKey(r))throw new F(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return wa(e,new R(r))}if(n instanceof Al)return wa(e,n._key);throw new F(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${si(n)}.`)}function pg(e,t){if(!Array.isArray(e)||e.length===0)throw new F(P.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function mg(e,t){let n=function(e,t){for(let n of e)for(let 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(n!==null)throw n===t.op?new F(P.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new F(P.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}function hg(e,t){if(!(t instanceof eg||t instanceof ng))throw new F(P.INVALID_ARGUMENT,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}function gg(e,t,n){let r;return r=e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,r}function _g(){return new Kh(`count`)}function vg(e){return yg(e,{count:_g()})}function yg(e,t){let n=ci(e.firestore,Lh),r=zh(n),i=Ui(t,((e,t)=>new xo(t,e.aggregateType,e._internalFieldPath)));return Mh(r,e._query,i).then((t=>function(e,t,n){return new qh(t,new Hh(e),n)}(n,e,t)))}var bg=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},xg=class e extends Jh{constructor(e,t,n,r,i,a){super(e,t,n,r,a),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new Sg(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){let n=this._document.data.field(Zl(`DocumentSnapshot.get`,e));if(n!==null)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new F(P.FAILED_PRECONDITION,`DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().`);let t=this._document,n={};return n.type=e._jsonSchemaVersion,n.bundle=``,n.bundleSource=`DocumentSnapshot`,n.bundleName=this._key.toString(),!t||!t.isValidDocument()||!t.isFoundDocument()?n:(this._userDataWriter.convertObjectMap(t.data.value.mapValue.fields,`previous`),n.bundle=(this._firestore,this.ref.path,`NOT SUPPORTED`),n)}};xg._jsonSchemaVersion=`firestore/documentSnapshot/1.0`,xg._jsonSchema={type:ui(`string`,xg._jsonSchemaVersion),bundleSource:ui(`string`,`DocumentSnapshot`),bundleName:ui(`string`),bundle:ui(`string`)};var Sg=class extends xg{data(e={}){return super.data(e)}},Cg=class e{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new bg(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){let e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach((n=>{e.call(t,new Sg(this._firestore,this._userDataWriter,n.key,n,new bg(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new F(P.INVALID_ARGUMENT,`To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().`);return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map((n=>{zf(e._snapshot.query)?op(e._snapshot.query):e.query._query;let r=new Sg(e._firestore,e._userDataWriter,n.doc.key,n.doc,new bg(e._snapshot.mutatedKeys.has(n.doc.key),e._snapshot.fromCache),e.query.converter);return n.doc,{type:`added`,doc:r,oldIndex:-1,newIndex:t++}}))}{let n=e._snapshot.oldDocs;return e._snapshot.docChanges.filter((e=>t||e.type!==3)).map((t=>{let r=new Sg(e._firestore,e._userDataWriter,t.doc.key,t.doc,new bg(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),i=-1,a=-1;return t.type!==0&&(i=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),t.type!==1&&(n=n.add(t.doc),a=n.indexOf(t.doc.key)),{type:wg(t.type),doc:r,oldIndex:i,newIndex:a}}))}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new F(P.FAILED_PRECONDITION,`QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().`);let t={};t.type=e._jsonSchemaVersion,t.bundleSource=`QuerySnapshot`,t.bundleName=Kr.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;let n=[],r=[],i=[];return this.docs.forEach((e=>{e._document!==null&&(n.push(e._document),r.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,`previous`)),i.push(e.ref.path))})),t.bundle=(this._firestore,this.query._query,t.bundleName,`NOT SUPPORTED`),t}};function wg(e){switch(e){case 0:return`added`;case 2:case 3:return`modified`;case 1:return`removed`;default:return j(61501,{type:e})}}Cg._jsonSchemaVersion=`firestore/querySnapshot/1.0`,Cg._jsonSchema={type:ui(`string`,Cg._jsonSchemaVersion),bundleSource:ui(`string`,`QuerySnapshot`),bundleName:ui(`string`),bundle:ui(`string`)};var Tg=class{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=Vl(e)}set(e,t,n){this._verifyNotCommitted();let r=Eg(e,this._firestore),i=gg(r.converter,t,n),a=Hl(this._dataReader,`WriteBatch.set`,r._key,i,r.converter!==null,n);return this._mutations.push(a.toMutation(r._key,ao.none())),this}update(e,t,n,...r){this._verifyNotCommitted();let i=Eg(e,this._firestore),a;return a=typeof(t=_(t))==`string`||t instanceof zc?Gl(this._dataReader,`WriteBatch.update`,i._key,t,n,r):Wl(this._dataReader,`WriteBatch.update`,i._key,t),this._mutations.push(a.toMutation(i._key,ao.exists(!0))),this}delete(e){this._verifyNotCommitted();let t=Eg(e,this._firestore);return this._mutations=this._mutations.concat(new yo(t._key,ao.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new F(P.FAILED_PRECONDITION,`A write batch can no longer be used after commit() has been called.`)}};function Eg(e,t){if((e=_(e)).firestore!==t)throw new F(P.INVALID_ARGUMENT,`Provided document reference is from a different Firestore instance.`);return e}function Dg(e){e=ci(e,Al);let t=ci(e.firestore,Lh);return Ah(zh(t),e._key).then((n=>Mg(t,e,n)))}function Og(e){e=ci(e,kl);let t=ci(e.firestore,Lh),n=zh(t),r=new Hh(t);return Xh(e._query),jh(n,e._query).then((n=>new Cg(t,r,e,n)))}function kg(e){return jg(ci(e.firestore,Lh),[new yo(e._key,ao.none())])}function Ag(e,...t){e=_(e);let n={includeMetadataChanges:!1,source:`default`},r=0;typeof t[r]!=`object`||Gh(t[r])||(n=t[r++]);let i={includeMetadataChanges:n.includeMetadataChanges,source:n.source};if(Gh(t[r])){let e=t[r];t[r]=e.next?.bind(e),t[r+1]=e.error?.bind(e),t[r+2]=e.complete?.bind(e)}let a,o,s;if(e instanceof Al)o=ci(e.firestore,Lh),s=$o(e._key.path),a={next:n=>{t[r]&&t[r](Mg(o,e,n))},error:t[r+1],complete:t[r+2]};else{let n=ci(e,kl);o=ci(n.firestore,Lh),s=n._query;let i=new Hh(o);a={next:e=>{t[r]&&t[r](new Cg(o,i,n,e))},error:t[r+1],complete:t[r+2]},Xh(e._query)}return kh(zh(o),s,i,a)}function jg(e,t){return Nh(zh(e),t)}function Mg(e,t,n){let r=n.docs.get(t._key);return new xg(e,new Hh(e),t._key,r,new bg(n.hasPendingWrites,n.fromCache),t.converter)}function Ng(e){return e=ci(e,Lh),zh(e),new Tg(e,(t=>jg(e,t)))}(function(e,t=!0){kr($t),Yt(new Ae(`firestore`,((e,{instanceIdentifier:n,options:r})=>{let i=e.getProvider(`app`).getImmediate(),a=new Lh(new Br(e.getProvider(`auth-internal`)),new Wr(i,e.getProvider(`app-check-internal`)),oa(i,n),i);return r={useFetchStreams:t,...r},a._setSettings(r),a}),`PUBLIC`).setMultipleInstances(!0)),nn(Uh,Wh,e),nn(Uh,Wh,`esm2020`)})();var Pg=class{constructor(){this.subscribers=new Set}subscribe(e){return this.subscribers.add(e),()=>this.unsubscribe(e)}unsubscribe(e){this.subscribers.delete(e)}notify(e){this.subscribers.forEach(t=>t(e))}get subscribersCount(){return this.subscribers.size}},Fg=new Uint8Array(16);function Ig(){return crypto.getRandomValues(Fg)}var Lg=[];for(let e=0;e<256;++e)Lg.push((e+256).toString(16).slice(1));function Rg(e,t=0){return(Lg[e[t+0]]+Lg[e[t+1]]+Lg[e[t+2]]+Lg[e[t+3]]+`-`+Lg[e[t+4]]+Lg[e[t+5]]+`-`+Lg[e[t+6]]+Lg[e[t+7]]+`-`+Lg[e[t+8]]+Lg[e[t+9]]+`-`+Lg[e[t+10]]+Lg[e[t+11]]+Lg[e[t+12]]+Lg[e[t+13]]+Lg[e[t+14]]+Lg[e[t+15]]).toLowerCase()}function zg(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():Bg(e,t,n)}function Bg(e,t,n){e||={};let r=e.random??e.rng?.()??Ig();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Rg(r)}function Vg(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var Y=class e{static registerFactory(e,t,n,r=!1){this._factoryMap[e]={factory:t,annotation:n,isLegacy:r}}static classFactory(e){if(!e)throw Error(`You should provide a class name.`);if(!this._factoryMap[e])throw Error(`You should register class ${e} prior to use.`);return this._factoryMap[e].factory}static registeredClasses(){return Object.entries(this._factoryMap).filter(([,e])=>!e.isLegacy).map(([e])=>e)}static registeredClassesAndLegacyNames(){return Object.keys(this._factoryMap)}static classesExtending(e){return Object.entries(this._factoryMap).filter(([,t])=>new t.factory instanceof e&&!t.isLegacy).map(([e])=>e)}static isInstanceOf(t,n){let r=e.classFactory(n);return t instanceof e?t instanceof r:e.createInstance(t)instanceof r}static annotations(t){if(t instanceof e?t=t.className:typeof t==`string`||(t=new t().className),!this._factoryMap[t])throw Error(`You should register class ${t} prior to use.`);return this._factoryMap[t].annotation}constructor(e=zg()){this._id=e}get className(){return this.__className}setId(e){this._id=e}get id(){return this._id}afterDeserialize(){}beforeSerialize(){}getPersistentProperties(){return this._persistentProperties?this._persistentProperties.map(e=>({...e,name:e.name.slice(1)})):[]}getPropInfo(e){let t=this.getPersistentProperties().find(t=>t.name===e);if(!t)throw Error(`Property "${e}" has not been registered.`);return t}isRequired(e){return this.getPropInfo(e).validator!=null}isPropValueValid(e){let t=this.getPropInfo(e);return t.validator?t.validator(this[t.name],t,this):!0}clone(e){let t=e.toObject();return delete t.id,this.fromObject(t)}fromObject(e){return this.fromObj(e),this.afterDeserialize(),this}fromObj(e){return this._persistentProperties&&this._persistentProperties.forEach(t=>{let n=e[this.removeUnderscore(t)];n!=null&&(this[t.name]=this.fromDeepObject(n))}),this}toObject(){let e={},t=this.toObj(e);return this.pushDocument(e,this.className,t),{...t,__rootCollections:e}}toObj(t){if(!this._persistentProperties)return{};this.beforeSerialize();let n={};if(!this.className)throw Error(`You should register \`${this.constructor.name||this.toString()||`this`}\` class prior to streaming it.`);return this._persistentProperties.forEach(r=>{let i=this[r.name],a=this.removeUnderscore(r);i!=null&&(r.isReference?n[a]=this.toReferenceObj(r,t):n[a]=this.toDeepObj(i,t),r.searchableArray&&(n[e.searchableArrayNameFor(a)]=i.map(e=>e.id)))}),n.__className=this.className,n}static searchableArrayNameFor(e){return`__${e}_searchable`}fromDeepObject(t){if(t==null)return t;if(Array.isArray(t))return t.map(e=>this.fromDeepObject(e));if(t.__documentReference){let n=t,r=e.createInstance(n);return r.__documentReference=t.__documentReference,r}if(t.__className)return e.createInstance(t);if(typeof t==`object`){let e={};return Object.entries(t).forEach(([t,n])=>e[t]=this.fromDeepObject(n)),e}return t}toDeepObj(t,n){if(t!=null){if(Array.isArray(t))return t.map(e=>this.toDeepObj(e,n));if(t.__documentReference)return t;if(t instanceof e)return t.toObj(n);if(typeof t==`object`){let e={};return Object.entries(t).forEach(([t,r])=>e[t]=this.toDeepObj(r,n)),e}return t}}static collectionPath(e,t,n){let r;return r=typeof t.storeInCollection==`function`?t.storeInCollection(e,t,n):t.storeInCollection??e.className,r}toReferenceObj(t,n){let r=this[t.name];return Array.isArray(r)?r.map(r=>(t.isPureReference||this.pushDocument(n,e.collectionPath(r,t),r),this.buildRefObject(r,e.collectionPath(r,t),t.cachedProps))):(t.isPureReference||this.pushDocument(n,e.collectionPath(r,t),r),this.buildRefObject(r,e.collectionPath(r,t),t.cachedProps))}buildRefObject(e,t,n){let r=n?.reduce((t,n)=>(e[n]!==void 0&&(t[n]=e[n]),t),{});return{id:e.id,__className:e.className||e.__className,__documentReference:{storedInCollection:t},...r}}pushDocument(e,t,n){if(`__documentReference`in n&&n.__documentReference)return;e[t]||(e[t]=[]);let r=this.toDeepObj(n,e);e[t].push(r)}removeUnderscore(e){return e.name.slice(1)}static createReference(t){let n=e.createInstance(t);return n.__documentReference=t.__documentReference||{storedInCollection:n.className},n}static createInstance(t){if(typeof t==`string`)return new(e.classFactory(t));try{return new(e.classFactory(t.__className))().fromObject(t)}catch(e){let n=Object.entries(t).filter(([e,t])=>t!=null&&typeof t!=`function`).map(([e,t])=>`${e}: ${t}`).join(`,
|
|
34
|
+
`);throw Error(`${e}\n-----> Class name not found in object:\n{\n\t ${n} \n}\n`)}}static propInfo(t,n){return e.createInstance(t).getPropInfo(n)}static propType(t){if(t.typeName)return Array.isArray(t.typeName)?`undefined[]`:t.typeName??`undefined`;let n=e.createInstance(t.ownerClassName())[t.name];if(Array.isArray(n)){if(n.length===0)return`undefined[]`;let t=n[0];return t instanceof e?t.className+`[]`:typeof t+`[]`}else if(n instanceof e)return n.className;else return typeof n}static getSystemRegisteredReferencesWithCachedProps(){return e.registeredClasses().reduce((t,n)=>{let r=e.createInstance(n).getPersistentProperties().filter(e=>e.cachedProps);return r.length>0&&(t[n]=r),t},{})}static{this._factoryMap={}}};Vg([Hg],Y.prototype,`_id`,void 0);function Hg(e,t){return Ug()(e,t)}function Ug(e){return function(t,n){Object.getOwnPropertyDescriptor(t,`_persistentProperties`)||(t._persistentProperties?t._persistentProperties=[...t._persistentProperties]:t._persistentProperties=[]);let r=t._persistentProperties.find(e=>e.name===n);r?Object.assign(r,e):t._persistentProperties.push({name:n,ownerClassName:()=>t.className,...e})}}function Wg(e,t){return n=>{Y.registerFactory(e,n,t),n.prototype.__className=e}}var Gg=class e{static{this.error={persistentNeedForSubCollection:`The document parameter for a sub-collection should be a Persistent instace`,invalidQueryOrder:`Cannot add where calls after or calls`}}constructor(t,n,r){if(r){if(!(n instanceof Y))throw Error(e.error.persistentNeedForSubCollection);this.collectionName=`${n.className}/${n.id}/${r}`}else this.collectionName=n instanceof Y?n.className:n;this._stream=t}findById(e,t){return new Promise((n,r)=>{this._stream.findById(e,this.collectionName).then(e=>{e?(t?t.fromObject(e):t=Y.createInstance(e),n(t)):n(void 0)}).catch(e=>r(e))})}save(e){let t=e.toObject();return this.collectionName!==t.__className&&(t.__rootCollections[this.collectionName]=t.__rootCollections[t.__className],delete t.__rootCollections[t.__className]),new Promise((e,n)=>{this._stream.save(t.__rootCollections).then(()=>e()).catch(e=>n(e))})}delete(e){return new Promise((t,n)=>{this._stream.delete(e,this.collectionName).then(()=>t()).catch(e=>n(e))})}find(){return new Kg(this)}query(e={},t){if(t){let n=t instanceof Y?t.className:t;e.operations||=[],e.operations.push({property:`__className`,operator:`==`,value:n})}return this.mapToInstance(()=>this._stream.find(this.preprocessQueryObject(e),this.collectionName))}count(e){return this._stream.count(e,this.collectionName)}next(e){return this.mapToInstance(()=>this._stream.next(e))}onDocumentChange(e,t){return this._stream.onDocumentChange(this.collectionName,e,e=>t(Yg.toPersistentDocumentChange(e)))}onCollectionChange(e,t){return this._stream.onCollectionChange(this.preprocessQueryObject(e.getQueryObject()),this.collectionName,e=>t(e.map(e=>Yg.toPersistentDocumentChange(e))))}onCollectionTemplateChange(e,t){return this._stream.onDocumentTemplateChange(e,e=>t(Yg.toPersistentDocumentChange(e)))}mapToInstance(e){return new Promise((t,n)=>{e().then(e=>t(e.map(e=>Y.createInstance(e)))).catch(e=>n(e))})}preprocessQueryObject(e){if(Object.values(e).length===0)return e;let t=e.operations?.map(e=>{let t=e.value[0]??e.value;return Yg.isArrayOperator(e.operator)&&t instanceof Y?{property:Y.searchableArrayNameFor(e.property),operator:e.operator,value:Array.isArray(e.value)?e.value.map(e=>e.id):t.id,aggregate:e.aggregate}:{property:e.property,operator:e.operator,value:e.value instanceof Y?{id:e.value.id}:e.value,aggregate:e.aggregate}})??[];return{...e,operations:t}}},Kg=class{constructor(e){this.queryObject={operations:[]},this.model=e}where(e,t,n,r){if(this.queryObject.operations?.at(-1)?.aggregate&&!r)throw Error(Gg.error.invalidQueryOrder);return this.queryObject.operations?.push({property:e,operator:t,value:n,aggregate:r}),this}whereDeepProp(e,t,n,r){if(this.queryObject.operations?.at(-1)?.aggregate&&!r)throw Error(Gg.error.invalidQueryOrder);let i=e.split(`.`),a={},o=i.length>1?a:n;return i.slice(1).forEach((e,t)=>{a[e]=t<i.length-2?{}:n,a=a[e]}),this.queryObject.operations?.push({property:i[0],operator:t,value:o,aggregate:r}),this}and(e,t,n){return this.where(e,t,n)}andDeepProp(e,t,n){return this.whereDeepProp(e,t,n)}or(e,t,n){return this.where(e,t,n,!0)}orDeepProp(e,t,n){return this.whereDeepProp(e,t,n,!0)}instanceOf(e){let t=e instanceof Y?e.className:e;return this.queryObject.operations?.push({property:`__className`,operator:`==`,value:t}),this}get(e){return e&&(this.queryObject.limit=e),this.model.query(this.queryObject)}limit(e){return this.queryObject.limit=e,this}orderBy(e,t=`asc`){return this.queryObject.sort={propertyName:e,order:t},this}orderByDeepProp(e,t=`asc`){return this.queryObject.sort={propertyName:e,order:t},this}count(){return this.model.count(this.queryObject)}getQueryObject(){return this.queryObject}getQueryModel(){return this.model}},qg=class e{constructor(){}static{this.error={shouldBeRegistered:`You should register a data source before using the data Store.`}}static useDataSource(e){this._dataSource=e}static get dataSource(){return e._dataSource}static getModel(t){if(!e._dataSource)throw Error(this.error.shouldBeRegistered);return new Gg(e._dataSource,t)}static getModelForSubCollection(t,n){if(!e._dataSource)throw Error(this.error.shouldBeRegistered);return new Gg(e._dataSource,t,n)}static async populate(e){if(!e)return;let t=async e=>{let t=e;if(!t.__documentReference)return e;let n=await this.getModel(t.__documentReference.storedInCollection).findById(t.id,e);return n&&(n.__documentReference=void 0),n};return Array.isArray(e)?(await Promise.all(e.map(e=>t(e)))).filter(e=>e):t(e)}static isPopulated(e){return Array.isArray(e)?e.reduce((e,t)=>e&&t.__documentReference===void 0,!0):e.__documentReference===void 0}},Jg=class e{constructor(e){this._resolveCollectionPaths=()=>{throw Error(`The method collectionsMatchingTemplate has not been implemented in the concrete data source`)},this._disabledChangeListeners=new Set,this._collectionsToWatch={},e&&(this._beforeUpdateDocument=e.beforeUpdateDocument,this._afterUpdateDocument=e.afterUpdateDocument,this._afterDocumentChange=e.afterDocumentChange,this._beforeDocumentChange=e.beforeDocumentChange,this._beforeQueryOwnerCollection=e.beforeQueryOwnerCollection),this.installUpdaters()}installUpdaters(){let e=Y.getSystemRegisteredReferencesWithCachedProps();this._collectionsToWatch={},Object.entries(e).forEach(([e,t])=>{t.forEach(t=>{t.typeName&&(Array.isArray(t.typeName)?t.typeName:[t?.typeName??e]).map(e=>Y.collectionPath(Y.createInstance(e),t)).forEach(e=>{this._collectionsToWatch[e]||(this._collectionsToWatch[e]=[]),this._collectionsToWatch[e].find(e=>e.name===t.name&&e.ownerClassName()===t.ownerClassName())||this._collectionsToWatch[e].push(t)})})})}set beforeDocumentChange(e){this._beforeDocumentChange=e}set afterDocumentChange(e){this._afterDocumentChange=e}set beforeUpdateDocument(e){this._beforeUpdateDocument=e}set afterUpdateDocument(e){this._afterUpdateDocument=e}set beforeQueryOwnerCollection(e){this._beforeQueryOwnerCollection=e}set resolveCollectionPaths(e){this._resolveCollectionPaths=e}get collectionsToWatch(){return this._collectionsToWatch}updateProps(e,t){let n=this._collectionsToWatch[e];return n?this.onDocumentChange(t,n):Promise.resolve()}async onDocumentChange(t,n){let r=Yg.toPersistentDocumentChange(t);this._beforeDocumentChange?.(r,n);let i={};t.type!==`update`||!r.before||r.after?.id&&this._disabledChangeListeners.has(r.after?.id)||(await Promise.all(n.map(async t=>{let n=e.ownerCollectionPath(Y.createInstance(t.ownerClassName()),t,r.params),a=await this._resolveCollectionPaths(n);await Promise.all(a.map(async e=>{let n=qg.getModel(e),a=n.find(),o=!1;t.cachedProps?.forEach(e=>{r.before[e]!==r.after[e]&&(o=!0)}),o&&(a=t.searchableArray?a.where(t.name,`contains`,r.before):a.where(t.name,`==`,r.before)),a=this._beforeQueryOwnerCollection?.(a)??a;let s=await a.get();return i[e]={totalDocumentsToUpdate:s.length,updatedDocuments:[],documentsToUpdate:s.map(e=>e.name??e.id)},Promise.all([s.map(async a=>{let o=!1;if(t.cachedProps?.forEach(e=>{r.before[e]!==r.after[e]&&(o=!0)}),o){if(t.searchableArray){let e=a[t.name].findIndex(e=>e.id===r.before.id);a[t.name][e]=r.after}else a[`_${t.name}`]=r.after;this._beforeUpdateDocument?.(a,t,r.after),this.disableChangeListener(a),await n.save(a),this.enableChangeListener(a),i[e]?.updatedDocuments.push(a.id),this._afterUpdateDocument?.(a,t,r.after)}else return Promise.resolve()})])}))})),this._afterDocumentChange?.(i,n))}disableChangeListener(e){this._disabledChangeListeners.add(e.id)}enableChangeListener(e){this._disabledChangeListeners.delete(e.id)}static ownerCollectionPath(e,t,n){let r;return r=typeof t.ownerCollection==`function`?t.ownerCollection(e,t,n):t.ownerCollection??e.className,r}},Yg=class e{constructor(){this._cachedPropsUpdater=void 0}installCachedPropsUpdater(e){return this._cachedPropsUpdater=new Jg(e),this._cachedPropsUpdater.resolveCollectionPaths=this.resolveCollectionPaths.bind(this),this._cachedPropsUpdater}get cachedPropsUpdater(){return this._cachedPropsUpdater}static toPropertyPathOperations(t){return t?t.map(t=>{if(e.isArrayOperator(t.operator)&&t.value[0]instanceof Y)return{property:Y.searchableArrayNameFor(t.property),operator:t.operator,value:t.value.map(e=>e.id),aggregate:t.aggregate};let[n,r]=this.toPropertyPathValue(t.value);return{property:`${String(t.property)}${n?`.`+n:``}`,operator:t.operator,value:r,aggregate:t.aggregate}}):[]}static isArrayOperator(e){return e===`containsAny`||e===`contains`}static toPersistentDocumentChange(e){return{...e,before:e.before&&Y.createInstance(e.before),after:e.after&&Y.createInstance(e.after)}}static toPropertyPathValue(e){if(typeof e==`object`&&!Array.isArray(e)){let t=Object.keys(e)[0],[n,r]=this.toPropertyPathValue(e[t]);return[`${t}${n?`.`+n:``}`,r]}else return[void 0,e]}static isStringMatchingTemplate(e,t){let n=e.split(`/`),r=t.split(`/`);if(r.length>n.length)return!1;for(let e=0;e<r.length;e++){let t=n[e],i=r[e];if(!(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith("${")&&t.endsWith(`}`))&&t!==i)return!1}for(let e=r.length;e<n.length;e++){let t=n[e];if(!(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith("${")&&t.endsWith(`}`)))return!1}return!0}static extractTemplateParams(e,t){let n=t.split(`/`),r=e.split(`/`),i={};if(r.length>n.length)return i;for(let e=0;e<r.length;e++){let t=n[e],a=r[e];if(t.startsWith(`{`)&&t.endsWith(`}`))i[t.slice(1,-1)]=a;else if(t.startsWith("${")&&t.endsWith(`}`))i[t.slice(2,-1)]=a;else if(t!==a)return{}}for(let e=r.length;e<n.length;e++){let t=n[e];if(!(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith("${")&&t.endsWith(`}`)))return{}}return i}},Xg=class e{static registerCloudStorage(t,n){e._cloudStorageFactoryMap[t]=n}static createInstance(t){let n=e._cloudStorageFactoryMap[t];if(!n)throw Error(`You should register the ${t} cloud storage provider prior to use it`);return n()}get className(){return this.__className}static useCloudStorage(t){e._defaultCloudStorage=t}static get defaultCloudStorage(){if(!e._defaultCloudStorage)throw Error(`You should define a default cloud storage provider prior to use it`);return e._defaultCloudStorage}static{this._cloudStorageFactoryMap={}}};function Zg(e,t){return Xg.registerCloudStorage(e,t),t=>{t.prototype.__className=e}}var Qg=class extends Xg{constructor(e=``){super(),this._simulateDelay=0,this._pendingPromises=[],this.mockFileSystem={},this._pathToMockFiles=e}simulateDelay(e){return this._simulateDelay=e,this}resolveWithDelay(e){if(this._simulateDelay<=0)return Promise.resolve(e);let t=new Promise(t=>{setTimeout(()=>t(e),this._simulateDelay)});return this._pendingPromises.push(t),t.finally(()=>this._pendingPromises=this._pendingPromises.filter(e=>e===t)),t}save(e,t){let n=e;this._onProgress&&this._onProgress(0,100),this.mockFileSystem[e]=JSON.stringify(t),this._onProgress&&this._onProgress(100,100);let r=t instanceof File?t.name:n;return this.resolveWithDelay(r)}uploadControl(){return{resume:()=>{},pause:()=>{},cancel:()=>{},onProgress:e=>this._onProgress=e}}getUrl(e){return Promise.resolve(this._pathToMockFiles+e)}delete(e){return delete this.mockFileSystem[e],this.resolveWithDelay()}};Qg=Vg([Zg(`MockCloudStorage`,()=>new Qg)],Qg);var $g=class extends Y{constructor(...e){super(...e),this._onChange=new Pg}async save({data:e,fileName:t,progress:n,cloudStorageProvider:r}={}){let i=e||this._pendingData;i&&(this._reference&&await this.delete(),this.provider=r||Xg.defaultCloudStorage,this._originalFileName=t||(i instanceof File?i.name:void 0),this._reference=await this.provider.save(this.id,i,n),this._url=await this.provider.getUrl(this._reference),this._pendingData=void 0,this._onChange.notify({event:0,storedFile:this}))}uploadControl(){return this.provider.uploadControl()}async delete(){if(!this._reference)throw Error(`Cannot delete a not stored file`);await this.provider.delete(this._reference),this._reference=void 0,this._url=void 0,this._onChange.notify({event:2,storedFile:this})}set provider(e){this._provider=e,this._cloudStorageProviderName=e.className}get provider(){if(!this._provider)try{this._provider=Xg.createInstance(this._cloudStorageProviderName)}catch{this._provider=Xg.defaultCloudStorage}return this._provider}get url(){return this._url}get mimeType(){return this._mimeType}setDataToStore(e){return this._pendingData=e,this._originalFileName=e instanceof File?e.name:void 0,this._mimeType=e instanceof Blob?e.type:void 0,this._onChange.notify({event:1,pendingData:e,storedFile:this}),this}get originalFileName(){return this._originalFileName}onChange(e){return this._onChange.subscribe(e)}};Vg([Hg],$g.prototype,`_reference`,void 0),Vg([Hg],$g.prototype,`_url`,void 0),Vg([Hg],$g.prototype,`_cloudStorageProviderName`,void 0),Vg([Hg],$g.prototype,`_originalFileName`,void 0),Vg([Hg],$g.prototype,`_mimeType`,void 0),$g=Vg([Wg(`StoredFile`)],$g);var e_=class{};(class e extends e_{static{this.error={shouldBeRegistered:`You should register an auth service before using Auth.`}}constructor(){if(super(),this._onAuthStateChange=new Pg,!e._authService)throw Error(e.error.shouldBeRegistered);e._authService.onAuthStateChange(e=>this.authStateChanged(e))}static useAuthService(t){e._authService!=t&&(e._authService=t,this._instance=void 0)}static get instance(){return this._instance||=new this}signUp(t){return e._authService.signUp(t)}login(t){return e._authService.login(t)}logout(){return e._authService.logout()}resetEmailPassword(t){return e._authService.resetEmailPassword(t)}resendVerificationEmail(t,n,r){return e._authService.resendVerificationEmail(t,n,r)}refreshToken(){return e._authService.refreshToken()}onAuthStateChange(e){return this._onAuthStateChange.subscribe(e)}removeAuthStateChange(e){this._onAuthStateChange.unsubscribe(e)}linkAdditionalProvider(t){return e._authService.linkAdditionalProvider(t)}unlinkProvider(t){return e._authService.unlinkProvider(t)}authStateChanged(e){this._onAuthStateChange.notify(e)}static{this._instance=void 0}}),class e{constructor(){}static{this.error={shouldBeRegistered:`You should register a cloud functions service with useCloudFunctionsService static method before using CloudFunctions.`}}static useCloudFunctionsService(e){this._cloudFunctionsService!=e&&(this._cloudFunctionsService=e)}static get instance(){if(!this._cloudFunctionsService)throw Error(e.error.shouldBeRegistered);return e._instance||=new e}getRawFunction(t){return e._cloudFunctionsService.retrieveFunction(t)}getFunction(t){let n=e._cloudFunctionsService.callFunction,r=this.getRawFunction(t);return async e=>{let t=await n(r,this.processParam(e));return this.processResult(t)}}processParam(e){if(e!=null)return e instanceof Y?e.toObject():Array.isArray(e)?e.map(e=>this.processParam(e)):typeof e==`object`?Object.entries(e).reduce((e,[t,n])=>(e[t]=this.processParam(n),e),{}):e}processResult(e){if(e!=null)return e.__className?Y.createInstance(e):Array.isArray(e)?e.map(e=>this.processResult(e)):typeof e==`object`?Object.entries(e).reduce((e,[t,n])=>(e[t]=this.processResult(n),e),{}):e}};var t_=class{};(class e extends t_{static{this.error={shouldBeRegistered:`You should register a Server Auth service before using the Server Auth.`}}constructor(){super()}static useServerAuthService(t){e._authService!=t&&(e._authService=t,this._instance=void 0)}static get instance(){if(!e._authService)throw Error(e.error.shouldBeRegistered);return this._instance||=new e}getUser(t){return e._authService.getUser(t)}updateUser(t,n){return e._authService.updateUser(t,n)}setCustomCredentials(t,n){return e._authService.setCustomCredentials(t,n)}deleteUser(t){return e._authService.deleteUser(t)}static{this._instance=void 0}});function n_(e){return e?e.replace(/([-_ ][\w])/g,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``).replace(` `,``)):``}nn(`firebase`,`12.15.0`,`app`);function r_(){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."}}var i_=r_,a_=new he(`auth`,`Firebase`,r_()),o_=new Ve(`@firebase/auth`);function s_(e,...t){o_.logLevel<=v.WARN&&o_.warn(`Auth (${$t}): ${e}`,...t)}function c_(e,...t){o_.logLevel<=v.ERROR&&o_.error(`Auth (${$t}): ${e}`,...t)}function l_(e,...t){throw m_(e,...t)}function u_(e,...t){return m_(e,...t)}function d_(e,t,n){return new he(`auth`,`Firebase`,{...i_(),[t]:n}).create(t,{appName:e.name})}function f_(e){return d_(e,`operation-not-supported-in-this-environment`,`Operations that alter the current user are not supported in conjunction with FirebaseServerApp`)}function p_(e,t,n){let r=n;if(!(t instanceof r))throw r.name!==t.constructor.name&&l_(e,`argument-error`),d_(e,`argument-error`,`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function m_(e,...t){if(typeof e!=`string`){let n=t[0],r=[...t.slice(1)];return r[0]&&(r[0].appName=e.name),e._errorFactory.create(n,...r)}return a_.create(e,...t)}function X(e,t,...n){if(!e)throw m_(t,...n)}function h_(e){let t=`INTERNAL ASSERTION FAILED: `+e;throw c_(t),Error(t)}function g_(e,t){e||h_(t)}function __(){return typeof self<`u`&&self.location?.href||``}function v_(){return y_()===`http:`||y_()===`https:`}function y_(){return typeof self<`u`&&self.location?.protocol||null}function b_(){return typeof navigator<`u`&&navigator&&`onLine`in navigator&&typeof navigator.onLine==`boolean`&&(v_()||se()||`connection`in navigator)?navigator.onLine:!0}function x_(){if(typeof navigator>`u`)return null;let e=navigator;return e.languages&&e.languages[0]||e.language||null}var S_=class{constructor(e,t){this.shortDelay=e,this.longDelay=t,g_(t>e,`Short delay should be less than long delay!`),this.isMobile=ie()||ce()}get(){return b_()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}};function C_(e,t){g_(e.emulator,`Emulator should always be set here`);let{url:n}=e.emulator;return t?`${n}${t.startsWith(`/`)?t.slice(1):t}`:n}var w_=class{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<`u`&&`fetch`in self)return self.fetch;if(typeof globalThis<`u`&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<`u`)return fetch;h_(`Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill`)}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<`u`&&`Headers`in self)return self.Headers;if(typeof globalThis<`u`&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<`u`)return Headers;h_(`Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill`)}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<`u`&&`Response`in self)return self.Response;if(typeof globalThis<`u`&&globalThis.Response)return globalThis.Response;if(typeof Response<`u`)return Response;h_(`Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill`)}},T_={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`},E_=[`/v1/accounts:signInWithCustomToken`,`/v1/accounts:signInWithEmailLink`,`/v1/accounts:signInWithIdp`,`/v1/accounts:signInWithPassword`,`/v1/accounts:signInWithPhoneNumber`,`/v1/token`],D_=new S_(3e4,6e4);function O_(e,t){return e.tenantId&&!t.tenantId?{...t,tenantId:e.tenantId}:t}async function k_(e,t,n,r,i={}){return A_(e,i,async()=>{let i={},a={};r&&(t===`GET`?a=r:i={body:JSON.stringify(r)});let o=xe({...a,key:e.config.apiKey}).slice(1),s=await e._getAdditionalHeaders();s[`Content-Type`]=`application/json`,e.languageCode&&(s[`X-Firebase-Locale`]=e.languageCode);let c={method:t,headers:s,...i};return oe()||(c.referrerPolicy=`strict-origin-when-cross-origin`),e.emulatorConfig&&Oe(e.emulatorConfig.host)&&(c.credentials=`include`),w_.fetch()(await M_(e,e.config.apiHost,n,o),c)})}async function A_(e,t,n){e._canInitEmulator=!1;let r={...T_,...t};try{let t=new P_(e),i=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();let a=await i.json();if(`needConfirmation`in a)throw F_(e,`account-exists-with-different-credential`,a);if(i.ok&&!(`errorMessage`in a))return a;{let[t,n]=(i.ok?a.errorMessage:a.error.message).split(` : `);if(t===`FEDERATED_USER_ID_ALREADY_LINKED`)throw F_(e,`credential-already-in-use`,a);if(t===`EMAIL_EXISTS`)throw F_(e,`email-already-in-use`,a);if(t===`USER_DISABLED`)throw F_(e,`user-disabled`,a);let o=r[t]||t.toLowerCase().replace(/[_\s]+/g,`-`);if(n)throw d_(e,o,n);l_(e,o)}}catch(t){if(t instanceof me)throw t;l_(e,`network-request-failed`,{message:String(t)})}}async function j_(e,t,n,r,i={}){let a=await k_(e,t,n,r,i);return`mfaPendingCredential`in a&&l_(e,`multi-factor-auth-required`,{_serverResponse:a}),a}async function M_(e,t,n,r){let i=`${t}${n}?${r}`,a=e,o=a.config.emulator?C_(e.config,i):`${e.config.apiScheme}://${i}`;return E_.includes(n)&&(await a._persistenceManagerAvailable,a._getPersistenceType()===`COOKIE`)?a._getPersistence()._getFinalTarget(o).toString():o}function N_(e){switch(e){case`ENFORCE`:return`ENFORCE`;case`AUDIT`:return`AUDIT`;case`OFF`:return`OFF`;default:return`ENFORCEMENT_STATE_UNSPECIFIED`}}var P_=class{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(u_(this.auth,`network-request-failed`)),D_.get())})}};function F_(e,t,n){let r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);let i=u_(e,t,r);return i.customData._tokenResponse=n,i}function I_(e){return e!==void 0&&e.enterprise!==void 0}var L_=class{constructor(e){if(this.siteKey=``,this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw Error(`recaptchaKey undefined`);this.siteKey=e.recaptchaKey.split(`/`)[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(let t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return N_(t.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)===`ENFORCE`||this.getProviderEnforcementState(e)===`AUDIT`}isAnyProviderEnabled(){return this.isProviderEnabled(`EMAIL_PASSWORD_PROVIDER`)||this.isProviderEnabled(`PHONE_PROVIDER`)}};async function R_(e,t){return k_(e,`GET`,`/v2/recaptchaConfig`,O_(e,t))}async function z_(e,t){return k_(e,`POST`,`/v1/accounts:delete`,t)}async function B_(e,t){return k_(e,`POST`,`/v1/accounts:update`,t)}async function V_(e,t){return k_(e,`POST`,`/v1/accounts:lookup`,t)}function H_(e){if(e)try{let t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch{}}async function U_(e,t=!1){let n=_(e),r=await n.getIdToken(t),i=G_(r);X(i&&i.exp&&i.auth_time&&i.iat,n.auth,`internal-error`);let a=typeof i.firebase==`object`?i.firebase:void 0,o=a?.sign_in_provider;return{claims:i,token:r,authTime:H_(W_(i.auth_time)),issuedAtTime:H_(W_(i.iat)),expirationTime:H_(W_(i.exp)),signInProvider:o||null,signInSecondFactor:a?.sign_in_second_factor||null}}function W_(e){return Number(e)*1e3}function G_(e){let[t,n,r]=e.split(`.`);if(t===void 0||n===void 0||r===void 0)return c_(`JWT malformed, contained fewer than 3 sections`),null;try{let e=c(n);return e?JSON.parse(e):(c_(`Failed to decode base64 JWT payload`),null)}catch(e){return c_(`Caught error parsing JWT payload as JSON`,e?.toString()),null}}function K_(e){let t=G_(e);return X(t,`internal-error`),X(t.exp!==void 0,`internal-error`),X(t.iat!==void 0,`internal-error`),Number(t.exp)-Number(t.iat)}async function q_(e,t,n=!1){if(n)return t;try{return await t}catch(t){throw t instanceof me&&J_(t)&&e.auth.currentUser===e&&await e.auth.signOut(),t}}function J_({code:e}){return e===`auth/user-disabled`||e===`auth/user-token-expired`}var Y_=class{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){if(e){let e=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),e}else{this.errorBackoff=3e4;let e=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,e)}}schedule(e=!1){if(!this.isRunning)return;let t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){e?.code===`auth/network-request-failed`&&this.schedule(!0);return}this.schedule()}},X_=class{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=H_(this.lastLoginAt),this.creationTime=H_(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}};async function Z_(e){let t=e.auth,n=await q_(e,V_(t,{idToken:await e.getIdToken()}));X(n?.users.length,t,`internal-error`);let r=n.users[0];e._notifyReloadListener(r);let i=r.providerUserInfo?.length?ev(r.providerUserInfo):[],a=$_(e.providerData,i),o=e.isAnonymous,s=!(e.email&&r.passwordHash)&&!a?.length,c=o?s:!1,l={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:a,metadata:new X_(r.createdAt,r.lastLoginAt),isAnonymous:c};Object.assign(e,l)}async function Q_(e){let t=_(e);await Z_(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}function $_(e,t){return[...e.filter(e=>!t.some(t=>t.providerId===e.providerId)),...t]}function ev(e){return e.map(({providerId:e,...t})=>({providerId:e,uid:t.rawId||``,displayName:t.displayName||null,email:t.email||null,phoneNumber:t.phoneNumber||null,photoURL:t.photoUrl||null}))}async function tv(e,t){let n=await A_(e,{},async()=>{let n=xe({grant_type:`refresh_token`,refresh_token:t}).slice(1),{tokenApiHost:r,apiKey:i}=e.config,a=await M_(e,r,`/v1/token`,`key=${i}`),o=await e._getAdditionalHeaders();o[`Content-Type`]=`application/x-www-form-urlencoded`;let s={method:`POST`,headers:o,body:n};return e.emulatorConfig&&Oe(e.emulatorConfig.host)&&(s.credentials=`include`),w_.fetch()(a,s)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function nv(e,t){return k_(e,`POST`,`/v2/accounts:revokeToken`,O_(e,t))}var rv=class e{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){X(e.idToken,`internal-error`),X(e.idToken!==void 0,`internal-error`),X(e.refreshToken!==void 0,`internal-error`);let t=`expiresIn`in e&&e.expiresIn!==void 0?Number(e.expiresIn):K_(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){X(e.length!==0,`internal-error`);let t=K_(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(X(this.refreshToken,e,`user-token-expired`),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){let{accessToken:n,refreshToken:r,expiresIn:i}=await tv(e,t);this.updateTokensAndExpiration(n,r,Number(i))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+n*1e3}static fromJSON(t,n){let{refreshToken:r,accessToken:i,expirationTime:a}=n,o=new e;return r&&(X(typeof r==`string`,`internal-error`,{appName:t}),o.refreshToken=r),i&&(X(typeof i==`string`,`internal-error`,{appName:t}),o.accessToken=i),a&&(X(typeof a==`number`,`internal-error`,{appName:t}),o.expirationTime=a),o}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new e,this.toJSON())}_performRefresh(){return h_(`not implemented`)}};function iv(e,t){X(typeof e==`string`||e===void 0,`internal-error`,{appName:t})}var av=class e{constructor({uid:e,auth:t,stsTokenManager:n,...r}){this.providerId=`firebase`,this.proactiveRefresh=new Y_(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=n,this.accessToken=n.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 X_(r.createdAt||void 0,r.lastLoginAt||void 0)}async getIdToken(e){let t=await q_(this,this.stsTokenManager.getToken(this.auth,e));return X(t,this.auth,`internal-error`),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return U_(this,e)}reload(){return Q_(this)}_assign(e){this!==e&&(X(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=>({...e})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(t){let n=new e({...this,auth:t,stsTokenManager:this.stsTokenManager._clone()});return n.metadata._copy(this.metadata),n}_onReload(e){X(!this.reloadListener,this.auth,`internal-error`),this.reloadListener=e,this.reloadUserInfo&&=(this._notifyReloadListener(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 Z_(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(y(this.auth.app))return Promise.reject(f_(this.auth));let e=await this.getIdToken();return await q_(this,z_(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{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=>({...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(t,n){let r=n.displayName??void 0,i=n.email??void 0,a=n.phoneNumber??void 0,o=n.photoURL??void 0,s=n.tenantId??void 0,c=n._redirectEventId??void 0,l=n.createdAt??void 0,u=n.lastLoginAt??void 0,{uid:d,emailVerified:f,isAnonymous:p,providerData:m,stsTokenManager:h}=n;X(d&&h,t,`internal-error`);let g=rv.fromJSON(this.name,h);X(typeof d==`string`,t,`internal-error`),iv(r,t.name),iv(i,t.name),X(typeof f==`boolean`,t,`internal-error`),X(typeof p==`boolean`,t,`internal-error`),iv(a,t.name),iv(o,t.name),iv(s,t.name),iv(c,t.name),iv(l,t.name),iv(u,t.name);let ee=new e({uid:d,auth:t,email:i,emailVerified:f,displayName:r,isAnonymous:p,photoURL:o,phoneNumber:a,tenantId:s,stsTokenManager:g,createdAt:l,lastLoginAt:u});return m&&Array.isArray(m)&&(ee.providerData=m.map(e=>({...e}))),c&&(ee._redirectEventId=c),ee}static async _fromIdTokenResponse(t,n,r=!1){let i=new rv;i.updateFromServerResponse(n);let a=new e({uid:n.localId,auth:t,stsTokenManager:i,isAnonymous:r});return await Z_(a),a}static async _fromGetAccountInfoResponse(t,n,r){let i=n.users[0];X(i.localId!==void 0,`internal-error`);let a=i.providerUserInfo===void 0?[]:ev(i.providerUserInfo),o=!(i.email&&i.passwordHash)&&!a?.length,s=new rv;s.updateFromIdToken(r);let c=new e({uid:i.localId,auth:t,stsTokenManager:s,isAnonymous:o}),l={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:a,metadata:new X_(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash)&&!a?.length};return Object.assign(c,l),c}},ov=new Map;function sv(e){g_(e instanceof Function,`Expected a class definition`);let t=ov.get(e);return t?(g_(t instanceof e,`Instance stored in cache mismatched with class`),t):(t=new e,ov.set(e,t),t)}var cv=class{constructor(){this.type=`NONE`,this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){let t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}};cv.type=`NONE`;var lv=cv;function uv(e,t,n){return`firebase:${e}:${t}:${n}`}var dv=class e{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;let{config:r,name:i}=this.auth;this.fullUserKey=uv(this.userKey,r.apiKey,i),this.fullPersistenceKey=uv(`persistence`,r.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){let e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e==`string`){let t=await V_(this.auth,{idToken:e}).catch(()=>void 0);return t?av._fromGetAccountInfoResponse(this.auth,t,e):null}return av._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;let t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(t,n,r=`authUser`){if(!n.length)return new e(sv(lv),t,r);let i=(await Promise.all(n.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e),a=i[0]||sv(lv),o=uv(r,t.config.apiKey,t.name),s=null;for(let e of n)try{let n=await e._get(o);if(n){let r;if(typeof n==`string`){let e=await V_(t,{idToken:n}).catch(()=>void 0);if(!e)break;r=await av._fromGetAccountInfoResponse(t,e,n)}else r=av._fromJSON(t,n);e!==a&&(s=r),a=e;break}}catch{}let c=i.filter(e=>e._shouldAllowMigration);return!a._shouldAllowMigration||!c.length?new e(a,t,r):(a=c[0],s&&await a._set(o,s.toJSON()),await Promise.all(n.map(async e=>{if(e!==a)try{await e._remove(o)}catch{}})),new e(a,t,r))}};function fv(e){let t=e.toLowerCase();if(t.includes(`opera/`)||t.includes(`opr/`)||t.includes(`opios/`))return`Opera`;if(gv(t))return`IEMobile`;if(t.includes(`msie`)||t.includes(`trident/`))return`IE`;if(t.includes(`edge/`))return`Edge`;if(pv(t))return`Firefox`;if(t.includes(`silk/`))return`Silk`;if(vv(t))return`Blackberry`;if(yv(t))return`Webos`;if(mv(t))return`Safari`;if((t.includes(`chrome/`)||hv(t))&&!t.includes(`edge/`))return`Chrome`;if(_v(t))return`Android`;{let t=e.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/);if(t?.length===2)return t[1]}return`Other`}function pv(e=re()){return/firefox\//i.test(e)}function mv(e=re()){let t=e.toLowerCase();return t.includes(`safari/`)&&!t.includes(`chrome/`)&&!t.includes(`crios/`)&&!t.includes(`android`)}function hv(e=re()){return/crios\//i.test(e)}function gv(e=re()){return/iemobile/i.test(e)}function _v(e=re()){return/android/i.test(e)}function vv(e=re()){return/blackberry/i.test(e)}function yv(e=re()){return/webos/i.test(e)}function bv(e=re()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function xv(e=re()){return bv(e)&&!!window.navigator?.standalone}function Sv(){return le()&&document.documentMode===10}function Cv(e=re()){return bv(e)||_v(e)||yv(e)||vv(e)||/windows phone/i.test(e)||gv(e)}function wv(e,t=[]){let n;switch(e){case`Browser`:n=fv(re());break;case`Worker`:n=`${fv(re())}-${e}`;break;default:n=e}let r=t.length?t.join(`,`):`FirebaseCore-web`;return`${n}/JsCore/${$t}/${r}`}var Tv=class{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){let n=t=>new Promise((n,r)=>{try{n(e(t))}catch(e){r(e)}});n.onAbort=t,this.queue.push(n);let r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;let t=[];try{for(let n of this.queue)await n(e),n.onAbort&&t.push(n.onAbort)}catch(e){t.reverse();for(let e of t)try{e()}catch{}throw this.auth._errorFactory.create(`login-blocked`,{originalMessage:e?.message})}}};async function Ev(e,t={}){return k_(e,`GET`,`/v2/passwordPolicy`,O_(e,t))}var Dv=6,Ov=class{constructor(e){let t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??Dv,t.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=t.maxPasswordLength),t.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=t.containsLowercaseCharacter),t.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=t.containsUppercaseCharacter),t.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=t.containsNumericCharacter),t.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=t.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState===`ENFORCEMENT_STATE_UNSPECIFIED`&&(this.enforcementState=`OFF`),this.allowedNonAlphanumericCharacters=e.allowedNonAlphanumericCharacters?.join(``)??``,this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){let t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&=t.meetsMinPasswordLength??!0,t.isValid&&=t.meetsMaxPasswordLength??!0,t.isValid&&=t.containsLowercaseLetter??!0,t.isValid&&=t.containsUppercaseLetter??!0,t.isValid&&=t.containsNumericCharacter??!0,t.isValid&&=t.containsNonAlphanumericCharacter??!0,t}validatePasswordLengthOptions(e,t){let n=this.customStrengthOptions.minPasswordLength,r=this.customStrengthOptions.maxPasswordLength;n&&(t.meetsMinPasswordLength=e.length>=n),r&&(t.meetsMaxPasswordLength=e.length<=r)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let n;for(let r=0;r<e.length;r++)n=e.charAt(r),this.updatePasswordCharacterOptionsStatuses(t,n>=`a`&&n<=`z`,n>=`A`&&n<=`Z`,n>=`0`&&n<=`9`,this.allowedNonAlphanumericCharacters.includes(n))}updatePasswordCharacterOptionsStatuses(e,t,n,r,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||=t),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||=n),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||=r),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||=i)}},kv=class{constructor(e,t,n,r){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=n,this.config=r,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new jv(this),this.idTokenSubscription=new jv(this),this.beforeStateQueue=new Tv(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=a_,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=r.sdkClientVersion,this._persistenceManagerAvailable=new Promise(e=>this._resolvePersistenceManagerAvailable=e)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=sv(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await dv.create(this,e),this._resolvePersistenceManagerAvailable?.(),!this._deleted)){if(this._popupRedirectResolver?._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=this.currentUser?.uid||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;let e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{let t=await V_(this,{idToken:e}),n=await av._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){if(y(this.app)){let e=this.app.settings.authIdToken;return e?new Promise(t=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(e).then(t,t))}):this.directlySetCurrentUser(null)}let t=await this.assertedPersistence.getCurrentUser(),n=t,r=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();let t=this.redirectUser?._redirectEventId,i=n?._redirectEventId,a=await this.tryRedirectSignIn(e);(!t||t===i)&&a?.user&&(n=a.user,r=!0)}if(!n)return this.directlySetCurrentUser(null);if(!n._redirectEventId){if(r)try{await this.beforeStateQueue.runMiddleware(n)}catch(e){n=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(e))}return n?this.reloadAndSetCurrentUserOrClear(n):this.directlySetCurrentUser(null)}return X(this._popupRedirectResolver,this,`argument-error`),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===n._redirectEventId?this.directlySetCurrentUser(n):this.reloadAndSetCurrentUserOrClear(n)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await Z_(e)}catch(e){if(e?.code!==`auth/network-request-failed`)return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=x_()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(y(this.app))return Promise.reject(f_(this));let t=e?_(e):null;return t&&X(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&&X(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 y(this.app)?Promise.reject(f_(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return y(this.app)?Promise.reject(f_(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(sv(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();let t=this._getPasswordPolicyInternal();return t.schemaVersion===this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?t.validatePassword(e):Promise.reject(this._errorFactory.create(`unsupported-password-policy-schema-version`,{}))}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){let e=new Ov(await Ev(this));this.tenantId===null?this._projectPasswordPolicy=e:this._tenantPasswordPolicies[this.tenantId]=e}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new he(`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{let n=this.onAuthStateChanged(()=>{n(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){let t={providerId:`apple.com`,tokenType:`ACCESS_TOKEN`,token:e,idToken:await this.currentUser.getIdToken()};this.tenantId!=null&&(t.tenantId=this.tenantId),await nv(this,t)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,t){let n=await this.getOrInitRedirectPersistenceManager(t);return e===null?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){let t=e&&sv(e)||this._popupRedirectResolver;X(t,this,`argument-error`),this.redirectPersistenceManager=await dv.create(this,[sv(t._redirectPersistence)],`redirectUser`),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){return this._isInitialized&&await this.queue(async()=>{}),this._currentUser?._redirectEventId===e?this._currentUser:this.redirectUser?._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(){if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);let e=this.currentUser?.uid??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,n,r){if(this._deleted)return()=>{};let i=typeof t==`function`?t:t.next.bind(t),a=!1,o=this._isInitialized?Promise.resolve():this._initializationPromise;if(X(o,this,`internal-error`),o.then(()=>{a||i(this.currentUser)}),typeof t==`function`){let i=e.addObserver(t,n,r);return()=>{a=!0,i()}}else{let n=e.addObserver(t);return()=>{a=!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 X(this.persistenceManager,this,`internal-error`),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=wv(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){let e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e[`X-Firebase-gmpid`]=this.app.options.appId);let t=await this.heartbeatServiceProvider.getImmediate({optional:!0})?.getHeartbeatsHeader();t&&(e[`X-Firebase-Client`]=t);let n=await this._getAppCheckToken();return n&&(e[`X-Firebase-AppCheck`]=n),e}async _getAppCheckToken(){if(y(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;let e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&s_(`Error while retrieving App Check token: ${e.error}`),e?.token}};function Av(e){return _(e)}var jv=class{constructor(e){this.auth=e,this.observer=null,this.addObserver=we(e=>this.observer=e)}get next(){return X(this.observer,this.auth,`internal-error`),this.observer.next.bind(this.observer)}},Mv={async loadJS(){throw Error(`Unable to load external scripts`)},recaptchaV2Script:``,recaptchaEnterpriseScript:``,gapiScript:``};function Nv(e){Mv=e}function Pv(e){return Mv.loadJS(e)}function Fv(){return Mv.recaptchaEnterpriseScript}function Iv(){return Mv.gapiScript}function Lv(e){return`__${e}${Math.floor(Math.random()*1e6)}`}var Rv=class{constructor(){this.enterprise=new zv}ready(e){e()}execute(e,t){return Promise.resolve(`token`)}render(e,t){return``}},zv=class{ready(e){e()}execute(e,t){return Promise.resolve(`token`)}render(e,t){return``}},Bv=`recaptcha-enterprise`,Vv=`NO_RECAPTCHA`,Hv=`onFirebaseAuthREInstanceReady`,Uv=class e{constructor(e){this.type=Bv,this.auth=Av(e)}async verify(t=`verify`,n=!1){async function r(e){if(!n){if(e.tenantId==null&&e._agentRecaptchaConfig!=null)return e._agentRecaptchaConfig.siteKey;if(e.tenantId!=null&&e._tenantRecaptchaConfigs[e.tenantId]!==void 0)return e._tenantRecaptchaConfigs[e.tenantId].siteKey}return new Promise(async(t,n)=>{R_(e,{clientType:`CLIENT_TYPE_WEB`,version:`RECAPTCHA_ENTERPRISE`}).then(r=>{if(r.recaptchaKey===void 0)n(Error(`recaptcha Enterprise site key undefined`));else{let n=new L_(r);return e.tenantId==null?e._agentRecaptchaConfig=n:e._tenantRecaptchaConfigs[e.tenantId]=n,t(n.siteKey)}}).catch(e=>{n(e)})})}function i(e,n,r){let i=window.grecaptcha;I_(i)?i.enterprise.ready(()=>{i.enterprise.execute(e,{action:t}).then(e=>{n(e)}).catch(()=>{n(Vv)})}):r(Error(`No reCAPTCHA enterprise script loaded.`))}return this.auth.settings.appVerificationDisabledForTesting?new Rv().execute(`siteKey`,{action:`verify`}):new Promise((t,a)=>{r(this.auth).then(async r=>{if(!n&&I_(window.grecaptcha)&&e.scriptInjectionDeferred)await e.scriptInjectionDeferred.promise,i(r,t,a);else{if(typeof window>`u`){a(Error(`RecaptchaVerifier is only supported in browser`));return}let n=Fv();n.length!==0&&(n+=r+`&onload=${Hv}`),e.scriptInjectionDeferred=new te,window[Hv]=()=>{e.scriptInjectionDeferred?.resolve()},Pv(n).then(()=>e.scriptInjectionDeferred?.promise).then(()=>{i(r,t,a)}).catch(e=>{a(e)})}}).catch(e=>{a(e)})})}};Uv.scriptInjectionDeferred=null;async function Wv(e,t,n,r=!1,i=!1){let a=new Uv(e),o;if(i)o=Vv;else try{o=await a.verify(n)}catch{o=await a.verify(n,!0)}let s={...t};if(n===`mfaSmsEnrollment`||n===`mfaSmsSignIn`){if(`phoneEnrollmentInfo`in s){let e=s.phoneEnrollmentInfo.phoneNumber,t=s.phoneEnrollmentInfo.recaptchaToken;Object.assign(s,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:t,captchaResponse:o,clientType:`CLIENT_TYPE_WEB`,recaptchaVersion:`RECAPTCHA_ENTERPRISE`}})}else if(`phoneSignInInfo`in s){let e=s.phoneSignInInfo.recaptchaToken;Object.assign(s,{phoneSignInInfo:{recaptchaToken:e,captchaResponse:o,clientType:`CLIENT_TYPE_WEB`,recaptchaVersion:`RECAPTCHA_ENTERPRISE`}})}return s}return r?Object.assign(s,{captchaResp:o}):Object.assign(s,{captchaResponse:o}),Object.assign(s,{clientType:`CLIENT_TYPE_WEB`}),Object.assign(s,{recaptchaVersion:`RECAPTCHA_ENTERPRISE`}),s}async function Gv(e,t,n,r,i){return i===`EMAIL_PASSWORD_PROVIDER`?e._getRecaptchaConfig()?.isProviderEnabled(`EMAIL_PASSWORD_PROVIDER`)?r(e,await Wv(e,t,n,n===`getOobCode`)):r(e,t).catch(async i=>i.code===`auth/missing-recaptcha-token`?(console.log(`${n} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`),r(e,await Wv(e,t,n,n===`getOobCode`))):Promise.reject(i)):i===`PHONE_PROVIDER`?e._getRecaptchaConfig()?.isProviderEnabled(`PHONE_PROVIDER`)?r(e,await Wv(e,t,n)).catch(async i=>e._getRecaptchaConfig()?.getProviderEnforcementState(`PHONE_PROVIDER`)===`AUDIT`&&(i.code===`auth/missing-recaptcha-token`||i.code===`auth/invalid-app-credential`)?(console.log(`Failed to verify with reCAPTCHA Enterprise. Automatically triggering the reCAPTCHA v2 flow to complete the ${n} flow.`),r(e,await Wv(e,t,n,!1,!0))):Promise.reject(i)):r(e,await Wv(e,t,n,!1,!0)):Promise.reject(i+` provider is not supported.`)}async function Kv(e){let t=Av(e),n=new L_(await R_(t,{clientType:`CLIENT_TYPE_WEB`,version:`RECAPTCHA_ENTERPRISE`}));t.tenantId==null?t._agentRecaptchaConfig=n:t._tenantRecaptchaConfigs[t.tenantId]=n,n.isAnyProviderEnabled()&&new Uv(t).verify()}function qv(e,t){let n=Xt(e,`auth`);if(n.isInitialized()){let e=n.getImmediate();if(ye(n.getOptions(),t??{}))return e;l_(e,`already-initialized`)}return n.initialize({options:t})}function Jv(e,t){let n=t?.persistence||[],r=(Array.isArray(n)?n:[n]).map(sv);t?.errorMap&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,t?.popupRedirectResolver)}function Yv(e,t,n){let r=Av(e);X(/^https?:\/\//.test(t),r,`invalid-emulator-scheme`);let i=!!n?.disableWarnings,a=Xv(t),{host:o,port:s}=Zv(t),c=s===null?``:`:${s}`,l={url:`${a}//${o}${c}/`},u=Object.freeze({host:o,port:s,protocol:a.replace(`:`,``),options:Object.freeze({disableWarnings:i})});if(!r._canInitEmulator){X(r.config.emulator&&r.emulatorConfig,r,`emulator-config-failed`),X(ye(l,r.config.emulator)&&ye(u,r.emulatorConfig),r,`emulator-config-failed`);return}r.config.emulator=l,r.emulatorConfig=u,r.settings.appVerificationDisabledForTesting=!0,Oe(o)?ke(`${a}//${o}${c}`):i||$v()}function Xv(e){let t=e.indexOf(`:`);return t<0?``:e.substr(0,t+1)}function Zv(e){let t=Xv(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:``,port:null};let r=n[2].split(`@`).pop()||``,i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){let e=i[1];return{host:e,port:Qv(r.substr(e.length+1))}}else{let[e,t]=r.split(`:`);return{host:e,port:Qv(t)}}}function Qv(e){if(!e)return null;let t=Number(e);return isNaN(t)?null:t}function $v(){function e(){let e=document.createElement(`p`),t=e.style;e.innerText=`Running in emulator mode. Do not use with production credentials.`,t.position=`fixed`,t.width=`100%`,t.backgroundColor=`#ffffff`,t.border=`.1em solid #000000`,t.color=`#b50000`,t.bottom=`0px`,t.left=`0px`,t.margin=`0px`,t.zIndex=`10000`,t.textAlign=`center`,e.classList.add(`firebase-emulator-warning`),document.body.appendChild(e)}typeof console<`u`&&typeof console.info==`function`&&console.info(`WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials.`),typeof window<`u`&&typeof document<`u`&&(document.readyState===`loading`?window.addEventListener(`DOMContentLoaded`,e):e())}var ey=class{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return h_(`not implemented`)}_getIdTokenResponse(e){return h_(`not implemented`)}_linkToIdToken(e,t){return h_(`not implemented`)}_getReauthenticationResolver(e){return h_(`not implemented`)}};async function ty(e,t){return k_(e,`POST`,`/v1/accounts:signUp`,t)}async function ny(e,t){return j_(e,`POST`,`/v1/accounts:signInWithPassword`,O_(e,t))}async function ry(e,t){return k_(e,`POST`,`/v1/accounts:sendOobCode`,O_(e,t))}async function iy(e,t){return ry(e,t)}async function ay(e,t){return ry(e,t)}async function oy(e,t){return j_(e,`POST`,`/v1/accounts:signInWithEmailLink`,O_(e,t))}async function sy(e,t){return j_(e,`POST`,`/v1/accounts:signInWithEmailLink`,O_(e,t))}var cy=class e extends ey{constructor(e,t,n,r=null){super(`password`,n),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(t,n){return new e(t,n,`password`)}static _fromEmailAndCode(t,n,r=null){return new e(t,n,`emailLink`,r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){let t=typeof e==`string`?JSON.parse(e):e;if(t?.email&&t?.password){if(t.signInMethod===`password`)return this._fromEmailAndPassword(t.email,t.password);if(t.signInMethod===`emailLink`)return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case`password`:return Gv(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:`CLIENT_TYPE_WEB`},`signInWithPassword`,ny,`EMAIL_PASSWORD_PROVIDER`);case`emailLink`:return oy(e,{email:this._email,oobCode:this._password});default:l_(e,`internal-error`)}}async _linkToIdToken(e,t){switch(this.signInMethod){case`password`:return Gv(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:`CLIENT_TYPE_WEB`},`signUpPassword`,ty,`EMAIL_PASSWORD_PROVIDER`);case`emailLink`:return sy(e,{idToken:t,email:this._email,oobCode:this._password});default:l_(e,`internal-error`)}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}};async function ly(e,t){return j_(e,`POST`,`/v1/accounts:signInWithIdp`,O_(e,t))}var uy=`http://localhost`,dy=class e extends ey{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(t){let n=new e(t.providerId,t.signInMethod);return t.idToken||t.accessToken?(t.idToken&&(n.idToken=t.idToken),t.accessToken&&(n.accessToken=t.accessToken),t.nonce&&!t.pendingToken&&(n.nonce=t.nonce),t.pendingToken&&(n.pendingToken=t.pendingToken)):t.oauthToken&&t.oauthTokenSecret?(n.accessToken=t.oauthToken,n.secret=t.oauthTokenSecret):l_(`argument-error`),n}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(t){let{providerId:n,signInMethod:r,...i}=typeof t==`string`?JSON.parse(t):t;if(!n||!r)return null;let a=new e(n,r);return a.idToken=i.idToken||void 0,a.accessToken=i.accessToken||void 0,a.secret=i.secret,a.nonce=i.nonce,a.pendingToken=i.pendingToken||null,a}_getIdTokenResponse(e){return ly(e,this.buildRequest())}_linkToIdToken(e,t){let n=this.buildRequest();return n.idToken=t,ly(e,n)}_getReauthenticationResolver(e){let t=this.buildRequest();return t.autoCreate=!1,ly(e,t)}buildRequest(){let e={requestUri:uy,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{let 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=xe(t)}return e}};async function fy(e,t){return k_(e,`POST`,`/v1/accounts:sendVerificationCode`,O_(e,t))}async function py(e,t){return j_(e,`POST`,`/v1/accounts:signInWithPhoneNumber`,O_(e,t))}async function my(e,t){let n=await j_(e,`POST`,`/v1/accounts:signInWithPhoneNumber`,O_(e,t));if(n.temporaryProof)throw F_(e,`account-exists-with-different-credential`,n);return n}var hy={USER_NOT_FOUND:`user-not-found`};async function gy(e,t){return j_(e,`POST`,`/v1/accounts:signInWithPhoneNumber`,O_(e,{...t,operation:`REAUTH`}),hy)}var _y=class e extends ey{constructor(e){super(`phone`,`phone`),this.params=e}static _fromVerification(t,n){return new e({verificationId:t,verificationCode:n})}static _fromTokenResponse(t,n){return new e({phoneNumber:t,temporaryProof:n})}_getIdTokenResponse(e){return py(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return my(e,{idToken:t,...this._makeVerificationRequest()})}_getReauthenticationResolver(e){return gy(e,this._makeVerificationRequest())}_makeVerificationRequest(){let{temporaryProof:e,phoneNumber:t,verificationId:n,verificationCode:r}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:n,code:r}}toJSON(){let e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}static fromJSON(t){typeof t==`string`&&(t=JSON.parse(t));let{verificationId:n,verificationCode:r,phoneNumber:i,temporaryProof:a}=t;return!r&&!n&&!i&&!a?null:new e({verificationId:n,verificationCode:r,phoneNumber:i,temporaryProof:a})}};function vy(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}}function yy(e){let t=Se(Ce(e)).link,n=t?Se(Ce(t)).deep_link_id:null,r=Se(Ce(e)).deep_link_id;return(r?Se(Ce(r)).link:null)||r||n||t||e}var by=class e{constructor(e){let t=Se(Ce(e)),n=t.apiKey??null,r=t.oobCode??null,i=vy(t.mode??null);X(n&&r&&i,`argument-error`),this.apiKey=n,this.operation=i,this.code=r,this.continueUrl=t.continueUrl??null,this.languageCode=t.lang??null,this.tenantId=t.tenantId??null}static parseLink(t){let n=yy(t);try{return new e(n)}catch{return null}}},xy=class e{constructor(){this.providerId=e.PROVIDER_ID}static credential(e,t){return cy._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){let n=by.parseLink(t);return X(n,`argument-error`),cy._fromEmailAndCode(e,n.code,n.tenantId)}};xy.PROVIDER_ID=`password`,xy.EMAIL_PASSWORD_SIGN_IN_METHOD=`password`,xy.EMAIL_LINK_SIGN_IN_METHOD=`emailLink`;var Sy=class{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}},Cy=class extends Sy{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}},wy=class e extends Cy{constructor(){super(`facebook.com`)}static credential(t){return dy._fromParams({providerId:e.PROVIDER_ID,signInMethod:e.FACEBOOK_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return e.credentialFromTaggedObject(t)}static credentialFromError(t){return e.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!(`oauthAccessToken`in t)||!t.oauthAccessToken)return null;try{return e.credential(t.oauthAccessToken)}catch{return null}}};wy.FACEBOOK_SIGN_IN_METHOD=`facebook.com`,wy.PROVIDER_ID=`facebook.com`;var Ty=class e extends Cy{constructor(){super(`google.com`),this.addScope(`profile`)}static credential(t,n){return dy._fromParams({providerId:e.PROVIDER_ID,signInMethod:e.GOOGLE_SIGN_IN_METHOD,idToken:t,accessToken:n})}static credentialFromResult(t){return e.credentialFromTaggedObject(t)}static credentialFromError(t){return e.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;let{oauthIdToken:n,oauthAccessToken:r}=t;if(!n&&!r)return null;try{return e.credential(n,r)}catch{return null}}};Ty.GOOGLE_SIGN_IN_METHOD=`google.com`,Ty.PROVIDER_ID=`google.com`;var Ey=class e extends Cy{constructor(){super(`github.com`)}static credential(t){return dy._fromParams({providerId:e.PROVIDER_ID,signInMethod:e.GITHUB_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return e.credentialFromTaggedObject(t)}static credentialFromError(t){return e.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!(`oauthAccessToken`in t)||!t.oauthAccessToken)return null;try{return e.credential(t.oauthAccessToken)}catch{return null}}};Ey.GITHUB_SIGN_IN_METHOD=`github.com`,Ey.PROVIDER_ID=`github.com`;var Dy=class e extends Cy{constructor(){super(`twitter.com`)}static credential(t,n){return dy._fromParams({providerId:e.PROVIDER_ID,signInMethod:e.TWITTER_SIGN_IN_METHOD,oauthToken:t,oauthTokenSecret:n})}static credentialFromResult(t){return e.credentialFromTaggedObject(t)}static credentialFromError(t){return e.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;let{oauthAccessToken:n,oauthTokenSecret:r}=t;if(!n||!r)return null;try{return e.credential(n,r)}catch{return null}}};Dy.TWITTER_SIGN_IN_METHOD=`twitter.com`,Dy.PROVIDER_ID=`twitter.com`;async function Oy(e,t){return j_(e,`POST`,`/v1/accounts:signUp`,O_(e,t))}var ky=class e{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(t,n,r,i=!1){return new e({user:await av._fromIdTokenResponse(t,r,i),providerId:Ay(r),_tokenResponse:r,operationType:n})}static async _forOperation(t,n,r){return await t._updateTokensIfNecessary(r,!0),new e({user:t,providerId:Ay(r),_tokenResponse:r,operationType:n})}};function Ay(e){return e.providerId?e.providerId:`phoneNumber`in e?`phone`:null}async function jy(e){if(y(e.app))return Promise.reject(f_(e));let t=Av(e);if(await t._initializationPromise,t.currentUser?.isAnonymous)return new ky({user:t.currentUser,providerId:null,operationType:`signIn`});let n=await Oy(t,{returnSecureToken:!0}),r=await ky._fromIdTokenResponse(t,`signIn`,n,!0);return await t._updateCurrentUser(r.user),r}var My=class e extends me{constructor(t,n,r,i){super(n.code,n.message),this.operationType=r,this.user=i,Object.setPrototypeOf(this,e.prototype),this.customData={appName:t.name,tenantId:t.tenantId??void 0,_serverResponse:n.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(t,n,r,i){return new e(t,n,r,i)}};function Ny(e,t,n,r){return(t===`reauthenticate`?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(n=>{throw n.code===`auth/multi-factor-auth-required`?My._fromErrorAndOperation(e,n,t,r):n})}function Py(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function Fy(e,t){let n=_(e);await Ly(!0,n,t);let{providerUserInfo:r}=await B_(n.auth,{idToken:await n.getIdToken(),deleteProvider:[t]}),i=Py(r||[]);return n.providerData=n.providerData.filter(e=>i.has(e.providerId)),i.has(`phone`)||(n.phoneNumber=null),await n.auth._persistUserIfCurrent(n),n}async function Iy(e,t,n=!1){let r=await q_(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return ky._forOperation(e,`link`,r)}async function Ly(e,t,n){await Z_(t);let r=Py(t.providerData),i=e===!1?`provider-already-linked`:`no-such-provider`;X(r.has(n)===e,t.auth,i)}async function Ry(e,t,n=!1){let{auth:r}=e;if(y(r.app))return Promise.reject(f_(r));let i=`reauthenticate`;try{let a=await q_(e,Ny(r,i,t,e),n);X(a.idToken,r,`internal-error`);let o=G_(a.idToken);X(o,r,`internal-error`);let{sub:s}=o;return X(e.uid===s,r,`user-mismatch`),ky._forOperation(e,i,a)}catch(e){throw e?.code===`auth/user-not-found`&&l_(r,`user-mismatch`),e}}async function zy(e,t,n=!1){if(y(e.app))return Promise.reject(f_(e));let r=`signIn`,i=await Ny(e,r,t),a=await ky._fromIdTokenResponse(e,r,i);return n||await e._updateCurrentUser(a.user),a}async function By(e,t){return zy(Av(e),t)}function Vy(e,t,n){X(n.url?.length>0,e,`invalid-continue-uri`),X(n.dynamicLinkDomain===void 0||n.dynamicLinkDomain.length>0,e,`invalid-dynamic-link-domain`),X(n.linkDomain===void 0||n.linkDomain.length>0,e,`invalid-hosting-link-domain`),t.continueUrl=n.url,t.dynamicLinkDomain=n.dynamicLinkDomain,t.linkDomain=n.linkDomain,t.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(X(n.iOS.bundleId.length>0,e,`missing-ios-bundle-id`),t.iOSBundleId=n.iOS.bundleId),n.android&&(X(n.android.packageName.length>0,e,`missing-android-pkg-name`),t.androidInstallApp=n.android.installApp,t.androidMinimumVersionCode=n.android.minimumVersion,t.androidPackageName=n.android.packageName)}async function Hy(e){let t=Av(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function Uy(e,t,n){let r=Av(e),i={requestType:`PASSWORD_RESET`,email:t,clientType:`CLIENT_TYPE_WEB`};n&&Vy(r,i,n),await Gv(r,i,`getOobCode`,ay,`EMAIL_PASSWORD_PROVIDER`)}async function Wy(e,t,n){if(y(e.app))return Promise.reject(f_(e));let r=Av(e),i=await Gv(r,{returnSecureToken:!0,email:t,password:n,clientType:`CLIENT_TYPE_WEB`},`signUpPassword`,Oy,`EMAIL_PASSWORD_PROVIDER`).catch(t=>{throw t.code===`auth/password-does-not-meet-requirements`&&Hy(e),t}),a=await ky._fromIdTokenResponse(r,`signIn`,i);return await r._updateCurrentUser(a.user),a}function Gy(e,t,n){return y(e.app)?Promise.reject(f_(e)):By(_(e),xy.credential(t,n)).catch(async t=>{throw t.code===`auth/password-does-not-meet-requirements`&&Hy(e),t})}async function Ky(e,t){let n=_(e),r={requestType:`VERIFY_EMAIL`,idToken:await e.getIdToken()};t&&Vy(n.auth,r,t);let{email:i}=await iy(n.auth,r);i!==e.email&&await e.reload()}async function qy(e,t){return k_(e,`POST`,`/v1/accounts:update`,t)}async function Jy(e,{displayName:t,photoURL:n}){if(t===void 0&&n===void 0)return;let r=_(e),i={idToken:await r.getIdToken(),displayName:t,photoUrl:n,returnSecureToken:!0},a=await q_(r,qy(r.auth,i));r.displayName=a.displayName||null,r.photoURL=a.photoUrl||null;let o=r.providerData.find(({providerId:e})=>e===`password`);o&&(o.displayName=r.displayName,o.photoURL=r.photoURL),await r._updateTokensIfNecessary(a)}function Yy(e,t,n,r){return _(e).onIdTokenChanged(t,n,r)}function Xy(e,t,n){return _(e).beforeAuthStateChanged(t,n)}function Zy(e,t){return k_(e,`POST`,`/v2/accounts/mfaEnrollment:start`,O_(e,t))}function Qy(e,t){return k_(e,`POST`,`/v2/accounts/mfaEnrollment:finalize`,O_(e,t))}function $y(e,t){return k_(e,`POST`,`/v2/accounts/mfaEnrollment:start`,O_(e,t))}function eb(e,t){return k_(e,`POST`,`/v2/accounts/mfaEnrollment:finalize`,O_(e,t))}var tb=`__sak`,nb=class{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(tb,`1`),this.storage.removeItem(tb),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){let 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()}},rb=1e3,ib=10,ab=class extends nb{constructor(){super(()=>window.localStorage,`LOCAL`),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=Cv(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(let t of Object.keys(this.listeners)){let n=this.storage.getItem(t),r=this.localCache[t];n!==r&&e(t,r,n)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((e,t,n)=>{this.notifyListeners(e,n)});return}let n=e.key;t?this.detachListener():this.stopPolling();let r=()=>{let e=this.storage.getItem(n);!t&&this.localCache[n]===e||this.notifyListeners(n,e)},i=this.storage.getItem(n);Sv()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(r,ib):r()}notifyListeners(e,t){this.localCache[e]=t;let n=this.listeners[e];if(n)for(let e of Array.from(n))e(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,n)=>{this.onStorageEvent(new StorageEvent(`storage`,{key:e,oldValue:t,newValue:n}),!0)})},rb)}stopPolling(){this.pollTimer&&=(clearInterval(this.pollTimer),null)}attachListener(){window.addEventListener(`storage`,this.boundEventHandler)}detachListener(){window.removeEventListener(`storage`,this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){let t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}};ab.type=`LOCAL`;var ob=ab,sb=1e3;function cb(e){let t=e.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`),n=RegExp(`${t}=([^;]+)`);return document.cookie.match(n)?.[1]??null}function lb(e){return`${window.location.protocol===`http:`?`__dev_`:`__HOST-`}FIREBASE_${e.split(`:`)[3]}`}var ub=class{constructor(){this.type=`COOKIE`,this.listenerUnsubscribes=new Map}_getFinalTarget(e){let t=new URL(`${window.location.origin}/__cookies__`);return t.searchParams.set(`finalTarget`,e),t}async _isAvailable(){return typeof isSecureContext==`boolean`&&!isSecureContext||typeof navigator>`u`||typeof document>`u`?!1:navigator.cookieEnabled??!0}async _set(e,t){}async _get(e){if(!this._isAvailable())return null;let t=lb(e);return window.cookieStore?(await window.cookieStore.get(t))?.value:cb(t)}async _remove(e){if(!this._isAvailable()||!await this._get(e))return;let t=lb(e);document.cookie=`${t}=;Max-Age=34560000;Partitioned;Secure;SameSite=Strict;Path=/;Priority=High`,await fetch(`/__cookies__`,{method:`DELETE`}).catch(()=>void 0)}_addListener(e,t){if(!this._isAvailable())return;let n=lb(e);if(window.cookieStore){let e=(e=>{let r=e.changed.find(e=>e.name===n);r&&t(r.value),e.deleted.find(e=>e.name===n)&&t(null)});return this.listenerUnsubscribes.set(t,()=>window.cookieStore.removeEventListener(`change`,e)),window.cookieStore.addEventListener(`change`,e)}let r=cb(n),i=setInterval(()=>{let e=cb(n);e!==r&&(t(e),r=e)},sb);this.listenerUnsubscribes.set(t,()=>clearInterval(i))}_removeListener(e,t){let n=this.listenerUnsubscribes.get(t);n&&(n(),this.listenerUnsubscribes.delete(t))}};ub.type=`COOKIE`;var db=class extends nb{constructor(){super(()=>window.sessionStorage,`SESSION`)}_addListener(e,t){}_removeListener(e,t){}};db.type=`SESSION`;var fb=db;function pb(e){return Promise.all(e.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}}))}var mb=class e{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){let n=this.receivers.find(e=>e.isListeningto(t));if(n)return n;let r=new e(t);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){let t=e,{eventId:n,eventType:r,data:i}=t.data,a=this.handlersMap[r];if(!a?.size)return;t.ports[0].postMessage({status:`ack`,eventId:n,eventType:r});let o=await pb(Array.from(a).map(async e=>e(t.origin,i)));t.ports[0].postMessage({status:`done`,eventId:n,eventType:r,response:o})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener(`message`,this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),(!t||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener(`message`,this.boundEventHandler)}};mb.receivers=[];function hb(e=``,t=10){let n=``;for(let e=0;e<t;e++)n+=Math.floor(Math.random()*10);return e+n}var gb=class{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){let r=typeof MessageChannel<`u`?new MessageChannel:null;if(!r)throw Error(`connection_unavailable`);let i,a;return new Promise((o,s)=>{let c=hb(``,20);r.port1.start();let l=setTimeout(()=>{s(Error(`unsupported_event`))},n);a={messageChannel:r,onMessage(e){let t=e;if(t.data.eventId===c)switch(t.data.status){case`ack`:clearTimeout(l),i=setTimeout(()=>{s(Error(`timeout`))},3e3);break;case`done`:clearTimeout(i),o(t.data.response);break;default:clearTimeout(l),clearTimeout(i),s(Error(`invalid_response`));break}}},this.handlers.add(a),r.port1.addEventListener(`message`,a.onMessage),this.target.postMessage({eventType:e,eventId:c,data:t},[r.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}};function _b(){return window}function vb(e){_b().location.href=e}function yb(){return _b().WorkerGlobalScope!==void 0&&typeof _b().importScripts==`function`}async function bb(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function xb(){return navigator?.serviceWorker?.controller||null}function Sb(){return yb()?self:null}var Cb=`firebaseLocalStorageDb`,wb=1,Tb=`firebaseLocalStorage`,Eb=`fbase_key`,Db=class{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 Ob(e,t){return e.transaction([Tb],t?`readwrite`:`readonly`).objectStore(Tb)}function kb(){return new Db(indexedDB.deleteDatabase(Cb)).toPromise()}function Ab(){let e=indexedDB.open(Cb,wb);return new Promise((t,n)=>{e.addEventListener(`error`,()=>{n(e.error)}),e.addEventListener(`upgradeneeded`,()=>{let t=e.result;try{t.createObjectStore(Tb,{keyPath:Eb})}catch(e){n(e)}}),e.addEventListener(`success`,async()=>{let n=e.result;n.objectStoreNames.contains(Tb)?t(n):(n.close(),await kb(),t(await Ab()))})})}async function jb(e,t,n){return new Db(Ob(e,!0).put({[Eb]:t,value:n})).toPromise()}async function Mb(e,t){let n=await new Db(Ob(e,!1).get(t)).toPromise();return n===void 0?null:n.value}function Nb(e,t){return new Db(Ob(e,!0).delete(t)).toPromise()}var Pb=800,Fb=3,Ib=class{constructor(){this.type=`LOCAL`,this.dbPromise=null,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.dbPromise?this.dbPromise:(this.dbPromise=Ab(),this.dbPromise.catch(()=>{this.dbPromise=null}),this.dbPromise)}async _withRetries(e){let t=0;for(;;)try{return await e(await this._openDb())}catch(e){if(t++>Fb)throw e;this.dbPromise&&=((await this.dbPromise).close(),null)}}async initializeServiceWorkerMessaging(){return yb()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=mb._getInstance(Sb()),this.receiver._subscribe(`keyChanged`,async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe(`ping`,async(e,t)=>[`keyChanged`])}async initializeSender(){if(this.activeServiceWorker=await bb(),!this.activeServiceWorker)return;this.sender=new gb(this.activeServiceWorker);let e=await this.sender._send(`ping`,{},800);e&&e[0]?.fulfilled&&e[0]?.value.includes(`keyChanged`)&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||xb()!==this.activeServiceWorker))try{await this.sender._send(`keyChanged`,{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{return indexedDB?(await this._withRetries(async e=>{await jb(e,tb,`1`),await Nb(e,tb)}),!0):!1}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(n=>jb(n,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){let t=await this._withRetries(t=>Mb(t,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Nb(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){let e=await this._withRetries(e=>new Db(Ob(e,!1).getAll()).toPromise());if(!e||this.pendingWrites!==0)return[];let t=[],n=new Set;if(e.length!==0)for(let{fbase_key:r,value:i}of e)n.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),t.push(r));for(let 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;let n=this.listeners[e];if(n)for(let e of Array.from(n))e(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),Pb)}stopPolling(){this.pollTimer&&=(clearInterval(this.pollTimer),null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&this.stopPolling()}};Ib.type=`LOCAL`;var Lb=Ib;function Rb(e,t){return k_(e,`POST`,`/v2/accounts/mfaSignIn:start`,O_(e,t))}function zb(e,t){return k_(e,`POST`,`/v2/accounts/mfaSignIn:finalize`,O_(e,t))}function Bb(e,t){return k_(e,`POST`,`/v2/accounts/mfaSignIn:finalize`,O_(e,t))}Lv(`rcb`),new S_(3e4,6e4);var Vb=`recaptcha`;async function Hb(e,t,n){if(!e._getRecaptchaConfig())try{await Kv(e)}catch{console.log(`Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.`)}try{let r;if(r=typeof t==`string`?{phoneNumber:t}:t,`session`in r){let t=r.session;if(`phoneNumber`in r)return X(t.type===`enroll`,e,`internal-error`),(await Gv(e,{idToken:t.credential,phoneEnrollmentInfo:{phoneNumber:r.phoneNumber,clientType:`CLIENT_TYPE_WEB`}},`mfaSmsEnrollment`,async(e,t)=>t.phoneEnrollmentInfo.captchaResponse===Vv?(X(n?.type===Vb,e,`argument-error`),Zy(e,await Ub(e,t,n))):Zy(e,t),`PHONE_PROVIDER`).catch(e=>Promise.reject(e))).phoneSessionInfo.sessionInfo;{X(t.type===`signin`,e,`internal-error`);let i=r.multiFactorHint?.uid||r.multiFactorUid;return X(i,e,`missing-multi-factor-info`),(await Gv(e,{mfaPendingCredential:t.credential,mfaEnrollmentId:i,phoneSignInInfo:{clientType:`CLIENT_TYPE_WEB`}},`mfaSmsSignIn`,async(e,t)=>t.phoneSignInInfo.captchaResponse===Vv?(X(n?.type===Vb,e,`argument-error`),Rb(e,await Ub(e,t,n))):Rb(e,t),`PHONE_PROVIDER`).catch(e=>Promise.reject(e))).phoneResponseInfo.sessionInfo}}else return(await Gv(e,{phoneNumber:r.phoneNumber,clientType:`CLIENT_TYPE_WEB`},`sendVerificationCode`,async(e,t)=>t.captchaResponse===Vv?(X(n?.type===Vb,e,`argument-error`),fy(e,await Ub(e,t,n))):fy(e,t),`PHONE_PROVIDER`).catch(e=>Promise.reject(e))).sessionInfo}finally{n?._reset()}}async function Ub(e,t,n){X(n.type===Vb,e,`argument-error`);let r=await n.verify();X(typeof r==`string`,e,`argument-error`);let i={...t};if(`phoneEnrollmentInfo`in i){let e=i.phoneEnrollmentInfo.phoneNumber,t=i.phoneEnrollmentInfo.captchaResponse,n=i.phoneEnrollmentInfo.clientType,a=i.phoneEnrollmentInfo.recaptchaVersion;return Object.assign(i,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:r,captchaResponse:t,clientType:n,recaptchaVersion:a}}),i}else if(`phoneSignInInfo`in i){let e=i.phoneSignInInfo.captchaResponse,t=i.phoneSignInInfo.clientType,n=i.phoneSignInInfo.recaptchaVersion;return Object.assign(i,{phoneSignInInfo:{recaptchaToken:r,captchaResponse:e,clientType:t,recaptchaVersion:n}}),i}else return Object.assign(i,{recaptchaToken:r}),i}var Wb=class e{constructor(t){this.providerId=e.PROVIDER_ID,this.auth=Av(t)}verifyPhoneNumber(e,t){return Hb(this.auth,e,_(t))}static credential(e,t){return _y._fromVerification(e,t)}static credentialFromResult(t){let n=t;return e.credentialFromTaggedObject(n)}static credentialFromError(t){return e.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;let{phoneNumber:t,temporaryProof:n}=e;return t&&n?_y._fromTokenResponse(t,n):null}};Wb.PROVIDER_ID=`phone`,Wb.PHONE_SIGN_IN_METHOD=`phone`;function Gb(e,t){return t?sv(t):(X(e._popupRedirectResolver,e,`argument-error`),e._popupRedirectResolver)}var Kb=class extends ey{constructor(e){super(`custom`,`custom`),this.params=e}_getIdTokenResponse(e){return ly(e,this._buildIdpRequest())}_linkToIdToken(e,t){return ly(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return ly(e,this._buildIdpRequest())}_buildIdpRequest(e){let 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 qb(e){return zy(e.auth,new Kb(e),e.bypassAuthState)}function Jb(e){let{auth:t,user:n}=e;return X(n,t,`internal-error`),Ry(n,new Kb(e),e.bypassAuthState)}async function Yb(e){let{auth:t,user:n}=e;return X(n,t,`internal-error`),Iy(n,new Kb(e),e.bypassAuthState)}var Xb=class{constructor(e,t,n,r,i=!1){this.auth=e,this.resolver=n,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(e){this.reject(e)}})}async onAuthEvent(e){let{urlResponse:t,sessionId:n,postBody:r,tenantId:i,error:a,type:o}=e;if(a){this.reject(a);return}let s={auth:this.auth,requestUri:t,sessionId:n,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(o)(s))}catch(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case`signInViaPopup`:case`signInViaRedirect`:return qb;case`linkViaPopup`:case`linkViaRedirect`:return Yb;case`reauthViaPopup`:case`reauthViaRedirect`:return Jb;default:l_(this.auth,`internal-error`)}}resolve(e){g_(this.pendingPromise,`Pending promise was never set`),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){g_(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()}},Zb=new S_(2e3,1e4);async function Qb(e,t,n){if(y(e.app))return Promise.reject(u_(e,`operation-not-supported-in-this-environment`));let r=Av(e);return p_(e,t,Sy),new ex(r,`signInViaPopup`,t,Gb(r,n)).executeNotNull()}async function $b(e,t,n){let r=_(e);p_(r.auth,t,Sy);let i=Gb(r.auth,n);return new ex(r.auth,`linkViaPopup`,t,i,r).executeNotNull()}var ex=class e extends Xb{constructor(t,n,r,i,a){super(t,n,i,a),this.provider=r,this.authWindow=null,this.pollId=null,e.currentPopupAction&&e.currentPopupAction.cancel(),e.currentPopupAction=this}async executeNotNull(){let e=await this.execute();return X(e,this.auth,`internal-error`),e}async onExecution(){g_(this.filter.length===1,`Popup operations only handle one event`);let e=hb();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(u_(this.auth,`web-storage-unsupported`))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(u_(this.auth,`cancelled-popup-request`))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,e.currentPopupAction=null}pollUserCancellation(){let e=()=>{if(this.authWindow?.window?.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(u_(this.auth,`popup-closed-by-user`))},8e3);return}this.pollId=window.setTimeout(e,Zb.get())};e()}};ex.currentPopupAction=null;var tx=`pendingRedirect`,nx=new Map,rx=class extends Xb{constructor(e,t,n=!1){super(e,[`signInViaRedirect`,`linkViaRedirect`,`reauthViaRedirect`,`unknown`],t,void 0,n),this.eventId=null}async execute(){let e=nx.get(this.auth._key());if(!e){try{let t=await ix(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(t)}catch(t){e=()=>Promise.reject(t)}nx.set(this.auth._key(),e)}return this.bypassAuthState||nx.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type===`signInViaRedirect`)return super.onAuthEvent(e);if(e.type===`unknown`){this.resolve(null);return}if(e.eventId){let t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}};async function ix(e,t){let n=sx(t),r=ox(e);if(!await r._isAvailable())return!1;let i=await r._get(n)===`true`;return await r._remove(n),i}function ax(e,t){nx.set(e._key(),t)}function ox(e){return sv(e._redirectPersistence)}function sx(e){return uv(tx,e.config.apiKey,e.name)}async function cx(e,t,n=!1){if(y(e.app))return Promise.reject(f_(e));let r=Av(e),i=await new rx(r,Gb(r,t),n).execute();return i&&!n&&(delete i.user._redirectEventId,await r._persistUserIfCurrent(i.user),await r._setRedirectUser(null,t)),i}var lx=600*1e3,ux=class{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||!px(e)?t:(this.hasHandledPotentialRedirect=!0,t||=(this.queuedRedirectEvent=e,!0),t)}sendToConsumer(e,t){if(e.error&&!fx(e)){let n=e.error.code?.split(`auth/`)[1]||`internal-error`;t.onError(u_(this.auth,n))}else t.onAuthEvent(e)}isEventForConsumer(e,t){let n=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=lx&&this.cachedEventUids.clear(),this.cachedEventUids.has(dx(e))}saveEventToCache(e){this.cachedEventUids.add(dx(e)),this.lastProcessedEventTime=Date.now()}};function dx(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join(`-`)}function fx({type:e,error:t}){return e===`unknown`&&t?.code===`auth/no-auth-event`}function px(e){switch(e.type){case`signInViaRedirect`:case`linkViaRedirect`:case`reauthViaRedirect`:return!0;case`unknown`:return fx(e);default:return!1}}async function mx(e,t={}){return k_(e,`GET`,`/v1/projects`,t)}var hx=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,gx=/^https?/;async function _x(e){if(e.config.emulator)return;let{authorizedDomains:t}=await mx(e);for(let e of t)try{if(vx(e))return}catch{}l_(e,`unauthorized-domain`)}function vx(e){let t=__(),{protocol:n,hostname:r}=new URL(t);if(e.startsWith(`chrome-extension://`)){let i=new URL(e);return i.hostname===``&&r===``?n===`chrome-extension:`&&e.replace(`chrome-extension://`,``)===t.replace(`chrome-extension://`,``):n===`chrome-extension:`&&i.hostname===r}if(!gx.test(n))return!1;if(hx.test(e))return r===e;let i=e.replace(/\./g,`\\.`);return RegExp(`^(.+\\.`+i+`|`+i+`)$`,`i`).test(r)}var yx=new S_(3e4,6e4);function bx(){let e=_b().___jsl;if(e?.H){for(let 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 xx(e){return new Promise((t,n)=>{function r(){bx(),gapi.load(`gapi.iframes`,{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{bx(),n(u_(e,`network-request-failed`))},timeout:yx.get()})}if(_b().gapi?.iframes?.Iframe)t(gapi.iframes.getContext());else if(_b().gapi?.load)r();else{let t=Lv(`iframefcb`);return _b()[t]=()=>{gapi.load?r():n(u_(e,`network-request-failed`))},Pv(`${Iv()}?onload=${t}`).catch(e=>n(e))}}).catch(e=>{throw Sx=null,e})}var Sx=null;function Cx(e){return Sx||=xx(e),Sx}var wx=new S_(5e3,15e3),Tx=`__/auth/iframe`,Ex=`emulator/auth/iframe`,Dx={style:{position:`absolute`,top:`-100px`,width:`1px`,height:`1px`},"aria-hidden":`true`,tabindex:`-1`},Ox=new Map([[`identitytoolkit.googleapis.com`,`p`],[`staging-identitytoolkit.sandbox.googleapis.com`,`s`],[`test-identitytoolkit.sandbox.googleapis.com`,`t`]]);function kx(e){let t=e.config;X(t.authDomain,e,`auth-domain-config-required`);let n=t.emulator?C_(t,Ex):`https://${e.config.authDomain}/${Tx}`,r={apiKey:t.apiKey,appName:e.name,v:$t},i=Ox.get(e.config.apiHost);i&&(r.eid=i);let a=e._getFrameworks();return a.length&&(r.fw=a.join(`,`)),`${n}?${xe(r).slice(1)}`}async function Ax(e){let t=await Cx(e),n=_b().gapi;return X(n,e,`internal-error`),t.open({where:document.body,url:kx(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Dx,dontclear:!0},t=>new Promise(async(n,r)=>{await t.restyle({setHideOnLeave:!1});let i=u_(e,`network-request-failed`),a=_b().setTimeout(()=>{r(i)},wx.get());function o(){_b().clearTimeout(a),n(t)}t.ping(o).then(o,()=>{r(i)})}))}var jx={location:`yes`,resizable:`yes`,statusbar:`yes`,toolbar:`no`},Mx=500,Nx=600,Px=`_blank`,Fx=`http://localhost`,Ix=class{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}};function Lx(e,t,n,r=Mx,i=Nx){let a=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString(),s=``,c={...jx,width:r.toString(),height:i.toString(),top:a,left:o},l=re().toLowerCase();n&&(s=hv(l)?Px:n),pv(l)&&(t||=Fx,c.scrollbars=`yes`);let u=Object.entries(c).reduce((e,[t,n])=>`${e}${t}=${n},`,``);if(xv(l)&&s!==`_self`)return Rx(t||``,s),new Ix(null);let d=window.open(t||``,s,u);X(d,e,`popup-blocked`);try{d.focus()}catch{}return new Ix(d)}function Rx(e,t){let n=document.createElement(`a`);n.href=e,n.target=t;let r=document.createEvent(`MouseEvent`);r.initMouseEvent(`click`,!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}var zx=`__/auth/handler`,Bx=`emulator/auth/handler`,Vx=`fac`;async function Hx(e,t,n,r,i,a){X(e.config.authDomain,e,`auth-domain-config-required`),X(e.config.apiKey,e,`invalid-api-key`);let o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:$t,eventId:i};if(t instanceof Sy){t.setDefaultLanguage(e.languageCode),o.providerId=t.providerId||``,ve(t.getCustomParameters())||(o.customParameters=JSON.stringify(t.getCustomParameters()));for(let[e,t]of Object.entries(a||{}))o[e]=t}if(t instanceof Cy){let e=t.getScopes().filter(e=>e!==``);e.length>0&&(o.scopes=e.join(`,`))}e.tenantId&&(o.tid=e.tenantId);let s=o;for(let e of Object.keys(s))s[e]===void 0&&delete s[e];let c=await e._getAppCheckToken(),l=c?`#${Vx}=${encodeURIComponent(c)}`:``;return`${Ux(e)}?${xe(s).slice(1)}${l}`}function Ux({config:e}){return e.emulator?C_(e,Bx):`https://${e.authDomain}/${zx}`}var Wx=`webStorageSupport`,Gx=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=fb,this._completeRedirectFn=cx,this._overrideRedirectResult=ax}async _openPopup(e,t,n,r){return g_(this.eventManagers[e._key()]?.manager,`_initialize() not called before _openPopup()`),Lx(e,await Hx(e,t,n,__(),r),hb())}async _openRedirect(e,t,n,r){return await this._originValidation(e),vb(await Hx(e,t,n,__(),r)),new Promise(()=>{})}_initialize(e){let t=e._key();if(this.eventManagers[t]){let{manager:e,promise:n}=this.eventManagers[t];return e?Promise.resolve(e):(g_(n,`If manager is not set, promise should be`),n)}let n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n.catch(()=>{delete this.eventManagers[t]}),n}async initAndGetManager(e){let t=await Ax(e),n=new ux(e);return t.register(`authEvent`,t=>(X(t?.authEvent,e,`invalid-auth-event`),{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(Wx,{type:Wx},n=>{let r=n?.[0]?.[Wx];r!==void 0&&t(!!r),l_(e,`internal-error`)},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){let t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=_x(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return Cv()||mv()||bv()}},Kx=class{constructor(e){this.factorId=e}_process(e,t,n){switch(t.type){case`enroll`:return this._finalizeEnroll(e,t.credential,n);case`signin`:return this._finalizeSignIn(e,t.credential);default:return h_(`unexpected MultiFactorSessionType`)}}},qx=class e extends Kx{constructor(e){super(`phone`),this.credential=e}static _fromCredential(t){return new e(t)}_finalizeEnroll(e,t,n){return Qy(e,{idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()})}_finalizeSignIn(e,t){return zb(e,{mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()})}},Jx=class{constructor(){}static assertion(e){return qx._fromCredential(e)}};Jx.FACTOR_ID=`phone`;var Yx=class{static assertionForEnrollment(e,t){return Xx._fromSecret(e,t)}static assertionForSignIn(e,t){return Xx._fromEnrollmentId(e,t)}static async generateSecret(e){let t=e;X(t.user?.auth!==void 0,`internal-error`);let n=await $y(t.user.auth,{idToken:t.credential,totpEnrollmentInfo:{}});return Zx._fromStartTotpMfaEnrollmentResponse(n,t.user.auth)}};Yx.FACTOR_ID=`totp`;var Xx=class e extends Kx{constructor(e,t,n){super(`totp`),this.otp=e,this.enrollmentId=t,this.secret=n}static _fromSecret(t,n){return new e(n,void 0,t)}static _fromEnrollmentId(t,n){return new e(n,t)}async _finalizeEnroll(e,t,n){return X(this.secret!==void 0,e,`argument-error`),eb(e,{idToken:t,displayName:n,totpVerificationInfo:this.secret._makeTotpVerificationInfo(this.otp)})}async _finalizeSignIn(e,t){X(this.enrollmentId!==void 0&&this.otp!==void 0,e,`argument-error`);let n={verificationCode:this.otp};return Bb(e,{mfaPendingCredential:t,mfaEnrollmentId:this.enrollmentId,totpVerificationInfo:n})}},Zx=class e{constructor(e,t,n,r,i,a,o){this.sessionInfo=a,this.auth=o,this.secretKey=e,this.hashingAlgorithm=t,this.codeLength=n,this.codeIntervalSeconds=r,this.enrollmentCompletionDeadline=i}static _fromStartTotpMfaEnrollmentResponse(t,n){return new e(t.totpSessionInfo.sharedSecretKey,t.totpSessionInfo.hashingAlgorithm,t.totpSessionInfo.verificationCodeLength,t.totpSessionInfo.periodSec,new Date(t.totpSessionInfo.finalizeEnrollmentTime).toUTCString(),t.totpSessionInfo.sessionInfo,n)}_makeTotpVerificationInfo(e){return{sessionInfo:this.sessionInfo,verificationCode:e}}generateQrCodeUrl(e,t){let n=!1;return(Qx(e)||Qx(t))&&(n=!0),n&&(Qx(e)&&(e=this.auth.currentUser?.email||`unknownuser`),Qx(t)&&(t=this.auth.name)),`otpauth://totp/${t}:${e}?secret=${this.secretKey}&issuer=${t}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`}};function Qx(e){return e===void 0||e?.length===0}var $x=`@firebase/auth`,eS=`1.13.3`,tS=class{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){return this.assertAuthConfigured(),this.auth.currentUser?.uid||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;let t=this.auth.onIdTokenChanged(t=>{e(t?.stsTokenManager.accessToken||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();let t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){X(this.auth._initializationPromise,`dependent-sdk-initialized-before-auth`)}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}};function nS(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}}function rS(e){Yt(new Ae(`auth`,(t,{options:n})=>{let r=t.getProvider(`app`).getImmediate(),i=t.getProvider(`heartbeat`),a=t.getProvider(`app-check-internal`),{apiKey:o,authDomain:s}=r.options;X(o&&!o.includes(`:`),`invalid-api-key`,{appName:r.name});let c=new kv(r,i,a,{apiKey:o,authDomain:s,clientPlatform:e,apiHost:`identitytoolkit.googleapis.com`,tokenApiHost:`securetoken.googleapis.com`,apiScheme:`https`,sdkClientVersion:wv(e)});return Jv(c,n),c},`PUBLIC`).setInstantiationMode(`EXPLICIT`).setInstanceCreatedCallback((e,t,n)=>{e.getProvider(`auth-internal`).initialize()})),Yt(new Ae(`auth-internal`,e=>(e=>new tS(e))(Av(e.getProvider(`auth`).getImmediate())),`PRIVATE`).setInstantiationMode(`EXPLICIT`)),nn($x,eS,nS(e)),nn($x,eS,`esm2020`)}var iS=ee(`authIdTokenMaxAge`)||300,aS=null,oS=e=>async t=>{let n=t&&await t.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>iS)return;let i=n?.token;aS!==i&&(aS=i,await fetch(e,{method:i?`POST`:`DELETE`,headers:i?{Authorization:`Bearer ${i}`}:{}}))};function sS(e=tn()){let t=Xt(e,`auth`);if(t.isInitialized())return t.getImmediate();let n=qv(e,{popupRedirectResolver:Gx,persistence:[Lb,ob,fb]}),r=ee(`authTokenSyncURL`);if(r&&typeof isSecureContext==`boolean`&&isSecureContext){let e=new URL(r,location.origin);if(location.origin===e.origin){let t=oS(e.toString());Xy(n,t,()=>t(n.currentUser)),Yy(n,e=>t(e))}}let i=m(`auth`);return i&&Yv(n,`http://${i}`),n}function cS(){return document.getElementsByTagName(`head`)?.[0]??document}Nv({loadJS(e){return new Promise((t,n)=>{let r=document.createElement(`script`);r.setAttribute(`src`,e),r.onload=t,r.onerror=e=>{let t=u_(`internal-error`);t.customData=e,n(t)},r.type=`text/javascript`,r.charset=`UTF-8`,cS().appendChild(r)})},gapiScript:`https://apis.google.com/js/api.js`,recaptchaV2Script:`https://www.google.com/recaptcha/api.js`,recaptchaEnterpriseScript:`https://www.google.com/recaptcha/enterprise.js?render=`}),rS(`Browser`);var lS=`firebasestorage.googleapis.com`,uS=`storageBucket`,dS=120*1e3,fS=600*1e3,pS=1e3,Z=class e extends me{constructor(t,n,r=0){super(mS(t),`Firebase Storage: ${n} (${mS(t)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,e.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return mS(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}\n${this.customData.serverResponse}`:this.message=this._baseMessage}},Q;(function(e){e.UNKNOWN=`unknown`,e.OBJECT_NOT_FOUND=`object-not-found`,e.BUCKET_NOT_FOUND=`bucket-not-found`,e.PROJECT_NOT_FOUND=`project-not-found`,e.QUOTA_EXCEEDED=`quota-exceeded`,e.UNAUTHENTICATED=`unauthenticated`,e.UNAUTHORIZED=`unauthorized`,e.UNAUTHORIZED_APP=`unauthorized-app`,e.RETRY_LIMIT_EXCEEDED=`retry-limit-exceeded`,e.INVALID_CHECKSUM=`invalid-checksum`,e.CANCELED=`canceled`,e.INVALID_EVENT_NAME=`invalid-event-name`,e.INVALID_URL=`invalid-url`,e.INVALID_DEFAULT_BUCKET=`invalid-default-bucket`,e.NO_DEFAULT_BUCKET=`no-default-bucket`,e.CANNOT_SLICE_BLOB=`cannot-slice-blob`,e.SERVER_FILE_WRONG_SIZE=`server-file-wrong-size`,e.NO_DOWNLOAD_URL=`no-download-url`,e.INVALID_ARGUMENT=`invalid-argument`,e.INVALID_ARGUMENT_COUNT=`invalid-argument-count`,e.APP_DELETED=`app-deleted`,e.INVALID_ROOT_OPERATION=`invalid-root-operation`,e.INVALID_FORMAT=`invalid-format`,e.INTERNAL_ERROR=`internal-error`,e.UNSUPPORTED_ENVIRONMENT=`unsupported-environment`})(Q||={});function mS(e){return`storage/`+e}function hS(){return new Z(Q.UNKNOWN,`An unknown error occurred, please check the error payload for server response.`)}function gS(e){return new Z(Q.OBJECT_NOT_FOUND,`Object '`+e+`' does not exist.`)}function _S(e){return new Z(Q.QUOTA_EXCEEDED,`Quota for bucket '`+e+`' exceeded, please view quota on https://firebase.google.com/pricing/.`)}function vS(){return new Z(Q.UNAUTHENTICATED,`User is not authenticated, please authenticate using Firebase Authentication and try again.`)}function yS(){return new Z(Q.UNAUTHORIZED_APP,`This app does not have permission to access Firebase Storage on this project.`)}function bS(e){return new Z(Q.UNAUTHORIZED,`User does not have permission to access '`+e+`'.`)}function xS(){return new Z(Q.RETRY_LIMIT_EXCEEDED,`Max retry time for operation exceeded, please try again.`)}function SS(){return new Z(Q.CANCELED,`User canceled the upload/download.`)}function CS(e){return new Z(Q.INVALID_URL,`Invalid URL '`+e+`'.`)}function wS(e){return new Z(Q.INVALID_DEFAULT_BUCKET,`Invalid default bucket '`+e+`'.`)}function TS(){return new Z(Q.NO_DEFAULT_BUCKET,`No default bucket found. Did you set the 'storageBucket' property when initializing the app?`)}function ES(){return new Z(Q.CANNOT_SLICE_BLOB,`Cannot slice blob for upload. Please retry the upload.`)}function DS(){return new Z(Q.SERVER_FILE_WRONG_SIZE,`Server recorded incorrect upload file size, please retry the upload.`)}function OS(){return new Z(Q.NO_DOWNLOAD_URL,`The given file does not have any download URLs.`)}function kS(e){return new Z(Q.UNSUPPORTED_ENVIRONMENT,`${e} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function AS(e){return new Z(Q.INVALID_ARGUMENT,e)}function jS(){return new Z(Q.APP_DELETED,`The Firebase app was deleted.`)}function MS(e){return new Z(Q.INVALID_ROOT_OPERATION,`The operation '`+e+`' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').`)}function NS(e,t){return new Z(Q.INVALID_FORMAT,`String does not match format '`+e+`': `+t)}function PS(e){throw new Z(Q.INTERNAL_ERROR,`Internal error: `+e)}var FS=class e{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){let e=encodeURIComponent;return`/b/`+e(this.bucket)+`/o/`+e(this.path)}bucketOnlyServerUrl(){return`/b/`+encodeURIComponent(this.bucket)+`/o`}static makeFromBucketSpec(t,n){let r;try{r=e.makeFromUrl(t,n)}catch{return new e(t,``)}if(r.path===``)return r;throw wS(t)}static makeFromUrl(t,n){let r=null,i=`([A-Za-z0-9.\\-_]+)`;function a(e){e.path.charAt(e.path.length-1)===`/`&&(e.path_=e.path_.slice(0,-1))}let o=RegExp(`^gs://([A-Za-z0-9.\\-_]+)(/(.*))?$`,`i`),s={bucket:1,path:3};function c(e){e.path_=decodeURIComponent(e.path)}let l=n.replace(/[.]/g,`\\.`),u=RegExp(`^https?://${l}/v[A-Za-z0-9_]+/b/${i}/o(/([^?#]*).*)?\$`,`i`),d={bucket:1,path:3},f=RegExp(`^https?://${n===lS?`(?:storage.googleapis.com|storage.cloud.google.com)`:n}/${i}/([^?#]*)`,`i`),p=[{regex:o,indices:s,postModify:a},{regex:u,indices:d,postModify:c},{regex:f,indices:{bucket:1,path:2},postModify:c}];for(let n=0;n<p.length;n++){let i=p[n],a=i.regex.exec(t);if(a){let t=a[i.indices.bucket],n=a[i.indices.path];n||=``,r=new e(t,n),i.postModify(r);break}}if(r==null)throw CS(t);return r}},IS=class{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}};function LS(e,t,n){let r=1,i=null,a=null,o=!1,s=0;function c(){return s===2}let l=!1;function u(...e){l||(l=!0,t.apply(null,e))}function d(t){i=setTimeout(()=>{i=null,e(p,c())},t)}function f(){a&&clearTimeout(a)}function p(e,...t){if(l){f();return}if(e){f(),u.call(null,e,...t);return}if(c()||o){f(),u.call(null,e,...t);return}r<64&&(r*=2);let n;s===1?(s=2,n=0):n=(r+Math.random())*1e3,d(n)}let m=!1;function h(e){m||(m=!0,f(),!l&&(i===null?e||(s=1):(e||(s=2),clearTimeout(i),d(0))))}return d(0),a=setTimeout(()=>{o=!0,h(!0)},n),h}function RS(e){e(!1)}function zS(e){return e!==void 0}function BS(e){return typeof e==`function`}function VS(e){return typeof e==`object`&&!Array.isArray(e)}function HS(e){return typeof e==`string`||e instanceof String}function US(e){return WS()&&e instanceof Blob}function WS(){return typeof Blob<`u`}function GS(e,t,n,r){if(r<t)throw AS(`Invalid value for '${e}'. Expected ${t} or greater.`);if(r>n)throw AS(`Invalid value for '${e}'. Expected ${n} or less.`)}function KS(e,t,n){let r=t;return n??(r=`https://${t}`),`${n}://${r}/v0${e}`}function qS(e){let t=encodeURIComponent,n=`?`;for(let r in e)if(e.hasOwnProperty(r)){let i=t(r)+`=`+t(e[r]);n=n+i+`&`}return n=n.slice(0,-1),n}var JS;(function(e){e[e.NO_ERROR=0]=`NO_ERROR`,e[e.NETWORK_ERROR=1]=`NETWORK_ERROR`,e[e.ABORT=2]=`ABORT`})(JS||={});function YS(e,t){let n=e>=500&&e<600,r=[408,429].indexOf(e)!==-1,i=t.indexOf(e)!==-1;return n||r||i}var XS=class{constructor(e,t,n,r,i,a,o,s,c,l,u,d=!0,f=!1){this.url_=e,this.method_=t,this.headers_=n,this.body_=r,this.successCodes_=i,this.additionalRetryCodes_=a,this.callback_=o,this.errorCallback_=s,this.timeout_=c,this.progressCallback_=l,this.connectionFactory_=u,this.retry=d,this.isUsingEmulator=f,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((e,t)=>{this.resolve_=e,this.reject_=t,this.start_()})}start_(){let e=(e,t)=>{if(t){e(!1,new ZS(!1,null,!0));return}let n=this.connectionFactory_();this.pendingConnection_=n;let r=e=>{let t=e.loaded,n=e.lengthComputable?e.total:-1;this.progressCallback_!==null&&this.progressCallback_(t,n)};this.progressCallback_!==null&&n.addUploadProgressListener(r),n.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&n.removeUploadProgressListener(r),this.pendingConnection_=null;let t=n.getErrorCode()===JS.NO_ERROR,i=n.getStatus();if(!t||YS(i,this.additionalRetryCodes_)&&this.retry){e(!1,new ZS(!1,null,n.getErrorCode()===JS.ABORT));return}e(!0,new ZS(this.successCodes_.indexOf(i)!==-1,n))})},t=(e,t)=>{let n=this.resolve_,r=this.reject_,i=t.connection;if(t.wasSuccessCode)try{let e=this.callback_(i,i.getResponse());zS(e)?n(e):n()}catch(e){r(e)}else if(i!==null){let e=hS();e.serverResponse=i.getErrorText(),this.errorCallback_?r(this.errorCallback_(i,e)):r(e)}else t.canceled?r(this.appDelete_?jS():SS()):r(xS())};this.canceled_?t(!1,new ZS(!1,null,!0)):this.backoffId_=LS(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&RS(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}},ZS=class{constructor(e,t,n){this.wasSuccessCode=e,this.connection=t,this.canceled=!!n}};function QS(e,t){t!==null&&t.length>0&&(e.Authorization=`Firebase `+t)}function $S(e,t){e[`X-Firebase-Storage-Version`]=`webjs/`+(t??`AppManager`)}function eC(e,t){t&&(e[`X-Firebase-GMPID`]=t)}function tC(e,t){t!==null&&(e[`X-Firebase-AppCheck`]=t)}function nC(e,t,n,r,i,a,o=!0,s=!1){let c=qS(e.urlParams),l=e.url+c,u=Object.assign({},e.headers);return eC(u,t),QS(u,n),$S(u,a),tC(u,r),new XS(l,e.method,u,e.body,e.successCodes,e.additionalRetryCodes,e.handler,e.errorHandler,e.timeout,e.progressCallback,i,o,s)}function rC(){if(typeof BlobBuilder<`u`)return BlobBuilder;if(typeof WebKitBlobBuilder<`u`)return WebKitBlobBuilder}function iC(...e){let t=rC();if(t!==void 0){let n=new t;for(let t=0;t<e.length;t++)n.append(e[t]);return n.getBlob()}else if(WS())return new Blob(e);else throw new Z(Q.UNSUPPORTED_ENVIRONMENT,`This browser doesn't seem to support creating Blobs`)}function aC(e,t,n){return e.webkitSlice?e.webkitSlice(t,n):e.mozSlice?e.mozSlice(t,n):e.slice?e.slice(t,n):null}function oC(e){if(typeof atob>`u`)throw kS(`base-64`);return atob(e)}var sC={RAW:`raw`,BASE64:`base64`,BASE64URL:`base64url`,DATA_URL:`data_url`},cC=class{constructor(e,t){this.data=e,this.contentType=t||null}};function lC(e,t){switch(e){case sC.RAW:return new cC(uC(t));case sC.BASE64:case sC.BASE64URL:return new cC(fC(e,t));case sC.DATA_URL:return new cC(mC(t),hC(t))}throw hS()}function uC(e){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<=127)t.push(r);else if(r<=2047)t.push(192|r>>6,128|r&63);else if((r&64512)==55296)if(!(n<e.length-1&&(e.charCodeAt(n+1)&64512)==56320))t.push(239,191,189);else{let i=r,a=e.charCodeAt(++n);r=65536|(i&1023)<<10|a&1023,t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}else(r&64512)==56320?t.push(239,191,189):t.push(224|r>>12,128|r>>6&63,128|r&63)}return new Uint8Array(t)}function dC(e){let t;try{t=decodeURIComponent(e)}catch{throw NS(sC.DATA_URL,`Malformed data URL.`)}return uC(t)}function fC(e,t){switch(e){case sC.BASE64:{let n=t.indexOf(`-`)!==-1,r=t.indexOf(`_`)!==-1;if(n||r)throw NS(e,`Invalid character '`+(n?`-`:`_`)+`' found: is it base64url encoded?`);break}case sC.BASE64URL:{let n=t.indexOf(`+`)!==-1,r=t.indexOf(`/`)!==-1;if(n||r)throw NS(e,`Invalid character '`+(n?`+`:`/`)+`' found: is it base64 encoded?`);t=t.replace(/-/g,`+`).replace(/_/g,`/`);break}}let n;try{n=oC(t)}catch(t){throw t.message.includes(`polyfill`)?t:NS(e,`Invalid character found`)}let r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}var pC=class{constructor(e){this.base64=!1,this.contentType=null;let t=e.match(/^data:([^,]+)?,/);if(t===null)throw NS(sC.DATA_URL,`Must be formatted 'data:[<mediatype>][;base64],<data>`);let n=t[1]||null;n!=null&&(this.base64=gC(n,`;base64`),this.contentType=this.base64?n.substring(0,n.length-7):n),this.rest=e.substring(e.indexOf(`,`)+1)}};function mC(e){let t=new pC(e);return t.base64?fC(sC.BASE64,t.rest):dC(t.rest)}function hC(e){return new pC(e).contentType}function gC(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}var _C=class e{constructor(e,t){let n=0,r=``;US(e)?(this.data_=e,n=e.size,r=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),n=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),n=e.length),this.size_=n,this.type_=r}size(){return this.size_}type(){return this.type_}slice(t,n){if(US(this.data_)){let r=this.data_,i=aC(r,t,n);return i===null?null:new e(i)}else return new e(new Uint8Array(this.data_.buffer,t,n-t),!0)}static getBlob(...t){if(WS()){let n=t.map(t=>t instanceof e?t.data_:t);return new e(iC.apply(null,n))}else{let n=t.map(e=>HS(e)?lC(sC.RAW,e).data:e.data_),r=0;n.forEach(e=>{r+=e.byteLength});let i=new Uint8Array(r),a=0;return n.forEach(e=>{for(let t=0;t<e.length;t++)i[a++]=e[t]}),new e(i,!0)}}uploadData(){return this.data_}};function vC(e){let t;try{t=JSON.parse(e)}catch{return null}return VS(t)?t:null}function yC(e){if(e.length===0)return null;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function bC(e,t){let n=t.split(`/`).filter(e=>e.length>0).join(`/`);return e.length===0?n:e+`/`+n}function xC(e){let t=e.lastIndexOf(`/`,e.length-2);return t===-1?e:e.slice(t+1)}function SC(e,t){return t}var CC=class{constructor(e,t,n,r){this.server=e,this.local=t||e,this.writable=!!n,this.xform=r||SC}},wC=null;function TC(e){return!HS(e)||e.length<2?e:xC(e)}function EC(){if(wC)return wC;let e=[];e.push(new CC(`bucket`)),e.push(new CC(`generation`)),e.push(new CC(`metageneration`)),e.push(new CC(`name`,`fullPath`,!0));function t(e,t){return TC(t)}let n=new CC(`name`);n.xform=t,e.push(n);function r(e,t){return t===void 0?t:Number(t)}let i=new CC(`size`);return i.xform=r,e.push(i),e.push(new CC(`timeCreated`)),e.push(new CC(`updated`)),e.push(new CC(`md5Hash`,null,!0)),e.push(new CC(`cacheControl`,null,!0)),e.push(new CC(`contentDisposition`,null,!0)),e.push(new CC(`contentEncoding`,null,!0)),e.push(new CC(`contentLanguage`,null,!0)),e.push(new CC(`contentType`,null,!0)),e.push(new CC(`metadata`,`customMetadata`,!0)),wC=e,wC}function DC(e,t){function n(){let n=e.bucket,r=e.fullPath,i=new FS(n,r);return t._makeStorageReference(i)}Object.defineProperty(e,"ref",{get:n})}function OC(e,t,n){let r={};r.type=`file`;let i=n.length;for(let e=0;e<i;e++){let i=n[e];r[i.local]=i.xform(r,t[i.server])}return DC(r,e),r}function kC(e,t,n){let r=vC(t);return r===null?null:OC(e,r,n)}function AC(e,t,n,r){let i=vC(t);if(i===null||!HS(i.downloadTokens))return null;let a=i.downloadTokens;if(a.length===0)return null;let o=encodeURIComponent;return a.split(`,`).map(t=>{let i=e.bucket,a=e.fullPath;return KS(`/b/`+o(i)+`/o/`+o(a),n,r)+qS({alt:`media`,token:t})})[0]}function jC(e,t){let n={},r=t.length;for(let i=0;i<r;i++){let r=t[i];r.writable&&(n[r.server]=e[r.local])}return JSON.stringify(n)}var MC=class{constructor(e,t,n,r){this.url=e,this.method=t,this.handler=n,this.timeout=r,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}};function NC(e){if(!e)throw hS()}function PC(e,t){function n(n,r){let i=kC(e,r,t);return NC(i!==null),i}return n}function FC(e,t){function n(n,r){let i=kC(e,r,t);return NC(i!==null),AC(i,r,e.host,e._protocol)}return n}function IC(e){function t(t,n){let r;return r=t.getStatus()===401?t.getErrorText().includes(`Firebase App Check token is invalid`)?yS():vS():t.getStatus()===402?_S(e.bucket):t.getStatus()===403?bS(e.path):n,r.status=t.getStatus(),r.serverResponse=n.serverResponse,r}return t}function LC(e){let t=IC(e);function n(n,r){let i=t(n,r);return n.getStatus()===404&&(i=gS(e.path)),i.serverResponse=r.serverResponse,i}return n}function RC(e,t,n){let r=KS(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime,a=new MC(r,`GET`,PC(e,n),i);return a.errorHandler=LC(t),a}function zC(e,t,n){let r=KS(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime,a=new MC(r,`GET`,FC(e,n),i);return a.errorHandler=LC(t),a}function BC(e,t){let n=KS(t.fullServerUrl(),e.host,e._protocol),r=e.maxOperationRetryTime;function i(e,t){}let a=new MC(n,`DELETE`,i,r);return a.successCodes=[200,204],a.errorHandler=LC(t),a}function VC(e,t){return e&&e.contentType||t&&t.type()||`application/octet-stream`}function HC(e,t,n){let r=Object.assign({},n);return r.fullPath=e.path,r.size=t.size(),r.contentType||=VC(null,t),r}function UC(e,t,n,r,i){let a=t.bucketOnlyServerUrl(),o={"X-Goog-Upload-Protocol":`multipart`};function s(){let e=``;for(let t=0;t<2;t++)e+=Math.random().toString().slice(2);return e}let c=s();o[`Content-Type`]=`multipart/related; boundary=`+c;let l=HC(t,r,i),u=jC(l,n),d=`--`+c+`\r
|
|
44
35
|
Content-Type: application/json; charset=utf-8\r
|
|
45
36
|
\r
|
|
46
|
-
`+
|
|
47
|
-
--`+
|
|
48
|
-
Content-Type: `+
|
|
37
|
+
`+u+`\r
|
|
38
|
+
--`+c+`\r
|
|
39
|
+
Content-Type: `+l.contentType+`\r
|
|
49
40
|
\r
|
|
50
|
-
`,
|
|
51
|
-
--`+l+"--",R=Gt.getBlob(m,r,_);if(R===null)throw Vd();const S={name:d.fullPath},N=Xn(i,n.host,n._protocol),k="POST",U=n.maxUploadRetryTime,$=new _n(N,k,Oa(n,t),U);return $.urlParams=S,$.headers=a,$.body=R.uploadData(),$.errorHandler=Wr(e),$}class Ai{constructor(e,t,r,s){this.current=e,this.total=t,this.finalized=!!r,this.metadata=s||null}}function La(n,e){let t=null;try{t=n.getResponseHeader("X-Goog-Upload-Status")}catch{Pt(!1)}return Pt(!!t&&(e||["active"]).indexOf(t)!==-1),t}function cv(n,e,t,r,s){const i=e.bucketOnlyServerUrl(),a=Kd(e,r,s),c={name:a.fullPath},l=Xn(i,n.host,n._protocol),d="POST",f={"X-Goog-Upload-Protocol":"resumable","X-Goog-Upload-Command":"start","X-Goog-Upload-Header-Content-Length":`${r.size()}`,"X-Goog-Upload-Header-Content-Type":a.contentType,"Content-Type":"application/json; charset=utf-8"},m=Gd(a,t),_=n.maxUploadRetryTime;function R(N){La(N);let k;try{k=N.getResponseHeader("X-Goog-Upload-URL")}catch{Pt(!1)}return Pt(wi(k)),k}const S=new _n(l,d,R,_);return S.urlParams=c,S.headers=f,S.body=m,S.errorHandler=Wr(e),S}function uv(n,e,t,r){const s={"X-Goog-Upload-Command":"query"};function i(d){const f=La(d,["active","final"]);let m=null;try{m=d.getResponseHeader("X-Goog-Upload-Size-Received")}catch{Pt(!1)}m||Pt(!1);const _=Number(m);return Pt(!isNaN(_)),new Ai(_,r.size(),f==="final")}const a="POST",c=n.maxUploadRetryTime,l=new _n(t,a,i,c);return l.headers=s,l.errorHandler=Wr(e),l}const Qd=256*1024;function lv(n,e,t,r,s,i,a,c){const l=new Ai(0,0);if(a?(l.current=a.current,l.total=a.total):(l.current=0,l.total=r.size()),r.size()!==l.total)throw AI();const d=l.total-l.current;let f=d;s>0&&(f=Math.min(f,s));const m=l.current,_=m+f;let R="";f===0?R="finalize":d===f?R="upload, finalize":R="upload";const S={"X-Goog-Upload-Command":R,"X-Goog-Upload-Offset":`${l.current}`},N=r.slice(m,_);if(N===null)throw Vd();function k(Q,_e){const re=La(Q,["active","final"]),w=l.current+f,g=r.size();let E;return re==="final"?E=Oa(e,i)(Q,_e):E=null,new Ai(w,g,re==="final",E)}const U="POST",$=e.maxUploadRetryTime,j=new _n(t,U,k,$);return j.headers=S,j.body=N.uploadData(),j.progressCallback=c||null,j.errorHandler=Wr(n),j}const Ve={RUNNING:"running",PAUSED:"paused",SUCCESS:"success",CANCELED:"canceled",ERROR:"error"};function Ma(n){switch(n){case"running":case"pausing":case"canceling":return Ve.RUNNING;case"paused":return Ve.PAUSED;case"success":return Ve.SUCCESS;case"canceled":return Ve.CANCELED;case"error":return Ve.ERROR;default:return Ve.ERROR}}class hv{constructor(e,t,r){if(DI(e)||t!=null||r!=null)this.next=e,this.error=t??void 0,this.complete=r??void 0;else{const i=e;this.next=i.next,this.error=i.error,this.complete=i.complete}}}function Zn(n){return(...e)=>{Promise.resolve().then(()=>n(...e))}}class dv{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=gn.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener("abort",()=>{this.errorCode_=gn.ABORT,e()}),this.xhr_.addEventListener("error",()=>{this.errorCode_=gn.NETWORK_ERROR,e()}),this.xhr_.addEventListener("load",()=>{e()})})}send(e,t,r,s,i){if(this.sent_)throw zr("cannot .send() more than once");if(tt(e)&&r&&(this.xhr_.withCredentials=!0),this.sent_=!0,this.xhr_.open(t,e,!0),i!==void 0)for(const a in i)i.hasOwnProperty(a)&&this.xhr_.setRequestHeader(a,i[a].toString());return s!==void 0?this.xhr_.send(s):this.xhr_.send(),this.sendPromise_}getErrorCode(){if(!this.sent_)throw zr("cannot .getErrorCode() before sending");return this.errorCode_}getStatus(){if(!this.sent_)throw zr("cannot .getStatus() before sending");try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw zr("cannot .getResponse() before sending");return this.xhr_.response}getErrorText(){if(!this.sent_)throw zr("cannot .getErrorText() before sending");return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener("progress",e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener("progress",e)}}class fv extends dv{initXhr(){this.xhr_.responseType="text"}}function yn(){return new fv}class pv{isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}constructor(e,t,r=null){this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=e,this._blob=t,this._metadata=r,this._mappings=Wd(),this._resumable=this._shouldDoResumable(this._blob),this._state="running",this._errorHandler=s=>{if(this._request=void 0,this._chunkMultiplier=1,s._codeEquals(te.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{const i=this.isExponentialBackoffExpired();if(Fd(s.status,[]))if(i)s=Dd();else{this.sleepTime=Math.max(this.sleepTime*2,mI),this._needToFetchStatus=!0,this.completeTransitions_();return}this._error=s,this._transition("error")}},this._metadataErrorHandler=s=>{this._request=void 0,s._codeEquals(te.CANCELED)?this.completeTransitions_():(this._error=s,this._transition("error"))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((s,i)=>{this._resolve=s,this._reject=i,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){const e=this._transferred;return t=>this._updateProgress(e+t)}_shouldDoResumable(e){return e.size()>256*1024}_start(){this._state==="running"&&this._request===void 0&&(this._resumable?this._uploadUrl===void 0?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(e){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([t,r])=>{switch(this._state){case"running":e(t,r);break;case"canceling":this._transition("canceled");break;case"pausing":this._transition("paused");break}})}_createResumable(){this._resolveToken((e,t)=>{const r=cv(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),s=this._ref.storage._makeRequest(r,yn,e,t);this._request=s,s.getPromise().then(i=>{this._request=void 0,this._uploadUrl=i,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){const e=this._uploadUrl;this._resolveToken((t,r)=>{const s=uv(this._ref.storage,this._ref._location,e,this._blob),i=this._ref.storage._makeRequest(s,yn,t,r);this._request=i,i.getPromise().then(a=>{a=a,this._request=void 0,this._updateProgress(a.current),this._needToFetchStatus=!1,a.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){const e=Qd*this._chunkMultiplier,t=new Ai(this._transferred,this._blob.size()),r=this._uploadUrl;this._resolveToken((s,i)=>{let a;try{a=lv(this._ref._location,this._ref.storage,r,this._blob,e,this._mappings,t,this._makeProgressCallback())}catch(l){this._error=l,this._transition("error");return}const c=this._ref.storage._makeRequest(a,yn,s,i,!1);this._request=c,c.getPromise().then(l=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(l.current),l.finalized?(this._metadata=l.metadata,this._transition("success")):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){Qd*this._chunkMultiplier*2<32*1024*1024&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{const r=rv(this._ref.storage,this._ref._location,this._mappings),s=this._ref.storage._makeRequest(r,yn,e,t);this._request=s,s.getPromise().then(i=>{this._request=void 0,this._metadata=i,this._transition("success")},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((e,t)=>{const r=av(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),s=this._ref.storage._makeRequest(r,yn,e,t);this._request=s,s.getPromise().then(i=>{this._request=void 0,this._metadata=i,this._updateProgress(this._blob.size()),this._transition("success")},this._errorHandler)})}_updateProgress(e){const t=this._transferred;this._transferred=e,this._transferred!==t&&this._notifyObservers()}_transition(e){if(this._state!==e)switch(e){case"canceling":case"pausing":this._state=e,this._request!==void 0?this._request.cancel():this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_());break;case"running":const t=this._state==="paused";this._state=e,t&&(this._notifyObservers(),this._start());break;case"paused":this._state=e,this._notifyObservers();break;case"canceled":this._error=Od(),this._state=e,this._notifyObservers();break;case"error":this._state=e,this._notifyObservers();break;case"success":this._state=e,this._notifyObservers();break}}completeTransitions_(){switch(this._state){case"pausing":this._transition("paused");break;case"canceling":this._transition("canceled");break;case"running":this._start();break}}get snapshot(){const e=Ma(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,t,r,s){const i=new hv(t||void 0,r||void 0,s||void 0);return this._addObserver(i),()=>{this._removeObserver(i)}}then(e,t){return this._promise.then(e,t)}catch(e){return this.then(null,e)}_addObserver(e){this._observers.push(e),this._notifyObserver(e)}_removeObserver(e){const t=this._observers.indexOf(e);t!==-1&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise(),this._observers.slice().forEach(t=>{this._notifyObserver(t)})}_finishPromise(){if(this._resolve!==void 0){let e=!0;switch(Ma(this._state)){case Ve.SUCCESS:Zn(this._resolve.bind(null,this.snapshot))();break;case Ve.CANCELED:case Ve.ERROR:const t=this._reject;Zn(t.bind(null,this._error))();break;default:e=!1;break}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(Ma(this._state)){case Ve.RUNNING:case Ve.PAUSED:e.next&&Zn(e.next.bind(e,this.snapshot))();break;case Ve.SUCCESS:e.complete&&Zn(e.complete.bind(e))();break;case Ve.CANCELED:case Ve.ERROR:e.error&&Zn(e.error.bind(e,this._error))();break;default:e.error&&Zn(e.error.bind(e,this._error))()}}resume(){const e=this._state==="paused"||this._state==="pausing";return e&&this._transition("running"),e}pause(){const e=this._state==="running";return e&&this._transition("pausing"),e}cancel(){const e=this._state==="running"||this._state==="pausing";return e&&this._transition("canceling"),e}}class En{constructor(e,t){this._service=e,t instanceof Be?this._location=t:this._location=Be.makeFromUrl(t,e.host)}toString(){return"gs://"+this._location.bucket+"/"+this._location.path}_newRef(e,t){return new En(e,t)}get root(){const e=new Be(this._location.bucket,"");return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return zd(this._location.path)}get storage(){return this._service}get parent(){const e=QI(this._location.path);if(e===null)return null;const t=new Be(this._location.bucket,e);return new En(this._service,t)}_throwIfRoot(e){if(this._location.path==="")throw PI(e)}}function mv(n,e,t){return n._throwIfRoot("uploadBytesResumable"),new pv(n,new Gt(e),t)}function gv(n){n._throwIfRoot("getDownloadURL");const e=sv(n.storage,n._location,Wd());return n.storage.makeRequestWithTokens(e,yn).then(t=>{if(t===null)throw RI();return t})}function _v(n){n._throwIfRoot("deleteObject");const e=iv(n.storage,n._location);return n.storage.makeRequestWithTokens(e,yn)}function yv(n,e){const t=YI(n._location.path,e),r=new Be(n._location.bucket,t);return new En(n.storage,r)}function Ev(n){return/^[A-Za-z]+:\/\//.test(n)}function Tv(n,e){return new En(n,e)}function Yd(n,e){if(n instanceof xa){const t=n;if(t._bucket==null)throw vI();const r=new En(t,t._bucket);return e!=null?Yd(r,e):r}else return e!==void 0?yv(n,e):n}function wv(n,e){if(e&&Ev(e)){if(n instanceof xa)return Tv(n,e);throw ka("To use ref(service, url), the first argument must be a Storage instance.")}else return Yd(n,e)}function Jd(n,e){const t=e?.[Nd];return t==null?null:Be.makeFromBucketSpec(t,n)}function Iv(n,e,t,r={}){n.host=`${e}:${t}`;const s=tt(e);s&&(ls(`https://${n.host}/b`),hs("Storage",!0)),n._isUsingEmulator=!0,n._protocol=s?"https":"http";const{mockUserToken:i}=r;i&&(n._overrideAuthToken=typeof i=="string"?i:yc(i,n.app.options.projectId))}class xa{constructor(e,t,r,s,i,a=!1){this.app=e,this._authProvider=t,this._appCheckProvider=r,this._url=s,this._firebaseVersion=i,this._isUsingEmulator=a,this._bucket=null,this._host=kd,this._protocol="https",this._appId=null,this._deleted=!1,this._maxOperationRetryTime=fI,this._maxUploadRetryTime=pI,this._requests=new Set,s!=null?this._bucket=Be.makeFromBucketSpec(s,this._host):this._bucket=Jd(this._host,this.app.options)}get host(){return this._host}set host(e){this._host=e,this._url!=null?this._bucket=Be.makeFromBucketSpec(this._url,e):this._bucket=Jd(e,this.app.options)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){xd("time",0,Number.POSITIVE_INFINITY,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){xd("time",0,Number.POSITIVE_INFINITY,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;const e=this._authProvider.getImmediate({optional:!0});if(e){const t=await e.getToken();if(t!==null)return t.accessToken}return null}async _getAppCheckToken(){if(Ae(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new En(this,e)}_makeRequest(e,t,r,s,i=!0){if(this._deleted)return new CI(Ld());{const a=FI(e,this._appId,r,s,t,this._firebaseVersion,i,this._isUsingEmulator);return this._requests.add(a),a.getPromise().then(()=>this._requests.delete(a),()=>this._requests.delete(a)),a}}async makeRequestWithTokens(e,t){const[r,s]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,r,s).getPromise()}}const Xd="@firebase/storage",Zd="0.14.1";const ef="storage";function vv(n,e,t){return n=Y(n),mv(n,e,t)}function Av(n){return n=Y(n),gv(n)}function Rv(n){return n=Y(n),_v(n)}function Ua(n,e){return n=Y(n),wv(n,e)}function bv(n=fs(),e){n=Y(n);const r=dr(n,ef).getImmediate({identifier:e}),s=ji("storage");return s&&tf(r,...s),r}function tf(n,e,t,r={}){Iv(n,e,t,r)}function Pv(n,{instanceIdentifier:e}){const t=n.getProvider("app").getImmediate(),r=n.getProvider("auth-internal"),s=n.getProvider("app-check-internal");return new xa(t,r,s,e,nn)}function Cv(){St(new _t(ef,Pv,"PUBLIC").setMultipleInstances(!0)),je(Xd,Zd,""),je(Xd,Zd,"esm2020")}Cv();const Sv="type.googleapis.com/google.protobuf.Int64Value",kv="type.googleapis.com/google.protobuf.UInt64Value";function nf(n,e){const t={};for(const r in n)n.hasOwnProperty(r)&&(t[r]=e(n[r]));return t}function Ri(n){if(n==null)return null;if(n instanceof Number&&(n=n.valueOf()),typeof n=="number"&&isFinite(n)||n===!0||n===!1||Object.prototype.toString.call(n)==="[object String]")return n;if(n instanceof Date)return n.toISOString();if(Array.isArray(n))return n.map(e=>Ri(e));if(typeof n=="function"||typeof n=="object")return nf(n,e=>Ri(e));throw new Error("Data cannot be encoded in JSON: "+n)}function er(n){if(n==null)return n;if(n["@type"])switch(n["@type"]){case Sv:case kv:{const e=Number(n.value);if(isNaN(e))throw new Error("Data cannot be decoded from JSON: "+n);return e}default:throw new Error("Data cannot be decoded from JSON: "+n)}return Array.isArray(n)?n.map(e=>er(e)):typeof n=="function"||typeof n=="object"?nf(n,e=>er(e)):n}const Fa="functions";const rf={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 Le extends He{constructor(e,t,r){super(`${Fa}/${e}`,t||""),this.details=r,Object.setPrototypeOf(this,Le.prototype)}}function Nv(n){if(n>=200&&n<300)return"ok";switch(n){case 0:return"internal";case 400:return"invalid-argument";case 401:return"unauthenticated";case 403:return"permission-denied";case 404:return"not-found";case 409:return"aborted";case 429:return"resource-exhausted";case 499:return"cancelled";case 500:return"internal";case 501:return"unimplemented";case 503:return"unavailable";case 504:return"deadline-exceeded"}return"unknown"}function bi(n,e){let t=Nv(n),r=t,s;try{const i=e&&e.error;if(i){const a=i.status;if(typeof a=="string"){if(!rf[a])return new Le("internal","internal");t=rf[a],r=a}const c=i.message;typeof c=="string"&&(r=c),s=i.details,s!==void 0&&(s=er(s))}}catch{}return t==="ok"?null:new Le(t,r,s)}class Dv{constructor(e,t,r,s){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,Ae(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.auth=t.getImmediate({optional:!0}),this.messaging=r.getImmediate({optional:!0}),this.auth||t.get().then(i=>this.auth=i,()=>{}),this.messaging||r.get().then(i=>this.messaging=i,()=>{}),this.appCheck||s?.get().then(i=>this.appCheck=i,()=>{})}async getAuthToken(){if(this.auth)try{return(await this.auth.getToken())?.accessToken}catch{return}}async getMessagingToken(){if(!(!this.messaging||!("Notification"in self)||Notification.permission!=="granted"))try{return await this.messaging.getToken()}catch{return}}async getAppCheckToken(e){if(this.serverAppAppCheckToken)return this.serverAppAppCheckToken;if(this.appCheck){const t=e?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken();return t.error?null:t.token}return null}async getContext(e){const t=await this.getAuthToken(),r=await this.getMessagingToken(),s=await this.getAppCheckToken(e);return{authToken:t,messagingToken:r,appCheckToken:s}}}const Ba="us-central1",Ov=/^data: (.*?)(?:\n|$)/;function Vv(n){let e=null;return{promise:new Promise((t,r)=>{e=setTimeout(()=>{r(new Le("deadline-exceeded","deadline-exceeded"))},n)}),cancel:()=>{e&&clearTimeout(e)}}}class Lv{constructor(e,t,r,s,i=Ba,a=(...c)=>fetch(...c)){this.app=e,this.fetchImpl=a,this.emulatorOrigin=null,this.contextProvider=new Dv(e,t,r,s),this.cancelAllRequests=new Promise(c=>{this.deleteService=()=>Promise.resolve(c())});try{const c=new URL(i);this.customDomain=c.origin+(c.pathname==="/"?"":c.pathname),this.region=Ba}catch{this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){const t=this.app.options.projectId;return this.emulatorOrigin!==null?`${this.emulatorOrigin}/${t}/${this.region}/${e}`:this.customDomain!==null?`${this.customDomain}/${e}`:`https://${this.region}-${t}.cloudfunctions.net/${e}`}}function Mv(n,e,t){const r=tt(e);n.emulatorOrigin=`http${r?"s":""}://${e}:${t}`,r&&(ls(n.emulatorOrigin+"/backends"),hs("Functions",!0))}function xv(n,e,t){const r=s=>Fv(n,e,s,{});return r.stream=(s,i)=>qv(n,e,s,i),r}function sf(n){return n.emulatorOrigin&&tt(n.emulatorOrigin)?"include":void 0}async function Uv(n,e,t,r,s){t["Content-Type"]="application/json";let i;try{i=await r(n,{method:"POST",body:JSON.stringify(e),headers:t,credentials:sf(s)})}catch{return{status:0,json:null}}let a=null;try{a=await i.json()}catch{}return{status:i.status,json:a}}async function of(n,e){const t={},r=await n.contextProvider.getContext(e.limitedUseAppCheckTokens);return r.authToken&&(t.Authorization="Bearer "+r.authToken),r.messagingToken&&(t["Firebase-Instance-ID-Token"]=r.messagingToken),r.appCheckToken!==null&&(t["X-Firebase-AppCheck"]=r.appCheckToken),t}function Fv(n,e,t,r){const s=n._url(e);return Bv(n,s,t,r)}async function Bv(n,e,t,r){t=Ri(t);const s={data:t},i=await of(n,r),a=r.timeout||7e4,c=Vv(a),l=await Promise.race([Uv(e,s,i,n.fetchImpl,n),c.promise,n.cancelAllRequests]);if(c.cancel(),!l)throw new Le("cancelled","Firebase Functions instance was deleted.");const d=bi(l.status,l.json);if(d)throw d;if(!l.json)throw new Le("internal","Response is not valid JSON object.");let f=l.json.data;if(typeof f>"u"&&(f=l.json.result),typeof f>"u")throw new Le("internal","Response is missing data field.");return{data:er(f)}}function qv(n,e,t,r){const s=n._url(e);return jv(n,s,t,r||{})}async function jv(n,e,t,r){t=Ri(t);const s={data:t},i=await of(n,r);i["Content-Type"]="application/json",i.Accept="text/event-stream";let a;try{a=await n.fetchImpl(e,{method:"POST",body:JSON.stringify(s),headers:i,signal:r?.signal,credentials:sf(n)})}catch(_){if(_ instanceof Error&&_.name==="AbortError"){const S=new Le("cancelled","Request was cancelled.");return{data:Promise.reject(S),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(S)}}}}}}const R=bi(0,null);return{data:Promise.reject(R),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(R)}}}}}}let c,l;const d=new Promise((_,R)=>{c=_,l=R});r?.signal?.addEventListener("abort",()=>{const _=new Le("cancelled","Request was cancelled.");l(_)});const f=a.body.getReader(),m=$v(f,c,l,r?.signal);return{stream:{[Symbol.asyncIterator](){const _=m.getReader();return{async next(){const{value:R,done:S}=await _.read();return{value:R,done:S}},async return(){return await _.cancel(),{done:!0,value:void 0}}}}},data:d}}function $v(n,e,t,r){const s=(a,c)=>{const l=a.match(Ov);if(!l)return;const d=l[1];try{const f=JSON.parse(d);if("result"in f){e(er(f.result));return}if("message"in f){c.enqueue(er(f.message));return}if("error"in f){const m=bi(0,f);c.error(m),t(m);return}}catch(f){if(f instanceof Le){c.error(f),t(f);return}}},i=new TextDecoder;return new ReadableStream({start(a){let c="";return l();async function l(){if(r?.aborted){const d=new Le("cancelled","Request was cancelled");return a.error(d),t(d),Promise.resolve()}try{const{value:d,done:f}=await n.read();if(f){c.trim()&&s(c.trim(),a),a.close();return}if(r?.aborted){const _=new Le("cancelled","Request was cancelled");a.error(_),t(_),await n.cancel();return}c+=i.decode(d,{stream:!0});const m=c.split(`
|
|
52
|
-
`);
|
|
53
|
-
//# sourceMappingURL=entropic-bond-firebase.umd.cjs.map
|
|
41
|
+
`,f=`\r
|
|
42
|
+
--`+c+`--`,p=_C.getBlob(d,r,f);if(p===null)throw ES();let m={name:l.fullPath},h=KS(a,e.host,e._protocol),g=e.maxUploadRetryTime,ee=new MC(h,`POST`,PC(e,n),g);return ee.urlParams=m,ee.headers=o,ee.body=p.uploadData(),ee.errorHandler=IC(t),ee}var WC=class{constructor(e,t,n,r){this.current=e,this.total=t,this.finalized=!!n,this.metadata=r||null}};function GC(e,t){let n=null;try{n=e.getResponseHeader(`X-Goog-Upload-Status`)}catch{NC(!1)}return NC(!!n&&(t||[`active`]).indexOf(n)!==-1),n}function KC(e,t,n,r,i){let a=t.bucketOnlyServerUrl(),o=HC(t,r,i),s={name:o.fullPath},c=KS(a,e.host,e._protocol),l={"X-Goog-Upload-Protocol":`resumable`,"X-Goog-Upload-Command":`start`,"X-Goog-Upload-Header-Content-Length":`${r.size()}`,"X-Goog-Upload-Header-Content-Type":o.contentType,"Content-Type":`application/json; charset=utf-8`},u=jC(o,n),d=e.maxUploadRetryTime;function f(e){GC(e);let t;try{t=e.getResponseHeader(`X-Goog-Upload-URL`)}catch{NC(!1)}return NC(HS(t)),t}let p=new MC(c,`POST`,f,d);return p.urlParams=s,p.headers=l,p.body=u,p.errorHandler=IC(t),p}function qC(e,t,n,r){let i={"X-Goog-Upload-Command":`query`};function a(e){let t=GC(e,[`active`,`final`]),n=null;try{n=e.getResponseHeader(`X-Goog-Upload-Size-Received`)}catch{NC(!1)}n||NC(!1);let i=Number(n);return NC(!isNaN(i)),new WC(i,r.size(),t===`final`)}let o=e.maxUploadRetryTime,s=new MC(n,`POST`,a,o);return s.headers=i,s.errorHandler=IC(t),s}var JC=256*1024;function YC(e,t,n,r,i,a,o,s){let c=new WC(0,0);if(o?(c.current=o.current,c.total=o.total):(c.current=0,c.total=r.size()),r.size()!==c.total)throw DS();let l=c.total-c.current,u=l;i>0&&(u=Math.min(u,i));let d=c.current,f=d+u,p=``;p=u===0?`finalize`:l===u?`upload, finalize`:`upload`;let m={"X-Goog-Upload-Command":p,"X-Goog-Upload-Offset":`${c.current}`},h=r.slice(d,f);if(h===null)throw ES();function g(e,n){let i=GC(e,[`active`,`final`]),o=c.current+u,s=r.size(),l;return l=i===`final`?PC(t,a)(e,n):null,new WC(o,s,i===`final`,l)}let ee=t.maxUploadRetryTime,te=new MC(n,`POST`,g,ee);return te.headers=m,te.body=h.uploadData(),te.progressCallback=s||null,te.errorHandler=IC(e),te}var XC={RUNNING:`running`,PAUSED:`paused`,SUCCESS:`success`,CANCELED:`canceled`,ERROR:`error`};function ZC(e){switch(e){case`running`:case`pausing`:case`canceling`:return XC.RUNNING;case`paused`:return XC.PAUSED;case`success`:return XC.SUCCESS;case`canceled`:return XC.CANCELED;case`error`:return XC.ERROR;default:return XC.ERROR}}var QC=class{constructor(e,t,n){if(BS(e)||t!=null||n!=null)this.next=e,this.error=t??void 0,this.complete=n??void 0;else{let t=e;this.next=t.next,this.error=t.error,this.complete=t.complete}}};function $C(e){return(...t)=>{Promise.resolve().then(()=>e(...t))}}var ew=class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=JS.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener(`abort`,()=>{this.errorCode_=JS.ABORT,e()}),this.xhr_.addEventListener(`error`,()=>{this.errorCode_=JS.NETWORK_ERROR,e()}),this.xhr_.addEventListener(`load`,()=>{e()})})}send(e,t,n,r,i){if(this.sent_)throw PS(`cannot .send() more than once`);if(Oe(e)&&n&&(this.xhr_.withCredentials=!0),this.sent_=!0,this.xhr_.open(t,e,!0),i!==void 0)for(let e in i)i.hasOwnProperty(e)&&this.xhr_.setRequestHeader(e,i[e].toString());return r===void 0?this.xhr_.send():this.xhr_.send(r),this.sendPromise_}getErrorCode(){if(!this.sent_)throw PS(`cannot .getErrorCode() before sending`);return this.errorCode_}getStatus(){if(!this.sent_)throw PS(`cannot .getStatus() before sending`);try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw PS(`cannot .getResponse() before sending`);return this.xhr_.response}getErrorText(){if(!this.sent_)throw PS(`cannot .getErrorText() before sending`);return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener(`progress`,e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener(`progress`,e)}},tw=class extends ew{initXhr(){this.xhr_.responseType=`text`}};function nw(){return new tw}var rw=class{isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}constructor(e,t,n=null){this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=e,this._blob=t,this._metadata=n,this._mappings=EC(),this._resumable=this._shouldDoResumable(this._blob),this._state=`running`,this._errorHandler=e=>{if(this._request=void 0,this._chunkMultiplier=1,e._codeEquals(Q.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{let t=this.isExponentialBackoffExpired();if(YS(e.status,[]))if(t)e=xS();else{this.sleepTime=Math.max(this.sleepTime*2,pS),this._needToFetchStatus=!0,this.completeTransitions_();return}this._error=e,this._transition(`error`)}},this._metadataErrorHandler=e=>{this._request=void 0,e._codeEquals(Q.CANCELED)?this.completeTransitions_():(this._error=e,this._transition(`error`))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){let e=this._transferred;return t=>this._updateProgress(e+t)}_shouldDoResumable(e){return e.size()>256*1024}_start(){this._state===`running`&&this._request===void 0&&(this._resumable?this._uploadUrl===void 0?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(e){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([t,n])=>{switch(this._state){case`running`:e(t,n);break;case`canceling`:this._transition(`canceled`);break;case`pausing`:this._transition(`paused`);break}})}_createResumable(){this._resolveToken((e,t)=>{let n=KC(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,nw,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._uploadUrl=e,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){let e=this._uploadUrl;this._resolveToken((t,n)=>{let r=qC(this._ref.storage,this._ref._location,e,this._blob),i=this._ref.storage._makeRequest(r,nw,t,n);this._request=i,i.getPromise().then(e=>{e=e,this._request=void 0,this._updateProgress(e.current),this._needToFetchStatus=!1,e.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){let e=JC*this._chunkMultiplier,t=new WC(this._transferred,this._blob.size()),n=this._uploadUrl;this._resolveToken((r,i)=>{let a;try{a=YC(this._ref._location,this._ref.storage,n,this._blob,e,this._mappings,t,this._makeProgressCallback())}catch(e){this._error=e,this._transition(`error`);return}let o=this._ref.storage._makeRequest(a,nw,r,i,!1);this._request=o,o.getPromise().then(e=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(e.current),e.finalized?(this._metadata=e.metadata,this._transition(`success`)):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){JC*this._chunkMultiplier*2<32*1024*1024&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{let n=RC(this._ref.storage,this._ref._location,this._mappings),r=this._ref.storage._makeRequest(n,nw,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._metadata=e,this._transition(`success`)},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((e,t)=>{let n=UC(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,nw,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._metadata=e,this._updateProgress(this._blob.size()),this._transition(`success`)},this._errorHandler)})}_updateProgress(e){let t=this._transferred;this._transferred=e,this._transferred!==t&&this._notifyObservers()}_transition(e){if(this._state!==e)switch(e){case`canceling`:case`pausing`:this._state=e,this._request===void 0?this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_()):this._request.cancel();break;case`running`:let t=this._state===`paused`;this._state=e,t&&(this._notifyObservers(),this._start());break;case`paused`:this._state=e,this._notifyObservers();break;case`canceled`:this._error=SS(),this._state=e,this._notifyObservers();break;case`error`:this._state=e,this._notifyObservers();break;case`success`:this._state=e,this._notifyObservers();break}}completeTransitions_(){switch(this._state){case`pausing`:this._transition(`paused`);break;case`canceling`:this._transition(`canceled`);break;case`running`:this._start();break}}get snapshot(){let e=ZC(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,t,n,r){let i=new QC(t||void 0,n||void 0,r||void 0);return this._addObserver(i),()=>{this._removeObserver(i)}}then(e,t){return this._promise.then(e,t)}catch(e){return this.then(null,e)}_addObserver(e){this._observers.push(e),this._notifyObserver(e)}_removeObserver(e){let t=this._observers.indexOf(e);t!==-1&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise(),this._observers.slice().forEach(e=>{this._notifyObserver(e)})}_finishPromise(){if(this._resolve!==void 0){let e=!0;switch(ZC(this._state)){case XC.SUCCESS:$C(this._resolve.bind(null,this.snapshot))();break;case XC.CANCELED:case XC.ERROR:let t=this._reject;$C(t.bind(null,this._error))();break;default:e=!1;break}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(ZC(this._state)){case XC.RUNNING:case XC.PAUSED:e.next&&$C(e.next.bind(e,this.snapshot))();break;case XC.SUCCESS:e.complete&&$C(e.complete.bind(e))();break;case XC.CANCELED:case XC.ERROR:e.error&&$C(e.error.bind(e,this._error))();break;default:e.error&&$C(e.error.bind(e,this._error))()}}resume(){let e=this._state===`paused`||this._state===`pausing`;return e&&this._transition(`running`),e}pause(){let e=this._state===`running`;return e&&this._transition(`pausing`),e}cancel(){let e=this._state===`running`||this._state===`pausing`;return e&&this._transition(`canceling`),e}},iw=class e{constructor(e,t){this._service=e,t instanceof FS?this._location=t:this._location=FS.makeFromUrl(t,e.host)}toString(){return`gs://`+this._location.bucket+`/`+this._location.path}_newRef(t,n){return new e(t,n)}get root(){let e=new FS(this._location.bucket,``);return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return xC(this._location.path)}get storage(){return this._service}get parent(){let t=yC(this._location.path);if(t===null)return null;let n=new FS(this._location.bucket,t);return new e(this._service,n)}_throwIfRoot(e){if(this._location.path===``)throw MS(e)}};function aw(e,t,n){return e._throwIfRoot(`uploadBytesResumable`),new rw(e,new _C(t),n)}function ow(e){e._throwIfRoot(`getDownloadURL`);let t=zC(e.storage,e._location,EC());return e.storage.makeRequestWithTokens(t,nw).then(e=>{if(e===null)throw OS();return e})}function sw(e){e._throwIfRoot(`deleteObject`);let t=BC(e.storage,e._location);return e.storage.makeRequestWithTokens(t,nw)}function cw(e,t){let n=bC(e._location.path,t),r=new FS(e._location.bucket,n);return new iw(e.storage,r)}function lw(e){return/^[A-Za-z]+:\/\//.test(e)}function uw(e,t){return new iw(e,t)}function dw(e,t){if(e instanceof hw){let n=e;if(n._bucket==null)throw TS();let r=new iw(n,n._bucket);return t==null?r:dw(r,t)}else if(t!==void 0)return cw(e,t);else return e}function fw(e,t){if(t&&lw(t)){if(e instanceof hw)return uw(e,t);throw AS(`To use ref(service, url), the first argument must be a Storage instance.`)}else return dw(e,t)}function pw(e,t){let n=t?.[uS];return n==null?null:FS.makeFromBucketSpec(n,e)}function mw(e,t,n,r={}){e.host=`${t}:${n}`;let i=Oe(t);i&&ke(`https://${e.host}/b`),e._isUsingEmulator=!0,e._protocol=i?`https`:`http`;let{mockUserToken:a}=r;a&&(e._overrideAuthToken=typeof a==`string`?a:ne(a,e.app.options.projectId))}var hw=class{constructor(e,t,n,r,i,a=!1){this.app=e,this._authProvider=t,this._appCheckProvider=n,this._url=r,this._firebaseVersion=i,this._isUsingEmulator=a,this._bucket=null,this._host=lS,this._protocol=`https`,this._appId=null,this._deleted=!1,this._maxOperationRetryTime=dS,this._maxUploadRetryTime=fS,this._requests=new Set,r==null?this._bucket=pw(this._host,this.app.options):this._bucket=FS.makeFromBucketSpec(r,this._host)}get host(){return this._host}set host(e){this._host=e,this._url==null?this._bucket=pw(e,this.app.options):this._bucket=FS.makeFromBucketSpec(this._url,e)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){GS(`time`,0,1/0,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){GS(`time`,0,1/0,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;let e=this._authProvider.getImmediate({optional:!0});if(e){let t=await e.getToken();if(t!==null)return t.accessToken}return null}async _getAppCheckToken(){if(y(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;let e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new iw(this,e)}_makeRequest(e,t,n,r,i=!0){if(this._deleted)return new IS(jS());{let a=nC(e,this._appId,n,r,t,this._firebaseVersion,i,this._isUsingEmulator);return this._requests.add(a),a.getPromise().then(()=>this._requests.delete(a),()=>this._requests.delete(a)),a}}async makeRequestWithTokens(e,t){let[n,r]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,n,r).getPromise()}},gw=`@firebase/storage`,_w=`0.14.3`,vw=`storage`;function yw(e,t,n){return e=_(e),aw(e,t,n)}function bw(e){return e=_(e),ow(e)}function xw(e){return e=_(e),sw(e)}function Sw(e,t){return e=_(e),fw(e,t)}function Cw(e=tn(),t){e=_(e);let n=Xt(e,vw).getImmediate({identifier:t}),r=h(`storage`);return r&&ww(n,...r),n}function ww(e,t,n,r={}){mw(e,t,n,r)}function Tw(e,{instanceIdentifier:t}){return new hw(e.getProvider(`app`).getImmediate(),e.getProvider(`auth-internal`),e.getProvider(`app-check-internal`),t,$t)}function Ew(){Yt(new Ae(vw,Tw,`PUBLIC`).setMultipleInstances(!0)),nn(gw,_w,``),nn(gw,_w,`esm2020`)}Ew();var Dw=`type.googleapis.com/google.protobuf.Int64Value`,Ow=`type.googleapis.com/google.protobuf.UInt64Value`;function kw(e,t){let n={};for(let r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r]));return n}function Aw(e){if(e==null)return null;if(e instanceof Number&&(e=e.valueOf()),typeof e==`number`&&isFinite(e)||e===!0||e===!1||Object.prototype.toString.call(e)===`[object String]`)return e;if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(e=>Aw(e));if(typeof e==`function`||typeof e==`object`)return kw(e,e=>Aw(e));throw Error(`Data cannot be encoded in JSON: `+e)}function jw(e){if(e==null)return e;if(e[`@type`])switch(e[`@type`]){case Dw:case Ow:{let t=Number(e.value);if(isNaN(t))throw Error(`Data cannot be decoded from JSON: `+e);return t}default:throw Error(`Data cannot be decoded from JSON: `+e)}return Array.isArray(e)?e.map(e=>jw(e)):typeof e==`function`||typeof e==`object`?kw(e,e=>jw(e)):e}var Mw=`functions`,Nw={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`},Pw=class e extends me{constructor(t,n,r){super(`${Mw}/${t}`,n||``),this.details=r,Object.setPrototypeOf(this,e.prototype)}};function Fw(e){if(e>=200&&e<300)return`ok`;switch(e){case 0:return`internal`;case 400:return`invalid-argument`;case 401:return`unauthenticated`;case 403:return`permission-denied`;case 404:return`not-found`;case 409:return`aborted`;case 429:return`resource-exhausted`;case 499:return`cancelled`;case 500:return`internal`;case 501:return`unimplemented`;case 503:return`unavailable`;case 504:return`deadline-exceeded`}return`unknown`}function Iw(e,t){let n=Fw(e),r=n,i;try{let e=t&&t.error;if(e){let t=e.status;if(typeof t==`string`){if(!Nw[t])return new Pw(`internal`,`internal`);n=Nw[t],r=t}let a=e.message;typeof a==`string`&&(r=a),i=e.details,i!==void 0&&(i=jw(i))}}catch{}return n===`ok`?null:new Pw(n,r,i)}var Lw=class{constructor(e,t,n,r){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,y(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.auth=t.getImmediate({optional:!0}),this.messaging=n.getImmediate({optional:!0}),this.auth||t.get().then(e=>this.auth=e,()=>{}),this.messaging||n.get().then(e=>this.messaging=e,()=>{}),this.appCheck||r?.get().then(e=>this.appCheck=e,()=>{})}async getAuthToken(){if(this.auth)try{return(await this.auth.getToken())?.accessToken}catch{return}}async getMessagingToken(){if(!(!this.messaging||!(`Notification`in self)||Notification.permission!==`granted`))try{return await this.messaging.getToken()}catch{return}}async getAppCheckToken(e){if(this.serverAppAppCheckToken)return this.serverAppAppCheckToken;if(this.appCheck){let t=e?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken();return t.error?null:t.token}return null}async getContext(e){return{authToken:await this.getAuthToken(),messagingToken:await this.getMessagingToken(),appCheckToken:await this.getAppCheckToken(e)}}},Rw=`us-central1`,zw=/^data: (.*?)(?:\n|$)/;function Bw(e){let t=null;return{promise:new Promise((n,r)=>{t=setTimeout(()=>{r(new Pw(`deadline-exceeded`,`deadline-exceeded`))},e)}),cancel:()=>{t&&clearTimeout(t)}}}var Vw=class{constructor(e,t,n,r,i=Rw,a=(...e)=>fetch(...e)){this.app=e,this.fetchImpl=a,this.emulatorOrigin=null,this.contextProvider=new Lw(e,t,n,r),this.cancelAllRequests=new Promise(e=>{this.deleteService=()=>Promise.resolve(e())});try{let e=new URL(i);this.customDomain=e.origin+(e.pathname===`/`?``:e.pathname),this.region=Rw}catch{this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){let t=this.app.options.projectId;return this.emulatorOrigin===null?this.customDomain===null?`https://${this.region}-${t}.cloudfunctions.net/${e}`:`${this.customDomain}/${e}`:`${this.emulatorOrigin}/${t}/${this.region}/${e}`}};function Hw(e,t,n){let r=Oe(t);e.emulatorOrigin=`http${r?`s`:``}://${t}:${n}`,r&&ke(e.emulatorOrigin+`/backends`)}function Uw(e,t,n){let r=r=>qw(e,t,r,n||{});return r.stream=(n,r)=>Yw(e,t,n,r),r}function Ww(e){return e.emulatorOrigin&&Oe(e.emulatorOrigin)?`include`:void 0}async function Gw(e,t,n,r,i){n[`Content-Type`]=`application/json`;let a;try{a=await r(e,{method:`POST`,body:JSON.stringify(t),headers:n,credentials:Ww(i)})}catch{return{status:0,json:null}}let o=null;try{o=await a.json()}catch{}return{status:a.status,json:o}}async function Kw(e,t){let n={},r=await e.contextProvider.getContext(t.limitedUseAppCheckTokens);return r.authToken&&(n.Authorization=`Bearer `+r.authToken),r.messagingToken&&(n[`Firebase-Instance-ID-Token`]=r.messagingToken),r.appCheckToken!==null&&(n[`X-Firebase-AppCheck`]=r.appCheckToken),n}function qw(e,t,n,r){return Jw(e,e._url(t),n,r)}async function Jw(e,t,n,r){n=Aw(n);let i={data:n},a=await Kw(e,r),o=Bw(r.timeout||7e4),s=await Promise.race([Gw(t,i,a,e.fetchImpl,e),o.promise,e.cancelAllRequests]);if(o.cancel(),!s)throw new Pw(`cancelled`,`Firebase Functions instance was deleted.`);let c=Iw(s.status,s.json);if(c)throw c;if(!s.json)throw new Pw(`internal`,`Response is not valid JSON object.`);let l=s.json.data;if(l===void 0&&(l=s.json.result),l===void 0)throw new Pw(`internal`,`Response is missing data field.`);return{data:jw(l)}}function Yw(e,t,n,r){return Xw(e,e._url(t),n,r||{})}async function Xw(e,t,n,r){n=Aw(n);let i={data:n},a=await Kw(e,r);a[`Content-Type`]=`application/json`,a.Accept=`text/event-stream`;let o;try{o=await e.fetchImpl(t,{method:`POST`,body:JSON.stringify(i),headers:a,signal:r?.signal,credentials:Ww(e)})}catch(e){if(e instanceof Error&&e.name===`AbortError`){let e=new Pw(`cancelled`,`Request was cancelled.`);return{data:Promise.reject(e),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(e)}}}}}}let t=Iw(0,null);return{data:Promise.reject(t),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(t)}}}}}}let s,c,l=new Promise((e,t)=>{s=e,c=t});r?.signal?.addEventListener(`abort`,()=>{let e=new Pw(`cancelled`,`Request was cancelled.`);c(e)});let u=Zw(o.body.getReader(),s,c,r?.signal);return{stream:{[Symbol.asyncIterator](){let e=u.getReader();return{async next(){let{value:t,done:n}=await e.read();return{value:t,done:n}},async return(){return await e.cancel(),{done:!0,value:void 0}}}}},data:l}}function Zw(e,t,n,r){let i=(e,r)=>{let i=e.match(zw);if(!i)return;let a=i[1];try{let e=JSON.parse(a);if(`result`in e){t(jw(e.result));return}if(`message`in e){r.enqueue(jw(e.message));return}if(`error`in e){let t=Iw(0,e);r.error(t),n(t);return}}catch(e){if(e instanceof Pw){r.error(e),n(e);return}}},a=new TextDecoder;return new ReadableStream({start(t){let o=``;return s();async function s(){if(r?.aborted){let e=new Pw(`cancelled`,`Request was cancelled`);return t.error(e),n(e),Promise.resolve()}try{let{value:c,done:l}=await e.read();if(l){o.trim()&&i(o.trim(),t),t.close();return}if(r?.aborted){let r=new Pw(`cancelled`,`Request was cancelled`);t.error(r),n(r),await e.cancel();return}o+=a.decode(c,{stream:!0});let u=o.split(`
|
|
43
|
+
`);o=u.pop()||``;for(let e of u)e.trim()&&i(e.trim(),t);return s()}catch(e){let r=e instanceof Pw?e:Iw(0,null);t.error(r),n(r)}}},cancel(){return e.cancel()}})}var Qw=`@firebase/functions`,$w=`0.13.5`,eT=`auth-internal`,tT=`app-check-internal`,nT=`messaging-internal`;function rT(e){Yt(new Ae(Mw,(e,{instanceIdentifier:t})=>new Vw(e.getProvider(`app`).getImmediate(),e.getProvider(eT),e.getProvider(nT),e.getProvider(tT),t),`PUBLIC`).setMultipleInstances(!0)),nn(Qw,$w,e),nn(Qw,$w,`esm2020`)}function iT(e=tn(),t=Rw){let n=Xt(_(e),Mw).getImmediate({identifier:t}),r=h(`functions`);return r&&aT(n,...r),n}function aT(e,t,n){Hw(_(e),t,n)}function oT(e,t,n){return Uw(_(e),t,n)}rT();var $=class e{static setFirebaseConfig(t){e._firebaseConfig=t}static{this.defaultEmulatorConfig={host:`localhost`,firestorePort:8080,storagePort:9199,authPort:9099,functionsPort:5001,emulate:!1}}static useEmulator(t){this._emulatorConfig={...e.defaultEmulatorConfig,emulate:!0,...t}}static get emulator(){return this._emulatorConfig}constructor(){if(!e._firebaseConfig)throw Error(`You should set a firebase config object before using Firebase`);this._firebaseApp=en(e._firebaseConfig)}static get instance(){return this._instance||=new e}firestore(){return Rh(this._firebaseApp)}storage(){return Cw(this._firebaseApp)}auth(){return sS(this._firebaseApp)}functions(){return iT(this._firebaseApp,e._region)}static setRegion(e){this._region=e}static{this._emulatorConfig=e.defaultEmulatorConfig}},sT=class extends Yg{constructor(e){if(super(),this._lastLimit=0,e&&$.useEmulator(e),$.emulator?.emulate){let{host:e,firestorePort:t}=$.emulator;Ol($.instance.firestore(),e,t)}}findById(e,t){let n=$.instance.firestore();return new Promise(async r=>{try{r((await Dg(Nl(n,t,e))).data())}catch(e){return console.log(e),null}})}save(e){let t=$.instance.firestore(),n=Ng(t);return Object.entries(e).forEach(([e,r])=>{r?.forEach(r=>{let i=Nl(t,e,r.id);n.set(i,r)})}),n.commit()}find(e,t){let n=this.queryObjectToQueryConstraints(e,t);return this.getFromQuery(n)}async count(e,t){return(await vg(this.queryObjectToQueryConstraints(e,t))).data().count}delete(e,t){return kg(Nl($.instance.firestore(),t,e))}next(e){if(!this._lastConstraints||!this._lastCollectionName)throw Error(`You should perform a query prior to using method next`);if(!this._lastDocRetrieved)return Promise.resolve([]);let t=$.instance.firestore();this._lastLimit=e||this._lastLimit;let n=this._lastConstraints.nonFilterConstraints.concat(cg(this._lastLimit),ug(this._lastDocRetrieved));return this.getFromQuery($h(Ml(t,this._lastCollectionName),rg(...this._lastConstraints.orConstraints,ig(...this._lastConstraints.andConstraints)),...n))}onCollectionChange(e,t,n){return Ag(this.queryObjectToQueryConstraints(e,t),e=>{n(e.docChanges().map(e=>({after:e.doc.data(),type:e.type===`added`?`create`:e.type===`removed`?`delete`:`update`,before:void 0,params:{}})))})}onDocumentChange(e,t,n){return Ag(Nl($.instance.firestore(),e,t),t=>{n({type:`update`,before:void 0,after:t.data(),params:t.metadata,collectionPath:e})})}onDocumentTemplateChange(e,t){throw Error(`Method not implemented.`)}queryObjectToQueryConstraints(e,t){let n=$.instance.firestore(),r=[],i=[],a=[];return Yg.toPropertyPathOperations(e.operations).forEach(e=>{let t=this.toFirebaseOperator(e.operator);e.aggregate?i.push(tg(e.property,t,e.value)):r.push(tg(e.property,t,e.value))}),e.sort?.propertyName&&a.push(og(e.sort.propertyName,e.sort.order)),this._lastConstraints={orConstraints:i,andConstraints:r,nonFilterConstraints:a},this._lastCollectionName=t,e.limit&&(this._lastLimit=e.limit,a.push(cg(e.limit))),$h(Ml(n,t),rg(...i,ig(...r)),...a)}toFirebaseOperator(e){switch(e){case`==`:case`!=`:case`<`:case`<=`:case`>`:case`>=`:return e;case`contains`:return`array-contains`;case`containsAny`:return`array-contains-any`;default:return e}}getFromQuery(e){return new Promise(async t=>{let n=await Og(e);n.empty?(this._lastDocRetrieved=void 0,t([])):(this._lastDocRetrieved=n.docs[n.docs.length-1],t(n.docs.map(e=>e.data())))})}resolveCollectionPaths(e){throw Error(`Method not implemented.`)}};function cT(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var lT=class extends Xg{constructor(e){if(super(),e&&$.useEmulator(e),$.emulator?.emulate){let{host:e,storagePort:t}=$.emulator;ww($.instance.storage(),e,t)}}save(e,t,n){let r=$.instance.storage();return new Promise((i,a)=>{if(this._uploadTask=yw(Sw(r,e),t),n)var o=this._uploadTask.on(`state_changed`,e=>{n(e.bytesTransferred,e.totalBytes)},null,()=>o());this._uploadTask.then(()=>i(e)).catch(e=>a(e))})}getUrl(e){return e?bw(Sw($.instance.storage(),e)):Promise.reject(`needs a reference`)}uploadControl(){if(!this._uploadTask)throw Error(`You should call save() before uploadControl()`);return{cancel:()=>this._uploadTask?.cancel(),pause:()=>this._uploadTask?.pause(),resume:()=>this._uploadTask?.resume(),onProgress:e=>this._uploadTask?.on(`state_changed`,t=>{e&&e(t.bytesTransferred,t.totalBytes)})}}delete(e){return xw(Sw($.instance.storage(),e))}};lT=cT([Zg(`FirebaseCloudStorage`,()=>new lT)],lT);var uT={twitter:()=>new Dy,facebook:()=>new wy,google:()=>new Ty},dT=class e extends e_{constructor(e){if(super(),this.credentialProviders={},e&&$.useEmulator(e),$.emulator?.emulate){let{host:e,authPort:t}=$.emulator;if(!e||!t)throw Error(`You should define a host and an auth emulator port to use the emulator`);Yv($.instance.auth(),`http://${e}:${t}`)}this.registerCredentialProviders()}signUp(e){let{authProvider:t,verificationLink:n}=e;return t.slice(0,5)===`email`?new Promise(async(r,i)=>{try{let i=this.credentialProviders[`email-sign-up`];if(!i)throw Error(`The provider ${t} is not registered`);let a=await i(e);e.name&&await Jy(a.user,{displayName:e.name}),n&&await Ky(a.user,{url:n}),r(await this.toUserCredentials(a.user))}catch(e){i({code:n_(e.code.slice(5)),message:e.message})}}):this.login(e)}login(e){let{authProvider:t}=e;return new Promise(async(n,r)=>{try{let r=this.credentialProviders[t];if(!r)throw Error(`The provider ${t} is not registered`);let i=await r(e);n(await this.toUserCredentials(i.user))}catch(e){r({code:e.code===400?`missingPassword`:n_(e.code.slice(5)),message:e.message})}})}logout(){return $.instance.auth().signOut()}resetEmailPassword(e){return new Promise(async(t,n)=>{try{await Uy($.instance.auth(),e),t()}catch(e){n({code:n_(e.code.slice(5)),message:e.message})}})}resendVerificationEmail(e,t,n){return new Promise(async(r,i)=>{try{await Gy($.instance.auth(),e,t);let a=$.instance.auth().currentUser;if(!a){i({code:`userNotFound`,message:`There is no logged in user`});return}await Ky(a,{url:n}),r()}catch(e){i({code:n_(e.code.slice(5)),message:n})}})}refreshToken(){return $.instance.auth().currentUser?.getIdToken(!0)}onAuthStateChange(e){$.instance.auth().onAuthStateChanged(async t=>{e(t?await this.toUserCredentials(t):void 0)})}linkAdditionalProvider(e){let t=uT[e](),n=$.instance.auth().currentUser;if(!n)throw Error(`There is no logged in user`);return $b(n,t)}unlinkProvider(e){let{currentUser:t}=$.instance.auth();if(!t)throw Error(`There is no logged in user`);return t.providerData,Fy(t,uT[e]().providerId)}async toUserCredentials(t){if(!t)throw Error(`The user in user credentials is not defined`);let n=(await t.getIdTokenResult()).claims;return e.convertCredentials(t,n)}static convertCredentials(e,t){return{id:e.uid,email:e.email??``,name:e.displayName??void 0,pictureUrl:e.photoURL??void 0,phoneNumber:e.phoneNumber??void 0,emailVerified:e.emailVerified,customData:{...t},lastLogin:Date.now(),creationDate:e.metadata.creationTime?new Date(e.metadata.creationTime).getTime():void 0}}registerCredentialProvider(e,t){this.credentialProviders[e]=t}registerCredentialProviders(){this.registerCredentialProvider(`email-sign-up`,e=>{if(!e.email||!e.password)throw Error(`Email and password are required`);return Wy($.instance.auth(),e.email,e.password)}),this.registerCredentialProvider(`email`,e=>{if(!e.email||!e.password)throw Error(`Email and password are required`);return Gy($.instance.auth(),e.email,e.password)}),this.registerCredentialProvider(`google`,()=>Qb($.instance.auth(),new Ty)),this.registerCredentialProvider(`facebook`,()=>Qb($.instance.auth(),new wy)),this.registerCredentialProvider(`twitter`,()=>Qb($.instance.auth(),new Dy)),this.registerCredentialProvider(`link-twitter`,()=>{let e=$.instance.auth().currentUser;if(!e)throw Error(`There is no logged in user`);return $b(e,new Dy)}),this.registerCredentialProvider(`anonymous`,()=>jy($.instance.auth()))}},fT=class{constructor(e,t){if(e&&$.setRegion(e),t&&$.useEmulator(t),$.emulator?.emulate){let{host:e,functionsPort:t}=$.emulator;aT($.instance.functions(),e,t)}}retrieveFunction(e){return oT($.instance.functions(),e)}async callFunction(e,t){return(await e(t)).data}};e.FirebaseAuth=dT,e.FirebaseCloudFunctions=fT,Object.defineProperty(e,"FirebaseCloudStorage",{enumerable:!0,get:function(){return lT}}),e.FirebaseDatasource=sT,e.FirebaseHelper=$});
|
|
44
|
+
//# sourceMappingURL=entropic-bond-firebase.umd.cjs.map
|