1var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),u=(e=>typeof require<`u`?require:typeof Proxy<`u`?new Proxy(e,{get:(e,t)=>(typeof require<`u`?require:e)[t]}):e)(function(e){if(typeof require<`u`)return require.apply(this,arguments);throw Error('Calling `require` for "'+e+"\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.")}),d=()=>void 0,f=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},p=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(``)},m={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(f(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):p(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++)],a=t<e.length?n[e.charAt(t)]:0;++t;let o=t<e.length?n[e.charAt(t)]:64;++t;let s=t<e.length?n[e.charAt(t)]:64;if(++t,i==null||a==null||o==null||s==null)throw new h;let c=i<<2|a>>4;if(r.push(c),o!==64){let e=a<<4&240|o>>2;if(r.push(e),s!==64){let e=o<<6&192|s;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)}}},h=class extends Error{constructor(){super(...arguments),this.name=`DecodeBase64StringError`}},g=function(e){let t=f(e);return m.encodeByteArray(t,!0)},ee=function(e){return g(e).replace(/\./g,``)},te=function(e){try{return m.decodeString(e,!0)}catch(e){console.error(`base64Decode failed: `,e)}return null};function ne(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:e===void 0&&(e={});break;case Array:e=[];break;default:return t}for(let n in t)!t.hasOwnProperty(n)||!re(n)||(e[n]=ne(e[n],t[n]));return e}function re(e){return e!==`__proto__`}function ie(){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 ae=()=>ie().__FIREBASE_DEFAULTS__,oe=()=>{if(typeof process>`u`)return;let e={}.__FIREBASE_DEFAULTS__;if(e)return JSON.parse(e)},se=()=>{if(typeof document>`u`)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;
1]+)/)}catch{return}let t=e&&te(e[1]);return t&&JSON.parse(t)},ce=()=>{try{return d()||ae()||oe()||se()}catch(e){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);return}},le=e=>ce()?.emulatorHosts?.[e],ue=e=>{let t=le(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]},de=()=>ce()?.config,fe=e=>ce()?.[`_${e}`],pe=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 me(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[ee(JSON.stringify(n)),ee(JSON.stringify(o)),``].join(`.`)}function _(){return typeof navigator<`u`&&typeof navigator.userAgent==`string`?navigator.userAgent:``}function he(){return typeof window<`u`&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(_())}function ge(){let e=ce()?.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 _e(){return typeof window<`u`||ve()}function ve(){return typeof WorkerGlobalScope<`u`&&typeof self<`u`&&self instanceof WorkerGlobalScope}function ye(){return typeof navigator<`u`&&navigator.userAgent===`Cloudflare-Workers`}function be(){let e=typeof chrome==`object`?chrome.runtime:typeof browser==`object`?browser.runtime:void 0;return typeof e==`object`&&e.id!==void 0}function xe(){return typeof navigator==`object`&&navigator.product===`ReactNative`}function Se(){let e=_();return e.indexOf(`MSIE `)>=0||e.indexOf(`Trident/`)>=0}function Ce(){return!ge()&&!!navigator.userAgent&&navigator.userAgent.includes(`Safari`)&&!navigator.userAgent.includes(`Chrome`)}function we(){return!ge()&&!!navigator.userAgent&&(navigator.userAgent.includes(`Safari`)||navigator.userAgent.includes(`WebKit`))&&!navigator.userAgent.includes(`Chrome`)}function Te(){try{return typeof indexedDB==`object`}catch{return!1}}function Ee(){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)}})}function De(){return!(typeof navigator>`u`||!navigator.cookieEnabled)}var Oe=`FirebaseError`,ke=class e extends Error{constructor(t,n,r){super(n),this.code=t,this.customData=r,this.name=Oe,Object.setPrototypeOf(this,e.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Ae.prototype.create)}},Ae=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?je(i,n):`Error`;return new ke(r,`${this.serviceName}: ${a} (${r}).`,n)}};function je(e,t){return e.replace(Me,(e,n)=>{let r=t[n];return r==null?`<${n}?>`:String(r)})}var Me=/\{\$([^}]+)}/g;function Ne(e){return JSON.parse(e)}var Pe=function(e){let t={},n={},r={},i=``;try{let a=e.split(`.`);t=Ne(te(a[0])||``),n=Ne(te(a[1])||``),i=a[2],r=n.d||{},delete n.d}catch{}return{header:t,claims:n,data:r,signature:i}},Fe=function(e){let t=Pe(e).claims;return typeof t==`object`&&t.hasOwnProperty(`iat`)?t.iat:null};function Ie(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Le(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function v(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(Re(n)&&Re(a)){if(!v(n,a))return!1}else if(n!==a)return!1}for(let e of r)if(!n.includes(e))return!1;return!0}function Re(e){return typeof e==`object`&&!!e}function ze(e){let t=[];
1for(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 Be(e){let t={};return e.replace(/^\?/,``).split(`&`).forEach(e=>{if(e){let[n,r]=e.split(`=`);t[decodeURIComponent(n)]=decodeURIComponent(r)}}),t}function Ve(e){let t=e.indexOf(`?`);if(!t)return``;let n=e.indexOf(`#`,t);return e.substring(t,n>0?n:void 0)}function He(e,t){let n=new Ue(e,t);return n.subscribe.bind(n)}var Ue=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=We(e,[`next`,`error`,`complete`])?e:{next:e,error:t,complete:n},r.next===void 0&&(r.next=Ge),r.error===void 0&&(r.error=Ge),r.complete===void 0&&(r.complete=Ge);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 We(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 Ge(){}var Ke=1e3,qe=2,Je=14400*1e3,Ye=.5;function Xe(e,t=Ke,n=qe){let r=t*n**+e,i=Math.round(Ye*r*(Math.random()-.5)*2);return Math.min(Je,r+i)}function y(e){return e&&e._delegate?e._delegate:e}function Ze(e){try{return(e.startsWith(`http://`)||e.startsWith(`https://`)?new URL(e).hostname:e).endsWith(`.cloudworkstations.dev`)}catch{return!1}}async function Qe(e){return(await fetch(e,{credentials:`include`})).ok}var b=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}},$e=`[DEFAULT]`,et=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 pe;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(nt(e))try{this.getOrInitializeService({instanceIdentifier:$e})}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=$e){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=$e){return this.instances.has(e)}getOptions(e=$e){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:tt(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=$e){return this.component?this.component.multipleInstances?e:$e:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!==`EXPLICIT`}};function tt(e){return e===$e?void 0:e}function nt(e){return e.instantiationMode===`EAGER`}var rt=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 et(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}},it=[],x;(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`})(x||={});var at={debug:x.DEBUG,verbose:x.VERBOSE,info:x.INFO,warn:x.WARN,error:x.ERROR,silent:x.SILENT},ot=x.INFO,st={[x.DEBUG]:`log`,[x.VERBOSE]:`log`,[x.INFO]:`info`,[x.WARN]:`warn`,[x.ERROR]:`error`},ct=(e,t,...n)=>{if(t<e.logLevel)return;let r=new Date().toISOString(),i=st[t];if(i)console[i](`[${r}] ${e.name}:`,...n);
1else throw Error(`Attempted to log a message with an invalid logType (value: ${t})`)},lt=class{constructor(e){this.name=e,this._logLevel=ot,this._logHandler=ct,this._userLogHandler=null,it.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in x))throw TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e==`string`?at[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,x.DEBUG,...e),this._logHandler(this,x.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,x.VERBOSE,...e),this._logHandler(this,x.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,x.INFO,...e),this._logHandler(this,x.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,x.WARN,...e),this._logHandler(this,x.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,x.ERROR,...e),this._logHandler(this,x.ERROR,...e)}};function ut(e){it.forEach(t=>{t.setLogLevel(e)})}function dt(e,t){for(let n of it){let r=null;t&&t.level&&(r=at[t.level]),e===null?n.userLogHandler=null:n.userLogHandler=(t,n,...i)=>{let a=i.map(e=>{if(e==null)return null;if(typeof e==`string`)return e;if(typeof e==`number`||typeof e==`boolean`)return e.toString();if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return null}}).filter(e=>e).join(` `);n>=(r??t.logLevel)&&e({level:x[n].toLowerCase(),message:a,args:i,type:t.name})}}}var ft=(e,t)=>t.some(t=>e instanceof t),pt,mt;function ht(){return pt||=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]}function gt(){return mt||=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey]}var _t=new WeakMap,vt=new WeakMap,yt=new WeakMap,bt=new WeakMap,xt=new WeakMap;function St(e){let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`success`,i),e.removeEventListener(`error`,a)},i=()=>{t(Ot(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener(`success`,i),e.addEventListener(`error`,a)});return t.then(t=>{t instanceof IDBCursor&&_t.set(t,e)}).catch(()=>{}),xt.set(t,e),t}function Ct(e){if(vt.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)});vt.set(e,t)}var wt={get(e,t,n){if(e instanceof IDBTransaction){if(t===`done`)return vt.get(e);if(t===`objectStoreNames`)return e.objectStoreNames||yt.get(e);if(t===`store`)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Ot(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){wt=e(wt)}function Et(e){return e===IDBDatabase.prototype.transaction&&!(`objectStoreNames`in IDBTransaction.prototype)?function(t,...n){let r=e.call(kt(this),t,...n);return yt.set(r,t.sort?t.sort():[t]),Ot(r)}:gt().includes(e)?function(...t){return e.apply(kt(this),t),Ot(_t.get(this))}:function(...t){return Ot(e.apply(kt(this),t))}}function Dt(e){return typeof e==`function`?Et(e):(e instanceof IDBTransaction&&Ct(e),ft(e,ht())?new Proxy(e,wt):e)}function Ot(e){if(e instanceof IDBRequest)return St(e);if(bt.has(e))return bt.get(e);let t=Dt(e);return t!==e&&(bt.set(e,t),xt.set(t,e)),t}var kt=e=>xt.get(e);function At(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){let o=indexedDB.open(e,t),s=Ot(o);return r&&o.addEventListener(`upgradeneeded`,e=>{r(Ot(o.result),e.oldVersion,e.newVersion,Ot(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 jt=[`get`,`getKey`,`getAll`,`getAllKeys`,`count`],Mt=[`put`,`add`,`delete`,`clear`],Nt=new Map;function Pt(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t==`string`))return;if(Nt.get(t))return Nt.get(t);let n=t.replace(/FromIndex$/,``),r=t!==n,i=Mt.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||jt.includes(n)))return;let a=async function(e,...t){let a=this.transaction(e,i?`readwrite`:`readonly`),o=a.store;
1return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&a.done]))[0]};return Nt.set(t,a),a}Tt(e=>({...e,get:(t,n,r)=>Pt(t,n)||e.get(t,n,r),has:(t,n)=>!!Pt(t,n)||e.has(t,n)}));var Ft=s({FirebaseError:()=>ke,SDK_VERSION:()=>An,_DEFAULT_ENTRY_NAME:()=>mn,_addComponent:()=>yn,_addOrOverwriteComponent:()=>bn,_apps:()=>gn,_clearComponents:()=>Tn,_components:()=>vn,_getProvider:()=>Sn,_isFirebaseApp:()=>C,_isFirebaseServerApp:()=>w,_isFirebaseServerAppSettings:()=>wn,_registerComponent:()=>xn,_removeServiceInstance:()=>Cn,_serverApps:()=>_n,deleteApp:()=>Fn,getApp:()=>Nn,getApps:()=>Pn,initializeApp:()=>jn,initializeServerApp:()=>Mn,onLog:()=>In,registerVersion:()=>T,setLogLevel:()=>Ln}),It=class{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(Lt(e)){let t=e.getImmediate();return`${t.library}/${t.version}`}else return null}).filter(e=>e).join(` `)}};function Lt(e){return e.getComponent()?.type===`VERSION`}var Rt=`@firebase/app`,zt=`0.14.13`,Bt=new lt(`@firebase/app`),Vt=`@firebase/app-compat`,Ht=`@firebase/analytics-compat`,Ut=`@firebase/analytics`,Wt=`@firebase/app-check-compat`,Gt=`@firebase/app-check`,Kt=`@firebase/auth`,qt=`@firebase/auth-compat`,S=`@firebase/database`,Jt=`@firebase/data-connect`,Yt=`@firebase/database-compat`,Xt=`@firebase/functions`,Zt=`@firebase/functions-compat`,Qt=`@firebase/installations`,$t=`@firebase/installations-compat`,en=`@firebase/messaging`,tn=`@firebase/messaging-compat`,nn=`@firebase/performance`,rn=`@firebase/performance-compat`,an=`@firebase/remote-config`,on=`@firebase/remote-config-compat`,sn=`@firebase/storage`,cn=`@firebase/storage-compat`,ln=`@firebase/firestore`,un=`@firebase/ai`,dn=`@firebase/firestore-compat`,fn=`firebase`,pn=`12.14.0`,mn=`[DEFAULT]`,hn={[Rt]:`fire-core`,[Vt]:`fire-core-compat`,[Ut]:`fire-analytics`,[Ht]:`fire-analytics-compat`,[Gt]:`fire-app-check`,[Wt]:`fire-app-check-compat`,[Kt]:`fire-auth`,[qt]:`fire-auth-compat`,[S]:`fire-rtdb`,[Jt]:`fire-data-connect`,[Yt]:`fire-rtdb-compat`,[Xt]:`fire-fn`,[Zt]:`fire-fn-compat`,[Qt]:`fire-iid`,[$t]:`fire-iid-compat`,[en]:`fire-fcm`,[tn]:`fire-fcm-compat`,[nn]:`fire-perf`,[rn]:`fire-perf-compat`,[an]:`fire-rc`,[on]:`fire-rc-compat`,[sn]:`fire-gcs`,[cn]:`fire-gcs-compat`,[ln]:`fire-fst`,[dn]:`fire-fst-compat`,[un]:`fire-vertex`,"fire-js":`fire-js`,[fn]:`fire-js-all`},gn=new Map,_n=new Map,vn=new Map;function yn(e,t){try{e.container.addComponent(t)}catch(n){Bt.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function bn(e,t){e.container.addOrOverwriteComponent(t)}function xn(e){let t=e.name;if(vn.has(t))return Bt.debug(`There were multiple attempts to register component ${t}.`),!1;vn.set(t,e);for(let t of gn.values())yn(t,e);for(let t of _n.values())yn(t,e);return!0}function Sn(e,t){let n=e.container.getProvider(`heartbeat`).getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function Cn(e,t,n=mn){Sn(e,t).clearInstance(n)}function C(e){return e.options!==void 0}function wn(e){return C(e)?!1:`authIdToken`in e||`appCheckToken`in e||`releaseOnDeref`in e||`automaticDataCollectionEnabled`in e}function w(e){return e==null?!1:e.settings!==void 0}function Tn(){vn.clear()}var En=new Ae(`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.`,"invali
1d-server-app-environment":`FirebaseServerApp is not for use in browser environments.`}),Dn=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 b(`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 En.create(`app-deleted`,{appName:this._name})}};function On(e,t){let n=te(e.split(`.`)[1]);if(n===null){console.error(`FirebaseServerApp ${t} is invalid: second part could not be parsed.`);return}if(JSON.parse(n).exp===void 0){console.error(`FirebaseServerApp ${t} is invalid: expiration claim could not be parsed`);return}JSON.parse(n).exp*1e3-new Date().getTime()<=0&&console.error(`FirebaseServerApp ${t} is invalid: the token has expired.`)}var kn=class extends Dn{constructor(e,t,n,r){let i=t.automaticDataCollectionEnabled===void 0?!0:t.automaticDataCollectionEnabled,a={name:n,automaticDataCollectionEnabled:i};e.apiKey===void 0?super(e.options,a,r):super(e,a,r),this._serverConfig={automaticDataCollectionEnabled:i,...t},this._serverConfig.authIdToken&&On(this._serverConfig.authIdToken,`authIdToken`),this._serverConfig.appCheckToken&&On(this._serverConfig.appCheckToken,`appCheckToken`),this._finalizationRegistry=null,typeof FinalizationRegistry<`u`&&(this._finalizationRegistry=new FinalizationRegistry(()=>{this.automaticCleanup()})),this._refCount=0,this.incRefCount(this._serverConfig.releaseOnDeref),this._serverConfig.releaseOnDeref=void 0,t.releaseOnDeref=void 0,T(Rt,zt,`serverapp`)}toJSON(){}get refCount(){return this._refCount}incRefCount(e){this.isDeleted||(this._refCount++,e!==void 0&&this._finalizationRegistry!==null&&this._finalizationRegistry.register(e,this))}decRefCount(){return this.isDeleted?0:--this._refCount}automaticCleanup(){Fn(this)}get settings(){return this.checkDestroyed(),this._serverConfig}checkDestroyed(){if(this.isDeleted)throw En.create(`server-app-deleted`)}},An=pn;function jn(e,t={}){let n=e;typeof t!=`object`&&(t={name:t});let r={name:mn,automaticDataCollectionEnabled:!0,...t},i=r.name;if(typeof i!=`string`||!i)throw En.create(`bad-app-name`,{appName:String(i)});if(n||=de(),!n)throw En.create(`no-options`);let a=gn.get(i);if(a){if(v(n,a.options)&&v(r,a.config))return a;throw En.create(`duplicate-app`,{appName:i})}let o=new rt(i);for(let e of vn.values())o.addComponent(e);let s=new Dn(n,r,o);return gn.set(i,s),s}function Mn(e,t={}){if(_e()&&!ve())throw En.create(`invalid-server-app-environment`);let n,r=t||{};if(e&&(C(e)?n=e.options:wn(e)?r=e:n=e),r.automaticDataCollectionEnabled===void 0&&(r.automaticDataCollectionEnabled=!0),n||=de(),!n)throw En.create(`no-options`);let i={...r,...n};i.releaseOnDeref!==void 0&&delete i.releaseOnDeref;let a=e=>[...e].reduce((e,t)=>Math.imul(31,e)+t.charCodeAt(0)|0,0);if(r.releaseOnDeref!==void 0&&typeof FinalizationRegistry>`u`)throw En.create(`finalization-registry-not-supported`,{});let o=``+a(JSON.stringify(i)),s=_n.get(o);if(s)return s.incRefCount(r.releaseOnDeref),s;let c=new rt(o);for(let e of vn.values())c.addComponent(e);let l=new kn(n,r,o,c);return _n.set(o,l),l}function Nn(e=mn){let t=gn.get(e);if(!t&&e===`[DEFAULT]`&&de())return jn();if(!t)throw En.create(`no-app`,{appName:e});return t}function Pn(){return Array.from(gn.values())}async function Fn(e){let t=!1,n=e.name;gn.has(n)?(t=!0,gn.delete(n)):_n.has(n)&&e.decRefCount()<=0&&(_n.delete(n),t=!0),t&&(await Promise.all(e.container.getProviders().map(e=>e.delete())),e.isDeleted=!0)}function T(e,t,n){let r=hn[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 "/")`),Bt.warn(e.join(` `));return}xn(new b(`${r}-version`,()=>({library:r,version:t}),`VERSION`))}function In(e,t){if(e!==null&&typeof e!=`function`)throw En.create(`invalid-log-argument`);dt(e,t)}function Ln(e){ut(e)}var Rn=`firebase-heartbeat-database`,zn=1,Bn=`firebase-heartbeat-store`,Vn=null;function Hn(){return Vn||=At(Rn,zn,{upgrade:(e,t)=>{switch(t){case 0:try{e.createObjectStore(Bn)}catch(e){console.warn(e)}}}}).catch(e=>{throw En.create(`idb-open`,{originalErrorMessage:e.message})}),Vn}async function Un(e){try{let t=(await Hn()).transaction(Bn),n=await t.objectStore(Bn).get(Gn(e));return await t.done,n}catch(e){if(e instanceof ke)Bt.warn(e.message);
1else{let t=En.create(`idb-get`,{originalErrorMessage:e?.message});Bt.warn(t.message)}}}async function Wn(e,t){try{let n=(await Hn()).transaction(Bn,`readwrite`);await n.objectStore(Bn).put(t,Gn(e)),await n.done}catch(e){if(e instanceof ke)Bt.warn(e.message);else{let t=En.create(`idb-set`,{originalErrorMessage:e?.message});Bt.warn(t.message)}}}function Gn(e){return`${e.name}!${e.options.appId}`}var Kn=1024,qn=30,Jn=class{constructor(e){this.container=e,this._heartbeatsCache=null;let t=this.container.getProvider(`app`).getImmediate();this._storage=new Zn(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=Yn();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>qn){let e=$n(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){Bt.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return``;let e=Yn(),{heartbeatsToSend:t,unsentEntries:n}=Xn(this._heartbeatsCache.heartbeats),r=ee(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 Bt.warn(e),``}}};function Yn(){return new Date().toISOString().substring(0,10)}function Xn(e,t=Kn){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]}),Qn(n)>t){n.pop();break}}else if(e.dates.push(i.date),Qn(n)>t){e.dates.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}var Zn=class{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return Te()?Ee().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){let e=await Un(this.app);return e?.heartbeats?e:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){let t=await this.read();return Wn(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 Wn(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:[...t.heartbeats,...e.heartbeats]})}else return}};function Qn(e){return ee(JSON.stringify({version:2,heartbeats:e})).length}function $n(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 er(e){xn(new b(`platform-logger`,e=>new It(e),`PRIVATE`)),xn(new b(`heartbeat`,e=>new Jn(e),`PRIVATE`)),T(Rt,zt,e),T(Rt,zt,`esm2020`),T(`fire-js`,``)}er(``);var tr=class{constructor(e,t){this._delegate=e,this.firebase=t,yn(e,new b(`app-compat`,()=>this,`PUBLIC`)),this.container=e.container}get automaticDataCollectionEnabled(){return this._delegate.automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this._delegate.automaticDataCollectionEnabled=e}get name(){return this._delegate.name}get options(){return this._delegate.options}delete(){return new Promise(e=>{this._delegate.checkDestroyed(),e()}).then(()=>(this.firebase.INTERNAL.removeApp(this.name),Fn(this._delegate)))}_getService(e,t=mn){this._delegate.checkDestroyed();let n=this._delegate.container.getProvider(e);return!n.isInitialized()&&n.getComponent()?.instantiationMode===`EXPLICIT`&&n.initialize(),n.getImmediate({identifier:t})}_removeServiceInstance(e,t=mn){this._delegate.container.getProvider(e).
1clearInstance(t)}_addComponent(e){yn(this._delegate,e)}_addOrOverwriteComponent(e){bn(this._delegate,e)}toJSON(){return{name:this.name,automaticDataCollectionEnabled:this.automaticDataCollectionEnabled,options:this.options}}},nr=new Ae(`app-compat`,`Firebase`,{"no-app":`No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()`,"invalid-app-argument":`firebase.{$appName}() takes either no argument or a Firebase App instance.`});function rr(e){let t={},n={__esModule:!0,initializeApp:a,app:i,registerVersion:T,setLogLevel:Ln,onLog:In,apps:null,SDK_VERSION:An,INTERNAL:{registerComponent:s,removeApp:r,useAsService:c,modularAPIs:Ft}};n.default=n,Object.defineProperty(n,"apps",{get:o});function r(e){delete t[e]}function i(e){if(e||=`[DEFAULT]`,!Ie(t,e))throw nr.create(`no-app`,{appName:e});return t[e]}i.App=e;function a(r,i={}){let a=jn(r,i);if(Ie(t,a.name))return t[a.name];let o=new e(a,n);return t[a.name]=o,o}function o(){return Object.keys(t).map(e=>t[e])}function s(t){let r=t.name,a=r.replace(`-compat`,``);if(xn(t)&&t.type===`PUBLIC`){let o=(e=i())=>{if(typeof e[a]!=`function`)throw nr.create(`invalid-app-argument`,{appName:r});return e[a]()};t.serviceProps!==void 0&&ne(o,t.serviceProps),n[a]=o,e.prototype[a]=function(...e){return this._getService.bind(this,r).apply(this,t.multipleInstances?e:[])}}return t.type===`PUBLIC`?n[a]:null}function c(e,t){return t===`serverAuth`?null:t}return n}function ir(){let e=rr(tr);e.INTERNAL={...e.INTERNAL,createFirebaseNamespace:ir,extendNamespace:t,createSubscribe:He,ErrorFactory:Ae,deepExtend:ne};function t(t){ne(e,t)}return e}var ar=ir(),or=new lt(`@firebase/app-compat`),sr=`@firebase/app-compat`,cr=`0.5.13`;function lr(e){T(sr,cr,e)}try{let e=ie();if(e.firebase!==void 0){or.warn(` 2 Warning: Firebase is already defined in the global scope. Please make sure 3 Firebase library is only loaded once. 4 `);let t=e.firebase.SDK_VERSION;t&&t.indexOf(`LITE`)>=0&&or.warn(` 5 Warning: You are trying to load Firebase while using Firebase Performance standalone script. 6 You should load Firebase Performance with this instance of Firebase to avoid loading duplicate code. 7 `)}}catch{}var ur=ar;lr(),ur.registerVersion(`firebase`,`12.14.0`,`app-compat`);var dr=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},fr={},pr,mr;(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>>>
726),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;
7e.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,mr=fr.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,pr=fr.Integer=o}).apply(dr===void 0?typeof self<`u`?self:typeof window<`u`?window:{}:dr);var hr=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},gr={},_r,vr,yr,br,xr,Sr,Cr,wr;(function(){var e,t=Object.defineProperty;function n(e){e=[typeof globalThis==`object`&&globalThis,e,typeof window==`object`&&window,typeof self==`object`&&self,typeof hr==`object`&&hr];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),_=0;function he(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=++_,this.da=this.fa=!1}function ge(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function _e(e,t,n){for(let r in e)t.call(n,e[r],r,e)}function ve(e,t){for(let n in e)t.call(void 0,e[n],n,e)}function ye(e){let t={};for(let n in e)t[n]=e[n];return t}let be=`constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleStr
7ing toString valueOf`.split(` `);function xe(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<be.length;t++)n=be[t],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function Se(e){this.src=e,this.g={},this.h=0}Se.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=we(e,t,r,i);return o>-1?(t=e[o],n||(t.fa=!1)):(t=new he(t,this.src,a,!!r,i),t.fa=n,e.push(t)),t};function Ce(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&&(ge(t),e.g[n].length==0&&(delete e.g[n],e.h--))}}function we(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 Te=`closure_lm_`+(Math.random()*1e6|0),Ee={};function De(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++)De(e,t[a],n,r,i);return null}return n=Le(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[Te]=c=new Se(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=Le(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=Le(n),e&&e[me]?(e=e.i,a=String(t).toString(),a in e.g&&(t=e.g[a],n=we(t,n,r,i),n>-1&&(ge(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=we(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])Ce(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))?(Ce(n,e),n.h==0&&(n.src=null,t[Te]=null)):ge(e)}}}function Ne(e){return e in Ee?Ee[e]:Ee[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[Te],e instanceof Se?e:null}var Ie=`__closure_events_fn_`+(Math.random()*1e9>>>0);function Le(e){return typeof e==`function`?e:(e[Ie]||(e[Ie]=function(t){return e.handleEvent(t)}),e[Ie])}function v(){le.call(this),this.i=new Se(this),this.M=this,this.G=null}d(v,le),v.prototype[me]=!0,v.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),xe(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}v.prototype.N=function(){if(v.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++)ge(n[e]);delete e.g[t],e.h--}}this.G=null},v.prototype.J=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},v.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&&Ce(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){_e(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 y={OPEN:`a`,hb:`b`,ERROR:`c`,tb:`d`};function Ze(){ue.call(this,`d`)}d(Ze,ue);function Qe(){ue.call(this,`c`)}d(Qe,ue);var b={},$e=null;function et(){return $e||=new v}b.Ia=`serverreachability`;function tt(e){ue.call(this,b.Ia,e)}d(tt,ue);function nt(e){let t=et();Re(t,new tt(t))}b.STAT_EVENT=`statevent`;function rt(e,t){ue.call(this,b.STAT_EVENT,e),this.stat=t}d(rt,ue);function it(e){let t=et();Re(t,new rt(t,e))}b.Ja=`timingevent`;function x(e,t){ue.call(this,b.Ja,e),this.size=t}d(x,ue);function at(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 ot(){this.g=!0}ot.prototype.ua=function(){this.g=!1};function st(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(`=`);
7if(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+` 8`+n+` 9`+o})}function ct(e,t,n,r,i,a,o){e.info(function(){return`XMLHTTP RESP (`+r+`) [ attempt `+i+`]: `+t+` 10`+n+` 11`+a+` `+o})}function lt(e,t,n,r){e.info(function(){return`XMLHTTP TEXT (`+t+`): `+dt(e,n)+(r?` `+r:``)})}function ut(e,t){e.info(function(){return`TIMEOUT: `+t})}ot.prototype.info=function(){};function dt(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 ft={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},pt={ib:`complete`,Fb:`success`,ERROR:`error`,Ga:`abort`,xb:`ready`,yb:`readystatechange`,TIMEOUT:`timeout`,sb:`incrementaldata`,wb:`progress`,lb:`downloadprogress`,Nb:`uploadprogress`},mt;function ht(){}d(ht,Ye),ht.prototype.g=function(){return new XMLHttpRequest},mt=new ht;function gt(e){return encodeURIComponent(String(e))}function _t(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 vt(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 yt}function yt(){this.i=null,this.g=``,this.h=!1}var bt={},xt={};function St(e,t,n){e.M=1,e.A=Jt(Wt(t)),e.u=n,e.R=!0,Ct(e,null)}function Ct(e,t){e.F=Date.now(),Dt(e),e.B=Wt(e.A);var n=e.B,r=e.S;Array.isArray(r)||(r=[String(r)]),ln(n.i,`t`,r),e.C=0,n=e.j.L,e.h=new yt,e.g=Zn(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=De(n,i[e],r||t.handleEvent,!1,t.h||t);if(!a)break;t.g[a.key]=a}t=e.J?ye(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)),nt(),st(e.i,e.v,e.B,e.l,e.S,e.u)}vt.prototype.ba=function(e){e=e.target;let t=this.O;t&&kn(e)==3?t.j():this.Y(e)},vt.prototype.Y=function(e){try{if(e==this.g)a:{let s=kn(this.g),c=this.g.ya(),l=this.g.ca();if(!(s<3)&&(s!=3||this.g&&(this.h.h||this.g.la()||An(this.g)))){this.K||s!=4||c==7||nt(c==8||l<=0?3:2),kt(this);var t=this.g.ca();this.X=t;var n=wt(this);if(this.o=t==200,ct(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)lt(this.i,this.l,e,`Initial handshake response via X-HTTP-Initial-Response`),this.L=!0,Mt(this,e);else{this.o=!1,this.m=3,it(12),jt(this),At(this);break a}}if(this.R){e=!0;let t;for(;!this.K&&this.C<n.length;)if(t=Et(this,n),t==xt){s==4&&(this.m=4,it(14),e=!1),lt(this.i,this.l,null,`[Incomplete Response]`);break}else if(t==bt){this.m=4,it(15),lt(this.i,this.l,n,`[Invalid Chunk]`),e=!1;break}else lt(this.i,this.l,t,null),Mt(this,t);if(Tt(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,it(16),e=!1),this.o=this.o&&e,!e)lt(this.i,this.l,n,`[Invalid Chunked Response]`),jt(this),At(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),Un(o),o.P=!0,it(11))}}else lt(this.i,this.l,n,null),Mt(this,n);s==4&&jt(this),this.o&&!this.K&&(s==4?Kn(this.j,this):(this.o=!1,Dt(this)))}else jn(this.g),t==400&&n.indexOf(`Unknown SID`)>0?(this.m=3,it(12)):(this.m=0,it(13)),jt(this),At(this)}}}catch{}};function wt(e){if(!Tt(e))return e.g.la();let t=An(e.g);if(t===``)return``;let n=``,r=t.length,i=kn(e.g)==4;if(!e.h.i){if(typeof TextDecoder>`u`)return jt(e),At(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 Tt(e){return e.g?e.v==`GET`&&e.M!=2&&e.j.Aa:!1}function Et(e,t){var n=e.C,r=t.indexOf(` 12`,n);return r==-1?xt:(n=Number(t.substring(n,r)),isNaN(n)?bt:(r+=1,r+n>t.length?xt:(t=t.slice(r,r+n),e.C=r+n,t)))}vt.prototype.cancel=function(){this.K=!0,jt(this)};function Dt(e){e.T=Date.now()+e.H,Ot(e,e.H)}function Ot(e,t){if(e.D!=null)throw Error(`WatchDog timer not null`);e.D=at(l(e.aa,e),t)}function kt(e){e.D&&=(o.clearTimeout(e.D),null)}vt.prototype.aa=function(){this.D=null;let e=Date.now();e-this.T>=0?(ut(this.i,this.B),this.M!=2&&(nt(),it(17)),jt(this),this.m=2,At(this)):Ot(this,this.T-e)};function At(e){e.j.I==0||e.K||Kn(e.j,e)}function jt(e){kt(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.dis
12pose())}function Mt(e,t){try{var n=e.j;if(n.I!=0&&(n.g==e||Lt(n.h,e))){if(!e.L&&Lt(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)Gn(n),Fn(n);else break a;Hn(n),it(18)}}else n.xa=i[1],0<n.xa-n.K&&i[2]<37500&&n.F&&n.A==0&&!n.C&&(n.C=at(l(n.Va,n),6e3));It(n.h)<=1&&n.ta&&(n.ta=void 0)}else Jn(n,11)}else if((e.L||n.g==e)&&Gn(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&&=(Rt(a,a.h),null))}if(r.G){let e=d.g?d.g.getResponseHeader(`X-HTTP-Session-Id`):null;e&&(r.wa=e,S(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=Xn(r,r.L?r.ba:null,r.W),o.L){zt(r.h,o);var s=o,c=r.O;c&&(s.H=c),s.D&&(kt(s),Dt(s)),r.g=o}else Vn(r);n.i.length>0&&In(n)}else l[0]!=`stop`&&l[0]!=`close`||Jn(n,7);else n.I==3&&(l[0]==`stop`||l[0]==`close`?l[0]==`stop`?Jn(n,7):Pn(n):l[0]!=`noop`&&n.l&&n.l.qa(l),n.A=0)}}nt(4)}catch{}}var Nt=class{constructor(e,t){this.g=e,this.map=t}};function Pt(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 Ft(e){return e.h?!0:e.g?e.g.size>=e.j:!1}function It(e){return e.h?1:e.g?e.g.size:0}function Lt(e,t){return e.h?e.h==t:e.g?e.g.has(t):!1}function Rt(e,t){e.g?e.g.add(t):e.h=t}function zt(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}Pt.prototype.cancel=function(){if(this.i=Bt(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 Bt(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 Vt=RegExp(`^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$`);function Ht(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 Ut(e){this.g=this.o=this.j=``,this.u=null,this.m=this.h=``,this.l=!1;let t;e instanceof Ut?(this.l=e.l,Gt(this,e.j),this.o=e.o,this.g=e.g,Kt(this,e.u),this.h=e.h,qt(this,un(e.i)),this.m=e.m):e&&(t=String(e).match(Vt))?(this.l=!1,Gt(this,t[1]||``,!0),this.o=Yt(t[2]||``),this.g=Yt(t[3]||``,!0),Kt(this,t[4]),this.h=Yt(t[5]||``,!0),qt(this,t[6]||``,!0),this.m=Yt(t[7]||``)):(this.l=!1,this.i=new rn(null,this.l))}Ut.prototype.toString=function(){let e=[];var t=this.j;t&&e.push(Xt(t,Qt,!0),`:`);var n=this.g;return(n||t==`file`)&&(e.push(`//`),(t=this.o)&&e.push(Xt(t,Qt,!0),`@`),e.push(gt(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(Xt(n,n.charAt(0)==`/`?en:$t,!0))),(n=this.i.toString())&&e.push(`?`,n),(n=this.m)&&e.push(`#`,Xt(n,nn)),e.join(``)},Ut.prototype.resolve=function(e){let t=Wt(this),n=!!e.j;n?Gt(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)Kt(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?qt(t,un(e.i)):n=!!e.m,n&&(t.m=e.m),t};function Wt(e){return new Ut(e)}function Gt(e,t,n){e.j=n?Yt(t,!0):t,e.j&&=e.j.replace(/:$/,``)}function Kt(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 qt(e,t,n){t instanceof rn?(e.i=t,fn(e.i,e.l)):(n||(t=Xt(t,tn)),e.i=new rn(t,e.l))}function S(e,t,n){e.i.set(t,n)}function Jt(e){return S(e,`zx`,Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),e}function Yt(e,t){return e?t?decodeURI(e.replace(/%25/g,`%2525`)):decodeURIComponent(e):``}function Xt(e,t,n){return typeof e==`string`?(e=encodeURI(e).replace(t,Zt),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,`%$1`)),e):null}function Zt(e){return e=e.charCodeAt(0),`%`+(e>>4&15).toString(16)+(e&15).toString(16)}var Qt=/[#\/\?@]/g,$t=/[#\?:]/g,en=/[#\?]/g,tn=/[#\?@]/g,nn=/#/g;function rn(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function an(e){e.g||(e.g=new Map,e.h=0,e.i&&Ht(e.i,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g,` `)),n)}))}e=rn.prototype,e.add=function(e,t){an(this),this.i=null,e=dn(this,e);let n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this};function on(e,t){an(e),t=dn(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function sn(e,t){return an(e),t=dn(e,t),e.g.has(t)}e.forEach=function(e,t){an(this),this.g.forEach(function(n,r){n.forEac
12h(function(n){e.call(t,n,r,this)},this)},this)};function cn(e,t){an(e);let n=[];if(typeof t==`string`)sn(e,t)&&(n=n.concat(e.g.get(dn(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 an(this),this.i=null,e=dn(this,e),sn(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=cn(this,e),e.length>0?String(e[0]):t):t};function ln(e,t,n){on(e,t),n.length>0&&(e.i=null,e.g.set(dn(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=gt(n);n=cn(this,n);for(let t=0;t<n.length;t++){let r=i;n[t]!==``&&(r+=`=`+gt(n[t])),e.push(r)}}return this.i=e.join(`&`)};function un(e){let t=new rn;return t.i=e.i,e.g&&(t.g=new Map(e.g),t.h=e.h),t}function dn(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function fn(e,t){t&&!e.j&&(an(e),e.i=null,e.g.forEach(function(e,t){let n=t.toLowerCase();t!=n&&(on(this,t),ln(this,n,e))},e)),e.j=t}function pn(e,t){let n=new ot;if(o.Image){let r=new Image;r.onload=u(hn,n,`TestLoadImage: loaded`,!0,t,r),r.onerror=u(hn,n,`TestLoadImage: error`,!1,t,r),r.onabort=u(hn,n,`TestLoadImage: abort`,!1,t,r),r.ontimeout=u(hn,n,`TestLoadImage: timeout`,!1,t,r),o.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}function mn(e,t){let n=new ot,r=new AbortController,i=setTimeout(()=>{r.abort(),hn(n,`TestPingServer: timeout`,!1,t)},1e4);fetch(e,{signal:r.signal}).then(e=>{clearTimeout(i),e.ok?hn(n,`TestPingServer: ok`,!0,t):hn(n,`TestPingServer: server error`,!1,t)}).catch(()=>{clearTimeout(i),hn(n,`TestPingServer: error`,!1,t)})}function hn(e,t,n,r,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),r(n)}catch{}}function gn(){this.g=new Je}function _n(e){this.i=e.Sb||null,this.h=e.ab||!1}d(_n,Ye),_n.prototype.g=function(){return new vn(this.i,this.h)};function vn(e,t){v.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(vn,v),e=vn.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,xn(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,bn(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,xn(this)),this.g&&(this.readyState=3,xn(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;yn(this)}else e.text().then(this.Oa.bind(this),this.ga.bind(this))};function yn(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?bn(this):xn(this),this.readyState==3&&yn(this)}},e.Oa=function(e){this.g&&(this.response=this.responseText=e,bn(this))},e.Na=function(e){this.g&&(this.response=e,bn(this))},e.ga=function(){this.g&&bn(this)};function bn(e){e.readyState=4,e.l=null,e.j=null,e.B=null,xn(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 13`)};function xn(e){e.onreadystatechange&&e.onreadystatechange.call(e)}Object.defineProperty(vn.prototype,"withCredentials",{get:function(){return this.m===`include`},set:function(e){this.m=e?`include`:`same-origin`}});function Sn(e){let t=``;return _e(e,function(e,n){t+=n,t+=`:`,t+=e,t+=`\r 14`}),t}function Cn(e,t,n){a:{for(r in n){var r=!1;break a}r=!0}
14r||(n=Sn(n),typeof e==`string`||S(e,t,n))}function C(e){v.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(C,v);var wn=/^https?$/i,w=[`POST`,`PUT`];e=C.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():mt.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){Tn(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){Tn(this,e)}};function Tn(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.o=5,En(e),On(e)}function En(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`),On(this))},e.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),On(this,!0)),C.Z.N.call(this)},e.Ca=function(){this.u||(this.B||this.v||this.j?Dn(this):this.Xa())},e.Xa=function(){Dn(this)};function Dn(e){if(e.h&&a!==void 0){if(e.v&&kn(e)==4)setTimeout(e.Ca.bind(e),0);else if(Re(e,`readystatechange`),kn(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(Vt)[1]||null;!t&&o.self&&o.self.location&&(t=o.self.location.protocol.slice(0,-1)),r=!wn.test(t?t.toLowerCase():``)}n=r}if(n)Re(e,`complete`),Re(e,`success`);else{e.o=6;try{var i=kn(e)>2?e.g.statusText:``}catch{i=``}e.l=i+` [`+e.ca()+`]`,En(e)}}finally{On(e)}}}}function On(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 kn(e){return e.g?e.g.readyState:0}e.ca=function(){try{return kn(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 An(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 jn(e){let t={};e=(e.g&&kn(e)>=2&&e.g.getAllResponseHeaders()||``).split(`\r 15`);for(let r=0;r<e.length;r++){if(fe(e[r]))continue;var n=_t(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)}ve(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 Mn(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function Nn(e){this.za=0,this.i=[],this.j=new ot,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=Mn(`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=Mn(`baseRetryDelayMs`,5e3,e),this.Za=Mn(`retryDelaySeedMs`,1e4,e),this.Ta=Mn(`forwardChannelMaxRetries`,2,e),this.va=Mn(`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 Pt(e&&e.concurrentRequestLimit),this.Ba=new gn,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=Nn.prototype,e.ka=8,e.I=1,e.connect=function(e,t,n,r){it(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=Xn(this,null,this.W),In(this)};function Pn(e){if(T(e),e.I==3){var t=e.V++,n=Wt(e.J);if(S(n,`SID`,e.M),S(n,`RID`,t),S(n,`TYPE`,`terminate`),zn(e,n),t=new vt(e,e.j,t),t.M=2,t.A=Jt(Wt(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=Zn(t.j,null),t.g.ea(t.A)),t.F=Date.now(),Dt(t)}Yn(e)}function Fn(e){e.g&&=(Un(e),e.g.cancel(),null)}function T(e){Fn(e),e.v&&=(o.clearTimeout(e.v),null),Gn(e),e.h.cancel(),e.m&&=(typeof e.m==`number`&&o.clearTimeout(e.m),null)}function In(e){if(!Ft(e.h)&&!e.m){e.m=!0;var t=e.Ea;ie||se(),ae||=(ie(),!0),oe.add(t,e),e.D=0}}function Ln(e,t){return It(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=at(l(e.Ea,e,t),qn(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 vt(this,this.j,e),a=this.o;if(this.U&&(a?(a=ye(a),xe(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=Bn(this,i,t),n=Wt(this.J),S(n,`RID`,e),S(n,`CVER`,22),this.G&&S(n,`X-HTTP-Session-Id`,this.G),zn(this,n),a&&(this.R?t=`headers=`+gt(Sn(a))+`&`+t:this.u&&Cn(n,this.u,a)),Rt(this.h,i),this.Ra&&S(n,`TYPE`,`init`),this.S?(S(n,`$req`,t),S(n,`SID`,`null`),i.U=!0,St(i,n,null)):St(i,n,t),this.I=2}}else this.I==3&&(e?Rn(this,e):this.i.length==0||Ft(this.h)||Rn(this))};function Rn(e,t){var n=t?t.l:e.V++;let r=Wt(e.J);S(r,`SID`,e.M),S(r,`RID`,n),S(r,`AID`,e.K),zn(e,r),e.u&&e.o&&Cn(r,e.u,e.o),n=new vt(e,e.j,n,e.D+1),e.u===null&&(n.J=e.o),t&&(e.i=t.G.concat(e.i)),t=Bn(e,n,1e3),n.H=Math.round(e.va*.5)+Math.round(e.va*.5*Math.random()),Rt(e.h,n),St(n,r,t)}function zn(e,t){e.H&&_e(e.H,function(e,n){S(t,n,e)}),e.l&&_e({},function(e,n){S(t,n,e)})}function Bn(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 Vn(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 Hn(e){return e.g||e.v||e.A>=3?!1:(e.Y++,e.v=at(l(e.Da,e),qn(e,e.A)),e.A++,!0)}
vendor: 5,189 bytes, line 15
15e.Da=function(){if(this.v=null,Wn(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=at(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,it(10),Fn(this),Wn(this))};function Un(e){e.B!=null&&(o.clearTimeout(e.B),e.B=null)}function Wn(e){e.g=new vt(e,e.j,`rpc`,e.Y),e.u===null&&(e.g.J=e.o),e.g.P=0;var t=Wt(e.na);S(t,`RID`,`rpc`),S(t,`SID`,e.M),S(t,`AID`,e.K),S(t,`CI`,e.F?`0`:`1`),!e.F&&e.ia&&S(t,`TO`,e.ia),S(t,`TYPE`,`xmlhttp`),zn(e,t),e.u&&e.o&&Cn(t,e.u,e.o),e.O&&(e.g.H=e.O);var n=e.g;e=e.ba,n.M=1,n.A=Jt(Wt(t)),n.u=null,n.R=!0,Ct(n,e)}e.Va=function(){this.C!=null&&(this.C=null,Fn(this),Hn(this),it(19))};function Gn(e){e.C!=null&&(o.clearTimeout(e.C),e.C=null)}function Kn(e,t){var n=null;if(e.g==t){Gn(e),Un(e),e.g=null;var r=2}else if(Lt(e.h,t))n=t.G,zt(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=et(),Re(r,new x(r,n)),In(e)}else Vn(e);else if(i=t.m,i==3||i==0&&t.X>0||!(r==1&&Ln(e,t)||r==2&&Hn(e)))switch(n&&n.length>0&&(t=e.h,t.i=t.i.concat(n)),i){case 1:Jn(e,5);break;case 4:Jn(e,10);break;case 3:Jn(e,6);break;default:Jn(e,2)}}}function qn(e,t){let n=e.Qa+Math.floor(Math.random()*e.Za);return e.isActive()||(n*=2),n*t}function Jn(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 Ut(r||`//www.google.com/images/cleardot.gif`),o.location&&o.location.protocol==`http`||Gt(r,`https`),Jt(r),t?pn(r.toString(),n):mn(r.toString(),n)}else it(2);e.I=0,e.l&&e.l.pa(t),Yn(e),T(e)}e.bb=function(e){e?(this.j.info(`Successfully pinged google.com`),it(2)):(this.j.info(`Failed to ping google.com`),it(1))};function Yn(e){if(e.I=0,e.ja=[],e.l){let t=Bt(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 Xn(e,t,n){var r=n instanceof Ut?Wt(n):new Ut(n);if(r.g!=``)t&&(r.g=t+`.`+r.g),Kt(r,r.u);else{var i=o.location;r=i.protocol,t=t?t+`.`+i.hostname:i.hostname,i=+i.port;let e=new Ut(null);r&&Gt(e,r),t&&(e.g=t),i&&Kt(e,i),n&&(e.h=n),r=e}return n=e.G,t=e.wa,n&&t&&S(r,n,t),S(r,`VER`,e.ka),zn(e,r),r}function Zn(e,t,n){if(t&&!e.L)throw Error(`Can't create secondary domain capable XhrIo object.`);return t=e.Aa&&!e.ma?new C(new _n({ab:n})):new C(e.ma),t.Fa(e.L),t}e.isActive=function(){return!!this.l&&this.l.isActive(this)};function Qn(){}e=Qn.prototype,e.ra=function(){},e.qa=function(){},e.pa=function(){},e.oa=function(){},e.isActive=function(){return!0},e.Ka=function(){};function $n(){}$n.prototype.g=function(e,t){return new er(e,t)};function er(e,t){v.call(this),this.g=new Nn(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 rr(this)}d(er,v),er.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},er.prototype.close=function(){Pn(this.g)},er.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 Nt(t.Ya++,e)),t.I==3&&In(t)},er.prototype.N=function(){this.g.l=null,delete this.j,Pn(this.g),delete this.g,er.Z.N.call(this)};function tr(e){Ze.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(tr,Ze);function nr(){Qe.call(this),this.status=1}d(nr,Qe);function rr(e){this.g=e}d(rr,Qn),rr.prototype.ra=function(){Re(this.g,`a`)},rr.prototype.qa=function(e){Re(this.g,new tr(e))},rr.prototype.pa=function(e){Re(this.g,new nr)},rr.prototype.oa=function(){Re(this.g,`b`)},$n.prototype.createWebChannel=$n.prototype.g,er.prototype.send=er.prototype.o,er.prototype.open=er.prototype.m,er.prototype.close=er.prototype.close,wr=gr.createWebChannelTransport=function(){return new $n},Cr=gr.getStatEventTarget=function(){return et()},Sr=gr.Event=b,xr=gr.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},ft.NO_ERROR=0,ft.TIMEOUT=8,ft.HTTP_ERROR=6,br=gr.ErrorCode=ft,pt.COMPLETE=`complete`,yr=gr.EventType=pt,Xe.EventType=y,y.OPEN=`a`,y.CLOSE=`b`,y.ERROR=`c`,y.MESSAGE=`d`,v.prototype.listen=v.prototype.J,vr=gr.WebChannel=Xe,gr.FetchXmlHttpFactory=_n,C.prototype.listenOnce=C.prototype.K,C.prototype.getLastError=C.prototype.Ha,C.prototype.getLastErrorCode=C.prototype.ya,
15C.prototype.getStatus=C.prototype.ca,C.prototype.getResponseJson=C.prototype.La,C.prototype.getResponseText=C.prototype.la,C.prototype.send=C.prototype.ea,C.prototype.setWithCredentials=C.prototype.Fa,_r=gr.XhrIo=C}).apply(hr===void 0?typeof self<`u`?self:typeof window<`u`?window:{}:hr);var Tr=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}};Tr.UNAUTHENTICATED=new Tr(null),Tr.GOOGLE_CREDENTIALS=new Tr(`google-credentials-uid`),Tr.FIRST_PARTY=new Tr(`first-party-uid`),Tr.MOCK_USER=new Tr(`mock-user`);var Er=`12.14.0`;function Dr(e){Er=e}var Or=new lt(`@firebase/firestore`);function kr(){return Or.logLevel}function Ar(e){Or.setLogLevel(e)}function E(e,...t){if(Or.logLevel<=x.DEBUG){let n=t.map(Mr);Or.debug(`Firestore (${Er}): ${e}`,...n)}}function D(e,...t){if(Or.logLevel<=x.ERROR){let n=t.map(Mr);Or.error(`Firestore (${Er}): ${e}`,...n)}}function jr(e,...t){if(Or.logLevel<=x.WARN){let n=t.map(Mr);Or.warn(`Firestore (${Er}): ${e}`,...n)}}function Mr(e){if(typeof e==`string`)return e;try{return function(e){return JSON.stringify(e)}(e)}catch{return e}}function O(e,t,n){let r=`Unexpected state`;typeof t==`string`?r=t:n=t,Nr(e,r,n)}function Nr(e,t,n){let r=`FIRESTORE (${Er}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(n!==void 0)try{r+=` CONTEXT: `+JSON.stringify(n)}catch{r+=` CONTEXT: `+n}throw D(r),Error(r)}function k(e,t,n,r){let i=`Unexpected state`;typeof n==`string`?i=n:r=n,e||Nr(t,i,r)}function Pr(e,t){e||O(57014,t)}function A(e,t){return e}var j={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`},M=class extends ke{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}},Fr=class{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}},Ir=class{constructor(e,t){this.user=t,this.type=`OAuth`,this.headers=new Map,this.headers.set(`Authorization`,`Bearer ${e}`)}},Lr=class{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(Tr.UNAUTHENTICATED)))}shutdown(){}},Rr=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}},zr=class{constructor(e){this.t=e,this.currentUser=Tr.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){k(this.o===void 0,42304);let n=this.i,r=e=>this.i===n?Promise.resolve():(n=this.i,t(e)),i=new Fr;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new Fr,e.enqueueRetryable((()=>r(this.currentUser)))};let a=()=>{let t=i;e.enqueueRetryable((async()=>{await t.promise,await r(this.currentUser)}))},o=e=>{E(`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):(E(`FirebaseAuthCredentialsProvider`,`Auth not yet detected`),i.resolve(),i=new Fr)}}),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?(k(typeof t.accessToken==`string`,31837,{l:t}),new Ir(t.accessToken,this.currentUser)):null:(E(`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 k(e===null||typeof e==`string`,2055,{h:e}),new Tr(e)}},Br=class{constructor(e,t,n){this.P=e,this.T=t,this.I=n,this.type=`FirstParty`,this.user=Tr.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set(`X-Goog-AuthUser`,this.P);let e=this.A();return e&&this.R.set(`Authorization`,e),this.T&&this.R.set(`X-Goog-
15Iam-Authorization-Token`,this.T),this.R}},Vr=class{constructor(e,t,n){this.P=e,this.T=t,this.I=n}getToken(){return Promise.resolve(new Br(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable((()=>t(Tr.FIRST_PARTY)))}shutdown(){}invalidateToken(){}},Hr=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)}},Ur=class{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,w(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){k(this.o===void 0,3512);let n=e=>{e.error!=null&&E(`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,E(`FirebaseAppCheckTokenProvider`,`Received ${n?`new`:`existing`} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable((()=>n(t)))};let r=e=>{E(`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):E(`FirebaseAppCheckTokenProvider`,`AppCheck not yet detected`)}}),0)}getToken(){if(this.p)return Promise.resolve(new Hr(this.p));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((e=>e?(k(typeof e.token==`string`,44558,{tokenResult:e}),this.m=e.token,new Hr(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 Wr(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 Gr=class{static newId(){let e=``;for(;e.length<20;){let t=Wr(40);for(let n=0;n<t.length;++n)e.length<20&&t[n]<248&&(e+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(t[n]%62))}return e}};function N(e,t){return e<t?-1:+(e>t)}function Kr(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 Yr(n)===Yr(i)?N(n,i):Yr(n)?1:-1}return N(e.length,t.length)}var qr=55296,Jr=57343;function Yr(e){let t=e.charCodeAt(0);return t>=qr&&t<=Jr}function Xr(e,t,n){return e.length===t.length&&e.every(((e,r)=>n(e,t[r])))}function Zr(e){return e+`\0`}var Qr=`__name__`,$r=class e{constructor(e,t,n){t===void 0?t=0:t>e.length&&O(637,{offset:t,range:e.length}),n===void 0?n=e.length-t:n>e.length-t&&O(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 N(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)):Kr(t,n)}static isNumericId(e){return e.startsWith(`__id`)&&e.endsWith(`__`)}static extractNumericId(e){return pr.fromString(e.substring(4,e.length-2))}},P=class e extends $r{construct(t,n,r){return new e(t,n,r)}canonicalString(){return this.toArray().join(`/`)}toString(){return this.canonicalString()}
15toUriEncodedString(){return this.toArray().map(encodeURIComponent).join(`/`)}static fromString(...t){let n=[];for(let e of t){if(e.indexOf(`//`)>=0)throw new M(j.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)===`__name__`}static keyField(){return new e([Qr])}static fromServerFormat(t){let n=[],r=``,i=0,a=()=>{if(r.length===0)throw new M(j.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 M(j.INVALID_ARGUMENT,`Path has trailing escape character: `+t);let e=t[i+1];if(e!==`\\`&&e!==`.`&&e!=="`")throw new M(j.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 M(j.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)}static emptyPath(){return new e([])}},F=class e{constructor(e){this.path=e}static fromPath(t){return new e(P.fromString(t))}static fromName(t){return new e(P.fromString(t).popFirst(5))}static empty(){return new e(P.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&&P.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return P.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(t){return new e(new P(t.slice()))}};function ni(e,t,n){if(!n)throw new M(j.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function ri(e,t,n,r){if(!0===t&&!0===r)throw new M(j.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function ii(e){if(!F.isDocumentKey(e))throw new M(j.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function ai(e){if(F.isDocumentKey(e))throw new M(j.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`:O(12329,{type:typeof e})}function I(e,t){if(`_delegate`in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new M(j.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 M(j.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function ci(e,t){if(t<=0)throw new M(j.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}function li(e,t){let n={typeString:e};return t&&(n.value=t),n}function ui(e,t){if(!oi(e))throw new M(j.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 M(j.INVALID_ARGUMENT,n);return!0}var di=-62135596800,fi=1e6,L=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)*fi))}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0||t>=1e9)throw new M(j.INVALID_ARGUMENT,`Timestamp nanoseconds out of range: `+t);if(e<di||e>=253402300800)throw new M(j.INVALID_ARGUMENT,`Timestamp seconds out of range: `+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/fi}_compareTo(e){return this.seconds===e.seconds?N(this.nanoseconds,e.nanoseconds):N(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(ui(t,e._jsonSchema))return new e(t.seconds,t.nanoseconds)}valueOf(){let e=this.seconds-di;return String(e).padStart(12,`0`)+`.`+String(this.nanoseconds).padStart(9,`0`)}};L._jsonSchemaVersion=`firestore/timestamp/1.0`,L._jsonSchema={type:li(`string`,L._jsonSchemaVersion),seconds:li(`number`),nanoseconds:li(`number`)};var R=class e{static fromTimestamp(t){return new e(t)}static min(){return new e(new L(0,0))}static max(){return new e(new L(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}},pi=-1,mi=class{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}};function hi(e){return e.fields.find((e=>e.kind===2))}function gi(e){return e.fields.filter((e=>e.kind!==2))}mi.UNKNOWN_ID=-1;var _i=class{constructor(e,t){this.fieldPath=e,this.kind=t}},vi=class e{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new e(0,xi.min())}};function yi(e,t){let n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1;return new xi(R.fromTimestamp(r===1e9?new L(n+1,0):new L(n,r)),F.empty(),t)}function bi(e){return new xi(e.readTime,e.key,pi)}var xi=class e{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new e(R.min(),F.empty(),pi)}static max(){return new e(R.max(),F.empty(),pi)}};function Si(e,t){let n=e.readTime.compareTo(t.readTime);return n===0?(n=F.comparator(e.documentKey,t.documentKey),n===0?N(e.largestBatchId,t.largestBatchId):n):n}var Ci=`The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.`,wi=class{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}
15raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}};async function Ti(e){if(e.code!==j.FAILED_PRECONDITION||e.message!==Ci)throw e;E(`LocalStore`,`Unexpectedly lost primary lease`)}var z=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&&O(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()}))}},Ei=`SimpleDb`,Di=class e{static open(t,n,r,i){try{return new e(n,t.transaction(i,r))}catch(e){throw new ji(n,e)}}constructor(e,t){this.action=e,this.transaction=t,this.aborted=!1,this.S=new Fr,this.transaction.oncomplete=()=>{this.S.resolve()},this.transaction.onabort=()=>{t.error?this.S.reject(new ji(e,t.error)):this.S.resolve()},this.transaction.onerror=t=>{let n=Ii(t.target.error);this.S.reject(new ji(e,n))}}get D(){return this.S.promise}abort(e){e&&this.S.reject(e),this.aborted||(E(Ei,`Aborting transaction:`,e?e.message:`Client-initiated abort`),this.aborted=!0,this.transaction.abort())}C(){let e=this.transaction;this.aborted||typeof e.commit!=`function`||e.commit()}store(e){return new Ni(this.transaction.objectStore(e))}},Oi=class e{static delete(e){return E(Ei,`Removing database:`,e),Pi(ie().indexedDB.deleteDatabase(e)).toPromise()}static v(){if(!Te())return!1;if(e.F())return!0;let t=_(),n=e.M(t),r=0<n&&n<10,i=ki(t),a=0<i&&i<4.5;return!(t.indexOf(`MSIE `)>0||t.indexOf(`Trident/`)>0||t.indexOf(`Edge/`)>0||r||a)}static F(){return typeof process<`u`&&process.__PRIVATE_env?.__PRIVATE_USE_MOCK_PERSISTENCE===`YES`}static O(e,t){return e.store(t)}static M(e){let t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=t?t[1].split(`_`).slice(0,2).join(`.`):`-1`;return Number(n)}constructor(t,n,r){this.name=t,this.version=n,this.N=r,this.B=null,e.M(_())===12.2&&D(`Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`)}async L(e){return this.db||=(E(Ei,`Opening database:`,this.name),await new Promise(((t,n)=>{let r=indexedDB.open(this.name,this.version);r.onsuccess=e=>{let n=e.target.result;t(n)},r.onblocked=()=>{n(new ji(e,`Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed.`))},r.onerror=t=>{let r=t.target.error;r.name===`VersionError`?n(new M(j.FAILED_PRECONDITION,`A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.`)):r.name===`InvalidStateError`?n(new M(j.FAILED_PRECONDITION,`Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: `+r)):n(new ji(e,r))},r.onupgradeneeded=e=>{E(Ei,`Database "`+this.name+`" requires upgrade from version:`,e.oldVersion);let t=e.target.result;this.N.k(t,r.transaction,e.oldVersion,this.version).next((()=>{E(Ei,`Database upgrade to version `+this.version+` complete`)}))}}))),this.q&&(this.db.onversionchange=e=>this.q(e)),this.db}K(e){this.q=e,this.db&&(this.db.onversionchange=t=>e(t))}async runTransaction(e,t,n,r){let i=t===`readonly`,a=0;for(;;){++a;try{this.db=await this.L(e);let t=Di.open(this.db,e,i?`readonly`:`readwrite`,n),a=r(t).next((e=>(t.C(),e))).catch((e=>(t.abort(e),z.reject(e)))).toPromise();return a.catch((()=>{})),await t.D,a}catch(e){let t=e,n=t.name!==`FirebaseError`&&a<3;if(E(Ei,`Transaction failed with error:`,t.message,`Retrying:`,n),this.close(),!n)return Promise.reject(t)}}}close(){this.db&&this.db.close(),this.db=void 0}};function ki(e){let t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(`.`).slice(0,2).join(`.`):`-1`;return Number(n)}var Ai=class{constructor(e){this.U=e,this.$=!1,this.W=null}get isDone(){return this.$}get G(){return this.W}set cursor(e){this.U=e}done(){this.$=!0}j(e){this.W=e}delete(){return Pi(this.U.delete())}},ji=class extends M{constructor(e,t){super(j.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name=`IndexedDbTransactionError`}};function Mi(e){return e.name===`IndexedDbTransactionError`}var Ni=class{constructor(e){this.store=e}put(e,t){let n;return t===void 0?(E(Ei,`PUT`,this.store.name,`<auto-key>`,e),n=this.store.put(e)):(E(Ei,`PUT`,this.store.name,e,t),n=this.store.put(t,e)),Pi(n)}add(e){return E(Ei,`ADD`,this.store.name,e,e),Pi(this.store.add(e))}get(e){return Pi(this.store.get(e)).next((t=>(t===void 0&&(t=null),E(Ei,`GET`,this.store.name,e,t),t)))}delete(e){return E(Ei,`DELETE`,this.store.name,e),Pi(this.store.delete(e))}count(){return E(Ei,`COUNT`,this.store.name),Pi(this.store.count())}J(e,t){let n=this.options(e,t),r=n.index?this.store.index(n.index):this.store;if(typeof r.getAll==`function`){let e=r.getAll(n.range);return new z(((t,n)=>{e.onerror=e=>{n(e.target.error)},e.onsuccess=e=>{t(e.target.result)}}))}{let e=this.cursor(n),t=[];return this.H(e,((e,n)=>{t.push(n)})).next((()=>t))}}Z(e,t){let n=this.store.getAll(e,t===null?void 0:t);return new z(((e,t)=>{n.onerror=e=>{t(e.target.error)},n.onsuccess=t=>{e(t.target.result)}}))}X(e,t){E(Ei,`DELETE ALL`,this.store.name);let n=this.options(e,t);n.Y=!1;let r=this.cursor(n);
15return this.H(r,((e,t,n)=>n.delete()))}ee(e,t){let n;t?n=e:(n={},t=e);let r=this.cursor(n);return this.H(r,t)}te(e){let t=this.cursor({});return new z(((n,r)=>{t.onerror=e=>{r(Ii(e.target.error))},t.onsuccess=t=>{let r=t.target.result;r?e(r.primaryKey,r.value).next((e=>{e?r.continue():n()})):n()}}))}H(e,t){let n=[];return new z(((r,i)=>{e.onerror=e=>{i(e.target.error)},e.onsuccess=e=>{let i=e.target.result;if(!i)return void r();let a=new Ai(i),o=t(i.primaryKey,i.value,a);if(o instanceof z){let e=o.catch((e=>(a.done(),z.reject(e))));n.push(e)}a.isDone?r():a.G===null?i.continue():i.continue(a.G)}})).next((()=>z.waitFor(n)))}options(e,t){let n;return e!==void 0&&(typeof e==`string`?n=e:t=e),{index:n,range:t}}cursor(e){let t=`next`;if(e.reverse&&(t=`prev`),e.index){let n=this.store.index(e.index);return e.Y?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}};function Pi(e){return new z(((t,n)=>{e.onsuccess=e=>{let n=e.target.result;t(n)},e.onerror=e=>{n(Ii(e.target.error))}}))}var Fi=!1;function Ii(e){let t=Oi.M(_());if(t>=12.2&&t<13){let t=`An internal error was encountered in the Indexed Database server`;if(e.message.indexOf(t)>=0){let e=new M(`internal`,`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${t}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return Fi||(Fi=!0,setTimeout((()=>{throw e}),0)),e}}return e}var Li=`IndexBackfiller`,Ri=class{constructor(e,t){this.asyncQueue=e,this.ne=t,this.task=null}start(){this.re(15e3)}stop(){this.task&&=(this.task.cancel(),null)}get started(){return this.task!==null}re(e){E(Li,`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay(`index_backfill`,e,(async()=>{this.task=null;try{E(Li,`Documents written: ${await this.ne.ie()}`)}catch(e){Mi(e)?E(Li,`Ignoring IndexedDB error during index backfill: `,e):await Ti(e)}await this.re(6e4)}))}},zi=class{constructor(e,t){this.localStore=e,this.persistence=t}async ie(e=50){return this.persistence.runTransaction(`Backfill Indexes`,`readwrite-primary`,(t=>this.se(t,e)))}se(e,t){let n=new Set,r=t,i=!0;return z.doWhile((()=>!0===i&&r>0),(()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next((t=>{if(t!==null&&!n.has(t))return E(Li,`Processing collection: ${t}`),this.oe(e,t,r).next((e=>{r-=e,n.add(t)}));i=!1})))).next((()=>t-r))}oe(e,t,n){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e,t).next((r=>this.localStore.localDocuments.getNextDocuments(e,t,r,n).next((n=>{let i=n.changes;return this.localStore.indexManager.updateIndexEntries(e,i).next((()=>this._e(r,n))).next((n=>(E(Li,`Updating offset: ${n}`),this.localStore.indexManager.updateCollectionGroup(e,t,n)))).next((()=>i.size))}))))}_e(e,t){let n=e;
vendor: 8,034 bytes, line 15
15return t.changes.forEach(((e,t)=>{let r=bi(t);Si(r,n)>0&&(n=r)})),new xi(n.readTime,n.documentKey,Math.max(t.batchId,e.largestBatchId))}},Bi=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}};Bi.ce=-1;var Vi=-1;function Hi(e){return e==null}function Ui(e){return e===0&&1/e==-1/0}function Wi(e){return typeof e==`number`&&Number.isInteger(e)&&!Ui(e)&&e<=2**53-1&&e>=-(2**53-1)}var Gi=`�`;function Ki(e){let t=``;for(let n=0;n<e.length;n++)t.length>0&&(t=Ji(t)),t=qi(e.get(n),t);return Ji(t)}function qi(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 Gi:n+=`��`;break;default:n+=r}}return n}function Ji(e){return e+`��`}function Yi(e){let t=e.length;if(k(t>=2,64408,{path:e}),t===2)return k(e.charAt(0)===Gi&&e.charAt(1)===`�`,56145,{path:e}),P.emptyPath();let n=t-2,r=[],i=``;for(let a=0;a<t;){let t=e.indexOf(Gi,a);switch((t<0||t>n)&&O(50515,{path:e}),e.charAt(t+1)){case`�`:let n=e.substring(a,t),o;i.length===0?o=n:(i+=n,o=i,i=``),r.push(o);break;case`�`:i+=e.substring(a,t),i+=`\0`;break;case`�`:i+=e.substring(a,t+1);break;default:O(61167,{path:e})}a=t+2}return new P(r)}var Xi=`remoteDocuments`,Zi=`owner`,Qi=`owner`,$i=`mutationQueues`,ea=`userId`,ta=`mutations`,na=`batchId`,ra=`userMutationsIndex`,ia=[`userId`,`batchId`];function aa(e,t){return[e,Ki(t)]}function oa(e,t,n){return[e,Ki(t),n]}var sa={},ca=`documentMutations`,la=`remoteDocumentsV14`,ua=[`prefixPath`,`collectionGroup`,`readTime`,`documentId`],da=`documentKeyIndex`,fa=[`prefixPath`,`collectionGroup`,`documentId`],pa=`collectionGroupIndex`,ma=[`collectionGroup`,`readTime`,`prefixPath`,`documentId`],ha=`remoteDocumentGlobal`,ga=`remoteDocumentGlobalKey`,_a=`targets`,va=`queryTargetsIndex`,ya=[`canonicalId`,`targetId`],ba=`targetDocuments`,xa=[`targetId`,`path`],Sa=`documentTargetsIndex`,Ca=[`path`,`targetId`],wa=`targetGlobalKey`,Ta=`targetGlobal`,Ea=`collectionParents`,Da=[`collectionId`,`parent`],Oa=`clientMetadata`,ka=`clientId`,Aa=`bundles`,ja=`bundleId`,Ma=`namedQueries`,Na=`name`,Pa=`indexConfiguration`,Fa=`indexId`,Ia=`collectionGroupIndex`,La=`collectionGroup`,Ra=`indexState`,za=[`indexId`,`uid`],Ba=`sequenceNumberIndex`,Va=[`uid`,`sequenceNumber`],Ha=`indexEntries`,Ua=[`indexId`,`uid`,`arrayValue`,`directionalValue`,`orderedDocumentKey`,`documentKey`],Wa=`documentKeyIndex`,Ga=[`indexId`,`uid`,`orderedDocumentKey`],Ka=`documentOverlays`,qa=[`userId`,`collectionPath`,`documentId`],Ja=`collectionPathOverlayIndex`,Ya=[`userId`,`collectionPath`,`largestBatchId`],Xa=`collectionGroupOverlayIndex`,Za=[`userId`,`collectionGroup`,`largestBatchId`],Qa=`globals`,$a=`name`,eo=[$i,ta,ca,Xi,_a,Zi,Ta,ba,Oa,ha,Ea,Aa,Ma],to=[...eo,Ka],no=[$i,ta,ca,la,_a,Zi,Ta,ba,Oa,ha,Ea,Aa,Ma,Ka],ro=no,io=[...ro,Pa,Ra,Ha],ao=io,oo=[...io,Qa],so=oo,co=class extends wi{constructor(e,t){super(),this.le=e,this.currentSequenceNumber=t}};function lo(e,t){let n=A(e);return Oi.O(n.le,t)}function uo(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function fo(e,t){for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function po(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}var B=class e{constructor(e,t){this.comparator=e,this.root=t||ho.EMPTY}insert(t,n){return new e(this.comparator,this.root.insert(t,n,this.comparator).copy(null,null,ho.BLACK,null,null))}remove(t){return new e(this.comparator,this.root.remove(t,this.comparator).copy(null,null,ho.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 mo(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new mo(this.root,e,this.comparator,!1)}getReverseIterator(){return new mo(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new mo(this.root,e,this.comparator,!0)}},mo=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}}},ho=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 O(43730,{key:this.key,value:this.value});if(this.right.isRed())throw O(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw O(27949);return e+ +!this.isRed()}};
15ho.EMPTY=null,ho.RED=!0,ho.BLACK=!1,ho.EMPTY=new class{constructor(){this.size=0}get key(){throw O(57766)}get value(){throw O(16141)}get color(){throw O(16727)}get left(){throw O(29726)}get right(){throw O(36894)}copy(e,t,n,r,i){return this}insert(e,t,n){return new ho(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 V=class e{constructor(e){this.comparator=e,this.data=new B(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 go(this.data.getIterator())}getIteratorFrom(e){return new go(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}},go=class{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}};function _o(e){return e.hasNext()?e.getNext():void 0}var vo=class e{constructor(e){this.fields=e,e.sort(ti.comparator)}static empty(){return new e([])}unionWith(t){let n=new V(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 Xr(this.fields,e.fields,((e,t)=>e.isEqual(t)))}},yo=class extends Error{constructor(){super(...arguments),this.name=`Base64DecodeError`}};function bo(){return typeof atob<`u`}var xo=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 yo(`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 N(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}};xo.EMPTY_BYTE_STRING=new xo(``);var So=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Co(e){if(k(!!e,39018),typeof e==`string`){let t=0,n=So.exec(e);if(k(!!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 wo(e){return typeof e==`string`?xo.fromBase64String(e):xo.fromUint8Array(e)}var To=`server_timestamp`,Eo=`__type__`,Do=`__previous_value__`,Oo=`__local_write_time__`;function ko(e){return(e?.mapValue?.fields||{})[Eo]?.stringValue===To}function Ao(e){let t=e.mapValue.fields[Do];return ko(t)?Ao(t):t}function jo(e){let t=Co(e.mapValue.fields[Oo].timestampValue);return new L(t.seconds,t.nanos)}var Mo=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}},No=`(default)`,Po=class e{constructor(e,t){this.projectId=e,this.database=t||No}static empty(){return new e(``,``)}get isDefaultDatabase(){return this.database===No}isEqual(t){return t instanceof e&&t.projectId===this.projectId&&t.database===this.database}};function Fo(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,[`projectId`]))throw new M(j.INVALID_ARGUMENT,`"projectId" not provided in firebase.initializeApp.`);return new Po(e.options.projectId,t)}var Io=`__type__`,Lo=`__max__`,Ro={mapValue:{fields:{__type__:{stringValue:Lo}}}},zo=`__vector__`,Bo=`value`,Vo={nullValue:`NULL_VALUE`};function Ho(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?ko(e)?4:os(e)?9007199254740991:is(e)?10:11:O(28295,{value:e})}function Uo(e,t){if(e===t)return!0;let n=Ho(e);if(n!==Ho(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return jo(e).isEqual(jo(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=Co(e.timestampValue),r=Co(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 wo(e.bytesValue).isEqual(wo(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){if(`integerValue`in e&&`integerValue`in t)return H(e.integerValue)===H(t.integerValue);if(`doubleValue`in e&&`doubleValue`in t){let n=H(e.doubleValue),r=H(t.doubleValue);return n===r?Ui(n)===Ui(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return Xr(e.arrayValue.values||[],t.arrayValue.values||[],Uo);case 10:case 11:return function(e,t){let n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(uo(n)!==uo(r))return!1;for(let e in n)if(n.hasOwnProperty(e)&&(r[e]===void 0||!Uo(n[e],r[e])))return!1;return!0}(e,t);default:return O(52216,{left:e})}}function Wo(e,t){return(e.values||[]).find((e=>Uo(e,t)))!==void 0}function Go(e,t){if(e===t)return 0;let n=Ho(e),r=Ho(t);if(n!==r)return N(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return N(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 Ko(e.timestampValue,t.timestampValue);case 4:return Ko(jo(e),jo(t));case 5:return Kr(e.stringValue,t.stringValue);case 6:return function(e,t){let n=wo(e),r=wo(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=N(n[e],r[e]);if(t!==0)return t}return N(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){let n=N(H(e.latitude),H(t.latitude));return n===0?N(H(e.longitude),H(t.longitude)):n}(e.geoPointValue,t.geoPointValue);case 9:return qo(e.arrayValue,t.arrayValue);case 10:return function(e,t){let n=e.fields||{},r=t.fields||{},i=n[Bo]?.arrayValue,a=r[Bo]?.arrayValue,o=N(i?.values?.length||0,a?.values?.length||0);return o===0?qo(i,a):o}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===Ro.mapValue&&t===Ro.mapValue)return 0;if(e===Ro.mapValue)return 1;if(t===Ro.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=Kr(r[e],a[e]);if(t!==0)return t;let o=Go(n[r[e]],i[a[e]]);if(o!==0)return o}return N(r.length,a.length)}(e.mapValue,t.mapValue);default:throw O(23264,{he:n})}}function Ko(e,t){if(typeof e==`string`&&typeof t==`string`&&e.length===t.length)return N(e,t);let n=Co(e),r=Co(t),i=N(n.seconds,r.seconds);return i===0?N(n.nanos,r.nanos):i}function qo(e,t){let n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){let t=Go(n[e],r[e]);if(t)return t}return N(n.length,r.length)}function Jo(e){return Yo(e)}function Yo(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=Co(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):`stringValue`in e?e.stringValue:`bytesValue`in e?function(e){return wo(e).toBase64()}(e.bytesValue):`referenceValue`in e?function(e){return F.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+=Yo(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}:${Yo(e.fields[i])}`;return n+`}`}(e.mapValue):O(61005,{value:e})}function Xo(e){switch(Ho(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let t=Ao(e);return t?16+Xo(t):16;case 5:return 2*e.stringValue.length;case 6:return wo(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return function(e){return(e.values||[]).reduce(((e,t)=>e+Xo(t)),0)}(e.arrayValue);case 10:case 11:return function(e){let t=0;return fo(e.fields,((e,n)=>{t+=e.length+Xo(n)})),t}(e.mapValue);default:throw O(13486,{value:e})}}function Zo(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Qo(e){return!!e&&`integerValue`in e}function $o(e){return Qo(e)||function(e){return!!e&&`doubleValue`in e}(e)}function es(e){return!!e&&`arrayValue`in e}function ts(e){return!!e&&`nullValue`in e}function ns(e){return!!e&&`doubleValue`in e&&isNaN(Number(e.doubleValue))}function rs(e){return!!e&&`mapValue`in e}function is(e){return(e?.mapValue?.fields||{})[Io]?.stringValue===zo}function as(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 fo(e.mapValue.fields,((e,n)=>t.mapValue.fields[e]=as(n))),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=as(e.arrayValue.values[n]);return t}return{...e}}function os(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===Lo}var ss={mapValue:{fields:{[Io]:{stringValue:zo},[Bo]:{arrayValue:{}}}}};function cs(e){return`nullValue`in e?Vo:`booleanValue`in e?{booleanValue:!1}
15:`integerValue`in e||`doubleValue`in e?{doubleValue:NaN}:`timestampValue`in e?{timestampValue:{seconds:-(2**53-1)}}:`stringValue`in e?{stringValue:``}:`bytesValue`in e?{bytesValue:``}:`referenceValue`in e?Zo(Po.empty(),F.empty()):`geoPointValue`in e?{geoPointValue:{latitude:-90,longitude:-180}}:`arrayValue`in e?{arrayValue:{}}:`mapValue`in e?is(e)?ss:{mapValue:{}}:O(35942,{value:e})}function ls(e){return`nullValue`in e?{booleanValue:!1}:`booleanValue`in e?{doubleValue:NaN}:`integerValue`in e||`doubleValue`in e?{timestampValue:{seconds:-(2**53-1)}}:`timestampValue`in e?{stringValue:``}:`stringValue`in e?{bytesValue:``}:`bytesValue`in e?Zo(Po.empty(),F.empty()):`referenceValue`in e?{geoPointValue:{latitude:-90,longitude:-180}}:`geoPointValue`in e?{arrayValue:{}}:`arrayValue`in e?ss:`mapValue`in e?is(e)?{mapValue:{}}:Ro:O(61959,{value:e})}function us(e,t){let n=Go(e.value,t.value);return n===0?e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0:n}function ds(e,t){let n=Go(e.value,t.value);return n===0?e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0:n}var fs=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)],!rs(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=as(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()]=as(e):r.push(i.lastSegment())}));let i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){let t=this.field(e.popLast());rs(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Uo(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)];rs(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){fo(t,((t,n)=>e[t]=n));for(let t of n)delete e[t]}clone(){return new e(as(this.value))}};function ps(e){let t=[];return fo(e.fields,((e,n)=>{let r=new ti([e]);if(rs(n)){let e=ps(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 vo(t)}var ms=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,R.min(),R.min(),R.min(),fs.empty(),0)}static newFoundDocument(t,n,r,i){return new e(t,1,n,R.min(),r,i,0)}static newNoDocument(t,n){return new e(t,2,n,R.min(),R.min(),fs.empty(),0)}static newUnknownDocument(t,n){return new e(t,3,n,R.min(),R.min(),fs.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(R.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=fs.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=fs.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=R.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}})`}}
15,hs=class{constructor(e,t){this.position=e,this.inclusive=t}};function gs(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()?F.comparator(F.fromName(o.referenceValue),n.key):Go(o,n.data.field(a.field)),a.dir===`desc`&&(r*=-1),r!==0)break}return r}function _s(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(!Uo(e.position[n],t.position[n]))return!1;return!0}var vs=class{constructor(e,t=`asc`){this.field=e,this.dir=t}};function ys(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}var bs=class{},U=class e extends bs{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 ks(t,n,r):n===`array-contains`?new Ns(t,r):n===`in`?new Ps(t,r):n===`not-in`?new Fs(t,r):n===`array-contains-any`?new Is(t,r):new e(t,n,r)}static createKeyFieldInFilter(e,t,n){return t===`in`?new As(e,n):new js(e,n)}matches(e){let t=e.data.field(this.field);return this.op===`!=`?t!==null&&t.nullValue===void 0&&this.matchesComparison(Go(t,this.value)):t!==null&&Ho(this.value)===Ho(t)&&this.matchesComparison(Go(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 O(47266,{operator:this.op})}}isInequality(){return[`<`,`<=`,`>`,`>=`,`!=`,`not-in`].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}},W=class e extends bs{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(t,n){return new e(t,n)}matches(e){return xs(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 xs(e){return e.op===`and`}function Ss(e){return e.op===`or`}function Cs(e){return ws(e)&&xs(e)}function ws(e){for(let t of e.filters)if(t instanceof W)return!1;return!0}function Ts(e){if(e instanceof U)return e.field.canonicalString()+e.op.toString()+Jo(e.value);if(Cs(e))return e.filters.map((e=>Ts(e))).join(`,`);{let t=e.filters.map((e=>Ts(e))).join(`,`);return`${e.op}(${t})`}}function Es(e,t){return e instanceof U?function(e,t){return t instanceof U&&e.op===t.op&&e.field.isEqual(t.field)&&Uo(e.value,t.value)}(e,t):e instanceof W?function(e,t){return t instanceof W&&e.op===t.op&&e.filters.length===t.filters.length?e.filters.reduce(((e,n,r)=>e&&Es(n,t.filters[r])),!0):!1}(e,t):void O(19439)}function Ds(e,t){let n=e.filters.concat(t);return W.create(n,e.op)}function Os(e){return e instanceof U?function(e){return`${e.field.canonicalString()} ${e.op} ${Jo(e.value)}`}(e):e instanceof W?function(e){return e.op.toString()+` {`+e.getFilters().map(Os).join(` ,`)+`}`}(e):`Filter`}var ks=class extends U{constructor(e,t,n){super(e,t,n),this.key=F.fromName(n.referenceValue)}matches(e){let t=F.comparator(e.key,this.key);return this.matchesComparison(t)}},As=class extends U{constructor(e,t){super(e,`in`,t),this.keys=Ms(`in`,t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}},js=class extends U{constructor(e,t){super(e,`not-in`,t),this.keys=Ms(`not-in`,t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}};function Ms(e,t){return(t.arrayValue?.values||[]).map((e=>F.fromName(e.referenceValue)))}var Ns=class extends U{constructor(e,t){super(e,`array-contains`,t)}matches(e){let t=e.data.field(this.field);return es(t)&&Wo(t.arrayValue,this.value)}},Ps=class extends U{constructor(e,t){super(e,`in`,t)}matches(e){let t=e.data.field(this.field);return t!==null&&Wo(this.value.arrayValue,t)}},Fs=class extends U{constructor(e,t){super(e,`not-in`,t)}matches(e){if(Wo(this.value.arrayValue,{nullValue:`NULL_VALUE`}))return!1;let t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!Wo(this.value.arrayValue,t)}},Is=class extends U{constructor(e,t){super(e,`array-contains-any`,t)}matches(e){let t=e.data.field(this.field);return!(!es(t)||!t.arrayValue.values)&&t.arrayValue.values.some((e=>Wo(this.value.arrayValue,e)))}},Ls=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.Te=null}};function Rs(e,t=null,n=[],r=[],i=null,a=null,o=null){return new Ls(e,t,n,r,i,a,o)}function zs(e){let t=A(e);if(t.Te===null){let e=t.path.canonicalString();t.collectionGroup!==null&&(e+=`|cg:`+t.collectionGroup),e+=`|f:`,e+=t.filters.map((e=>Ts(e))).join(`,`),e+=`|ob:`,e+=t.orderBy.map((e=>function(e){return e.field.canonicalString()+e.dir}(e))).join(`,`),Hi(t.limit)||(e+=`|l:`,e+=t.limit),t.startAt&&(e+=`|lb:`,e+=t.startAt.inclusive?`b:`:`a:`,e+=t.startAt.position.map((e=>Jo(e))).join(`,`)),t.endAt&&(e+=`|ub:`,e+=t.endAt.inclusive?`a:`:`b:`,e+=t.endAt.position.map((e=>Jo(e))).join(`,`)),t.Te=e}return t.Te}function Bs(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(!ys(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(!Es(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!_s(e.startAt,t.startAt)&&_s(e.endAt,t.endAt)}function Vs(e){return F.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}function Hs(e,t){return e.filters.filter((e=>e instanceof U&&e.field.isEqual(t)))}function Us(e,t,n){let r=Vo,i=!0;for(let n of Hs(e,t)){let e=Vo,t=!0;switch(n.op){case`<`:case`<=`:e=cs(n.value);break;case`==`:case`in`:case`>=`:e=n.value;break;case`>`:e=n.value,t=!1;break;case`!=`:case`not-in`:e=Vo}us({value:r,inclusive:i},{value:e,inclusive:t})<0&&(r=e,i=t)}if(n!==null){for(let a=0;a<e.orderBy.length;++a)if(e.orderBy[a].field.isEqual(t)){let e=n.position[a];us({value:r,inclusive:i},{value:e,inclusive:n.inclusive})<0&&(r=e,i=n.inclusive);break}}return{value:r,inclusive:i}}function Ws(e,t,n){let r=Ro,i=!0;for(let n of Hs(e,t)){let e=Ro,t=!0;switch(n.op){case`>=`:case`>`:e=ls(n.value),t=!1;break;case`==`:case`in`:case`<=`:e=n.value;break;case`<`:e=n.value,t=!1;break;case`!=`:case`not-in`:e=Ro}ds({value:r,inclusive:i},{value:e,inclusive:t})>0&&(r=e,i=t)}if(n!==null){for(let a=0;a<e.orderBy.length;++a)if(e.orderBy[a].field.isEqual(t)){let e=n.position[a];ds({value:r,inclusive:i},{value:e,inclusive:n.inclusive})>0&&(r=e,i=n.inclusive);break}}return{value:r,inclusive:i}}var Gs=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.Ie=null,this.Ee=null,this.Re=null,this.startAt,this.endAt}};function Ks(e,t,n,r,i,a,o,s){return new Gs(e,t,n,r,i,a,o,s)}function qs(e){return new Gs(e)}function Js(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 Ys(e){return F.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}function Xs(e){return e.collectionGroup!==null}function Zs(e){let t=A(e);if(t.Ie===null){t.Ie=[];let e=new Set;for(let n of t.explicitOrderBy)t.Ie.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 V(ti.comparator);
15return 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.Ie.push(new vs(r,n))})),e.has(ti.keyField().canonicalString())||t.Ie.push(new vs(ti.keyField(),n))}return t.Ie}function Qs(e){let t=A(e);return t.Ee||=$s(t,Zs(e)),t.Ee}function $s(e,t){if(e.limitType===`F`)return Rs(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 vs(e.field,t)}));let n=e.endAt?new hs(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new hs(e.startAt.position,e.startAt.inclusive):null;return Rs(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function ec(e,t){let n=e.filters.concat([t]);return new Gs(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function tc(e,t){let n=e.explicitOrderBy.concat([t]);return new Gs(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}function nc(e,t,n){return new Gs(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function rc(e,t){return new Gs(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)}function ic(e,t){return new Gs(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,t)}function ac(e,t){return Bs(Qs(e),Qs(t))&&e.limitType===t.limitType}function oc(e){return`${zs(Qs(e))}|lt:${e.limitType}`}function sc(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=>Os(e))).join(`, `)}]`),Hi(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=>Jo(e))).join(`,`)),e.endAt&&(t+=`, endAt: `,t+=e.endAt.inclusive?`a:`:`b:`,t+=e.endAt.position.map((e=>Jo(e))).join(`,`)),`Target(${t})`}(Qs(e))}; limitType=${e.limitType})`}function cc(e,t){return t.isFoundDocument()&&function(e,t){let n=t.key.path;return e.collectionGroup===null?F.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 Zs(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=gs(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,Zs(e),t)||e.endAt&&!function(e,t,n){let r=gs(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,Zs(e),t))}(e,t)}function lc(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function uc(e){return(t,n)=>{let r=!1;for(let i of Zs(e)){let e=dc(i,t,n);if(e!==0)return e;r||=i.field.isKeyField()}return 0}}function dc(e,t,n){let r=e.field.isKeyField()?F.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?Go(r,i):O(42886)}(e.field,t,n);switch(e.dir){case`asc`:return r;case`desc`:return-1*r;default:return O(19790,{direction:e.dir})}}var fc=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){fo(this.inner,((t,n)=>{for(let[t,r]of n)e(t,r)}))}isEmpty(){return po(this.inner)}size(){return this.innerSize}},pc=new B(F.comparator);function mc(){return pc}var hc=new B(F.comparator);function gc(...e){let t=hc;for(let n of e)t=t.insert(n.key,n);return t}function _c(e){let t=hc;return e.forEach(((e,n)=>t=t.insert(e,n.overlayedDocument))),t}function vc(){return bc()}function yc(){return bc()}function bc(){return new fc((e=>e.toString()),((e,t)=>e.isEqual(t)))}var xc=new B(F.comparator),Sc=new V(F.comparator);function G(...e){let t=Sc;for(let n of e)t=t.add(n);return t}var Cc=new V(N);function wc(){return Cc}function Tc(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:Ui(t)?`-0`:t}}function Ec(e){return{integerValue:``+e}}function Dc(e,t){return Wi(t)?Ec(t):Tc(e,t)}var Oc=class{constructor(){this._=void 0}};function kc(e,t,n){return e instanceof Mc?function(e,t){let n={fields:{[Eo]:{stringValue:To},[Oo]:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&ko(t)&&(t=Ao(t)),t&&(n.fields[Do]=t),{mapValue:n}}(n,t):e instanceof Nc?Pc(e,t):e instanceof Fc?Ic(e,t):e instanceof Rc?function(e,t){let n=jc(e,t),r=Hc(n)+Hc(e.Ae);return Qo(n)&&Qo(e.Ae)?Ec(r):Tc(e.serializer,r)}(e,t):e instanceof zc?function(e,t){return Vc(e,t,Math.min)}(e,t):e instanceof Bc?function(e,t){return Vc(e,t,Math.max)}(e,t):void 0}function Ac(e,t,n){return e instanceof Nc?Pc(e,t):e instanceof Fc?Ic(e,t):n}function jc(e,t){return e instanceof Rc?$o(t)?t:{integerValue:0}:null}var Mc=class extends Oc{},Nc=class extends Oc{constructor(e){super(),this.elements=e}};function Pc(e,t){let n=Uc(t);for(let t of e.elements)n.some((e=>Uo(e,t)))||n.push(t);return{arrayValue:{values:n}}}var Fc=class extends Oc{constructor(e){super(),this.elements=e}};function Ic(e,t){let n=Uc(t);for(let t of e.elements)n=n.filter((e=>!Uo(e,t)));return{arrayValue:{values:n}}}var Lc=class extends Oc{constructor(e,t){super(),this.serializer
15=e,this.Ae=t}},Rc=class extends Lc{},zc=class extends Lc{},Bc=class extends Lc{};function Vc(e,t,n){if(!$o(t))return e.Ae;let r=n(Hc(t),Hc(e.Ae));return Qo(t)&&Qo(e.Ae)?Ec(r):Tc(e.serializer,r)}function Hc(e){return H(e.integerValue||e.doubleValue)}function Uc(e){return es(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}var Wc=class{constructor(e,t){this.field=e,this.transform=t}};function Gc(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof Nc&&t instanceof Nc||e instanceof Fc&&t instanceof Fc?Xr(e.elements,t.elements,Uo):e instanceof Rc&&t instanceof Rc||e instanceof zc&&t instanceof zc||e instanceof Bc&&t instanceof Bc?Uo(e.Ae,t.Ae):e instanceof Mc&&t instanceof Mc}(e.transform,t.transform)}var Kc=class{constructor(e,t){this.version=e,this.transformResults=t}},qc=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 Jc(e,t){return e.updateTime===void 0?e.exists===void 0||e.exists===t.isFoundDocument():t.isFoundDocument()&&t.version.isEqual(e.updateTime)}var Yc=class{};function Xc(e,t){if(!e.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return e.isNoDocument()?new ol(e.key,qc.none()):new tl(e.key,e.data,qc.none());{let n=e.data,r=fs.empty(),i=new V(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 nl(e.key,r,new vo(i.toArray()),qc.none())}}function Zc(e,t,n){e instanceof tl?function(e,t,n){let r=e.value.clone(),i=il(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof nl?function(e,t,n){if(!Jc(e.precondition,t))return void t.convertToUnknownDocument(n.version);let r=il(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(rl(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 Qc(e,t,n,r){return e instanceof tl?function(e,t,n,r){if(!Jc(e.precondition,t))return n;let i=e.value.clone(),a=al(e.fieldTransforms,r,t);return i.setAll(a),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof nl?function(e,t,n,r){if(!Jc(e.precondition,t))return n;let i=al(e.fieldTransforms,r,t),a=t.data;return a.setAll(rl(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 Jc(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function $c(e,t){let n=null;for(let r of e.fieldTransforms){let e=t.data.field(r.field),i=jc(r.transform,e||null);i!=null&&(n===null&&(n=fs.empty()),n.set(r.field,i))}return n||null}function el(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)&&Xr(e,t,((e,t)=>Gc(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 tl=class extends Yc{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}},nl=class extends Yc{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 rl(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 il(e,t,n){let r=new Map;k(e.length===n.length,32656,{Ve:n.length,de: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,Ac(o,s,n[i]))}return r}function al(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,kc(e,a,t))}return r}var ol=class extends Yc{constructor(e,t){super(),this.key=e,this.prec
15ondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}},sl=class extends Yc{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}},cl=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)&&Zc(r,e,n[t])}}applyToLocalView(e,t){for(let n of this.baseMutations)n.key.isEqual(e.key)&&(t=Qc(n,e,t,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(e.key)&&(t=Qc(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let n=yc();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=Xc(a,o);s!==null&&n.set(r.key,s),a.isValidDocument()||a.convertToNoDocument(R.min())})),n}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),G())}isEqual(e){return this.batchId===e.batchId&&Xr(this.mutations,e.mutations,((e,t)=>el(e,t)))&&Xr(this.baseMutations,e.baseMutations,((e,t)=>el(e,t)))}},ll=class e{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(t,n,r){k(t.mutations.length===r.length,58842,{me:t.mutations.length,fe:r.length});let i=function(){return xc}(),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)}},ul=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 }`}},dl=class{constructor(e,t){this.count=e,this.unchangedNames=t}},fl,K;function pl(e){switch(e){case j.OK:return O(64938);case j.CANCELLED:case j.UNKNOWN:case j.DEADLINE_EXCEEDED:case j.RESOURCE_EXHAUSTED:case j.INTERNAL:case j.UNAVAILABLE:case j.UNAUTHENTICATED:return!1;case j.INVALID_ARGUMENT:case j.NOT_FOUND:case j.ALREADY_EXISTS:case j.PERMISSION_DENIED:case j.FAILED_PRECONDITION:case j.ABORTED:case j.OUT_OF_RANGE:case j.UNIMPLEMENTED:case j.DATA_LOSS:return!0;default:return O(15467,{code:e})}}function ml(e){if(e===void 0)return D(`GRPC error has no .code`),j.UNKNOWN;switch(e){case fl.OK:return j.OK;case fl.CANCELLED:return j.CANCELLED;case fl.UNKNOWN:return j.UNKNOWN;case fl.DEADLINE_EXCEEDED:return j.DEADLINE_EXCEEDED;case fl.RESOURCE_EXHAUSTED:return j.RESOURCE_EXHAUSTED;case fl.INTERNAL:return j.INTERNAL;case fl.UNAVAILABLE:return j.UNAVAILABLE;case fl.UNAUTHENTICATED:return j.UNAUTHENTICATED;case fl.INVALID_ARGUMENT:return j.INVALID_ARGUMENT;case fl.NOT_FOUND:return j.NOT_FOUND;case fl.ALREADY_EXISTS:return j.ALREADY_EXISTS;case fl.PERMISSION_DENIED:return j.PERMISSION_DENIED;case fl.FAILED_PRECONDITION:return j.FAILED_PRECONDITION;case fl.ABORTED:return j.ABORTED;case fl.OUT_OF_RANGE:return j.OUT_OF_RANGE;case fl.UNIMPLEMENTED:return j.UNIMPLEMENTED;case fl.DATA_LOSS:return j.DATA_LOSS;default:return O(39323,{code:e})}}(K=fl||={})[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`;var hl=null;function gl(){return new TextEncoder}var _l=new pr([4294967295,4294967295],0);function vl(e){let t=gl().encode(e),n=new mr;return n.update(t),new Uint8Array(n.digest())}function yl(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 pr([n,r],0),new pr([i,a],0)]}var bl=class e{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new xl(`Invalid padding: ${t}`);if(n<0||e.length>0&&this.hashCount===0)throw new xl(`Invalid hash count: ${n}`);if(e.length===0&&t!==0)throw new xl(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=pr.fromNumber(this.ge)}
15ye(e,t,n){let r=e.add(t.multiply(pr.fromNumber(n)));return r.compare(_l)===1&&(r=new pr([r.getBits(0),r.getBits(1)],0)),r.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.ge===0)return!1;let[t,n]=yl(vl(e));for(let e=0;e<this.hashCount;e++){let r=this.ye(t,n,e);if(!this.we(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]=yl(vl(e));for(let e=0;e<this.hashCount;e++){let r=this.ye(t,n,e);this.Se(r)}}Se(e){let t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}},xl=class extends Error{constructor(){super(...arguments),this.name=`BloomFilterError`}},Sl=class e{constructor(e,t,n,r,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(t,n,r){let i=new Map;return i.set(t,Cl.createSynthesizedTargetChangeForCurrentChange(t,n,r)),new e(R.min(),i,new B(N),mc(),G())}},Cl=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,G(),G(),G())}},wl=class{constructor(e,t,n,r){this.be=e,this.removedTargetIds=t,this.key=n,this.De=r}},Tl=class{constructor(e,t){this.targetId=e,this.Ce=t}},El=class{constructor(e,t,n=xo.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}},Dl=class{constructor(e){this.targetId=e,this.ve=0,this.Fe=jl(),this.Me=xo.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(),n=G();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:O(38017,{changeType:i})}})),new Cl(this.Me,this.xe,e,t,n)}qe(){this.Oe=!1,this.Fe=jl()}Ke(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,k(this.ve>=0,3241,{ve:this.ve,targetId:this.targetId})}Qe(){this.Oe=!0,this.xe=!0}},Ol=`WatchChangeAggregator`,kl=class{constructor(e){this.Ge=e,this.ze=new Map,this.je=mc(),this.Je=Al(),this.He=Al(),this.Ze=new B(N)}Xe(e){for(let t of e.be)e.De&&e.De.isFoundDocument()?this.Ye(t,e.De):this.et(t,e.key,e.De);for(let t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,(t=>{let n=this.ze.get(t);if(n)switch(e.state){case 0:this.nt(t)&&n.Le(e.resumeToken);break;case 1:n.We(),n.Ne||n.qe(),n.Le(e.resumeToken);break;case 2:n.We(),n.Ne||this.removeTarget(t);break;case 3:this.nt(t)&&(n.Qe(),n.Le(e.resumeToken));break;case 4:this.nt(t)&&(this.rt(t),n.Le(e.resumeToken));break;default:O(56790,{state:e.state})}else E(Ol,`handleTargetChange received targetChange for untracked target ID (${t}) with state (${e.state})`)}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach(((e,n)=>{this.nt(n)&&t(n)}))}it(e){let t=e.targetId,n=e.Ce.count,r=this.st(t);if(r){let i=r.target;if(Vs(i))if(n===0){let e=new F(i.path);this.et(t,e,ms.newNoDocument(e,R.min()))}else k(n===1,20013,{expectedCount:n});else{let r=this.ot(t);if(r!==n){let n=this._t(e),i=n?this.ut(n,e,r):1;if(i!==0){this.rt(t);let e=i===2?`TargetPurposeExistenceFilterMismatchBloom`:`TargetPurposeExistenceFilterMismatch`;this.Ze=this.Ze.insert(t,e)}hl?.o(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.Ce,this.Ge.lt(),n,i))}}}}_t(e){let t=e.Ce.unchangedNames;if(!t||!t.bits)return null;let{bits:{bitmap:n=``,padding:r=0},hashCount:i=0}=t,a,o;try{a=wo(n).toUint8Array()}catch(e){if(e instanceof yo)return jr(`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 bl(a,r,i)}catch(e){return jr(e instanceof xl?`BloomFilter error: `:`Applying bloom filter failed: `,e),null}return o.ge===0?null:o}ut(e,t,n){return t.Ce.count===n-this.ht(e,t.targetId)?0:2}ht(e,t){let n=this.Ge.getRemoteKeysForTarget(t),r=0;
15return n.forEach((n=>{let i=this.Ge.lt(),a=`projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;e.mightContain(a)||(this.et(t,n,null),r++)})),r}Pt(e){let t=new Map;this.ze.forEach(((n,r)=>{let i=this.st(r);if(i){if(n.current&&Vs(i.target)){let t=new F(i.target.path);this.Tt(t).has(r)||this.It(r,t)||this.et(r,t,ms.newNoDocument(t,e))}n.Be&&(t.set(r,n.ke()),n.qe())}}));let n=G();this.He.forEach(((e,t)=>{let r=!0;t.forEachWhile((e=>{let t=this.st(e);return!t||t.purpose===`TargetPurposeLimboResolution`||(r=!1,!1)})),r&&(n=n.add(e))})),this.je.forEach(((t,n)=>n.setReadTime(e)));let r=new Sl(e,t,this.Ze,this.je,n);return this.je=mc(),this.Je=Al(),this.He=Al(),this.Ze=new B(N),r}Ye(e,t){let n=this.ze.get(e);if(!n||!this.nt(e))return void E(Ol,`addDocumentToTarget received document for unknown inactive target (${e})`);let r=this.It(e,t.key)?2:0;n.Ke(t.key,r),this.je=this.je.insert(t.key,t),this.Je=this.Je.insert(t.key,this.Tt(t.key).add(e)),this.He=this.He.insert(t.key,this.Et(t.key).add(e))}et(e,t,n){let r=this.ze.get(e);r&&this.nt(e)?(this.It(e,t)?r.Ke(t,1):r.Ue(t),this.He=this.He.insert(t,this.Et(t).delete(e)),this.He=this.He.insert(t,this.Et(t).add(e)),n&&(this.je=this.je.insert(t,n))):E(Ol,`removeDocumentFromTarget received document for unknown or inactive target (${e})`)}removeTarget(e){this.ze.delete(e)}ot(e){let t=this.ze.get(e);if(!t)return 0;let n=t.ke();return this.Ge.getRemoteKeysForTarget(e).size+n.addedDocuments.size-n.removedDocuments.size}$e(e){let t=this.ze.get(e);t||(E(Ol,`recordPendingTargetRequest set up tracking for target ID ${e}`),t=new Dl(e),this.ze.set(e,t)),t.$e()}Et(e){let t=this.He.get(e);return t||(t=new V(N),this.He=this.He.insert(e,t)),t}Tt(e){let t=this.Je.get(e);return t||(t=new V(N),this.Je=this.Je.insert(e,t)),t}nt(e){let t=this.st(e)!==null;return t||E(Ol,`Detected inactive target`,e),t}st(e){let t=this.ze.get(e);return t===void 0||t.Ne?null:this.Ge.Rt(e)}rt(e){this.ze.set(e,new Dl(e)),this.Ge.getRemoteKeysForTarget(e).forEach((t=>{this.et(e,t,null)}))}It(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}};function Al(){return new B(F.comparator)}function jl(){return new B(F.comparator)}var Ml={asc:`ASCENDING`,desc:`DESCENDING`},Nl={"<":`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`},Pl={and:`AND`,or:`OR`},Fl=class{constructor(e,t){this.databaseId=e,this.useProto3Json=t}};function Il(e,t){return e.useProto3Json||Hi(t)?t:{value:t}}function Ll(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 Rl(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function zl(e,t){return Ll(e,t.toTimestamp())}function Bl(e){return k(!!e,49232),R.fromTimestamp(function(e){let t=Co(e);return new L(t.seconds,t.nanos)}(e))}function Vl(e,t){return Hl(e,t).canonicalString()}function Hl(e,t){let n=function(e){return new P([`projects`,e.projectId,`databases`,e.database])}(e).child(`documents`);return t===void 0?n:n.child(t)}function Ul(e){let t=P.fromString(e);return k(hu(t),10190,{key:t.toString()}),t}function Wl(e,t){return Vl(e.databaseId,t.path)}function Gl(e,t){let n=Ul(t);if(n.get(1)!==e.databaseId.projectId)throw new M(j.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 M(j.INVALID_ARGUMENT,`Tried to deserialize key from different database: `+n.get(3)+` vs `+e.databaseId.database);return new F(Yl(n))}function Kl(e,t){return Vl(e.databaseId,t)}function ql(e){let t=Ul(e);return t.length===4?P.emptyPath():Yl(t)}function Jl(e){return new P([`projects`,e.databaseId.projectId,`databases`,e.databaseId.database]).canonicalString()}function Yl(e){return k(e.length>4&&e.get(4)===`documents`,29091,{key:e.toString()}),e.popFirst(5)}function Xl(e,t,n){return{name:Wl(e,t),fields:n.value.mapValue.fields}}function Zl(e,t,n){let r=Gl(e,t.name),i=Bl(t.updateTime),a=t.createTime?Bl(t.createTime):R.min(),o=new fs({mapValue:{fields:t.fields}}),s=ms.newFoundDocument(r,i,a,o);return n&&s.setHasCommittedMutations(),n?s.setHasCommittedMutations():s}function Ql(e,t){return`found`in t?function(e,t){k(!!t.found,43571),t.found.name,t.found.updateTime;let n=Gl(e,t.found.name),r=Bl(t.found.updateTime),i=t.found.createTime?Bl(t.found.createTime):R.min(),a=new fs({mapValue:{fields:t.found.fields}});return ms.newFoundDocument(n,r,i,a)}(e,t):`missing`in t?function(e,t){k(!!t.missing,3894),k(!!t.readTime,22933);let n=Gl(e,t.missing),r=Bl(t.readTime);return ms.newNoDocument(n,r)}(e,t):O(7234,{result:t})}function $l(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:O(39313,{state:e})}(t.targetChange.targetChangeType||`NO_CHANGE`),i=t.targetChange.targetIds||[],a=function(e,t){return e.useProto3Json?(k(t===void 0||typeof t==`string`,58123),xo.fromBase64String(t||``)):(k(t===void 0||t instanceof Buffer||t instanceof Uint8Array,16193),xo.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),o=t.targetChange.cause;n=new El(r,i,a,o&&function(e){return new M(e.code===void 0?j.UNKNOWN:ml(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=Gl(e,r.document.name),a=Bl(r.document.updateTime),o=r.document.createTime?Bl(r.document.createTime):R.min(),s=new fs({mapValue:{fields:r.document.fields}}),c=ms.newFoundDocument(i,a,o,s);n=new wl(r.targetIds||[],r.removedTargetIds||[],c.key,c)}else if(`documentDelete`in t){t.documentDelete;let r=t.documentDelete;r.document;let i=Gl(e,r.document),a=r.readTime?Bl(r.readTime):R.min(),o=ms.newNoDocument(i,a);n=new wl([],r.removedTargetIds||[],o.key,o)}else if(`documentRemove`in t){t.documentRemove;let r=t.documentRemove;r.document;let i=Gl(e,r.document);n=new wl([],r.removedTargetIds||[],i,null)}else{if(!(`filter`in t))return O(11601,{At:t});{t.filter;let e=t.filter;e.targetId;
15let{count:r=0,unchangedNames:i}=e,a=new dl(r,i),o=e.targetId;n=new Tl(o,a)}}return n}function eu(e,t){let n;if(t instanceof tl)n={update:Xl(e,t.key,t.value)};else if(t instanceof ol)n={delete:Wl(e,t.key)};else if(t instanceof nl)n={update:Xl(e,t.key,t.data),updateMask:mu(t.fieldMask)};else{if(!(t instanceof sl))return O(16599,{Vt:t.type});n={verify:Wl(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map((e=>function(e,t){let n=t.transform;if(n instanceof Mc)return{fieldPath:t.field.canonicalString(),setToServerValue:`REQUEST_TIME`};if(n instanceof Nc)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof Fc)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Rc)return{fieldPath:t.field.canonicalString(),increment:n.Ae};if(n instanceof zc)return{fieldPath:t.field.canonicalString(),minimum:n.Ae};if(n instanceof Bc)return{fieldPath:t.field.canonicalString(),maximum:n.Ae};throw O(20930,{transform:t.transform})}(0,e)))),t.precondition.isNone||(n.currentDocument=function(e,t){return t.updateTime===void 0?t.exists===void 0?O(27497):{exists:t.exists}:{updateTime:zl(e,t.updateTime)}}(e,t.precondition)),n}function tu(e,t){let n=t.currentDocument?function(e){return e.updateTime===void 0?e.exists===void 0?qc.none():qc.exists(e.exists):qc.updateTime(Bl(e.updateTime))}(t.currentDocument):qc.none(),r=t.updateTransforms?t.updateTransforms.map((t=>function(e,t){let n=null;return`setToServerValue`in t?(k(t.setToServerValue===`REQUEST_TIME`,16630,{proto:t}),n=new Mc):`appendMissingElements`in t?n=new Nc(t.appendMissingElements.values||[]):`removeAllFromArray`in t?n=new Fc(t.removeAllFromArray.values||[]):`increment`in t?n=new Rc(e,t.increment):`minimum`in t?n=new zc(e,t.minimum):`maximum`in t?n=new Bc(e,t.maximum):O(16584,{proto:t}),new Wc(ti.fromServerFormat(t.fieldPath),n)}(e,t))):[];if(t.update){t.update.name;let i=Gl(e,t.update.name),a=new fs({mapValue:{fields:t.update.fields}});return t.updateMask?new nl(i,a,function(e){return new vo((e.fieldPaths||[]).map((e=>ti.fromServerFormat(e))))}(t.updateMask),n,r):new tl(i,a,n,r)}return t.delete?new ol(Gl(e,t.delete),n):t.verify?new sl(Gl(e,t.verify),n):O(1463,{proto:t})}function nu(e,t){return e&&e.length>0?(k(t!==void 0,14353),e.map((e=>function(e,t){let n=e.updateTime?Bl(e.updateTime):Bl(t);return n.isEqual(R.min())&&(n=Bl(t)),new Kc(n,e.transformResults||[])}(e,t)))):[]}function ru(e,t){return{documents:[Kl(e,t.path)]}}function iu(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=Kl(e,i);let a=function(e){if(e.length!==0)return pu(W.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:du(e.field),direction:cu(e.dir)}}(e)))}(t.orderBy);o&&(n.structuredQuery.orderBy=o);let s=Il(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)),{dt:n,parent:i}}function au(e){let t=ql(e.parent),n=e.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){k(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=su(e);return t instanceof W&&Cs(t)?t.getFilters():[t]}(n.where));let o=[];n.orderBy&&(o=function(e){return e.map((e=>function(e){return new vs(fu(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,Hi(t)?null:t}(n.limit));let c=null;n.startAt&&(c=function(e){let t=!!e.before;return new hs(e.values||[],t)}(n.startAt));let l=null;return n.endAt&&(l=function(e){let t=!e.before;return new hs(e.values||[],t)}(n.endAt)),Ks(t,i,o,a,s,`F`,c,l)}function ou(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 O(28987,{purpose:e})}}(t.purpose);return n==null?null:{"goog-listen-tags":n}}function su(e){return e.unaryFilter===void 0?e.fieldFilter===void 0?e.compositeFilter===void 0?O(30097,{filter:e}):function(e){return W.create(e.compositeFilter.filters.map((e=>su(e))),function(e){switch(e){case`AND`:return`and`;case`OR`:return`or`;default:return O(1026)}}(e.compositeFilter.op))}(e):function(e){return U.create(fu(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 O(58110);default:return O(50506)}}(e.fieldFilter.op),e.fieldFilter.value)}(e):function(e){switch(e.unaryFilter.op){case`IS_NAN`:let t=fu(e.unaryFilter.field);return U.create(t,`==`,{doubleValue:NaN});case`IS_NULL`:let n=fu(e.unaryFilter.field);return U.create(n,`==`,{nullValue:`NULL_VALUE`});
15case`IS_NOT_NAN`:let r=fu(e.unaryFilter.field);return U.create(r,`!=`,{doubleValue:NaN});case`IS_NOT_NULL`:let i=fu(e.unaryFilter.field);return U.create(i,`!=`,{nullValue:`NULL_VALUE`});case`OPERATOR_UNSPECIFIED`:return O(61313);default:return O(60726)}}(e)}function cu(e){return Ml[e]}function lu(e){return Nl[e]}function uu(e){return Pl[e]}function du(e){return{fieldPath:e.canonicalString()}}function fu(e){return ti.fromServerFormat(e.fieldPath)}function pu(e){return e instanceof U?function(e){if(e.op===`==`){if(ns(e.value))return{unaryFilter:{field:du(e.field),op:`IS_NAN`}};if(ts(e.value))return{unaryFilter:{field:du(e.field),op:`IS_NULL`}}}else if(e.op===`!=`){if(ns(e.value))return{unaryFilter:{field:du(e.field),op:`IS_NOT_NAN`}};if(ts(e.value))return{unaryFilter:{field:du(e.field),op:`IS_NOT_NULL`}}}return{fieldFilter:{field:du(e.field),op:lu(e.op),value:e.value}}}(e):e instanceof W?function(e){let t=e.getFilters().map((e=>pu(e)));return t.length===1?t[0]:{compositeFilter:{op:uu(e.op),filters:t}}}(e):O(54877,{filter:e})}function mu(e){let t=[];return e.fields.forEach((e=>t.push(e.canonicalString()))),{fieldPaths:t}}function hu(e){return e.length>=4&&e.get(0)===`projects`&&e.get(2)===`databases`}function gu(e){return!!e&&typeof e._toProto==`function`&&e._protoValueType===`ProtoValue`}var _u=class e{constructor(e,t,n,r,i=R.min(),a=R.min(),o=xo.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)}},vu=class{constructor(e){this.gt=e}};function yu(e,t){let n;if(t.document)n=Zl(e.gt,t.document,!!t.hasCommittedMutations);else if(t.noDocument){let e=F.fromSegments(t.noDocument.path),r=Cu(t.noDocument.readTime);n=ms.newNoDocument(e,r),t.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!t.unknownDocument)return O(56709);{let e=F.fromSegments(t.unknownDocument.path),r=Cu(t.unknownDocument.version);n=ms.newUnknownDocument(e,r)}}return t.readTime&&n.setReadTime(function(e){let t=new L(e[0],e[1]);return R.fromTimestamp(t)}(t.readTime)),n}function bu(e,t){let n=t.key,r={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:xu(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())r.document=function(e,t){return{name:Wl(e,t.key),fields:t.data.value.mapValue.fields,updateTime:Ll(e,t.version.toTimestamp()),createTime:Ll(e,t.createTime.toTimestamp())}}(e.gt,t);else if(t.isNoDocument())r.noDocument={path:n.path.toArray(),readTime:Su(t.version)};else{if(!t.isUnknownDocument())return O(57904,{document:t});r.unknownDocument={path:n.path.toArray(),version:Su(t.version)}}return r}function xu(e){let t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function Su(e){let t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function Cu(e){let t=new L(e.seconds,e.nanoseconds);return R.fromTimestamp(t)}function wu(e,t){let n=(t.baseMutations||[]).map((t=>tu(e.gt,t)));for(let e=0;e<t.mutations.length-1;++e){let n=t.mutations[e];e+1<t.mutations.length&&t.mutations[e+1].transform!==void 0&&(n.updateTransforms=t.mutations[e+1].transform.fieldTransforms,t.mutations.splice(e+1,1),++e)}let r=t.mutations.map((t=>tu(e.gt,t))),i=L.fromMillis(t.localWriteTimeMs);return new cl(t.batchId,i,n,r)}function Tu(e){let t=Cu(e.readTime),n=e.lastLimboFreeSnapshotVersion===void 0?R.min():Cu(e.lastLimboFreeSnapshotVersion),r;return r=function(e){return e.documents!==void 0}(e.query)?function(e){let t=e.documents.length;return k(t===1,1966,{count:t}),Qs(qs(ql(e.documents[0])))}(e.query):function(e){return Qs(au(e))}(e.query),new _u(r,e.targetId,`TargetPurposeListen`,e.lastListenSequenceNumber,t,n,xo.fromBase64String(e.resumeToken))}function Eu(e,t){let n=Su(t.snapshotVersion),r=Su(t.lastLimboFreeSnapshotVersion),i;i=Vs(t.target)?ru(e.gt,t.target):iu(e.gt,t.target).dt;let a=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:zs(t.target),readTime:n,resumeToken:a,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:r,query:i}}function Du(e){let t=au({parent:e.parent,structuredQuery:e.structuredQuery});return e.limitType===`LAST`?nc(t,t.limit,`L`):t}function Ou(e,t){return new ul(t.largestBatchId,tu(e.gt,t.overlayMutation))}function ku(e,t){let n=t.path.lastSegment();return[e,Ki(t.path.popLast()),n]}function Au(e,t,n,r){return{indexId:e,uid:t,sequenceNumber:n,readTime:Su(r.readTime),documentKey:Ki(r.documentKey.path),largestBatchId:r.largestBatchId}}var ju=class{getBundleMetadata(e,t){return Mu(e).get(t).next((e=>{if(e)return function(e){return{id:e.bundleId,createTime:Cu(e.createTime),version:e.version}}(e)}))}saveBundleMetadata(e,t){return Mu(e).put(function(e){return{bundleId:e.id,createTime:Su(Bl(e.createTime)),version:e.version}}(t))}getNamedQuery(e,t){return Nu(e).get(t).next((e=>{if(e)return function(e){return{name:e.name,query:Du(e.bundledQuery),readTime:Cu(e.readTime)}}(e)}))}saveNamedQuery(e,t){return Nu(e).put(function(e){return{name:e.name,readTime:Su(Bl(e.readTime)),bundledQuery:e.bundledQuery}}(t))}};function Mu(e){return lo(e,Aa)}function Nu(e){return lo(e,Ma)}
15var Pu=class e{constructor(e,t){this.serializer=e,this.userId=t}static yt(t,n){return new e(t,n.uid||``)}getOverlay(e,t){return Fu(e).get(ku(this.userId,t)).next((e=>e?Ou(this.serializer,e):null))}getOverlays(e,t){let n=vc();return z.forEach(t,(t=>this.getOverlay(e,t).next((e=>{e!==null&&n.set(t,e)})))).next((()=>n))}saveOverlays(e,t,n){let r=[];return n.forEach(((n,i)=>{let a=new ul(t,i);r.push(this.wt(e,a))})),z.waitFor(r)}removeOverlaysForBatchId(e,t,n){let r=new Set;t.forEach((e=>r.add(Ki(e.getCollectionPath()))));let i=[];return r.forEach((t=>{let r=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,n+1],!1,!0);i.push(Fu(e).X(Ja,r))})),z.waitFor(i)}getOverlaysForCollection(e,t,n){let r=vc(),i=Ki(t),a=IDBKeyRange.bound([this.userId,i,n],[this.userId,i,1/0],!0);return Fu(e).J(Ja,a).next((e=>{for(let t of e){let e=Ou(this.serializer,t);r.set(e.getKey(),e)}return r}))}getOverlaysForCollectionGroup(e,t,n,r){let i=vc(),a,o=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,1/0],!0);return Fu(e).ee({index:Xa,range:o},((e,t,n)=>{let o=Ou(this.serializer,t);i.size()<r||o.largestBatchId===a?(i.set(o.getKey(),o),a=o.largestBatchId):n.done()})).next((()=>i))}wt(e,t){return Fu(e).put(function(e,t,n){let[r,i,a]=ku(t,n.mutation.key);return{userId:t,collectionPath:i,documentId:a,collectionGroup:n.mutation.key.getCollectionGroup(),largestBatchId:n.largestBatchId,overlayMutation:eu(e.gt,n.mutation)}}(this.serializer,this.userId,t))}};function Fu(e){return lo(e,Ka)}var Iu=class{St(e){return lo(e,Qa)}getSessionToken(e){return this.St(e).get(`sessionToken`).next((e=>{let t=e?.value;return t?xo.fromUint8Array(t):xo.EMPTY_BYTE_STRING}))}setSessionToken(e,t){return this.St(e).put({name:`sessionToken`,value:t.toUint8Array()})}},Lu=class{constructor(){}bt(e,t){this.Dt(e,t),t.Ct()}Dt(e,t){if(`nullValue`in e)this.vt(t,5);else if(`booleanValue`in e)this.vt(t,10),t.Ft(+!!e.booleanValue);else if(`integerValue`in e)this.vt(t,15),t.Ft(H(e.integerValue));else if(`doubleValue`in e){let n=H(e.doubleValue);isNaN(n)?this.vt(t,13):(this.vt(t,15),Ui(n)?t.Ft(0):t.Ft(n))}else if(`timestampValue`in e){let n=e.timestampValue;this.vt(t,20),typeof n==`string`&&(n=Co(n)),t.Mt(`${n.seconds||``}`),t.Ft(n.nanos||0)}else if(`stringValue`in e)this.xt(e.stringValue,t),this.Ot(t);else if(`bytesValue`in e)this.vt(t,30),t.Nt(wo(e.bytesValue)),this.Ot(t);else if(`referenceValue`in e)this.Bt(e.referenceValue,t);else if(`geoPointValue`in e){let n=e.geoPointValue;this.vt(t,45),t.Ft(n.latitude||0),t.Ft(n.longitude||0)}else `mapValue`in e?os(e)?this.vt(t,2**53-1):is(e)?this.Lt(e.mapValue,t):(this.kt(e.mapValue,t),this.Ot(t)):`arrayValue`in e?(this.qt(e.arrayValue,t),this.Ot(t)):O(19022,{Kt:e})}xt(e,t){this.vt(t,25),this.Ut(e,t)}Ut(e,t){t.Mt(e)}kt(e,t){let n=e.fields||{};this.vt(t,55);for(let e of Object.keys(n))this.xt(e,t),this.Dt(n[e],t)}Lt(e,t){let n=e.fields||{};this.vt(t,53);let r=Bo,i=n[r].arrayValue?.values?.length||0;this.vt(t,15),t.Ft(H(i)),this.xt(r,t),this.Dt(n[r],t)}qt(e,t){let n=e.values||[];this.vt(t,50);for(let e of n)this.Dt(e,t)}Bt(e,t){this.vt(t,37),F.fromName(e).path.forEach((e=>{this.vt(t,60),this.Ut(e,t)}))}vt(e,t){e.Ft(t)}Ot(e){e.Ft(2)}};Lu.$t=new Lu;var Ru=255;function zu(e){if(e===0)return 8;let t=0;return e>>4||(t+=4,e<<=4),e>>6||(t+=2,e<<=2),e>>7||(t+=1),t}function Bu(e){let t=64-function(e){let t=0;for(let n=0;n<8;++n){let r=zu(255&e[n]);if(t+=r,r!==8)break}return t}(e);return Math.ceil(t/8)}var Vu=class{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Wt(e){let t=e[Symbol.iterator](),n=t.next();for(;!n.done;)this.Qt(n.value),n=t.next();this.Gt()}zt(e){let t=e[Symbol.iterator](),n=t.next();for(;!n.done;)this.jt(n.value),n=t.next();this.Jt()}Ht(e){for(let t of e){let e=t.charCodeAt(0);if(e<128)this.Qt(e);else if(e<2048)this.Qt(960|e>>>6),this.Qt(128|63&e);else if(t<`\ud800`||`\udbff`<t)this.Qt(480|e>>>12),this.Qt(128|63&e>>>6),this.Qt(128|63&e);else{let e=t.codePointAt(0);this.Qt(240|e>>>18),this.Qt(128|63&e>>>12),this.Qt(128|63&e>>>6),this.Qt(128|63&e)}}this.Gt()}Zt(e){for(let t of e){let e=t.charCodeAt(0);if(e<128)this.jt(e);else if(e<2048)this.jt(960|e>>>6),this.jt(128|63&e);else if(t<`\ud800`||`\udbff`<t)this.jt(480|e>>>12),this.jt(128|63&e>>>6),this.jt(128|63&e);else{let e=t.codePointAt(0);this.jt(240|e>>>18),this.jt(128|63&e>>>12),this.jt(128|63&e>>>6),this.jt(128|63&e)}}this.Jt()}Xt(e){let t=this.Yt(e),n=Bu(t);this.en(1+n),this.buffer[this.position++]=255&n;for(let e=t.length-n;e<t.length;++e)this.buffer[this.position++]=255&t[e]}tn(e){let t=this.Yt(e),n=Bu(t);this.en(1+n),this.buffer[this.position++]=~(255&n);for(let e=t.length-n;e<t.length;++e)this.buffer[this.position++]=~(255&t[e])}nn(){this.rn(Ru),this.rn(255)}sn(){this._n(Ru),this._n(255)}reset(){this.position=0}seed(e){this.en(e.length),this.buffer.set(e,this.position),this.position+=e.length}an(){return this.buffer.slice(0,this.position)}Yt(e){let t=function(e){let t=new DataView(new ArrayBuffer(8));return t.setFloat64(0,e,!1),new Uint8Array(t.buffer)}(e),n=!!(128&t[0]);t[0]^=n?255:128;for(let e=1;e<t.length;++e)t[e]^=n?255:0;return t}Qt(e){let t=255&e;t===0?(this.rn(0),this.rn(255)):t===Ru?(this.rn(Ru),this.rn(0)):this.rn(t)}jt(e){let t=255&e;t===0?(this._n(0),this._n(255)):t===Ru?(this._n(Ru),this._n(0)):this._n(e)}Gt(){this.rn(0),this.rn(1)}Jt(){this._n(0),this._n(1)}rn(e){this.en(1),this.buffer[this.position++]=e}_n(e){this.en(1),this.buffer[this.position++]=~e}en(e){let t=e+this.position;if(t<=this.buffer.length)return;let n=2*this.buffer.length;n<t&&(n=t);let r=new Uint8Array(n);r.set(this.buffer),this.buffer=r}},Hu=class{constructor(e){this.un=e}Nt(e){this.un.Wt(e)}Mt(e){this.un.Ht(e)}Ft(e){this.un.Xt(e)}Ct(){this.un.nn()}},Uu=class{constructor(e){this.un=e}Nt(e){this.un.zt(e)}Mt(e){this.un.Zt(e)}Ft(e){this.un.tn(e)}Ct(){this.un.sn()}},Wu=class{constructor(){this.un=new Vu,this.ascending=new Hu(this.un),this.descending=new Uu(this.un)}seed(e){this.un.seed(e)}cn(e){return e===0?this.ascending:this.descending}an(){return this.un.an()}reset(){this.un.reset()}},Gu=class e{constructor(e,t,n,r){this.ln=e,this.hn=t,this.Pn=n,this.Tn=r}In(){let t=this.Tn.length,n=t===0||this.Tn[t-1]===255?t+1:t,r=new Uint8Array(n);return r.set(this.Tn,0),n===t?++r[r.length-1]:r.set([0],this.Tn.length),new e(this.ln,this.hn,this.Pn,r)}En(e,t,n){return{indexId:this.ln,uid:e,arrayValue:Ju(this.Pn),directionalValue:Ju(this.Tn),orderedDocumentKey:Ju(t),documentKey:n.path.toArray()}}Rn(e,t,n){let r=this.En(e,t,n);return[r.indexId,r.uid,r.arrayValue,r.directionalValue,r.orderedDocumentKey,r.documentKey]}};function Ku(e,t){let n=e.ln-t.ln;return n===0?(n=qu(e.Pn,t.Pn),n===0?(n=qu(e.Tn,t.Tn),n===0?F.comparator(e.hn,t.hn):n):n):n}function qu(e,t){for(let n=0;n<e.length&&n<t.length;++n){let r=e[n]-t[n];if(r!==0)return r}return e.length-t.length}function Ju(e){return we()?function(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t}(e):e}function Yu(e){return typeof e==`string`?function(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(e):e}var Xu=class{constructor(e){this.An=new V(((e,t)=>ti.comparator(e.field,t.field))),this.collectionId=e.collectionGroup==null?e.path.lastSegment():e.collectionGroup,this.Vn=e.orderBy,this.dn=[];for(let t of e.filters){let e=t;e.isInequality()?this.An=this.An.add(e):this.dn.push(e)}}get mn(){return this.An.size>1}fn(e){if(k(e.collectionGroup===this.collectionId,49279),this.mn)return!1;let t=hi(e);if(t!==void 0&&!this.gn(t))return!1;let n=gi(e),r=new Set,i=0,a=0;for(;i<n.length&&this.gn(n[i]);++i)r=r.add(n[i].fieldPath.canonicalString());if(i===n.length)return!0;
15if(this.An.size>0){let e=this.An.getIterator().getNext();if(!r.has(e.field.canonicalString())){let t=n[i];if(!this.pn(e,t)||!this.yn(this.Vn[a++],t))return!1}++i}for(;i<n.length;++i){let e=n[i];if(a>=this.Vn.length||!this.yn(this.Vn[a++],e))return!1}return!0}wn(){if(this.mn)return null;let e=new V(ti.comparator),t=[];for(let n of this.dn)if(!n.field.isKeyField())if(n.op===`array-contains`||n.op===`array-contains-any`)t.push(new _i(n.field,2));else{if(e.has(n.field))continue;e=e.add(n.field),t.push(new _i(n.field,0))}for(let n of this.Vn)n.field.isKeyField()||e.has(n.field)||(e=e.add(n.field),t.push(new _i(n.field,n.dir===`asc`?0:1)));return new mi(mi.UNKNOWN_ID,this.collectionId,t,vi.empty())}gn(e){for(let t of this.dn)if(this.pn(t,e))return!0;return!1}pn(e,t){if(e===void 0||!e.field.isEqual(t.fieldPath))return!1;let n=e.op===`array-contains`||e.op===`array-contains-any`;return t.kind===2===n}yn(e,t){return!!e.field.isEqual(t.fieldPath)&&(t.kind===0&&e.dir===`asc`||t.kind===1&&e.dir===`desc`)}};function Zu(e){if(k(e instanceof U||e instanceof W,20012),e instanceof U){if(e instanceof Ps){let t=e.value.arrayValue?.values?.map((t=>U.create(e.field,`==`,t)))||[];return W.create(t,`or`)}return e}let t=e.filters.map((e=>Zu(e)));return W.create(t,e.op)}function Qu(e){if(e.getFilters().length===0)return[];let t=nd(Zu(e));return k(td(t),7391),$u(t)||ed(t)?[t]:t.getFilters()}function $u(e){return e instanceof U}function ed(e){return e instanceof W&&Cs(e)}function td(e){return $u(e)||ed(e)||function(e){if(e instanceof W&&Ss(e)){for(let t of e.getFilters())if(!$u(t)&&!ed(t))return!1;return!0}return!1}(e)}function nd(e){if(k(e instanceof U||e instanceof W,34018),e instanceof U)return e;if(e.filters.length===1)return nd(e.filters[0]);let t=e.filters.map((e=>nd(e))),n=W.create(t,e.op);return n=ad(n),td(n)?n:(k(n instanceof W,64498),k(xs(n),40251),k(n.filters.length>1,57927),n.filters.reduce(((e,t)=>rd(e,t))))}function rd(e,t){let n;return k(e instanceof U||e instanceof W,38388),k(t instanceof U||t instanceof W,25473),n=e instanceof U?t instanceof U?function(e,t){return W.create([e,t],`and`)}(e,t):id(e,t):t instanceof U?id(t,e):function(e,t){if(k(e.filters.length>0&&t.filters.length>0,48005),xs(e)&&xs(t))return Ds(e,t.getFilters());let n=Ss(e)?e:t,r=Ss(e)?t:e,i=n.filters.map((e=>rd(e,r)));return W.create(i,`or`)}(e,t),ad(n)}function id(e,t){if(xs(t))return Ds(t,e.getFilters());{let n=t.filters.map((t=>rd(e,t)));return W.create(n,`or`)}}function ad(e){if(k(e instanceof U||e instanceof W,11850),e instanceof U)return e;let t=e.getFilters();if(t.length===1)return ad(t[0]);if(ws(e))return e;let n=t.map((e=>ad(e))),r=[];return n.forEach((t=>{t instanceof U?r.push(t):t instanceof W&&(t.op===e.op?r.push(...t.filters):r.push(t))})),r.length===1?r[0]:W.create(r,e.op)}var od=class{constructor(){this.Sn=new sd}addToCollectionParentIndex(e,t){return this.Sn.add(t),z.resolve()}getCollectionParents(e,t){return z.resolve(this.Sn.getEntries(t))}addFieldIndex(e,t){return z.resolve()}deleteFieldIndex(e,t){return z.resolve()}deleteAllFieldIndexes(e){return z.resolve()}createTargetIndexes(e,t){return z.resolve()}getDocumentsMatchingTarget(e,t){return z.resolve(null)}getIndexType(e,t){return z.resolve(0)}getFieldIndexes(e,t){return z.resolve([])}getNextCollectionGroupToUpdate(e){return z.resolve(null)}getMinOffset(e,t){return z.resolve(xi.min())}getMinOffsetFromCollectionGroup(e,t){return z.resolve(xi.min())}updateCollectionGroup(e,t,n){return z.resolve()}updateIndexEntries(e,t){return z.resolve()}},sd=class{constructor(){this.index={}}add(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new V(P.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 V(P.comparator)).toArray()}},cd=`IndexedDbIndexManager`,ld=new Uint8Array,ud=class{constructor(e,t){this.databaseId=t,this.bn=new sd,this.Dn=new fc((e=>zs(e)),((e,t)=>Bs(e,t))),this.uid=e.uid||``}addToCollectionParentIndex(e,t){if(!this.bn.has(t)){let n=t.lastSegment(),r=t.popLast();e.addOnCommittedListener((()=>{this.bn.add(t)}));let i={collectionId:n,parent:Ki(r)};return dd(e).put(i)}return z.resolve()}getCollectionParents(e,t){let n=[],r=IDBKeyRange.bound([t,``],[Zr(t),``],!1,!0);return dd(e).J(r).next((e=>{for(let r of e){if(r.collectionId!==t)break;n.push(Yi(r.parent))}return n}))}addFieldIndex(e,t){let n=pd(e),r=function(e){return{indexId:e.indexId,collectionGroup:e.collectionGroup,fields:e.fields.map((e=>[e.fieldPath.canonicalString(),e.kind]))}}(t);delete r.indexId;let i=n.add(r);if(t.indexState){let n=md(e);return i.next((e=>{n.put(Au(e,this.uid,t.indexState.sequenceNumber,t.indexState.offset))}))}return i.next()}deleteFieldIndex(e,t){let n=pd(e),r=md(e),i=fd(e);return n.delete(t.indexId).next((()=>r.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0)))).next((()=>i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))))}deleteAllFieldIndexes(e){let t=pd(e),n=fd(e),r=md(e);return t.X().next((()=>n.X())).next((()=>r.X()))}createTargetIndexes(e,t){return z.forEach(this.Cn(t),(t=>this.getIndexType(e,t).next((n=>{if(n===0||n===1){let n=new Xu(t).wn();if(n!=null)return this.addFieldIndex(e,n)}}))))}getDocumentsMatchingTarget(e,t){let n=fd(e),r=!0,i=new Map;return z.forEach(this.Cn(t),(t=>this.vn(e,t).next((e=>{r&&=!!e,i.set(t,e)})))).next((()=>
15{if(r){let e=G(),r=[];return z.forEach(i,((i,a)=>{E(cd,`Using index ${function(e){return`id=${e.indexId}|cg=${e.collectionGroup}|f=${e.fields.map((e=>`${e.fieldPath}:${e.kind}`)).join(`,`)}`}(i)} to execute ${zs(t)}`);let o=function(e,t){let n=hi(t);if(n===void 0)return null;for(let t of Hs(e,n.fieldPath))switch(t.op){case`array-contains-any`:return t.value.arrayValue.values||[];case`array-contains`:return[t.value]}return null}(a,i),s=function(e,t){let n=new Map;for(let r of gi(t))for(let t of Hs(e,r.fieldPath))switch(t.op){case`==`:case`in`:n.set(r.fieldPath.canonicalString(),t.value);break;case`not-in`:case`!=`:return n.set(r.fieldPath.canonicalString(),t.value),Array.from(n.values())}return null}(a,i),c=function(e,t){let n=[],r=!0;for(let i of gi(t)){let t=i.kind===0?Us(e,i.fieldPath,e.startAt):Ws(e,i.fieldPath,e.startAt);n.push(t.value),r&&=t.inclusive}return new hs(n,r)}(a,i),l=function(e,t){let n=[],r=!0;for(let i of gi(t)){let t=i.kind===0?Ws(e,i.fieldPath,e.endAt):Us(e,i.fieldPath,e.endAt);n.push(t.value),r&&=t.inclusive}return new hs(n,r)}(a,i),u=this.Fn(i,a,c),d=this.Fn(i,a,l),f=this.Mn(i,a,s),p=this.xn(i.indexId,o,u,c.inclusive,d,l.inclusive,f);return z.forEach(p,(i=>n.Z(i,t.limit).next((t=>{t.forEach((t=>{let n=F.fromSegments(t.documentKey);e.has(n)||(e=e.add(n),r.push(n))}))}))))})).next((()=>r))}return z.resolve(null)}))}Cn(e){let t=this.Dn.get(e);return t||(t=e.filters.length===0?[e]:Qu(W.create(e.filters,`and`)).map((t=>Rs(e.path,e.collectionGroup,e.orderBy,t.getFilters(),e.limit,e.startAt,e.endAt))),this.Dn.set(e,t),t)}xn(e,t,n,r,i,a,o){let s=(t==null?1:t.length)*Math.max(n.length,i.length),c=s/(t==null?1:t.length),l=[];for(let u=0;u<s;++u){let s=t?this.On(t[u/c]):ld,d=this.Nn(e,s,n[u%c],r),f=this.Bn(e,s,i[u%c],a),p=o.map((t=>this.Nn(e,s,t,!0)));l.push(...this.createRange(d,f,p))}return l}Nn(e,t,n,r){let i=new Gu(e,F.empty(),t,n);return r?i:i.In()}Bn(e,t,n,r){let i=new Gu(e,F.empty(),t,n);return r?i.In():i}vn(e,t){let n=new Xu(t),r=t.collectionGroup==null?t.path.lastSegment():t.collectionGroup;return this.getFieldIndexes(e,r).next((e=>{let t=null;for(let r of e)n.fn(r)&&(!t||r.fields.length>t.fields.length)&&(t=r);return t}))}getIndexType(e,t){let n=2,r=this.Cn(t);return z.forEach(r,(t=>this.vn(e,t).next((e=>{e?n!==0&&e.fields.length<function(e){let t=new V(ti.comparator),n=!1;for(let r of e.filters)for(let e of r.getFlattenedFilters())e.field.isKeyField()||(e.op===`array-contains`||e.op===`array-contains-any`?n=!0:t=t.add(e.field));for(let n of e.orderBy)n.field.isKeyField()||(t=t.add(n.field));return t.size+ +!!n}(t)&&(n=1):n=0})))).next((()=>function(e){return e.limit!==null}(t)&&r.length>1&&n===2?1:n))}Ln(e,t){let n=new Wu;for(let r of gi(e)){let e=t.data.field(r.fieldPath);if(e==null)return null;let i=n.cn(r.kind);Lu.$t.bt(e,i)}return n.an()}On(e){let t=new Wu;return Lu.$t.bt(e,t.cn(0)),t.an()}kn(e,t){let n=new Wu;return Lu.$t.bt(Zo(this.databaseId,t),n.cn(function(e){let t=gi(e);return t.length===0?0:t[t.length-1].kind}(e))),n.an()}Mn(e,t,n){if(n===null)return[];let r=[];r.push(new Wu);let i=0;for(let a of gi(e)){let e=n[i++];for(let n of r)if(this.qn(t,a.fieldPath)&&es(e))r=this.Kn(r,a,e);else{let t=n.cn(a.kind);Lu.$t.bt(e,t)}}return this.Un(r)}Fn(e,t,n){return this.Mn(e,t,n.position)}Un(e){let t=[];for(let n=0;n<e.length;++n)t[n]=e[n].an();return t}Kn(e,t,n){let r=[...e],i=[];for(let e of n.arrayValue.values||[])for(let n of r){let r=new Wu;r.seed(n.an()),Lu.$t.bt(e,r.cn(t.kind)),i.push(r)}return i}qn(e,t){return!!e.filters.find((e=>e instanceof U&&e.field.isEqual(t)&&(e.op===`in`||e.op===`not-in`)))}getFieldIndexes(e,t){let n=pd(e),r=md(e);return(t?n.J(Ia,IDBKeyRange.bound(t,t)):n.J()).next((e=>{let t=[];return z.forEach(e,(e=>r.get([e.indexId,this.uid]).next((n=>{t.push(function(e,t){let n=t?new vi(t.sequenceNumber,new xi(Cu(t.readTime),new F(Yi(t.documentKey)),t.largestBatchId)):vi.empty(),r=e.fields.map((([e,t])=>new _i(ti.fromServerFormat(e),t)));return new mi(e.indexId,e.collectionGroup,r,n)}(e,n))})))).next((()=>t))}))}getNextCollectionGroupToUpdate(e){return this.getFieldIndexes(e).next((e=>e.length===0?null:(e.sort(((e,t)=>{let n=e.indexState.sequenceNumber-t.indexState.sequenceNumber;return n===0?N(e.collectionGroup,t.collectionGroup):n}
15)),e[0].collectionGroup)))}updateCollectionGroup(e,t,n){let r=pd(e),i=md(e);return this.$n(e).next((e=>r.J(Ia,IDBKeyRange.bound(t,t)).next((t=>z.forEach(t,(t=>i.put(Au(t.indexId,this.uid,e,n))))))))}updateIndexEntries(e,t){let n=new Map;return z.forEach(t,((t,r)=>{let i=n.get(t.collectionGroup);return(i?z.resolve(i):this.getFieldIndexes(e,t.collectionGroup)).next((i=>(n.set(t.collectionGroup,i),z.forEach(i,(n=>this.Wn(e,t,n).next((t=>{let i=this.Qn(r,n);return t.isEqual(i)?z.resolve():this.Gn(e,r,n,t,i)})))))))}))}zn(e,t,n,r){return fd(e).put(r.En(this.uid,this.kn(n,t.key),t.key))}jn(e,t,n,r){return fd(e).delete(r.Rn(this.uid,this.kn(n,t.key),t.key))}Wn(e,t,n){let r=fd(e),i=new V(Ku);return r.ee({index:Wa,range:IDBKeyRange.only([n.indexId,this.uid,Ju(this.kn(n,t))])},((e,r)=>{i=i.add(new Gu(n.indexId,t,Yu(r.arrayValue),Yu(r.directionalValue)))})).next((()=>i))}Qn(e,t){let n=new V(Ku),r=this.Ln(t,e);if(r==null)return n;let i=hi(t);if(i!=null){let a=e.data.field(i.fieldPath);if(es(a))for(let i of a.arrayValue.values||[])n=n.add(new Gu(t.indexId,e.key,this.On(i),r))}else n=n.add(new Gu(t.indexId,e.key,ld,r));return n}Gn(e,t,n,r,i){E(cd,`Updating index entries for document '%s'`,t.key);let a=[];return function(e,t,n,r,i){let a=e.getIterator(),o=t.getIterator(),s=_o(a),c=_o(o);for(;s||c;){let e=!1,t=!1;if(s&&c){let r=n(s,c);r<0?t=!0:r>0&&(e=!0)}else s==null?e=!0:t=!0;e?(r(c),c=_o(o)):t?(i(s),s=_o(a)):(s=_o(a),c=_o(o))}}(r,i,Ku,(r=>{a.push(this.zn(e,t,n,r))}),(r=>{a.push(this.jn(e,t,n,r))})),z.waitFor(a)}$n(e){let t=1;return md(e).ee({index:Ba,reverse:!0,range:IDBKeyRange.upperBound([this.uid,2**53-1])},((e,n,r)=>{r.done(),t=n.sequenceNumber+1})).next((()=>t))}createRange(e,t,n){n=n.sort(((e,t)=>Ku(e,t))).filter(((e,t,n)=>!t||Ku(e,n[t-1])!==0));let r=[];r.push(e);for(let i of n){let n=Ku(i,e),a=Ku(i,t);if(n===0)r[0]=e.In();else if(n>0&&a<0)r.push(i),r.push(i.In());else if(a>0)break}r.push(t);let i=[];for(let e=0;e<r.length;e+=2){if(this.Jn(r[e],r[e+1]))return[];let t=r[e].Rn(this.uid,ld,F.empty()),n=r[e+1].Rn(this.uid,ld,F.empty());i.push(IDBKeyRange.bound(t,n))}return i}Jn(e,t){return Ku(e,t)>0}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(hd)}getMinOffset(e,t){return z.mapArray(this.Cn(t),(t=>this.vn(e,t).next((e=>e||O(44426))))).next(hd)}};function dd(e){return lo(e,Ea)}function fd(e){return lo(e,Ha)}function pd(e){return lo(e,Pa)}function md(e){return lo(e,Ra)}function hd(e){k(e.length!==0,28825);let t=e[0].indexState.offset,n=t.largestBatchId;for(let r=1;r<e.length;r++){let i=e[r].indexState.offset;Si(i,t)<0&&(t=i),n<i.largestBatchId&&(n=i.largestBatchId)}return new xi(t.readTime,t.documentKey,n)}var gd={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},_d=41943040,vd=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}};function yd(e,t,n){let r=e.store(ta),i=e.store(ca),a=[],o=IDBKeyRange.only(n.batchId),s=0,c=r.ee({range:o},((e,t,n)=>(s++,n.delete())));a.push(c.next((()=>{k(s===1,47070,{batchId:n.batchId})})));let l=[];for(let e of n.mutations){let r=oa(t,e.key.path,n.batchId);a.push(i.delete(r)),l.push(e.key)}return z.waitFor(a).next((()=>l))}function bd(e){if(!e)return 0;let t;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw O(14731);t=e.noDocument}return JSON.stringify(t).length}vd.DEFAULT_COLLECTION_PERCENTILE=10,vd.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,vd.DEFAULT=new vd(_d,vd.DEFAULT_COLLECTION_PERCENTILE,vd.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),vd.DISABLED=new vd(-1,0,0);var xd=class e{constructor(e,t,n,r){this.userId=e,this.serializer=t,this.indexManager=n,this.referenceDelegate=r,this.Hn={}}static yt(t,n,r,i){return k(t.uid!==``,64387),new e(t.isAuthenticated()?t.uid:``,n,r,i)}checkEmpty(e){let t=!0,n=IDBKeyRange.bound([this.userId,-1/0],[this.userId,1/0]);return Cd(e).ee({index:ra,range:n},((e,n,r)=>{t=!1,r.done()})).next((()=>t))}addMutationBatch(e,t,n,r){let i=wd(e),a=Cd(e);return a.add({}).next((o=>{k(typeof o==`number`,49019);let s=new cl(o,t,n,r),c=function(e,t,n){let r=n.baseMutations.map((t=>eu(e.gt,t))),i=n.mutations.map((t=>eu(e.gt,t)));return{userId:t,batchId:n.batchId,localWriteTimeMs:n.localWriteTime.toMillis(),baseMutations:r,mutations:i}}(this.serializer,this.userId,s),l=[],u=new V(((e,t)=>N(e.canonicalString(),t.canonicalString())));for(let e of r){let t=oa(this.userId,e.key.path,o);u=u.add(e.key.path.popLast()),l.push(a.put(c)),l.push(i.put(t,sa))}return u.forEach((t=>{l.push(this.indexManager.addToCollectionParentIndex(e,t))})),e.addOnCommittedListener((()=>{this.Hn[o]=s.keys()})),z.waitFor(l).next((()=>s))}))}lookupMutationBatch(e,t){return Cd(e).get(t).next((e=>e?(k(e.userId===this.userId,48,`Unexpected user for mutation batch`,{userId:e.userId,batchId:t}),wu(this.serializer,e)):null))}Zn(e,t){return this.Hn[t]?z.resolve(this.Hn[t]):this.lookupMutationBatch(e,t).next((e=>{if(e){let n=e.keys();return this.Hn[t]=n,n}return null}))}getNextMutationBatchAfterBatchId(e,t){let n=t+1,r=IDBKeyRange.lowerBound([this.userId,n]),i=null;return Cd(e).ee({index:ra,range:r},((e,t,r)=>{t.userId===this.userId&&(k(t.batchId>=n,47524,{Xn:n}),i=wu(this.serializer,t)),r.done()})).next((()=>i))}getHighestUnacknowledgedBatchId(e){let t=IDBKeyRange.upperBound([this.userId,1/0]),n=Vi;return Cd(e).ee({index:ra,range:t,reverse:!0},((e,t,r)=>{n=t.batchId,r.done()})).next((()=>n))}getAllMutationBatches(e){let t=IDBKeyRange.bound([this.userId,Vi],[this.userId,1/0]);return Cd(e).J(ra,t).next((e=>e.map((e=>wu(this.serializer,e)))))}getAllMutationBatchesAffectingDocumentKey(e,t){let n=aa(this.userId,t.path),r=IDBKeyRange.lowerBound(n),i=[];return wd(e).ee({range:r},((n,r,a)=>{let[o,s,c]=n,l=Yi(s);if(o===this.userId&&t.path.isEqual(l))return Cd(e).get(c).next((e=>{if(!e)throw O(61480,{Yn:n,batchId:c});k(e.userId===this.userId,10503,`Unexpected user for mutation batch`,{userId:e.userId,batchId:c}),i.push(wu(this.serializer,e))}));a.done()})).next((()=>i))}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new V(N),r=[];return t.forEach((t=>{let i=aa(this.userId,t.path),a=IDBKeyRange.lowerBound(i),o=wd(e).ee({range:a}
15,((e,r,i)=>{let[a,o,s]=e,c=Yi(o);a===this.userId&&t.path.isEqual(c)?n=n.add(s):i.done()}));r.push(o)})),z.waitFor(r).next((()=>this.er(e,n)))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=aa(this.userId,n),a=IDBKeyRange.lowerBound(i),o=new V(N);return wd(e).ee({range:a},((e,t,i)=>{let[a,s,c]=e,l=Yi(s);a===this.userId&&n.isPrefixOf(l)?l.length===r&&(o=o.add(c)):i.done()})).next((()=>this.er(e,o)))}er(e,t){let n=[],r=[];return t.forEach((t=>{r.push(Cd(e).get(t).next((e=>{if(e===null)throw O(35274,{batchId:t});k(e.userId===this.userId,9748,`Unexpected user for mutation batch`,{userId:e.userId,batchId:t}),n.push(wu(this.serializer,e))})))})),z.waitFor(r).next((()=>n))}removeMutationBatch(e,t){return yd(e.le,this.userId,t).next((n=>(e.addOnCommittedListener((()=>{this.tr(t.batchId)})),z.forEach(n,(t=>this.referenceDelegate.markPotentiallyOrphaned(e,t))))))}tr(e){delete this.Hn[e]}performConsistencyCheck(e){return this.checkEmpty(e).next((t=>{if(!t)return z.resolve();let n=IDBKeyRange.lowerBound(function(e){return[e]}(this.userId)),r=[];return wd(e).ee({range:n},((e,t,n)=>{if(e[0]===this.userId){let t=Yi(e[1]);r.push(t)}else n.done()})).next((()=>{k(r.length===0,56720,{nr:r.map((e=>e.canonicalString()))})}))}))}containsKey(e,t){return Sd(e,this.userId,t)}rr(e){return Td(e).get(this.userId).next((e=>e||{userId:this.userId,lastAcknowledgedBatchId:Vi,lastStreamToken:``}))}};function Sd(e,t,n){let r=aa(t,n.path),i=r[1],a=IDBKeyRange.lowerBound(r),o=!1;return wd(e).ee({range:a,Y:!0},((e,n,r)=>{let[a,s,c]=e;a===t&&s===i&&(o=!0),r.done()})).next((()=>o))}function Cd(e){return lo(e,ta)}function wd(e){return lo(e,ca)}function Td(e){return lo(e,$i)}var Ed=class e{constructor(e){this.ir=e}next(){return this.ir+=2,this.ir}static sr(){return new e(0)}static _r(){return new e(-1)}},Dd=class{constructor(e,t){this.referenceDelegate=e,this.serializer=t}allocateTargetId(e){return this.ar(e).next((t=>(t.highestTargetId=new Ed(t.highestTargetId).next(),this.ur(e,t).next((()=>t.highestTargetId)))))}getLastRemoteSnapshotVersion(e){return this.ar(e).next((e=>R.fromTimestamp(new L(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds))))}getHighestSequenceNumber(e){return this.ar(e).next((e=>e.highestListenSequenceNumber))}setTargetsMetadata(e,t,n){return this.ar(e).next((r=>(r.highestListenSequenceNumber=t,n&&(r.lastRemoteSnapshotVersion=n.toTimestamp()),t>r.highestListenSequenceNumber&&(r.highestListenSequenceNumber=t),this.ur(e,r))))}addTargetData(e,t){return this.cr(e,t).next((()=>this.ar(e).next((n=>(n.targetCount+=1,this.lr(t,n),this.ur(e,n))))))}updateTargetData(e,t){return this.cr(e,t)}removeTargetData(e,t){return this.removeMatchingKeysForTargetId(e,t.targetId).next((()=>Od(e).delete(t.targetId))).next((()=>this.ar(e))).next((t=>(k(t.targetCount>0,8065),--t.targetCount,this.ur(e,t))))}removeTargets(e,t,n){let r=0,i=[];return Od(e).ee(((a,o)=>{let s=Tu(o);s.sequenceNumber<=t&&n.get(s.targetId)===null&&(r++,i.push(this.removeTargetData(e,s)))})).next((()=>z.waitFor(i))).next((()=>r))}forEachTarget(e,t){return Od(e).ee(((e,n)=>{t(Tu(n))}))}ar(e){return kd(e).get(wa).next((e=>(k(e!==null,2888),e)))}ur(e,t){return kd(e).put(wa,t)}cr(e,t){return Od(e).put(Eu(this.serializer,t))}lr(e,t){let n=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,n=!0),e.sequenceNumber>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,n=!0),n}getTargetCount(e){return this.ar(e).next((e=>e.targetCount))}getTargetData(e,t){let n=zs(t),r=IDBKeyRange.bound([n,-1/0],[n,1/0]),i=null;return Od(e).ee({range:r,index:va},((e,n,r)=>{let a=Tu(n);Bs(t,a.target)&&(i=a,r.done())})).next((()=>i))}addMatchingKeys(e,t,n){let r=[],i=Ad(e);return t.forEach((t=>{let a=Ki(t.path);r.push(i.put({targetId:n,path:a})),r.push(this.referenceDelegate.addReference(e,n,t))})),z.waitFor(r)}removeMatchingKeys(e,t,n){let r=Ad(e);return z.forEach(t,(t=>{let i=Ki(t.path);return z.waitFor([r.delete([n,i]),this.referenceDelegate.removeReference(e,n,t)])}))}removeMatchingKeysForTargetId(e,t){let n=Ad(e),r=IDBKeyRange.bound([t],[t+1],!1,!0);return n.delete(r)}getMatchingKeysForTargetId(e,t){let n=IDBKeyRange.bound([t],[t+1],!1,!0),r=Ad(e),i=G();return r.ee({range:n,Y:!0},((e,t,n)=>{let r=new F(Yi(e[1]));i=i.add(r)})).next((()=>i))}containsKey(e,t){let n=Ki(t.path),r=IDBKeyRange.bound([n],[Zr(n)],!1,!0),i=0;return Ad(e).ee({index:Sa,Y:!0,range:r},(([e,t],n,r)=>{e!==0&&(i++,r.done())})).next((()=>i>0))}Rt(e,t){return Od(e).get(t).next((e=>e?Tu(e):null))}};function Od(e){return lo(e,_a)}function kd(e){return lo(e,Ta)}function Ad(e){return lo(e,ba)}var jd=`LruGarbageCollector`,Md=1048576;function Nd([e,t],[n,r]){let i=N(e,n);return i===0?N(t,r):i}var Pd=class{constructor(e){this.hr=e,this.buffer=new V(Nd),this.Pr=0}Tr(){return++this.Pr}Ir(e){let t=[e,this.Tr()];if(this.buffer.size<this.hr)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();Nd(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}},Fd=class{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Er=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Rr(6e4)}stop(){this.Er&&=(this.Er.cancel(),null)}get started(){return this.Er!==null}Rr(e){E(jd,`Garbage collection scheduled in ${e}ms`),this.Er=this.asyncQueue.enqueueAfterDelay(`lru_garbage_collection`,e,(async()=>{this.Er=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){Mi(e)?E(jd,`Ignoring IndexedDB error during garbage collection: `,e):await Ti(e)}await this.Rr(3e5)}))}},Id=class{constructor(e,t){this.Ar=e,this.params=t}calculateTargetCount(e,t){return this.Ar.Vr(e).next((e=>Math.floor(t/100*e)))}nthSequenceNumber(e,t){if(t===0)return z.resolve(Bi.ce);let n=new Pd(t);return this.Ar.forEachTarget(e,(e=>n.Ir(e.sequenceNumber))).next((()=>this.Ar.dr(e,(e=>n.Ir(e))))).next((()=>n.maxValue))}removeTargets(e,t,n){return this.Ar.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.Ar.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(E(`LruGarbageCollector`,`Garbage collection skipped; disabled`),z.resolve(gd)):this.getCacheSize(e).next((n=>n<this.params.cacheSizeCollectionThreshold?(E(`LruGarbageCollector`,`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),gd):this.mr(e,t)))}getCacheSize(e){return this.Ar.getCacheSize(e)}mr(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?(E(`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=>
15(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(),kr()<=x.DEBUG&&E(`LruGarbageCollector`,`LRU Garbage Collection\n\tCounted targets in ${a-l}ms\n\tDetermined least recently used ${r} in `+(o-a)+`ms 16\tRemoved ${i} targets in `+(s-o)+`ms 17\tRemoved ${e} documents in `+(c-s)+`ms 18Total Duration: ${c-l}ms`),z.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e}))))}};function Ld(e,t){return new Id(e,t)}var Rd=class{constructor(e,t){this.db=e,this.garbageCollector=Ld(this,t)}Vr(e){let t=this.gr(e);return this.db.getTargetCache().getTargetCount(e).next((e=>t.next((t=>e+t))))}gr(e){let t=0;return this.dr(e,(e=>{t++})).next((()=>t))}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}dr(e,t){return this.pr(e,((e,n)=>t(n)))}addReference(e,t,n){return zd(e,n)}removeReference(e,t,n){return zd(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return zd(e,t)}yr(e,t){return function(e,t){let n=!1;return Td(e).te((r=>Sd(e,r,t).next((e=>(e&&(n=!0),z.resolve(!e)))))).next((()=>n))}(e,t)}removeOrphanedDocuments(e,t){let n=this.db.getRemoteDocumentCache().newChangeBuffer(),r=[],i=0;return this.pr(e,((a,o)=>{if(o<=t){let t=this.yr(e,a).next((t=>{if(!t)return i++,n.getEntry(e,a).next((()=>(n.removeEntry(a,R.min()),Ad(e).delete(function(e){return[0,Ki(e.path)]}(a)))))}));r.push(t)}})).next((()=>z.waitFor(r))).next((()=>n.apply(e))).next((()=>i))}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,n)}updateLimboDocument(e,t){return zd(e,t)}pr(e,t){let n=Ad(e),r,i=Bi.ce;return n.ee({index:Sa},(([e,n],{path:a,sequenceNumber:o})=>{e===0?(i!==Bi.ce&&t(new F(Yi(r)),i),i=o,r=a):i=Bi.ce})).next((()=>{i!==Bi.ce&&t(new F(Yi(r)),i)}))}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}};function zd(e,t){return Ad(e).put(function(e,t){return{targetId:0,path:Ki(e.path),sequenceNumber:t}}(t,e.currentSequenceNumber))}var Bd=class{constructor(){this.changes=new fc((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,ms.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let n=this.changes.get(t);return n===void 0?this.getFromCache(e,t):z.resolve(n)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}},Vd=class{constructor(e){this.serializer=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,n){return Gd(e).put(n)}removeEntry(e,t,n){return Gd(e).delete(function(e,t){let n=e.path.toArray();return[n.slice(0,n.length-2),n[n.length-2],xu(t),n[n.length-1]]}(t,n))}updateMetadata(e,t){return this.getMetadata(e).next((n=>(n.byteSize+=t,this.wr(e,n))))}getEntry(e,t){let n=ms.newInvalidDocument(t);return Gd(e).ee({index:da,range:IDBKeyRange.only(Kd(t))},((e,r)=>{n=this.Sr(t,r)})).next((()=>n))}br(e,t){let n={size:0,document:ms.newInvalidDocument(t)};return Gd(e).ee({index:da,range:IDBKeyRange.only(Kd(t))},((e,r)=>{n={document:this.Sr(t,r),size:bd(r)}})).next((()=>n))}getEntries(e,t){let n=mc();return this.Dr(e,t,((e,t)=>{let r=this.Sr(e,t);n=n.insert(e,r)})).next((()=>n))}Cr(e,t){let n=mc(),r=new B(F.comparator);return this.Dr(e,t,((e,t)=>{let i=this.Sr(e,t);n=n.insert(e,i),r=r.insert(e,bd(t))})).next((()=>({documents:n,vr:r})))}Dr(e,t,n){if(t.isEmpty())return z.resolve();let r=new V(Jd);t.forEach((e=>r=r.add(e)));let i=IDBKeyRange.bound(Kd(r.first()),Kd(r.last())),a=r.getIterator(),o=a.getNext();return Gd(e).ee({index:da,range:i},((e,t,r)=>{let i=F.fromSegments([...t.prefixPath,t.collectionGroup,t.documentId]);for(;o&&Jd(o,i)<0;)n(o,null),o=a.getNext();o&&o.isEqual(i)&&(n(o,t),o=a.hasNext()?a.getNext():null),o?r.j(Kd(o)):r.done()})).next((()=>{for(;o;)n(o,null),o=a.hasNext()?a.getNext():null}))}getDocumentsMatchingQuery(e,t,n,r,i){let a=t.path,o=[a.popLast().toArray(),a.lastSegment(),xu(n.readTime),n.documentKey.path.isEmpty()?``:n.documentKey.path.lastSegment()],s=[a.popLast().toArray(),a.lastSegment(),[2**53-1,2**53-1],``];return Gd(e).J(IDBKeyRange.bound(o,s,!0)).next((e=>{i?.incrementDocumentReadCount(e.length);let n=mc();for(let i of e){let e=this.Sr(F.fromSegments(i.prefixPath.concat(i.collectionGroup,i.documentId)),i);
18e.isFoundDocument()&&(cc(t,e)||r.has(e.key))&&(n=n.insert(e.key,e))}return n}))}getAllFromCollectionGroup(e,t,n,r){let i=mc(),a=qd(t,n),o=qd(t,xi.max());return Gd(e).ee({index:pa,range:IDBKeyRange.bound(a,o,!0)},((e,t,n)=>{let a=this.Sr(F.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);i=i.insert(a.key,a),i.size===r&&n.done()})).next((()=>i))}newChangeBuffer(e){return new Ud(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next((e=>e.byteSize))}getMetadata(e){return Wd(e).get(ga).next((e=>(k(!!e,20021),e)))}wr(e,t){return Wd(e).put(ga,t)}Sr(e,t){if(t){let e=yu(this.serializer,t);if(!(e.isNoDocument()&&e.version.isEqual(R.min())))return e}return ms.newInvalidDocument(e)}};function Hd(e){return new Vd(e)}var Ud=class extends Bd{constructor(e,t){super(),this.Fr=e,this.trackRemovals=t,this.Mr=new fc((e=>e.toString()),((e,t)=>e.isEqual(t)))}applyChanges(e){let t=[],n=0,r=new V(((e,t)=>N(e.canonicalString(),t.canonicalString())));return this.changes.forEach(((i,a)=>{let o=this.Mr.get(i);if(t.push(this.Fr.removeEntry(e,i,o.readTime)),a.isValidDocument()){let s=bu(this.Fr.serializer,a);r=r.add(i.path.popLast());let c=bd(s);n+=c-o.size,t.push(this.Fr.addEntry(e,i,s))}else if(n-=o.size,this.trackRemovals){let n=bu(this.Fr.serializer,a.convertToNoDocument(R.min()));t.push(this.Fr.addEntry(e,i,n))}})),r.forEach((n=>{t.push(this.Fr.indexManager.addToCollectionParentIndex(e,n))})),t.push(this.Fr.updateMetadata(e,n)),z.waitFor(t)}getFromCache(e,t){return this.Fr.br(e,t).next((e=>(this.Mr.set(t,{size:e.size,readTime:e.document.readTime}),e.document)))}getAllFromCache(e,t){return this.Fr.Cr(e,t).next((({documents:e,vr:t})=>(t.forEach(((t,n)=>{this.Mr.set(t,{size:n,readTime:e.get(t).readTime})})),e)))}};function Wd(e){return lo(e,ha)}function Gd(e){return lo(e,la)}function Kd(e){let t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function qd(e,t){let n=t.documentKey.path.toArray();return[e,xu(t.readTime),n.slice(0,n.length-2),n.length>0?n[n.length-1]:``]}function Jd(e,t){let n=e.path.toArray(),r=t.path.toArray(),i=0;for(let e=0;e<n.length-2&&e<r.length-2;++e)if(i=N(n[e],r[e]),i)return i;return i=N(n.length,r.length),i||(i=N(n[n.length-2],r[r.length-2]),i||N(n[n.length-1],r[r.length-1]))}var Yd=class{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}},Xd=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&&Qc(n.mutation,e,vo.empty(),L.now()),e)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.getLocalViewOfDocuments(e,t,G()).next((()=>t))))}getLocalViewOfDocuments(e,t,n=G()){let r=vc();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,n).next((e=>{let t=gc();return e.forEach(((e,n)=>{t=t.insert(e,n.overlayedDocument)})),t}))))}getOverlayedDocuments(e,t){let n=vc();return this.populateOverlays(e,n,t).next((()=>this.computeViews(e,t,n,G())))}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=mc(),a=bc(),o=function(){return bc()}();return t.forEach(((e,t)=>{let o=n.get(t.key);r.has(t.key)&&(o===void 0||o.mutation instanceof nl)?i=i.insert(t.key,t):o===void 0?a.set(t.key,vo.empty()):(a.set(t.key,o.mutation.getFieldMask()),Qc(o.mutation,t,o.mutation.getFieldMask(),L.now()))})),this.recalculateAndSaveOverlays(e,i).next((e=>(e.forEach(((e,t)=>a.set(e,t))),t.forEach(((e,t)=>o.set(e,new Yd(t,a.get(e)??null)))),o)))}recalculateAndSaveOverlays(e,t){let n=bc(),r=new B(((e,t)=>e-t)),i=G();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)||vo.empty();o=i.applyToLocalView(a,o),n.set(e,o);let s=(r.get(i.batchId)||G()).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=yc();
18c.forEach((e=>{if(!i.has(e)){let r=Xc(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 z.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 Ys(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Xs(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):z.resolve(vc()),o=pi,s=i;return a.next((t=>z.forEach(t,((t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),i.get(t)?z.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,G()))).next((e=>({batchId:o,changes:_c(e)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new F(t)).next((e=>{let t=gc();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t}))}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){let i=t.collectionGroup,a=gc();return this.indexManager.getCollectionParents(e,i).next((o=>z.forEach(o,(o=>{let s=function(e,t){return new Gs(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=>{i.forEach(((t,n)=>{let r=n.getKey();e.get(r)===null&&(e=e.insert(r,ms.newInvalidDocument(r)))}));let n=gc();return e.forEach(((e,r)=>{let a=i.get(e);a!==void 0&&Qc(a.mutation,r,vo.empty(),L.now()),cc(t,r)&&(n=n.insert(e,r))})),n}))}},Zd=class{constructor(e){this.serializer=e,this.Or=new Map,this.Nr=new Map}getBundleMetadata(e,t){return z.resolve(this.Or.get(t))}saveBundleMetadata(e,t){return this.Or.set(t.id,function(e){return{id:e.id,version:e.version,createTime:Bl(e.createTime)}}(t)),z.resolve()}getNamedQuery(e,t){return z.resolve(this.Nr.get(t))}saveNamedQuery(e,t){return this.Nr.set(t.name,function(e){return{name:e.name,query:Du(e.bundledQuery),readTime:Bl(e.readTime)}}(t)),z.resolve()}},Qd=class{constructor(){this.overlays=new B(F.comparator),this.Br=new Map}getOverlay(e,t){return z.resolve(this.overlays.get(t))}getOverlays(e,t){let n=vc();return z.forEach(t,(t=>this.getOverlay(e,t).next((e=>{e!==null&&n.set(t,e)})))).next((()=>n))}saveOverlays(e,t,n){return n.forEach(((n,r)=>{this.wt(e,t,r)})),z.resolve()}removeOverlaysForBatchId(e,t,n){let r=this.Br.get(n);return r!==void 0&&(r.forEach((e=>this.overlays=this.overlays.remove(e))),this.Br.delete(n)),z.resolve()}getOverlaysForCollection(e,t,n){let r=vc(),i=t.length+1,a=new F(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 z.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new B(((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=vc(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let o=vc(),s=i.getIterator();for(;s.hasNext()&&(s.getNext().value.forEach(((e,t)=>o.set(e,t))),!(o.size()>=r)););return z.resolve(o)}wt(e,t,n){let r=this.overlays.get(n.key);if(r!==null){let e=this.Br.get(r.largestBatchId).delete(n.key);this.Br.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new ul(t,n));let i=this.Br.get(t);i===void 0&&(i=G(),this.Br.set(t,i)),this.Br.set(t,i.add(n.key))}},$d=class{constructor(){this.sessionToken=xo.EMPTY_BYTE_STRING}getSessionToken(e){return z.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,z.resolve()}},ef=class{constructor(){this.Lr=new V(tf.kr),this.qr=new V(tf.Kr)}isEmpty(){return this.Lr.isEmpty()}addReference(e,t){let n=new tf(e,t);this.Lr=this.Lr.add(n),this.qr=this.qr.add(n)}Ur(e,t){e.forEach((e=>this.addReference(e,t)))}removeReference(e,t){this.$r(new tf(e,t))}Wr(e,t){e.forEach((e=>this.removeReference(e,t)))}Qr(e){let t=new F(new P([])),n=new tf(t,e),r=new tf(t,e+1),i=[];return this.qr.forEachInRange([n,r],(e=>{this.$r(e),i.push(e.key)})),i}Gr(){this.Lr.forEach((e=>this.$r(e)))}$r(e){this.Lr=this.Lr.delete(e),this.qr=this.qr.delete(e)}zr(e){let t=new F(new P([])),n=new tf(t,e),r=new tf(t,e+1),i=G();return this.qr.forEachInRange([n,r],(e=>{i=i.add(e.key)})),i}containsKey(e){let t=new tf(e,0),n=this.Lr.firstAfterOrEqual(t);return n!==null&&e.isEqual(n.key)}},tf=class{constructor(e,t){this.key=e,this.jr=t}static kr(e,t){return F.comparator(e.key,t.key)||N(e.jr,t.jr)}static Kr(e,t){return N(e.jr,t.jr)||F.comparator(e.key,t.key)}},nf=class{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutation
18Queue=[],this.Xn=1,this.Jr=new V(tf.kr)}checkEmpty(e){return z.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,n,r){let i=this.Xn;this.Xn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let a=new cl(i,t,n,r);this.mutationQueue.push(a);for(let t of r)this.Jr=this.Jr.add(new tf(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return z.resolve(a)}lookupMutationBatch(e,t){return z.resolve(this.Hr(t))}getNextMutationBatchAfterBatchId(e,t){let n=t+1,r=this.Zr(n),i=r<0?0:r;return z.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return z.resolve(this.mutationQueue.length===0?Vi:this.Xn-1)}getAllMutationBatches(e){return z.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let n=new tf(t,0),r=new tf(t,1/0),i=[];return this.Jr.forEachInRange([n,r],(e=>{let t=this.Hr(e.jr);i.push(t)})),z.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new V(N);return t.forEach((e=>{let t=new tf(e,0),r=new tf(e,1/0);this.Jr.forEachInRange([t,r],(e=>{n=n.add(e.jr)}))})),z.resolve(this.Xr(n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=n;F.isDocumentKey(i)||(i=i.child(``));let a=new tf(new F(i),0),o=new V(N);return this.Jr.forEachWhile((e=>{let t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.jr)),!0)}),a),z.resolve(this.Xr(o))}Xr(e){let t=[];return e.forEach((e=>{let n=this.Hr(e);n!==null&&t.push(n)})),t}removeMutationBatch(e,t){k(this.Yr(t.batchId,`removed`)===0,55003),this.mutationQueue.shift();let n=this.Jr;return z.forEach(t.mutations,(r=>{let i=new tf(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)})).next((()=>{this.Jr=n}))}tr(e){}containsKey(e,t){let n=new tf(t,0),r=this.Jr.firstAfterOrEqual(n);return z.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,z.resolve()}Yr(e,t){return this.Zr(e)}Zr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Hr(e){let t=this.Zr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}},rf=class{constructor(e){this.ei=e,this.docs=function(){return new B(F.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.ei(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 z.resolve(n?n.document.mutableCopy():ms.newInvalidDocument(t))}getEntries(e,t){let n=mc();return t.forEach((e=>{let t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():ms.newInvalidDocument(e))})),z.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let i=mc(),a=t.path,o=new F(a.child(`__id-9223372036854775808__`)),s=this.docs.getIteratorFrom(o);for(;s.hasNext();){let{key:e,value:{document:o}}=s.getNext();if(!a.isPrefixOf(e.path))break;e.path.length>a.length+1||Si(bi(o),n)<=0||(r.has(o.key)||cc(t,o))&&(i=i.insert(o.key,o.mutableCopy()))}return z.resolve(i)}getAllFromCollectionGroup(e,t,n,r){O(9500)}ti(e,t){return z.forEach(this.docs,(e=>t(e)))}newChangeBuffer(e){return new af(this)}getSize(e){return z.resolve(this.size)}},af=class extends Bd{constructor(e){super(),this.Fr=e}applyChanges(e){let t=[];
18return this.changes.forEach(((n,r)=>{r.isValidDocument()?t.push(this.Fr.addEntry(e,r)):this.Fr.removeEntry(n)})),z.waitFor(t)}getFromCache(e,t){return this.Fr.getEntry(e,t)}getAllFromCache(e,t){return this.Fr.getEntries(e,t)}},of=class{constructor(e){this.persistence=e,this.ni=new fc((e=>zs(e)),Bs),this.lastRemoteSnapshotVersion=R.min(),this.highestTargetId=0,this.ri=0,this.ii=new ef,this.targetCount=0,this.si=Ed.sr()}forEachTarget(e,t){return this.ni.forEach(((e,n)=>t(n))),z.resolve()}getLastRemoteSnapshotVersion(e){return z.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return z.resolve(this.ri)}allocateTargetId(e){return this.highestTargetId=this.si.next(),z.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.ri&&(this.ri=t),z.resolve()}cr(e){this.ni.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.si=new Ed(t),this.highestTargetId=t),e.sequenceNumber>this.ri&&(this.ri=e.sequenceNumber)}addTargetData(e,t){return this.cr(t),this.targetCount+=1,z.resolve()}updateTargetData(e,t){return this.cr(t),z.resolve()}removeTargetData(e,t){return this.ni.delete(t.target),this.ii.Qr(t.targetId),--this.targetCount,z.resolve()}removeTargets(e,t,n){let r=0,i=[];return this.ni.forEach(((a,o)=>{o.sequenceNumber<=t&&n.get(o.targetId)===null&&(this.ni.delete(a),i.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)})),z.waitFor(i).next((()=>r))}getTargetCount(e){return z.resolve(this.targetCount)}getTargetData(e,t){let n=this.ni.get(t)||null;return z.resolve(n)}addMatchingKeys(e,t,n){return this.ii.Ur(t,n),z.resolve()}removeMatchingKeys(e,t,n){this.ii.Wr(t,n);let r=this.persistence.referenceDelegate,i=[];return r&&t.forEach((t=>{i.push(r.markPotentiallyOrphaned(e,t))})),z.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.ii.Qr(t),z.resolve()}getMatchingKeysForTargetId(e,t){let n=this.ii.zr(t);return z.resolve(n)}containsKey(e,t){return z.resolve(this.ii.containsKey(t))}},sf=class{constructor(e,t){this.oi={},this.overlays={},this._i=new Bi(0),this.ai=!1,this.ai=!0,this.ui=new $d,this.referenceDelegate=e(this),this.ci=new of(this),this.indexManager=new od,this.remoteDocumentCache=function(e){return new rf(e)}((e=>this.referenceDelegate.li(e))),this.serializer=new vu(t),this.hi=new Zd(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ai=!1,Promise.resolve()}get started(){return this.ai}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new Qd,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.oi[e.toKey()];return n||(n=new nf(t,this.referenceDelegate),this.oi[e.toKey()]=n),n}getGlobalsCache(){return this.ui}getTargetCache(){return this.ci}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.hi}runTransaction(e,t,n){E(`MemoryPersistence`,`Starting transaction:`,e);let r=new cf(this._i.next());return this.referenceDelegate.Pi(),n(r).next((e=>this.referenceDelegate.Ti(r).next((()=>e)))).toPromise().then((e=>(r.raiseOnCommittedEvent(),e)))}Ii(e,t){return z.or(Object.values(this.oi).map((n=>()=>n.containsKey(e,t))))}},cf=class extends wi{constructor(e){super(),this.currentSequenceNumber=e}},lf=class e{constructor(e){this.persistence=e,this.Ei=new ef,this.Ri=null}static Ai(t){return new e(t)}get Vi(){if(this.Ri)return this.Ri;throw O(60996)}addReference(e,t,n){return this.Ei.addReference(n,t),this.Vi.delete(n.toString()),z.resolve()}removeReference(e,t,n){return this.Ei.removeReference(n,t),this.Vi.add(n.toString()),z.resolve()}markPotentiallyOrphaned(e,t){return this.Vi.add(t.toString()),z.resolve()}removeTarget(e,t){this.Ei.Qr(t.targetId).forEach((e=>this.Vi.add(e.toString())));let n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next((e=>{e.forEach((e=>this.Vi.add(e.toString())))})).next((()=>n.removeTargetData(e,t)))}Pi(){this.Ri=new Set}Ti(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return z.forEach(this.Vi,(n=>{let r=F.fromPath(n);return this.di(e,r).next((e=>{e||t.removeEntry(r,R.min())}))})).next((()=>(this.Ri=null,t.apply(e))))}updateLimboDocument(e,t){return this.di(e,t).next((e=>{e?this.Vi.delete(t.toString()):this.Vi.add(t.toString())}))}li(e){return 0}di(e,t){return z.or([()=>z.resolve(this.Ei.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ii(e,t)])}},uf=class e{constructor(e,t){this.persistence=e,this.mi=new fc((e=>Ki(e.path)),((e,t)=>e.isEqual(t))),this.garbageCollector=Ld(this,t)}static Ai(t,n){return new e(t,n)}Pi(){}Ti(e){return z.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEac
18hTarget(e,t)}Vr(e){let t=this.gr(e);return this.persistence.getTargetCache().getTargetCount(e).next((e=>t.next((t=>e+t))))}gr(e){let t=0;return this.dr(e,(e=>{t++})).next((()=>t))}dr(e,t){return z.forEach(this.mi,((n,r)=>this.yr(e,n,r).next((e=>e?z.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.ti(e,(r=>this.yr(e,r,t).next((e=>{e||(n++,i.removeEntry(r,R.min()))})))).next((()=>i.apply(e))).next((()=>n))}markPotentiallyOrphaned(e,t){return this.mi.set(t,e.currentSequenceNumber),z.resolve()}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.mi.set(n,e.currentSequenceNumber),z.resolve()}removeReference(e,t,n){return this.mi.set(n,e.currentSequenceNumber),z.resolve()}updateLimboDocument(e,t){return this.mi.set(t,e.currentSequenceNumber),z.resolve()}li(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Xo(e.data.value)),t}yr(e,t,n){return z.or([()=>this.persistence.Ii(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.mi.get(t);return z.resolve(e!==void 0&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}},df=class{constructor(e){this.serializer=e}k(e,t,n,r){let i=new Di(`createOrUpgrade`,t);n<1&&r>=1&&(function(e){e.createObjectStore(Zi)}(e),function(e){e.createObjectStore($i,{keyPath:ea}),e.createObjectStore(ta,{keyPath:na,autoIncrement:!0}).createIndex(ra,ia,{unique:!0}),e.createObjectStore(ca)}(e),ff(e),function(e){e.createObjectStore(Xi)}(e));let a=z.resolve();return n<3&&r>=3&&(n!==0&&(function(e){e.deleteObjectStore(ba),e.deleteObjectStore(_a),e.deleteObjectStore(Ta)}(e),ff(e)),a=a.next((()=>function(e){let t=e.store(Ta),n={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:R.min().toTimestamp(),targetCount:0};return t.put(wa,n)}(i)))),n<4&&r>=4&&(n!==0&&(a=a.next((()=>function(e,t){return t.store(ta).J().next((n=>{e.deleteObjectStore(ta),e.createObjectStore(ta,{keyPath:na,autoIncrement:!0}).createIndex(ra,ia,{unique:!0});let r=t.store(ta),i=n.map((e=>r.put(e)));return z.waitFor(i)}))}(e,i)))),a=a.next((()=>{(function(e){e.createObjectStore(Oa,{keyPath:ka})})(e)}))),n<5&&r>=5&&(a=a.next((()=>this.fi(i)))),n<6&&r>=6&&(a=a.next((()=>(function(e){e.createObjectStore(ha)}(e),this.gi(i))))),n<7&&r>=7&&(a=a.next((()=>this.pi(i)))),n<8&&r>=8&&(a=a.next((()=>this.yi(e,i)))),n<9&&r>=9&&(a=a.next((()=>{(function(e){e.objectStoreNames.contains(`remoteDocumentChanges`)&&e.deleteObjectStore(`remoteDocumentChanges`)})(e)}))),n<10&&r>=10&&(a=a.next((()=>this.wi(i)))),n<11&&r>=11&&(a=a.next((()=>{(function(e){e.createObjectStore(Aa,{keyPath:ja})})(e),function(e){e.createObjectStore(Ma,{keyPath:Na})}(e)}))),n<12&&r>=12&&(a=a.next((()=>{(function(e){let t=e.createObjectStore(Ka,{keyPath:qa});t.createIndex(Ja,Ya,{unique:!1}),t.createIndex(Xa,Za,{unique:!1})})(e)}))),n<13&&r>=13&&(a=a.next((()=>function(e){let t=e.createObjectStore(la,{keyPath:ua});t.createIndex(da,fa),t.createIndex(pa,ma)}(e))).next((()=>this.Si(e,i))).next((()=>e.deleteObjectStore(Xi)))),n<14&&r>=14&&(a=a.next((()=>this.bi(e,i)))),n<15&&r>=15&&(a=a.next((()=>function(e){e.createObjectStore(Pa,{keyPath:Fa,autoIncrement:!0}).createIndex(Ia,La,{unique:!1}),e.createObjectStore(Ra,{keyPath:za}).createIndex(Ba,Va,{unique:!1}),e.createObjectStore(Ha,{keyPath:Ua}).createIndex(Wa,Ga,{unique:!1})}(e)))),n<16&&r>=16&&(a=a.next((()=>{t.objectStore(Ra).clear()})).next((()=>{t.objectStore(Ha).clear()}))),n<17&&r>=17&&(a=a.next((()=>{(function(e){e.createObjectStore(Qa,{keyPath:$a})})(e)}))),n<18&&r>=18&&we()&&(a=a.next((()=>{t.objectStore(Ra).clear()})).next((()=>{t.objectStore(Ha).clear()}))),a}gi(e){let t=0;return e.store(Xi).ee(((e,n)=>{t+=bd(n)})).next((()=>{let n={byteSize:t};return e.store(ha).put(ga,n)}))}fi(e){let t=e.store($i),n=e.store(ta);return t.J().next((t=>z.forEach(t,(t=>{let r=IDBKeyRange.bound([t.userId,Vi],[t.userId,t.lastAcknowledgedBatchId]);return n.J(ra,r).next((n=>z.forEach(n,(n=>{k(n.userId===t.userId,18650,`Cannot process batch from unexpected user`,{batchId:n.batchId});let r=wu(this.serializer,n);return yd(e,t.userId,r).next((()=>{}))}))))}
18))))}pi(e){let t=e.store(ba),n=e.store(Xi);return e.store(Ta).get(wa).next((e=>{let r=[];return n.ee(((n,i)=>{let a=new P(n),o=function(e){return[0,Ki(e)]}(a);r.push(t.get(o).next((n=>n?z.resolve():(n=>t.put({targetId:0,path:Ki(n),sequenceNumber:e.highestListenSequenceNumber}))(a))))})).next((()=>z.waitFor(r)))}))}yi(e,t){e.createObjectStore(Ea,{keyPath:Da});let n=t.store(Ea),r=new sd,i=e=>{if(r.add(e)){let t=e.lastSegment(),r=e.popLast();return n.put({collectionId:t,parent:Ki(r)})}};return t.store(Xi).ee({Y:!0},((e,t)=>i(new P(e).popLast()))).next((()=>t.store(ca).ee({Y:!0},(([e,t,n],r)=>i(Yi(t).popLast())))))}wi(e){let t=e.store(_a);return t.ee(((e,n)=>{let r=Tu(n),i=Eu(this.serializer,r);return t.put(i)}))}Si(e,t){let n=t.store(Xi),r=[];return n.ee(((e,n)=>{let i=t.store(la),a=function(e){return e.document?new F(P.fromString(e.document.name).popFirst(5)):e.noDocument?F.fromSegments(e.noDocument.path):e.unknownDocument?F.fromSegments(e.unknownDocument.path):O(36783)}(n).path.toArray(),o={prefixPath:a.slice(0,a.length-2),collectionGroup:a[a.length-2],documentId:a[a.length-1],readTime:n.readTime||[0,0],unknownDocument:n.unknownDocument,noDocument:n.noDocument,document:n.document,hasCommittedMutations:!!n.hasCommittedMutations};r.push(i.put(o))})).next((()=>z.waitFor(r)))}bi(e,t){let n=t.store(ta),r=Hd(this.serializer),i=new sf(lf.Ai,this.serializer.gt);return n.J().next((e=>{let n=new Map;return e.forEach((e=>{let t=n.get(e.userId)??G();wu(this.serializer,e).keys().forEach((e=>t=t.add(e))),n.set(e.userId,t)})),z.forEach(n,((e,n)=>{let a=new Tr(n),o=Pu.yt(this.serializer,a),s=i.getIndexManager(a);return new Xd(r,xd.yt(a,this.serializer,s,i.referenceDelegate),o,s).recalculateAndSaveOverlaysForDocumentKeys(new co(t,Bi.ce),e).next()}))}))}};function ff(e){e.createObjectStore(ba,{keyPath:xa}).createIndex(Sa,Ca,{unique:!0}),e.createObjectStore(_a,{keyPath:`targetId`}).createIndex(va,ya,{unique:!0}),e.createObjectStore(Ta)}var pf=`IndexedDbPersistence`,mf=18e5,hf=5e3,gf="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",_f=`main`,vf=class e{constructor(t,n,r,i,a,o,s,c,l,u,d=18){if(this.allowTabSynchronization=t,this.persistenceKey=n,this.clientId=r,this.Di=a,this.window=o,this.document=s,this.Ci=l,this.Fi=u,this.Mi=d,this._i=null,this.ai=!1,this.isPrimary=!1,this.networkEnabled=!0,this.xi=null,this.inForeground=!1,this.Oi=null,this.Ni=null,this.Bi=-1/0,this.Li=e=>Promise.resolve(),!e.v())throw new M(j.UNIMPLEMENTED,`This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.`);this.referenceDelegate=new Rd(this,i),this.ki=n+_f,this.serializer=new vu(c),this.qi=new Oi(this.ki,this.Mi,new df(this.serializer)),this.ui=new Iu,this.ci=new Dd(this.referenceDelegate,this.serializer),this.remoteDocumentCache=Hd(this.serializer),this.hi=new ju,this.window&&this.window.localStorage?this.Ki=this.window.localStorage:(this.Ki=null,!1===u&&D(pf,`LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page.`))}start(){return this.Ui().then((()=>
18{if(!this.isPrimary&&!this.allowTabSynchronization)throw new M(j.FAILED_PRECONDITION,gf);return this.$i(),this.Wi(),this.Qi(),this.runTransaction(`getHighestListenSequenceNumber`,`readonly`,(e=>this.ci.getHighestSequenceNumber(e)))})).then((e=>{this._i=new Bi(e,this.Ci)})).then((()=>{this.ai=!0})).catch((e=>(this.qi&&this.qi.close(),Promise.reject(e))))}Gi(e){return this.Li=async t=>{if(this.started)return e(t)},e(this.isPrimary)}setDatabaseDeletedListener(e){this.qi.K((async t=>{t.newVersion===null&&await e()}))}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.Di.enqueueAndForget((async()=>{this.started&&await this.Ui()})))}Ui(){return this.runTransaction(`updateClientMetadataAndTryBecomePrimary`,`readwrite`,(e=>bf(e).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next((()=>{if(this.isPrimary)return this.zi(e).next((e=>{e||(this.isPrimary=!1,this.Di.enqueueRetryable((()=>this.Li(!1))))}))})).next((()=>this.ji(e))).next((t=>this.isPrimary&&!t?this.Ji(e).next((()=>!1)):!!t&&this.Hi(e).next((()=>!0)))))).catch((e=>{if(Mi(e))return E(pf,`Failed to extend owner lease: `,e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return E(pf,`Releasing owner lease after error during lease refresh`,e),!1})).then((e=>{this.isPrimary!==e&&this.Di.enqueueRetryable((()=>this.Li(e))),this.isPrimary=e}))}zi(e){return yf(e).get(Qi).next((e=>z.resolve(this.Zi(e))))}Xi(e){return bf(e).delete(this.clientId)}async Yi(){if(this.isPrimary&&!this.es(this.Bi,mf)){this.Bi=Date.now();let e=await this.runTransaction(`maybeGarbageCollectMultiClientState`,`readwrite-primary`,(e=>{let t=lo(e,Oa);return t.J().next((e=>{let n=this.ts(e,mf),r=e.filter((e=>n.indexOf(e)===-1));return z.forEach(r,(e=>t.delete(e.clientId))).next((()=>r))}))})).catch((()=>[]));if(this.Ki)for(let t of e)this.Ki.removeItem(this.ns(t.clientId))}}Qi(){this.Ni=this.Di.enqueueAfterDelay(`client_metadata_refresh`,4e3,(()=>this.Ui().then((()=>this.Yi())).then((()=>this.Qi()))))}Zi(e){return!!e&&e.ownerId===this.clientId}ji(e){return this.Fi?z.resolve(!0):yf(e).get(Qi).next((t=>{if(t!==null&&this.es(t.leaseTimestampMs,hf)&&!this.rs(t.ownerId)){if(this.Zi(t)&&this.networkEnabled)return!0;if(!this.Zi(t)){if(!t.allowTabSynchronization)throw new M(j.FAILED_PRECONDITION,gf);return!1}}return!(!this.networkEnabled||!this.inForeground)||bf(e).J().next((e=>this.ts(e,hf).find((e=>{if(this.clientId!==e.clientId){let t=!this.networkEnabled&&e.networkEnabled,n=!this.inForeground&&e.inForeground,r=this.networkEnabled===e.networkEnabled;if(t||n&&r)return!0}return!1}))===void 0))})).next((e=>(this.isPrimary!==e&&E(pf,`Client ${e?`is`:`is not`} eligible for a primary lease.`),e)))}async shutdown(){this.ai=!1,this.ss(),this.Ni&&=(this.Ni.cancel(),null),this._s(),this.us(),await this.qi.runTransaction(`shutdown`,`readwrite`,[Zi,Oa],(e=>{let t=new co(e,Bi.ce);return this.Ji(t).next((()=>this.Xi(t)))})),this.qi.close(),this.cs()}ts(e,t){return e.filter((e=>this.es(e.updateTimeMs,t)&&!this.rs(e.clientId)))}ls(){return this.runTransaction(`getActiveClients`,`readonly`,(e=>bf(e).J().next((e=>this.ts(e,mf).map((e=>e.clientId))))))}get started(){return this.ai}getGlobalsCache(){return this.ui}getMutationQueue(e,t){return xd.yt(e,this.serializer,t,this.referenceDelegate)}getTargetCache(){return this.ci}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new ud(e,this.serializer.gt.databaseId)}getDocumentOverlayCache(e){return Pu.yt(this.serializer,e)}getBundleCache(){return this.hi}runTransaction(e,t,n){E(pf,`Starting transaction:`,e);let r=t===`readonly`?`readonly`:`readwrite`,i=function(e){return e===18?so:e===17?oo:e===16?ao:e===15?io:e===14?ro:e===13?no:e===12?to:e===11?eo:void O(60245)}(this.Mi),a;return this.qi.runTransaction(e,r,i,(r=>(a=new co(r,this._i?this._i.next():Bi.ce),t===`readwrite-primary`?this.zi(a).next((e=>!!e||this.ji(a))).next((t=>{if(!t)throw D(`Failed to obtain primary lease for action '${e}'.`),this.isPrimary=!1,this.Di.enqueueRetryable((()=>this.Li(!1))),new M(j.FAILED_PRECONDITION,Ci);return n(a)})).next((e=>this.Hi(a).next((()=>e)))):this.hs(a).next((()=>n(a)))))).then((e=>(a.raiseOnCommittedEvent(),e)))}hs(e){return yf(e).get(Qi).next((e=>{if(e!==null&&this.es(e.leaseTimestampMs,hf)&&!this.rs(e.ownerId)&&!this.Zi(e)&&!(this.Fi||this.allowTabSynchronization&&e.allowTabSynchronization))throw new M(j.FAILED_PRECONDITION,gf)}))}Hi(e){let t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return yf(e).put(Qi,t)}static v(){return Oi.v()}Ji(e){let t=yf(e);return t.get(Qi).next((e=>this.Zi(e)?(E(pf,`Releasing primary lease.`),t.delete(Qi)):z.resolve()))}es(e,t){let n=Date.now();return!(e<n-t)&&(!(e>n)||(D(`Detected an update time that is in the future: ${e} > ${n}`),!1))}$i(){this.document!==null&&typeof this.document.addEventListener==`function`&&(this.Oi=()=>{this.Di.enqueueAndForget((()=>(this.inForeground=this.document.visibilityState===`visible`,this.Ui())))},this.document.addEventListener(`visibilitychange`,this.Oi),this.inForeground=this.document.visibilityState===`visible`)}_s(){this.Oi&&=(this.document.removeEventListener(`visibilitychange`,this.Oi),null)}Wi(){typeof this.window?.addEventListener==`function`&&(this.xi=()=>{this.ss();let e=/(?:Version|Mobile)\/1[456]/;Ce()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.Di.enterRestrictedMode(!0),this.Di.enqueueAndForget((()=>this.shutdown()))},this.window.addEventListener(`pagehide`,this.xi))}us(){this.xi&&=(this.window.removeEventListener(`pagehide`,this.xi),null)}rs(e){try{let t=this.Ki?.getItem(this.ns(e))!==null;return E(pf,`Client '${e}' ${t?`is`:`is not`} zombied in LocalStorage`),t}catch(e){return D(pf,`Failed to get zombied client id.`,e),!1}}ss(){if(this.Ki)try{this.Ki.setItem(this.ns(this.clientId),String(Date.now()))}catch(e){D(`Failed to set zombie client id.`,e)}}cs(){if(this.Ki)try{this.Ki.removeItem(this.ns(this.clientId))}catch{}}ns(e){return`firestore_zombie_${this.persistenceKey}_${e}`}};function yf(e){return lo(e,Zi)}function bf(e){return lo(e,Oa)}function xf(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+=`.`+e.database),`firestore/`+t+`/`+n+`/`}var Sf=class e{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.Ps=n,this.Ts=r}static Is(t,n){let r=G(),i=G();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)}},Cf=class{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}},wf=class{constructor(){this.Es=!1,this.Rs=!1,this.As=100,this.Vs=function(){return Ce()?8:ki(_())>0?6:4}()}initialize(e,t){this.ds=e,this.indexManager=t,this.Es=!0}getDocumentsMatchingQuery(e,t,n,r){let i={result:null};return this.fs(e,t).next((e=>{i.result=e})).next((()=>
18{if(!i.result)return this.gs(e,t,r,n).next((e=>{i.result=e}))})).next((()=>{if(i.result)return;let n=new Cf;return this.ps(e,t,n).next((r=>{if(i.result=r,this.Rs)return this.ys(e,t,n,r.size)}))})).next((()=>i.result))}ys(e,t,n,r){return n.documentReadCount<this.As?(kr()<=x.DEBUG&&E(`QueryEngine`,`SDK will not create cache indexes for query:`,sc(t),`since it only creates cache indexes for collection contains`,`more than or equal to`,this.As,`documents`),z.resolve()):(kr()<=x.DEBUG&&E(`QueryEngine`,`Query:`,sc(t),`scans`,n.documentReadCount,`local documents and returns`,r,`documents as results.`),n.documentReadCount>this.Vs*r?(kr()<=x.DEBUG&&E(`QueryEngine`,`The SDK decides to create cache indexes for query:`,sc(t),`as using cache indexes may help improve performance.`),this.indexManager.createTargetIndexes(e,Qs(t))):z.resolve())}fs(e,t){if(Js(t))return z.resolve(null);let n=Qs(t);return this.indexManager.getIndexType(e,n).next((r=>r===0?null:(t.limit!==null&&r===1&&(t=nc(t,null,`F`),n=Qs(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next((r=>{let i=G(...r);return this.ds.getDocuments(e,i).next((r=>this.indexManager.getMinOffset(e,n).next((n=>{let a=this.ws(t,r);return this.Ss(t,a,i,n.readTime)?this.fs(e,nc(t,null,`F`)):this.bs(e,a,t,n)}))))})))))}gs(e,t,n,r){return Js(t)||r.isEqual(R.min())?z.resolve(null):this.ds.getDocuments(e,n).next((i=>{let a=this.ws(t,i);return this.Ss(t,a,n,r)?z.resolve(null):(kr()<=x.DEBUG&&E(`QueryEngine`,`Re-using previous result from %s to execute query: %s`,r.toString(),sc(t)),this.bs(e,a,t,yi(r,pi)).next((e=>e)))}))}ws(e,t){let n=new V(uc(e));return t.forEach(((t,r)=>{cc(e,r)&&(n=n.add(r))})),n}Ss(e,t,n,r){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)}ps(e,t,n){return kr()<=x.DEBUG&&E(`QueryEngine`,`Using full collection scan to execute query:`,sc(t)),this.ds.getDocumentsMatchingQuery(e,t,xi.min(),n)}bs(e,t,n,r){return this.ds.getDocumentsMatchingQuery(e,n,r).next((e=>(t.forEach((t=>{e=e.insert(t.key,t)})),e)))}},Tf=`LocalStore`,Ef=3e8,Df=class{constructor(e,t,n,r){this.persistence=e,this.Ds=t,this.serializer=r,this.Cs=new B(N),this.vs=new fc((e=>zs(e)),Bs),this.Fs=new Map,this.Ms=e.getRemoteDocumentCache(),this.ci=e.getTargetCache(),this.hi=e.getBundleCache(),this.xs(n)}xs(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Xd(this.Ms,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Ms.setIndexManager(this.indexManager),this.Ds.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction(`Collect garbage`,`readwrite-primary`,(t=>e.collect(t,this.Cs)))}};function Of(e,t,n,r){return new Df(e,t,n,r)}async function kf(e,t){let n=A(e);return await n.persistence.runTransaction(`Handle user change`,`readonly`,(e=>{let r;
18return n.mutationQueue.getAllMutationBatches(e).next((i=>(r=i,n.xs(t),n.mutationQueue.getAllMutationBatches(e)))).next((t=>{let i=[],a=[],o=G();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=>({Os:e,removedBatchIds:i,addedBatchIds:a})))}))}))}function Af(e,t){let n=A(e);return n.persistence.runTransaction(`Acknowledge batch`,`readwrite-primary`,(e=>{let r=t.batch.keys(),i=n.Ms.newChangeBuffer({trackRemovals:!0});return function(e,t,n,r){let i=n.batch,a=i.keys(),o=z.resolve();return a.forEach((e=>{o=o.next((()=>r.getEntry(t,e))).next((t=>{let a=n.docVersions.get(e);k(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=G();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 jf(e){let t=A(e);return t.persistence.runTransaction(`Get last remote snapshot version`,`readonly`,(e=>t.ci.getLastRemoteSnapshotVersion(e)))}function Mf(e,t){let n=A(e),r=t.snapshotVersion,i=n.Cs;return n.persistence.runTransaction(`Apply remote event`,`readwrite-primary`,(e=>{let a=n.Ms.newChangeBuffer({trackRemovals:!0});i=n.Cs;let o=[];
18t.targetChanges.forEach(((a,s)=>{let c=i.get(s);if(!c)return;o.push(n.ci.removeMatchingKeys(e,a.removedDocuments,s).next((()=>n.ci.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(xo.EMPTY_BYTE_STRING,R.min()).withLastLimboFreeSnapshotVersion(R.min()),i=i.insert(s,l),function(e,t,n){return e.resumeToken.approximateByteSize()===0||t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=Ef?!0:n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(c,l,a)&&o.push(n.ci.updateTargetData(e,l))}));let s=mc(),c=G();if(t.documentUpdates.forEach((r=>{t.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))})),o.push(Nf(e,a,t.documentUpdates).next((e=>{s=e.Ns,c=e.Bs}))),!r.isEqual(R.min())){let t=n.ci.getLastRemoteSnapshotVersion(e).next((t=>n.ci.setTargetsMetadata(e,e.currentSequenceNumber,r)));o.push(t)}return z.waitFor(o).next((()=>a.apply(e))).next((()=>n.localDocuments.getLocalViewOfDocuments(e,s,c))).next((()=>s))})).then((e=>(n.Cs=i,e)))}function Nf(e,t,n){let r=G(),i=G();return n.forEach((e=>r=r.add(e))),t.getEntries(e,r).next((e=>{let r=mc();return n.forEach(((n,a)=>{let o=e.get(n);a.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),a.isNoDocument()&&a.version.isEqual(R.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)):E(Tf,`Ignoring outdated watch update for `,n,`. Current version:`,o.version,` Watch version:`,a.version)})),{Ns:r,Bs:i}}))}function Pf(e,t){let n=A(e);return n.persistence.runTransaction(`Get next mutation batch`,`readonly`,(e=>(t===void 0&&(t=Vi),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t))))}function Ff(e,t){let n=A(e);return n.persistence.runTransaction(`Allocate target`,`readwrite`,(e=>{let r;return n.ci.getTargetData(e,t).next((i=>i?(r=i,z.resolve(r)):n.ci.allocateTargetId(e).next((i=>(r=new _u(t,i,`TargetPurposeListen`,e.currentSequenceNumber),n.ci.addTargetData(e,r).next((()=>r)))))))})).then((e=>{let r=n.Cs.get(e.targetId);return(r===null||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.Cs=n.Cs.insert(e.targetId,e),n.vs.set(t,e.targetId)),e}))}async function If(e,t,n){let r=A(e),i=r.Cs.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(!Mi(e))throw e;E(Tf,`Failed to update sequence numbers for target ${t}: ${e}`)}r.Cs=r.Cs.remove(t),r.vs.delete(i.target)}
18function Lf(e,t,n){let r=A(e),i=R.min(),a=G();return r.persistence.runTransaction(`Execute query`,`readwrite`,(e=>function(e,t,n){let r=A(e),i=r.vs.get(n);return i===void 0?r.ci.getTargetData(t,n):z.resolve(r.Cs.get(i))}(r,e,Qs(t)).next((t=>{if(t)return i=t.lastLimboFreeSnapshotVersion,r.ci.getMatchingKeysForTargetId(e,t.targetId).next((e=>{a=e}))})).next((()=>r.Ds.getDocumentsMatchingQuery(e,t,n?i:R.min(),n?a:G()))).next((e=>(Bf(r,lc(t),e),{documents:e,Ls:a})))))}function Rf(e,t){let n=A(e),r=A(n.ci),i=n.Cs.get(t);return i?Promise.resolve(i.target):n.persistence.runTransaction(`Get target data`,`readonly`,(e=>r.Rt(e,t).next((e=>e?e.target:null))))}function zf(e,t){let n=A(e),r=n.Fs.get(t)||R.min();return n.persistence.runTransaction(`Get new document changes`,`readonly`,(e=>n.Ms.getAllFromCollectionGroup(e,t,yi(r,pi),2**53-1))).then((e=>(Bf(n,t,e),e)))}function Bf(e,t,n){let r=e.Fs.get(t)||R.min();n.forEach(((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)})),e.Fs.set(t,r)}async function Vf(e,t,n,r){let i=A(e),a=G(),o=mc();for(let e of n){let n=t.ks(e.metadata.name);e.document&&(a=a.add(n));let r=t.qs(e);r.setReadTime(t.Ks(e.metadata.readTime)),o=o.insert(n,r)}let s=i.Ms.newChangeBuffer({trackRemovals:!0}),c=await Ff(i,function(e){return Qs(qs(P.fromString(`__bundle__/docs/${e}`)))}(r));return i.persistence.runTransaction(`Apply bundle documents`,`readwrite`,(e=>Nf(e,s,o).next((t=>(s.apply(e),t))).next((t=>i.ci.removeMatchingKeysForTargetId(e,c.targetId).next((()=>i.ci.addMatchingKeys(e,a,c.targetId))).next((()=>i.localDocuments.getLocalViewOfDocuments(e,t.Ns,t.Bs))).next((()=>t.Ns))))))}async function Hf(e,t,n=G()){let r=await Ff(e,Qs(Du(t.bundledQuery))),i=A(e);return i.persistence.runTransaction(`Save named query`,`readwrite`,(e=>{let a=Bl(t.readTime);if(r.snapshotVersion.compareTo(a)>=0)return i.hi.saveNamedQuery(e,t);let o=r.withResumeToken(xo.EMPTY_BYTE_STRING,a);return i.Cs=i.Cs.insert(o.targetId,o),i.ci.updateTargetData(e,o).next((()=>i.ci.removeMatchingKeysForTargetId(e,r.targetId))).next((()=>i.ci.addMatchingKeys(e,n,r.targetId))).next((()=>i.hi.saveNamedQuery(e,t)))}))}var Uf=`firestore_clients`;function Wf(e,t){return`${Uf}_${e}_${t}`}var Gf=`firestore_mutations`;function Kf(e,t,n){let r=`${Gf}_${e}_${n}`;return t.isAuthenticated()&&(r+=`_${t.uid}`),r}var qf=`firestore_targets`;function Jf(e,t){return`${qf}_${e}_${t}`}var Yf=`SharedClientState`,Xf=class e{constructor(e,t,n,r){this.user=e,this.batchId=t,this.state=n,this.error=r}static Us(t,n,r){let i=JSON.parse(r),a,o=typeof i==`object`&&[`pending`,`acknowledged`,`rejected`].indexOf(i.state)!==-1&&(i.error===void 0||typeof i.error==`object`);return o&&i.error&&(o=typeof i.error.message==`string`&&typeof i.error.code==`string`,o&&(a=new M(i.error.code,i.error.message))),o?new e(t,n,i.state,a):(D(Yf,`Failed to parse mutation state for ID '${n}': ${r}`),null)}$s(){let e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}},Zf=class e{constructor(e,t,n){this.targetId=e,this.state=t,this.error=n}static Us(t,n){let r=JSON.parse(n),i,a=typeof r==`object`&&[`not-current`,`current`,`rejected`].indexOf(r.state)!==-1&&(r.error===void 0||typeof r.error==`object`);return a&&r.error&&(a=typeof r.error.message==`string`&&typeof r.error.code==`string`,a&&(i=new M(r.error.code,r.error.message))),a?new e(t,r.state,i):(D(Yf,`Failed to parse target state for ID '${t}': ${n}`),null)}$s(){let e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}},Qf=class e{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static Us(t,n){let r=JSON.parse(n),i=typeof r==`object`&&r.activeTargetIds instanceof Array,a=wc();for(let e=0;i&&e<r.activeTargetIds.length;++e)i=Wi(r.activeTargetIds[e]),a=a.add(r.activeTargetIds[e]);return i?new e(t,a):(D(Yf,`Failed to parse client data for instance '${t}': ${n}`),null)}},$f=class e{constructor(e,t){this.clientId=e,this.onlineState=t}static Us(t){let n=JSON.parse(t);return typeof n==`object`&&[`Unknown`,`Online`,`Offline`].indexOf(n.onlineState)!==-1&&typeof n.clientId==`string`?new e(n.clientId,n.onlineState):(D(Yf,`Failed to parse online state: ${t}`),null)}},ep=class{constructor(){this.activeTargetIds=wc()}Ws(e){this.activeTargetIds=this.activeTargetIds.add(e)}Qs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}$s(){let e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}},tp=class{constructor(e,t,n,r,i){this.window=e,this.Di=t,this.persistenceKey=n,this.Gs=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.zs=this.js.bind(this),this.Js=new B(N),this.started=!1,this.Hs=[];let a=n.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);this.storage=this.window.localStorage,this.currentUser=i,this.Zs=Wf(this.persistenceKey,this.Gs),this.Xs=function(e){return`firestore_sequence_number_${e}`}(this.persistenceKey),this.Js=this.Js.insert(this.Gs,new ep),this.Ys=RegExp(`^${Uf}_${a}_([^_]*)$`),this.eo=RegExp(`^${Gf}_${a}_(\\d+)(?:_(.*))?$`),this.no=RegExp(`^${qf}_${a}_(\\d+)$`),this.ro=function(e){return`firestore_online_state_${e}`}(this.persistenceKey),this.io=function(e){return`firestore_bundle_loaded_v2_${e}`}(this.persistenceKey),this.window.addEventListener(`storage`,this.zs)}static v(e){return!(!e||!e.localStorage)}async start(){let e=await this.syncEngine.ls();for(let t of e){if(t===this.Gs)continue;let e=this.getItem(Wf(this.persistenceKey,t));if(e){let n=Qf.Us(t,e);n&&(this.Js=this.Js.insert(n.clientId,n))}}this.so();let t=this.storage.getItem(this.ro);if(t){let e=this.oo(t);e&&this._o(e)}for(let e of this.Hs)this.js(e);this.Hs=[],this.window.addEventListener(`pagehide`,(()=>this.shutdown())),this.started=!0}writeSequenceNumber(e){this.setItem(this.Xs,JSON.stringify(e))}getAllActiveQueryTargets(){return this.ao(this.Js)}isActiveQueryTarget(e){let t=!1;
18return this.Js.forEach(((n,r)=>{r.activeTargetIds.has(e)&&(t=!0)})),t}addPendingMutation(e){this.uo(e,`pending`)}updateMutationState(e,t,n){this.uo(e,t,n),this.co(e)}addLocalQueryTarget(e,t=!0){let n=`not-current`;if(this.isActiveQueryTarget(e)){let t=this.storage.getItem(Jf(this.persistenceKey,e));if(t){let r=Zf.Us(e,t);r&&(n=r.state)}}return t&&this.lo.Ws(e),this.so(),n}removeLocalQueryTarget(e){this.lo.Qs(e),this.so()}isLocalQueryTarget(e){return this.lo.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(Jf(this.persistenceKey,e))}updateQueryState(e,t,n){this.ho(e,t,n)}handleUserChange(e,t,n){t.forEach((e=>{this.co(e)})),this.currentUser=e,n.forEach((e=>{this.addPendingMutation(e)}))}setOnlineState(e){this.Po(e)}notifyBundleLoaded(e){this.To(e)}shutdown(){this.started&&=(this.window.removeEventListener(`storage`,this.zs),this.removeItem(this.Zs),!1)}getItem(e){let t=this.storage.getItem(e);return E(Yf,`READ`,e,t),t}setItem(e,t){E(Yf,`SET`,e,t),this.storage.setItem(e,t)}removeItem(e){E(Yf,`REMOVE`,e),this.storage.removeItem(e)}js(e){let t=e;if(t.storageArea===this.storage){if(E(Yf,`EVENT`,t.key,t.newValue),t.key===this.Zs)return void D(`Received WebStorage notification for local change. Another client might have garbage-collected our state`);this.Di.enqueueRetryable((async()=>{if(this.started){if(t.key!==null){if(this.Ys.test(t.key)){if(t.newValue==null){let e=this.Io(t.key);return this.Eo(e,null)}{let e=this.Ro(t.key,t.newValue);if(e)return this.Eo(e.clientId,e)}}else if(this.eo.test(t.key)){if(t.newValue!==null){let e=this.Ao(t.key,t.newValue);if(e)return this.Vo(e)}}else if(this.no.test(t.key)){if(t.newValue!==null){let e=this.mo(t.key,t.newValue);if(e)return this.fo(e)}}else if(t.key===this.ro){if(t.newValue!==null){let e=this.oo(t.newValue);if(e)return this._o(e)}}else if(t.key===this.Xs){let e=function(e){let t=Bi.ce;if(e!=null)try{let n=JSON.parse(e);k(typeof n==`number`,30636,{po:e}),t=n}catch(e){D(Yf,`Failed to read sequence number from WebStorage`,e)}return t}(t.newValue);e!==Bi.ce&&this.sequenceNumberHandler(e)}else if(t.key===this.io){let e=this.yo(t.newValue);await Promise.all(e.map((e=>this.syncEngine.wo(e))))}}}else this.Hs.push(t)}))}}get lo(){return this.Js.get(this.Gs)}so(){this.setItem(this.Zs,this.lo.$s())}uo(e,t,n){let r=new Xf(this.currentUser,e,t,n),i=Kf(this.persistenceKey,this.currentUser,e);this.setItem(i,r.$s())}co(e){let t=Kf(this.persistenceKey,this.currentUser,e);this.removeItem(t)}Po(e){let t={clientId:this.Gs,onlineState:e};this.storage.setItem(this.ro,JSON.stringify(t))}ho(e,t,n){let r=Jf(this.persistenceKey,e),i=new Zf(e,t,n);this.setItem(r,i.$s())}To(e){let t=JSON.stringify(Array.from(e));this.setItem(this.io,t)}Io(e){let t=this.Ys.exec(e);return t?t[1]:null}Ro(e,t){let n=this.Io(e);return Qf.Us(n,t)}Ao(e,t){let n=this.eo.exec(e),r=Number(n[1]),i=n[2]===void 0?null:n[2];return Xf.Us(new Tr(i),r,t)}mo(e,t){let n=this.no.exec(e),r=Number(n[1]);return Zf.Us(r,t)}oo(e){return $f.Us(e)}yo(e){return JSON.parse(e)}async Vo(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.So(e.batchId,e.state,e.error);E(Yf,`Ignoring mutation for non-active user ${e.user.uid}`)}fo(e){return this.syncEngine.bo(e.targetId,e.state,e.error)}Eo(e,t){let n=t?this.Js.insert(e,t):this.Js.remove(e),r=this.ao(this.Js),i=this.ao(n),a=[],o=[];return i.forEach((e=>{r.has(e)||a.push(e)})),r.forEach((e=>{i.has(e)||o.push(e)})),this.syncEngine.Do(a,o).then((()=>{this.Js=n}))}_o(e){this.Js.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}ao(e){let t=wc();return e.forEach(((e,n)=>{t=t.unionWith(n.activeTargetIds)})),t}},np=class{constructor(){this.Co=new ep,this.vo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.Co.Ws(e),this.vo[e]||`not-current`}updateQueryState(e,t,n){this.vo[e]=t}removeLocalQueryTarget(e){this.Co.Qs(e)}isLocalQueryTarget(e){return this.Co.activeTargetIds.has(e)}clearQueryState(e){delete this.vo[e]}getAllActiveQueryTargets(){return this.Co.activeTargetIds}isActiveQueryTarget(e){return this.Co.activeTargetIds.has(e)}start(){return this.Co=new ep,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}},rp=class{Fo(e){}shutdown(){}},ip=`ConnectivityMonitor`,ap=class{constructor(){this.Mo=()=>this.xo(),this.Oo=()=>this.No(),this.Bo=[],this.Lo()}Fo(e){this.Bo.push(e)}shutdown(){window.removeEventListener(`online`,this.Mo),window.removeEventListener(`offline`,this.Oo)}Lo(){window.addEventListener(`online`,this.Mo),window.addEventListener(`offline`,this.Oo)}xo(){E(ip,`Network connectivity changed: AVAILABLE`);for(let e of this.Bo)e(0)}No(){E(ip,`Network connectivity changed: UNAVAILABLE`);for(let e of this.Bo)e(1)}static v(){return typeof window<`u`&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}},op=null;function sp(){return op===null?op=function(){return 268435456+Math.round(2147483648*Math.random())}():op++,`0x`+op.toString(16)}var cp=`RestConnection`,lp={BatchGetDocuments:`batchGet`,Commit:`commit`,RunQuery:`runQuery`,RunAggregation
18Query:`runAggregationQuery`,ExecutePipeline:`executePipeline`},up=class{get ko(){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.qo=t+`://`+e.host,this.Ko=`projects/${n}/databases/${r}`,this.Uo=this.databaseId.database===No?`project_id=${n}`:`project_id=${n}&database_id=${r}`}$o(e,t,n,r,i){let a=sp(),o=this.Wo(e,t.toUriEncodedString());E(cp,`Sending RPC '${e}' ${a}:`,o,n);let s={"google-cloud-resource-prefix":this.Ko,"x-goog-request-params":this.Uo};this.Qo(s,r,i);let{host:c}=new URL(o),l=Ze(c);return this.Go(e,o,s,n,l).then((t=>(E(cp,`Received RPC '${e}' ${a}: `,t),t)),(t=>{throw jr(cp,`RPC '${e}' ${a} failed with error: `,t,`url: `,o,`request:`,n),t}))}zo(e,t,n,r,i,a){return this.$o(e,t,n,r,i)}Qo(e,t,n){e[`X-Goog-Api-Client`]=function(){return`gl-js/ fire/`+Er}(),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))}Wo(e,t){let n=lp[e],r=`${this.qo}/v1/${t}:${n}`;return this.databaseInfo.apiKey&&(r=`${r}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),r}terminate(){}},dp=class{constructor(e){this.jo=e.jo,this.Jo=e.Jo}Ho(e){this.Zo=e}Xo(e){this.Yo=e}e_(e){this.t_=e}onMessage(e){this.n_=e}close(){this.Jo()}send(e){this.jo(e)}r_(){this.Zo()}i_(){this.Yo()}s_(e){this.t_(e)}o_(e){this.n_(e)}},fp=`WebChannelConnection`,pp=(e,t,n)=>{e.listen(t,(e=>{try{n(e)}catch(e){setTimeout((()=>{throw e}),0)}}))},mp=class e extends up{constructor(e){super(e),this.__=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static a_(){e.u_||=(pp(Cr(),Sr.STAT_EVENT,(e=>{e.stat===xr.PROXY?E(fp,`STAT_EVENT: detected buffering proxy`):e.stat===xr.NOPROXY&&E(fp,`STAT_EVENT: detected no buffering proxy`)})),!0)}Go(e,t,n,r,i){let a=sp();return new Promise(((i,o)=>{let s=new _r;s.setWithCredentials(!0),s.listenOnce(yr.COMPLETE,(()=>
18{try{switch(s.getLastErrorCode()){case br.NO_ERROR:let t=s.getResponseJson();E(fp,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(t)),i(t);break;case br.TIMEOUT:E(fp,`RPC '${e}' ${a} timed out`),o(new M(j.DEADLINE_EXCEEDED,`Request time out`));break;case br.HTTP_ERROR:let n=s.getStatus();if(E(fp,`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 M(function(e){let t=e.toLowerCase().replace(/_/g,`-`);return Object.values(j).indexOf(t)>=0?t:j.UNKNOWN}(t.status),t.message)):o(new M(j.UNKNOWN,`Server responded with status `+s.getStatus()))}else o(new M(j.UNAVAILABLE,`Connection failed.`));break;default:O(9055,{c_:e,streamId:a,l_:s.getLastErrorCode(),h_:s.getLastError()})}}finally{E(fp,`RPC '${e}' ${a} completed.`)}}));let c=JSON.stringify(r);E(fp,`RPC '${e}' ${a} sending request:`,r),s.send(t,`POST`,c,n,15)}))}P_(t,n,r){let i=sp(),a=[this.qo,`/`,`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.Qo(s.initMessageHeaders,n,r),s.encodeInitMessageHeaders=!0;let l=a.join(``);E(fp,`Creating RPC '${t}' stream ${i}: ${l}`,s);let u=o.createWebChannel(l,s);this.T_(u);let d=!1,f=!1,p=new dp({jo:e=>{f?E(fp,`Not sending because RPC '${t}' stream ${i} is closed:`,e):(d||=(E(fp,`Opening RPC '${t}' stream ${i} transport.`),u.open(),!0),E(fp,`RPC '${t}' stream ${i} sending:`,e),u.send(e))},Jo:()=>u.close()});return pp(u,vr.EventType.OPEN,(()=>{f||(E(fp,`RPC '${t}' stream ${i} transport opened.`),p.r_())})),pp(u,vr.EventType.CLOSE,(()=>{f||(f=!0,E(fp,`RPC '${t}' stream ${i} transport closed`),p.s_(),this.I_(u))})),pp(u,vr.EventType.ERROR,(e=>{f||(f=!0,jr(fp,`RPC '${t}' stream ${i} transport errored. Name:`,e.name,`Message:`,e.message),p.s_(new M(j.UNAVAILABLE,`The operation could not be completed`)))})),pp(u,vr.EventType.MESSAGE,(e=>{if(!f){let n=e.data[0];k(!!n,16349);let r=n,a=r?.error||r[0]?.error;if(a){E(fp,`RPC '${t}' stream ${i} received error:`,a);let e=a.status,n=function(e){let t=fl[e];if(t!==void 0)return ml(t)}(e),r=a.message;e===`NOT_FOUND`&&r.includes(`database`)&&r.includes(`does not exist`)&&r.includes(this.databaseId.database)&&jr(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),n===void 0&&(n=j.INTERNAL,r=`Unknown error status: `+e+` with message `+a.message),f=!0,p.s_(new M(n,r)),u.close()}else E(fp,`RPC '${t}' stream ${i} received:`,n),p.o_(n)}})),e.a_(),setTimeout((()=>{p.i_()}),0),p}terminate(){this.__.forEach((e=>e.close())),this.__=[]}T_(e){this.__.push(e)}I_(e){this.__=this.__.filter((t=>t===e))}Qo(e,t,n){super.Qo(e,t,n),this.databaseInfo.apiKey&&(e[`x-goog-api-key`]=this.databaseInfo.apiKey)}createWebChannelTransport(){return wr()}};function hp(e){return new mp(e)}function gp(){return typeof window<`u`?window:null}function _p(){return typeof document<`u`?document:null}function vp(e){return new Fl(e,!0)}mp.u_=!1;var yp=class{constructor(e,t,n=1e3,r=1.5,i=6e4){this.Di=e,this.timerId=t,this.E_=n,this.R_=r,this.A_=i,this.V_=0,this.d_=null,this.m_=Date.now(),this.reset()}reset(){this.V_=0}f_(){this.V_=this.A_}g_(e){this.cancel();let t=Math.floor(this.V_+this.p_()),n=Math.max(0,Date.now()-this.m_),r=Math.max(0,t-n);r>0&&E(`ExponentialBackoff`,`Backing off for ${r} ms (base delay: ${this.V_} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.d_=this.Di.enqueueAfterDelay(this.timerId,r,(()=>(this.m_=Date.now(),e()))),this.V_*=this.R_,this.V_<this.E_&&(this.V_=this.E_),this.V_>this.A_&&(this.V_=this.A_)}
18y_(){this.d_!==null&&(this.d_.skipDelay(),this.d_=null)}cancel(){this.d_!==null&&(this.d_.cancel(),this.d_=null)}p_(){return(Math.random()-.5)*this.V_}},bp=`PersistentStream`,xp=class{constructor(e,t,n,r,i,a,o,s){this.Di=e,this.w_=n,this.S_=r,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=o,this.listener=s,this.state=0,this.b_=0,this.D_=null,this.C_=null,this.stream=null,this.v_=0,this.F_=new yp(e,t)}M_(){return this.state===1||this.state===5||this.x_()}x_(){return this.state===2||this.state===3}start(){this.v_=0,this.state===4?this.O_():this.auth()}async stop(){this.M_()&&await this.close(0)}N_(){this.state=0,this.F_.reset()}B_(){this.x_()&&this.D_===null&&(this.D_=this.Di.enqueueAfterDelay(this.w_,6e4,(()=>this.L_())))}k_(e){this.q_(),this.stream.send(e)}async L_(){if(this.x_())return this.close(0)}q_(){this.D_&&=(this.D_.cancel(),null)}K_(){this.C_&&=(this.C_.cancel(),null)}async close(e,t){this.q_(),this.K_(),this.F_.cancel(),this.b_++,e===4?t&&t.code===j.RESOURCE_EXHAUSTED?(D(t.toString()),D(`Using maximum backoff delay to prevent overloading the backend.`),this.F_.f_()):t&&t.code===j.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()):this.F_.reset(),this.stream!==null&&(this.U_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.e_(t)}U_(){}auth(){this.state=1;let e=this.W_(this.b_),t=this.b_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([e,n])=>{this.b_===t&&this.Q_(e,n)}),(t=>{e((()=>{let e=new M(j.UNKNOWN,`Fetching auth token failed: `+t.message);return this.G_(e)}))}))}Q_(e,t){let n=this.W_(this.b_);this.stream=this.z_(e,t),this.stream.Ho((()=>{n((()=>this.listener.Ho()))})),this.stream.Xo((()=>{n((()=>(this.state=2,this.C_=this.Di.enqueueAfterDelay(this.S_,1e4,(()=>(this.x_()&&(this.state=3),Promise.resolve()))),this.listener.Xo())))})),this.stream.e_((e=>{n((()=>this.G_(e)))})),this.stream.onMessage((e=>{n((()=>++this.v_==1?this.j_(e):this.onNext(e)))}))}O_(){this.state=5,this.F_.g_((async()=>{this.state=0,this.start()}))}G_(e){return E(bp,`close with error: ${e}`),this.stream=null,this.close(4,e)}W_(e){return t=>{this.Di.enqueueAndForget((()=>this.b_===e?t():(E(bp,`stream callback skipped by getCloseGuardedDispatcher.`),Promise.resolve())))}}},Sp=class extends xp{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}z_(e,t){return this.connection.P_(`Listen`,e,t)}j_(e){return this.onNext(e)}onNext(e){this.F_.reset();let t=$l(this.serializer,e),n=function(e){if(!(`targetChange`in e))return R.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?R.min():t.readTime?Bl(t.readTime):R.min()}(e);return this.listener.J_(t,n)}H_(e){let t={};t.database=Jl(this.serializer),t.addTarget=function(e,t){let n,r=t.target;if(n=Vs(r)?{documents:ru(e,r)}:{query:iu(e,r).dt},n.targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=Rl(e,t.resumeToken);let r=Il(e,t.expectedCount);r!==null&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(R.min())>0){n.readTime=Ll(e,t.snapshotVersion.toTimestamp());let r=Il(e,t.expectedCount);r!==null&&(n.expectedCount=r)}return n}(this.serializer,e);let n=ou(this.serializer,e);n&&(t.labels=n),this.k_(t)}Z_(e){let t={};t.database=Jl(this.serializer),t.removeTarget=e,this.k_(t)}},Cp=class extends xp{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 X_(){return this.v_>0}start(){this.lastStreamToken=void 0,super.start()}U_(){this.X_&&this.Y_([])}z_(e,t){return this.connection.P_(`Write`,e,t)}j_(e){return k(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,k(!e.writeResults||e.writeResults.length===0,55816),this.listener.ea()}onNext(e){k(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.F_.reset();let t=nu(e.writeResults,e.commitTime),n=Bl(e.commitTime);return this.listener.ta(n,t)}na(){let e={};e.database=Jl(this.serializer),this.k_(e)}Y_(e){let t={streamToken:this.lastStreamToken,writes:e.map((e=>eu(this.serializer,e)))};this.k_(t)}},wp=class{},Tp=class extends wp{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer
18=r,this.ra=!1}ia(){if(this.ra)throw new M(j.FAILED_PRECONDITION,`The client has already been terminated.`)}$o(e,t,n,r){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,a])=>this.connection.$o(e,Hl(t,n),r,i,a))).catch((e=>{throw e.name===`FirebaseError`?(e.code===j.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new M(j.UNKNOWN,e.toString())}))}zo(e,t,n,r,i){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,o])=>this.connection.zo(e,Hl(t,n),r,a,o,i))).catch((e=>{throw e.name===`FirebaseError`?(e.code===j.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new M(j.UNKNOWN,e.toString())}))}terminate(){this.ra=!0,this.connection.terminate()}};function Ep(e,t,n,r){return new Tp(e,t,n,r)}var Dp=class{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state=`Unknown`,this.sa=0,this.oa=null,this._a=!0}aa(){this.sa===0&&(this.ua(`Unknown`),this.oa=this.asyncQueue.enqueueAfterDelay(`online_state_timeout`,1e4,(()=>(this.oa=null,this.ca(`Backend didn't respond within 10 seconds.`),this.ua(`Offline`),Promise.resolve()))))}la(e){this.state===`Online`?this.ua(`Unknown`):(this.sa++,this.sa>=1&&(this.ha(),this.ca(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ua(`Offline`)))}set(e){this.ha(),this.sa=0,e===`Online`&&(this._a=!1),this.ua(e)}ua(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}ca(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._a?(D(t),this._a=!1):E(`OnlineStateTracker`,t)}ha(){this.oa!==null&&(this.oa.cancel(),this.oa=null)}},Op=`RemoteStore`,kp=class{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Pa=[],this.Ta=new Map,this.Ia=new Map,this.Ea=new Map,this.Ra=new Ed(1e3),this.Aa=new Ed(1001),this.Va=new Set,this.da=[],this.ma=i,this.ma.Fo((e=>{n.enqueueAndForget((async()=>{zp(this)&&(E(Op,`Restarting streams for network reachability change.`),await async function(e){let t=A(e);t.Va.add(4),await jp(t),t.fa.set(`Unknown`),t.Va.delete(4),await Ap(t)}(this))}))})),this.fa=new Dp(n,r)}};async function Ap(e){if(zp(e))for(let t of e.da)await t(!0)}async function jp(e){for(let t of e.da)await t(!1)}function Mp(e,t){return e.Ia.get(t)||void 0}function Np(e,t){let n=A(e),r=Mp(n,t.targetId);if(r!==void 0&&n.Ta.has(r))return;let i=function(e,t){let n=Mp(e,t);n!==void 0&&e.Ea.delete(n);let r=function(e,t){return t%2==0?e.Ra.next():e.Aa.next()}(e,t);return e.Ia.set(t,r),e.Ea.set(r,t),r}(n,t.targetId);E(Op,`remoteStoreListen mapping SDK target ID to remote`,t.targetId,i);let a=new _u(t.target,i,t.purpose,t.sequenceNumber,t.snapshotVersion,t.lastLimboFreeSnapshotVersion,t.resumeToken);n.Ta.set(i,a),Rp(n)?Lp(n):im(n).x_()&&Fp(n,a)}function Pp(e,t){let n=A(e),r=im(n),i=Mp(n,t);E(Op,`remoteStoreUnlisten removing mapping of SDK target ID to remote`,t,i),n.Ta.delete(i),n.Ia.delete(t),n.Ea.delete(i),r.x_()&&Ip(n,i),n.Ta.size===0&&(r.x_()?r.B_():zp(n)&&n.fa.set(`Unknown`))}function Fp(e,t){if(e.ga.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(R.min())>0){let n=e.Ea.get(t.targetId);if(n===void 0)return void E(Op,`SDK target ID not found for remote ID: `+t.targetId);let r=e.remoteSyncer.getRemoteKeysForTarget(n).size;t=t.withExpectedCount(r)}im(e).H_(t)}function Ip(e,t){e.ga.$e(t),im(e).Z_(t)}function Lp(e){e.ga=new kl({getRemoteKeysForTarget:t=>{let n=e.Ea.get(t);return n===void 0?G():e.remoteSyncer.getRemoteKeysForTarget(n)},Rt:t=>e.Ta.get(t)||null,lt:()=>e.datastore.serializer.databaseId}),im(e).start(),e.fa.aa()}function Rp(e){return zp(e)&&!im(e).M_()&&e.Ta.size>0}function zp(e){return A(e).Va.size===0}function Bp(e){e.ga=void 0}async function Vp(e){e.fa.set(`Online`)}async function Hp(e){e.Ta.forEach(((t,n)=>{Fp(e,t)}))}async function Up(e,t){Bp(e),Rp(e)?(e.fa.la(t),Lp(e)):e.fa.set(`Unknown`)}async function Wp(e,t,n){if(e.fa.set(`Online`),t instanceof El&&t.state===2&&t.cause)try{await async function(e,t){let n=t.cause;for(let r of t.targetIds){if(e.Ta.has(r)){let t=e.Ea.get(r);t!==void 0&&(await e.remoteSyncer.rejectListen(t,n),e.Ia.delete(t),e.Ea.delete(r)),e.Ta.delete(r)}e.ga.removeTarget(r)}}(e,t)}catch(n){E(Op,`Failed to remove targets %s: %s `,t.targetIds.join(`,`),n),await Gp(e,n)}else if(t instanceof wl?e.ga.Xe(t):t instanceof Tl?e.ga.it(t):e.ga.tt(t),!n.isEqual(R.min()))try{let t=await jf(e.localStore);n.compareTo(t)>=0&&await function(e,t){let n=e.ga.Pt(t);
18n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){let i=e.Ta.get(r);i&&e.Ta.set(r,i.withResumeToken(n.resumeToken,t))}})),n.targetMismatches.forEach(((t,n)=>{let r=e.Ta.get(t);r&&(e.Ta.set(t,r.withResumeToken(xo.EMPTY_BYTE_STRING,r.snapshotVersion)),Ip(e,t),Fp(e,new _u(r.target,t,n,r.sequenceNumber)))}));let r=function(e,t){let n=new Map;t.targetChanges.forEach(((t,r)=>{let i=e.Ea.get(r);i!==void 0&&n.set(i,t)}));let r=new B(N);return t.targetMismatches.forEach(((t,n)=>{let i=e.Ea.get(t);i!==void 0&&(r=r.insert(i,n))})),new Sl(t.snapshotVersion,n,r,t.documentUpdates,t.resolvedLimboDocuments)}(e,n);return e.remoteSyncer.applyRemoteEvent(r)}(e,n)}catch(t){E(Op,`Failed to raise snapshot:`,t),await Gp(e,t)}}async function Gp(e,t,n){if(!Mi(t))throw t;e.Va.add(1),await jp(e),e.fa.set(`Offline`),n||=()=>jf(e.localStore),e.asyncQueue.enqueueRetryable((async()=>{E(Op,`Retrying IndexedDB access`),await n(),e.Va.delete(1),await Ap(e)}))}function Kp(e,t){return t().catch((n=>Gp(e,n,t)))}async function qp(e){let t=A(e),n=am(t),r=t.Pa.length>0?t.Pa[t.Pa.length-1].batchId:Vi;for(;Jp(t);)try{let e=await Pf(t.localStore,r);if(e===null){t.Pa.length===0&&n.B_();break}r=e.batchId,Yp(t,e)}catch(e){await Gp(t,e)}Xp(t)&&Zp(t)}function Jp(e){return zp(e)&&e.Pa.length<10}function Yp(e,t){e.Pa.push(t);let n=am(e);n.x_()&&n.X_&&n.Y_(t.mutations)}function Xp(e){return zp(e)&&!am(e).M_()&&e.Pa.length>0}function Zp(e){am(e).start()}async function Qp(e){am(e).na()}async function $p(e){let t=am(e);for(let n of e.Pa)t.Y_(n.mutations)}async function em(e,t,n){let r=e.Pa.shift(),i=ll.from(r,t,n);await Kp(e,(()=>e.remoteSyncer.applySuccessfulWrite(i))),await qp(e)}async function tm(e,t){t&&am(e).X_&&await async function(e,t){if(function(e){return pl(e)&&e!==j.ABORTED}(t.code)){let n=e.Pa.shift();am(e).N_(),await Kp(e,(()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t))),await qp(e)}}(e,t),Xp(e)&&Zp(e)}async function nm(e,t){let n=A(e);n.asyncQueue.verifyOperationInProgress(),E(Op,`RemoteStore received new credentials`);let r=zp(n);n.Va.add(3),await jp(n),r&&n.fa.set(`Unknown`),await n.remoteSyncer.handleCredentialChange(t),n.Va.delete(3),await Ap(n)}async function rm(e,t){let n=A(e);t?(n.Va.delete(2),await Ap(n)):t||(n.Va.add(2),await jp(n),n.fa.set(`Unknown`))}function im(e){return e.pa||(e.pa=function(e,t,n){let r=A(e);return r.ia(),new Sp(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Ho:Vp.bind(null,e),Xo:Hp.bind(null,e),e_:Up.bind(null,e),J_:Wp.bind(null,e)}),e.da.push((async t=>{t?(e.pa.N_(),Rp(e)?Lp(e):e.fa.set(`Unknown`)):(await e.pa.stop(),Bp(e))}))),e.pa}function am(e){return e.ya||(e.ya=function(e,t,n){let r=A(e);return r.ia(),new Cp(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Ho:()=>Promise.resolve(),Xo:Qp.bind(null,e),e_:tm.bind(null,e),ea:$p.bind(null,e),ta:em.bind(null,e)}),e.da.push((async t=>{t?(e.ya.N_(),await qp(e)):(await e.ya.stop(),e.Pa.length>0&&(E(Op,`Stopping write stream with ${e.Pa.length} pending writes`),e.Pa=[]))}))),e.ya}var om=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 Fr,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 M(j.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 sm(e,t){if(D(`AsyncQueue`,`${t}: ${e}`),Mi(e))return new M(j.UNAVAILABLE,`${t}: ${e}`);throw e}var cm=class e{static emptySet(t){return new e(t.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||F.comparator(t.key,n.key):(e,t)=>F.comparator(e.key,t.key),this.keyedMap=gc(),this.sortedSet=new B(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 ( 19 `+e.join(` 20`)+` 21)`}copy(t,n){let r=new e;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r}},lm=class{constructor(){this.wa=new B(F.comparator)}track(e){let t=e.doc.key,n=this.wa.get(t);n?e.type!==0&&n.type===3?this.wa=this.wa.insert(t,e):e.type===3&&n.type!==1?this.wa=this.wa.insert(t,{type:n.type,doc:e.doc}):e.type===2&&n.type===2?this.wa=this.wa.insert(t,{type:2,doc:e.doc}):e.type===2&&n.type===0?this.wa=this.wa.insert(t,{type:0,doc:e.doc}):e.type===1&&n.type===0?this.wa=this.wa.remove(t):e.type===1&&n.type===2?this.wa=this.wa.insert(t,{type:1,doc:n.doc}):e.type===0&&n.type===1?this.wa=this.wa.insert(t,{type:2,doc:e.doc}):O(63341,{At:e,Sa:n}):this.wa=this.wa.insert(t,e)}ba(){let e=[];return this.wa.inorderTraversal(((t,n)=>{e.push(n)})),e}},um=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=[];
21return n.forEach((e=>{o.push({type:0,doc:e})})),new e(t,n,cm.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)&&ac(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}},dm=class{constructor(){this.Da=void 0,this.Ca=[]}va(){return this.Ca.some((e=>e.Fa()))}},fm=class{constructor(){this.queries=pm(),this.onlineState=`Unknown`,this.Ma=new Set}terminate(){(function(e,t){let n=A(e),r=n.queries;n.queries=pm(),r.forEach(((e,n)=>{for(let e of n.Ca)e.onError(t)}))})(this,new M(j.ABORTED,`Firestore shutting down`))}};function pm(){return new fc((e=>oc(e)),ac)}async function mm(e,t){let n=A(e),r=3,i=t.query,a=n.queries.get(i);a?!a.va()&&t.Fa()&&(r=2):(a=new dm,r=+!t.Fa());try{switch(r){case 0:a.Da=await n.onListen(i,!0);break;case 1:a.Da=await n.onListen(i,!1);break;case 2:await n.onFirstRemoteStoreListen(i)}}catch(e){let n=sm(e,`Initialization of query '${sc(t.query)}' failed`);t.onError(n);return}n.queries.set(i,a),a.Ca.push(t),t.xa(n.onlineState),a.Da&&t.Oa(a.Da)&&vm(n)}async function hm(e,t){let n=A(e),r=t.query,i=3,a=n.queries.get(r);if(a){let e=a.Ca.indexOf(t);e>=0&&(a.Ca.splice(e,1),a.Ca.length===0?i=+!t.Fa():!a.va()&&t.Fa()&&(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 gm(e,t){let n=A(e),r=!1;for(let e of t){let t=e.query,i=n.queries.get(t);if(i){for(let t of i.Ca)t.Oa(e)&&(r=!0);i.Da=e}}r&&vm(n)}function _m(e,t,n){let r=A(e),i=r.queries.get(t);if(i)for(let e of i.Ca)e.onError(n);r.queries.delete(t)}function vm(e){e.Ma.forEach((e=>{e.next()}))}var ym,bm;(bm=ym||={}).Na=`default`,bm.Cache=`cache`;var xm=class{constructor(e,t,n){this.query=e,this.Ba=t,this.La=!1,this.ka=null,this.onlineState=`Unknown`,this.options=n||{}}Oa(e){if(!this.options.includeMetadataChanges){let t=[];for(let n of e.docChanges)n.type!==3&&t.push(n);e=new um(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.La?this.qa(e)&&(this.Ba.next(e),t=!0):this.Ka(e,this.onlineState)&&(this.Ua(e),t=!0),this.ka=e,t}onError(e){this.Ba.error(e)}xa(e){this.onlineState=e;let t=!1;return this.ka&&!this.La&&this.Ka(this.ka,e)&&(this.Ua(this.ka),t=!0),t}Ka(e,t){if(!e.fromCache||!this.Fa())return!0;let n=t!==`Offline`;return(!this.options.$a||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||t===`Offline`)}qa(e){if(e.docChanges.length>0)return!0;let t=this.ka&&this.ka.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}Ua(e){e=um.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.La=!0,this.Ba.next(e)}Fa(){return this.options.source!==ym.Cache}},Sm=class{constructor(e,t){this.Wa=e,this.byteLength=t}Qa(){return`metadata`in this.Wa}},Cm=class{constructor(e){this.serializer=e}ks(e){return Gl(this.serializer,e)}qs(e){return e.metadata.exists?Zl(this.serializer,e.document,!1):ms.newNoDocument(this.ks(e.metadata.name),this.Ks(e.metadata.readTime))}Ks(e){return Bl(e)}},wm=class{constructor(e,t){this.Ga=e,this.serializer=t,this.za=[],this.ja=[],this.collectionGroups=new Set,this.progress=Tm(e)}get queries(){return this.za}get documents(){return this.ja}Ja(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;if(e.Wa.namedQuery)this.za.push(e.Wa.namedQuery);else if(e.Wa.documentMetadata){this.ja.push({metadata:e.Wa.documentMetadata}),e.Wa.documentMetadata.exists||++t;let n=P.fromString(e.Wa.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else e.Wa.document&&(this.ja[this.ja.length-1].document=e.Wa.document,++t);return t===this.progress.documentsLoaded?null:(this.progress.documentsLoaded=t,{...this.progress})}Ha(e){let t=new Map,n=new Cm(this.serializer);for(let r of e)if(r.metadata.queries){let e=n.ks(r.metadata.name);for(let n of r.metadata.queries){let r=(t.get(n)||G()).add(e);t.set(n,r)}}return t}async Za(e){let t=await Vf(e,new Cm(this.serializer),this.ja,this.Ga.id),n=this.Ha(this.documents);for(let t of this.za)await Hf(e,t,n.get(t.name));return this.progress.taskState=`Success`,{progress:this.progress,Xa:this.collectionGroups,Ya:t}}};function Tm(e){return{taskState:`Running`,documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}var Em=class{constructor(e){this.key=e}},Dm=class{constructor(e){this.key=e}},Om=class{constructor(e,t){this.query=e,this.eu=t,this.tu=null,this.hasCachedResults=!1,this.current=!1,this.nu=G(),this.mutatedKeys=G(),this.ru=uc(e),this.iu=new cm(this.ru)}get su(){return this.eu}ou(e,t){let n=t?t._u:new lm,r=t?t.iu:this.iu,i=t?t.mutatedKeys:this.mutatedKeys,a=r,o=!1,s=this.query.limitType===`F`&&r.size===this.query.limit?r.last():null,c=this.query.limitType===`L`&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal(((e,t)=>{let l=r.get(e),u=cc(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.au(l,u)||(n.track({type:2,doc:u}),p=!0,(s&&this.ru(u,s)>0||c&&this.ru(u,c)<0)&&(o=!0)):!l&&u?(n.track({type:0,doc:u}),p=!0):l&&!u&&(n.track({type:1,doc:l}
21),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)))})),this.query.limit!==null)for(;a.size>this.query.limit;){let e=this.query.limitType===`F`?a.last():a.first();a=a.delete(e.key),i=i.delete(e.key),n.track({type:1,doc:e})}return{iu:a,_u:n,Ss:o,mutatedKeys:i}}au(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){let i=this.iu;this.iu=e.iu,this.mutatedKeys=e.mutatedKeys;let a=e._u.ba();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 O(20277,{At:e})}};return n(e)-n(t)}(e.type,t.type)||this.ru(e.doc,t.doc))),this.uu(n),r??=!1;let o=t&&!r?this.cu():[],s=this.nu.size===0&&this.current&&!r?1:0,c=s!==this.tu;return this.tu=s,a.length!==0||c?{snapshot:new um(this.query,e.iu,i,a,e.mutatedKeys,s===0,c,!1,!!n&&n.resumeToken.approximateByteSize()>0),lu:o}:{lu:o}}xa(e){return this.current&&e===`Offline`?(this.current=!1,this.applyChanges({iu:this.iu,_u:new lm,mutatedKeys:this.mutatedKeys,Ss:!1},!1)):{lu:[]}}hu(e){return!this.eu.has(e)&&!!this.iu.has(e)&&!this.iu.get(e).hasLocalMutations}uu(e){e&&(e.addedDocuments.forEach((e=>this.eu=this.eu.add(e))),e.modifiedDocuments.forEach((e=>{})),e.removedDocuments.forEach((e=>this.eu=this.eu.delete(e))),this.current=e.current)}cu(){if(!this.current)return[];let e=this.nu;this.nu=G(),this.iu.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 Dm(e))})),this.nu.forEach((n=>{e.has(n)||t.push(new Em(n))})),t}Pu(e){this.eu=e.Ls,this.nu=G();let t=this.ou(e.documents);return this.applyChanges(t,!0)}Tu(){return um.fromInitialDocuments(this.query,this.iu,this.mutatedKeys,this.tu===0,this.hasCachedResults)}},km=`SyncEngine`,Am=class{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}},jm=class{constructor(e){this.key=e,this.Iu=!1}},Mm=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.Eu={},this.Ru=new fc((e=>oc(e)),ac),this.Au=new Map,this.Vu=new Set,this.du=new B(F.comparator),this.mu=new Map,this.fu=new ef,this.gu={},this.pu=new Map,this.yu=Ed._r(),this.onlineState=`Unknown`,this.wu=void 0}get isPrimaryClient(){return!0===this.wu}};async function Nm(e,t,n=!0){let r=dh(e),i,a=r.Ru.get(t);return a?(r.sharedClientState.addLocalQueryTarget(a.targetId),i=a.view.Tu()):i=await Fm(r,t,n,!0),i}async function Pm(e,t){await Fm(dh(e),t,!0,!1)}async function Fm(e,t,n,r){let i=await Ff(e.localStore,Qs(t)),a=i.targetId,o=e.sharedCl
21ientState.addLocalQueryTarget(a,n),s;return r&&(s=await Im(e,t,a,o===`current`,i.resumeToken)),e.isPrimaryClient&&n&&Np(e.remoteStore,i),s}async function Im(e,t,n,r,i){e.Su=(t,n,r)=>async function(e,t,n,r){let i=t.view.ou(n);i.Ss&&(i=await Lf(e.localStore,t.query,!1).then((({documents:e})=>t.view.ou(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 Xm(e,t.targetId,s.lu),s.snapshot}(e,t,n,r);let a=await Lf(e.localStore,t,!0),o=new Om(t,a.Ls),s=o.ou(a.documents),c=Cl.createSynthesizedTargetChangeForCurrentChange(n,r&&e.onlineState!==`Offline`,i),l=o.applyChanges(s,e.isPrimaryClient,c);Xm(e,n,l.lu);let u=new Am(t,n,o);return e.Ru.set(t,u),e.Au.has(n)?e.Au.get(n).push(t):e.Au.set(n,[t]),l.snapshot}async function Lm(e,t,n){let r=A(e),i=r.Ru.get(t),a=r.Au.get(i.targetId);if(a.length>1)return r.Au.set(i.targetId,a.filter((e=>!ac(e,t)))),void r.Ru.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedCl
21ientState.isActiveQueryTarget(i.targetId)||await If(r.localStore,i.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(i.targetId),n&&Pp(r.remoteStore,i.targetId),Jm(r,i.targetId)})).catch(Ti)):(Jm(r,i.targetId),await If(r.localStore,i.targetId,!0))}async function Rm(e,t){let n=A(e),r=n.Ru.get(t),i=n.Au.get(r.targetId);n.isPrimaryClient&&i.length===1&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),Pp(n.remoteStore,r.targetId))}async function zm(e,t,n){let r=fh(e);try{let e=await function(e,t){let n=A(e),r=L.now(),i=t.reduce(((e,t)=>e.add(t.key)),G()),a,o;return n.persistence.runTransaction(`Locally write mutations`,`readwrite`,(e=>{let s=mc(),c=G();return n.Ms.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=$c(e,a.get(e.key).overlayedDocument);t!=null&&o.push(new nl(e.key,t,ps(t.value.mapValue),qc.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:_c(a)})))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.gu[e.currentUser.toKey()];r||=new B(N),r=r.insert(t,n),e.gu[e.currentUser.toKey()]=r}(r,e.batchId,n),await $m(r,e.changes),await qp(r.remoteStore)}catch(e){let t=sm(e,`Failed to persist write`);n.reject(t)}}async function Bm(e,t){let n=A(e);try{let e=await Mf(n.localStore,t);
21t.targetChanges.forEach(((e,t)=>{let r=n.mu.get(t);r&&(k(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1,22616),e.addedDocuments.size>0?r.Iu=!0:e.modifiedDocuments.size>0?k(r.Iu,14607):e.removedDocuments.size>0&&(k(r.Iu,42227),r.Iu=!1))})),await $m(n,e,t)}catch(e){await Ti(e)}}function Vm(e,t,n){let r=A(e);if(r.isPrimaryClient&&n===0||!r.isPrimaryClient&&n===1){let e=[];r.Ru.forEach(((n,r)=>{let i=r.view.xa(t);i.snapshot&&e.push(i.snapshot)})),function(e,t){let n=A(e);n.onlineState=t;let r=!1;n.queries.forEach(((e,n)=>{for(let e of n.Ca)e.xa(t)&&(r=!0)})),r&&vm(n)}(r.eventManager,t),e.length&&r.Eu.J_(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function Hm(e,t,n){let r=A(e);r.sharedClientState.updateQueryState(t,`rejected`,n);let i=r.mu.get(t),a=i&&i.key;if(a){let e=new B(F.comparator);e=e.insert(a,ms.newNoDocument(a,R.min()));let n=G().add(a);await Bm(r,new Sl(R.min(),new Map,new B(N),e,n)),r.du=r.du.remove(a),r.mu.delete(t),Qm(r)}else await If(r.localStore,t,!1).then((()=>Jm(r,t,n))).catch(Ti)}async function Um(e,t){let n=A(e),r=t.batch.batchId;try{let e=await Af(n.localStore,t);qm(n,r,null),Km(n,r),n.sharedClientState.updateMutationState(r,`acknowledged`),await $m(n,e)}catch(e){await Ti(e)}}async function Wm(e,t,n){let r=A(e);try{let e=await function(e,t){let n=A(e);return n.persistence.runTransaction(`Reject batch`,`readwrite-primary`,(e=>{let r;
21return n.mutationQueue.lookupMutationBatch(e,t).next((t=>(k(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);qm(r,t,n),Km(r,t),r.sharedClientState.updateMutationState(t,`rejected`,n),await $m(r,e)}catch(e){await Ti(e)}}async function Gm(e,t){let n=A(e);zp(n.remoteStore)||E(km,`The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.`);try{let e=await function(e){let t=A(e);return t.persistence.runTransaction(`Get highest unacknowledged batch id`,`readonly`,(e=>t.mutationQueue.getHighestUnacknowledgedBatchId(e)))}(n.localStore);if(e===Vi)return void t.resolve();let r=n.pu.get(e)||[];r.push(t),n.pu.set(e,r)}catch(e){let n=sm(e,`Initialization of waitForPendingWrites() operation failed`);t.reject(n)}}function Km(e,t){(e.pu.get(t)||[]).forEach((e=>{e.resolve()})),e.pu.delete(t)}function qm(e,t,n){let r=A(e),i=r.gu[r.currentUser.toKey()];if(i){let e=i.get(t);e&&(n?e.reject(n):e.resolve(),i=i.remove(t)),r.gu[r.currentUser.toKey()]=i}}function Jm(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(let r of e.Au.get(t))e.Ru.delete(r),n&&e.Eu.bu(r,n);e.Au.delete(t),e.isPrimaryClient&&e.fu.Qr(t).forEach((t=>{e.fu.containsKey(t)||Ym(e,t)}))}function Ym(e,t){e.Vu.delete(t.path.canonicalString());let n=e.du.get(t);n!==null&&(Pp(e.remoteStore,n),e.du=e.du.remove(t),e.mu.delete(n),Qm(e))}function Xm(e,t,n){for(let r of n)r instanceof Em?(e.fu.addReference(r.key,t),Zm(e,r)):r instanceof Dm?(E(km,`Document no longer in limbo: `+r.key),e.fu.removeReference(r.key,t),e.fu.containsKey(r.key)||Ym(e,r.key)):O(19791,{Du:r})}function Zm(e,t){let n=t.key,r=n.path.canonicalString();e.du.get(n)||e.Vu.has(r)||(E(km,`New document in limbo: `+n),e.Vu.add(r),Qm(e))}function Qm(e){for(;e.Vu.size>0&&e.du.size<e.maxConcurrentLimboResolutions;){let t=e.Vu.values().next().value;e.Vu.delete(t);let n=new F(P.fromString(t)),r=e.yu.next();e.mu.set(r,new jm(n)),e.du=e.du.insert(n,r),Np(e.remoteStore,new _u(Qs(qs(n.path)),r,`TargetPurposeLimboResolution`,Bi.ce))}}async function $m(e,t,n){let r=A(e),i=[],a=[],o=[];r.Ru.isEmpty()||(r.Ru.forEach(((e,s)=>{o.push(r.Su(s,t,n).then((e=>{if((e||n)&&r.isPrimaryClient){let t=e?!e.fromCache:n?.targetChanges.get(s.targetId)?.current;
21r.sharedClientState.updateQueryState(s.targetId,t?`current`:`not-current`)}if(e){i.push(e);let t=Sf.Is(s.targetId,e);a.push(t)}})))})),await Promise.all(o),r.Eu.J_(i),await async function(e,t){let n=A(e);try{await n.persistence.runTransaction(`notifyLocalViewChanges`,`readwrite`,(e=>z.forEach(t,(t=>z.forEach(t.Ps,(r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=>z.forEach(t.Ts,(r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!Mi(e))throw e;E(Tf,`Failed to update sequence numbers: `+e)}for(let e of t){let t=e.targetId;if(!e.fromCache){let e=n.Cs.get(t),r=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(r);n.Cs=n.Cs.insert(t,i)}}}(r.localStore,a))}async function eh(e,t){let n=A(e);if(!n.currentUser.isEqual(t)){E(km,`User change. New user:`,t.toKey());let e=await kf(n.localStore,t);n.currentUser=t,function(e,t){e.pu.forEach((e=>{e.forEach((e=>{e.reject(new M(j.CANCELLED,t))}))})),e.pu.clear()}(n,`'waitForPendingWrites' promise is rejected due to a user change.`),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await $m(n,e.Os)}}function th(e,t){let n=A(e),r=n.mu.get(t);if(r&&r.Iu)return G().add(r.key);{let e=G(),r=n.Au.get(t);if(!r)return e;for(let t of r){let r=n.Ru.get(t);e=e.unionWith(r.view.su)}return e}}async function nh(e,t){let n=A(e),r=await Lf(n.localStore,t.query,!0),i=t.view.Pu(r);return n.isPrimaryClient&&Xm(n,t.targetId,i.lu),i}async function rh(e,t){let n=A(e);return zf(n.localStore,t).then((e=>$m(n,e)))}async function ih(e,t,n,r){let i=A(e),a=await function(e,t){let n=A(e),r=A(n.mutationQueue);return n.persistence.runTransaction(`Lookup mutation documents`,`readonly`,(e=>r.Zn(e,t).next((t=>t?n.localDocuments.getDocuments(e,t):z.resolve(null)))))}(i.localStore,t);a===null?E(km,`Cannot apply mutation batch with id: `+t):(n===`pending`?await qp(i.remoteStore):n===`acknowledged`||n===`rejected`?(qm(i,t,r||null),Km(i,t),function(e,t){A(A(e).mutationQueue).tr(t)}(i.localStore,t)):O(6720,`Unknown batchState`,{Cu:n}),await $m(i,a))}async function ah(e,t){let n=A(e);if(dh(n),fh(n),!0===t&&!0!==n.wu){let e=await oh(n,n.sharedClientState.getAllActiveQueryTargets().toArray());n.wu=!0,await rm(n.remoteStore,!0);for(let t of e)Np(n.remoteStore,t)}else if(!1===t&&!1!==n.wu){let e=[],t=Promise.resolve();n.Au.forEach(((r,i)=>{n.sharedClientState.isLocalQueryTarget(i)?e.push(i):t=t.then((()=>(Jm(n,i),If(n.localStore,i,!0)))),Pp(n.remoteStore,i)})),await t,await oh(n,e),function(e){let t=A(e);t.mu.forEach(((e,n)=>{Pp(t.remoteStore,n)})),t.fu.Gr(),t.mu=new Map,t.du=new B(F.comparator)}(n),n.wu=!1,await rm(n.remoteStore,!1)}}async function oh(e,t,n){let r=A(e),i=[],a=[];for(let e of t){let t,n=r.Au.get(e);if(n&&n.length!==0){t=await Ff(r.localStore,Qs(n[0]));for(let e of n){let t=await nh(r,r.Ru.get(e));t.snapshot&&a.push(t.snapshot)}}else{let n=await Rf(r.localStore,e);t=await Ff(r.localStore,n),await Im(r,sh(n),e,!1,t.resumeToken)}i.push(t)}return r.Eu.J_(a),i}function sh(e){return Ks(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,`F`,e.startAt,e.endAt)}function ch(e){return function(e){return A(A(e).persistence).ls()}(A(e).localStore)}async function lh(e,t,n,r){let i=A(e);if(i.wu)return void E(km,`Ignoring unexpected query state notification.`);let a=i.Au.get(t);if(a&&a.length>0)switch(n){case`current`:case`not-current`:await $m(i,await zf(i.localStore,lc(a[0])),Sl.createSynthesizedRemoteEventForCurrentChange(t,n===`current`,xo.EMPTY_BYTE_STRING));break;case`rejected`:await If(i.localStore,t,!0),Jm(i,t,r);break;default:O(64155,n)}}async function uh(e,t,n){let r=dh(e);if(r.wu){for(let e of t){if(r.Au.has(e)&&r.sharedClientState.isActiveQueryTarget(e)){E(km,`Adding an already active target `+e);continue}let t=await Rf(r.localStore,e),n=await Ff(r.localStore,t);await Im(r,sh(t),n.targetId,!1,n.resumeToken),Np(r.remoteStore,n)}for(let e of n)r.Au.has(e)&&await If(r.localStore,e,!1).then((()=>{Pp(r.remoteStore,e),Jm(r,e)})).catch(Ti)}}function dh(e){let t=A(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=Bm.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=th.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=Hm.bind(null,t),t.Eu.J_=gm.bind(null,t.eventManager),t.Eu.bu=_m.bind(null,t.eventManager),t}function fh(e){let t=A(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=Um.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Wm.bind(null,t),t}function ph(e,t,n){let r=A(e);(async function(e,t,n){try{let r=await t.getMetadata();if(await function(e,t){let n=A(e),r=Bl(t.createTime);return n.persistence.runTransaction(`hasNewerBundle`,`readonly`,(e=>n.hi.getBundleMetadata(e,t.id))).then((e=>!!e&&e.createTime.compareTo(r)>=0))}(e.localStore,r))return await t.close(),n._completeWith(function(e){return{taskState:`Success`,documentsLoaded:e.totalDocuments,bytesLoaded:e.totalBytes,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}(r)),Promise.resolve(new Set);n._updateProgress(Tm(r));let i=new wm(r,t.serializer),a=await t.vu();for(;a;){let e=await i.Ja(a);e&&n._updateProgress(e),a=await t.vu()}let o=await i.Za(e.localStore);return await $m(e,o.Ya,void 0),await function(e,t){let n=A(e);return n.persistence.runTransaction(`Save bundle`,`readwrite`,(e=>n.hi.saveBundleMetadata(e,t)))}(e.localStore,r),n._completeWith(o.progress),Promise.resolve(o.Xa)}catch(e){return jr(km,`Loading bundle failed with ${e}`),n._failWith(e),Promise.resolve(new Set)}})(r,t,n).then((e=>
21{r.sharedClientState.notifyBundleLoaded(e)}))}var mh=class{constructor(){this.kind=`memory`,this.synchronizeTabs=!1}async initialize(e){this.serializer=vp(e.databaseInfo.databaseId),this.sharedClientState=this.Fu(e),this.persistence=this.Mu(e),await this.persistence.start(),this.localStore=this.xu(e),this.gcScheduler=this.Ou(e,this.localStore),this.indexBackfillerScheduler=this.Nu(e,this.localStore)}Ou(e,t){return null}Nu(e,t){return null}xu(e){return Of(this.persistence,new wf,e.initialUser,this.serializer)}Mu(e){return new sf(lf.Ai,this.serializer)}Fu(e){return new np}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}};mh.provider={build:()=>new mh};var hh=class extends mh{constructor(e){super(),this.cacheSizeBytes=e}Ou(e,t){k(this.persistence.referenceDelegate instanceof uf,46915);let n=this.persistence.referenceDelegate.garbageCollector;return new Fd(n,e.asyncQueue,t)}Mu(e){let t=this.cacheSizeBytes===void 0?vd.DEFAULT:vd.withCacheSize(this.cacheSizeBytes);return new sf((e=>uf.Ai(e,t)),this.serializer)}},gh=class extends mh{constructor(e,t,n){super(),this.Bu=e,this.cacheSizeBytes=t,this.forceOwnership=n,this.kind=`persistent`,this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await this.Bu.initialize(this,e),await fh(this.Bu.syncEngine),await qp(this.Bu.remoteStore),await this.persistence.Gi((()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve())))}xu(e){return Of(this.persistence,new wf,e.initialUser,this.serializer)}Ou(e,t){let n=this.persistence.referenceDelegate.garbageCollector;return new Fd(n,e.asyncQueue,t)}Nu(e,t){let n=new zi(t,this.persistence);return new Ri(e.asyncQueue,n)}Mu(e){let t=xf(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=this.cacheSizeBytes===void 0?vd.DEFAULT:vd.withCacheSize(this.cacheSizeBytes);return new vf(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,gp(),_p(),this.serializer,this.sharedClientState,!!this.forceOwnership)}Fu(e){return new np}},_h=class extends gh{constructor(e,t){super(e,t,!1),this.Bu=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);let t=this.Bu.syncEngine;this.sharedClientState instanceof tp&&(this.sharedClientState.syncEngine={So:ih.bind(null,t),bo:lh.bind(null,t),Do:uh.bind(null,t),ls:ch.bind(null,t),wo:rh.bind(null,t)},await this.sharedClientState.start()),await this.persistence.Gi((async e=>{await ah(this.Bu.syncEngine,e),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start():e||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(e&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():e||this.indexBackfillerScheduler.stop())}))}Fu(e){let t=gp();if(!tp.v(t))throw new M(j.UNIMPLEMENTED,`IndexedDB persistence is only available on platforms that support LocalStorage.`);let n=xf(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new tp(t,e.asyncQueue,n,e.clientId,e.initialUser)}},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=>Vm(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=eh.bind(null,this.syncEngine),await rm(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new fm}()}createDatastore(e){let t=vp(e.databaseInfo.databaseId),n=hp(e.databaseInfo);return Ep(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,r,i){return new kp(e,t,n,r,i)}(this.localStore,this.datastore,e.asyncQueue,(e=>Vm(this.syncEngine,e,0)),function(){return ap.v()?new ap:new rp}())}createSyncEngine(e,t){return function(e,t,n,r,i,a,o){let s=new Mm(e,t,n,r,i,a);return o&&(s.wu=!0),s}(this.localStore,this.remoteStore,this.eventManager,this.sharedCl
21ientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await async function(e){let t=A(e);E(Op,`RemoteStore shutting down.`),t.Va.add(5),await jp(t),t.ma.shutdown(),t.fa.set(`Unknown`)}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}};vh.provider={build:()=>new vh};function yh(e,t=10240){let n=0;return{async read(){if(n<e.byteLength){let r={value:e.slice(n,n+t),done:!1};return n+=t,r}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}var bh=class{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Lu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Lu(this.observer.error,e):D(`Uncaught Error in snapshot listener:`,e.toString()))}ku(){this.muted=!0}Lu(e,t){setTimeout((()=>{this.muted||e(t)}),0)}},xh=class{constructor(e,t){this.qu=e,this.serializer=t,this.metadata=new Fr,this.buffer=new Uint8Array,this.Ku=function(){return new TextDecoder(`utf-8`)}(),this.Uu().then((e=>{e&&e.Qa()?this.metadata.resolve(e.Wa.metadata):this.metadata.reject(Error(`The first element of the bundle is not a metadata, it is\n ${JSON.stringify(e?.Wa)}`))}),(e=>this.metadata.reject(e)))}close(){return this.qu.cancel()}async getMetadata(){return this.metadata.promise}async vu(){return await this.getMetadata(),this.Uu()}async Uu(){let e=await this.$u();if(e===null)return null;let t=this.Ku.decode(e),n=Number(t);isNaN(n)&&this.Wu(`length string (${t}) is not valid number`);let r=await this.Qu(n);return new Sm(JSON.parse(r),e.length+n)}Gu(){return this.buffer.findIndex((e=>e===123))}async $u(){for(;this.Gu()<0&&!await this.zu(););if(this.buffer.length===0)return null;let e=this.Gu();e<0&&this.Wu(`Reached the end of bundle when a length string is expected.`);let t=this.buffer.slice(0,e);return this.buffer=this.buffer.slice(e),t}async Qu(e){for(;this.buffer.length<e;)await this.zu()&&this.Wu(`Reached the end of bundle when more is expected.`);let t=this.Ku.decode(this.buffer.slice(0,e));return this.buffer=this.buffer.slice(e),t}Wu(e){throw this.qu.cancel(),Error(`Invalid bundle format: ${e}`)}async zu(){let e=await this.qu.read();if(!e.done){let t=new Uint8Array(this.buffer.length+e.value.length);t.set(this.buffer),t.set(e.value,this.buffer.length),this.buffer=t}return e.done}},Sh=class{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new M(j.INVALID_ARGUMENT,`Firestore transactions require all reads to be executed before all writes.`),this.lastTransactionError;let t=await async function(e,t){let n=A(e),r={documents:t.map((e=>Wl(n.serializer,e)))},i=await n.zo(`BatchGetDocuments`,n.serializer.databaseId,P.emptyPath(),r,t.length),a=new Map;i.forEach((e=>{let t=Ql(n.serializer,e);a.set(t.key.toString(),t)}));let o=[];return t.forEach((e=>{let t=a.get(e.toString());k(!!t,55234,{key:e}),o.push(t)})),o}(this.datastore,e);return t.forEach((e=>this.recordVersion(e))),t}set(e,t){this.write(t.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}update(e,t){try{this.write(t.toMutation(e,this.preconditionForUpdate(e)))}catch(e){this.lastTransactionError=e}this.writtenDocs.add(e.toString())}delete(e){this.write(new ol(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;let e=this.readVersions;this.mutations.forEach((t=>{e.delete(t.key.toString())})),e.forEach(((e,t)=>{let n=F.fromPath(t);this.mutations.push(new sl(n,this.precondition(n)))})),await async function(e,t){let n=A(e),r={writes:t.map((e=>eu(n.serializer,e)))};await n.$o(`Commit`,n.serializer.databaseId,P.emptyPath(),r)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw O(50498,{Ju:e.constructor.name});t=R.min()}let n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new M(j.ABORTED,`Document version changed between two reads.`)}else this.readVersions.set(e.key.toString(),t)}precondition(e){let t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?t.isEqual(R.min())?qc.exists(!1):qc.updateTime(t):qc.none()}preconditionForUpdate(e){let t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(R.min()))throw new M(j.INVALID_ARGUMENT,`Can't update a document that doesn't exist.`);return qc.updateTime(t)}return qc.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}},Ch=class{constructor(e,t,n,r,i){this.asyncQueue=e,this.datastore=t,this.options=n,this.updateFunction=r,this.deferred=i,this.Hu=n.maxAttempts,this.F_=new yp(this.asyncQueue,`transaction_retry`)}Zu(){--this.Hu,this.Xu()}Xu(){this.F_.g_((async()=>{let e=new Sh(this.datastore),t=this.Yu(e);t&&t.then((t=>{this.asyncQueue.enqueueAndForget((()=>e.commit().then((()=>{this.deferred.resolve(t)}
21)).catch((e=>{this.ec(e)}))))})).catch((e=>{this.ec(e)}))}))}Yu(e){try{let t=this.updateFunction(e);return!Hi(t)&&t.catch&&t.then?t:(this.deferred.reject(Error(`Transaction callback must return a Promise`)),null)}catch(e){return this.deferred.reject(e),null}}ec(e){this.Hu>0&&this.tc(e)?(--this.Hu,this.asyncQueue.enqueueAndForget((()=>(this.Xu(),Promise.resolve())))):this.deferred.reject(e)}tc(e){if(e?.name===`FirebaseError`){let t=e.code;return t===`aborted`||t===`failed-precondition`||t===`already-exists`||!pl(t)}return!1}},wh=`FirestoreClient`,Th=class{constructor(e,t,n,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this._databaseInfo=r,this.user=Tr.UNAUTHENTICATED,this.clientId=Gr.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,(async e=>{E(wh,`Received user=`,e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=>(E(wh,`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 Fr;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=sm(t,`Failed to shutdown persistence`);e.reject(n)}})),e.promise}};async function Eh(e,t){e.asyncQueue.verifyOperationInProgress(),E(wh,`Initializing OfflineComponentProvider`);let n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=>{r.isEqual(e)||(await kf(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e._offlineComponents=t}async function Dh(e,t){e.asyncQueue.verifyOperationInProgress();let n=await Oh(e);E(wh,`Initializing OnlineComponentProvider`),await t.initialize(n,e.configuration),e.setCredentialChangeListener((e=>nm(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=>nm(t.remoteStore,n))),e._onlineComponents=t}async function Oh(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){E(wh,`Using user provided OfflineComponentProvider`);try{await Eh(e,e._uninitializedComponentsProvider._offline)}catch(t){let n=t;if(!function(e){return e.name===`FirebaseError`?e.code===j.FAILED_PRECONDITION||e.code===j.UNIMPLEMENTED:!(typeof DOMException<`u`&&e instanceof DOMException)||e.code===22||e.code===20||e.code===11}(n))throw n;jr(`Error using user provided cache. Falling back to memory cache: `+n),await Eh(e,new mh)}}else E(wh,`Using default OfflineComponentProvider`),await Eh(e,new hh(void 0));return e._offlineComponents}async function kh(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(E(wh,`Using user provided OnlineComponentProvider`),await Dh(e,e._uninitializedComponentsProvider._online)):(E(wh,`Using default OnlineComponentProvider`),await Dh(e,new vh))),e._onlineComponents}function Ah(e){return Oh(e).then((e=>e.persistence))}function jh(e){return Oh(e).then((e=>e.localStore))}function Mh(e){return kh(e).then((e=>e.remoteStore))}function Nh(e){return kh(e).then((e=>e.syncEngine))}function Ph(e){return kh(e).then((e=>e.datastore))}async function Fh(e){let t=await kh(e),n=t.eventManager;return n.onListen=Nm.bind(null,t.syncEngine),n.onUnlisten=Lm.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=Pm.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=Rm.bind(null,t.syncEngine),n}function Ih(e){return e.asyncQueue.enqueue((async()=>{let t=await Ah(e),n=await Mh(e);return t.setNetworkEnabled(!0),function(e){let t=A(e);return t.Va.delete(0),Ap(t)}(n)}))}function Lh(e){return e.asyncQueue.enqueue((async()=>{let t=await Ah(e),n=await Mh(e);return t.setNetworkEnabled(!1),async function(e){let t=A(e);t.Va.add(0),await jp(t),t.fa.set(`Offline`)}(n)}))}function Rh(e,t,n,r){let i=new bh(r),a=new xm(t,i,n);return e.asyncQueue.enqueueAndForget((async()=>
21mm(await Fh(e),a))),()=>{i.ku(),e.asyncQueue.enqueueAndForget((async()=>hm(await Fh(e),a)))}}function zh(e,t){let n=new Fr;return e.asyncQueue.enqueueAndForget((async()=>async function(e,t,n){try{let r=await function(e,t){let n=A(e);return n.persistence.runTransaction(`read document`,`readonly`,(e=>n.localDocuments.getDocument(e,t)))}(e,t);r.isFoundDocument()?n.resolve(r):r.isNoDocument()?n.resolve(null):n.reject(new M(j.UNAVAILABLE,`Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)`))}catch(e){let r=sm(e,`Failed to get document '${t} from cache`);n.reject(r)}}(await jh(e),t,n))),n.promise}function Bh(e,t,n={}){let r=new Fr;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new bh({next:s=>{a.ku(),t.enqueueAndForget((()=>hm(e,o)));let c=s.docs.has(n);!c&&s.fromCache?i.reject(new M(j.UNAVAILABLE,`Failed to get document because the client is offline.`)):c&&s.fromCache&&r&&r.source===`server`?i.reject(new M(j.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 xm(qs(n.path),a,{includeMetadataChanges:!0,$a:!0});return mm(e,o)}(await Fh(e),e.asyncQueue,t,n,r))),r.promise}function Vh(e,t){let n=new Fr;return e.asyncQueue.enqueueAndForget((async()=>async function(e,t,n){try{let r=await Lf(e,t,!0),i=new Om(t,r.Ls),a=i.ou(r.documents),o=i.applyChanges(a,!1);n.resolve(o.snapshot)}catch(e){let r=sm(e,`Failed to execute query '${t} against cache`);n.reject(r)}}(await jh(e),t,n))),n.promise}function Hh(e,t,n={}){let r=new Fr;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new bh({next:n=>{a.ku(),t.enqueueAndForget((()=>hm(e,o))),n.fromCache&&r.source===`server`?i.reject(new M(j.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 xm(n,a,{includeMetadataChanges:!0,$a:!0});return mm(e,o)}(await Fh(e),e.asyncQueue,t,n,r))),r.promise}function Uh(e,t){let n=new Fr;return e.asyncQueue.enqueueAndForget((async()=>zm(await Nh(e),t,n))),n.promise}function Wh(e,t){let n=new bh(t);return e.asyncQueue.enqueueAndForget((async()=>function(e,t){A(e).Ma.add(t),t.next()}(await Fh(e),n))),()=>{n.ku(),e.asyncQueue.enqueueAndForget((async()=>function(e,t){A(e).Ma.delete(t)}(await Fh(e),n)))}}function Gh(e,t,n){let r=new Fr;return e.asyncQueue.enqueueAndForget((async()=>{let i=await Ph(e);new Ch(e.asyncQueue,i,n,t,r).Zu()})),r.promise}function Kh(e,t,n,r){let i=function(e,t){let n;return n=typeof e==`string`?gl().encode(e):e,function(e,t){return new xh(e,t)}(function(e,t){if(e instanceof Uint8Array)return yh(e,t);if(e instanceof ArrayBuffer)return yh(new Uint8Array(e),t);if(e instanceof ReadableStream)return e.getReader();throw Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(n),t)}(n,vp(t));e.asyncQueue.enqueueAndForget((async()=>{ph(await Nh(e),i,r)}))}function qh(e,t){return e.asyncQueue.enqueue((async()=>function(e,t){let n=A(e);return n.persistence.runTransaction(`Get named query`,`readonly`,(e=>n.hi.getNamedQuery(e,t)))}(await jh(e),t)))}function Jh(e){let t={};return e.timeoutSeconds!==void 0&&(t.timeoutSeconds=e.timeoutSeconds),t}var Yh=`ComponentProvider`,Xh=new Map;function Zh(e,t,n,r,i){return new Mo(e,t,n,i.host,i.ssl,i.experimentalForceLongPolling,i.experimentalAutoDetectLongPolling,Jh(i.experimentalLongPollingOptions),i.useFetchStreams,i.isUsingEmulator,r)}var Qh=`firestore.googleapis.com`,$h=!0,eg=class{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new M(j.INVALID_ARGUMENT,`Can't provide ssl option if host option is not set`);this.host=Qh,this.ssl=$h}else this.host=e.host,this.ssl=e.ssl??$h;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=_d;
21else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<Md)throw new M(j.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=Jh(e.experimentalLongPollingOptions??{}),function(e){if(e.timeoutSeconds!==void 0){if(isNaN(e.timeoutSeconds))throw new M(j.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new M(j.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new M(j.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}},tg=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 eg({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask=`notTerminated`}get app(){if(!this._app)throw new M(j.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 M(j.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 eg(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=function(e){if(!e)return new Lr;switch(e.type){case`firstParty`:return new Vr(e.sessionIndex||`0`,e.iamToken||null,e.authTokenFactory||null);case`provider`:return e.client;default:throw new M(j.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=Xh.get(e);t&&(E(Yh,`Removing Datastore`),Xh.delete(e),t.terminate())}(this),Promise.resolve()}};function ng(e,t,n,r={}){e=I(e,tg);let i=Ze(t),a=e._getSettings(),o={...a,emulatorOptions:e._getEmulatorOptions()},s=`${t}:${n}`;i&&Qe(`https://${s}`),a.host!==Qh&&a.host!==s&&jr(`Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.`);let c={...a,host:s,ssl:i,emulatorOptions:r};if(!v(c,o)&&(e._setSettings(c),r.mockUserToken)){let t,n;if(typeof r.mockUserToken==`string`)t=r.mockUserToken,n=Tr.MOCK_USER;else{t=me(r.mockUserToken,e._app?.options.projectId);let i=r.mockUserToken.sub||r.mockUserToken.user_id;if(!i)throw new M(j.INVALID_ARGUMENT,`mockUserToken must contain 'sub' or 'user_id' field!`);n=new Tr(i)}e._authCredentials=new Rr(new Ir(t,n))}}var rg=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)}},q=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()}
21get path(){return this._key.path.canonicalString()}get parent(){return new ig(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(ui(n,e._jsonSchema))return new e(t,r||null,new F(P.fromString(n.referencePath)))}};q._jsonSchemaVersion=`firestore/documentReference/1.0`,q._jsonSchema={type:li(`string`,q._jsonSchemaVersion),referencePath:li(`string`)};var ig=class e extends rg{constructor(e,t,n){super(e,t,qs(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 q(this.firestore,null,new F(e))}withConverter(t){return new e(this.firestore,t,this._path)}};function ag(e,t,...n){if(e=y(e),ni(`collection`,`path`,t),e instanceof tg){let r=P.fromString(t,...n);return ai(r),new ig(e,null,r)}{if(!(e instanceof q||e instanceof ig))throw new M(j.INVALID_ARGUMENT,`Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore`);let r=e._path.child(P.fromString(t,...n));return ai(r),new ig(e.firestore,null,r)}}function og(e,t){if(e=I(e,tg),ni(`collectionGroup`,`collection id`,t),t.indexOf(`/`)>=0)throw new M(j.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new rg(e,null,function(e){return new Gs(P.emptyPath(),e)}(t))}function sg(e,t,...n){if(e=y(e),arguments.length===1&&(t=Gr.newId()),ni(`doc`,`path`,t),e instanceof tg){let r=P.fromString(t,...n);return ii(r),new q(e,null,new F(r))}{if(!(e instanceof q||e instanceof ig))throw new M(j.INVALID_ARGUMENT,`Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore`);let r=e._path.child(P.fromString(t,...n));return ii(r),new q(e.firestore,e instanceof ig?e.converter:null,new F(r))}}function cg(e,t){return e=y(e),t=y(t),(e instanceof q||e instanceof ig)&&(t instanceof q||t instanceof ig)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter}function lg(e,t){return e=y(e),t=y(t),e instanceof rg&&t instanceof rg&&e.firestore===t.firestore&&ac(e._query,t._query)&&e.converter===t.converter}var ug=`AsyncQueue`,dg=class{constructor(e=Promise.resolve()){this.nc=[],this.rc=!1,this.sc=[],this.oc=null,this._c=!1,this.ac=!1,this.uc=[],this.F_=new yp(this,`async_queue_retry`),this.cc=()=>{let e=_p();e&&E(ug,`Visibility state changed to `+e.visibilityState),this.F_.y_()},this.lc=e;let t=_p();t&&typeof t.addEventListener==`function`&&t.addEventListener(`visibilitychange`,this.cc)}get isShuttingDown(){return this.rc}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.hc(),this.Pc(e)}enterRestrictedMode(e){if(!this.rc){this.rc=!0,this.ac=e||!1;let t=_p();t&&typeof t.removeEventListener==`function`&&t.removeEventListener(`visibilitychange`,this.cc)}}enqueue(e){if(this.hc(),this.rc)return new Promise((()=>{}));let t=new Fr;return this.Pc((()=>this.rc&&this.ac?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.nc.push(e),this.Tc())))}async Tc(){if(this.nc.length!==0){try{await this.nc[0](),this.nc.shift(),this.F_.reset()}catch(e){if(!Mi(e))throw e;E(ug,`Operation failed with retryable error: `+e)}this.nc.length>0&&this.F_.g_((()=>this.Tc()))}}Pc(e){let t=this.lc.then((()=>(this._c=!0,e().catch((e=>{throw this.oc=e,this._c=!1,D(`INTERNAL UNHANDLED ERROR: `,fg(e)),e})).then((e=>(this._c=!1,e))))));return this.lc=t,t}enqueueAfterDelay(e,t,n){this.hc(),this.uc.indexOf(e)>-1&&(t=0);let r=om.createAndSchedule(this,e,t,n,(e=>this.Ic(e)));return this.sc.push(r),r}hc(){this.oc&&O(47125,{Ec:fg(this.oc)})}verifyOperationInProgress(){}async Rc(){let e;do e=this.lc,await e;while(e!==this.lc)}Ac(e){for(let t of this.sc)if(t.timerId===e)return!0;return!1}Vc(e){return this.Rc().then((()=>{this.sc.sort(((e,t)=>e.targetTimeMs-t.targetTimeMs));for(let t of this.sc)if(t.skipDelay(),e!==`all`&&t.timerId===e)break;return this.Rc()}))}dc(e){this.uc.push(e)}Ic(e){let t=this.sc.indexOf(e);this.sc.splice(t,1)}};function fg(e){let t=e.message||``;return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+` 22`+e.stack),t}var pg=class{constructor(){this._progressObserver={},this._taskCompletionResolver=new Fr,this._lastProgress={taskState:`Running`,totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(e,t,n){this._progressObserver={next:e,error:t,complete:n}}catch(e){return this._taskCompletionResolver.promise.catch(e)}then(e,t){return this._taskCompletionResolver.promise.then(e,t)}_completeWith(e){this._updateProgress(e),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(e)}_failWith(e){this._lastProgress.taskState=`Error`,this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(e),this._taskCompletionResolver.reject(e)}_updateProgress(e){this._lastProgress=e,this._progressObserver.next&&this._progressObserver.next(e)}},J=class extends tg{constructor(e,t,n,r){super(e,t,n,r),this.type=`firestore`,this._queue=new dg,this._persistenceKey=r?.name||`[DEFAULT]`}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new dg(e),this._firestoreClient=void 0,await e}}};function mg(e,t){let n=typeof e==`object`?e:Nn(),r=typeof e==`string`?e:t||No,i=Sn(n,`firestore`).getImmediate({identifier:r});if(!i._initialized){let e=ue(`firestore`);e&&ng(i,...e)}return i}function hg(e){if(e._terminated)throw new M(j.FAILED_PRECONDITION,`The client has already been terminated.`);return e._firestoreClient||gg(e),e._firestoreClient}function gg(e){let t=e._freezeSettings(),n=Zh(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 Th(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))}function _g(e,t){jr("enableIndexedDbPersistence() will be deprecated
22in the future, you can use `FirestoreSettings.cache` instead.");let n=e._freezeSettings();return yg(e,vh.provider,{build:e=>new gh(e,n.cacheSizeBytes,t?.forceOwnership)}),Promise.resolve()}async function vg(e){jr("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");let t=e._freezeSettings();yg(e,vh.provider,{build:e=>new _h(e,t.cacheSizeBytes)})}function yg(e,t,n){if((e=I(e,J))._firestoreClient||e._terminated)throw new M(j.FAILED_PRECONDITION,`Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.`);if(e._componentsProvider||e._getSettings().localCache)throw new M(j.FAILED_PRECONDITION,`SDK cache is already specified.`);e._componentsProvider={_online:t,_offline:n},gg(e)}function bg(e){if(e._initialized&&!e._terminated)throw new M(j.FAILED_PRECONDITION,`Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.`);let t=new Fr;return e._queue.enqueueAndForgetEvenWhileRestricted((async()=>{try{await async function(e){if(!Oi.v())return Promise.resolve();let t=e+_f;await Oi.delete(t)}(xf(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}})),t.promise}function xg(e){return function(e){let t=new Fr;return e.asyncQueue.enqueueAndForget((async()=>Gm(await Nh(e),t))),t.promise}(hg(e=I(e,J)))}function Sg(e){return Ih(hg(e=I(e,J)))}function Cg(e){return Lh(hg(e=I(e,J)))}function wg(e,t){let n=hg(e=I(e,J)),r=new pg;return Kh(n,e._databaseId,t,r),r}function Tg(e,t){return qh(hg(e=I(e,J)),t).then((t=>t?new rg(e,null,t.query):null))}var Eg=class e{constructor(e){this._byteString=e}static fromBase64String(t){try{return new e(xo.fromBase64String(t))}catch(e){throw new M(j.INVALID_ARGUMENT,`Failed to construct data from Base64 string: `+e)}}static fromUint8Array(t){return new e(xo.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(ui(t,e._jsonSchema))return e.fromBase64String(t.bytes)}};Eg._jsonSchemaVersion=`firestore/bytes/1.0`,Eg._jsonSchema={type:li(`string`,Eg._jsonSchemaVersion),bytes:li(`string`)};var Dg=class{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new M(j.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 Og(){return new Dg(Qr)}var kg=class{constructor(e){this._methodName=e}},Ag=class e{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new M(j.INVALID_ARGUMENT,`Latitude must be a number between -90 and 90, but was: `+e);if(!isFinite(t)||t<-180||t>180)throw new M(j.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 N(this._lat,e._lat)||N(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:e._jsonSchemaVersion}}static fromJSON(t){if(ui(t,e._jsonSchema))return new e(t.latitude,t.longitude)}};Ag._jsonSchemaVersion=`firestore/geoPoint/1.0`,Ag._jsonSchema={type:li(`string`,Ag._jsonSchemaVersion),latitude:li(`number`),longitude:li(`number`)};var jg=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(ui(t,e._jsonSchema)){if(Array.isArray(t.vectorValues)&&t.vectorValues.every((e=>typeof e==`number`)))return new e(t.vectorValues);throw new M(j.INVALID_ARGUMENT,`Expected 'vectorValues' field to be a number array`)}}};jg._jsonSchemaVersion=`firestore/vectorValue/1.0`,jg._jsonSchema={type:li(`string`,jg._jsonSchemaVersion),vectorValues:li(`object`)};var Mg=/^__.*__$/,Ng=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return this.fieldMask===null?new tl(e,this.data,t,this.fieldTransforms):new nl(e,this.data,this.fieldMask,t,this.fieldTransforms)}},Pg=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new nl(e,this.data,this.fieldMask,t,this.fieldTransforms)}};function Fg(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw O(40011,{dataSource:e})}}var Ig=class e{constructor(e,t,n,r,i,a){this.settings=e,this.databaseId=t,this.serializer
22=n,this.ignoreUndefinedProperties=r,i===void 0&&this.mc(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}i(t){return new e({...this.settings,...t},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}gc(e){let t=this.path?.child(e),n=this.i({path:t,arrayElement:!1});return n.yc(e),n}wc(e){let t=this.path?.child(e),n=this.i({path:t,arrayElement:!1});return n.mc(),n}Sc(e){return this.i({path:void 0,arrayElement:!0})}bc(e){return n_(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}mc(){if(this.path)for(let e=0;e<this.path.length;e++)this.yc(this.path.get(e))}yc(e){if(e.length===0)throw this.bc(`Document fields must not be empty`);if(Fg(this.dataSource)&&Mg.test(e))throw this.bc(`Document fields cannot begin and end with "__"`)}},Lg=class{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||vp(e)}V(e,t,n,r=!1){return new Ig({dataSource:e,methodName:t,targetDoc:n,path:ti.emptyPath(),arrayElement:!1,hasConverter:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function Rg(e){let t=e._freezeSettings(),n=vp(e._databaseId);return new Lg(e._databaseId,!!t.ignoreUndefinedProperties,n)}function zg(e,t,n,r,i,a={}){let o=e.V(a.merge||a.mergeFields?2:0,t,n,i);Qg(`Data must be an object, but it was:`,o,r);let s=Xg(r,o),c,l;if(a.merge)c=new vo(o.fieldMask),l=o.fieldTransforms;else if(a.mergeFields){let e=[];for(let r of a.mergeFields){let i=$g(t,r,n);if(!o.contains(i))throw new M(j.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);r_(e,i)||e.push(i)}c=new vo(e),l=o.fieldTransforms.filter((e=>c.covers(e.field)))}else c=null,l=o.fieldTransforms;return new Ng(new fs(s),c,l)}var Bg=class e extends kg{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.bc(`${this._methodName}() can only appear at the top level of your update data`):e.bc(`${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 Vg(e,t,n){return new Ig({dataSource:3,targetDoc:t.settings.targetDoc,methodName:e._methodName,arrayElement:n},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}var Hg=class e extends kg{_toFieldTransform(e){return new Wc(e.path,new Mc)}isEqual(t){return t instanceof e}},Ug=class e extends kg{constructor(e,t){super(e),this.Cc=t}_toFieldTransform(e){let t=Vg(this,e,!0),n=new Nc(this.Cc.map((e=>Yg(e,t))));return new Wc(e.path,n)}isEqual(t){return t instanceof e&&v(this.Cc,t.Cc)}},Wg=class e extends kg{constructor(e,t){super(e),this.Cc=t}_toFieldTransform(e){let t=Vg(this,e,!0),n=new Fc(this.Cc.map((e=>Yg(e,t))));return new Wc(e.path,n)}isEqual(t){return t instanceof e&&v(this.Cc,t.Cc)}},Gg=class e extends kg{constructor(e,t){super(e),this.vc=t}_toFieldTransform(e){let t=new Rc(e.serializer,Dc(e.serializer,this.vc));return new Wc(e.path,t)}isEqual(t){return t instanceof e&&(this.vc===t.vc||Number.isNaN(this.vc)&&Number.isNaN(t.vc))}};function Kg(e,t,n,r){let i=e.V(1,t,n);Qg(`Data must be an object, but it was:`,i,r);let a=[],o=fs.empty();return fo(r,((e,r)=>{let s=t_(t,e,n);r=y(r);let c=i.wc(s);if(r instanceof Bg)a.push(s);else{let e=Yg(r,c);e!=null&&(a.push(s),o.set(s,e))}})),new Pg(o,new vo(a),i.fieldTransforms)}function qg(e,t,n,r,i,a){let o=e.V(1,t,n),s=[$g(t,r,n)],c=[i];if(a.length%2!=0)throw new M(j.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($g(t,a[e])),c.push(a[e+1]);let l=[],u=fs.empty();for(let e=s.length-1;e>=0;--e)if(!r_(l,s[e])){let t=s[e],n=c[e];n=y(n);let r=o.wc(t);if(n instanceof Bg)l.push(t);else{let e=Yg(n,r);e!=null&&(l.push(t),u.set(t,e))}}return new Pg(u,new vo(l),o.fieldTransforms)}function Jg(e,t,n,r=!1){return Yg(n,e.V(r?4:3,t))}function Yg(e,t){if(Zg(e=y(e)))return Qg(`Unsupported field value:`,t,e),Xg(e,t);if(e instanceof kg)return function(e,t){if(!Fg(t.dataSource))throw t.bc(`${e._methodName}
22() can only be used with update() and set()`);if(!t.path)throw t.bc(`${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.bc(`Nested arrays are not supported`);return function(e,t){let n=[],r=0;for(let i of e){let e=Yg(i,t.Sc(r));e??={nullValue:`NULL_VALUE`},n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if((e=y(e))===null)return{nullValue:`NULL_VALUE`};if(typeof e==`number`)return Dc(t.serializer,e);if(typeof e==`boolean`)return{booleanValue:e};if(typeof e==`string`)return{stringValue:e};if(e instanceof Date){let n=L.fromDate(e);return{timestampValue:Ll(t.serializer,n)}}if(e instanceof L){let n=new L(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:Ll(t.serializer,n)}}if(e instanceof Ag)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Eg)return{bytesValue:Rl(t.serializer,e._byteString)};if(e instanceof q){let n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.bc(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Vl(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof jg)return function(e,t){let n=e instanceof jg?e.toArray():e;return{mapValue:{fields:{[Io]:{stringValue:zo},[Bo]:{arrayValue:{values:n.map((e=>{if(typeof e!=`number`)throw t.bc(`VectorValues must only contain numeric values.`);return Tc(t.serializer,e)}))}}}}}}(e,t);if(gu(e))return e._toProto(t.serializer);throw t.bc(`Unsupported field value: ${si(e)}`)}(e,t)}function Xg(e,t){let n={};return po(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):fo(e,((e,r)=>{let i=Yg(r,t.gc(e));i!=null&&(n[e]=i)})),{mapValue:{fields:n}}}function Zg(e){return!(typeof e!=`object`||!e||e instanceof Array||e instanceof Date||e instanceof L||e instanceof Ag||e instanceof Eg||e instanceof q||e instanceof kg||e instanceof jg||gu(e))}function Qg(e,t,n){if(!Zg(n)||!oi(n)){let r=si(n);throw r===`an object`?t.bc(e+` a custom object`):t.bc(e+` `+r)}}function $g(e,t,n){if((t=y(t))instanceof Dg)return t._internalPath;if(typeof t==`string`)return t_(e,t);throw n_(`Field path arguments must be of type string or `,e,!1,void 0,n)}var e_=RegExp(`[~\\*/\\[\\]]`);function t_(e,t,n){if(t.search(e_)>=0)throw n_(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new Dg(...t.split(`.`))._internalPath}catch{throw n_(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function n_(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 M(j.INVALID_ARGUMENT,s+e+c)}function r_(e,t){return e.some((e=>e.isEqual(t)))}var i_=class{convertValue(e,t=`none`){switch(Ho(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(wo(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 O(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t=`none`){let n={};return fo(e,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertVectorValue(e){let t=e.fields?.[Bo].arrayValue?.values?.map((e=>H(e.doubleValue)));return new jg(t)}convertGeoPoint(e){return new Ag(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=Ao(e);return n==null?null:this.convertValue(n,t);case`estimate`:return this.convertTimestamp(jo(e));default:return null}}convertTimestamp(e){let t=Co(e);return new L(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=P.fromString(e);k(hu(n),9688,{name:e});let r=new Po(n.get(1),n.get(3)),i=new F(n.popFirst(5));return r.isEqual(t)||D(`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}},a_=class extends i_{constructor(e){super(),this.firestore=e}convertBytes(e){return new Eg(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);
22return new q(this.firestore,null,t)}};function o_(){return new Bg(`deleteField`)}function s_(){return new Hg(`serverTimestamp`)}function c_(...e){return new Ug(`arrayUnion`,e)}function l_(...e){return new Wg(`arrayRemove`,e)}function u_(e){return new Gg(`increment`,e)}var d_=`@firebase/firestore`,f_=`4.15.0`;function p_(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 m_=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 q(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new h_(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($g(`DocumentSnapshot.get`,e));if(t!==null)return this._userDataWriter.convertValue(t)}}},h_=class extends m_{data(){return super.data()}};function g_(e){if(e.limitType===`L`&&e.explicitOrderBy.length===0)throw new M(j.UNIMPLEMENTED,`limitToLast() queries require specifying at least one orderBy() clause`)}var __=class{},v_=class extends __{};function y_(e,t,...n){let r=[];t instanceof __&&r.push(t),r=r.concat(n),function(e){let t=e.filter((e=>e instanceof S_)).length,n=e.filter((e=>e instanceof b_)).length;if(t>1||t>0&&n>0)throw new M(j.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 b_=class e extends v_{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 z_(e._query,t),new rg(e.firestore,e.converter,ec(e._query,t))}_parse(e){let t=Rg(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 M(j.INVALID_ARGUMENT,`Invalid Query. You can't perform '${a}' queries on documentId().`);if(a===`in`||a===`not-in`){R_(o,a);let t=[];for(let n of o)t.push(L_(r,e,n));s={arrayValue:{values:t}}}else s=L_(r,e,o)}else a!==`in`&&a!==`not-in`&&a!==`array-contains-any`||R_(o,a),s=Jg(n,t,o,a===`in`||a===`not-in`);return U.create(i,a,s)}(e._query,`where`,t,e.firestore._databaseId,this._field,this._op,this._value)}};function x_(e,t,n){let r=t,i=$g(`where`,e);return b_._create(i,r,n)}var S_=class e extends __{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]:W.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)z_(n,e),n=ec(n,e)}(e._query,t),new rg(e.firestore,e.converter,ec(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type===`and`?`and`:`or`}};function C_(...e){return e.forEach((e=>B_(`or`,e))),S_._create(`or`,e)}function w_(...e){return e.forEach((e=>B_(`and`,e))),S_._create(`and`,e)}var T_=class e extends v_{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 M(j.INVALID_ARGUMENT,`Invalid query. You must not call startAt() or startAfter() before calling orderBy().`);if(e.endAt!==null)throw new M(j.INVALID_ARGUMENT,`Invalid query. You must not call endAt() or endBefore() before calling orderBy().`);return new vs(t,n)}(e._query,this._field,this._direction);return new rg(e.firestore,e.converter,tc(e._query,t))}};function E_(e,t=`asc`){let n=t,r=$g(`orderBy`,e);return T_._create(r,n)}var D_=class e extends v_{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 rg(e.firestore,e.converter,nc(e._query,this._limit,this._limitType))}};function O_(e){return ci(`limit`,e),D_._create(`limit`,e,`F`)}function k_(e){return ci(`limitToLast`,e),D_._create(`limitToLast`,e,`L`)}var A_=class e extends v_{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=I_(e,this.type,this._docOrFields,this._inclusive);return new rg(e.firestore,e.converter,rc(e._query,t))}};function j_(...e){return A_._create(`startAt`,e,!0)}function M_(...e){return A_._create(`startAfter`,e,!1)}var N_=class e extends v_{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=I_(e,this.type,this._docOrFields,this._inclusive);return new rg(e.firestore,e.converter,ic(e._query,t))}};function P_(...e){return N_._create(`endBefore`,e,!1)}function F_(...e){return N_._create(`endAt`,e,!0)}function I_(e,t,n,r){if(n[0]=y(n[0]),n[0]instanceof m_)return function(e,t,n,r,i){if(!r)throw new M(j.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);let a=[];for(let n of Zs(e))if(n.field.isKeyField())a.push(Zo(t,r.key));else{let e=r.data.field(n.field);if(ko(e))throw new M(j.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 M(j.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 hs(a,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);{let i=Rg(e.firestore);return function(e,t,n,r,i,a){let o=e.explicitOrderBy;if(i.length>o.length)throw new M(j.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];
22if(o[a].field.isKeyField()){if(typeof c!=`string`)throw new M(j.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);if(!Xs(e)&&c.indexOf(`/`)!==-1)throw new M(j.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(P.fromString(c));if(!F.isDocumentKey(n))throw new M(j.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 F(n);s.push(Zo(t,i))}else{let e=Jg(n,r,c);s.push(e)}}return new hs(s,a)}(e._query,e.firestore._databaseId,i,t,n,r)}}function L_(e,t,n){if(typeof(n=y(n))==`string`){if(n===``)throw new M(j.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.`);if(!Xs(t)&&n.indexOf(`/`)!==-1)throw new M(j.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(P.fromString(n));if(!F.isDocumentKey(r))throw new M(j.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 Zo(e,new F(r))}if(n instanceof q)return Zo(e,n._key);throw new M(j.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${si(n)}.`)}function R_(e,t){if(!Array.isArray(e)||e.length===0)throw new M(j.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function z_(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 M(j.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new M(j.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}function B_(e,t){if(!(t instanceof b_||t instanceof S_))throw new M(j.INVALID_ARGUMENT,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}function V_(e,t,n){let r;return r=e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,r}var H_=class extends i_{constructor(e){super(),this.firestore=e}convertBytes(e){return new Eg(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new q(this.firestore,null,t)}},U_=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},W_=class e extends m_{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 G_(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($g(`DocumentSnapshot.get`,e));if(n!==null)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new M(j.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)}};W_._jsonSchemaVersion=`firestore/documentSnapshot/1.0`,W_._jsonSchema={type:li(`string`,W_._jsonSchemaVersion),bundleSource:li(`string`,`DocumentSnapshot`),bundleName:li(`string`),bundle:li(`string`)};var G_=class extends W_{data(e={}){return super.data(e)}},K_=class e{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new U_(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 G_(this._firestore,this._userDataWriter,n.key,n,new U_(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 M(j.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=>{let r=new G_(e._firestore,e._userDataWriter,n.doc.key,n.doc,new U_(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 G_(e._firestore,e._userDataWriter,t.doc.key,t.doc,new U_(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:q_(t.type),doc:r,oldIndex:i,newIndex:a}}))}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new M(j.FAILED_PRECONDITION,`QuerySnapsh
22ot.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=Gr.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 q_(e){switch(e){case 0:return`added`;case 2:case 3:return`modified`;case 1:return`removed`;default:return O(61501,{type:e})}}function J_(e,t){return e instanceof W_&&t instanceof W_?e._firestore===t._firestore&&e._key.isEqual(t._key)&&(e._document===null?t._document===null:e._document.isEqual(t._document))&&e._converter===t._converter:e instanceof K_&&t instanceof K_&&e._firestore===t._firestore&&lg(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)}K_._jsonSchemaVersion=`firestore/querySnapshot/1.0`,K_._jsonSchema={type:li(`string`,K_._jsonSchemaVersion),bundleSource:li(`string`,`QuerySnapshot`),bundleName:li(`string`),bundle:li(`string`)};var Y_={maxAttempts:5},X_=class{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=Rg(e)}set(e,t,n){this._verifyNotCommitted();let r=Z_(e,this._firestore),i=V_(r.converter,t,n),a=zg(this._dataReader,`WriteBatch.set`,r._key,i,r.converter!==null,n);return this._mutations.push(a.toMutation(r._key,qc.none())),this}update(e,t,n,...r){this._verifyNotCommitted();let i=Z_(e,this._firestore),a;return a=typeof(t=y(t))==`string`||t instanceof Dg?qg(this._dataReader,`WriteBatch.update`,i._key,t,n,r):Kg(this._dataReader,`WriteBatch.update`,i._key,t),this._mutations.push(a.toMutation(i._key,qc.exists(!0))),this}delete(e){this._verifyNotCommitted();let t=Z_(e,this._firestore);return this._mutations=this._mutations.concat(new ol(t._key,qc.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 M(j.FAILED_PRECONDITION,`A write batch can no longer be used after commit() has been called.`)}};function Z_(e,t){if((e=y(e)).firestore!==t)throw new M(j.INVALID_ARGUMENT,`Provided document reference is from a different Firestore instance.`);return e}var Q_=class{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=Rg(e)}get(e){let t=Z_(e,this._firestore),n=new H_(this._firestore);return this._transaction.lookup([t._key]).then((e=>{if(!e||e.length!==1)return O(24041);let r=e[0];if(r.isFoundDocument())return new m_(this._firestore,n,r.key,r,t.converter);if(r.isNoDocument())return new m_(this._firestore,n,t._key,null,t.converter);throw O(18433,{doc:r})}))}set(e,t,n){let r=Z_(e,this._firestore),i=V_(r.converter,t,n),a=zg(this._dataReader,`Transaction.set`,r._key,i,r.converter!==null,n);return this._transaction.set(r._key,a),this}update(e,t,n,...r){let i=Z_(e,this._firestore),a;return a=typeof(t=y(t))==`string`||t instanceof Dg?qg(this._dataReader,`Transaction.update`,i._key,t,n,r):Kg(this._dataReader,`Transaction.update`,i._key,t),this._transaction.update(i._key,a),this}delete(e){let t=Z_(e,this._firestore);return this._transaction.delete(t._key),this}},$_=class extends Q_{constructor(e,t){super(e,t),this._firestore=e}get(e){let t=Z_(e,this._firestore),n=new a_(this._firestore);return super.get(e).then((e=>new W_(this._firestore,n,t._key,e._document,new U_(!1,!1),t.converter)))}};function ev(e,t,n){e=I(e,J);let r={...Y_,...n};return(function(e){if(e.maxAttempts<1)throw new M(j.INVALID_ARGUMENT,`Max attempts must be at least 1`)})(r),Gh(hg(e),(n=>t(new $_(e,n))),r)}function tv(e){e=I(e,q);let t=I(e.firestore,J);return Bh(hg(t),e._key).then((n=>mv(t,e,n)))}function nv(e){e=I(e,q);let t=I(e.firestore,J),n=hg(t),r=new a_(t);return zh(n,e._key).then((n=>new W_(t,r,e._key,n,new U_(n!==null&&n.hasLocalMutations,!0),e.converter)))}function rv(e){e=I(e,q);let t=I(e.firestore,J);return Bh(hg(t),e._key,{source:`server`}).then((n=>mv(t,e,n)))}function iv(e){e=I(e,rg);let t=I(e.firestore,J),n=hg(t),r=new a_(t);return g_(e._query),Hh(n,e._query).then((n=>new K_(t,r,e,n)))}function av(e){e=I(e,rg);let t=I(e.firestore,J),n=hg(t),r=new a_(t);return Vh(n,e._query).then((n=>new K_(t,r,e,n)))}function ov(e){e=I(e,rg);let t=I(e.firestore,J),n=hg(t),r=new a_(t);return Hh(n,e._query,{source:`server`}).then((n=>new K_(t,r,e,n)))}function sv(e,t,n){e=I(e,q);let r=I(e.firestore,J),i=V_(e.converter,t,n);return pv(r,[zg(Rg(r),`setDoc`,e._key,i,e.converter!==null,n).toMutation(e._key,q
22c.none())])}function cv(e,t,n,...r){e=I(e,q);let i=I(e.firestore,J),a=Rg(i),o;return o=typeof(t=y(t))==`string`||t instanceof Dg?qg(a,`updateDoc`,e._key,t,n,r):Kg(a,`updateDoc`,e._key,t),pv(i,[o.toMutation(e._key,qc.exists(!0))])}function lv(e){return pv(I(e.firestore,J),[new ol(e._key,qc.none())])}function uv(e,t){let n=I(e.firestore,J),r=sg(e),i=V_(e.converter,t);return pv(n,[zg(Rg(e.firestore),`addDoc`,r._key,i,e.converter!==null,{}).toMutation(r._key,qc.exists(!1))]).then((()=>r))}function dv(e,...t){e=y(e);let n={includeMetadataChanges:!1,source:`default`},r=0;typeof t[r]!=`object`||p_(t[r])||(n=t[r++]);let i={includeMetadataChanges:n.includeMetadataChanges,source:n.source};if(p_(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 q)o=I(e.firestore,J),s=qs(e._key.path),a={next:n=>{t[r]&&t[r](mv(o,e,n))},error:t[r+1],complete:t[r+2]};else{let n=I(e,rg);o=I(n.firestore,J),s=n._query;let i=new a_(o);a={next:e=>{t[r]&&t[r](new K_(o,i,n,e))},error:t[r+1],complete:t[r+2]},g_(e._query)}return Rh(hg(o),s,i,a)}function fv(e,t){return e=I(e,J),Wh(hg(e),p_(t)?t:{next:t})}function pv(e,t){return Uh(hg(e),t)}function mv(e,t,n){let r=n.docs.get(t._key);return new W_(e,new a_(e),t._key,r,new U_(n.hasPendingWrites,n.fromCache),t.converter)}function hv(e){return e=I(e,J),hg(e),new X_(e,(t=>pv(e,t)))}(function(e,t=!0){Dr(An),xn(new b(`firestore`,((e,{instanceIdentifier:n,options:r})=>{let i=e.getProvider(`app`).getImmediate(),a=new J(new zr(e.getProvider(`auth-internal`)),new Ur(i,e.getProvider(`app-check-internal`)),Fo(i,n),i);return r={useFetchStreams:t,...r},a._setSettings(r),a}),`PUBLIC`).setMultipleInstances(!0)),T(d_,f_,e),T(d_,f_,`esm2020`)})();var gv=`@firebase/firestore-compat`,_v=`0.4.10`;function vv(e,t){if(t===void 0)return{merge:!1};if(t.mergeFields!==void 0&&t.merge!==void 0)throw new M(`invalid-argument`,`Invalid options passed to function ${e}(): You cannot specify both "merge" and "mergeFields".`);return t}function yv(){if(typeof Uint8Array>`u`)throw new M(`unimplemented`,`Uint8Arrays are not available in this environment.`)}function bv(){if(!bo())throw new M(`unimplemented`,`Blobs are unavailable in Firestore in this environment.`)}var xv=class e{constructor(e){this._delegate=e}static fromBase64String(t){return bv(),new e(Eg.fromBase64String(t))}static fromUint8Array(t){return yv(),new e(Eg.fromUint8Array(t))}toBase64(){return bv(),this._delegate.toBase64()}toUint8Array(){return yv(),this._delegate.toUint8Array()}isEqual(e){return this._delegate.isEqual(e._delegate)}toString(){return`Blob(base64: `+this.toBase64()+`)`}};function Sv(e){return Cv(e,[`next`,`error`,`complete`])}function Cv(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}var wv=class{enableIndexedDbPersistence(e,t){return _g(e._delegate,{forceOwnership:t})}enableMultiTabIndexedDbPersistence(e){return vg(e._delegate)}clearIndexedDbPersistence(e){return bg(e._delegate)}},Tv=class{constructor(e,t,n){this._delegate=t,this._persistenceProvider=n,this.INTERNAL={delete:()=>this.terminate()},e instanceof Po||(this._appCompat=e)}get _databaseId(){return this._delegate._databaseId}settings(e){let t=this._delegate._getSettings();!e.merge&&t.host!==e.host&&jr(`You are overriding the original host. If you did not intend to override your settings, use {merge: true}.`),e.merge&&(e={...t,...e},delete e.merge),this._delegate._setSettings(e)}useEmulator(e,t,n={}){ng(this._delegate,e,t,n)}enableNetwork(){return Sg(this._delegate)}disableNetwork(){return Cg(this._delegate)}enablePersistence(e){let t=!1,n=!1;return e&&(t=!!e.synchronizeTabs,n=!!e.experimentalForceOwningTab,ri(`synchronizeTabs`,t,`experimentalForceOwningTab`,n)),t?this._persistenceProvider.enableMultiTabIndexedDbPersistence(this):this._persistenceProvider.enableIndexedDbPersistence(this,n)}clearPersistence(){return this._persistenceProvider.clearIndexedDbPersistence(this)}terminate(){return this._appCompat&&(this._appCompat._removeServiceInstance(`firestore-compat`),this._appCompat._removeServiceInstance(`firestore`)),this._delegate._delete()}waitForPendingWrites(){return xg(this._delegate)}onSnapshotsInSync(e){return fv(this._delegate,e)}get app(){if(!this._appCompat)throw new M(`failed-precondition`,`Firestore was not initialized using the Firebase SDK. 'app' is not available`);return this._appCompat}collection(e){try{return new Bv(this,ag(this._delegate,e))}catch(e){throw Mv(e,`collection()`,`Firestore.collection()`)}}doc(e){try{return new jv(this,sg(this._delegate,e))}catch(e){throw Mv(e,`doc()`,`Firestore.doc()`)}}collectionGroup(e){try{return new Lv(this,og(this._delegate,e))}catch(e){throw Mv(e,`collectionGroup()`,`Firestore.collectionGroup()`)}}runTransaction(e){return ev(this._delegate,t=>e(new Ov(this,t)))}batch(){return hg(this._delegate),new kv(new X_(this._delegate,e=>pv(this._delegate,e)))}loadBundle(e){return wg(this._delegate,e)}namedQuery(e){return Tg(this._delegate,e).then(e=>e?new Lv(this,e):null)}},Ev=class extends i_{constructor(e){super(),this.firestore=e}convertBytes(e){return new xv(new Eg(e))}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);
22return jv.forKey(t,this.firestore,null)}};function Dv(e){Ar(e)}var Ov=class{constructor(e,t){this._firestore=e,this._delegate=t,this._userDataWriter=new Ev(e)}get(e){let t=Vv(e);return this._delegate.get(t).then(e=>new Fv(this._firestore,new W_(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,t.converter)))}set(e,t,n){let r=Vv(e);return n?(vv(`Transaction.set`,n),this._delegate.set(r,t,n)):this._delegate.set(r,t),this}update(e,t,n,...r){let i=Vv(e);return arguments.length===2?this._delegate.update(i,t):this._delegate.update(i,t,n,...r),this}delete(e){let t=Vv(e);return this._delegate.delete(t),this}},kv=class{constructor(e){this._delegate=e}set(e,t,n){let r=Vv(e);return n?(vv(`WriteBatch.set`,n),this._delegate.set(r,t,n)):this._delegate.set(r,t),this}update(e,t,n,...r){let i=Vv(e);return arguments.length===2?this._delegate.update(i,t):this._delegate.update(i,t,n,...r),this}delete(e){let t=Vv(e);return this._delegate.delete(t),this}commit(){return this._delegate.commit()}},Av=class e{constructor(e,t,n){this._firestore=e,this._userDataWriter=t,this._delegate=n}fromFirestore(e,t){let n=new G_(this._firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,null);return this._delegate.fromFirestore(new Iv(this._firestore,n),t??{})}toFirestore(e,t){return t?this._delegate.toFirestore(e,t):this._delegate.toFirestore(e)}static getInstance(t,n){let r=e.INSTANCES,i=r.get(t);i||(i=new WeakMap,r.set(t,i));let a=i.get(n);return a||(a=new e(t,new Ev(t),n),i.set(n,a)),a}};Av.INSTANCES=new WeakMap;var jv=class e{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new Ev(e)}static forPath(t,n,r){if(t.length%2!=0)throw new M(`invalid-argument`,`Invalid document reference. Document references must have an even number of segments, but ${t.canonicalString()} has ${t.length}`);return new e(n,new q(n._delegate,r,new F(t)))}static forKey(t,n,r){return new e(n,new q(n._delegate,r,t))}get id(){return this._delegate.id}get parent(){return new Bv(this.firestore,this._delegate.parent)}get path(){return this._delegate.path}collection(e){try{return new Bv(this.firestore,ag(this._delegate,e))}catch(e){throw Mv(e,`collection()`,`DocumentReference.collection()`)}}isEqual(e){return e=y(e),e instanceof q?cg(this._delegate,e):!1}set(e,t){t=vv(`DocumentReference.set`,t);try{return t?sv(this._delegate,e,t):sv(this._delegate,e)}catch(e){throw Mv(e,`setDoc()`,`DocumentReference.set()`)}}update(e,t,...n){try{return arguments.length===1?cv(this._delegate,e):cv(this._delegate,e,t,...n)}catch(e){throw Mv(e,`updateDoc()`,`DocumentReference.update()`)}}delete(){return lv(this._delegate)}onSnapshot(...e){let t=Nv(e),n=Pv(e,e=>new Fv(this.firestore,new W_(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)));return dv(this._delegate,t,n)}get(e){let t;return t=e?.source===`cache`?nv(this._delegate):e?.source===`server`?rv(this._delegate):tv(this._delegate),t.then(e=>new Fv(this.firestore,new W_(this.firestore._delegate,this._userDataWriter,e._key,e._document,e.metadata,this._delegate.converter)))}withConverter(t){return new e(this.firestore,t?this._delegate.withConverter(Av.getInstance(this.firestore,t)):this._delegate.withConverter(null))}};function Mv(e,t,n){return e.message=e.message.replace(t,n),e}function Nv(e){for(let t of e)if(typeof t==`object`&&!Sv(t))return t;return{}}function Pv(e,t){let n;return n=Sv(e[0])?e[0]:Sv(e[1])?e[1]:typeof e[0]==`function`?{next:e[0],error:e[1],complete:e[2]}:{next:e[1],error:e[2],complete:e[3]},{next:e=>{n.next&&n.next(t(e))},error:n.error?.bind(n),complete:n.complete?.bind(n)}}var Fv=class{constructor(e,t){this._firestore=e,this._delegate=t}get ref(){return new jv(this._firestore,this._delegate.ref)}get id(){return this._delegate.id}get metadata(){return this._delegate.metadata}get exists(){return this._delegate.exists()}data(e){return this._delegate.data(e)}get(e,t){return this._delegate.get(e,t)}isEqual(e){return J_(this._delegate,e._delegate)}},Iv=class extends Fv{data(e){let t=this._delegate.data(e);return this._delegate._converter||Pr(t!==void 0,`Document in a QueryDocumentSnapshot should exist`),t}},Lv=class e{constructor(e,t){this.firestore=e,this._delegate=t,this._userDataWriter=new Ev(e)}where(t,n,r){try{return new e(this.firestore,y_(this._delegate,x_(t,n,r)))}catch(e){throw Mv(e,/(orderBy|where)\(\)/,`Query.$1()`)}}orderBy(t,n){try{return new e(this.firestore,y_(this._delegate,E_(t,n)))}catch(e){throw Mv(e,/(orderBy|where)\(\)/,`Query.$1()`)}}limit(t){try{return new e(this.firestore,y_(this._delegate,O_(t)))}catch(e){throw Mv(e,`limit()`,`Query.limit()`)}}limitToLast(t){try{return new e(this.firestore,y_(this._delegate,k_(t)))}catch(e){throw Mv(e,`limitToLast()`,`Query.limitToLast()`)}}startAt(...t){try{return new e(this.firestore,y_(this._delegate,j_(...t)))}catch(e){throw Mv(e,`startAt()`,`Query.startAt()`)}}startAfter(...t){try{return new e(this.firestore,y_(this._delegate,M_(...t)))}catch(e){throw Mv(e,`startAfter()`,`Query.startAfter()`)}}endBefore(...t){try{return new e(this.firestore,y_(this._delegate,P_(...t)))}catch(e){throw Mv(e,`endBefore()`,`Query.endBefore()`)}}endAt(...t){try{return new e(this.firestore,y_(this._delegate,F_(...t)))}catch(e){throw Mv(e,`endAt()`,`Query.endAt()`)}}isEqual(e){return lg(this._delegate,e._delegate)}get(e){let t;return t=e?.source===`cache`?av(this._delegate):e?.source===`server`?ov(this._delegate):iv(this._delegate),t.then(e=>
22new zv(this.firestore,new K_(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)))}onSnapshot(...e){let t=Nv(e),n=Pv(e,e=>new zv(this.firestore,new K_(this.firestore._delegate,this._userDataWriter,this._delegate,e._snapshot)));return dv(this._delegate,t,n)}withConverter(t){return new e(this.firestore,t?this._delegate.withConverter(Av.getInstance(this.firestore,t)):this._delegate.withConverter(null))}},Rv=class{constructor(e,t){this._firestore=e,this._delegate=t}get type(){return this._delegate.type}get doc(){return new Iv(this._firestore,this._delegate.doc)}get oldIndex(){return this._delegate.oldIndex}get newIndex(){return this._delegate.newIndex}},zv=class{constructor(e,t){this._firestore=e,this._delegate=t}get query(){return new Lv(this._firestore,this._delegate.query)}get metadata(){return this._delegate.metadata}get size(){return this._delegate.size}get empty(){return this._delegate.empty}get docs(){return this._delegate.docs.map(e=>new Iv(this._firestore,e))}docChanges(e){return this._delegate.docChanges(e).map(e=>new Rv(this._firestore,e))}forEach(e,t){this._delegate.forEach(n=>{e.call(t,new Iv(this._firestore,n))})}isEqual(e){return J_(this._delegate,e._delegate)}},Bv=class e extends Lv{constructor(e,t){super(e,t),this.firestore=e,this._delegate=t}get id(){return this._delegate.id}get path(){return this._delegate.path}get parent(){let e=this._delegate.parent;return e?new jv(this.firestore,e):null}doc(e){try{return e===void 0?new jv(this.firestore,sg(this._delegate)):new jv(this.firestore,sg(this._delegate,e))}catch(e){throw Mv(e,`doc()`,`CollectionReference.doc()`)}}add(e){return uv(this._delegate,e).then(e=>new jv(this.firestore,e))}isEqual(e){return cg(this._delegate,e._delegate)}withConverter(t){return new e(this.firestore,t?this._delegate.withConverter(Av.getInstance(this.firestore,t)):this._delegate.withConverter(null))}};function Vv(e){return I(e,q)}var Hv={Firestore:Tv,GeoPoint:Ag,Timestamp:L,Blob:xv,Transaction:Ov,WriteBatch:kv,DocumentReference:jv,DocumentSnapshot:Fv,Query:Lv,QueryDocumentSnapshot:Iv,QuerySnapshot:zv,CollectionReference:Bv,FieldPath:class e{constructor(...e){this._delegate=new Dg(...e)}static documentId(){return new e(ti.keyField().canonicalString())}isEqual(e){return e=y(e),e instanceof Dg?this._delegate._internalPath.isEqual(e._internalPath):!1}},FieldValue:class e{static serverTimestamp(){let t=s_();return t._methodName=`FieldValue.serverTimestamp`,new e(t)}static delete(){let t=o_();return t._methodName=`FieldValue.delete`,new e(t)}static arrayUnion(...t){let n=c_(...t);return n._methodName=`FieldValue.arrayUnion`,new e(n)}static arrayRemove(...t){let n=l_(...t);return n._methodName=`FieldValue.arrayRemove`,new e(n)}static increment(t){let n=u_(t);return n._methodName=`FieldValue.increment`,new e(n)}constructor(e){this._delegate=e}isEqual(e){return this._delegate.isEqual(e._delegate)}},setLogLevel:Dv,CACHE_SIZE_UNLIMITED:-1};function Uv(e,t){e.INTERNAL.registerComponent(new b(`firestore-compat`,e=>t(e.getProvider(`app-compat`).getImmediate(),e.getProvider(`firestore`).getImmediate()),`PUBLIC`).setServiceProps({...Hv}))}function Wv(e){Uv(e,(e,t)=>new Tv(e,t,new wv)),e.registerVersion(gv,_v)}Wv(ur);var Gv={FACEBOOK:`facebook.com`,GITHUB:`github.com`,GOOGLE:`google.com`,PASSWORD:`password`,PHONE:`phone`,TWITTER:`twitter.com`},Kv={EMAIL_SIGNIN:`EMAIL_SIGNIN`,PASSWORD_RESET:`PASSWORD_RESET`,RECOVER_EMAIL:`RECOVER_EMAIL`,REVERT_SECOND_FACTOR_ADDITION:`REVERT_SECOND_FACTOR_ADDITION`,VERIFY_AND_CHANGE_EMAIL:`VERIFY_AND_CHANGE_EMAIL`,VERIFY_EMAIL:`VERIFY_EMAIL`};function qv(){return{"admin-restricted-operation":`This operation is restricted to administrators only.`,"argument-error":``,"app-not-authorized":`This app, identified by the domain where it's hosted, is not authorized to use Firebase Authentication with the provided API key. Review your key configuration in the Google API console.`,"app-not-installed":`The requested mobile application corresponding to the identifier (Android package name or iOS bundle ID) provided is not installed on this device.`,"captcha-check-failed":`The reCAPTCHA response token provided is either invalid, expired, already used or the domain associated with it does not match the list of whitelisted domains.`,"code-expired":`The SMS code has expired. Please re-send the verification code to try again.`,"cordova-not-ready":`Cordova framework is not ready.`,"cors-unsupported":`This browser is not supported.`,"credential-already-in-use":`This credential is already associated with a different user account.`,"custom-token-mismatch":`The custom token corresponds to a different audience.`,"requires-recent-login":`This operation is sensitive and requires recent authentication. Log in again before retrying this request.`,"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.","dynamic-link-not-activated":`Please activate Dynamic Links in the Firebase Console and agree to the terms and conditions.`,"email-change-needs-verification":`Multi-factor users must al
22ways have a verified email.`,"email-already-in-use":`The email address is already in use by another account.`,"emulator-config-failed":`Auth instance has already been used to make a network call. Auth can no longer be configured to use the emulator. Try calling "connectAuthEmulator()" sooner.`,"expired-action-code":`The action code has expired.`,"cancelled-popup-request":`This operation has been cancelled due to another conflicting popup being opened.`,"internal-error":`An internal AuthError has occurred.`,"invalid-app-credential":`The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.`,"invalid-app-id":`The mobile app identifier is not registered for the current project.`,"invalid-user-token":`This user's credential isn't valid for this project. This can happen if the user's token has been tampered with, or if the user isn't for the project associated with this API key.`,"invalid-auth-event":`An internal AuthError has occurred.`,"invalid-verification-code":`The SMS verification code used to create the phone auth credential is invalid. Please resend the verification code sms and be sure to use the verification code provided by the user.`,"invalid-continue-uri":`The continue URL provided in the request is invalid.`,"invalid-cordova-configuration":`The following Cordova plugins must be installed to enable OAuth sign-in: cordova-plugin-buildinfo, cordova-universal-links-plugin, cordova-plugin-browsertab, cordova-plugin-inappbrowser and cordova-plugin-customurlscheme.`,"invalid-custom-token":`The custom token format is incorrect. Please check the documentation.`,"invalid-dynamic-link-domain":`The provided dynamic link domain is not configured or authorized for the current project.`,"invalid-email":`The email address is badly formatted.`,"invalid-emulator-scheme":`Emulator URL must start with a valid scheme (http:// or https://).`,"invalid-api-key":`Your API key is invalid, please check you have copied it correctly.`,"invalid-cert-hash":`The SHA-1 certificate hash provided is invalid.`,"invalid-credential":`The supplied auth credential is incorrect, malformed or has expired.`,"invalid-message-payload":`The email template corresponding to this action contains invalid characters in its message. Please fix by going to the Auth email templates section in the Firebase Console.`,"invalid-multi-factor-session":`The request does not contain a valid proof of first factor successful sign-in.`,"invalid-oauth-provider":`EmailAuthProvider is not supported for this operation. This operation only supports OAuth providers.`,"invalid-oauth-client-id":`The OAuth client ID provided is either invalid or does not match the specified API key.`,"unauthorized-domain":`This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.`,"invalid-action-code":`The action code is invalid. This can happen if the code is malformed, expired, or has already been used.`,"wrong-password":`The password is invalid or the user does not have a password.`,"invalid-persistence-type":`The specified persistence type is invalid. It can only be local, session or none.`,"invalid-phone-number":`The format of the phone number provided is incorrect. Please enter the phone number in a format that can be parsed into E.164 format. E.164 phone numbers are written in the format [+][country code][subscriber number including area code].`,"invalid-provider-id":`The specified provider ID is invali
22d.`,"invalid-recipient-email":`The email corresponding to this action failed to send as the provided recipient email address is invalid.`,"invalid-sender":`The email template corresponding to this action contains an invalid sender email or name. Please fix by going to the Auth email templates section in the Firebase Console.`,"invalid-verification-id":`The verification ID used to create the phone auth credential is invalid.`,"invalid-tenant-id":`The Auth instance's tenant ID is invalid.`,"login-blocked":`Login blocked by user-provided method: {$originalMessage}`,"missing-android-pkg-name":`An Android Package Name must be provided if the Android App is required to be installed.`,"auth-domain-config-required":`Be sure to include authDomain when calling firebase.initializeApp(), by following the instructions in the Firebase console.`,"missing-app-credential":`The phone verification request is missing an application verifier assertion. A reCAPTCHA response token needs to be provided.`,"missing-verification-code":`The phone auth credential was created with an empty SMS verification code.`,"missing-continue-uri":`A continue URL must be provided in the request.`,"missing-iframe-start":`An internal AuthError has occurred.`,"missing-ios-bundle-id":`An iOS Bundle ID must be provided if an App Store ID is provided.`,"missing-or-invalid-nonce":`The request does not contain a valid nonce. This can occur if the SHA-256 hash of the provided raw nonce does not match the hashed nonce in the ID token payload.`,"missing-password":`A non-empty password must be provided`,"missing-multi-factor-info":`No second factor identifier is provided.`,"missing-multi-factor-session":`The request is missing proof of first factor successful sign-in.`,"missing-phone-number":`To send verification codes, provide a phone number for the recipient.`,"missing-verification-id":`The phone auth credential was created with an empty verification ID.`,"app-deleted":`This instance of FirebaseApp has been deleted.`,"multi-factor-info-not-found":`The user does not have a second factor matching the identifier provided.`,"multi-factor-auth-required":`Proof of ownership of a second factor is required to complete sign-in.`,"account-exists-with-different-credential":`An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.`,"network-request-failed":`A network AuthError (such as timeout, interrupted connection or unreachable host) has occurred.`,"no-auth-event":`An internal AuthError has occurred.`,"no-such-provider":`User was not linked to an account with the given provider.`,"null-user":`A null user object was provided as the argument for an operation which requires a non-null user object.`,"operation-not-allowed":`The given sign-in provider is disabled for this Firebase project. Enable it in the Firebase console, under the sign-in method tab of the Auth section.`,"operation-not-supported-in-this-environment":`This operation is not supported in the environment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled.`,"popup-blocked":`Unable to establish a connection with the popup. It may have been blocked by the browser.`,"popup-closed-by-user":`The popup has been closed by the user before finalizing the operation.`,"provider-already-linked":`User can only be linked to one identity for the given provider.`,"quota-exceeded":`The project's quota for this operation has been exceeded.`,"redirect-cancelled-by-user":`The redirect operation has been cancelled by the user before finalizing.`,"redirect-operation-pending":`A redirect sign-in operation is already pending.`,"rejected-credential":`The request contains malformed or mismatching credentials.`,"second-factor-already-in-use":`The second factor is already enrolled on this account.`,"maximum-second-factor-count-exceeded":`The maximum allowed number of second factors on a user has been exceeded.`,"tenant-id-mismatch":`The provided tenant ID does not match the Auth instance's tenant ID`,timeout:`The operation has timed out.`,"user-token-expired":`The user's credential is no longer valid. The user must sign in again.`,"too-many-requests":`We have blocked all requests from this device due to unusual activity. Try again later.`,"unauthorized-continue-uri":`The domain of the continue URL is not whitelisted. Please whitelist the domain in the Firebase console.`,"unsupported-first-factor":`Enrolling a second factor or signing in with a multi-factor account requires sign-in with a supported first factor.`,"unsupported-persistence-type":`The current environment does not support the specified persistence type.`,"unsupported-tenant-operation":`This operation is not supported in a multi-tenant context.`,"unverified-email":`The operation requires a verified email.`,"user-cancelled":`The user did not grant your application the permissions it requested.`,"user-not-found":`There is no user record corresponding to this identifier. The user may have been deleted.`,"user-disabled":`The user account has been disabled by an administrator.`,"user-mismatch":`The supplied credentials do not correspond to the previously signed in user.`,"user-signed-out":``,"weak-password":`The password must be 6 characters long or more.`,"web-storage-unsupported":`This browser is not supported or 3rd party cookies and data may be disabled.`,"already-initialized":`initializeAuth() has already been called with different options. To avoid this error, call initializeAuth() with the same options as when it was originally called, or call getAuth() to return the already initialized instance.`,"missing-rec
22aptcha-token":`The reCAPTCHA token is missing when sending request to the backend.`,"invalid-recaptcha-token":`The reCAPTCHA token is invalid when sending request to the backend.`,"invalid-recaptcha-action":`The reCAPTCHA action is invalid when sending request to the backend.`,"recaptcha-not-enabled":`reCAPTCHA Enterprise integration is not enabled for this project.`,"missing-client-type":`The reCAPTCHA client type is missing when sending request to the backend.`,"missing-recaptcha-version":`The reCAPTCHA version is missing when sending request to the backend.`,"invalid-req-type":`Invalid request parameters.`,"invalid-recaptcha-version":`The reCAPTCHA version is invalid when sending request to the backend.`,"unsupported-password-policy-schema-version":`The password policy received from the backend uses a schema version that is not supported by this version of the Firebase SDK.`,"password-does-not-meet-requirements":`The password does not meet the requirements.`,"invalid-hosting-link-domain":"The provided Hosting link domain is not configured in Firebase Hosting or is not owned by the current project. This cannot be a default Hosting domain (`web.app` or `firebaseapp.com`)."}}function Jv(){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 Yv=qv,Xv=Jv,Zv=new Ae(`auth`,`Firebase`,Jv()),Qv=new lt(`@firebase/auth`);function $v(e,...t){Qv.logLevel<=x.WARN&&Qv.warn(`Auth (${An}): ${e}`,...t)}function ey(e,...t){Qv.logLevel<=x.ERROR&&Qv.error(`Auth (${An}): ${e}`,...t)}function ty(e,...t){throw oy(e,...t)}function ny(e,...t){return oy(e,...t)}function ry(e,t,n){return new Ae(`auth`,`Firebase`,{...Xv(),[t]:n}).create(t,{appName:e.name})}function iy(e){return ry(e,`operation-not-supported-in-this-environment`,`Operations that alter the current user are not supported in conjunction with FirebaseServerApp`)}function ay(e,t,n){let r=n;if(!(t instanceof r))throw r.name!==t.constructor.name&&ty(e,`argument-error`),ry(e,`argument-error`,`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function oy(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 Zv.create(e,...t)}function Y(e,t,...n){if(!e)throw oy(t,...n)}function sy(e){let t=`INTERNAL ASSERTION FAILED: `+e;throw ey(t),Error(t)}function cy(e,t){e||sy(t)}function ly(){return typeof self<`u`&&self.location?.href||``}function uy(){return dy()===`http:`||dy()===`https:`}function dy(){return typeof self<`u`&&self.location?.protocol||null}function fy(){return typeof navigator<`u`&&navigator&&`onLine`in navigator&&typeof navigator.onLine==`boolean`&&(uy()||be()||`connection`in navigator)?navigator.onLine:!0}function py(){if(typeof navigator>`u`)return null;let e=navigator;return e.languages&&e.languages[0]||e.language||null}var my=class{constructor(e,t){this.shortDelay=e,this.longDelay=t,cy(t>e,`Short delay should be less than long delay!`),this.isMobile=he()||xe()}get(){return fy()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}};function hy(e,t){cy(e.emulator,`Emulator should always be set here`);let{url:n}=e.emulator;return t?`${n}${t.startsWith(`/`)?t.slice(1):t}`:n}var gy=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;sy(`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;sy(`Could not find Headers implementation, make sure you call FetchProvi
22der.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;sy(`Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill`)}},_y={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:`invali
22d-recaptcha-version`,INVALID_REQ_TYPE:`invalid-req-type`},vy=[`/v1/accounts:signInWithCustomToken`,`/v1/accounts:signInWithEmailLink`,`/v1/accounts:signInWithIdp`,`/v1/accounts:signInWithPassword`,`/v1/accounts:signInWithPhoneNumber`,`/v1/token`],yy=new my(3e4,6e4);function X(e,t){return e.tenantId&&!t.tenantId?{...t,tenantId:e.tenantId}:t}async function Z(e,t,n,r,i={}){return by(e,i,async()=>{let i={},a={};r&&(t===`GET`?a=r:i={body:JSON.stringify(r)});let o=ze({key:e.config.apiKey,...a}).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 ye()||(c.referrerPolicy=`no-referrer`),e.emulatorConfig&&Ze(e.emulatorConfig.host)&&(c.credentials=`include`),gy.fetch()(await Sy(e,e.config.apiHost,n,o),c)})}async function by(e,t,n){e._canInitEmulator=!1;let r={..._y,...t};try{let t=new wy(e),i=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();let a=await i.json();if(`needConfirmation`in a)throw Ty(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 Ty(e,`credential-already-in-use`,a);if(t===`EMAIL_EXISTS`)throw Ty(e,`email-already-in-use`,a);if(t===`USER_DISABLED`)throw Ty(e,`user-disabled`,a);let o=r[t]||t.toLowerCase().replace(/[_\s]+/g,`-`);if(n)throw ry(e,o,n);ty(e,o)}}catch(t){if(t instanceof ke)throw t;ty(e,`network-request-failed`,{message:String(t)})}}async function xy(e,t,n,r,i={}){let a=await Z(e,t,n,r,i);return`mfaPendingCredential`in a&&ty(e,`multi-factor-auth-required`,{_serverResponse:a}),a}async function Sy(e,t,n,r){let i=`${t}${n}?${r}`,a=e,o=a.config.emulator?hy(e.config,i):`${e.config.apiScheme}://${i}`;return vy.includes(n)&&(await a._persistenceManagerAvailable,a._getPersistenceType()===`COOKIE`)?a._getPersistence()._getFinalTarget(o).toString():o}function Cy(e){switch(e){case`ENFORCE`:return`ENFORCE`;case`AUDIT`:return`AUDIT`;case`OFF`:return`OFF`;default:return`ENFORCEMENT_STATE_UNSPECIFIED`}}var wy=class{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(ny(this.auth,`network-request-failed`)),yy.get())})}};function Ty(e,t,n){let r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);let i=ny(e,t,r);return i.customData._tokenResponse=n,i}function Ey(e){return e!==void 0&&e.getResponse!==void 0}function Dy(e){return e!==void 0&&e.enterprise!==void 0}var Oy=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 Cy(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 ky(e){return(await Z(e,`GET`,`/v1/recaptchaParams`)).recaptchaSiteKey||``}async function Ay(e,t){return Z(e,`GET`,`/v2/recaptchaConfig`,X(e,t))}async function jy(e,t){return Z(e,`POST`,`/v1/accounts:delete`,t)}async function My(e,t){return Z(e,`POST`,`/v1/accounts:update`,t)}async function Ny(e,t){return Z(e,`POST`,`/v1/accounts:lookup`,t)}function Py(e){if(e)try{let t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch{}}async function Fy(e,t=!1){let n=y(e),r=await n.getIdToken(t),i=Ly(r);Y(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:Py(Iy(i.auth_time)),issuedAtTime:Py(Iy(i.iat)),expirationTime:Py(Iy(i.exp)),signInProvider:o||null,signInSecondFactor:a?.sign_in_second_factor||null}}function Iy(e){return Number(e)*1e3}function Ly(e){let[t,n,r]=e.split(`.`);if(t===void 0||n===void 0||r===void 0)return ey(`JWT malformed, contained fewer than 3 sections`),null;try{let e=te(n);return e?JSON.parse(e):(ey(`Failed to decode base64 JWT payload`),null)}catch(e){return ey(`Caught error parsing JWT payload as JSON`,e?.toString()),null}}function Ry(e){let t=Ly(e);return Y(t,`internal-error`),Y(t.exp!==void 0,`internal-error`),Y(t.iat!==void 0,`internal-error`),Number(t.exp)-Number(t.iat)}async function zy(e,t,n=!1){if(n)return t;try{return await t}catch(t){throw t instanceof ke&&By(t)&&e.auth.currentUser===e&&await e.auth.signOut(),t}}function By({code:e}){return e===`auth/user-disabled`||e===`auth/user-token-expired`}var Vy=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()}},Hy=class{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Py(this.lastLoginAt),this.creationTime=Py(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}};async function Uy(e){let t=e.auth,n=await zy(e,Ny(t,{idToken:await e.getIdToken()}));Y(n?.users.length,t,`internal-error`);let r=n.users[0];e._notifyReloadListener(r);let i=r.providerUserInfo?.length?Ky(r.providerUserInfo):[],a=Gy(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 Hy(r.createdAt,r.lastLoginAt),isAnonymous:c};Object.assign(e,l)}async function Wy(e){let t=y(e);await Uy(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}function Gy(e,t){return[...e.filter(e=>!t.some(t=>t.providerId===e.providerId)),...t]}function Ky(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 qy(e,t){let n=await by(e,{},async()=>{let n=ze({grant_type:`refresh_token`,refresh_token:t}).slice(1),{tokenApiHost:r,apiKey:i}=e.config,a=await Sy(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&&Ze(e.emulatorConfig.host)&&(s.credentials=`include`),gy.fetch()(a,s)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function Jy(e,t){return Z(e,`POST`,`/v2/accounts:revokeToken`,X(e,t))}var Yy=class e{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){Y(e.idToken,`internal-error`),Y(e.idToken!==void 0,`internal-error`),Y(e.refreshToken!==void 0,`internal-error`);
22let t=`expiresIn`in e&&e.expiresIn!==void 0?Number(e.expiresIn):Ry(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){Y(e.length!==0,`internal-error`);let t=Ry(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(Y(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 qy(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&&(Y(typeof r==`string`,`internal-error`,{appName:t}),o.refreshToken=r),i&&(Y(typeof i==`string`,`internal-error`,{appName:t}),o.accessToken=i),a&&(Y(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 sy(`not implemented`)}};function Xy(e,t){Y(typeof e==`string`||e===void 0,`internal-error`,{appName:t})}var Zy=class e{constructor({uid:e,auth:t,stsTokenManager:n,...r}){this.providerId=`firebase`,this.proactiveRefresh=new Vy(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 Hy(r.createdAt||void 0,r.lastLoginAt||void 0)}async getIdToken(e){let t=await zy(this,this.stsTokenManager.getToken(this.auth,e));return Y(t,this.auth,`internal-error`),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return Fy(this,e)}reload(){return Wy(this)}_assign(e){this!==e&&(Y(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){Y(!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 Uy(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(w(this.auth.app))return Promise.reject(iy(this.auth));let e=await this.getIdToken();return await zy(this,jy(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;Y(d&&h,t,`internal-error`);let g=Yy.fromJSON(this.name,h);Y(typeof d==`string`,t,`internal-error`),Xy(r,t.name),Xy(i,t.name),Y(typeof f==`boolean`,t,`internal-error`),Y(typeof p==`boolean`,t,`internal-error`),Xy(a,t.name),Xy(o,t.name),Xy(s,t.name),Xy(c,t.name),Xy(l,t.name),Xy(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 Yy;i.updateFromServerResponse(n);let a=new e({uid:n.localId,auth:t,stsTokenManager:i,isAnonymous:r});return await Uy(a),a}static async _fromGetAccountInfoResponse(t,n,r){let i=n.users[0];Y(i.localId!==void 0,`internal-error`);let a=i.providerUserInfo===void 0?[]:Ky(i.providerUserInfo),o=!(i.email&&i.passwordHash)&&!a?.length,s=new Yy;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 Hy(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash)&&!a?.length};return Object.assign(c,l),c}},Qy=new Map;function $y(e){cy(e instanceof Function,`Expected a class definition`);let t=Qy.get(e);return t?(cy(t instanceof e,`Instance stored in cache mismatched with class`),t):(t=new e,Qy.set(e,t),t)}var eb=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){}};eb.type=`NONE`;var tb=eb;function nb(e,t,n){return`firebase:${e}:${t}:${n}`}var rb=class e{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;let{config:r,name:i}=this.auth;this.fullUserKey=nb(this.userKey,r.apiKey,i),this.fullPersistenceKey=nb(`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 Ny(this.auth,{idToken:e}).catch(()=>void 0);return t?Zy._fromGetAccountInfoResponse(this.auth,t,e):null}return Zy._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($y(tb),t,r);let i=(await Promise.all(n.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e),a=i[0]||$y(tb),o=nb(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 Ny(t,{idToken:n}).catch(()=>void 0);if(!e)break;r=await Zy._fromGetAccountInfoResponse(t,e,n)}else r=Zy._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 ib(e){let t=e.toLowerCase();if(t.includes(`opera/`)||t.includes(`opr/`)||t.includes(`opios/`))return`Opera`;if(cb(t))return`IEMobile`;if(t.includes(`msie`)||t.includes(`trident/`))return`IE`;if(t.includes(`edge/`))return`Edge`;
22if(ab(t))return`Firefox`;if(t.includes(`silk/`))return`Silk`;if(ub(t))return`Blackberry`;if(db(t))return`Webos`;if(ob(t))return`Safari`;if((t.includes(`chrome/`)||sb(t))&&!t.includes(`edge/`))return`Chrome`;if(lb(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 ab(e=_()){return/firefox\//i.test(e)}function ob(e=_()){let t=e.toLowerCase();return t.includes(`safari/`)&&!t.includes(`chrome/`)&&!t.includes(`crios/`)&&!t.includes(`android`)}function sb(e=_()){return/crios\//i.test(e)}function cb(e=_()){return/iemobile/i.test(e)}function lb(e=_()){return/android/i.test(e)}function ub(e=_()){return/blackberry/i.test(e)}function db(e=_()){return/webos/i.test(e)}function fb(e=_()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function pb(e=_()){return/(iPad|iPhone|iPod).*OS 7_\d/i.test(e)||/(iPad|iPhone|iPod).*OS 8_\d/i.test(e)}function mb(e=_()){return fb(e)&&!!window.navigator?.standalone}function hb(){return Se()&&document.documentMode===10}function gb(e=_()){return fb(e)||lb(e)||db(e)||ub(e)||/windows phone/i.test(e)||cb(e)}function _b(e,t=[]){let n;switch(e){case`Browser`:n=ib(_());break;case`Worker`:n=`${ib(_())}-${e}`;break;default:n=e}let r=t.length?t.join(`,`):`FirebaseCore-web`;return`${n}/JsCore/${An}/${r}`}var vb=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 yb(e,t={}){return Z(e,`GET`,`/v2/passwordPolicy`,X(e,t))}var bb=6,xb=class{constructor(e){let t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??bb,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)}},Sb=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 Cb(this),this.idTokenSubscription=new Cb(this),this.beforeStateQueue=new vb(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=Zv,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=$y(t)),this._initializationPromise=this.queue(async()=>
22{if(!this._deleted&&(this.persistenceManager=await rb.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 Ny(this,{idToken:e}),n=await Zy._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(w(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 Y(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 Uy(e)}catch(e){if(e?.code!==`auth/network-request-failed`)return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=py()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(w(this.app))return Promise.reject(iy(this));let t=e?y(e):null;return t&&Y(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&&Y(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 w(this.app)?Promise.reject(iy(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return w(this.app)?Promise.reject(iy(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence($y(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 xb(await yb(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 Ae(`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)=>
22{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 Jy(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&&$y(e)||this._popupRedirectResolver;Y(t,this,`argument-error`),this.redirectPersistenceManager=await rb.create(this,[$y(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(Y(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 Y(this.persistenceManager,this,`internal-error`),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=_b(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(w(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;let e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&$v(`Error while retrieving App Check token: ${e.error}`),e?.token}};function Q(e){return y(e)}var Cb=class{constructor(e){this.auth=e,this.observer=null,this.addObserver=He(e=>this.observer=e)}get next(){return Y(this.observer,this.auth,`internal-error`),this.observer.next.bind(this.observer)}},wb={async loadJS(){throw Error(`Unable to load external scripts`)},recaptchaV2Script:``,recaptchaEnterpriseScript:``,gapiScript:``};function Tb(e){wb=e}function Eb(e){return wb.loadJS(e)}function Db(){return wb.recaptchaV2Script}function Ob(){return wb.recaptchaEnterpriseScript}function kb(){return wb.gapiScript}function Ab(e){return`__${e}${Math.floor(Math.random()*1e6)}`}var jb=500,Mb=6e4,Nb=0xe8d4a51000,Pb=class{constructor(e){this.auth=e,this.counter=Nb,this._widgets=new Map}render(e,t){let n=this.counter;return this._widgets.set(n,new Lb(e,this.auth.name,t||{})),this.counter++,n}reset(e){let t=e||Nb;this._widgets.get(t)?.delete(),this._widgets.delete(t)}getResponse(e){let t=e||Nb;return this._widgets.get(t)?.getResponse()||``}async execute(e){let t=e||Nb;return this._widgets.get(t)?.execute(),``}},Fb=class{constructor(){this.enterprise=new Ib}ready(e){e()}execute(e,t){return Promise.resolve(`token`)}render(e,t){return``}},Ib=class{ready(e){e()}execute(e,t){return Promise.resolve(`token`)}render(e,t){return``}},Lb=class{constructor(e,t,n){this.params=n,this.timerId=null,this.deleted=!1,this.responseToken=null,this.clickHandler=()=>{this.execute()};let r=typeof e==`string`?document.getElementById(e):e;Y(r,`argument-error`,{appName:t}),this.container=r,this.isVisible=this.params.size!==`invisible`,this.isVisible?this.execute():this.container.addEventListener(`click`,this.clickHandler)}getResponse(){return this.checkIfDeleted(),this.responseToken}delete(){this.checkIfDeleted(),this.deleted=!0,this.timerId&&=(clearTimeout(this.timerId),null),this.container.removeEventListener(`click`,this.clickHandler)}execute(){this.checkIfDeleted(),!this.timerId&&(this.timerId=window.setTimeout(()=>{this.responseToken=Rb(50);let{callback:e,"expired-callback":t}=this.params;if(e)try{e(this.responseToken)}catch{}this.timerId=window.setTimeout(()=>{if(this.timerId=null,this.responseToken=null,t)try{t()}catch{}this.isVisible&&this.execute()},Mb)},jb))}checkIfDeleted(){if(this.deleted)throw Error(`reCAPTCHA mock was already deleted!`)}};function Rb(e){let t=[];for(let n=0;n<e;n++)t.push(`1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`.charAt(Math.floor(Math.random()*62)));return t.join(``)}var zb=`recaptcha-enterprise`,Bb=`NO_RECAPTCHA`,Vb=class{constructor(e){this.type=zb,this.auth=Q(e)}async verify(e=`verify`,t=!1){async function n(e){if(!t){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)=>{Ay(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 Oy(r);return e.tenantId==null?e._agentRecaptchaConfig=n:e._tenantRecaptchaConfigs[e.tenantId]=n,t(n.siteKey)}}).catch(e=>{n(e)})})}function r(t,n,r){let i=window.grecaptcha;Dy(i)?i.enterprise.ready(()=>{i.enterprise.execute(t,{action:e}).then(e=>{n(e)}).catch(()=>{n(Bb)})}):r(Error(`No reCAPTCHA enterprise script loaded.`))}return this.auth.settings.appVerificationDisabledForTesting?new Fb().execute(`siteKey`,{action:`verify`}):new Promise((e,i)=>{n(this.auth).then(n=>{if(!t&&Dy(window.grecaptcha))r(n,e,i);else{if(typeof window>`u`){i(Error(`RecaptchaVerifier is only supported in browser`));return}let t=Ob();t.length!==0&&(t+=n),Eb(t).then(()=>{r(n,e,i)}).catch(e=>{i(e)})}}).catch(e=>{i(e)})})}};async function Hb(e,t,n,r=!1,i=!1){let a=new Vb(e),o;if(i)o=Bb;else try{o=await a.verify(n)}
22catch{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 Ub(e,t,n,r,i){return i===`EMAIL_PASSWORD_PROVIDER`?e._getRecaptchaConfig()?.isProviderEnabled(`EMAIL_PASSWORD_PROVIDER`)?r(e,await Hb(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 Hb(e,t,n,n===`getOobCode`))):Promise.reject(i)):i===`PHONE_PROVIDER`?e._getRecaptchaConfig()?.isProviderEnabled(`PHONE_PROVIDER`)?r(e,await Hb(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 Hb(e,t,n,!1,!0))):Promise.reject(i)):r(e,await Hb(e,t,n,!1,!0)):Promise.reject(i+` provider is not supported.`)}async function Wb(e){let t=Q(e),n=new Oy(await Ay(t,{clientType:`CLIENT_TYPE_WEB`,version:`RECAPTCHA_ENTERPRISE`}));t.tenantId==null?t._agentRecaptchaConfig=n:t._tenantRecaptchaConfigs[t.tenantId]=n,n.isAnyProviderEnabled()&&new Vb(t).verify()}function Gb(e,t){let n=Sn(e,`auth`);if(n.isInitialized()){let e=n.getImmediate();if(v(n.getOptions(),t??{}))return e;ty(e,`already-initialized`)}return n.initialize({options:t})}function Kb(e,t){let n=t?.persistence||[],r=(Array.isArray(n)?n:[n]).map($y);t?.errorMap&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,t?.popupRedirectResolver)}function qb(e,t,n){let r=Q(e);Y(/^https?:\/\//.test(t),r,`invalid-emulator-scheme`);let i=!!n?.disableWarnings,a=Jb(t),{host:o,port:s}=Yb(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){Y(r.config.emulator&&r.emulatorConfig,r,`emulator-config-failed`),Y(v(l,r.config.emulator)&&v(u,r.emulatorConfig),r,`emulator-config-failed`);return}r.config.emulator=l,r.emulatorConfig=u,r.settings.appVerificationDisabledForTesting=!0,Ze(o)?Qe(`${a}//${o}${c}`):i||Zb()}function Jb(e){let t=e.indexOf(`:`);return t<0?``:e.substr(0,t+1)}function Yb(e){let t=Jb(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:Xb(r.substr(e.length+1))}}else{let[e,t]=r.split(`:`);return{host:e,port:Xb(t)}}}function Xb(e){if(!e)return null;let t=Number(e);return isNaN(t)?null:t}function Zb(){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 Qb=class{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return sy(`not implemented`)}_getIdTokenResponse(e){return sy(`not implemented`)}_linkToIdToken(e,t){return sy(`not implemented`)}_getReauthenticationResolver(e){return sy(`not implemented`)}};async function $b(e,t){return Z(e,`POST`,`/v1/accounts:resetPassword`,X(e,t))}async function ex(e,t){return Z(e,`POST`,`/v1/accounts:update`,t)}async function tx(e,t){return Z(e,`POST`,`/v1/accounts:signUp`,t)}async function nx(e,t){return Z(e,`POST`,`/v1/accounts:update`,X(e,t))}
22async function rx(e,t){return xy(e,`POST`,`/v1/accounts:signInWithPassword`,X(e,t))}async function ix(e,t){return Z(e,`POST`,`/v1/accounts:sendOobCode`,X(e,t))}async function ax(e,t){return ix(e,t)}async function ox(e,t){return ix(e,t)}async function sx(e,t){return ix(e,t)}async function cx(e,t){return ix(e,t)}async function lx(e,t){return xy(e,`POST`,`/v1/accounts:signInWithEmailLink`,X(e,t))}async function ux(e,t){return xy(e,`POST`,`/v1/accounts:signInWithEmailLink`,X(e,t))}var dx=class e extends Qb{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 Ub(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:`CLIENT_TYPE_WEB`},`signInWithPassword`,rx,`EMAIL_PASSWORD_PROVIDER`);case`emailLink`:return lx(e,{email:this._email,oobCode:this._password});default:ty(e,`internal-error`)}}async _linkToIdToken(e,t){switch(this.signInMethod){case`password`:return Ub(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:`CLIENT_TYPE_WEB`},`signUpPassword`,tx,`EMAIL_PASSWORD_PROVIDER`);case`emailLink`:return ux(e,{idToken:t,email:this._email,oobCode:this._password});default:ty(e,`internal-error`)}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}};async function fx(e,t){return xy(e,`POST`,`/v1/accounts:signInWithIdp`,X(e,t))}var px=`http://localhost`,mx=class e extends Qb{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):ty(`argument-error`),n}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,n
22once: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 fx(e,this.buildRequest())}_linkToIdToken(e,t){let n=this.buildRequest();return n.idToken=t,fx(e,n)}_getReauthenticationResolver(e){let t=this.buildRequest();return t.autoCreate=!1,fx(e,t)}buildRequest(){let e={requestUri:px,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=ze(t)}return e}};async function hx(e,t){return Z(e,`POST`,`/v1/accounts:sendVerificationCode`,X(e,t))}async function gx(e,t){return xy(e,`POST`,`/v1/accounts:signInWithPhoneNumber`,X(e,t))}async function _x(e,t){let n=await xy(e,`POST`,`/v1/accounts:signInWithPhoneNumber`,X(e,t));if(n.temporaryProof)throw Ty(e,`account-exists-with-different-credential`,n);return n}var vx={USER_NOT_FOUND:`user-not-found`};async function yx(e,t){return xy(e,`POST`,`/v1/accounts:signInWithPhoneNumber`,X(e,{...t,operation:`REAUTH`}),vx)}var bx=class e extends Qb{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 gx(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return _x(e,{idToken:t,...this._makeVerificationRequest()})}_getReauthenticationResolver(e){return yx(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 xx(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 Sx(e){let t=Be(Ve(e)).link,n=t?Be(Ve(t)).deep_link_id:null,r=Be(Ve(e)).deep_link_id;return(r?Be(Ve(r)).link:null)||r||n||t||e}var Cx=class e{constructor(e){let t=Be(Ve(e)),n=t.apiKey??null,r=t.oobCode??null,i=xx(t.mode??null);Y(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=Sx(t);try{return new e(n)}catch{return null}}},wx=class e{constructor(){this.providerId=e.PROVIDER_ID}static credential(e,t){return dx._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){let n=Cx.parseLink(t);return Y(n,`argument-error`),dx._fromEmailAndCode(e,n.code,n.tenantId)}};wx.PROVIDER_ID=`password`,wx.EMAIL_PASSWORD_SIGN_IN_METHOD=`password`,wx.EMAIL_LINK_SIGN_IN_METHOD=`emailLink`;var Tx=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}},Ex=class extends Tx{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}
22,Dx=class e extends Ex{static credentialFromJSON(e){let t=typeof e==`string`?JSON.parse(e):e;return Y(`providerId`in t&&`signInMethod`in t,`argument-error`),mx._fromParams(t)}credential(e){return this._credential({...e,nonce:e.rawNonce})}_credential(e){return Y(e.idToken||e.accessToken,`argument-error`),mx._fromParams({...e,providerId:this.providerId,signInMethod:this.providerId})}static credentialFromResult(t){return e.oauthCredentialFromTaggedObject(t)}static credentialFromError(t){return e.oauthCredentialFromTaggedObject(t.customData||{})}static oauthCredentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;let{oauthIdToken:n,oauthAccessToken:r,oauthTokenSecret:i,pendingToken:a,nonce:o,providerId:s}=t;if(!r&&!i&&!n&&!a||!s)return null;try{return new e(s)._credential({idToken:n,accessToken:r,nonce:o,pendingToken:a})}catch{return null}}},Ox=class e extends Ex{constructor(){super(`facebook.com`)}static credential(t){return mx._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}}};Ox.FACEBOOK_SIGN_IN_METHOD=`facebook.com`,Ox.PROVIDER_ID=`facebook.com`;var kx=class e extends Ex{constructor(){super(`google.com`),this.addScope(`profile`)}static credential(t,n){return mx._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}}};kx.GOOGLE_SIGN_IN_METHOD=`google.com`,kx.PROVIDER_ID=`google.com`;var Ax=class e extends Ex{constructor(){super(`github.com`)}static credential(t){return mx._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}}};Ax.GITHUB_SIGN_IN_METHOD=`github.com`,Ax.PROVIDER_ID=`github.com`;var jx=`http://localhost`,Mx=class e extends Qb{constructor(e,t){super(e,e),this.pendingToken=t}_getIdTokenResponse(e){return fx(e,this.buildRequest())}_linkToIdToken(e,t){let n=this.buildRequest();return n.idToken=t,fx(e,n)}_getReauthenticationResolver(e){let t=this.buildRequest();return t.autoCreate=!1,fx(e,t)}toJSON(){return{signInMethod:this.signInMethod,providerId:this.providerId,pendingToken:this.pendingToken}}static fromJSON(t){let{providerId:n,signInMethod:r,pendingToken:i}=typeof t==`string`?JSON.parse(t):t;return!n||!r||!i||n!==r?null:new e(n,i)}static _create(t,n){return new e(t,n)}buildRequest(){return{requestUri:jx,returnSecureToken:!0,pendingToken:this.pendingToken}}},Nx=`saml.`,Px=class e extends Tx{constructor(e){Y(e.startsWith(Nx),`argument-error`),super(e)}static credentialFromResult(t){return e.samlCredentialFromTaggedObject(t)}static credentialFromError(t){return e.samlCredentialFromTaggedObject(t.customData||{})}static credentialFromJSON(e){let t=Mx.fromJSON(e);return Y(t,`argument-error`),t}static samlCredentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;let{pendingToken:t,providerId:n}=e;if(!t||!n)return null;try{return Mx._create(n,t)}catch{return null}}},Fx=class e extends Ex{constructor(){super(`twitter.com`)}static credential(t,n){return mx._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||{})}
22static 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}}};Fx.TWITTER_SIGN_IN_METHOD=`twitter.com`,Fx.PROVIDER_ID=`twitter.com`;async function Ix(e,t){return xy(e,`POST`,`/v1/accounts:signUp`,X(e,t))}var Lx=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 Zy._fromIdTokenResponse(t,r,i),providerId:Rx(r),_tokenResponse:r,operationType:n})}static async _forOperation(t,n,r){return await t._updateTokensIfNecessary(r,!0),new e({user:t,providerId:Rx(r),_tokenResponse:r,operationType:n})}};function Rx(e){return e.providerId?e.providerId:`phoneNumber`in e?`phone`:null}async function zx(e){if(w(e.app))return Promise.reject(iy(e));let t=Q(e);if(await t._initializationPromise,t.currentUser?.isAnonymous)return new Lx({user:t.currentUser,providerId:null,operationType:`signIn`});let n=await Ix(t,{returnSecureToken:!0}),r=await Lx._fromIdTokenResponse(t,`signIn`,n,!0);return await t._updateCurrentUser(r.user),r}var Bx=class e extends ke{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 Vx(e,t,n,r){return(t===`reauthenticate`?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(n=>{throw n.code===`auth/multi-factor-auth-required`?Bx._fromErrorAndOperation(e,n,t,r):n})}function Hx(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function Ux(e,t){let n=y(e);await Gx(!0,n,t);let{providerUserInfo:r}=await My(n.auth,{idToken:await n.getIdToken(),deleteProvider:[t]}),i=Hx(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 Wx(e,t,n=!1){let r=await zy(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return Lx._forOperation(e,`link`,r)}async function Gx(e,t,n){await Uy(t);let r=Hx(t.providerData),i=e===!1?`provider-already-linked`:`no-such-provider`;Y(r.has(n)===e,t.auth,i)}async function Kx(e,t,n=!1){let{auth:r}=e;if(w(r.app))return Promise.reject(iy(r));let i=`reauthenticate`;try{let a=await zy(e,Vx(r,i,t,e),n);Y(a.idToken,r,`internal-error`);let o=Ly(a.idToken);Y(o,r,`internal-error`);let{sub:s}=o;return Y(e.uid===s,r,`user-mismatch`),Lx._forOperation(e,i,a)}catch(e){throw e?.code===`auth/user-not-found`&&ty(r,`user-mismatch`),e}}async function qx(e,t,n=!1){if(w(e.app))return Promise.reject(iy(e));let r=`signIn`,i=await Vx(e,r,t),a=await Lx._fromIdTokenResponse(e,r,i);return n||await e._updateCurrentUser(a.user),a}async function Jx(e,t){return qx(Q(e),t)}async function Yx(e,t){let n=y(e);return await Gx(!1,n,t.providerId),Wx(n,t)}async function Xx(e,t){return Kx(y(e),t)}async function Zx(e,t){return xy(e,`POST`,`/v1/accounts:signInWithCustomToken`,X(e,t))}async function Qx(e,t){if(w(e.app))return Promise.reject(iy(e));let n=Q(e),r=await Zx(n,{token:t,returnSecureToken:!0}),i=await Lx._fromIdTokenResponse(n,`signIn`,r);return await n._updateCurrentUser(i.user),i}var $x=class{constructor(e,t){this.factorId=e,this.uid=t.mfaEnrollmentId,this.enrollmentTime=new Date(t.enrolledAt).toUTCString(),this.displayName=t.displayName}static _fromServerResponse(e,t){return`phoneInfo`in t?eS._fromServerResponse(e,t):`totpInfo`in t?tS._fromServerResponse(e,t):ty(e,`internal-error`)}},eS=class e extends $x{constructor(e){super(`phone`,e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(t,n){return new e(n)}},tS=class e extends $x{constructor(e){super(`totp`,e)}static _fromServerResponse(t,n){return new e(n)}};function nS(e,t,n){Y(n.url?.length>0,e,`invalid-continue-uri`),Y(n.dynamicLinkDomain===void 0||n.dynamicLinkDomain.length>0,e,`invalid-dynamic-link-domain`),Y(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&&(Y(n.iOS.bundleId.length>0,e,`missing-ios-bundle-id`),t.iOSBundleId=n.iOS.bundleId),n.android&&(Y(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 rS(e){let t=Q(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function iS(e,t,n){let r=Q(e),i={requestType:`PASSWORD_RESET`,email:t,clientType:`CLIENT_TYPE_WEB`};n&&nS(r,i,n),await Ub(r,i,`getOobCode`,ox,`EMAIL_PASSWORD_PROVIDER`)}async function aS(e,t,n){await $b(y(e),{oobCode:t,newPassword:n}).catch(async t=>{throw t.code===`auth/password-does-not-meet-requirements`&&rS(e),t})}async function oS(e,t){await nx(y(e),{oobCode:t})}async function sS(e,t){let n=y(e),r=await $b(n,{oobCode:t}),i=r.requestType;switch(Y(i,n,`internal-error`),i){case`EMAIL_SIGNIN`:break;case`VERIFY_AND_CHANGE_EMAIL`:Y(r.newEmail,n,`internal-error`);break;case`REVERT_SECOND_FACTOR_ADDITION`:Y(r.mfaInfo,n,`internal-error`);default:Y(r.email,n,`internal-error`)}let a=null;return r.mfaInfo&&(a=$x._fromServerResponse(Q(n),r.mfaInfo)),{data:{email:(r.requestType===`VERIFY_AND_CHANGE_EMAIL`?r.newEmail:r.email)||null,previousEmail:(r.requestType===`VERIFY_AND_CHANGE_EMAIL`?r.email:r.newEmail)||null,multiFactorInfo:a},operation:i}}async function cS(e,t){let{data:n}=await sS(y(e),t);return n.email}
22async function lS(e,t,n){if(w(e.app))return Promise.reject(iy(e));let r=Q(e),i=await Ub(r,{returnSecureToken:!0,email:t,password:n,clientType:`CLIENT_TYPE_WEB`},`signUpPassword`,Ix,`EMAIL_PASSWORD_PROVIDER`).catch(t=>{throw t.code===`auth/password-does-not-meet-requirements`&&rS(e),t}),a=await Lx._fromIdTokenResponse(r,`signIn`,i);return await r._updateCurrentUser(a.user),a}function uS(e,t,n){return w(e.app)?Promise.reject(iy(e)):Jx(y(e),wx.credential(t,n)).catch(async t=>{throw t.code===`auth/password-does-not-meet-requirements`&&rS(e),t})}async function dS(e,t,n){let r=Q(e),i={requestType:`EMAIL_SIGNIN`,email:t,clientType:`CLIENT_TYPE_WEB`};function a(e,t){Y(t.handleCodeInApp,r,`argument-error`),t&&nS(r,e,t)}a(i,n),await Ub(r,i,`getOobCode`,sx,`EMAIL_PASSWORD_PROVIDER`)}function fS(e,t){return Cx.parseLink(t)?.operation===`EMAIL_SIGNIN`}async function pS(e,t,n){if(w(e.app))return Promise.reject(iy(e));let r=y(e),i=wx.credentialWithLink(t,n||ly());return Y(i._tenantId===(r.tenantId||null),r,`tenant-id-mismatch`),Jx(r,i)}async function mS(e,t){return Z(e,`POST`,`/v1/accounts:createAuthUri`,X(e,t))}async function hS(e,t){let n={identifier:t,continueUri:uy()?ly():`http://localhost`},{signinMethods:r}=await mS(y(e),n);return r||[]}async function gS(e,t){let n=y(e),r={requestType:`VERIFY_EMAIL`,idToken:await e.getIdToken()};t&&nS(n.auth,r,t);let{email:i}=await ax(n.auth,r);i!==e.email&&await e.reload()}async function _S(e,t,n){let r=y(e),i={requestType:`VERIFY_AND_CHANGE_EMAIL`,idToken:await e.getIdToken(),newEmail:t};n&&nS(r.auth,i,n);let{email:a}=await cx(r.auth,i);a!==e.email&&await e.reload()}async function vS(e,t){return Z(e,`POST`,`/v1/accounts:update`,t)}async function yS(e,{displayName:t,photoURL:n}){if(t===void 0&&n===void 0)return;let r=y(e),i={idToken:await r.getIdToken(),displayName:t,photoUrl:n,returnSecureToken:!0},a=await zy(r,vS(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 bS(e,t){let n=y(e);return w(n.auth.app)?Promise.reject(iy(n.auth)):SS(n,t,null)}function xS(e,t){return SS(y(e),null,t)}async function SS(e,t,n){let{auth:r}=e,i={idToken:await e.getIdToken(),returnSecureToken:!0};t&&(i.email=t),n&&(i.password=n);let a=await zy(e,ex(r,i));await e._updateTokensIfNecessary(a,!0)}function CS(e){if(!e)return null;let{providerId:t}=e,n=e.rawUserInfo?JSON.parse(e.rawUserInfo):{},r=e.isNewUser||e.kind===`identitytoolkit#SignupNewUserResponse`;if(!t&&e?.idToken){let t=Ly(e.idToken)?.firebase?.sign_in_provider;if(t)return new wS(r,t!==`anonymous`&&t!==`custom`?t:null)}if(!t)return null;switch(t){case`facebook.com`:return new ES(r,n);case`github.com`:return new DS(r,n);case`google.com`:return new OS(r,n);case`twitter.com`:return new kS(r,n,e.screenName||null);case`custom`:case`anonymous`:return new wS(r,null);default:return new wS(r,t,n)}}var wS=class{constructor(e,t,n={}){this.isNewUser=e,this.providerId=t,this.profile=n}},TS=class extends wS{constructor(e,t,n,r){super(e,t,n),this.username=r}},ES=class extends wS{constructor(e,t){super(e,`facebook.com`,t)}},DS=class extends TS{constructor(e,t){super(e,`github.com`,t,typeof t?.login==`string`?t?.login:null)}},OS=class extends wS{constructor(e,t){super(e,`google.com`,t)}},kS=class extends TS{constructor(e,t,n){super(e,`twitter.com`,t,n)}};function AS(e){let{user:t,_tokenResponse:n}=e;return t.isAnonymous&&!n?{providerId:null,isNewUser:!1,profile:null}:CS(n)}function jS(e,t,n,r){return y(e).onIdTokenChanged(t,n,r)}function MS(e,t,n){return y(e).beforeAuthStateChanged(t,n)}function NS(e){return y(e).signOut()}var PS=class e{constructor(e,t,n){this.type=e,this.credential=t,this.user=n}static _fromIdtoken(t,n){return new e(`enroll`,t,n)}static _fromMfaPendingCredential(t){return new e(`signin`,t)}toJSON(){return{multiFactorSession:{[this.type===`enroll`?`idToken`:`pendingCredential`]:this.credential}}}static fromJSON(t){if(t?.multiFactorSession){if(t.multiFactorSession?.pendingCredential)return e._fromMfaPendingCredential(t.multiFactorSession.pendingCredential);if(t.multiFactorSession?.idToken)return e._fromIdtoken(t.multiFactorSession.idToken)}return null}},FS=class e{constructor(e,t,n){this.session=e,this.hints=t,this.signInResolver=n}static _fromError(t,n){let r=Q(t),i=n.customData._serverResponse,a=(i.mfaInfo||[]).map(e=>$x._fromServerResponse(r,e));Y(i.mfaPendingCredential,r,`internal-error`);let o=PS._fromMfaPendingCredential(i.mfaPendingCredential);return new e(o,a,async e=>{let t=await e._process(r,o);delete i.mfaInfo,delete i.mfaPendingCredential;let a={...i,idToken:t.idToken,refreshToken:t.refreshToken};switch(n.operationType){case`signIn`:let e=await Lx._fromIdTokenResponse(r,n.operationType,a);return await r._updateCurrentUser(e.user),e;case`reauthenticate`:return Y(n.user,r,`internal-error`),Lx._forOperation(n.user,n.operationType,a);default:ty(r,`internal-error`)}})}async resolveSignIn(e){let t=e;return this.signInResolver(t)}};function IS(e,t){let n=y(e),r=t;return Y(t.customData.operationType,n,`argument-error`),Y(r.customData._serverResponse?.mfaPendingCredential,n,`argument-error`),FS._fromError(n,r)}function LS(e,t){return Z(e,`POST`,`/v2/accounts/mfaEnrollment:start`,X(e,t))}function RS(e,t){return Z(e,`POST`,`/v2/accounts/mfaEnrollment:finalize`,X(e,t))}function zS(e,t){return Z(e,`POST`,`/v2/accounts/mfaEnrollment:start`,X(e,t))}function BS(e,t){return Z(e,`POST`,`/v2/accounts/mfaEnrollment:finalize`,X(e,t))}function VS(e,t){return Z(e,`POST`,`/v2/accounts/mfaEnrollment:withdraw`,X(e,t))}var HS=class e{constructor(e){this.user=e,this.enrolledFactors=[],e._onReload(t=>{t.mfaInfo&&(this.enrolledFactors=t.mfaInfo.map(t=>$x._fromServerResponse(e.auth,t)))})}static _fromUser(t){return new e(t)}async getSession(){return PS._fromIdtoken(await this.user.getIdToken(),this.user)}
22async enroll(e,t){let n=e,r=await this.getSession(),i=await zy(this.user,n._process(this.user.auth,r,t));return await this.user._updateTokensIfNecessary(i),this.user.reload()}async unenroll(e){let t=typeof e==`string`?e:e.uid,n=await this.user.getIdToken();try{let e=await zy(this.user,VS(this.user.auth,{idToken:n,mfaEnrollmentId:t}));this.enrolledFactors=this.enrolledFactors.filter(({uid:e})=>e!==t),await this.user._updateTokensIfNecessary(e),await this.user.reload()}catch(e){throw e}}},US=new WeakMap;function WS(e){let t=y(e);return US.has(t)||US.set(t,HS._fromUser(t)),US.get(t)}var GS=`__sak`,KS=class{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(GS,`1`),this.storage.removeItem(GS),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()}},qS=1e3,JS=10,YS=class extends KS{constructor(){super(()=>window.localStorage,`LOCAL`),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=gb(),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);hb()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(r,JS):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)})},qS)}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]),Ob
22ject.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]}};YS.type=`LOCAL`;var XS=YS,ZS=1e3;function QS(e){let t=e.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`),n=RegExp(`${t}=([^;]+)`);return document.cookie.match(n)?.[1]??null}function $S(e){return`${window.location.protocol===`http:`?`__dev_`:`__HOST-`}FIREBASE_${e.split(`:`)[3]}`}var eC=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=$S(e);return window.cookieStore?(await window.cookieStore.get(t))?.value:QS(t)}async _remove(e){if(!this._isAvailable()||!await this._get(e))return;let t=$S(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=$S(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=QS(n),i=setInterval(()=>{let e=QS(n);e!==r&&(t(e),r=e)},ZS);this.listenerUnsubscribes.set(t,()=>clearInterval(i))}_removeListener(e,t){let n=this.listenerUnsubscribes.get(t);n&&(n(),this.listenerUnsubscribes.delete(t))}};eC.type=`COOKIE`;var tC=class extends KS{constructor(){super(()=>window.sessionStorage,`SESSION`)}_addListener(e,t){}_removeListener(e,t){}};tC.type=`SESSION`;var nC=tC;function rC(e){return Promise.all(e.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}}))}var iC=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 rC(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)}};iC.receivers=[];function aC(e=``,t=10){let n=``;for(let e=0;e<t;e++)n+=Math.floor(Math.random()*10);return e+n}var oC=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=aC(``,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 sC(){return window}
22function cC(e){sC().location.href=e}function lC(){return sC().WorkerGlobalScope!==void 0&&typeof sC().importScripts==`function`}async function uC(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function dC(){return navigator?.serviceWorker?.controller||null}function fC(){return lC()?self:null}var pC=`firebaseLocalStorageDb`,mC=1,hC=`firebaseLocalStorage`,gC=`fbase_key`,_C=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 vC(e,t){return e.transaction([hC],t?`readwrite`:`readonly`).objectStore(hC)}function yC(){return new _C(indexedDB.deleteDatabase(pC)).toPromise()}function bC(){let e=indexedDB.open(pC,mC);return new Promise((t,n)=>{e.addEventListener(`error`,()=>{n(e.error)}),e.addEventListener(`upgradeneeded`,()=>{let t=e.result;try{t.createObjectStore(hC,{keyPath:gC})}catch(e){n(e)}}),e.addEventListener(`success`,async()=>{let n=e.result;n.objectStoreNames.contains(hC)?t(n):(n.close(),await yC(),t(await bC()))})})}async function xC(e,t,n){return new _C(vC(e,!0).put({[gC]:t,value:n})).toPromise()}async function SC(e,t){let n=await new _C(vC(e,!1).get(t)).toPromise();return n===void 0?null:n.value}function CC(e,t){return new _C(vC(e,!0).delete(t)).toPromise()}var wC=800,TC=3,EC=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=bC(),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++>TC)throw e;this.dbPromise&&=((await this.dbPromise).close(),null)}}async initializeServiceWorkerMessaging(){return lC()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=iC._getInstance(fC()),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 uC(),!this.activeServiceWorker)return;this.sender=new oC(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||dC()!==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 xC(e,GS,`1`),await CC(e,GS)}),!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=>xC(n,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){let t=await this._withRetries(t=>SC(t,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>CC(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){let e=await this._withRetries(e=>new _C(vC(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(),wC)}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]),Ob
22ject.keys(this.listeners).length===0&&this.stopPolling()}};EC.type=`LOCAL`;var DC=EC;function OC(e,t){return Z(e,`POST`,`/v2/accounts/mfaSignIn:start`,X(e,t))}function kC(e,t){return Z(e,`POST`,`/v2/accounts/mfaSignIn:finalize`,X(e,t))}function AC(e,t){return Z(e,`POST`,`/v2/accounts/mfaSignIn:finalize`,X(e,t))}var jC=Ab(`rcb`),MC=new my(3e4,6e4),NC=class{constructor(){this.hostLanguage=``,this.counter=0,this.librarySeparatelyLoaded=!!sC().grecaptcha?.render}load(e,t=``){return Y(PC(t),e,`argument-error`),this.shouldResolveImmediately(t)&&Ey(sC().grecaptcha)?Promise.resolve(sC().grecaptcha):new Promise((n,r)=>{let i=sC().setTimeout(()=>{r(ny(e,`network-request-failed`))},MC.get());sC()[jC]=()=>{sC().clearTimeout(i),delete sC()[jC];let a=sC().grecaptcha;if(!a||!Ey(a)){r(ny(e,`internal-error`));return}let o=a.render;a.render=(e,t)=>{let n=o(e,t);return this.counter++,n},this.hostLanguage=t,n(a)},Eb(`${Db()}?${ze({onload:jC,render:`explicit`,hl:t})}`).catch(()=>{clearTimeout(i),r(ny(e,`internal-error`))})})}clearedOneInstance(){this.counter--}shouldResolveImmediately(e){return!!sC().grecaptcha?.render&&(e===this.hostLanguage||this.counter>0||this.librarySeparatelyLoaded)}};function PC(e){return e.length<=6&&/^\s*[a-zA-Z0-9\-]*\s*$/.test(e)}var FC=class{async load(e){return new Pb(e)}clearedOneInstance(){}},IC=`recaptcha`,LC={theme:`light`,type:`image`},RC=class{constructor(e,t,n={...LC}){this.parameters=n,this.type=IC,this.destroyed=!1,this.widgetId=null,this.tokenChangeListeners=new Set,this.renderPromise=null,this.recaptcha=null,this.auth=Q(e),this.isInvisible=this.parameters.size===`invisible`,Y(typeof document<`u`,this.auth,`operation-not-supported-in-this-environment`);let r=typeof t==`string`?document.getElementById(t):t;Y(r,this.auth,`argument-error`),this.container=r,this.parameters.callback=this.makeTokenCallback(this.parameters.callback),this._recaptchaLoader=this.auth.settings.appVerificationDisabledForTesting?new FC:new NC,this.validateStartingState()}async verify(){this.assertNotDestroyed();let e=await this.render(),t=this.getAssertedRecaptcha();return t.getResponse(e)||new Promise(n=>{let r=e=>{e&&(this.tokenChangeListeners.delete(r),n(e))};this.tokenChangeListeners.add(r),this.isInvisible&&t.execute(e)})}render(){try{this.assertNotDestroyed()}catch(e){return Promise.reject(e)}return this.renderPromise||=this.makeRenderPromise().catch(e=>{throw this.renderPromise=null,e}),this.renderPromise}_reset(){this.assertNotDestroyed(),this.widgetId!==null&&this.getAssertedRecaptcha().reset(this.widgetId)}clear(){this.assertNotDestroyed(),this.destroyed=!0,this._recaptchaLoader.clearedOneInstance(),this.isInvisible||this.container.childNodes.forEach(e=>{this.container.removeChild(e)})}validateStartingState(){Y(!this.parameters.sitekey,this.auth,`argument-error`),Y(this.isInvisible||!this.container.hasChildNodes(),this.auth,`argument-error`),Y(typeof document<`u`,this.auth,`operation-not-supported-in-this-environment`)}makeTokenCallback(e){return t=>{if(this.tokenChangeListeners.forEach(e=>e(t)),typeof e==`function`)e(t);else if(typeof e==`string`){let n=sC()[e];typeof n==`function`&&n(t)}}}assertNotDestroyed(){Y(!this.destroyed,this.auth,`internal-error`)}async makeRenderPromise(){if(await this.init(),!this.widgetId){let e=this.container;if(!this.isInvisible){let t=document.createElement(`div`);e.appendChild(t),e=t}this.widgetId=this.getAssertedRecaptcha().render(e,this.parameters)}return this.widgetId}
22async init(){Y(uy()&&!lC(),this.auth,`internal-error`),await zC(),this.recaptcha=await this._recaptchaLoader.load(this.auth,this.auth.languageCode||void 0);let e=await ky(this.auth);Y(e,this.auth,`internal-error`),this.parameters.sitekey=e}getAssertedRecaptcha(){return Y(this.recaptcha,this.auth,`internal-error`),this.recaptcha}};function zC(){let e=null;return new Promise(t=>{if(document.readyState===`complete`){t();return}e=()=>t(),window.addEventListener(`load`,e)}).catch(t=>{throw e&&window.removeEventListener(`load`,e),t})}var BC=class{constructor(e,t){this.verificationId=e,this.onConfirmation=t}confirm(e){let t=bx._fromVerification(this.verificationId,e);return this.onConfirmation(t)}};async function VC(e,t,n){if(w(e.app))return Promise.reject(iy(e));let r=Q(e);return new BC(await WC(r,t,y(n)),e=>Jx(r,e))}async function HC(e,t,n){let r=y(e);return await Gx(!1,r,`phone`),new BC(await WC(r.auth,t,y(n)),e=>Yx(r,e))}async function UC(e,t,n){let r=y(e);return w(r.auth.app)?Promise.reject(iy(r.auth)):new BC(await WC(r.auth,t,y(n)),e=>Xx(r,e))}async function WC(e,t,n){if(!e._getRecaptchaConfig())try{await Wb(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 Y(t.type===`enroll`,e,`internal-error`),(await Ub(e,{idToken:t.credential,phoneEnrollmentInfo:{phoneNumber:r.phoneNumber,clientType:`CLIENT_TYPE_WEB`}},`mfaSmsEnrollment`,async(e,t)=>t.phoneEnrollmentInfo.captchaResponse===Bb?(Y(n?.type===IC,e,`argument-error`),LS(e,await KC(e,t,n))):LS(e,t),`PHONE_PROVIDER`).catch(e=>Promise.reject(e))).phoneSessionInfo.sessionInfo;{Y(t.type===`signin`,e,`internal-error`);let i=r.multiFactorHint?.uid||r.multiFactorUid;return Y(i,e,`missing-multi-factor-info`),(await Ub(e,{mfaPendingCredential:t.credential,mfaEnrollmentId:i,phoneSignInInfo:{clientType:`CLIENT_TYPE_WEB`}},`mfaSmsSignIn`,async(e,t)=>t.phoneSignInInfo.captchaResponse===Bb?(Y(n?.type===IC,e,`argument-error`),OC(e,await KC(e,t,n))):OC(e,t),`PHONE_PROVIDER`).catch(e=>Promise.reject(e))).phoneResponseInfo.sessionInfo}}else return(await Ub(e,{phoneNumber:r.phoneNumber,clientType:`CLIENT_TYPE_WEB`},`sendVerificationCode`,async(e,t)=>t.captchaResponse===Bb?(Y(n?.type===IC,e,`argument-error`),hx(e,await KC(e,t,n))):hx(e,t),`PHONE_PROVIDER`).catch(e=>Promise.reject(e))).sessionInfo}finally{n?._reset()}}async function GC(e,t){let n=y(e);if(w(n.auth.app))return Promise.reject(iy(n.auth));await Wx(n,t)}async function KC(e,t,n){Y(n.type===IC,e,`argument-error`);let r=await n.verify();Y(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 qC=class e{constructor(t){this.providerId=e.PROVIDER_ID,this.auth=Q(t)}verifyPhoneNumber(e,t){return WC(this.auth,e,y(t))}static credential(e,t){return bx._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?bx._fromTokenResponse(t,n):null}};qC.PROVIDER_ID=`phone`,qC.PHONE_SIGN_IN_METHOD=`phone`;function JC(e,t){return t?$y(t):(Y(e._popupRedirectResolver,e,`argument-error`),e._popupRedirectResolver)}var YC=class extends Qb{constructor(e){super(`custom`,`custom`),this.params=e}_getIdTokenResponse(e){return fx(e,this._buildIdpRequest())}_linkToIdToken(e,t){return fx(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return fx(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 XC(e){return qx(e.auth,new YC(e),e.bypassAuthState)}function ZC(e){let{auth:t,user:n}=e;return Y(n,t,`internal-error`),Kx(n,new YC(e),e.bypassAuthState)}async function QC(e){let{auth:t,user:n}=e;return Y(n,t,`internal-error`),Wx(n,new YC(e),e.bypassAuthState)}var $C=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 XC;case`linkViaPopup`:case`linkViaRedirect`:return QC;case`reauthViaPopup`:case`reauthViaRedirect`:return ZC;default:ty(this.auth,`internal-error`)}}resolve(e){cy(this.pendingPromise,`Pending promise was never set`),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){cy(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()}},ew=new my(2e3,1e4);async function tw(e,t,n){if(w(e.app))return Promise.reject(ny(e,`operation-not-supported-in-this-environment`));let r=Q(e);return ay(e,t,Tx),new iw(r,`signInViaPopup`,t,JC(r,n)).executeNotNull()}async function nw(e,t,n){let r=y(e);if(w(r.auth.app))return Promise.reject(ny(r.auth,`operation-not-supported-in-this-environment`));ay(r.auth,t,Tx);let i=JC(r.auth,n);return new iw(r.auth,`reauthViaPopup`,t,i,r).executeNotNull()}async function rw(e,t,n){let r=y(e);ay(r.auth,t,Tx);let i=JC(r.auth,n);return new iw(r.auth,`linkViaPopup`,t,i,r).executeNotNull()}var iw=class e extends $C{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 Y(e,this.auth,`internal-error`),e}async onExecution(){cy(this.filter.length===1,`Popup operations only handle one event`);let e=aC();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(ny(this.auth,`web-storage-unsupported`))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(ny(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(ny(this.auth,`popup-closed-by-user`))},8e3);return}this.pollId=window.setTimeout(e,ew.get())};e()}};iw.currentPopupAction=null;
22var aw=`pendingRedirect`,ow=new Map,sw=class extends $C{constructor(e,t,n=!1){super(e,[`signInViaRedirect`,`linkViaRedirect`,`reauthViaRedirect`,`unknown`],t,void 0,n),this.eventId=null}async execute(){let e=ow.get(this.auth._key());if(!e){try{let t=await cw(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(t)}catch(t){e=()=>Promise.reject(t)}ow.set(this.auth._key(),e)}return this.bypassAuthState||ow.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 cw(e,t){let n=pw(t),r=fw(e);if(!await r._isAvailable())return!1;let i=await r._get(n)===`true`;return await r._remove(n),i}async function lw(e,t){return fw(e)._set(pw(t),`true`)}function uw(){ow.clear()}function dw(e,t){ow.set(e._key(),t)}function fw(e){return $y(e._redirectPersistence)}function pw(e){return nb(aw,e.config.apiKey,e.name)}
22function mw(e,t,n){return hw(e,t,n)}async function hw(e,t,n){if(w(e.app))return Promise.reject(iy(e));let r=Q(e);ay(e,t,Tx),await r._initializationPromise;let i=JC(r,n);return await lw(i,r),i._openRedirect(r,t,`signInViaRedirect`)}function gw(e,t,n){return _w(e,t,n)}async function _w(e,t,n){let r=y(e);if(ay(r.auth,t,Tx),w(r.auth.app))return Promise.reject(iy(r.auth));await r.auth._initializationPromise;let i=JC(r.auth,n);await lw(i,r.auth);let a=await Sw(r);return i._openRedirect(r.auth,t,`reauthViaRedirect`,a)}function vw(e,t,n){return yw(e,t,n)}async function yw(e,t,n){let r=y(e);ay(r.auth,t,Tx),await r.auth._initializationPromise;let i=JC(r.auth,n);await Gx(!1,r,t.providerId),await lw(i,r.auth);let a=await Sw(r);return i._openRedirect(r.auth,t,`linkViaRedirect`,a)}async function bw(e,t){return await Q(e)._initializationPromise,xw(e,t,!1)}async function xw(e,t,n=!1){if(w(e.app))return Promise.reject(iy(e));let r=Q(e),i=await new sw(r,JC(r,t),n).execute();return i&&!n&&(delete i.user._redirectEventId,await r._persistUserIfCurrent(i.user),await r._setRedirectUser(null,t)),i}async function Sw(e){let t=aC(`${e.uid}:::`);return e._redirectEventId=t,await e.auth._setRedirectUser(e),await e.auth._persistUserIfCurrent(e),t}var Cw=600*1e3,ww=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||!Dw(e)?t:(this.hasHandledPotentialRedirect=!0,t||=(this.queuedRedirectEvent=e,!0),t)}sendToConsumer(e,t){if(e.error&&!Ew(e)){let n=e.error.code?.split(`auth/`)[1]||`internal-error`;t.onError(ny(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>=Cw&&this.cachedEventUids.clear(),this.cachedEventUids.has(Tw(e))}saveEventToCache(e){this.cachedEventUids.add(Tw(e)),this.lastProcessedEventTime=Date.now()}};function Tw(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join(`-`)}function Ew({type:e,error:t}){return e===`unknown`&&t?.code===`auth/no-auth-event`}function Dw(e){switch(e.type){case`signInViaRedirect`:case`linkViaRedirect`:case`reauthViaRedirect`:return!0;case`unknown`:return Ew(e);default:return!1}}async function Ow(e,t={}){return Z(e,`GET`,`/v1/projects`,t)}var kw=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,Aw=/^https?/;async function jw(e){if(e.config.emulator)return;let{authorizedDomains:t}=await Ow(e);for(let e of t)try{if(Mw(e))return}catch{}ty(e,`unauthorized-domain`)}function Mw(e){let t=ly(),{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(!Aw.test(n))return!1;if(kw.test(e))return r===e;let i=e.replace(/\./g,`\\.`);return RegExp(`^(.+\\.`+i+`|`+i+`)$`,`i`).test(r)}var Nw=new my(3e4,6e4);function Pw(){let e=sC().___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 Fw(e){return new Promise((t,n)=>{function r(){Pw(),gapi.load(`gapi.iframes`,{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{Pw(),n(ny(e,`network-request-failed`))},timeout:Nw.get()})}if(sC().gapi?.iframes?.Iframe)t(gapi.iframes.getContext());else if(sC().gapi?.load)r();else{let t=Ab(`iframefcb`);return sC()[t]=()=>{gapi.load?r():n(ny(e,`network-request-failed`))},Eb(`${kb()}?onload=${t}`).catch(e=>n(e))}}).catch(e=>{throw Iw=null,e})}var Iw=null;function Lw(e){return Iw||=Fw(e),Iw}var Rw=new my(5e3,15e3),zw=`__/auth/iframe`,Bw=`emulator/auth/iframe`,Vw={style:{position:`absolute`,top:`-100px`,width:`1px`,height:`1px`},"aria-hidden":`true`,tabindex:`-1`},Hw=new Map([[`identitytoolkit.googleapis.com`,`p`],[`staging-identitytoolkit.sandbox.googleapis.com`,`s`],[`test-identitytoolkit.sandbox.googleapis.com`,`t`]]);function Uw(e){let t=e.config;Y(t.authDomain,e,`auth-domain-config-required`);let n=t.emulator?hy(t,Bw):`https://${e.config.authDomain}/${zw}
22`,r={apiKey:t.apiKey,appName:e.name,v:An},i=Hw.get(e.config.apiHost);i&&(r.eid=i);let a=e._getFrameworks();return a.length&&(r.fw=a.join(`,`)),`${n}?${ze(r).slice(1)}`}async function Ww(e){let t=await Lw(e),n=sC().gapi;return Y(n,e,`internal-error`),t.open({where:document.body,url:Uw(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Vw,dontclear:!0},t=>new Promise(async(n,r)=>{await t.restyle({setHideOnLeave:!1});let i=ny(e,`network-request-failed`),a=sC().setTimeout(()=>{r(i)},Rw.get());function o(){sC().clearTimeout(a),n(t)}t.ping(o).then(o,()=>{r(i)})}))}var Gw={location:`yes`,resizable:`yes`,statusbar:`yes`,toolbar:`no`},Kw=500,qw=600,Jw=`_blank`,Yw=`http://localhost`,Xw=class{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}};function Zw(e,t,n,r=Kw,i=qw){let a=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString(),s=``,c={...Gw,width:r.toString(),height:i.toString(),top:a,left:o},l=_().toLowerCase();n&&(s=sb(l)?Jw:n),ab(l)&&(t||=Yw,c.scrollbars=`yes`);let u=Object.entries(c).reduce((e,[t,n])=>`${e}${t}=${n},`,``);if(mb(l)&&s!==`_self`)return Qw(t||``,s),new Xw(null);let d=window.open(t||``,s,u);Y(d,e,`popup-blocked`);try{d.focus()}catch{}return new Xw(d)}function Qw(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 $w=`__/auth/handler`,eT=`emulator/auth/handler`,tT=`fac`;async function nT(e,t,n,r,i,a){Y(e.config.authDomain,e,`auth-domain-config-required`),Y(e.config.apiKey,e,`invalid-api-key`);let o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:An,eventId:i};if(t instanceof Tx){t.setDefaultLanguage(e.languageCode),o.providerId=t.providerId||``,Le(t.getCustomParameters())||(o.customParameters=JSON.stringify(t.getCustomParameters()));for(let[e,t]of Object.entries(a||{}))o[e]=t}if(t instanceof Ex){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?`#${tT}=${encodeURIComponent(c)}`:``;return`${rT(e)}?${ze(s).slice(1)}${l}`}function rT({config:e}){return e.emulator?hy(e,eT):`https://${e.authDomain}/${$w}`}var iT=`webStorageSupport`,aT=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=nC,this._completeRedirectFn=xw,this._overrideRedirectResult=dw}async _openPopup(e,t,n,r){return cy(this.eventManagers[e._key()]?.manager,`_initialize() not called before _openPopup()`),Zw(e,await nT(e,t,n,ly(),r),aC())}async _openRedirect(e,t,n,r){return await this._originValidation(e),cC(await nT(e,t,n,ly(),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):(cy(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 Ww(e),n=new ww(e);return t.register(`authEvent`,t=>(Y(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(iT,{type:iT},n=>{let r=n?.[0]?.[iT];r!==void 0&&t(!!r),ty(e,`internal-error`)},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){let t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=jw(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return gb()||ob()||fb()}},oT=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 sy(`unexpected MultiFactorSessionType`)}}}
22,sT=class e extends oT{constructor(e){super(`phone`),this.credential=e}static _fromCredential(t){return new e(t)}_finalizeEnroll(e,t,n){return RS(e,{idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()})}_finalizeSignIn(e,t){return kC(e,{mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()})}},cT=class{constructor(){}static assertion(e){return sT._fromCredential(e)}};cT.FACTOR_ID=`phone`;var lT=class{static assertionForEnrollment(e,t){return uT._fromSecret(e,t)}static assertionForSignIn(e,t){return uT._fromEnrollmentId(e,t)}static async generateSecret(e){let t=e;Y(t.user?.auth!==void 0,`internal-error`);let n=await zS(t.user.auth,{idToken:t.credential,totpEnrollmentInfo:{}});return dT._fromStartTotpMfaEnrollmentResponse(n,t.user.auth)}};lT.FACTOR_ID=`totp`;var uT=class e extends oT{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 Y(this.secret!==void 0,e,`argument-error`),BS(e,{idToken:t,displayName:n,totpVerificationInfo:this.secret._makeTotpVerificationInfo(this.otp)})}async _finalizeSignIn(e,t){Y(this.enrollmentId!==void 0&&this.otp!==void 0,e,`argument-error`);let n={verificationCode:this.otp};return AC(e,{mfaPendingCredential:t,mfaEnrollmentId:this.enrollmentId,totpVerificationInfo:n})}},dT=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(fT(e)||fT(t))&&(n=!0),n&&(fT(e)&&(e=this.auth.currentUser?.email||`unknownuser`),fT(t)&&(t=this.auth.name)),`otpauth://totp/${t}:${e}?secret=${this.secretKey}&issuer=${t}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`}};function fT(e){return e===void 0||e?.length===0}var pT=`@firebase/auth`,mT=`1.13.2`,hT=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(){Y(this.auth._initializationPromise,`dependent-sdk-initialized-before-auth`)}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}};function gT(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 _T(e){xn(new b(`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;Y(o&&!o.includes(`:`),`invalid-api-key`,{appName:r.name});let c=new Sb(r,i,a,{apiKey:o,authDomain:s,clientPlatform:e,apiHost:`identitytoolkit.googleapis.com`,tokenApiHost:`securetoken.googleapis.com`,apiScheme:`https`,sdkClientVersion:_b(e)});return Kb(c,n),c},`PUBLIC`).setInstantiationMode(`EXPLICIT`).setInstanceCreatedCallback((e,t,n)=>{e.getProvider(`auth-internal`).initialize()})),xn(new b(`auth-internal`,e=>(e=>new hT(e))(Q(e.getProvider(`auth`).getImmediate())),`PRIVATE`).setInstantiationMode(`EXPLICIT`)),T(pT,mT,gT(e)),T(pT,mT,`esm2020`)}var vT=fe(`authIdTokenMaxAge`)||300,yT=null,bT=e=>async t=>{let n=t&&await t.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>vT)return;let i=n?.token;
22yT!==i&&(yT=i,await fetch(e,{method:i?`POST`:`DELETE`,headers:i?{Authorization:`Bearer ${i}`}:{}}))};function xT(e=Nn()){let t=Sn(e,`auth`);if(t.isInitialized())return t.getImmediate();let n=Gb(e,{popupRedirectResolver:aT,persistence:[DC,XS,nC]}),r=fe(`authTokenSyncURL`);if(r&&typeof isSecureContext==`boolean`&&isSecureContext){let e=new URL(r,location.origin);if(location.origin===e.origin){let t=bT(e.toString());MS(n,t,()=>t(n.currentUser)),jS(n,e=>t(e))}}let i=le(`auth`);return i&&qb(n,`http://${i}`),n}function ST(){return document.getElementsByTagName(`head`)?.[0]??document}Tb({loadJS(e){return new Promise((t,n)=>{let r=document.createElement(`script`);r.setAttribute(`src`,e),r.onload=t,r.onerror=e=>{let t=ny(`internal-error`);t.customData=e,n(t)},r.type=`text/javascript`,r.charset=`UTF-8`,ST().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=`}),_T(`Browser`);function CT(){return window}var wT=2e3;async function TT(e,t,n){let{BuildInfo:r}=CT();cy(t.sessionId,`AuthEvent did not contain a session ID`);let i=await AT(t.sessionId),a={};return fb()?a.ibi=r.packageName:lb()?a.apn=r.packageName:ty(e,`operation-not-supported-in-this-environment`),r.displayName&&(a.appDisplayName=r.displayName),a.sessionId=i,nT(e,n,t.type,void 0,t.eventId??void 0,a)}async function ET(e){let{BuildInfo:t}=CT(),n={};fb()?n.iosBundleId=t.packageName:lb()?n.androidPackageName=t.packageName:ty(e,`operation-not-supported-in-this-environment`),await Ow(e,n)}function DT(e){let{cordova:t}=CT();return new Promise(n=>{t.plugins.browsertab.isAvailable(r=>{let i=null;r?t.plugins.browsertab.openUrl(e):i=t.InAppBrowser.open(e,pb()?`_blank`:`_system`,`location=yes`),n(i)})})}async function OT(e,t,n){let{cordova:r}=CT(),i=()=>{};try{await new Promise((a,o)=>{let s=null;function c(){a();let e=r.plugins.browsertab?.close;typeof e==`function`&&e(),typeof n?.close==`function`&&n.close()}function l(){s||=window.setTimeout(()=>{o(ny(e,`redirect-cancelled-by-user`))},wT)}function u(){document?.visibilityState===`visible`&&l()}t.addPassiveListener(c),document.addEventListener(`resume`,l,!1),lb()&&document.addEventListener(`visibilitychange`,u,!1),i=()=>{t.removePassiveListener(c),document.removeEventListener(`resume`,l,!1),document.removeEventListener(`visibilitychange`,u,!1),s&&window.clearTimeout(s)}})}finally{i()}}function kT(e){let t=CT();Y(typeof t?.universalLinks?.subscribe==`function`,e,`invalid-cordova-configuration`,{missingPlugin:`cordova-universal-links-plugin-fix`}),Y(t?.BuildInfo?.packageName!==void 0,e,`invalid-cordova-configuration`,{missingPlugin:`cordova-plugin-buildInfo`}),Y(typeof t?.cordova?.plugins?.browsertab?.openUrl==`function`,e,`invalid-cordova-configuration`,{missingPlugin:`cordova-plugin-browsertab`}),Y(typeof t?.cordova?.plugins?.browsertab?.isAvailable==`function`,e,`invalid-cordova-configuration`,{missingPlugin:`cordova-plugin-browsertab`}),Y(typeof t?.cordova?.InAppBrowser?.open==`function`,e,`invalid-cordova-configuration`,{missingPlugin:`cordova-plugin-inappbrowser`})}async function AT(e){let t=jT(e),n=await crypto.subtle.digest(`SHA-256`,t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,`0`)).join(``)}function jT(e){if(cy(/[0-9a-zA-Z]+/.test(e),`Can only convert alpha-numeric strings`),typeof TextEncoder<`u`)return new TextEncoder().encode(e);let t=new ArrayBuffer(e.length),n=new Uint8Array(t);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return n}var MT=20,NT=class extends ww{constructor(){super(...arguments),this.passiveListeners=new Set,this.initPromise=new Promise(e=>{this.resolveInitialized=e})}addPassiveListener(e){this.passiveListeners.add(e)}removePassiveListener(e){this.passiveListeners.delete(e)}resetRedirect(){this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1}onEvent(e){return this.resolveInitialized(),this.passiveListeners.forEach(t=>t(e)),super.onEvent(e)}async initialized(){await this.initPromise}};function PT(e,t,n=null){return{type:t,eventId:n,urlResponse:null,sessionId:RT(),postBody:null,tenantId:e.tenantId,error:ny(e,`no-auth-event`)}}function FT(e,t){return zT()._set(BT(e),t)}async function IT(e){let t=await zT()._get(BT(e));return t&&await zT()._remove(BT(e)),t}function LT(e,t){let n=HT(t);if(n.includes(`/__/auth/callback`)){let t=UT(n),r=(t.firebaseError?VT(decodeURIComponent(t.firebaseError)):null)?.code?.split(`auth/`)?.[1],i=r?ny(r):null;return i?{type:e.type,eventId:e.eventId,tenantId:e.tenantId,error:i,urlResponse:null,sessionId:null,postBody:null}:{type:e.type,eventId:e.eventId,tenantId:e.tenantId,sessionId:e.sessionId,urlResponse:n,postBody:null}}return null}function RT(){let e=[];for(let t=0;t<MT;t++){let t=Math.floor(Math.random()*62);e.push(`1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`.charAt(t))}return e.join(``)}function zT(){return $y(XS)}function BT(e){return nb(`authEvent`,e.config.apiKey,e.name)}function VT(e){try{return JSON.parse(e)}catch{return null}}
22function HT(e){let t=UT(e),n=t.link?decodeURIComponent(t.link):void 0,r=UT(n).link,i=t.deep_link_id?decodeURIComponent(t.deep_link_id):void 0;return UT(i).link||i||r||n||e}function UT(e){if(!e?.includes(`?`))return{};let[t,...n]=e.split(`?`);return Be(n.join(`?`))}var WT=500,GT=class{constructor(){this._redirectPersistence=nC,this._shouldInitProactively=!0,this.eventManagers=new Map,this.originValidationPromises={},this._completeRedirectFn=xw,this._overrideRedirectResult=dw}async _initialize(e){let t=e._key(),n=this.eventManagers.get(t);return n||(n=new NT(e),this.eventManagers.set(t,n),this.attachCallbackListeners(e,n)),n}_openPopup(e){ty(e,`operation-not-supported-in-this-environment`)}async _openRedirect(e,t,n,r){kT(e);let i=await this._initialize(e);await i.initialized(),i.resetRedirect(),uw(),await this._originValidation(e);let a=PT(e,n,r);return await FT(e,a),OT(e,i,await DT(await TT(e,a,t)))}_isIframeWebStorageSupported(e,t){throw Error(`Method not implemented.`)}_originValidation(e){let t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=ET(e)),this.originValidationPromises[t]}attachCallbackListeners(e,t){let{universalLinks:n,handleOpenURL:r,BuildInfo:i}=CT(),a=setTimeout(async()=>{await IT(e),t.onEvent(KT())},WT),o=async n=>{clearTimeout(a);let r=await IT(e),i=null;r&&n?.url&&(i=LT(r,n.url)),t.onEvent(i||KT())};n!==void 0&&typeof n.subscribe==`function`&&n.subscribe(null,o);let s=r,c=`${i.packageName.toLowerCase()}://`;CT().handleOpenURL=async e=>{if(e.toLowerCase().startsWith(c)&&o({url:e}),typeof s==`function`)try{s(e)}catch(e){console.error(e)}}}};function KT(){return{type:`unknown`,eventId:null,sessionId:null,urlResponse:null,postBody:null,tenantId:null,error:ny(`no-auth-event`)}}function qT(e,t){Q(e)._logFramework(t)}var JT=`@firebase/auth-compat`,YT=`0.6.7`,XT=1e3;function ZT(){return self?.location?.protocol||null}function QT(){return ZT()===`http:`||ZT()===`https:`}function $T(e=_()){return!!((ZT()===`file:`||ZT()===`ionic:`||ZT()===`capacitor:`)&&e.toLowerCase().match(/iphone|ipad|ipod|android/))}function eE(){return xe()||ge()}function tE(){return Se()&&document?.documentMode===11}function nE(e=_()){return/Edge\/\d+/.test(e)}function rE(e=_()){return tE()||nE(e)}function iE(){try{let e=self.localStorage,t=aC();if(e)return e.setItem(t,`1`),e.removeItem(t),rE()?Te():!0}catch{return aE()&&Te()}return!1}function aE(){return typeof global<`u`&&`WorkerGlobalScope`in global&&`importScripts`in global}function oE(){return(QT()||be()||$T())&&!eE()&&iE()&&!aE()}function sE(){return $T()&&typeof document<`u`}async function cE(){return sE()?new Promise(e=>{let t=setTimeout(()=>{e(!1)},XT);document.addEventListener(`deviceready`,()=>{clearTimeout(t),e(!0)})}):!1}function lE(){return typeof window<`u`?window:null}var uE={LOCAL:`local`,NONE:`none`,SESSION:`session`},dE=Y,fE=`persistence`;function pE(e,t){if(dE(Object.values(uE).includes(t),e,`invalid-persistence-type`),xe()){dE(t!==uE.SESSION,e,`unsupported-persistence-type`);return}if(ge()){dE(t===uE.NONE,e,`unsupported-persistence-type`);return}if(aE()){dE(t===uE.NONE||t===uE.LOCAL&&Te(),e,`unsupported-persistence-type`);return}dE(t===uE.NONE||iE(),e,`unsupported-persistence-type`)}async function mE(e){await e._initializationPromise;let t=gE(),n=nb(fE,e.config.apiKey,e.name);t&&t.setItem(n,e._getPersistenceType())}function hE(e,t){let n=gE();if(!n)return[];let r=nb(fE,e,t);switch(n.getItem(r)){case uE.NONE:return[tb];case uE.LOCAL:return[DC,nC];case uE.SESSION:return[nC];default:return[]}}function gE(){try{return lE()?.sessionStorage||null}catch{return null}}var _E=Y,vE=class{constructor(){this.browserResolver=$y(aT),this.cordovaResolver=$y(GT),this.underlyingResolver=null,this._redirectPersistence=nC,this._completeRedirectFn=xw,this._overrideRedirectResult=dw}async _initialize(e){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._initialize(e)}async _openPopup(e,t,n,r){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openPopup(e,t,n,r)}async _openRedirect(e,t,n,r){return await this.selectUnderlyingResolver(),this.assertedUnderlyingResolver._openRedirect(e,t,n,r)}_isIframeWebStorageSupported(e,t){this.assertedUnderlyingResolver._isIframeWebStorageSupported(e,t)}_originValidation(e){return this.assertedUnderlyingResolver._originValidation(e)}get _shouldInitProactively(){return sE()||this.browserResolver._shouldInitProactively}get assertedUnderlyingResolver(){return _E(this.underlyingResolver,`internal-error`),this.underlyingResolver}async selectUnderlyingResolver(){if(this.underlyingResolver)return;let e=await cE();this.underlyingResolver=e?this.cordovaResolver:this.browserResolver}};function yE(e){return e.unwrap()}function bE(e){return e.wrapped()}function xE(e){return CE(e)}function SE(e,t){let n=t.customData?._tokenResponse;if(t?.code===`auth/multi-factor-auth-required`){let n=t;n.resolver=new EE(e,IS(e,t))}else if(n){let e=CE(t),r=t;e&&(r.credential=e,r.tenantId=n.tenantId||void 0,r.email=n.email||void 0,r.ph
22oneNumber=n.phoneNumber||void 0)}}function CE(e){let{_tokenResponse:t}=e instanceof ke?e.customData:e;if(!t)return null;if(!(e instanceof ke)&&`temporaryProof`in t&&`phoneNumber`in t)return qC.credentialFromResult(e);let n=t.providerId;if(!n||n===Gv.PASSWORD)return null;let r;switch(n){case Gv.GOOGLE:r=kx;break;case Gv.FACEBOOK:r=Ox;break;case Gv.GITHUB:r=Ax;break;case Gv.TWITTER:r=Fx;break;default:let{oauthIdToken:e,oauthAccessToken:i,oauthTokenSecret:a,pendingToken:o,nonce:s}=t;return!i&&!a&&!e&&!o?null:o?n.startsWith(`saml.`)?Mx._create(n,o):mx._fromParams({providerId:n,signInMethod:n,pendingToken:o,idToken:e,accessToken:i}):new Dx(n).credential({idToken:e,accessToken:i,rawNonce:s})}return e instanceof ke?r.credentialFromError(e):r.credentialFromResult(e)}function wE(e,t){return t.catch(t=>{throw t instanceof ke&&SE(e,t),t}).then(e=>{let t=e.operationType,n=e.user;return{operationType:t,credential:xE(e),additionalUserInfo:AS(e),user:DE.getOrCreate(n)}})}async function TE(e,t){let n=await t;return{verificationId:n.verificationId,confirm:t=>wE(e,n.confirm(t))}}var EE=class{constructor(e,t){this.resolver=t,this.auth=bE(e)}get session(){return this.resolver.session}get hints(){return this.resolver.hints}resolveSignIn(e){return wE(yE(this.auth),this.resolver.resolveSignIn(e))}},DE=class e{constructor(e){this._delegate=e,this.multiFactor=WS(e)}static getOrCreate(t){return e.USER_MAP.has(t)||e.USER_MAP.set(t,new e(t)),e.USER_MAP.get(t)}delete(){return this._delegate.delete()}reload(){return this._delegate.reload()}toJSON(){return this._delegate.toJSON()}getIdTokenResult(e){return this._delegate.getIdTokenResult(e)}getIdToken(e){return this._delegate.getIdToken(e)}linkAndRetrieveDataWithCredential(e){return this.linkWithCredential(e)}async linkWithCredential(e){return wE(this.auth,Yx(this._delegate,e))}async linkWithPhoneNumber(e,t){return TE(this.auth,HC(this._delegate,e,t))}async linkWithPopup(e){return wE(this.auth,rw(this._delegate,e,vE))}async linkWithRedirect(e){return await mE(Q(this.auth)),vw(this._delegate,e,vE)}reauthenticateAndRetrieveDataWithCredential(e){return this.reauthenticateWithCredential(e)}async reauthenticateWithCredential(e){return wE(this.auth,Xx(this._delegate,e))}reauthenticateWithPhoneNumber(e,t){return TE(this.auth,UC(this._delegate,e,t))}reauthenticateWithPopup(e){return wE(this.auth,nw(this._delegate,e,vE))}async reauthenticateWithRedirect(e){return await mE(Q(this.auth)),gw(this._delegate,e,vE)}sendEmailVerification(e){return gS(this._delegate,e)}async unlink(e){return await Ux(this._delegate,e),this}updateEmail(e){return bS(this._delegate,e)}updatePassword(e){return xS(this._delegate,e)}updatePhoneNumber(e){return GC(this._delegate,e)}updateProfile(e){return yS(this._delegate,e)}verifyBeforeUpdateEmail(e,t){return _S(this._delegate,e,t)}get emailVerified(){return this._delegate.emailVerified}get isAnonymous(){return this._delegate.isAnonymous}get metadata(){return this._delegate.metadata}get phoneNumber(){return this._delegate.phoneNumber}get providerData(){return this._delegate.providerData}get refreshToken(){return this._delegate.refreshToken}get tenantId(){return this._delegate.tenantId}get displayName(){return this._delegate.displayName}get email(){return this._delegate.email}get photoURL(){return this._delegate.photoURL}get providerId(){return this._delegate.providerId}get uid(){return this._delegate.uid}get auth(){return this._delegate.auth}};DE.USER_MAP=new WeakMap;var OE=Y,kE=class{constructor(e,t){if(this.app=e,t.isInitialized()){this._delegate=t.getImmediate(),this.linkUnderlyingAuth();return}let{apiKey:n}=e.options;OE(n,`invalid-api-key`,{appName:e.name}),OE(n,`invalid-api-key`,{appName:e.name});let r=typeof window<`u`?vE:void 0;this._delegate=t.initialize({options:{persistence:jE(n,e.name),popupRedirectResolver:r}}),this._delegate._updateErrorMap(Yv),this.linkUnderlyingAuth()}get emulatorConfig(){return this._delegate.emulatorConfig}get currentUser(){return this._delegate.currentUser?DE.getOrCreate(this._delegate.currentUser):null}get languageCode(){return this._delegate.languageCode}set languageCode(e){this._delegate.languageCode=e}get settings(){return this._delegate.settings}get tenantId(){return this._delegate.tenantId}set tenantId(e){this._delegate.tenantId=e}
22useDeviceLanguage(){this._delegate.useDeviceLanguage()}signOut(){return this._delegate.signOut()}useEmulator(e,t){qb(this._delegate,e,t)}applyActionCode(e){return oS(this._delegate,e)}checkActionCode(e){return sS(this._delegate,e)}confirmPasswordReset(e,t){return aS(this._delegate,e,t)}async createUserWithEmailAndPassword(e,t){return wE(this._delegate,lS(this._delegate,e,t))}fetchProvidersForEmail(e){return this.fetchSignInMethodsForEmail(e)}fetchSignInMethodsForEmail(e){return hS(this._delegate,e)}isSignInWithEmailLink(e){return fS(this._delegate,e)}async getRedirectResult(){OE(oE(),this._delegate,`operation-not-supported-in-this-environment`);let e=await bw(this._delegate,vE);return e?wE(this._delegate,Promise.resolve(e)):{credential:null,user:null}}addFrameworkForLogging(e){qT(this._delegate,e)}onAuthStateChanged(e,t,n){let{next:r,error:i,complete:a}=AE(e,t,n);return this._delegate.onAuthStateChanged(r,i,a)}onIdTokenChanged(e,t,n){let{next:r,error:i,complete:a}=AE(e,t,n);return this._delegate.onIdTokenChanged(r,i,a)}sendSignInLinkToEmail(e,t){return dS(this._delegate,e,t)}sendPasswordResetEmail(e,t){return iS(this._delegate,e,t||void 0)}async setPersistence(e){pE(this._delegate,e);let t;switch(e){case uE.SESSION:t=nC;break;case uE.LOCAL:t=await $y(DC)._isAvailable()?DC:XS;break;case uE.NONE:t=tb;break;default:return ty(`argument-error`,{appName:this._delegate.name})}return this._delegate.setPersistence(t)}signInAndRetrieveDataWithCredential(e){return this.signInWithCredential(e)}signInAnonymously(){return wE(this._delegate,zx(this._delegate))}signInWithCredential(e){return wE(this._delegate,Jx(this._delegate,e))}signInWithCustomToken(e){return wE(this._delegate,Qx(this._delegate,e))}signInWithEmailAndPassword(e,t){return wE(this._delegate,uS(this._delegate,e,t))}signInWithEmailLink(e,t){return wE(this._delegate,pS(this._delegate,e,t))}signInWithPhoneNumber(e,t){return TE(this._delegate,VC(this._delegate,e,t))}async signInWithPopup(e){return OE(oE(),this._delegate,`operation-not-supported-in-this-environment`),wE(this._delegate,tw(this._delegate,e,vE))}async signInWithRedirect(e){return OE(oE(),this._delegate,`operation-not-supported-in-this-environment`),await mE(this._delegate),mw(this._delegate,e,vE)}updateCurrentUser(e){return this._delegate.updateCurrentUser(e)}verifyPasswordResetCode(e){return cS(this._delegate,e)}unwrap(){return this._delegate}_delete(){return this._delegate._delete()}linkUnderlyingAuth(){this._delegate.wrapped=()=>this}};kE.Persistence=uE;function AE(e,t,n){let r=e;typeof e!=`function`&&({next:r,error:t,complete:n}=e);let i=r;return{next:e=>i(e&&DE.getOrCreate(e)),error:t,complete:n}}function jE(e,t){let n=hE(e,t);if(typeof self<`u`&&!n.includes(DC)&&n.push(DC),typeof window<`u`)for(let e of[XS,nC])n.includes(e)||n.push(e);return n.includes(tb)||n.push(tb),n}var ME=class{static credential(e,t){return qC.credential(e,t)}constructor(){this.providerId=`phone`,this._delegate=new qC(yE(ur.auth()))}verifyPhoneNumber(e,t){return this._delegate.verifyPhoneNumber(e,t)}unwrap(){return this._delegate}};ME.PHONE_SIGN_IN_METHOD=qC.PHONE_SIGN_IN_METHOD,ME.PROVIDER_ID=qC.PROVIDER_ID;var NE=Y,PE=class{constructor(e,t,n=ur.app()){NE(n.options?.apiKey,`invalid-api-key`,{appName:n.name}),this._delegate=new RC(n.auth(),e,t),this.type=this._delegate.type}clear(){this._delegate.clear()}render(){return this._delegate.render()}verify(){return this._delegate.verify()}},FE=`auth-compat`;function IE(e){e.INTERNAL.registerComponent(new b(FE,e=>new kE(e.getProvider(`app-compat`).getImmediate(),e.getProvider(`auth`)),`PUBLIC`).setServiceProps({ActionCodeInfo:{Operation:{EMAIL_SIGNIN:Kv.EMAIL_SIGNIN,PASSWORD_RESET:Kv.PASSWORD_RESET,RECOVER_EMAIL:Kv.RECOVER_EMAIL,REVERT_SECOND_FACTOR_ADDITION:Kv.REVERT_SECOND_FACTOR_ADDITION,VERIFY_AND_CHANGE_EMAIL:Kv.VERIFY_AND_CHANGE_EMAIL,VERIFY_EMAIL:Kv.VERIFY_EMAIL}},EmailAuthProvider:wx,FacebookAuthProvider:Ox,GithubAuthProvider:Ax,GoogleAuthProvider:kx,OAuthProvider:Dx,SAMLAuthProvider:Px,PhoneAuthProvider:ME,PhoneMultiFactorGenerator:cT,RecaptchaVerifier:PE,TwitterAuthProvider:Fx,Auth:kE,AuthCredential:Qb,Error:ke}).setInstantiationMode(`LAZY`).setMultipleInstances(!1)),e.registerVersion(JT,YT)}IE(ur);var LE=`firebasestorage.googleapis.com`,RE=`storageBucket`,zE=120*1e3,BE=600*1e3,VE=1e3,HE=class e extends ke{constructor(t,n,r=0){super(UE(t),`Firebase Storage: ${n} (${UE(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 UE(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}},$;(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=`invali
22d-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`})($||={});function UE(e){return`storage/`+e}function WE(){return new HE($.UNKNOWN,`An unknown error occurred, please check the error payload for server response.`)}function GE(e){return new HE($.OBJECT_NOT_FOUND,`Object '`+e+`' does not exist.`)}function KE(e){return new HE($.QUOTA_EXCEEDED,`Quota for bucket '`+e+`' exceeded, please view quota on https://firebase.google.com/pricing/.`)}function qE(){return new HE($.UNAUTHENTICATED,`User is not authenticated, please authenticate using Firebase Authentication and try again.`)}function JE(){return new HE($.UNAUTHORIZED_APP,`This app does not have permission to access Firebase Storage on this project.`)}function YE(e){return new HE($.UNAUTHORIZED,`User does not have permission to access '`+e+`'.`)}function XE(){return new HE($.RETRY_LIMIT_EXCEEDED,`Max retry time for operation exceeded, please try again.`)}function ZE(){return new HE($.CANCELED,`User canceled the upload/download.`)}function QE(e){return new HE($.INVALID_URL,`Invalid URL '`+e+`'.`)}function $E(e){return new HE($.INVALID_DEFAULT_BUCKET,`Invalid default bucket '`+e+`'.`)}function eD(){return new HE($.NO_DEFAULT_BUCKET,`No default bucket found. Did you set the 'storageBucket' property when initializing the app?`)}function tD(){return new HE($.CANNOT_SLICE_BLOB,`Cannot slice blob for upload. Please retry the upload.`)}function nD(){return new HE($.SERVER_FILE_WRONG_SIZE,`Server recorded incorrect upload file size, please retry the upload.`)}function rD(){return new HE($.NO_DOWNLOAD_URL,`The given file does not have any download URLs.`)}function iD(e){return new HE($.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 aD(e){return new HE($.INVALID_ARGUMENT,e)}function oD(){return new HE($.APP_DELETED,`The Firebase app was deleted.`)}function sD(e){return new HE($.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 cD(e,t){return new HE($.INVALID_FORMAT,`String does not match format '`+e+`': `+t)}function lD(e){throw new HE($.INTERNAL_ERROR,`Internal error: `+e)}var uD=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 $E(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===LE?`(?: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 QE(t);return r}},dD=class{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}};function fD(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 pD(e){e(!1)}function mD(e){return e!==void 0}function hD(e){return typeof e==`function`}function gD(e){return typeof e==`object`&&!Array.isArray(e)}function _D(e){return typeof e==`string`||e instanceof String}function vD(e){return yD()&&e instanceof Blob}function yD(){return typeof Blob<`u`}function bD(e,t,n,r){if(r<t)throw aD(`Invalid value for '${e}'. Expected ${t} or greater.`);if(r>n)throw aD(`Invalid value for '${e}'. Expected ${n} or less.`)}
22function xD(e,t,n){let r=t;return n??(r=`https://${t}`),`${n}://${r}/v0${e}`}function SD(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 CD;(function(e){e[e.NO_ERROR=0]=`NO_ERROR`,e[e.NETWORK_ERROR=1]=`NETWORK_ERROR`,e[e.ABORT=2]=`ABORT`})(CD||={});function wD(e,t){let n=e>=500&&e<600,r=[408,429].indexOf(e)!==-1,i=t.indexOf(e)!==-1;return n||r||i}var TD=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 ED(!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()===CD.NO_ERROR,i=n.getStatus();if(!t||wD(i,this.additionalRetryCodes_)&&this.retry){e(!1,new ED(!1,null,n.getErrorCode()===CD.ABORT));return}e(!0,new ED(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());mD(e)?n(e):n()}catch(e){r(e)}else if(i!==null){let e=WE();e.serverResponse=i.getErrorText(),this.errorCallback_?r(this.errorCallback_(i,e)):r(e)}else t.canceled?r(this.appDelete_?oD():ZE()):r(XE())};this.canceled_?t(!1,new ED(!1,null,!0)):this.backoffId_=fD(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&pD(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}},ED=class{constructor(e,t,n){this.wasSuccessCode=e,this.connection=t,this.canceled=!!n}};function DD(e,t){t!==null&&t.length>0&&(e.Authorization=`Firebase `+t)}function OD(e,t){e[`X-Firebase-Storage-Version`]=`webjs/`+(t??`AppManager`)}function kD(e,t){t&&(e[`X-Firebase-GMPID`]=t)}function AD(e,t){t!==null&&(e[`X-Firebase-AppCheck`]=t)}function jD(e,t,n,r,i,a,o=!0,s=!1){let c=SD(e.urlParams),l=e.url+c,u=Object.assign({},e.headers);return kD(u,t),DD(u,n),OD(u,a),AD(u,r),new TD(l,e.method,u,e.body,e.successCodes,e.additionalRetryCodes,e.handler,e.errorHandler,e.timeout,e.progressCallback,i,o,s)}function MD(){if(typeof BlobBuilder<`u`)return BlobBuilder;if(typeof WebKitBlobBuilder<`u`)return WebKitBlobBuilder}function ND(...e){let t=MD();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(yD())return new Blob(e);else throw new HE($.UNSUPPORTED_ENVIRONMENT,`This browser doesn't seem to support creating Blobs`)}function PD(e,t,n){return e.webkitSlice?e.webkitSlice(t,n):e.mozSlice?e.mozSlice(t,n):e.slice?e.slice(t,n):null}function FD(e){if(typeof atob>`u`)throw iD(`base-64`);return atob(e)}var ID={RAW:`raw`,BASE64:`base64`,BASE64URL:`base64url`,DATA_URL:`data_url`},LD=class{constructor(e,t){this.data=e,this.contentType=t||null}};function RD(e,t){switch(e){case ID.RAW:return new LD(zD(t));case ID.BASE64:case ID.BASE64URL:return new LD(VD(e,t));case ID.DATA_URL:return new LD(UD(t),WD(t))}throw WE()}function zD(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 BD(e){let t;try{t=decodeURIComponent(e)}catch{throw cD(ID.DATA_URL,`Malformed data URL.`)}return zD(t)}function VD(e,t){switch(e){case ID.BASE64:{let n=t.indexOf(`-`)!==-1,r=t.indexOf(`_`)!==-1;if(n||r)throw cD(e,`Invalid character '`+(n?`-`:`_`)+`' found: is it base64url encoded?`);break}case ID.BASE64URL:{let n=t.indexOf(`+`)!==-1,r=t.indexOf(`/`)!==-1;if(n||r)throw cD(e,`Invalid character '`+(n?`+`:`/`)+`' found: is it base64 encoded?`);t=t.replace(/-/g,`+`).replace(/_/g,`/`);break}}let n;try{n=FD(t)}catch(t){throw t.message.includes(`polyfill`)?t:cD(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 HD=class{constructor(e){this.base64=!1,this.contentType=null;let t=e.match(/^data:([^,]+)?,/);if(t===null)throw cD(ID.DATA_URL,`Must be formatted 'data:[<mediatype>][;base64],<data>`);let n=t[1]||null;n!=null&&(this.base64=GD(n,`;base64`),this.contentType=this.base64?n.substring(0,n.length-7):n),this.rest=e.substring(e.indexOf(`,`)+1)}};function UD(e){let t=new HD(e);return t.base64?VD(ID.BASE64,t.rest):BD(t.rest)}function WD(e){return new HD(e).contentType}function GD(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}var KD=class e{constructor(e,t){let n=0,r=``;vD(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(vD(this.data_)){let r=this.data_,i=PD(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(yD()){let n=t.map(t=>t instanceof e?t.data_:t);return new e(ND.apply(null,n))}else{let n=t.map(e=>_D(e)?RD(ID.RAW,e).data:e.data_),r=0;
22n.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 qD(e){let t;try{t=JSON.parse(e)}catch{return null}return gD(t)?t:null}function JD(e){if(e.length===0)return null;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function YD(e,t){let n=t.split(`/`).filter(e=>e.length>0).join(`/`);return e.length===0?n:e+`/`+n}function XD(e){let t=e.lastIndexOf(`/`,e.length-2);return t===-1?e:e.slice(t+1)}function ZD(e,t){return t}var QD=class{constructor(e,t,n,r){this.server=e,this.local=t||e,this.writable=!!n,this.xform=r||ZD}},$D=null;function eO(e){return!_D(e)||e.length<2?e:XD(e)}function tO(){if($D)return $D;let e=[];e.push(new QD(`bucket`)),e.push(new QD(`generation`)),e.push(new QD(`metageneration`)),e.push(new QD(`name`,`fullPath`,!0));function t(e,t){return eO(t)}let n=new QD(`name`);n.xform=t,e.push(n);function r(e,t){return t===void 0?t:Number(t)}let i=new QD(`size`);return i.xform=r,e.push(i),e.push(new QD(`timeCreated`)),e.push(new QD(`updated`)),e.push(new QD(`md5Hash`,null,!0)),e.push(new QD(`cacheControl`,null,!0)),e.push(new QD(`contentDisposition`,null,!0)),e.push(new QD(`contentEncoding`,null,!0)),e.push(new QD(`contentLanguage`,null,!0)),e.push(new QD(`contentType`,null,!0)),e.push(new QD(`metadata`,`customMetadata`,!0)),$D=e,$D}function nO(e,t){function n(){let n=e.bucket,r=e.fullPath,i=new uD(n,r);return t._makeStorageReference(i)}Object.defineProperty(e,"ref",{get:n})}function rO(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 nO(r,e),r}function iO(e,t,n){let r=qD(t);return r===null?null:rO(e,r,n)}function aO(e,t,n,r){let i=qD(t);if(i===null||!_D(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 xD(`/b/`+o(i)+`/o/`+o(a),n,r)+SD({alt:`media`,token:t})})[0]}function oO(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 sO=`prefixes`,cO=`items`;function lO(e,t,n){let r={prefixes:[],items:[],nextPageToken:n.nextPageToken};if(n[sO])for(let i of n[sO]){let n=i.replace(/\/$/,``),a=e._makeStorageReference(new uD(t,n));r.prefixes.push(a)}if(n[cO])for(let i of n[cO]){let n=e._makeStorageReference(new uD(t,i.name));r.items.push(n)}return r}function uO(e,t,n){let r=qD(n);return r===null?null:lO(e,t,r)}var dO=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 fO(e){if(!e)throw WE()}function pO(e,t){function n(n,r){let i=iO(e,r,t);return fO(i!==null),i}return n}function mO(e,t){function n(n,r){let i=uO(e,t,r);return fO(i!==null),i}return n}function hO(e,t){function n(n,r){let i=iO(e,r,t);return fO(i!==null),aO(i,r,e.host,e._protocol)}return n}function gO(e){function t(t,n){let r;return r=t.getStatus()===401?t.getErrorText().includes(`Firebase App Check token is invalid`)?JE():qE():t.getStatus()===402?KE(e.bucket):t.getStatus()===403?YE(e.path):n,r.status=t.getStatus(),r.serverResponse=n.serverResponse,r}return t}function _O(e){let t=gO(e);function n(n,r){let i=t(n,r);return n.getStatus()===404&&(i=GE(e.path)),i.serverResponse=r.serverResponse,i}return n}function vO(e,t,n){let r=xD(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime,a=new dO(r,`GET`,pO(e,n),i);return a.errorHandler=_O(t),a}function yO(e,t,n,r,i){let a={};t.isRoot?a.prefix=``:a.prefix=t.path+`/`,n&&n.length>0&&(a.delimiter=n),r&&(a.pageToken=r),i&&(a.maxResults=i);let o=xD(t.bucketOnlyServerUrl(),e.host,e._protocol),s=e.maxOperationRetryTime,c=new dO(o,`GET`,mO(e,t.bucket),s);return c.urlParams=a,c.errorHandler=gO(t),c}function bO(e,t,n){let r=xD(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime,a=new dO(r,`GET`,hO(e,n),i);return a.errorHandler=_O(t),a}function xO(e,t,n,r){let i=xD(t.fullServerUrl(),e.host,e._protocol),a=oO(n,r),o={"Content-Type":`application/json; charset=utf-8`},s=e.maxOperationRetryTime,c=new dO(i,`PATCH`,pO(e,r),s);return c.headers=o,c.body=a,c.errorHandler=_O(t),c}function SO(e,t){let n=xD(t.fullServerUrl(),e.host,e._protocol),r=e.maxOperationRetryTime;function i(e,t){}let a=new dO(n,`DELETE`,i,r);return a.successCodes=[200,204],a.errorHandler=_O(t),a}function CO(e,t){return e&&e.contentType||t&&t.type()||`application/octet-stream`}function wO(e,t,n){let r=Object.assign({},n);return r.fullPath=e.path,r.size=t.size(),r.contentType||=CO(null,t),r}function TO(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=wO(t,r,i),u=oO(l,n),d=`--`+c+`\r 23Content-Type: application/json; charset=utf-8\r 24\r 25`+u+`\r 26--`+c+`\r 27Content-Type: `+l.contentType+`\r 28\r 29`,f=`\r 30--`+c+`--`,p=KD.getBlob(d,r,f);if(p===null)throw tD();let m={name:l.fullPath},h=xD(a,e.host,e._protocol),g=e.maxUploadRetryTime,ee=new dO(h,`POST`,pO(e,n),g);
30return ee.urlParams=m,ee.headers=o,ee.body=p.uploadData(),ee.errorHandler=gO(t),ee}var EO=class{constructor(e,t,n,r){this.current=e,this.total=t,this.finalized=!!n,this.metadata=r||null}};function DO(e,t){let n=null;try{n=e.getResponseHeader(`X-Goog-Upload-Status`)}catch{fO(!1)}return fO(!!n&&(t||[`active`]).indexOf(n)!==-1),n}function OO(e,t,n,r,i){let a=t.bucketOnlyServerUrl(),o=wO(t,r,i),s={name:o.fullPath},c=xD(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=oO(o,n),d=e.maxUploadRetryTime;function f(e){DO(e);let t;try{t=e.getResponseHeader(`X-Goog-Upload-URL`)}catch{fO(!1)}return fO(_D(t)),t}let p=new dO(c,`POST`,f,d);return p.urlParams=s,p.headers=l,p.body=u,p.errorHandler=gO(t),p}function kO(e,t,n,r){let i={"X-Goog-Upload-Command":`query`};function a(e){let t=DO(e,[`active`,`final`]),n=null;try{n=e.getResponseHeader(`X-Goog-Upload-Size-Received`)}catch{fO(!1)}n||fO(!1);let i=Number(n);return fO(!isNaN(i)),new EO(i,r.size(),t===`final`)}let o=e.maxUploadRetryTime,s=new dO(n,`POST`,a,o);return s.headers=i,s.errorHandler=gO(t),s}var AO=256*1024;function jO(e,t,n,r,i,a,o,s){let c=new EO(0,0);if(o?(c.current=o.current,c.total=o.total):(c.current=0,c.total=r.size()),r.size()!==c.total)throw nD();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 tD();function g(e,n){let i=DO(e,[`active`,`final`]),o=c.current+u,s=r.size(),l;return l=i===`final`?pO(t,a)(e,n):null,new EO(o,s,i===`final`,l)}let ee=t.maxUploadRetryTime,te=new dO(n,`POST`,g,ee);return te.headers=m,te.body=h.uploadData(),te.progressCallback=s||null,te.errorHandler=gO(e),te}var MO={STATE_CHANGED:`state_changed`},NO={RUNNING:`running`,PAUSED:`paused`,SUCCESS:`success`,CANCELED:`canceled`,ERROR:`error`};function PO(e){switch(e){case`running`:case`pausing`:case`canceling`:return NO.RUNNING;case`paused`:return NO.PAUSED;case`success`:return NO.SUCCESS;case`canceled`:return NO.CANCELED;case`error`:return NO.ERROR;default:return NO.ERROR}}var FO=class{constructor(e,t,n){if(hD(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 IO(e){return(...t)=>{Promise.resolve().then(()=>e(...t))}}var LO=class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=CD.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener(`abort`,()=>{this.errorCode_=CD.ABORT,e()}),this.xhr_.addEventListener(`error`,()=>{this.errorCode_=CD.NETWORK_ERROR,e()}),this.xhr_.addEventListener(`load`,()=>{e()})})}send(e,t,n,r,i){if(this.sent_)throw lD(`cannot .send() more than once`);if(Ze(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 lD(`cannot .getErrorCode() before sending`);return this.errorCode_}getStatus(){if(!this.sent_)throw lD(`cannot .getStatus() before sending`);try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw lD(`cannot .getResponse() before sending`);return this.xhr_.response}getErrorText(){if(!this.sent_)throw lD(`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)}},RO=class extends LO{initXhr(){this.xhr_.responseType=`text`}};function zO(){return new RO}var BO=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=tO(),this._resumable=this._shouldDoResumable(this._blob),this._state=`running`,this._errorHandler=e=>{if(this._request=void 0,this._chunkMultiplier=1,e._codeEquals($.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{let t=this.isExponentialBackoffExpired();if(wD(e.status,[]))if(t)e=XE();else{this.sleepTime=Math.max(this.sleepTime*2,VE),this._needToFetchStatus=!0,this.completeTransitions_();return}this._error=e,this._transition(`error`)}},this._metadataErrorHandler=e=>{this._request=void 0,e._codeEquals($.CANCELED)?this.completeTransitions_():(this._error=e,this._transition(`error`))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((e,t)=>
vendor: 5,655 bytes, line 30
30{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=OO(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,zO,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=kO(this._ref.storage,this._ref._location,e,this._blob),i=this._ref.storage._makeRequest(r,zO,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=AO*this._chunkMultiplier,t=new EO(this._transferred,this._blob.size()),n=this._uploadUrl;this._resolveToken((r,i)=>{let a;try{a=jO(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,zO,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(){AO*this._chunkMultiplier*2<32*1024*1024&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{let n=vO(this._ref.storage,this._ref._location,this._mappings),r=this._ref.storage._makeRequest(n,zO,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=TO(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,zO,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=ZE(),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=PO(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 FO(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(PO(this._state)){case NO.SUCCESS:IO(this._resolve.bind(null,this.snapshot))();break;case NO.CANCELED:case NO.ERROR:let t=this._reject;IO(t.bind(null,this._error))();break;default:e=!1;break}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(PO(this._state)){case NO.RUNNING:case NO.PAUSED:e.next&&IO(e.next.bind(e,this.snapshot))();break;case NO.SUCCESS:e.complete&&IO(e.complete.bind(e))();break;case NO.CANCELED:case NO.ERROR:e.error&&IO(e.error.bind(e,this._error))();break;default:e.error&&IO(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}},VO=class e{constructor(e,t){this._service=e,t instanceof uD?this._location=t:this._location=uD.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 uD(this._location.bucket,``);return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}
30get name(){return XD(this._location.path)}get storage(){return this._service}get parent(){let t=JD(this._location.path);if(t===null)return null;let n=new uD(this._location.bucket,t);return new e(this._service,n)}_throwIfRoot(e){if(this._location.path===``)throw sD(e)}};function HO(e,t,n){return e._throwIfRoot(`uploadBytesResumable`),new BO(e,new KD(t),n)}function UO(e){let t={prefixes:[],items:[]};return WO(e,t).then(()=>t)}async function WO(e,t,n){let r=await GO(e,{pageToken:n});t.prefixes.push(...r.prefixes),t.items.push(...r.items),r.nextPageToken!=null&&await WO(e,t,r.nextPageToken)}function GO(e,t){t!=null&&typeof t.maxResults==`number`&&bD(`options.maxResults`,1,1e3,t.maxResults);let n=t||{},r=yO(e.storage,e._location,`/`,n.pageToken,n.maxResults);return e.storage.makeRequestWithTokens(r,zO)}function KO(e){e._throwIfRoot(`getMetadata`);let t=vO(e.storage,e._location,tO());return e.storage.makeRequestWithTokens(t,zO)}function qO(e,t){e._throwIfRoot(`updateMetadata`);let n=xO(e.storage,e._location,t,tO());return e.storage.makeRequestWithTokens(n,zO)}function JO(e){e._throwIfRoot(`getDownloadURL`);let t=bO(e.storage,e._location,tO());return e.storage.makeRequestWithTokens(t,zO).then(e=>{if(e===null)throw rD();return e})}function YO(e){e._throwIfRoot(`deleteObject`);let t=SO(e.storage,e._location);return e.storage.makeRequestWithTokens(t,zO)}function XO(e,t){let n=YD(e._location.path,t),r=new uD(e._location.bucket,n);return new VO(e.storage,r)}function ZO(e){return/^[A-Za-z]+:\/\//.test(e)}function QO(e,t){return new VO(e,t)}function $O(e,t){if(e instanceof rk){let n=e;if(n._bucket==null)throw eD();let r=new VO(n,n._bucket);return t==null?r:$O(r,t)}else if(t!==void 0)return XO(e,t);else return e}function ek(e,t){if(t&&ZO(t)){if(e instanceof rk)return QO(e,t);throw aD(`To use ref(service, url), the first argument must be a Storage instance.`)}else return $O(e,t)}function tk(e,t){let n=t?.[RE];return n==null?null:uD.makeFromBucketSpec(n,e)}function nk(e,t,n,r={}){e.host=`${t}:${n}`;let i=Ze(t);i&&Qe(`https://${e.host}/b`),e._isUsingEmulator=!0,e._protocol=i?`https`:`http`;let{mockUserToken:a}=r;a&&(e._overrideAuthToken=typeof a==`string`?a:me(a,e.app.options.projectId))}var rk=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=LE,this._protocol=`https`,this._appId=null,this._deleted=!1,this._maxOperationRetryTime=zE,this._maxUploadRetryTime=BE,this._requests=new Set,r==null?this._bucket=tk(this._host,this.app.options):this._bucket=uD.makeFromBucketSpec(r,this._host)}get host(){return this._host}set host(e){this._host=e,this._url==null?this._bucket=tk(e,this.app.options):this._bucket=uD.makeFromBucketSpec(this._url,e)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){bD(`time`,0,1/0,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){bD(`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(w(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 VO(this,e)}_makeRequest(e,t,n,r,i=!0){if(this._deleted)return new dD(oD());{let a=jD(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()}},ik=`@firebase/storage`,ak=`0.14.3`,ok=`storage`;function sk(e,t,n){return e=y(e),HO(e,t,n)}function ck(e){return e=y(e),KO(e)}function lk(e,t){return e=y(e),qO(e,t)}function uk(e,t){return e=y(e),GO(e,t)}function dk(e){return e=y(e),UO(e)}function fk(e){return e=y(e),JO(e)}function pk(e){return e=y(e),YO(e)}function mk(e,t){return e=y(e),ek(e,t)}function hk(e,t){return XO(e,t)}function gk(e=Nn(),t){e=y(e);let n=Sn(e,ok).getImmediate({identifier:t}),r=ue(`storage`);return r&&_k(n,...r),n}function _k(e,t,n,r={}){nk(e,t,n,r)}function vk(e,{instanceIdentifier:t}){return new rk(e.getProvider(`app`).getImmediate(),e.getProvider(`auth-internal`),e.getProvider(`app-check-internal`),t,An)}function yk(){xn(new b(ok,vk,`PUBLIC`).setMultipleInstances(!0)),T(ik,ak,``),T(ik,ak,`esm2020`)}yk();var bk=class{constructor(e,t,n){this._delegate=e,this.task=t,this.ref=n}get bytesTransferred(){return this._delegate.bytesTransferred}get metadata(){return this._delegate.metadata}get state(){return this._delegate.state}get totalBytes(){return this._delegate.totalBytes}},xk=class{constructor(e,t){this._delegate=e,this._ref=t,this.cancel=this._delegate.cancel.bind(this._delegate),this.catch=this._delegate.catch.bind(this._delegate),this.pause=this._delegate.pause.bind(this._delegate),this.resume=this._delegate.resume.bind(this._delegate)}get snapshot(){return new bk(this._delegate.snapshot,this,this._ref)}then(e,t){return this._delegate.then(t=>{if(e)return e(new bk(t,this,this._ref))},t)}on(e,t,n,r){let i;return t&&(i=typeof t==`function`?e=>t(new bk(e,this,this._ref)):{next:t.next?e=>t.next(new bk(e,this,this._ref)):void 0,complete:t.complete||void 0,error:t.error||void 0}),this._delegate.on(e,i,n||void 0,r||void 0)}},Sk=class{constructor(e,t){this._delegate=e,this._service=t}get prefixes(){return this._delegate.prefixes.map(e=>new Ck(e,this._service))}get items(){return this._delegate.items.map(e=>new Ck(e,this._service))}get nextPageToken(){return this._delegate.nextPageToken||null}},Ck=class e{constructor(e,t){this._delegate=e,this.storage=t}get name(){return this._delegate.name}get bucket(){return this._delegate.bucket}get fullPath(){return this._delegate.fullPath}toString(){return this._delegate.toString()}child(t){return new e(hk(this._delegate,t),this.storage)}get root(){return new e(this._delegate.root,this.storage)}get parent(){let t=this._delegate.parent;return t==null?null:new e(t,this.storage)}put(e,t){return this._throwIfRoot(`put`),new xk(sk(this._delegate,e,t),this)}putString(e,t=ID.RAW,n){this._throwIfRoot(`putString`);let r=RD(t,e),i={...n};return i.contentType==null&&r.contentType!=null&&(i.contentType=r.contentType),new xk(new BO(this._delegate,new KD(r.data,!0),i),this)}listAll(){return dk(this._delegate).then(e=>new Sk(e,this.storage))}list(e){return uk(this._delegate,e||void 0).then(e=>new Sk(e,this.storage))}getMetadata(){return ck(this._delegate)}updateMetadata(e){return lk(this._delegate,e)}getDownloadURL(){return fk(this._delegate)}delete(){return this._throwIfRoot(`delete`),pk(this._delegate)}_throwIfRoot(e){if(this._delegate._location.path===``)throw sD(e)}},wk=class{constructor(e,t){this.app=e,this._delegate=t}get maxOperationRetryTime(){return this._delegate.maxOperationRetryTime}get maxUploadRetryTime(){return this._delegate.maxUploadRetryTime}ref(e){if(Tk(e))throw aD(`ref() expected a child path but got a URL, use refFromURL instead.`);return new Ck(mk(this._delegate,e),this)}refFromURL(e){if(!Tk(e))throw aD(`refFromURL() expected a full URL but got a child path, use ref() instead.`);try{uD.makeFromUrl(e,this._delegate.host)}catch{throw aD(`refFromUrl() expected a valid full URL but got an invali
30d one.`)}return new Ck(mk(this._delegate,e),this)}setMaxUploadRetryTime(e){this._delegate.maxUploadRetryTime=e}setMaxOperationRetryTime(e){this._delegate.maxOperationRetryTime=e}useEmulator(e,t,n={}){_k(this._delegate,e,t,n)}};function Tk(e){return/^[A-Za-z]+:\/\//.test(e)}var Ek=`@firebase/storage-compat`,Dk=`0.4.3`,Ok=`storage-compat`;function kk(e,{instanceIdentifier:t}){return new wk(e.getProvider(`app-compat`).getImmediate(),e.getProvider(`storage`).getImmediate({identifier:t}))}function Ak(e){let t={TaskState:NO,TaskEvent:MO,StringFormat:ID,Storage:wk,Reference:Ck};e.INTERNAL.registerComponent(new b(Ok,kk,`PUBLIC`).setServiceProps(t).setMultipleInstances(!0)),e.registerVersion(Ek,Dk)}Ak(ur);var jk=`type.googleapis.com/google.protobuf.Int64Value`,Mk=`type.googleapis.com/google.protobuf.UInt64Value`;function Nk(e,t){let n={};for(let r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r]));return n}function Pk(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=>Pk(e));if(typeof e==`function`||typeof e==`object`)return Nk(e,e=>Pk(e));throw Error(`Data cannot be encoded in JSON: `+e)}function Fk(e){if(e==null)return e;if(e[`@type`])switch(e[`@type`]){case jk:case Mk:{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=>Fk(e)):typeof e==`function`||typeof e==`object`?Nk(e,e=>Fk(e)):e}var Ik=`functions`,Lk={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`},Rk=class e extends ke{constructor(t,n,r){super(`${Ik}/${t}`,n||``),this.details=r,Object.setPrototypeOf(this,e.prototype)}};function zk(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 Bk(e,t){let n=zk(e),r=n,i;try{let e=t&&t.error;if(e){let t=e.status;if(typeof t==`string`){if(!Lk[t])return new Rk(`internal`,`internal`);n=Lk[t],r=t}let a=e.message;typeof a==`string`&&(r=a),i=e.details,i!==void 0&&(i=Fk(i))}}catch{}return n===`ok`?null:new Rk(n,r,i)}var Vk=class{constructor(e,t,n,r){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,w(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)}}},Hk=`us-central1`,Uk=/^data: (.*?)(?:\n|$)/;function Wk(e){let t=null;return{promise:new Promise((n,r)=>{t=setTimeout(()=>{r(new Rk(`deadline-exceeded`,`deadline-exceeded`))},e)}),cancel:()=>{t&&clearTimeout(t)}}}var Gk=class{constructor(e,t,n,r,i=Hk,a=(...e)=>fetch(...e)){this.app=e,this.fetchImpl=a,this.emulatorOrigin=null,this.contextProvider=new Vk(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=Hk}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 Kk(e,t,n){let r=Ze(t);e.emulatorOrigin=`http${r?`s`:``}://${t}:${n}`,r&&Qe(e.emulatorOrigin+`/backends`)}function qk(e,t,n){let r=r=>Qk(e,t,r,n||{});return r.stream=(n,r)=>eA(e,t,n,r),r}function Jk(e,t,n){let r=r=>$k(e,t,r,n||{});return r.stream=(n,r)=>tA(e,t,n,r||{}),r}function Yk(e){return e.emulatorOrigin&&Ze(e.emulatorOrigin)?`include`:void 0}async function Xk(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:Yk(i)})}catch{return{status:0,json:null}}let o=null;try{o=await a.json()}catch{}return{status:a.status,json:o}}async function Zk(e,t){let n={},r=await e.contextProvider.getContext(t.limitedUseAppCheckTokens);return r.authToken&&(n.Authorization=`Bearer `+r.authToken),r.messagingToken&&
30(n[`Firebase-Instance-ID-Token`]=r.messagingToken),r.appCheckToken!==null&&(n[`X-Firebase-AppCheck`]=r.appCheckToken),n}function Qk(e,t,n,r){return $k(e,e._url(t),n,r)}async function $k(e,t,n,r){n=Pk(n);let i={data:n},a=await Zk(e,r),o=Wk(r.timeout||7e4),s=await Promise.race([Xk(t,i,a,e.fetchImpl,e),o.promise,e.cancelAllRequests]);if(o.cancel(),!s)throw new Rk(`cancelled`,`Firebase Functions instance was deleted.`);let c=Bk(s.status,s.json);if(c)throw c;if(!s.json)throw new Rk(`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 Rk(`internal`,`Response is missing data field.`);return{data:Fk(l)}}function eA(e,t,n,r){return tA(e,e._url(t),n,r||{})}async function tA(e,t,n,r){n=Pk(n);let i={data:n},a=await Zk(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:Yk(e)})}catch(e){if(e instanceof Error&&e.name===`AbortError`){let e=new Rk(`cancelled`,`Request was cancelled.`);return{data:Promise.reject(e),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(e)}}}}}}let t=Bk(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 Rk(`cancelled`,`Request was cancelled.`);c(e)});let u=nA(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 nA(e,t,n,r){let i=(e,r)=>{let i=e.match(Uk);if(!i)return;let a=i[1];try{let e=JSON.parse(a);if(`result`in e){t(Fk(e.result));return}if(`message`in e){r.enqueue(Fk(e.message));return}if(`error`in e){let t=Bk(0,e);r.error(t),n(t);return}}catch(e){if(e instanceof Rk){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 Rk(`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 Rk(`cancelled`,`Request was cancelled`);t.error(r),n(r),await e.cancel();return}o+=a.decode(c,{stream:!0});let u=o.split(` 31`);o=u.pop()||``;for(let e of u)e.trim()&&i(e.trim(),t);return s()}catch(e){let r=e instanceof Rk?e:Bk(0,null);t.error(r),n(r)}}},cancel(){return e.cancel()}})}var rA=`@firebase/functions`,iA=`0.13.5`,aA=`auth-internal`,oA=`app-check-internal`,sA=`messaging-internal`;function cA(e){xn(new b(Ik,(e,{instanceIdentifier:t})=>new Gk(e.getProvider(`app`).getImmediate(),e.getProvider(aA),e.getProvider(sA),e.getProvider(oA),t),`PUBLIC`).setMultipleInstances(!0)),T(rA,iA,e),T(rA,iA,`esm2020`)}function lA(e=Nn(),t=Hk){let n=Sn(y(e),Ik).getImmediate({identifier:t}),r=ue(`functions`);return r&&uA(n,...r),n}function uA(e,t,n){Kk(y(e),t,n)}function dA(e,t,n){return qk(y(e),t,n)}function fA(e,t,n){return Jk(y(e),t,n)}cA();var pA=`@firebase/functions-compat`,mA=`0.4.5`,hA=class{constructor(e,t){this.app=e,this._delegate=t,this._region=this._delegate.region,this._customDomain=this._delegate.customDomain}httpsCallable(e,t){return dA(this._delegate,e,t)}httpsCallableFromURL(e,t){return fA(this._delegate,e,t)}useFunctionsEmulator(e){let t=e.match(`[a-zA-Z]+://([a-zA-Z0-9.-]+)(?::([0-9]+))?`);if(t==null)throw new ke(`functions`,`No origin provided to useFunctionsEmulator()`);if(t[2]==null)throw new ke(`functions`,`Port missing in origin provided to useFunctionsEmulator()`);return uA(this._delegate,t[1],Number(t[2]))}useEmulator(e,t){return uA(this._delegate,e,t)}},gA=`us-central1`,_A=(e,{instanceIdentifier:t})=>new hA(e.getProvider(`app-compat`).getImmediate(),e.getProvider(`functions`).getImmediate({identifier:t??gA}));function vA(){let e={Functions:hA};ur.INTERNAL.registerComponent(new b(`functions-compat`,_A,`PUBLIC`).setServiceProps(e).setMultipleInstances(!0))}vA(),ur.registerVersion(pA,mA);var yA=`@firebase/installations`,bA=`0.6.22`,xA=1e4,SA=`w:${bA}`,CA=`FIS_v2`,wA=`https://firebaseinstallations.googleapis.com/v1`,TA=3600*1e3,EA=new Ae(`installations`,`Installations`,{"missing-app-config-values":`Missing App configuration value: "{$valueName}"`,"not-registered":`Firebase Installation is not registered.`,"installation-not-found":`Firebase Installation not found.`,"request-failed":`{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"`,"app-offline":`Could not process request. Application offline.`,"delete-pending-registration":`Can't delete installation while there is a pending registration request.`});function DA(e){return e instanceof ke&&e.code.includes(`request-failed`)}function OA({projectId:e}){return`${wA}/projects/${e}/installations`}
31function kA(e){return{token:e.token,requestStatus:2,expiresIn:PA(e.expiresIn),creationTime:Date.now()}}async function AA(e,t){let n=(await t.json()).error;return EA.create(`request-failed`,{requestName:e,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function jA({apiKey:e}){return new Headers({"Content-Type":`application/json`,Accept:`application/json`,"x-goog-api-key":e})}function MA(e,{refreshToken:t}){let n=jA(e);return n.append(`Authorization`,FA(t)),n}async function NA(e){let t=await e();return t.status>=500&&t.status<600?e():t}function PA(e){return Number(e.replace(`s`,`000`))}function FA(e){return`${CA} ${e}`}async function IA({appConfig:e,heartbeatServiceProvider:t},{fid:n}){let r=OA(e),i=jA(e),a=t.getImmediate({optional:!0});if(a){let e=await a.getHeartbeatsHeader();e&&i.append(`x-firebase-client`,e)}let o={fid:n,authVersion:CA,appId:e.appId,sdkVersion:SA},s={method:`POST`,headers:i,body:JSON.stringify(o)},c=await NA(()=>fetch(r,s));if(c.ok){let e=await c.json();return{fid:e.fid||n,registrationStatus:2,refreshToken:e.refreshToken,authToken:kA(e.authToken)}}else throw await AA(`Create Installation`,c)}function LA(e){return new Promise(t=>{setTimeout(t,e)})}function RA(e){return btoa(String.fromCharCode(...e)).replace(/\+/g,`-`).replace(/\//g,`_`)}var zA=/^[cdef][\w-]{21}$/,BA=``;function VA(){try{let e=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(e),e[0]=112+e[0]%16;let t=HA(e);return zA.test(t)?t:BA}catch{return BA}}function HA(e){return RA(e).substr(0,22)}function UA(e){return`${e.appName}!${e.appId}`}var WA=new Map;function GA(e,t){let n=UA(e);KA(n,t),qA(n,t)}function KA(e,t){let n=WA.get(e);if(n)for(let e of n)e(t)}function qA(e,t){let n=YA();n&&n.postMessage({key:e,fid:t}),XA()}var JA=null;function YA(){return!JA&&`BroadcastChannel`in self&&(JA=new BroadcastChannel(`[Firebase] FID Change`),JA.onmessage=e=>{KA(e.data.key,e.data.fid)}),JA}function XA(){WA.size===0&&JA&&(JA.close(),JA=null)}var ZA=`firebase-installations-database`,QA=1,$A=`firebase-installations-store`,ej=null;function tj(){return ej||=At(ZA,QA,{upgrade:(e,t)=>{switch(t){case 0:e.createObjectStore($A)}}}),ej}async function nj(e,t){let n=UA(e),r=(await tj()).transaction($A,`readwrite`),i=r.objectStore($A),a=await i.get(n);return await i.put(t,n),await r.done,(!a||a.fid!==t.fid)&&GA(e,t.fid),t}async function rj(e){let t=UA(e),n=(await tj()).transaction($A,`readwrite`);await n.objectStore($A).delete(t),await n.done}async function ij(e,t){let n=UA(e),r=(await tj()).transaction($A,`readwrite`),i=r.objectStore($A),a=await i.get(n),o=t(a);return o===void 0?await i.delete(n):await i.put(o,n),await r.done,o&&(!a||a.fid!==o.fid)&&GA(e,o.fid),o}async function aj(e){let t,n=await ij(e.appConfig,n=>{let r=sj(e,oj(n));return t=r.registrationPromise,r.installationEntry});return n.fid===BA?{installationEntry:await t}:{installationEntry:n,registrationPromise:t}}function oj(e){return dj(e||{fid:VA(),registrationStatus:0})}function sj(e,t){if(t.registrationStatus===0){if(!navigator.onLine)return{installationEntry:t,registrationPromise:Promise.reject(EA.create(`app-offline`))};let n={fid:t.fid,registrationStatus:1,registrationTime:Date.now()};return{installationEntry:n,registrationPromise:cj(e,n)}}else if(t.registrationStatus===1)return{installationEntry:t,registrationPromise:lj(e)};else return{installationEntry:t}}async function cj(e,t){try{let n=await IA(e,t);return nj(e.appConfig,n)}catch(n){throw DA(n)&&n.customData.serverCode===409?await rj(e.appConfig):await nj(e.appConfig,{fid:t.fid,registrationStatus:0}),n}}async function lj(e){let t=await uj(e.appConfig);for(;t.registrationStatus===1;)await LA(100),t=await uj(e.appConfig);if(t.registrationStatus===0){let{installationEntry:t,registrationPromise:n}=await aj(e);return n||t}return t}function uj(e){return ij(e,e=>{if(!e)throw EA.create(`installation-not-found`);return dj(e)})}function dj(e){return fj(e)?{fid:e.fid,registrationStatus:0}:e}function fj(e){return e.registrationStatus===1&&e.registrationTime+xA<Date.now()}async function pj({appConfig:e,heartbeatServiceProvider:t},n){let r=mj(e,n),i=MA(e,n),a=t.getImmediate({optional:!0});if(a){let e=await a.getHeartbeatsHeader();e&&i.append(`x-firebase-client`,e)}let o={installation:{sdkVersion:SA,appId:e.appId}},s={method:`POST`,headers:i,body:JSON.stringify(o)},c=await NA(()=>fetch(r,s));if(c.ok)return kA(await c.json());throw await AA(`Generate Auth Token`,c)}function mj(e,{fid:t}){return`${OA(e)}/${t}/authTokens:generate`}async function hj(e,t=!1){let n,r=await ij(e.appConfig,r=>{if(!yj(r))throw EA.create(`not-registered`);let i=r.authToken;if(!t&&bj(i))return r;if(i.requestStatus===1)return n=gj(e,t),r;{if(!navigator.onLine)throw EA.create(`app-offline`);let t=Sj(r);return n=vj(e,t),t}});return n?await n:r.authToken}async function gj(e,t){let n=await _j(e.appConfig);for(;n.authToken.requestStatus===1;)await LA(100),n=await _j(e.appConfig);let r=n.authToken;return r.requestStatus===0?hj(e,t):r}function _j(e){return ij(e,e=>{if(!yj(e))throw EA.create(`not-registered`);let t=e.authToken;return Cj(t)?{...e,authToken:{requestStatus:0}}:e})}async function vj(e,t){try{let n=await pj(e,t),r={...t,authToken:n};return await nj(e.appConfig,r),n}catch(n){if(DA(n)&&(n.customData.serverCode===401||n.customData.serverCode===404))await rj(e.appConfig);else{let n={...t,authToken:{requestStatus:0}};await nj(e.appConfig,n)}throw n}}function yj(e){return e!==void 0&&e.registrationStatus===2}function bj(e){return e.requestStatus===2&&!xj(e)}function xj(e){let t=Date.now();
31return t<e.creationTime||e.creationTime+e.expiresIn<t+TA}function Sj(e){let t={requestStatus:1,requestTime:Date.now()};return{...e,authToken:t}}function Cj(e){return e.requestStatus===1&&e.requestTime+xA<Date.now()}async function wj(e){let t=e,{installationEntry:n,registrationPromise:r}=await aj(t);return r?r.catch(console.error):hj(t).catch(console.error),n.fid}async function Tj(e,t=!1){let n=e;return await Ej(n),(await hj(n,t)).token}async function Ej(e){let{registrationPromise:t}=await aj(e);t&&await t}function Dj(e){if(!e||!e.options)throw Oj(`App Configuration`);if(!e.name)throw Oj(`App Name`);for(let t of[`projectId`,`apiKey`,`appId`])if(!e.options[t])throw Oj(t);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}function Oj(e){return EA.create(`missing-app-config-values`,{valueName:e})}var kj=`installations`,Aj=`installations-internal`,jj=e=>{let t=e.getProvider(`app`).getImmediate();return{app:t,appConfig:Dj(t),heartbeatServiceProvider:Sn(t,`heartbeat`),_delete:()=>Promise.resolve()}},Mj=e=>{let t=Sn(e.getProvider(`app`).getImmediate(),kj).getImmediate();return{getId:()=>wj(t),getToken:e=>Tj(t,e)}};function Nj(){xn(new b(kj,jj,`PUBLIC`)),xn(new b(Aj,Mj,`PRIVATE`))}Nj(),T(yA,bA),T(yA,bA,`esm2020`);var Pj=`analytics`,Fj=`firebase_id`,Ij=`origin`,Lj=60*1e3,Rj=`https://firebase.googleapis.com/v1alpha/projects/-/apps/{app-id}/webConfig`,zj=`https://www.googletagmanager.com/gtag/js`,Bj=new lt(`@firebase/analytics`),Vj=new Ae(`analytics`,`Analytics`,{"already-exists":`A Firebase Analytics instance with the appId {$id} already exists. Only one Firebase Analytics instance can be created for each appId.`,"already-initialized":`initializeAnalytics() cannot be called again with different options than those it was initially called with. It can be called again with the same options to return the existing instance, or getAnalytics() can be used to get a reference to the already-initialized instance.`,"already-initialized-settings":`Firebase Analytics has already been initialized.settings() must be called before initializing any Analytics instanceor it will have no effect.`,"interop-component-reg-failed":`Firebase Analytics Interop Component failed to instantiate: {$reason}`,"invalid-analytics-context":`Firebase Analytics is not supported in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}`,"indexeddb-unavailable":`IndexedDB unavailable or restricted in this environment. Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments. Details: {$errorInfo}`,"fetch-throttle":`The config fetch request timed out while in an exponential backoff state. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.`,"config-fetch-failed":`Dynamic config fetch failed: [{$httpStatus}] {$responseMessage}`,"no-api-key":`The "apiKey" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid API key.`,"no-app-id":`The "appId" field is empty in the local Firebase config. Firebase Analytics requires this field tocontain a valid app ID.`,"no-client-id":`The "client_id" field is empty.`,"invalid-gtag-resource":`Trusted Types detected an invalid gtag resource: {$gtagURL}.`});function Hj(e){if(!e.startsWith(zj)){let t=Vj.create(`invalid-gtag-resource`,{gtagURL:e});return Bj.warn(t.message),``}return e}function Uj(e){return Promise.all(e.map(e=>e.catch(e=>e)))}function Wj(e,t){let n;return window.trustedTypes&&(n=window.trustedTypes.createPolicy(e,t)),n}function Gj(e,t){let n=Wj(`firebase-js-sdk-policy`,{createScriptURL:Hj}),r=document.createElement(`script`),i=`${zj}?l=${e}&id=${t}`;r.src=n?n?.createScriptURL(i):i,r.async=!0,document.head.appendChild(r)}function Kj(e){let t=[];return Array.isArray(window[e])?t=window[e]:window[e]=t,t}async function qj(e,t,n,r,i,a){let o=r[i];try{if(o)await t[o];else{let e=(await Uj(n)).find(e=>e.measurementId===i);e&&await t[e.appId]}}catch(e){Bj.error(e)}e(`config`,i,a)}async function Jj(e,t,n,r,i){try{let a=[];if(i&&i.send_to){let e=i.send_to;Array.isArray(e)||(e=[e]);let r=await Uj(n);for(let n of e){let e=r.find(e=>e.measurementId===n),i=e&&t[e.appId];if(i)a.push(i);else{a=[];break}}}a.length===0&&(a=Object.values(t)),await Promise.all(a),e(`event`,r,i||{})}catch(e){Bj.error(e)}}function Yj(e,t,n,r){async function i(i,...a){try{if(i===`event`){let[r,i]=a;await Jj(e,t,n,r,i)}else if(i===`config`){let[i,o]=a;await qj(e,t,n,r,i,o)}else if(i===`consent`){let[t,n]=a;e(`consent`,t,n)}else if(i===`get`){let[t,n,r]=a;e(`get`,t,n,r)}else if(i===`set`){let[t]=a;e(`set`,t)}else e(i,...a)}catch(e){Bj.error(e)}}return i}function Xj(e,t,n,r,i){let a=function(...e){window[r].push(arguments)};return window[i]&&typeof window[i]==`function`&&(a=window[i]),window[i]=Yj(a,e,t,n),{gtagCore:a,wrappedGtag:window[i]}}function Zj(e){let t=window.document.getElementsByTagName(`script`);for(let n of Object.values(t))if(n.src&&n.src.includes(zj)&&n.src.includes(e))return n;return null}var Qj=30,$j=1e3,eM=new class{constructor(e={},t=$j){this.throttleMetadata=e,this.intervalMillis=t}getThrottleMetadata(e){return this.throttleMetadata[e]}setThrottleMetadata(e,t){this.throttleMetadata[e]=t}deleteThrottleMetadata(e){delete this.throttleMetadata[e]}};function tM(e){return new Headers({Accept:`application/json`,"x-goog-api-key":e})}async function nM(e){let{appId:t,apiKey:n}=e,r={method:`GET`,headers:tM(n)},i=Rj.replace(`{app-id}`,t),a=await fetch(i,r);if(a.status!==200&&a.status!==304){let e=``;try{let t=await a.json();t.error?.message&&(e=t.error.message)}catch{}throw Vj.create(`config-fetch-failed`,{httpStatus:a.status,responseMessage:e})}return a.json()}async function rM(e,t=eM,n){let{appId:r,apiKey:i,measurementId:a}=e.options;if(!r)throw Vj.create(`no-app-id`);if(!i){if(a)return{measurementId:a,appId:r};throw Vj.create(`no-api-key`)}let o=t.getThrottleMetadata(r)||{backoffCount:0,throttleEndTimeMillis:Date.now()},s=new sM;return setTimeout(async()=>{s.abort()},n===void 0?Lj:n),iM({appId:r,apiKey:i,measurementId:a},o,s,t)}
31async function iM(e,{throttleEndTimeMillis:t,backoffCount:n},r,i=eM){let{appId:a,measurementId:o}=e;try{await aM(r,t)}catch(e){if(o)return Bj.warn(`Timed out fetching this Firebase app's measurement ID from the server. Falling back to the measurement ID ${o} provided in the "measurementId" field in the local Firebase config. [${e?.message}]`),{appId:a,measurementId:o};throw e}try{let t=await nM(e);return i.deleteThrottleMetadata(a),t}catch(t){let s=t;if(!oM(s)){if(i.deleteThrottleMetadata(a),o)return Bj.warn(`Failed to fetch this Firebase app's measurement ID from the server. Falling back to the measurement ID ${o} provided in the "measurementId" field in the local Firebase config. [${s?.message}]`),{appId:a,measurementId:o};throw t}let c=Number(s?.customData?.httpStatus)===503?Xe(n,i.intervalMillis,Qj):Xe(n,i.intervalMillis),l={throttleEndTimeMillis:Date.now()+c,backoffCount:n+1};return i.setThrottleMetadata(a,l),Bj.debug(`Calling attemptFetch again in ${c} millis`),iM(e,l,r,i)}}function aM(e,t){return new Promise((n,r)=>{let i=Math.max(t-Date.now(),0),a=setTimeout(n,i);e.addEventListener(()=>{clearTimeout(a),r(Vj.create(`fetch-throttle`,{throttleEndTimeMillis:t}))})})}function oM(e){if(!(e instanceof ke)||!e.customData)return!1;let t=Number(e.customData.httpStatus);return t===429||t===500||t===503||t===504}var sM=class{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach(e=>e())}},cM;async function lM(e,t,n,r,i){if(i&&i.global){e(`event`,n,r);return}else{let i=await t;e(`event`,n,{...r,send_to:i})}}async function uM(e,t,n,r){if(r&&r.global)return e(`set`,{screen_name:n}),Promise.resolve();e(`config`,await t,{update:!0,screen_name:n})}async function dM(e,t,n,r){if(r&&r.global)return e(`set`,{user_id:n}),Promise.resolve();e(`config`,await t,{update:!0,user_id:n})}async function fM(e,t,n,r){if(r&&r.global){let t={};for(let e of Object.keys(n))t[`user_properties.${e}`]=n[e];return e(`set`,t),Promise.resolve()}else e(`config`,await t,{update:!0,user_properties:n})}async function pM(e,t){let n=await e;window[`ga-disable-${n}`]=!t}var mM;function hM(e){mM=e}function gM(e){cM=e}async function _M(){if(Te())try{await Ee()}catch(e){return Bj.warn(Vj.create(`indexeddb-unavailable`,{errorInfo:e?.toString()}).message),!1}else return Bj.warn(Vj.create(`indexeddb-unavailable`,{errorInfo:`IndexedDB is not available in this environment.`}).message),!1;return!0}async function vM(e,t,n,r,i,a,o){let s=rM(e);s.then(t=>{n[t.measurementId]=t.appId,e.options.measurementId&&t.measurementId!==e.options.measurementId&&Bj.warn(`The measurement ID in the local Firebase config (${e.options.measurementId}) does not match the measurement ID fetched from the server (${t.measurementId}). To ensure analytics events are always sent to the correct Analytics property, update the measurement ID field in the local config or remove it from the local config.`)}).catch(e=>Bj.error(e)),t.push(s);let c=_M().then(e=>{if(e)return r.getId()}),[l,u]=await Promise.all([s,c]);Zj(a)||Gj(a,l.measurementId),mM&&(i(`consent`,`default`,mM),hM(void 0)),i(`js`,new Date);let d=o?.config??{};return d[Ij]=`firebase`,d.update=!0,u!=null&&(d[Fj]=u),i(`config`,l.measurementId,d),cM&&(i(`set`,cM),gM(void 0)),l.measurementId}var yM=class{constructor(e){this.app=e}_delete(){return delete bM[this.app.options.appId],Promise.resolve()}},bM={},xM=[],SM={},CM=`dataLayer`,wM=`gtag`,TM,EM,DM=!1;function OM(e){if(DM)throw Vj.create(`already-initialized`);e.dataLayerName&&(CM=e.dataLayerName),e.gtagName&&(wM=e.gtagName)}function kM(){let e=[];
31if(be()&&e.push(`This is a browser extension environment.`),De()||e.push(`Cookies are not available.`),e.length>0){let t=e.map((e,t)=>`(${t+1}) ${e}`).join(` `),n=Vj.create(`invalid-analytics-context`,{errorInfo:t});Bj.warn(n.message)}}function AM(e,t,n){kM();let r=e.options.appId;if(!r)throw Vj.create(`no-app-id`);if(!e.options.apiKey)if(e.options.measurementId)Bj.warn(`The "apiKey" field is empty in the local Firebase config. This is needed to fetch the latest measurement ID for this Firebase app. Falling back to the measurement ID ${e.options.measurementId} provided in the "measurementId" field in the local Firebase config.`);else throw Vj.create(`no-api-key`);if(bM[r]!=null)throw Vj.create(`already-exists`,{id:r});if(!DM){Kj(CM);let{wrappedGtag:e,gtagCore:t}=Xj(bM,xM,SM,CM,wM);EM=e,TM=t,DM=!0}return bM[r]=vM(e,xM,SM,t,TM,CM,n),new yM(e)}function jM(e=Nn()){e=y(e);let t=Sn(e,Pj);return t.isInitialized()?t.getImmediate():MM(e)}function MM(e,t={}){let n=Sn(e,Pj);if(n.isInitialized()){let e=n.getImmediate();if(v(t,n.getOptions()))return e;throw Vj.create(`already-initialized`)}return n.initialize({options:t})}async function NM(){if(be()||!De()||!Te())return!1;try{return await Ee()}catch{return!1}}function PM(e,t,n){e=y(e),uM(EM,bM[e.app.options.appId],t,n).catch(e=>Bj.error(e))}function FM(e,t,n){e=y(e),dM(EM,bM[e.app.options.appId],t,n).catch(e=>Bj.error(e))}function IM(e,t,n){e=y(e),fM(EM,bM[e.app.options.appId],t,n).catch(e=>Bj.error(e))}function LM(e,t){e=y(e),pM(bM[e.app.options.appId],t).catch(e=>Bj.error(e))}function RM(e,t,n,r){e=y(e),lM(EM,bM[e.app.options.appId],t,n,r).catch(e=>Bj.error(e))}var zM=`@firebase/analytics`,BM=`0.10.22`;function VM(){xn(new b(Pj,(e,{options:t})=>AM(e.getProvider(`app`).getImmediate(),e.getProvider(`installations-internal`).getImmediate(),t),`PUBLIC`)),xn(new b(`analytics-internal`,e,`PRIVATE`)),T(zM,BM),T(zM,BM,`esm2020`);function e(e){try{let t=e.getProvider(Pj).getImmediate();return{logEvent:(e,n,r)=>RM(t,e,n,r),setUserProperties:(e,n)=>IM(t,e,n)}}catch(e){throw Vj.create(`interop-component-reg-failed`,{reason:e})}}}VM();var HM=`@firebase/analytics-compat`,UM=`0.2.28`,WM=class{constructor(e,t){this.app=e,this._delegate=t}logEvent(e,t,n){RM(this._delegate,e,t,n)}setCurrentScreen(e,t){PM(this._delegate,e,t)}setUserId(e,t){FM(this._delegate,e,t)}setUserProperties(e,t){IM(this._delegate,e,t)}setAnalyticsCollectionEnabled(e){LM(this._delegate,e)}},GM;(function(e){e.ADD_SHIPPING_INFO=`add_shipping_info`,e.ADD_PAYMENT_INFO=`add_payment_info`,e.ADD_TO_CART=`add_to_cart`,e.ADD_TO_WISHLIST=`add_to_wishlist`,e.BEGIN_CHECKOUT=`begin_checkout`,e.CHECKOUT_PROGRESS=`checkout_progress`,e.EXCEPTION=`exception`,e.GENERATE_LEAD=`generate_lead`,e.LOGIN=`login`,e.PAGE_VIEW=`page_view`,e.PURCHASE=`purchase`,e.REFUND=`refund`,e.REMOVE_FROM_CART=`remove_from_cart`,e.SCREEN_VIEW=`screen_view`,e.SEARCH=`search`,e.SELECT_CONTENT=`select_content`,e.SELECT_ITEM=`select_item`,e.SELECT_PROMOTION=`select_promotion`,e.SET_CHECKOUT_OPTION=`set_checkout_option`,e.SHARE=`share`,e.SIGN_UP=`sign_up`,e.TIMING_COMPLETE=`timing_complete`,e.VIEW_CART=`view_cart`,e.VIEW_ITEM=`view_item`,e.VIEW_ITEM_LIST=`view_item_list`,e.VIEW_PROMOTION=`view_promotion`,e.VIEW_SEARCH_RESULTS=`view_search_results`})(GM||={});var KM=e=>new WM(e.getProvider(`app-compat`).getImmediate(),e.getProvider(`analytics`).getImmediate());function qM(){let e={Analytics:WM,settings:OM,isSupported:NM,EventName:GM};ur.INTERNAL.registerComponent(new b(`analytics-compat`,KM,`PUBLIC`).setServiceProps(e).setMultipleInstances(!0))}qM(),ur.registerVersion(HM,UM),T(`firebase`,`12.14.0`,`app`);var JM={ENV:`production`,FIREBASE_PROJECT_ID:`risk-memo-a024f`,FIREBASE_API_URL:`https://europe-west1-risk-memo-a024f.cloudfunctions.net/`,FIREBASE_REGION:`europe-west1`,FIREBASE_STORAGE_BUCKET:`risk-memo-a024f.appspot.com`,FIREBASE_AUTH_DOMAIN:`app.riskmemo.com`,FIREBASE_API_KEY:`AIzaSyCpiesrNvCJKlOuCNXccB5GSkV30yuaXSo`,FIREBASE_MESSAGING_SENDER_ID:`949910693517`,FIREBASE_APP_ID:`1:949910693517:web:8d9f0e7073be86151fa4c4`,FIREBASE_MEASUREMENT_ID:`G-LVZNFK1D25`,SITEKEY:`6LeHcmcrAAAAAP6igXGO6Wlu-qMpHPyVpcWE8Ijg`,EXAMPLE_CHECKLIST:`ed2d469e-0823-4c10-a282-af94408f9080`,SETTINGS_ID:`prAZLvKjAXuWF0FZ4mNT`,GOOGLE_MAP_KEY:`AIzaSyBpcUn2lEmU3ltidYU5KaG0R9dKDZsw9-o`,ILOVEPDF_PUBLIC_KEY:`project_public_97d596de26e88f92578ed3bd8f107677_OBr_P60c023a3d8021316aa8d3382a8021114`,ILOVEPDF_SECRET_KEY:`secret_key_086872c69e97ba0266c7e5dfe61f0191_Fg3BYa87c55dc7b4129ba47bb120a9ac6f24e`,HELP_SCOUT:`3e+8KmMkPAegA6OMrE0McAEF5MRbFFL/eI6bmkqu2Qg=`,CHECKLIST_URL:`https://checklist.riskmemo.com`},YM=new Map,XM={activated:!1,tokenObservers:[]},ZM={initialized:!1,enabled:!1};function QM(e){return YM.get(e)||{...XM}}function $M(e,t){return YM.set(e,t),YM.get(e)}function eN(){return ZM}var tN=`https://content-firebaseappcheck.googleapis.com/v1`,nN=`exchangeRecaptchaV3Token`,rN=`exchangeDebugToken`,iN={OFFSET_DURATION:300*1e3,RETRIAL_MIN_WAIT:30*1e3,RETRIAL_MAX_WAIT:960*1e3},aN=1440*60*1e3,oN=class{constructor(e,t,n,r,i){if(this.operation=e,this.retryPolicy=t,this.getWaitDuration=n,this.lowerBound=r,this.up
31perBound=i,this.pending=null,this.nextErrorWaitInterval=r,r>i)throw Error(`Proactive refresh lower bound greater than upper bound!`)}start(){this.nextErrorWaitInterval=this.lowerBound,this.process(!0).catch(()=>{})}stop(){this.pending&&=(this.pending.reject(`cancelled`),null)}isRunning(){return!!this.pending}async process(e){this.stop();try{this.pending=new pe,this.pending.promise.catch(e=>{}),await sN(this.getNextRun(e)),this.pending.resolve(),await this.pending.promise,this.pending=new pe,this.pending.promise.catch(e=>{}),await this.operation(),this.pending.resolve(),await this.pending.promise,this.process(!0).catch(()=>{})}catch(e){this.retryPolicy(e)?this.process(!1).catch(()=>{}):this.stop()}}getNextRun(e){if(e)return this.nextErrorWaitInterval=this.lowerBound,this.getWaitDuration();{let e=this.nextErrorWaitInterval;return this.nextErrorWaitInterval*=2,this.nextErrorWaitInterval>this.upperBound&&(this.nextErrorWaitInterval=this.upperBound),e}}};function sN(e){return new Promise(t=>{setTimeout(t,e)})}var cN=new Ae(`appCheck`,`AppCheck`,{"already-initialized":`You have already called initializeAppCheck() for FirebaseApp {$appName} with different options. To avoid this error, call initializeAppCheck() with the same options as when it was originally called. This will return the already initialized instance.`,"use-before-activation":`App Check is being used before initializeAppCheck() is called for FirebaseApp {$appName}. Call initializeAppCheck() before instantiating other Firebase services.`,"fetch-network-error":`Fetch failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.`,"fetch-parse-error":`Fetch client could not parse response. Original error: {$originalErrorMessage}.`,"fetch-status-error":`Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.`,"storage-open":`Error thrown when opening storage. Original error: {$originalErrorMessage}.`,"storage-get":`Error thrown when reading from storage. Original error: {$originalErrorMessage}.`,"storage-set":`Error thrown when writing to storage. Original error: {$originalErrorMessage}.`,"recaptcha-error":`ReCAPTCHA error.`,"initial-throttle":`{$httpStatus} error. Attempts allowed again after {$time}`,throttled:`Requests throttled due to previous {$httpStatus} error. Attempts allowed again after {$time}`});function lN(e=!1){return e?self.grecaptcha?.enterprise:self.grecaptcha}function uN(e){if(!QM(e).activated)throw cN.create(`use-before-activation`,{appName:e.name})}function dN(e){let t=Math.round(e/1e3),n=Math.floor(t/(3600*24)),r=Math.floor((t-n*3600*24)/3600),i=Math.floor((t-n*3600*24-r*3600)/60),a=t-n*3600*24-r*3600-i*60,o=``;return n&&(o+=fN(n)+`d:`),r&&(o+=fN(r)+`h:`),o+=fN(i)+`m:`+fN(a)+`s`,o}function fN(e){return e===0?`00`:e>=10?e.toString():`0`+e}async function pN({url:e,body:t},n){let r={"Content-Type":`application/json`},i=n.getImmediate({optional:!0});if(i){let e=await i.getHeartbeatsHeader();e&&(r[`X-Firebase-Client`]=e)}let a={method:`POST`,body:JSON.stringify(t),headers:r},o;try{o=await fetch(e,a)}catch(e){throw cN.create(`fetch-network-error`,{originalErrorMessage:e?.message})}if(o.status!==200)throw cN.create(`fetch-status-error`,{httpStatus:o.status});let s;try{s=await o.json()}catch(e){throw cN.create(`fetch-parse-error`,{originalErrorMessage:e?.message})}let c=s.ttl.match(/^([\d.]+)(s)$/);if(!c||!c[2]||isNaN(Number(c[1])))throw cN.create(`fetch-parse-error`,{originalErrorMessage:`ttl field (timeToLive) is not in standard Protobuf Duration format: ${s.ttl}`});let l=Number(c[1])*1e3,u=Date.now();return{token:s.token,expireTimeMillis:u+l,issuedAtTimeMillis:u}}function mN(e,t){let{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${tN}/projects/${n}/apps/${r}:${nN}?key=${i}`,body:{recaptcha_v3_token:t}}}function hN(e,t){let{projectId:n,appId:r,apiKey:i}=e.options;return{url:`${tN}/projects/${n}/apps/${r}:${rN}?key=${i}`,body:{debug_token:t}}}var gN=`firebase-app-check-database`,_N=1,vN=`firebase-app-check-store`,yN=`debug-token`,bN=null;function xN(){return bN||(bN=new Promise((e,t)=>{try{let n=indexedDB.open(gN,_N);n.onsuccess=t=>{e(t.target.result)},n.onerror=e=>{t(cN.create(`storage-open`,{originalErrorMessage:e.target.error?.message}))},n.onupgradeneeded=e=>{let t=e.target.result;switch(e.oldVersion){case 0:t.createObjectStore(vN,{keyPath:`compositeKey`})}}}catch(e){t(cN.create(`storage-open`,{originalErrorMessage:e?.message}))}}),bN)}function SN(e){return DN(ON(e))}function CN(e,t){return EN(ON(e),t)}function wN(e){return EN(yN,e)}function TN(){return DN(yN)}async function EN(e,t){let n=(await xN()).transaction(vN,`readwrite`),r=n.objectStore(vN).put({compositeKey:e,value:t});return new Promise((e,t)=>
31{r.onsuccess=t=>{e()},n.onerror=e=>{t(cN.create(`storage-set`,{originalErrorMessage:e.target.error?.message}))}})}async function DN(e){let t=(await xN()).transaction(vN,`readonly`),n=t.objectStore(vN).get(e);return new Promise((e,r)=>{n.onsuccess=t=>{let n=t.target.result;e(n?n.value:void 0)},t.onerror=e=>{r(cN.create(`storage-get`,{originalErrorMessage:e.target.error?.message}))}})}function ON(e){return`${e.options.appId}-${e.name}`}var kN=new lt(`@firebase/app-check`);async function AN(e){if(Te()){let t;try{t=await SN(e)}catch(e){kN.warn(`Failed to read token from IndexedDB. Error: ${e}`)}return t}}function jN(e,t){return Te()?CN(e,t).catch(e=>{kN.warn(`Failed to write token to IndexedDB. Error: ${e}`)}):Promise.resolve()}async function MN(){let e;try{e=await TN()}catch{}if(e)return e;{let e=crypto.randomUUID();return wN(e).catch(e=>kN.warn(`Failed to persist debug token to IndexedDB. Error: ${e}`)),e}}function NN(){return eN().enabled}async function PN(){let e=eN();if(e.enabled&&e.token)return e.token.promise;throw Error(` 32 Can't get debug token in production mode. 33 `)}function FN(){let e=ie(),t=eN();if(t.initialized=!0,typeof e.FIREBASE_APPCHECK_DEBUG_TOKEN!=`string`&&e.FIREBASE_APPCHECK_DEBUG_TOKEN!==!0)return;t.enabled=!0;let n=new pe;t.token=n,typeof e.FIREBASE_APPCHECK_DEBUG_TOKEN==`string`?n.resolve(e.FIREBASE_APPCHECK_DEBUG_TOKEN):n.resolve(MN())}var IN={error:`UNKNOWN_ERROR`};function LN(e){return m.encodeString(JSON.stringify(e),!1)}async function RN(e,t=!1,n=!1){let r=e.app;uN(r);let i=QM(r),a=i.token,o;if(a&&!GN(a)&&(i.token=void 0,a=void 0),!a){let e=await i.cachedTokenPromise;e&&(GN(e)?a=e:await jN(r,void 0))}if(!t&&a&&GN(a))return{token:a.token};let s=!1;if(NN())try{let t=await PN();i.exchangeTokenPromise||(i.exchangeTokenPromise=pN(hN(r,t),e.heartbeatServiceProvider).finally(()=>{i.exchangeTokenPromise=void 0}),s=!0);let n=await i.exchangeTokenPromise;return await jN(r,n),i.token=n,{token:n.token}}catch(e){return e.code===`appCheck/throttled`||e.code===`appCheck/initial-throttle`?kN.warn(e.message):n&&kN.error(e),KN(e)}try{i.exchangeTokenPromise||(i.exchangeTokenPromise=i.provider.getToken().finally(()=>{i.exchangeTokenPromise=void 0}),s=!0),a=await QM(r).exchangeTokenPromise}catch(e){e.code===`appCheck/throttled`||e.code===`appCheck/initial-throttle`?kN.warn(e.message):n&&kN.error(e),o=e}let c;return a?o?c=GN(a)?{token:a.token,internalError:o}:KN(o):(c={token:a.token},i.token=a,await jN(r,a)):c=KN(o),s&&WN(r,c),c}async function zN(e){let t=e.app;uN(t);let{provider:n}=QM(t);if(NN()){let n=hN(t,await PN());n.body.limited_use=!0;let{token:r}=await pN(n,e.heartbeatServiceProvider);return{token:r}}else{let{token:e}=await n.getToken(!0);return{token:e}}}function BN(e,t,n,r){let{app:i}=e,a=QM(i),o={next:n,error:r,type:t};if(a.tokenObservers=[...a.tokenObservers,o],a.token&&GN(a.token)){let t=a.token;Promise.resolve().then(()=>{n({token:t.token}),HN(e)}).catch(()=>{})}a.cachedTokenPromise.then(()=>HN(e))}function VN(e,t){let n=QM(e),r=n.tokenObservers.filter(e=>e.next!==t);r.length===0&&n.tokenRefresher&&n.tokenRefresher.isRunning()&&n.tokenRefresher.stop(),n.tokenObservers=r}function HN(e){let{app:t}=e,n=QM(t),r=n.tokenRefresher;r||(r=UN(e),n.tokenRefresher=r),!r.isRunning()&&n.isTokenAutoRefreshEnabled&&r.start()}function UN(e){let{app:t}=e;return new oN(async()=>{let n=QM(t),r;if(r=n.token?await RN(e,!0):await RN(e),r.error)throw r.error;if(r.internalError)throw r.internalError},()=>!0,()=>{let e=QM(t);if(e.token){let t=e.token.issuedAtTimeMillis+(e.token.expireTimeMillis-e.token.issuedAtTimeMillis)*.5+300*1e3,n=e.token.expireTimeMillis-300*1e3;return t=Math.min(t,n),Math.max(0,t-Date.now())}else return 0},iN.RETRIAL_MIN_WAIT,iN.RETRIAL_MAX_WAIT)}function WN(e,t){let n=QM(e).tokenObservers;for(let e of n)try{e.type===`EXTERNAL`&&t.error!=null?e.error(t.error):e.next(t)}catch{}}function GN(e){return e.expireTimeMillis-Date.now()>0}function KN(e){return{token:LN(IN),error:e}}var qN=class{constructor(e,t){this.app=e,this.heartbeatServiceProvider=t}_delete(){let{tokenObservers:e}=QM(this.app);for(let t of e)VN(this.app,t.next);return Promise.resolve()}};function JN(e,t){return new qN(e,t)}function YN(e){return{getToken:t=>RN(e,t),getLimitedUseToken:()=>zN(e),addTokenListener:t=>BN(e,`INTERNAL`,t),removeTokenListener:t=>VN(e.app,t)}}var XN=`@firebase/app-check`,ZN=`0.11.4`,QN=`https://www.google.com/recaptcha/api.js`;
33function $N(e,t){let n=new pe,r=QM(e);r.reCAPTCHAState={initialized:n};let i=tP(e),a=lN(!1);return a?eP(e,t,a,i,n):iP(()=>{let r=lN(!1);if(!r)throw Error(`no recaptcha`);eP(e,t,r,i,n)}),n.promise}function eP(e,t,n,r,i){n.ready(()=>{rP(e,t,n,r),i.resolve(n)})}function tP(e){let t=`fire_app_check_${e.name}`,n=document.createElement(`div`);return n.id=t,n.style.display=`none`,document.body.appendChild(n),t}async function nP(e){uN(e);let t=await QM(e).reCAPTCHAState.initialized.promise;return new Promise((n,r)=>{let i=QM(e).reCAPTCHAState;t.ready(()=>{n(t.execute(i.widgetId,{action:`fire_app_check`}))})})}function rP(e,t,n,r){let i=n.render(r,{sitekey:t,size:`invisible`,callback:()=>{QM(e).reCAPTCHAState.succeeded=!0},"error-callback":()=>{QM(e).reCAPTCHAState.succeeded=!1}}),a=QM(e);a.reCAPTCHAState={...a.reCAPTCHAState,widgetId:i}}function iP(e){let t=document.createElement(`script`);t.src=QN,t.onload=e,document.head.appendChild(t)}var aP=class e{constructor(e){this._siteKey=e,this._throttleData=null}async getToken(e=!1){cP(this._throttleData);let t=await nP(this._app).catch(e=>{throw cN.create(`recaptcha-error`)});if(!QM(this._app).reCAPTCHAState?.succeeded)throw cN.create(`recaptcha-error`);let n;try{let r=mN(this._app,t);e&&(r.body.limited_use=!0),n=await pN(r,this._heartbeatServiceProvider)}catch(e){throw e.code?.includes(`fetch-status-error`)?(this._throttleData=sP(Number(e.customData?.httpStatus),this._throttleData),cN.create(`initial-throttle`,{time:dN(this._throttleData.allowRequestsAfter-Date.now()),httpStatus:this._throttleData.httpStatus})):e}return this._throttleData=null,n}initialize(e){this._app=e,this._heartbeatServiceProvider=Sn(e,`heartbeat`),$N(e,this._siteKey).catch(()=>{})}isEqual(t){return t instanceof e?this._siteKey===t._siteKey:!1}},oP=class e{constructor(e){this._customProviderOptions=e}async getToken(){let e=await this._customProviderOptions.getToken(),t=Fe(e.token),n=t!==null&&t<Date.now()&&t>0?t*1e3:Date.now();return{...e,issuedAtTimeMillis:n}}initialize(e){this._app=e}isEqual(t){return t instanceof e?this._customProviderOptions.getToken.toString()===t._customProviderOptions.getToken.toString():!1}};function sP(e,t){if(e===404||e===403)return{backoffCount:1,allowRequestsAfter:Date.now()+aN,httpStatus:e};{let n=t?t.backoffCount:0,r=Xe(n,1e3,2);return{backoffCount:n+1,allowRequestsAfter:Date.now()+r,httpStatus:e}}}function cP(e){if(e&&Date.now()-e.allowRequestsAfter<=0)throw cN.create(`throttled`,{time:dN(e.allowRequestsAfter-Date.now()),httpStatus:e.httpStatus})}function lP(e=Nn(),t){e=y(e);let n=Sn(e,`app-check`);if(eN().initialized||FN(),NN()&&PN().then(e=>console.log(`App Check debug token: ${e}. You will need to add it to your app's App Check settings in the Firebase console for it to work.`)),n.isInitialized()){let r=n.getImmediate(),i=n.getOptions();if(i.isTokenAutoRefreshEnabled===t.isTokenAutoRefreshEnabled&&i.provider.isEqual(t.provider))return r;throw cN.create(`already-initialized`,{appName:e.name})}let r=n.initialize({options:t});return uP(e,t.provider,t.isTokenAutoRefreshEnabled),QM(e).isTokenAutoRefreshEnabled&&BN(r,`INTERNAL`,()=>{}),r}function uP(e,t,n=!1){let r=$M(e,{...XM});r.activated=!0,r.provider=t,r.cachedTokenPromise=AN(e).then(t=>(t&&GN(t)&&(r.token=t,WN(e,{token:t.token})),t)),r.isTokenAutoRefreshEnabled=n&&e.automaticDataCollectionEnabled,!e.automaticDataCollectionEnabled&&n&&kN.warn("`isTokenAutoRefreshEnabled` is true but `automaticDataCollectionEnabled` was set to false during `initializeApp()`. This blocks automatic token refresh."),r.provider.initialize(e)}var dP=`app-check`,fP=`app-check-internal`;function pP(){xn(new b(dP,e=>JN(e.getProvider(`app`).getImmediate(),e.getProvider(`heartbeat`)),`PUBLIC`).setInstantiationMode(`EXPLICIT`).setInstanceCreatedCallback((e,t,n)=>{e.getProvider(fP).initialize()})),xn(new b(fP,e=>YN(e.getProvider(`app-check`).getImmediate()),`PUBLIC`).setInstantiationMode(`EXPLICIT`)),T(XN,ZN)}pP();var mP={apiKey:JM.FIREBASE_API_KEY,authDomain:JM.FIREBASE_AUTH_DOMAIN,projectId:JM.FIREBASE_PROJECT_ID,storageBucket:JM.FIREBASE_STORAGE_BUCKET,messagingSenderId:JM.FIREBASE_MESSAGING_SENDER_ID,appId:JM.FIREBASE_APP_ID};ur.initializeApp(mP);var hP=Nn(),gP=xT(hP),_P=mg(hP);gk(hP);var vP=lA(hP,JM.FIREBASE_REGION);jM(hP);var yP;if(self.FIREBASE_APPCHECK_DEBUG_TOKEN=!!location.hostname.includes(`localhost`),JM.ENV!==`emulator`)if(JM.ENV===`staging`){let e=dA(vP,`customAppCheck`);yP=new oP({getToken:async()=>{let t=JM.STAGING_APP_CHECK_TOKEN;return t?e({appId:JM.FIREBASE_APP_ID,token:t}).then(e=>e.data):(console.error(`Staging secret is not defined!`),Promise.reject(Error(`Staging secret is not defined!`)))}})}else (JM.ENV===`production`||JM.ENV===`development`)&&(yP=new aP(JM.SITEKEY));yP&&lP(hP,{provider:yP,isTokenAutoRefreshEnabled:!0});var bP=ur.app(hP.name),xP=bP.auth(),SP=bP.firestore(),CP=bP.storage(),wP=bP.functions(JM.FIREBASE_REGION);bP.analytics(),JM.ENV===`emulator`&&(wP.useEmulator(`localhost`,5001),SP.useEmulator(`localhost`,8080),uA(vP,`localhost`,5001),ng(_P,`localhost`,8080)),SP.settings({experimentalAutoDetectLongPolling:!0,merge:!0});var TP=ur.firestore.FieldValue.serverTimestamp,EP=ur.firestore.Timestamp.fromDate,DP=ur.firestore.FieldValue.arrayUnion,OP=ur.firestore.FieldValue.arrayRemove;export{cv as A,s as B,dv as C,ev as D,y_ as E,ag as F,l as H,sg as I,Og as L,hv as M,l_ as N,sv as O,c_ as P,s_ as R,O_ as S,E_ as T,u as V,uv as _,SP as a,tv as b,OP as c,JM as d,kx as f,NS as g,tw as h,xP as i,x_ as j,M_ as k,TP as l,uS as m,gP as n,wP as o,Dx as p,_P as r,CP as s,DP as t,EP as u,w_ as v,C_ as w,iv as x,lv as y,o as z};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.