@entropic-bond/firebase 1.13.27 → 1.13.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +1,37 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`entropic-bond-firebase`]={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=()=>void 0,n=function(e){let t=[],n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=i&63|128):(i&64512)==55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)==56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t},r=function(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){let a=e[n++];t[r++]=String.fromCharCode((i&31)<<6|a&63)}else if(i>239&&i<365){let a=e[n++],o=e[n++],s=e[n++],c=((i&7)<<18|(a&63)<<12|(o&63)<<6|s&63)-65536;t[r++]=String.fromCharCode(55296+(c>>10)),t[r++]=String.fromCharCode(56320+(c&1023))}else{let a=e[n++],o=e[n++];t[r++]=String.fromCharCode((i&15)<<12|(a&63)<<6|o&63)}}return t.join(``)},i={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`,get ENCODED_VALS(){return this.ENCODED_VALS_BASE+`+/=`},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+`-_.`},HAS_NATIVE_SUPPORT:typeof atob==`function`,encodeByteArray(e,t){if(!Array.isArray(e))throw Error(`encodeByteArray takes an array as a parameter`);this.init_();let n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let t=0;t<e.length;t+=3){let i=e[t],a=t+1<e.length,o=a?e[t+1]:0,s=t+2<e.length,c=s?e[t+2]:0,l=i>>2,u=(i&3)<<4|o>>4,d=(o&15)<<2|c>>6,f=c&63;s||(f=64,a||(d=64)),r.push(n[l],n[u],n[d],n[f])}return r.join(``)},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(n(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):r(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();let n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let t=0;t<e.length;){let i=n[e.charAt(t++)],o=t<e.length?n[e.charAt(t)]:0;++t;let s=t<e.length?n[e.charAt(t)]:64;++t;let c=t<e.length?n[e.charAt(t)]:64;if(++t,i==null||o==null||s==null||c==null)throw new a;let l=i<<2|o>>4;if(r.push(l),s!==64){let e=o<<4&240|s>>2;if(r.push(e),c!==64){let e=s<<6&192|c;r.push(e)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}},a=class extends Error{constructor(){super(...arguments),this.name=`DecodeBase64StringError`}},o=function(e){let t=n(e);return i.encodeByteArray(t,!0)},s=function(e){return o(e).replace(/\./g,``)},c=function(e){try{return i.decodeString(e,!0)}catch(e){console.error(`base64Decode failed: `,e)}return null};function l(){if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global;throw Error(`Unable to locate global object.`)}var u=()=>l().__FIREBASE_DEFAULTS__,d=()=>{if(typeof process>`u`||process.env===void 0)return;let e=process.env.__FIREBASE_DEFAULTS__;if(e)return JSON.parse(e)},f=()=>{if(typeof document>`u`)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}let t=e&&c(e[1]);return t&&JSON.parse(t)},p=()=>{try{return t()||u()||d()||f()}catch(e){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);return}},m=e=>p()?.emulatorHosts?.[e],h=e=>{let t=m(e);if(!t)return;let n=t.lastIndexOf(`:`);if(n<=0||n+1===t.length)throw Error(`Invalid host ${t} with no separate hostname and port!`);let r=parseInt(t.substring(n+1),10);return t[0]===`[`?[t.substring(1,n-1),r]:[t.substring(0,n),r]},g=()=>p()?.config,ee=e=>p()?.[`_${e}`],te=class{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),typeof e==`function`&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,n))}}};function ne(e,t){if(e.uid)throw Error(`The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.`);let n={alg:`none`,type:`JWT`},r=t||`demo-project`,i=e.iat||0,a=e.sub||e.user_id;if(!a)throw Error(`mockUserToken must contain 'sub' or 'user_id' field!`);let o={iss:`https://securetoken.google.com/${r}`,aud:r,iat:i,exp:i+3600,auth_time:i,sub:a,user_id:a,firebase:{sign_in_provider:`custom`,identities:{}},...e};return[s(JSON.stringify(n)),s(JSON.stringify(o)),``].join(`.`)}function _(){return typeof navigator<`u`&&typeof navigator.userAgent==`string`?navigator.userAgent:``}function re(){return typeof window<`u`&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(_())}function ie(){let e=p()?.forceEnvironment;if(e===`node`)return!0;if(e===`browser`)return!1;try{return Object.prototype.toString.call(global.process)===`[object process]`}catch{return!1}}function ae(){return typeof navigator<`u`&&navigator.userAgent===`Cloudflare-Workers`}function oe(){let e=typeof chrome==`object`?chrome.runtime:typeof browser==`object`?browser.runtime:void 0;return typeof e==`object`&&e.id!==void 0}function se(){return typeof navigator==`object`&&navigator.product===`ReactNative`}function ce(){let e=_();return e.indexOf(`MSIE `)>=0||e.indexOf(`Trident/`)>=0}function v(){return!ie()&&!!navigator.userAgent&&navigator.userAgent.includes(`Safari`)&&!navigator.userAgent.includes(`Chrome`)}function le(){try{return typeof indexedDB==`object`}catch{return!1}}function ue(){return new Promise((e,t)=>{try{let n=!0,r=`validate-browser-context-for-indexeddb-analytics-module`,i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{t(i.error?.message||``)}}catch(e){t(e)}})}var de=`FirebaseError`,fe=class e extends Error{constructor(t,n,r){super(n),this.code=t,this.customData=r,this.name=de,Object.setPrototypeOf(this,e.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,pe.prototype.create)}},pe=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?me(i,n):`Error`;return new fe(r,`${this.serviceName}: ${a} (${r}).`,n)}};function me(e,t){return e.replace(he,(e,n)=>{let r=t[n];return r==null?`<${n}?>`:String(r)})}var he=/\{\$([^}]+)}/g;function ge(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function _e(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(ve(n)&&ve(a)){if(!_e(n,a))return!1}else if(n!==a)return!1}for(let e of r)if(!n.includes(e))return!1;return!0}function ve(e){return typeof e==`object`&&!!e}function ye(e){let t=[];for(let[n,r]of Object.entries(e))Array.isArray(r)?r.forEach(e=>{t.push(encodeURIComponent(n)+`=`+encodeURIComponent(e))}):t.push(encodeURIComponent(n)+`=`+encodeURIComponent(r));return t.length?`&`+t.join(`&`):``}function be(e){let t={};return e.replace(/^\?/,``).split(`&`).forEach(e=>{if(e){let[n,r]=e.split(`=`);t[decodeURIComponent(n)]=decodeURIComponent(r)}}),t}function xe(e){let t=e.indexOf(`?`);if(!t)return``;let n=e.indexOf(`#`,t);return e.substring(t,n>0?n:void 0)}function Se(e,t){let n=new Ce(e,t);return n.subscribe.bind(n)}var Ce=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=Te),r.error===void 0&&(r.error=Te),r.complete===void 0&&(r.complete=Te);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 Te(){}function y(e){return e&&e._delegate?e._delegate:e}function Ee(e){try{return(e.startsWith(`http://`)||e.startsWith(`https://`)?new URL(e).hostname:e).endsWith(`.cloudworkstations.dev`)}catch{return!1}}async function De(e){return(await fetch(e,{credentials:`include`})).ok}var Oe=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}},ke=`[DEFAULT]`,Ae=class{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){let t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){let e=new te;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{let n=this.getOrInitializeService({instanceIdentifier:t});n&&e.resolve(n)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){let t=this.normalizeInstanceIdentifier(e?.identifier),n=e?.optional??!1;if(this.isInitialized(t)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:t})}catch(e){if(n)return null;throw e}else if(n)return null;else throw Error(`Service ${this.name} is not available`)}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if(Me(e))try{this.getOrInitializeService({instanceIdentifier:ke})}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=ke){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=ke){return this.instances.has(e)}getOptions(e=ke){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:je(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=ke){return this.component?this.component.multipleInstances?e:ke:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!==`EXPLICIT`}};function je(e){return e===ke?void 0:e}function Me(e){return e.instantiationMode===`EAGER`}var Ne=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 Ae(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}},Pe=[],b;(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`})(b||={});var x={debug:b.DEBUG,verbose:b.VERBOSE,info:b.INFO,warn:b.WARN,error:b.ERROR,silent:b.SILENT},Fe=b.INFO,Ie={[b.DEBUG]:`log`,[b.VERBOSE]:`log`,[b.INFO]:`info`,[b.WARN]:`warn`,[b.ERROR]:`error`},Le=(e,t,...n)=>{if(t<e.logLevel)return;let r=new Date().toISOString(),i=Ie[t];if(i)console[i](`[${r}] ${e.name}:`,...n);else throw Error(`Attempted to log a message with an invalid logType (value: ${t})`)},Re=class{constructor(e){this.name=e,this._logLevel=Fe,this._logHandler=Le,this._userLogHandler=null,Pe.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in b))throw TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e==`string`?x[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,b.DEBUG,...e),this._logHandler(this,b.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,b.VERBOSE,...e),this._logHandler(this,b.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,b.INFO,...e),this._logHandler(this,b.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,b.WARN,...e),this._logHandler(this,b.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,b.ERROR,...e),this._logHandler(this,b.ERROR,...e)}},ze=(e,t)=>t.some(t=>e instanceof t),Be,Ve;function He(){return Be||=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]}function Ue(){return Ve||=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey]}var We=new WeakMap,Ge=new WeakMap,Ke=new WeakMap,qe=new WeakMap,Je=new WeakMap;function Ye(e){let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`success`,i),e.removeEventListener(`error`,a)},i=()=>{t(tt(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener(`success`,i),e.addEventListener(`error`,a)});return t.then(t=>{t instanceof IDBCursor&&We.set(t,e)}).catch(()=>{}),Je.set(t,e),t}function Xe(e){if(Ge.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)});Ge.set(e,t)}var Ze={get(e,t,n){if(e instanceof IDBTransaction){if(t===`done`)return Ge.get(e);if(t===`objectStoreNames`)return e.objectStoreNames||Ke.get(e);if(t===`store`)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return tt(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 Qe(e){Ze=e(Ze)}function $e(e){return e===IDBDatabase.prototype.transaction&&!(`objectStoreNames`in IDBTransaction.prototype)?function(t,...n){let r=e.call(nt(this),t,...n);return Ke.set(r,t.sort?t.sort():[t]),tt(r)}:Ue().includes(e)?function(...t){return e.apply(nt(this),t),tt(We.get(this))}:function(...t){return tt(e.apply(nt(this),t))}}function et(e){return typeof e==`function`?$e(e):(e instanceof IDBTransaction&&Xe(e),ze(e,He())?new Proxy(e,Ze):e)}function tt(e){if(e instanceof IDBRequest)return Ye(e);if(qe.has(e))return qe.get(e);let t=et(e);return t!==e&&(qe.set(e,t),Je.set(t,e)),t}var nt=e=>Je.get(e);function rt(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){let o=indexedDB.open(e,t),s=tt(o);return r&&o.addEventListener(`upgradeneeded`,e=>{r(tt(o.result),e.oldVersion,e.newVersion,tt(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 it=[`get`,`getKey`,`getAll`,`getAllKeys`,`count`],at=[`put`,`add`,`delete`,`clear`],ot=new Map;function st(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t==`string`))return;if(ot.get(t))return ot.get(t);let n=t.replace(/FromIndex$/,``),r=t!==n,i=at.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||it.includes(n)))return;let a=async function(e,...t){let a=this.transaction(e,i?`readwrite`:`readonly`),o=a.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&a.done]))[0]};return ot.set(t,a),a}Qe(e=>({...e,get:(t,n,r)=>st(t,n)||e.get(t,n,r),has:(t,n)=>!!st(t,n)||e.has(t,n)}));var ct=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 ut=`@firebase/app`,dt=`0.14.10`,ft=new Re(`@firebase/app`),pt=`@firebase/app-compat`,mt=`@firebase/analytics-compat`,ht=`@firebase/analytics`,gt=`@firebase/app-check-compat`,_t=`@firebase/app-check`,vt=`@firebase/auth`,yt=`@firebase/auth-compat`,bt=`@firebase/database`,xt=`@firebase/data-connect`,St=`@firebase/database-compat`,Ct=`@firebase/functions`,wt=`@firebase/functions-compat`,Tt=`@firebase/installations`,Et=`@firebase/installations-compat`,Dt=`@firebase/messaging`,Ot=`@firebase/messaging-compat`,kt=`@firebase/performance`,At=`@firebase/performance-compat`,jt=`@firebase/remote-config`,Mt=`@firebase/remote-config-compat`,Nt=`@firebase/storage`,Pt=`@firebase/storage-compat`,Ft=`@firebase/firestore`,It=`@firebase/ai`,Lt=`@firebase/firestore-compat`,Rt=`firebase`,zt=`12.11.0`,Bt=`[DEFAULT]`,Vt={[ut]:`fire-core`,[pt]:`fire-core-compat`,[ht]:`fire-analytics`,[mt]:`fire-analytics-compat`,[_t]:`fire-app-check`,[gt]:`fire-app-check-compat`,[vt]:`fire-auth`,[yt]:`fire-auth-compat`,[bt]:`fire-rtdb`,[xt]:`fire-data-connect`,[St]:`fire-rtdb-compat`,[Ct]:`fire-fn`,[wt]:`fire-fn-compat`,[Tt]:`fire-iid`,[Et]:`fire-iid-compat`,[Dt]:`fire-fcm`,[Ot]:`fire-fcm-compat`,[kt]:`fire-perf`,[At]:`fire-perf-compat`,[jt]:`fire-rc`,[Mt]:`fire-rc-compat`,[Nt]:`fire-gcs`,[Pt]:`fire-gcs-compat`,[Ft]:`fire-fst`,[Lt]:`fire-fst-compat`,[It]:`fire-vertex`,"fire-js":`fire-js`,[Rt]:`fire-js-all`},Ht=new Map,Ut=new Map,Wt=new Map;function Gt(e,t){try{e.container.addComponent(t)}catch(n){ft.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function Kt(e){let t=e.name;if(Wt.has(t))return ft.debug(`There were multiple attempts to register component ${t}.`),!1;Wt.set(t,e);for(let t of Ht.values())Gt(t,e);for(let t of Ut.values())Gt(t,e);return!0}function qt(e,t){let n=e.container.getProvider(`heartbeat`).getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function S(e){return e==null?!1:e.settings!==void 0}var Jt=new pe(`app`,`Firebase`,{"no-app":`No Firebase App '{$appName}' has been created - call initializeApp() first`,"bad-app-name":`Illegal App name: '{$appName}'`,"duplicate-app":`Firebase App named '{$appName}' already exists with different options or config`,"app-deleted":`Firebase App named '{$appName}' already deleted`,"server-app-deleted":`Firebase Server App has been deleted`,"no-options":`Need to provide options, when not being deployed to hosting via source.`,"invalid-app-argument":`firebase.{$appName}() takes either no argument or a Firebase App instance.`,"invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":`Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.`,"idb-get":`Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.`,"idb-set":`Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.`,"idb-delete":`Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.`,"finalization-registry-not-supported":`FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.`,"invalid-server-app-environment":`FirebaseServerApp is not for use in browser environments.`}),Yt=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 Oe(`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 Jt.create(`app-deleted`,{appName:this._name})}},Xt=zt;function Zt(e,t={}){let n=e;typeof t!=`object`&&(t={name:t});let r={name:Bt,automaticDataCollectionEnabled:!0,...t},i=r.name;if(typeof i!=`string`||!i)throw Jt.create(`bad-app-name`,{appName:String(i)});if(n||=g(),!n)throw Jt.create(`no-options`);let a=Ht.get(i);if(a){if(_e(n,a.options)&&_e(r,a.config))return a;throw Jt.create(`duplicate-app`,{appName:i})}let o=new Ne(i);for(let e of Wt.values())o.addComponent(e);let s=new Yt(n,r,o);return Ht.set(i,s),s}function Qt(e=Bt){let t=Ht.get(e);if(!t&&e===`[DEFAULT]`&&g())return Zt();if(!t)throw Jt.create(`no-app`,{appName:e});return t}function $t(e,t,n){let r=Vt[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 "/")`),ft.warn(e.join(` `));return}Kt(new Oe(`${r}-version`,()=>({library:r,version:t}),`VERSION`))}var en=`firebase-heartbeat-database`,tn=1,nn=`firebase-heartbeat-store`,rn=null;function an(){return rn||=rt(en,tn,{upgrade:(e,t)=>{switch(t){case 0:try{e.createObjectStore(nn)}catch(e){console.warn(e)}}}}).catch(e=>{throw Jt.create(`idb-open`,{originalErrorMessage:e.message})}),rn}async function on(e){try{let t=(await an()).transaction(nn),n=await t.objectStore(nn).get(cn(e));return await t.done,n}catch(e){if(e instanceof fe)ft.warn(e.message);else{let t=Jt.create(`idb-get`,{originalErrorMessage:e?.message});ft.warn(t.message)}}}async function sn(e,t){try{let n=(await an()).transaction(nn,`readwrite`);await n.objectStore(nn).put(t,cn(e)),await n.done}catch(e){if(e instanceof fe)ft.warn(e.message);else{let t=Jt.create(`idb-set`,{originalErrorMessage:e?.message});ft.warn(t.message)}}}function cn(e){return`${e.name}!${e.options.appId}`}var ln=1024,un=30,dn=class{constructor(e){this.container=e,this._heartbeatsCache=null,this._storage=new mn(this.container.getProvider(`app`).getImmediate()),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){try{let e=this.container.getProvider(`platform-logger`).getImmediate().getPlatformInfoString(),t=fn();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>un){let e=gn(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){ft.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return``;let e=fn(),{heartbeatsToSend:t,unsentEntries:n}=pn(this._heartbeatsCache.heartbeats),r=s(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,n.length>0?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),r}catch(e){return ft.warn(e),``}}};function fn(){return new Date().toISOString().substring(0,10)}function pn(e,t=ln){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]}),hn(n)>t){n.pop();break}}else if(e.dates.push(i.date),hn(n)>t){e.dates.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}var mn=class{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return le()?ue().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){let e=await on(this.app);return e?.heartbeats?e:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){let t=await this.read();return sn(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 sn(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:[...t.heartbeats,...e.heartbeats]})}else return}};function hn(e){return s(JSON.stringify({version:2,heartbeats:e})).length}function gn(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 _n(e){Kt(new Oe(`platform-logger`,e=>new ct(e),`PRIVATE`)),Kt(new Oe(`heartbeat`,e=>new dn(e),`PRIVATE`)),$t(ut,dt,e),$t(ut,dt,`esm2020`),$t(`fire-js`,``)}_n(``);var vn=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},yn={},bn,xn;(function(){var e;function t(e,t){function n(){}n.prototype=t.prototype,e.F=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.D=function(e,n,r){for(var i=Array(arguments.length-2),a=2;a<arguments.length;a++)i[a-2]=arguments[a];return t.prototype[n].apply(e,i)}}function n(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=[,,,,],this.C=Array(this.blockSize),this.o=this.h=0,this.u()}t(r,n),r.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function i(e,t,n){n||=0;let r=Array(16);if(typeof t==`string`)for(var i=0;i<16;++i)r[i]=t.charCodeAt(n++)|t.charCodeAt(n++)<<8|t.charCodeAt(n++)<<16|t.charCodeAt(n++)<<24;else for(i=0;i<16;++i)r[i]=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24;t=e.g[0],n=e.g[1],i=e.g[2];let a=e.g[3],o;o=t+(a^n&(i^a))+r[0]+3614090360&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[1]+3905402710&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[2]+606105819&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[3]+3250441966&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(a^n&(i^a))+r[4]+4118548399&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[5]+1200080426&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[6]+2821735955&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[7]+4249261313&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(a^n&(i^a))+r[8]+1770035416&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[9]+2336552879&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[10]+4294925233&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[11]+2304563134&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(a^n&(i^a))+r[12]+1804603682&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[13]+4254626195&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[14]+2792965006&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[15]+1236535329&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(i^a&(n^i))+r[1]+4129170786&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[6]+3225465664&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[11]+643717713&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[0]+3921069994&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^a&(n^i))+r[5]+3593408605&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[10]+38016083&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[15]+3634488961&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[4]+3889429448&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^a&(n^i))+r[9]+568446438&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[14]+3275163606&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[3]+4107603335&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[8]+1163531501&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^a&(n^i))+r[13]+2850285829&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[2]+4243563512&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[7]+1735328473&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[12]+2368359562&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(n^i^a)+r[5]+4294588738&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[8]+2272392833&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[11]+1839030562&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[14]+4259657740&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(n^i^a)+r[1]+2763975236&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[4]+1272893353&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[7]+4139469664&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[10]+3200236656&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(n^i^a)+r[13]+681279174&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[0]+3936430074&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[3]+3572445317&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[6]+76029189&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(n^i^a)+r[9]+3654602809&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[12]+3873151461&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[15]+530742520&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[2]+3299628645&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(i^(n|~a))+r[0]+4096336452&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[7]+1126891415&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[14]+2878612391&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[5]+4237533241&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~a))+r[12]+1700485571&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[3]+2399980690&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[10]+4293915773&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[1]+2240044497&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~a))+r[8]+1873313359&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[15]+4264355552&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[6]+2734768916&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[13]+1309151649&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~a))+r[4]+4149444226&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[11]+3174756917&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[2]+718787259&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[9]+3951481745&4294967295,e.g[0]=e.g[0]+t&4294967295,e.g[1]=e.g[1]+(i+(o<<21&4294967295|o>>>11))&4294967295,e.g[2]=e.g[2]+i&4294967295,e.g[3]=e.g[3]+a&4294967295}r.prototype.v=function(e,t){t===void 0&&(t=e.length);let n=t-this.blockSize,r=this.C,a=this.h,o=0;for(;o<t;){if(a==0)for(;o<=n;)i(this,e,o),o+=this.blockSize;if(typeof e==`string`){for(;o<t;)if(r[a++]=e.charCodeAt(o++),a==this.blockSize){i(this,r),a=0;break}}else for(;o<t;)if(r[a++]=e[o++],a==this.blockSize){i(this,r),a=0;break}}this.h=a,this.o+=t},r.prototype.A=function(){var e=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;t=this.o*8;for(var n=e.length-8;n<e.length;++n)e[n]=t&255,t/=256;for(this.v(e),e=Array(16),t=0,n=0;n<4;++n)for(let r=0;r<32;r+=8)e[t++]=this.g[n]>>>r&255;return e};function a(e,t){var n=s;return Object.prototype.hasOwnProperty.call(n,e)?n[e]:n[e]=t(e)}function o(e,t){this.h=t;let n=[],r=!0;for(let i=e.length-1;i>=0;i--){let a=e[i]|0;r&&a==t||(n[i]=a,r=!1)}this.g=n}var s={};function c(e){return-128<=e&&e<128?a(e,function(e){return new o([e|0],e<0?-1:0)}):new o([e|0],e<0?-1:0)}function l(e){if(isNaN(e)||!isFinite(e))return d;if(e<0)return g(l(-e));let t=[],n=1;for(let r=0;e>=n;r++)t[r]=e/n|0,n*=4294967296;return new o(t,0)}function u(e,t){if(e.length==0)throw Error(`number format error: empty string`);if(t||=10,t<2||36<t)throw Error(`radix out of range: `+t);if(e.charAt(0)==`-`)return g(u(e.substring(1),t));if(e.indexOf(`-`)>=0)throw Error(`number format error: interior "-" character`);let n=l(t**8),r=d;for(let a=0;a<e.length;a+=8){var i=Math.min(8,e.length-a);let o=parseInt(e.substring(a,a+i),t);i<8?(i=l(t**+i),r=r.j(i).add(l(o))):(r=r.j(n),r=r.add(l(o)))}return r}var d=c(0),f=c(1),p=c(16777216);e=o.prototype,e.m=function(){if(h(this))return-g(this).m();let e=0,t=1;for(let n=0;n<this.g.length;n++){let r=this.i(n);e+=(r>=0?r:4294967296+r)*t,t*=4294967296}return e},e.toString=function(e){if(e||=10,e<2||36<e)throw Error(`radix out of range: `+e);if(m(this))return`0`;if(h(this))return`-`+g(this).toString(e);let t=l(e**6);var n=this;let r=``;for(;;){let i=_(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)?0:1};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 _(e,t){if(m(t))throw Error(`division by zero`);if(m(e))return new ne(d,d);if(h(e))return t=_(g(e),t),new ne(g(t.g),g(t.h));if(h(t))return t=_(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=re(n),r=re(r);var i=ie(n,1),a=ie(r,1);for(r=ie(r,2),n=ie(n,2);!m(r);){var o=a.add(r);o.l(e)<=0&&(i=i.add(n),a=o),r=ie(r,1),n=ie(n,1)}return t=ee(e,i.j(t)),new ne(i,t)}for(i=d;e.l(t)>=0;){for(n=Math.max(1,Math.floor(e.m()/t.m())),r=Math.ceil(Math.log(n)/Math.LN2),r=r<=48?1:2**(r-48),a=l(n),o=a.j(t);h(o)||o.l(e)>0;)n-=r,a=l(n),o=a.j(t);m(a)&&(a=f),i=i.add(a),e=ee(e,o)}return new ne(i,e)}e.B=function(e){return _(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 re(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 ie(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,xn=yn.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,bn=yn.Integer=o}).apply(vn===void 0?typeof self<`u`?self:typeof window<`u`?window:{}:vn);var Sn=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},Cn={},wn,Tn,En,Dn,On,kn,An,jn;(function(){var e,t=Object.defineProperty;function n(e){e=[typeof globalThis==`object`&&globalThis,e,typeof window==`object`&&window,typeof self==`object`&&self,typeof Sn==`object`&&Sn];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=ae;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 _,e=>e.reset());class _{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 re,ie=!1,ae=new te,oe=()=>{let e=Promise.resolve(void 0);re=()=>{e.then(se)}};function se(){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)}ie=!1}function ce(){this.u=this.u,this.C=this.C}ce.prototype.u=!1,ce.prototype.dispose=function(){this.u||(this.u=!0,this.N())},ce.prototype[Symbol.dispose]=function(){this.dispose()},ce.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function v(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}v.prototype.h=function(){this.defaultPrevented=!0};var le=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 ue(e){return/^[\s\xa0]*$/.test(e)}function de(e,t){v.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(de,v),de.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&&de.Z.h.call(this)},de.prototype.h=function(){de.Z.h.call(this);let e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var fe=`closure_listenable_`+(Math.random()*1e6|0),pe=0;function me(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=++pe,this.da=this.fa=!1}function he(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function ge(e,t,n){for(let r in e)t.call(n,e[r],r,e)}function _e(e,t){for(let n in e)t.call(void 0,e[n],n,e)}function ve(e){let t={};for(let n in e)t[n]=e[n];return t}let ye=`constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf`.split(` `);function be(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<ye.length;t++)n=ye[t],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function xe(e){this.src=e,this.g={},this.h=0}xe.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=Ce(e,t,r,i);return o>-1?(t=e[o],n||(t.fa=!1)):(t=new me(t,this.src,a,!!r,i),t.fa=n,e.push(t)),t};function Se(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&&(he(t),e.g[n].length==0&&(delete e.g[n],e.h--))}}function Ce(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 we=`closure_lm_`+(Math.random()*1e6|0),Te={};function y(e,t,n,r,i){if(r&&r.once)return Oe(e,t,n,r,i);if(Array.isArray(t)){for(let a=0;a<t.length;a++)y(e,t[a],n,r,i);return null}return n=b(n),e&&e[fe]?e.J(t,n,s(r)?!!r.capture:!!r,i):Ee(e,t,n,!1,r,i)}function Ee(e,t,n,r,i,a){if(!t)throw Error(`Invalid event type`);let o=s(i)?!!i.capture:!!i,c=Ne(e);if(c||(e[we]=c=new xe(e)),n=c.add(t,n,r,o,a),n.proxy)return n;if(r=De(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)le||(i=o),i===void 0&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(je(t.toString()),r);else if(e.addListener&&e.removeListener)e.addListener(r);else throw Error(`addEventListener and attachEvent are unavailable.`);return n}function De(){function e(n){return t.call(e.src,e.listener,n)}let t=Me;return e}function Oe(e,t,n,r,i){if(Array.isArray(t)){for(let a=0;a<t.length;a++)Oe(e,t[a],n,r,i);return null}return n=b(n),e&&e[fe]?e.K(t,n,s(r)?!!r.capture:!!r,i):Ee(e,t,n,!0,r,i)}function ke(e,t,n,r,i){if(Array.isArray(t))for(var a=0;a<t.length;a++)ke(e,t[a],n,r,i);else r=s(r)?!!r.capture:!!r,n=b(n),e&&e[fe]?(e=e.i,a=String(t).toString(),a in e.g&&(t=e.g[a],n=Ce(t,n,r,i),n>-1&&(he(t[n]),Array.prototype.splice.call(t,n,1),t.length==0&&(delete e.g[a],e.h--)))):(e&&=Ne(e))&&(t=e.g[t.toString()],e=-1,t&&(e=Ce(t,n,r,i)),(n=e>-1?t[e]:null)&&Ae(n))}function Ae(e){if(typeof e!=`number`&&e&&!e.da){var t=e.src;if(t&&t[fe])Se(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(je(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=Ne(t))?(Se(n,e),n.h==0&&(n.src=null,t[we]=null)):he(e)}}}function je(e){return e in Te?Te[e]:Te[e]=`on`+e}function Me(e,t){if(e.da)e=!0;else{t=new de(t,this);let n=e.listener,r=e.ha||e.src;e.fa&&Ae(e),e=n.call(r,t)}return e}function Ne(e){return e=e[we],e instanceof xe?e:null}var Pe=`__closure_events_fn_`+(Math.random()*1e9>>>0);function b(e){return typeof e==`function`?e:(e[Pe]||(e[Pe]=function(t){return e.handleEvent(t)}),e[Pe])}function x(){ce.call(this),this.i=new xe(this),this.M=this,this.G=null}d(x,ce),x.prototype[fe]=!0,x.prototype.removeEventListener=function(e,t,n,r){ke(this,e,t,n,r)};function Fe(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 v(t,e);else if(t instanceof v)t.target=t.target||e;else{var i=t;t=new v(r,e),be(t,i)}i=!0;let a,o;if(n)for(o=n.length-1;o>=0;o--)a=t.g=n[o],i=Ie(a,r,!0,t)&&i;if(a=t.g=e,i=Ie(a,r,!0,t)&&i,i=Ie(a,r,!1,t)&&i,n)for(o=0;o<n.length;o++)a=t.g=n[o],i=Ie(a,r,!1,t)&&i}x.prototype.N=function(){if(x.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++)he(n[e]);delete e.g[t],e.h--}}this.G=null},x.prototype.J=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},x.prototype.K=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};function Ie(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&&Se(e.i,o),i=t.call(n,r)!==!1&&i}}return i&&!r.defaultPrevented}function Le(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 Re(e){e.g=Le(()=>{e.g=null,e.i&&(e.i=!1,Re(e))},e.l);let t=e.h;e.h=null,e.m.apply(null,t)}class ze extends ce{constructor(e,t){super(),this.m=e,this.l=t,this.h=null,this.i=!1,this.g=null}j(e){this.h=arguments,this.g?this.i=!0:Re(this)}N(){super.N(),this.g&&(o.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Be(e){ce.call(this),this.h=e,this.g={}}d(Be,ce);var Ve=[];function He(e){ge(e.g,function(e,t){this.g.hasOwnProperty(t)&&Ae(e)},e),e.g={}}Be.prototype.N=function(){Be.Z.N.call(this),He(this)},Be.prototype.handleEvent=function(){throw Error(`EventHandler.handleEvent not implemented`)};var Ue=o.JSON.stringify,We=o.JSON.parse,Ge=class{stringify(e){return o.JSON.stringify(e,void 0)}parse(e){return o.JSON.parse(e,void 0)}};function Ke(){}function qe(){}var Je={OPEN:`a`,hb:`b`,ERROR:`c`,tb:`d`};function Ye(){v.call(this,`d`)}d(Ye,v);function Xe(){v.call(this,`c`)}d(Xe,v);var Ze={},Qe=null;function $e(){return Qe||=new x}Ze.Ia=`serverreachability`;function et(e){v.call(this,Ze.Ia,e)}d(et,v);function tt(e){let t=$e();Fe(t,new et(t))}Ze.STAT_EVENT=`statevent`;function nt(e,t){v.call(this,Ze.STAT_EVENT,e),this.stat=t}d(nt,v);function rt(e){let t=$e();Fe(t,new nt(t,e))}Ze.Ja=`timingevent`;function it(e,t){v.call(this,Ze.Ja,e),this.size=t}d(it,v);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(`=`);if(c.length>1){let e=c[0];c=c[1];let t=e.split(`_`);o=t.length>=2&&t[1]==`type`?o+(e+`=`+c+`&`):o+(e+`=redacted&`)}}}else o=null;else o=a;return`XMLHTTP REQ (`+r+`) [attempt `+i+`]: `+t+`
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e[`entropic-bond-firebase`]={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=()=>void 0,n=function(e){let t=[],n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=i&63|128):(i&64512)==55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)==56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t},r=function(e){let t=[],n=0,r=0;for(;n<e.length;){let i=e[n++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){let a=e[n++];t[r++]=String.fromCharCode((i&31)<<6|a&63)}else if(i>239&&i<365){let a=e[n++],o=e[n++],s=e[n++],c=((i&7)<<18|(a&63)<<12|(o&63)<<6|s&63)-65536;t[r++]=String.fromCharCode(55296+(c>>10)),t[r++]=String.fromCharCode(56320+(c&1023))}else{let a=e[n++],o=e[n++];t[r++]=String.fromCharCode((i&15)<<12|(a&63)<<6|o&63)}}return t.join(``)},i={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`,get ENCODED_VALS(){return this.ENCODED_VALS_BASE+`+/=`},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+`-_.`},HAS_NATIVE_SUPPORT:typeof atob==`function`,encodeByteArray(e,t){if(!Array.isArray(e))throw Error(`encodeByteArray takes an array as a parameter`);this.init_();let n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let t=0;t<e.length;t+=3){let i=e[t],a=t+1<e.length,o=a?e[t+1]:0,s=t+2<e.length,c=s?e[t+2]:0,l=i>>2,u=(i&3)<<4|o>>4,d=(o&15)<<2|c>>6,f=c&63;s||(f=64,a||(d=64)),r.push(n[l],n[u],n[d],n[f])}return r.join(``)},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(n(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):r(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();let n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let t=0;t<e.length;){let i=n[e.charAt(t++)],o=t<e.length?n[e.charAt(t)]:0;++t;let s=t<e.length?n[e.charAt(t)]:64;++t;let c=t<e.length?n[e.charAt(t)]:64;if(++t,i==null||o==null||s==null||c==null)throw new a;let l=i<<2|o>>4;if(r.push(l),s!==64){let e=o<<4&240|s>>2;if(r.push(e),c!==64){let e=s<<6&192|c;r.push(e)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}},a=class extends Error{constructor(){super(...arguments),this.name=`DecodeBase64StringError`}},o=function(e){let t=n(e);return i.encodeByteArray(t,!0)},s=function(e){return o(e).replace(/\./g,``)},c=function(e){try{return i.decodeString(e,!0)}catch(e){console.error(`base64Decode failed: `,e)}return null};function l(){if(typeof self<`u`)return self;if(typeof window<`u`)return window;if(typeof global<`u`)return global;throw Error(`Unable to locate global object.`)}var u=()=>l().__FIREBASE_DEFAULTS__,d=()=>{if(typeof process>`u`||process.env===void 0)return;let e=process.env.__FIREBASE_DEFAULTS__;if(e)return JSON.parse(e)},f=()=>{if(typeof document>`u`)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}let t=e&&c(e[1]);return t&&JSON.parse(t)},p=()=>{try{return t()||u()||d()||f()}catch(e){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);return}},m=e=>p()?.emulatorHosts?.[e],h=e=>{let t=m(e);if(!t)return;let n=t.lastIndexOf(`:`);if(n<=0||n+1===t.length)throw Error(`Invalid host ${t} with no separate hostname and port!`);let r=parseInt(t.substring(n+1),10);return t[0]===`[`?[t.substring(1,n-1),r]:[t.substring(0,n),r]},g=()=>p()?.config,ee=e=>p()?.[`_${e}`],te=class{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),typeof e==`function`&&(this.promise.catch(()=>{}),e.length===1?e(t):e(t,n))}}};function ne(e,t){if(e.uid)throw Error(`The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.`);let n={alg:`none`,type:`JWT`},r=t||`demo-project`,i=e.iat||0,a=e.sub||e.user_id;if(!a)throw Error(`mockUserToken must contain 'sub' or 'user_id' field!`);let o={iss:`https://securetoken.google.com/${r}`,aud:r,iat:i,exp:i+3600,auth_time:i,sub:a,user_id:a,firebase:{sign_in_provider:`custom`,identities:{}},...e};return[s(JSON.stringify(n)),s(JSON.stringify(o)),``].join(`.`)}function re(){return typeof navigator<`u`&&typeof navigator.userAgent==`string`?navigator.userAgent:``}function ie(){return typeof window<`u`&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(re())}function ae(){let e=p()?.forceEnvironment;if(e===`node`)return!0;if(e===`browser`)return!1;try{return Object.prototype.toString.call(global.process)===`[object process]`}catch{return!1}}function oe(){return typeof navigator<`u`&&navigator.userAgent===`Cloudflare-Workers`}function se(){let e=typeof chrome==`object`?chrome.runtime:typeof browser==`object`?browser.runtime:void 0;return typeof e==`object`&&e.id!==void 0}function ce(){return typeof navigator==`object`&&navigator.product===`ReactNative`}function le(){let e=re();return e.indexOf(`MSIE `)>=0||e.indexOf(`Trident/`)>=0}function ue(){return!ae()&&!!navigator.userAgent&&navigator.userAgent.includes(`Safari`)&&!navigator.userAgent.includes(`Chrome`)}function de(){try{return typeof indexedDB==`object`}catch{return!1}}function fe(){return new Promise((e,t)=>{try{let n=!0,r=`validate-browser-context-for-indexeddb-analytics-module`,i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{t(i.error?.message||``)}}catch(e){t(e)}})}var pe=`FirebaseError`,me=class e extends Error{constructor(t,n,r){super(n),this.code=t,this.customData=r,this.name=pe,Object.setPrototypeOf(this,e.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,he.prototype.create)}},he=class{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){let n=t[0]||{},r=`${this.service}/${e}`,i=this.errors[e],a=i?ge(i,n):`Error`;return new me(r,`${this.serviceName}: ${a} (${r}).`,n)}};function ge(e,t){return e.replace(_e,(e,n)=>{let r=t[n];return r==null?`<${n}?>`:String(r)})}var _e=/\{\$([^}]+)}/g;function ve(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function ye(e,t){if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);for(let i of n){if(!r.includes(i))return!1;let n=e[i],a=t[i];if(be(n)&&be(a)){if(!ye(n,a))return!1}else if(n!==a)return!1}for(let e of r)if(!n.includes(e))return!1;return!0}function be(e){return typeof e==`object`&&!!e}function xe(e){let t=[];for(let[n,r]of Object.entries(e))Array.isArray(r)?r.forEach(e=>{t.push(encodeURIComponent(n)+`=`+encodeURIComponent(e))}):t.push(encodeURIComponent(n)+`=`+encodeURIComponent(r));return t.length?`&`+t.join(`&`):``}function Se(e){let t={};return e.replace(/^\?/,``).split(`&`).forEach(e=>{if(e){let[n,r]=e.split(`=`);t[decodeURIComponent(n)]=decodeURIComponent(r)}}),t}function Ce(e){let t=e.indexOf(`?`);if(!t)return``;let n=e.indexOf(`#`,t);return e.substring(t,n>0?n:void 0)}function we(e,t){let n=new Te(e,t);return n.subscribe.bind(n)}var Te=class{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(e=>{this.error(e)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,n){let r;if(e===void 0&&t===void 0&&n===void 0)throw Error(`Missing Observer.`);r=Ee(e,[`next`,`error`,`complete`])?e:{next:e,error:t,complete:n},r.next===void 0&&(r.next=De),r.error===void 0&&(r.error=De),r.complete===void 0&&(r.complete=De);let i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch{}}),this.observers.push(r),i}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],--this.observerCount,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{t(this.observers[e])}catch(e){typeof console<`u`&&console.error&&console.error(e)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}};function Ee(e,t){if(typeof e!=`object`||!e)return!1;for(let n of t)if(n in e&&typeof e[n]==`function`)return!0;return!1}function De(){}function _(e){return e&&e._delegate?e._delegate:e}function Oe(e){try{return(e.startsWith(`http://`)||e.startsWith(`https://`)?new URL(e).hostname:e).endsWith(`.cloudworkstations.dev`)}catch{return!1}}async function ke(e){return(await fetch(e,{credentials:`include`})).ok}var Ae=class{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode=`LAZY`,this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}},je=`[DEFAULT]`,Me=class{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){let t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){let e=new te;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{let n=this.getOrInitializeService({instanceIdentifier:t});n&&e.resolve(n)}catch{}}return this.instancesDeferred.get(t).promise}getImmediate(e){let t=this.normalizeInstanceIdentifier(e?.identifier),n=e?.optional??!1;if(this.isInitialized(t)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:t})}catch(e){if(n)return null;throw e}else if(n)return null;else throw Error(`Service ${this.name} is not available`)}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if(Pe(e))try{this.getOrInitializeService({instanceIdentifier:je})}catch{}for(let[e,t]of this.instancesDeferred.entries()){let n=this.normalizeInstanceIdentifier(e);try{let e=this.getOrInitializeService({instanceIdentifier:n});t.resolve(e)}catch{}}}}clearInstance(e=je){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){let e=Array.from(this.instances.values());await Promise.all([...e.filter(e=>`INTERNAL`in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>`_delete`in e).map(e=>e._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=je){return this.instances.has(e)}getOptions(e=je){return this.instancesOptions.get(e)||{}}initialize(e={}){let{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);let r=this.getOrInitializeService({instanceIdentifier:n,options:t});for(let[e,t]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(e)&&t.resolve(r);return r}onInit(e,t){let n=this.normalizeInstanceIdentifier(t),r=this.onInitCallbacks.get(n)??new Set;r.add(e),this.onInitCallbacks.set(n,r);let i=this.instances.get(n);return i&&e(i,n),()=>{r.delete(e)}}invokeOnInitCallbacks(e,t){let n=this.onInitCallbacks.get(t);if(n)for(let r of n)try{r(e,t)}catch{}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:Ne(e),options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch{}return n||null}normalizeInstanceIdentifier(e=je){return this.component?this.component.multipleInstances?e:je:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!==`EXPLICIT`}};function Ne(e){return e===je?void 0:e}function Pe(e){return e.instantiationMode===`EAGER`}var Fe=class{constructor(e){this.name=e,this.providers=new Map}addComponent(e){let t=this.getProvider(e.name);if(t.isComponentSet())throw Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);let t=new Me(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}},Ie=[],v;(function(e){e[e.DEBUG=0]=`DEBUG`,e[e.VERBOSE=1]=`VERBOSE`,e[e.INFO=2]=`INFO`,e[e.WARN=3]=`WARN`,e[e.ERROR=4]=`ERROR`,e[e.SILENT=5]=`SILENT`})(v||={});var Le={debug:v.DEBUG,verbose:v.VERBOSE,info:v.INFO,warn:v.WARN,error:v.ERROR,silent:v.SILENT},Re=v.INFO,ze={[v.DEBUG]:`log`,[v.VERBOSE]:`log`,[v.INFO]:`info`,[v.WARN]:`warn`,[v.ERROR]:`error`},Be=(e,t,...n)=>{if(t<e.logLevel)return;let r=new Date().toISOString(),i=ze[t];if(i)console[i](`[${r}] ${e.name}:`,...n);else throw Error(`Attempted to log a message with an invalid logType (value: ${t})`)},Ve=class{constructor(e){this.name=e,this._logLevel=Re,this._logHandler=Be,this._userLogHandler=null,Ie.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in v))throw TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e==`string`?Le[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!=`function`)throw TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,v.DEBUG,...e),this._logHandler(this,v.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,v.VERBOSE,...e),this._logHandler(this,v.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,v.INFO,...e),this._logHandler(this,v.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,v.WARN,...e),this._logHandler(this,v.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,v.ERROR,...e),this._logHandler(this,v.ERROR,...e)}},He=(e,t)=>t.some(t=>e instanceof t),Ue,We;function Ge(){return Ue||=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]}function Ke(){return We||=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey]}var qe=new WeakMap,Je=new WeakMap,Ye=new WeakMap,Xe=new WeakMap,Ze=new WeakMap;function Qe(e){let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`success`,i),e.removeEventListener(`error`,a)},i=()=>{t(it(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener(`success`,i),e.addEventListener(`error`,a)});return t.then(t=>{t instanceof IDBCursor&&qe.set(t,e)}).catch(()=>{}),Ze.set(t,e),t}function $e(e){if(Je.has(e))return;let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`complete`,i),e.removeEventListener(`error`,a),e.removeEventListener(`abort`,a)},i=()=>{t(),r()},a=()=>{n(e.error||new DOMException(`AbortError`,`AbortError`)),r()};e.addEventListener(`complete`,i),e.addEventListener(`error`,a),e.addEventListener(`abort`,a)});Je.set(e,t)}var et={get(e,t,n){if(e instanceof IDBTransaction){if(t===`done`)return Je.get(e);if(t===`objectStoreNames`)return e.objectStoreNames||Ye.get(e);if(t===`store`)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return it(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&(t===`done`||t===`store`)?!0:t in e}};function tt(e){et=e(et)}function nt(e){return e===IDBDatabase.prototype.transaction&&!(`objectStoreNames`in IDBTransaction.prototype)?function(t,...n){let r=e.call(at(this),t,...n);return Ye.set(r,t.sort?t.sort():[t]),it(r)}:Ke().includes(e)?function(...t){return e.apply(at(this),t),it(qe.get(this))}:function(...t){return it(e.apply(at(this),t))}}function rt(e){return typeof e==`function`?nt(e):(e instanceof IDBTransaction&&$e(e),He(e,Ge())?new Proxy(e,et):e)}function it(e){if(e instanceof IDBRequest)return Qe(e);if(Xe.has(e))return Xe.get(e);let t=rt(e);return t!==e&&(Xe.set(e,t),Ze.set(t,e)),t}var at=e=>Ze.get(e);function ot(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){let o=indexedDB.open(e,t),s=it(o);return r&&o.addEventListener(`upgradeneeded`,e=>{r(it(o.result),e.oldVersion,e.newVersion,it(o.transaction),e)}),n&&o.addEventListener(`blocked`,e=>n(e.oldVersion,e.newVersion,e)),s.then(e=>{a&&e.addEventListener(`close`,()=>a()),i&&e.addEventListener(`versionchange`,e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),s}var st=[`get`,`getKey`,`getAll`,`getAllKeys`,`count`],ct=[`put`,`add`,`delete`,`clear`],lt=new Map;function ut(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t==`string`))return;if(lt.get(t))return lt.get(t);let n=t.replace(/FromIndex$/,``),r=t!==n,i=ct.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||st.includes(n)))return;let a=async function(e,...t){let a=this.transaction(e,i?`readwrite`:`readonly`),o=a.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&a.done]))[0]};return lt.set(t,a),a}tt(e=>({...e,get:(t,n,r)=>ut(t,n)||e.get(t,n,r),has:(t,n)=>!!ut(t,n)||e.has(t,n)}));var dt=class{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(ft(e)){let t=e.getImmediate();return`${t.library}/${t.version}`}else return null}).filter(e=>e).join(` `)}};function ft(e){return e.getComponent()?.type===`VERSION`}var pt=`@firebase/app`,mt=`0.15.0`,ht=new Ve(`@firebase/app`),gt=`@firebase/app-compat`,_t=`@firebase/analytics-compat`,vt=`@firebase/analytics`,yt=`@firebase/app-check-compat`,bt=`@firebase/app-check`,xt=`@firebase/auth`,St=`@firebase/auth-compat`,Ct=`@firebase/database`,wt=`@firebase/data-connect`,Tt=`@firebase/database-compat`,Et=`@firebase/functions`,Dt=`@firebase/functions-compat`,Ot=`@firebase/installations`,kt=`@firebase/installations-compat`,At=`@firebase/messaging`,jt=`@firebase/messaging-compat`,Mt=`@firebase/performance`,Nt=`@firebase/performance-compat`,Pt=`@firebase/remote-config`,Ft=`@firebase/remote-config-compat`,It=`@firebase/storage`,Lt=`@firebase/storage-compat`,Rt=`@firebase/firestore`,zt=`@firebase/ai`,Bt=`@firebase/firestore-compat`,Vt=`firebase`,Ht=`12.15.0`,Ut=`[DEFAULT]`,Wt={[pt]:`fire-core`,[gt]:`fire-core-compat`,[vt]:`fire-analytics`,[_t]:`fire-analytics-compat`,[bt]:`fire-app-check`,[yt]:`fire-app-check-compat`,[xt]:`fire-auth`,[St]:`fire-auth-compat`,[Ct]:`fire-rtdb`,[wt]:`fire-data-connect`,[Tt]:`fire-rtdb-compat`,[Et]:`fire-fn`,[Dt]:`fire-fn-compat`,[Ot]:`fire-iid`,[kt]:`fire-iid-compat`,[At]:`fire-fcm`,[jt]:`fire-fcm-compat`,[Mt]:`fire-perf`,[Nt]:`fire-perf-compat`,[Pt]:`fire-rc`,[Ft]:`fire-rc-compat`,[It]:`fire-gcs`,[Lt]:`fire-gcs-compat`,[Rt]:`fire-fst`,[Bt]:`fire-fst-compat`,[zt]:`fire-vertex`,"fire-js":`fire-js`,[Vt]:`fire-js-all`},Gt=new Map,Kt=new Map,qt=new Map;function Jt(e,t){try{e.container.addComponent(t)}catch(n){ht.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function Yt(e){let t=e.name;if(qt.has(t))return ht.debug(`There were multiple attempts to register component ${t}.`),!1;qt.set(t,e);for(let t of Gt.values())Jt(t,e);for(let t of Kt.values())Jt(t,e);return!0}function Xt(e,t){let n=e.container.getProvider(`heartbeat`).getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function y(e){return e==null?!1:e.settings!==void 0}var Zt=new he(`app`,`Firebase`,{"no-app":`No Firebase App '{$appName}' has been created - call initializeApp() first`,"bad-app-name":`Illegal App name: '{$appName}'`,"duplicate-app":`Firebase App named '{$appName}' already exists with different options or config`,"app-deleted":`Firebase App named '{$appName}' already deleted`,"server-app-deleted":`Firebase Server App has been deleted`,"no-options":`Need to provide options, when not being deployed to hosting via source.`,"invalid-app-argument":`firebase.{$appName}() takes either no argument or a Firebase App instance.`,"invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":`Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.`,"idb-get":`Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.`,"idb-set":`Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.`,"idb-delete":`Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.`,"finalization-registry-not-supported":`FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.`,"invalid-server-app-environment":`FirebaseServerApp is not for use in browser environments.`}),Qt=class{constructor(e,t,n){this._isDeleted=!1,this._options={...e},this._config={...t},this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new Ae(`app`,()=>this,`PUBLIC`))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw Zt.create(`app-deleted`,{appName:this._name})}},$t=Ht;function en(e,t={}){let n=e;typeof t!=`object`&&(t={name:t});let r={name:Ut,automaticDataCollectionEnabled:!0,...t},i=r.name;if(typeof i!=`string`||!i)throw Zt.create(`bad-app-name`,{appName:String(i)});if(n||=g(),!n)throw Zt.create(`no-options`);let a=Gt.get(i);if(a){if(ye(n,a.options)&&ye(r,a.config))return a;throw Zt.create(`duplicate-app`,{appName:i})}let o=new Fe(i);for(let e of qt.values())o.addComponent(e);let s=new Qt(n,r,o);return Gt.set(i,s),s}function tn(e=Ut){let t=Gt.get(e);if(!t&&e===`[DEFAULT]`&&g())return en();if(!t)throw Zt.create(`no-app`,{appName:e});return t}function nn(e,t,n){let r=Wt[e]??e;n&&(r+=`-${n}`);let i=r.match(/\s|\//),a=t.match(/\s|\//);if(i||a){let e=[`Unable to register library "${r}" with version "${t}":`];i&&e.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&a&&e.push(`and`),a&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),ht.warn(e.join(` `));return}Yt(new Ae(`${r}-version`,()=>({library:r,version:t}),`VERSION`))}var rn=`firebase-heartbeat-database`,an=1,on=`firebase-heartbeat-store`,sn=null;function cn(){return sn||=ot(rn,an,{upgrade:(e,t)=>{switch(t){case 0:try{e.createObjectStore(on)}catch(e){console.warn(e)}}}}).catch(e=>{throw Zt.create(`idb-open`,{originalErrorMessage:e.message})}),sn}async function ln(e){try{let t=(await cn()).transaction(on),n=await t.objectStore(on).get(dn(e));return await t.done,n}catch(e){if(e instanceof me)ht.warn(e.message);else{let t=Zt.create(`idb-get`,{originalErrorMessage:e?.message});ht.warn(t.message)}}}async function un(e,t){try{let n=(await cn()).transaction(on,`readwrite`);await n.objectStore(on).put(t,dn(e)),await n.done}catch(e){if(e instanceof me)ht.warn(e.message);else{let t=Zt.create(`idb-set`,{originalErrorMessage:e?.message});ht.warn(t.message)}}}function dn(e){return`${e.name}!${e.options.appId}`}var fn=1024,pn=30,mn=class{constructor(e){this.container=e,this._heartbeatsCache=null;let t=this.container.getProvider(`app`).getImmediate();this._storage=new _n(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){try{let e=this.container.getProvider(`platform-logger`).getImmediate().getPlatformInfoString(),t=hn();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===t||this._heartbeatsCache.heartbeats.some(e=>e.date===t))return;if(this._heartbeatsCache.heartbeats.push({date:t,agent:e}),this._heartbeatsCache.heartbeats.length>pn){let e=yn(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){ht.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return``;let e=hn(),{heartbeatsToSend:t,unsentEntries:n}=gn(this._heartbeatsCache.heartbeats),r=s(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,n.length>0?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),r}catch(e){return ht.warn(e),``}}};function hn(){return new Date().toISOString().substring(0,10)}function gn(e,t=fn){let n=[],r=e.slice();for(let i of e){let e=n.find(e=>e.agent===i.agent);if(!e){if(n.push({agent:i.agent,dates:[i.date]}),vn(n)>t){n.pop();break}}else if(e.dates.push(i.date),vn(n)>t){e.dates.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}var _n=class{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return de()?fe().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){let e=await ln(this.app);return e?.heartbeats?e:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){let t=await this.read();return un(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){let t=await this.read();return un(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:[...t.heartbeats,...e.heartbeats]})}else return}};function vn(e){return s(JSON.stringify({version:2,heartbeats:e})).length}function yn(e){if(e.length===0)return-1;let t=0,n=e[0].date;for(let r=1;r<e.length;r++)e[r].date<n&&(n=e[r].date,t=r);return t}function bn(e){Yt(new Ae(`platform-logger`,e=>new dt(e),`PRIVATE`)),Yt(new Ae(`heartbeat`,e=>new mn(e),`PRIVATE`)),nn(pt,mt,e),nn(pt,mt,`esm2020`),nn(`fire-js`,``)}bn(``);var xn=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},Sn={},Cn,wn;(function(){var e;function t(e,t){function n(){}n.prototype=t.prototype,e.F=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.D=function(e,n,r){for(var i=Array(arguments.length-2),a=2;a<arguments.length;a++)i[a-2]=arguments[a];return t.prototype[n].apply(e,i)}}function n(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=[,,,,],this.C=Array(this.blockSize),this.o=this.h=0,this.u()}t(r,n),r.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function i(e,t,n){n||=0;let r=Array(16);if(typeof t==`string`)for(var i=0;i<16;++i)r[i]=t.charCodeAt(n++)|t.charCodeAt(n++)<<8|t.charCodeAt(n++)<<16|t.charCodeAt(n++)<<24;else for(i=0;i<16;++i)r[i]=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24;t=e.g[0],n=e.g[1],i=e.g[2];let a=e.g[3],o;o=t+(a^n&(i^a))+r[0]+3614090360&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[1]+3905402710&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[2]+606105819&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[3]+3250441966&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(a^n&(i^a))+r[4]+4118548399&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[5]+1200080426&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[6]+2821735955&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[7]+4249261313&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(a^n&(i^a))+r[8]+1770035416&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[9]+2336552879&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[10]+4294925233&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[11]+2304563134&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(a^n&(i^a))+r[12]+1804603682&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[13]+4254626195&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[14]+2792965006&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[15]+1236535329&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(i^a&(n^i))+r[1]+4129170786&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[6]+3225465664&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[11]+643717713&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[0]+3921069994&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^a&(n^i))+r[5]+3593408605&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[10]+38016083&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[15]+3634488961&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[4]+3889429448&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^a&(n^i))+r[9]+568446438&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[14]+3275163606&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[3]+4107603335&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[8]+1163531501&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^a&(n^i))+r[13]+2850285829&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[2]+4243563512&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[7]+1735328473&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[12]+2368359562&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(n^i^a)+r[5]+4294588738&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[8]+2272392833&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[11]+1839030562&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[14]+4259657740&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(n^i^a)+r[1]+2763975236&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[4]+1272893353&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[7]+4139469664&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[10]+3200236656&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(n^i^a)+r[13]+681279174&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[0]+3936430074&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[3]+3572445317&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[6]+76029189&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(n^i^a)+r[9]+3654602809&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[12]+3873151461&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[15]+530742520&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[2]+3299628645&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(i^(n|~a))+r[0]+4096336452&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[7]+1126891415&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[14]+2878612391&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[5]+4237533241&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~a))+r[12]+1700485571&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[3]+2399980690&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[10]+4293915773&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[1]+2240044497&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~a))+r[8]+1873313359&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[15]+4264355552&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[6]+2734768916&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[13]+1309151649&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~a))+r[4]+4149444226&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[11]+3174756917&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[2]+718787259&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[9]+3951481745&4294967295,e.g[0]=e.g[0]+t&4294967295,e.g[1]=e.g[1]+(i+(o<<21&4294967295|o>>>11))&4294967295,e.g[2]=e.g[2]+i&4294967295,e.g[3]=e.g[3]+a&4294967295}r.prototype.v=function(e,t){t===void 0&&(t=e.length);let n=t-this.blockSize,r=this.C,a=this.h,o=0;for(;o<t;){if(a==0)for(;o<=n;)i(this,e,o),o+=this.blockSize;if(typeof e==`string`){for(;o<t;)if(r[a++]=e.charCodeAt(o++),a==this.blockSize){i(this,r),a=0;break}}else for(;o<t;)if(r[a++]=e[o++],a==this.blockSize){i(this,r),a=0;break}}this.h=a,this.o+=t},r.prototype.A=function(){var e=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;t=this.o*8;for(var n=e.length-8;n<e.length;++n)e[n]=t&255,t/=256;for(this.v(e),e=Array(16),t=0,n=0;n<4;++n)for(let r=0;r<32;r+=8)e[t++]=this.g[n]>>>r&255;return e};function a(e,t){var n=s;return Object.prototype.hasOwnProperty.call(n,e)?n[e]:n[e]=t(e)}function o(e,t){this.h=t;let n=[],r=!0;for(let i=e.length-1;i>=0;i--){let a=e[i]|0;r&&a==t||(n[i]=a,r=!1)}this.g=n}var s={};function c(e){return-128<=e&&e<128?a(e,function(e){return new o([e|0],e<0?-1:0)}):new o([e|0],e<0?-1:0)}function l(e){if(isNaN(e)||!isFinite(e))return d;if(e<0)return g(l(-e));let t=[],n=1;for(let r=0;e>=n;r++)t[r]=e/n|0,n*=4294967296;return new o(t,0)}function u(e,t){if(e.length==0)throw Error(`number format error: empty string`);if(t||=10,t<2||36<t)throw Error(`radix out of range: `+t);if(e.charAt(0)==`-`)return g(u(e.substring(1),t));if(e.indexOf(`-`)>=0)throw Error(`number format error: interior "-" character`);let n=l(t**8),r=d;for(let a=0;a<e.length;a+=8){var i=Math.min(8,e.length-a);let o=parseInt(e.substring(a,a+i),t);i<8?(i=l(t**+i),r=r.j(i).add(l(o))):(r=r.j(n),r=r.add(l(o)))}return r}var d=c(0),f=c(1),p=c(16777216);e=o.prototype,e.m=function(){if(h(this))return-g(this).m();let e=0,t=1;for(let n=0;n<this.g.length;n++){let r=this.i(n);e+=(r>=0?r:4294967296+r)*t,t*=4294967296}return e},e.toString=function(e){if(e||=10,e<2||36<e)throw Error(`radix out of range: `+e);if(m(this))return`0`;if(h(this))return`-`+g(this).toString(e);let t=l(e**6);var n=this;let r=``;for(;;){let i=re(n,t).g;n=ee(n,i.j(t));let a=((n.g.length>0?n.g[0]:n.h)>>>0).toString(e);if(n=i,m(n))return a+r;for(;a.length<6;)a=`0`+a;r=a+r}},e.i=function(e){return e<0?0:e<this.g.length?this.g[e]:this.h};function m(e){if(e.h!=0)return!1;for(let t=0;t<e.g.length;t++)if(e.g[t]!=0)return!1;return!0}function h(e){return e.h==-1}e.l=function(e){return e=ee(this,e),h(e)?-1:+!m(e)};function g(e){let t=e.g.length,n=[];for(let r=0;r<t;r++)n[r]=~e.g[r];return new o(n,~e.h).add(f)}e.abs=function(){return h(this)?g(this):this},e.add=function(e){let t=Math.max(this.g.length,e.g.length),n=[],r=0;for(let i=0;i<=t;i++){let t=r+(this.i(i)&65535)+(e.i(i)&65535),a=(t>>>16)+(this.i(i)>>>16)+(e.i(i)>>>16);r=a>>>16,t&=65535,a&=65535,n[i]=a<<16|t}return new o(n,n[n.length-1]&-2147483648?-1:0)};function ee(e,t){return e.add(g(t))}e.j=function(e){if(m(this)||m(e))return d;if(h(this))return h(e)?g(this).j(g(e)):g(g(this).j(e));if(h(e))return g(this.j(g(e)));if(this.l(p)<0&&e.l(p)<0)return l(this.m()*e.m());let t=this.g.length+e.g.length,n=[];for(var r=0;r<2*t;r++)n[r]=0;for(r=0;r<this.g.length;r++)for(let t=0;t<e.g.length;t++){let i=this.i(r)>>>16,a=this.i(r)&65535,o=e.i(t)>>>16,s=e.i(t)&65535;n[2*r+2*t]+=a*s,te(n,2*r+2*t),n[2*r+2*t+1]+=i*s,te(n,2*r+2*t+1),n[2*r+2*t+1]+=a*o,te(n,2*r+2*t+1),n[2*r+2*t+2]+=i*o,te(n,2*r+2*t+2)}for(e=0;e<t;e++)n[e]=n[2*e+1]<<16|n[2*e];for(e=t;e<2*t;e++)n[e]=0;return new o(n,0)};function te(e,t){for(;(e[t]&65535)!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function ne(e,t){this.g=e,this.h=t}function re(e,t){if(m(t))throw Error(`division by zero`);if(m(e))return new ne(d,d);if(h(e))return t=re(g(e),t),new ne(g(t.g),g(t.h));if(h(t))return t=re(e,g(t)),new ne(g(t.g),t.h);if(e.g.length>30){if(h(e)||h(t))throw Error(`slowDivide_ only works with positive integers.`);for(var n=f,r=t;r.l(e)<=0;)n=ie(n),r=ie(r);var i=ae(n,1),a=ae(r,1);for(r=ae(r,2),n=ae(n,2);!m(r);){var o=a.add(r);o.l(e)<=0&&(i=i.add(n),a=o),r=ae(r,1),n=ae(n,1)}return t=ee(e,i.j(t)),new ne(i,t)}for(i=d;e.l(t)>=0;){for(n=Math.max(1,Math.floor(e.m()/t.m())),r=Math.ceil(Math.log(n)/Math.LN2),r=r<=48?1:2**(r-48),a=l(n),o=a.j(t);h(o)||o.l(e)>0;)n-=r,a=l(n),o=a.j(t);m(a)&&(a=f),i=i.add(a),e=ee(e,o)}return new ne(i,e)}e.B=function(e){return re(this,e).h},e.and=function(e){let t=Math.max(this.g.length,e.g.length),n=[];for(let r=0;r<t;r++)n[r]=this.i(r)&e.i(r);return new o(n,this.h&e.h)},e.or=function(e){let t=Math.max(this.g.length,e.g.length),n=[];for(let r=0;r<t;r++)n[r]=this.i(r)|e.i(r);return new o(n,this.h|e.h)},e.xor=function(e){let t=Math.max(this.g.length,e.g.length),n=[];for(let r=0;r<t;r++)n[r]=this.i(r)^e.i(r);return new o(n,this.h^e.h)};function ie(e){let t=e.g.length+1,n=[];for(let r=0;r<t;r++)n[r]=e.i(r)<<1|e.i(r-1)>>>31;return new o(n,e.h)}function ae(e,t){let n=t>>5;t%=32;let r=e.g.length-n,i=[];for(let a=0;a<r;a++)i[a]=t>0?e.i(a+n)>>>t|e.i(a+n+1)<<32-t:e.i(a+n);return new o(i,e.h)}r.prototype.digest=r.prototype.A,r.prototype.reset=r.prototype.u,r.prototype.update=r.prototype.v,wn=Sn.Md5=r,o.prototype.add=o.prototype.add,o.prototype.multiply=o.prototype.j,o.prototype.modulo=o.prototype.B,o.prototype.compare=o.prototype.l,o.prototype.toNumber=o.prototype.m,o.prototype.toString=o.prototype.toString,o.prototype.getBits=o.prototype.i,o.fromNumber=l,o.fromString=u,Cn=Sn.Integer=o}).apply(xn===void 0?typeof self<`u`?self:typeof window<`u`?window:{}:xn);var Tn=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},En={},Dn,On,kn,An,jn,Mn,Nn,Pn;(function(){var e,t=Object.defineProperty;function n(e){e=[typeof globalThis==`object`&&globalThis,e,typeof window==`object`&&window,typeof self==`object`&&self,typeof Tn==`object`&&Tn];for(var t=0;t<e.length;++t){var n=e[t];if(n&&n.Math==Math)return n}throw Error(`Cannot find global object`)}var r=n(this);function i(e,n){if(n)a:{var i=r;e=e.split(`.`);for(var a=0;a<e.length-1;a++){var o=e[a];if(!(o in i))break a;i=i[o]}e=e[e.length-1],a=i[e],n=n(a),n!=a&&n!=null&&t(i,e,{configurable:!0,writable:!0,value:n})}}i(`Symbol.dispose`,function(e){return e||Symbol(`Symbol.dispose`)}),i(`Array.prototype.values`,function(e){return e||function(){return this[Symbol.iterator]()}}),i(`Object.entries`,function(e){return e||function(e){var t=[],n;for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push([n,e[n]]);return t}});var a=a||{},o=this||self;function s(e){var t=typeof e;return t==`object`&&e!=null||t==`function`}function c(e,t,n){return e.call.apply(e.bind,arguments)}function l(e,t,n){return l=c,l.apply(null,arguments)}function u(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function d(e,t){function n(){}n.prototype=t.prototype,e.Z=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Ob=function(e,n,r){for(var i=Array(arguments.length-2),a=2;a<arguments.length;a++)i[a-2]=arguments[a];return t.prototype[n].apply(e,i)}}var f=typeof AsyncContext<`u`&&typeof AsyncContext.Snapshot==`function`?e=>e&&AsyncContext.Snapshot.wrap(e):e=>e;function p(e){let t=e.length;if(t>0){let n=Array(t);for(let r=0;r<t;r++)n[r]=e[r];return n}return[]}function m(e,t){for(let t=1;t<arguments.length;t++){let r=arguments[t];var n=typeof r;if(n=n==`object`?r?Array.isArray(r)?`array`:n:`null`:n,n==`array`||n==`object`&&typeof r.length==`number`){n=e.length||0;let t=r.length||0;e.length=n+t;for(let i=0;i<t;i++)e[n+i]=r[i]}else e.push(r)}}class h{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return this.h>0?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}function g(e){o.setTimeout(()=>{throw e},0)}function ee(){var e=oe;let t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}class te{constructor(){this.h=this.g=null}add(e,t){let n=ne.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}}var ne=new h(()=>new re,e=>e.reset());class re{constructor(){this.next=this.g=this.h=null}set(e,t){this.h=e,this.g=t,this.next=null}reset(){this.next=this.g=this.h=null}}let ie,ae=!1,oe=new te,se=()=>{let e=Promise.resolve(void 0);ie=()=>{e.then(ce)}};function ce(){for(var e;e=ee();){try{e.h.call(e.g)}catch(e){g(e)}var t=ne;t.j(e),t.h<100&&(t.h++,e.next=t.g,t.g=e)}ae=!1}function le(){this.u=this.u,this.C=this.C}le.prototype.u=!1,le.prototype.dispose=function(){this.u||(this.u=!0,this.N())},le.prototype[Symbol.dispose]=function(){this.dispose()},le.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function ue(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}ue.prototype.h=function(){this.defaultPrevented=!0};var de=function(){if(!o.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{let e=()=>{};o.addEventListener(`test`,e,t),o.removeEventListener(`test`,e,t)}catch{}return e}();function fe(e){return/^[\s\xa0]*$/.test(e)}function pe(e,t){ue.call(this,e?e.type:``),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key=``,this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType=``,this.i=null,e&&this.init(e,t)}d(pe,ue),pe.prototype.init=function(e,t){let n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget,t||(n==`mouseover`?t=e.fromElement:n==`mouseout`&&(t=e.toElement)),this.relatedTarget=t,r?(this.clientX=r.clientX===void 0?r.pageX:r.clientX,this.clientY=r.clientY===void 0?r.pageY:r.clientY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=e.clientX===void 0?e.pageX:e.clientX,this.clientY=e.clientY===void 0?e.pageY:e.clientY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||``,this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType=e.pointerType,this.state=e.state,this.i=e,e.defaultPrevented&&pe.Z.h.call(this)},pe.prototype.h=function(){pe.Z.h.call(this);let e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var me=`closure_listenable_`+(Math.random()*1e6|0),he=0;function ge(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ha=i,this.key=++he,this.da=this.fa=!1}function _e(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function ve(e,t,n){for(let r in e)t.call(n,e[r],r,e)}function ye(e,t){for(let n in e)t.call(void 0,e[n],n,e)}function be(e){let t={};for(let n in e)t[n]=e[n];return t}let xe=`constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf`.split(` `);function Se(e,t){let n,r;for(let t=1;t<arguments.length;t++){for(n in r=arguments[t],r)e[n]=r[n];for(let t=0;t<xe.length;t++)n=xe[t],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function Ce(e){this.src=e,this.g={},this.h=0}Ce.prototype.add=function(e,t,n,r,i){let a=e.toString();e=this.g[a],e||(e=this.g[a]=[],this.h++);let o=Te(e,t,r,i);return o>-1?(t=e[o],n||(t.fa=!1)):(t=new ge(t,this.src,a,!!r,i),t.fa=n,e.push(t)),t};function we(e,t){let n=t.type;if(n in e.g){var r=e.g[n],i=Array.prototype.indexOf.call(r,t,void 0),a;(a=i>=0)&&Array.prototype.splice.call(r,i,1),a&&(_e(t),e.g[n].length==0&&(delete e.g[n],e.h--))}}function Te(e,t,n,r){for(let i=0;i<e.length;++i){let a=e[i];if(!a.da&&a.listener==t&&a.capture==!!n&&a.ha==r)return i}return-1}var Ee=`closure_lm_`+(Math.random()*1e6|0),De={};function _(e,t,n,r,i){if(r&&r.once)return Ae(e,t,n,r,i);if(Array.isArray(t)){for(let a=0;a<t.length;a++)_(e,t[a],n,r,i);return null}return n=v(n),e&&e[me]?e.J(t,n,s(r)?!!r.capture:!!r,i):Oe(e,t,n,!1,r,i)}function Oe(e,t,n,r,i,a){if(!t)throw Error(`Invalid event type`);let o=s(i)?!!i.capture:!!i,c=Fe(e);if(c||(e[Ee]=c=new Ce(e)),n=c.add(t,n,r,o,a),n.proxy)return n;if(r=ke(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)de||(i=o),i===void 0&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(Ne(t.toString()),r);else if(e.addListener&&e.removeListener)e.addListener(r);else throw Error(`addEventListener and attachEvent are unavailable.`);return n}function ke(){function e(n){return t.call(e.src,e.listener,n)}let t=Pe;return e}function Ae(e,t,n,r,i){if(Array.isArray(t)){for(let a=0;a<t.length;a++)Ae(e,t[a],n,r,i);return null}return n=v(n),e&&e[me]?e.K(t,n,s(r)?!!r.capture:!!r,i):Oe(e,t,n,!0,r,i)}function je(e,t,n,r,i){if(Array.isArray(t))for(var a=0;a<t.length;a++)je(e,t[a],n,r,i);else r=s(r)?!!r.capture:!!r,n=v(n),e&&e[me]?(e=e.i,a=String(t).toString(),a in e.g&&(t=e.g[a],n=Te(t,n,r,i),n>-1&&(_e(t[n]),Array.prototype.splice.call(t,n,1),t.length==0&&(delete e.g[a],e.h--)))):(e&&=Fe(e))&&(t=e.g[t.toString()],e=-1,t&&(e=Te(t,n,r,i)),(n=e>-1?t[e]:null)&&Me(n))}function Me(e){if(typeof e!=`number`&&e&&!e.da){var t=e.src;if(t&&t[me])we(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(Ne(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=Fe(t))?(we(n,e),n.h==0&&(n.src=null,t[Ee]=null)):_e(e)}}}function Ne(e){return e in De?De[e]:De[e]=`on`+e}function Pe(e,t){if(e.da)e=!0;else{t=new pe(t,this);let n=e.listener,r=e.ha||e.src;e.fa&&Me(e),e=n.call(r,t)}return e}function Fe(e){return e=e[Ee],e instanceof Ce?e:null}var Ie=`__closure_events_fn_`+(Math.random()*1e9>>>0);function v(e){return typeof e==`function`?e:(e[Ie]||(e[Ie]=function(t){return e.handleEvent(t)}),e[Ie])}function Le(){le.call(this),this.i=new Ce(this),this.M=this,this.G=null}d(Le,le),Le.prototype[me]=!0,Le.prototype.removeEventListener=function(e,t,n,r){je(this,e,t,n,r)};function Re(e,t){var n,r=e.G;if(r)for(n=[];r;r=r.G)n.push(r);if(e=e.M,r=t.type||t,typeof t==`string`)t=new ue(t,e);else if(t instanceof ue)t.target=t.target||e;else{var i=t;t=new ue(r,e),Se(t,i)}i=!0;let a,o;if(n)for(o=n.length-1;o>=0;o--)a=t.g=n[o],i=ze(a,r,!0,t)&&i;if(a=t.g=e,i=ze(a,r,!0,t)&&i,i=ze(a,r,!1,t)&&i,n)for(o=0;o<n.length;o++)a=t.g=n[o],i=ze(a,r,!1,t)&&i}Le.prototype.N=function(){if(Le.Z.N.call(this),this.i){var e=this.i;for(let t in e.g){let n=e.g[t];for(let e=0;e<n.length;e++)_e(n[e]);delete e.g[t],e.h--}}this.G=null},Le.prototype.J=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},Le.prototype.K=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};function ze(e,t,n,r){if(t=e.i.g[String(t)],!t)return!0;t=t.concat();let i=!0;for(let a=0;a<t.length;++a){let o=t[a];if(o&&!o.da&&o.capture==n){let t=o.listener,n=o.ha||o.src;o.fa&&we(e.i,o),i=t.call(n,r)!==!1&&i}}return i&&!r.defaultPrevented}function Be(e,t){if(typeof e!=`function`)if(e&&typeof e.handleEvent==`function`)e=l(e.handleEvent,e);else throw Error(`Invalid listener argument`);return Number(t)>2147483647?-1:o.setTimeout(e,t||0)}function Ve(e){e.g=Be(()=>{e.g=null,e.i&&(e.i=!1,Ve(e))},e.l);let t=e.h;e.h=null,e.m.apply(null,t)}class He extends le{constructor(e,t){super(),this.m=e,this.l=t,this.h=null,this.i=!1,this.g=null}j(e){this.h=arguments,this.g?this.i=!0:Ve(this)}N(){super.N(),this.g&&(o.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Ue(e){le.call(this),this.h=e,this.g={}}d(Ue,le);var We=[];function Ge(e){ve(e.g,function(e,t){this.g.hasOwnProperty(t)&&Me(e)},e),e.g={}}Ue.prototype.N=function(){Ue.Z.N.call(this),Ge(this)},Ue.prototype.handleEvent=function(){throw Error(`EventHandler.handleEvent not implemented`)};var Ke=o.JSON.stringify,qe=o.JSON.parse,Je=class{stringify(e){return o.JSON.stringify(e,void 0)}parse(e){return o.JSON.parse(e,void 0)}};function Ye(){}function Xe(){}var Ze={OPEN:`a`,hb:`b`,ERROR:`c`,tb:`d`};function Qe(){ue.call(this,`d`)}d(Qe,ue);function $e(){ue.call(this,`c`)}d($e,ue);var et={},tt=null;function nt(){return tt||=new Le}et.Ia=`serverreachability`;function rt(e){ue.call(this,et.Ia,e)}d(rt,ue);function it(e){let t=nt();Re(t,new rt(t))}et.STAT_EVENT=`statevent`;function at(e,t){ue.call(this,et.STAT_EVENT,e),this.stat=t}d(at,ue);function ot(e){let t=nt();Re(t,new at(t,e))}et.Ja=`timingevent`;function st(e,t){ue.call(this,et.Ja,e),this.size=t}d(st,ue);function ct(e,t){if(typeof e!=`function`)throw Error(`Fn must not be null and must be a function`);return o.setTimeout(function(){e()},t)}function lt(){this.g=!0}lt.prototype.ua=function(){this.g=!1};function ut(e,t,n,r,i,a){e.info(function(){if(e.g)if(a){var o=``,s=a.split(`&`);for(let e=0;e<s.length;e++){var c=s[e].split(`=`);if(c.length>1){let e=c[0];c=c[1];let t=e.split(`_`);o=t.length>=2&&t[1]==`type`?o+(e+`=`+c+`&`):o+(e+`=redacted&`)}}}else o=null;else o=a;return`XMLHTTP REQ (`+r+`) [attempt `+i+`]: `+t+`
2
2
  `+n+`
3
- `+o})}function ct(e,t,n,r,i,a,o){e.info(function(){return`XMLHTTP RESP (`+r+`) [ attempt `+i+`]: `+t+`
3
+ `+o})}function dt(e,t,n,r,i,a,o){e.info(function(){return`XMLHTTP RESP (`+r+`) [ attempt `+i+`]: `+t+`
4
4
  `+n+`
5
- `+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 Ue(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,Ke),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 Be(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=tr(e.j,n?t:null,!e.u),e.P>0&&(e.O=new ze(l(e.Y,e,e.g),e.P)),t=e.V,n=e.g,r=e.ba;var i=`readystatechange`;Array.isArray(i)||(i&&(Ve[0]=i.toString()),i=Ve);for(let e=0;e<i.length;e++){let a=y(n,i[e],r||t.handleEvent,!1,t.h||t);if(!a)break;t.g[a.key]=a}t=e.J?ve(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)),tt(),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&&E(e)==3?t.j():this.Y(e)},vt.prototype.Y=function(e){try{if(e==this.g)a:{let s=E(this.g),c=this.g.ya(),l=this.g.ca();if(!(s<3)&&(s!=3||this.g&&(this.h.h||this.g.la()||Rn(this.g)))){this.K||s!=4||c==7||tt(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)&&!ue(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,rt(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,rt(14),e=!1),lt(this.i,this.l,null,`[Incomplete Response]`);break}else if(t==bt){this.m=4,rt(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,rt(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),Jn(o),o.P=!0,rt(11))}}else lt(this.i,this.l,n,null),Mt(this,n);s==4&&jt(this),this.o&&!this.K&&(s==4?Xn(this.j,this):(this.o=!1,Dt(this)))}else D(this.g),t==400&&n.indexOf(`Unknown SID`)>0?(this.m=3,rt(12)):(this.m=0,rt(13)),jt(this),At(this)}}}catch{}};function wt(e){if(!Tt(e))return e.g.la();let t=Rn(e.g);if(t===``)return``;let n=``,r=t.length,i=E(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(`
6
- `,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&&(tt(),rt(17)),jt(this),this.m=2,At(this)):Ot(this,this.T-e)};function At(e){e.j.I==0||e.K||Xn(e.j,e)}function jt(e){kt(e);var t=e.O;t&&typeof t.dispose==`function`&&t.dispose(),e.O=null,He(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.dispose())}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)j(n),zn(n);else break a;qn(n),rt(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 Qn(n,11)}else if((e.L||n.g==e)&&j(n),!ue(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=er(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 Kn(r);n.i.length>0&&Vn(n)}else l[0]!=`stop`&&l[0]!=`close`||Qn(n,7);else n.I==3&&(l[0]==`stop`||l[0]==`close`?l[0]==`stop`?Qn(n,7):A(n):l[0]!=`noop`&&n.l&&n.l.qa(l),n.A=0)}}tt(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.forEach(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 Ge}function _n(e){this.i=e.Sb||null,this.h=e.ab||!1}d(_n,Ke),_n.prototype.g=function(){return new vn(this.i,this.h)};function vn(e,t){x.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,x),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
7
- `)};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 C(e){let t=``;return ge(e,function(e,n){t+=n,t+=`:`,t+=e,t+=`\r
8
- `}),t}function Mn(e,t,n){a:{for(r in n){var r=!1;break a}r=!0}r||(n=C(n),typeof e==`string`||S(e,t,n))}function w(e){x.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(w,x);var Nn=/^https?$/i,Pn=[`POST`,`PUT`];e=w.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){T(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(Pn,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){T(this,e)}};function T(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.o=5,Fn(e),Ln(e)}function Fn(e){e.A||(e.A=!0,Fe(e,`complete`),Fe(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,Fe(this,`complete`),Fe(this,`abort`),Ln(this))},e.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Ln(this,!0)),w.Z.N.call(this)},e.Ca=function(){this.u||(this.B||this.v||this.j?In(this):this.Xa())},e.Xa=function(){In(this)};function In(e){if(e.h&&a!==void 0){if(e.v&&E(e)==4)setTimeout(e.Ca.bind(e),0);else if(Fe(e,`readystatechange`),E(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=!Nn.test(t?t.toLowerCase():``)}n=r}if(n)Fe(e,`complete`),Fe(e,`success`);else{e.o=6;try{var i=E(e)>2?e.g.statusText:``}catch{i=``}e.l=i+` [`+e.ca()+`]`,Fn(e)}}finally{Ln(e)}}}}function Ln(e,t){if(e.g){e.m&&=(clearTimeout(e.m),null);let n=e.g;e.g=null,t||Fe(e,`ready`);try{n.onreadystatechange=null}catch{}}}e.isActive=function(){return!!this.g};function E(e){return e.g?e.g.readyState:0}e.ca=function(){try{return E(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)),We(t)}};function Rn(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 D(e){let t={};e=(e.g&&E(e)>=2&&e.g.getAllResponseHeaders()||``).split(`\r
9
- `);for(let r=0;r<e.length;r++){if(ue(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)}_e(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 O(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function k(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=O(`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=O(`baseRetryDelayMs`,5e3,e),this.Za=O(`retryDelaySeedMs`,1e4,e),this.Ta=O(`forwardChannelMaxRetries`,2,e),this.va=O(`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=k.prototype,e.ka=8,e.I=1,e.connect=function(e,t,n,r){rt(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=er(this,null,this.W),Vn(this)};function A(e){if(Bn(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`),Wn(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=tr(t.j,null),t.g.ea(t.A)),t.F=Date.now(),Dt(t)}$n(e)}function zn(e){e.g&&=(Jn(e),e.g.cancel(),null)}function Bn(e){zn(e),e.v&&=(o.clearTimeout(e.v),null),j(e),e.h.cancel(),e.m&&=(typeof e.m==`number`&&o.clearTimeout(e.m),null)}function Vn(e){if(!Ft(e.h)&&!e.m){e.m=!0;var t=e.Ea;re||oe(),ie||=(re(),!0),ae.add(t,e),e.D=0}}function Hn(e,t){return It(e.h)>=e.h.j-(e.m?1:0)?!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),Zn(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=ve(a),be(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=Gn(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),Wn(this,n),a&&(this.R?t=`headers=`+gt(C(a))+`&`+t:this.u&&Mn(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?Un(this,e):this.i.length==0||Ft(this.h)||Un(this))};function Un(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),Wn(e,r),e.u&&e.o&&Mn(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=Gn(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 Wn(e,t){e.H&&ge(e.H,function(e,n){S(t,n,e)}),e.l&&ge({},function(e,n){S(t,n,e)})}function Gn(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=Ue(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 Kn(e){if(!e.g&&!e.v){e.Y=1;var t=e.Da;re||oe(),ie||=(re(),!0),ae.add(t,e),e.A=0}}function qn(e){return e.g||e.v||e.A>=3?!1:(e.Y++,e.v=at(l(e.Da,e),Zn(e,e.A)),e.A++,!0)}e.Da=function(){if(this.v=null,Yn(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,rt(10),zn(this),Yn(this))};function Jn(e){e.B!=null&&(o.clearTimeout(e.B),e.B=null)}function Yn(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`),Wn(e,t),e.u&&e.o&&Mn(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,zn(this),qn(this),rt(19))};function j(e){e.C!=null&&(o.clearTimeout(e.C),e.C=null)}function Xn(e,t){var n=null;if(e.g==t){j(e),Jn(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=$e(),Fe(r,new it(r,n)),Vn(e)}else Kn(e);else if(i=t.m,i==3||i==0&&t.X>0||!(r==1&&Hn(e,t)||r==2&&qn(e)))switch(n&&n.length>0&&(t=e.h,t.i=t.i.concat(n)),i){case 1:Qn(e,5);break;case 4:Qn(e,10);break;case 3:Qn(e,6);break;default:Qn(e,2)}}}function Zn(e,t){let n=e.Qa+Math.floor(Math.random()*e.Za);return e.isActive()||(n*=2),n*t}function Qn(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 rt(2);e.I=0,e.l&&e.l.pa(t),$n(e),Bn(e)}e.bb=function(e){e?(this.j.info(`Successfully pinged google.com`),rt(2)):(this.j.info(`Failed to ping google.com`),rt(1))};function $n(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 er(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),Wn(e,r),r}function tr(e,t,n){if(t&&!e.L)throw Error(`Can't create secondary domain capable XhrIo object.`);return t=e.Aa&&!e.ma?new w(new _n({ab:n})):new w(e.ma),t.Fa(e.L),t}e.isActive=function(){return!!this.l&&this.l.isActive(this)};function nr(){}e=nr.prototype,e.ra=function(){},e.qa=function(){},e.pa=function(){},e.oa=function(){},e.isActive=function(){return!0},e.Ka=function(){};function M(){}M.prototype.g=function(e,t){return new rr(e,t)};function rr(e,t){x.call(this),this.g=new k(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)&&!ue(e)&&(this.g.u=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t&&=t.httpSessionIdParam)&&!ue(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 ar(this)}d(rr,x),rr.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},rr.prototype.close=function(){A(this.g)},rr.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__=Ue(e),e=n);t.i.push(new Nt(t.Ya++,e)),t.I==3&&Vn(t)},rr.prototype.N=function(){this.g.l=null,delete this.j,A(this.g),delete this.g,rr.Z.N.call(this)};function ir(e){Ye.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(ir,Ye);function N(){Xe.call(this),this.status=1}d(N,Xe);function ar(e){this.g=e}d(ar,nr),ar.prototype.ra=function(){Fe(this.g,`a`)},ar.prototype.qa=function(e){Fe(this.g,new ir(e))},ar.prototype.pa=function(e){Fe(this.g,new N)},ar.prototype.oa=function(){Fe(this.g,`b`)},M.prototype.createWebChannel=M.prototype.g,rr.prototype.send=rr.prototype.o,rr.prototype.open=rr.prototype.m,rr.prototype.close=rr.prototype.close,jn=Cn.createWebChannelTransport=function(){return new M},An=Cn.getStatEventTarget=function(){return $e()},kn=Cn.Event=Ze,On=Cn.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,Dn=Cn.ErrorCode=ft,pt.COMPLETE=`complete`,En=Cn.EventType=pt,qe.EventType=Je,Je.OPEN=`a`,Je.CLOSE=`b`,Je.ERROR=`c`,Je.MESSAGE=`d`,x.prototype.listen=x.prototype.J,Tn=Cn.WebChannel=qe,Cn.FetchXmlHttpFactory=_n,w.prototype.listenOnce=w.prototype.K,w.prototype.getLastError=w.prototype.Ha,w.prototype.getLastErrorCode=w.prototype.ya,w.prototype.getStatus=w.prototype.ca,w.prototype.getResponseJson=w.prototype.La,w.prototype.getResponseText=w.prototype.la,w.prototype.send=w.prototype.ea,w.prototype.setWithCredentials=w.prototype.Fa,wn=Cn.XhrIo=w}).apply(Sn===void 0?typeof self<`u`?self:typeof window<`u`?window:{}:Sn);var C=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}};C.UNAUTHENTICATED=new C(null),C.GOOGLE_CREDENTIALS=new C(`google-credentials-uid`),C.FIRST_PARTY=new C(`first-party-uid`),C.MOCK_USER=new C(`mock-user`);var Mn=`12.11.0`;function w(e){Mn=e}var Nn=new Re(`@firebase/firestore`);function Pn(){return Nn.logLevel}function T(e,...t){if(Nn.logLevel<=b.DEBUG){let n=t.map(Ln);Nn.debug(`Firestore (${Mn}): ${e}`,...n)}}function Fn(e,...t){if(Nn.logLevel<=b.ERROR){let n=t.map(Ln);Nn.error(`Firestore (${Mn}): ${e}`,...n)}}function In(e,...t){if(Nn.logLevel<=b.WARN){let n=t.map(Ln);Nn.warn(`Firestore (${Mn}): ${e}`,...n)}}function Ln(e){if(typeof e==`string`)return e;try{return function(e){return JSON.stringify(e)}(e)}catch{return e}}function E(e,t,n){let r=`Unexpected state`;typeof t==`string`?r=t:n=t,Rn(e,r,n)}function Rn(e,t,n){let r=`FIRESTORE (${Mn}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(n!==void 0)try{r+=` CONTEXT: `+JSON.stringify(n)}catch{r+=` CONTEXT: `+n}throw Fn(r),Error(r)}function D(e,t,n,r){let i=`Unexpected state`;typeof n==`string`?i=n:r=n,e||Rn(t,i,r)}function O(e,t){return e}var k={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`},A=class extends fe{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}},zn=class{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}},Bn=class{constructor(e,t){this.user=t,this.type=`OAuth`,this.headers=new Map,this.headers.set(`Authorization`,`Bearer ${e}`)}},Vn=class{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(C.UNAUTHENTICATED)))}shutdown(){}},Hn=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}},Un=class{constructor(e){this.t=e,this.currentUser=C.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){D(this.o===void 0,42304);let n=this.i,r=e=>this.i===n?Promise.resolve():(n=this.i,t(e)),i=new zn;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new zn,e.enqueueRetryable((()=>r(this.currentUser)))};let a=()=>{let t=i;e.enqueueRetryable((async()=>{await t.promise,await r(this.currentUser)}))},o=e=>{T(`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):(T(`FirebaseAuthCredentialsProvider`,`Auth not yet detected`),i.resolve(),i=new zn)}}),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?(D(typeof t.accessToken==`string`,31837,{l:t}),new Bn(t.accessToken,this.currentUser)):null:(T(`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 D(e===null||typeof e==`string`,2055,{h:e}),new C(e)}},Wn=class{constructor(e,t,n){this.P=e,this.T=t,this.I=n,this.type=`FirstParty`,this.user=C.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-Iam-Authorization-Token`,this.T),this.R}},Gn=class{constructor(e,t,n){this.P=e,this.T=t,this.I=n}getToken(){return Promise.resolve(new Wn(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable((()=>t(C.FIRST_PARTY)))}shutdown(){}invalidateToken(){}},Kn=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)}},qn=class{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,S(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){D(this.o===void 0,3512);let n=e=>{e.error!=null&&T(`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,T(`FirebaseAppCheckTokenProvider`,`Received ${n?`new`:`existing`} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable((()=>n(t)))};let r=e=>{T(`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):T(`FirebaseAppCheckTokenProvider`,`AppCheck not yet detected`)}}),0)}getToken(){if(this.p)return Promise.resolve(new Kn(this.p));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((e=>e?(D(typeof e.token==`string`,44558,{tokenResult:e}),this.m=e.token,new Kn(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 Jn(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 Yn=class{static newId(){let e=``;for(;e.length<20;){let t=Jn(40);for(let n=0;n<t.length;++n)e.length<20&&t[n]<248&&(e+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(t[n]%62))}return e}};function j(e,t){return e<t?-1:e>t?1:0}function Xn(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 $n(n)===$n(i)?j(n,i):$n(n)?1:-1}return j(e.length,t.length)}var Zn=55296,Qn=57343;function $n(e){let t=e.charCodeAt(0);return t>=Zn&&t<=Qn}function er(e,t,n){return e.length===t.length&&e.every(((e,r)=>n(e,t[r])))}var tr=`__name__`,nr=class e{constructor(e,t,n){t===void 0?t=0:t>e.length&&E(637,{offset:t,range:e.length}),n===void 0?n=e.length-t:n>e.length-t&&E(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 j(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)):Xn(t,n)}static isNumericId(e){return e.startsWith(`__id`)&&e.endsWith(`__`)}static extractNumericId(e){return bn.fromString(e.substring(4,e.length-2))}},M=class e extends nr{construct(t,n,r){return new e(t,n,r)}canonicalString(){return this.toArray().join(`/`)}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join(`/`)}static fromString(...t){let n=[];for(let e of t){if(e.indexOf(`//`)>=0)throw new A(k.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([])}},rr=/^[_a-zA-Z][_a-zA-Z0-9]*$/,ir=class e extends nr{construct(t,n,r){return new e(t,n,r)}static isValidIdentifier(e){return rr.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([tr])}static fromServerFormat(t){let n=[],r=``,i=0,a=()=>{if(r.length===0)throw new A(k.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 A(k.INVALID_ARGUMENT,`Path has trailing escape character: `+t);let e=t[i+1];if(e!==`\\`&&e!==`.`&&e!=="`")throw new A(k.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 A(k.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)}static emptyPath(){return new e([])}},N=class e{constructor(e){this.path=e}static fromPath(t){return new e(M.fromString(t))}static fromName(t){return new e(M.fromString(t).popFirst(5))}static empty(){return new e(M.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&M.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return M.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(t){return new e(new M(t.slice()))}};function ar(e,t,n){if(!n)throw new A(k.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function or(e,t,n,r){if(!0===t&&!0===r)throw new A(k.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function sr(e){if(!N.isDocumentKey(e))throw new A(k.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function cr(e){if(N.isDocumentKey(e))throw new A(k.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function lr(e){return typeof e==`object`&&!!e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}function ur(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`:E(12329,{type:typeof e})}function dr(e,t){if(`_delegate`in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new A(k.INVALID_ARGUMENT,`Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?`);{let n=ur(e);throw new A(k.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function fr(e,t){if(t<=0)throw new A(k.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}function P(e,t){let n={typeString:e};return t&&(n.value=t),n}function pr(e,t){if(!lr(e))throw new A(k.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 A(k.INVALID_ARGUMENT,n);return!0}var mr=-62135596800,hr=1e6,F=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)*hr))}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0||t>=1e9)throw new A(k.INVALID_ARGUMENT,`Timestamp nanoseconds out of range: `+t);if(e<mr||e>=253402300800)throw new A(k.INVALID_ARGUMENT,`Timestamp seconds out of range: `+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/hr}_compareTo(e){return this.seconds===e.seconds?j(this.nanoseconds,e.nanoseconds):j(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(pr(t,e._jsonSchema))return new e(t.seconds,t.nanoseconds)}valueOf(){let e=this.seconds-mr;return String(e).padStart(12,`0`)+`.`+String(this.nanoseconds).padStart(9,`0`)}};F._jsonSchemaVersion=`firestore/timestamp/1.0`,F._jsonSchema={type:P(`string`,F._jsonSchemaVersion),seconds:P(`number`),nanoseconds:P(`number`)};var I=class e{static fromTimestamp(t){return new e(t)}static min(){return new e(new F(0,0))}static max(){return new e(new F(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}},gr=-1,_r=class{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}};_r.UNKNOWN_ID=-1;function vr(e,t){let n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1;return new br(I.fromTimestamp(r===1e9?new F(n+1,0):new F(n,r)),N.empty(),t)}function yr(e){return new br(e.readTime,e.key,gr)}var br=class e{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new e(I.min(),N.empty(),gr)}static max(){return new e(I.max(),N.empty(),gr)}};function xr(e,t){let n=e.readTime.compareTo(t.readTime);return n===0?(n=N.comparator(e.documentKey,t.documentKey),n===0?j(e.largestBatchId,t.largestBatchId):n):n}var Sr=`The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.`,Cr=class{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}};async function wr(e){if(e.code!==k.FAILED_PRECONDITION||e.message!==Sr)throw e;T(`LocalStore`,`Unexpectedly lost primary lease`)}var L=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&&E(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(t,this.result):new e(((e,r)=>{this.nextCallback=n=>{this.wrapSuccess(t,n).next(e,r)},this.catchCallback=t=>{this.wrapFailure(n,t).next(e,r)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(t){try{let n=t();return n instanceof e?n:e.resolve(n)}catch(t){return e.reject(t)}}wrapSuccess(t,n){return t?this.wrapUserFunction((()=>t(n))):e.resolve(n)}wrapFailure(t,n){return t?this.wrapUserFunction((()=>t(n))):e.reject(n)}static resolve(t){return new e(((e,n)=>{e(t)}))}static reject(t){return new e(((e,n)=>{n(t)}))}static waitFor(t){return new e(((e,n)=>{let r=0,i=0,a=!1;t.forEach((t=>{++r,t.next((()=>{++i,a&&i===r&&e()}),(e=>n(e)))})),a=!0,i===r&&e()}))}static or(t){let n=e.resolve(!1);for(let r of t)n=n.next((t=>t?e.resolve(t):r()));return n}static forEach(e,t){let n=[];return e.forEach(((e,r)=>{n.push(t.call(this,e,r))})),this.waitFor(n)}static mapArray(t,n){return new e(((e,r)=>{let i=t.length,a=Array(i),o=0;for(let s=0;s<i;s++){let c=s;n(t[c]).next((t=>{a[c]=t,++o,o===i&&e(a)}),(e=>r(e)))}}))}static doWhile(t,n){return new e(((e,r)=>{let i=()=>{!0===t()?n().next((()=>{i()}),r):e()};i()}))}};function Tr(e){let t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(`.`).slice(0,2).join(`.`):`-1`;return Number(n)}function Er(e){return e.name===`IndexedDbTransactionError`}var Dr=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}};Dr.ce=-1;var Or=-1;function kr(e){return e==null}function Ar(e){return e===0&&1/e==-1/0}function jr(e){return typeof e==`number`&&Number.isInteger(e)&&!Ar(e)&&e<=2**53-1&&e>=-(2**53-1)}var Mr=``;function Nr(e){let t=``;for(let n=0;n<e.length;n++)t.length>0&&(t=Fr(t)),t=Pr(e.get(n),t);return Fr(t)}function Pr(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 Mr:n+=``;break;default:n+=r}}return n}function Fr(e){return e+Mr+``}function Ir(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function Lr(e,t){for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function Rr(e,t){let n=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(t(e[r],r,e));return n}function zr(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}var R=class e{constructor(e,t){this.comparator=e,this.root=t||Vr.EMPTY}insert(t,n){return new e(this.comparator,this.root.insert(t,n,this.comparator).copy(null,null,Vr.BLACK,null,null))}remove(t){return new e(this.comparator,this.root.remove(t,this.comparator).copy(null,null,Vr.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 Br(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Br(this.root,e,this.comparator,!1)}getReverseIterator(){return new Br(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Br(this.root,e,this.comparator,!0)}},Br=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}}},Vr=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 E(43730,{key:this.key,value:this.value});if(this.right.isRed())throw E(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw E(27949);return e+(this.isRed()?0:1)}};Vr.EMPTY=null,Vr.RED=!0,Vr.BLACK=!1,Vr.EMPTY=new class{constructor(){this.size=0}get key(){throw E(57766)}get value(){throw E(16141)}get color(){throw E(16727)}get left(){throw E(29726)}get right(){throw E(36894)}copy(e,t,n,r,i){return this}insert(e,t,n){return new Vr(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 Hr=class e{constructor(e){this.comparator=e,this.data=new R(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 Ur(this.data.getIterator())}getIteratorFrom(e){return new Ur(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}},Ur=class{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}},Wr=class e{constructor(e){this.fields=e,e.sort(ir.comparator)}static empty(){return new e([])}unionWith(t){let n=new Hr(ir.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 er(this.fields,e.fields,((e,t)=>e.isEqual(t)))}},Gr=class extends Error{constructor(){super(...arguments),this.name=`Base64DecodeError`}},Kr=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 Gr(`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 j(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}};Kr.EMPTY_BYTE_STRING=new Kr(``);var qr=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Jr(e){if(D(!!e,39018),typeof e==`string`){let t=0,n=qr.exec(e);if(D(!!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:z(e.seconds),nanos:z(e.nanos)}}function z(e){return typeof e==`number`?e:typeof e==`string`?Number(e):0}function Yr(e){return typeof e==`string`?Kr.fromBase64String(e):Kr.fromUint8Array(e)}var Xr=`server_timestamp`,Zr=`__type__`,Qr=`__previous_value__`,$r=`__local_write_time__`;function ei(e){return(e?.mapValue?.fields||{})[Zr]?.stringValue===Xr}function ti(e){let t=e.mapValue.fields[Qr];return ei(t)?ti(t):t}function ni(e){let t=Jr(e.mapValue.fields[$r].timestampValue);return new F(t.seconds,t.nanos)}var ri=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}},ii=`(default)`,ai=class e{constructor(e,t){this.projectId=e,this.database=t||ii}static empty(){return new e(``,``)}get isDefaultDatabase(){return this.database===ii}isEqual(t){return t instanceof e&&t.projectId===this.projectId&&t.database===this.database}};function oi(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,[`projectId`]))throw new A(k.INVALID_ARGUMENT,`"projectId" not provided in firebase.initializeApp.`);return new ai(e.options.projectId,t)}var si=`__type__`,ci=`__max__`,li={mapValue:{fields:{__type__:{stringValue:ci}}}},ui=`__vector__`,di=`value`;function fi(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?ei(e)?4:ki(e)?9007199254740991:Di(e)?10:11:E(28295,{value:e})}function pi(e,t){if(e===t)return!0;let n=fi(e);if(n!==fi(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return ni(e).isEqual(ni(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=Jr(e.timestampValue),r=Jr(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 Yr(e.bytesValue).isEqual(Yr(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return z(e.geoPointValue.latitude)===z(t.geoPointValue.latitude)&&z(e.geoPointValue.longitude)===z(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if(`integerValue`in e&&`integerValue`in t)return z(e.integerValue)===z(t.integerValue);if(`doubleValue`in e&&`doubleValue`in t){let n=z(e.doubleValue),r=z(t.doubleValue);return n===r?Ar(n)===Ar(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return er(e.arrayValue.values||[],t.arrayValue.values||[],pi);case 10:case 11:return function(e,t){let n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(Ir(n)!==Ir(r))return!1;for(let e in n)if(n.hasOwnProperty(e)&&(r[e]===void 0||!pi(n[e],r[e])))return!1;return!0}(e,t);default:return E(52216,{left:e})}}function mi(e,t){return(e.values||[]).find((e=>pi(e,t)))!==void 0}function hi(e,t){if(e===t)return 0;let n=fi(e),r=fi(t);if(n!==r)return j(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return j(e.booleanValue,t.booleanValue);case 2:return function(e,t){let n=z(e.integerValue||e.doubleValue),r=z(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 gi(e.timestampValue,t.timestampValue);case 4:return gi(ni(e),ni(t));case 5:return Xn(e.stringValue,t.stringValue);case 6:return function(e,t){let n=Yr(e),r=Yr(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=j(n[e],r[e]);if(t!==0)return t}return j(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){let n=j(z(e.latitude),z(t.latitude));return n===0?j(z(e.longitude),z(t.longitude)):n}(e.geoPointValue,t.geoPointValue);case 9:return _i(e.arrayValue,t.arrayValue);case 10:return function(e,t){let n=e.fields||{},r=t.fields||{},i=n[di]?.arrayValue,a=r[di]?.arrayValue,o=j(i?.values?.length||0,a?.values?.length||0);return o===0?_i(i,a):o}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===li.mapValue&&t===li.mapValue)return 0;if(e===li.mapValue)return 1;if(t===li.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=Xn(r[e],a[e]);if(t!==0)return t;let o=hi(n[r[e]],i[a[e]]);if(o!==0)return o}return j(r.length,a.length)}(e.mapValue,t.mapValue);default:throw E(23264,{he:n})}}function gi(e,t){if(typeof e==`string`&&typeof t==`string`&&e.length===t.length)return j(e,t);let n=Jr(e),r=Jr(t),i=j(n.seconds,r.seconds);return i===0?j(n.nanos,r.nanos):i}function _i(e,t){let n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){let t=hi(n[e],r[e]);if(t)return t}return j(n.length,r.length)}function vi(e){return yi(e)}function yi(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=Jr(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):`stringValue`in e?e.stringValue:`bytesValue`in e?function(e){return Yr(e).toBase64()}(e.bytesValue):`referenceValue`in e?function(e){return N.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+=yi(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}:${yi(e.fields[i])}`;return n+`}`}(e.mapValue):E(61005,{value:e})}function bi(e){switch(fi(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let t=ti(e);return t?16+bi(t):16;case 5:return 2*e.stringValue.length;case 6:return Yr(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return function(e){return(e.values||[]).reduce(((e,t)=>e+bi(t)),0)}(e.arrayValue);case 10:case 11:return function(e){let t=0;return Lr(e.fields,((e,n)=>{t+=e.length+bi(n)})),t}(e.mapValue);default:throw E(13486,{value:e})}}function xi(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Si(e){return!!e&&`integerValue`in e}function Ci(e){return!!e&&`arrayValue`in e}function wi(e){return!!e&&`nullValue`in e}function Ti(e){return!!e&&`doubleValue`in e&&isNaN(Number(e.doubleValue))}function Ei(e){return!!e&&`mapValue`in e}function Di(e){return(e?.mapValue?.fields||{})[si]?.stringValue===ui}function Oi(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 Lr(e.mapValue.fields,((e,n)=>t.mapValue.fields[e]=Oi(n))),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=Oi(e.arrayValue.values[n]);return t}return{...e}}function ki(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===ci}var Ai=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)],!Ei(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Oi(t)}setAll(e){let t=ir.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()]=Oi(e):r.push(i.lastSegment())}));let i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){let t=this.field(e.popLast());Ei(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return pi(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)];Ei(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){Lr(t,((t,n)=>e[t]=n));for(let t of n)delete e[t]}clone(){return new e(Oi(this.value))}};function ji(e){let t=[];return Lr(e.fields,((e,n)=>{let r=new ir([e]);if(Ei(n)){let e=ji(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 Wr(t)}var Mi=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,I.min(),I.min(),I.min(),Ai.empty(),0)}static newFoundDocument(t,n,r,i){return new e(t,1,n,I.min(),r,i,0)}static newNoDocument(t,n){return new e(t,2,n,I.min(),I.min(),Ai.empty(),0)}static newUnknownDocument(t,n){return new e(t,3,n,I.min(),I.min(),Ai.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(I.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=Ai.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Ai.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=I.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}})`}},Ni=class{constructor(e,t){this.position=e,this.inclusive=t}};function Pi(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()?N.comparator(N.fromName(o.referenceValue),n.key):hi(o,n.data.field(a.field)),a.dir===`desc`&&(r*=-1),r!==0)break}return r}function Fi(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(!pi(e.position[n],t.position[n]))return!1;return!0}var Ii=class{constructor(e,t=`asc`){this.field=e,this.dir=t}};function Li(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}var Ri=class{},B=class e extends Ri{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 Ki(t,n,r):n===`array-contains`?new Xi(t,r):n===`in`?new Zi(t,r):n===`not-in`?new Qi(t,r):n===`array-contains-any`?new $i(t,r):new e(t,n,r)}static createKeyFieldInFilter(e,t,n){return t===`in`?new qi(e,n):new Ji(e,n)}matches(e){let t=e.data.field(this.field);return this.op===`!=`?t!==null&&t.nullValue===void 0&&this.matchesComparison(hi(t,this.value)):t!==null&&fi(this.value)===fi(t)&&this.matchesComparison(hi(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 E(47266,{operator:this.op})}}isInequality(){return[`<`,`<=`,`>`,`>=`,`!=`,`not-in`].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}},zi=class e extends Ri{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 Bi(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 Bi(e){return e.op===`and`}function Vi(e){return Hi(e)&&Bi(e)}function Hi(e){for(let t of e.filters)if(t instanceof zi)return!1;return!0}function Ui(e){if(e instanceof B)return e.field.canonicalString()+e.op.toString()+vi(e.value);if(Vi(e))return e.filters.map((e=>Ui(e))).join(`,`);{let t=e.filters.map((e=>Ui(e))).join(`,`);return`${e.op}(${t})`}}function Wi(e,t){return e instanceof B?function(e,t){return t instanceof B&&e.op===t.op&&e.field.isEqual(t.field)&&pi(e.value,t.value)}(e,t):e instanceof zi?function(e,t){return t instanceof zi&&e.op===t.op&&e.filters.length===t.filters.length?e.filters.reduce(((e,n,r)=>e&&Wi(n,t.filters[r])),!0):!1}(e,t):void E(19439)}function Gi(e){return e instanceof B?function(e){return`${e.field.canonicalString()} ${e.op} ${vi(e.value)}`}(e):e instanceof zi?function(e){return e.op.toString()+` {`+e.getFilters().map(Gi).join(` ,`)+`}`}(e):`Filter`}var Ki=class extends B{constructor(e,t,n){super(e,t,n),this.key=N.fromName(n.referenceValue)}matches(e){let t=N.comparator(e.key,this.key);return this.matchesComparison(t)}},qi=class extends B{constructor(e,t){super(e,`in`,t),this.keys=Yi(`in`,t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}},Ji=class extends B{constructor(e,t){super(e,`not-in`,t),this.keys=Yi(`not-in`,t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}};function Yi(e,t){return(t.arrayValue?.values||[]).map((e=>N.fromName(e.referenceValue)))}var Xi=class extends B{constructor(e,t){super(e,`array-contains`,t)}matches(e){let t=e.data.field(this.field);return Ci(t)&&mi(t.arrayValue,this.value)}},Zi=class extends B{constructor(e,t){super(e,`in`,t)}matches(e){let t=e.data.field(this.field);return t!==null&&mi(this.value.arrayValue,t)}},Qi=class extends B{constructor(e,t){super(e,`not-in`,t)}matches(e){if(mi(this.value.arrayValue,{nullValue:`NULL_VALUE`}))return!1;let t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!mi(this.value.arrayValue,t)}},$i=class extends B{constructor(e,t){super(e,`array-contains-any`,t)}matches(e){let t=e.data.field(this.field);return!(!Ci(t)||!t.arrayValue.values)&&t.arrayValue.values.some((e=>mi(this.value.arrayValue,e)))}},ea=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 ta(e,t=null,n=[],r=[],i=null,a=null,o=null){return new ea(e,t,n,r,i,a,o)}function na(e){let t=O(e);if(t.Te===null){let e=t.path.canonicalString();t.collectionGroup!==null&&(e+=`|cg:`+t.collectionGroup),e+=`|f:`,e+=t.filters.map((e=>Ui(e))).join(`,`),e+=`|ob:`,e+=t.orderBy.map((e=>function(e){return e.field.canonicalString()+e.dir}(e))).join(`,`),kr(t.limit)||(e+=`|l:`,e+=t.limit),t.startAt&&(e+=`|lb:`,e+=t.startAt.inclusive?`b:`:`a:`,e+=t.startAt.position.map((e=>vi(e))).join(`,`)),t.endAt&&(e+=`|ub:`,e+=t.endAt.inclusive?`a:`:`b:`,e+=t.endAt.position.map((e=>vi(e))).join(`,`)),t.Te=e}return t.Te}function ra(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(!Li(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(!Wi(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!Fi(e.startAt,t.startAt)&&Fi(e.endAt,t.endAt)}function ia(e){return N.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}var aa=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.Ee=null,this.Ie=null,this.Re=null,this.startAt,this.endAt}};function oa(e,t,n,r,i,a,o,s){return new aa(e,t,n,r,i,a,o,s)}function sa(e){return new aa(e)}function ca(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 la(e){return N.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}function ua(e){return e.collectionGroup!==null}function da(e){let t=O(e);if(t.Ee===null){t.Ee=[];let e=new Set;for(let n of t.explicitOrderBy)t.Ee.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 Hr(ir.comparator);return e.filters.forEach((e=>{e.getFlattenedFilters().forEach((e=>{e.isInequality()&&(t=t.add(e.field))}))})),t})(t).forEach((r=>{e.has(r.canonicalString())||r.isKeyField()||t.Ee.push(new Ii(r,n))})),e.has(ir.keyField().canonicalString())||t.Ee.push(new Ii(ir.keyField(),n))}return t.Ee}function fa(e){let t=O(e);return t.Ie||=ma(t,da(e)),t.Ie}function pa(e){let t=O(e);return t.Re||=ma(t,e.explicitOrderBy),t.Re}function ma(e,t){if(e.limitType===`F`)return ta(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 Ii(e.field,t)}));let n=e.endAt?new Ni(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new Ni(e.startAt.position,e.startAt.inclusive):null;return ta(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function ha(e,t){let n=e.filters.concat([t]);return new aa(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function ga(e,t){let n=e.explicitOrderBy.concat([t]);return new aa(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}function _a(e,t,n){return new aa(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function va(e,t){return new aa(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)}function ya(e,t){return ra(fa(e),fa(t))&&e.limitType===t.limitType}function ba(e){return`${na(fa(e))}|lt:${e.limitType}`}function xa(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=>Gi(e))).join(`, `)}]`),kr(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=>vi(e))).join(`,`)),e.endAt&&(t+=`, endAt: `,t+=e.endAt.inclusive?`a:`:`b:`,t+=e.endAt.position.map((e=>vi(e))).join(`,`)),`Target(${t})`}(fa(e))}; limitType=${e.limitType})`}function Sa(e,t){return t.isFoundDocument()&&function(e,t){let n=t.key.path;return e.collectionGroup===null?N.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 da(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=Pi(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,da(e),t)||e.endAt&&!function(e,t,n){let r=Pi(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,da(e),t))}(e,t)}function Ca(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function wa(e){return(t,n)=>{let r=!1;for(let i of da(e)){let e=Ta(i,t,n);if(e!==0)return e;r||=i.field.isKeyField()}return 0}}function Ta(e,t,n){let r=e.field.isKeyField()?N.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?hi(r,i):E(42886)}(e.field,t,n);switch(e.dir){case`asc`:return r;case`desc`:return-1*r;default:return E(19790,{direction:e.dir})}}var Ea=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){Lr(this.inner,((t,n)=>{for(let[t,r]of n)e(t,r)}))}isEmpty(){return zr(this.inner)}size(){return this.innerSize}},Da=new R(N.comparator);function Oa(){return Da}var ka=new R(N.comparator);function Aa(...e){let t=ka;for(let n of e)t=t.insert(n.key,n);return t}function ja(e){let t=ka;return e.forEach(((e,n)=>t=t.insert(e,n.overlayedDocument))),t}function Ma(){return Pa()}function Na(){return Pa()}function Pa(){return new Ea((e=>e.toString()),((e,t)=>e.isEqual(t)))}var Fa=new R(N.comparator),Ia=new Hr(N.comparator);function V(...e){let t=Ia;for(let n of e)t=t.add(n);return t}var La=new Hr(j);function Ra(){return La}function za(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:Ar(t)?`-0`:t}}function Ba(e){return{integerValue:``+e}}function Va(e,t){return jr(t)?Ba(t):za(e,t)}var Ha=class{constructor(){this._=void 0}};function Ua(e,t,n){return e instanceof Ka?function(e,t){let n={fields:{[Zr]:{stringValue:Xr},[$r]:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&ei(t)&&(t=ti(t)),t&&(n.fields[Qr]=t),{mapValue:n}}(n,t):e instanceof qa?Ja(e,t):e instanceof Ya?Xa(e,t):function(e,t){let n=Ga(e,t),r=Qa(n)+Qa(e.Ae);return Si(n)&&Si(e.Ae)?Ba(r):za(e.serializer,r)}(e,t)}function Wa(e,t,n){return e instanceof qa?Ja(e,t):e instanceof Ya?Xa(e,t):n}function Ga(e,t){return e instanceof Za?function(e){return Si(e)||function(e){return!!e&&`doubleValue`in e}(e)}(t)?t:{integerValue:0}:null}var Ka=class extends Ha{},qa=class extends Ha{constructor(e){super(),this.elements=e}};function Ja(e,t){let n=$a(t);for(let t of e.elements)n.some((e=>pi(e,t)))||n.push(t);return{arrayValue:{values:n}}}var Ya=class extends Ha{constructor(e){super(),this.elements=e}};function Xa(e,t){let n=$a(t);for(let t of e.elements)n=n.filter((e=>!pi(e,t)));return{arrayValue:{values:n}}}var Za=class extends Ha{constructor(e,t){super(),this.serializer=e,this.Ae=t}};function Qa(e){return z(e.integerValue||e.doubleValue)}function $a(e){return Ci(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}function eo(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof qa&&t instanceof qa||e instanceof Ya&&t instanceof Ya?er(e.elements,t.elements,pi):e instanceof Za&&t instanceof Za?pi(e.Ae,t.Ae):e instanceof Ka&&t instanceof Ka}(e.transform,t.transform)}var to=class{constructor(e,t){this.version=e,this.transformResults=t}},no=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 ro(e,t){return e.updateTime===void 0?e.exists===void 0||e.exists===t.isFoundDocument():t.isFoundDocument()&&t.version.isEqual(e.updateTime)}var io=class{};function ao(e,t){if(!e.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return e.isNoDocument()?new go(e.key,no.none()):new uo(e.key,e.data,no.none());{let n=e.data,r=Ai.empty(),i=new Hr(ir.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 fo(e.key,r,new Wr(i.toArray()),no.none())}}function oo(e,t,n){e instanceof uo?function(e,t,n){let r=e.value.clone(),i=mo(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof fo?function(e,t,n){if(!ro(e.precondition,t))return void t.convertToUnknownDocument(n.version);let r=mo(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(po(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 so(e,t,n,r){return e instanceof uo?function(e,t,n,r){if(!ro(e.precondition,t))return n;let i=e.value.clone(),a=ho(e.fieldTransforms,r,t);return i.setAll(a),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof fo?function(e,t,n,r){if(!ro(e.precondition,t))return n;let i=ho(e.fieldTransforms,r,t),a=t.data;return a.setAll(po(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 ro(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function co(e,t){let n=null;for(let r of e.fieldTransforms){let e=t.data.field(r.field),i=Ga(r.transform,e||null);i!=null&&(n===null&&(n=Ai.empty()),n.set(r.field,i))}return n||null}function lo(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)&&er(e,t,((e,t)=>eo(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 uo=class extends io{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}},fo=class extends io{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 po(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 mo(e,t,n){let r=new Map;D(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,Wa(o,s,n[i]))}return r}function ho(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,Ua(e,a,t))}return r}var go=class extends io{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}},_o=class extends io{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}},vo=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)&&oo(r,e,n[t])}}applyToLocalView(e,t){for(let n of this.baseMutations)n.key.isEqual(e.key)&&(t=so(n,e,t,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(e.key)&&(t=so(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let n=Na();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=ao(a,o);s!==null&&n.set(r.key,s),a.isValidDocument()||a.convertToNoDocument(I.min())})),n}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),V())}isEqual(e){return this.batchId===e.batchId&&er(this.mutations,e.mutations,((e,t)=>lo(e,t)))&&er(this.baseMutations,e.baseMutations,((e,t)=>lo(e,t)))}},yo=class e{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(t,n,r){D(t.mutations.length===r.length,58842,{me:t.mutations.length,fe:r.length});let i=function(){return Fa}(),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)}},bo=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 }`}},xo=class{constructor(e,t,n){this.alias=e,this.aggregateType=t,this.fieldPath=n}},So=class{constructor(e,t){this.count=e,this.unchangedNames=t}},H,U;function Co(e){switch(e){case k.OK:return E(64938);case k.CANCELLED:case k.UNKNOWN:case k.DEADLINE_EXCEEDED:case k.RESOURCE_EXHAUSTED:case k.INTERNAL:case k.UNAVAILABLE:case k.UNAUTHENTICATED:return!1;case k.INVALID_ARGUMENT:case k.NOT_FOUND:case k.ALREADY_EXISTS:case k.PERMISSION_DENIED:case k.FAILED_PRECONDITION:case k.ABORTED:case k.OUT_OF_RANGE:case k.UNIMPLEMENTED:case k.DATA_LOSS:return!0;default:return E(15467,{code:e})}}function wo(e){if(e===void 0)return Fn(`GRPC error has no .code`),k.UNKNOWN;switch(e){case H.OK:return k.OK;case H.CANCELLED:return k.CANCELLED;case H.UNKNOWN:return k.UNKNOWN;case H.DEADLINE_EXCEEDED:return k.DEADLINE_EXCEEDED;case H.RESOURCE_EXHAUSTED:return k.RESOURCE_EXHAUSTED;case H.INTERNAL:return k.INTERNAL;case H.UNAVAILABLE:return k.UNAVAILABLE;case H.UNAUTHENTICATED:return k.UNAUTHENTICATED;case H.INVALID_ARGUMENT:return k.INVALID_ARGUMENT;case H.NOT_FOUND:return k.NOT_FOUND;case H.ALREADY_EXISTS:return k.ALREADY_EXISTS;case H.PERMISSION_DENIED:return k.PERMISSION_DENIED;case H.FAILED_PRECONDITION:return k.FAILED_PRECONDITION;case H.ABORTED:return k.ABORTED;case H.OUT_OF_RANGE:return k.OUT_OF_RANGE;case H.UNIMPLEMENTED:return k.UNIMPLEMENTED;case H.DATA_LOSS:return k.DATA_LOSS;default:return E(39323,{code:e})}}(U=H||={})[U.OK=0]=`OK`,U[U.CANCELLED=1]=`CANCELLED`,U[U.UNKNOWN=2]=`UNKNOWN`,U[U.INVALID_ARGUMENT=3]=`INVALID_ARGUMENT`,U[U.DEADLINE_EXCEEDED=4]=`DEADLINE_EXCEEDED`,U[U.NOT_FOUND=5]=`NOT_FOUND`,U[U.ALREADY_EXISTS=6]=`ALREADY_EXISTS`,U[U.PERMISSION_DENIED=7]=`PERMISSION_DENIED`,U[U.UNAUTHENTICATED=16]=`UNAUTHENTICATED`,U[U.RESOURCE_EXHAUSTED=8]=`RESOURCE_EXHAUSTED`,U[U.FAILED_PRECONDITION=9]=`FAILED_PRECONDITION`,U[U.ABORTED=10]=`ABORTED`,U[U.OUT_OF_RANGE=11]=`OUT_OF_RANGE`,U[U.UNIMPLEMENTED=12]=`UNIMPLEMENTED`,U[U.INTERNAL=13]=`INTERNAL`,U[U.UNAVAILABLE=14]=`UNAVAILABLE`,U[U.DATA_LOSS=15]=`DATA_LOSS`;var To=null;function Eo(){return new TextEncoder}var Do=new bn([4294967295,4294967295],0);function Oo(e){let t=Eo().encode(e),n=new xn;return n.update(t),new Uint8Array(n.digest())}function ko(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 bn([n,r],0),new bn([i,a],0)]}var Ao=class e{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new jo(`Invalid padding: ${t}`);if(n<0||e.length>0&&this.hashCount===0)throw new jo(`Invalid hash count: ${n}`);if(e.length===0&&t!==0)throw new jo(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=bn.fromNumber(this.ge)}ye(e,t,n){let r=e.add(t.multiply(bn.fromNumber(n)));return r.compare(Do)===1&&(r=new bn([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]=ko(Oo(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]=ko(Oo(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}},jo=class extends Error{constructor(){super(...arguments),this.name=`BloomFilterError`}},Mo=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,No.createSynthesizedTargetChangeForCurrentChange(t,n,r)),new e(I.min(),i,new R(j),Oa(),V())}},No=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,V(),V(),V())}},Po=class{constructor(e,t,n,r){this.be=e,this.removedTargetIds=t,this.key=n,this.De=r}},Fo=class{constructor(e,t){this.targetId=e,this.Ce=t}},Io=class{constructor(e,t,n=Kr.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}},Lo=class{constructor(){this.ve=0,this.Fe=Bo(),this.Me=Kr.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=V(),t=V(),n=V();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:E(38017,{changeType:i})}})),new No(this.Me,this.xe,e,t,n)}qe(){this.Oe=!1,this.Fe=Bo()}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,D(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}},Ro=class{constructor(e){this.Ge=e,this.ze=new Map,this.je=Oa(),this.Je=zo(),this.He=zo(),this.Ze=new R(j)}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.nt(t);switch(e.state){case 0:this.rt(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.rt(t)&&(n.Qe(),n.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),n.Le(e.resumeToken));break;default:E(56790,{state:e.state})}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach(((e,n)=>{this.rt(n)&&t(n)}))}st(e){let t=e.targetId,n=e.Ce.count,r=this.ot(t);if(r){let i=r.target;if(ia(i))if(n===0){let e=new N(i.path);this.et(t,e,Mi.newNoDocument(e,I.min()))}else D(n===1,20013,{expectedCount:n});else{let r=this._t(t);if(r!==n){let n=this.ut(e),i=n?this.ct(n,e,r):1;if(i!==0){this.it(t);let e=i===2?`TargetPurposeExistenceFilterMismatchBloom`:`TargetPurposeExistenceFilterMismatch`;this.Ze=this.Ze.insert(t,e)}To?.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.ht(),n,i))}}}}ut(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=Yr(n).toUint8Array()}catch(e){if(e instanceof Gr)return In(`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 Ao(a,r,i)}catch(e){return In(e instanceof jo?`BloomFilter error: `:`Applying bloom filter failed: `,e),null}return o.ge===0?null:o}ct(e,t,n){return t.Ce.count===n-this.Pt(e,t.targetId)?0:2}Pt(e,t){let n=this.Ge.getRemoteKeysForTarget(t),r=0;return n.forEach((n=>{let i=this.Ge.ht(),a=`projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;e.mightContain(a)||(this.et(t,n,null),r++)})),r}Tt(e){let t=new Map;this.ze.forEach(((n,r)=>{let i=this.ot(r);if(i){if(n.current&&ia(i.target)){let t=new N(i.target.path);this.Et(t).has(r)||this.It(r,t)||this.et(r,t,Mi.newNoDocument(t,e))}n.Be&&(t.set(r,n.ke()),n.qe())}}));let n=V();this.He.forEach(((e,t)=>{let r=!0;t.forEachWhile((e=>{let t=this.ot(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 Mo(e,t,this.Ze,this.je,n);return this.je=Oa(),this.Je=zo(),this.He=zo(),this.Ze=new R(j),r}Ye(e,t){if(!this.rt(e))return;let n=this.It(e,t.key)?2:0;this.nt(e).Ke(t.key,n),this.je=this.je.insert(t.key,t),this.Je=this.Je.insert(t.key,this.Et(t.key).add(e)),this.He=this.He.insert(t.key,this.Rt(t.key).add(e))}et(e,t,n){if(!this.rt(e))return;let r=this.nt(e);this.It(e,t)?r.Ke(t,1):r.Ue(t),this.He=this.He.insert(t,this.Rt(t).delete(e)),this.He=this.He.insert(t,this.Rt(t).add(e)),n&&(this.je=this.je.insert(t,n))}removeTarget(e){this.ze.delete(e)}_t(e){let t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.nt(e).$e()}nt(e){let t=this.ze.get(e);return t||(t=new Lo,this.ze.set(e,t)),t}Rt(e){let t=this.He.get(e);return t||(t=new Hr(j),this.He=this.He.insert(e,t)),t}Et(e){let t=this.Je.get(e);return t||(t=new Hr(j),this.Je=this.Je.insert(e,t)),t}rt(e){let t=this.ot(e)!==null;return t||T(`WatchChangeAggregator`,`Detected inactive target`,e),t}ot(e){let t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new Lo),this.Ge.getRemoteKeysForTarget(e).forEach((t=>{this.et(e,t,null)}))}It(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}};function zo(){return new R(N.comparator)}function Bo(){return new R(N.comparator)}var Vo={asc:`ASCENDING`,desc:`DESCENDING`},Ho={"<":`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`},Uo={and:`AND`,or:`OR`},Wo=class{constructor(e,t){this.databaseId=e,this.useProto3Json=t}};function Go(e,t){return e.useProto3Json||kr(t)?t:{value:t}}function Ko(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 qo(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function Jo(e,t){return Ko(e,t.toTimestamp())}function Yo(e){return D(!!e,49232),I.fromTimestamp(function(e){let t=Jr(e);return new F(t.seconds,t.nanos)}(e))}function Xo(e,t){return Zo(e,t).canonicalString()}function Zo(e,t){let n=function(e){return new M([`projects`,e.projectId,`databases`,e.database])}(e).child(`documents`);return t===void 0?n:n.child(t)}function Qo(e){let t=M.fromString(e);return D(Ss(t),10190,{key:t.toString()}),t}function $o(e,t){return Xo(e.databaseId,t.path)}function es(e,t){let n=Qo(t);if(n.get(1)!==e.databaseId.projectId)throw new A(k.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 A(k.INVALID_ARGUMENT,`Tried to deserialize key from different database: `+n.get(3)+` vs `+e.databaseId.database);return new N(is(n))}function ts(e,t){return Xo(e.databaseId,t)}function ns(e){let t=Qo(e);return t.length===4?M.emptyPath():is(t)}function rs(e){return new M([`projects`,e.databaseId.projectId,`databases`,e.databaseId.database]).canonicalString()}function is(e){return D(e.length>4&&e.get(4)===`documents`,29091,{key:e.toString()}),e.popFirst(5)}function as(e,t,n){return{name:$o(e,t),fields:n.value.mapValue.fields}}function os(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:E(39313,{state:e})}(t.targetChange.targetChangeType||`NO_CHANGE`),i=t.targetChange.targetIds||[],a=function(e,t){return e.useProto3Json?(D(t===void 0||typeof t==`string`,58123),Kr.fromBase64String(t||``)):(D(t===void 0||t instanceof Buffer||t instanceof Uint8Array,16193),Kr.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),o=t.targetChange.cause;n=new Io(r,i,a,o&&function(e){return new A(e.code===void 0?k.UNKNOWN:wo(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=es(e,r.document.name),a=Yo(r.document.updateTime),o=r.document.createTime?Yo(r.document.createTime):I.min(),s=new Ai({mapValue:{fields:r.document.fields}}),c=Mi.newFoundDocument(i,a,o,s);n=new Po(r.targetIds||[],r.removedTargetIds||[],c.key,c)}else if(`documentDelete`in t){t.documentDelete;let r=t.documentDelete;r.document;let i=es(e,r.document),a=r.readTime?Yo(r.readTime):I.min(),o=Mi.newNoDocument(i,a);n=new Po([],r.removedTargetIds||[],o.key,o)}else if(`documentRemove`in t){t.documentRemove;let r=t.documentRemove;r.document;let i=es(e,r.document);n=new Po([],r.removedTargetIds||[],i,null)}else{if(!(`filter`in t))return E(11601,{Vt:t});{t.filter;let e=t.filter;e.targetId;let{count:r=0,unchangedNames:i}=e,a=new So(r,i),o=e.targetId;n=new Fo(o,a)}}return n}function ss(e,t){let n;if(t instanceof uo)n={update:as(e,t.key,t.value)};else if(t instanceof go)n={delete:$o(e,t.key)};else if(t instanceof fo)n={update:as(e,t.key,t.data),updateMask:xs(t.fieldMask)};else{if(!(t instanceof _o))return E(16599,{dt:t.type});n={verify:$o(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map((e=>function(e,t){let n=t.transform;if(n instanceof Ka)return{fieldPath:t.field.canonicalString(),setToServerValue:`REQUEST_TIME`};if(n instanceof qa)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof Ya)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Za)return{fieldPath:t.field.canonicalString(),increment:n.Ae};throw E(20930,{transform:t.transform})}(0,e)))),t.precondition.isNone||(n.currentDocument=function(e,t){return t.updateTime===void 0?t.exists===void 0?E(27497):{exists:t.exists}:{updateTime:Jo(e,t.updateTime)}}(e,t.precondition)),n}function cs(e,t){return e&&e.length>0?(D(t!==void 0,14353),e.map((e=>function(e,t){let n=e.updateTime?Yo(e.updateTime):Yo(t);return n.isEqual(I.min())&&(n=Yo(t)),new to(n,e.transformResults||[])}(e,t)))):[]}function ls(e,t){return{documents:[ts(e,t.path)]}}function us(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=ts(e,i);let a=function(e){if(e.length!==0)return bs(zi.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:vs(e.field),direction:hs(e.dir)}}(e)))}(t.orderBy);o&&(n.structuredQuery.orderBy=o);let s=Go(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)),{ft:n,parent:i}}function ds(e,t,n,r){let{ft:i,parent:a}=us(e,t),o={},s=[],c=0;return n.forEach((e=>{let t=r?e.alias:`aggregate_`+ c++;o[t]=e.alias,e.aggregateType===`count`?s.push({alias:t,count:{}}):e.aggregateType===`avg`?s.push({alias:t,avg:{field:vs(e.fieldPath)}}):e.aggregateType===`sum`&&s.push({alias:t,sum:{field:vs(e.fieldPath)}})})),{request:{structuredAggregationQuery:{aggregations:s,structuredQuery:i.structuredQuery},parent:i.parent},gt:o,parent:a}}function fs(e){let t=ns(e.parent),n=e.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){D(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=ms(e);return t instanceof zi&&Vi(t)?t.getFilters():[t]}(n.where));let o=[];n.orderBy&&(o=function(e){return e.map((e=>function(e){return new Ii(ys(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,kr(t)?null:t}(n.limit));let c=null;n.startAt&&(c=function(e){let t=!!e.before;return new Ni(e.values||[],t)}(n.startAt));let l=null;return n.endAt&&(l=function(e){let t=!e.before;return new Ni(e.values||[],t)}(n.endAt)),oa(t,i,o,a,s,`F`,c,l)}function ps(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 E(28987,{purpose:e})}}(t.purpose);return n==null?null:{"goog-listen-tags":n}}function ms(e){return e.unaryFilter===void 0?e.fieldFilter===void 0?e.compositeFilter===void 0?E(30097,{filter:e}):function(e){return zi.create(e.compositeFilter.filters.map((e=>ms(e))),function(e){switch(e){case`AND`:return`and`;case`OR`:return`or`;default:return E(1026)}}(e.compositeFilter.op))}(e):function(e){return B.create(ys(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 E(58110);default:return E(50506)}}(e.fieldFilter.op),e.fieldFilter.value)}(e):function(e){switch(e.unaryFilter.op){case`IS_NAN`:let t=ys(e.unaryFilter.field);return B.create(t,`==`,{doubleValue:NaN});case`IS_NULL`:let n=ys(e.unaryFilter.field);return B.create(n,`==`,{nullValue:`NULL_VALUE`});case`IS_NOT_NAN`:let r=ys(e.unaryFilter.field);return B.create(r,`!=`,{doubleValue:NaN});case`IS_NOT_NULL`:let i=ys(e.unaryFilter.field);return B.create(i,`!=`,{nullValue:`NULL_VALUE`});case`OPERATOR_UNSPECIFIED`:return E(61313);default:return E(60726)}}(e)}function hs(e){return Vo[e]}function gs(e){return Ho[e]}function _s(e){return Uo[e]}function vs(e){return{fieldPath:e.canonicalString()}}function ys(e){return ir.fromServerFormat(e.fieldPath)}function bs(e){return e instanceof B?function(e){if(e.op===`==`){if(Ti(e.value))return{unaryFilter:{field:vs(e.field),op:`IS_NAN`}};if(wi(e.value))return{unaryFilter:{field:vs(e.field),op:`IS_NULL`}}}else if(e.op===`!=`){if(Ti(e.value))return{unaryFilter:{field:vs(e.field),op:`IS_NOT_NAN`}};if(wi(e.value))return{unaryFilter:{field:vs(e.field),op:`IS_NOT_NULL`}}}return{fieldFilter:{field:vs(e.field),op:gs(e.op),value:e.value}}}(e):e instanceof zi?function(e){let t=e.getFilters().map((e=>bs(e)));return t.length===1?t[0]:{compositeFilter:{op:_s(e.op),filters:t}}}(e):E(54877,{filter:e})}function xs(e){let t=[];return e.fields.forEach((e=>t.push(e.canonicalString()))),{fieldPaths:t}}function Ss(e){return e.length>=4&&e.get(0)===`projects`&&e.get(2)===`databases`}function Cs(e){return!!e&&typeof e._toProto==`function`&&e._protoValueType===`ProtoValue`}var ws=class e{constructor(e,t,n,r,i=I.min(),a=I.min(),o=Kr.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)}},Ts=class{constructor(e){this.yt=e}};function Es(e){let t=fs({parent:e.parent,structuredQuery:e.structuredQuery});return e.limitType===`LAST`?_a(t,t.limit,`L`):t}var Ds=class{constructor(){}Dt(e,t){this.Ct(e,t),t.vt()}Ct(e,t){if(`nullValue`in e)this.Ft(t,5);else if(`booleanValue`in e)this.Ft(t,10),t.Mt(e.booleanValue?1:0);else if(`integerValue`in e)this.Ft(t,15),t.Mt(z(e.integerValue));else if(`doubleValue`in e){let n=z(e.doubleValue);isNaN(n)?this.Ft(t,13):(this.Ft(t,15),Ar(n)?t.Mt(0):t.Mt(n))}else if(`timestampValue`in e){let n=e.timestampValue;this.Ft(t,20),typeof n==`string`&&(n=Jr(n)),t.xt(`${n.seconds||``}`),t.Mt(n.nanos||0)}else if(`stringValue`in e)this.Ot(e.stringValue,t),this.Nt(t);else if(`bytesValue`in e)this.Ft(t,30),t.Bt(Yr(e.bytesValue)),this.Nt(t);else if(`referenceValue`in e)this.Lt(e.referenceValue,t);else if(`geoPointValue`in e){let n=e.geoPointValue;this.Ft(t,45),t.Mt(n.latitude||0),t.Mt(n.longitude||0)}else `mapValue`in e?ki(e)?this.Ft(t,2**53-1):Di(e)?this.kt(e.mapValue,t):(this.qt(e.mapValue,t),this.Nt(t)):`arrayValue`in e?(this.Kt(e.arrayValue,t),this.Nt(t)):E(19022,{Ut:e})}Ot(e,t){this.Ft(t,25),this.$t(e,t)}$t(e,t){t.xt(e)}qt(e,t){let n=e.fields||{};this.Ft(t,55);for(let e of Object.keys(n))this.Ot(e,t),this.Ct(n[e],t)}kt(e,t){let n=e.fields||{};this.Ft(t,53);let r=di,i=n[r].arrayValue?.values?.length||0;this.Ft(t,15),t.Mt(z(i)),this.Ot(r,t),this.Ct(n[r],t)}Kt(e,t){let n=e.values||[];this.Ft(t,50);for(let e of n)this.Ct(e,t)}Lt(e,t){this.Ft(t,37),N.fromName(e).path.forEach((e=>{this.Ft(t,60),this.$t(e,t)}))}Ft(e,t){e.Mt(t)}Nt(e){e.Mt(2)}};Ds.Wt=new Ds;var Os=class{constructor(){this.bn=new ks}addToCollectionParentIndex(e,t){return this.bn.add(t),L.resolve()}getCollectionParents(e,t){return L.resolve(this.bn.getEntries(t))}addFieldIndex(e,t){return L.resolve()}deleteFieldIndex(e,t){return L.resolve()}deleteAllFieldIndexes(e){return L.resolve()}createTargetIndexes(e,t){return L.resolve()}getDocumentsMatchingTarget(e,t){return L.resolve(null)}getIndexType(e,t){return L.resolve(0)}getFieldIndexes(e,t){return L.resolve([])}getNextCollectionGroupToUpdate(e){return L.resolve(null)}getMinOffset(e,t){return L.resolve(br.min())}getMinOffsetFromCollectionGroup(e,t){return L.resolve(br.min())}updateCollectionGroup(e,t,n){return L.resolve()}updateIndexEntries(e,t){return L.resolve()}},ks=class{constructor(){this.index={}}add(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new Hr(M.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 Hr(M.comparator)).toArray()}},As={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},js=41943040,Ms=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}};Ms.DEFAULT_COLLECTION_PERCENTILE=10,Ms.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Ms.DEFAULT=new Ms(js,Ms.DEFAULT_COLLECTION_PERCENTILE,Ms.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Ms.DISABLED=new Ms(-1,0,0);var Ns=class e{constructor(e){this.sr=e}next(){return this.sr+=2,this.sr}static _r(){return new e(0)}static ar(){return new e(-1)}},Ps=`LruGarbageCollector`,Fs=1048576;function Is([e,t],[n,r]){let i=j(e,n);return i===0?j(t,r):i}var Ls=class{constructor(e){this.Pr=e,this.buffer=new Hr(Is),this.Tr=0}Er(){return++this.Tr}Ir(e){let t=[e,this.Er()];if(this.buffer.size<this.Pr)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();Is(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}},Rs=class{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Rr=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Ar(6e4)}stop(){this.Rr&&=(this.Rr.cancel(),null)}get started(){return this.Rr!==null}Ar(e){T(Ps,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay(`lru_garbage_collection`,e,(async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){Er(e)?T(Ps,`Ignoring IndexedDB error during garbage collection: `,e):await wr(e)}await this.Ar(3e5)}))}},zs=class{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.dr(e).next((e=>Math.floor(t/100*e)))}nthSequenceNumber(e,t){if(t===0)return L.resolve(Dr.ce);let n=new Ls(t);return this.Vr.forEachTarget(e,(e=>n.Ir(e.sequenceNumber))).next((()=>this.Vr.mr(e,(e=>n.Ir(e))))).next((()=>n.maxValue))}removeTargets(e,t,n){return this.Vr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(T(`LruGarbageCollector`,`Garbage collection skipped; disabled`),L.resolve(As)):this.getCacheSize(e).next((n=>n<this.params.cacheSizeCollectionThreshold?(T(`LruGarbageCollector`,`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),As):this.gr(e,t)))}getCacheSize(e){return this.Vr.getCacheSize(e)}gr(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?(T(`LruGarbageCollector`,`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),r=this.params.maximumSequenceNumbersToCollect):r=t,a=Date.now(),this.nthSequenceNumber(e,r)))).next((r=>(n=r,o=Date.now(),this.removeTargets(e,n,t)))).next((t=>(i=t,s=Date.now(),this.removeOrphanedDocuments(e,n)))).next((e=>(c=Date.now(),Pn()<=b.DEBUG&&T(`LruGarbageCollector`,`LRU Garbage Collection\n\tCounted targets in ${a-l}ms\n\tDetermined least recently used ${r} in `+(o-a)+`ms
5
+ `+a+` `+o})}function ft(e,t,n,r){e.info(function(){return`XMLHTTP TEXT (`+t+`): `+mt(e,n)+(r?` `+r:``)})}function pt(e,t){e.info(function(){return`TIMEOUT: `+t})}lt.prototype.info=function(){};function mt(e,t){if(!e.g)return t;if(!t)return null;try{let a=JSON.parse(t);if(a){for(e=0;e<a.length;e++)if(Array.isArray(a[e])){var n=a[e];if(!(n.length<2)){var r=n[1];if(Array.isArray(r)&&!(r.length<1)){var i=r[0];if(i!=`noop`&&i!=`stop`&&i!=`close`)for(let e=1;e<r.length;e++)r[e]=``}}}}return Ke(a)}catch{return t}}var ht={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},gt={ib:`complete`,Fb:`success`,ERROR:`error`,Ga:`abort`,xb:`ready`,yb:`readystatechange`,TIMEOUT:`timeout`,sb:`incrementaldata`,wb:`progress`,lb:`downloadprogress`,Nb:`uploadprogress`},_t;function vt(){}d(vt,Ye),vt.prototype.g=function(){return new XMLHttpRequest},_t=new vt;function yt(e){return encodeURIComponent(String(e))}function bt(e){var t=1;e=e.split(`:`);let n=[];for(;t>0&&e.length;)n.push(e.shift()),t--;return e.length&&n.push(e.join(`:`)),n}function xt(e,t,n,r){this.j=e,this.i=t,this.l=n,this.S=r||1,this.V=new Ue(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new St}function St(){this.i=null,this.g=``,this.h=!1}var Ct={},wt={};function Tt(e,t,n){e.M=1,e.A=Zt(qt(t)),e.u=n,e.R=!0,Et(e,null)}function Et(e,t){e.F=Date.now(),At(e),e.B=qt(e.A);var n=e.B,r=e.S;Array.isArray(r)||(r=[String(r)]),fn(n.i,`t`,r),e.C=0,n=e.j.L,e.h=new St,e.g=rr(e.j,n?t:null,!e.u),e.P>0&&(e.O=new He(l(e.Y,e,e.g),e.P)),t=e.V,n=e.g,r=e.ba;var i=`readystatechange`;Array.isArray(i)||(i&&(We[0]=i.toString()),i=We);for(let e=0;e<i.length;e++){let a=_(n,i[e],r||t.handleEvent,!1,t.h||t);if(!a)break;t.g[a.key]=a}t=e.J?be(e.J):{},e.u?(e.v||=`POST`,t[`Content-Type`]=`application/x-www-form-urlencoded`,e.g.ea(e.B,e.v,e.u,t)):(e.v=`GET`,e.g.ea(e.B,e.v,null,t)),it(),ut(e.i,e.v,e.B,e.l,e.S,e.u)}xt.prototype.ba=function(e){e=e.target;let t=this.O;t&&zn(e)==3?t.j():this.Y(e)},xt.prototype.Y=function(e){try{if(e==this.g)a:{let s=zn(this.g),c=this.g.ya(),l=this.g.ca();if(!(s<3)&&(s!=3||this.g&&(this.h.h||this.g.la()||Bn(this.g)))){this.K||s!=4||c==7||it(c==8||l<=0?3:2),Mt(this);var t=this.g.ca();this.X=t;var n=Dt(this);if(this.o=t==200,dt(this.i,this.v,this.B,this.l,this.S,s,t),this.o){if(this.U&&!this.L){b:{if(this.g){var r,i=this.g;if((r=i.g?i.g.getResponseHeader(`X-HTTP-Initial-Response`):null)&&!fe(r)){var a=r;break b}}a=null}if(e=a)ft(this.i,this.l,e,`Initial handshake response via X-HTTP-Initial-Response`),this.L=!0,Ft(this,e);else{this.o=!1,this.m=3,ot(12),Pt(this),Nt(this);break a}}if(this.R){e=!0;let t;for(;!this.K&&this.C<n.length;)if(t=kt(this,n),t==wt){s==4&&(this.m=4,ot(14),e=!1),ft(this.i,this.l,null,`[Incomplete Response]`);break}else if(t==Ct){this.m=4,ot(15),ft(this.i,this.l,n,`[Invalid Chunk]`),e=!1;break}else ft(this.i,this.l,t,null),Ft(this,t);if(Ot(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),s!=4||n.length!=0||this.h.h||(this.m=1,ot(16),e=!1),this.o=this.o&&e,!e)ft(this.i,this.l,n,`[Invalid Chunked Response]`),Pt(this),Nt(this);else if(n.length>0&&!this.W){this.W=!0;var o=this.j;o.g==this&&o.aa&&!o.P&&(o.j.info(`Great, no buffering proxy detected. Bytes received: `+n.length),Xn(o),o.P=!0,ot(11))}}else ft(this.i,this.l,n,null),Ft(this,n);s==4&&Pt(this),this.o&&!this.K&&(s==4?Qn(this.j,this):(this.o=!1,At(this)))}else T(this.g),t==400&&n.indexOf(`Unknown SID`)>0?(this.m=3,ot(12)):(this.m=0,ot(13)),Pt(this),Nt(this)}}}catch{}};function Dt(e){if(!Ot(e))return e.g.la();let t=Bn(e.g);if(t===``)return``;let n=``,r=t.length,i=zn(e.g)==4;if(!e.h.i){if(typeof TextDecoder>`u`)return Pt(e),Nt(e),``;e.h.i=new o.TextDecoder}for(let a=0;a<r;a++)e.h.h=!0,n+=e.h.i.decode(t[a],{stream:!(i&&a==r-1)});return t.length=0,e.h.g+=n,e.C=0,e.h.g}function Ot(e){return e.g?e.v==`GET`&&e.M!=2&&e.j.Aa:!1}function kt(e,t){var n=e.C,r=t.indexOf(`
6
+ `,n);return r==-1?wt:(n=Number(t.substring(n,r)),isNaN(n)?Ct:(r+=1,r+n>t.length?wt:(t=t.slice(r,r+n),e.C=r+n,t)))}xt.prototype.cancel=function(){this.K=!0,Pt(this)};function At(e){e.T=Date.now()+e.H,jt(e,e.H)}function jt(e,t){if(e.D!=null)throw Error(`WatchDog timer not null`);e.D=ct(l(e.aa,e),t)}function Mt(e){e.D&&=(o.clearTimeout(e.D),null)}xt.prototype.aa=function(){this.D=null;let e=Date.now();e-this.T>=0?(pt(this.i,this.B),this.M!=2&&(it(),ot(17)),Pt(this),this.m=2,Nt(this)):jt(this,this.T-e)};function Nt(e){e.j.I==0||e.K||Qn(e.j,e)}function Pt(e){Mt(e);var t=e.O;t&&typeof t.dispose==`function`&&t.dispose(),e.O=null,Ge(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.dispose())}function Ft(e,t){try{var n=e.j;if(n.I!=0&&(n.g==e||Bt(n.h,e))){if(!e.L&&Bt(n.h,e)&&n.I==3){try{var r=n.Ba.g.parse(t)}catch{r=null}if(Array.isArray(r)&&r.length==3){var i=r;if(i[0]==0){a:if(!n.v){if(n.g)if(n.g.F+3e3<e.F)k(n),Wn(n);else break a;Yn(n),ot(18)}}else n.xa=i[1],0<n.xa-n.K&&i[2]<37500&&n.F&&n.A==0&&!n.C&&(n.C=ct(l(n.Va,n),6e3));zt(n.h)<=1&&n.ta&&(n.ta=void 0)}else er(n,11)}else if((e.L||n.g==e)&&k(n),!fe(t))for(i=n.Ba.g.parse(t),t=0;t<i.length;t++){let l=i[t],u=l[0];if(!(u<=n.K))if(n.K=u,l=l[1],n.I==2)if(l[0]==`c`){n.M=l[1],n.ba=l[2];let t=l[3];t!=null&&(n.ka=t,n.j.info(`VER=`+n.ka));let i=l[4];i!=null&&(n.za=i,n.j.info(`SVER=`+n.za));let u=l[5];u!=null&&typeof u==`number`&&u>0&&(r=1.5*u,n.O=r,n.j.info(`backChannelRequestTimeoutMs_=`+r)),r=n;let d=e.g;if(d){let e=d.g?d.g.getResponseHeader(`X-Client-Wire-Protocol`):null;if(e){var a=r.h;a.g||e.indexOf(`spdy`)==-1&&e.indexOf(`quic`)==-1&&e.indexOf(`h2`)==-1||(a.j=a.l,a.g=new Set,a.h&&=(Vt(a,a.h),null))}if(r.G){let e=d.g?d.g.getResponseHeader(`X-HTTP-Session-Id`):null;e&&(r.wa=e,y(r.J,r.G,e))}}n.I=3,n.l&&n.l.ra(),n.aa&&(n.T=Date.now()-e.F,n.j.info(`Handshake RTT: `+n.T+`ms`)),r=n;var o=e;if(r.na=nr(r,r.L?r.ba:null,r.W),o.L){Ht(r.h,o);var s=o,c=r.O;c&&(s.H=c),s.D&&(Mt(s),At(s)),r.g=o}else Jn(r);n.i.length>0&&Kn(n)}else l[0]!=`stop`&&l[0]!=`close`||er(n,7);else n.I==3&&(l[0]==`stop`||l[0]==`close`?l[0]==`stop`?er(n,7):Un(n):l[0]!=`noop`&&n.l&&n.l.qa(l),n.A=0)}}it(4)}catch{}}var It=class{constructor(e,t){this.g=e,this.map=t}};function Lt(e){this.l=e||10,o.PerformanceNavigationTiming?(e=o.performance.getEntriesByType(`navigation`),e=e.length>0&&(e[0].nextHopProtocol==`hq`||e[0].nextHopProtocol==`h2`)):e=!!(o.chrome&&o.chrome.loadTimes&&o.chrome.loadTimes()&&o.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function Rt(e){return e.h?!0:e.g?e.g.size>=e.j:!1}function zt(e){return e.h?1:e.g?e.g.size:0}function Bt(e,t){return e.h?e.h==t:e.g?e.g.has(t):!1}function Vt(e,t){e.g?e.g.add(t):e.h=t}function Ht(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}Lt.prototype.cancel=function(){if(this.i=Ut(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(let e of this.g.values())e.cancel();this.g.clear()}};function Ut(e){if(e.h!=null)return e.i.concat(e.h.G);if(e.g!=null&&e.g.size!==0){let t=e.i;for(let n of e.g.values())t=t.concat(n.G);return t}return p(e.i)}var Wt=RegExp(`^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$`);function Gt(e,t){if(e){e=e.split(`&`);for(let n=0;n<e.length;n++){let r=e[n].indexOf(`=`),i,a=null;r>=0?(i=e[n].substring(0,r),a=e[n].substring(r+1)):i=e[n],t(i,a?decodeURIComponent(a.replace(/\+/g,` `)):``)}}}function Kt(e){this.g=this.o=this.j=``,this.u=null,this.m=this.h=``,this.l=!1;let t;e instanceof Kt?(this.l=e.l,Jt(this,e.j),this.o=e.o,this.g=e.g,Yt(this,e.u),this.h=e.h,Xt(this,pn(e.i)),this.m=e.m):e&&(t=String(e).match(Wt))?(this.l=!1,Jt(this,t[1]||``,!0),this.o=Qt(t[2]||``),this.g=Qt(t[3]||``,!0),Yt(this,t[4]),this.h=Qt(t[5]||``,!0),Xt(this,t[6]||``,!0),this.m=Qt(t[7]||``)):(this.l=!1,this.i=new sn(null,this.l))}Kt.prototype.toString=function(){let e=[];var t=this.j;t&&e.push($t(t,tn,!0),`:`);var n=this.g;return(n||t==`file`)&&(e.push(`//`),(t=this.o)&&e.push($t(t,tn,!0),`@`),e.push(yt(n).replace(/%25([0-9a-fA-F]{2})/g,`%$1`)),n=this.u,n!=null&&e.push(`:`,String(n))),(n=this.h)&&(this.g&&n.charAt(0)!=`/`&&e.push(`/`),e.push($t(n,n.charAt(0)==`/`?rn:nn,!0))),(n=this.i.toString())&&e.push(`?`,n),(n=this.m)&&e.push(`#`,$t(n,on)),e.join(``)},Kt.prototype.resolve=function(e){let t=qt(this),n=!!e.j;n?Jt(t,e.j):n=!!e.o,n?t.o=e.o:n=!!e.g,n?t.g=e.g:n=e.u!=null;var r=e.h;if(n)Yt(t,e.u);else if(n=!!e.h){if(r.charAt(0)!=`/`)if(this.g&&!this.h)r=`/`+r;else{var i=t.h.lastIndexOf(`/`);i!=-1&&(r=t.h.slice(0,i+1)+r)}if(i=r,i==`..`||i==`.`)r=``;else if(i.indexOf(`./`)!=-1||i.indexOf(`/.`)!=-1){r=i.lastIndexOf(`/`,0)==0,i=i.split(`/`);let e=[];for(let t=0;t<i.length;){let n=i[t++];n==`.`?r&&t==i.length&&e.push(``):n==`..`?((e.length>1||e.length==1&&e[0]!=``)&&e.pop(),r&&t==i.length&&e.push(``)):(e.push(n),r=!0)}r=e.join(`/`)}else r=i}return n?t.h=r:n=e.i.toString()!==``,n?Xt(t,pn(e.i)):n=!!e.m,n&&(t.m=e.m),t};function qt(e){return new Kt(e)}function Jt(e,t,n){e.j=n?Qt(t,!0):t,e.j&&=e.j.replace(/:$/,``)}function Yt(e,t){if(t){if(t=Number(t),isNaN(t)||t<0)throw Error(`Bad port number `+t);e.u=t}else e.u=null}function Xt(e,t,n){t instanceof sn?(e.i=t,hn(e.i,e.l)):(n||(t=$t(t,an)),e.i=new sn(t,e.l))}function y(e,t,n){e.i.set(t,n)}function Zt(e){return y(e,`zx`,Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),e}function Qt(e,t){return e?t?decodeURI(e.replace(/%25/g,`%2525`)):decodeURIComponent(e):``}function $t(e,t,n){return typeof e==`string`?(e=encodeURI(e).replace(t,en),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,`%$1`)),e):null}function en(e){return e=e.charCodeAt(0),`%`+(e>>4&15).toString(16)+(e&15).toString(16)}var tn=/[#\/\?@]/g,nn=/[#\?:]/g,rn=/[#\?]/g,an=/[#\?@]/g,on=/#/g;function sn(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function cn(e){e.g||(e.g=new Map,e.h=0,e.i&&Gt(e.i,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g,` `)),n)}))}e=sn.prototype,e.add=function(e,t){cn(this),this.i=null,e=mn(this,e);let n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this};function ln(e,t){cn(e),t=mn(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function un(e,t){return cn(e),t=mn(e,t),e.g.has(t)}e.forEach=function(e,t){cn(this),this.g.forEach(function(n,r){n.forEach(function(n){e.call(t,n,r,this)},this)},this)};function dn(e,t){cn(e);let n=[];if(typeof t==`string`)un(e,t)&&(n=n.concat(e.g.get(mn(e,t))));else for(e=Array.from(e.g.values()),t=0;t<e.length;t++)n=n.concat(e[t]);return n}e.set=function(e,t){return cn(this),this.i=null,e=mn(this,e),un(this,e)&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},e.get=function(e,t){return e?(e=dn(this,e),e.length>0?String(e[0]):t):t};function fn(e,t,n){ln(e,t),n.length>0&&(e.i=null,e.g.set(mn(e,t),p(n)),e.h+=n.length)}e.toString=function(){if(this.i)return this.i;if(!this.g)return``;let e=[],t=Array.from(this.g.keys());for(let r=0;r<t.length;r++){var n=t[r];let i=yt(n);n=dn(this,n);for(let t=0;t<n.length;t++){let r=i;n[t]!==``&&(r+=`=`+yt(n[t])),e.push(r)}}return this.i=e.join(`&`)};function pn(e){let t=new sn;return t.i=e.i,e.g&&(t.g=new Map(e.g),t.h=e.h),t}function mn(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function hn(e,t){t&&!e.j&&(cn(e),e.i=null,e.g.forEach(function(e,t){let n=t.toLowerCase();t!=n&&(ln(this,t),fn(this,n,e))},e)),e.j=t}function gn(e,t){let n=new lt;if(o.Image){let r=new Image;r.onload=u(vn,n,`TestLoadImage: loaded`,!0,t,r),r.onerror=u(vn,n,`TestLoadImage: error`,!1,t,r),r.onabort=u(vn,n,`TestLoadImage: abort`,!1,t,r),r.ontimeout=u(vn,n,`TestLoadImage: timeout`,!1,t,r),o.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}function _n(e,t){let n=new lt,r=new AbortController,i=setTimeout(()=>{r.abort(),vn(n,`TestPingServer: timeout`,!1,t)},1e4);fetch(e,{signal:r.signal}).then(e=>{clearTimeout(i),e.ok?vn(n,`TestPingServer: ok`,!0,t):vn(n,`TestPingServer: server error`,!1,t)}).catch(()=>{clearTimeout(i),vn(n,`TestPingServer: error`,!1,t)})}function vn(e,t,n,r,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),r(n)}catch{}}function yn(){this.g=new Je}function bn(e){this.i=e.Sb||null,this.h=e.ab||!1}d(bn,Ye),bn.prototype.g=function(){return new xn(this.i,this.h)};function xn(e,t){Le.call(this),this.H=e,this.o=t,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText=``,this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F=`GET`,this.D=``,this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}d(xn,Le),e=xn.prototype,e.open=function(e,t){if(this.readyState!=0)throw this.abort(),Error(`Error reopening a connection`);this.F=e,this.D=t,this.readyState=1,wn(this)},e.send=function(e){if(this.readyState!=1)throw this.abort(),Error(`need to call open() first. `);if(this.v.signal.aborted)throw this.abort(),Error(`Request was aborted.`);this.g=!0;let t={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};e&&(t.body=e),(this.H||o).fetch(new Request(this.D,t)).then(this.Pa.bind(this),this.ga.bind(this))},e.abort=function(){this.response=this.responseText=``,this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel(`Request was aborted.`).catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,Cn(this)),this.readyState=0},e.Pa=function(e){if(this.g&&(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,wn(this)),this.g&&(this.readyState=3,wn(this),this.g)))if(this.responseType===`arraybuffer`)e.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(o.ReadableStream!==void 0&&`body`in e){if(this.j=e.body.getReader(),this.o){if(this.responseType)throw Error(`responseType must be empty for "streamBinaryChunks" mode responses.`);this.response=[]}else this.response=this.responseText=``,this.B=new TextDecoder;Sn(this)}else e.text().then(this.Oa.bind(this),this.ga.bind(this))};function Sn(e){e.j.read().then(e.Ma.bind(e)).catch(e.ga.bind(e))}e.Ma=function(e){if(this.g){if(this.o&&e.value)this.response.push(e.value);else if(!this.o){var t=e.value?e.value:new Uint8Array;(t=this.B.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?Cn(this):wn(this),this.readyState==3&&Sn(this)}},e.Oa=function(e){this.g&&(this.response=this.responseText=e,Cn(this))},e.Na=function(e){this.g&&(this.response=e,Cn(this))},e.ga=function(){this.g&&Cn(this)};function Cn(e){e.readyState=4,e.l=null,e.j=null,e.B=null,wn(e)}e.setRequestHeader=function(e,t){this.A.append(e,t)},e.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||``},e.getAllResponseHeaders=function(){if(!this.h)return``;let e=[],t=this.h.entries();for(var n=t.next();!n.done;)n=n.value,e.push(n[0]+`: `+n[1]),n=t.next();return e.join(`\r
7
+ `)};function wn(e){e.onreadystatechange&&e.onreadystatechange.call(e)}Object.defineProperty(xn.prototype,"withCredentials",{get:function(){return this.m===`include`},set:function(e){this.m=e?`include`:`same-origin`}});function b(e){let t=``;return ve(e,function(e,n){t+=n,t+=`:`,t+=e,t+=`\r
8
+ `}),t}function x(e,t,n){a:{for(r in n){var r=!1;break a}r=!0}r||(n=b(n),typeof e==`string`||y(e,t,n))}function S(e){Le.call(this),this.headers=new Map,this.L=e||null,this.h=!1,this.g=null,this.D=``,this.o=0,this.l=``,this.j=this.B=this.v=this.A=!1,this.m=null,this.F=``,this.H=!1}d(S,Le);var C=/^https?$/i,w=[`POST`,`PUT`];e=S.prototype,e.Fa=function(e){this.H=e},e.ea=function(e,t,n,r){if(this.g)throw Error(`[goog.net.XhrIo] Object is active with another request=`+this.D+`; newUri=`+e);t=t?t.toUpperCase():`GET`,this.D=e,this.l=``,this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():_t.g(),this.g.onreadystatechange=f(l(this.Ca,this));try{this.B=!0,this.g.open(t,String(e),!0),this.B=!1}catch(e){Fn(this,e);return}if(e=n||``,n=new Map(this.headers),r)if(Object.getPrototypeOf(r)===Object.prototype)for(var i in r)n.set(i,r[i]);else if(typeof r.keys==`function`&&typeof r.get==`function`)for(let e of r.keys())n.set(e,r.get(e));else throw Error(`Unknown input type for opt_headers: `+String(r));r=Array.from(n.keys()).find(e=>e.toLowerCase()==`content-type`),i=o.FormData&&e instanceof o.FormData,!(Array.prototype.indexOf.call(w,t,void 0)>=0)||r||i||n.set(`Content-Type`,`application/x-www-form-urlencoded;charset=utf-8`);for(let[e,t]of n)this.g.setRequestHeader(e,t);this.F&&(this.g.responseType=this.F),`withCredentials`in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&=(clearTimeout(this.m),null),this.v=!0,this.g.send(e),this.v=!1}catch(e){Fn(this,e)}};function Fn(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.o=5,In(e),Rn(e)}function In(e){e.A||(e.A=!0,Re(e,`complete`),Re(e,`error`))}e.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=e||7,Re(this,`complete`),Re(this,`abort`),Rn(this))},e.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Rn(this,!0)),S.Z.N.call(this)},e.Ca=function(){this.u||(this.B||this.v||this.j?Ln(this):this.Xa())},e.Xa=function(){Ln(this)};function Ln(e){if(e.h&&a!==void 0){if(e.v&&zn(e)==4)setTimeout(e.Ca.bind(e),0);else if(Re(e,`readystatechange`),zn(e)==4){e.h=!1;try{let a=e.ca();a:switch(a){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var t=!0;break a;default:t=!1}var n;if(!(n=t)){var r;if(r=a===0){let t=String(e.D).match(Wt)[1]||null;!t&&o.self&&o.self.location&&(t=o.self.location.protocol.slice(0,-1)),r=!C.test(t?t.toLowerCase():``)}n=r}if(n)Re(e,`complete`),Re(e,`success`);else{e.o=6;try{var i=zn(e)>2?e.g.statusText:``}catch{i=``}e.l=i+` [`+e.ca()+`]`,In(e)}}finally{Rn(e)}}}}function Rn(e,t){if(e.g){e.m&&=(clearTimeout(e.m),null);let n=e.g;e.g=null,t||Re(e,`ready`);try{n.onreadystatechange=null}catch{}}}e.isActive=function(){return!!this.g};function zn(e){return e.g?e.g.readyState:0}e.ca=function(){try{return zn(this)>2?this.g.status:-1}catch{return-1}},e.la=function(){try{return this.g?this.g.responseText:``}catch{return``}},e.La=function(e){if(this.g){var t=this.g.responseText;return e&&t.indexOf(e)==0&&(t=t.substring(e.length)),qe(t)}};function Bn(e){try{if(!e.g)return null;if(`response`in e.g)return e.g.response;switch(e.F){case``:case`text`:return e.g.responseText;case`arraybuffer`:if(`mozResponseArrayBuffer`in e.g)return e.g.mozResponseArrayBuffer}return null}catch{return null}}function T(e){let t={};e=(e.g&&zn(e)>=2&&e.g.getAllResponseHeaders()||``).split(`\r
9
+ `);for(let r=0;r<e.length;r++){if(fe(e[r]))continue;var n=bt(e[r]);let i=n[0];if(n=n[1],typeof n!=`string`)continue;n=n.trim();let a=t[i]||[];t[i]=a,a.push(n)}ye(t,function(e){return e.join(`, `)})}e.ya=function(){return this.o},e.Ha=function(){return typeof this.l==`string`?this.l:String(this.l)};function Vn(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function Hn(e){this.za=0,this.i=[],this.j=new lt,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=Vn(`failFast`,!1,e),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=Vn(`baseRetryDelayMs`,5e3,e),this.Za=Vn(`retryDelaySeedMs`,1e4,e),this.Ta=Vn(`forwardChannelMaxRetries`,2,e),this.va=Vn(`forwardChannelRequestTimeoutMs`,2e4,e),this.ma=e&&e.xmlHttpFactory||void 0,this.Ua=e&&e.Rb||void 0,this.Aa=e&&e.useFetchStreams||!1,this.O=void 0,this.L=e&&e.supportsCrossDomainXhr||!1,this.M=``,this.h=new Lt(e&&e.concurrentRequestLimit),this.Ba=new yn,this.S=e&&e.fastHandshake||!1,this.R=e&&e.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=e&&e.Pb||!1,e&&e.ua&&this.j.ua(),e&&e.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&e&&e.detectBufferingProxy||!1,this.ia=void 0,e&&e.longPollingTimeout&&e.longPollingTimeout>0&&(this.ia=e.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}e=Hn.prototype,e.ka=8,e.I=1,e.connect=function(e,t,n,r){ot(0),this.W=e,this.H=t||{},n&&r!==void 0&&(this.H.OSID=n,this.H.OAID=r),this.F=this.X,this.J=nr(this,null,this.W),Kn(this)};function Un(e){if(Gn(e),e.I==3){var t=e.V++,n=qt(e.J);if(y(n,`SID`,e.M),y(n,`RID`,t),y(n,`TYPE`,`terminate`),D(e,n),t=new xt(e,e.j,t),t.M=2,t.A=Zt(qt(n)),n=!1,o.navigator&&o.navigator.sendBeacon)try{n=o.navigator.sendBeacon(t.A.toString(),``)}catch{}!n&&o.Image&&(new Image().src=t.A,n=!0),n||(t.g=rr(t.j,null),t.g.ea(t.A)),t.F=Date.now(),At(t)}tr(e)}function Wn(e){e.g&&=(Xn(e),e.g.cancel(),null)}function Gn(e){Wn(e),e.v&&=(o.clearTimeout(e.v),null),k(e),e.h.cancel(),e.m&&=(typeof e.m==`number`&&o.clearTimeout(e.m),null)}function Kn(e){if(!Rt(e.h)&&!e.m){e.m=!0;var t=e.Ea;ie||se(),ae||=(ie(),!0),oe.add(t,e),e.D=0}}function qn(e,t){return zt(e.h)>=e.h.j-+!!e.m?!1:e.m?(e.i=t.G.concat(e.i),!0):e.I==1||e.I==2||e.D>=(e.Sa?0:e.Ta)?!1:(e.m=ct(l(e.Ea,e,t),$n(e,e.D)),e.D++,!0)}e.Ea=function(e){if(this.m)if(this.m=null,this.I==1){if(!e){this.V=Math.floor(Math.random()*1e5),e=this.V++;let i=new xt(this,this.j,e),a=this.o;if(this.U&&(a?(a=be(a),Se(a,this.U)):a=this.U),this.u!==null||this.R||(i.J=a,a=null),this.S)a:{for(var t=0,n=0;n<this.i.length;n++){b:{var r=this.i[n];if(`__data__`in r.map&&(r=r.map.__data__,typeof r==`string`)){r=r.length;break b}r=void 0}if(r===void 0)break;if(t+=r,t>4096){t=n;break a}if(t===4096||n===this.i.length-1){t=n+1;break a}}t=1e3}else t=1e3;t=O(this,i,t),n=qt(this.J),y(n,`RID`,e),y(n,`CVER`,22),this.G&&y(n,`X-HTTP-Session-Id`,this.G),D(this,n),a&&(this.R?t=`headers=`+yt(b(a))+`&`+t:this.u&&x(n,this.u,a)),Vt(this.h,i),this.Ra&&y(n,`TYPE`,`init`),this.S?(y(n,`$req`,t),y(n,`SID`,`null`),i.U=!0,Tt(i,n,null)):Tt(i,n,t),this.I=2}}else this.I==3&&(e?E(this,e):this.i.length==0||Rt(this.h)||E(this))};function E(e,t){var n=t?t.l:e.V++;let r=qt(e.J);y(r,`SID`,e.M),y(r,`RID`,n),y(r,`AID`,e.K),D(e,r),e.u&&e.o&&x(r,e.u,e.o),n=new xt(e,e.j,n,e.D+1),e.u===null&&(n.J=e.o),t&&(e.i=t.G.concat(e.i)),t=O(e,n,1e3),n.H=Math.round(e.va*.5)+Math.round(e.va*.5*Math.random()),Vt(e.h,n),Tt(n,r,t)}function D(e,t){e.H&&ve(e.H,function(e,n){y(t,n,e)}),e.l&&ve({},function(e,n){y(t,n,e)})}function O(e,t,n){n=Math.min(e.i.length,n);let r=e.l?l(e.l.Ka,e.l,e):null;a:{var i=e.i;let t=-1;for(;;){let e=[`count=`+n];t==-1?n>0?(t=i[0].g,e.push(`ofs=`+t)):t=0:e.push(`ofs=`+t);let c=!0;for(let l=0;l<n;l++){var a=i[l].g;let n=i[l].map;if(a-=t,a<0)t=Math.max(0,i[l].g-100),c=!1;else try{a=`req`+a+`_`||``;try{var o=n instanceof Map?n:Object.entries(n);for(let[t,n]of o){let r=n;s(n)&&(r=Ke(n)),e.push(a+t+`=`+encodeURIComponent(r))}}catch(t){throw e.push(a+`type=_badmap`),t}}catch{r&&r(n)}}if(c){o=e.join(`&`);break a}}o=void 0}return e=e.i.splice(0,n),t.G=e,o}function Jn(e){if(!e.g&&!e.v){e.Y=1;var t=e.Da;ie||se(),ae||=(ie(),!0),oe.add(t,e),e.A=0}}function Yn(e){return e.g||e.v||e.A>=3?!1:(e.Y++,e.v=ct(l(e.Da,e),$n(e,e.A)),e.A++,!0)}e.Da=function(){if(this.v=null,Zn(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var e=4*this.T;this.j.info(`BP detection timer enabled: `+e),this.B=ct(l(this.Wa,this),e)}},e.Wa=function(){this.B&&(this.B=null,this.j.info(`BP detection timeout reached.`),this.j.info(`Buffering proxy detected and switch to long-polling!`),this.F=!1,this.P=!0,ot(10),Wn(this),Zn(this))};function Xn(e){e.B!=null&&(o.clearTimeout(e.B),e.B=null)}function Zn(e){e.g=new xt(e,e.j,`rpc`,e.Y),e.u===null&&(e.g.J=e.o),e.g.P=0;var t=qt(e.na);y(t,`RID`,`rpc`),y(t,`SID`,e.M),y(t,`AID`,e.K),y(t,`CI`,e.F?`0`:`1`),!e.F&&e.ia&&y(t,`TO`,e.ia),y(t,`TYPE`,`xmlhttp`),D(e,t),e.u&&e.o&&x(t,e.u,e.o),e.O&&(e.g.H=e.O);var n=e.g;e=e.ba,n.M=1,n.A=Zt(qt(t)),n.u=null,n.R=!0,Et(n,e)}e.Va=function(){this.C!=null&&(this.C=null,Wn(this),Yn(this),ot(19))};function k(e){e.C!=null&&(o.clearTimeout(e.C),e.C=null)}function Qn(e,t){var n=null;if(e.g==t){k(e),Xn(e),e.g=null;var r=2}else if(Bt(e.h,t))n=t.G,Ht(e.h,t),r=1;else return;if(e.I!=0){if(t.o)if(r==1){n=t.u?t.u.length:0,t=Date.now()-t.F;var i=e.D;r=nt(),Re(r,new st(r,n)),Kn(e)}else Jn(e);else if(i=t.m,i==3||i==0&&t.X>0||!(r==1&&qn(e,t)||r==2&&Yn(e)))switch(n&&n.length>0&&(t=e.h,t.i=t.i.concat(n)),i){case 1:er(e,5);break;case 4:er(e,10);break;case 3:er(e,6);break;default:er(e,2)}}}function $n(e,t){let n=e.Qa+Math.floor(Math.random()*e.Za);return e.isActive()||(n*=2),n*t}function er(e,t){if(e.j.info(`Error code `+t),t==2){var n=l(e.bb,e),r=e.Ua;let t=!r;r=new Kt(r||`//www.google.com/images/cleardot.gif`),o.location&&o.location.protocol==`http`||Jt(r,`https`),Zt(r),t?gn(r.toString(),n):_n(r.toString(),n)}else ot(2);e.I=0,e.l&&e.l.pa(t),tr(e),Gn(e)}e.bb=function(e){e?(this.j.info(`Successfully pinged google.com`),ot(2)):(this.j.info(`Failed to ping google.com`),ot(1))};function tr(e){if(e.I=0,e.ja=[],e.l){let t=Ut(e.h);(t.length!=0||e.i.length!=0)&&(m(e.ja,t),m(e.ja,e.i),e.h.i.length=0,p(e.i),e.i.length=0),e.l.oa()}}function nr(e,t,n){var r=n instanceof Kt?qt(n):new Kt(n);if(r.g!=``)t&&(r.g=t+`.`+r.g),Yt(r,r.u);else{var i=o.location;r=i.protocol,t=t?t+`.`+i.hostname:i.hostname,i=+i.port;let e=new Kt(null);r&&Jt(e,r),t&&(e.g=t),i&&Yt(e,i),n&&(e.h=n),r=e}return n=e.G,t=e.wa,n&&t&&y(r,n,t),y(r,`VER`,e.ka),D(e,r),r}function rr(e,t,n){if(t&&!e.L)throw Error(`Can't create secondary domain capable XhrIo object.`);return t=e.Aa&&!e.ma?new S(new bn({ab:n})):new S(e.ma),t.Fa(e.L),t}e.isActive=function(){return!!this.l&&this.l.isActive(this)};function ir(){}e=ir.prototype,e.ra=function(){},e.qa=function(){},e.pa=function(){},e.oa=function(){},e.isActive=function(){return!0},e.Ka=function(){};function ar(){}ar.prototype.g=function(e,t){return new or(e,t)};function or(e,t){Le.call(this),this.g=new Hn(t),this.l=e,this.h=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e[`X-Client-Protocol`]=`webchannel`:e={"X-Client-Protocol":`webchannel`}),this.g.o=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e[`X-WebChannel-Content-Type`]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.sa&&(e?e[`X-WebChannel-Client-Profile`]=t.sa:e={"X-WebChannel-Client-Profile":t.sa}),this.g.U=e,(e=t&&t.Qb)&&!fe(e)&&(this.g.u=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t&&=t.httpSessionIdParam)&&!fe(t)&&(this.g.G=t,e=this.h,e!==null&&t in e&&(e=this.h,t in e&&delete e[t])),this.j=new lr(this)}d(or,Le),or.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},or.prototype.close=function(){Un(this.g)},or.prototype.o=function(e){var t=this.g;if(typeof e==`string`){var n={};n.__data__=e,e=n}else this.v&&(n={},n.__data__=Ke(e),e=n);t.i.push(new It(t.Ya++,e)),t.I==3&&Kn(t)},or.prototype.N=function(){this.g.l=null,delete this.j,Un(this.g),delete this.g,or.Z.N.call(this)};function sr(e){Qe.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){a:{for(let n in t){e=n;break a}e=void 0}(this.i=e)&&(e=this.i,t=t!==null&&e in t?t[e]:void 0),this.data=t}else this.data=e}d(sr,Qe);function cr(){$e.call(this),this.status=1}d(cr,$e);function lr(e){this.g=e}d(lr,ir),lr.prototype.ra=function(){Re(this.g,`a`)},lr.prototype.qa=function(e){Re(this.g,new sr(e))},lr.prototype.pa=function(e){Re(this.g,new cr)},lr.prototype.oa=function(){Re(this.g,`b`)},ar.prototype.createWebChannel=ar.prototype.g,or.prototype.send=or.prototype.o,or.prototype.open=or.prototype.m,or.prototype.close=or.prototype.close,Pn=En.createWebChannelTransport=function(){return new ar},Nn=En.getStatEventTarget=function(){return nt()},Mn=En.Event=et,jn=En.Stat={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},ht.NO_ERROR=0,ht.TIMEOUT=8,ht.HTTP_ERROR=6,An=En.ErrorCode=ht,gt.COMPLETE=`complete`,kn=En.EventType=gt,Xe.EventType=Ze,Ze.OPEN=`a`,Ze.CLOSE=`b`,Ze.ERROR=`c`,Ze.MESSAGE=`d`,Le.prototype.listen=Le.prototype.J,On=En.WebChannel=Xe,En.FetchXmlHttpFactory=bn,S.prototype.listenOnce=S.prototype.K,S.prototype.getLastError=S.prototype.Ha,S.prototype.getLastErrorCode=S.prototype.ya,S.prototype.getStatus=S.prototype.ca,S.prototype.getResponseJson=S.prototype.La,S.prototype.getResponseText=S.prototype.la,S.prototype.send=S.prototype.ea,S.prototype.setWithCredentials=S.prototype.Fa,Dn=En.XhrIo=S}).apply(Tn===void 0?typeof self<`u`?self:typeof window<`u`?window:{}:Tn);var b=class e{static FOLD_CASE=1;static LITERAL=2;static CLASS_NL=4;static DOT_NL=8;static ONE_LINE=16;static NON_GREEDY=32;static PERL_X=64;static UNICODE_GROUPS=128;static WAS_DOLLAR=256;static MATCH_NL=e.CLASS_NL|e.DOT_NL;static PERL=e.CLASS_NL|e.ONE_LINE|e.PERL_X|e.UNICODE_GROUPS;static POSIX=0;static UNANCHORED=0;static ANCHOR_START=1;static ANCHOR_BOTH=2},x=class{static CODES=new Map([[`\x07`,7],[`\b`,8],[` `,9],[`
10
+ `,10],[`\v`,11],[`\f`,12],[`\r`,13],[` `,32],[`"`,34],[`$`,36],[`&`,38],[`(`,40],[`)`,41],[`*`,42],[`+`,43],[`-`,45],[`.`,46],[`0`,48],[`1`,49],[`2`,50],[`3`,51],[`4`,52],[`5`,53],[`6`,54],[`7`,55],[`8`,56],[`9`,57],[`:`,58],[`<`,60],[`>`,62],[`?`,63],[`A`,65],[`B`,66],[`C`,67],[`F`,70],[`P`,80],[`Q`,81],[`U`,85],[`Z`,90],[`[`,91],[`\\`,92],[`]`,93],[`^`,94],[`_`,95],[`a`,97],[`b`,98],[`f`,102],[`i`,105],[`m`,109],[`n`,110],[`r`,114],[`s`,115],[`t`,116],[`v`,118],[`x`,120],[`z`,122],[`{`,123],[`|`,124],[`}`,125]]);static toUpperCase(e){let t=String.fromCodePoint(e).toUpperCase();if(t.length>1)return e;let n=String.fromCodePoint(t.codePointAt(0)).toLowerCase();return n.length>1||n.codePointAt(0)!==e?e:t.codePointAt(0)}static toLowerCase(e){let t=String.fromCodePoint(e).toLowerCase();if(t.length>1)return e;let n=String.fromCodePoint(t.codePointAt(0)).toUpperCase();return n.length>1||n.codePointAt(0)!==e?e:t.codePointAt(0)}},S=class e{static CASE_ORBIT=new Map([[75,107],[107,8490],[8490,75],[83,115],[115,383],[383,83],[181,924],[924,956],[956,181],[197,229],[229,8491],[8491,197],[452,453],[453,454],[454,452],[455,456],[456,457],[457,455],[458,459],[459,460],[460,458],[497,498],[498,499],[499,497],[837,921],[921,953],[953,8126],[8126,837],[914,946],[946,976],[976,914],[917,949],[949,1013],[1013,917],[920,952],[952,977],[977,1012],[1012,920],[922,954],[954,1008],[1008,922],[928,960],[960,982],[982,928],[929,961],[961,1009],[1009,929],[931,962],[962,963],[963,931],[934,966],[966,981],[981,934],[937,969],[969,8486],[8486,937],[1042,1074],[1074,7296],[7296,1042],[1044,1076],[1076,7297],[7297,1044],[1054,1086],[1086,7298],[7298,1054],[1057,1089],[1089,7299],[7299,1057],[1058,1090],[1090,7300],[7300,7301],[7301,1058],[1066,1098],[1098,7302],[7302,1066],[1122,1123],[1123,7303],[7303,1122],[7304,42570],[42570,42571],[42571,7304],[7776,7777],[7777,7835],[7835,7776],[223,7838],[7838,223],[8064,8072],[8072,8064],[8065,8073],[8073,8065],[8066,8074],[8074,8066],[8067,8075],[8075,8067],[8068,8076],[8076,8068],[8069,8077],[8077,8069],[8070,8078],[8078,8070],[8071,8079],[8079,8071],[8080,8088],[8088,8080],[8081,8089],[8089,8081],[8082,8090],[8090,8082],[8083,8091],[8091,8083],[8084,8092],[8092,8084],[8085,8093],[8093,8085],[8086,8094],[8094,8086],[8087,8095],[8095,8087],[8096,8104],[8104,8096],[8097,8105],[8105,8097],[8098,8106],[8106,8098],[8099,8107],[8107,8099],[8100,8108],[8108,8100],[8101,8109],[8109,8101],[8102,8110],[8110,8102],[8103,8111],[8111,8103],[8115,8124],[8124,8115],[8131,8140],[8140,8131],[912,8147],[8147,912],[944,8163],[8163,944],[8179,8188],[8188,8179],[64261,64262],[64262,64261],[66560,66600],[66600,66560],[66561,66601],[66601,66561],[66562,66602],[66602,66562],[66563,66603],[66603,66563],[66564,66604],[66604,66564],[66565,66605],[66605,66565],[66566,66606],[66606,66566],[66567,66607],[66607,66567],[66568,66608],[66608,66568],[66569,66609],[66609,66569],[66570,66610],[66610,66570],[66571,66611],[66611,66571],[66572,66612],[66612,66572],[66573,66613],[66613,66573],[66574,66614],[66614,66574],[66575,66615],[66615,66575],[66576,66616],[66616,66576],[66577,66617],[66617,66577],[66578,66618],[66618,66578],[66579,66619],[66619,66579],[66580,66620],[66620,66580],[66581,66621],[66621,66581],[66582,66622],[66622,66582],[66583,66623],[66623,66583],[66584,66624],[66624,66584],[66585,66625],[66625,66585],[66586,66626],[66626,66586],[66587,66627],[66627,66587],[66588,66628],[66628,66588],[66589,66629],[66629,66589],[66590,66630],[66630,66590],[66591,66631],[66631,66591],[66592,66632],[66632,66592],[66593,66633],[66633,66593],[66594,66634],[66634,66594],[66595,66635],[66635,66595],[66596,66636],[66636,66596],[66597,66637],[66637,66597],[66598,66638],[66638,66598],[66599,66639],[66639,66599],[66736,66776],[66776,66736],[66737,66777],[66777,66737],[66738,66778],[66778,66738],[66739,66779],[66779,66739],[66740,66780],[66780,66740],[66741,66781],[66781,66741],[66742,66782],[66782,66742],[66743,66783],[66783,66743],[66744,66784],[66784,66744],[66745,66785],[66785,66745],[66746,66786],[66786,66746],[66747,66787],[66787,66747],[66748,66788],[66788,66748],[66749,66789],[66789,66749],[66750,66790],[66790,66750],[66751,66791],[66791,66751],[66752,66792],[66792,66752],[66753,66793],[66793,66753],[66754,66794],[66794,66754],[66755,66795],[66795,66755],[66756,66796],[66796,66756],[66757,66797],[66797,66757],[66758,66798],[66798,66758],[66759,66799],[66799,66759],[66760,66800],[66800,66760],[66761,66801],[66801,66761],[66762,66802],[66802,66762],[66763,66803],[66803,66763],[66764,66804],[66804,66764],[66765,66805],[66805,66765],[66766,66806],[66806,66766],[66767,66807],[66807,66767],[66768,66808],[66808,66768],[66769,66809],[66809,66769],[66770,66810],[66810,66770],[66771,66811],[66811,66771],[66928,66967],[66967,66928],[66929,66968],[66968,66929],[66930,66969],[66969,66930],[66931,66970],[66970,66931],[66932,66971],[66971,66932],[66933,66972],[66972,66933],[66934,66973],[66973,66934],[66935,66974],[66974,66935],[66936,66975],[66975,66936],[66937,66976],[66976,66937],[66938,66977],[66977,66938],[66940,66979],[66979,66940],[66941,66980],[66980,66941],[66942,66981],[66981,66942],[66943,66982],[66982,66943],[66944,66983],[66983,66944],[66945,66984],[66984,66945],[66946,66985],[66985,66946],[66947,66986],[66986,66947],[66948,66987],[66987,66948],[66949,66988],[66988,66949],[66950,66989],[66989,66950],[66951,66990],[66990,66951],[66952,66991],[66991,66952],[66953,66992],[66992,66953],[66954,66993],[66993,66954],[66956,66995],[66995,66956],[66957,66996],[66996,66957],[66958,66997],[66997,66958],[66959,66998],[66998,66959],[66960,66999],[66999,66960],[66961,67e3],[67e3,66961],[66962,67001],[67001,66962],[66964,67003],[67003,66964],[66965,67004],[67004,66965],[68736,68800],[68800,68736],[68737,68801],[68801,68737],[68738,68802],[68802,68738],[68739,68803],[68803,68739],[68740,68804],[68804,68740],[68741,68805],[68805,68741],[68742,68806],[68806,68742],[68743,68807],[68807,68743],[68744,68808],[68808,68744],[68745,68809],[68809,68745],[68746,68810],[68810,68746],[68747,68811],[68811,68747],[68748,68812],[68812,68748],[68749,68813],[68813,68749],[68750,68814],[68814,68750],[68751,68815],[68815,68751],[68752,68816],[68816,68752],[68753,68817],[68817,68753],[68754,68818],[68818,68754],[68755,68819],[68819,68755],[68756,68820],[68820,68756],[68757,68821],[68821,68757],[68758,68822],[68822,68758],[68759,68823],[68823,68759],[68760,68824],[68824,68760],[68761,68825],[68825,68761],[68762,68826],[68826,68762],[68763,68827],[68827,68763],[68764,68828],[68828,68764],[68765,68829],[68829,68765],[68766,68830],[68830,68766],[68767,68831],[68831,68767],[68768,68832],[68832,68768],[68769,68833],[68833,68769],[68770,68834],[68834,68770],[68771,68835],[68835,68771],[68772,68836],[68836,68772],[68773,68837],[68837,68773],[68774,68838],[68838,68774],[68775,68839],[68839,68775],[68776,68840],[68840,68776],[68777,68841],[68841,68777],[68778,68842],[68842,68778],[68779,68843],[68843,68779],[68780,68844],[68844,68780],[68781,68845],[68845,68781],[68782,68846],[68846,68782],[68783,68847],[68847,68783],[68784,68848],[68848,68784],[68785,68849],[68849,68785],[68786,68850],[68850,68786],[71840,71872],[71872,71840],[71841,71873],[71873,71841],[71842,71874],[71874,71842],[71843,71875],[71875,71843],[71844,71876],[71876,71844],[71845,71877],[71877,71845],[71846,71878],[71878,71846],[71847,71879],[71879,71847],[71848,71880],[71880,71848],[71849,71881],[71881,71849],[71850,71882],[71882,71850],[71851,71883],[71883,71851],[71852,71884],[71884,71852],[71853,71885],[71885,71853],[71854,71886],[71886,71854],[71855,71887],[71887,71855],[71856,71888],[71888,71856],[71857,71889],[71889,71857],[71858,71890],[71890,71858],[71859,71891],[71891,71859],[71860,71892],[71892,71860],[71861,71893],[71893,71861],[71862,71894],[71894,71862],[71863,71895],[71895,71863],[71864,71896],[71896,71864],[71865,71897],[71897,71865],[71866,71898],[71898,71866],[71867,71899],[71899,71867],[71868,71900],[71900,71868],[71869,71901],[71901,71869],[71870,71902],[71902,71870],[71871,71903],[71903,71871],[93760,93792],[93792,93760],[93761,93793],[93793,93761],[93762,93794],[93794,93762],[93763,93795],[93795,93763],[93764,93796],[93796,93764],[93765,93797],[93797,93765],[93766,93798],[93798,93766],[93767,93799],[93799,93767],[93768,93800],[93800,93768],[93769,93801],[93801,93769],[93770,93802],[93802,93770],[93771,93803],[93803,93771],[93772,93804],[93804,93772],[93773,93805],[93805,93773],[93774,93806],[93806,93774],[93775,93807],[93807,93775],[93776,93808],[93808,93776],[93777,93809],[93809,93777],[93778,93810],[93810,93778],[93779,93811],[93811,93779],[93780,93812],[93812,93780],[93781,93813],[93813,93781],[93782,93814],[93814,93782],[93783,93815],[93815,93783],[93784,93816],[93816,93784],[93785,93817],[93817,93785],[93786,93818],[93818,93786],[93787,93819],[93819,93787],[93788,93820],[93820,93788],[93789,93821],[93821,93789],[93790,93822],[93822,93790],[93791,93823],[93823,93791],[125184,125218],[125218,125184],[125185,125219],[125219,125185],[125186,125220],[125220,125186],[125187,125221],[125221,125187],[125188,125222],[125222,125188],[125189,125223],[125223,125189],[125190,125224],[125224,125190],[125191,125225],[125225,125191],[125192,125226],[125226,125192],[125193,125227],[125227,125193],[125194,125228],[125228,125194],[125195,125229],[125229,125195],[125196,125230],[125230,125196],[125197,125231],[125231,125197],[125198,125232],[125232,125198],[125199,125233],[125233,125199],[125200,125234],[125234,125200],[125201,125235],[125235,125201],[125202,125236],[125236,125202],[125203,125237],[125237,125203],[125204,125238],[125238,125204],[125205,125239],[125239,125205],[125206,125240],[125240,125206],[125207,125241],[125241,125207],[125208,125242],[125242,125208],[125209,125243],[125243,125209],[125210,125244],[125244,125210],[125211,125245],[125245,125211],[125212,125246],[125246,125212],[125213,125247],[125247,125213],[125214,125248],[125248,125214],[125215,125249],[125249,125215],[125216,125250],[125250,125216],[125217,125251],[125251,125217]]);static C=[[0,31,1],[127,159,1],[173,888,715],[889,896,7],[897,899,1],[907,909,2],[930,1328,398],[1367,1368,1],[1419,1420,1],[1424,1480,56],[1481,1487,1],[1515,1518,1],[1525,1541,1],[1564,1757,193],[1806,1807,1],[1867,1868,1],[1970,1983,1],[2043,2044,1],[2094,2095,1],[2111,2140,29],[2141,2143,2],[2155,2159,1],[2191,2199,1],[2274,2436,162],[2445,2446,1],[2449,2450,1],[2473,2481,8],[2483,2485,1],[2490,2491,1],[2501,2502,1],[2505,2506,1],[2511,2518,1],[2520,2523,1],[2526,2532,6],[2533,2559,26],[2560,2564,4],[2571,2574,1],[2577,2578,1],[2601,2609,8],[2612,2618,3],[2619,2621,2],[2627,2630,1],[2633,2634,1],[2638,2640,1],[2642,2648,1],[2653,2655,2],[2656,2661,1],[2679,2688,1],[2692,2702,10],[2706,2729,23],[2737,2740,3],[2746,2747,1],[2758,2766,4],[2767,2769,2],[2770,2783,1],[2788,2789,1],[2802,2808,1],[2816,2820,4],[2829,2830,1],[2833,2834,1],[2857,2865,8],[2868,2874,6],[2875,2885,10],[2886,2889,3],[2890,2894,4],[2895,2900,1],[2904,2907,1],[2910,2916,6],[2917,2936,19],[2937,2945,1],[2948,2955,7],[2956,2957,1],[2961,2966,5],[2967,2968,1],[2971,2973,2],[2976,2978,1],[2981,2983,1],[2987,2989,1],[3002,3005,1],[3011,3013,1],[3017,3022,5],[3023,3025,2],[3026,3030,1],[3032,3045,1],[3067,3071,1],[3085,3089,4],[3113,3130,17],[3131,3141,10],[3145,3150,5],[3151,3156,1],[3159,3163,4],[3164,3166,2],[3167,3172,5],[3173,3184,11],[3185,3190,1],[3213,3217,4],[3241,3252,11],[3258,3259,1],[3269,3273,4],[3278,3284,1],[3287,3292,1],[3295,3300,5],[3301,3312,11],[3316,3327,1],[3341,3345,4],[3397,3401,4],[3408,3411,1],[3428,3429,1],[3456,3460,4],[3479,3481,1],[3506,3516,10],[3518,3519,1],[3527,3529,1],[3531,3534,1],[3541,3543,2],[3552,3557,1],[3568,3569,1],[3573,3584,1],[3643,3646,1],[3676,3712,1],[3715,3717,2],[3723,3748,25],[3750,3774,24],[3775,3781,6],[3783,3791,8],[3802,3803,1],[3808,3839,1],[3912,3949,37],[3950,3952,1],[3992,4029,37],[4045,4059,14],[4060,4095,1],[4294,4296,2],[4297,4300,1],[4302,4303,1],[4681,4686,5],[4687,4695,8],[4697,4702,5],[4703,4745,42],[4750,4751,1],[4785,4790,5],[4791,4799,8],[4801,4806,5],[4807,4823,16],[4881,4886,5],[4887,4955,68],[4956,4989,33],[4990,4991,1],[5018,5023,1],[5110,5111,1],[5118,5119,1],[5789,5791,1],[5881,5887,1],[5910,5918,1],[5943,5951,1],[5972,5983,1],[5997,6001,4],[6004,6015,1],[6110,6111,1],[6122,6127,1],[6138,6143,1],[6158,6170,12],[6171,6175,1],[6265,6271,1],[6315,6319,1],[6390,6399,1],[6431,6444,13],[6445,6447,1],[6460,6463,1],[6465,6467,1],[6510,6511,1],[6517,6527,1],[6572,6575,1],[6602,6607,1],[6619,6621,1],[6684,6685,1],[6751,6781,30],[6782,6794,12],[6795,6799,1],[6810,6815,1],[6830,6831,1],[6863,6911,1],[6989,6991,1],[7039,7156,117],[7157,7163,1],[7224,7226,1],[7242,7244,1],[7305,7311,1],[7355,7356,1],[7368,7375,1],[7419,7423,1],[7958,7959,1],[7966,7967,1],[8006,8007,1],[8014,8015,1],[8024,8030,2],[8062,8063,1],[8117,8133,16],[8148,8149,1],[8156,8176,20],[8177,8181,4],[8191,8203,12],[8204,8207,1],[8234,8238,1],[8288,8303,1],[8306,8307,1],[8335,8349,14],[8350,8351,1],[8385,8399,1],[8433,8447,1],[8588,8591,1],[9255,9279,1],[9291,9311,1],[11124,11125,1],[11158,11508,350],[11509,11512,1],[11558,11560,2],[11561,11564,1],[11566,11567,1],[11624,11630,1],[11633,11646,1],[11671,11679,1],[11687,11743,8],[11870,11903,1],[11930,12020,90],[12021,12031,1],[12246,12271,1],[12352,12439,87],[12440,12544,104],[12545,12548,1],[12592,12687,95],[12772,12782,1],[12831,42125,29294],[42126,42127,1],[42183,42191,1],[42540,42559,1],[42744,42751,1],[42955,42959,1],[42962,42964,2],[42970,42993,1],[43053,43055,1],[43066,43071,1],[43128,43135,1],[43206,43213,1],[43226,43231,1],[43348,43358,1],[43389,43391,1],[43470,43482,12],[43483,43485,1],[43519,43575,56],[43576,43583,1],[43598,43599,1],[43610,43611,1],[43715,43738,1],[43767,43776,1],[43783,43784,1],[43791,43792,1],[43799,43807,1],[43815,43823,8],[43884,43887,1],[44014,44015,1],[44026,44031,1],[55204,55215,1],[55239,55242,1],[55292,63743,1],[64110,64111,1],[64218,64255,1],[64263,64274,1],[64280,64284,1],[64311,64317,6],[64319,64325,3],[64451,64466,1],[64912,64913,1],[64968,64974,1],[64976,65007,1],[65050,65055,1],[65107,65127,20],[65132,65135,1],[65141,65277,136],[65278,65280,1],[65471,65473,1],[65480,65481,1],[65488,65489,1],[65496,65497,1],[65501,65503,1],[65511,65519,8],[65520,65531,1],[65534,65535,1],[65548,65575,27],[65595,65598,3],[65614,65615,1],[65630,65663,1],[65787,65791,1],[65795,65798,1],[65844,65846,1],[65935,65949,14],[65950,65951,1],[65953,65999,1],[66046,66175,1],[66205,66207,1],[66257,66271,1],[66300,66303,1],[66340,66348,1],[66379,66383,1],[66427,66431,1],[66462,66500,38],[66501,66503,1],[66518,66559,1],[66718,66719,1],[66730,66735,1],[66772,66775,1],[66812,66815,1],[66856,66863,1],[66916,66926,1],[66939,66955,16],[66963,66966,3],[66978,66994,16],[67002,67005,3],[67006,67071,1],[67383,67391,1],[67414,67423,1],[67432,67455,1],[67462,67505,43],[67515,67583,1],[67590,67591,1],[67593,67638,45],[67641,67643,1],[67645,67646,1],[67670,67743,73],[67744,67750,1],[67760,67807,1],[67827,67830,3],[67831,67834,1],[67868,67870,1],[67898,67902,1],[67904,67967,1],[68024,68027,1],[68048,68049,1],[68100,68103,3],[68104,68107,1],[68116,68120,4],[68150,68151,1],[68155,68158,1],[68169,68175,1],[68185,68191,1],[68256,68287,1],[68327,68330,1],[68343,68351,1],[68406,68408,1],[68438,68439,1],[68467,68471,1],[68498,68504,1],[68509,68520,1],[68528,68607,1],[68681,68735,1],[68787,68799,1],[68851,68857,1],[68904,68911,1],[68922,69215,1],[69247,69290,43],[69294,69295,1],[69298,69372,1],[69416,69423,1],[69466,69487,1],[69514,69551,1],[69580,69599,1],[69623,69631,1],[69710,69713,1],[69750,69758,1],[69821,69827,6],[69828,69839,1],[69865,69871,1],[69882,69887,1],[69941,69960,19],[69961,69967,1],[70007,70015,1],[70112,70133,21],[70134,70143,1],[70162,70210,48],[70211,70271,1],[70279,70281,2],[70286,70302,16],[70314,70319,1],[70379,70383,1],[70394,70399,1],[70404,70413,9],[70414,70417,3],[70418,70441,23],[70449,70452,3],[70458,70469,11],[70470,70473,3],[70474,70478,4],[70479,70481,2],[70482,70486,1],[70488,70492,1],[70500,70501,1],[70509,70511,1],[70517,70655,1],[70748,70754,6],[70755,70783,1],[70856,70863,1],[70874,71039,1],[71094,71095,1],[71134,71167,1],[71237,71247,1],[71258,71263,1],[71277,71295,1],[71354,71359,1],[71370,71423,1],[71451,71452,1],[71468,71471,1],[71495,71679,1],[71740,71839,1],[71923,71934,1],[71943,71944,1],[71946,71947,1],[71956,71959,3],[71990,71993,3],[71994,72007,13],[72008,72015,1],[72026,72095,1],[72104,72105,1],[72152,72153,1],[72165,72191,1],[72264,72271,1],[72355,72367,1],[72441,72447,1],[72458,72703,1],[72713,72759,46],[72774,72783,1],[72813,72815,1],[72848,72849,1],[72872,72887,15],[72888,72959,1],[72967,72970,3],[73015,73017,1],[73019,73022,3],[73032,73039,1],[73050,73055,1],[73062,73065,3],[73103,73106,3],[73113,73119,1],[73130,73439,1],[73465,73471,1],[73489,73531,42],[73532,73533,1],[73562,73647,1],[73649,73663,1],[73714,73726,1],[74650,74751,1],[74863,74869,6],[74870,74879,1],[75076,77711,1],[77811,77823,1],[78896,78911,1],[78934,82943,1],[83527,92159,1],[92729,92735,1],[92767,92778,11],[92779,92781,1],[92863,92874,11],[92875,92879,1],[92910,92911,1],[92918,92927,1],[92998,93007,1],[93018,93026,8],[93048,93052,1],[93072,93759,1],[93851,93951,1],[94027,94030,1],[94088,94094,1],[94112,94175,1],[94181,94191,1],[94194,94207,1],[100344,100351,1],[101590,101631,1],[101641,110575,1],[110580,110588,8],[110591,110883,292],[110884,110897,1],[110899,110927,1],[110931,110932,1],[110934,110947,1],[110952,110959,1],[111356,113663,1],[113771,113775,1],[113789,113791,1],[113801,113807,1],[113818,113819,1],[113824,118527,1],[118574,118575,1],[118599,118607,1],[118724,118783,1],[119030,119039,1],[119079,119080,1],[119155,119162,1],[119275,119295,1],[119366,119487,1],[119508,119519,1],[119540,119551,1],[119639,119647,1],[119673,119807,1],[119893,119965,72],[119968,119969,1],[119971,119972,1],[119975,119976,1],[119981,119994,13],[119996,120004,8],[120070,120075,5],[120076,120085,9],[120093,120122,29],[120127,120133,6],[120135,120137,1],[120145,120486,341],[120487,120780,293],[120781,121484,703],[121485,121498,1],[121504,121520,16],[121521,122623,1],[122655,122660,1],[122667,122879,1],[122887,122905,18],[122906,122914,8],[122917,122923,6],[122924,122927,1],[122990,123022,1],[123024,123135,1],[123181,123183,1],[123198,123199,1],[123210,123213,1],[123216,123535,1],[123567,123583,1],[123642,123646,1],[123648,124111,1],[124154,124895,1],[124903,124908,5],[124911,124927,16],[125125,125126,1],[125143,125183,1],[125260,125263,1],[125274,125277,1],[125280,126064,1],[126133,126208,1],[126270,126463,1],[126468,126496,28],[126499,126501,2],[126502,126504,2],[126515,126520,5],[126522,126524,2],[126525,126529,1],[126531,126534,1],[126536,126540,2],[126544,126547,3],[126549,126550,1],[126552,126560,2],[126563,126565,2],[126566,126571,5],[126579,126589,5],[126591,126602,11],[126620,126624,1],[126628,126634,6],[126652,126703,1],[126706,126975,1],[127020,127023,1],[127124,127135,1],[127151,127152,1],[127168,127184,16],[127222,127231,1],[127406,127461,1],[127491,127503,1],[127548,127551,1],[127561,127567,1],[127570,127583,1],[127590,127743,1],[128728,128731,1],[128749,128751,1],[128765,128767,1],[128887,128890,1],[128986,128991,1],[129004,129007,1],[129009,129023,1],[129036,129039,1],[129096,129103,1],[129114,129119,1],[129160,129167,1],[129198,129199,1],[129202,129279,1],[129620,129631,1],[129646,129647,1],[129661,129663,1],[129673,129679,1],[129726,129734,8],[129735,129741,1],[129756,129759,1],[129769,129775,1],[129785,129791,1],[129939,129995,56],[129996,130031,1],[130042,131071,1],[173792,173823,1],[177978,177983,1],[178206,178207,1],[183970,183983,1],[191457,191471,1],[192094,194559,1],[195102,196607,1],[201547,201551,1],[205744,917759,1],[918e3,1114111,1]];static Cc=[[0,31,1],[127,159,1]];static Cf=[[173,1536,1363],[1537,1541,1],[1564,1757,193],[1807,2192,385],[2193,2274,81],[6158,8203,2045],[8204,8207,1],[8234,8238,1],[8288,8292,1],[8294,8303,1],[65279,65529,250],[65530,65531,1],[69821,69837,16],[78896,78911,1],[113824,113827,1],[119155,119162,1],[917505,917536,31],[917537,917631,1]];static Co=[[57344,63743,1],[983040,1048573,1],[1048576,1114109,1]];static Cs=[[55296,57343,1]];static L=[[65,90,1],[97,122,1],[170,181,11],[186,192,6],[193,214,1],[216,246,1],[248,705,1],[710,721,1],[736,740,1],[748,750,2],[880,884,1],[886,887,1],[890,893,1],[895,902,7],[904,906,1],[908,910,2],[911,929,1],[931,1013,1],[1015,1153,1],[1162,1327,1],[1329,1366,1],[1369,1376,7],[1377,1416,1],[1488,1514,1],[1519,1522,1],[1568,1610,1],[1646,1647,1],[1649,1747,1],[1749,1765,16],[1766,1774,8],[1775,1786,11],[1787,1788,1],[1791,1808,17],[1810,1839,1],[1869,1957,1],[1969,1994,25],[1995,2026,1],[2036,2037,1],[2042,2048,6],[2049,2069,1],[2074,2084,10],[2088,2112,24],[2113,2136,1],[2144,2154,1],[2160,2183,1],[2185,2190,1],[2208,2249,1],[2308,2361,1],[2365,2384,19],[2392,2401,1],[2417,2432,1],[2437,2444,1],[2447,2448,1],[2451,2472,1],[2474,2480,1],[2482,2486,4],[2487,2489,1],[2493,2510,17],[2524,2525,1],[2527,2529,1],[2544,2545,1],[2556,2565,9],[2566,2570,1],[2575,2576,1],[2579,2600,1],[2602,2608,1],[2610,2611,1],[2613,2614,1],[2616,2617,1],[2649,2652,1],[2654,2674,20],[2675,2676,1],[2693,2701,1],[2703,2705,1],[2707,2728,1],[2730,2736,1],[2738,2739,1],[2741,2745,1],[2749,2768,19],[2784,2785,1],[2809,2821,12],[2822,2828,1],[2831,2832,1],[2835,2856,1],[2858,2864,1],[2866,2867,1],[2869,2873,1],[2877,2908,31],[2909,2911,2],[2912,2913,1],[2929,2947,18],[2949,2954,1],[2958,2960,1],[2962,2965,1],[2969,2970,1],[2972,2974,2],[2975,2979,4],[2980,2984,4],[2985,2986,1],[2990,3001,1],[3024,3077,53],[3078,3084,1],[3086,3088,1],[3090,3112,1],[3114,3129,1],[3133,3160,27],[3161,3162,1],[3165,3168,3],[3169,3200,31],[3205,3212,1],[3214,3216,1],[3218,3240,1],[3242,3251,1],[3253,3257,1],[3261,3293,32],[3294,3296,2],[3297,3313,16],[3314,3332,18],[3333,3340,1],[3342,3344,1],[3346,3386,1],[3389,3406,17],[3412,3414,1],[3423,3425,1],[3450,3455,1],[3461,3478,1],[3482,3505,1],[3507,3515,1],[3517,3520,3],[3521,3526,1],[3585,3632,1],[3634,3635,1],[3648,3654,1],[3713,3714,1],[3716,3718,2],[3719,3722,1],[3724,3747,1],[3749,3751,2],[3752,3760,1],[3762,3763,1],[3773,3776,3],[3777,3780,1],[3782,3804,22],[3805,3807,1],[3840,3904,64],[3905,3911,1],[3913,3948,1],[3976,3980,1],[4096,4138,1],[4159,4176,17],[4177,4181,1],[4186,4189,1],[4193,4197,4],[4198,4206,8],[4207,4208,1],[4213,4225,1],[4238,4256,18],[4257,4293,1],[4295,4301,6],[4304,4346,1],[4348,4680,1],[4682,4685,1],[4688,4694,1],[4696,4698,2],[4699,4701,1],[4704,4744,1],[4746,4749,1],[4752,4784,1],[4786,4789,1],[4792,4798,1],[4800,4802,2],[4803,4805,1],[4808,4822,1],[4824,4880,1],[4882,4885,1],[4888,4954,1],[4992,5007,1],[5024,5109,1],[5112,5117,1],[5121,5740,1],[5743,5759,1],[5761,5786,1],[5792,5866,1],[5873,5880,1],[5888,5905,1],[5919,5937,1],[5952,5969,1],[5984,5996,1],[5998,6e3,1],[6016,6067,1],[6103,6108,5],[6176,6264,1],[6272,6276,1],[6279,6312,1],[6314,6320,6],[6321,6389,1],[6400,6430,1],[6480,6509,1],[6512,6516,1],[6528,6571,1],[6576,6601,1],[6656,6678,1],[6688,6740,1],[6823,6917,94],[6918,6963,1],[6981,6988,1],[7043,7072,1],[7086,7087,1],[7098,7141,1],[7168,7203,1],[7245,7247,1],[7258,7293,1],[7296,7304,1],[7312,7354,1],[7357,7359,1],[7401,7404,1],[7406,7411,1],[7413,7414,1],[7418,7424,6],[7425,7615,1],[7680,7957,1],[7960,7965,1],[7968,8005,1],[8008,8013,1],[8016,8023,1],[8025,8031,2],[8032,8061,1],[8064,8116,1],[8118,8124,1],[8126,8130,4],[8131,8132,1],[8134,8140,1],[8144,8147,1],[8150,8155,1],[8160,8172,1],[8178,8180,1],[8182,8188,1],[8305,8319,14],[8336,8348,1],[8450,8455,5],[8458,8467,1],[8469,8473,4],[8474,8477,1],[8484,8490,2],[8491,8493,1],[8495,8505,1],[8508,8511,1],[8517,8521,1],[8526,8579,53],[8580,11264,2684],[11265,11492,1],[11499,11502,1],[11506,11507,1],[11520,11557,1],[11559,11565,6],[11568,11623,1],[11631,11648,17],[11649,11670,1],[11680,11686,1],[11688,11694,1],[11696,11702,1],[11704,11710,1],[11712,11718,1],[11720,11726,1],[11728,11734,1],[11736,11742,1],[11823,12293,470],[12294,12337,43],[12338,12341,1],[12347,12348,1],[12353,12438,1],[12445,12447,1],[12449,12538,1],[12540,12543,1],[12549,12591,1],[12593,12686,1],[12704,12735,1],[12784,12799,1],[13312,19903,1],[19968,42124,1],[42192,42237,1],[42240,42508,1],[42512,42527,1],[42538,42539,1],[42560,42606,1],[42623,42653,1],[42656,42725,1],[42775,42783,1],[42786,42888,1],[42891,42954,1],[42960,42961,1],[42963,42965,2],[42966,42969,1],[42994,43009,1],[43011,43013,1],[43015,43018,1],[43020,43042,1],[43072,43123,1],[43138,43187,1],[43250,43255,1],[43259,43261,2],[43262,43274,12],[43275,43301,1],[43312,43334,1],[43360,43388,1],[43396,43442,1],[43471,43488,17],[43489,43492,1],[43494,43503,1],[43514,43518,1],[43520,43560,1],[43584,43586,1],[43588,43595,1],[43616,43638,1],[43642,43646,4],[43647,43695,1],[43697,43701,4],[43702,43705,3],[43706,43709,1],[43712,43714,2],[43739,43741,1],[43744,43754,1],[43762,43764,1],[43777,43782,1],[43785,43790,1],[43793,43798,1],[43808,43814,1],[43816,43822,1],[43824,43866,1],[43868,43881,1],[43888,44002,1],[44032,55203,1],[55216,55238,1],[55243,55291,1],[63744,64109,1],[64112,64217,1],[64256,64262,1],[64275,64279,1],[64285,64287,2],[64288,64296,1],[64298,64310,1],[64312,64316,1],[64318,64320,2],[64321,64323,2],[64324,64326,2],[64327,64433,1],[64467,64829,1],[64848,64911,1],[64914,64967,1],[65008,65019,1],[65136,65140,1],[65142,65276,1],[65313,65338,1],[65345,65370,1],[65382,65470,1],[65474,65479,1],[65482,65487,1],[65490,65495,1],[65498,65500,1],[65536,65547,1],[65549,65574,1],[65576,65594,1],[65596,65597,1],[65599,65613,1],[65616,65629,1],[65664,65786,1],[66176,66204,1],[66208,66256,1],[66304,66335,1],[66349,66368,1],[66370,66377,1],[66384,66421,1],[66432,66461,1],[66464,66499,1],[66504,66511,1],[66560,66717,1],[66736,66771,1],[66776,66811,1],[66816,66855,1],[66864,66915,1],[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1],[67072,67382,1],[67392,67413,1],[67424,67431,1],[67456,67461,1],[67463,67504,1],[67506,67514,1],[67584,67589,1],[67592,67594,2],[67595,67637,1],[67639,67640,1],[67644,67647,3],[67648,67669,1],[67680,67702,1],[67712,67742,1],[67808,67826,1],[67828,67829,1],[67840,67861,1],[67872,67897,1],[67968,68023,1],[68030,68031,1],[68096,68112,16],[68113,68115,1],[68117,68119,1],[68121,68149,1],[68192,68220,1],[68224,68252,1],[68288,68295,1],[68297,68324,1],[68352,68405,1],[68416,68437,1],[68448,68466,1],[68480,68497,1],[68608,68680,1],[68736,68786,1],[68800,68850,1],[68864,68899,1],[69248,69289,1],[69296,69297,1],[69376,69404,1],[69415,69424,9],[69425,69445,1],[69488,69505,1],[69552,69572,1],[69600,69622,1],[69635,69687,1],[69745,69746,1],[69749,69763,14],[69764,69807,1],[69840,69864,1],[69891,69926,1],[69956,69959,3],[69968,70002,1],[70006,70019,13],[70020,70066,1],[70081,70084,1],[70106,70108,2],[70144,70161,1],[70163,70187,1],[70207,70208,1],[70272,70278,1],[70280,70282,2],[70283,70285,1],[70287,70301,1],[70303,70312,1],[70320,70366,1],[70405,70412,1],[70415,70416,1],[70419,70440,1],[70442,70448,1],[70450,70451,1],[70453,70457,1],[70461,70480,19],[70493,70497,1],[70656,70708,1],[70727,70730,1],[70751,70753,1],[70784,70831,1],[70852,70853,1],[70855,71040,185],[71041,71086,1],[71128,71131,1],[71168,71215,1],[71236,71296,60],[71297,71338,1],[71352,71424,72],[71425,71450,1],[71488,71494,1],[71680,71723,1],[71840,71903,1],[71935,71942,1],[71945,71948,3],[71949,71955,1],[71957,71958,1],[71960,71983,1],[71999,72001,2],[72096,72103,1],[72106,72144,1],[72161,72163,2],[72192,72203,11],[72204,72242,1],[72250,72272,22],[72284,72329,1],[72349,72368,19],[72369,72440,1],[72704,72712,1],[72714,72750,1],[72768,72818,50],[72819,72847,1],[72960,72966,1],[72968,72969,1],[72971,73008,1],[73030,73056,26],[73057,73061,1],[73063,73064,1],[73066,73097,1],[73112,73440,328],[73441,73458,1],[73474,73476,2],[73477,73488,1],[73490,73523,1],[73648,73728,80],[73729,74649,1],[74880,75075,1],[77712,77808,1],[77824,78895,1],[78913,78918,1],[82944,83526,1],[92160,92728,1],[92736,92766,1],[92784,92862,1],[92880,92909,1],[92928,92975,1],[92992,92995,1],[93027,93047,1],[93053,93071,1],[93760,93823,1],[93952,94026,1],[94032,94099,67],[94100,94111,1],[94176,94177,1],[94179,94208,29],[94209,100343,1],[100352,101589,1],[101632,101640,1],[110576,110579,1],[110581,110587,1],[110589,110590,1],[110592,110882,1],[110898,110928,30],[110929,110930,1],[110933,110948,15],[110949,110951,1],[110960,111355,1],[113664,113770,1],[113776,113788,1],[113792,113800,1],[113808,113817,1],[119808,119892,1],[119894,119964,1],[119966,119967,1],[119970,119973,3],[119974,119977,3],[119978,119980,1],[119982,119993,1],[119995,119997,2],[119998,120003,1],[120005,120069,1],[120071,120074,1],[120077,120084,1],[120086,120092,1],[120094,120121,1],[120123,120126,1],[120128,120132,1],[120134,120138,4],[120139,120144,1],[120146,120485,1],[120488,120512,1],[120514,120538,1],[120540,120570,1],[120572,120596,1],[120598,120628,1],[120630,120654,1],[120656,120686,1],[120688,120712,1],[120714,120744,1],[120746,120770,1],[120772,120779,1],[122624,122654,1],[122661,122666,1],[122928,122989,1],[123136,123180,1],[123191,123197,1],[123214,123536,322],[123537,123565,1],[123584,123627,1],[124112,124139,1],[124896,124902,1],[124904,124907,1],[124909,124910,1],[124912,124926,1],[124928,125124,1],[125184,125251,1],[125259,126464,1205],[126465,126467,1],[126469,126495,1],[126497,126498,1],[126500,126503,3],[126505,126514,1],[126516,126519,1],[126521,126523,2],[126530,126535,5],[126537,126541,2],[126542,126543,1],[126545,126546,1],[126548,126551,3],[126553,126561,2],[126562,126564,2],[126567,126570,1],[126572,126578,1],[126580,126583,1],[126585,126588,1],[126590,126592,2],[126593,126601,1],[126603,126619,1],[126625,126627,1],[126629,126633,1],[126635,126651,1],[131072,173791,1],[173824,177977,1],[177984,178205,1],[178208,183969,1],[183984,191456,1],[191472,192093,1],[194560,195101,1],[196608,201546,1],[201552,205743,1]];static foldL=[[837,837,1]];static Ll=[[97,122,1],[181,223,42],[224,246,1],[248,255,1],[257,311,2],[312,328,2],[329,375,2],[378,382,2],[383,384,1],[387,389,2],[392,396,4],[397,402,5],[405,409,4],[410,411,1],[414,417,3],[419,421,2],[424,426,2],[427,429,2],[432,436,4],[438,441,3],[442,445,3],[446,447,1],[454,460,3],[462,476,2],[477,495,2],[496,499,3],[501,505,4],[507,563,2],[564,569,1],[572,575,3],[576,578,2],[583,591,2],[592,659,1],[661,687,1],[881,883,2],[887,891,4],[892,893,1],[912,940,28],[941,974,1],[976,977,1],[981,983,1],[985,1007,2],[1008,1011,1],[1013,1019,3],[1020,1072,52],[1073,1119,1],[1121,1153,2],[1163,1215,2],[1218,1230,2],[1231,1327,2],[1376,1416,1],[4304,4346,1],[4349,4351,1],[5112,5117,1],[7296,7304,1],[7424,7467,1],[7531,7543,1],[7545,7578,1],[7681,7829,2],[7830,7837,1],[7839,7935,2],[7936,7943,1],[7952,7957,1],[7968,7975,1],[7984,7991,1],[8e3,8005,1],[8016,8023,1],[8032,8039,1],[8048,8061,1],[8064,8071,1],[8080,8087,1],[8096,8103,1],[8112,8116,1],[8118,8119,1],[8126,8130,4],[8131,8132,1],[8134,8135,1],[8144,8147,1],[8150,8151,1],[8160,8167,1],[8178,8180,1],[8182,8183,1],[8458,8462,4],[8463,8467,4],[8495,8505,5],[8508,8509,1],[8518,8521,1],[8526,8580,54],[11312,11359,1],[11361,11365,4],[11366,11372,2],[11377,11379,2],[11380,11382,2],[11383,11387,1],[11393,11491,2],[11492,11500,8],[11502,11507,5],[11520,11557,1],[11559,11565,6],[42561,42605,2],[42625,42651,2],[42787,42799,2],[42800,42801,1],[42803,42865,2],[42866,42872,1],[42874,42876,2],[42879,42887,2],[42892,42894,2],[42897,42899,2],[42900,42901,1],[42903,42921,2],[42927,42933,6],[42935,42947,2],[42952,42954,2],[42961,42969,2],[42998,43002,4],[43824,43866,1],[43872,43880,1],[43888,43967,1],[64256,64262,1],[64275,64279,1],[65345,65370,1],[66600,66639,1],[66776,66811,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1],[68800,68850,1],[71872,71903,1],[93792,93823,1],[119834,119859,1],[119886,119892,1],[119894,119911,1],[119938,119963,1],[119990,119993,1],[119995,119997,2],[119998,120003,1],[120005,120015,1],[120042,120067,1],[120094,120119,1],[120146,120171,1],[120198,120223,1],[120250,120275,1],[120302,120327,1],[120354,120379,1],[120406,120431,1],[120458,120485,1],[120514,120538,1],[120540,120545,1],[120572,120596,1],[120598,120603,1],[120630,120654,1],[120656,120661,1],[120688,120712,1],[120714,120719,1],[120746,120770,1],[120772,120777,1],[120779,122624,1845],[122625,122633,1],[122635,122654,1],[122661,122666,1],[125218,125251,1]];static foldLl=[[65,90,1],[192,214,1],[216,222,1],[256,302,2],[306,310,2],[313,327,2],[330,376,2],[377,381,2],[385,386,1],[388,390,2],[391,393,2],[394,395,1],[398,401,1],[403,404,1],[406,408,1],[412,413,1],[415,416,1],[418,422,2],[423,425,2],[428,430,2],[431,433,2],[434,435,1],[437,439,2],[440,444,4],[452,453,1],[455,456,1],[458,459,1],[461,475,2],[478,494,2],[497,498,1],[500,502,2],[503,504,1],[506,562,2],[570,571,1],[573,574,1],[577,579,2],[580,582,1],[584,590,2],[837,880,43],[882,886,4],[895,902,7],[904,906,1],[908,910,2],[911,913,2],[914,929,1],[931,939,1],[975,984,9],[986,1006,2],[1012,1015,3],[1017,1018,1],[1021,1071,1],[1120,1152,2],[1162,1216,2],[1217,1229,2],[1232,1326,2],[1329,1366,1],[4256,4293,1],[4295,4301,6],[5024,5109,1],[7312,7354,1],[7357,7359,1],[7680,7828,2],[7838,7934,2],[7944,7951,1],[7960,7965,1],[7976,7983,1],[7992,7999,1],[8008,8013,1],[8025,8031,2],[8040,8047,1],[8072,8079,1],[8088,8095,1],[8104,8111,1],[8120,8124,1],[8136,8140,1],[8152,8155,1],[8168,8172,1],[8184,8188,1],[8486,8490,4],[8491,8498,7],[8579,11264,2685],[11265,11311,1],[11360,11362,2],[11363,11364,1],[11367,11373,2],[11374,11376,1],[11378,11381,3],[11390,11392,1],[11394,11490,2],[11499,11501,2],[11506,42560,31054],[42562,42604,2],[42624,42650,2],[42786,42798,2],[42802,42862,2],[42873,42877,2],[42878,42886,2],[42891,42893,2],[42896,42898,2],[42902,42922,2],[42923,42926,1],[42928,42932,1],[42934,42948,2],[42949,42951,1],[42953,42960,7],[42966,42968,2],[42997,65313,22316],[65314,65338,1],[66560,66599,1],[66736,66771,1],[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[68736,68786,1],[71840,71871,1],[93760,93791,1],[125184,125217,1]];static Lm=[[688,705,1],[710,721,1],[736,740,1],[748,750,2],[884,890,6],[1369,1600,231],[1765,1766,1],[2036,2037,1],[2042,2074,32],[2084,2088,4],[2249,2417,168],[3654,3782,128],[4348,6103,1755],[6211,6823,612],[7288,7293,1],[7468,7530,1],[7544,7579,35],[7580,7615,1],[8305,8319,14],[8336,8348,1],[11388,11389,1],[11631,11823,192],[12293,12337,44],[12338,12341,1],[12347,12445,98],[12446,12540,94],[12541,12542,1],[40981,42232,1251],[42233,42237,1],[42508,42623,115],[42652,42653,1],[42775,42783,1],[42864,42888,24],[42994,42996,1],[43e3,43001,1],[43471,43494,23],[43632,43741,109],[43763,43764,1],[43868,43871,1],[43881,65392,21511],[65438,65439,1],[67456,67461,1],[67463,67504,1],[67506,67514,1],[92992,92995,1],[94099,94111,1],[94176,94177,1],[94179,110576,16397],[110577,110579,1],[110581,110587,1],[110589,110590,1],[122928,122989,1],[123191,123197,1],[124139,125259,1120]];static Lo=[[170,186,16],[443,448,5],[449,451,1],[660,1488,828],[1489,1514,1],[1519,1522,1],[1568,1599,1],[1601,1610,1],[1646,1647,1],[1649,1747,1],[1749,1774,25],[1775,1786,11],[1787,1788,1],[1791,1808,17],[1810,1839,1],[1869,1957,1],[1969,1994,25],[1995,2026,1],[2048,2069,1],[2112,2136,1],[2144,2154,1],[2160,2183,1],[2185,2190,1],[2208,2248,1],[2308,2361,1],[2365,2384,19],[2392,2401,1],[2418,2432,1],[2437,2444,1],[2447,2448,1],[2451,2472,1],[2474,2480,1],[2482,2486,4],[2487,2489,1],[2493,2510,17],[2524,2525,1],[2527,2529,1],[2544,2545,1],[2556,2565,9],[2566,2570,1],[2575,2576,1],[2579,2600,1],[2602,2608,1],[2610,2611,1],[2613,2614,1],[2616,2617,1],[2649,2652,1],[2654,2674,20],[2675,2676,1],[2693,2701,1],[2703,2705,1],[2707,2728,1],[2730,2736,1],[2738,2739,1],[2741,2745,1],[2749,2768,19],[2784,2785,1],[2809,2821,12],[2822,2828,1],[2831,2832,1],[2835,2856,1],[2858,2864,1],[2866,2867,1],[2869,2873,1],[2877,2908,31],[2909,2911,2],[2912,2913,1],[2929,2947,18],[2949,2954,1],[2958,2960,1],[2962,2965,1],[2969,2970,1],[2972,2974,2],[2975,2979,4],[2980,2984,4],[2985,2986,1],[2990,3001,1],[3024,3077,53],[3078,3084,1],[3086,3088,1],[3090,3112,1],[3114,3129,1],[3133,3160,27],[3161,3162,1],[3165,3168,3],[3169,3200,31],[3205,3212,1],[3214,3216,1],[3218,3240,1],[3242,3251,1],[3253,3257,1],[3261,3293,32],[3294,3296,2],[3297,3313,16],[3314,3332,18],[3333,3340,1],[3342,3344,1],[3346,3386,1],[3389,3406,17],[3412,3414,1],[3423,3425,1],[3450,3455,1],[3461,3478,1],[3482,3505,1],[3507,3515,1],[3517,3520,3],[3521,3526,1],[3585,3632,1],[3634,3635,1],[3648,3653,1],[3713,3714,1],[3716,3718,2],[3719,3722,1],[3724,3747,1],[3749,3751,2],[3752,3760,1],[3762,3763,1],[3773,3776,3],[3777,3780,1],[3804,3807,1],[3840,3904,64],[3905,3911,1],[3913,3948,1],[3976,3980,1],[4096,4138,1],[4159,4176,17],[4177,4181,1],[4186,4189,1],[4193,4197,4],[4198,4206,8],[4207,4208,1],[4213,4225,1],[4238,4352,114],[4353,4680,1],[4682,4685,1],[4688,4694,1],[4696,4698,2],[4699,4701,1],[4704,4744,1],[4746,4749,1],[4752,4784,1],[4786,4789,1],[4792,4798,1],[4800,4802,2],[4803,4805,1],[4808,4822,1],[4824,4880,1],[4882,4885,1],[4888,4954,1],[4992,5007,1],[5121,5740,1],[5743,5759,1],[5761,5786,1],[5792,5866,1],[5873,5880,1],[5888,5905,1],[5919,5937,1],[5952,5969,1],[5984,5996,1],[5998,6e3,1],[6016,6067,1],[6108,6176,68],[6177,6210,1],[6212,6264,1],[6272,6276,1],[6279,6312,1],[6314,6320,6],[6321,6389,1],[6400,6430,1],[6480,6509,1],[6512,6516,1],[6528,6571,1],[6576,6601,1],[6656,6678,1],[6688,6740,1],[6917,6963,1],[6981,6988,1],[7043,7072,1],[7086,7087,1],[7098,7141,1],[7168,7203,1],[7245,7247,1],[7258,7287,1],[7401,7404,1],[7406,7411,1],[7413,7414,1],[7418,8501,1083],[8502,8504,1],[11568,11623,1],[11648,11670,1],[11680,11686,1],[11688,11694,1],[11696,11702,1],[11704,11710,1],[11712,11718,1],[11720,11726,1],[11728,11734,1],[11736,11742,1],[12294,12348,54],[12353,12438,1],[12447,12449,2],[12450,12538,1],[12543,12549,6],[12550,12591,1],[12593,12686,1],[12704,12735,1],[12784,12799,1],[13312,19903,1],[19968,40980,1],[40982,42124,1],[42192,42231,1],[42240,42507,1],[42512,42527,1],[42538,42539,1],[42606,42656,50],[42657,42725,1],[42895,42999,104],[43003,43009,1],[43011,43013,1],[43015,43018,1],[43020,43042,1],[43072,43123,1],[43138,43187,1],[43250,43255,1],[43259,43261,2],[43262,43274,12],[43275,43301,1],[43312,43334,1],[43360,43388,1],[43396,43442,1],[43488,43492,1],[43495,43503,1],[43514,43518,1],[43520,43560,1],[43584,43586,1],[43588,43595,1],[43616,43631,1],[43633,43638,1],[43642,43646,4],[43647,43695,1],[43697,43701,4],[43702,43705,3],[43706,43709,1],[43712,43714,2],[43739,43740,1],[43744,43754,1],[43762,43777,15],[43778,43782,1],[43785,43790,1],[43793,43798,1],[43808,43814,1],[43816,43822,1],[43968,44002,1],[44032,55203,1],[55216,55238,1],[55243,55291,1],[63744,64109,1],[64112,64217,1],[64285,64287,2],[64288,64296,1],[64298,64310,1],[64312,64316,1],[64318,64320,2],[64321,64323,2],[64324,64326,2],[64327,64433,1],[64467,64829,1],[64848,64911,1],[64914,64967,1],[65008,65019,1],[65136,65140,1],[65142,65276,1],[65382,65391,1],[65393,65437,1],[65440,65470,1],[65474,65479,1],[65482,65487,1],[65490,65495,1],[65498,65500,1],[65536,65547,1],[65549,65574,1],[65576,65594,1],[65596,65597,1],[65599,65613,1],[65616,65629,1],[65664,65786,1],[66176,66204,1],[66208,66256,1],[66304,66335,1],[66349,66368,1],[66370,66377,1],[66384,66421,1],[66432,66461,1],[66464,66499,1],[66504,66511,1],[66640,66717,1],[66816,66855,1],[66864,66915,1],[67072,67382,1],[67392,67413,1],[67424,67431,1],[67584,67589,1],[67592,67594,2],[67595,67637,1],[67639,67640,1],[67644,67647,3],[67648,67669,1],[67680,67702,1],[67712,67742,1],[67808,67826,1],[67828,67829,1],[67840,67861,1],[67872,67897,1],[67968,68023,1],[68030,68031,1],[68096,68112,16],[68113,68115,1],[68117,68119,1],[68121,68149,1],[68192,68220,1],[68224,68252,1],[68288,68295,1],[68297,68324,1],[68352,68405,1],[68416,68437,1],[68448,68466,1],[68480,68497,1],[68608,68680,1],[68864,68899,1],[69248,69289,1],[69296,69297,1],[69376,69404,1],[69415,69424,9],[69425,69445,1],[69488,69505,1],[69552,69572,1],[69600,69622,1],[69635,69687,1],[69745,69746,1],[69749,69763,14],[69764,69807,1],[69840,69864,1],[69891,69926,1],[69956,69959,3],[69968,70002,1],[70006,70019,13],[70020,70066,1],[70081,70084,1],[70106,70108,2],[70144,70161,1],[70163,70187,1],[70207,70208,1],[70272,70278,1],[70280,70282,2],[70283,70285,1],[70287,70301,1],[70303,70312,1],[70320,70366,1],[70405,70412,1],[70415,70416,1],[70419,70440,1],[70442,70448,1],[70450,70451,1],[70453,70457,1],[70461,70480,19],[70493,70497,1],[70656,70708,1],[70727,70730,1],[70751,70753,1],[70784,70831,1],[70852,70853,1],[70855,71040,185],[71041,71086,1],[71128,71131,1],[71168,71215,1],[71236,71296,60],[71297,71338,1],[71352,71424,72],[71425,71450,1],[71488,71494,1],[71680,71723,1],[71935,71942,1],[71945,71948,3],[71949,71955,1],[71957,71958,1],[71960,71983,1],[71999,72001,2],[72096,72103,1],[72106,72144,1],[72161,72163,2],[72192,72203,11],[72204,72242,1],[72250,72272,22],[72284,72329,1],[72349,72368,19],[72369,72440,1],[72704,72712,1],[72714,72750,1],[72768,72818,50],[72819,72847,1],[72960,72966,1],[72968,72969,1],[72971,73008,1],[73030,73056,26],[73057,73061,1],[73063,73064,1],[73066,73097,1],[73112,73440,328],[73441,73458,1],[73474,73476,2],[73477,73488,1],[73490,73523,1],[73648,73728,80],[73729,74649,1],[74880,75075,1],[77712,77808,1],[77824,78895,1],[78913,78918,1],[82944,83526,1],[92160,92728,1],[92736,92766,1],[92784,92862,1],[92880,92909,1],[92928,92975,1],[93027,93047,1],[93053,93071,1],[93952,94026,1],[94032,94208,176],[94209,100343,1],[100352,101589,1],[101632,101640,1],[110592,110882,1],[110898,110928,30],[110929,110930,1],[110933,110948,15],[110949,110951,1],[110960,111355,1],[113664,113770,1],[113776,113788,1],[113792,113800,1],[113808,113817,1],[122634,123136,502],[123137,123180,1],[123214,123536,322],[123537,123565,1],[123584,123627,1],[124112,124138,1],[124896,124902,1],[124904,124907,1],[124909,124910,1],[124912,124926,1],[124928,125124,1],[126464,126467,1],[126469,126495,1],[126497,126498,1],[126500,126503,3],[126505,126514,1],[126516,126519,1],[126521,126523,2],[126530,126535,5],[126537,126541,2],[126542,126543,1],[126545,126546,1],[126548,126551,3],[126553,126561,2],[126562,126564,2],[126567,126570,1],[126572,126578,1],[126580,126583,1],[126585,126588,1],[126590,126592,2],[126593,126601,1],[126603,126619,1],[126625,126627,1],[126629,126633,1],[126635,126651,1],[131072,173791,1],[173824,177977,1],[177984,178205,1],[178208,183969,1],[183984,191456,1],[191472,192093,1],[194560,195101,1],[196608,201546,1],[201552,205743,1]];static Lt=[[453,459,3],[498,8072,7574],[8073,8079,1],[8088,8095,1],[8104,8111,1],[8124,8140,16],[8188,8188,1]];static foldLt=[[452,454,2],[455,457,2],[458,460,2],[497,499,2],[8064,8071,1],[8080,8087,1],[8096,8103,1],[8115,8131,16],[8179,8179,1]];static Lu=[[65,90,1],[192,214,1],[216,222,1],[256,310,2],[313,327,2],[330,376,2],[377,381,2],[385,386,1],[388,390,2],[391,393,2],[394,395,1],[398,401,1],[403,404,1],[406,408,1],[412,413,1],[415,416,1],[418,422,2],[423,425,2],[428,430,2],[431,433,2],[434,435,1],[437,439,2],[440,444,4],[452,461,3],[463,475,2],[478,494,2],[497,500,3],[502,504,1],[506,562,2],[570,571,1],[573,574,1],[577,579,2],[580,582,1],[584,590,2],[880,882,2],[886,895,9],[902,904,2],[905,906,1],[908,910,2],[911,913,2],[914,929,1],[931,939,1],[975,978,3],[979,980,1],[984,1006,2],[1012,1015,3],[1017,1018,1],[1021,1071,1],[1120,1152,2],[1162,1216,2],[1217,1229,2],[1232,1326,2],[1329,1366,1],[4256,4293,1],[4295,4301,6],[5024,5109,1],[7312,7354,1],[7357,7359,1],[7680,7828,2],[7838,7934,2],[7944,7951,1],[7960,7965,1],[7976,7983,1],[7992,7999,1],[8008,8013,1],[8025,8031,2],[8040,8047,1],[8120,8123,1],[8136,8139,1],[8152,8155,1],[8168,8172,1],[8184,8187,1],[8450,8455,5],[8459,8461,1],[8464,8466,1],[8469,8473,4],[8474,8477,1],[8484,8490,2],[8491,8493,1],[8496,8499,1],[8510,8511,1],[8517,8579,62],[11264,11311,1],[11360,11362,2],[11363,11364,1],[11367,11373,2],[11374,11376,1],[11378,11381,3],[11390,11392,1],[11394,11490,2],[11499,11501,2],[11506,42560,31054],[42562,42604,2],[42624,42650,2],[42786,42798,2],[42802,42862,2],[42873,42877,2],[42878,42886,2],[42891,42893,2],[42896,42898,2],[42902,42922,2],[42923,42926,1],[42928,42932,1],[42934,42948,2],[42949,42951,1],[42953,42960,7],[42966,42968,2],[42997,65313,22316],[65314,65338,1],[66560,66599,1],[66736,66771,1],[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[68736,68786,1],[71840,71871,1],[93760,93791,1],[119808,119833,1],[119860,119885,1],[119912,119937,1],[119964,119966,2],[119967,119973,3],[119974,119977,3],[119978,119980,1],[119982,119989,1],[120016,120041,1],[120068,120069,1],[120071,120074,1],[120077,120084,1],[120086,120092,1],[120120,120121,1],[120123,120126,1],[120128,120132,1],[120134,120138,4],[120139,120144,1],[120172,120197,1],[120224,120249,1],[120276,120301,1],[120328,120353,1],[120380,120405,1],[120432,120457,1],[120488,120512,1],[120546,120570,1],[120604,120628,1],[120662,120686,1],[120720,120744,1],[120778,125184,4406],[125185,125217,1]];static Upper=this.Lu;static foldLu=[[97,122,1],[181,223,42],[224,246,1],[248,255,1],[257,303,2],[307,311,2],[314,328,2],[331,375,2],[378,382,2],[383,384,1],[387,389,2],[392,396,4],[402,405,3],[409,410,1],[414,417,3],[419,421,2],[424,429,5],[432,436,4],[438,441,3],[445,447,2],[453,454,1],[456,457,1],[459,460,1],[462,476,2],[477,495,2],[498,499,1],[501,505,4],[507,543,2],[547,563,2],[572,575,3],[576,578,2],[583,591,2],[592,596,1],[598,599,1],[601,603,2],[604,608,4],[609,613,2],[614,616,2],[617,620,1],[623,625,2],[626,629,3],[637,640,3],[642,643,1],[647,652,1],[658,669,11],[670,837,167],[881,883,2],[887,891,4],[892,893,1],[940,943,1],[945,974,1],[976,977,1],[981,983,1],[985,1007,2],[1008,1011,1],[1013,1019,3],[1072,1119,1],[1121,1153,2],[1163,1215,2],[1218,1230,2],[1231,1327,2],[1377,1414,1],[4304,4346,1],[4349,4351,1],[5112,5117,1],[7296,7304,1],[7545,7549,4],[7566,7681,115],[7683,7829,2],[7835,7841,6],[7843,7935,2],[7936,7943,1],[7952,7957,1],[7968,7975,1],[7984,7991,1],[8e3,8005,1],[8017,8023,2],[8032,8039,1],[8048,8061,1],[8112,8113,1],[8126,8144,18],[8145,8160,15],[8161,8165,4],[8526,8580,54],[11312,11359,1],[11361,11365,4],[11366,11372,2],[11379,11382,3],[11393,11491,2],[11500,11502,2],[11507,11520,13],[11521,11557,1],[11559,11565,6],[42561,42605,2],[42625,42651,2],[42787,42799,2],[42803,42863,2],[42874,42876,2],[42879,42887,2],[42892,42897,5],[42899,42900,1],[42903,42921,2],[42933,42947,2],[42952,42954,2],[42961,42967,6],[42969,42998,29],[43859,43888,29],[43889,43967,1],[65345,65370,1],[66600,66639,1],[66776,66811,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1],[68800,68850,1],[71872,71903,1],[93792,93823,1],[125218,125251,1]];static M=[[768,879,1],[1155,1161,1],[1425,1469,1],[1471,1473,2],[1474,1476,2],[1477,1479,2],[1552,1562,1],[1611,1631,1],[1648,1750,102],[1751,1756,1],[1759,1764,1],[1767,1768,1],[1770,1773,1],[1809,1840,31],[1841,1866,1],[1958,1968,1],[2027,2035,1],[2045,2070,25],[2071,2073,1],[2075,2083,1],[2085,2087,1],[2089,2093,1],[2137,2139,1],[2200,2207,1],[2250,2273,1],[2275,2307,1],[2362,2364,1],[2366,2383,1],[2385,2391,1],[2402,2403,1],[2433,2435,1],[2492,2494,2],[2495,2500,1],[2503,2504,1],[2507,2509,1],[2519,2530,11],[2531,2558,27],[2561,2563,1],[2620,2622,2],[2623,2626,1],[2631,2632,1],[2635,2637,1],[2641,2672,31],[2673,2677,4],[2689,2691,1],[2748,2750,2],[2751,2757,1],[2759,2761,1],[2763,2765,1],[2786,2787,1],[2810,2815,1],[2817,2819,1],[2876,2878,2],[2879,2884,1],[2887,2888,1],[2891,2893,1],[2901,2903,1],[2914,2915,1],[2946,3006,60],[3007,3010,1],[3014,3016,1],[3018,3021,1],[3031,3072,41],[3073,3076,1],[3132,3134,2],[3135,3140,1],[3142,3144,1],[3146,3149,1],[3157,3158,1],[3170,3171,1],[3201,3203,1],[3260,3262,2],[3263,3268,1],[3270,3272,1],[3274,3277,1],[3285,3286,1],[3298,3299,1],[3315,3328,13],[3329,3331,1],[3387,3388,1],[3390,3396,1],[3398,3400,1],[3402,3405,1],[3415,3426,11],[3427,3457,30],[3458,3459,1],[3530,3535,5],[3536,3540,1],[3542,3544,2],[3545,3551,1],[3570,3571,1],[3633,3636,3],[3637,3642,1],[3655,3662,1],[3761,3764,3],[3765,3772,1],[3784,3790,1],[3864,3865,1],[3893,3897,2],[3902,3903,1],[3953,3972,1],[3974,3975,1],[3981,3991,1],[3993,4028,1],[4038,4139,101],[4140,4158,1],[4182,4185,1],[4190,4192,1],[4194,4196,1],[4199,4205,1],[4209,4212,1],[4226,4237,1],[4239,4250,11],[4251,4253,1],[4957,4959,1],[5906,5909,1],[5938,5940,1],[5970,5971,1],[6002,6003,1],[6068,6099,1],[6109,6155,46],[6156,6157,1],[6159,6277,118],[6278,6313,35],[6432,6443,1],[6448,6459,1],[6679,6683,1],[6741,6750,1],[6752,6780,1],[6783,6832,49],[6833,6862,1],[6912,6916,1],[6964,6980,1],[7019,7027,1],[7040,7042,1],[7073,7085,1],[7142,7155,1],[7204,7223,1],[7376,7378,1],[7380,7400,1],[7405,7412,7],[7415,7417,1],[7616,7679,1],[8400,8432,1],[11503,11505,1],[11647,11744,97],[11745,11775,1],[12330,12335,1],[12441,12442,1],[42607,42610,1],[42612,42621,1],[42654,42655,1],[42736,42737,1],[43010,43014,4],[43019,43043,24],[43044,43047,1],[43052,43136,84],[43137,43188,51],[43189,43205,1],[43232,43249,1],[43263,43302,39],[43303,43309,1],[43335,43347,1],[43392,43395,1],[43443,43456,1],[43493,43561,68],[43562,43574,1],[43587,43596,9],[43597,43643,46],[43644,43645,1],[43696,43698,2],[43699,43700,1],[43703,43704,1],[43710,43711,1],[43713,43755,42],[43756,43759,1],[43765,43766,1],[44003,44010,1],[44012,44013,1],[64286,65024,738],[65025,65039,1],[65056,65071,1],[66045,66272,227],[66422,66426,1],[68097,68099,1],[68101,68102,1],[68108,68111,1],[68152,68154,1],[68159,68325,166],[68326,68900,574],[68901,68903,1],[69291,69292,1],[69373,69375,1],[69446,69456,1],[69506,69509,1],[69632,69634,1],[69688,69702,1],[69744,69747,3],[69748,69759,11],[69760,69762,1],[69808,69818,1],[69826,69888,62],[69889,69890,1],[69927,69940,1],[69957,69958,1],[70003,70016,13],[70017,70018,1],[70067,70080,1],[70089,70092,1],[70094,70095,1],[70188,70199,1],[70206,70209,3],[70367,70378,1],[70400,70403,1],[70459,70460,1],[70462,70468,1],[70471,70472,1],[70475,70477,1],[70487,70498,11],[70499,70502,3],[70503,70508,1],[70512,70516,1],[70709,70726,1],[70750,70832,82],[70833,70851,1],[71087,71093,1],[71096,71104,1],[71132,71133,1],[71216,71232,1],[71339,71351,1],[71453,71467,1],[71724,71738,1],[71984,71989,1],[71991,71992,1],[71995,71998,1],[72e3,72002,2],[72003,72145,142],[72146,72151,1],[72154,72160,1],[72164,72193,29],[72194,72202,1],[72243,72249,1],[72251,72254,1],[72263,72273,10],[72274,72283,1],[72330,72345,1],[72751,72758,1],[72760,72767,1],[72850,72871,1],[72873,72886,1],[73009,73014,1],[73018,73020,2],[73021,73023,2],[73024,73029,1],[73031,73098,67],[73099,73102,1],[73104,73105,1],[73107,73111,1],[73459,73462,1],[73472,73473,1],[73475,73524,49],[73525,73530,1],[73534,73538,1],[78912,78919,7],[78920,78933,1],[92912,92916,1],[92976,92982,1],[94031,94033,2],[94034,94087,1],[94095,94098,1],[94180,94192,12],[94193,113821,19628],[113822,118528,4706],[118529,118573,1],[118576,118598,1],[119141,119145,1],[119149,119154,1],[119163,119170,1],[119173,119179,1],[119210,119213,1],[119362,119364,1],[121344,121398,1],[121403,121452,1],[121461,121476,15],[121499,121503,1],[121505,121519,1],[122880,122886,1],[122888,122904,1],[122907,122913,1],[122915,122916,1],[122918,122922,1],[123023,123184,161],[123185,123190,1],[123566,123628,62],[123629,123631,1],[124140,124143,1],[125136,125142,1],[125252,125258,1],[917760,917999,1]];static foldM=[[921,953,32],[8126,8126,1]];static Mc=[[2307,2363,56],[2366,2368,1],[2377,2380,1],[2382,2383,1],[2434,2435,1],[2494,2496,1],[2503,2504,1],[2507,2508,1],[2519,2563,44],[2622,2624,1],[2691,2750,59],[2751,2752,1],[2761,2763,2],[2764,2818,54],[2819,2878,59],[2880,2887,7],[2888,2891,3],[2892,2903,11],[3006,3007,1],[3009,3010,1],[3014,3016,1],[3018,3020,1],[3031,3073,42],[3074,3075,1],[3137,3140,1],[3202,3203,1],[3262,3264,2],[3265,3268,1],[3271,3272,1],[3274,3275,1],[3285,3286,1],[3315,3330,15],[3331,3390,59],[3391,3392,1],[3398,3400,1],[3402,3404,1],[3415,3458,43],[3459,3535,76],[3536,3537,1],[3544,3551,1],[3570,3571,1],[3902,3903,1],[3967,4139,172],[4140,4145,5],[4152,4155,3],[4156,4182,26],[4183,4194,11],[4195,4196,1],[4199,4205,1],[4227,4228,1],[4231,4236,1],[4239,4250,11],[4251,4252,1],[5909,5940,31],[6070,6078,8],[6079,6085,1],[6087,6088,1],[6435,6438,1],[6441,6443,1],[6448,6449,1],[6451,6456,1],[6681,6682,1],[6741,6743,2],[6753,6755,2],[6756,6765,9],[6766,6770,1],[6916,6965,49],[6971,6973,2],[6974,6977,1],[6979,6980,1],[7042,7073,31],[7078,7079,1],[7082,7143,61],[7146,7148,1],[7150,7154,4],[7155,7204,49],[7205,7211,1],[7220,7221,1],[7393,7415,22],[12334,12335,1],[43043,43044,1],[43047,43136,89],[43137,43188,51],[43189,43203,1],[43346,43347,1],[43395,43444,49],[43445,43450,5],[43451,43454,3],[43455,43456,1],[43567,43568,1],[43571,43572,1],[43597,43643,46],[43645,43755,110],[43758,43759,1],[43765,44003,238],[44004,44006,2],[44007,44009,2],[44010,44012,2],[69632,69634,2],[69762,69808,46],[69809,69810,1],[69815,69816,1],[69932,69957,25],[69958,70018,60],[70067,70069,1],[70079,70080,1],[70094,70188,94],[70189,70190,1],[70194,70195,1],[70197,70368,171],[70369,70370,1],[70402,70403,1],[70462,70463,1],[70465,70468,1],[70471,70472,1],[70475,70477,1],[70487,70498,11],[70499,70709,210],[70710,70711,1],[70720,70721,1],[70725,70832,107],[70833,70834,1],[70841,70843,2],[70844,70846,1],[70849,71087,238],[71088,71089,1],[71096,71099,1],[71102,71216,114],[71217,71218,1],[71227,71228,1],[71230,71340,110],[71342,71343,1],[71350,71456,106],[71457,71462,5],[71724,71726,1],[71736,71984,248],[71985,71989,1],[71991,71992,1],[71997,72e3,3],[72002,72145,143],[72146,72147,1],[72156,72159,1],[72164,72249,85],[72279,72280,1],[72343,72751,408],[72766,72873,107],[72881,72884,3],[73098,73102,1],[73107,73108,1],[73110,73461,351],[73462,73475,13],[73524,73525,1],[73534,73535,1],[73537,94033,20496],[94034,94087,1],[94192,94193,1],[119141,119142,1],[119149,119154,1]];static Me=[[1160,1161,1],[6846,8413,1567],[8414,8416,1],[8418,8420,1],[42608,42610,1]];static Mn=[[768,879,1],[1155,1159,1],[1425,1469,1],[1471,1473,2],[1474,1476,2],[1477,1479,2],[1552,1562,1],[1611,1631,1],[1648,1750,102],[1751,1756,1],[1759,1764,1],[1767,1768,1],[1770,1773,1],[1809,1840,31],[1841,1866,1],[1958,1968,1],[2027,2035,1],[2045,2070,25],[2071,2073,1],[2075,2083,1],[2085,2087,1],[2089,2093,1],[2137,2139,1],[2200,2207,1],[2250,2273,1],[2275,2306,1],[2362,2364,2],[2369,2376,1],[2381,2385,4],[2386,2391,1],[2402,2403,1],[2433,2492,59],[2497,2500,1],[2509,2530,21],[2531,2558,27],[2561,2562,1],[2620,2625,5],[2626,2631,5],[2632,2635,3],[2636,2637,1],[2641,2672,31],[2673,2677,4],[2689,2690,1],[2748,2753,5],[2754,2757,1],[2759,2760,1],[2765,2786,21],[2787,2810,23],[2811,2815,1],[2817,2876,59],[2879,2881,2],[2882,2884,1],[2893,2901,8],[2902,2914,12],[2915,2946,31],[3008,3021,13],[3072,3076,4],[3132,3134,2],[3135,3136,1],[3142,3144,1],[3146,3149,1],[3157,3158,1],[3170,3171,1],[3201,3260,59],[3263,3270,7],[3276,3277,1],[3298,3299,1],[3328,3329,1],[3387,3388,1],[3393,3396,1],[3405,3426,21],[3427,3457,30],[3530,3538,8],[3539,3540,1],[3542,3633,91],[3636,3642,1],[3655,3662,1],[3761,3764,3],[3765,3772,1],[3784,3790,1],[3864,3865,1],[3893,3897,2],[3953,3966,1],[3968,3972,1],[3974,3975,1],[3981,3991,1],[3993,4028,1],[4038,4141,103],[4142,4144,1],[4146,4151,1],[4153,4154,1],[4157,4158,1],[4184,4185,1],[4190,4192,1],[4209,4212,1],[4226,4229,3],[4230,4237,7],[4253,4957,704],[4958,4959,1],[5906,5908,1],[5938,5939,1],[5970,5971,1],[6002,6003,1],[6068,6069,1],[6071,6077,1],[6086,6089,3],[6090,6099,1],[6109,6155,46],[6156,6157,1],[6159,6277,118],[6278,6313,35],[6432,6434,1],[6439,6440,1],[6450,6457,7],[6458,6459,1],[6679,6680,1],[6683,6742,59],[6744,6750,1],[6752,6754,2],[6757,6764,1],[6771,6780,1],[6783,6832,49],[6833,6845,1],[6847,6862,1],[6912,6915,1],[6964,6966,2],[6967,6970,1],[6972,6978,6],[7019,7027,1],[7040,7041,1],[7074,7077,1],[7080,7081,1],[7083,7085,1],[7142,7144,2],[7145,7149,4],[7151,7153,1],[7212,7219,1],[7222,7223,1],[7376,7378,1],[7380,7392,1],[7394,7400,1],[7405,7412,7],[7416,7417,1],[7616,7679,1],[8400,8412,1],[8417,8421,4],[8422,8432,1],[11503,11505,1],[11647,11744,97],[11745,11775,1],[12330,12333,1],[12441,12442,1],[42607,42612,5],[42613,42621,1],[42654,42655,1],[42736,42737,1],[43010,43014,4],[43019,43045,26],[43046,43052,6],[43204,43205,1],[43232,43249,1],[43263,43302,39],[43303,43309,1],[43335,43345,1],[43392,43394,1],[43443,43446,3],[43447,43449,1],[43452,43453,1],[43493,43561,68],[43562,43566,1],[43569,43570,1],[43573,43574,1],[43587,43596,9],[43644,43696,52],[43698,43700,1],[43703,43704,1],[43710,43711,1],[43713,43756,43],[43757,43766,9],[44005,44008,3],[44013,64286,20273],[65024,65039,1],[65056,65071,1],[66045,66272,227],[66422,66426,1],[68097,68099,1],[68101,68102,1],[68108,68111,1],[68152,68154,1],[68159,68325,166],[68326,68900,574],[68901,68903,1],[69291,69292,1],[69373,69375,1],[69446,69456,1],[69506,69509,1],[69633,69688,55],[69689,69702,1],[69744,69747,3],[69748,69759,11],[69760,69761,1],[69811,69814,1],[69817,69818,1],[69826,69888,62],[69889,69890,1],[69927,69931,1],[69933,69940,1],[70003,70016,13],[70017,70070,53],[70071,70078,1],[70089,70092,1],[70095,70191,96],[70192,70193,1],[70196,70198,2],[70199,70206,7],[70209,70367,158],[70371,70378,1],[70400,70401,1],[70459,70460,1],[70464,70502,38],[70503,70508,1],[70512,70516,1],[70712,70719,1],[70722,70724,1],[70726,70750,24],[70835,70840,1],[70842,70847,5],[70848,70850,2],[70851,71090,239],[71091,71093,1],[71100,71101,1],[71103,71104,1],[71132,71133,1],[71219,71226,1],[71229,71231,2],[71232,71339,107],[71341,71344,3],[71345,71349,1],[71351,71453,102],[71454,71455,1],[71458,71461,1],[71463,71467,1],[71727,71735,1],[71737,71738,1],[71995,71996,1],[71998,72003,5],[72148,72151,1],[72154,72155,1],[72160,72193,33],[72194,72202,1],[72243,72248,1],[72251,72254,1],[72263,72273,10],[72274,72278,1],[72281,72283,1],[72330,72342,1],[72344,72345,1],[72752,72758,1],[72760,72765,1],[72767,72850,83],[72851,72871,1],[72874,72880,1],[72882,72883,1],[72885,72886,1],[73009,73014,1],[73018,73020,2],[73021,73023,2],[73024,73029,1],[73031,73104,73],[73105,73109,4],[73111,73459,348],[73460,73472,12],[73473,73526,53],[73527,73530,1],[73536,73538,2],[78912,78919,7],[78920,78933,1],[92912,92916,1],[92976,92982,1],[94031,94095,64],[94096,94098,1],[94180,113821,19641],[113822,118528,4706],[118529,118573,1],[118576,118598,1],[119143,119145,1],[119163,119170,1],[119173,119179,1],[119210,119213,1],[119362,119364,1],[121344,121398,1],[121403,121452,1],[121461,121476,15],[121499,121503,1],[121505,121519,1],[122880,122886,1],[122888,122904,1],[122907,122913,1],[122915,122916,1],[122918,122922,1],[123023,123184,161],[123185,123190,1],[123566,123628,62],[123629,123631,1],[124140,124143,1],[125136,125142,1],[125252,125258,1],[917760,917999,1]];static foldMn=[[921,953,32],[8126,8126,1]];static N=[[48,57,1],[178,179,1],[185,188,3],[189,190,1],[1632,1641,1],[1776,1785,1],[1984,1993,1],[2406,2415,1],[2534,2543,1],[2548,2553,1],[2662,2671,1],[2790,2799,1],[2918,2927,1],[2930,2935,1],[3046,3058,1],[3174,3183,1],[3192,3198,1],[3302,3311,1],[3416,3422,1],[3430,3448,1],[3558,3567,1],[3664,3673,1],[3792,3801,1],[3872,3891,1],[4160,4169,1],[4240,4249,1],[4969,4988,1],[5870,5872,1],[6112,6121,1],[6128,6137,1],[6160,6169,1],[6470,6479,1],[6608,6618,1],[6784,6793,1],[6800,6809,1],[6992,7001,1],[7088,7097,1],[7232,7241,1],[7248,7257,1],[8304,8308,4],[8309,8313,1],[8320,8329,1],[8528,8578,1],[8581,8585,1],[9312,9371,1],[9450,9471,1],[10102,10131,1],[11517,12295,778],[12321,12329,1],[12344,12346,1],[12690,12693,1],[12832,12841,1],[12872,12879,1],[12881,12895,1],[12928,12937,1],[12977,12991,1],[42528,42537,1],[42726,42735,1],[43056,43061,1],[43216,43225,1],[43264,43273,1],[43472,43481,1],[43504,43513,1],[43600,43609,1],[44016,44025,1],[65296,65305,1],[65799,65843,1],[65856,65912,1],[65930,65931,1],[66273,66299,1],[66336,66339,1],[66369,66378,9],[66513,66517,1],[66720,66729,1],[67672,67679,1],[67705,67711,1],[67751,67759,1],[67835,67839,1],[67862,67867,1],[68028,68029,1],[68032,68047,1],[68050,68095,1],[68160,68168,1],[68221,68222,1],[68253,68255,1],[68331,68335,1],[68440,68447,1],[68472,68479,1],[68521,68527,1],[68858,68863,1],[68912,68921,1],[69216,69246,1],[69405,69414,1],[69457,69460,1],[69573,69579,1],[69714,69743,1],[69872,69881,1],[69942,69951,1],[70096,70105,1],[70113,70132,1],[70384,70393,1],[70736,70745,1],[70864,70873,1],[71248,71257,1],[71360,71369,1],[71472,71483,1],[71904,71922,1],[72016,72025,1],[72784,72812,1],[73040,73049,1],[73120,73129,1],[73552,73561,1],[73664,73684,1],[74752,74862,1],[92768,92777,1],[92864,92873,1],[93008,93017,1],[93019,93025,1],[93824,93846,1],[119488,119507,1],[119520,119539,1],[119648,119672,1],[120782,120831,1],[123200,123209,1],[123632,123641,1],[124144,124153,1],[125127,125135,1],[125264,125273,1],[126065,126123,1],[126125,126127,1],[126129,126132,1],[126209,126253,1],[126255,126269,1],[127232,127244,1],[130032,130041,1]];static Nd=[[48,57,1],[1632,1641,1],[1776,1785,1],[1984,1993,1],[2406,2415,1],[2534,2543,1],[2662,2671,1],[2790,2799,1],[2918,2927,1],[3046,3055,1],[3174,3183,1],[3302,3311,1],[3430,3439,1],[3558,3567,1],[3664,3673,1],[3792,3801,1],[3872,3881,1],[4160,4169,1],[4240,4249,1],[6112,6121,1],[6160,6169,1],[6470,6479,1],[6608,6617,1],[6784,6793,1],[6800,6809,1],[6992,7001,1],[7088,7097,1],[7232,7241,1],[7248,7257,1],[42528,42537,1],[43216,43225,1],[43264,43273,1],[43472,43481,1],[43504,43513,1],[43600,43609,1],[44016,44025,1],[65296,65305,1],[66720,66729,1],[68912,68921,1],[69734,69743,1],[69872,69881,1],[69942,69951,1],[70096,70105,1],[70384,70393,1],[70736,70745,1],[70864,70873,1],[71248,71257,1],[71360,71369,1],[71472,71481,1],[71904,71913,1],[72016,72025,1],[72784,72793,1],[73040,73049,1],[73120,73129,1],[73552,73561,1],[92768,92777,1],[92864,92873,1],[93008,93017,1],[120782,120831,1],[123200,123209,1],[123632,123641,1],[124144,124153,1],[125264,125273,1],[130032,130041,1]];static Nl=[[5870,5872,1],[8544,8578,1],[8581,8584,1],[12295,12321,26],[12322,12329,1],[12344,12346,1],[42726,42735,1],[65856,65908,1],[66369,66378,9],[66513,66517,1],[74752,74862,1]];static No=[[178,179,1],[185,188,3],[189,190,1],[2548,2553,1],[2930,2935,1],[3056,3058,1],[3192,3198,1],[3416,3422,1],[3440,3448,1],[3882,3891,1],[4969,4988,1],[6128,6137,1],[6618,8304,1686],[8308,8313,1],[8320,8329,1],[8528,8543,1],[8585,9312,727],[9313,9371,1],[9450,9471,1],[10102,10131,1],[11517,12690,1173],[12691,12693,1],[12832,12841,1],[12872,12879,1],[12881,12895,1],[12928,12937,1],[12977,12991,1],[43056,43061,1],[65799,65843,1],[65909,65912,1],[65930,65931,1],[66273,66299,1],[66336,66339,1],[67672,67679,1],[67705,67711,1],[67751,67759,1],[67835,67839,1],[67862,67867,1],[68028,68029,1],[68032,68047,1],[68050,68095,1],[68160,68168,1],[68221,68222,1],[68253,68255,1],[68331,68335,1],[68440,68447,1],[68472,68479,1],[68521,68527,1],[68858,68863,1],[69216,69246,1],[69405,69414,1],[69457,69460,1],[69573,69579,1],[69714,69733,1],[70113,70132,1],[71482,71483,1],[71914,71922,1],[72794,72812,1],[73664,73684,1],[93019,93025,1],[93824,93846,1],[119488,119507,1],[119520,119539,1],[119648,119672,1],[125127,125135,1],[126065,126123,1],[126125,126127,1],[126129,126132,1],[126209,126253,1],[126255,126269,1],[127232,127244,1]];static P=[[33,35,1],[37,42,1],[44,47,1],[58,59,1],[63,64,1],[91,93,1],[95,123,28],[125,161,36],[167,171,4],[182,183,1],[187,191,4],[894,903,9],[1370,1375,1],[1417,1418,1],[1470,1472,2],[1475,1478,3],[1523,1524,1],[1545,1546,1],[1548,1549,1],[1563,1565,2],[1566,1567,1],[1642,1645,1],[1748,1792,44],[1793,1805,1],[2039,2041,1],[2096,2110,1],[2142,2404,262],[2405,2416,11],[2557,2678,121],[2800,3191,391],[3204,3572,368],[3663,3674,11],[3675,3844,169],[3845,3858,1],[3860,3898,38],[3899,3901,1],[3973,4048,75],[4049,4052,1],[4057,4058,1],[4170,4175,1],[4347,4960,613],[4961,4968,1],[5120,5742,622],[5787,5788,1],[5867,5869,1],[5941,5942,1],[6100,6102,1],[6104,6106,1],[6144,6154,1],[6468,6469,1],[6686,6687,1],[6816,6822,1],[6824,6829,1],[7002,7008,1],[7037,7038,1],[7164,7167,1],[7227,7231,1],[7294,7295,1],[7360,7367,1],[7379,8208,829],[8209,8231,1],[8240,8259,1],[8261,8273,1],[8275,8286,1],[8317,8318,1],[8333,8334,1],[8968,8971,1],[9001,9002,1],[10088,10101,1],[10181,10182,1],[10214,10223,1],[10627,10648,1],[10712,10715,1],[10748,10749,1],[11513,11516,1],[11518,11519,1],[11632,11776,144],[11777,11822,1],[11824,11855,1],[11858,11869,1],[12289,12291,1],[12296,12305,1],[12308,12319,1],[12336,12349,13],[12448,12539,91],[42238,42239,1],[42509,42511,1],[42611,42622,11],[42738,42743,1],[43124,43127,1],[43214,43215,1],[43256,43258,1],[43260,43310,50],[43311,43359,48],[43457,43469,1],[43486,43487,1],[43612,43615,1],[43742,43743,1],[43760,43761,1],[44011,64830,20819],[64831,65040,209],[65041,65049,1],[65072,65106,1],[65108,65121,1],[65123,65128,5],[65130,65131,1],[65281,65283,1],[65285,65290,1],[65292,65295,1],[65306,65307,1],[65311,65312,1],[65339,65341,1],[65343,65371,28],[65373,65375,2],[65376,65381,1],[65792,65794,1],[66463,66512,49],[66927,67671,744],[67871,67903,32],[68176,68184,1],[68223,68336,113],[68337,68342,1],[68409,68415,1],[68505,68508,1],[69293,69461,168],[69462,69465,1],[69510,69513,1],[69703,69709,1],[69819,69820,1],[69822,69825,1],[69952,69955,1],[70004,70005,1],[70085,70088,1],[70093,70107,14],[70109,70111,1],[70200,70205,1],[70313,70731,418],[70732,70735,1],[70746,70747,1],[70749,70854,105],[71105,71127,1],[71233,71235,1],[71264,71276,1],[71353,71484,131],[71485,71486,1],[71739,72004,265],[72005,72006,1],[72162,72255,93],[72256,72262,1],[72346,72348,1],[72350,72354,1],[72448,72457,1],[72769,72773,1],[72816,72817,1],[73463,73464,1],[73539,73551,1],[73727,74864,1137],[74865,74868,1],[77809,77810,1],[92782,92783,1],[92917,92983,66],[92984,92987,1],[92996,93847,851],[93848,93850,1],[94178,113823,19645],[121479,121483,1],[125278,125279,1]];static Pc=[[95,8255,8160],[8256,8276,20],[65075,65076,1],[65101,65103,1],[65343,65343,1]];static Pd=[[45,1418,1373],[1470,5120,3650],[6150,8208,2058],[8209,8213,1],[11799,11802,3],[11834,11835,1],[11840,11869,29],[12316,12336,20],[12448,65073,52625],[65074,65112,38],[65123,65293,170],[69293,69293,1]];static Pe=[[41,93,52],[125,3899,3774],[3901,5788,1887],[8262,8318,56],[8334,8969,635],[8971,9002,31],[10089,10101,2],[10182,10215,33],[10217,10223,2],[10628,10648,2],[10713,10715,2],[10749,11811,1062],[11813,11817,2],[11862,11868,2],[12297,12305,2],[12309,12315,2],[12318,12319,1],[64830,65048,218],[65078,65092,2],[65096,65114,18],[65116,65118,2],[65289,65341,52],[65373,65379,3]];static Pf=[[187,8217,8030],[8221,8250,29],[11779,11781,2],[11786,11789,3],[11805,11809,4]];static Pi=[[171,8216,8045],[8219,8220,1],[8223,8249,26],[11778,11780,2],[11785,11788,3],[11804,11808,4]];static Po=[[33,35,1],[37,39,1],[42,46,2],[47,58,11],[59,63,4],[64,92,28],[161,167,6],[182,183,1],[191,894,703],[903,1370,467],[1371,1375,1],[1417,1472,55],[1475,1478,3],[1523,1524,1],[1545,1546,1],[1548,1549,1],[1563,1565,2],[1566,1567,1],[1642,1645,1],[1748,1792,44],[1793,1805,1],[2039,2041,1],[2096,2110,1],[2142,2404,262],[2405,2416,11],[2557,2678,121],[2800,3191,391],[3204,3572,368],[3663,3674,11],[3675,3844,169],[3845,3858,1],[3860,3973,113],[4048,4052,1],[4057,4058,1],[4170,4175,1],[4347,4960,613],[4961,4968,1],[5742,5867,125],[5868,5869,1],[5941,5942,1],[6100,6102,1],[6104,6106,1],[6144,6149,1],[6151,6154,1],[6468,6469,1],[6686,6687,1],[6816,6822,1],[6824,6829,1],[7002,7008,1],[7037,7038,1],[7164,7167,1],[7227,7231,1],[7294,7295,1],[7360,7367,1],[7379,8214,835],[8215,8224,9],[8225,8231,1],[8240,8248,1],[8251,8254,1],[8257,8259,1],[8263,8273,1],[8275,8277,2],[8278,8286,1],[11513,11516,1],[11518,11519,1],[11632,11776,144],[11777,11782,5],[11783,11784,1],[11787,11790,3],[11791,11798,1],[11800,11801,1],[11803,11806,3],[11807,11818,11],[11819,11822,1],[11824,11833,1],[11836,11839,1],[11841,11843,2],[11844,11855,1],[11858,11860,1],[12289,12291,1],[12349,12539,190],[42238,42239,1],[42509,42511,1],[42611,42622,11],[42738,42743,1],[43124,43127,1],[43214,43215,1],[43256,43258,1],[43260,43310,50],[43311,43359,48],[43457,43469,1],[43486,43487,1],[43612,43615,1],[43742,43743,1],[43760,43761,1],[44011,65040,21029],[65041,65046,1],[65049,65072,23],[65093,65094,1],[65097,65100,1],[65104,65106,1],[65108,65111,1],[65119,65121,1],[65128,65130,2],[65131,65281,150],[65282,65283,1],[65285,65287,1],[65290,65294,2],[65295,65306,11],[65307,65311,4],[65312,65340,28],[65377,65380,3],[65381,65792,411],[65793,65794,1],[66463,66512,49],[66927,67671,744],[67871,67903,32],[68176,68184,1],[68223,68336,113],[68337,68342,1],[68409,68415,1],[68505,68508,1],[69461,69465,1],[69510,69513,1],[69703,69709,1],[69819,69820,1],[69822,69825,1],[69952,69955,1],[70004,70005,1],[70085,70088,1],[70093,70107,14],[70109,70111,1],[70200,70205,1],[70313,70731,418],[70732,70735,1],[70746,70747,1],[70749,70854,105],[71105,71127,1],[71233,71235,1],[71264,71276,1],[71353,71484,131],[71485,71486,1],[71739,72004,265],[72005,72006,1],[72162,72255,93],[72256,72262,1],[72346,72348,1],[72350,72354,1],[72448,72457,1],[72769,72773,1],[72816,72817,1],[73463,73464,1],[73539,73551,1],[73727,74864,1137],[74865,74868,1],[77809,77810,1],[92782,92783,1],[92917,92983,66],[92984,92987,1],[92996,93847,851],[93848,93850,1],[94178,113823,19645],[121479,121483,1],[125278,125279,1]];static Ps=[[40,91,51],[123,3898,3775],[3900,5787,1887],[8218,8222,4],[8261,8317,56],[8333,8968,635],[8970,9001,31],[10088,10100,2],[10181,10214,33],[10216,10222,2],[10627,10647,2],[10712,10714,2],[10748,11810,1062],[11812,11816,2],[11842,11861,19],[11863,11867,2],[12296,12304,2],[12308,12314,2],[12317,64831,52514],[65047,65077,30],[65079,65091,2],[65095,65113,18],[65115,65117,2],[65288,65339,51],[65371,65375,4],[65378,65378,1]];static S=[[36,43,7],[60,62,1],[94,96,2],[124,126,2],[162,166,1],[168,169,1],[172,174,2],[175,177,1],[180,184,4],[215,247,32],[706,709,1],[722,735,1],[741,747,1],[749,751,2],[752,767,1],[885,900,15],[901,1014,113],[1154,1421,267],[1422,1423,1],[1542,1544,1],[1547,1550,3],[1551,1758,207],[1769,1789,20],[1790,2038,248],[2046,2047,1],[2184,2546,362],[2547,2554,7],[2555,2801,246],[2928,3059,131],[3060,3066,1],[3199,3407,208],[3449,3647,198],[3841,3843,1],[3859,3861,2],[3862,3863,1],[3866,3871,1],[3892,3896,2],[4030,4037,1],[4039,4044,1],[4046,4047,1],[4053,4056,1],[4254,4255,1],[5008,5017,1],[5741,6107,366],[6464,6622,158],[6623,6655,1],[7009,7018,1],[7028,7036,1],[8125,8127,2],[8128,8129,1],[8141,8143,1],[8157,8159,1],[8173,8175,1],[8189,8190,1],[8260,8274,14],[8314,8316,1],[8330,8332,1],[8352,8384,1],[8448,8449,1],[8451,8454,1],[8456,8457,1],[8468,8470,2],[8471,8472,1],[8478,8483,1],[8485,8489,2],[8494,8506,12],[8507,8512,5],[8513,8516,1],[8522,8525,1],[8527,8586,59],[8587,8592,5],[8593,8967,1],[8972,9e3,1],[9003,9254,1],[9280,9290,1],[9372,9449,1],[9472,10087,1],[10132,10180,1],[10183,10213,1],[10224,10626,1],[10649,10711,1],[10716,10747,1],[10750,11123,1],[11126,11157,1],[11159,11263,1],[11493,11498,1],[11856,11857,1],[11904,11929,1],[11931,12019,1],[12032,12245,1],[12272,12287,1],[12292,12306,14],[12307,12320,13],[12342,12343,1],[12350,12351,1],[12443,12444,1],[12688,12689,1],[12694,12703,1],[12736,12771,1],[12783,12800,17],[12801,12830,1],[12842,12871,1],[12880,12896,16],[12897,12927,1],[12938,12976,1],[12992,13311,1],[19904,19967,1],[42128,42182,1],[42752,42774,1],[42784,42785,1],[42889,42890,1],[43048,43051,1],[43062,43065,1],[43639,43641,1],[43867,43882,15],[43883,64297,20414],[64434,64450,1],[64832,64847,1],[64975,65020,45],[65021,65023,1],[65122,65124,2],[65125,65126,1],[65129,65284,155],[65291,65308,17],[65309,65310,1],[65342,65344,2],[65372,65374,2],[65504,65510,1],[65512,65518,1],[65532,65533,1],[65847,65855,1],[65913,65929,1],[65932,65934,1],[65936,65948,1],[65952,66e3,48],[66001,66044,1],[67703,67704,1],[68296,71487,3191],[73685,73713,1],[92988,92991,1],[92997,113820,20823],[118608,118723,1],[118784,119029,1],[119040,119078,1],[119081,119140,1],[119146,119148,1],[119171,119172,1],[119180,119209,1],[119214,119274,1],[119296,119361,1],[119365,119552,187],[119553,119638,1],[120513,120539,26],[120571,120597,26],[120629,120655,26],[120687,120713,26],[120745,120771,26],[120832,121343,1],[121399,121402,1],[121453,121460,1],[121462,121475,1],[121477,121478,1],[123215,123647,432],[126124,126128,4],[126254,126704,450],[126705,126976,271],[126977,127019,1],[127024,127123,1],[127136,127150,1],[127153,127167,1],[127169,127183,1],[127185,127221,1],[127245,127405,1],[127462,127490,1],[127504,127547,1],[127552,127560,1],[127568,127569,1],[127584,127589,1],[127744,128727,1],[128732,128748,1],[128752,128764,1],[128768,128886,1],[128891,128985,1],[128992,129003,1],[129008,129024,16],[129025,129035,1],[129040,129095,1],[129104,129113,1],[129120,129159,1],[129168,129197,1],[129200,129201,1],[129280,129619,1],[129632,129645,1],[129648,129660,1],[129664,129672,1],[129680,129725,1],[129727,129733,1],[129742,129755,1],[129760,129768,1],[129776,129784,1],[129792,129938,1],[129940,129994,1]];static Sc=[[36,162,126],[163,165,1],[1423,1547,124],[2046,2047,1],[2546,2547,1],[2555,2801,246],[3065,3647,582],[6107,8352,2245],[8353,8384,1],[43064,65020,21956],[65129,65284,155],[65504,65505,1],[65509,65510,1],[73693,73696,1],[123647,126128,2481]];static Sk=[[94,96,2],[168,175,7],[180,184,4],[706,709,1],[722,735,1],[741,747,1],[749,751,2],[752,767,1],[885,900,15],[901,2184,1283],[8125,8127,2],[8128,8129,1],[8141,8143,1],[8157,8159,1],[8173,8175,1],[8189,8190,1],[12443,12444,1],[42752,42774,1],[42784,42785,1],[42889,42890,1],[43867,43882,15],[43883,64434,20551],[64435,64450,1],[65342,65344,2],[65507,127995,62488],[127996,127999,1]];static Sm=[[43,60,17],[61,62,1],[124,126,2],[172,177,5],[215,247,32],[1014,1542,528],[1543,1544,1],[8260,8274,14],[8314,8316,1],[8330,8332,1],[8472,8512,40],[8513,8516,1],[8523,8592,69],[8593,8596,1],[8602,8603,1],[8608,8614,3],[8622,8654,32],[8655,8658,3],[8660,8692,32],[8693,8959,1],[8992,8993,1],[9084,9115,31],[9116,9139,1],[9180,9185,1],[9655,9665,10],[9720,9727,1],[9839,10176,337],[10177,10180,1],[10183,10213,1],[10224,10239,1],[10496,10626,1],[10649,10711,1],[10716,10747,1],[10750,11007,1],[11056,11076,1],[11079,11084,1],[64297,65122,825],[65124,65126,1],[65291,65308,17],[65309,65310,1],[65372,65374,2],[65506,65513,7],[65514,65516,1],[120513,120539,26],[120571,120597,26],[120629,120655,26],[120687,120713,26],[120745,120771,26],[126704,126705,1]];static So=[[166,169,3],[174,176,2],[1154,1421,267],[1422,1550,128],[1551,1758,207],[1769,1789,20],[1790,2038,248],[2554,2928,374],[3059,3064,1],[3066,3199,133],[3407,3449,42],[3841,3843,1],[3859,3861,2],[3862,3863,1],[3866,3871,1],[3892,3896,2],[4030,4037,1],[4039,4044,1],[4046,4047,1],[4053,4056,1],[4254,4255,1],[5008,5017,1],[5741,6464,723],[6622,6655,1],[7009,7018,1],[7028,7036,1],[8448,8449,1],[8451,8454,1],[8456,8457,1],[8468,8470,2],[8471,8478,7],[8479,8483,1],[8485,8489,2],[8494,8506,12],[8507,8522,15],[8524,8525,1],[8527,8586,59],[8587,8597,10],[8598,8601,1],[8604,8607,1],[8609,8610,1],[8612,8613,1],[8615,8621,1],[8623,8653,1],[8656,8657,1],[8659,8661,2],[8662,8691,1],[8960,8967,1],[8972,8991,1],[8994,9e3,1],[9003,9083,1],[9085,9114,1],[9140,9179,1],[9186,9254,1],[9280,9290,1],[9372,9449,1],[9472,9654,1],[9656,9664,1],[9666,9719,1],[9728,9838,1],[9840,10087,1],[10132,10175,1],[10240,10495,1],[11008,11055,1],[11077,11078,1],[11085,11123,1],[11126,11157,1],[11159,11263,1],[11493,11498,1],[11856,11857,1],[11904,11929,1],[11931,12019,1],[12032,12245,1],[12272,12287,1],[12292,12306,14],[12307,12320,13],[12342,12343,1],[12350,12351,1],[12688,12689,1],[12694,12703,1],[12736,12771,1],[12783,12800,17],[12801,12830,1],[12842,12871,1],[12880,12896,16],[12897,12927,1],[12938,12976,1],[12992,13311,1],[19904,19967,1],[42128,42182,1],[43048,43051,1],[43062,43063,1],[43065,43639,574],[43640,43641,1],[64832,64847,1],[64975,65021,46],[65022,65023,1],[65508,65512,4],[65517,65518,1],[65532,65533,1],[65847,65855,1],[65913,65929,1],[65932,65934,1],[65936,65948,1],[65952,66e3,48],[66001,66044,1],[67703,67704,1],[68296,71487,3191],[73685,73692,1],[73697,73713,1],[92988,92991,1],[92997,113820,20823],[118608,118723,1],[118784,119029,1],[119040,119078,1],[119081,119140,1],[119146,119148,1],[119171,119172,1],[119180,119209,1],[119214,119274,1],[119296,119361,1],[119365,119552,187],[119553,119638,1],[120832,121343,1],[121399,121402,1],[121453,121460,1],[121462,121475,1],[121477,121478,1],[123215,126124,2909],[126254,126976,722],[126977,127019,1],[127024,127123,1],[127136,127150,1],[127153,127167,1],[127169,127183,1],[127185,127221,1],[127245,127405,1],[127462,127490,1],[127504,127547,1],[127552,127560,1],[127568,127569,1],[127584,127589,1],[127744,127994,1],[128e3,128727,1],[128732,128748,1],[128752,128764,1],[128768,128886,1],[128891,128985,1],[128992,129003,1],[129008,129024,16],[129025,129035,1],[129040,129095,1],[129104,129113,1],[129120,129159,1],[129168,129197,1],[129200,129201,1],[129280,129619,1],[129632,129645,1],[129648,129660,1],[129664,129672,1],[129680,129725,1],[129727,129733,1],[129742,129755,1],[129760,129768,1],[129776,129784,1],[129792,129938,1],[129940,129994,1]];static Z=[[32,160,128],[5760,8192,2432],[8193,8202,1],[8232,8233,1],[8239,8287,48],[12288,12288,1]];static Zl=[[8232,8232,1]];static Zp=[[8233,8233,1]];static Zs=[[32,160,128],[5760,8192,2432],[8193,8202,1],[8239,8287,48],[12288,12288,1]];static Adlam=[[125184,125259,1],[125264,125273,1],[125278,125279,1]];static Ahom=[[71424,71450,1],[71453,71467,1],[71472,71494,1]];static Anatolian_Hieroglyphs=[[82944,83526,1]];static Arabic=[[1536,1540,1],[1542,1547,1],[1549,1562,1],[1564,1566,1],[1568,1599,1],[1601,1610,1],[1622,1647,1],[1649,1756,1],[1758,1791,1],[1872,1919,1],[2160,2190,1],[2192,2193,1],[2200,2273,1],[2275,2303,1],[64336,64450,1],[64467,64829,1],[64832,64911,1],[64914,64967,1],[64975,65008,33],[65009,65023,1],[65136,65140,1],[65142,65276,1],[69216,69246,1],[69373,69375,1],[126464,126467,1],[126469,126495,1],[126497,126498,1],[126500,126503,3],[126505,126514,1],[126516,126519,1],[126521,126523,2],[126530,126535,5],[126537,126541,2],[126542,126543,1],[126545,126546,1],[126548,126551,3],[126553,126561,2],[126562,126564,2],[126567,126570,1],[126572,126578,1],[126580,126583,1],[126585,126588,1],[126590,126592,2],[126593,126601,1],[126603,126619,1],[126625,126627,1],[126629,126633,1],[126635,126651,1],[126704,126705,1]];static Armenian=[[1329,1366,1],[1369,1418,1],[1421,1423,1],[64275,64279,1]];static Avestan=[[68352,68405,1],[68409,68415,1]];static Balinese=[[6912,6988,1],[6992,7038,1]];static Bamum=[[42656,42743,1],[92160,92728,1]];static Bassa_Vah=[[92880,92909,1],[92912,92917,1]];static Batak=[[7104,7155,1],[7164,7167,1]];static Bengali=[[2432,2435,1],[2437,2444,1],[2447,2448,1],[2451,2472,1],[2474,2480,1],[2482,2486,4],[2487,2489,1],[2492,2500,1],[2503,2504,1],[2507,2510,1],[2519,2524,5],[2525,2527,2],[2528,2531,1],[2534,2558,1]];static Bhaiksuki=[[72704,72712,1],[72714,72758,1],[72760,72773,1],[72784,72812,1]];static Bopomofo=[[746,747,1],[12549,12591,1],[12704,12735,1]];static Brahmi=[[69632,69709,1],[69714,69749,1],[69759,69759,1]];static Braille=[[10240,10495,1]];static Buginese=[[6656,6683,1],[6686,6687,1]];static Buhid=[[5952,5971,1]];static Canadian_Aboriginal=[[5120,5759,1],[6320,6389,1],[72368,72383,1]];static Carian=[[66208,66256,1]];static Caucasian_Albanian=[[66864,66915,1],[66927,66927,1]];static Chakma=[[69888,69940,1],[69942,69959,1]];static Cham=[[43520,43574,1],[43584,43597,1],[43600,43609,1],[43612,43615,1]];static Cherokee=[[5024,5109,1],[5112,5117,1],[43888,43967,1]];static Chorasmian=[[69552,69579,1]];static Common=[[0,64,1],[91,96,1],[123,169,1],[171,185,1],[187,191,1],[215,247,32],[697,735,1],[741,745,1],[748,767,1],[884,894,10],[901,903,2],[1541,1548,7],[1563,1567,4],[1600,1757,157],[2274,2404,130],[2405,3647,1242],[4053,4056,1],[4347,5867,1520],[5868,5869,1],[5941,5942,1],[6146,6147,1],[6149,7379,1230],[7393,7401,8],[7402,7404,1],[7406,7411,1],[7413,7415,1],[7418,8192,774],[8193,8203,1],[8206,8292,1],[8294,8304,1],[8308,8318,1],[8320,8334,1],[8352,8384,1],[8448,8485,1],[8487,8489,1],[8492,8497,1],[8499,8525,1],[8527,8543,1],[8585,8587,1],[8592,9254,1],[9280,9290,1],[9312,10239,1],[10496,11123,1],[11126,11157,1],[11159,11263,1],[11776,11869,1],[12272,12292,1],[12294,12296,2],[12297,12320,1],[12336,12343,1],[12348,12351,1],[12443,12444,1],[12448,12539,91],[12540,12688,148],[12689,12703,1],[12736,12771,1],[12783,12832,49],[12833,12895,1],[12927,13007,1],[13055,13144,89],[13145,13311,1],[19904,19967,1],[42752,42785,1],[42888,42890,1],[43056,43065,1],[43310,43471,161],[43867,43882,15],[43883,64830,20947],[64831,65040,209],[65041,65049,1],[65072,65106,1],[65108,65126,1],[65128,65131,1],[65279,65281,2],[65282,65312,1],[65339,65344,1],[65371,65381,1],[65392,65438,46],[65439,65504,65],[65505,65510,1],[65512,65518,1],[65529,65533,1],[65792,65794,1],[65799,65843,1],[65847,65855,1],[65936,65948,1],[66e3,66044,1],[66273,66299,1],[113824,113827,1],[118608,118723,1],[118784,119029,1],[119040,119078,1],[119081,119142,1],[119146,119162,1],[119171,119172,1],[119180,119209,1],[119214,119274,1],[119488,119507,1],[119520,119539,1],[119552,119638,1],[119648,119672,1],[119808,119892,1],[119894,119964,1],[119966,119967,1],[119970,119973,3],[119974,119977,3],[119978,119980,1],[119982,119993,1],[119995,119997,2],[119998,120003,1],[120005,120069,1],[120071,120074,1],[120077,120084,1],[120086,120092,1],[120094,120121,1],[120123,120126,1],[120128,120132,1],[120134,120138,4],[120139,120144,1],[120146,120485,1],[120488,120779,1],[120782,120831,1],[126065,126132,1],[126209,126269,1],[126976,127019,1],[127024,127123,1],[127136,127150,1],[127153,127167,1],[127169,127183,1],[127185,127221,1],[127232,127405,1],[127462,127487,1],[127489,127490,1],[127504,127547,1],[127552,127560,1],[127568,127569,1],[127584,127589,1],[127744,128727,1],[128732,128748,1],[128752,128764,1],[128768,128886,1],[128891,128985,1],[128992,129003,1],[129008,129024,16],[129025,129035,1],[129040,129095,1],[129104,129113,1],[129120,129159,1],[129168,129197,1],[129200,129201,1],[129280,129619,1],[129632,129645,1],[129648,129660,1],[129664,129672,1],[129680,129725,1],[129727,129733,1],[129742,129755,1],[129760,129768,1],[129776,129784,1],[129792,129938,1],[129940,129994,1],[130032,130041,1],[917505,917536,31],[917537,917631,1]];static foldCommon=[[924,956,32]];static Coptic=[[994,1007,1],[11392,11507,1],[11513,11519,1]];static Cuneiform=[[73728,74649,1],[74752,74862,1],[74864,74868,1],[74880,75075,1]];static Cypriot=[[67584,67589,1],[67592,67594,2],[67595,67637,1],[67639,67640,1],[67644,67647,3]];static Cypro_Minoan=[[77712,77810,1]];static Cyrillic=[[1024,1156,1],[1159,1327,1],[7296,7304,1],[7467,7544,77],[11744,11775,1],[42560,42655,1],[65070,65071,1],[122928,122989,1],[123023,123023,1]];static Deseret=[[66560,66639,1]];static Devanagari=[[2304,2384,1],[2389,2403,1],[2406,2431,1],[43232,43263,1],[72448,72457,1]];static Dives_Akuru=[[71936,71942,1],[71945,71948,3],[71949,71955,1],[71957,71958,1],[71960,71989,1],[71991,71992,1],[71995,72006,1],[72016,72025,1]];static Dogra=[[71680,71739,1]];static Duployan=[[113664,113770,1],[113776,113788,1],[113792,113800,1],[113808,113817,1],[113820,113823,1]];static Egyptian_Hieroglyphs=[[77824,78933,1]];static Elbasan=[[66816,66855,1]];static Elymaic=[[69600,69622,1]];static Ethiopic=[[4608,4680,1],[4682,4685,1],[4688,4694,1],[4696,4698,2],[4699,4701,1],[4704,4744,1],[4746,4749,1],[4752,4784,1],[4786,4789,1],[4792,4798,1],[4800,4802,2],[4803,4805,1],[4808,4822,1],[4824,4880,1],[4882,4885,1],[4888,4954,1],[4957,4988,1],[4992,5017,1],[11648,11670,1],[11680,11686,1],[11688,11694,1],[11696,11702,1],[11704,11710,1],[11712,11718,1],[11720,11726,1],[11728,11734,1],[11736,11742,1],[43777,43782,1],[43785,43790,1],[43793,43798,1],[43808,43814,1],[43816,43822,1],[124896,124902,1],[124904,124907,1],[124909,124910,1],[124912,124926,1]];static Georgian=[[4256,4293,1],[4295,4301,6],[4304,4346,1],[4348,4351,1],[7312,7354,1],[7357,7359,1],[11520,11557,1],[11559,11565,6]];static Glagolitic=[[11264,11359,1],[122880,122886,1],[122888,122904,1],[122907,122913,1],[122915,122916,1],[122918,122922,1]];static Gothic=[[66352,66378,1]];static Grantha=[[70400,70403,1],[70405,70412,1],[70415,70416,1],[70419,70440,1],[70442,70448,1],[70450,70451,1],[70453,70457,1],[70460,70468,1],[70471,70472,1],[70475,70477,1],[70480,70487,7],[70493,70499,1],[70502,70508,1],[70512,70516,1]];static Greek=[[880,883,1],[885,887,1],[890,893,1],[895,900,5],[902,904,2],[905,906,1],[908,910,2],[911,929,1],[931,993,1],[1008,1023,1],[7462,7466,1],[7517,7521,1],[7526,7530,1],[7615,7936,321],[7937,7957,1],[7960,7965,1],[7968,8005,1],[8008,8013,1],[8016,8023,1],[8025,8031,2],[8032,8061,1],[8064,8116,1],[8118,8132,1],[8134,8147,1],[8150,8155,1],[8157,8175,1],[8178,8180,1],[8182,8190,1],[8486,43877,35391],[65856,65934,1],[65952,119296,53344],[119297,119365,1]];static foldGreek=[[181,837,656]];static Gujarati=[[2689,2691,1],[2693,2701,1],[2703,2705,1],[2707,2728,1],[2730,2736,1],[2738,2739,1],[2741,2745,1],[2748,2757,1],[2759,2761,1],[2763,2765,1],[2768,2784,16],[2785,2787,1],[2790,2801,1],[2809,2815,1]];static Gunjala_Gondi=[[73056,73061,1],[73063,73064,1],[73066,73102,1],[73104,73105,1],[73107,73112,1],[73120,73129,1]];static Gurmukhi=[[2561,2563,1],[2565,2570,1],[2575,2576,1],[2579,2600,1],[2602,2608,1],[2610,2611,1],[2613,2614,1],[2616,2617,1],[2620,2622,2],[2623,2626,1],[2631,2632,1],[2635,2637,1],[2641,2649,8],[2650,2652,1],[2654,2662,8],[2663,2678,1]];static Han=[[11904,11929,1],[11931,12019,1],[12032,12245,1],[12293,12295,2],[12321,12329,1],[12344,12347,1],[13312,19903,1],[19968,40959,1],[63744,64109,1],[64112,64217,1],[94178,94179,1],[94192,94193,1],[131072,173791,1],[173824,177977,1],[177984,178205,1],[178208,183969,1],[183984,191456,1],[191472,192093,1],[194560,195101,1],[196608,201546,1],[201552,205743,1]];static Hangul=[[4352,4607,1],[12334,12335,1],[12593,12686,1],[12800,12830,1],[12896,12926,1],[43360,43388,1],[44032,55203,1],[55216,55238,1],[55243,55291,1],[65440,65470,1],[65474,65479,1],[65482,65487,1],[65490,65495,1],[65498,65500,1]];static Hanifi_Rohingya=[[68864,68903,1],[68912,68921,1]];static Hanunoo=[[5920,5940,1]];static Hatran=[[67808,67826,1],[67828,67829,1],[67835,67839,1]];static Hebrew=[[1425,1479,1],[1488,1514,1],[1519,1524,1],[64285,64310,1],[64312,64316,1],[64318,64320,2],[64321,64323,2],[64324,64326,2],[64327,64335,1]];static Hiragana=[[12353,12438,1],[12445,12447,1],[110593,110879,1],[110898,110928,30],[110929,110930,1],[127488,127488,1]];static Imperial_Aramaic=[[67648,67669,1],[67671,67679,1]];static Inherited=[[768,879,1],[1157,1158,1],[1611,1621,1],[1648,2385,737],[2386,2388,1],[6832,6862,1],[7376,7378,1],[7380,7392,1],[7394,7400,1],[7405,7412,7],[7416,7417,1],[7616,7679,1],[8204,8205,1],[8400,8432,1],[12330,12333,1],[12441,12442,1],[65024,65039,1],[65056,65069,1],[66045,66272,227],[70459,118528,48069],[118529,118573,1],[118576,118598,1],[119143,119145,1],[119163,119170,1],[119173,119179,1],[119210,119213,1],[917760,917999,1]];static foldInherited=[[921,953,32],[8126,8126,1]];static Inscriptional_Pahlavi=[[68448,68466,1],[68472,68479,1]];static Inscriptional_Parthian=[[68416,68437,1],[68440,68447,1]];static Javanese=[[43392,43469,1],[43472,43481,1],[43486,43487,1]];static Kaithi=[[69760,69826,1],[69837,69837,1]];static Kannada=[[3200,3212,1],[3214,3216,1],[3218,3240,1],[3242,3251,1],[3253,3257,1],[3260,3268,1],[3270,3272,1],[3274,3277,1],[3285,3286,1],[3293,3294,1],[3296,3299,1],[3302,3311,1],[3313,3315,1]];static Katakana=[[12449,12538,1],[12541,12543,1],[12784,12799,1],[13008,13054,1],[13056,13143,1],[65382,65391,1],[65393,65437,1],[110576,110579,1],[110581,110587,1],[110589,110590,1],[110592,110880,288],[110881,110882,1],[110933,110948,15],[110949,110951,1]];static Kawi=[[73472,73488,1],[73490,73530,1],[73534,73561,1]];static Kayah_Li=[[43264,43309,1],[43311,43311,1]];static Kharoshthi=[[68096,68099,1],[68101,68102,1],[68108,68115,1],[68117,68119,1],[68121,68149,1],[68152,68154,1],[68159,68168,1],[68176,68184,1]];static Khitan_Small_Script=[[94180,101120,6940],[101121,101589,1]];static Khmer=[[6016,6109,1],[6112,6121,1],[6128,6137,1],[6624,6655,1]];static Khojki=[[70144,70161,1],[70163,70209,1]];static Khudawadi=[[70320,70378,1],[70384,70393,1]];static Lao=[[3713,3714,1],[3716,3718,2],[3719,3722,1],[3724,3747,1],[3749,3751,2],[3752,3773,1],[3776,3780,1],[3782,3784,2],[3785,3790,1],[3792,3801,1],[3804,3807,1]];static Latin=[[65,90,1],[97,122,1],[170,186,16],[192,214,1],[216,246,1],[248,696,1],[736,740,1],[7424,7461,1],[7468,7516,1],[7522,7525,1],[7531,7543,1],[7545,7614,1],[7680,7935,1],[8305,8319,14],[8336,8348,1],[8490,8491,1],[8498,8526,28],[8544,8584,1],[11360,11391,1],[42786,42887,1],[42891,42954,1],[42960,42961,1],[42963,42965,2],[42966,42969,1],[42994,43007,1],[43824,43866,1],[43868,43876,1],[43878,43881,1],[64256,64262,1],[65313,65338,1],[65345,65370,1],[67456,67461,1],[67463,67504,1],[67506,67514,1],[122624,122654,1],[122661,122666,1]];static Lepcha=[[7168,7223,1],[7227,7241,1],[7245,7247,1]];static Limbu=[[6400,6430,1],[6432,6443,1],[6448,6459,1],[6464,6468,4],[6469,6479,1]];static Linear_A=[[67072,67382,1],[67392,67413,1],[67424,67431,1]];static Linear_B=[[65536,65547,1],[65549,65574,1],[65576,65594,1],[65596,65597,1],[65599,65613,1],[65616,65629,1],[65664,65786,1]];static Lisu=[[42192,42239,1],[73648,73648,1]];static Lycian=[[66176,66204,1]];static Lydian=[[67872,67897,1],[67903,67903,1]];static Mahajani=[[69968,70006,1]];static Makasar=[[73440,73464,1]];static Malayalam=[[3328,3340,1],[3342,3344,1],[3346,3396,1],[3398,3400,1],[3402,3407,1],[3412,3427,1],[3430,3455,1]];static Mandaic=[[2112,2139,1],[2142,2142,1]];static Manichaean=[[68288,68326,1],[68331,68342,1]];static Marchen=[[72816,72847,1],[72850,72871,1],[72873,72886,1]];static Masaram_Gondi=[[72960,72966,1],[72968,72969,1],[72971,73014,1],[73018,73020,2],[73021,73023,2],[73024,73031,1],[73040,73049,1]];static Medefaidrin=[[93760,93850,1]];static Meetei_Mayek=[[43744,43766,1],[43968,44013,1],[44016,44025,1]];static Mende_Kikakui=[[124928,125124,1],[125127,125142,1]];static Meroitic_Cursive=[[68e3,68023,1],[68028,68047,1],[68050,68095,1]];static Meroitic_Hieroglyphs=[[67968,67999,1]];static Miao=[[93952,94026,1],[94031,94087,1],[94095,94111,1]];static Modi=[[71168,71236,1],[71248,71257,1]];static Mongolian=[[6144,6145,1],[6148,6150,2],[6151,6169,1],[6176,6264,1],[6272,6314,1],[71264,71276,1]];static Mro=[[92736,92766,1],[92768,92777,1],[92782,92783,1]];static Multani=[[70272,70278,1],[70280,70282,2],[70283,70285,1],[70287,70301,1],[70303,70313,1]];static Myanmar=[[4096,4255,1],[43488,43518,1],[43616,43647,1]];static Nabataean=[[67712,67742,1],[67751,67759,1]];static Nag_Mundari=[[124112,124153,1]];static Nandinagari=[[72096,72103,1],[72106,72151,1],[72154,72164,1]];static New_Tai_Lue=[[6528,6571,1],[6576,6601,1],[6608,6618,1],[6622,6623,1]];static Newa=[[70656,70747,1],[70749,70753,1]];static Nko=[[1984,2042,1],[2045,2047,1]];static Nushu=[[94177,110960,16783],[110961,111355,1]];static Nyiakeng_Puachue_Hmong=[[123136,123180,1],[123184,123197,1],[123200,123209,1],[123214,123215,1]];static Ogham=[[5760,5788,1]];static Ol_Chiki=[[7248,7295,1]];static Old_Hungarian=[[68736,68786,1],[68800,68850,1],[68858,68863,1]];static Old_Italic=[[66304,66339,1],[66349,66351,1]];static Old_North_Arabian=[[68224,68255,1]];static Old_Permic=[[66384,66426,1]];static Old_Persian=[[66464,66499,1],[66504,66517,1]];static Old_Sogdian=[[69376,69415,1]];static Old_South_Arabian=[[68192,68223,1]];static Old_Turkic=[[68608,68680,1]];static Old_Uyghur=[[69488,69513,1]];static Oriya=[[2817,2819,1],[2821,2828,1],[2831,2832,1],[2835,2856,1],[2858,2864,1],[2866,2867,1],[2869,2873,1],[2876,2884,1],[2887,2888,1],[2891,2893,1],[2901,2903,1],[2908,2909,1],[2911,2915,1],[2918,2935,1]];static Osage=[[66736,66771,1],[66776,66811,1]];static Osmanya=[[66688,66717,1],[66720,66729,1]];static Pahawh_Hmong=[[92928,92997,1],[93008,93017,1],[93019,93025,1],[93027,93047,1],[93053,93071,1]];static Palmyrene=[[67680,67711,1]];static Pau_Cin_Hau=[[72384,72440,1]];static Phags_Pa=[[43072,43127,1]];static Phoenician=[[67840,67867,1],[67871,67871,1]];static Psalter_Pahlavi=[[68480,68497,1],[68505,68508,1],[68521,68527,1]];static Rejang=[[43312,43347,1],[43359,43359,1]];static Runic=[[5792,5866,1],[5870,5880,1]];static Samaritan=[[2048,2093,1],[2096,2110,1]];static Saurashtra=[[43136,43205,1],[43214,43225,1]];static Sharada=[[70016,70111,1]];static Shavian=[[66640,66687,1]];static Siddham=[[71040,71093,1],[71096,71133,1]];static SignWriting=[[120832,121483,1],[121499,121503,1],[121505,121519,1]];static Sinhala=[[3457,3459,1],[3461,3478,1],[3482,3505,1],[3507,3515,1],[3517,3520,3],[3521,3526,1],[3530,3535,5],[3536,3540,1],[3542,3544,2],[3545,3551,1],[3558,3567,1],[3570,3572,1],[70113,70132,1]];static Sogdian=[[69424,69465,1]];static Sora_Sompeng=[[69840,69864,1],[69872,69881,1]];static Soyombo=[[72272,72354,1]];static Sundanese=[[7040,7103,1],[7360,7367,1]];static Syloti_Nagri=[[43008,43052,1]];static Syriac=[[1792,1805,1],[1807,1866,1],[1869,1871,1],[2144,2154,1]];static Tagalog=[[5888,5909,1],[5919,5919,1]];static Tagbanwa=[[5984,5996,1],[5998,6e3,1],[6002,6003,1]];static Tai_Le=[[6480,6509,1],[6512,6516,1]];static Tai_Tham=[[6688,6750,1],[6752,6780,1],[6783,6793,1],[6800,6809,1],[6816,6829,1]];static Tai_Viet=[[43648,43714,1],[43739,43743,1]];static Takri=[[71296,71353,1],[71360,71369,1]];static Tamil=[[2946,2947,1],[2949,2954,1],[2958,2960,1],[2962,2965,1],[2969,2970,1],[2972,2974,2],[2975,2979,4],[2980,2984,4],[2985,2986,1],[2990,3001,1],[3006,3010,1],[3014,3016,1],[3018,3021,1],[3024,3031,7],[3046,3066,1],[73664,73713,1],[73727,73727,1]];static Tangsa=[[92784,92862,1],[92864,92873,1]];static Tangut=[[94176,94208,32],[94209,100343,1],[100352,101119,1],[101632,101640,1]];static Telugu=[[3072,3084,1],[3086,3088,1],[3090,3112,1],[3114,3129,1],[3132,3140,1],[3142,3144,1],[3146,3149,1],[3157,3158,1],[3160,3162,1],[3165,3168,3],[3169,3171,1],[3174,3183,1],[3191,3199,1]];static Thaana=[[1920,1969,1]];static Thai=[[3585,3642,1],[3648,3675,1]];static Tibetan=[[3840,3911,1],[3913,3948,1],[3953,3991,1],[3993,4028,1],[4030,4044,1],[4046,4052,1],[4057,4058,1]];static Tifinagh=[[11568,11623,1],[11631,11632,1],[11647,11647,1]];static Tirhuta=[[70784,70855,1],[70864,70873,1]];static Toto=[[123536,123566,1]];static Ugaritic=[[66432,66461,1],[66463,66463,1]];static Vai=[[42240,42539,1]];static Vithkuqi=[[66928,66938,1],[66940,66954,1],[66956,66962,1],[66964,66965,1],[66967,66977,1],[66979,66993,1],[66995,67001,1],[67003,67004,1]];static Wancho=[[123584,123641,1],[123647,123647,1]];static Warang_Citi=[[71840,71922,1],[71935,71935,1]];static Yezidi=[[69248,69289,1],[69291,69293,1],[69296,69297,1]];static Yi=[[40960,42124,1],[42128,42182,1]];static Zanabazar_Square=[[72192,72263,1]];static CATEGORIES=new Map([[`C`,e.C],[`Cc`,e.Cc],[`Cf`,e.Cf],[`Co`,e.Co],[`Cs`,e.Cs],[`L`,e.L],[`Ll`,e.Ll],[`Lm`,e.Lm],[`Lo`,e.Lo],[`Lt`,e.Lt],[`Lu`,e.Lu],[`M`,e.M],[`Mc`,e.Mc],[`Me`,e.Me],[`Mn`,e.Mn],[`N`,e.N],[`Nd`,e.Nd],[`Nl`,e.Nl],[`No`,e.No],[`P`,e.P],[`Pc`,e.Pc],[`Pd`,e.Pd],[`Pe`,e.Pe],[`Pf`,e.Pf],[`Pi`,e.Pi],[`Po`,e.Po],[`Ps`,e.Ps],[`S`,e.S],[`Sc`,e.Sc],[`Sk`,e.Sk],[`Sm`,e.Sm],[`So`,e.So],[`Z`,e.Z],[`Zl`,e.Zl],[`Zp`,e.Zp],[`Zs`,e.Zs]]);static SCRIPTS=new Map([[`Adlam`,e.Adlam],[`Ahom`,e.Ahom],[`Anatolian_Hieroglyphs`,e.Anatolian_Hieroglyphs],[`Arabic`,e.Arabic],[`Armenian`,e.Armenian],[`Avestan`,e.Avestan],[`Balinese`,e.Balinese],[`Bamum`,e.Bamum],[`Bassa_Vah`,e.Bassa_Vah],[`Batak`,e.Batak],[`Bengali`,e.Bengali],[`Bhaiksuki`,e.Bhaiksuki],[`Bopomofo`,e.Bopomofo],[`Brahmi`,e.Brahmi],[`Braille`,e.Braille],[`Buginese`,e.Buginese],[`Buhid`,e.Buhid],[`Canadian_Aboriginal`,e.Canadian_Aboriginal],[`Carian`,e.Carian],[`Caucasian_Albanian`,e.Caucasian_Albanian],[`Chakma`,e.Chakma],[`Cham`,e.Cham],[`Cherokee`,e.Cherokee],[`Chorasmian`,e.Chorasmian],[`Common`,e.Common],[`Coptic`,e.Coptic],[`Cuneiform`,e.Cuneiform],[`Cypriot`,e.Cypriot],[`Cypro_Minoan`,e.Cypro_Minoan],[`Cyrillic`,e.Cyrillic],[`Deseret`,e.Deseret],[`Devanagari`,e.Devanagari],[`Dives_Akuru`,e.Dives_Akuru],[`Dogra`,e.Dogra],[`Duployan`,e.Duployan],[`Egyptian_Hieroglyphs`,e.Egyptian_Hieroglyphs],[`Elbasan`,e.Elbasan],[`Elymaic`,e.Elymaic],[`Ethiopic`,e.Ethiopic],[`Georgian`,e.Georgian],[`Glagolitic`,e.Glagolitic],[`Gothic`,e.Gothic],[`Grantha`,e.Grantha],[`Greek`,e.Greek],[`Gujarati`,e.Gujarati],[`Gunjala_Gondi`,e.Gunjala_Gondi],[`Gurmukhi`,e.Gurmukhi],[`Han`,e.Han],[`Hangul`,e.Hangul],[`Hanifi_Rohingya`,e.Hanifi_Rohingya],[`Hanunoo`,e.Hanunoo],[`Hatran`,e.Hatran],[`Hebrew`,e.Hebrew],[`Hiragana`,e.Hiragana],[`Imperial_Aramaic`,e.Imperial_Aramaic],[`Inherited`,e.Inherited],[`Inscriptional_Pahlavi`,e.Inscriptional_Pahlavi],[`Inscriptional_Parthian`,e.Inscriptional_Parthian],[`Javanese`,e.Javanese],[`Kaithi`,e.Kaithi],[`Kannada`,e.Kannada],[`Katakana`,e.Katakana],[`Kawi`,e.Kawi],[`Kayah_Li`,e.Kayah_Li],[`Kharoshthi`,e.Kharoshthi],[`Khitan_Small_Script`,e.Khitan_Small_Script],[`Khmer`,e.Khmer],[`Khojki`,e.Khojki],[`Khudawadi`,e.Khudawadi],[`Lao`,e.Lao],[`Latin`,e.Latin],[`Lepcha`,e.Lepcha],[`Limbu`,e.Limbu],[`Linear_A`,e.Linear_A],[`Linear_B`,e.Linear_B],[`Lisu`,e.Lisu],[`Lycian`,e.Lycian],[`Lydian`,e.Lydian],[`Mahajani`,e.Mahajani],[`Makasar`,e.Makasar],[`Malayalam`,e.Malayalam],[`Mandaic`,e.Mandaic],[`Manichaean`,e.Manichaean],[`Marchen`,e.Marchen],[`Masaram_Gondi`,e.Masaram_Gondi],[`Medefaidrin`,e.Medefaidrin],[`Meetei_Mayek`,e.Meetei_Mayek],[`Mende_Kikakui`,e.Mende_Kikakui],[`Meroitic_Cursive`,e.Meroitic_Cursive],[`Meroitic_Hieroglyphs`,e.Meroitic_Hieroglyphs],[`Miao`,e.Miao],[`Modi`,e.Modi],[`Mongolian`,e.Mongolian],[`Mro`,e.Mro],[`Multani`,e.Multani],[`Myanmar`,e.Myanmar],[`Nabataean`,e.Nabataean],[`Nag_Mundari`,e.Nag_Mundari],[`Nandinagari`,e.Nandinagari],[`New_Tai_Lue`,e.New_Tai_Lue],[`Newa`,e.Newa],[`Nko`,e.Nko],[`Nushu`,e.Nushu],[`Nyiakeng_Puachue_Hmong`,e.Nyiakeng_Puachue_Hmong],[`Ogham`,e.Ogham],[`Ol_Chiki`,e.Ol_Chiki],[`Old_Hungarian`,e.Old_Hungarian],[`Old_Italic`,e.Old_Italic],[`Old_North_Arabian`,e.Old_North_Arabian],[`Old_Permic`,e.Old_Permic],[`Old_Persian`,e.Old_Persian],[`Old_Sogdian`,e.Old_Sogdian],[`Old_South_Arabian`,e.Old_South_Arabian],[`Old_Turkic`,e.Old_Turkic],[`Old_Uyghur`,e.Old_Uyghur],[`Oriya`,e.Oriya],[`Osage`,e.Osage],[`Osmanya`,e.Osmanya],[`Pahawh_Hmong`,e.Pahawh_Hmong],[`Palmyrene`,e.Palmyrene],[`Pau_Cin_Hau`,e.Pau_Cin_Hau],[`Phags_Pa`,e.Phags_Pa],[`Phoenician`,e.Phoenician],[`Psalter_Pahlavi`,e.Psalter_Pahlavi],[`Rejang`,e.Rejang],[`Runic`,e.Runic],[`Samaritan`,e.Samaritan],[`Saurashtra`,e.Saurashtra],[`Sharada`,e.Sharada],[`Shavian`,e.Shavian],[`Siddham`,e.Siddham],[`SignWriting`,e.SignWriting],[`Sinhala`,e.Sinhala],[`Sogdian`,e.Sogdian],[`Sora_Sompeng`,e.Sora_Sompeng],[`Soyombo`,e.Soyombo],[`Sundanese`,e.Sundanese],[`Syloti_Nagri`,e.Syloti_Nagri],[`Syriac`,e.Syriac],[`Tagalog`,e.Tagalog],[`Tagbanwa`,e.Tagbanwa],[`Tai_Le`,e.Tai_Le],[`Tai_Tham`,e.Tai_Tham],[`Tai_Viet`,e.Tai_Viet],[`Takri`,e.Takri],[`Tamil`,e.Tamil],[`Tangsa`,e.Tangsa],[`Tangut`,e.Tangut],[`Telugu`,e.Telugu],[`Thaana`,e.Thaana],[`Thai`,e.Thai],[`Tibetan`,e.Tibetan],[`Tifinagh`,e.Tifinagh],[`Tirhuta`,e.Tirhuta],[`Toto`,e.Toto],[`Ugaritic`,e.Ugaritic],[`Vai`,e.Vai],[`Vithkuqi`,e.Vithkuqi],[`Wancho`,e.Wancho],[`Warang_Citi`,e.Warang_Citi],[`Yezidi`,e.Yezidi],[`Yi`,e.Yi],[`Zanabazar_Square`,e.Zanabazar_Square]]);static FOLD_CATEGORIES=new Map([[`L`,e.foldL],[`Ll`,e.foldLl],[`Lt`,e.foldLt],[`Lu`,e.foldLu],[`M`,e.foldM],[`Mn`,e.foldMn]]);static FOLD_SCRIPT=new Map([[`Common`,e.foldCommon],[`Greek`,e.foldGreek],[`Inherited`,e.foldInherited]])},C=class{static MAX_RUNE=1114111;static MAX_ASCII=127;static MAX_LATIN1=255;static MAX_BMP=65535;static MIN_FOLD=65;static MAX_FOLD=125251;static is32(e,t){let n=0,r=e.length;for(;n<r;){let i=n+Math.floor((r-n)/2),a=e[i];if(a[0]<=t&&t<=a[1])return(t-a[0])%a[2]===0;t<a[0]?r=i:n=i+1}return!1}static is(e,t){if(t<=this.MAX_LATIN1){for(let n of e)if(!(t>n[1]))return t<n[0]?!1:(t-n[0])%n[2]===0;return!1}return e.length>0&&t>=e[0][0]&&this.is32(e,t)}static isUpper(e){if(e<=this.MAX_LATIN1){let t=String.fromCodePoint(e);return t.toUpperCase()===t&&t.toLowerCase()!==t}return this.is(S.Upper,e)}static isPrint(e){return e<=this.MAX_LATIN1?e>=32&&e<127||e>=161&&e!==173:this.is(S.L,e)||this.is(S.M,e)||this.is(S.N,e)||this.is(S.P,e)||this.is(S.S,e)}static simpleFold(e){if(S.CASE_ORBIT.has(e))return S.CASE_ORBIT.get(e);let t=x.toLowerCase(e);return t===e?x.toUpperCase(e):t}static equalsIgnoreCase(e,t){if(e<0||t<0||e===t)return!0;if(e<=this.MAX_ASCII&&t<=this.MAX_ASCII)return x.CODES.get(`A`)<=e&&e<=x.CODES.get(`Z`)&&(e|=32),x.CODES.get(`A`)<=t&&t<=x.CODES.get(`Z`)&&(t|=32),e===t;for(let n=this.simpleFold(e);n!==e;n=this.simpleFold(n))if(n===t)return!0;return!1}},w=class{static METACHARACTERS=`\\.+*?()|[]{}^$`;static EMPTY_BEGIN_LINE=1;static EMPTY_END_LINE=2;static EMPTY_BEGIN_TEXT=4;static EMPTY_END_TEXT=8;static EMPTY_WORD_BOUNDARY=16;static EMPTY_NO_WORD_BOUNDARY=32;static EMPTY_ALL=-1;static emptyInts(){return[]}static isalnum(e){return x.CODES.get(`0`)<=e&&e<=x.CODES.get(`9`)||x.CODES.get(`a`)<=e&&e<=x.CODES.get(`z`)||x.CODES.get(`A`)<=e&&e<=x.CODES.get(`Z`)}static unhex(e){return x.CODES.get(`0`)<=e&&e<=x.CODES.get(`9`)?e-x.CODES.get(`0`):x.CODES.get(`a`)<=e&&e<=x.CODES.get(`f`)?e-x.CODES.get(`a`)+10:x.CODES.get(`A`)<=e&&e<=x.CODES.get(`F`)?e-x.CODES.get(`A`)+10:-1}static escapeRune(e){let t=``;if(C.isPrint(e))this.METACHARACTERS.indexOf(String.fromCodePoint(e))>=0&&(t+=`\\`),t+=String.fromCodePoint(e);else switch(e){case x.CODES.get(`"`):t+=`\\"`;break;case x.CODES.get(`\\`):t+=`\\\\`;break;case x.CODES.get(` `):t+=`\\t`;break;case x.CODES.get(`
11
+ `):t+=`\\n`;break;case x.CODES.get(`\r`):t+=`\\r`;break;case x.CODES.get(`\b`):t+=`\\b`;break;case x.CODES.get(`\f`):t+=`\\f`;break;default:{let n=e.toString(16);e<256?(t+=`\\x`,n.length===1&&(t+=`0`),t+=n):t+=`\\x{${n}}`;break}}return t}static stringToRunes(e){return String(e).split(``).map(e=>e.codePointAt(0))}static runeToString(e){return String.fromCodePoint(e)}static isWordRune(e){return x.CODES.get(`a`)<=e&&e<=x.CODES.get(`z`)||x.CODES.get(`A`)<=e&&e<=x.CODES.get(`Z`)||x.CODES.get(`0`)<=e&&e<=x.CODES.get(`9`)||e===x.CODES.get(`_`)}static emptyOpContext(e,t){let n=0;return e<0&&(n|=this.EMPTY_BEGIN_TEXT|this.EMPTY_BEGIN_LINE),e===x.CODES.get(`
12
+ `)&&(n|=this.EMPTY_BEGIN_LINE),t<0&&(n|=this.EMPTY_END_TEXT|this.EMPTY_END_LINE),t===x.CODES.get(`
13
+ `)&&(n|=this.EMPTY_END_LINE),this.isWordRune(e)===this.isWordRune(t)?n|=this.EMPTY_NO_WORD_BOUNDARY:n|=this.EMPTY_WORD_BOUNDARY,n}static quoteMeta(e){return e.split(``).map(e=>this.METACHARACTERS.indexOf(e)>=0?`\\${e}`:e).join(``)}static charCount(e){return e>C.MAX_BMP?2:1}static stringToUtf8ByteArray(e){if(globalThis.TextEncoder)return Array.from(new TextEncoder().encode(e));{let t=[],n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=i&63|128):(i&64512)==55296&&r+1<e.length&&(e.charCodeAt(r+1)&64512)==56320?(i=65536+((i&1023)<<10)+(e.charCodeAt(++r)&1023),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=i&63|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=i&63|128)}return t}}static utf8ByteArrayToString(e){if(globalThis.TextDecoder)return new TextDecoder(`utf-8`).decode(new Uint8Array(e));{let t=[],n=0,r=0;for(;n<e.length;){let i=e[n++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){let a=e[n++];t[r++]=String.fromCharCode((i&31)<<6|a&63)}else if(i>239&&i<365){let a=e[n++],o=e[n++],s=e[n++],c=((i&7)<<18|(a&63)<<12|(o&63)<<6|s&63)-65536;t[r++]=String.fromCharCode(55296+(c>>10)),t[r++]=String.fromCharCode(56320+(c&1023))}else{let a=e[n++],o=e[n++];t[r++]=String.fromCharCode((i&15)<<12|(a&63)<<6|o&63)}}return t.join(``)}}},Fn=(e=[],t=0)=>{let n={};for(let r=0;r<e.length;r++){let i=e[r],a=t+r;n[i]=a,n[a]=i}return Object.freeze(n)},In=class e{static Encoding=Fn([`UTF_16`,`UTF_8`]);getEncoding(){throw Error(`not implemented`)}isUTF8Encoding(){return this.getEncoding()===e.Encoding.UTF_8}isUTF16Encoding(){return this.getEncoding()===e.Encoding.UTF_16}},Ln=class extends In{constructor(e=null){super(),this.bytes=e}getEncoding(){return In.Encoding.UTF_8}asCharSequence(){return w.utf8ByteArrayToString(this.bytes)}asBytes(){return this.bytes}length(){return this.bytes.length}},Rn=class extends In{constructor(e=null){super(),this.charSequence=e}getEncoding(){return In.Encoding.UTF_16}asCharSequence(){return this.charSequence}asBytes(){return this.charSequence.toString().split(``).map(e=>e.codePointAt(0))}length(){return this.charSequence.length}},zn=class{static utf16(e){return new Rn(e)}static utf8(e){return Array.isArray(e)?new Ln(e):new Ln(w.stringToUtf8ByteArray(e))}},Bn=class extends Error{constructor(e){super(e),this.name=`RE2JSException`}},T=class extends Bn{constructor(e,t=null){let n=`error parsing regexp: ${e}`;t&&(n+=`: \`${t}\``),super(n),this.name=`RE2JSSyntaxException`,this.message=n,this.error=e,this.input=t}getDescription(){return this.error}getPattern(){return this.input}},Vn=class extends Bn{constructor(e){super(e),this.name=`RE2JSCompileException`}},Hn=class extends Bn{constructor(e){super(e),this.name=`RE2JSGroupException`}},Un=class extends Bn{constructor(e){super(e),this.name=`RE2JSFlagsException`}},Wn=class{static quoteReplacement(e){return e.indexOf(`\\`)<0&&e.indexOf(`$`)<0?e:e.split(``).map(e=>{let t=e.codePointAt(0);return t===x.CODES[`\\`]||t===x.CODES.$?`\\${e}`:e}).join(``)}constructor(e,t){if(e===null)throw Error(`pattern is null`);this.patternInput=e;let n=this.patternInput.re2();this.patternGroupCount=n.numberOfCapturingGroups(),this.groups=[],this.namedGroups=n.namedGroups,t instanceof In?this.resetMatcherInput(t):Array.isArray(t)?this.resetMatcherInput(zn.utf8(t)):this.resetMatcherInput(zn.utf16(t))}pattern(){return this.patternInput}reset(){return this.matcherInputLength=this.matcherInput.length(),this.appendPos=0,this.hasMatch=!1,this.hasGroups=!1,this.anchorFlag=0,this}resetMatcherInput(e){if(e===null)throw Error(`input is null`);return this.matcherInput=e,this.reset(),this}start(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new Hn(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e]}end(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new Hn(`group '${e}' not found`);e=t}return this.loadGroup(e),this.groups[2*e+1]}group(e=0){if(typeof e==`string`){let t=this.namedGroups[e];if(!Number.isFinite(t))throw new Hn(`group '${e}' not found`);e=t}let t=this.start(e),n=this.end(e);return t<0&&n<0?null:this.substring(t,n)}groupCount(){return this.patternGroupCount}loadGroup(e){if(e<0||e>this.patternGroupCount)throw new Hn(`Group index out of bounds: ${e}`);if(!this.hasMatch)throw new Hn(`perhaps no match attempted`);if(e===0||this.hasGroups)return;let t=this.groups[1]+1;t>this.matcherInputLength&&(t=this.matcherInputLength);let n=this.patternInput.re2().matchMachineInput(this.matcherInput,this.groups[0],t,this.anchorFlag,1+this.patternGroupCount);if(!n[0])throw new Hn(`inconsistency in matching group data`);this.groups=n[1],this.hasGroups=!0}matches(){return this.genMatch(0,b.ANCHOR_BOTH)}lookingAt(){return this.genMatch(0,b.ANCHOR_START)}find(e=null){if(e!==null){if(e<0||e>this.matcherInputLength)throw new Hn(`start index out of bounds: ${e}`);return this.reset(),this.genMatch(e,0)}return e=0,this.hasMatch&&(e=this.groups[1],this.groups[0]===this.groups[1]&&e++),this.genMatch(e,b.UNANCHORED)}genMatch(e,t){let n=this.patternInput.re2().matchMachineInput(this.matcherInput,e,this.matcherInputLength,t,1);return n[0]?(this.groups=n[1],this.hasMatch=!0,this.hasGroups=!1,this.anchorFlag=t,!0):!1}substring(e,t){return this.matcherInput.isUTF8Encoding()?w.utf8ByteArrayToString(this.matcherInput.asBytes().slice(e,t)):this.matcherInput.asCharSequence().substring(e,t).toString()}inputLength(){return this.matcherInputLength}appendReplacement(e,t=!1){let n=``,r=this.start(),i=this.end();return this.appendPos<r&&(n+=this.substring(this.appendPos,r)),this.appendPos=i,n+=t?this.appendReplacementInternalPerl(e):this.appendReplacementInternal(e),n}appendReplacementInternal(e){let t=``,n=0,r=e.length;for(let i=0;i<r-1;i++){if(e.codePointAt(i)===x.CODES.get(`\\`)){n<i&&(t+=e.substring(n,i)),i++,n=i;continue}if(e.codePointAt(i)===x.CODES.get(`$`)){let a=e.codePointAt(i+1);if(x.CODES.get(`0`)<=a&&a<=x.CODES.get(`9`)){let o=a-x.CODES.get(`0`);for(n<i&&(t+=e.substring(n,i)),i+=2;i<r&&(a=e.codePointAt(i),!(a<x.CODES.get(`0`)||a>x.CODES.get(`9`)||o*10+a-x.CODES.get(`0`)>this.patternGroupCount));i++)o=o*10+a-x.CODES.get(`0`);if(o>this.patternGroupCount)throw new Hn(`n > number of groups: ${o}`);let s=this.group(o);s!==null&&(t+=s),n=i,i--;continue}else if(a===x.CODES.get(`{`)){n<i&&(t+=e.substring(n,i)),i++;let r=i+1;for(;r<e.length&&e.codePointAt(r)!==x.CODES.get(`}`)&&e.codePointAt(r)!==x.CODES.get(` `);)r++;if(r===e.length||e.codePointAt(r)!==x.CODES.get(`}`))throw new Hn(`named capture group is missing trailing '}'`);let a=e.substring(i+1,r);t+=this.group(a),n=r+1}}}return n<r&&(t+=e.substring(n,r)),t}appendReplacementInternalPerl(e){let t=``,n=0,r=e.length;for(let i=0;i<r-1;i++)if(e.codePointAt(i)===x.CODES.get(`$`)){let a=e.codePointAt(i+1);if(x.CODES.get(`$`)===a){n<i&&(t+=e.substring(n,i)),t+=`$`,i++,n=i+1;continue}else if(x.CODES.get(`&`)===a){n<i&&(t+=e.substring(n,i));let r=this.group(0);r===null?t+=`$&`:t+=r,i++,n=i+1;continue}else if(x.CODES.get(`1`)<=a&&a<=x.CODES.get(`9`)){let o=a-x.CODES.get(`0`);for(n<i&&(t+=e.substring(n,i)),i+=2;i<r&&(a=e.codePointAt(i),!(a<x.CODES.get(`0`)||a>x.CODES.get(`9`)||o*10+a-x.CODES.get(`0`)>this.patternGroupCount));i++)o=o*10+a-x.CODES.get(`0`);if(o>this.patternGroupCount){t+=`$${o}`,n=i,i--;continue}let s=this.group(o);s!==null&&(t+=s),n=i,i--;continue}else if(a===x.CODES.get(`<`)){n<i&&(t+=e.substring(n,i)),i++;let r=i+1;for(;r<e.length&&e.codePointAt(r)!==x.CODES.get(`>`)&&e.codePointAt(r)!==x.CODES.get(` `);)r++;if(r===e.length||e.codePointAt(r)!==x.CODES.get(`>`)){t+=e.substring(i-1,r+1),n=r+1;continue}let a=e.substring(i+1,r);Object.prototype.hasOwnProperty.call(this.namedGroups,a)?t+=this.group(a):t+=`$<${a}>`,n=r+1}}return n<r&&(t+=e.substring(n,r)),t}appendTail(){return this.substring(this.appendPos,this.matcherInputLength)}replaceAll(e,t=!1){return this.replace(e,!0,t)}replaceFirst(e,t=!1){return this.replace(e,!1,t)}replace(e,t=!0,n=!1){let r=``;for(this.reset();this.find()&&(r+=this.appendReplacement(e,n),t););return r+=this.appendTail(),r}},Gn=class{static EOF(){return-8}canCheckPrefix(){return!0}endPos(){return this.end}},Kn=class extends Gn{constructor(e,t=0,n=e.length){super(),this.bytes=e,this.start=t,this.end=n}step(e){if(e+=this.start,e>=this.end)return Gn.EOF();let t=this.bytes[e++]&255;return t&128?(t&224)==192?(t&=31,e>=this.end?Gn.EOF():(t=t<<6|this.bytes[e++]&63,t<<3|2)):(t&240)==224?(t&=15,e+1>=this.end?Gn.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|3)):(t&=7,e+2>=this.end?Gn.EOF():(t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t=t<<6|this.bytes[e++]&63,t<<3|4)):t<<3|1}index(e,t){t+=this.start;let n=this.indexOf(this.bytes,e.prefixUTF8,t);return n<0?n:n-t}context(e){e+=this.start;let t=-1;if(e>this.start&&e<=this.end){let n=e-1;if(t=this.bytes[n--],t>=128){let r=e-4;for(r<this.start&&(r=this.start);n>=r&&(this.bytes[n]&192)==128;)n--;n<this.start&&(n=this.start),t=this.step(n)>>3}}let n=e<this.end?this.step(e)>>3:-1;return w.emptyOpContext(t,n)}indexOf(e,t,n=0){let r=t.length;if(r===0)return-1;let i=e.length;for(let a=n;a<=i-r;a++)for(let n=0;n<r&&e[a+n]===t[n];n++)if(n===r-1)return a;return-1}},qn=class extends Gn{constructor(e,t=0,n=e.length){super(),this.charSequence=e,this.start=t,this.end=n}step(e){if(e+=this.start,e<this.end){let t=this.charSequence.codePointAt(e);return t<<3|w.charCount(t)}else return Gn.EOF()}index(e,t){t+=this.start;let n=this.charSequence.indexOf(e.prefix,t);return n<0?n:n-t}context(e){e+=this.start;let t=e>0&&e<=this.charSequence.length?this.charSequence.codePointAt(e-1):-1,n=e<this.charSequence.length?this.charSequence.codePointAt(e):-1;return w.emptyOpContext(t,n)}},E=class{static fromUTF8(e,t=0,n=e.length){return new Kn(e,t,n)}static fromUTF16(e,t=0,n=e.length){return new qn(e,t,n)}},D=class e{static Op=Fn([`NO_MATCH`,`EMPTY_MATCH`,`LITERAL`,`CHAR_CLASS`,`ANY_CHAR_NOT_NL`,`ANY_CHAR`,`BEGIN_LINE`,`END_LINE`,`BEGIN_TEXT`,`END_TEXT`,`WORD_BOUNDARY`,`NO_WORD_BOUNDARY`,`CAPTURE`,`STAR`,`PLUS`,`QUEST`,`REPEAT`,`CONCAT`,`ALTERNATE`,`LEFT_PAREN`,`VERTICAL_BAR`]);static isPseudoOp(t){return t>=e.Op.LEFT_PAREN}static emptySubs(){return[]}static quoteIfHyphen(e){return e===x.CODES.get(`-`)?`\\`:``}static fromRegexp(t){let n=new e(t.op);return n.flags=t.flags,n.subs=t.subs,n.runes=t.runes,n.cap=t.cap,n.min=t.min,n.max=t.max,n.name=t.name,n.namedGroups=t.namedGroups,n}constructor(t){this.op=t,this.flags=0,this.subs=e.emptySubs(),this.runes=null,this.min=0,this.max=0,this.cap=0,this.name=null,this.namedGroups={}}reinit(){this.flags=0,this.subs=e.emptySubs(),this.runes=null,this.cap=0,this.min=0,this.max=0,this.name=null,this.namedGroups={}}toString(){return this.appendTo()}appendTo(){let t=``;switch(this.op){case e.Op.NO_MATCH:t+=`[^\\x00-\\x{10FFFF}]`;break;case e.Op.EMPTY_MATCH:t+=`(?:)`;break;case e.Op.STAR:case e.Op.PLUS:case e.Op.QUEST:case e.Op.REPEAT:{let n=this.subs[0];switch(n.op>e.Op.CAPTURE||n.op===e.Op.LITERAL&&n.runes.length>1?t+=`(?:${n.appendTo()})`:t+=n.appendTo(),this.op){case e.Op.STAR:t+=`*`;break;case e.Op.PLUS:t+=`+`;break;case e.Op.QUEST:t+=`?`;break;case e.Op.REPEAT:t+=`{${this.min}`,this.min!==this.max&&(t+=`,`,this.max>=0&&(t+=this.max)),t+=`}`;break}(this.flags&b.NON_GREEDY)!==0&&(t+=`?`);break}case e.Op.CONCAT:for(let n of this.subs)n.op===e.Op.ALTERNATE?t+=`(?:${n.appendTo()})`:t+=n.appendTo();break;case e.Op.ALTERNATE:{let e=``;for(let n of this.subs)t+=e,e=`|`,t+=n.appendTo();break}case e.Op.LITERAL:(this.flags&b.FOLD_CASE)!==0&&(t+=`(?i:`);for(let e of this.runes)t+=w.escapeRune(e);(this.flags&b.FOLD_CASE)!==0&&(t+=`)`);break;case e.Op.ANY_CHAR_NOT_NL:t+=`(?-s:.)`;break;case e.Op.ANY_CHAR:t+=`(?s:.)`;break;case e.Op.CAPTURE:this.name===null||this.name.length===0?t+=`(`:t+=`(?P<${this.name}>`,this.subs[0].op!==e.Op.EMPTY_MATCH&&(t+=this.subs[0].appendTo()),t+=`)`;break;case e.Op.BEGIN_TEXT:t+=`\\A`;break;case e.Op.END_TEXT:(this.flags&b.WAS_DOLLAR)===0?t+=`\\z`:t+=`(?-m:$)`;break;case e.Op.BEGIN_LINE:t+=`^`;break;case e.Op.END_LINE:t+=`$`;break;case e.Op.WORD_BOUNDARY:t+=`\\b`;break;case e.Op.NO_WORD_BOUNDARY:t+=`\\B`;break;case e.Op.CHAR_CLASS:if(this.runes.length%2!=0){t+=`[invalid char class]`;break}if(t+=`[`,this.runes.length===0)t+=`^\\x00-\\x{10FFFF}`;else if(this.runes[0]===0&&this.runes[this.runes.length-1]===C.MAX_RUNE){t+=`^`;for(let n=1;n<this.runes.length-1;n+=2){let r=this.runes[n]+1,i=this.runes[n+1]-1;t+=e.quoteIfHyphen(r),t+=w.escapeRune(r),r!==i&&(t+=`-`,t+=e.quoteIfHyphen(i),t+=w.escapeRune(i))}}else for(let n=0;n<this.runes.length;n+=2){let r=this.runes[n],i=this.runes[n+1];t+=e.quoteIfHyphen(r),t+=w.escapeRune(r),r!==i&&(t+=`-`,t+=e.quoteIfHyphen(i),t+=w.escapeRune(i))}t+=`]`;break;default:t+=this.op;break}return t}maxCap(){let t=0;if(this.op===e.Op.CAPTURE&&(t=this.cap),this.subs!==null)for(let e of this.subs){let n=e.maxCap();t<n&&(t=n)}return t}equals(t){if(!(t!==null&&t instanceof e)||this.op!==t.op)return!1;switch(this.op){case e.Op.END_TEXT:if((this.flags&b.WAS_DOLLAR)!==(t.flags&b.WAS_DOLLAR))return!1;break;case e.Op.LITERAL:case e.Op.CHAR_CLASS:if(this.runes===null&&t.runes===null)break;if(this.runes===null||t.runes===null||this.runes.length!==t.runes.length)return!1;for(let e=0;e<this.runes.length;e++)if(this.runes[e]!==t.runes[e])return!1;break;case e.Op.ALTERNATE:case e.Op.CONCAT:if(this.subs.length!==t.subs.length)return!1;for(let e=0;e<this.subs.length;++e)if(!this.subs[e].equals(t.subs[e]))return!1;break;case e.Op.STAR:case e.Op.PLUS:case e.Op.QUEST:if((this.flags&b.NON_GREEDY)!==(t.flags&b.NON_GREEDY)||!this.subs[0].equals(t.subs[0]))return!1;break;case e.Op.REPEAT:if((this.flags&b.NON_GREEDY)!==(t.flags&b.NON_GREEDY)||this.min!==t.min||this.max!==t.max||!this.subs[0].equals(t.subs[0]))return!1;break;case e.Op.CAPTURE:if(this.cap!==t.cap||(this.name===null?t.name!==null:this.name!==t.name)||!this.subs[0].equals(t.subs[0]))return!1;break}return!0}},O=class e{static ALT=1;static ALT_MATCH=2;static CAPTURE=3;static EMPTY_WIDTH=4;static FAIL=5;static MATCH=6;static NOP=7;static RUNE=8;static RUNE1=9;static RUNE_ANY=10;static RUNE_ANY_NOT_NL=11;static isRuneOp(t){return e.RUNE<=t&&t<=e.RUNE_ANY_NOT_NL}static escapeRunes(e){let t=`"`;for(let n of e)t+=w.escapeRune(n);return t+=`"`,t}constructor(e){this.op=e,this.out=0,this.arg=0,this.runes=null}matchRune(e){if(this.runes.length===1){let t=this.runes[0];return(this.arg&b.FOLD_CASE)===0?e===t:C.equalsIgnoreCase(t,e)}for(let t=0;t<this.runes.length&&t<=8;t+=2){if(e<this.runes[t])return!1;if(e<=this.runes[t+1])return!0}let t=0,n=this.runes.length/2|0;for(;t<n;){let r=t+((n-t)/2|0);if(this.runes[2*r]<=e){if(e<=this.runes[2*r+1])return!0;t=r+1}else n=r}return!1}toString(){switch(this.op){case e.ALT:return`alt -> ${this.out}, ${this.arg}`;case e.ALT_MATCH:return`altmatch -> ${this.out}, ${this.arg}`;case e.CAPTURE:return`cap ${this.arg} -> ${this.out}`;case e.EMPTY_WIDTH:return`empty ${this.arg} -> ${this.out}`;case e.MATCH:return`match`;case e.FAIL:return`fail`;case e.NOP:return`nop -> ${this.out}`;case e.RUNE:return this.runes===null?`rune <null>`:[`rune `,e.escapeRunes(this.runes),(this.arg&b.FOLD_CASE)===0?``:`/i`,` -> `,this.out].join(``);case e.RUNE1:return`rune1 ${e.escapeRunes(this.runes)} -> ${this.out}`;case e.RUNE_ANY:return`any -> ${this.out}`;case e.RUNE_ANY_NOT_NL:return`anynotnl -> ${this.out}`;default:throw Error(`unhandled case in Inst.toString`)}}},Jn=class{constructor(){this.inst=[],this.start=0,this.numCap=2}getInst(e){return this.inst[e]}numInst(){return this.inst.length}addInst(e){this.inst.push(new O(e))}skipNop(e){let t=this.inst[e];for(;t.op===O.NOP||t.op===O.CAPTURE;)t=this.inst[e],e=t.out;return t}prefix(){let e=``,t=this.skipNop(this.start);if(!O.isRuneOp(t.op)||t.runes.length!==1)return[t.op===O.MATCH,e];for(;O.isRuneOp(t.op)&&t.runes.length===1&&(t.arg&b.FOLD_CASE)===0;)e+=String.fromCodePoint(t.runes[0]),t=this.skipNop(t.out);return[t.op===O.MATCH,e]}startCond(){let e=0,t=this.start;loop:for(;;){let n=this.inst[t];switch(n.op){case O.EMPTY_WIDTH:e|=n.arg;break;case O.FAIL:return-1;case O.CAPTURE:case O.NOP:break;default:break loop}t=n.out}return e}next(e){let t=this.inst[e>>1];return e&1?t.arg:t.out}patch(e,t){for(;e!==0;){let n=this.inst[e>>1];e&1?(e=n.arg,n.arg=t):(e=n.out,n.out=t)}}append(e,t){if(e===0)return t;if(t===0)return e;let n=e;for(;;){let e=this.next(n);if(e===0)break;n=e}let r=this.inst[n>>1];return n&1?r.arg=t:r.out=t,e}toString(){let e=``;for(let t=0;t<this.inst.length;t++){let n=e.length;e+=t,t===this.start&&(e+=`*`),e+=` `.substring(e.length-n),e+=this.inst[t],e+=`
14
+ `}return e}},Yn=class{constructor(e=0,t=0,n=!1){this.i=e,this.out=t,this.nullable=n}},Xn=class e{static ANY_RUNE_NOT_NL(){return[0,x.CODES.get(`
15
+ `)-1,x.CODES.get(`
16
+ `)+1,C.MAX_RUNE]}static ANY_RUNE(){return[0,C.MAX_RUNE]}static compileRegexp(t){let n=new e,r=n.compile(t);return n.prog.patch(r.out,n.newInst(O.MATCH).i),n.prog.start=r.i,n.prog}constructor(){this.prog=new Jn,this.newInst(O.FAIL)}newInst(e){return this.prog.addInst(e),new Yn(this.prog.numInst()-1,0,!0)}nop(){let e=this.newInst(O.NOP);return e.out=e.i<<1,e}fail(){return new Yn}cap(e){let t=this.newInst(O.CAPTURE);return t.out=t.i<<1,this.prog.getInst(t.i).arg=e,this.prog.numCap<e+1&&(this.prog.numCap=e+1),t}cat(e,t){return e.i===0||t.i===0?this.fail():(this.prog.patch(e.out,t.i),new Yn(e.i,t.out,e.nullable&&t.nullable))}alt(e,t){if(e.i===0)return t;if(t.i===0)return e;let n=this.newInst(O.ALT),r=this.prog.getInst(n.i);return r.out=e.i,r.arg=t.i,n.out=this.prog.append(e.out,t.out),n.nullable=e.nullable||t.nullable,n}loop(e,t){let n=this.newInst(O.ALT),r=this.prog.getInst(n.i);return t?(r.arg=e.i,n.out=n.i<<1):(r.out=e.i,n.out=n.i<<1|1),this.prog.patch(e.out,n.i),n}quest(e,t){let n=this.newInst(O.ALT),r=this.prog.getInst(n.i);return t?(r.arg=e.i,n.out=n.i<<1):(r.out=e.i,n.out=n.i<<1|1),n.out=this.prog.append(n.out,e.out),n}star(e,t){return e.nullable?this.quest(this.plus(e,t),t):this.loop(e,t)}plus(e,t){return new Yn(e.i,this.loop(e,t).out,e.nullable)}empty(e){let t=this.newInst(O.EMPTY_WIDTH);return this.prog.getInst(t.i).arg=e,t.out=t.i<<1,t}rune(e,t){let n=this.newInst(O.RUNE);n.nullable=!1;let r=this.prog.getInst(n.i);return r.runes=e,t&=b.FOLD_CASE,(e.length!==1||C.simpleFold(e[0])===e[0])&&(t&=~b.FOLD_CASE),r.arg=t,n.out=n.i<<1,(t&b.FOLD_CASE)===0&&e.length===1||e.length===2&&e[0]===e[1]?r.op=O.RUNE1:e.length===2&&e[0]===0&&e[1]===C.MAX_RUNE?r.op=O.RUNE_ANY:e.length===4&&e[0]===0&&e[1]===x.CODES.get(`
17
+ `)-1&&e[2]===x.CODES.get(`
18
+ `)+1&&e[3]===C.MAX_RUNE&&(r.op=O.RUNE_ANY_NOT_NL),n}compile(t){switch(t.op){case D.Op.NO_MATCH:return this.fail();case D.Op.EMPTY_MATCH:return this.nop();case D.Op.LITERAL:if(t.runes.length===0)return this.nop();{let e=null;for(let n of t.runes){let r=this.rune([n],t.flags);e=e===null?r:this.cat(e,r)}return e}case D.Op.CHAR_CLASS:return this.rune(t.runes,t.flags);case D.Op.ANY_CHAR_NOT_NL:return this.rune(e.ANY_RUNE_NOT_NL(),0);case D.Op.ANY_CHAR:return this.rune(e.ANY_RUNE(),0);case D.Op.BEGIN_LINE:return this.empty(w.EMPTY_BEGIN_LINE);case D.Op.END_LINE:return this.empty(w.EMPTY_END_LINE);case D.Op.BEGIN_TEXT:return this.empty(w.EMPTY_BEGIN_TEXT);case D.Op.END_TEXT:return this.empty(w.EMPTY_END_TEXT);case D.Op.WORD_BOUNDARY:return this.empty(w.EMPTY_WORD_BOUNDARY);case D.Op.NO_WORD_BOUNDARY:return this.empty(w.EMPTY_NO_WORD_BOUNDARY);case D.Op.CAPTURE:{let e=this.cap(t.cap<<1),n=this.compile(t.subs[0]),r=this.cap(t.cap<<1|1);return this.cat(this.cat(e,n),r)}case D.Op.STAR:return this.star(this.compile(t.subs[0]),(t.flags&b.NON_GREEDY)!==0);case D.Op.PLUS:return this.plus(this.compile(t.subs[0]),(t.flags&b.NON_GREEDY)!==0);case D.Op.QUEST:return this.quest(this.compile(t.subs[0]),(t.flags&b.NON_GREEDY)!==0);case D.Op.CONCAT:if(t.subs.length===0)return this.nop();{let e=null;for(let n of t.subs){let t=this.compile(n);e=e===null?t:this.cat(e,t)}return e}case D.Op.ALTERNATE:if(t.subs.length===0)return this.nop();{let e=null;for(let n of t.subs){let t=this.compile(n);e=e===null?t:this.alt(e,t)}return e}default:throw new Vn(`regexp: unhandled case in compile`)}}},Zn=class e{static simplify(t){if(t===null)return null;switch(t.op){case D.Op.CAPTURE:case D.Op.CONCAT:case D.Op.ALTERNATE:{let n=t;for(let r=0;r<t.subs.length;r++){let i=t.subs[r],a=e.simplify(i);n===t&&a!==i&&(n=D.fromRegexp(t),n.runes=null,n.subs=t.subs.slice(0,t.subs.length)),n!==t&&(n.subs[r]=a)}return n}case D.Op.STAR:case D.Op.PLUS:case D.Op.QUEST:{let n=e.simplify(t.subs[0]);return e.simplify1(t.op,t.flags,n,t)}case D.Op.REPEAT:{if(t.min===0&&t.max===0)return new D(D.Op.EMPTY_MATCH);let n=e.simplify(t.subs[0]);if(t.max===-1){if(t.min===0)return e.simplify1(D.Op.STAR,t.flags,n,null);if(t.min===1)return e.simplify1(D.Op.PLUS,t.flags,n,null);let r=new D(D.Op.CONCAT),i=[];for(let e=0;e<t.min-1;e++)i.push(n);return i.push(e.simplify1(D.Op.PLUS,t.flags,n,null)),r.subs=i.slice(0),r}if(t.min===1&&t.max===1)return n;let r=null;if(t.min>0){r=[];for(let e=0;e<t.min;e++)r.push(n)}if(t.max>t.min){let i=e.simplify1(D.Op.QUEST,t.flags,n,null);for(let r=t.min+1;r<t.max;r++){let r=new D(D.Op.CONCAT);r.subs=[n,i],i=e.simplify1(D.Op.QUEST,t.flags,r,null)}if(r===null)return i;r.push(i)}if(r!==null){let e=new D(D.Op.CONCAT);return e.subs=r.slice(0),e}return new D(D.Op.NO_MATCH)}}return t}static simplify1(e,t,n,r){return n.op===D.Op.EMPTY_MATCH||e===n.op&&(t&b.NON_GREEDY)===(n.flags&b.NON_GREEDY)?n:r!==null&&r.op===e&&(r.flags&b.NON_GREEDY)===(t&b.NON_GREEDY)&&n===r.subs[0]?r:(r=new D(e),r.flags=t,r.subs=[n],r)}},k=class{constructor(e,t){this.sign=e,this.cls=t}},Qn=[48,57],$n=[9,10,12,13,32,32],er=[48,57,65,90,95,95,97,122],tr=new Map([[`\\d`,new k(1,Qn)],[`\\D`,new k(-1,Qn)],[`\\s`,new k(1,$n)],[`\\S`,new k(-1,$n)],[`\\w`,new k(1,er)],[`\\W`,new k(-1,er)]]),nr=[48,57,65,90,97,122],rr=[65,90,97,122],ir=[0,127],ar=[9,9,32,32],or=[0,31,127,127],sr=[48,57],cr=[33,126],lr=[97,122],ur=[32,126],dr=[33,47,58,64,91,96,123,126],fr=[9,13,32,32],pr=[65,90],mr=[48,57,65,90,95,95,97,122],hr=[48,57,65,70,97,102],gr=new Map([[`[:alnum:]`,new k(1,nr)],[`[:^alnum:]`,new k(-1,nr)],[`[:alpha:]`,new k(1,rr)],[`[:^alpha:]`,new k(-1,rr)],[`[:ascii:]`,new k(1,ir)],[`[:^ascii:]`,new k(-1,ir)],[`[:blank:]`,new k(1,ar)],[`[:^blank:]`,new k(-1,ar)],[`[:cntrl:]`,new k(1,or)],[`[:^cntrl:]`,new k(-1,or)],[`[:digit:]`,new k(1,sr)],[`[:^digit:]`,new k(-1,sr)],[`[:graph:]`,new k(1,cr)],[`[:^graph:]`,new k(-1,cr)],[`[:lower:]`,new k(1,lr)],[`[:^lower:]`,new k(-1,lr)],[`[:print:]`,new k(1,ur)],[`[:^print:]`,new k(-1,ur)],[`[:punct:]`,new k(1,dr)],[`[:^punct:]`,new k(-1,dr)],[`[:space:]`,new k(1,fr)],[`[:^space:]`,new k(-1,fr)],[`[:upper:]`,new k(1,pr)],[`[:^upper:]`,new k(-1,pr)],[`[:word:]`,new k(1,mr)],[`[:^word:]`,new k(-1,mr)],[`[:xdigit:]`,new k(1,hr)],[`[:^xdigit:]`,new k(-1,hr)]]),_r=class e{static charClassToString(e,t){let n=`[`;for(let r=0;r<t;r+=2){r>0&&(n+=` `);let t=e[r],i=e[r+1];t===i?n+=`0x${t.toString(16)}`:n+=`0x${t.toString(16)}-0x${i.toString(16)}`}return n+=`]`,n}static cmp(e,t,n,r){let i=e[t]-n;return i===0?r-e[t+1]:i}static qsortIntPair(t,n,r){let i=((n+r)/2|0)&-2,a=t[i],o=t[i+1],s=n,c=r;for(;s<=c;){for(;s<r&&e.cmp(t,s,a,o)<0;)s+=2;for(;c>n&&e.cmp(t,c,a,o)>0;)c-=2;if(s<=c){if(s!==c){let e=t[s];t[s]=t[c],t[c]=e,e=t[s+1],t[s+1]=t[c+1],t[c+1]=e}s+=2,c-=2}}n<c&&e.qsortIntPair(t,n,c),s<r&&e.qsortIntPair(t,s,r)}constructor(e=w.emptyInts()){this.r=e,this.len=e.length}toArray(){return this.len===this.r.length?this.r:this.r.slice(0,this.len)}cleanClass(){if(this.len<4)return this;e.qsortIntPair(this.r,0,this.len-2);let t=2;for(let e=2;e<this.len;e+=2){let n=this.r[e],r=this.r[e+1];if(n<=this.r[t-1]+1){r>this.r[t-1]&&(this.r[t-1]=r);continue}this.r[t]=n,this.r[t+1]=r,t+=2}return this.len=t,this}appendLiteral(e,t){return(t&b.FOLD_CASE)===0?this.appendRange(e,e):this.appendFoldedRange(e,e)}appendRange(e,t){if(this.len>0){for(let n=2;n<=4;n+=2)if(this.len>=n){let r=this.r[this.len-n],i=this.r[this.len-n+1];if(e<=i+1&&r<=t+1)return e<r&&(this.r[this.len-n]=e),t>i&&(this.r[this.len-n+1]=t),this}}return this.r[this.len++]=e,this.r[this.len++]=t,this}appendFoldedRange(e,t){if(e<=C.MIN_FOLD&&t>=C.MAX_FOLD||t<C.MIN_FOLD||e>C.MAX_FOLD)return this.appendRange(e,t);e<C.MIN_FOLD&&(this.appendRange(e,C.MIN_FOLD-1),e=C.MIN_FOLD),t>C.MAX_FOLD&&(this.appendRange(C.MAX_FOLD+1,t),t=C.MAX_FOLD);for(let n=e;n<=t;n++){this.appendRange(n,n);for(let e=C.simpleFold(n);e!==n;e=C.simpleFold(e))this.appendRange(e,e)}return this}appendClass(e){for(let t=0;t<e.length;t+=2)this.appendRange(e[t],e[t+1]);return this}appendFoldedClass(e){for(let t=0;t<e.length;t+=2)this.appendFoldedRange(e[t],e[t+1]);return this}appendNegatedClass(e){let t=0;for(let n=0;n<e.length;n+=2){let r=e[n],i=e[n+1];t<=r-1&&this.appendRange(t,r-1),t=i+1}return t<=C.MAX_RUNE&&this.appendRange(t,C.MAX_RUNE),this}appendTable(e){for(let t of e){let e=t[0],n=t[1],r=t[2];if(r===1){this.appendRange(e,n);continue}for(let t=e;t<=n;t+=r)this.appendRange(t,t)}return this}appendNegatedTable(e){let t=0;for(let n of e){let e=n[0],r=n[1],i=n[2];if(i===1){t<=e-1&&this.appendRange(t,e-1),t=r+1;continue}for(let n=e;n<=r;n+=i)t<=n-1&&this.appendRange(t,n-1),t=n+1}return t<=C.MAX_RUNE&&this.appendRange(t,C.MAX_RUNE),this}appendTableWithSign(e,t){return t<0?this.appendNegatedTable(e):this.appendTable(e)}negateClass(){let e=0,t=0;for(let n=0;n<this.len;n+=2){let r=this.r[n],i=this.r[n+1];e<=r-1&&(this.r[t]=e,this.r[t+1]=r-1,t+=2),e=i+1}return this.len=t,e<=C.MAX_RUNE&&(this.r[this.len++]=e,this.r[this.len++]=C.MAX_RUNE),this}appendClassWithSign(e,t){return t<0?this.appendNegatedClass(e):this.appendClass(e)}appendGroup(t,n){let r=t.cls;return n&&(r=new e().appendFoldedClass(r).cleanClass().toArray()),this.appendClassWithSign(r,t.sign)}toString(){return e.charClassToString(this.r,this.len)}},vr=class e{static of(t,n){return new e(t,n)}constructor(e,t){this.first=e,this.second=t}},yr=class{constructor(e){this.str=e,this.position=0}pos(){return this.position}rewindTo(e){this.position=e}more(){return this.position<this.str.length}peek(){return this.str.codePointAt(this.position)}skip(e){this.position+=e}skipString(e){this.position+=e.length}pop(){let e=this.str.codePointAt(this.position);return this.position+=w.charCount(e),e}lookingAt(e){return this.rest().startsWith(e)}rest(){return this.str.substring(this.position)}from(e){return this.str.substring(e,this.position)}toString(){return this.rest()}},br=class e{static ERR_INTERNAL_ERROR=`regexp/syntax: internal error`;static ERR_INVALID_CHAR_RANGE=`invalid character class range`;static ERR_INVALID_ESCAPE=`invalid escape sequence`;static ERR_INVALID_NAMED_CAPTURE=`invalid named capture`;static ERR_INVALID_PERL_OP=`invalid or unsupported Perl syntax`;static ERR_INVALID_REPEAT_OP=`invalid nested repetition operator`;static ERR_INVALID_REPEAT_SIZE=`invalid repeat count`;static ERR_MISSING_BRACKET=`missing closing ]`;static ERR_MISSING_PAREN=`missing closing )`;static ERR_MISSING_REPEAT_ARGUMENT=`missing argument to repetition operator`;static ERR_TRAILING_BACKSLASH=`trailing backslash at end of expression`;static ERR_DUPLICATE_NAMED_CAPTURE=`duplicate capture group name`;static ANY_TABLE(){return[[0,C.MAX_RUNE,1]]}static unicodeTable(t){return t===`Any`?vr.of(e.ANY_TABLE(),e.ANY_TABLE()):S.CATEGORIES.has(t)?vr.of(S.CATEGORIES.get(t),S.FOLD_CATEGORIES.get(t)):S.SCRIPTS.has(t)?vr.of(S.SCRIPTS.get(t),S.FOLD_SCRIPT.get(t)):null}static minFoldRune(e){if(e<C.MIN_FOLD||e>C.MAX_FOLD)return e;let t=e,n=e;for(e=C.simpleFold(e);e!==n;e=C.simpleFold(e))t>e&&(t=e);return t}static leadingRegexp(e){if(e.op===D.Op.EMPTY_MATCH)return null;if(e.op===D.Op.CONCAT&&e.subs.length>0){let t=e.subs[0];return t.op===D.Op.EMPTY_MATCH?null:t}return e}static literalRegexp(e,t){let n=new D(D.Op.LITERAL);return n.flags=t,n.runes=w.stringToRunes(e),n}static parse(t,n){return new e(t,n).parseInternal()}static parseRepeat(t){let n=t.pos();if(!t.more()||!t.lookingAt(`{`))return-1;t.skip(1);let r=e.parseInt(t);if(r===-1||!t.more())return-1;let i;if(!t.lookingAt(`,`))i=r;else{if(t.skip(1),!t.more())return-1;if(t.lookingAt(`}`))i=-1;else if((i=e.parseInt(t))===-1)return-1}if(!t.more()||!t.lookingAt(`}`))return-1;if(t.skip(1),r<0||r>1e3||i===-2||i>1e3||i>=0&&r>i)throw new T(e.ERR_INVALID_REPEAT_SIZE,t.from(n));return r<<16|i&C.MAX_BMP}static isValidCaptureName(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++){let n=e.codePointAt(t);if(n!==x.CODES.get(`_`)&&!w.isalnum(n))return!1}return!0}static parseInt(e){let t=e.pos();for(;e.more()&&e.peek()>=x.CODES.get(`0`)&&e.peek()<=x.CODES.get(`9`);)e.skip(1);let n=e.from(t);return n.length===0||n.length>1&&n.codePointAt(0)===x.CODES.get(`0`)?-1:n.length>8?-2:parseFloat(n,10)}static isCharClass(e){return e.op===D.Op.LITERAL&&e.runes.length===1||e.op===D.Op.CHAR_CLASS||e.op===D.Op.ANY_CHAR_NOT_NL||e.op===D.Op.ANY_CHAR}static matchRune(e,t){switch(e.op){case D.Op.LITERAL:return e.runes.length===1&&e.runes[0]===t;case D.Op.CHAR_CLASS:for(let n=0;n<e.runes.length;n+=2)if(e.runes[n]<=t&&t<=e.runes[n+1])return!0;return!1;case D.Op.ANY_CHAR_NOT_NL:return t!==x.CODES.get(`
19
+ `);case D.Op.ANY_CHAR:return!0}return!1}static mergeCharClass(t,n){switch(t.op){case D.Op.ANY_CHAR:break;case D.Op.ANY_CHAR_NOT_NL:e.matchRune(n,x.CODES.get(`
20
+ `))&&(t.op=D.Op.ANY_CHAR);break;case D.Op.CHAR_CLASS:n.op===D.Op.LITERAL?t.runes=new _r(t.runes).appendLiteral(n.runes[0],n.flags).toArray():t.runes=new _r(t.runes).appendClass(n.runes).toArray();break;case D.Op.LITERAL:if(n.runes[0]===t.runes[0]&&n.flags===t.flags)break;t.op=D.Op.CHAR_CLASS,t.runes=new _r().appendLiteral(t.runes[0],t.flags).appendLiteral(n.runes[0],n.flags).toArray();break}}static parseEscape(t){let n=t.pos();if(t.skip(1),!t.more())throw new T(e.ERR_TRAILING_BACKSLASH);let r=t.pop();bigswitch:switch(r){case x.CODES.get(`1`):case x.CODES.get(`2`):case x.CODES.get(`3`):case x.CODES.get(`4`):case x.CODES.get(`5`):case x.CODES.get(`6`):case x.CODES.get(`7`):if(!t.more()||t.peek()<x.CODES.get(`0`)||t.peek()>x.CODES.get(`7`))break;case x.CODES.get(`0`):{let e=r-x.CODES.get(`0`);for(let n=1;n<3&&!(!t.more()||t.peek()<x.CODES.get(`0`)||t.peek()>x.CODES.get(`7`));n++)e=e*8+t.peek()-x.CODES.get(`0`),t.skip(1);return e}case x.CODES.get(`x`):{if(!t.more())break;if(r=t.pop(),r===x.CODES.get(`{`)){let e=0,n=0;for(;;){if(!t.more())break bigswitch;if(r=t.pop(),r===x.CODES.get(`}`))break;let i=w.unhex(r);if(i<0||(n=n*16+i,n>C.MAX_RUNE))break bigswitch;e++}if(e===0)break bigswitch;return n}let e=w.unhex(r);if(!t.more())break;r=t.pop();let n=w.unhex(r);if(e<0||n<0)break;return e*16+n}case x.CODES.get(`a`):return x.CODES.get(`\x07`);case x.CODES.get(`f`):return x.CODES.get(`\f`);case x.CODES.get(`n`):return x.CODES.get(`
21
+ `);case x.CODES.get(`r`):return x.CODES.get(`\r`);case x.CODES.get(`t`):return x.CODES.get(` `);case x.CODES.get(`v`):return x.CODES.get(`\v`);default:if(!w.isalnum(r))return r;break}throw new T(e.ERR_INVALID_ESCAPE,t.from(n))}static parseClassChar(t,n){if(!t.more())throw new T(e.ERR_MISSING_BRACKET,t.from(n));return t.lookingAt(`\\`)?e.parseEscape(t):t.pop()}static concatRunes(e,t){return[...e,...t]}constructor(e,t=0){this.wholeRegexp=e,this.flags=t,this.numCap=0,this.namedGroups={},this.stack=[],this.free=null}newRegexp(e){let t=this.free;return t!==null&&t.subs!==null&&t.subs.length>0?(this.free=t.subs[0],t.reinit(),t.op=e):t=new D(e),t}reuse(e){e.subs!==null&&e.subs.length>0&&(e.subs[0]=this.free),this.free=e}pop(){return this.stack.pop()}popToPseudo(){let e=this.stack.length,t=e;for(;t>0&&!D.isPseudoOp(this.stack[t-1].op);)t--;let n=this.stack.slice(t,e);return this.stack=this.stack.slice(0,t),n}push(e){if(e.op===D.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]===e.runes[1]){if(this.maybeConcat(e.runes[0],this.flags&~b.FOLD_CASE))return null;e.op=D.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags&~b.FOLD_CASE}else if(e.op===D.Op.CHAR_CLASS&&e.runes.length===4&&e.runes[0]===e.runes[1]&&e.runes[2]===e.runes[3]&&C.simpleFold(e.runes[0])===e.runes[2]&&C.simpleFold(e.runes[2])===e.runes[0]||e.op===D.Op.CHAR_CLASS&&e.runes.length===2&&e.runes[0]+1===e.runes[1]&&C.simpleFold(e.runes[0])===e.runes[1]&&C.simpleFold(e.runes[1])===e.runes[0]){if(this.maybeConcat(e.runes[0],this.flags|b.FOLD_CASE))return null;e.op=D.Op.LITERAL,e.runes=[e.runes[0]],e.flags=this.flags|b.FOLD_CASE}else this.maybeConcat(-1,0);return this.stack.push(e),e}maybeConcat(t,n){let r=this.stack.length;if(r<2)return!1;let i=this.stack[r-1],a=this.stack[r-2];return i.op!==D.Op.LITERAL||a.op!==D.Op.LITERAL||(i.flags&b.FOLD_CASE)!==(a.flags&b.FOLD_CASE)?!1:(a.runes=e.concatRunes(a.runes,i.runes),t>=0?(i.runes=[t],i.flags=n,!0):(this.pop(),this.reuse(i),!1))}newLiteral(t,n){let r=this.newRegexp(D.Op.LITERAL);return r.flags=n,(n&b.FOLD_CASE)!==0&&(t=e.minFoldRune(t)),r.runes=[t],r}literal(e){this.push(this.newLiteral(e,this.flags))}op(e){let t=this.newRegexp(e);return t.flags=this.flags,this.push(t)}repeat(t,n,r,i,a,o){let s=this.flags;if((s&b.PERL_X)!==0&&(a.more()&&a.lookingAt(`?`)&&(a.skip(1),s^=b.NON_GREEDY),o!==-1))throw new T(e.ERR_INVALID_REPEAT_OP,a.from(o));let c=this.stack.length;if(c===0)throw new T(e.ERR_MISSING_REPEAT_ARGUMENT,a.from(i));let l=this.stack[c-1];if(D.isPseudoOp(l.op))throw new T(e.ERR_MISSING_REPEAT_ARGUMENT,a.from(i));let u=this.newRegexp(t);u.min=n,u.max=r,u.flags=s,u.subs=[l],this.stack[c-1]=u}concat(){this.maybeConcat(-1,0);let e=this.popToPseudo();return e.length===0?this.push(this.newRegexp(D.Op.EMPTY_MATCH)):this.push(this.collapse(e,D.Op.CONCAT))}alternate(){let e=this.popToPseudo();return e.length>0&&this.cleanAlt(e[e.length-1]),e.length===0?this.push(this.newRegexp(D.Op.NO_MATCH)):this.push(this.collapse(e,D.Op.ALTERNATE))}cleanAlt(e){e.op===D.Op.CHAR_CLASS&&(e.runes=new _r(e.runes).cleanClass().toArray(),e.runes.length===2&&e.runes[0]===0&&e.runes[1]===C.MAX_RUNE?(e.runes=null,e.op=D.Op.ANY_CHAR):e.runes.length===4&&e.runes[0]===0&&e.runes[1]===x.CODES.get(`
22
+ `)-1&&e.runes[2]===x.CODES.get(`
23
+ `)+1&&e.runes[3]===C.MAX_RUNE&&(e.runes=null,e.op=D.Op.ANY_CHAR_NOT_NL))}collapse(e,t){if(e.length===1)return e[0];let n=0;for(let r of e)n+=r.op===t?r.subs.length:1;let r=Array(n).fill(null),i=0;for(let n of e)n.op===t?(r.splice(i,n.subs.length,...n.subs),i+=n.subs.length,this.reuse(n)):r[i++]=n;let a=this.newRegexp(t);if(a.subs=r,t===D.Op.ALTERNATE&&(a.subs=this.factor(a.subs),a.subs.length===1)){let e=a;a=a.subs[0],this.reuse(e)}return a}factor(t){if(t.length<2)return t;let n=0,r=t.length,i=0,a=null,o=0,s=0,c=0;for(let e=0;e<=r;e++){let l=null,u=0,d=0;if(e<r){let r=t[n+e];if(r.op===D.Op.CONCAT&&r.subs.length>0&&(r=r.subs[0]),r.op===D.Op.LITERAL&&(l=r.runes,u=r.runes.length,d=r.flags&b.FOLD_CASE),d===s){let e=0;for(;e<o&&e<u&&a[e]===l[e];)e++;if(e>0){o=e;continue}}}if(e!==c)if(e===c+1)t[i++]=t[n+c];else{let r=this.newRegexp(D.Op.LITERAL);r.flags=s,r.runes=a.slice(0,o);for(let r=c;r<e;r++)t[n+r]=this.removeLeadingString(t[n+r],o);let l=this.collapse(t.slice(n+c,n+e),D.Op.ALTERNATE),u=this.newRegexp(D.Op.CONCAT);u.subs=[r,l],t[i++]=u}c=e,a=l,o=u,s=d}r=i,n=0,c=0,i=0;let l=null;for(let a=0;a<=r;a++){let o=null;if(!(a<r&&(o=e.leadingRegexp(t[n+a]),l!==null&&l.equals(o)&&(e.isCharClass(l)||l.op===D.Op.REPEAT&&l.min===l.max&&e.isCharClass(l.subs[0]))))){if(a!==c)if(a===c+1)t[i++]=t[n+c];else{let e=l;for(let e=c;e<a;e++){let r=e!==c;t[n+e]=this.removeLeadingRegexp(t[n+e],r)}let r=this.collapse(t.slice(n+c,n+a),D.Op.ALTERNATE),o=this.newRegexp(D.Op.CONCAT);o.subs=[e,r],t[i++]=o}c=a,l=o}}r=i,n=0,c=0,i=0;for(let a=0;a<=r;a++)if(!(a<r&&e.isCharClass(t[n+a]))){if(a!==c)if(a===c+1)t[i++]=t[n+c];else{let r=c;for(let e=c+1;e<a;e++){let i=t[n+r],a=t[n+e];(i.op<a.op||i.op===a.op&&(i.runes===null?0:i.runes.length)<(a.runes===null?0:a.runes.length))&&(r=e)}let o=t[n+c];t[n+c]=t[n+r],t[n+r]=o;for(let r=c+1;r<a;r++)e.mergeCharClass(t[n+c],t[n+r]),this.reuse(t[n+r]);this.cleanAlt(t[n+c]),t[i++]=t[n+c]}a<r&&(t[i++]=t[n+a]),c=a+1}r=i,n=0,c=0,i=0;for(let e=0;e<r;++e)e+1<r&&t[n+e].op===D.Op.EMPTY_MATCH&&t[n+e+1].op===D.Op.EMPTY_MATCH||(t[i++]=t[n+e]);return r=i,n=0,t.slice(n,r)}removeLeadingString(e,t){if(e.op===D.Op.CONCAT&&e.subs.length>0){let n=this.removeLeadingString(e.subs[0],t);if(e.subs[0]=n,n.op===D.Op.EMPTY_MATCH)switch(this.reuse(n),e.subs.length){case 0:case 1:e.op=D.Op.EMPTY_MATCH,e.subs=null;break;case 2:{let t=e;e=e.subs[1],this.reuse(t);break}default:e.subs=e.subs.slice(1,e.subs.length);break}return e}return e.op===D.Op.LITERAL&&(e.runes=e.runes.slice(t,e.runes.length),e.runes.length===0&&(e.op=D.Op.EMPTY_MATCH)),e}removeLeadingRegexp(e,t){if(e.op===D.Op.CONCAT&&e.subs.length>0){switch(t&&this.reuse(e.subs[0]),e.subs=e.subs.slice(1,e.subs.length),e.subs.length){case 0:e.op=D.Op.EMPTY_MATCH,e.subs=D.emptySubs();break;case 1:{let t=e;e=e.subs[0],this.reuse(t);break}}return e}return t&&this.reuse(e),this.newRegexp(D.Op.EMPTY_MATCH)}parseInternal(){if((this.flags&b.LITERAL)!==0)return e.literalRegexp(this.wholeRegexp,this.flags);let t=-1,n=-1,r=-1,i=new yr(this.wholeRegexp);for(;i.more();){let a=-1;bigswitch:switch(i.peek()){case x.CODES.get(`(`):if((this.flags&b.PERL_X)!==0&&i.lookingAt(`(?`)){this.parsePerlFlags(i);break}this.op(D.Op.LEFT_PAREN).cap=++this.numCap,i.skip(1);break;case x.CODES.get(`|`):this.parseVerticalBar(),i.skip(1);break;case x.CODES.get(`)`):this.parseRightParen(),i.skip(1);break;case x.CODES.get(`^`):(this.flags&b.ONE_LINE)===0?this.op(D.Op.BEGIN_LINE):this.op(D.Op.BEGIN_TEXT),i.skip(1);break;case x.CODES.get(`$`):(this.flags&b.ONE_LINE)===0?this.op(D.Op.END_LINE):this.op(D.Op.END_TEXT).flags|=b.WAS_DOLLAR,i.skip(1);break;case x.CODES.get(`.`):(this.flags&b.DOT_NL)===0?this.op(D.Op.ANY_CHAR_NOT_NL):this.op(D.Op.ANY_CHAR),i.skip(1);break;case x.CODES.get(`[`):this.parseClass(i);break;case x.CODES.get(`*`):case x.CODES.get(`+`):case x.CODES.get(`?`):{a=i.pos();let e=null;switch(i.pop()){case x.CODES.get(`*`):e=D.Op.STAR;break;case x.CODES.get(`+`):e=D.Op.PLUS;break;case x.CODES.get(`?`):e=D.Op.QUEST;break}this.repeat(e,n,r,a,i,t);break}case x.CODES.get(`{`):{a=i.pos();let o=e.parseRepeat(i);if(o<0){i.rewindTo(a),this.literal(i.pop());break}n=o>>16,r=(o&C.MAX_BMP)<<16>>16,this.repeat(D.Op.REPEAT,n,r,a,i,t);break}case x.CODES.get(`\\`):{let t=i.pos();if(i.skip(1),(this.flags&b.PERL_X)!==0&&i.more())switch(i.pop()){case x.CODES.get(`A`):this.op(D.Op.BEGIN_TEXT);break bigswitch;case x.CODES.get(`b`):this.op(D.Op.WORD_BOUNDARY);break bigswitch;case x.CODES.get(`B`):this.op(D.Op.NO_WORD_BOUNDARY);break bigswitch;case x.CODES.get(`C`):throw new T(e.ERR_INVALID_ESCAPE,`\\C`);case x.CODES.get(`Q`):{let e=i.rest(),t=e.indexOf(`\\E`);t>=0&&(e=e.substring(0,t)),i.skipString(e),i.skipString(`\\E`);let n=0;for(;n<e.length;){let t=e.codePointAt(n);this.literal(t),n+=w.charCount(t)}break bigswitch}case x.CODES.get(`z`):this.op(D.Op.END_TEXT);break bigswitch;default:i.rewindTo(t);break}let n=this.newRegexp(D.Op.CHAR_CLASS);if(n.flags=this.flags,i.lookingAt(`\\p`)||i.lookingAt(`\\P`)){let e=new _r;if(this.parseUnicodeClass(i,e)){n.runes=e.toArray(),this.push(n);break bigswitch}}let r=new _r;if(this.parsePerlClassEscape(i,r)){n.runes=r.toArray(),this.push(n);break bigswitch}i.rewindTo(t),this.reuse(n),this.literal(e.parseEscape(i));break}default:this.literal(i.pop());break}t=a}if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length!==1)throw new T(e.ERR_MISSING_PAREN,this.wholeRegexp);return this.stack[0].namedGroups=this.namedGroups,this.stack[0]}parsePerlFlags(t){let n=t.pos(),r=t.rest();if(r.startsWith(`(?P<`)||r.startsWith(`(?<`)){let n=r.charAt(2)===`P`?4:3,i=r.indexOf(`>`);if(i<0)throw new T(e.ERR_INVALID_NAMED_CAPTURE,r);let a=r.substring(n,i);if(t.skipString(a),t.skip(n+1),!e.isValidCaptureName(a))throw new T(e.ERR_INVALID_NAMED_CAPTURE,r.substring(0,i+1));let o=this.op(D.Op.LEFT_PAREN);if(o.cap=++this.numCap,this.namedGroups[a])throw new T(e.ERR_DUPLICATE_NAMED_CAPTURE,a);this.namedGroups[a]=this.numCap,o.name=a;return}t.skip(2);let i=this.flags,a=1,o=!1;loop:for(;t.more();){let e=t.pop();switch(e){case x.CODES.get(`i`):i|=b.FOLD_CASE,o=!0;break;case x.CODES.get(`m`):i&=~b.ONE_LINE,o=!0;break;case x.CODES.get(`s`):i|=b.DOT_NL,o=!0;break;case x.CODES.get(`U`):i|=b.NON_GREEDY,o=!0;break;case x.CODES.get(`-`):if(a<0)break loop;a=-1,i=~i,o=!1;break;case x.CODES.get(`:`):case x.CODES.get(`)`):if(a<0){if(!o)break loop;i=~i}e===x.CODES.get(`:`)&&this.op(D.Op.LEFT_PAREN),this.flags=i;return;default:break loop}}throw new T(e.ERR_INVALID_PERL_OP,t.from(n))}parseVerticalBar(){this.concat(),this.swapVerticalBar()||this.op(D.Op.VERTICAL_BAR)}swapVerticalBar(){let t=this.stack.length;if(t>=3&&this.stack[t-2].op===D.Op.VERTICAL_BAR&&e.isCharClass(this.stack[t-1])&&e.isCharClass(this.stack[t-3])){let n=this.stack[t-1],r=this.stack[t-3];if(n.op>r.op){let e=r;r=n,n=e,this.stack[t-3]=r}return e.mergeCharClass(r,n),this.reuse(n),this.pop(),!0}if(t>=2){let e=this.stack[t-1],n=this.stack[t-2];if(n.op===D.Op.VERTICAL_BAR)return t>=3&&this.cleanAlt(this.stack[t-3]),this.stack[t-2]=e,this.stack[t-1]=n,!0}return!1}parseRightParen(){if(this.concat(),this.swapVerticalBar()&&this.pop(),this.alternate(),this.stack.length<2)throw new T(e.ERR_INTERNAL_ERROR,`stack underflow`);let t=this.pop(),n=this.pop();if(n.op!==D.Op.LEFT_PAREN)throw new T(e.ERR_MISSING_PAREN,this.wholeRegexp);this.flags=n.flags,n.cap===0?this.push(t):(n.op=D.Op.CAPTURE,n.subs=[t],this.push(n))}parsePerlClassEscape(e,t){let n=e.pos();if((this.flags&b.PERL_X)===0||!e.more()||e.pop()!==x.CODES.get(`\\`)||!e.more())return!1;e.pop();let r=e.from(n),i=tr.has(r)?tr.get(r):null;return i===null?!1:(t.appendGroup(i,(this.flags&b.FOLD_CASE)!==0),!0)}parseNamedClass(t,n){let r=t.rest(),i=r.indexOf(`:]`);if(i<0)return!1;let a=r.substring(0,i+2);t.skipString(a);let o=gr.has(a)?gr.get(a):null;if(o===null)throw new T(e.ERR_INVALID_CHAR_RANGE,a);return n.appendGroup(o,(this.flags&b.FOLD_CASE)!==0),!0}parseUnicodeClass(t,n){let r=t.pos();if((this.flags&b.UNICODE_GROUPS)===0||!t.lookingAt(`\\p`)&&!t.lookingAt(`\\P`))return!1;t.skip(1);let i=1,a=t.pop();if(a===x.CODES.get(`P`)&&(i=-1),!t.more())throw t.rewindTo(r),new T(e.ERR_INVALID_CHAR_RANGE,t.rest());a=t.pop();let o;if(a!==x.CODES.get(`{`))o=w.runeToString(a);else{let n=t.rest(),i=n.indexOf(`}`);if(i<0)throw t.rewindTo(r),new T(e.ERR_INVALID_CHAR_RANGE,t.rest());o=n.substring(0,i),t.skipString(o),t.skip(1)}o.length!==0&&o.codePointAt(0)===x.CODES.get(`^`)&&(i=0-i,o=o.substring(1));let s=e.unicodeTable(o);if(s===null)throw new T(e.ERR_INVALID_CHAR_RANGE,t.from(r));let c=s.first,l=s.second;if((this.flags&b.FOLD_CASE)===0||l===null)n.appendTableWithSign(c,i);else{let e=new _r().appendTable(c).appendTable(l).cleanClass().toArray();n.appendClassWithSign(e,i)}return!0}parseClass(t){let n=t.pos();t.skip(1);let r=this.newRegexp(D.Op.CHAR_CLASS);r.flags=this.flags;let i=new _r,a=1;t.more()&&t.lookingAt(`^`)&&(a=-1,t.skip(1),(this.flags&b.CLASS_NL)===0&&i.appendRange(x.CODES.get(`
24
+ `),x.CODES.get(`
25
+ `)));let o=!0;for(;!t.more()||t.peek()!==x.CODES.get(`]`)||o;){if(t.more()&&t.lookingAt(`-`)&&(this.flags&b.PERL_X)===0&&!o){let r=t.rest();if(r===`-`||!r.startsWith(`-]`))throw t.rewindTo(n),new T(e.ERR_INVALID_CHAR_RANGE,t.rest())}o=!1;let r=t.pos();if(t.lookingAt(`[:`)){if(this.parseNamedClass(t,i))continue;t.rewindTo(r)}if(this.parseUnicodeClass(t,i)||this.parsePerlClassEscape(t,i))continue;t.rewindTo(r);let a=e.parseClassChar(t,n),s=a;if(t.more()&&t.lookingAt(`-`)){if(t.skip(1),t.more()&&t.lookingAt(`]`))t.skip(-1);else if(s=e.parseClassChar(t,n),s<a)throw new T(e.ERR_INVALID_CHAR_RANGE,t.from(r))}(this.flags&b.FOLD_CASE)===0?i.appendRange(a,s):i.appendFoldedRange(a,s)}t.skip(1),i.cleanClass(),a<0&&i.negateClass(),r.runes=i.toArray(),this.push(r)}},xr=class{constructor(){this.inst=null,this.cap=[]}},Sr=class{constructor(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}contains(e){let t=this.sparse[e];return t<this.size&&this.densePcs[t]===e}isEmpty(){return this.size===0}add(e){let t=this.size++;return this.sparse[e]=t,this.denseThreads[t]=null,this.densePcs[t]=e,t}clear(){this.sparse=[],this.densePcs=[],this.denseThreads=[],this.size=0}toString(){let e=`{`;for(let t=0;t<this.size;t++)t!==0&&(e+=`, `),e+=this.densePcs[t];return e+=`}`,e}},Cr=class e{static fromRE2(t){let n=new e;return n.prog=t.prog,n.re2=t,n.q0=new Sr(n.prog.numInst()),n.q1=new Sr(n.prog.numInst()),n.pool=[],n.poolSize=0,n.matched=!1,n.matchcap=Array(n.prog.numCap<2?2:n.prog.numCap).fill(0),n.ncap=0,n}static fromMachine(t){let n=new e;return n.re2=t.re2,n.prog=t.prog,n.q0=t.q0,n.q1=t.q1,n.pool=t.pool,n.poolSize=t.poolSize,n.matched=t.matched,n.matchcap=t.matchcap,n.ncap=t.ncap,n}init(e){this.ncap=e,e>this.matchcap.length?this.initNewCap(e):this.resetCap(e)}resetCap(e){for(let t=0;t<this.poolSize;t++){let n=this.pool[t];n.cap=Array(e).fill(0)}}initNewCap(e){for(let t=0;t<this.poolSize;t++){let n=this.pool[t];n.cap=Array(e).fill(0)}this.matchcap=Array(e).fill(0)}submatches(){return this.ncap===0?w.emptyInts():this.matchcap.slice(0,this.ncap)}alloc(e){let t;return this.poolSize>0?(this.poolSize--,t=this.pool[this.poolSize]):t=new xr,t.inst=e,t}freeQueue(e,t=0){let n=e.size-t,r=this.poolSize+n;this.pool.length<r&&(this.pool=this.pool.slice(0,Math.max(this.pool.length*2,r)));for(let n=t;n<e.size;n++){let t=e.denseThreads[n];t!==null&&(this.pool[this.poolSize]=t,this.poolSize++)}e.clear()}freeThread(e){this.pool.length<=this.poolSize&&(this.pool=this.pool.slice(0,this.pool.length*2)),this.pool[this.poolSize]=e,this.poolSize++}match(e,t,n){let r=this.re2.cond;if(r===w.EMPTY_ALL||(n===b.ANCHOR_START||n===b.ANCHOR_BOTH)&&t!==0)return!1;this.matched=!1,this.matchcap=Array(this.prog.numCap).fill(-1);let i=this.q0,a=this.q1,o=e.step(t),s=o>>3,c=o&7,l=-1,u=0;o!==Gn.EOF()&&(o=e.step(t+c),l=o>>3,u=o&7);let d;for(d=t===0?w.emptyOpContext(-1,s):e.context(t);;){if(i.isEmpty()){if((r&w.EMPTY_BEGIN_TEXT)!==0&&t!==0||this.matched)break;if(this.re2.prefix.length!==0&&l!==this.re2.prefixRune&&e.canCheckPrefix()){let n=e.index(this.re2,t);if(n<0)break;t+=n,o=e.step(t),s=o>>3,c=o&7,o=e.step(t+c),l=o>>3,u=o&7}}!this.matched&&(t===0||n===b.UNANCHORED)&&(this.ncap>0&&(this.matchcap[0]=t),this.add(i,this.prog.start,t,this.matchcap,d,null));let f=t+c;if(d=e.context(f),this.step(i,a,t,f,s,d,n,t===e.endPos()),c===0||this.ncap===0&&this.matched)break;t+=c,s=l,c=u,s!==-1&&(o=e.step(t+c),l=o>>3,u=o&7);let p=i;i=a,a=p}return this.freeQueue(a),this.matched}step(e,t,n,r,i,a,o,s){let c=this.re2.longest;for(let l=0;l<e.size;l++){let u=e.denseThreads[l];if(u===null)continue;if(c&&this.matched&&this.ncap>0&&this.matchcap[0]<u.cap[0]){this.freeThread(u);continue}let d=u.inst,f=!1;switch(d.op){case O.MATCH:if(o===b.ANCHOR_BOTH&&!s)break;this.ncap>0&&(!c||!this.matched||this.matchcap[1]<n)&&(u.cap[1]=n,this.matchcap=u.cap.slice(0,this.ncap)),c||this.freeQueue(e,l+1),this.matched=!0;break;case O.RUNE:f=d.matchRune(i);break;case O.RUNE1:f=i===d.runes[0];break;case O.RUNE_ANY:f=!0;break;case O.RUNE_ANY_NOT_NL:f=i!==x.CODES.get(`
26
+ `);break;default:throw Error(`bad inst`)}f&&(u=this.add(t,d.out,r,u.cap,a,u)),u!==null&&(this.freeThread(u),e.denseThreads[l]=null)}e.clear()}add(e,t,n,r,i,a){if(t===0||e.contains(t))return a;let o=e.add(t),s=this.prog.inst[t];switch(s.op){case O.FAIL:break;case O.ALT:case O.ALT_MATCH:a=this.add(e,s.out,n,r,i,a),a=this.add(e,s.arg,n,r,i,a);break;case O.EMPTY_WIDTH:(s.arg&~i)===0&&(a=this.add(e,s.out,n,r,i,a));break;case O.NOP:a=this.add(e,s.out,n,r,i,a);break;case O.CAPTURE:if(s.arg<this.ncap){let t=r[s.arg];r[s.arg]=n,this.add(e,s.out,n,r,i,null),r[s.arg]=t}else a=this.add(e,s.out,n,r,i,a);break;case O.MATCH:case O.RUNE:case O.RUNE1:case O.RUNE_ANY:case O.RUNE_ANY_NOT_NL:a===null?a=this.alloc(s):a.inst=s,this.ncap>0&&a.cap!==r&&(a.cap=r.slice(0,this.ncap)),e.denseThreads[o]=a,a=null;break;default:throw Error(`unhandled`)}return a}},wr=class{constructor(e){this.value=e}get(){return this.value}set(e){this.value=e}compareAndSet(e,t){return this.value===e?(this.value=t,!0):!1}},Tr=class e{static initTest(t){let n=e.compile(t),r=new e(n.expr,n.prog,n.numSubexp,n.longest);return r.cond=n.cond,r.prefix=n.prefix,r.prefixUTF8=n.prefixUTF8,r.prefixComplete=n.prefixComplete,r.prefixRune=n.prefixRune,r}static compile(t){return e.compileImpl(t,b.PERL,!1)}static compilePOSIX(t){return e.compileImpl(t,b.POSIX,!0)}static compileImpl(t,n,r){let i=br.parse(t,n),a=i.maxCap();i=Zn.simplify(i);let o=Xn.compileRegexp(i),s=new e(t,o,a,r),[c,l]=o.prefix();return s.prefixComplete=c,s.prefix=l,s.prefixUTF8=w.stringToUtf8ByteArray(s.prefix),s.prefix.length>0&&(s.prefixRune=s.prefix.codePointAt(0)),s.namedGroups=i.namedGroups,s}static match(t,n){return e.compile(t).match(n)}constructor(e,t,n=0,r=0){this.expr=e,this.prog=t,this.numSubexp=n,this.longest=r,this.cond=t.startCond(),this.prefix=null,this.prefixUTF8=null,this.prefixComplete=!1,this.prefixRune=0,this.pooled=new wr}numberOfCapturingGroups(){return this.numSubexp}get(){let e;do e=this.pooled.get();while(e&&!this.pooled.compareAndSet(e,e.next));return e}reset(){this.pooled.set(null)}put(e,t){let n=this.pooled.get();do n=this.pooled.get(),!t&&n&&(e=Cr.fromMachine(e),t=!0),e.next!==n&&(e.next=n);while(!this.pooled.compareAndSet(n,e))}toString(){return this.expr}doExecute(e,t,n,r){let i=this.get(),a=!1;i?i.next!==null&&(i=Cr.fromMachine(i),a=!0):(i=Cr.fromRE2(this),a=!0),i.init(r);let o=i.match(e,t,n)?i.submatches():null;return this.put(i,a),o}match(e){return this.doExecute(E.fromUTF16(e),0,b.UNANCHORED,0)!==null}matchWithGroup(e,t,n,r,i){return e instanceof In||(e=zn.utf16(e)),this.matchMachineInput(e,t,n,r,i)}matchMachineInput(e,t,n,r,i){if(t>n)return[!1,null];let a=e.isUTF16Encoding()?E.fromUTF16(e.asCharSequence(),0,n):E.fromUTF8(e.asBytes(),0,n),o=this.doExecute(a,t,r,2*i);return o===null?[!1,null]:[!0,o]}matchUTF8(e){return this.doExecute(E.fromUTF8(e),0,b.UNANCHORED,0)!==null}replaceAll(e,t){return this.replaceAllFunc(e,()=>t,2*e.length+1)}replaceFirst(e,t){return this.replaceAllFunc(e,()=>t,1)}replaceAllFunc(e,t,n){let r=0,i=0,a=``,o=E.fromUTF16(e),s=0;for(;i<=e.length;){let c=this.doExecute(o,i,b.UNANCHORED,2);if(c===null||c.length===0)break;a+=e.substring(r,c[0]),(c[1]>r||c[0]===0)&&(a+=t(e.substring(c[0],c[1])),s++),r=c[1];let l=o.step(i)&7;if(i+l>c[1]?i+=l:i+1>c[1]?i++:i=c[1],s>=n)break}return a+=e.substring(r),a}pad(e){if(e===null)return null;let t=(1+this.numSubexp)*2;if(e.length<t){let n=Array(t).fill(-1);for(let t=0;t<e.length;t++)n[t]=e[t];e=n}return e}allMatches(e,t,n=e=>e){let r=[],i=e.endPos();t<0&&(t=i+1);let a=0,o=0,s=-1;for(;o<t&&a<=i;){let t=this.doExecute(e,a,b.UNANCHORED,this.prog.numCap);if(t===null||t.length===0)break;let c=!0;if(t[1]===a){t[0]===s&&(c=!1);let n=e.step(a);n<0?a=i+1:a+=n&7}else a=t[1];s=t[1],c&&(r.push(n(this.pad(t))),o++)}return r}findUTF8(e){let t=this.doExecute(E.fromUTF8(e),0,b.UNANCHORED,2);return t===null?null:e.slice(t[0],t[1])}findUTF8Index(e){let t=this.doExecute(E.fromUTF8(e),0,b.UNANCHORED,2);return t===null?null:t.slice(0,2)}find(e){let t=this.doExecute(E.fromUTF16(e),0,b.UNANCHORED,2);return t===null?``:e.substring(t[0],t[1])}findIndex(e){return this.doExecute(E.fromUTF16(e),0,b.UNANCHORED,2)}findUTF8Submatch(e){let t=this.doExecute(E.fromUTF8(e),0,b.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r<n.length;r++)2*r<t.length&&t[2*r]>=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n}findUTF8SubmatchIndex(e){return this.pad(this.doExecute(E.fromUTF8(e),0,b.UNANCHORED,this.prog.numCap))}findSubmatch(e){let t=this.doExecute(E.fromUTF16(e),0,b.UNANCHORED,this.prog.numCap);if(t===null)return null;let n=Array(1+this.numSubexp).fill(null);for(let r=0;r<n.length;r++)2*r<t.length&&t[2*r]>=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n}findSubmatchIndex(e){return this.pad(this.doExecute(E.fromUTF16(e),0,b.UNANCHORED,this.prog.numCap))}findAllUTF8(e,t){let n=this.allMatches(E.fromUTF8(e),t,t=>e.slice(t[0],t[1]));return n.length===0?null:n}findAllUTF8Index(e,t){let n=this.allMatches(E.fromUTF8(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAll(e,t){let n=this.allMatches(E.fromUTF16(e),t,t=>e.substring(t[0],t[1]));return n.length===0?null:n}findAllIndex(e,t){let n=this.allMatches(E.fromUTF16(e),t,e=>e.slice(0,2));return n.length===0?null:n}findAllUTF8Submatch(e,t){let n=this.allMatches(E.fromUTF8(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r<n.length;r++)t[2*r]>=0&&(n[r]=e.slice(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllUTF8SubmatchIndex(e,t){let n=this.allMatches(E.fromUTF8(e),t);return n.length===0?null:n}findAllSubmatch(e,t){let n=this.allMatches(E.fromUTF16(e),t,t=>{let n=Array(t.length/2|0).fill(null);for(let r=0;r<n.length;r++)t[2*r]>=0&&(n[r]=e.substring(t[2*r],t[2*r+1]));return n});return n.length===0?null:n}findAllSubmatchIndex(e,t){let n=this.allMatches(E.fromUTF16(e),t);return n.length===0?null:n}},Er=class e{static CASE_INSENSITIVE=1;static DOTALL=2;static MULTILINE=4;static DISABLE_UNICODE_GROUPS=8;static LONGEST_MATCH=16;static quote(e){return w.quoteMeta(e)}static compile(t,n=0){let r=t;if((n&e.CASE_INSENSITIVE)!==0&&(r=`(?i)${r}`),(n&e.DOTALL)!==0&&(r=`(?s)${r}`),(n&e.MULTILINE)!==0&&(r=`(?m)${r}`),(n&~(e.MULTILINE|e.DOTALL|e.CASE_INSENSITIVE|e.DISABLE_UNICODE_GROUPS|e.LONGEST_MATCH))!==0)throw new Un(`Flags should only be a combination of MULTILINE, DOTALL, CASE_INSENSITIVE, DISABLE_UNICODE_GROUPS, LONGEST_MATCH`);let i=b.PERL;(n&e.DISABLE_UNICODE_GROUPS)!==0&&(i&=~b.UNICODE_GROUPS);let a=new e(t,n);return a.re2Input=Tr.compileImpl(r,i,(n&e.LONGEST_MATCH)!==0),a}static matches(t,n){return e.compile(t).matcher(n).matches()}static initTest(t,n,r){if(t==null)throw Error(`pattern is null`);if(r==null)throw Error(`re2 is null`);let i=new e(t,n);return i.re2Input=r,i}constructor(e,t){this.patternInput=e,this.flagsInput=t}reset(){this.re2Input.reset()}flags(){return this.flagsInput}pattern(){return this.patternInput}re2(){return this.re2Input}matches(e){return this.matcher(e).matches()}matcher(e){return Array.isArray(e)&&(e=zn.utf8(e)),new Wn(this,e)}split(e,t=0){let n=this.matcher(e),r=[],i=0,a=0;for(;n.find();){if(a===0&&n.end()===0){a=n.end();continue}if(t>0&&r.length===t-1)break;if(a===n.start()){if(t===0){i+=1,a=n.end();continue}}else for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.start())),a=n.end()}if(t===0&&a!==n.inputLength()){for(;i>0;)r.push(``),--i;r.push(n.substring(a,n.inputLength()))}return(t!==0||r.length===0)&&r.push(n.substring(a,n.inputLength())),r}toString(){return this.patternInput}groupCount(){return this.re2Input.numberOfCapturingGroups()}namedGroups(){return this.re2Input.namedGroups}equals(e){return this===e?!0:e===null||this.constructor!==e.constructor?!1:this.flagsInput===e.flagsInput&&this.patternInput===e.patternInput}},Dr=class{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?`uid:`+this.uid:`anonymous-user`}isEqual(e){return e.uid===this.uid}};Dr.UNAUTHENTICATED=new Dr(null),Dr.GOOGLE_CREDENTIALS=new Dr(`google-credentials-uid`),Dr.FIRST_PARTY=new Dr(`first-party-uid`),Dr.MOCK_USER=new Dr(`mock-user`);var Or=`12.15.0`;function kr(e){Or=e}var Ar=new Ve(`@firebase/firestore`);function jr(){return Ar.logLevel}function A(e,...t){if(Ar.logLevel<=v.DEBUG){let n=t.map(Pr);Ar.debug(`Firestore (${Or}): ${e}`,...n)}}function Mr(e,...t){if(Ar.logLevel<=v.ERROR){let n=t.map(Pr);Ar.error(`Firestore (${Or}): ${e}`,...n)}}function Nr(e,...t){if(Ar.logLevel<=v.WARN){let n=t.map(Pr);Ar.warn(`Firestore (${Or}): ${e}`,...n)}}function Pr(e){if(typeof e==`string`)return e;try{return function(e){return JSON.stringify(e)}(e)}catch{return e}}function j(e,t,n){let r=`Unexpected state`;typeof t==`string`?r=t:n=t,Fr(e,r,n)}function Fr(e,t,n){let r=`FIRESTORE (${Or}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(n!==void 0)try{r+=` CONTEXT: `+JSON.stringify(n)}catch{r+=` CONTEXT: `+n}throw Mr(r),Error(r)}function M(e,t,n,r){let i=`Unexpected state`;typeof n==`string`?i=n:r=n,e||Fr(t,i,r)}function N(e,t){return e}var P={OK:`ok`,CANCELLED:`cancelled`,UNKNOWN:`unknown`,INVALID_ARGUMENT:`invalid-argument`,DEADLINE_EXCEEDED:`deadline-exceeded`,NOT_FOUND:`not-found`,ALREADY_EXISTS:`already-exists`,PERMISSION_DENIED:`permission-denied`,UNAUTHENTICATED:`unauthenticated`,RESOURCE_EXHAUSTED:`resource-exhausted`,FAILED_PRECONDITION:`failed-precondition`,ABORTED:`aborted`,OUT_OF_RANGE:`out-of-range`,UNIMPLEMENTED:`unimplemented`,INTERNAL:`internal`,UNAVAILABLE:`unavailable`,DATA_LOSS:`data-loss`},F=class extends me{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}},Ir=class{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}},Lr=class{constructor(e,t){this.user=t,this.type=`OAuth`,this.headers=new Map,this.headers.set(`Authorization`,`Bearer ${e}`)}},Rr=class{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(Dr.UNAUTHENTICATED)))}shutdown(){}},zr=class{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=>t(this.token.user)))}shutdown(){this.changeListener=null}},Br=class{constructor(e){this.t=e,this.currentUser=Dr.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){M(this.o===void 0,42304);let n=this.i,r=e=>this.i===n?Promise.resolve():(n=this.i,t(e)),i=new Ir;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new Ir,e.enqueueRetryable((()=>r(this.currentUser)))};let a=()=>{let t=i;e.enqueueRetryable((async()=>{await t.promise,await r(this.currentUser)}))},o=e=>{A(`FirebaseAuthCredentialsProvider`,`Auth detected`),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit((e=>o(e))),setTimeout((()=>{if(!this.auth){let e=this.t.getImmediate({optional:!0});e?o(e):(A(`FirebaseAuthCredentialsProvider`,`Auth not yet detected`),i.resolve(),i=new Ir)}}),0),a()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((t=>this.i===e?t?(M(typeof t.accessToken==`string`,31837,{l:t}),new Lr(t.accessToken,this.currentUser)):null:(A(`FirebaseAuthCredentialsProvider`,`getToken aborted due to token change.`),this.getToken()))):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){let e=this.auth&&this.auth.getUid();return M(e===null||typeof e==`string`,2055,{h:e}),new Dr(e)}},Vr=class{constructor(e,t,n){this.T=e,this.P=t,this.R=n,this.type=`FirstParty`,this.user=Dr.FIRST_PARTY,this.I=new Map}A(){return this.R?this.R():null}get headers(){this.I.set(`X-Goog-AuthUser`,this.T);let e=this.A();return e&&this.I.set(`Authorization`,e),this.P&&this.I.set(`X-Goog-Iam-Authorization-Token`,this.P),this.I}},Hr=class{constructor(e,t,n){this.T=e,this.P=t,this.R=n}getToken(){return Promise.resolve(new Vr(this.T,this.P,this.R))}start(e,t){e.enqueueRetryable((()=>t(Dr.FIRST_PARTY)))}shutdown(){}invalidateToken(){}},Ur=class{constructor(e){this.value=e,this.type=`AppCheck`,this.headers=new Map,e&&e.length>0&&this.headers.set(`x-firebase-appcheck`,this.value)}},Wr=class{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,y(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){M(this.o===void 0,3512);let n=e=>{e.error!=null&&A(`FirebaseAppCheckTokenProvider`,`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);let n=e.token!==this.m;return this.m=e.token,A(`FirebaseAppCheckTokenProvider`,`Received ${n?`new`:`existing`} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable((()=>n(t)))};let r=e=>{A(`FirebaseAppCheckTokenProvider`,`AppCheck detected`),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((e=>r(e))),setTimeout((()=>{if(!this.appCheck){let e=this.V.getImmediate({optional:!0});e?r(e):A(`FirebaseAppCheckTokenProvider`,`AppCheck not yet detected`)}}),0)}getToken(){if(this.p)return Promise.resolve(new Ur(this.p));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((e=>e?(M(typeof e.token==`string`,44558,{tokenResult:e}),this.m=e.token,new Ur(e.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}};function Gr(e){let t=typeof self<`u`&&(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&&typeof t.getRandomValues==`function`)t.getRandomValues(n);else for(let t=0;t<e;t++)n[t]=Math.floor(256*Math.random());return n}var Kr=class{static newId(){let e=``;for(;e.length<20;){let t=Gr(40);for(let n=0;n<t.length;++n)e.length<20&&t[n]<248&&(e+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(t[n]%62))}return e}};function I(e,t){return e<t?-1:+(e>t)}function qr(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e.charAt(r),i=t.charAt(r);if(n!==i)return Xr(n)===Xr(i)?I(n,i):Xr(n)?1:-1}return I(e.length,t.length)}var Jr=55296,Yr=57343;function Xr(e){let t=e.charCodeAt(0);return t>=Jr&&t<=Yr}function Zr(e,t,n){return e.length===t.length&&e.every(((e,r)=>n(e,t[r])))}var Qr=`__name__`,$r=class e{constructor(e,t,n){t===void 0?t=0:t>e.length&&j(637,{offset:t,range:e.length}),n===void 0?n=e.length-t:n>e.length-t&&j(1746,{length:n,range:e.length-t}),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(t){return e.comparator(this,t)===0}child(t){let n=this.segments.slice(this.offset,this.limit());return t instanceof e?t.forEach((e=>{n.push(e)})):n.push(t),this.construct(n)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return this.length===0}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,n){let r=Math.min(t.length,n.length);for(let i=0;i<r;i++){let r=e.compareSegments(t.get(i),n.get(i));if(r!==0)return r}return I(t.length,n.length)}static compareSegments(t,n){let r=e.isNumericId(t),i=e.isNumericId(n);return r&&!i?-1:!r&&i?1:r&&i?e.extractNumericId(t).compare(e.extractNumericId(n)):qr(t,n)}static isNumericId(e){return e.startsWith(`__id`)&&e.endsWith(`__`)}static extractNumericId(e){return Cn.fromString(e.substring(4,e.length-2))}},L=class e extends $r{construct(t,n,r){return new e(t,n,r)}canonicalString(){return this.toArray().join(`/`)}toString(){return this.canonicalString()}toStringWithLeadingSlash(){return`/${this.canonicalString()}`}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join(`/`)}static fromString(...t){let n=[];for(let e of t){if(e.indexOf(`//`)>=0)throw new F(P.INVALID_ARGUMENT,`Invalid segment (${e}). Paths must not contain // in them.`);n.push(...e.split(`/`).filter((e=>e.length>0)))}return new e(n)}static emptyPath(){return new e([])}},ei=/^[_a-zA-Z][_a-zA-Z0-9]*$/,ti=class e extends $r{construct(t,n,r){return new e(t,n,r)}static isValidIdentifier(e){return ei.test(e)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`"),e.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(`.`)}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===Qr}static keyField(){return new e([Qr])}static fromServerFormat(t){let n=[],r=``,i=0,a=()=>{if(r.length===0)throw new F(P.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);n.push(r),r=``},o=!1;for(;i<t.length;){let e=t[i];if(e===`\\`){if(i+1===t.length)throw new F(P.INVALID_ARGUMENT,`Path has trailing escape character: `+t);let e=t[i+1];if(e!==`\\`&&e!==`.`&&e!=="`")throw new F(P.INVALID_ARGUMENT,`Path has invalid escape sequence: `+t);r+=e,i+=2}else e==="`"?(o=!o,i++):e!==`.`||o?(r+=e,i++):(a(),i++)}if(a(),o)throw new F(P.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)}static emptyPath(){return new e([])}},R=class e{constructor(e){this.path=e}static fromPath(t){return new e(L.fromString(t))}static fromName(t){return new e(L.fromString(t).popFirst(5))}static empty(){return new e(L.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return e!==null&&L.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return L.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(t){return new e(new L(t.slice()))}};function ni(e,t,n){if(!n)throw new F(P.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function ri(e,t,n,r){if(!0===t&&!0===r)throw new F(P.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function ii(e){if(!R.isDocumentKey(e))throw new F(P.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function ai(e){if(R.isDocumentKey(e))throw new F(P.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function oi(e){return typeof e==`object`&&!!e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}function si(e){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e==`string`)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if(typeof e==`number`||typeof e==`boolean`)return``+e;if(typeof e==`object`){if(e instanceof Array)return`an array`;{let t=function(e){return e.constructor?e.constructor.name:null}(e);return t?`a custom ${t} object`:`an object`}}return typeof e==`function`?`a function`:j(12329,{type:typeof e})}function ci(e,t){if(`_delegate`in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new F(P.INVALID_ARGUMENT,`Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?`);{let n=si(e);throw new F(P.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function li(e,t){if(t<=0)throw new F(P.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}function ui(e,t){let n={typeString:e};return t&&(n.value=t),n}function di(e,t){if(!oi(e))throw new F(P.INVALID_ARGUMENT,`JSON must be an object`);let n;for(let r in t)if(t[r]){let i=t[r].typeString,a=`value`in t[r]?{value:t[r].value}:void 0;if(!(r in e)){n=`JSON missing required field: '${r}'`;break}let o=e[r];if(i&&typeof o!==i){n=`JSON field '${r}' must be a ${i}.`;break}if(a!==void 0&&o!==a.value){n=`Expected '${r}' field to equal '${a.value}'`;break}}if(n)throw new F(P.INVALID_ARGUMENT,n);return!0}var fi=-62135596800,pi=1e6,mi=class e{static now(){return e.fromMillis(Date.now())}static fromDate(t){return e.fromMillis(t.getTime())}static fromMillis(t){let n=Math.floor(t/1e3);return new e(n,Math.floor((t-1e3*n)*pi))}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0||t>=1e9)throw new F(P.INVALID_ARGUMENT,`Timestamp nanoseconds out of range: `+t);if(e<fi||e>=253402300800)throw new F(P.INVALID_ARGUMENT,`Timestamp seconds out of range: `+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/pi}_compareTo(e){return this.seconds===e.seconds?I(this.nanoseconds,e.nanoseconds):I(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return`Timestamp(seconds=`+this.seconds+`, nanoseconds=`+this.nanoseconds+`)`}toJSON(){return{type:e._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(t){if(di(t,e._jsonSchema))return new e(t.seconds,t.nanoseconds)}valueOf(){let e=this.seconds-fi;return String(e).padStart(12,`0`)+`.`+String(this.nanoseconds).padStart(9,`0`)}};mi._jsonSchemaVersion=`firestore/timestamp/1.0`,mi._jsonSchema={type:ui(`string`,mi._jsonSchemaVersion),seconds:ui(`number`),nanoseconds:ui(`number`)};var z=class e{static fromTimestamp(t){return new e(t)}static min(){return new e(new mi(0,0))}static max(){return new e(new mi(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return`SnapshotVersion(`+this.timestamp.toString()+`)`}toTimestamp(){return this.timestamp}},hi=-1,gi=class{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}};gi.UNKNOWN_ID=-1;function _i(e,t){let n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1;return new yi(z.fromTimestamp(r===1e9?new mi(n+1,0):new mi(n,r)),R.empty(),t)}function vi(e){return new yi(e.readTime,e.key,hi)}var yi=class e{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new e(z.min(),R.empty(),hi)}static max(){return new e(z.max(),R.empty(),hi)}};function bi(e,t){let n=e.readTime.compareTo(t.readTime);return n===0?(n=R.comparator(e.documentKey,t.documentKey),n===0?I(e.largestBatchId,t.largestBatchId):n):n}var xi=`The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.`,Si=class{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}};async function Ci(e){if(e.code!==P.FAILED_PRECONDITION||e.message!==xi)throw e;A(`LocalStore`,`Unexpectedly lost primary lease`)}var B=class e{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e((e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)}),(e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)}))}catch(e){return this.next(void 0,e)}next(t,n){return this.callbackAttached&&j(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(t,this.result):new e(((e,r)=>{this.nextCallback=n=>{this.wrapSuccess(t,n).next(e,r)},this.catchCallback=t=>{this.wrapFailure(n,t).next(e,r)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(t){try{let n=t();return n instanceof e?n:e.resolve(n)}catch(t){return e.reject(t)}}wrapSuccess(t,n){return t?this.wrapUserFunction((()=>t(n))):e.resolve(n)}wrapFailure(t,n){return t?this.wrapUserFunction((()=>t(n))):e.reject(n)}static resolve(t){return new e(((e,n)=>{e(t)}))}static reject(t){return new e(((e,n)=>{n(t)}))}static waitFor(t){return new e(((e,n)=>{let r=0,i=0,a=!1;t.forEach((t=>{++r,t.next((()=>{++i,a&&i===r&&e()}),(e=>n(e)))})),a=!0,i===r&&e()}))}static or(t){let n=e.resolve(!1);for(let r of t)n=n.next((t=>t?e.resolve(t):r()));return n}static forEach(e,t){let n=[];return e.forEach(((e,r)=>{n.push(t.call(this,e,r))})),this.waitFor(n)}static mapArray(t,n){return new e(((e,r)=>{let i=t.length,a=Array(i),o=0;for(let s=0;s<i;s++){let c=s;n(t[c]).next((t=>{a[c]=t,++o,o===i&&e(a)}),(e=>r(e)))}}))}static doWhile(t,n){return new e(((e,r)=>{let i=()=>{!0===t()?n().next((()=>{i()}),r):e()};i()}))}};function wi(e){let t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(`.`).slice(0,2).join(`.`):`-1`;return Number(n)}function Ti(e){return e.name===`IndexedDbTransactionError`}var Ei=class{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.ae(e),this.ue=e=>t.writeSequenceNumber(e))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this.ue&&this.ue(e),e}};Ei.ce=-1;var Di=-1;function Oi(e){return e==null}function ki(e){return e===0&&1/e==-1/0}function Ai(e){return typeof e==`number`&&Number.isInteger(e)&&!ki(e)&&e<=2**53-1&&e>=-(2**53-1)}function ji(e){return typeof e==`string`}var Mi=``;function Ni(e){let t=``;for(let n=0;n<e.length;n++)t.length>0&&(t=Fi(t)),t=Pi(e.get(n),t);return Fi(t)}function Pi(e,t){let n=t,r=e.length;for(let t=0;t<r;t++){let r=e.charAt(t);switch(r){case`\0`:n+=``;break;case Mi:n+=``;break;default:n+=r}}return n}function Fi(e){return e+``}var V=class e{constructor(e,t){this.comparator=e,this.root=t||Li.EMPTY}insert(t,n){return new e(this.comparator,this.root.insert(t,n,this.comparator).copy(null,null,Li.BLACK,null,null))}remove(t){return new e(this.comparator,this.root.remove(t,this.comparator).copy(null,null,Li.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let n=this.comparator(e,t.key);if(n===0)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){let r=this.comparator(e,n.key);if(r===0)return t+n.left.size;r<0?n=n.left:(t+=n.left.size+1,n=n.right)}return-1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal(((t,n)=>(e(t,n),!1)))}toString(){let e=[];return this.inorderTraversal(((t,n)=>(e.push(`${t}:${n}`),!1))),`{${e.join(`, `)}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Ii(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Ii(this.root,e,this.comparator,!1)}getReverseIterator(){return new Ii(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Ii(this.root,e,this.comparator,!0)}},Ii=class{constructor(e,t,n,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?n(e.key,t):1,t&&r&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===0){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(this.nodeStack.length===0)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}},Li=class e{constructor(t,n,r,i,a){this.key=t,this.value=n,this.color=r??e.RED,this.left=i??e.EMPTY,this.right=a??e.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,n,r,i,a){return new e(t??this.key,n??this.value,r??this.color,i??this.left,a??this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,n){let r=this,i=n(e,r.key);return r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):i===0?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n)),r.fixUp()}removeMin(){if(this.left.isEmpty())return e.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,n){let r,i=this;if(n(t,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(t,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),n(t,i.key)===0){if(i.right.isEmpty())return e.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,n))}return i.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){let t=this.copy(null,null,e.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){let t=this.copy(null,null,e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}colorFlip(){let e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){return 2**this.check()<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw j(43730,{key:this.key,value:this.value});if(this.right.isRed())throw j(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw j(27949);return e+ +!this.isRed()}};Li.EMPTY=null,Li.RED=!0,Li.BLACK=!1,Li.EMPTY=new class{constructor(){this.size=0}get key(){throw j(57766)}get value(){throw j(16141)}get color(){throw j(16727)}get left(){throw j(29726)}get right(){throw j(36894)}copy(e,t,n,r,i){return this}insert(e,t,n){return new Li(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};var Ri=class e{constructor(e){this.comparator=e,this.data=new V(this.comparator)}has(e){return this.data.get(e)!==null}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal(((t,n)=>(e(t),!1)))}forEachInRange(e,t){let n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){let r=n.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}forEachWhile(e,t){let n;for(n=t===void 0?this.data.getIterator():this.data.getIteratorFrom(t);n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new zi(this.data.getIterator())}getIteratorFrom(e){return new zi(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach((e=>{t=t.add(e)})),t}isEqual(t){if(!(t instanceof e)||this.size!==t.size)return!1;let n=this.data.getIterator(),r=t.data.getIterator();for(;n.hasNext();){let e=n.getNext().key,t=r.getNext().key;if(this.comparator(e,t)!==0)return!1}return!0}toArray(){let e=[];return this.forEach((t=>{e.push(t)})),e}toString(){let e=[];return this.forEach((t=>e.push(t))),`SortedSet(`+e.toString()+`)`}copy(t){let n=new e(this.comparator);return n.data=t,n}},zi=class{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}},Bi=class e{constructor(e){this.fields=e,e.sort(ti.comparator)}static empty(){return new e([])}unionWith(t){let n=new Ri(ti.comparator);for(let e of this.fields)n=n.add(e);for(let e of t)n=n.add(e);return new e(n.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Zr(this.fields,e.fields,((e,t)=>e.isEqual(t)))}};function Vi(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function Hi(e,t){for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function Ui(e,t){let n=[];for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&n.push(t(e[r],r,e));return n}function Wi(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}var Gi=class extends Error{constructor(){super(...arguments),this.name=`Base64DecodeError`}},Ki=class e{constructor(e){this.binaryString=e}static fromBase64String(t){return new e(function(e){try{return atob(e)}catch(e){throw typeof DOMException<`u`&&e instanceof DOMException?new Gi(`Invalid base64 string: `+e):e}}(t))}static fromUint8Array(t){return new e(function(e){let t=``;for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(t))}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function(e){return btoa(e)}(this.binaryString)}toUint8Array(){return function(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return I(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}};Ki.EMPTY_BYTE_STRING=new Ki(``);var qi=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Ji(e){if(M(!!e,39018),typeof e==`string`){let t=0,n=qi.exec(e);if(M(!!n,46558,{timestamp:e}),n[1]){let e=n[1];e=(e+`000000000`).substr(0,9),t=Number(e)}let r=new Date(e);return{seconds:Math.floor(r.getTime()/1e3),nanos:t}}return{seconds:H(e.seconds),nanos:H(e.nanos)}}function H(e){return typeof e==`number`?e:typeof e==`string`?Number(e):0}function Yi(e){return typeof e==`string`?Ki.fromBase64String(e):Ki.fromUint8Array(e)}var Xi=`server_timestamp`,Zi=`__type__`,Qi=`__previous_value__`,$i=`__local_write_time__`;function ea(e){return(e?.mapValue?.fields||{})[Zi]?.stringValue===Xi}function ta(e){let t=e.mapValue.fields[Qi];return ea(t)?ta(t):t}function na(e){let t=Ji(e.mapValue.fields[$i].timestampValue);return new mi(t.seconds,t.nanos)}var ra=class{constructor(e,t,n,r,i,a,o,s,c,l,u){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=a,this.autoDetectLongPolling=o,this.longPollingOptions=s,this.useFetchStreams=c,this.isUsingEmulator=l,this.apiKey=u}},ia=`(default)`,aa=class e{constructor(e,t){this.projectId=e,this.database=t||ia}static empty(){return new e(``,``)}get isDefaultDatabase(){return this.database===ia}isEqual(t){return t instanceof e&&t.projectId===this.projectId&&t.database===this.database}};function oa(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,[`projectId`]))throw new F(P.INVALID_ARGUMENT,`"projectId" not provided in firebase.initializeApp.`);return new aa(e.options.projectId,t)}var sa=`__type__`,ca=`__max__`,la={mapValue:{fields:{__type__:{stringValue:ca}}}},ua=`__vector__`,da=`value`,fa={nullValue:`NULL_VALUE`},pa={booleanValue:!0},ma={booleanValue:!1};function ha(e){return`nullValue`in e?0:`booleanValue`in e?1:`integerValue`in e||`doubleValue`in e?2:`timestampValue`in e?3:`stringValue`in e?5:`bytesValue`in e?6:`referenceValue`in e?7:`geoPointValue`in e?8:`arrayValue`in e?9:`mapValue`in e?ea(e)?4:Fa(e)?9007199254740991:Ma(e)?10:11:j(28295,{value:e})}function ga(e,t,n){if(e===t)return!0;let r=ha(e);if(r!==ha(t))return!1;switch(r){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return na(e).isEqual(na(t));case 3:return function(e,t){if(typeof e.timestampValue==`string`&&typeof t.timestampValue==`string`&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;let n=Ji(e.timestampValue),r=Ji(t.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(e,t){return Yi(e.bytesValue).isEqual(Yi(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return H(e.geoPointValue.latitude)===H(t.geoPointValue.latitude)&&H(e.geoPointValue.longitude)===H(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t,n){if(`integerValue`in e&&`integerValue`in t)return H(e.integerValue)===H(t.integerValue);let r,i;if(`doubleValue`in e&&`doubleValue`in t)r=H(e.doubleValue),i=H(t.doubleValue);else{if(!n?.Ee)return!1;r=H(e.integerValue??e.doubleValue),i=H(t.integerValue??t.doubleValue)}return r===i?!!n?.he||ki(r)===ki(i):!!(n===void 0||n.Te)&&isNaN(r)&&isNaN(i)}(e,t,n);case 9:return Zr(e.arrayValue.values||[],t.arrayValue.values||[],((e,t)=>ga(e,t,n)));case 10:case 11:return function(e,t,n){let r=e.mapValue.fields||{},i=t.mapValue.fields||{};if(Vi(r)!==Vi(i))return!1;for(let e in r)if(r.hasOwnProperty(e)&&(i[e]===void 0||!ga(r[e],i[e],n)))return!1;return!0}(e,t,n);default:return j(52216,{left:e})}}function _a(e,t){return(e.values||[]).find((e=>ga(e,t)))!==void 0}function va(e,t){if(e===t)return 0;let n=ha(e),r=ha(t);if(n!==r)return I(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return I(e.booleanValue,t.booleanValue);case 2:return function(e,t){let n=H(e.integerValue||e.doubleValue),r=H(t.integerValue||t.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(e,t);case 3:return ya(e.timestampValue,t.timestampValue);case 4:return ya(na(e),na(t));case 5:return qr(e.stringValue,t.stringValue);case 6:return function(e,t){let n=Yi(e),r=Yi(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){let n=e.split(`/`),r=t.split(`/`);for(let e=0;e<n.length&&e<r.length;e++){let t=I(n[e],r[e]);if(t!==0)return t}return I(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){let n=I(H(e.latitude),H(t.latitude));return n===0?I(H(e.longitude),H(t.longitude)):n}(e.geoPointValue,t.geoPointValue);case 9:return ba(e.arrayValue,t.arrayValue);case 10:return function(e,t){let n=e.fields||{},r=t.fields||{},i=n[da]?.arrayValue,a=r[da]?.arrayValue,o=I(i?.values?.length||0,a?.values?.length||0);return o===0?ba(i,a):o}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===la.mapValue&&t===la.mapValue)return 0;if(e===la.mapValue)return 1;if(t===la.mapValue)return-1;let n=e.fields||{},r=Object.keys(n),i=t.fields||{},a=Object.keys(i);r.sort(),a.sort();for(let e=0;e<r.length&&e<a.length;++e){let t=qr(r[e],a[e]);if(t!==0)return t;let o=va(n[r[e]],i[a[e]]);if(o!==0)return o}return I(r.length,a.length)}(e.mapValue,t.mapValue);default:throw j(23264,{Pe:n})}}function ya(e,t){if(typeof e==`string`&&typeof t==`string`&&e.length===t.length)return I(e,t);let n=Ji(e),r=Ji(t),i=I(n.seconds,r.seconds);return i===0?I(n.nanos,r.nanos):i}function ba(e,t){let n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){let t=va(n[e],r[e]);if(t!==void 0&&t!==0)return t}return I(n.length,r.length)}function xa(e){return Sa(e)}function Sa(e){return`nullValue`in e?`null`:`booleanValue`in e?``+e.booleanValue:`integerValue`in e?``+e.integerValue:`doubleValue`in e?``+e.doubleValue:`timestampValue`in e?function(e){let t=Ji(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):`stringValue`in e?e.stringValue:`bytesValue`in e?function(e){return Yi(e).toBase64()}(e.bytesValue):`referenceValue`in e?function(e){return R.fromName(e).toString()}(e.referenceValue):`geoPointValue`in e?function(e){return`geo(${e.latitude},${e.longitude})`}(e.geoPointValue):`arrayValue`in e?function(e){let t=`[`,n=!0;for(let r of e.values||[])n?n=!1:t+=`,`,t+=Sa(r);return t+`]`}(e.arrayValue):`mapValue`in e?function(e){let t=Object.keys(e.fields||{}).sort(),n=`{`,r=!0;for(let i of t)r?r=!1:n+=`,`,n+=`${i}:${Sa(e.fields[i])}`;return n+`}`}(e.mapValue):j(61005,{value:e})}function Ca(e){switch(ha(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let t=ta(e);return t?16+Ca(t):16;case 5:return 2*e.stringValue.length;case 6:return Yi(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return function(e){return(e.values||[]).reduce(((e,t)=>e+Ca(t)),0)}(e.arrayValue);case 10:case 11:return function(e){let t=0;return Hi(e.fields,((e,n)=>{t+=e.length+Ca(n)})),t}(e.mapValue);default:throw j(13486,{value:e})}}function wa(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Ta(e){return!!e&&`integerValue`in e}function Ea(e){return!!e&&`doubleValue`in e}function Da(e){return Ta(e)||Ea(e)}function Oa(e){return!!e&&`arrayValue`in e}function ka(e){return!!e&&`nullValue`in e}function Aa(e){return!!e&&`doubleValue`in e&&isNaN(Number(e.doubleValue))}function ja(e){return!!e&&`mapValue`in e}function Ma(e){return(e?.mapValue?.fields||{})[sa]?.stringValue===ua}function Na(e){return(e?.mapValue?.fields||{})[da]?.arrayValue}function Pa(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&typeof e.timestampValue==`object`)return{timestampValue:{...e.timestampValue}};if(e.mapValue){let t={mapValue:{fields:{}}};return Hi(e.mapValue.fields,((e,n)=>t.mapValue.fields[e]=Pa(n))),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=Pa(e.arrayValue.values[n]);return t}return{...e}}function Fa(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===ca}var Ia=class e{constructor(e){this.value=e}static empty(){return new e({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(t=(t.mapValue.fields||{})[e.get(n)],!ja(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Pa(t)}setAll(e){let t=ti.emptyPath(),n={},r=[];e.forEach(((e,i)=>{if(!t.isImmediateParentOf(i)){let e=this.getFieldsMap(t);this.applyChanges(e,n,r),n={},r=[],t=i.popLast()}e?n[i.lastSegment()]=Pa(e):r.push(i.lastSegment())}));let i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){let t=this.field(e.popLast());ja(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return ga(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n<e.length;++n){let r=t.mapValue.fields[e.get(n)];ja(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){Hi(t,((t,n)=>e[t]=n));for(let t of n)delete e[t]}clone(){return new e(Pa(this.value))}};function La(e){let t=[];return Hi(e.fields,((e,n)=>{let r=new ti([e]);if(ja(n)){let e=La(n.mapValue).fields;if(e.length===0)t.push(r);else for(let n of e)t.push(r.child(n))}else t.push(r)})),new Bi(t)}function Ra(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:`NaN`};if(t===1/0)return{doubleValue:`Infinity`};if(t===-1/0)return{doubleValue:`-Infinity`}}return{doubleValue:ki(t)?`-0`:t}}function za(e){return{integerValue:``+e}}function Ba(e,t,n){return Number.isInteger(t)&&n?.preferIntegers||Ai(t)?za(t):Ra(e,t)}var Va=class{constructor(){this._=void 0}};function Ha(e,t,n){return e instanceof Ga?function(e,t){let n={fields:{[Zi]:{stringValue:Xi},[$i]:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&ea(t)&&(t=ta(t)),t&&(n.fields[Qi]=t),{mapValue:n}}(n,t):e instanceof Ka?qa(e,t):e instanceof Ja?Ya(e,t):e instanceof Za?function(e,t){let n=Wa(e,t),r=to(n)+to(e.Re);return Ta(n)&&Ta(e.Re)?za(r):Ra(e.serializer,r)}(e,t):e instanceof Qa?function(e,t){return eo(e,t,Math.min)}(e,t):e instanceof $a?function(e,t){return eo(e,t,Math.max)}(e,t):void 0}function Ua(e,t,n){return e instanceof Ka?qa(e,t):e instanceof Ja?Ya(e,t):n}function Wa(e,t){return e instanceof Za?Da(t)?t:{integerValue:0}:null}var Ga=class extends Va{},Ka=class extends Va{constructor(e){super(),this.elements=e}};function qa(e,t){let n=no(t);for(let t of e.elements)n.some((e=>ga(e,t)))||n.push(t);return{arrayValue:{values:n}}}var Ja=class extends Va{constructor(e){super(),this.elements=e}};function Ya(e,t){let n=no(t);for(let t of e.elements)n=n.filter((e=>!ga(e,t)));return{arrayValue:{values:n}}}var Xa=class extends Va{constructor(e,t){super(),this.serializer=e,this.Re=t}},Za=class extends Xa{},Qa=class extends Xa{},$a=class extends Xa{};function eo(e,t,n){if(!Da(t))return e.Re;let r=n(to(t),to(e.Re));return Ta(t)&&Ta(e.Re)?za(r):Ra(e.serializer,r)}function to(e){return H(e.integerValue||e.doubleValue)}function no(e){return Oa(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}function ro(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof Ka&&t instanceof Ka||e instanceof Ja&&t instanceof Ja?Zr(e.elements,t.elements,ga):e instanceof Za&&t instanceof Za||e instanceof Qa&&t instanceof Qa||e instanceof $a&&t instanceof $a?ga(e.Re,t.Re):e instanceof Ga&&t instanceof Ga}(e.transform,t.transform)}var io=class{constructor(e,t){this.version=e,this.transformResults=t}},ao=class e{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new e}static exists(t){return new e(void 0,t)}static updateTime(t){return new e(t)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}};function oo(e,t){return e.updateTime===void 0?e.exists===void 0||e.exists===t.isFoundDocument():t.isFoundDocument()&&t.version.isEqual(e.updateTime)}var so=class{};function co(e,t){if(!e.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return e.isNoDocument()?new yo(e.key,ao.none()):new mo(e.key,e.data,ao.none());{let n=e.data,r=Ia.empty(),i=new Ri(ti.comparator);for(let e of t.fields)if(!i.has(e)){let t=n.field(e);t===null&&e.length>1&&(e=e.popLast(),t=n.field(e)),t===null?r.delete(e):r.set(e,t),i=i.add(e)}return new ho(e.key,r,new Bi(i.toArray()),ao.none())}}function lo(e,t,n){e instanceof mo?function(e,t,n){let r=e.value.clone(),i=_o(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof ho?function(e,t,n){if(!oo(e.precondition,t))return void t.convertToUnknownDocument(n.version);let r=_o(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(go(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(e,t,n):function(e,t,n){t.convertToNoDocument(n.version).setHasCommittedMutations()}(0,t,n)}function uo(e,t,n,r){return e instanceof mo?function(e,t,n,r){if(!oo(e.precondition,t))return n;let i=e.value.clone(),a=vo(e.fieldTransforms,r,t);return i.setAll(a),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof ho?function(e,t,n,r){if(!oo(e.precondition,t))return n;let i=vo(e.fieldTransforms,r,t),a=t.data;return a.setAll(go(e)),a.setAll(i),t.convertToFoundDocument(t.version,a).setHasLocalMutations(),n===null?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map((e=>e.field)))}(e,t,n,r):function(e,t,n){return oo(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function fo(e,t){let n=null;for(let r of e.fieldTransforms){let e=t.data.field(r.field),i=Wa(r.transform,e||null);i!=null&&(n===null&&(n=Ia.empty()),n.set(r.field,i))}return n||null}function po(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&!!function(e,t){return e===void 0&&t===void 0||!(!e||!t)&&Zr(e,t,((e,t)=>ro(e,t)))}(e.fieldTransforms,t.fieldTransforms)&&(e.type===0?e.value.isEqual(t.value):e.type!==1||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}var mo=class extends so{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}},ho=class extends so{constructor(e,t,n,r,i=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=r,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}};function go(e){let t=new Map;return e.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){let r=e.data.field(n);t.set(n,r)}})),t}function _o(e,t,n){let r=new Map;M(e.length===n.length,32656,{Ie:n.length,Ae:e.length});for(let i=0;i<n.length;i++){let a=e[i],o=a.transform,s=t.data.field(a.field);r.set(a.field,Ua(o,s,n[i]))}return r}function vo(e,t,n){let r=new Map;for(let i of e){let e=i.transform,a=n.data.field(i.field);r.set(i.field,Ha(e,a,t))}return r}var yo=class extends so{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}},bo=class extends so{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}},xo=class{constructor(e,t,n){this.alias=e,this.aggregateType=t,this.fieldPath=n}},So=class{constructor(e,t){this.position=e,this.inclusive=t}};function Co(e,t,n){let r=0;for(let i=0;i<e.position.length;i++){let a=t[i],o=e.position[i];if(r=a.field.isKeyField()?R.comparator(R.fromName(o.referenceValue),n.key):va(o,n.data.field(a.field)),a.dir===`desc`&&(r*=-1),r!==0)break}return r}function wo(e,t){if(e===null)return t===null;if(t===null||e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!ga(e.position[n],t.position[n]))return!1;return!0}var To=class{},Eo=class e extends To{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(t,n,r){return t.isKeyField()?n===`in`||n===`not-in`?this.createKeyFieldInFilter(t,n,r):new Po(t,n,r):n===`array-contains`?new Ro(t,r):n===`in`?new zo(t,r):n===`not-in`?new Bo(t,r):n===`array-contains-any`?new Vo(t,r):new e(t,n,r)}static createKeyFieldInFilter(e,t,n){return t===`in`?new Fo(e,n):new Io(e,n)}matches(e){let t=e.data.field(this.field);return this.op===`!=`?t!==null&&t.nullValue===void 0&&this.matchesComparison(va(t,this.value)):t!==null&&ha(this.value)===ha(t)&&this.matchesComparison(va(t,this.value))}matchesComparison(e){switch(this.op){case`<`:return e<0;case`<=`:return e<=0;case`==`:return e===0;case`!=`:return e!==0;case`>`:return e>0;case`>=`:return e>=0;default:return j(47266,{operator:this.op})}}isInequality(){return[`<`,`<=`,`>`,`>=`,`!=`,`not-in`].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}},Do=class e extends To{constructor(e,t){super(),this.filters=e,this.op=t,this.Ve=null}static create(t,n){return new e(t,n)}matches(e){return Oo(this)?this.filters.find((t=>!t.matches(e)))===void 0:this.filters.find((t=>t.matches(e)))!==void 0}getFlattenedFilters(){return this.Ve!==null||(this.Ve=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.Ve}getFilters(){return Object.assign([],this.filters)}};function Oo(e){return e.op===`and`}function ko(e){return Ao(e)&&Oo(e)}function Ao(e){for(let t of e.filters)if(t instanceof Do)return!1;return!0}function jo(e){if(e instanceof Eo)return e.field.canonicalString()+e.op.toString()+xa(e.value);if(ko(e))return e.filters.map((e=>jo(e))).join(`,`);{let t=e.filters.map((e=>jo(e))).join(`,`);return`${e.op}(${t})`}}function Mo(e,t){return e instanceof Eo?function(e,t){return t instanceof Eo&&e.op===t.op&&e.field.isEqual(t.field)&&ga(e.value,t.value)}(e,t):e instanceof Do?function(e,t){return t instanceof Do&&e.op===t.op&&e.filters.length===t.filters.length?e.filters.reduce(((e,n,r)=>e&&Mo(n,t.filters[r])),!0):!1}(e,t):void j(19439)}function No(e){return e instanceof Eo?function(e){return`${e.field.canonicalString()} ${e.op} ${xa(e.value)}`}(e):e instanceof Do?function(e){return e.op.toString()+` {`+e.getFilters().map(No).join(` ,`)+`}`}(e):`Filter`}var Po=class extends Eo{constructor(e,t,n){super(e,t,n),this.key=R.fromName(n.referenceValue)}matches(e){let t=R.comparator(e.key,this.key);return this.matchesComparison(t)}},Fo=class extends Eo{constructor(e,t){super(e,`in`,t),this.keys=Lo(`in`,t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}},Io=class extends Eo{constructor(e,t){super(e,`not-in`,t),this.keys=Lo(`not-in`,t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}};function Lo(e,t){return(t.arrayValue?.values||[]).map((e=>R.fromName(e.referenceValue)))}var Ro=class extends Eo{constructor(e,t){super(e,`array-contains`,t)}matches(e){let t=e.data.field(this.field);return Oa(t)&&_a(t.arrayValue,this.value)}},zo=class extends Eo{constructor(e,t){super(e,`in`,t)}matches(e){let t=e.data.field(this.field);return t!==null&&_a(this.value.arrayValue,t)}},Bo=class extends Eo{constructor(e,t){super(e,`not-in`,t)}matches(e){if(_a(this.value.arrayValue,{nullValue:`NULL_VALUE`}))return!1;let t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!_a(this.value.arrayValue,t)}},Vo=class extends Eo{constructor(e,t){super(e,`array-contains-any`,t)}matches(e){let t=e.data.field(this.field);return!(!Oa(t)||!t.arrayValue.values)&&t.arrayValue.values.some((e=>_a(this.value.arrayValue,e)))}},Ho=class{constructor(e,t=`asc`){this.field=e,this.dir=t}};function Uo(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}var Wo=class e{constructor(e,t,n,r,i,a,o){this.key=e,this.documentType=t,this.version=n,this.readTime=r,this.createTime=i,this.data=a,this.documentState=o}static newInvalidDocument(t){return new e(t,0,z.min(),z.min(),z.min(),Ia.empty(),0)}static newFoundDocument(t,n,r,i){return new e(t,1,n,z.min(),r,i,0)}static newNoDocument(t,n){return new e(t,2,n,z.min(),z.min(),Ia.empty(),0)}static newUnknownDocument(t,n){return new e(t,3,n,z.min(),z.min(),Ia.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(z.min())||this.documentType!==2&&this.documentType!==0||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=Ia.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Ia.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=z.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(t){return t instanceof e&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new e(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}},Go=class{constructor(e,t=null,n=[],r=[],i=null,a=null,o=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=a,this.endAt=o,this.de=null}};function Ko(e,t=null,n=[],r=[],i=null,a=null,o=null){return new Go(e,t,n,r,i,a,o)}function qo(e){let t=N(e);if(t.de===null){let e=t.path.canonicalString();t.collectionGroup!==null&&(e+=`|cg:`+t.collectionGroup),e+=`|f:`,e+=t.filters.map((e=>jo(e))).join(`,`),e+=`|ob:`,e+=t.orderBy.map((e=>function(e){return e.field.canonicalString()+e.dir}(e))).join(`,`),Oi(t.limit)||(e+=`|l:`,e+=t.limit),t.startAt&&(e+=`|lb:`,e+=t.startAt.inclusive?`b:`:`a:`,e+=t.startAt.position.map((e=>xa(e))).join(`,`)),t.endAt&&(e+=`|ub:`,e+=t.endAt.inclusive?`a:`:`b:`,e+=t.endAt.position.map((e=>xa(e))).join(`,`)),t.de=e}return t.de}function Jo(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let n=0;n<e.orderBy.length;n++)if(!Uo(e.orderBy[n],t.orderBy[n]))return!1;if(e.filters.length!==t.filters.length)return!1;for(let n=0;n<e.filters.length;n++)if(!Mo(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!wo(e.startAt,t.startAt)&&wo(e.endAt,t.endAt)}function Yo(e){return!!e.isCorePipeline}function Xo(e){return!!e.path&&R.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}var Zo=class{constructor(e,t=null,n=[],r=[],i=null,a=`F`,o=null,s=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=a,this.startAt=o,this.endAt=s,this.fe=null,this.me=null,this.pe=null,this.startAt,this.endAt}};function Qo(e,t,n,r,i,a,o,s){return new Zo(e,t,n,r,i,a,o,s)}function $o(e){return new Zo(e)}function es(e){return e.filters.length===0&&e.limit===null&&e.startAt==null&&e.endAt==null&&(e.explicitOrderBy.length===0||e.explicitOrderBy.length===1&&e.explicitOrderBy[0].field.isKeyField())}function ts(e){return R.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}function ns(e){return e.collectionGroup!==null}function rs(e){let t=N(e);if(t.fe===null){t.fe=[];let e=new Set;for(let n of t.explicitOrderBy)t.fe.push(n),e.add(n.field.canonicalString());let n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:`asc`;(function(e){let t=new Ri(ti.comparator);return e.filters.forEach((e=>{e.getFlattenedFilters().forEach((e=>{e.isInequality()&&(t=t.add(e.field))}))})),t})(t).forEach((r=>{e.has(r.canonicalString())||r.isKeyField()||t.fe.push(new Ho(r,n))})),e.has(ti.keyField().canonicalString())||t.fe.push(new Ho(ti.keyField(),n))}return t.fe}function is(e){let t=N(e);return t.me||=os(t,rs(e)),t.me}function as(e){let t=N(e);return t.pe||=os(t,e.explicitOrderBy),t.pe}function os(e,t){if(e.limitType===`F`)return Ko(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map((e=>{let t=e.dir===`desc`?`asc`:`desc`;return new Ho(e.field,t)}));let n=e.endAt?new So(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new So(e.startAt.position,e.startAt.inclusive):null;return Ko(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function ss(e,t){let n=e.filters.concat([t]);return new Zo(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function cs(e,t){let n=e.explicitOrderBy.concat([t]);return new Zo(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}function ls(e,t,n){return new Zo(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function us(e,t){return new Zo(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)}function ds(e,t){return Jo(is(e),is(t))&&e.limitType===t.limitType}function fs(e){return`Query(target=${function(e){let t=e.path.canonicalString();return e.collectionGroup!==null&&(t+=` collectionGroup=`+e.collectionGroup),e.filters.length>0&&(t+=`, filters: [${e.filters.map((e=>No(e))).join(`, `)}]`),Oi(e.limit)||(t+=`, limit: `+e.limit),e.orderBy.length>0&&(t+=`, orderBy: [${e.orderBy.map((e=>function(e){return`${e.field.canonicalString()} (${e.dir})`}(e))).join(`, `)}]`),e.startAt&&(t+=`, startAt: `,t+=e.startAt.inclusive?`b:`:`a:`,t+=e.startAt.position.map((e=>xa(e))).join(`,`)),e.endAt&&(t+=`, endAt: `,t+=e.endAt.inclusive?`a:`:`b:`,t+=e.endAt.position.map((e=>xa(e))).join(`,`)),`Target(${t})`}(is(e))}; limitType=${e.limitType})`}function ps(e,t){return t.isFoundDocument()&&function(e,t){let n=t.key.path;return e.collectionGroup===null?R.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n):t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n)}(e,t)&&function(e,t){for(let n of rs(e))if(!n.field.isKeyField()&&t.data.field(n.field)===null)return!1;return!0}(e,t)&&function(e,t){for(let n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&&function(e,t){return!(e.startAt&&!function(e,t,n){let r=Co(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,rs(e),t)||e.endAt&&!function(e,t,n){let r=Co(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,rs(e),t))}(e,t)}function ms(e){return(t,n)=>{let r=!1;for(let i of rs(e)){let e=hs(i,t,n);if(e!==0)return e;r||=i.field.isKeyField()}return 0}}function hs(e,t,n){let r=e.field.isKeyField()?R.comparator(t.key,n.key):function(e,t,n){let r=t.data.field(e),i=n.data.field(e);return r!==null&&i!==null?va(r,i):j(42886)}(e.field,t,n);switch(e.dir){case`asc`:return r;case`desc`:return-1*r;default:return j(19790,{direction:e.dir})}}var gs=class{constructor(e,t){this.count=e,this.unchangedNames=t}},_s,U;function vs(e){switch(e){case P.OK:return j(64938);case P.CANCELLED:case P.UNKNOWN:case P.DEADLINE_EXCEEDED:case P.RESOURCE_EXHAUSTED:case P.INTERNAL:case P.UNAVAILABLE:case P.UNAUTHENTICATED:return!1;case P.INVALID_ARGUMENT:case P.NOT_FOUND:case P.ALREADY_EXISTS:case P.PERMISSION_DENIED:case P.FAILED_PRECONDITION:case P.ABORTED:case P.OUT_OF_RANGE:case P.UNIMPLEMENTED:case P.DATA_LOSS:return!0;default:return j(15467,{code:e})}}function ys(e){if(e===void 0)return Mr(`GRPC error has no .code`),P.UNKNOWN;switch(e){case _s.OK:return P.OK;case _s.CANCELLED:return P.CANCELLED;case _s.UNKNOWN:return P.UNKNOWN;case _s.DEADLINE_EXCEEDED:return P.DEADLINE_EXCEEDED;case _s.RESOURCE_EXHAUSTED:return P.RESOURCE_EXHAUSTED;case _s.INTERNAL:return P.INTERNAL;case _s.UNAVAILABLE:return P.UNAVAILABLE;case _s.UNAUTHENTICATED:return P.UNAUTHENTICATED;case _s.INVALID_ARGUMENT:return P.INVALID_ARGUMENT;case _s.NOT_FOUND:return P.NOT_FOUND;case _s.ALREADY_EXISTS:return P.ALREADY_EXISTS;case _s.PERMISSION_DENIED:return P.PERMISSION_DENIED;case _s.FAILED_PRECONDITION:return P.FAILED_PRECONDITION;case _s.ABORTED:return P.ABORTED;case _s.OUT_OF_RANGE:return P.OUT_OF_RANGE;case _s.UNIMPLEMENTED:return P.UNIMPLEMENTED;case _s.DATA_LOSS:return P.DATA_LOSS;default:return j(39323,{code:e})}}(U=_s||={})[U.OK=0]=`OK`,U[U.CANCELLED=1]=`CANCELLED`,U[U.UNKNOWN=2]=`UNKNOWN`,U[U.INVALID_ARGUMENT=3]=`INVALID_ARGUMENT`,U[U.DEADLINE_EXCEEDED=4]=`DEADLINE_EXCEEDED`,U[U.NOT_FOUND=5]=`NOT_FOUND`,U[U.ALREADY_EXISTS=6]=`ALREADY_EXISTS`,U[U.PERMISSION_DENIED=7]=`PERMISSION_DENIED`,U[U.UNAUTHENTICATED=16]=`UNAUTHENTICATED`,U[U.RESOURCE_EXHAUSTED=8]=`RESOURCE_EXHAUSTED`,U[U.FAILED_PRECONDITION=9]=`FAILED_PRECONDITION`,U[U.ABORTED=10]=`ABORTED`,U[U.OUT_OF_RANGE=11]=`OUT_OF_RANGE`,U[U.UNIMPLEMENTED=12]=`UNIMPLEMENTED`,U[U.INTERNAL=13]=`INTERNAL`,U[U.UNAVAILABLE=14]=`UNAVAILABLE`,U[U.DATA_LOSS=15]=`DATA_LOSS`;var bs=class{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),n=this.inner[t];if(n!==void 0){for(let[t,r]of n)if(this.equalsFn(t,e))return r}}has(e){return this.get(e)!==void 0}set(e,t){let n=this.mapKeyFn(e),r=this.inner[n];if(r===void 0)return this.inner[n]=[[e,t]],void this.innerSize++;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],e))return void(r[n]=[e,t]);r.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),n=this.inner[t];if(n===void 0)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return n.length===1?delete this.inner[t]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(e){Hi(this.inner,((t,n)=>{for(let[t,r]of n)e(t,r)}))}isEmpty(){return Wi(this.inner)}size(){return this.innerSize}},xs=new V(R.comparator);function Ss(){return xs}var Cs=new V(R.comparator);function ws(...e){let t=Cs;for(let n of e)t=t.insert(n.key,n);return t}function Ts(e){let t=Cs;return e.forEach(((e,n)=>t=t.insert(e,n.overlayedDocument))),t}function Es(){return Os()}function Ds(){return Os()}function Os(){return new bs((e=>e.toString()),((e,t)=>e.isEqual(t)))}var ks=new V(R.comparator),As=new Ri(R.comparator);function W(...e){let t=As;for(let n of e)t=t.add(n);return t}var js=new Ri(I);function Ms(){return js}var Ns=null;function Ps(){return new TextEncoder}var Fs=new Cn([4294967295,4294967295],0);function Is(e){let t=Ps().encode(e),n=new wn;return n.update(t),new Uint8Array(n.digest())}function Ls(e){let t=new DataView(e.buffer),n=t.getUint32(0,!0),r=t.getUint32(4,!0),i=t.getUint32(8,!0),a=t.getUint32(12,!0);return[new Cn([n,r],0),new Cn([i,a],0)]}var Rs=class e{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new zs(`Invalid padding: ${t}`);if(n<0||e.length>0&&this.hashCount===0)throw new zs(`Invalid hash count: ${n}`);if(e.length===0&&t!==0)throw new zs(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.ye=Cn.fromNumber(this.ge)}we(e,t,n){let r=e.add(t.multiply(Cn.fromNumber(n)));return r.compare(Fs)===1&&(r=new Cn([r.getBits(0),r.getBits(1)],0)),r.modulo(this.ye).toNumber()}be(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.ge===0)return!1;let[t,n]=Ls(Is(e));for(let e=0;e<this.hashCount;e++){let r=this.we(t,n,e);if(!this.be(r))return!1}return!0}static create(t,n,r){let i=t%8==0?0:8-t%8,a=new e(new Uint8Array(Math.ceil(t/8)),i,n);return r.forEach((e=>a.insert(e))),a}insert(e){if(this.ge===0)return;let[t,n]=Ls(Is(e));for(let e=0;e<this.hashCount;e++){let r=this.we(t,n,e);this.ve(r)}}ve(e){let t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}},zs=class extends Error{constructor(){super(...arguments),this.name=`BloomFilterError`}},Bs=class e{constructor(e,t,n,r,i,a){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.augmentedDocumentUpdates=i,this.resolvedLimboDocuments=a}static createSynthesizedRemoteEventForCurrentChange(t,n,r){let i=new Map;return i.set(t,Vs.createSynthesizedTargetChangeForCurrentChange(t,n,r)),new e(z.min(),i,new V(I),Ss(),Ss(),W())}},Vs=class e{constructor(e,t,n,r,i){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(t,n,r){return new e(r,n,W(),W(),W())}},Hs=class{constructor(e,t,n,r){this.Se=e,this.removedTargetIds=t,this.key=n,this.De=r}},Us=class{constructor(e,t){this.targetId=e,this.xe=t}},Ws=class{constructor(e,t,n=Ki.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}},Gs=class{constructor(e){this.targetId=e,this.Ce=0,this.Fe=Ys(),this.Oe=Ki.EMPTY_BYTE_STRING,this.Me=!1,this.Ne=!0}get current(){return this.Me}get resumeToken(){return this.Oe}get Le(){return this.Ce!==0}get Be(){return this.Ne}Ue(e){e.approximateByteSize()>0&&(this.Ne=!0,this.Oe=e)}ke(){let e=W(),t=W(),n=W();return this.Fe.forEach(((r,i)=>{switch(i){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:j(38017,{changeType:i})}})),new Vs(this.Oe,this.Me,e,t,n)}qe(){this.Ne=!1,this.Fe=Ys()}$e(e,t){this.Ne=!0,this.Fe=this.Fe.insert(e,t)}Ke(e){this.Ne=!0,this.Fe=this.Fe.remove(e)}We(){this.Ce+=1}Qe(){--this.Ce,M(this.Ce>=0,3241,{Ce:this.Ce,targetId:this.targetId})}Ge(){this.Ne=!0,this.Me=!0}},Ks=`WatchChangeAggregator`,qs=class{constructor(e){this.ze=e,this.je=new Map,this.He=Ss(),this.Je=Js(),this.Ye=Ss(),this.Ze=Js(),this.Xe=new V(I)}et(e){for(let t of e.Se)e.De&&e.De.isFoundDocument()?this.tt(t,e.De):this.nt(t,e.key,e.De);for(let t of e.removedTargetIds)this.nt(t,e.key,e.De)}rt(e){this.forEachTarget(e,(t=>{let n=this.je.get(t);if(n)switch(e.state){case 0:this.it(t)&&n.Ue(e.resumeToken);break;case 1:n.Qe(),n.Le||n.qe(),n.Ue(e.resumeToken);break;case 2:n.Qe(),n.Le||this.removeTarget(t);break;case 3:this.it(t)&&(n.Ge(),n.Ue(e.resumeToken));break;case 4:this.it(t)&&(this.st(t),n.Ue(e.resumeToken));break;default:j(56790,{state:e.state})}else A(Ks,`handleTargetChange received targetChange for untracked target ID (${t}) with state (${e.state})`)}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.je.forEach(((e,n)=>{this.it(n)&&t(n)}))}_t(e){return Yo(e)?e.getPipelineSourceType()===`documents`&&e.getPipelineDocuments()?.length===1:Xo(e)}ot(e){let t=e.targetId,n=e.xe.count,r=this.ut(t);if(r){let i=r.target;if(this._t(i))if(n===0){let e=new R(Yo(i)?L.fromString(i.getPipelineDocuments()[0]):i.path);this.nt(t,e,Wo.newNoDocument(e,z.min()))}else M(n===1,20013,`Single document existence filter with count: `+n);else{let r=this.ct(t);if(r!==n){let n=this.lt(e),i=n?this.Et(n,e,r):1;if(i!==0){this.st(t);let e=i===2?`TargetPurposeExistenceFilterMismatchBloom`:`TargetPurposeExistenceFilterMismatch`;this.Xe=this.Xe.insert(t,e)}Ns?.u(function(e,t,n,r,i){let a={localCacheCount:e,existenceFilterCount:t.count,databaseId:n.database,projectId:n.projectId},o=t.unchangedNames;return o&&(a.bloomFilter={applied:i===0,hashCount:o?.hashCount??0,bitmapLength:o?.bits?.bitmap?.length??0,padding:o?.bits?.padding??0,mightContain:e=>r?.mightContain(e)??!1}),a}(r,e.xe,this.ze.Tt(),n,i))}}}}lt(e){let t=e.xe.unchangedNames;if(!t||!t.bits)return null;let{bits:{bitmap:n=``,padding:r=0},hashCount:i=0}=t,a,o;try{a=Yi(n).toUint8Array()}catch(e){if(e instanceof Gi)return Nr(`Decoding the base64 bloom filter in existence filter failed (`+e.message+`); ignoring the bloom filter and falling back to full re-query.`),null;throw e}try{o=new Rs(a,r,i)}catch(e){return Nr(e instanceof zs?`BloomFilter error: `:`Applying bloom filter failed: `,e),null}return o.ge===0?null:o}Et(e,t,n){return t.xe.count===n-this.Pt(e,t.targetId)?0:2}Pt(e,t){let n=this.ze.getRemoteKeysForTarget(t),r=0;return n.forEach((n=>{let i=this.ze.Tt(),a=`projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;e.mightContain(a)||(this.nt(t,n,null),r++)})),r}Rt(e){let t=new Map;this.je.forEach(((n,r)=>{let i=this.ut(r);if(i){if(n.current&&this._t(i.target)){let t=new R(Yo(i.target)?L.fromString(i.target.getPipelineDocuments()[0]):i.target.path);this.It(t).has(r)||this.At(r,t)||this.nt(r,t,Wo.newNoDocument(t,e))}n.Be&&(t.set(r,n.ke()),n.qe())}}));let n=W();this.Ze.forEach(((e,t)=>{let r=!0;t.forEachWhile((e=>{let t=this.ut(e);return!t||t.purpose===`TargetPurposeLimboResolution`||(r=!1,!1)})),r&&(n=n.add(e))})),this.He.forEach(((t,n)=>n.setReadTime(e))),this.Ye.forEach(((t,n)=>n.setReadTime(e)));let r=new Bs(e,t,this.Xe,this.He,this.Ye,n);return this.He=Ss(),this.Je=Js(),this.Ye=Ss(),this.Ze=Js(),this.Xe=new V(I),r}tt(e,t){let n=this.je.get(e);if(!n||!this.it(e))return void A(Ks,`addDocumentToTarget received document for unknown inactive target (${e})`);let r=this.At(e,t.key)?2:0;n.$e(t.key,r),Yo(this.ut(e).target)&&this.ut(e).target.getPipelineFlavor()!==`exact`?this.Ye=this.Ye.insert(t.key,t):this.He=this.He.insert(t.key,t),this.Je=this.Je.insert(t.key,this.It(t.key).add(e)),this.Ze=this.Ze.insert(t.key,this.Vt(t.key).add(e))}nt(e,t,n){let r=this.je.get(e);r&&this.it(e)?(this.At(e,t)?r.$e(t,1):r.Ke(t),this.Ze=this.Ze.insert(t,this.Vt(t).delete(e)),this.Ze=this.Ze.insert(t,this.Vt(t).add(e)),n&&(Yo(this.ut(e).target)&&this.ut(e).target.getPipelineFlavor()!==`exact`?this.Ye=this.Ye.insert(t,n):this.He=this.He.insert(t,n))):A(Ks,`removeDocumentFromTarget received document for unknown or inactive target (${e})`)}removeTarget(e){this.je.delete(e)}ct(e){let t=this.je.get(e);if(!t)return 0;let n=t.ke();return this.ze.getRemoteKeysForTarget(e).size+n.addedDocuments.size-n.removedDocuments.size}We(e){let t=this.je.get(e);t||(A(Ks,`recordPendingTargetRequest set up tracking for target ID ${e}`),t=new Gs(e),this.je.set(e,t)),t.We()}Vt(e){let t=this.Ze.get(e);return t||(t=new Ri(I),this.Ze=this.Ze.insert(e,t)),t}It(e){let t=this.Je.get(e);return t||(t=new Ri(I),this.Je=this.Je.insert(e,t)),t}it(e){let t=this.ut(e)!==null;return t||A(Ks,`Detected inactive target`,e),t}ut(e){let t=this.je.get(e);return t===void 0||t.Le?null:this.ze.dt(e)}st(e){this.je.set(e,new Gs(e)),this.ze.getRemoteKeysForTarget(e).forEach((t=>{this.nt(e,t,null)}))}At(e,t){return this.ze.getRemoteKeysForTarget(e).has(t)}};function Js(){return new V(R.comparator)}function Ys(){return new V(R.comparator)}var Xs={asc:`ASCENDING`,desc:`DESCENDING`},Zs={"<":`LESS_THAN`,"<=":`LESS_THAN_OR_EQUAL`,">":`GREATER_THAN`,">=":`GREATER_THAN_OR_EQUAL`,"==":`EQUAL`,"!=":`NOT_EQUAL`,"array-contains":`ARRAY_CONTAINS`,in:`IN`,"not-in":`NOT_IN`,"array-contains-any":`ARRAY_CONTAINS_ANY`},Qs={and:`AND`,or:`OR`},$s=class{constructor(e,t){this.databaseId=e,this.useProto3Json=t}};function ec(e,t){return e.useProto3Json||Oi(t)?t:{value:t}}function tc(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,``).replace(`Z`,``)}.${(`000000000`+t.nanoseconds).slice(-9)}Z`:{seconds:``+t.seconds,nanos:t.nanoseconds}}function nc(e){let t=Ji(e);return new mi(t.seconds,t.nanos)}function rc(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function ic(e,t){return tc(e,t.toTimestamp())}function ac(e){return M(!!e,49232),z.fromTimestamp(nc(e))}function oc(e,t){return sc(e,t).canonicalString()}function sc(e,t){let n=function(e){return new L([`projects`,e.projectId,`databases`,e.database])}(e).child(`documents`);return t===void 0?n:n.child(t)}function cc(e){let t=L.fromString(e);return M(Nc(t),10190,{key:t.toString()}),t}function lc(e,t){return oc(e.databaseId,t.path)}function uc(e,t){let n=cc(t);if(n.get(1)!==e.databaseId.projectId)throw new F(P.INVALID_ARGUMENT,`Tried to deserialize key from different project: `+n.get(1)+` vs `+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new F(P.INVALID_ARGUMENT,`Tried to deserialize key from different database: `+n.get(3)+` vs `+e.databaseId.database);return new R(mc(n))}function dc(e,t){return oc(e.databaseId,t)}function fc(e){let t=cc(e);return t.length===4?L.emptyPath():mc(t)}function pc(e){return new L([`projects`,e.databaseId.projectId,`databases`,e.databaseId.database]).canonicalString()}function mc(e){return M(e.length>4&&e.get(4)===`documents`,29091,{key:e.toString()}),e.popFirst(5)}function hc(e,t,n){return{name:lc(e,t),fields:n.value.mapValue.fields}}function gc(e,t){let n;if(`targetChange`in t){t.targetChange;let r=function(e){return e===`NO_CHANGE`?0:e===`ADD`?1:e===`REMOVE`?2:e===`CURRENT`?3:e===`RESET`?4:j(39313,{state:e})}(t.targetChange.targetChangeType||`NO_CHANGE`),i=t.targetChange.targetIds||[],a=function(e,t){return e.useProto3Json?(M(t===void 0||typeof t==`string`,58123),Ki.fromBase64String(t||``)):(M(t===void 0||t instanceof Buffer||t instanceof Uint8Array,16193),Ki.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),o=t.targetChange.cause;n=new Ws(r,i,a,o&&function(e){return new F(e.code===void 0?P.UNKNOWN:ys(e.code),e.message||``)}(o)||null)}else if(`documentChange`in t){t.documentChange;let r=t.documentChange;r.document,r.document.name,r.document.updateTime;let i=uc(e,r.document.name),a=ac(r.document.updateTime),o=r.document.createTime?ac(r.document.createTime):z.min(),s=new Ia({mapValue:{fields:r.document.fields}}),c=Wo.newFoundDocument(i,a,o,s);n=new Hs(r.targetIds||[],r.removedTargetIds||[],c.key,c)}else if(`documentDelete`in t){t.documentDelete;let r=t.documentDelete;r.document;let i=uc(e,r.document),a=r.readTime?ac(r.readTime):z.min(),o=Wo.newNoDocument(i,a);n=new Hs([],r.removedTargetIds||[],o.key,o)}else if(`documentRemove`in t){t.documentRemove;let r=t.documentRemove;r.document;let i=uc(e,r.document);n=new Hs([],r.removedTargetIds||[],i,null)}else{if(!(`filter`in t))return j(11601,{ft:t});{t.filter;let e=t.filter;e.targetId;let{count:r=0,unchangedNames:i}=e,a=new gs(r,i),o=e.targetId;n=new Us(o,a)}}return n}function _c(e,t){let n;if(t instanceof mo)n={update:hc(e,t.key,t.value)};else if(t instanceof yo)n={delete:lc(e,t.key)};else if(t instanceof ho)n={update:hc(e,t.key,t.data),updateMask:Mc(t.fieldMask)};else{if(!(t instanceof bo))return j(16599,{gt:t.type});n={verify:lc(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map((e=>function(e,t){let n=t.transform;if(n instanceof Ga)return{fieldPath:t.field.canonicalString(),setToServerValue:`REQUEST_TIME`};if(n instanceof Ka)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof Ja)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Za)return{fieldPath:t.field.canonicalString(),increment:n.Re};if(n instanceof Qa)return{fieldPath:t.field.canonicalString(),minimum:n.Re};if(n instanceof $a)return{fieldPath:t.field.canonicalString(),maximum:n.Re};throw j(20930,{transform:t.transform})}(0,e)))),t.precondition.isNone||(n.currentDocument=function(e,t){return t.updateTime===void 0?t.exists===void 0?j(27497):{exists:t.exists}:{updateTime:ic(e,t.updateTime)}}(e,t.precondition)),n}function vc(e,t){return e&&e.length>0?(M(t!==void 0,14353),e.map((e=>function(e,t){let n=e.updateTime?ac(e.updateTime):ac(t);return n.isEqual(z.min())&&(n=ac(t)),new io(n,e.transformResults||[])}(e,t)))):[]}function yc(e,t){return{documents:[dc(e,t.path)]}}function bc(e,t){let n={structuredQuery:{}},r=t.path,i;t.collectionGroup===null?(i=r.popLast(),n.structuredQuery.from=[{collectionId:r.lastSegment()}]):(i=r,n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]),n.parent=dc(e,i);let a=function(e){if(e.length!==0)return jc(Do.create(e,`and`))}(t.filters);a&&(n.structuredQuery.where=a);let o=function(e){if(e.length!==0)return e.map((e=>function(e){return{field:kc(e.field),direction:Ec(e.dir)}}(e)))}(t.orderBy);o&&(n.structuredQuery.orderBy=o);let s=ec(e,t.limit);return s!==null&&(n.structuredQuery.limit=s),t.startAt&&(n.structuredQuery.startAt=function(e){return{before:e.inclusive,values:e.position}}(t.startAt)),t.endAt&&(n.structuredQuery.endAt=function(e){return{before:!e.inclusive,values:e.position}}(t.endAt)),{yt:n,parent:i}}function xc(e,t,n,r){let{yt:i,parent:a}=bc(e,t),o={},s=[],c=0;return n.forEach((e=>{let t=r?e.alias:`aggregate_`+c++;o[t]=e.alias,e.aggregateType===`count`?s.push({alias:t,count:{}}):e.aggregateType===`avg`?s.push({alias:t,avg:{field:kc(e.fieldPath)}}):e.aggregateType===`sum`&&s.push({alias:t,sum:{field:kc(e.fieldPath)}})})),{request:{structuredAggregationQuery:{aggregations:s,structuredQuery:i.structuredQuery},parent:i.parent},wt:o,parent:a}}function Sc(e){let t=fc(e.parent),n=e.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){M(r===1,65062);let e=n.from[0];e.allDescendants?i=e.collectionId:t=t.child(e.collectionId)}let a=[];n.where&&(a=function(e){let t=Tc(e);return t instanceof Do&&ko(t)?t.getFilters():[t]}(n.where));let o=[];n.orderBy&&(o=function(e){return e.map((e=>function(e){return new Ho(Ac(e.field),function(e){switch(e){case`ASCENDING`:return`asc`;case`DESCENDING`:return`desc`;default:return}}(e.direction))}(e)))}(n.orderBy));let s=null;n.limit&&(s=function(e){let t;return t=typeof e==`object`?e.value:e,Oi(t)?null:t}(n.limit));let c=null;n.startAt&&(c=function(e){let t=!!e.before;return new So(e.values||[],t)}(n.startAt));let l=null;return n.endAt&&(l=function(e){let t=!e.before;return new So(e.values||[],t)}(n.endAt)),Qo(t,i,o,a,s,`F`,c,l)}function Cc(e,t){let n=function(e){switch(e){case`TargetPurposeListen`:return null;case`TargetPurposeExistenceFilterMismatch`:return`existence-filter-mismatch`;case`TargetPurposeExistenceFilterMismatchBloom`:return`existence-filter-mismatch-bloom`;case`TargetPurposeLimboResolution`:return`limbo-document`;default:return j(28987,{purpose:e})}}(t.purpose);return n==null?null:{"goog-listen-tags":n}}function wc(e,t){return{structuredPipeline:{pipeline:{stages:t.stages.map((t=>t._toProto(e)))}}}}function Tc(e){return e.unaryFilter===void 0?e.fieldFilter===void 0?e.compositeFilter===void 0?j(30097,{filter:e}):function(e){return Do.create(e.compositeFilter.filters.map((e=>Tc(e))),function(e){switch(e){case`AND`:return`and`;case`OR`:return`or`;default:return j(1026)}}(e.compositeFilter.op))}(e):function(e){return Eo.create(Ac(e.fieldFilter.field),function(e){switch(e){case`EQUAL`:return`==`;case`NOT_EQUAL`:return`!=`;case`GREATER_THAN`:return`>`;case`GREATER_THAN_OR_EQUAL`:return`>=`;case`LESS_THAN`:return`<`;case`LESS_THAN_OR_EQUAL`:return`<=`;case`ARRAY_CONTAINS`:return`array-contains`;case`IN`:return`in`;case`NOT_IN`:return`not-in`;case`ARRAY_CONTAINS_ANY`:return`array-contains-any`;case`OPERATOR_UNSPECIFIED`:return j(58110);default:return j(50506)}}(e.fieldFilter.op),e.fieldFilter.value)}(e):function(e){switch(e.unaryFilter.op){case`IS_NAN`:let t=Ac(e.unaryFilter.field);return Eo.create(t,`==`,{doubleValue:NaN});case`IS_NULL`:let n=Ac(e.unaryFilter.field);return Eo.create(n,`==`,{nullValue:`NULL_VALUE`});case`IS_NOT_NAN`:let r=Ac(e.unaryFilter.field);return Eo.create(r,`!=`,{doubleValue:NaN});case`IS_NOT_NULL`:let i=Ac(e.unaryFilter.field);return Eo.create(i,`!=`,{nullValue:`NULL_VALUE`});case`OPERATOR_UNSPECIFIED`:return j(61313);default:return j(60726)}}(e)}function Ec(e){return Xs[e]}function Dc(e){return Zs[e]}function Oc(e){return Qs[e]}function kc(e){return{fieldPath:e.canonicalString()}}function Ac(e){return ti.fromServerFormat(e.fieldPath)}function jc(e){return e instanceof Eo?function(e){if(e.op===`==`){if(Aa(e.value))return{unaryFilter:{field:kc(e.field),op:`IS_NAN`}};if(ka(e.value))return{unaryFilter:{field:kc(e.field),op:`IS_NULL`}}}else if(e.op===`!=`){if(Aa(e.value))return{unaryFilter:{field:kc(e.field),op:`IS_NOT_NAN`}};if(ka(e.value))return{unaryFilter:{field:kc(e.field),op:`IS_NOT_NULL`}}}return{fieldFilter:{field:kc(e.field),op:Dc(e.op),value:e.value}}}(e):e instanceof Do?function(e){let t=e.getFilters().map((e=>jc(e)));return t.length===1?t[0]:{compositeFilter:{op:Oc(e.op),filters:t}}}(e):j(54877,{filter:e})}function Mc(e){let t=[];return e.fields.forEach((e=>t.push(e.canonicalString()))),{fieldPaths:t}}function Nc(e){return e.length>=4&&e.get(0)===`projects`&&e.get(2)===`databases`}function Pc(e){return!!e&&typeof e._toProto==`function`&&e._protoValueType===`ProtoValue`}function Fc(e,t){let n={fields:{}};return t.forEach(((t,r)=>{if(typeof r!=`string`)throw Error(`Cannot encode map with non-string key: ${r}`);n.fields[r]=t._toProto(e)})),{mapValue:n}}function Ic(e){return{stringValue:e}}function Lc(e){return new $s(e,!0)}var Rc=class e{constructor(e){this._byteString=e}static fromBase64String(t){try{return new e(Ki.fromBase64String(t))}catch(e){throw new F(P.INVALID_ARGUMENT,`Failed to construct data from Base64 string: `+e)}}static fromUint8Array(t){return new e(Ki.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return`Bytes(base64: `+this.toBase64()+`)`}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:e._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(t){if(di(t,e._jsonSchema))return e.fromBase64String(t.bytes)}};Rc._jsonSchemaVersion=`firestore/bytes/1.0`,Rc._jsonSchema={type:ui(`string`,Rc._jsonSchemaVersion),bytes:ui(`string`)};var zc=class{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new F(P.INVALID_ARGUMENT,`Invalid field name at argument $(i + 1). Field names must not be empty.`);this._internalPath=new ti(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}};function Bc(){return new zc(Qr)}var Vc=class{constructor(e){this._methodName=e}},Hc=class e{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new F(P.INVALID_ARGUMENT,`Latitude must be a number between -90 and 90, but was: `+e);if(!isFinite(t)||t<-180||t>180)throw new F(P.INVALID_ARGUMENT,`Longitude must be a number between -180 and 180, but was: `+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return I(this._lat,e._lat)||I(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:e._jsonSchemaVersion}}static fromJSON(t){if(di(t,e._jsonSchema))return new e(t.latitude,t.longitude)}};function Uc(e){let t={};return e.timeoutSeconds!==void 0&&(t.timeoutSeconds=e.timeoutSeconds),t}Hc._jsonSchemaVersion=`firestore/geoPoint/1.0`,Hc._jsonSchema={type:ui(`string`,Hc._jsonSchemaVersion),latitude:ui(`number`),longitude:ui(`number`)};var Wc=class{bt(e){}shutdown(){}},Gc=`ConnectivityMonitor`,Kc=class{constructor(){this.vt=()=>this.St(),this.Dt=()=>this.xt(),this.Ct=[],this.Ft()}bt(e){this.Ct.push(e)}shutdown(){window.removeEventListener(`online`,this.vt),window.removeEventListener(`offline`,this.Dt)}Ft(){window.addEventListener(`online`,this.vt),window.addEventListener(`offline`,this.Dt)}St(){A(Gc,`Network connectivity changed: AVAILABLE`);for(let e of this.Ct)e(0)}xt(){A(Gc,`Network connectivity changed: UNAVAILABLE`);for(let e of this.Ct)e(1)}static C(){return typeof window<`u`&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}},qc=null;function Jc(){return qc===null?qc=function(){return 268435456+Math.round(2147483648*Math.random())}():qc++,`0x`+qc.toString(16)}var Yc=`RestConnection`,Xc={BatchGetDocuments:`batchGet`,Commit:`commit`,RunQuery:`runQuery`,RunAggregationQuery:`runAggregationQuery`,ExecutePipeline:`executePipeline`},Zc=class{get Ot(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;let t=e.ssl?`https`:`http`,n=encodeURIComponent(this.databaseId.projectId),r=encodeURIComponent(this.databaseId.database);this.Mt=t+`://`+e.host,this.Nt=`projects/${n}/databases/${r}`,this.Lt=this.databaseId.database===ia?`project_id=${n}`:`project_id=${n}&database_id=${r}`}Bt(e,t,n,r,i){let a=Jc(),o=this.Ut(e,t.toUriEncodedString());A(Yc,`Sending RPC '${e}' ${a}:`,o,n);let s={"google-cloud-resource-prefix":this.Nt,"x-goog-request-params":this.Lt};this.kt(s,r,i);let{host:c}=new URL(o),l=Oe(c);return this.qt(e,o,s,n,l).then((t=>(A(Yc,`Received RPC '${e}' ${a}: `,t),t)),(t=>{throw Nr(Yc,`RPC '${e}' ${a} failed with error: `,t,`url: `,o,`request:`,n),t}))}$t(e,t,n,r,i,a){return this.Bt(e,t,n,r,i)}kt(e,t,n){e[`X-Goog-Api-Client`]=function(){return`gl-js/ fire/`+Or}(),e[`Content-Type`]=`text/plain`,this.databaseInfo.appId&&(e[`X-Firebase-GMPID`]=this.databaseInfo.appId),t&&t.headers.forEach(((t,n)=>e[n]=t)),n&&n.headers.forEach(((t,n)=>e[n]=t))}Ut(e,t){let n=Xc[e],r=`${this.Mt}/v1/${t}:${n}`;return this.databaseInfo.apiKey&&(r=`${r}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),r}terminate(){}},Qc=class{constructor(e){this.Kt=e.Kt,this.Wt=e.Wt}Qt(e){this.Gt=e}zt(e){this.jt=e}Ht(e){this.Jt=e}onMessage(e){this.Yt=e}close(){this.Wt()}send(e){this.Kt(e)}Zt(){this.Gt()}Xt(){this.jt()}en(e){this.Jt(e)}tn(e){this.Yt(e)}},$c=`WebChannelConnection`,el=(e,t,n)=>{e.listen(t,(e=>{try{n(e)}catch(e){setTimeout((()=>{throw e}),0)}}))},tl=class e extends Zc{constructor(e){super(e),this.nn=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static rn(){e.sn||=(el(Nn(),Mn.STAT_EVENT,(e=>{e.stat===jn.PROXY?A($c,`STAT_EVENT: detected buffering proxy`):e.stat===jn.NOPROXY&&A($c,`STAT_EVENT: detected no buffering proxy`)})),!0)}qt(e,t,n,r,i){let a=Jc();return new Promise(((i,o)=>{let s=new Dn;s.setWithCredentials(!0),s.listenOnce(kn.COMPLETE,(()=>{try{switch(s.getLastErrorCode()){case An.NO_ERROR:let t=s.getResponseJson();A($c,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(t)),i(t);break;case An.TIMEOUT:A($c,`RPC '${e}' ${a} timed out`),o(new F(P.DEADLINE_EXCEEDED,`Request time out`));break;case An.HTTP_ERROR:let n=s.getStatus();if(A($c,`RPC '${e}' ${a} failed with status:`,n,`response text:`,s.getResponseText()),n>0){let e=s.getResponseJson();Array.isArray(e)&&(e=e[0]);let t=e?.error;t&&t.status&&t.message?o(new F(function(e){let t=e.toLowerCase().replace(/_/g,`-`);return Object.values(P).indexOf(t)>=0?t:P.UNKNOWN}(t.status),t.message)):o(new F(P.UNKNOWN,`Server responded with status `+s.getStatus()))}else o(new F(P.UNAVAILABLE,`Connection failed.`));break;default:j(9055,{_n:e,streamId:a,an:s.getLastErrorCode(),un:s.getLastError()})}}finally{A($c,`RPC '${e}' ${a} completed.`)}}));let c=JSON.stringify(r);A($c,`RPC '${e}' ${a} sending request:`,r),s.send(t,`POST`,c,n,15)}))}cn(t,n,r){let i=Jc(),a=[this.Mt,`/`,`google.firestore.v1.Firestore`,`/`,t,`/channel`],o=this.createWebChannelTransport(),s={httpSessionIdParam:`gsessionid`,initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},c=this.longPollingOptions.timeoutSeconds;c!==void 0&&(s.longPollingTimeout=Math.round(1e3*c)),this.useFetchStreams&&(s.useFetchStreams=!0),this.kt(s.initMessageHeaders,n,r),s.encodeInitMessageHeaders=!0;let l=a.join(``);A($c,`Creating RPC '${t}' stream ${i}: ${l}`,s);let u=o.createWebChannel(l,s);this.En(u);let d=!1,f=!1,p=new Qc({Kt:e=>{f?A($c,`Not sending because RPC '${t}' stream ${i} is closed:`,e):(d||=(A($c,`Opening RPC '${t}' stream ${i} transport.`),u.open(),!0),A($c,`RPC '${t}' stream ${i} sending:`,e),u.send(e))},Wt:()=>u.close()});return el(u,On.EventType.OPEN,(()=>{f||(A($c,`RPC '${t}' stream ${i} transport opened.`),p.Zt())})),el(u,On.EventType.CLOSE,(()=>{f||(f=!0,A($c,`RPC '${t}' stream ${i} transport closed`),p.en(),this.hn(u))})),el(u,On.EventType.ERROR,(e=>{f||(f=!0,Nr($c,`RPC '${t}' stream ${i} transport errored. Name:`,e.name,`Message:`,e.message),p.en(new F(P.UNAVAILABLE,`The operation could not be completed`)))})),el(u,On.EventType.MESSAGE,(e=>{if(!f){let n=e.data[0];M(!!n,16349);let r=n,a=r?.error||r[0]?.error;if(a){A($c,`RPC '${t}' stream ${i} received error:`,a);let e=a.status,n=function(e){let t=_s[e];if(t!==void 0)return ys(t)}(e),r=a.message;e===`NOT_FOUND`&&r.includes(`database`)&&r.includes(`does not exist`)&&r.includes(this.databaseId.database)&&Nr(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),n===void 0&&(n=P.INTERNAL,r=`Unknown error status: `+e+` with message `+a.message),f=!0,p.en(new F(n,r)),u.close()}else A($c,`RPC '${t}' stream ${i} received:`,n),p.tn(n)}})),e.rn(),setTimeout((()=>{p.Xt()}),0),p}terminate(){this.nn.forEach((e=>e.close())),this.nn=[]}En(e){this.nn.push(e)}hn(e){this.nn=this.nn.filter((t=>t===e))}kt(e,t,n){super.kt(e,t,n),this.databaseInfo.apiKey&&(e[`x-goog-api-key`]=this.databaseInfo.apiKey)}createWebChannelTransport(){return Pn()}};function nl(e){return new tl(e)}tl.sn=!1;var rl=class{constructor(e,t,n=1e3,r=1.5,i=6e4){this.Tn=e,this.timerId=t,this.Pn=n,this.Rn=r,this.In=i,this.An=0,this.Vn=null,this.dn=Date.now(),this.reset()}reset(){this.An=0}fn(){this.An=this.In}mn(e){this.cancel();let t=Math.floor(this.An+this.pn()),n=Math.max(0,Date.now()-this.dn),r=Math.max(0,t-n);r>0&&A(`ExponentialBackoff`,`Backing off for ${r} ms (base delay: ${this.An} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.Vn=this.Tn.enqueueAfterDelay(this.timerId,r,(()=>(this.dn=Date.now(),e()))),this.An*=this.Rn,this.An<this.Pn&&(this.An=this.Pn),this.An>this.In&&(this.An=this.In)}gn(){this.Vn!==null&&(this.Vn.skipDelay(),this.Vn=null)}cancel(){this.Vn!==null&&(this.Vn.cancel(),this.Vn=null)}pn(){return(Math.random()-.5)*this.An}},il=`PersistentStream`,al=class{constructor(e,t,n,r,i,a,o,s){this.Tn=e,this.yn=n,this.wn=r,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=o,this.listener=s,this.state=0,this.bn=0,this.vn=null,this.Sn=null,this.stream=null,this.Dn=0,this.xn=new rl(e,t)}Cn(){return this.state===1||this.state===5||this.Fn()}Fn(){return this.state===2||this.state===3}start(){this.Dn=0,this.state===4?this.On():this.auth()}async stop(){this.Cn()&&await this.close(0)}Mn(){this.state=0,this.xn.reset()}Nn(){this.Fn()&&this.vn===null&&(this.vn=this.Tn.enqueueAfterDelay(this.yn,6e4,(()=>this.Ln())))}Bn(e){this.Un(),this.stream.send(e)}async Ln(){if(this.Fn())return this.close(0)}Un(){this.vn&&=(this.vn.cancel(),null)}kn(){this.Sn&&=(this.Sn.cancel(),null)}async close(e,t){this.Un(),this.kn(),this.xn.cancel(),this.bn++,e===4?t&&t.code===P.RESOURCE_EXHAUSTED?(Mr(t.toString()),Mr(`Using maximum backoff delay to prevent overloading the backend.`),this.xn.fn()):t&&t.code===P.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()):this.xn.reset(),this.stream!==null&&(this.qn(),this.stream.close(),this.stream=null),this.state=e,await this.listener.Ht(t)}qn(){}auth(){this.state=1;let e=this.$n(this.bn),t=this.bn;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([e,n])=>{this.bn===t&&this.Kn(e,n)}),(t=>{e((()=>{let e=new F(P.UNKNOWN,`Fetching auth token failed: `+t.message);return this.Wn(e)}))}))}Kn(e,t){let n=this.$n(this.bn);this.stream=this.Qn(e,t),this.stream.Qt((()=>{n((()=>this.listener.Qt()))})),this.stream.zt((()=>{n((()=>(this.state=2,this.Sn=this.Tn.enqueueAfterDelay(this.wn,1e4,(()=>(this.Fn()&&(this.state=3),Promise.resolve()))),this.listener.zt())))})),this.stream.Ht((e=>{n((()=>this.Wn(e)))})),this.stream.onMessage((e=>{n((()=>++this.Dn==1?this.Gn(e):this.onNext(e)))}))}On(){this.state=5,this.xn.mn((async()=>{this.state=0,this.start()}))}Wn(e){return A(il,`close with error: ${e}`),this.stream=null,this.close(4,e)}$n(e){return t=>{this.Tn.enqueueAndForget((()=>this.bn===e?t():(A(il,`stream callback skipped by getCloseGuardedDispatcher.`),Promise.resolve())))}}},ol=class extends al{constructor(e,t,n,r,i,a){super(e,`listen_stream_connection_backoff`,`listen_stream_idle`,`health_check_timeout`,t,n,r,a),this.serializer=i}Qn(e,t){return this.connection.cn(`Listen`,e,t)}Gn(e){return this.onNext(e)}onNext(e){this.xn.reset();let t=gc(this.serializer,e),n=function(e){if(!(`targetChange`in e))return z.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?z.min():t.readTime?ac(t.readTime):z.min()}(e);return this.listener.zn(t,n)}jn(e){let t={};t.database=pc(this.serializer),t.addTarget=function(e,t){let n,r=t.target;if(n=Yo(r)?{pipelineQuery:wc(e,r)}:Xo(r)?{documents:yc(e,r)}:{query:bc(e,r).yt},n.targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=rc(e,t.resumeToken);let r=ec(e,t.expectedCount);r!==null&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(z.min())>0){n.readTime=tc(e,t.snapshotVersion.toTimestamp());let r=ec(e,t.expectedCount);r!==null&&(n.expectedCount=r)}return n}(this.serializer,e);let n=Cc(this.serializer,e);n&&(t.labels=n),this.Bn(t)}Hn(e){let t={};t.database=pc(this.serializer),t.removeTarget=e,this.Bn(t)}},sl=class extends al{constructor(e,t,n,r,i,a){super(e,`write_stream_connection_backoff`,`write_stream_idle`,`health_check_timeout`,t,n,r,a),this.serializer=i}get Jn(){return this.Dn>0}start(){this.lastStreamToken=void 0,super.start()}qn(){this.Jn&&this.Yn([])}Qn(e,t){return this.connection.cn(`Write`,e,t)}Gn(e){return M(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,M(!e.writeResults||e.writeResults.length===0,55816),this.listener.Zn()}onNext(e){M(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.xn.reset();let t=vc(e.writeResults,e.commitTime),n=ac(e.commitTime);return this.listener.Xn(n,t)}er(){let e={};e.database=pc(this.serializer),this.Bn(e)}Yn(e){let t={streamToken:this.lastStreamToken,writes:e.map((e=>_c(this.serializer,e)))};this.Bn(t)}},cl=class{},ll=class extends cl{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=r,this.tr=!1}nr(){if(this.tr)throw new F(P.FAILED_PRECONDITION,`The client has already been terminated.`)}Bt(e,t,n,r){return this.nr(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,a])=>this.connection.Bt(e,sc(t,n),r,i,a))).catch((e=>{throw e.name===`FirebaseError`?(e.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new F(P.UNKNOWN,e.toString())}))}$t(e,t,n,r,i){return this.nr(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,o])=>this.connection.$t(e,sc(t,n),r,a,o,i))).catch((e=>{throw e.name===`FirebaseError`?(e.code===P.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new F(P.UNKNOWN,e.toString())}))}terminate(){this.tr=!0,this.connection.terminate()}};function ul(e,t,n,r){return new ll(e,t,n,r)}var dl=`ComponentProvider`,fl=new Map;function pl(e,t,n,r,i){return new ra(e,t,n,i.host,i.ssl,i.experimentalForceLongPolling,i.experimentalAutoDetectLongPolling,Uc(i.experimentalLongPollingOptions),i.useFetchStreams,i.isUsingEmulator,r)}var ml={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},hl=41943040,gl=class e{static withCacheSize(t){return new e(t,e.DEFAULT_COLLECTION_PERCENTILE,e.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}};gl.DEFAULT_COLLECTION_PERCENTILE=10,gl.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,gl.DEFAULT=new gl(hl,gl.DEFAULT_COLLECTION_PERCENTILE,gl.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),gl.DISABLED=new gl(-1,0,0);var _l=`LruGarbageCollector`,vl=1048576;function yl([e,t],[n,r]){let i=I(e,n);return i===0?I(t,r):i}var bl=class{constructor(e){this.rr=e,this.buffer=new Ri(yl),this.ir=0}sr(){return++this.ir}_r(e){let t=[e,this.sr()];if(this.buffer.size<this.rr)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();yl(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}},xl=class{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.ar=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.ur(6e4)}stop(){this.ar&&=(this.ar.cancel(),null)}get started(){return this.ar!==null}ur(e){A(_l,`Garbage collection scheduled in ${e}ms`),this.ar=this.asyncQueue.enqueueAfterDelay(`lru_garbage_collection`,e,(async()=>{this.ar=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){Ti(e)?A(_l,`Ignoring IndexedDB error during garbage collection: `,e):await Ci(e)}await this.ur(3e5)}))}},Sl=class{constructor(e,t){this.cr=e,this.params=t}calculateTargetCount(e,t){return this.cr.lr(e).next((e=>Math.floor(t/100*e)))}nthSequenceNumber(e,t){if(t===0)return B.resolve(Ei.ce);let n=new bl(t);return this.cr.forEachTarget(e,(e=>n._r(e.sequenceNumber))).next((()=>this.cr.Er(e,(e=>n._r(e))))).next((()=>n.maxValue))}removeTargets(e,t,n){return this.cr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.cr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(A(`LruGarbageCollector`,`Garbage collection skipped; disabled`),B.resolve(ml)):this.getCacheSize(e).next((n=>n<this.params.cacheSizeCollectionThreshold?(A(`LruGarbageCollector`,`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),ml):this.hr(e,t)))}getCacheSize(e){return this.cr.getCacheSize(e)}hr(e,t){let n,r,i,a,o,s,c,l=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((t=>(t>this.params.maximumSequenceNumbersToCollect?(A(`LruGarbageCollector`,`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),r=this.params.maximumSequenceNumbersToCollect):r=t,a=Date.now(),this.nthSequenceNumber(e,r)))).next((r=>(n=r,o=Date.now(),this.removeTargets(e,n,t)))).next((t=>(i=t,s=Date.now(),this.removeOrphanedDocuments(e,n)))).next((e=>(c=Date.now(),jr()<=v.DEBUG&&A(`LruGarbageCollector`,`LRU Garbage Collection\n\tCounted targets in ${a-l}ms\n\tDetermined least recently used ${r} in `+(o-a)+`ms
10
27
  \tRemoved ${i} targets in `+(s-o)+`ms
11
28
  \tRemoved ${e} documents in `+(c-s)+`ms
12
- Total Duration: ${c-l}ms`),L.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e}))))}};function Bs(e,t){return new zs(e,t)}var Vs=class{constructor(){this.changes=new Ea((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,Mi.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let n=this.changes.get(t);return n===void 0?this.getFromCache(e,t):L.resolve(n)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}},Hs=class{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}},Us=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&&so(n.mutation,e,Wr.empty(),F.now()),e)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.getLocalViewOfDocuments(e,t,V()).next((()=>t))))}getLocalViewOfDocuments(e,t,n=V()){let r=Ma();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,n).next((e=>{let t=Aa();return e.forEach(((e,n)=>{t=t.insert(e,n.overlayedDocument)})),t}))))}getOverlayedDocuments(e,t){let n=Ma();return this.populateOverlays(e,n,t).next((()=>this.computeViews(e,t,n,V())))}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=Oa(),a=Pa(),o=function(){return Pa()}();return t.forEach(((e,t)=>{let o=n.get(t.key);r.has(t.key)&&(o===void 0||o.mutation instanceof fo)?i=i.insert(t.key,t):o===void 0?a.set(t.key,Wr.empty()):(a.set(t.key,o.mutation.getFieldMask()),so(o.mutation,t,o.mutation.getFieldMask(),F.now()))})),this.recalculateAndSaveOverlays(e,i).next((e=>(e.forEach(((e,t)=>a.set(e,t))),t.forEach(((e,t)=>o.set(e,new Hs(t,a.get(e)??null)))),o)))}recalculateAndSaveOverlays(e,t){let n=Pa(),r=new R(((e,t)=>e-t)),i=V();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)||Wr.empty();o=i.applyToLocalView(a,o),n.set(e,o);let s=(r.get(i.batchId)||V()).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=Na();c.forEach((e=>{if(!i.has(e)){let r=ao(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 L.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 la(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):ua(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):L.resolve(Ma()),o=gr,s=i;return a.next((t=>L.forEach(t,((t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),i.get(t)?L.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,V()))).next((e=>({batchId:o,changes:ja(e)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new N(t)).next((e=>{let t=Aa();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t}))}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){let i=t.collectionGroup,a=Aa();return this.indexManager.getCollectionParents(e,i).next((o=>L.forEach(o,(o=>{let s=function(e,t){return new aa(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,Mi.newInvalidDocument(r)))}));let n=Aa();return e.forEach(((e,r)=>{let a=i.get(e);a!==void 0&&so(a.mutation,r,Wr.empty(),F.now()),Sa(t,r)&&(n=n.insert(e,r))})),n}))}},Ws=class{constructor(e){this.serializer=e,this.Nr=new Map,this.Br=new Map}getBundleMetadata(e,t){return L.resolve(this.Nr.get(t))}saveBundleMetadata(e,t){return this.Nr.set(t.id,function(e){return{id:e.id,version:e.version,createTime:Yo(e.createTime)}}(t)),L.resolve()}getNamedQuery(e,t){return L.resolve(this.Br.get(t))}saveNamedQuery(e,t){return this.Br.set(t.name,function(e){return{name:e.name,query:Es(e.bundledQuery),readTime:Yo(e.readTime)}}(t)),L.resolve()}},Gs=class{constructor(){this.overlays=new R(N.comparator),this.Lr=new Map}getOverlay(e,t){return L.resolve(this.overlays.get(t))}getOverlays(e,t){let n=Ma();return L.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.St(e,t,r)})),L.resolve()}removeOverlaysForBatchId(e,t,n){let r=this.Lr.get(n);return r!==void 0&&(r.forEach((e=>this.overlays=this.overlays.remove(e))),this.Lr.delete(n)),L.resolve()}getOverlaysForCollection(e,t,n){let r=Ma(),i=t.length+1,a=new N(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 L.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new R(((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=Ma(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let o=Ma(),s=i.getIterator();for(;s.hasNext()&&(s.getNext().value.forEach(((e,t)=>o.set(e,t))),!(o.size()>=r)););return L.resolve(o)}St(e,t,n){let r=this.overlays.get(n.key);if(r!==null){let e=this.Lr.get(r.largestBatchId).delete(n.key);this.Lr.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new bo(t,n));let i=this.Lr.get(t);i===void 0&&(i=V(),this.Lr.set(t,i)),this.Lr.set(t,i.add(n.key))}},Ks=class{constructor(){this.sessionToken=Kr.EMPTY_BYTE_STRING}getSessionToken(e){return L.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,L.resolve()}},qs=class{constructor(){this.kr=new Hr(W.qr),this.Kr=new Hr(W.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(e,t){let n=new W(e,t);this.kr=this.kr.add(n),this.Kr=this.Kr.add(n)}$r(e,t){e.forEach((e=>this.addReference(e,t)))}removeReference(e,t){this.Wr(new W(e,t))}Qr(e,t){e.forEach((e=>this.removeReference(e,t)))}Gr(e){let t=new N(new M([])),n=new W(t,e),r=new W(t,e+1),i=[];return this.Kr.forEachInRange([n,r],(e=>{this.Wr(e),i.push(e.key)})),i}zr(){this.kr.forEach((e=>this.Wr(e)))}Wr(e){this.kr=this.kr.delete(e),this.Kr=this.Kr.delete(e)}jr(e){let t=new N(new M([])),n=new W(t,e),r=new W(t,e+1),i=V();return this.Kr.forEachInRange([n,r],(e=>{i=i.add(e.key)})),i}containsKey(e){let t=new W(e,0),n=this.kr.firstAfterOrEqual(t);return n!==null&&e.isEqual(n.key)}},W=class{constructor(e,t){this.key=e,this.Jr=t}static qr(e,t){return N.comparator(e.key,t.key)||j(e.Jr,t.Jr)}static Ur(e,t){return j(e.Jr,t.Jr)||N.comparator(e.key,t.key)}},Js=class{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Yn=1,this.Hr=new Hr(W.qr)}checkEmpty(e){return L.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,n,r){let i=this.Yn;this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let a=new vo(i,t,n,r);this.mutationQueue.push(a);for(let t of r)this.Hr=this.Hr.add(new W(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return L.resolve(a)}lookupMutationBatch(e,t){return L.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){let n=t+1,r=this.Xr(n),i=r<0?0:r;return L.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return L.resolve(this.mutationQueue.length===0?Or:this.Yn-1)}getAllMutationBatches(e){return L.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let n=new W(t,0),r=new W(t,1/0),i=[];return this.Hr.forEachInRange([n,r],(e=>{let t=this.Zr(e.Jr);i.push(t)})),L.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new Hr(j);return t.forEach((e=>{let t=new W(e,0),r=new W(e,1/0);this.Hr.forEachInRange([t,r],(e=>{n=n.add(e.Jr)}))})),L.resolve(this.Yr(n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=n;N.isDocumentKey(i)||(i=i.child(``));let a=new W(new N(i),0),o=new Hr(j);return this.Hr.forEachWhile((e=>{let t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.Jr)),!0)}),a),L.resolve(this.Yr(o))}Yr(e){let t=[];return e.forEach((e=>{let n=this.Zr(e);n!==null&&t.push(n)})),t}removeMutationBatch(e,t){D(this.ei(t.batchId,`removed`)===0,55003),this.mutationQueue.shift();let n=this.Hr;return L.forEach(t.mutations,(r=>{let i=new W(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)})).next((()=>{this.Hr=n}))}nr(e){}containsKey(e,t){let n=new W(t,0),r=this.Hr.firstAfterOrEqual(n);return L.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,L.resolve()}ei(e,t){return this.Xr(e)}Xr(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Zr(e){let t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}},Ys=class{constructor(e){this.ti=e,this.docs=function(){return new R(N.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.ti(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 L.resolve(n?n.document.mutableCopy():Mi.newInvalidDocument(t))}getEntries(e,t){let n=Oa();return t.forEach((e=>{let t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():Mi.newInvalidDocument(e))})),L.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let i=Oa(),a=t.path,o=new N(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||xr(yr(o),n)<=0||(r.has(o.key)||Sa(t,o))&&(i=i.insert(o.key,o.mutableCopy()))}return L.resolve(i)}getAllFromCollectionGroup(e,t,n,r){E(9500)}ni(e,t){return L.forEach(this.docs,(e=>t(e)))}newChangeBuffer(e){return new Xs(this)}getSize(e){return L.resolve(this.size)}},Xs=class extends Vs{constructor(e){super(),this.Mr=e}applyChanges(e){let t=[];return this.changes.forEach(((n,r)=>{r.isValidDocument()?t.push(this.Mr.addEntry(e,r)):this.Mr.removeEntry(n)})),L.waitFor(t)}getFromCache(e,t){return this.Mr.getEntry(e,t)}getAllFromCache(e,t){return this.Mr.getEntries(e,t)}},Zs=class{constructor(e){this.persistence=e,this.ri=new Ea((e=>na(e)),ra),this.lastRemoteSnapshotVersion=I.min(),this.highestTargetId=0,this.ii=0,this.si=new qs,this.targetCount=0,this.oi=Ns._r()}forEachTarget(e,t){return this.ri.forEach(((e,n)=>t(n))),L.resolve()}getLastRemoteSnapshotVersion(e){return L.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return L.resolve(this.ii)}allocateTargetId(e){return this.highestTargetId=this.oi.next(),L.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.ii&&(this.ii=t),L.resolve()}lr(e){this.ri.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.oi=new Ns(t),this.highestTargetId=t),e.sequenceNumber>this.ii&&(this.ii=e.sequenceNumber)}addTargetData(e,t){return this.lr(t),this.targetCount+=1,L.resolve()}updateTargetData(e,t){return this.lr(t),L.resolve()}removeTargetData(e,t){return this.ri.delete(t.target),this.si.Gr(t.targetId),--this.targetCount,L.resolve()}removeTargets(e,t,n){let r=0,i=[];return this.ri.forEach(((a,o)=>{o.sequenceNumber<=t&&n.get(o.targetId)===null&&(this.ri.delete(a),i.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)})),L.waitFor(i).next((()=>r))}getTargetCount(e){return L.resolve(this.targetCount)}getTargetData(e,t){let n=this.ri.get(t)||null;return L.resolve(n)}addMatchingKeys(e,t,n){return this.si.$r(t,n),L.resolve()}removeMatchingKeys(e,t,n){this.si.Qr(t,n);let r=this.persistence.referenceDelegate,i=[];return r&&t.forEach((t=>{i.push(r.markPotentiallyOrphaned(e,t))})),L.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.si.Gr(t),L.resolve()}getMatchingKeysForTargetId(e,t){let n=this.si.jr(t);return L.resolve(n)}containsKey(e,t){return L.resolve(this.si.containsKey(t))}},Qs=class{constructor(e,t){this._i={},this.overlays={},this.ai=new Dr(0),this.ui=!1,this.ui=!0,this.ci=new Ks,this.referenceDelegate=e(this),this.li=new Zs(this),this.indexManager=new Os,this.remoteDocumentCache=function(e){return new Ys(e)}((e=>this.referenceDelegate.hi(e))),this.serializer=new Ts(t),this.Pi=new Ws(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new Gs,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this._i[e.toKey()];return n||(n=new Js(t,this.referenceDelegate),this._i[e.toKey()]=n),n}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(e,t,n){T(`MemoryPersistence`,`Starting transaction:`,e);let r=new $s(this.ai.next());return this.referenceDelegate.Ti(),n(r).next((e=>this.referenceDelegate.Ei(r).next((()=>e)))).toPromise().then((e=>(r.raiseOnCommittedEvent(),e)))}Ii(e,t){return L.or(Object.values(this._i).map((n=>()=>n.containsKey(e,t))))}},$s=class extends Cr{constructor(e){super(),this.currentSequenceNumber=e}},ec=class e{constructor(e){this.persistence=e,this.Ri=new qs,this.Ai=null}static Vi(t){return new e(t)}get di(){if(this.Ai)return this.Ai;throw E(60996)}addReference(e,t,n){return this.Ri.addReference(n,t),this.di.delete(n.toString()),L.resolve()}removeReference(e,t,n){return this.Ri.removeReference(n,t),this.di.add(n.toString()),L.resolve()}markPotentiallyOrphaned(e,t){return this.di.add(t.toString()),L.resolve()}removeTarget(e,t){this.Ri.Gr(t.targetId).forEach((e=>this.di.add(e.toString())));let n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next((e=>{e.forEach((e=>this.di.add(e.toString())))})).next((()=>n.removeTargetData(e,t)))}Ti(){this.Ai=new Set}Ei(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return L.forEach(this.di,(n=>{let r=N.fromPath(n);return this.mi(e,r).next((e=>{e||t.removeEntry(r,I.min())}))})).next((()=>(this.Ai=null,t.apply(e))))}updateLimboDocument(e,t){return this.mi(e,t).next((e=>{e?this.di.delete(t.toString()):this.di.add(t.toString())}))}hi(e){return 0}mi(e,t){return L.or([()=>L.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ii(e,t)])}},tc=class e{constructor(e,t){this.persistence=e,this.fi=new Ea((e=>Nr(e.path)),((e,t)=>e.isEqual(t))),this.garbageCollector=Bs(this,t)}static Vi(t,n){return new e(t,n)}Ti(){}Ei(e){return L.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}dr(e){let t=this.pr(e);return this.persistence.getTargetCache().getTargetCount(e).next((e=>t.next((t=>e+t))))}pr(e){let t=0;return this.mr(e,(e=>{t++})).next((()=>t))}mr(e,t){return L.forEach(this.fi,((n,r)=>this.wr(e,n,r).next((e=>e?L.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.ni(e,(r=>this.wr(e,r,t).next((e=>{e||(n++,i.removeEntry(r,I.min()))})))).next((()=>i.apply(e))).next((()=>n))}markPotentiallyOrphaned(e,t){return this.fi.set(t,e.currentSequenceNumber),L.resolve()}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.fi.set(n,e.currentSequenceNumber),L.resolve()}removeReference(e,t,n){return this.fi.set(n,e.currentSequenceNumber),L.resolve()}updateLimboDocument(e,t){return this.fi.set(t,e.currentSequenceNumber),L.resolve()}hi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=bi(e.data.value)),t}wr(e,t,n){return L.or([()=>this.persistence.Ii(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.fi.get(t);return L.resolve(e!==void 0&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}},nc=class e{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.Ts=n,this.Es=r}static Is(t,n){let r=V(),i=V();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)}},rc=class{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}},ic=class{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=function(){return v()?8:Tr(_())>0?6:4}()}initialize(e,t){this.fs=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,n,r){let i={result:null};return this.gs(e,t).next((e=>{i.result=e})).next((()=>{if(!i.result)return this.ps(e,t,r,n).next((e=>{i.result=e}))})).next((()=>{if(i.result)return;let n=new rc;return this.ys(e,t,n).next((r=>{if(i.result=r,this.As)return this.ws(e,t,n,r.size)}))})).next((()=>i.result))}ws(e,t,n,r){return n.documentReadCount<this.Vs?(Pn()<=b.DEBUG&&T(`QueryEngine`,`SDK will not create cache indexes for query:`,xa(t),`since it only creates cache indexes for collection contains`,`more than or equal to`,this.Vs,`documents`),L.resolve()):(Pn()<=b.DEBUG&&T(`QueryEngine`,`Query:`,xa(t),`scans`,n.documentReadCount,`local documents and returns`,r,`documents as results.`),n.documentReadCount>this.ds*r?(Pn()<=b.DEBUG&&T(`QueryEngine`,`The SDK decides to create cache indexes for query:`,xa(t),`as using cache indexes may help improve performance.`),this.indexManager.createTargetIndexes(e,fa(t))):L.resolve())}gs(e,t){if(ca(t))return L.resolve(null);let n=fa(t);return this.indexManager.getIndexType(e,n).next((r=>r===0?null:(t.limit!==null&&r===1&&(t=_a(t,null,`F`),n=fa(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next((r=>{let i=V(...r);return this.fs.getDocuments(e,i).next((r=>this.indexManager.getMinOffset(e,n).next((n=>{let a=this.Ss(t,r);return this.bs(t,a,i,n.readTime)?this.gs(e,_a(t,null,`F`)):this.Ds(e,a,t,n)}))))})))))}ps(e,t,n,r){return ca(t)||r.isEqual(I.min())?L.resolve(null):this.fs.getDocuments(e,n).next((i=>{let a=this.Ss(t,i);return this.bs(t,a,n,r)?L.resolve(null):(Pn()<=b.DEBUG&&T(`QueryEngine`,`Re-using previous result from %s to execute query: %s`,r.toString(),xa(t)),this.Ds(e,a,t,vr(r,gr)).next((e=>e)))}))}Ss(e,t){let n=new Hr(wa(e));return t.forEach(((t,r)=>{Sa(e,r)&&(n=n.add(r))})),n}bs(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)}ys(e,t,n){return Pn()<=b.DEBUG&&T(`QueryEngine`,`Using full collection scan to execute query:`,xa(t)),this.fs.getDocumentsMatchingQuery(e,t,br.min(),n)}Ds(e,t,n,r){return this.fs.getDocumentsMatchingQuery(e,n,r).next((e=>(t.forEach((t=>{e=e.insert(t.key,t)})),e)))}},ac=`LocalStore`,oc=3e8,sc=class{constructor(e,t,n,r){this.persistence=e,this.Cs=t,this.serializer=r,this.vs=new R(j),this.Fs=new Ea((e=>na(e)),ra),this.Ms=new Map,this.xs=e.getRemoteDocumentCache(),this.li=e.getTargetCache(),this.Pi=e.getBundleCache(),this.Os(n)}Os(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Us(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction(`Collect garbage`,`readwrite-primary`,(t=>e.collect(t,this.vs)))}};function cc(e,t,n,r){return new sc(e,t,n,r)}async function lc(e,t){let n=O(e);return await n.persistence.runTransaction(`Handle user change`,`readonly`,(e=>{let r;return n.mutationQueue.getAllMutationBatches(e).next((i=>(r=i,n.Os(t),n.mutationQueue.getAllMutationBatches(e)))).next((t=>{let i=[],a=[],o=V();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=>({Ns:e,removedBatchIds:i,addedBatchIds:a})))}))}))}function uc(e,t){let n=O(e);return n.persistence.runTransaction(`Acknowledge batch`,`readwrite-primary`,(e=>{let r=t.batch.keys(),i=n.xs.newChangeBuffer({trackRemovals:!0});return function(e,t,n,r){let i=n.batch,a=i.keys(),o=L.resolve();return a.forEach((e=>{o=o.next((()=>r.getEntry(t,e))).next((t=>{let a=n.docVersions.get(e);D(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=V();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 dc(e){let t=O(e);return t.persistence.runTransaction(`Get last remote snapshot version`,`readonly`,(e=>t.li.getLastRemoteSnapshotVersion(e)))}function fc(e,t){let n=O(e),r=t.snapshotVersion,i=n.vs;return n.persistence.runTransaction(`Apply remote event`,`readwrite-primary`,(e=>{let a=n.xs.newChangeBuffer({trackRemovals:!0});i=n.vs;let o=[];t.targetChanges.forEach(((a,s)=>{let c=i.get(s);if(!c)return;o.push(n.li.removeMatchingKeys(e,a.removedDocuments,s).next((()=>n.li.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(Kr.EMPTY_BYTE_STRING,I.min()).withLastLimboFreeSnapshotVersion(I.min()),i=i.insert(s,l),function(e,t,n){return e.resumeToken.approximateByteSize()===0||t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=oc?!0:n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(c,l,a)&&o.push(n.li.updateTargetData(e,l))}));let s=Oa(),c=V();if(t.documentUpdates.forEach((r=>{t.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))})),o.push(pc(e,a,t.documentUpdates).next((e=>{s=e.Bs,c=e.Ls}))),!r.isEqual(I.min())){let t=n.li.getLastRemoteSnapshotVersion(e).next((t=>n.li.setTargetsMetadata(e,e.currentSequenceNumber,r)));o.push(t)}return L.waitFor(o).next((()=>a.apply(e))).next((()=>n.localDocuments.getLocalViewOfDocuments(e,s,c))).next((()=>s))})).then((e=>(n.vs=i,e)))}function pc(e,t,n){let r=V(),i=V();return n.forEach((e=>r=r.add(e))),t.getEntries(e,r).next((e=>{let r=Oa();return n.forEach(((n,a)=>{let o=e.get(n);a.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),a.isNoDocument()&&a.version.isEqual(I.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)):T(ac,`Ignoring outdated watch update for `,n,`. Current version:`,o.version,` Watch version:`,a.version)})),{Bs:r,Ls:i}}))}function mc(e,t){let n=O(e);return n.persistence.runTransaction(`Get next mutation batch`,`readonly`,(e=>(t===void 0&&(t=Or),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t))))}function hc(e,t){let n=O(e);return n.persistence.runTransaction(`Allocate target`,`readwrite`,(e=>{let r;return n.li.getTargetData(e,t).next((i=>i?(r=i,L.resolve(r)):n.li.allocateTargetId(e).next((i=>(r=new ws(t,i,`TargetPurposeListen`,e.currentSequenceNumber),n.li.addTargetData(e,r).next((()=>r)))))))})).then((e=>{let r=n.vs.get(e.targetId);return(r===null||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.vs=n.vs.insert(e.targetId,e),n.Fs.set(t,e.targetId)),e}))}async function gc(e,t,n){let r=O(e),i=r.vs.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(!Er(e))throw e;T(ac,`Failed to update sequence numbers for target ${t}: ${e}`)}r.vs=r.vs.remove(t),r.Fs.delete(i.target)}function _c(e,t,n){let r=O(e),i=I.min(),a=V();return r.persistence.runTransaction(`Execute query`,`readwrite`,(e=>function(e,t,n){let r=O(e),i=r.Fs.get(n);return i===void 0?r.li.getTargetData(t,n):L.resolve(r.vs.get(i))}(r,e,fa(t)).next((t=>{if(t)return i=t.lastLimboFreeSnapshotVersion,r.li.getMatchingKeysForTargetId(e,t.targetId).next((e=>{a=e}))})).next((()=>r.Cs.getDocumentsMatchingQuery(e,t,n?i:I.min(),n?a:V()))).next((e=>(vc(r,Ca(t),e),{documents:e,ks:a})))))}function vc(e,t,n){let r=e.Ms.get(t)||I.min();n.forEach(((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)})),e.Ms.set(t,r)}var yc=class{constructor(){this.activeTargetIds=Ra()}Qs(e){this.activeTargetIds=this.activeTargetIds.add(e)}Gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){let e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}},bc=class{constructor(){this.vo=new yc,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.vo.Qs(e),this.Fo[e]||`not-current`}updateQueryState(e,t,n){this.Fo[e]=t}removeLocalQueryTarget(e){this.vo.Gs(e)}isLocalQueryTarget(e){return this.vo.activeTargetIds.has(e)}clearQueryState(e){delete this.Fo[e]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(e){return this.vo.activeTargetIds.has(e)}start(){return this.vo=new yc,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}},xc=class{Mo(e){}shutdown(){}},Sc=`ConnectivityMonitor`,Cc=class{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(e){this.Lo.push(e)}shutdown(){window.removeEventListener(`online`,this.xo),window.removeEventListener(`offline`,this.No)}ko(){window.addEventListener(`online`,this.xo),window.addEventListener(`offline`,this.No)}Oo(){T(Sc,`Network connectivity changed: AVAILABLE`);for(let e of this.Lo)e(0)}Bo(){T(Sc,`Network connectivity changed: UNAVAILABLE`);for(let e of this.Lo)e(1)}static v(){return typeof window<`u`&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}},wc=null;function Tc(){return wc===null?wc=function(){return 268435456+Math.round(2147483648*Math.random())}():wc++,`0x`+wc.toString(16)}var Ec=`RestConnection`,Dc={BatchGetDocuments:`batchGet`,Commit:`commit`,RunQuery:`runQuery`,RunAggregationQuery:`runAggregationQuery`,ExecutePipeline:`executePipeline`},Oc=class{get qo(){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.Ko=t+`://`+e.host,this.Uo=`projects/${n}/databases/${r}`,this.$o=this.databaseId.database===ii?`project_id=${n}`:`project_id=${n}&database_id=${r}`}Wo(e,t,n,r,i){let a=Tc(),o=this.Qo(e,t.toUriEncodedString());T(Ec,`Sending RPC '${e}' ${a}:`,o,n);let s={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(s,r,i);let{host:c}=new URL(o),l=Ee(c);return this.zo(e,o,s,n,l).then((t=>(T(Ec,`Received RPC '${e}' ${a}: `,t),t)),(t=>{throw In(Ec,`RPC '${e}' ${a} failed with error: `,t,`url: `,o,`request:`,n),t}))}jo(e,t,n,r,i,a){return this.Wo(e,t,n,r,i)}Go(e,t,n){e[`X-Goog-Api-Client`]=function(){return`gl-js/ fire/`+Mn}(),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))}Qo(e,t){let n=Dc[e],r=`${this.Ko}/v1/${t}:${n}`;return this.databaseInfo.apiKey&&(r=`${r}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),r}terminate(){}},kc=class{constructor(e){this.Jo=e.Jo,this.Ho=e.Ho}Zo(e){this.Xo=e}Yo(e){this.e_=e}t_(e){this.n_=e}onMessage(e){this.r_=e}close(){this.Ho()}send(e){this.Jo(e)}i_(){this.Xo()}s_(){this.e_()}o_(e){this.n_(e)}__(e){this.r_(e)}},Ac=`WebChannelConnection`,jc=(e,t,n)=>{e.listen(t,(e=>{try{n(e)}catch(e){setTimeout((()=>{throw e}),0)}}))},Mc=class e extends Oc{constructor(e){super(e),this.a_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static u_(){e.c_||=(jc(An(),kn.STAT_EVENT,(e=>{e.stat===On.PROXY?T(Ac,`STAT_EVENT: detected buffering proxy`):e.stat===On.NOPROXY&&T(Ac,`STAT_EVENT: detected no buffering proxy`)})),!0)}zo(e,t,n,r,i){let a=Tc();return new Promise(((i,o)=>{let s=new wn;s.setWithCredentials(!0),s.listenOnce(En.COMPLETE,(()=>{try{switch(s.getLastErrorCode()){case Dn.NO_ERROR:let t=s.getResponseJson();T(Ac,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(t)),i(t);break;case Dn.TIMEOUT:T(Ac,`RPC '${e}' ${a} timed out`),o(new A(k.DEADLINE_EXCEEDED,`Request time out`));break;case Dn.HTTP_ERROR:let n=s.getStatus();if(T(Ac,`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 A(function(e){let t=e.toLowerCase().replace(/_/g,`-`);return Object.values(k).indexOf(t)>=0?t:k.UNKNOWN}(t.status),t.message)):o(new A(k.UNKNOWN,`Server responded with status `+s.getStatus()))}else o(new A(k.UNAVAILABLE,`Connection failed.`));break;default:E(9055,{l_:e,streamId:a,h_:s.getLastErrorCode(),P_:s.getLastError()})}}finally{T(Ac,`RPC '${e}' ${a} completed.`)}}));let c=JSON.stringify(r);T(Ac,`RPC '${e}' ${a} sending request:`,r),s.send(t,`POST`,c,n,15)}))}T_(t,n,r){let i=Tc(),a=[this.Ko,`/`,`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.Go(s.initMessageHeaders,n,r),s.encodeInitMessageHeaders=!0;let l=a.join(``);T(Ac,`Creating RPC '${t}' stream ${i}: ${l}`,s);let u=o.createWebChannel(l,s);this.E_(u);let d=!1,f=!1,p=new kc({Jo:e=>{f?T(Ac,`Not sending because RPC '${t}' stream ${i} is closed:`,e):(d||=(T(Ac,`Opening RPC '${t}' stream ${i} transport.`),u.open(),!0),T(Ac,`RPC '${t}' stream ${i} sending:`,e),u.send(e))},Ho:()=>u.close()});return jc(u,Tn.EventType.OPEN,(()=>{f||(T(Ac,`RPC '${t}' stream ${i} transport opened.`),p.i_())})),jc(u,Tn.EventType.CLOSE,(()=>{f||(f=!0,T(Ac,`RPC '${t}' stream ${i} transport closed`),p.o_(),this.I_(u))})),jc(u,Tn.EventType.ERROR,(e=>{f||(f=!0,In(Ac,`RPC '${t}' stream ${i} transport errored. Name:`,e.name,`Message:`,e.message),p.o_(new A(k.UNAVAILABLE,`The operation could not be completed`)))})),jc(u,Tn.EventType.MESSAGE,(e=>{if(!f){let n=e.data[0];D(!!n,16349);let r=n,a=r?.error||r[0]?.error;if(a){T(Ac,`RPC '${t}' stream ${i} received error:`,a);let e=a.status,n=function(e){let t=H[e];if(t!==void 0)return wo(t)}(e),r=a.message;e===`NOT_FOUND`&&r.includes(`database`)&&r.includes(`does not exist`)&&r.includes(this.databaseId.database)&&In(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),n===void 0&&(n=k.INTERNAL,r=`Unknown error status: `+e+` with message `+a.message),f=!0,p.o_(new A(n,r)),u.close()}else T(Ac,`RPC '${t}' stream ${i} received:`,n),p.__(n)}})),e.u_(),setTimeout((()=>{p.s_()}),0),p}terminate(){this.a_.forEach((e=>e.close())),this.a_=[]}E_(e){this.a_.push(e)}I_(e){this.a_=this.a_.filter((t=>t===e))}Go(e,t,n){super.Go(e,t,n),this.databaseInfo.apiKey&&(e[`x-goog-api-key`]=this.databaseInfo.apiKey)}createWebChannelTransport(){return jn()}};function Nc(e){return new Mc(e)}function Pc(){return typeof document<`u`?document:null}function Fc(e){return new Wo(e,!0)}Mc.c_=!1;var Ic=class{constructor(e,t,n=1e3,r=1.5,i=6e4){this.Ci=e,this.timerId=t,this.R_=n,this.A_=r,this.V_=i,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(e){this.cancel();let t=Math.floor(this.d_+this.y_()),n=Math.max(0,Date.now()-this.f_),r=Math.max(0,t-n);r>0&&T(`ExponentialBackoff`,`Backing off for ${r} ms (base delay: ${this.d_} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,r,(()=>(this.f_=Date.now(),e()))),this.d_*=this.A_,this.d_<this.R_&&(this.d_=this.R_),this.d_>this.V_&&(this.d_=this.V_)}w_(){this.m_!==null&&(this.m_.skipDelay(),this.m_=null)}cancel(){this.m_!==null&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.d_}},Lc=`PersistentStream`,Rc=class{constructor(e,t,n,r,i,a,o,s){this.Ci=e,this.S_=n,this.b_=r,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=o,this.listener=s,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new Ic(e,t)}x_(){return this.state===1||this.state===5||this.O_()}O_(){return this.state===2||this.state===3}start(){this.F_=0,this.state===4?this.N_():this.auth()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&this.C_===null&&(this.C_=this.Ci.enqueueAfterDelay(this.S_,6e4,(()=>this.k_())))}q_(e){this.K_(),this.stream.send(e)}async k_(){if(this.O_())return this.close(0)}K_(){this.C_&&=(this.C_.cancel(),null)}U_(){this.v_&&=(this.v_.cancel(),null)}async close(e,t){this.K_(),this.U_(),this.M_.cancel(),this.D_++,e===4?t&&t.code===k.RESOURCE_EXHAUSTED?(Fn(t.toString()),Fn(`Using maximum backoff delay to prevent overloading the backend.`),this.M_.g_()):t&&t.code===k.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()):this.M_.reset(),this.stream!==null&&(this.W_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.t_(t)}W_(){}auth(){this.state=1;let e=this.Q_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([e,n])=>{this.D_===t&&this.G_(e,n)}),(t=>{e((()=>{let e=new A(k.UNKNOWN,`Fetching auth token failed: `+t.message);return this.z_(e)}))}))}G_(e,t){let n=this.Q_(this.D_);this.stream=this.j_(e,t),this.stream.Zo((()=>{n((()=>this.listener.Zo()))})),this.stream.Yo((()=>{n((()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.b_,1e4,(()=>(this.O_()&&(this.state=3),Promise.resolve()))),this.listener.Yo())))})),this.stream.t_((e=>{n((()=>this.z_(e)))})),this.stream.onMessage((e=>{n((()=>++this.F_==1?this.J_(e):this.onNext(e)))}))}N_(){this.state=5,this.M_.p_((async()=>{this.state=0,this.start()}))}z_(e){return T(Lc,`close with error: ${e}`),this.stream=null,this.close(4,e)}Q_(e){return t=>{this.Ci.enqueueAndForget((()=>this.D_===e?t():(T(Lc,`stream callback skipped by getCloseGuardedDispatcher.`),Promise.resolve())))}}},zc=class extends Rc{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}j_(e,t){return this.connection.T_(`Listen`,e,t)}J_(e){return this.onNext(e)}onNext(e){this.M_.reset();let t=os(this.serializer,e),n=function(e){if(!(`targetChange`in e))return I.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?I.min():t.readTime?Yo(t.readTime):I.min()}(e);return this.listener.H_(t,n)}Z_(e){let t={};t.database=rs(this.serializer),t.addTarget=function(e,t){let n,r=t.target;if(n=ia(r)?{documents:ls(e,r)}:{query:us(e,r).ft},n.targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=qo(e,t.resumeToken);let r=Go(e,t.expectedCount);r!==null&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(I.min())>0){n.readTime=Ko(e,t.snapshotVersion.toTimestamp());let r=Go(e,t.expectedCount);r!==null&&(n.expectedCount=r)}return n}(this.serializer,e);let n=ps(this.serializer,e);n&&(t.labels=n),this.q_(t)}X_(e){let t={};t.database=rs(this.serializer),t.removeTarget=e,this.q_(t)}},Bc=class extends Rc{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 Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(e,t){return this.connection.T_(`Write`,e,t)}J_(e){return D(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,D(!e.writeResults||e.writeResults.length===0,55816),this.listener.ta()}onNext(e){D(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();let t=cs(e.writeResults,e.commitTime),n=Yo(e.commitTime);return this.listener.na(n,t)}ra(){let e={};e.database=rs(this.serializer),this.q_(e)}ea(e){let t={streamToken:this.lastStreamToken,writes:e.map((e=>ss(this.serializer,e)))};this.q_(t)}},Vc=class{},Hc=class extends Vc{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=r,this.ia=!1}sa(){if(this.ia)throw new A(k.FAILED_PRECONDITION,`The client has already been terminated.`)}Wo(e,t,n,r){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,a])=>this.connection.Wo(e,Zo(t,n),r,i,a))).catch((e=>{throw e.name===`FirebaseError`?(e.code===k.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new A(k.UNKNOWN,e.toString())}))}jo(e,t,n,r,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,o])=>this.connection.jo(e,Zo(t,n),r,a,o,i))).catch((e=>{throw e.name===`FirebaseError`?(e.code===k.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new A(k.UNKNOWN,e.toString())}))}terminate(){this.ia=!0,this.connection.terminate()}};function Uc(e,t,n,r){return new Hc(e,t,n,r)}var Wc=class{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state=`Unknown`,this.oa=0,this._a=null,this.aa=!0}ua(){this.oa===0&&(this.ca(`Unknown`),this._a=this.asyncQueue.enqueueAfterDelay(`online_state_timeout`,1e4,(()=>(this._a=null,this.la(`Backend didn't respond within 10 seconds.`),this.ca(`Offline`),Promise.resolve()))))}ha(e){this.state===`Online`?this.ca(`Unknown`):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca(`Offline`)))}set(e){this.Pa(),this.oa=0,e===`Online`&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){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.aa?(Fn(t),this.aa=!1):T(`OnlineStateTracker`,t)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}},Gc=`RemoteStore`,Kc=class{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Ta=[],this.Ea=new Map,this.Ia=new Set,this.Ra=[],this.Aa=i,this.Aa.Mo((e=>{n.enqueueAndForget((async()=>{tl(this)&&(T(Gc,`Restarting streams for network reachability change.`),await async function(e){let t=O(e);t.Ia.add(4),await Jc(t),t.Va.set(`Unknown`),t.Ia.delete(4),await qc(t)}(this))}))})),this.Va=new Wc(n,r)}};async function qc(e){if(tl(e))for(let t of e.Ra)await t(!0)}async function Jc(e){for(let t of e.Ra)await t(!1)}function Yc(e,t){let n=O(e);n.Ea.has(t.targetId)||(n.Ea.set(t.targetId,t),el(n)?$c(n):bl(n).O_()&&Zc(n,t))}function Xc(e,t){let n=O(e),r=bl(n);n.Ea.delete(t),r.O_()&&Qc(n,t),n.Ea.size===0&&(r.O_()?r.L_():tl(n)&&n.Va.set(`Unknown`))}function Zc(e,t){if(e.da.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(I.min())>0){let n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}bl(e).Z_(t)}function Qc(e,t){e.da.$e(t),bl(e).X_(t)}function $c(e){e.da=new Ro({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),At:t=>e.Ea.get(t)||null,ht:()=>e.datastore.serializer.databaseId}),bl(e).start(),e.Va.ua()}function el(e){return tl(e)&&!bl(e).x_()&&e.Ea.size>0}function tl(e){return O(e).Ia.size===0}function nl(e){e.da=void 0}async function rl(e){e.Va.set(`Online`)}async function il(e){e.Ea.forEach(((t,n)=>{Zc(e,t)}))}async function al(e,t){nl(e),el(e)?(e.Va.ha(t),$c(e)):e.Va.set(`Unknown`)}async function ol(e,t,n){if(e.Va.set(`Online`),t instanceof Io&&t.state===2&&t.cause)try{await async function(e,t){let n=t.cause;for(let r of t.targetIds)e.Ea.has(r)&&(await e.remoteSyncer.rejectListen(r,n),e.Ea.delete(r),e.da.removeTarget(r))}(e,t)}catch(n){T(Gc,`Failed to remove targets %s: %s `,t.targetIds.join(`,`),n),await sl(e,n)}else if(t instanceof Po?e.da.Xe(t):t instanceof Fo?e.da.st(t):e.da.tt(t),!n.isEqual(I.min()))try{let t=await dc(e.localStore);n.compareTo(t)>=0&&await function(e,t){let n=e.da.Tt(t);return n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){let i=e.Ea.get(r);i&&e.Ea.set(r,i.withResumeToken(n.resumeToken,t))}})),n.targetMismatches.forEach(((t,n)=>{let r=e.Ea.get(t);r&&(e.Ea.set(t,r.withResumeToken(Kr.EMPTY_BYTE_STRING,r.snapshotVersion)),Qc(e,t),Zc(e,new ws(r.target,t,n,r.sequenceNumber)))})),e.remoteSyncer.applyRemoteEvent(n)}(e,n)}catch(t){T(Gc,`Failed to raise snapshot:`,t),await sl(e,t)}}async function sl(e,t,n){if(!Er(t))throw t;e.Ia.add(1),await Jc(e),e.Va.set(`Offline`),n||=()=>dc(e.localStore),e.asyncQueue.enqueueRetryable((async()=>{T(Gc,`Retrying IndexedDB access`),await n(),e.Ia.delete(1),await qc(e)}))}function cl(e,t){return t().catch((n=>sl(e,n,t)))}async function ll(e){let t=O(e),n=xl(t),r=t.Ta.length>0?t.Ta[t.Ta.length-1].batchId:Or;for(;ul(t);)try{let e=await mc(t.localStore,r);if(e===null){t.Ta.length===0&&n.L_();break}r=e.batchId,dl(t,e)}catch(e){await sl(t,e)}fl(t)&&pl(t)}function ul(e){return tl(e)&&e.Ta.length<10}function dl(e,t){e.Ta.push(t);let n=xl(e);n.O_()&&n.Y_&&n.ea(t.mutations)}function fl(e){return tl(e)&&!xl(e).x_()&&e.Ta.length>0}function pl(e){xl(e).start()}async function ml(e){xl(e).ra()}async function hl(e){let t=xl(e);for(let n of e.Ta)t.ea(n.mutations)}async function gl(e,t,n){let r=e.Ta.shift(),i=yo.from(r,t,n);await cl(e,(()=>e.remoteSyncer.applySuccessfulWrite(i))),await ll(e)}async function _l(e,t){t&&xl(e).Y_&&await async function(e,t){if(function(e){return Co(e)&&e!==k.ABORTED}(t.code)){let n=e.Ta.shift();xl(e).B_(),await cl(e,(()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t))),await ll(e)}}(e,t),fl(e)&&pl(e)}async function vl(e,t){let n=O(e);n.asyncQueue.verifyOperationInProgress(),T(Gc,`RemoteStore received new credentials`);let r=tl(n);n.Ia.add(3),await Jc(n),r&&n.Va.set(`Unknown`),await n.remoteSyncer.handleCredentialChange(t),n.Ia.delete(3),await qc(n)}async function yl(e,t){let n=O(e);t?(n.Ia.delete(2),await qc(n)):t||(n.Ia.add(2),await Jc(n),n.Va.set(`Unknown`))}function bl(e){return e.ma||(e.ma=function(e,t,n){let r=O(e);return r.sa(),new zc(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Zo:rl.bind(null,e),Yo:il.bind(null,e),t_:al.bind(null,e),H_:ol.bind(null,e)}),e.Ra.push((async t=>{t?(e.ma.B_(),el(e)?$c(e):e.Va.set(`Unknown`)):(await e.ma.stop(),nl(e))}))),e.ma}function xl(e){return e.fa||(e.fa=function(e,t,n){let r=O(e);return r.sa(),new Bc(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Zo:()=>Promise.resolve(),Yo:ml.bind(null,e),t_:_l.bind(null,e),ta:hl.bind(null,e),na:gl.bind(null,e)}),e.Ra.push((async t=>{t?(e.fa.B_(),await ll(e)):(await e.fa.stop(),e.Ta.length>0&&(T(Gc,`Stopping write stream with ${e.Ta.length} pending writes`),e.Ta=[]))}))),e.fa}var Sl=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 zn,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 A(k.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 Cl(e,t){if(Fn(`AsyncQueue`,`${t}: ${e}`),Er(e))return new A(k.UNAVAILABLE,`${t}: ${e}`);throw e}var wl=class e{static emptySet(t){return new e(t.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||N.comparator(t.key,n.key):(e,t)=>N.comparator(e.key,t.key),this.keyedMap=Aa(),this.sortedSet=new R(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 (
29
+ Total Duration: ${c-l}ms`),B.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e}))))}};function Cl(e,t){return new Sl(e,t)}var wl=`firestore.googleapis.com`,Tl=!0,El=class{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new F(P.INVALID_ARGUMENT,`Can't provide ssl option if host option is not set`);this.host=wl,this.ssl=Tl}else this.host=e.host,this.ssl=e.ssl??Tl;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=hl;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<vl)throw new F(P.INVALID_ARGUMENT,`cacheSizeBytes must be at least 1048576`);this.cacheSizeBytes=e.cacheSizeBytes}ri(`experimentalForceLongPolling`,e.experimentalForceLongPolling,`experimentalAutoDetectLongPolling`,e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=Uc(e.experimentalLongPollingOptions??{}),function(e){if(e.timeoutSeconds!==void 0){if(isNaN(e.timeoutSeconds))throw new F(P.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new F(P.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new F(P.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(e,t){return e.timeoutSeconds===t.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}},Dl=class{constructor(e,t,n,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=r,this.type=`firestore-lite`,this._persistenceKey=`(lite)`,this._settings=new El({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask=`notTerminated`}get app(){if(!this._app)throw new F(P.FAILED_PRECONDITION,`Firestore was not initialized using the Firebase SDK. 'app' is not available`);return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!==`notTerminated`}_setSettings(e){if(this._settingsFrozen)throw new F(P.FAILED_PRECONDITION,`Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.`);this._settings=new El(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=function(e){if(!e)return new Rr;switch(e.type){case`firstParty`:return new Hr(e.sessionIndex||`0`,e.iamToken||null,e.authTokenFactory||null);case`provider`:return e.client;default:throw new F(P.INVALID_ARGUMENT,`makeAuthCredentialsProvider failed due to invalid credential type`)}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask===`notTerminated`&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask===`notTerminated`?await this._terminate():this._terminateTask=`notTerminated`}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){let t=fl.get(e);t&&(A(dl,`Removing Datastore`),fl.delete(e),t.terminate())}(this),Promise.resolve()}};function Ol(e,t,n,r={}){e=ci(e,Dl);let i=Oe(t),a=e._getSettings(),o={...a,emulatorOptions:e._getEmulatorOptions()},s=`${t}:${n}`;i&&ke(`https://${s}`),a.host!==wl&&a.host!==s&&Nr(`Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.`);let c={...a,host:s,ssl:i,emulatorOptions:r};if(!ye(c,o)&&(e._setSettings(c),r.mockUserToken)){let t,n;if(typeof r.mockUserToken==`string`)t=r.mockUserToken,n=Dr.MOCK_USER;else{t=ne(r.mockUserToken,e._app?.options.projectId);let i=r.mockUserToken.sub||r.mockUserToken.user_id;if(!i)throw new F(P.INVALID_ARGUMENT,`mockUserToken must contain 'sub' or 'user_id' field!`);n=new Dr(i)}e._authCredentials=new zr(new Lr(t,n))}}var kl=class e{constructor(e,t,n){this.converter=t,this._query=n,this.type=`query`,this.firestore=e}withConverter(t){return new e(this.firestore,t,this._query)}},Al=class e{constructor(e,t,n){this.converter=t,this._key=n,this.type=`document`,this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new jl(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new e(this.firestore,t,this._key)}toJSON(){return{type:e._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(t,n,r){if(di(n,e._jsonSchema))return new e(t,r||null,new R(L.fromString(n.referencePath)))}};Al._jsonSchemaVersion=`firestore/documentReference/1.0`,Al._jsonSchema={type:ui(`string`,Al._jsonSchemaVersion),referencePath:ui(`string`)};var jl=class e extends kl{constructor(e,t,n){super(e,t,$o(n)),this._path=n,this.type=`collection`}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new Al(this.firestore,null,new R(e))}withConverter(t){return new e(this.firestore,t,this._path)}};function Ml(e,t,...n){if(e=_(e),ni(`collection`,`path`,t),e instanceof Dl){let r=L.fromString(t,...n);return ai(r),new jl(e,null,r)}{if(!(e instanceof Al||e instanceof jl))throw new F(P.INVALID_ARGUMENT,`Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore`);let r=e._path.child(L.fromString(t,...n));return ai(r),new jl(e.firestore,null,r)}}function Nl(e,t,...n){if(e=_(e),arguments.length===1&&(t=Kr.newId()),ni(`doc`,`path`,t),e instanceof Dl){let r=L.fromString(t,...n);return ii(r),new Al(e,null,new R(r))}{if(!(e instanceof Al||e instanceof jl))throw new F(P.INVALID_ARGUMENT,`Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore`);let r=e._path.child(L.fromString(t,...n));return ii(r),new Al(e.firestore,e instanceof jl?e.converter:null,new R(r))}}var Pl=class e{constructor(e){this._values=(e||[]).map((e=>e))}toArray(){return this._values.map((e=>e))}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(this._values,e._values)}toJSON(){return{type:e._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(t){if(di(t,e._jsonSchema)){if(Array.isArray(t.vectorValues)&&t.vectorValues.every((e=>typeof e==`number`)))return new e(t.vectorValues);throw new F(P.INVALID_ARGUMENT,`Expected 'vectorValues' field to be a number array`)}}};Pl._jsonSchemaVersion=`firestore/vectorValue/1.0`,Pl._jsonSchema={type:ui(`string`,Pl._jsonSchemaVersion),vectorValues:ui(`object`)};var Fl=/^__.*__$/,Il=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return this.fieldMask===null?new mo(e,this.data,t,this.fieldTransforms):new ho(e,this.data,this.fieldMask,t,this.fieldTransforms)}},Ll=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new ho(e,this.data,this.fieldMask,t,this.fieldTransforms)}};function Rl(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw j(40011,{dataSource:e})}}var zl=class e{constructor(e,t,n,r,i,a){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,i===void 0&&this.validatePath(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(t){return new e({...this.settings,...t},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){let t=this.path?.child(e),n=this.contextWith({path:t,arrayElement:!1});return n.validatePathSegment(e),n}childContextForFieldPath(e){let t=this.path?.child(e),n=this.contextWith({path:t,arrayElement:!1});return n.validatePath(),n}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return eu(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find((t=>e.isPrefixOf(t)))!==void 0||this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))!==void 0}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(e.length===0)throw this.createError(`Document fields must not be empty`);if(Rl(this.dataSource)&&Fl.test(e))throw this.createError(`Document fields cannot begin and end with "__"`)}},Bl=class{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Lc(e)}createContext(e,t,n,r=!1){return new zl({dataSource:e,methodName:t,targetDoc:n,path:ti.emptyPath(),arrayElement:!1,hasConverter:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function Vl(e){let t=e._freezeSettings(),n=Lc(e._databaseId);return new Bl(e._databaseId,!!t.ignoreUndefinedProperties,n)}function Hl(e,t,n,r,i,a={}){let o=e.createContext(a.merge||a.mergeFields?2:0,t,n,i);Xl(`Data must be an object, but it was:`,o,r);let s=Jl(r,o),c,l;if(a.merge)c=new Bi(o.fieldMask),l=o.fieldTransforms;else if(a.mergeFields){let e=[];for(let r of a.mergeFields){let i=Zl(t,r,n);if(!o.contains(i))throw new F(P.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);tu(e,i)||e.push(i)}c=new Bi(e),l=o.fieldTransforms.filter((e=>c.covers(e.field)))}else c=null,l=o.fieldTransforms;return new Il(new Ia(s),c,l)}var Ul=class e extends Vc{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(t){return t instanceof e}};function Wl(e,t,n,r){let i=e.createContext(1,t,n);Xl(`Data must be an object, but it was:`,i,r);let a=[],o=Ia.empty();return Hi(r,((e,r)=>{let s=$l(t,e,n);r=_(r);let c=i.childContextForFieldPath(s);if(r instanceof Ul)a.push(s);else{let e=ql(r,c);e!=null&&(a.push(s),o.set(s,e))}})),new Ll(o,new Bi(a),i.fieldTransforms)}function Gl(e,t,n,r,i,a){let o=e.createContext(1,t,n),s=[Zl(t,r,n)],c=[i];if(a.length%2!=0)throw new F(P.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<a.length;e+=2)s.push(Zl(t,a[e])),c.push(a[e+1]);let l=[],u=Ia.empty();for(let e=s.length-1;e>=0;--e)if(!tu(l,s[e])){let t=s[e],n=c[e];n=_(n);let r=o.childContextForFieldPath(t);if(n instanceof Ul)l.push(t);else{let e=ql(n,r);e!=null&&(l.push(t),u.set(t,e))}}return new Ll(u,new Bi(l),o.fieldTransforms)}function Kl(e,t,n,r=!1){return ql(n,e.createContext(r?4:3,t))}function ql(e,t,n){if(Yl(e=_(e)))return Xl(`Unsupported field value:`,t,e),Jl(e,t);if(e instanceof Vc)return function(e,t){if(!Rl(t.dataSource))throw t.createError(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.createError(`${e._methodName}() is not currently supported inside arrays`);let n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(e===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.arrayElement&&t.dataSource!==4)throw t.createError(`Nested arrays are not supported`);return function(e,t){let n=[],r=0;for(let i of e){let e=ql(i,t.childContextForArray(r));e??={nullValue:`NULL_VALUE`},n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t,n){if((e=_(e))===null)return{nullValue:`NULL_VALUE`};if(typeof e==`number`)return Ba(t.serializer,e,n);if(typeof e==`boolean`)return{booleanValue:e};if(typeof e==`string`)return{stringValue:e};if(e instanceof Date){let n=mi.fromDate(e);return{timestampValue:tc(t.serializer,n)}}if(e instanceof mi){let n=new mi(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:tc(t.serializer,n)}}if(e instanceof Hc)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Rc)return{bytesValue:rc(t.serializer,e._byteString)};if(e instanceof Al){let n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.createError(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:oc(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof Pl)return function(e,t){let n=e instanceof Pl?e.toArray():e;return{mapValue:{fields:{[sa]:{stringValue:ua},[da]:{arrayValue:{values:n.map((e=>{if(typeof e!=`number`)throw t.createError(`VectorValues must only contain numeric values.`);return Ra(t.serializer,e)}))}}}}}}(e,t);if(Pc(e))return e._toProto(t.serializer);throw t.createError(`Unsupported field value: ${si(e)}`)}(e,t,n)}function Jl(e,t){let n={};return Wi(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):Hi(e,((e,r)=>{let i=ql(r,t.childContextForField(e));i!=null&&(n[e]=i)})),{mapValue:{fields:n}}}function Yl(e){return!(typeof e!=`object`||!e||e instanceof Array||e instanceof Date||e instanceof mi||e instanceof Hc||e instanceof Rc||e instanceof Al||e instanceof Vc||e instanceof Pl||Pc(e))}function Xl(e,t,n){if(!Yl(n)||!oi(n)){let r=si(n);throw r===`an object`?t.createError(e+` a custom object`):t.createError(e+` `+r)}}function Zl(e,t,n){if((t=_(t))instanceof zc)return t._internalPath;if(typeof t==`string`)return $l(e,t);throw eu(`Field path arguments must be of type string or `,e,!1,void 0,n)}var Ql=RegExp(`[~\\*/\\[\\]]`);function $l(e,t,n){if(t.search(Ql)>=0)throw eu(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new zc(...t.split(`.`))._internalPath}catch{throw eu(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function eu(e,t,n,r,i){let a=r&&!r.isEmpty(),o=i!==void 0,s=`Function ${t}() called with invalid data`;n&&(s+=" (via `toFirestore()`)"),s+=`. `;let c=``;return(a||o)&&(c+=` (found`,a&&(c+=` in field ${r}`),o&&(c+=` in document ${i}`),c+=`)`),new F(P.INVALID_ARGUMENT,s+e+c)}function tu(e,t){return e.some((e=>e.isEqual(t)))}function nu(e){return typeof e._readUserData==`function`}var ru=class e{constructor(e){this.optionDefinitions=e}_getKnownOptions(t,n){let r=Ia.empty();for(let i in this.optionDefinitions)if(this.optionDefinitions.hasOwnProperty(i)){let a=this.optionDefinitions[i];if(i in t){let o=t[i],s;a.nestedOptions&&oi(o)?s={mapValue:{fields:new e(a.nestedOptions).getOptionsProto(n,o)}}:o&&(s=ql(o,n)??void 0),s&&r.set(ti.fromServerFormat(a.serverName),s)}}return r}getOptionsProto(e,t,n){let r=this._getKnownOptions(t,e);if(n){let t=new Map(Ui(n,((t,n)=>[ti.fromServerFormat(n),t===void 0?null:ql(t,e)])));r.setAll(t)}return r.value.mapValue.fields??{}}};function iu(e){return typeof e==`object`&&!!e&&!!(`nullValue`in e&&(e.nullValue===null||e.nullValue===`NULL_VALUE`)||`booleanValue`in e&&(e.booleanValue===null||typeof e.booleanValue==`boolean`)||`integerValue`in e&&(e.integerValue===null||typeof e.integerValue==`number`||typeof e.integerValue==`string`)||`doubleValue`in e&&(e.doubleValue===null||typeof e.doubleValue==`number`)||`timestampValue`in e&&(e.timestampValue===null||function(e){return typeof e==`object`&&!!e&&`seconds`in e&&(e.seconds===null||typeof e.seconds==`number`||typeof e.seconds==`string`)&&`nanos`in e&&(e.nanos===null||typeof e.nanos==`number`)}(e.timestampValue))||`stringValue`in e&&(e.stringValue===null||typeof e.stringValue==`string`)||`bytesValue`in e&&(e.bytesValue===null||e.bytesValue instanceof Uint8Array)||`referenceValue`in e&&(e.referenceValue===null||typeof e.referenceValue==`string`)||`geoPointValue`in e&&(e.geoPointValue===null||function(e){return typeof e==`object`&&!!e&&`latitude`in e&&(e.latitude===null||typeof e.latitude==`number`)&&`longitude`in e&&(e.longitude===null||typeof e.longitude==`number`)}(e.geoPointValue))||`arrayValue`in e&&(e.arrayValue===null||function(e){return typeof e==`object`&&!!e&&!(!(`values`in e)||e.values!==null&&!Array.isArray(e.values))}(e.arrayValue))||`mapValue`in e&&(e.mapValue===null||function(e){return typeof e==`object`&&!!e&&!(!(`fields`in e)||e.fields!==null&&!oi(e.fields))}(e.mapValue))||`fieldReferenceValue`in e&&(e.fieldReferenceValue===null||typeof e.fieldReferenceValue==`string`)||`functionValue`in e&&(e.functionValue===null||function(e){return typeof e==`object`&&!!e&&!(!(`name`in e)||e.name!==null&&typeof e.name!=`string`||!(`args`in e)||e.args!==null&&!Array.isArray(e.args))}(e.functionValue))||`pipelineValue`in e&&(e.pipelineValue===null||function(e){return typeof e==`object`&&!!e&&!(!(`stages`in e)||e.stages!==null&&!Array.isArray(e.stages))}(e.pipelineValue)))}function au(e){return new Pl(e)}function G(e){let t;return e instanceof cu?e:(t=oi(e)?Cu(e):e instanceof Array?wu(e):vu(e,void 0),t)}function ou(e){if(e instanceof cu)return e;if(e instanceof Pl)return _u(e);if(Array.isArray(e))return _u(au(e));throw Error(`Unsupported value: `+typeof e)}function su(e){return ji(e)?mu(e):G(e)}var cu=class{constructor(){this._protoValueType=`ProtoValue`}add(e){return new K(`add`,[this,G(e)],`add`)}asBoolean(){if(this instanceof yu)return this;if(this instanceof gu)return new xu(this);if(this instanceof pu)return new Su(this);if(this instanceof K)return new bu(this);throw new F(`invalid-argument`,`Conversion of type ${typeof this} to BooleanExpression not supported.`)}subtract(e){return new K(`subtract`,[this,G(e)],`subtract`)}multiply(e){return new K(`multiply`,[this,G(e)],`multiply`)}divide(e){return new K(`divide`,[this,G(e)],`divide`)}mod(e){return new K(`mod`,[this,G(e)],`mod`)}equal(e){return new K(`equal`,[this,G(e)],`equal`).asBoolean()}notEqual(e){return new K(`not_equal`,[this,G(e)],`notEqual`).asBoolean()}lessThan(e){return new K(`less_than`,[this,G(e)],`lessThan`).asBoolean()}lessThanOrEqual(e){return new K(`less_than_or_equal`,[this,G(e)],`lessThanOrEqual`).asBoolean()}greaterThan(e){return new K(`greater_than`,[this,G(e)],`greaterThan`).asBoolean()}greaterThanOrEqual(e){return new K(`greater_than_or_equal`,[this,G(e)],`greaterThanOrEqual`).asBoolean()}arrayConcat(e,...t){let n=[e,...t].map((e=>G(e)));return new K(`array_concat`,[this,...n],`arrayConcat`)}arrayContains(e){return new K(`array_contains`,[this,G(e)],`arrayContains`).asBoolean()}arrayContainsAll(e){let t=Array.isArray(e)?new fu(e.map(G),`arrayContainsAll`):e;return new K(`array_contains_all`,[this,t],`arrayContainsAll`).asBoolean()}arrayContainsAny(e){let t=Array.isArray(e)?new fu(e.map(G),`arrayContainsAny`):e;return new K(`array_contains_any`,[this,t],`arrayContainsAny`).asBoolean()}arrayReverse(){return new K(`array_reverse`,[this])}arrayLength(){return new K(`array_length`,[this],`arrayLength`)}equalAny(e){let t=Array.isArray(e)?new fu(e.map(G),`equalAny`):e;return new K(`equal_any`,[this,t],`equalAny`).asBoolean()}notEqualAny(e){let t=Array.isArray(e)?new fu(e.map(G),`notEqualAny`):e;return new K(`not_equal_any`,[this,t],`notEqualAny`).asBoolean()}exists(){return new K(`exists`,[this],`exists`).asBoolean()}charLength(){return new K(`char_length`,[this],`charLength`)}like(e){return new K(`like`,[this,G(e)],`like`).asBoolean()}regexContains(e){return new K(`regex_contains`,[this,G(e)],`regexContains`).asBoolean()}regexFind(e){return new K(`regex_find`,[this,G(e)],`regexFind`)}regexFindAll(e){return new K(`regex_find_all`,[this,G(e)],`regexFindAll`)}regexMatch(e){return new K(`regex_match`,[this,G(e)],`regexMatch`).asBoolean()}stringContains(e){return new K(`string_contains`,[this,G(e)],`stringContains`).asBoolean()}startsWith(e){return new K(`starts_with`,[this,G(e)],`startsWith`).asBoolean()}endsWith(e){return new K(`ends_with`,[this,G(e)],`endsWith`).asBoolean()}toLower(){return new K(`to_lower`,[this],`toLower`)}toUpper(){return new K(`to_upper`,[this],`toUpper`)}trim(e){let t=[this];return e&&t.push(G(e)),new K(`trim`,t,`trim`)}ltrim(e){let t=[this];return e&&t.push(G(e)),new K(`ltrim`,t,`ltrim`)}rtrim(e){let t=[this];return e&&t.push(G(e)),new K(`rtrim`,t,`rtrim`)}type(){return new K(`type`,[this])}isType(e){return new K(`is_type`,[this,_u(e)],`isType`).asBoolean()}stringConcat(e,...t){let n=[e,...t].map(G);return new K(`string_concat`,[this,...n],`stringConcat`)}stringIndexOf(e){return new K(`string_index_of`,[this,G(e)],`stringIndexOf`)}stringRepeat(e){return new K(`string_repeat`,[this,G(e)],`stringRepeat`)}stringReplaceAll(e,t){return new K(`string_replace_all`,[this,G(e),G(t)],`stringReplaceAll`)}stringReplaceOne(e,t){return new K(`string_replace_one`,[this,G(e),G(t)],`stringReplaceOne`)}concat(e,...t){let n=[e,...t].map(G);return new K(`concat`,[this,...n],`concat`)}reverse(){return new K(`reverse`,[this],`reverse`)}arrayFilter(e,t){return new K(`array_filter`,[this,G(e),t],`arrayFilter`)}arrayTransform(e,t){return new K(`array_transform`,[this,G(e),t],`arrayTransform`)}arrayTransformWithIndex(e,t,n){return new K(`array_transform`,[this,G(e),G(t),n],`arrayTransformWithIndex`)}arraySlice(e,t){let n=[this,G(e)];return t!==void 0&&n.push(G(t)),new K(`array_slice`,n,`arraySlice`)}arrayFirst(){return new K(`array_first`,[this],`arrayFirst`)}arrayFirstN(e){return new K(`array_first_n`,[this,G(e)],`arrayFirstN`)}arrayLast(){return new K(`array_last`,[this],`arrayLast`)}arrayLastN(e){return new K(`array_last_n`,[this,G(e)],`arrayLastN`)}arrayMaximum(){return new K(`maximum`,[this],`arrayMaximum`)}arrayMaximumN(e){return new K(`maximum_n`,[this,G(e)],`arrayMaximumN`)}arrayMinimum(){return new K(`minimum`,[this],`arrayMinimum`)}arrayMinimumN(e){return new K(`minimum_n`,[this,G(e)],`arrayMinimumN`)}arrayIndexOf(e){return new K(`array_index_of`,[this,G(e),G(`first`)],`arrayIndexOf`)}arrayLastIndexOf(e){return new K(`array_index_of`,[this,G(e),G(`last`)],`arrayLastIndexOf`)}arrayIndexOfAll(e){return new K(`array_index_of_all`,[this,G(e)],`arrayIndexOfAll`)}byteLength(){return new K(`byte_length`,[this],`byteLength`)}ceil(){return new K(`ceil`,[this])}floor(){return new K(`floor`,[this])}abs(){return new K(`abs`,[this])}exp(){return new K(`exp`,[this])}mapGet(e){return new K(`map_get`,[this,_u(e)],`mapGet`)}mapSet(e,t,...n){return new K(`map_set`,[this,G(e),G(t),...n.map(G)],`mapSet`)}mapKeys(){return new K(`map_keys`,[this],`mapKeys`)}mapValues(){return new K(`map_values`,[this],`mapValues`)}mapEntries(){return new K(`map_entries`,[this],`mapEntries`)}getField(e){return new K(`get_field`,[this,G(e)],`get_field`)}count(){return lu._create(`count`,[this],`count`)}sum(){return lu._create(`sum`,[this],`sum`)}average(){return lu._create(`average`,[this],`average`)}minimum(){return lu._create(`minimum`,[this],`minimum`)}maximum(){return lu._create(`maximum`,[this],`maximum`)}first(){return lu._create(`first`,[this],`first`)}last(){return lu._create(`last`,[this],`last`)}arrayAgg(){return lu._create(`array_agg`,[this],`arrayAgg`)}arrayAggDistinct(){return lu._create(`array_agg_distinct`,[this],`arrayAggDistinct`)}countDistinct(){return lu._create(`count_distinct`,[this],`countDistinct`)}logicalMaximum(e,...t){let n=[e,...t];return new K(`maximum`,[this,...n.map(G)],`logicalMaximum`)}logicalMinimum(e,...t){let n=[e,...t];return new K(`minimum`,[this,...n.map(G)],`minimum`)}vectorLength(){return new K(`vector_length`,[this],`vectorLength`)}cosineDistance(e){return new K(`cosine_distance`,[this,ou(e)],`cosineDistance`)}dotProduct(e){return new K(`dot_product`,[this,ou(e)],`dotProduct`)}euclideanDistance(e){return new K(`euclidean_distance`,[this,ou(e)],`euclideanDistance`)}unixMicrosToTimestamp(){return new K(`unix_micros_to_timestamp`,[this],`unixMicrosToTimestamp`)}timestampToUnixMicros(){return new K(`timestamp_to_unix_micros`,[this],`timestampToUnixMicros`)}unixMillisToTimestamp(){return new K(`unix_millis_to_timestamp`,[this],`unixMillisToTimestamp`)}timestampToUnixMillis(){return new K(`timestamp_to_unix_millis`,[this],`timestampToUnixMillis`)}unixSecondsToTimestamp(){return new K(`unix_seconds_to_timestamp`,[this],`unixSecondsToTimestamp`)}timestampToUnixSeconds(){return new K(`timestamp_to_unix_seconds`,[this],`timestampToUnixSeconds`)}timestampAdd(e,t){return new K(`timestamp_add`,[this,G(e),G(t)],`timestampAdd`)}timestampSubtract(e,t){return new K(`timestamp_subtract`,[this,G(e),G(t)],`timestampSubtract`)}timestampDiff(e,t){return new K(`timestamp_diff`,[this,su(e),G(t)],`timestampDiff`)}timestampExtract(e,t){let n=[this,G(e)];return t&&n.push(G(t)),new K(`timestamp_extract`,n,`timestampExtract`)}documentId(){return new K(`document_id`,[this],`documentId`)}parent(){return new K(`parent`,[this],`parent`)}substring(e,t){let n=G(e);return new K(`substring`,t===void 0?[this,n]:[this,n,G(t)],`substring`)}arrayGet(e){return new K(`array_get`,[this,G(e)],`arrayGet`)}isError(){return new K(`is_error`,[this],`isError`).asBoolean()}ifError(e){let t=new K(`if_error`,[this,G(e)],`ifError`);return e instanceof yu?t.asBoolean():t}isAbsent(){return new K(`is_absent`,[this],`isAbsent`).asBoolean()}mapRemove(e){return new K(`map_remove`,[this,G(e)],`mapRemove`)}mapMerge(e,...t){let n=G(e),r=t.map(G);return new K(`map_merge`,[this,n,...r],`mapMerge`)}pow(e){return new K(`pow`,[this,G(e)])}trunc(e){return e===void 0?new K(`trunc`,[this]):new K(`trunc`,[this,G(e)],`trunc`)}round(e){return e===void 0?new K(`round`,[this]):new K(`round`,[this,G(e)],`round`)}collectionId(){return new K(`collection_id`,[this])}length(){return new K(`length`,[this])}ln(){return new K(`ln`,[this])}sqrt(){return new K(`sqrt`,[this])}stringReverse(){return new K(`string_reverse`,[this])}ifAbsent(e){return new K(`if_absent`,[this,G(e)],`ifAbsent`)}ifNull(e){return new K(`if_null`,[this,G(e)],`ifNull`)}coalesce(e,...t){return new K(`coalesce`,[this,G(e),...t.map(G)],`coalesce`)}join(e){return new K(`join`,[this,G(e)],`join`)}log10(){return new K(`log10`,[this])}arraySum(){return new K(`sum`,[this])}split(e){return new K(`split`,[this,G(e)])}timestampTruncate(e,t){let n=[this,G(e)];return t&&n.push(G(t)),new K(`timestamp_trunc`,n)}ascending(){return Tu(this)}descending(){return Eu(this)}as(e){return new du(this,e,`as`)}},lu=class e{constructor(e,t){this.name=e,this.params=t,this.exprType=`AggregateFunction`,this._protoValueType=`ProtoValue`}static _create(t,n,r){let i=new e(t,n);return i._methodName=r,i}as(e){return new uu(this,e,`as`)}_toProto(e){return{functionValue:{name:this.name,args:this.params.map((t=>t._toProto(e)))}}}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach((t=>t._readUserData(e)))}},uu=class{constructor(e,t,n){this.aggregate=e,this.alias=t,this._methodName=n}_readUserData(e){this.aggregate._readUserData(e)}},du=class{constructor(e,t,n){this.expr=e,this.alias=t,this._methodName=n,this.exprType=`AliasedExpression`,this.selectable=!0}_readUserData(e){this.expr._readUserData(e)}},fu=class extends cu{constructor(e,t){super(),this.Rr=e,this._methodName=t,this.expressionType=`ListOfExpressions`}_toProto(e){return{arrayValue:{values:this.Rr.map((t=>t._toProto(e)))}}}_readUserData(e){this.Rr.forEach((t=>t._readUserData(e)))}},pu=class extends cu{constructor(e,t){super(),this.fieldPath=e,this._methodName=t,this.expressionType=`Field`,this.selectable=!0}get _fieldPath(){return this.fieldPath}get fieldName(){return this.fieldPath.canonicalString()}get alias(){return this.fieldName}get expr(){return this}geoDistance(e){return new K(`geo_distance`,[this,G(e)],`geoDistance`)}_toProto(e){return{fieldReferenceValue:this.fieldPath.canonicalString()}}_readUserData(e){}};function mu(e){return hu(e,`field`)}function hu(e,t){return new pu(typeof e==`string`?Qr===e?Bc()._internalPath:Zl(`field`,e):e._internalPath,t)}var gu=class e extends cu{constructor(e,t){super(),this.value=e,this._methodName=t,this.expressionType=`Constant`}static _fromProto(t){let n=new e(t,void 0);return n._protoValue=t,n}_toProto(e){return M(this._protoValue!==void 0,237),this._protoValue}_getValue(){return this._protoValue}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,iu(this._protoValue)||(this._protoValue=ql(this.value,e))}};function _u(e,t){return vu(e,`constant`)}function vu(e,t){let n=new gu(e,t);return typeof e==`boolean`?new xu(n):n}var K=class extends cu{constructor(e,t,n,r){super(),this.name=e,this.params=t,this.expressionType=`Function`,this._optionsProto=void 0,n!==void 0&&(this._methodName=n),r!==void 0&&(this._options=r)}get _optionsUtil(){return new ru({})}_toProto(e){let t={functionValue:{name:this.name,args:this.params.map((t=>t._toProto(e)))}};return this._optionsProto&&(t.functionValue.options=this._optionsProto),t}_readUserData(e){e=this._methodName?e.contextWith({methodName:this._methodName}):e,this.params.forEach((t=>t._readUserData(e))),this._options&&(this._optionsProto=this._optionsUtil.getOptionsProto(e,this._options))}},yu=class e extends cu{get _methodName(){return this._expr._methodName}countIf(){return lu._create(`count_if`,[this],`countIf`)}not(){return new K(`not`,[this],`not`).asBoolean()}conditional(e,t){return new K(`conditional`,[this,e,t],`conditional`)}ifError(t){let n=G(t),r=new K(`if_error`,[this,n],`ifError`);return n instanceof e?r.asBoolean():r}_toProto(e){return this._expr._toProto(e)}_readUserData(e){this._expr._readUserData(e)}},bu=class extends yu{constructor(e){super(),this._expr=e,this.expressionType=`Function`}},xu=class extends yu{constructor(e){super(),this._expr=e,this.expressionType=`Constant`}_getValue(){return this._expr._getValue()}},Su=class extends yu{constructor(e){super(),this._expr=e,this.expressionType=`Field`}};function Cu(e,t){let n=[];for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)){let r=e[t];n.push(_u(t)),n.push(G(r))}return new K(`map`,n,`map`)}function wu(e){return function(e,t){return new K(`array`,e.map((e=>G(e))),t)}(e,`array`)}function Tu(e){return new Du(su(e),`ascending`,`ascending`)}function Eu(e){return new Du(su(e),`descending`,`descending`)}var Du=class{constructor(e,t,n){this.expr=e,this.direction=t,this._methodName=n,this._protoValueType=`ProtoValue`}_toProto(e){return{mapValue:{fields:{direction:Ic(this.direction),expression:this.expr._toProto(e)}}}}_readUserData(e){this.expr._readUserData(e)}},Ou=class{constructor(e){this.optionsProto=void 0,{rawOptions:this.rawOptions,...this.knownOptions}=e}_readUserData(e){this.optionsProto=this._optionsUtil.getOptionsProto(e,this.knownOptions,this.rawOptions)}_toProto(e){return{name:this._name,options:this.optionsProto}}},ku=class extends Ou{get _name(){return`add_fields`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.fields=e}_toProto(e){return{...super._toProto(e),args:[Fc(e,this.fields)]}}_readUserData(e){super._readUserData(e),Hu(this.fields,e)}},Au=class extends Ou{get _name(){return`aggregate`}get _optionsUtil(){return new ru({})}constructor(e,t,n){super(n),this.groups=e,this.accumulators=t}_toProto(e){return{...super._toProto(e),args:[Fc(e,this.accumulators),Fc(e,this.groups)]}}_readUserData(e){super._readUserData(e),Hu(this.groups,e),Hu(this.accumulators,e)}},ju=class extends Ou{get _name(){return`distinct`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.groups=e}_toProto(e){return{...super._toProto(e),args:[Fc(e,this.groups)]}}_readUserData(e){super._readUserData(e),Hu(this.groups,e)}},Mu=class extends Ou{get _name(){return`collection`}get _optionsUtil(){return new ru({forceIndex:{serverName:`force_index`}})}constructor(e,t){super(t),this.Vr=e.startsWith(`/`)?e:`/`+e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:this.Vr}]}}_readUserData(e){super._readUserData(e)}},Nu=class extends Ou{get _name(){return`collection_group`}get _optionsUtil(){return new ru({forceIndex:{serverName:`force_index`}})}constructor(e,t){super(t),this.collectionId=e}_toProto(e){return{...super._toProto(e),args:[{referenceValue:``},{stringValue:this.collectionId}]}}_readUserData(e){super._readUserData(e)}},Pu=class extends Ou{get _name(){return`database`}get _optionsUtil(){return new ru({})}_toProto(e){return{...super._toProto(e)}}_readUserData(e){super._readUserData(e)}},Fu=class extends Ou{get _name(){return`documents`}get _optionsUtil(){return new ru({})}constructor(e,t){if(super(t),!e||e.length===0)throw new F(P.INVALID_ARGUMENT,`Empty document paths are not allowed in DocumentsSource`);let n=e.map((e=>e.startsWith(`/`)?e:`/`+e)),r=new Set(n);if(r.size!==n.length)throw new F(P.INVALID_ARGUMENT,`Duplicate document paths are not allowed in DocumentsSource`);this.dr=n,this.mr=r}_toProto(e){return{...super._toProto(e),args:this.dr.map((e=>({referenceValue:e})))}}_readUserData(e){super._readUserData(e)}},Iu=class extends Ou{get _name(){return`where`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.condition=e}_toProto(e){return{...super._toProto(e),args:[this.condition._toProto(e)]}}_readUserData(e){super._readUserData(e),Hu(this.condition,e)}},Lu=class extends Ou{get _name(){return`limit`}get _optionsUtil(){return new ru({})}constructor(e,t){M(!isNaN(e)&&e!==1/0&&e!==-1/0,34860),super(t),this.limit=e}_toProto(e){return{...super._toProto(e),args:[Ba(e,this.limit)]}}},Ru=class extends Ou{get _name(){return`offset`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.offset=e}_toProto(e){return{...super._toProto(e),args:[Ba(e,this.offset)]}}},zu=class extends Ou{get _name(){return`select`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.selections=e}_toProto(e){return{...super._toProto(e),args:[Fc(e,this.selections)]}}_readUserData(e){super._readUserData(e),Hu(this.selections,e)}},Bu=class extends Ou{get _name(){return`sort`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.orderings=e}_toProto(e){return{...super._toProto(e),args:this.orderings.map((t=>t._toProto(e)))}}_readUserData(e){super._readUserData(e),Hu(this.orderings,e)}},Vu=class e extends Ou{get _name(){return`replace_with`}get _optionsUtil(){return new ru({})}constructor(e,t){super(t),this.map=e}_toProto(t){return{...super._toProto(t),args:[this.map._toProto(t),Ic(e.pr)]}}_readUserData(e){super._readUserData(e),Hu(this.map,e)}};Vu.pr=`full_replace`;function Hu(e,t){return nu(e)?e._readUserData(t):Array.isArray(e)||e instanceof Map?e.forEach((e=>e._readUserData(t))):Object.values(e).forEach((e=>e._readUserData(t))),e}var Uu=class{constructor(e,t,n){this.serializer=e,this.stages=t,this.listenOptions=n,this.isCorePipeline=!0}getPipelineCollection(){return Gu(this)}getPipelineCollectionGroup(){return Ku(this)}getPipelineCollectionId(){return qu(this)}getPipelineDocuments(){return Ju(this)}getPipelineFlavor(){return function(e){let t=`exact`;return e.stages.forEach(((n,r)=>{n._name!==ju.name&&n._name!==Au.name||(t=`keyless`),n._name===zu.name&&t===`exact`&&(t=`augmented`),n._name===ku.name&&r<e.stages.length-1&&t===`exact`&&(t=`augmented`)})),t}(this)}getPipelineSourceType(){return Wu(this)}};function Wu(e){let t=e.stages[0];return t instanceof Mu||t instanceof Nu||t instanceof Pu||t instanceof Fu?t._name:`unknown`}function Gu(e){if(Wu(e)===`collection`)return e.stages[0].Vr}function Ku(e){if(Wu(e)===`collection_group`)return e.stages[0].collectionId}function qu(e){switch(Wu(e)){case`collection`:return L.fromString(Gu(e)).lastSegment();case`collection_group`:return Ku(e);default:return}}function Ju(e){if(Wu(e)===`documents`)return e.stages[0].dr}var Yu=class e{constructor(e,t,n,r){this._db=e,this.userDataReader=t,this._userDataWriter=n,this.stages=r}wr(e,t){let n=this.userDataReader.createContext(3,e);return nu(t)?t._readUserData(n):t.forEach((e=>e._readUserData(n))),t}where(t){let n=this.stages.map((e=>e));return this.wr(`where`,t),n.push(new Iu(t,{})),new e(this._db,this.userDataReader,this._userDataWriter,n)}limit(t){let n=this.stages.map((e=>e));return n.push(new Lu(t,{})),new e(this._db,this.userDataReader,this._userDataWriter,n)}sort(t,...n){let r=this.stages.map((e=>e));return`orderings`in t?r.push(new Bu(this.wr(`sort`,t.orderings),{})):r.push(new Bu(this.wr(`sort`,[t,...n]),{})),new e(this._db,this.userDataReader,this._userDataWriter,r)}br(e){return{pipeline:{stages:this.stages.map((t=>t._toProto(e)))}}}},q=class e{constructor(e,t){this.type=e,this.value=t}static vr(){return new e(`ERROR`,void 0)}static Sr(){return new e(`UNSET`,void 0)}static Dr(){return new e(`NULL`,fa)}static newValue(t){return ka(t)?new e(`NULL`,fa):function(e){return!!e&&`booleanValue`in e}(t)?new e(`BOOLEAN`,t):Ta(t)?new e(`INT`,t):Ea(t)?new e(`DOUBLE`,t):function(e){return!!e&&`timestampValue`in e&&!!e.timestampValue}(t)?new e(`TIMESTAMP`,t):function(e){return!!e&&`stringValue`in e}(t)?new e(`STRING`,t):function(e){return!!e&&`bytesValue`in e}(t)?new e(`BYTES`,t):t.referenceValue?new e(`REFERENCE`,t):t.geoPointValue?new e(`GEO_POINT`,t):Oa(t)?new e(`ARRAY`,t):Ma(t)?new e(`VECTOR`,t):ja(t)?new e(`MAP`,t):new e(`ERROR`,void 0)}Cr(){return this.type===`ERROR`||this.type===`UNSET`}Fr(){return this.type===`NULL`}};function Xu(e){if(!e.Cr())return e.value}function Zu(e){return e instanceof yu?e._expr:e}function J(e){if((e=Zu(e))instanceof pu)return new Qu(e);if(e instanceof gu)return new $u(e);if(e instanceof fu)return new ed(e);if(e instanceof K){if(e.name===`add`)return new sd(e);if(e.name===`subtract`)return new cd(e);if(e.name===`multiply`)return new ld(e);if(e.name===`divide`)return new ud(e);if(e.name===`mod`)return new dd(e);if(e.name===`and`)return new fd(e);if(e.name===`equal`)return new Od(e);if(e.name===`not_equal`)return new kd(e);if(e.name===`less_than`)return new Ad(e);if(e.name===`less_than_or_equal`)return new jd(e);if(e.name===`greater_than`)return new Md(e);if(e.name===`greater_than_or_equal`)return new Nd(e);if(e.name===`array_concat`)return new Pd(e);if(e.name===`array_reverse`)return new Fd(e);if(e.name===`array_contains`)return new Id(e);if(e.name===`array_contains_all`)return new Ld(e);if(e.name===`array_contains_any`)return new Rd(e);if(e.name===`array_length`)return new zd(e);if(e.name===`array_element`)return new Bd(e);if(e.name===`equal_any`)return new gd(e);if(e.name===`not_equal_any`)return new _d(e);if(e.name===`is_nan`)return new vd(e);if(e.name===`is_not_nan`)return new yd(e);if(e.name===`is_null`)return new bd(e);if(e.name===`is_not_null`)return new xd(e);if(e.name===`is_error`)return new Sd(e);if(e.name===`exists`)return new Cd(e);if(e.name===`not`)return new pd(e);if(e.name===`or`)return new md(e);if(e.name===`xor`)return new hd(e);if(e.name===`conditional`)return new wd(e);if(e.name===`maximum`)return new Td(e);if(e.name===`minimum`)return new Ed(e);if(e.name===`reverse`)return new Vd(e);if(e.name===`replace_first`)return new Hd(e);if(e.name===`replace_all`)return new Ud(e);if(e.name===`char_length`)return new Wd(e);if(e.name===`byte_length`)return new Gd(e);if(e.name===`like`)return new qd(e);if(e.name===`regex_contains`)return new Jd(e);if(e.name===`regex_match`)return new Yd(e);if(e.name===`string_contains`)return new Xd(e);if(e.name===`starts_with`)return new Zd(e);if(e.name===`ends_with`)return new Qd(e);if(e.name===`to_lower`)return new $d(e);if(e.name===`to_upper`)return new ef(e);if(e.name===`trim`)return new tf(e);if(e.name===`string_concat`)return new nf(e);if(e.name===`map_get`)return new rf(e);if(e.name===`cosine_distance`)return new of(e);if(e.name===`dot_product`)return new sf(e);if(e.name===`euclidean_distance`)return new cf(e);if(e.name===`vector_length`)return new lf(e);if(e.name===`unix_micros_to_timestamp`)return new wf(e);if(e.name===`timestamp_to_unix_micros`)return new Of(e);if(e.name===`unix_millis_to_timestamp`)return new Tf(e);if(e.name===`timestamp_to_unix_millis`)return new kf(e);if(e.name===`unix_seconds_to_timestamp`)return new Ef(e);if(e.name===`timestamp_to_unix_seconds`)return new Af(e);if(e.name===`timestamp_add`)return new Mf(e);if(e.name===`timestamp_subtract`)return new Nf(e)}throw Error(`Unknown Expr : ${e}`)}var Qu=class{constructor(e){this.expr=e}evaluate(e,t){if(this.expr.fieldName===Qr)return q.newValue({referenceValue:lc(e.serializer,t.key)});if(this.expr.fieldName===`__update_time__`)return q.newValue({timestampValue:ic(e.serializer,t.version)});if(this.expr.fieldName===`__create_time__`)return q.newValue({timestampValue:ic(e.serializer,t.createTime)});let n=t.data.field(this.expr._fieldPath);return n?ea(n)?q.newValue(function(e,t){if(e.serverTimestampBehavior===`estimate`)return{timestampValue:ic(e.serializer,z.fromTimestamp(na(t)))};if(e.serverTimestampBehavior===`previous`){let e=ta(t);if(e)return e}return{nullValue:`NULL_VALUE`}}(e,n)):q.newValue(n):q.Sr()}},$u=class{constructor(e){this.expr=e}evaluate(e,t){return q.newValue(this.expr._getValue())}},ed=class{constructor(e){this.expr=e}evaluate(e,t){let n=this.expr.Rr.map((n=>J(n).evaluate(e,t)));return n.some((e=>e.Cr()))?q.vr():q.newValue({arrayValue:{values:n.map((e=>e.value))}})}};function td(e){return Ea(e)?Number(e.doubleValue):Number(e.integerValue)}function nd(e){return BigInt(e.integerValue)}var rd=BigInt(`0x7fffffffffffffff`),id=-BigInt(`0x8000000000000000`),ad=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length>=2,24778);let n=J(this.expr.params[0]).evaluate(e,t),r=J(this.expr.params[1]).evaluate(e,t),i=this.Or(n,r);for(let n of this.expr.params.slice(2)){let r=J(n).evaluate(e,t);i=this.Or(i,r)}return i}Or(e,t){if(e.Cr()||t.Cr())return q.vr();if(e.Fr()||t.Fr())return q.Dr();let n=e.value,r=t.value;if(!Ea(n)&&!Ta(n)||!Ea(r)&&!Ta(r))return q.vr();if(Ea(n)||Ea(r)){let e=this.Mr(n,r);return e?q.newValue(e):q.vr()}if(Ta(n)&&Ta(r)){let e=this.Nr(n,r);return e===void 0?q.vr():typeof e==`number`?q.newValue({doubleValue:e}):e<id||e>rd?q.vr():q.newValue({integerValue:`${e}`})}return q.vr()}};function od(e,t){return ha(e)===ha(t)?Aa(e)||Aa(t)?`NOT_EQ`:ka(e)&&ka(t)?`EQ`:ka(e)||ka(t)?`NULL`:Oa(e)&&Oa(t)?function(e,t){if(e.values?.length!==t.values?.length)return`NOT_EQ`;let n=!1;for(let r=0;r<(e.values?.length??0);r++){let i=e.values[r],a=t.values[r];switch(od(i,a)){case`EQ`:break;case`NOT_EQ`:case`TYPE_MISMATCH`:return`NOT_EQ`;case`NULL`:n=!0;break;default:j(44609,{Lr:i,Br:a})}}return n?`NULL`:`EQ`}(e.arrayValue,t.arrayValue):Ma(e)&&Ma(t)||ja(e)&&ja(t)?function(e,t){let n=e.fields||{},r=t.fields||{};if(Vi(n)!==Vi(r))return`NOT_EQ`;let i=!1;for(let e in n)if(n.hasOwnProperty(e)){if(r[e]===void 0)return`NOT_EQ`;switch(od(n[e],r[e])){case`NOT_EQ`:case`TYPE_MISMATCH`:return`NOT_EQ`;case`NULL`:i=!0}}return i?`NULL`:`EQ`}(e.mapValue,t.mapValue):function(e,t){return ga(e,t,{Te:!1,Ee:!0,he:!0})}(e,t)?`EQ`:`NOT_EQ`:`TYPE_MISMATCH`}var sd=class extends ad{Nr(e,t){return nd(e)+nd(t)}Mr(e,t){return{doubleValue:td(e)+td(t)}}},cd=class extends ad{constructor(e){super(e),this.expr=e}Nr(e,t){return nd(e)-nd(t)}Mr(e,t){return{doubleValue:td(e)-td(t)}}},ld=class extends ad{constructor(e){super(e),this.expr=e}Nr(e,t){return nd(e)*nd(t)}Mr(e,t){return{doubleValue:td(e)*td(t)}}},ud=class extends ad{constructor(e){super(e),this.expr=e}Nr(e,t){let n=nd(t);if(n!==BigInt(0))return nd(e)/n}Mr(e,t){let n=td(t);return n===0?{doubleValue:ki(n)?-1/0:1/0}:{doubleValue:td(e)/n}}},dd=class extends ad{constructor(e){super(e),this.expr=e}Nr(e,t){let n=nd(t);if(n!==BigInt(0))return nd(e)%n}Mr(e,t){let n=td(t);if(n!==0)return{doubleValue:td(e)%n}}},fd=class{constructor(e){this.expr=e}evaluate(e,t){let n=!1,r=!1;for(let i of this.expr.params){let a=J(i).evaluate(e,t);switch(a.type){case`BOOLEAN`:if(!a.value?.booleanValue)return q.newValue(ma);break;case`NULL`:r=!0;break;default:n=!0}}return n?q.vr():r?q.Dr():q.newValue(pa)}},pd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,9634);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`BOOLEAN`:return q.newValue({booleanValue:!n.value?.booleanValue});case`NULL`:return q.Dr();default:return q.vr()}}},md=class{constructor(e){this.expr=e}evaluate(e,t){let n=!1,r=!1;for(let i of this.expr.params){let a=J(i).evaluate(e,t);switch(a.type){case`BOOLEAN`:if(a.value?.booleanValue)return q.newValue(pa);break;case`NULL`:r=!0;break;default:n=!0}}return n?q.vr():r?q.Dr():q.newValue(ma)}},hd=class e{constructor(e){this.expr=e}evaluate(t,n){let r=!1,i=!1;for(let a of this.expr.params){let o=J(a).evaluate(t,n);switch(o.type){case`BOOLEAN`:r=e.xor(r,!!o.value?.booleanValue);break;case`NULL`:i=!0;break;default:return q.vr()}}return i?q.Dr():q.newValue({booleanValue:r})}static xor(e,t){return(e||t)&&!(e&&t)}},gd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,55094);let n=!1,r=J(this.expr.params[0]).evaluate(e,t);switch(r.type){case`NULL`:n=!0;break;case`ERROR`:case`UNSET`:return q.vr()}let i=J(this.expr.params[1]).evaluate(e,t);switch(i.type){case`ARRAY`:break;case`NULL`:n=!0;break;default:return q.vr()}if(n)return q.Dr();for(let e of i.value?.arrayValue?.values??[])switch(ka(r.value)&&ka(e)?`EQ`:od(r.value,e)){case`EQ`:return q.newValue(pa);case`NOT_EQ`:case`TYPE_MISMATCH`:break;case`NULL`:n=!0;break;default:j(44608,{value:r.value,candidate:e})}return n?q.Dr():q.newValue(ma)}},_d=class{constructor(e){this.expr=e}evaluate(e,t){return new pd(new K(`not`,[new K(`equal_any`,this.expr.params)])).evaluate(e,t)}},vd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,23322);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`INT`:return q.newValue(ma);case`DOUBLE`:return q.newValue({booleanValue:isNaN(td(n.value))});case`NULL`:return q.Dr();default:return q.vr()}}},yd=class{constructor(e){this.expr=e}evaluate(e,t){return M(this.expr.params.length===1,50406),new pd(new K(`not`,[new K(`is_nan`,this.expr.params)])).evaluate(e,t)}},bd=class{constructor(e){this.expr=e}evaluate(e,t){switch(M(this.expr.params.length===1,23123),J(this.expr.params[0]).evaluate(e,t).type){case`NULL`:return q.newValue(pa);case`UNSET`:case`ERROR`:return q.vr();default:return q.newValue(ma)}}},xd=class{constructor(e){this.expr=e}evaluate(e,t){return M(this.expr.params.length===1,23167),new pd(new K(`not`,[new K(`is_null`,this.expr.params)])).evaluate(e,t)}},Sd=class{constructor(e){this.expr=e}evaluate(e,t){return M(this.expr.params.length===1,5228),J(this.expr.params[0]).evaluate(e,t).type===`ERROR`?q.newValue(pa):q.newValue(ma)}},Cd=class{constructor(e){this.expr=e}evaluate(e,t){switch(M(this.expr.params.length===1,6877),J(this.expr.params[0]).evaluate(e,t).type){case`ERROR`:return q.vr();case`UNSET`:return q.newValue(ma);default:return q.newValue(pa)}}},wd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===3,11706);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`BOOLEAN`:return n.value?.booleanValue?J(this.expr.params[1]).evaluate(e,t):J(this.expr.params[2]).evaluate(e,t);case`NULL`:return J(this.expr.params[2]).evaluate(e,t);default:return q.vr()}}},Td=class{constructor(e){this.expr=e}evaluate(e,t){let n=this.expr.params.map((n=>J(n).evaluate(e,t))),r;for(let e of n)switch(e.type){case`ERROR`:case`UNSET`:case`NULL`:continue;default:r=r===void 0||va(e.value,r.value)>0?e:r}return r===void 0?q.Dr():r}},Ed=class{constructor(e){this.expr=e}evaluate(e,t){let n=this.expr.params.map((n=>J(n).evaluate(e,t))),r;for(let e of n)switch(e.type){case`ERROR`:case`UNSET`:case`NULL`:continue;default:r=r===void 0||va(e.value,r.value)<0?e:r}return r===void 0?q.Dr():r}},Dd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,31033,`${this.expr.name}() function should have exactly 2 params`);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`ERROR`:case`UNSET`:return q.vr()}let r=J(this.expr.params[1]).evaluate(e,t);switch(r.type){case`ERROR`:case`UNSET`:return q.vr()}return this.Ur(n,r)}},Od=class extends Dd{constructor(e){super(e),this.expr=e}Ur(e,t){if(e.Fr()&&t.Fr())return q.newValue(pa);if(e.Fr()||t.Fr()||Aa(e.value)||Aa(t.value)||ha(e.value)!==ha(t.value))return q.newValue(ma);switch(od(e.value,t.value)){case`EQ`:return q.newValue(pa);case`NOT_EQ`:return q.newValue(ma);case`NULL`:return q.Dr();default:j(44615,{left:e,right:t})}}},kd=class extends Dd{constructor(e){super(e),this.expr=e}Ur(e,t){switch(od(e.value,t.value)){case`EQ`:return q.newValue(ma);case`NOT_EQ`:case`TYPE_MISMATCH`:return q.newValue(pa);case`NULL`:return q.Dr();default:j(44614,{left:e,right:t})}}},Ad=class extends Dd{constructor(e){super(e),this.expr=e}Ur(e,t){return ha(e.value)!==ha(t.value)||Aa(e.value)||Aa(t.value)?q.newValue(ma):q.newValue({booleanValue:va(e.value,t.value)<0})}},jd=class extends Dd{constructor(e){super(e),this.expr=e}Ur(e,t){return ha(e.value)!==ha(t.value)||Aa(e.value)||Aa(t.value)?q.newValue(ma):od(e.value,t.value)===`EQ`?q.newValue(pa):q.newValue({booleanValue:va(e.value,t.value)<0})}},Md=class extends Dd{constructor(e){super(e),this.expr=e}Ur(e,t){return ha(e.value)!==ha(t.value)||Aa(e.value)||Aa(t.value)?q.newValue(ma):q.newValue({booleanValue:va(e.value,t.value)>0})}},Nd=class extends Dd{constructor(e){super(e),this.expr=e}Ur(e,t){return ha(e.value)!==ha(t.value)||Aa(e.value)||Aa(t.value)?q.newValue(ma):od(e.value,t.value)===`EQ`?q.newValue(pa):q.newValue({booleanValue:va(e.value,t.value)>0})}},Pd=class{constructor(e){this.expr=e}evaluate(e,t){throw Error(`Unimplemented`)}},Fd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,216);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`NULL`:return q.Dr();case`ARRAY`:{let e=n.value.arrayValue?.values??[];return q.newValue({arrayValue:{values:[...e].reverse()}})}default:return q.vr()}}},Id=class{constructor(e){this.expr=e}evaluate(e,t){return M(this.expr.params.length===2,52884),new gd(new K(`eq_any`,[this.expr.params[1],this.expr.params[0]])).evaluate(e,t)}},Ld=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,1392);let n=!1,r=J(this.expr.params[0]).evaluate(e,t);switch(r.type){case`ARRAY`:break;case`NULL`:n=!0;break;default:return q.vr()}let i=J(this.expr.params[1]).evaluate(e,t);switch(i.type){case`ARRAY`:break;case`NULL`:n=!0;break;default:return q.vr()}if(n)return q.Dr();let a=i.value?.arrayValue?.values??[],o=r.value?.arrayValue?.values??[];for(let e of a){let t=!1;n=!1;for(let r of o){switch(ka(e)&&ka(r)?`EQ`:od(e,r)){case`EQ`:t=!0;break;case`NOT_EQ`:case`TYPE_MISMATCH`:break;case`NULL`:n=!0;break;default:j(44613,{value:r,search:e})}if(t)break}if(!t)return q.newValue(ma)}return q.newValue(pa)}},Rd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,2680);let n=!1,r=J(this.expr.params[0]).evaluate(e,t);switch(r.type){case`ARRAY`:break;case`NULL`:n=!0;break;default:return q.vr()}let i=J(this.expr.params[1]).evaluate(e,t);switch(i.type){case`ARRAY`:break;case`NULL`:n=!0;break;default:return q.vr()}if(n)return q.Dr();let a=i.value?.arrayValue?.values??[],o=r.value?.arrayValue?.values??[];for(let e of o)for(let t of a)switch(ka(e)&&ka(t)?`EQ`:od(e,t)){case`EQ`:return q.newValue(pa);case`NOT_EQ`:case`TYPE_MISMATCH`:break;case`NULL`:n=!0;break;default:j(44608,{value:e,search:t})}return n?q.Dr():q.newValue(ma)}},zd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,38605);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`NULL`:return q.Dr();case`ARRAY`:return q.newValue({integerValue:`${n.value?.arrayValue?.values?.length??0}`});default:return q.vr()}}},Bd=class{constructor(e){this.expr=e}evaluate(e,t){throw Error(`Unimplemented`)}},Vd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,1508);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`NULL`:return q.Dr();case`BYTES`:{let e=n.value?.bytesValue;if(typeof e==`string`){let t=Ki.fromBase64String(e).toUint8Array();return t.reverse(),q.newValue({bytesValue:Ki.fromUint8Array(t).toBase64()})}return q.newValue({bytesValue:new Uint8Array(e).reverse()})}case`STRING`:{let e=n.value?.stringValue,t=new Intl.__PRIVATE_Segmenter(void 0,{granularity:`grapheme`}).segment(e),r=Array.from(t,(e=>e.segment)).reverse();return q.newValue({stringValue:r.join(``)})}default:return q.vr()}}},Hd=class{constructor(e){this.expr=e}evaluate(e,t){throw Error(`Unimplemented`)}},Ud=class{constructor(e){this.expr=e}evaluate(e,t){throw Error(`Unimplemented`)}},Wd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,19400);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`NULL`:return q.Dr();case`STRING`:{let e=function(e){let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(r===void 0)return;if(r<=65535)if(r>=55296&&r<=57343)if(r<=56319){let r=e.codePointAt(n+1);r!==void 0&&r>=56320&&r<=57343?(t+=1,n++):t+=1}else t+=1;else t+=1;else{if(!(r<=1114111))return;t+=1,n++}}return t}(n.value.stringValue);return e===void 0?q.vr():q.newValue({integerValue:e})}default:return q.vr()}}},Gd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,8486);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`BYTES`:{let e=n.value?.bytesValue;return typeof e==`string`?q.newValue({integerValue:Ki.fromBase64String(e).toUint8Array().length}):q.newValue({integerValue:new Uint8Array(e).length})}case`STRING`:{let e=function(e){let t=0;for(let n=0;n<e.length;n++){let r=e.codePointAt(n);if(r===void 0)return;if(r>=55296&&r<=57343){if(!(r<=56319))return;{let r=e.codePointAt(n+1);if(r===void 0||!(r>=56320&&r<=57343))return;t+=4,n++}}else if(r<=127)t+=1;else if(r<=2047)t+=2;else if(r<=65535)t+=3;else{if(!(r<=1114111))return;t+=4,n++}}return t}(n.value?.stringValue);return e===void 0?q.vr():q.newValue({integerValue:e})}case`NULL`:return q.Dr();default:return q.vr()}}},Kd=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,39773,`${this.expr.name}() function should have exactly two parameters`);let n=!1,r=J(this.expr.params[0]).evaluate(e,t);switch(r.type){case`STRING`:break;case`NULL`:n=!0;break;default:return q.vr()}let i=J(this.expr.params[1]).evaluate(e,t);switch(i.type){case`STRING`:break;case`NULL`:n=!0;break;default:return q.vr()}return n?q.Dr():this.kr(r.value?.stringValue,i.value?.stringValue)}},qd=class extends Kd{kr(e,t){try{let n=function(e){let t=``;for(let n=0;n<e.length;n++){let r=e.charAt(n);switch(r){case`_`:t+=`.`;break;case`%`:t+=`.*`;break;case`\\`:case`.`:case`*`:case`?`:case`+`:case`^`:case`$`:case`|`:case`(`:case`)`:case`[`:case`]`:case`{`:case`}`:t+=`\\`+r;break;default:t+=r}}return`^`+t+`$`}(t),r=Er.compile(n);return q.newValue({booleanValue:r.matches(e)})}catch(e){return Nr(`Invalid LIKE pattern converted to regex: ${t}, returning error. Error: ${e}`),q.vr()}}},Jd=class extends Kd{kr(e,t){try{let n=Er.compile(t);return q.newValue({booleanValue:n.matcher(e).find()})}catch{return Nr(`Invalid regex pattern found in regex_contains: ${t}, returning error`),q.vr()}}},Yd=class extends Kd{kr(e,t){try{return q.newValue({booleanValue:Er.compile(t).matches(e)})}catch{return Nr(`Invalid regex pattern found in regex_match: ${t}, returning error`),q.vr()}}},Xd=class extends Kd{kr(e,t){return q.newValue({booleanValue:e.includes(t)})}},Zd=class extends Kd{kr(e,t){return q.newValue({booleanValue:e.startsWith(t)})}},Qd=class extends Kd{kr(e,t){return q.newValue({booleanValue:e.endsWith(t)})}},$d=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,29079);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`STRING`:return q.newValue({stringValue:n.value?.stringValue?.toLowerCase()});case`NULL`:return q.Dr();default:return q.vr()}}},ef=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,60487);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`STRING`:return q.newValue({stringValue:n.value?.stringValue?.toUpperCase()});case`NULL`:return q.Dr();default:return q.vr()}}},tf=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,28544);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`STRING`:return q.newValue({stringValue:n.value?.stringValue?.trim()});case`NULL`:return q.Dr();default:return q.vr()}}},nf=class{constructor(e){this.expr=e}evaluate(e,t){let n=this.expr.params.map((n=>J(n).evaluate(e,t))),r=``,i=!1;for(let e of n)switch(e.type){case`STRING`:r+=e.value.stringValue;break;case`NULL`:i=!0;break;default:return q.vr()}return i?q.Dr():q.newValue({stringValue:r})}},rf=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,4483);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`UNSET`:return q.Sr();case`MAP`:break;default:return q.vr()}let r=J(this.expr.params[1]).evaluate(e,t);if(r.type!==`STRING`)return q.vr();let i=n.value?.mapValue?.fields?.[r.value?.stringValue];return i===void 0?q.Sr():q.newValue(i)}},af=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===2,25231,`${this.expr.name}() function should have exactly 2 params`);let n=!1,r=J(this.expr.params[0]).evaluate(e,t);switch(r.type){case`VECTOR`:break;case`NULL`:n=!0;break;default:return q.vr()}let i=J(this.expr.params[1]).evaluate(e,t);switch(i.type){case`VECTOR`:break;case`NULL`:n=!0;break;default:return q.vr()}if(n)return q.Dr();let a=Na(r.value),o=Na(i.value);if(a===void 0||o===void 0||a.values?.length!==o.values?.length)return q.vr();let s=this.qr(a,o);return s===void 0||isNaN(s)?q.vr():q.newValue({doubleValue:s})}},of=class extends af{qr(e,t){let n=e?.values??[],r=t?.values??[];if(n.length===0)return;let i=0,a=0,o=0;for(let e=0;e<n.length;e++){if(!Da(n[e])||!Da(r[e]))return;let t=td(n[e]),s=td(r[e]);i+=t*s,a+=t*t,o+=s*s}let s=Math.sqrt(a)*Math.sqrt(o);if(s!==0)return 1-Math.max(-1,Math.min(1,i/s))}},sf=class extends af{qr(e,t){let n=e?.values??[],r=t?.values??[];if(n.length===0)return 0;let i=0;for(let e=0;e<n.length;e++){if(!Da(n[e])||!Da(r[e]))return;i+=td(n[e])*td(r[e])}return i}},cf=class extends af{qr(e,t){let n=e?.values??[],r=t?.values??[];if(n.length===0)return 0;let i=0;for(let e=0;e<n.length;e++){if(!Da(n[e])||!Da(r[e]))return;let t=td(n[e]),a=td(r[e]);i+=(t-a)**2}return Math.sqrt(i)}},lf=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,39044);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`VECTOR`:{let e=Na(n.value);return q.newValue({integerValue:e?.values?.length??0})}case`NULL`:return q.Dr();default:return q.vr()}}},uf=BigInt(-62135596800),df=BigInt(253402300799),ff=BigInt(1e3),pf=BigInt(1e6),mf=uf*ff,hf=df*ff+BigInt(999),gf=uf*pf,_f=df*pf+BigInt(999999);function vf(e){return e>=gf&&e<=_f}function yf(e){return e>=uf&&e<=df}function bf(e,t){let n=BigInt(e);return!(n<uf||n>df)&&!(t<0||t>=1e9)&&(n!==uf||t===0)&&!(n===df&&t>999999999)}function xf(e,t){return t<0?{seconds:e-1,nanos:t+1e9}:{seconds:e,nanos:t}}function Sf(e){return BigInt(e.seconds)*pf+BigInt(Math.trunc(e.nanoseconds/1e3))}var Cf=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,49262,`${this.expr.name}() function should have exactly one parameter`);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`INT`:return this.toTimestamp(BigInt(n.value.integerValue));case`NULL`:return q.Dr();default:return q.vr()}}},wf=class extends Cf{toTimestamp(e){if(!vf(e))return q.vr();let t=Number(e/pf),n=Number(e%pf*BigInt(1e3)),r=xf(t,n);return t=r.seconds,n=r.nanos,bf(t,n)?q.newValue({timestampValue:{seconds:t,nanos:n}}):q.vr()}},Tf=class extends Cf{toTimestamp(e){if(!function(e){return e>=mf&&e<=hf}(e))return q.vr();let t=Number(e/ff),n=Number(e%ff*BigInt(1e6)),r=xf(t,n);return t=r.seconds,n=r.nanos,bf(t,n)?q.newValue({timestampValue:{seconds:t,nanos:n}}):q.vr()}},Ef=class extends Cf{toTimestamp(e){if(!yf(e))return q.vr();let t=Number(e);return q.newValue({timestampValue:{seconds:t,nanos:0}})}},Df=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===1,1265,`${this.expr.name}() function should have exactly one parameter`);let n=J(this.expr.params[0]).evaluate(e,t);switch(n.type){case`TIMESTAMP`:break;case`NULL`:return q.Dr();default:return q.vr()}let r=nc(n.value.timestampValue);return bf(r.seconds,r.nanoseconds)?this.$r(r):q.vr()}},Of=class extends Df{$r(e){let t=Sf(e);return vf(t)?q.newValue({integerValue:`${t.toString()}`}):q.vr()}},kf=class extends Df{$r(e){let t=Sf(e),n=t/BigInt(1e3),r=t%BigInt(1e3);return n>BigInt(0)||r===BigInt(0)?q.newValue({integerValue:n.toString()}):q.newValue({integerValue:(n-BigInt(1)).toString()})}},Af=class extends Df{$r(e){let t=BigInt(e.seconds);return yf(t)?q.newValue({integerValue:t.toString()}):q.vr()}},jf=class{constructor(e){this.expr=e}evaluate(e,t){M(this.expr.params.length===3,2775,`${this.expr.name}() function should have exactly 3 parameters`);let n=!1,r=J(this.expr.params[0]).evaluate(e,t);switch(r.type){case`TIMESTAMP`:break;case`NULL`:n=!0;break;default:return q.vr()}let i=J(this.expr.params[1]).evaluate(e,t),a;switch(i.type){case`STRING`:if(a=function(e){switch(e){case`microsecond`:return`microsecond`;case`millisecond`:return`millisecond`;case`second`:return`second`;case`minute`:return`minute`;case`hour`:return`hour`;case`day`:return`day`;default:return}}(i.value.stringValue),a===void 0)return q.vr();break;case`NULL`:n=!0;break;default:return q.vr()}let o=J(this.expr.params[2]).evaluate(e,t);switch(o.type){case`INT`:break;case`NULL`:n=!0;break;default:return q.vr()}if(n)return q.Dr();let s=BigInt(o.value.integerValue),c;try{switch(a){case`microsecond`:c=s;break;case`millisecond`:c=s*BigInt(1e3);break;case`second`:c=s*BigInt(1e6);break;case`minute`:c=s*BigInt(6e7);break;case`hour`:c=s*BigInt(36e8);break;case`day`:c=s*BigInt(864e8);break;default:return q.vr()}if(a!==`microsecond`&&s!==BigInt(0)&&c/s!==BigInt(this.Kr(a)))return q.vr()}catch(e){return Nr(`Error during timestamp arithmetic: ${e}`),q.vr()}let l=nc(r.value.timestampValue);if(!bf(l.seconds,l.nanoseconds))return q.vr();let u=Sf(l),d=this.Wr(u,c);if(!vf(d))return q.vr();let f=Number(d/pf),p=d%pf,m=Number((p<0?p+pf:p)*BigInt(1e3)),h=p<0?f-1:f;return bf(h,m)?q.newValue({timestampValue:{seconds:h,nanos:m}}):q.vr()}Kr(e){switch(e){case`millisecond`:return 1e3;case`second`:return 1e6;case`minute`:return 6e7;case`hour`:return 36e8;case`day`:return 864e8;default:return 1}}},Mf=class extends jf{Wr(e,t){return e+t}},Nf=class extends jf{Wr(e,t){return e-t}};function Pf(e){if((e=Zu(e))instanceof pu)return`fld(${e.fieldName})`;if(e instanceof gu)return`cst(${function(e){return e===null?`null`:typeof e==`number`?e.toString():typeof e==`string`?`"${e}"`:e instanceof Al?`ref(${e.path})`:e instanceof Pl?`vec(${JSON.stringify(e)})`:JSON.stringify(e)}(e.value)})`;if(e instanceof K)return`fn(${e.name},[${e.params.map(Pf).join(`,`)}])`;if(e.expressionType===`ListOfExpressions`)return`list([${e.Rr.map(Pf).join(`,`)}])`;throw Error(`Unrecognized expr ${JSON.stringify(e,null,2)}`)}function Ff(e){if(e instanceof ku)return`${e._name}(${If(e.fields)})`;if(e instanceof Au){let t=`${e._name}(${If(e.accumulators)})`;return e.groups.size>0&&(t+=`grouping(${If(e.groups)})`),t}if(e instanceof ju)return`${e._name}(${If(e.groups)})`;if(e instanceof Mu)return`${e._name}(${e.Vr})`;if(e instanceof Nu)return`${e._name}(${e.collectionId})`;if(e instanceof Pu)return`${e._name}()`;if(e instanceof Fu)return`${e._name}(${e.dr.sort()})`;if(e instanceof Iu)return`${e._name}(${Pf(e.condition)})`;if(e instanceof Lu)return`${e._name}(${e.limit})`;if(e instanceof Bu)return`${e._name}(${function(e){return e.map((e=>`${Pf(e.expr)}${e.direction}`)).join(`,`)}(e.orderings)})`;throw Error(`Unrecognized stage ${e._name}`)}function If(e){return`${Array.from(e.entries()).sort().map((([e,t])=>`${e}=${Pf(t)}`)).join(`,`)}`}function Lf(e){return e.stages.map((e=>Ff(e))).join(`|`)}function Rf(e,t){return Lf(e)===Lf(t)}function zf(e){return e instanceof Uu}function Bf(e){return zf(e)?Lf(e):fs(e)}function Vf(e){return zf(e)?Lf(e):function(e){return`${qo(is(e))}|lt:${e.limitType}`}(e)}function Hf(e,t){return e instanceof Uu&&t instanceof Uu?Rf(e,t):!(e instanceof Uu&&!(t instanceof Uu)||!(e instanceof Uu)&&t instanceof Uu)&&ds(e,t)}function Uf(e){return Yo(e)?Lf(e):qo(e)}function Wf(e,t){return e instanceof Uu&&t instanceof Uu?Rf(e,t):!(e instanceof Uu&&!(t instanceof Uu)||!(e instanceof Uu)&&t instanceof Uu)&&Jo(e,t)}function Gf(e,t){let n=function(e){let t=!1,n=[];for(let r of e)if(r instanceof Bu)if(t=!0,r.orderings.some((e=>e.expr instanceof pu&&e.expr.fieldName===Qr)))n.push(r);else{let e=r.orderings.map((e=>e));e.push(mu(Qr).ascending()),n.push(new Bu(e,{}))}else r instanceof Lu&&(t||=(n.push(new Bu([mu(Qr).ascending()],{})),!0)),n.push(r);return t||n.push(new Bu([mu(Qr).ascending()],{})),n}(e.stages);if(e.userDataReader){let t=e.userDataReader.createContext(3,`toCorePipeline`);n.forEach((e=>e._readUserData(t)))}return new Uu(e.userDataReader.serializer,n,t)}var Kf=class{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){let n=t.mutationResults;for(let t=0;t<this.mutations.length;t++){let r=this.mutations[t];r.key.isEqual(e.key)&&lo(r,e,n[t])}}applyToLocalView(e,t){for(let n of this.baseMutations)n.key.isEqual(e.key)&&(t=uo(n,e,t,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(e.key)&&(t=uo(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let n=Ds();return this.mutations.forEach((r=>{let i=e.get(r.key),a=i.overlayedDocument,o=this.applyToLocalView(a,i.mutatedFields);o=t.has(r.key)?null:o;let s=co(a,o);s!==null&&n.set(r.key,s),a.isValidDocument()||a.convertToNoDocument(z.min())})),n}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),W())}isEqual(e){return this.batchId===e.batchId&&Zr(this.mutations,e.mutations,((e,t)=>po(e,t)))&&Zr(this.baseMutations,e.baseMutations,((e,t)=>po(e,t)))}},qf=class e{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(t,n,r){M(t.mutations.length===r.length,58842,{Qr:t.mutations.length,Gr:r.length});let i=function(){return ks}(),a=t.mutations;for(let e=0;e<a.length;e++)i=i.insert(a[e].key,r[e].version);return new e(t,n,r,i)}},Jf=class{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{\n largestBatchId: ${this.largestBatchId},\n mutation: ${this.mutation.toString()}\n }`}},Yf=class e{constructor(e,t,n,r,i=z.min(),a=z.min(),o=Ki.EMPTY_BYTE_STRING,s=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=o,this.expectedCount=s}withSequenceNumber(t){return new e(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(t,n){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,t,null)}withExpectedCount(t){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,t)}withLastLimboFreeSnapshotVersion(t){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken,this.expectedCount)}},Xf=class{constructor(e){this.zr=e}};function Zf(e){let t=Sc({parent:e.parent,structuredQuery:e.structuredQuery});return e.limitType===`LAST`?ls(t,t.limit,`L`):t}var Qf=class{constructor(){}Yr(e,t){this.Zr(e,t),t.Xr()}Zr(e,t){if(`nullValue`in e)this.ei(t,5);else if(`booleanValue`in e)this.ei(t,10),t.ti(+!!e.booleanValue);else if(`integerValue`in e)this.ei(t,15),t.ti(H(e.integerValue));else if(`doubleValue`in e){let n=H(e.doubleValue);isNaN(n)?this.ei(t,13):(this.ei(t,15),ki(n)?t.ti(0):t.ti(n))}else if(`timestampValue`in e){let n=e.timestampValue;this.ei(t,20),typeof n==`string`&&(n=Ji(n)),t.ni(`${n.seconds||``}`),t.ti(n.nanos||0)}else if(`stringValue`in e)this.ri(e.stringValue,t),this.ii(t);else if(`bytesValue`in e)this.ei(t,30),t.si(Yi(e.bytesValue)),this.ii(t);else if(`referenceValue`in e)this._i(e.referenceValue,t);else if(`geoPointValue`in e){let n=e.geoPointValue;this.ei(t,45),t.ti(n.latitude||0),t.ti(n.longitude||0)}else`mapValue`in e?Fa(e)?this.ei(t,2**53-1):Ma(e)?this.oi(e.mapValue,t):(this.ai(e.mapValue,t),this.ii(t)):`arrayValue`in e?(this.ui(e.arrayValue,t),this.ii(t)):j(19022,{ci:e})}ri(e,t){this.ei(t,25),this.li(e,t)}li(e,t){t.ni(e)}ai(e,t){let n=e.fields||{};this.ei(t,55);for(let e of Object.keys(n))this.ri(e,t),this.Zr(n[e],t)}oi(e,t){let n=e.fields||{};this.ei(t,53);let r=da,i=n[r].arrayValue?.values?.length||0;this.ei(t,15),t.ti(H(i)),this.ri(r,t),this.Zr(n[r],t)}ui(e,t){let n=e.values||[];this.ei(t,50);for(let e of n)this.Zr(e,t)}_i(e,t){this.ei(t,37),R.fromName(e).path.forEach((e=>{this.ei(t,60),this.li(e,t)}))}ei(e,t){e.ti(t)}ii(e){e.ti(2)}};Qf.Ei=new Qf;var $f=class{constructor(){this.Hi=new ep}addToCollectionParentIndex(e,t){return this.Hi.add(t),B.resolve()}getCollectionParents(e,t){return B.resolve(this.Hi.getEntries(t))}addFieldIndex(e,t){return B.resolve()}deleteFieldIndex(e,t){return B.resolve()}deleteAllFieldIndexes(e){return B.resolve()}createTargetIndexes(e,t){return B.resolve()}getDocumentsMatchingTarget(e,t){return B.resolve(null)}getIndexType(e,t){return B.resolve(0)}getFieldIndexes(e,t){return B.resolve([])}getNextCollectionGroupToUpdate(e){return B.resolve(null)}getMinOffset(e,t){return B.resolve(yi.min())}getMinOffsetFromCollectionGroup(e,t){return B.resolve(yi.min())}updateCollectionGroup(e,t,n){return B.resolve()}updateIndexEntries(e,t){return B.resolve()}},ep=class{constructor(){this.index={}}add(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new Ri(L.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}has(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}getEntries(e){return(this.index[e]||new Ri(L.comparator)).toArray()}},tp=class e{constructor(e){this.Ds=e}next(){return this.Ds+=2,this.Ds}static xs(){return new e(0)}static Cs(){return new e(-1)}};function np(e,t){let n=t;for(let t of e.stages)n=ap({serializer:e.serializer,serverTimestampBehavior:e.listenOptions?.serverTimestampBehavior},t,n);return n}function rp(e,t){return np(e,[t]).length>0}function ip(e,t){return zf(e)?rp(e,t):ps(e,t)}function ap(e,t,n){if(t instanceof Mu)return function(e,t,n){return n.filter((e=>e.isFoundDocument()&&`/${e.key.getCollectionPath().canonicalString()}`===t.Vr))}(0,t,n);if(t instanceof Iu)return function(e,t,n){return n.filter((n=>{let r=Xu(J(t.condition).evaluate(e,n));return r!==void 0&&ga(r,pa)}))}(e,t,n);if(t instanceof Nu)return function(e,t,n){return n.filter((e=>e.isFoundDocument()&&e.key.getCollectionPath().lastSegment()===t.collectionId))}(0,t,n);if(t instanceof Pu)return function(e,t,n){return n.filter((e=>e.isFoundDocument()))}(0,0,n);if(t instanceof Fu)return function(e,t,n){return n.filter((e=>e.isFoundDocument()&&t.mr.has(e.key.path.toStringWithLeadingSlash())))}(0,t,n);if(t instanceof Lu)return function(e,t,n){return n.slice(0,t.limit)}(0,t,n);if(t instanceof Bu)return function(e,t,n){let r=t.orderings.map((e=>({ks:J(e.expr),direction:e.direction})));return[...n].sort(((t,n)=>{for(let{ks:i,direction:a}of r){let r=Xu(i.evaluate(e,t)),o=Xu(i.evaluate(e,n)),s=va(r??fa,o??fa);if(s!==0)return a===`ascending`?s:-s}return 0}))}(e,t,n);throw Error(`Unknown stage: ${t._name}`)}function op(e){let t=function(e){for(let t=e.stages.length-1;t>=0;t--){let n=e.stages[t];if(n instanceof Bu)return n.orderings}throw Error(`Pipeline must contain at least one Sort stage`)}(e);return(n,r)=>{for(let i of t){let t=Xu(J(i.expr).evaluate({serializer:e.serializer},n)),a=Xu(J(i.expr).evaluate({serializer:e.serializer},r)),o=va(t||fa,a||fa);if(o!==0)return i.direction===`ascending`?o:-o}return 0}}function sp(e){for(let t=e.stages.length-1;t>=0;t--){let n=e.stages[t];if(n instanceof Lu)return{limit:n.limit}}}var cp=class{constructor(){this.changes=new bs((e=>e.toString()),((e,t)=>e.isEqual(t))),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,Wo.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let n=this.changes.get(t);return n===void 0?this.getFromCache(e,t):B.resolve(n)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}},lp=class{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}},up=class{constructor(e,t,n,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=r}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next((r=>(n=r,this.remoteDocumentCache.getEntry(e,t)))).next((e=>(n!==null&&uo(n.mutation,e,Bi.empty(),mi.now()),e)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.getLocalViewOfDocuments(e,t,W()).next((()=>t))))}getLocalViewOfDocuments(e,t,n=W()){let r=Es();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,n).next((e=>{let t=ws();return e.forEach(((e,n)=>{t=t.insert(e,n.overlayedDocument)})),t}))))}getOverlayedDocuments(e,t){let n=Es();return this.populateOverlays(e,n,t).next((()=>this.computeViews(e,t,n,W())))}populateOverlays(e,t,n){let r=[];return n.forEach((e=>{t.has(e)||r.push(e)})),this.documentOverlayCache.getOverlays(e,r).next((e=>{e.forEach(((e,n)=>{t.set(e,n)}))}))}computeViews(e,t,n,r){let i=Ss(),a=Os(),o=function(){return Os()}();return t.forEach(((e,t)=>{let o=n.get(t.key);r.has(t.key)&&(o===void 0||o.mutation instanceof ho)?i=i.insert(t.key,t):o===void 0?a.set(t.key,Bi.empty()):(a.set(t.key,o.mutation.getFieldMask()),uo(o.mutation,t,o.mutation.getFieldMask(),mi.now()))})),this.recalculateAndSaveOverlays(e,i).next((e=>(e.forEach(((e,t)=>a.set(e,t))),t.forEach(((e,t)=>o.set(e,new lp(t,a.get(e)??null)))),o)))}recalculateAndSaveOverlays(e,t){let n=Os(),r=new V(((e,t)=>e-t)),i=W();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((e=>{for(let i of e)i.keys().forEach((e=>{let a=t.get(e);if(a===null)return;let o=n.get(e)||Bi.empty();o=i.applyToLocalView(a,o),n.set(e,o);let s=(r.get(i.batchId)||W()).add(e);r=r.insert(i.batchId,s)}))})).next((()=>{let a=[],o=r.getReverseIterator();for(;o.hasNext();){let r=o.getNext(),s=r.key,c=r.value,l=Ds();c.forEach((e=>{if(!i.has(e)){let r=co(t.get(e),n.get(e));r!==null&&l.set(e,r),i=i.add(e)}})),a.push(this.documentOverlayCache.saveOverlays(e,s,l))}return B.waitFor(a)})).next((()=>n))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.recalculateAndSaveOverlays(e,t)))}getDocumentsMatchingQuery(e,t,n,r){return zf(t)?this.getDocumentsMatchingPipeline(e,t,n,r):ts(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):ns(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,r):this.getDocumentsMatchingCollectionQuery(e,t,n,r)}getNextDocuments(e,t,n,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next((i=>{let a=r-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-i.size):B.resolve(Es()),o=hi,s=i;return a.next((t=>B.forEach(t,((t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),i.get(t)?B.resolve():this.remoteDocumentCache.getEntry(e,t).next((e=>{s=s.insert(t,e)}))))).next((()=>this.populateOverlays(e,t,i))).next((()=>this.computeViews(e,s,t,W()))).next((e=>({batchId:o,changes:Ts(e)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new R(t)).next((e=>{let t=ws();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t}))}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){let i=t.collectionGroup,a=ws();return this.indexManager.getCollectionParents(e,i).next((o=>B.forEach(o,(o=>{let s=function(e,t){return new Zo(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,o.child(i));return this.getDocumentsMatchingCollectionQuery(e,s,n,r).next((e=>{e.forEach(((e,t)=>{a=a.insert(e,t)}))}))})).next((()=>a))))}getDocumentsMatchingCollectionQuery(e,t,n,r){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next((a=>(i=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,i,r)))).next((e=>this.retrieveMatchingLocalDocuments(i,e,(e=>ps(t,e)))))}getDocumentsMatchingPipeline(e,t,n,r){if(Wu(t)===`collection_group`){let i=Ku(t),a=ws();return this.indexManager.getCollectionParents(e,i).next((o=>B.forEach(o,(o=>{let s=function(e,t){let n=e.stages.map((e=>e instanceof Nu?new Mu(t.canonicalString(),{}):e));return new Uu(e.serializer,n)}(t,o.child(i));return this.getDocumentsMatchingPipeline(e,s,n,r).next((e=>{e.forEach(((e,t)=>{a=a.insert(e,t)}))}))})).next((()=>a))))}{let i;return this.getOverlaysForPipeline(e,t,n.largestBatchId).next((a=>{switch(i=a,Wu(t)){case`collection`:return this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,i,r);case`documents`:let a=W();for(let e of Ju(t))a=a.add(R.fromPath(e));return this.remoteDocumentCache.getEntries(e,a);case`database`:return this.remoteDocumentCache.getAllEntries(e);default:throw new F(`invalid-argument`,`Invalid pipeline source to execute offline: ${Lf(t)}`)}})).next((e=>this.retrieveMatchingLocalDocuments(i,e,(e=>rp(t,e)))))}}retrieveMatchingLocalDocuments(e,t,n){e.forEach(((e,n)=>{let r=n.getKey();t.get(r)===null&&(t=t.insert(r,Wo.newInvalidDocument(r)))}));let r=ws();return t.forEach(((t,i)=>{let a=e.get(t);a!==void 0&&uo(a.mutation,i,Bi.empty(),mi.now()),n(i)&&(r=r.insert(t,i))})),r}getOverlaysForPipeline(e,t,n){switch(Wu(t)){case`collection`:return this.documentOverlayCache.getOverlaysForCollection(e,L.fromString(Gu(t)),n);case`collection_group`:throw new F(`invalid-argument`,`Unexpected collection group pipeline: ${Lf(t)}`);case`documents`:return this.documentOverlayCache.getOverlays(e,Ju(t).map((e=>R.fromPath(e))));case`database`:return this.documentOverlayCache.getAllOverlays(e,n);default:throw new F(`invalid-argument`,`Failed to get overlays for pipeline: ${Lf(t)}`)}}},dp=class{constructor(e){this.serializer=e,this.Hs=new Map,this.Js=new Map}getBundleMetadata(e,t){return B.resolve(this.Hs.get(t))}saveBundleMetadata(e,t){return this.Hs.set(t.id,function(e){return{id:e.id,version:e.version,createTime:ac(e.createTime)}}(t)),B.resolve()}getNamedQuery(e,t){return B.resolve(this.Js.get(t))}saveNamedQuery(e,t){return this.Js.set(t.name,function(e){return{name:e.name,query:Zf(e.bundledQuery),readTime:ac(e.readTime)}}(t)),B.resolve()}},fp=class{constructor(){this.overlays=new V(R.comparator),this.Ys=new Map}getOverlay(e,t){return B.resolve(this.overlays.get(t))}getOverlays(e,t){let n=Es();return B.forEach(t,(t=>this.getOverlay(e,t).next((e=>{e!==null&&n.set(t,e)})))).next((()=>n))}getAllOverlays(e,t){let n=Es();return this.overlays.forEach(((e,r)=>{r.largestBatchId>t&&n.set(e,r)})),B.resolve(n)}saveOverlays(e,t,n){return n.forEach(((n,r)=>{this.Hr(e,t,r)})),B.resolve()}removeOverlaysForBatchId(e,t,n){let r=this.Ys.get(n);return r!==void 0&&(r.forEach((e=>this.overlays=this.overlays.remove(e))),this.Ys.delete(n)),B.resolve()}getOverlaysForCollection(e,t,n){let r=Es(),i=t.length+1,a=new R(t.child(``)),o=this.overlays.getIteratorFrom(a);for(;o.hasNext();){let e=o.getNext().value,a=e.getKey();if(!t.isPrefixOf(a.path))break;a.path.length===i&&e.largestBatchId>n&&r.set(e.getKey(),e)}return B.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new V(((e,t)=>e-t)),a=this.overlays.getIterator();for(;a.hasNext();){let e=a.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=i.get(e.largestBatchId);t===null&&(t=Es(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let o=Es(),s=i.getIterator();for(;s.hasNext()&&(s.getNext().value.forEach(((e,t)=>o.set(e,t))),!(o.size()>=r)););return B.resolve(o)}Hr(e,t,n){let r=this.overlays.get(n.key);if(r!==null){let e=this.Ys.get(r.largestBatchId).delete(n.key);this.Ys.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new Jf(t,n));let i=this.Ys.get(t);i===void 0&&(i=W(),this.Ys.set(t,i)),this.Ys.set(t,i.add(n.key))}},pp=class{constructor(){this.sessionToken=Ki.EMPTY_BYTE_STRING}getSessionToken(e){return B.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,B.resolve()}},mp=class{constructor(){this.Zs=new Ri(hp.Xs),this.e_=new Ri(hp.t_)}isEmpty(){return this.Zs.isEmpty()}addReference(e,t){let n=new hp(e,t);this.Zs=this.Zs.add(n),this.e_=this.e_.add(n)}n_(e,t){e.forEach((e=>this.addReference(e,t)))}removeReference(e,t){this.r_(new hp(e,t))}i_(e,t){e.forEach((e=>this.removeReference(e,t)))}s_(e){let t=new R(new L([])),n=new hp(t,e),r=new hp(t,e+1),i=[];return this.e_.forEachInRange([n,r],(e=>{this.r_(e),i.push(e.key)})),i}__(){this.Zs.forEach((e=>this.r_(e)))}r_(e){this.Zs=this.Zs.delete(e),this.e_=this.e_.delete(e)}o_(e){let t=new R(new L([])),n=new hp(t,e),r=new hp(t,e+1),i=W();return this.e_.forEachInRange([n,r],(e=>{i=i.add(e.key)})),i}containsKey(e){let t=new hp(e,0),n=this.Zs.firstAfterOrEqual(t);return n!==null&&e.isEqual(n.key)}},hp=class{constructor(e,t){this.key=e,this.a_=t}static Xs(e,t){return R.comparator(e.key,t.key)||I(e.a_,t.a_)}static t_(e,t){return I(e.a_,t.a_)||R.comparator(e.key,t.key)}},gp=class{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.gs=1,this.u_=new Ri(hp.Xs)}checkEmpty(e){return B.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,n,r){let i=this.gs;this.gs++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let a=new Kf(i,t,n,r);this.mutationQueue.push(a);for(let t of r)this.u_=this.u_.add(new hp(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return B.resolve(a)}lookupMutationBatch(e,t){return B.resolve(this.c_(t))}getNextMutationBatchAfterBatchId(e,t){let n=t+1,r=this.l_(n),i=r<0?0:r;return B.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return B.resolve(this.mutationQueue.length===0?Di:this.gs-1)}getAllMutationBatches(e){return B.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let n=new hp(t,0),r=new hp(t,1/0),i=[];return this.u_.forEachInRange([n,r],(e=>{let t=this.c_(e.a_);i.push(t)})),B.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new Ri(I);return t.forEach((e=>{let t=new hp(e,0),r=new hp(e,1/0);this.u_.forEachInRange([t,r],(e=>{n=n.add(e.a_)}))})),B.resolve(this.E_(n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=n;R.isDocumentKey(i)||(i=i.child(``));let a=new hp(new R(i),0),o=new Ri(I);return this.u_.forEachWhile((e=>{let t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.a_)),!0)}),a),B.resolve(this.E_(o))}E_(e){let t=[];return e.forEach((e=>{let n=this.c_(e);n!==null&&t.push(n)})),t}removeMutationBatch(e,t){M(this.h_(t.batchId,`removed`)===0,55003),this.mutationQueue.shift();let n=this.u_;return B.forEach(t.mutations,(r=>{let i=new hp(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)})).next((()=>{this.u_=n}))}bs(e){}containsKey(e,t){let n=new hp(t,0),r=this.u_.firstAfterOrEqual(n);return B.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,B.resolve()}h_(e,t){return this.l_(e)}l_(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}c_(e){let t=this.l_(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}},_p=class{constructor(e){this.T_=e,this.docs=function(){return new V(R.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let n=t.key,r=this.docs.get(n),i=r?r.size:0,a=this.T_(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let n=this.docs.get(t);return B.resolve(n?n.document.mutableCopy():Wo.newInvalidDocument(t))}getEntries(e,t){let n=Ss();return t.forEach((e=>{let t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():Wo.newInvalidDocument(e))})),B.resolve(n)}getAllEntries(e){let t=Ss();return this.docs.forEach(((e,n)=>{t=t.insert(e,n.document)})),B.resolve(t)}getDocumentsMatchingQuery(e,t,n,r){let i,a;zf(t)?(i=L.fromString(Gu(t)),a=e=>rp(t,e)):(i=t.path,a=e=>ps(t,e));let o=Ss(),s=new R(i.child(`__id-9223372036854775808__`)),c=this.docs.getIteratorFrom(s);for(;c.hasNext();){let{key:e,value:{document:t}}=c.getNext();if(!i.isPrefixOf(e.path))break;e.path.length>i.length+1||bi(vi(t),n)<=0||(r.has(t.key)||a(t))&&(o=o.insert(t.key,t.mutableCopy()))}return B.resolve(o)}getAllFromCollectionGroup(e,t,n,r){j(9500)}P_(e,t){return B.forEach(this.docs,(e=>t(e)))}newChangeBuffer(e){return new vp(this)}getSize(e){return B.resolve(this.size)}},vp=class extends cp{constructor(e){super(),this.zs=e}applyChanges(e){let t=[];return this.changes.forEach(((n,r)=>{r.isValidDocument()?t.push(this.zs.addEntry(e,r)):this.zs.removeEntry(n)})),B.waitFor(t)}getFromCache(e,t){return this.zs.getEntry(e,t)}getAllFromCache(e,t){return this.zs.getEntries(e,t)}},yp=class{constructor(e){this.persistence=e,this.R_=new bs((e=>Uf(e)),Wf),this.lastRemoteSnapshotVersion=z.min(),this.highestTargetId=0,this.I_=0,this.A_=new mp,this.targetCount=0,this.V_=tp.xs()}forEachTarget(e,t){return this.R_.forEach(((e,n)=>t(n))),B.resolve()}getLastRemoteSnapshotVersion(e){return B.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return B.resolve(this.I_)}allocateTargetId(e){return this.highestTargetId=this.V_.next(),B.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.I_&&(this.I_=t),B.resolve()}Ms(e){this.R_.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.V_=new tp(t),this.highestTargetId=t),e.sequenceNumber>this.I_&&(this.I_=e.sequenceNumber)}addTargetData(e,t){return this.Ms(t),this.targetCount+=1,B.resolve()}updateTargetData(e,t){return this.Ms(t),B.resolve()}removeTargetData(e,t){return this.R_.delete(t.target),this.A_.s_(t.targetId),--this.targetCount,B.resolve()}removeTargets(e,t,n){let r=0,i=[];return this.R_.forEach(((a,o)=>{o.sequenceNumber<=t&&n.get(o.targetId)===null&&(this.R_.delete(a),i.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)})),B.waitFor(i).next((()=>r))}getTargetCount(e){return B.resolve(this.targetCount)}getTargetData(e,t){let n=this.R_.get(t)||null;return B.resolve(n)}addMatchingKeys(e,t,n){return this.A_.n_(t,n),B.resolve()}removeMatchingKeys(e,t,n){this.A_.i_(t,n);let r=this.persistence.referenceDelegate,i=[];return r&&t.forEach((t=>{i.push(r.markPotentiallyOrphaned(e,t))})),B.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.A_.s_(t),B.resolve()}getMatchingKeysForTargetId(e,t){let n=this.A_.o_(t);return B.resolve(n)}containsKey(e,t){return B.resolve(this.A_.containsKey(t))}},bp=class{constructor(e,t){this.d_={},this.overlays={},this.f_=new Ei(0),this.m_=!1,this.m_=!0,this.p_=new pp,this.referenceDelegate=e(this),this.g_=new yp(this),this.indexManager=new $f,this.remoteDocumentCache=function(e){return new _p(e)}((e=>this.referenceDelegate.y_(e))),this.serializer=new Xf(t),this.w_=new dp(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.m_=!1,Promise.resolve()}get started(){return this.m_}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new fp,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.d_[e.toKey()];return n||(n=new gp(t,this.referenceDelegate),this.d_[e.toKey()]=n),n}getGlobalsCache(){return this.p_}getTargetCache(){return this.g_}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.w_}runTransaction(e,t,n){A(`MemoryPersistence`,`Starting transaction:`,e);let r=new xp(this.f_.next());return this.referenceDelegate.b_(),n(r).next((e=>this.referenceDelegate.v_(r).next((()=>e)))).toPromise().then((e=>(r.raiseOnCommittedEvent(),e)))}S_(e,t){return B.or(Object.values(this.d_).map((n=>()=>n.containsKey(e,t))))}},xp=class extends Si{constructor(e){super(),this.currentSequenceNumber=e}},Sp=class e{constructor(e){this.persistence=e,this.D_=new mp,this.x_=null}static C_(t){return new e(t)}get F_(){if(this.x_)return this.x_;throw j(60996)}addReference(e,t,n){return this.D_.addReference(n,t),this.F_.delete(n.toString()),B.resolve()}removeReference(e,t,n){return this.D_.removeReference(n,t),this.F_.add(n.toString()),B.resolve()}markPotentiallyOrphaned(e,t){return this.F_.add(t.toString()),B.resolve()}removeTarget(e,t){this.D_.s_(t.targetId).forEach((e=>this.F_.add(e.toString())));let n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next((e=>{e.forEach((e=>this.F_.add(e.toString())))})).next((()=>n.removeTargetData(e,t)))}b_(){this.x_=new Set}v_(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return B.forEach(this.F_,(n=>{let r=R.fromPath(n);return this.O_(e,r).next((e=>{e||t.removeEntry(r,z.min())}))})).next((()=>(this.x_=null,t.apply(e))))}updateLimboDocument(e,t){return this.O_(e,t).next((e=>{e?this.F_.delete(t.toString()):this.F_.add(t.toString())}))}y_(e){return 0}O_(e,t){return B.or([()=>B.resolve(this.D_.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.S_(e,t)])}},Cp=class e{constructor(e,t){this.persistence=e,this.M_=new bs((e=>Ni(e.path)),((e,t)=>e.isEqual(t))),this.garbageCollector=Cl(this,t)}static C_(t,n){return new e(t,n)}b_(){}v_(e){return B.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}lr(e){let t=this.Ls(e);return this.persistence.getTargetCache().getTargetCount(e).next((e=>t.next((t=>e+t))))}Ls(e){let t=0;return this.Er(e,(e=>{t++})).next((()=>t))}Er(e,t){return B.forEach(this.M_,((n,r)=>this.Us(e,n,r).next((e=>e?B.resolve():t(r)))))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0,r=this.persistence.getRemoteDocumentCache(),i=r.newChangeBuffer();return r.P_(e,(r=>this.Us(e,r,t).next((e=>{e||(n++,i.removeEntry(r,z.min()))})))).next((()=>i.apply(e))).next((()=>n))}markPotentiallyOrphaned(e,t){return this.M_.set(t,e.currentSequenceNumber),B.resolve()}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.M_.set(n,e.currentSequenceNumber),B.resolve()}removeReference(e,t,n){return this.M_.set(n,e.currentSequenceNumber),B.resolve()}updateLimboDocument(e,t){return this.M_.set(t,e.currentSequenceNumber),B.resolve()}y_(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Ca(e.data.value)),t}Us(e,t,n){return B.or([()=>this.persistence.S_(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.M_.get(t);return B.resolve(e!==void 0&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}},wp=class e{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.wo=n,this.bo=r}static vo(t,n){let r=W(),i=W();for(let e of n.docChanges)switch(e.type){case 0:r=r.add(e.doc.key);break;case 1:i=i.add(e.doc.key)}return new e(t,n.fromCache,r,i)}};function Tp(e,t){return R.comparator(e.key,t.key)}var Ep=class{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}},Dp=class{constructor(){this.So=!1,this.Do=!1,this.xo=100,this.Co=function(){return ue()?8:wi(re())>0?6:4}()}initialize(e,t){this.Fo=e,this.indexManager=t,this.So=!0}getDocumentsMatchingQuery(e,t,n,r){let i={result:null};return this.Oo(e,t).next((e=>{i.result=e})).next((()=>{if(!i.result)return this.Mo(e,t,r,n).next((e=>{i.result=e}))})).next((()=>{if(i.result)return;let n=new Ep;return this.No(e,t,n).next((r=>{if(i.result=r,this.Do)return this.Lo(e,t,n,r.size)}))})).next((()=>i.result))}Lo(e,t,n,r){return zf(t)?B.resolve():n.documentReadCount<this.xo?(jr()<=v.DEBUG&&A(`QueryEngine`,`SDK will not create cache indexes for query:`,fs(t),`since it only creates cache indexes for collection contains`,`more than or equal to`,this.xo,`documents`),B.resolve()):(jr()<=v.DEBUG&&A(`QueryEngine`,`Query:`,fs(t),`scans`,n.documentReadCount,`local documents and returns`,r,`documents as results.`),n.documentReadCount>this.Co*r?(jr()<=v.DEBUG&&A(`QueryEngine`,`The SDK decides to create cache indexes for query:`,fs(t),`as using cache indexes may help improve performance.`),this.indexManager.createTargetIndexes(e,is(t))):B.resolve())}Oo(e,t){if(zf(t))return B.resolve(null);let n=t;if(es(n))return B.resolve(null);let r=is(n);return this.indexManager.getIndexType(e,r).next((t=>t===0?null:(n.limit!==null&&t===1&&(n=ls(n,null,`F`),r=is(n)),this.indexManager.getDocumentsMatchingTarget(e,r).next((t=>{let i=W(...t);return this.Fo.getDocuments(e,i).next((t=>this.indexManager.getMinOffset(e,r).next((r=>{let a=this.Bo(n,t);return this.Uo(n,a,i,r.readTime)?this.Oo(e,ls(n,null,`F`)):this.ko(e,a,n,r)}))))})))))}Mo(e,t,n,r){return(zf(t)?function(e){for(let t of e.stages){if(t instanceof Lu||t instanceof Ru)return!1;if(t instanceof Iu){if(t.condition instanceof bu&&t.condition._expr.name===`exists`&&t.condition._expr.params[0]instanceof pu&&t.condition._expr.params[0].fieldName===Qr)continue;return!1}}return!0}(t):es(t))||r.isEqual(z.min())?B.resolve(null):this.Fo.getDocuments(e,n).next((i=>{let a=this.Bo(t,i);return this.Uo(t,a,n,r)?B.resolve(null):(jr()<=v.DEBUG&&A(`QueryEngine`,`Re-using previous result from %s to execute query: %s`,r.toString(),Bf(t)),this.ko(e,a,t,_i(r,hi)).next((e=>e)))}))}Bo(e,t){let n,r;return zf(e)?(n=new Ri(Tp),r=t=>rp(e,t)):(n=new Ri(ms(e)),r=t=>ps(e,t)),t.forEach(((e,t)=>{r(t)&&(n=n.add(t))})),n}Uo(e,t,n,r){if(zf(e))return function(e){return e.stages.some((e=>e instanceof Lu||e instanceof Ru))}(e);if(e.limit===null)return!1;if(n.size!==t.size)return!0;let i=e.limitType===`F`?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}No(e,t,n){return jr()<=v.DEBUG&&A(`QueryEngine`,`Using full collection scan to execute query:`,Bf(t)),this.Fo.getDocumentsMatchingQuery(e,t,yi.min(),n)}ko(e,t,n,r){return this.Fo.getDocumentsMatchingQuery(e,n,r).next((e=>(t.forEach((t=>{e=e.insert(t.key,t)})),e)))}},Op=`LocalStore`,kp=3e8,Ap=class{constructor(e,t,n,r){this.persistence=e,this.qo=t,this.serializer=r,this.$o=new V(I),this.Ko=new bs((e=>Uf(e)),Wf),this.Wo=new Map,this.Qo=e.getRemoteDocumentCache(),this.g_=e.getTargetCache(),this.w_=e.getBundleCache(),this.Go(n)}Go(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new up(this.Qo,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Qo.setIndexManager(this.indexManager),this.qo.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction(`Collect garbage`,`readwrite-primary`,(t=>e.collect(t,this.$o)))}};function jp(e,t,n,r){return new Ap(e,t,n,r)}async function Mp(e,t){let n=N(e);return await n.persistence.runTransaction(`Handle user change`,`readonly`,(e=>{let r;return n.mutationQueue.getAllMutationBatches(e).next((i=>(r=i,n.Go(t),n.mutationQueue.getAllMutationBatches(e)))).next((t=>{let i=[],a=[],o=W();for(let e of r){i.push(e.batchId);for(let t of e.mutations)o=o.add(t.key)}for(let e of t){a.push(e.batchId);for(let t of e.mutations)o=o.add(t.key)}return n.localDocuments.getDocuments(e,o).next((e=>({zo:e,removedBatchIds:i,addedBatchIds:a})))}))}))}function Np(e,t){let n=N(e);return n.persistence.runTransaction(`Acknowledge batch`,`readwrite-primary`,(e=>{let r=t.batch.keys(),i=n.Qo.newChangeBuffer({trackRemovals:!0});return function(e,t,n,r){let i=n.batch,a=i.keys(),o=B.resolve();return a.forEach((e=>{o=o.next((()=>r.getEntry(t,e))).next((t=>{let a=n.docVersions.get(e);M(a!==null,48541),t.version.compareTo(a)<0&&(i.applyToRemoteDocument(t,n),t.isValidDocument()&&(t.setReadTime(n.commitVersion),r.addEntry(t)))}))})),o.next((()=>e.mutationQueue.removeMutationBatch(t,i)))}(n,e,t,i).next((()=>i.apply(e))).next((()=>n.mutationQueue.performConsistencyCheck(e))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=W();for(let n=0;n<e.mutationResults.length;++n)e.mutationResults[n].transformResults.length>0&&(t=t.add(e.batch.mutations[n].key));return t}(t)))).next((()=>n.localDocuments.getDocuments(e,r)))}))}function Pp(e){let t=N(e);return t.persistence.runTransaction(`Get last remote snapshot version`,`readonly`,(e=>t.g_.getLastRemoteSnapshotVersion(e)))}function Fp(e,t){let n=N(e),r=t.snapshotVersion,i=n.$o;return n.persistence.runTransaction(`Apply remote event`,`readwrite-primary`,(e=>{let a=n.Qo.newChangeBuffer({trackRemovals:!0});i=n.$o;let o=[];t.targetChanges.forEach(((a,s)=>{let c=i.get(s);if(!c)return;o.push(n.g_.removeMatchingKeys(e,a.removedDocuments,s).next((()=>n.g_.addMatchingKeys(e,a.addedDocuments,s))));let l=c.withSequenceNumber(e.currentSequenceNumber);t.targetMismatches.get(s)===null?a.resumeToken.approximateByteSize()>0&&(l=l.withResumeToken(a.resumeToken,r)):l=l.withResumeToken(Ki.EMPTY_BYTE_STRING,z.min()).withLastLimboFreeSnapshotVersion(z.min()),i=i.insert(s,l),function(e,t,n){return e.resumeToken.approximateByteSize()===0||t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=kp?!0:n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(c,l,a)&&o.push(n.g_.updateTargetData(e,l))}));let s=Ss(),c=W();if(t.documentUpdates.forEach((r=>{t.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))})),o.push(Ip(e,a,t.documentUpdates).next((e=>{s=e.jo,c=e.Ho}))),!r.isEqual(z.min())){let t=n.g_.getLastRemoteSnapshotVersion(e).next((t=>n.g_.setTargetsMetadata(e,e.currentSequenceNumber,r)));o.push(t)}return B.waitFor(o).next((()=>a.apply(e))).next((()=>n.localDocuments.getLocalViewOfDocuments(e,s,c))).next((()=>s))})).then((e=>(n.$o=i,e)))}function Ip(e,t,n){let r=W(),i=W();return n.forEach((e=>r=r.add(e))),t.getEntries(e,r).next((e=>{let r=Ss();return n.forEach(((n,a)=>{let o=e.get(n);a.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),a.isNoDocument()&&a.version.isEqual(z.min())?(t.removeEntry(n,a.readTime),r=r.insert(n,a)):!o.isValidDocument()||a.version.compareTo(o.version)>0||a.version.compareTo(o.version)===0&&o.hasPendingWrites?(t.addEntry(a),r=r.insert(n,a)):A(Op,`Ignoring outdated watch update for `,n,`. Current version:`,o.version,` Watch version:`,a.version)})),{jo:r,Ho:i}}))}function Lp(e,t){let n=N(e);return n.persistence.runTransaction(`Get next mutation batch`,`readonly`,(e=>(t===void 0&&(t=Di),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t))))}function Rp(e,t){let n=N(e);return n.persistence.runTransaction(`Allocate target`,`readwrite`,(e=>{let r;return n.g_.getTargetData(e,t).next((i=>i?(r=i,B.resolve(r)):n.g_.allocateTargetId(e).next((i=>(r=new Yf(t,i,`TargetPurposeListen`,e.currentSequenceNumber),n.g_.addTargetData(e,r).next((()=>r)))))))})).then((e=>{let r=n.$o.get(e.targetId);return(r===null||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.$o=n.$o.insert(e.targetId,e),n.Ko.set(t,e.targetId)),e}))}async function zp(e,t,n){let r=N(e),i=r.$o.get(t),a=n?`readwrite`:`readwrite-primary`;try{n||await r.persistence.runTransaction(`Release target`,a,(e=>r.persistence.referenceDelegate.removeTarget(e,i)))}catch(e){if(!Ti(e))throw e;A(Op,`Failed to update sequence numbers for target ${t}: ${e}`)}r.$o=r.$o.remove(t),r.Ko.delete(i.target)}function Bp(e,t,n){let r=N(e),i=z.min(),a=W();return r.persistence.runTransaction(`Execute query`,`readwrite`,(e=>function(e,t,n){let r=N(e),i=r.Ko.get(n);return i===void 0?r.g_.getTargetData(t,n):B.resolve(r.$o.get(i))}(r,e,zf(t)?t:is(t)).next((t=>{if(t)return i=t.lastLimboFreeSnapshotVersion,r.g_.getMatchingKeysForTargetId(e,t.targetId).next((e=>{a=e}))})).next((()=>r.qo.getDocumentsMatchingQuery(e,t,n?i:z.min(),n?a:W()))).next((e=>(Vp(r,e),{documents:e,Jo:a})))))}function Vp(e,t){t.forEach(((t,n)=>{let r=n.key.getCollectionGroup(),i=e.Wo.get(r)||z.min();n.readTime.compareTo(i)>0&&e.Wo.set(r,n.readTime)}))}var Hp=class{constructor(){this.activeTargetIds=Ms()}na(e){this.activeTargetIds=this.activeTargetIds.add(e)}ra(e){this.activeTargetIds=this.activeTargetIds.delete(e)}ta(){let e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}},Up=class{constructor(){this.Ua=new Hp,this.ka={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.Ua.na(e),this.ka[e]||`not-current`}updateQueryState(e,t,n){this.ka[e]=t}removeLocalQueryTarget(e){this.Ua.ra(e)}isLocalQueryTarget(e){return this.Ua.activeTargetIds.has(e)}clearQueryState(e){delete this.ka[e]}getAllActiveQueryTargets(){return this.Ua.activeTargetIds}isActiveQueryTarget(e){return this.Ua.activeTargetIds.has(e)}start(){return this.Ua=new Hp,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}};function Wp(){return typeof document<`u`?document:null}var Gp=class{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state=`Unknown`,this.qa=0,this.$a=null,this.Ka=!0}Wa(){this.qa===0&&(this.Qa(`Unknown`),this.$a=this.asyncQueue.enqueueAfterDelay(`online_state_timeout`,1e4,(()=>(this.$a=null,this.Ga(`Backend didn't respond within 10 seconds.`),this.Qa(`Offline`),Promise.resolve()))))}za(e){this.state===`Online`?this.Qa(`Unknown`):(this.qa++,this.qa>=1&&(this.ja(),this.Ga(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.Qa(`Offline`)))}set(e){this.ja(),this.qa=0,e===`Online`&&(this.Ka=!1),this.Qa(e)}Qa(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}Ga(e){let t=`Could not reach Cloud Firestore backend. ${e}\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.Ka?(Mr(t),this.Ka=!1):A(`OnlineStateTracker`,t)}ja(){this.$a!==null&&(this.$a.cancel(),this.$a=null)}},Kp=`RemoteStore`,qp=class{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Ha=[],this.Ja=new Map,this.Ya=new Map,this.Za=new Map,this.Xa=new tp(1e3),this.eu=new tp(1001),this.tu=new Set,this.nu=[],this.ru=i,this.ru.bt((e=>{n.enqueueAndForget((async()=>{rm(this)&&(A(Kp,`Restarting streams for network reachability change.`),await async function(e){let t=N(e);t.tu.add(4),await Yp(t),t.iu.set(`Unknown`),t.tu.delete(4),await Jp(t)}(this))}))})),this.iu=new Gp(n,r)}};async function Jp(e){if(rm(e))for(let t of e.nu)await t(!0)}async function Yp(e){for(let t of e.nu)await t(!1)}function Xp(e,t){return e.Ya.get(t)||void 0}function Zp(e,t){let n=N(e),r=Xp(n,t.targetId);if(r!==void 0&&n.Ja.has(r))return;let i=function(e,t){let n=Xp(e,t);n!==void 0&&e.Za.delete(n);let r=function(e,t){return t%2==0?e.Xa.next():e.eu.next()}(e,t);return e.Ya.set(t,r),e.Za.set(r,t),r}(n,t.targetId);A(Kp,`remoteStoreListen mapping SDK target ID to remote`,t.targetId,i);let a=new Yf(t.target,i,t.purpose,t.sequenceNumber,t.snapshotVersion,t.lastLimboFreeSnapshotVersion,t.resumeToken);n.Ja.set(i,a),nm(n)?tm(n):Sm(n).Fn()&&$p(n,a)}function Qp(e,t){let n=N(e),r=Sm(n),i=Xp(n,t);A(Kp,`remoteStoreUnlisten removing mapping of SDK target ID to remote`,t,i),n.Ja.delete(i),n.Ya.delete(t),n.Za.delete(i),r.Fn()&&em(n,i),n.Ja.size===0&&(r.Fn()?r.Nn():rm(n)&&n.iu.set(`Unknown`))}function $p(e,t){if(e.su.We(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(z.min())>0){let n=e.Za.get(t.targetId);if(n===void 0)return void A(Kp,`SDK target ID not found for remote ID: `+t.targetId);let r=e.remoteSyncer.getRemoteKeysForTarget(n).size;t=t.withExpectedCount(r)}Sm(e).jn(t)}function em(e,t){e.su.We(t),Sm(e).Hn(t)}function tm(e){e.su=new qs({getRemoteKeysForTarget:t=>{let n=e.Za.get(t);return n===void 0?W():e.remoteSyncer.getRemoteKeysForTarget(n)},dt:t=>e.Ja.get(t)||null,Tt:()=>e.datastore.serializer.databaseId}),Sm(e).start(),e.iu.Wa()}function nm(e){return rm(e)&&!Sm(e).Cn()&&e.Ja.size>0}function rm(e){return N(e).tu.size===0}function im(e){e.su=void 0}async function am(e){e.iu.set(`Online`)}async function om(e){e.Ja.forEach(((t,n)=>{$p(e,t)}))}async function sm(e,t){im(e),nm(e)?(e.iu.za(t),tm(e)):e.iu.set(`Unknown`)}async function cm(e,t,n){if(e.iu.set(`Online`),t instanceof Ws&&t.state===2&&t.cause)try{await async function(e,t){let n=t.cause;for(let r of t.targetIds){if(e.Ja.has(r)){let t=e.Za.get(r);t!==void 0&&(await e.remoteSyncer.rejectListen(t,n),e.Ya.delete(t),e.Za.delete(r)),e.Ja.delete(r)}e.su.removeTarget(r)}}(e,t)}catch(n){A(Kp,`Failed to remove targets %s: %s `,t.targetIds.join(`,`),n),await lm(e,n)}else if(t instanceof Hs?e.su.et(t):t instanceof Us?e.su.ot(t):e.su.rt(t),!n.isEqual(z.min()))try{let t=await Pp(e.localStore);n.compareTo(t)>=0&&await function(e,t){let n=e.su.Rt(t);n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){let i=e.Ja.get(r);i&&e.Ja.set(r,i.withResumeToken(n.resumeToken,t))}})),n.targetMismatches.forEach(((t,n)=>{let r=e.Ja.get(t);r&&(e.Ja.set(t,r.withResumeToken(Ki.EMPTY_BYTE_STRING,r.snapshotVersion)),em(e,t),$p(e,new Yf(r.target,t,n,r.sequenceNumber)))}));let r=function(e,t){let n=new Map;t.targetChanges.forEach(((t,r)=>{let i=e.Za.get(r);i!==void 0&&n.set(i,t)}));let r=new V(I);return t.targetMismatches.forEach(((t,n)=>{let i=e.Za.get(t);i!==void 0&&(r=r.insert(i,n))})),new Bs(t.snapshotVersion,n,r,t.documentUpdates,t.augmentedDocumentUpdates,t.resolvedLimboDocuments)}(e,n);return e.remoteSyncer.applyRemoteEvent(r)}(e,n)}catch(t){A(Kp,`Failed to raise snapshot:`,t),await lm(e,t)}}async function lm(e,t,n){if(!Ti(t))throw t;e.tu.add(1),await Yp(e),e.iu.set(`Offline`),n||=()=>Pp(e.localStore),e.asyncQueue.enqueueRetryable((async()=>{A(Kp,`Retrying IndexedDB access`),await n(),e.tu.delete(1),await Jp(e)}))}function um(e,t){return t().catch((n=>lm(e,n,t)))}async function dm(e){let t=N(e),n=Cm(t),r=t.Ha.length>0?t.Ha[t.Ha.length-1].batchId:Di;for(;fm(t);)try{let e=await Lp(t.localStore,r);if(e===null){t.Ha.length===0&&n.Nn();break}r=e.batchId,pm(t,e)}catch(e){await lm(t,e)}mm(t)&&hm(t)}function fm(e){return rm(e)&&e.Ha.length<10}function pm(e,t){e.Ha.push(t);let n=Cm(e);n.Fn()&&n.Jn&&n.Yn(t.mutations)}function mm(e){return rm(e)&&!Cm(e).Cn()&&e.Ha.length>0}function hm(e){Cm(e).start()}async function gm(e){Cm(e).er()}async function _m(e){let t=Cm(e);for(let n of e.Ha)t.Yn(n.mutations)}async function vm(e,t,n){let r=e.Ha.shift(),i=qf.from(r,t,n);await um(e,(()=>e.remoteSyncer.applySuccessfulWrite(i))),await dm(e)}async function ym(e,t){t&&Cm(e).Jn&&await async function(e,t){if(function(e){return vs(e)&&e!==P.ABORTED}(t.code)){let n=e.Ha.shift();Cm(e).Mn(),await um(e,(()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t))),await dm(e)}}(e,t),mm(e)&&hm(e)}async function bm(e,t){let n=N(e);n.asyncQueue.verifyOperationInProgress(),A(Kp,`RemoteStore received new credentials`);let r=rm(n);n.tu.add(3),await Yp(n),r&&n.iu.set(`Unknown`),await n.remoteSyncer.handleCredentialChange(t),n.tu.delete(3),await Jp(n)}async function xm(e,t){let n=N(e);t?(n.tu.delete(2),await Jp(n)):t||(n.tu.add(2),await Yp(n),n.iu.set(`Unknown`))}function Sm(e){return e._u||(e._u=function(e,t,n){let r=N(e);return r.nr(),new ol(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Qt:am.bind(null,e),zt:om.bind(null,e),Ht:sm.bind(null,e),zn:cm.bind(null,e)}),e.nu.push((async t=>{t?(e._u.Mn(),nm(e)?tm(e):e.iu.set(`Unknown`)):(await e._u.stop(),im(e))}))),e._u}function Cm(e){return e.ou||(e.ou=function(e,t,n){let r=N(e);return r.nr(),new sl(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Qt:()=>Promise.resolve(),zt:gm.bind(null,e),Ht:ym.bind(null,e),Zn:_m.bind(null,e),Xn:vm.bind(null,e)}),e.nu.push((async t=>{t?(e.ou.Mn(),await dm(e)):(await e.ou.stop(),e.Ha.length>0&&(A(Kp,`Stopping write stream with ${e.Ha.length} pending writes`),e.Ha=[]))}))),e.ou}var wm=class e{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new Ir,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((e=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(t,n,r,i,a){let o=new e(t,n,Date.now()+r,i,a);return o.start(r),o}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new F(P.CANCELLED,`Operation cancelled`+(e?`: `+e:``))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle===null?Promise.resolve():(this.clearTimeout(),this.op().then((e=>this.deferred.resolve(e))))))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}};function Tm(e,t){if(Mr(`AsyncQueue`,`${t}: ${e}`),Ti(e))return new F(P.UNAVAILABLE,`${t}: ${e}`);throw e}var Em=class e{static emptySet(t){return new e(t.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||R.comparator(t.key,n.key):(e,t)=>R.comparator(e.key,t.key),this.keyedMap=ws(),this.sortedSet=new V(this.comparator)}has(e){return this.keyedMap.get(e)!=null}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){let t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal(((t,n)=>(e(t),!1)))}add(e){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(t){if(!(t instanceof e)||this.size!==t.size)return!1;let n=this.sortedSet.getIterator(),r=t.sortedSet.getIterator();for(;n.hasNext();){let e=n.getNext().key,t=r.getNext().key;if(!e.isEqual(t))return!1}return!0}toString(){let e=[];return this.forEach((t=>{e.push(t.toString())})),e.length===0?`DocumentSet ()`:`DocumentSet (
13
30
  `+e.join(`
14
31
  `)+`
15
- )`}copy(t,n){let r=new e;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r}},Tl=class{constructor(){this.ga=new R(N.comparator)}track(e){let t=e.doc.key,n=this.ga.get(t);n?e.type!==0&&n.type===3?this.ga=this.ga.insert(t,e):e.type===3&&n.type!==1?this.ga=this.ga.insert(t,{type:n.type,doc:e.doc}):e.type===2&&n.type===2?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):e.type===2&&n.type===0?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):e.type===1&&n.type===0?this.ga=this.ga.remove(t):e.type===1&&n.type===2?this.ga=this.ga.insert(t,{type:1,doc:n.doc}):e.type===0&&n.type===1?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):E(63341,{Vt:e,pa:n}):this.ga=this.ga.insert(t,e)}ya(){let e=[];return this.ga.inorderTraversal(((t,n)=>{e.push(n)})),e}},El=class e{constructor(e,t,n,r,i,a,o,s,c){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=o,this.excludesMetadataChanges=s,this.hasCachedResults=c}static fromInitialDocuments(t,n,r,i,a){let o=[];return n.forEach((e=>{o.push({type:0,doc:e})})),new e(t,n,wl.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)&&ya(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}},Dl=class{constructor(){this.wa=void 0,this.Sa=[]}ba(){return this.Sa.some((e=>e.Da()))}},Ol=class{constructor(){this.queries=kl(),this.onlineState=`Unknown`,this.Ca=new Set}terminate(){(function(e,t){let n=O(e),r=n.queries;n.queries=kl(),r.forEach(((e,n)=>{for(let e of n.Sa)e.onError(t)}))})(this,new A(k.ABORTED,`Firestore shutting down`))}};function kl(){return new Ea((e=>ba(e)),ya)}async function Al(e,t){let n=O(e),r=3,i=t.query,a=n.queries.get(i);a?!a.ba()&&t.Da()&&(r=2):(a=new Dl,r=t.Da()?0:1);try{switch(r){case 0:a.wa=await n.onListen(i,!0);break;case 1:a.wa=await n.onListen(i,!1);break;case 2:await n.onFirstRemoteStoreListen(i)}}catch(e){let n=Cl(e,`Initialization of query '${xa(t.query)}' failed`);t.onError(n);return}n.queries.set(i,a),a.Sa.push(t),t.va(n.onlineState),a.wa&&t.Fa(a.wa)&&Pl(n)}async function jl(e,t){let n=O(e),r=t.query,i=3,a=n.queries.get(r);if(a){let e=a.Sa.indexOf(t);e>=0&&(a.Sa.splice(e,1),a.Sa.length===0?i=t.Da()?0:1:!a.ba()&&t.Da()&&(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 Ml(e,t){let n=O(e),r=!1;for(let e of t){let t=e.query,i=n.queries.get(t);if(i){for(let t of i.Sa)t.Fa(e)&&(r=!0);i.wa=e}}r&&Pl(n)}function Nl(e,t,n){let r=O(e),i=r.queries.get(t);if(i)for(let e of i.Sa)e.onError(n);r.queries.delete(t)}function Pl(e){e.Ca.forEach((e=>{e.next()}))}var Fl,Il;(Il=Fl||={}).Ma=`default`,Il.Cache=`cache`;var Ll=class{constructor(e,t,n){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState=`Unknown`,this.options=n||{}}Fa(e){if(!this.options.includeMetadataChanges){let t=[];for(let n of e.docChanges)n.type!==3&&t.push(n);e=new El(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){if(!e.fromCache||!this.Da())return!0;let n=t!==`Offline`;return(!this.options.qa||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||t===`Offline`)}Ba(e){if(e.docChanges.length>0)return!0;let t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}ka(e){e=El.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==Fl.Cache}},Rl=class{constructor(e){this.key=e}},zl=class{constructor(e){this.key=e}},Bl=class{constructor(e,t){this.query=e,this.Za=t,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=V(),this.mutatedKeys=V(),this.eu=wa(e),this.tu=new wl(this.eu)}get nu(){return this.Za}ru(e,t){let n=t?t.iu:new Tl,r=t?t.tu:this.tu,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=Sa(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.su(l,u)||(n.track({type:2,doc:u}),p=!0,(s&&this.eu(u,s)>0||c&&this.eu(u,c)<0)&&(o=!0)):!l&&u?(n.track({type:0,doc:u}),p=!0):l&&!u&&(n.track({type:1,doc:l}),p=!0,(s||c)&&(o=!0)),p&&(u?(a=a.add(u),i=f?i.add(e):i.delete(e)):(a=a.delete(e),i=i.delete(e)))})),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{tu:a,iu:n,bs:o,mutatedKeys:i}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){let i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;let a=e.iu.ya();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 E(20277,{Vt:e})}};return n(e)-n(t)}(e.type,t.type)||this.eu(e.doc,t.doc))),this.ou(n),r??=!1;let o=t&&!r?this._u():[],s=this.Ya.size===0&&this.current&&!r?1:0,c=s!==this.Xa;return this.Xa=s,a.length!==0||c?{snapshot:new El(this.query,e.tu,i,a,e.mutatedKeys,s===0,c,!1,!!n&&n.resumeToken.approximateByteSize()>0),au:o}:{au:o}}va(e){return this.current&&e===`Offline`?(this.current=!1,this.applyChanges({tu:this.tu,iu:new Tl,mutatedKeys:this.mutatedKeys,bs:!1},!1)):{au:[]}}uu(e){return!this.Za.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach((e=>this.Za=this.Za.add(e))),e.modifiedDocuments.forEach((e=>{})),e.removedDocuments.forEach((e=>this.Za=this.Za.delete(e))),this.current=e.current)}_u(){if(!this.current)return[];let e=this.Ya;this.Ya=V(),this.tu.forEach((e=>{this.uu(e.key)&&(this.Ya=this.Ya.add(e.key))}));let t=[];return e.forEach((e=>{this.Ya.has(e)||t.push(new zl(e))})),this.Ya.forEach((n=>{e.has(n)||t.push(new Rl(n))})),t}cu(e){this.Za=e.ks,this.Ya=V();let t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return El.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Xa===0,this.hasCachedResults)}},Vl=`SyncEngine`,Hl=class{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}},Ul=class{constructor(e){this.key=e,this.hu=!1}},Wl=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.Pu={},this.Tu=new Ea((e=>ba(e)),ya),this.Eu=new Map,this.Iu=new Set,this.Ru=new R(N.comparator),this.Au=new Map,this.Vu=new qs,this.du={},this.mu=new Map,this.fu=Ns.ar(),this.onlineState=`Unknown`,this.gu=void 0}get isPrimaryClient(){return!0===this.gu}};async function Gl(e,t,n=!0){let r=pu(e),i,a=r.Tu.get(t);return a?(r.sharedClientState.addLocalQueryTarget(a.targetId),i=a.view.lu()):i=await ql(r,t,n,!0),i}async function Kl(e,t){await ql(pu(e),t,!0,!1)}async function ql(e,t,n,r){let i=await hc(e.localStore,fa(t)),a=i.targetId,o=e.sharedClientState.addLocalQueryTarget(a,n),s;return r&&(s=await Jl(e,t,a,o===`current`,i.resumeToken)),e.isPrimaryClient&&n&&Yc(e.remoteStore,i),s}async function Jl(e,t,n,r,i){e.pu=(t,n,r)=>async function(e,t,n,r){let i=t.view.ru(n);i.bs&&(i=await _c(e.localStore,t.query,!1).then((({documents:e})=>t.view.ru(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 su(e,t.targetId,s.au),s.snapshot}(e,t,n,r);let a=await _c(e.localStore,t,!0),o=new Bl(t,a.ks),s=o.ru(a.documents),c=No.createSynthesizedTargetChangeForCurrentChange(n,r&&e.onlineState!==`Offline`,i),l=o.applyChanges(s,e.isPrimaryClient,c);su(e,n,l.au);let u=new Hl(t,n,o);return e.Tu.set(t,u),e.Eu.has(n)?e.Eu.get(n).push(t):e.Eu.set(n,[t]),l.snapshot}async function Yl(e,t,n){let r=O(e),i=r.Tu.get(t),a=r.Eu.get(i.targetId);if(a.length>1)return r.Eu.set(i.targetId,a.filter((e=>!ya(e,t)))),void r.Tu.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)||await gc(r.localStore,i.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(i.targetId),n&&Xc(r.remoteStore,i.targetId),au(r,i.targetId)})).catch(wr)):(au(r,i.targetId),await gc(r.localStore,i.targetId,!0))}async function Xl(e,t){let n=O(e),r=n.Tu.get(t),i=n.Eu.get(r.targetId);n.isPrimaryClient&&i.length===1&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),Xc(n.remoteStore,r.targetId))}async function Zl(e,t,n){let r=mu(e);try{let e=await function(e,t){let n=O(e),r=F.now(),i=t.reduce(((e,t)=>e.add(t.key)),V()),a,o;return n.persistence.runTransaction(`Locally write mutations`,`readwrite`,(e=>{let s=Oa(),c=V();return n.xs.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=co(e,a.get(e.key).overlayedDocument);t!=null&&o.push(new fo(e.key,t,ji(t.value.mapValue),no.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:ja(a)})))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.du[e.currentUser.toKey()];r||=new R(j),r=r.insert(t,n),e.du[e.currentUser.toKey()]=r}(r,e.batchId,n),await uu(r,e.changes),await ll(r.remoteStore)}catch(e){let t=Cl(e,`Failed to persist write`);n.reject(t)}}async function Ql(e,t){let n=O(e);try{let e=await fc(n.localStore,t);t.targetChanges.forEach(((e,t)=>{let r=n.Au.get(t);r&&(D(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1,22616),e.addedDocuments.size>0?r.hu=!0:e.modifiedDocuments.size>0?D(r.hu,14607):e.removedDocuments.size>0&&(D(r.hu,42227),r.hu=!1))})),await uu(n,e,t)}catch(e){await wr(e)}}function $l(e,t,n){let r=O(e);if(r.isPrimaryClient&&n===0||!r.isPrimaryClient&&n===1){let e=[];r.Tu.forEach(((n,r)=>{let i=r.view.va(t);i.snapshot&&e.push(i.snapshot)})),function(e,t){let n=O(e);n.onlineState=t;let r=!1;n.queries.forEach(((e,n)=>{for(let e of n.Sa)e.va(t)&&(r=!0)})),r&&Pl(n)}(r.eventManager,t),e.length&&r.Pu.H_(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function eu(e,t,n){let r=O(e);r.sharedClientState.updateQueryState(t,`rejected`,n);let i=r.Au.get(t),a=i&&i.key;if(a){let e=new R(N.comparator);e=e.insert(a,Mi.newNoDocument(a,I.min()));let n=V().add(a);await Ql(r,new Mo(I.min(),new Map,new R(j),e,n)),r.Ru=r.Ru.remove(a),r.Au.delete(t),lu(r)}else await gc(r.localStore,t,!1).then((()=>au(r,t,n))).catch(wr)}async function tu(e,t){let n=O(e),r=t.batch.batchId;try{let e=await uc(n.localStore,t);iu(n,r,null),ru(n,r),n.sharedClientState.updateMutationState(r,`acknowledged`),await uu(n,e)}catch(e){await wr(e)}}async function nu(e,t,n){let r=O(e);try{let e=await function(e,t){let n=O(e);return n.persistence.runTransaction(`Reject batch`,`readwrite-primary`,(e=>{let r;return n.mutationQueue.lookupMutationBatch(e,t).next((t=>(D(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);iu(r,t,n),ru(r,t),r.sharedClientState.updateMutationState(t,`rejected`,n),await uu(r,e)}catch(e){await wr(e)}}function ru(e,t){(e.mu.get(t)||[]).forEach((e=>{e.resolve()})),e.mu.delete(t)}function iu(e,t,n){let r=O(e),i=r.du[r.currentUser.toKey()];if(i){let e=i.get(t);e&&(n?e.reject(n):e.resolve(),i=i.remove(t)),r.du[r.currentUser.toKey()]=i}}function au(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(let r of e.Eu.get(t))e.Tu.delete(r),n&&e.Pu.yu(r,n);e.Eu.delete(t),e.isPrimaryClient&&e.Vu.Gr(t).forEach((t=>{e.Vu.containsKey(t)||ou(e,t)}))}function ou(e,t){e.Iu.delete(t.path.canonicalString());let n=e.Ru.get(t);n!==null&&(Xc(e.remoteStore,n),e.Ru=e.Ru.remove(t),e.Au.delete(n),lu(e))}function su(e,t,n){for(let r of n)r instanceof Rl?(e.Vu.addReference(r.key,t),cu(e,r)):r instanceof zl?(T(Vl,`Document no longer in limbo: `+r.key),e.Vu.removeReference(r.key,t),e.Vu.containsKey(r.key)||ou(e,r.key)):E(19791,{wu:r})}function cu(e,t){let n=t.key,r=n.path.canonicalString();e.Ru.get(n)||e.Iu.has(r)||(T(Vl,`New document in limbo: `+n),e.Iu.add(r),lu(e))}function lu(e){for(;e.Iu.size>0&&e.Ru.size<e.maxConcurrentLimboResolutions;){let t=e.Iu.values().next().value;e.Iu.delete(t);let n=new N(M.fromString(t)),r=e.fu.next();e.Au.set(r,new Ul(n)),e.Ru=e.Ru.insert(n,r),Yc(e.remoteStore,new ws(fa(sa(n.path)),r,`TargetPurposeLimboResolution`,Dr.ce))}}async function uu(e,t,n){let r=O(e),i=[],a=[],o=[];r.Tu.isEmpty()||(r.Tu.forEach(((e,s)=>{o.push(r.pu(s,t,n).then((e=>{if((e||n)&&r.isPrimaryClient){let t=e?!e.fromCache:n?.targetChanges.get(s.targetId)?.current;r.sharedClientState.updateQueryState(s.targetId,t?`current`:`not-current`)}if(e){i.push(e);let t=nc.Is(s.targetId,e);a.push(t)}})))})),await Promise.all(o),r.Pu.H_(i),await async function(e,t){let n=O(e);try{await n.persistence.runTransaction(`notifyLocalViewChanges`,`readwrite`,(e=>L.forEach(t,(t=>L.forEach(t.Ts,(r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=>L.forEach(t.Es,(r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!Er(e))throw e;T(ac,`Failed to update sequence numbers: `+e)}for(let e of t){let t=e.targetId;if(!e.fromCache){let e=n.vs.get(t),r=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(r);n.vs=n.vs.insert(t,i)}}}(r.localStore,a))}async function du(e,t){let n=O(e);if(!n.currentUser.isEqual(t)){T(Vl,`User change. New user:`,t.toKey());let e=await lc(n.localStore,t);n.currentUser=t,function(e,t){e.mu.forEach((e=>{e.forEach((e=>{e.reject(new A(k.CANCELLED,t))}))})),e.mu.clear()}(n,`'waitForPendingWrites' promise is rejected due to a user change.`),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await uu(n,e.Ns)}}function fu(e,t){let n=O(e),r=n.Au.get(t);if(r&&r.hu)return V().add(r.key);{let e=V(),r=n.Eu.get(t);if(!r)return e;for(let t of r){let r=n.Tu.get(t);e=e.unionWith(r.view.nu)}return e}}function pu(e){let t=O(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=Ql.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=fu.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=eu.bind(null,t),t.Pu.H_=Ml.bind(null,t.eventManager),t.Pu.yu=Nl.bind(null,t.eventManager),t}function mu(e){let t=O(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=tu.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=nu.bind(null,t),t}var hu=class{constructor(){this.kind=`memory`,this.synchronizeTabs=!1}async initialize(e){this.serializer=Fc(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){return cc(this.persistence,new ic,e.initialUser,this.serializer)}Cu(e){return new Qs(ec.Vi,this.serializer)}Du(e){return new bc}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}};hu.provider={build:()=>new hu};var gu=class extends hu{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){D(this.persistence.referenceDelegate instanceof tc,46915);let n=this.persistence.referenceDelegate.garbageCollector;return new Rs(n,e.asyncQueue,t)}Cu(e){let t=this.cacheSizeBytes===void 0?Ms.DEFAULT:Ms.withCacheSize(this.cacheSizeBytes);return new Qs((e=>tc.Vi(e,t)),this.serializer)}},_u=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=>$l(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=du.bind(null,this.syncEngine),await yl(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new Ol}()}createDatastore(e){let t=Fc(e.databaseInfo.databaseId),n=Nc(e.databaseInfo);return Uc(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,r,i){return new Kc(e,t,n,r,i)}(this.localStore,this.datastore,e.asyncQueue,(e=>$l(this.syncEngine,e,0)),function(){return Cc.v()?new Cc:new xc}())}createSyncEngine(e,t){return function(e,t,n,r,i,a,o){let s=new Wl(e,t,n,r,i,a);return o&&(s.gu=!0),s}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await async function(e){let t=O(e);T(Gc,`RemoteStore shutting down.`),t.Ia.add(5),await Jc(t),t.Aa.shutdown(),t.Va.set(`Unknown`)}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}};_u.provider={build:()=>new _u};var vu=class{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):Fn(`Uncaught Error in snapshot listener:`,e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout((()=>{this.muted||e(t)}),0)}},yu=`FirestoreClient`,bu=class{constructor(e,t,n,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this._databaseInfo=r,this.user=C.UNAUTHENTICATED,this.clientId=Yn.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,(async e=>{T(yu,`Received user=`,e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=>(T(yu,`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 zn;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=Cl(t,`Failed to shutdown persistence`);e.reject(n)}})),e.promise}};async function xu(e,t){e.asyncQueue.verifyOperationInProgress(),T(yu,`Initializing OfflineComponentProvider`);let n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=>{r.isEqual(e)||(await lc(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e._offlineComponents=t}async function Su(e,t){e.asyncQueue.verifyOperationInProgress();let n=await Cu(e);T(yu,`Initializing OnlineComponentProvider`),await t.initialize(n,e.configuration),e.setCredentialChangeListener((e=>vl(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=>vl(t.remoteStore,n))),e._onlineComponents=t}async function Cu(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){T(yu,`Using user provided OfflineComponentProvider`);try{await xu(e,e._uninitializedComponentsProvider._offline)}catch(t){let n=t;if(!function(e){return e.name===`FirebaseError`?e.code===k.FAILED_PRECONDITION||e.code===k.UNIMPLEMENTED:!(typeof DOMException<`u`&&e instanceof DOMException)||e.code===22||e.code===20||e.code===11}(n))throw n;In(`Error using user provided cache. Falling back to memory cache: `+n),await xu(e,new hu)}}else T(yu,`Using default OfflineComponentProvider`),await xu(e,new gu(void 0));return e._offlineComponents}async function wu(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(T(yu,`Using user provided OnlineComponentProvider`),await Su(e,e._uninitializedComponentsProvider._online)):(T(yu,`Using default OnlineComponentProvider`),await Su(e,new _u))),e._onlineComponents}function Tu(e){return wu(e).then((e=>e.syncEngine))}function Eu(e){return wu(e).then((e=>e.datastore))}async function Du(e){let t=await wu(e),n=t.eventManager;return n.onListen=Gl.bind(null,t.syncEngine),n.onUnlisten=Yl.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=Kl.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=Xl.bind(null,t.syncEngine),n}function Ou(e,t,n,r){let i=new vu(r),a=new Ll(t,i,n);return e.asyncQueue.enqueueAndForget((async()=>Al(await Du(e),a))),()=>{i.Nu(),e.asyncQueue.enqueueAndForget((async()=>jl(await Du(e),a)))}}function ku(e,t,n={}){let r=new zn;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new vu({next:s=>{a.Nu(),t.enqueueAndForget((()=>jl(e,o)));let c=s.docs.has(n);!c&&s.fromCache?i.reject(new A(k.UNAVAILABLE,`Failed to get document because the client is offline.`)):c&&s.fromCache&&r&&r.source===`server`?i.reject(new A(k.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 Ll(sa(n.path),a,{includeMetadataChanges:!0,qa:!0});return Al(e,o)}(await Du(e),e.asyncQueue,t,n,r))),r.promise}function Au(e,t,n={}){let r=new zn;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new vu({next:n=>{a.Nu(),t.enqueueAndForget((()=>jl(e,o))),n.fromCache&&r.source===`server`?i.reject(new A(k.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 Ll(n,a,{includeMetadataChanges:!0,qa:!0});return Al(e,o)}(await Du(e),e.asyncQueue,t,n,r))),r.promise}function ju(e,t,n){let r=new zn;return e.asyncQueue.enqueueAndForget((async()=>{try{let i=await Eu(e);r.resolve(async function(e,t,n){let r=O(e),{request:i,gt:a,parent:o}=ds(r.serializer,pa(t),n);r.connection.qo||delete i.parent;let s=(await r.jo(`RunAggregationQuery`,r.serializer.databaseId,o,i,1)).filter((e=>!!e.result));D(s.length===1,64727);let c=s[0].result?.aggregateFields;return Object.keys(c).reduce(((e,t)=>(e[a[t]]=c[t],e)),{})}(i,t,n))}catch(e){r.reject(e)}})),r.promise}function Mu(e,t){let n=new zn;return e.asyncQueue.enqueueAndForget((async()=>Zl(await Tu(e),t,n))),n.promise}function Nu(e){let t={};return e.timeoutSeconds!==void 0&&(t.timeoutSeconds=e.timeoutSeconds),t}var Pu=`ComponentProvider`,Fu=new Map;function Iu(e,t,n,r,i){return new ri(e,t,n,i.host,i.ssl,i.experimentalForceLongPolling,i.experimentalAutoDetectLongPolling,Nu(i.experimentalLongPollingOptions),i.useFetchStreams,i.isUsingEmulator,r)}var Lu=`firestore.googleapis.com`,Ru=!0,zu=class{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new A(k.INVALID_ARGUMENT,`Can't provide ssl option if host option is not set`);this.host=Lu,this.ssl=Ru}else this.host=e.host,this.ssl=e.ssl??Ru;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=js;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<Fs)throw new A(k.INVALID_ARGUMENT,`cacheSizeBytes must be at least 1048576`);this.cacheSizeBytes=e.cacheSizeBytes}or(`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=Nu(e.experimentalLongPollingOptions??{}),function(e){if(e.timeoutSeconds!==void 0){if(isNaN(e.timeoutSeconds))throw new A(k.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new A(k.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new A(k.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}},Bu=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 zu({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask=`notTerminated`}get app(){if(!this._app)throw new A(k.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 A(k.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 zu(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=function(e){if(!e)return new Vn;switch(e.type){case`firstParty`:return new Gn(e.sessionIndex||`0`,e.iamToken||null,e.authTokenFactory||null);case`provider`:return e.client;default:throw new A(k.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=Fu.get(e);t&&(T(Pu,`Removing Datastore`),Fu.delete(e),t.terminate())}(this),Promise.resolve()}};function Vu(e,t,n,r={}){e=dr(e,Bu);let i=Ee(t),a=e._getSettings(),o={...a,emulatorOptions:e._getEmulatorOptions()},s=`${t}:${n}`;i&&De(`https://${s}`),a.host!==Lu&&a.host!==s&&In(`Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.`);let c={...a,host:s,ssl:i,emulatorOptions:r};if(!_e(c,o)&&(e._setSettings(c),r.mockUserToken)){let t,n;if(typeof r.mockUserToken==`string`)t=r.mockUserToken,n=C.MOCK_USER;else{t=ne(r.mockUserToken,e._app?.options.projectId);let i=r.mockUserToken.sub||r.mockUserToken.user_id;if(!i)throw new A(k.INVALID_ARGUMENT,`mockUserToken must contain 'sub' or 'user_id' field!`);n=new C(i)}e._authCredentials=new Hn(new Bn(t,n))}}var Hu=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)}},Uu=class e{constructor(e,t,n){this.converter=t,this._key=n,this.type=`document`,this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new Wu(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(pr(n,e._jsonSchema))return new e(t,r||null,new N(M.fromString(n.referencePath)))}};Uu._jsonSchemaVersion=`firestore/documentReference/1.0`,Uu._jsonSchema={type:P(`string`,Uu._jsonSchemaVersion),referencePath:P(`string`)};var Wu=class e extends Hu{constructor(e,t,n){super(e,t,sa(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 Uu(this.firestore,null,new N(e))}withConverter(t){return new e(this.firestore,t,this._path)}};function Gu(e,t,...n){if(e=y(e),ar(`collection`,`path`,t),e instanceof Bu){let r=M.fromString(t,...n);return cr(r),new Wu(e,null,r)}{if(!(e instanceof Uu||e instanceof Wu))throw new A(k.INVALID_ARGUMENT,`Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore`);let r=e._path.child(M.fromString(t,...n));return cr(r),new Wu(e.firestore,null,r)}}function Ku(e,t,...n){if(e=y(e),arguments.length===1&&(t=Yn.newId()),ar(`doc`,`path`,t),e instanceof Bu){let r=M.fromString(t,...n);return sr(r),new Uu(e,null,new N(r))}{if(!(e instanceof Uu||e instanceof Wu))throw new A(k.INVALID_ARGUMENT,`Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore`);let r=e._path.child(M.fromString(t,...n));return sr(r),new Uu(e.firestore,e instanceof Wu?e.converter:null,new N(r))}}var qu=`AsyncQueue`,Ju=class{constructor(e=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new Ic(this,`async_queue_retry`),this._c=()=>{let e=Pc();e&&T(qu,`Visibility state changed to `+e.visibilityState),this.M_.w_()},this.ac=e;let t=Pc();t&&typeof t.addEventListener==`function`&&t.addEventListener(`visibilitychange`,this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;let t=Pc();t&&typeof t.removeEventListener==`function`&&t.removeEventListener(`visibilitychange`,this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise((()=>{}));let t=new zn;return this.cc((()=>this.ec&&this.sc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.Yu.push(e),this.lc())))}async lc(){if(this.Yu.length!==0){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(e){if(!Er(e))throw e;T(qu,`Operation failed with retryable error: `+e)}this.Yu.length>0&&this.M_.p_((()=>this.lc()))}}cc(e){let t=this.ac.then((()=>(this.rc=!0,e().catch((e=>{throw this.nc=e,this.rc=!1,Fn(`INTERNAL UNHANDLED ERROR: `,Yu(e)),e})).then((e=>(this.rc=!1,e))))));return this.ac=t,t}enqueueAfterDelay(e,t,n){this.uc(),this.oc.indexOf(e)>-1&&(t=0);let r=Sl.createAndSchedule(this,e,t,n,(e=>this.hc(e)));return this.tc.push(r),r}uc(){this.nc&&E(47125,{Pc:Yu(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do e=this.ac,await e;while(e!==this.ac)}Ec(e){for(let t of this.tc)if(t.timerId===e)return!0;return!1}Ic(e){return this.Tc().then((()=>{this.tc.sort(((e,t)=>e.targetTimeMs-t.targetTimeMs));for(let t of this.tc)if(t.skipDelay(),e!==`all`&&t.timerId===e)break;return this.Tc()}))}Rc(e){this.oc.push(e)}hc(e){let t=this.tc.indexOf(e);this.tc.splice(t,1)}};function Yu(e){let t=e.message||``;return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+`
16
- `+e.stack),t}var Xu=class extends Bu{constructor(e,t,n,r){super(e,t,n,r),this.type=`firestore`,this._queue=new Ju,this._persistenceKey=r?.name||`[DEFAULT]`}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new Ju(e),this._firestoreClient=void 0,await e}}};function Zu(e,t){let n=typeof e==`object`?e:Qt(),r=typeof e==`string`?e:t||ii,i=qt(n,`firestore`).getImmediate({identifier:r});if(!i._initialized){let e=h(`firestore`);e&&Vu(i,...e)}return i}function Qu(e){if(e._terminated)throw new A(k.FAILED_PRECONDITION,`The client has already been terminated.`);return e._firestoreClient||$u(e),e._firestoreClient}function $u(e){let t=e._freezeSettings(),n=Iu(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 bu(e._authCredentials,e._appCheckCredentials,e._queue,n,e._componentsProvider&&function(e){let t=e?._online.build();return{_offline:e?._offline.build(t),_online:t}}(e._componentsProvider))}var ed=class e{constructor(e){this._byteString=e}static fromBase64String(t){try{return new e(Kr.fromBase64String(t))}catch(e){throw new A(k.INVALID_ARGUMENT,`Failed to construct data from Base64 string: `+e)}}static fromUint8Array(t){return new e(Kr.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(pr(t,e._jsonSchema))return e.fromBase64String(t.bytes)}};ed._jsonSchemaVersion=`firestore/bytes/1.0`,ed._jsonSchema={type:P(`string`,ed._jsonSchemaVersion),bytes:P(`string`)};var td=class{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new A(k.INVALID_ARGUMENT,`Invalid field name at argument $(i + 1). Field names must not be empty.`);this._internalPath=new ir(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}},nd=class{constructor(e){this._methodName=e}},rd=class e{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new A(k.INVALID_ARGUMENT,`Latitude must be a number between -90 and 90, but was: `+e);if(!isFinite(t)||t<-180||t>180)throw new A(k.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 j(this._lat,e._lat)||j(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:e._jsonSchemaVersion}}static fromJSON(t){if(pr(t,e._jsonSchema))return new e(t.latitude,t.longitude)}};rd._jsonSchemaVersion=`firestore/geoPoint/1.0`,rd._jsonSchema={type:P(`string`,rd._jsonSchemaVersion),latitude:P(`number`),longitude:P(`number`)};var id=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(pr(t,e._jsonSchema)){if(Array.isArray(t.vectorValues)&&t.vectorValues.every((e=>typeof e==`number`)))return new e(t.vectorValues);throw new A(k.INVALID_ARGUMENT,`Expected 'vectorValues' field to be a number array`)}}};id._jsonSchemaVersion=`firestore/vectorValue/1.0`,id._jsonSchema={type:P(`string`,id._jsonSchemaVersion),vectorValues:P(`object`)};var ad=/^__.*__$/,od=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return this.fieldMask===null?new uo(e,this.data,t,this.fieldTransforms):new fo(e,this.data,this.fieldMask,t,this.fieldTransforms)}},sd=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new fo(e,this.data,this.fieldMask,t,this.fieldTransforms)}};function cd(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw E(40011,{dataSource:e})}}var ld=class e{constructor(e,t,n,r,i,a){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,i===void 0&&this.Ac(),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)}dc(e){let t=this.path?.child(e),n=this.i({path:t,arrayElement:!1});return n.mc(e),n}fc(e){let t=this.path?.child(e),n=this.i({path:t,arrayElement:!1});return n.Ac(),n}gc(e){return this.i({path:void 0,arrayElement:!0})}yc(e){return wd(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}Ac(){if(this.path)for(let e=0;e<this.path.length;e++)this.mc(this.path.get(e))}mc(e){if(e.length===0)throw this.yc(`Document fields must not be empty`);if(cd(this.dataSource)&&ad.test(e))throw this.yc(`Document fields cannot begin and end with "__"`)}},ud=class{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Fc(e)}A(e,t,n,r=!1){return new ld({dataSource:e,methodName:t,targetDoc:n,path:ir.emptyPath(),arrayElement:!1,hasConverter:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function dd(e){let t=e._freezeSettings(),n=Fc(e._databaseId);return new ud(e._databaseId,!!t.ignoreUndefinedProperties,n)}function fd(e,t,n,r,i,a={}){let o=e.A(a.merge||a.mergeFields?2:0,t,n,i);bd(`Data must be an object, but it was:`,o,r);let s=vd(r,o),c,l;if(a.merge)c=new Wr(o.fieldMask),l=o.fieldTransforms;else if(a.mergeFields){let e=[];for(let r of a.mergeFields){let i=xd(t,r,n);if(!o.contains(i))throw new A(k.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);Td(e,i)||e.push(i)}c=new Wr(e),l=o.fieldTransforms.filter((e=>c.covers(e.field)))}else c=null,l=o.fieldTransforms;return new od(new Ai(s),c,l)}var pd=class e extends nd{_toFieldTransform(e){if(e.dataSource!==2)throw e.dataSource===1?e.yc(`${this._methodName}() can only appear at the top level of your update data`):e.yc(`${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 md(e,t,n,r){let i=e.A(1,t,n);bd(`Data must be an object, but it was:`,i,r);let a=[],o=Ai.empty();return Lr(r,((e,r)=>{let s=Cd(t,e,n);r=y(r);let c=i.fc(s);if(r instanceof pd)a.push(s);else{let e=_d(r,c);e!=null&&(a.push(s),o.set(s,e))}})),new sd(o,new Wr(a),i.fieldTransforms)}function hd(e,t,n,r,i,a){let o=e.A(1,t,n),s=[xd(t,r,n)],c=[i];if(a.length%2!=0)throw new A(k.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(xd(t,a[e])),c.push(a[e+1]);let l=[],u=Ai.empty();for(let e=s.length-1;e>=0;--e)if(!Td(l,s[e])){let t=s[e],n=c[e];n=y(n);let r=o.fc(t);if(n instanceof pd)l.push(t);else{let e=_d(n,r);e!=null&&(l.push(t),u.set(t,e))}}return new sd(u,new Wr(l),o.fieldTransforms)}function gd(e,t,n,r=!1){return _d(n,e.A(r?4:3,t))}function _d(e,t){if(yd(e=y(e)))return bd(`Unsupported field value:`,t,e),vd(e,t);if(e instanceof nd)return function(e,t){if(!cd(t.dataSource))throw t.yc(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.yc(`${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.yc(`Nested arrays are not supported`);return function(e,t){let n=[],r=0;for(let i of e){let e=_d(i,t.gc(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 Va(t.serializer,e);if(typeof e==`boolean`)return{booleanValue:e};if(typeof e==`string`)return{stringValue:e};if(e instanceof Date){let n=F.fromDate(e);return{timestampValue:Ko(t.serializer,n)}}if(e instanceof F){let n=new F(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:Ko(t.serializer,n)}}if(e instanceof rd)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof ed)return{bytesValue:qo(t.serializer,e._byteString)};if(e instanceof Uu){let n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.yc(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Xo(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof id)return function(e,t){let n=e instanceof id?e.toArray():e;return{mapValue:{fields:{[si]:{stringValue:ui},[di]:{arrayValue:{values:n.map((e=>{if(typeof e!=`number`)throw t.yc(`VectorValues must only contain numeric values.`);return za(t.serializer,e)}))}}}}}}(e,t);if(Cs(e))return e._toProto(t.serializer);throw t.yc(`Unsupported field value: ${ur(e)}`)}(e,t)}function vd(e,t){let n={};return zr(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):Lr(e,((e,r)=>{let i=_d(r,t.dc(e));i!=null&&(n[e]=i)})),{mapValue:{fields:n}}}function yd(e){return!(typeof e!=`object`||!e||e instanceof Array||e instanceof Date||e instanceof F||e instanceof rd||e instanceof ed||e instanceof Uu||e instanceof nd||e instanceof id||Cs(e))}function bd(e,t,n){if(!yd(n)||!lr(n)){let r=ur(n);throw r===`an object`?t.yc(e+` a custom object`):t.yc(e+` `+r)}}function xd(e,t,n){if((t=y(t))instanceof td)return t._internalPath;if(typeof t==`string`)return Cd(e,t);throw wd(`Field path arguments must be of type string or `,e,!1,void 0,n)}var Sd=RegExp(`[~\\*/\\[\\]]`);function Cd(e,t,n){if(t.search(Sd)>=0)throw wd(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new td(...t.split(`.`))._internalPath}catch{throw wd(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function wd(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 A(k.INVALID_ARGUMENT,s+e+c)}function Td(e,t){return e.some((e=>e.isEqual(t)))}var Ed=class{convertValue(e,t=`none`){switch(fi(e)){case 0:return null;case 1:return e.booleanValue;case 2:return z(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(Yr(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 E(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t=`none`){let n={};return Lr(e,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertVectorValue(e){let t=e.fields?.[di].arrayValue?.values?.map((e=>z(e.doubleValue)));return new id(t)}convertGeoPoint(e){return new rd(z(e.latitude),z(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=>this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case`previous`:let n=ti(e);return n==null?null:this.convertValue(n,t);case`estimate`:return this.convertTimestamp(ni(e));default:return null}}convertTimestamp(e){let t=Jr(e);return new F(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=M.fromString(e);D(Ss(n),9688,{name:e});let r=new ai(n.get(1),n.get(3)),i=new N(n.popFirst(5));return r.isEqual(t)||Fn(`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}},Dd=class extends Ed{constructor(e){super(),this.firestore=e}convertBytes(e){return new ed(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new Uu(this.firestore,null,t)}},Od=`@firebase/firestore`,kd=`4.13.0`;function Ad(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 jd=class{constructor(e=`count`,t){this._internalFieldPath=t,this.type=`AggregateField`,this.aggregateType=e}},Md=class{constructor(e,t,n){this._userDataWriter=t,this._data=n,this.type=`AggregateQuerySnapshot`,this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}_fieldsProto(){return new Ai({mapValue:{fields:this._data}}).clone().value.mapValue.fields}},Nd=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 Uu(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new Pd(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(xd(`DocumentSnapshot.get`,e));if(t!==null)return this._userDataWriter.convertValue(t)}}},Pd=class extends Nd{data(){return super.data()}};function Fd(e){if(e.limitType===`L`&&e.explicitOrderBy.length===0)throw new A(k.UNIMPLEMENTED,`limitToLast() queries require specifying at least one orderBy() clause`)}var Id=class{},Ld=class extends Id{};function Rd(e,t,...n){let r=[];t instanceof Id&&r.push(t),r=r.concat(n),function(e){let t=e.filter((e=>e instanceof Vd)).length,n=e.filter((e=>e instanceof zd)).length;if(t>1||t>0&&n>0)throw new A(k.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 zd=class e extends Ld{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 $d(e._query,t),new Hu(e.firestore,e.converter,ha(e._query,t))}_parse(e){let t=dd(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 A(k.INVALID_ARGUMENT,`Invalid Query. You can't perform '${a}' queries on documentId().`);if(a===`in`||a===`not-in`){Qd(o,a);let t=[];for(let n of o)t.push(Zd(r,e,n));s={arrayValue:{values:t}}}else s=Zd(r,e,o)}else a!==`in`&&a!==`not-in`&&a!==`array-contains-any`||Qd(o,a),s=gd(n,t,o,a===`in`||a===`not-in`);return B.create(i,a,s)}(e._query,`where`,t,e.firestore._databaseId,this._field,this._op,this._value)}};function Bd(e,t,n){let r=t,i=xd(`where`,e);return zd._create(i,r,n)}var Vd=class e extends Id{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]:zi.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)$d(n,e),n=ha(n,e)}(e._query,t),new Hu(e.firestore,e.converter,ha(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type===`and`?`and`:`or`}};function Hd(...e){return e.forEach((e=>ef(`or`,e))),Vd._create(`or`,e)}function Ud(...e){return e.forEach((e=>ef(`and`,e))),Vd._create(`and`,e)}var Wd=class e extends Ld{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 A(k.INVALID_ARGUMENT,`Invalid query. You must not call startAt() or startAfter() before calling orderBy().`);if(e.endAt!==null)throw new A(k.INVALID_ARGUMENT,`Invalid query. You must not call endAt() or endBefore() before calling orderBy().`);return new Ii(t,n)}(e._query,this._field,this._direction);return new Hu(e.firestore,e.converter,ga(e._query,t))}};function Gd(e,t=`asc`){let n=t,r=xd(`orderBy`,e);return Wd._create(r,n)}var Kd=class e extends Ld{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 Hu(e.firestore,e.converter,_a(e._query,this._limit,this._limitType))}};function qd(e){return fr(`limit`,e),Kd._create(`limit`,e,`F`)}var Jd=class e extends Ld{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=Xd(e,this.type,this._docOrFields,this._inclusive);return new Hu(e.firestore,e.converter,va(e._query,t))}};function Yd(...e){return Jd._create(`startAfter`,e,!1)}function Xd(e,t,n,r){if(n[0]=y(n[0]),n[0]instanceof Nd)return function(e,t,n,r,i){if(!r)throw new A(k.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);let a=[];for(let n of da(e))if(n.field.isKeyField())a.push(xi(t,r.key));else{let e=r.data.field(n.field);if(ei(e))throw new A(k.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 A(k.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 Ni(a,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);{let i=dd(e.firestore);return function(e,t,n,r,i,a){let o=e.explicitOrderBy;if(i.length>o.length)throw new A(k.INVALID_ARGUMENT,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);let s=[];for(let a=0;a<i.length;a++){let c=i[a];if(o[a].field.isKeyField()){if(typeof c!=`string`)throw new A(k.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);if(!ua(e)&&c.indexOf(`/`)!==-1)throw new A(k.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(M.fromString(c));if(!N.isDocumentKey(n))throw new A(k.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 N(n);s.push(xi(t,i))}else{let e=gd(n,r,c);s.push(e)}}return new Ni(s,a)}(e._query,e.firestore._databaseId,i,t,n,r)}}function Zd(e,t,n){if(typeof(n=y(n))==`string`){if(n===``)throw new A(k.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.`);if(!ua(t)&&n.indexOf(`/`)!==-1)throw new A(k.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(M.fromString(n));if(!N.isDocumentKey(r))throw new A(k.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 xi(e,new N(r))}if(n instanceof Uu)return xi(e,n._key);throw new A(k.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${ur(n)}.`)}function Qd(e,t){if(!Array.isArray(e)||e.length===0)throw new A(k.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function $d(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 A(k.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new A(k.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}function ef(e,t){if(!(t instanceof zd||t instanceof Vd))throw new A(k.INVALID_ARGUMENT,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}function tf(e,t,n){let r;return r=e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,r}function nf(){return new jd(`count`)}function rf(e){return af(e,{count:nf()})}function af(e,t){let n=dr(e.firestore,Xu),r=Qu(n),i=Rr(t,((e,t)=>new xo(t,e.aggregateType,e._internalFieldPath)));return ju(r,e._query,i).then((t=>function(e,t,n){return new Md(t,new Dd(e),n)}(n,e,t)))}var of=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},sf=class e extends Nd{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 cf(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(xd(`DocumentSnapshot.get`,e));if(n!==null)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new A(k.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)}};sf._jsonSchemaVersion=`firestore/documentSnapshot/1.0`,sf._jsonSchema={type:P(`string`,sf._jsonSchemaVersion),bundleSource:P(`string`,`DocumentSnapshot`),bundleName:P(`string`),bundle:P(`string`)};var cf=class extends sf{data(e={}){return super.data(e)}},lf=class e{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new of(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 cf(this._firestore,this._userDataWriter,n.key,n,new of(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 A(k.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 cf(e._firestore,e._userDataWriter,n.doc.key,n.doc,new of(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 cf(e._firestore,e._userDataWriter,t.doc.key,t.doc,new of(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:uf(t.type),doc:r,oldIndex:i,newIndex:a}}))}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new A(k.FAILED_PRECONDITION,`QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().`);let t={};t.type=e._jsonSchemaVersion,t.bundleSource=`QuerySnapshot`,t.bundleName=Yn.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 uf(e){switch(e){case 0:return`added`;case 2:case 3:return`modified`;case 1:return`removed`;default:return E(61501,{type:e})}}lf._jsonSchemaVersion=`firestore/querySnapshot/1.0`,lf._jsonSchema={type:P(`string`,lf._jsonSchemaVersion),bundleSource:P(`string`,`QuerySnapshot`),bundleName:P(`string`),bundle:P(`string`)};var df=class{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=dd(e)}set(e,t,n){this._verifyNotCommitted();let r=ff(e,this._firestore),i=tf(r.converter,t,n),a=fd(this._dataReader,`WriteBatch.set`,r._key,i,r.converter!==null,n);return this._mutations.push(a.toMutation(r._key,no.none())),this}update(e,t,n,...r){this._verifyNotCommitted();let i=ff(e,this._firestore),a;return a=typeof(t=y(t))==`string`||t instanceof td?hd(this._dataReader,`WriteBatch.update`,i._key,t,n,r):md(this._dataReader,`WriteBatch.update`,i._key,t),this._mutations.push(a.toMutation(i._key,no.exists(!0))),this}delete(e){this._verifyNotCommitted();let t=ff(e,this._firestore);return this._mutations=this._mutations.concat(new go(t._key,no.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 A(k.FAILED_PRECONDITION,`A write batch can no longer be used after commit() has been called.`)}};function ff(e,t){if((e=y(e)).firestore!==t)throw new A(k.INVALID_ARGUMENT,`Provided document reference is from a different Firestore instance.`);return e}function pf(e){e=dr(e,Uu);let t=dr(e.firestore,Xu);return ku(Qu(t),e._key).then((n=>vf(t,e,n)))}function mf(e){e=dr(e,Hu);let t=dr(e.firestore,Xu),n=Qu(t),r=new Dd(t);return Fd(e._query),Au(n,e._query).then((n=>new lf(t,r,e,n)))}function hf(e){return _f(dr(e.firestore,Xu),[new go(e._key,no.none())])}function gf(e,...t){e=y(e);let n={includeMetadataChanges:!1,source:`default`},r=0;typeof t[r]!=`object`||Ad(t[r])||(n=t[r++]);let i={includeMetadataChanges:n.includeMetadataChanges,source:n.source};if(Ad(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 Uu)o=dr(e.firestore,Xu),s=sa(e._key.path),a={next:n=>{t[r]&&t[r](vf(o,e,n))},error:t[r+1],complete:t[r+2]};else{let n=dr(e,Hu);o=dr(n.firestore,Xu),s=n._query;let i=new Dd(o);a={next:e=>{t[r]&&t[r](new lf(o,i,n,e))},error:t[r+1],complete:t[r+2]},Fd(e._query)}return Ou(Qu(o),s,i,a)}function _f(e,t){return Mu(Qu(e),t)}function vf(e,t,n){let r=n.docs.get(t._key);return new sf(e,new Dd(e),t._key,r,new of(n.hasPendingWrites,n.fromCache),t.converter)}function yf(e){return e=dr(e,Xu),Qu(e),new df(e,(t=>_f(e,t)))}(function(e,t=!0){w(Xt),Kt(new Oe(`firestore`,((e,{instanceIdentifier:n,options:r})=>{let i=e.getProvider(`app`).getImmediate(),a=new Xu(new Un(e.getProvider(`auth-internal`)),new qn(i,e.getProvider(`app-check-internal`)),oi(i,n),i);return r={useFetchStreams:t,...r},a._setSettings(r),a}),`PUBLIC`).setMultipleInstances(!0)),$t(Od,kd,e),$t(Od,kd,`esm2020`)})();var bf=class{constructor(){this.subscribers=new Set}subscribe(e){return this.subscribers.add(e),()=>this.unsubscribe(e)}unsubscribe(e){this.subscribers.delete(e)}notify(e){this.subscribers.forEach(t=>t(e))}get subscribersCount(){return this.subscribers.size}},G=[];for(let e=0;e<256;++e)G.push((e+256).toString(16).slice(1));function xf(e,t=0){return(G[e[t+0]]+G[e[t+1]]+G[e[t+2]]+G[e[t+3]]+`-`+G[e[t+4]]+G[e[t+5]]+`-`+G[e[t+6]]+G[e[t+7]]+`-`+G[e[t+8]]+G[e[t+9]]+`-`+G[e[t+10]]+G[e[t+11]]+G[e[t+12]]+G[e[t+13]]+G[e[t+14]]+G[e[t+15]]).toLowerCase()}var Sf,Cf=new Uint8Array(16);function wf(){if(!Sf){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);Sf=crypto.getRandomValues.bind(crypto)}return Sf(Cf)}var Tf={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Ef(e,t,n){e||={};let r=e.random??e.rng?.()??wf();if(r.length<16)throw Error(`Random bytes length must be >= 16`);return r[6]=r[6]&15|64,r[8]=r[8]&63|128,xf(r)}function Df(e,t,n){return Tf.randomUUID&&!e?Tf.randomUUID():Ef(e)}var Of=Object.defineProperty,kf=(e,t,n,r)=>{for(var i=void 0,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(t,n,i)||i);return i&&Of(t,n,i),i},K,Af=(K=class{static registerFactory(e,t,n,r=!1){this._factoryMap[e]={factory:t,annotation:n,isLegacy:r}}static classFactory(e){if(!e)throw Error(`You should provide a class name.`);if(!this._factoryMap[e])throw Error(`You should register class ${e} prior to use.`);return this._factoryMap[e].factory}static registeredClasses(){return Object.entries(this._factoryMap).filter(([,e])=>!e.isLegacy).map(([e])=>e)}static registeredClassesAndLegacyNames(){return Object.keys(this._factoryMap)}static classesExtending(e){return Object.entries(this._factoryMap).filter(([,t])=>new t.factory instanceof e&&!t.isLegacy).map(([e])=>e)}static annotations(e){if(e instanceof K?e=e.className:typeof e==`string`||(e=new e().className),!this._factoryMap[e])throw Error(`You should register class ${e} prior to use.`);return this._factoryMap[e].annotation}constructor(e=Df()){this._id=e}get className(){return this.__className}setId(e){this._id=e}get id(){return this._id}afterDeserialize(){}beforeSerialize(){}getPersistentProperties(){return this._persistentProperties?this._persistentProperties.map(e=>({...e,name:e.name.slice(1)})):[]}getPropInfo(e){let t=this.getPersistentProperties().find(t=>t.name===e);if(!t)throw Error(`Property "${e}" has not been registered.`);return t}isRequired(e){return this.getPropInfo(e).validator!=null}isPropValueValid(e){let t=this.getPropInfo(e);return t.validator?t.validator(this[t.name],t,this):!0}clone(e){let t=e.toObject();return delete t.id,this.fromObject(t)}fromObject(e){return this.fromObj(e),this.afterDeserialize(),this}fromObj(e){return this._persistentProperties&&this._persistentProperties.forEach(t=>{let n=e[this.removeUnderscore(t)];n!=null&&(this[t.name]=this.fromDeepObject(n))}),this}toObject(){let e={},t=this.toObj(e);return this.pushDocument(e,this.className,t),{...t,__rootCollections:e}}toObj(e){if(!this._persistentProperties)return{};this.beforeSerialize();let t={};if(!this.className)throw Error(`You should register \`${this.constructor.name||this.toString()||`this`}\` class prior to streaming it.`);return this._persistentProperties.forEach(n=>{let r=this[n.name],i=this.removeUnderscore(n);r!=null&&(n.isReference?t[i]=this.toReferenceObj(n,e):t[i]=this.toDeepObj(r,e),n.searchableArray&&(t[K.searchableArrayNameFor(i)]=r.map(e=>e.id)))}),t.__className=this.className,t}static searchableArrayNameFor(e){return`__${e}_searchable`}fromDeepObject(e){if(e==null)return e;if(Array.isArray(e))return e.map(e=>this.fromDeepObject(e));if(e.__documentReference){let t=e,n=K.createInstance(t);return n.__documentReference=e.__documentReference,n}if(e.__className)return K.createInstance(e);if(typeof e==`object`){let t={};return Object.entries(e).forEach(([e,n])=>t[e]=this.fromDeepObject(n)),t}return e}toDeepObj(e,t){if(e!=null){if(Array.isArray(e))return e.map(e=>this.toDeepObj(e,t));if(e.__documentReference)return e;if(e instanceof K)return e.toObj(t);if(typeof e==`object`){let n={};return Object.entries(e).forEach(([e,r])=>n[e]=this.toDeepObj(r,t)),n}return e}}static collectionPath(e,t,n){let r;return r=typeof t.storeInCollection==`function`?t.storeInCollection(e,t,n):t.storeInCollection??e.className,r}toReferenceObj(e,t){let n=this[e.name];return Array.isArray(n)?n.map(n=>(e.isPureReference||this.pushDocument(t,K.collectionPath(n,e),n),this.buildRefObject(n,K.collectionPath(n,e),e.cachedProps))):(e.isPureReference||this.pushDocument(t,K.collectionPath(n,e),n),this.buildRefObject(n,K.collectionPath(n,e),e.cachedProps))}buildRefObject(e,t,n){let r=n?.reduce((t,n)=>(e[n]!==void 0&&(t[n]=e[n]),t),{});return{id:e.id,__className:e.className||e.__className,__documentReference:{storedInCollection:t},...r}}pushDocument(e,t,n){if(`__documentReference`in n&&n.__documentReference)return;e[t]||(e[t]=[]);let r=this.toDeepObj(n,e);e[t].push(r)}removeUnderscore(e){return e.name.slice(1)}static createReference(e){let t=K.createInstance(e);return t.__documentReference=e.__documentReference||{storedInCollection:t.className},t}static createInstance(e){if(typeof e==`string`)return new(K.classFactory(e));try{return new(K.classFactory(e.__className))().fromObject(e)}catch(t){let n=Object.entries(e).filter(([e,t])=>t!=null&&typeof t!=`function`).map(([e,t])=>`${e}: ${t}`).join(`,
17
- `);throw Error(`${t}
18
- -----> Class name not found in object:
19
- {
20
- ${n}
21
- }
22
- `)}}static propInfo(e,t){return K.createInstance(e).getPropInfo(t)}static propType(e){if(e.typeName)return Array.isArray(e.typeName)?`undefined[]`:e.typeName??`undefined`;let t=K.createInstance(e.ownerClassName())[e.name];if(Array.isArray(t)){if(t.length===0)return`undefined[]`;let e=t[0];return e instanceof K?e.className+`[]`:typeof e+`[]`}else return t instanceof K?t.className:typeof t}static getSystemRegisteredReferencesWithCachedProps(){return K.registeredClasses().reduce((e,t)=>{let n=K.createInstance(t).getPersistentProperties().filter(e=>e.cachedProps);return n.length>0&&(e[t]=n),e},{})}},K._factoryMap={},K);kf([jf],Af.prototype,`_id`);var q=Af;function jf(e,t){return Mf()(e,t)}function Mf(e){return function(t,n){Object.getOwnPropertyDescriptor(t,`_persistentProperties`)||(t._persistentProperties?t._persistentProperties=[...t._persistentProperties]:t._persistentProperties=[]);let r=t._persistentProperties.find(e=>e.name===n);r?Object.assign(r,e):t._persistentProperties.push({name:n,ownerClassName:()=>t.className,...e})}}function Nf(e,t){return n=>{q.registerFactory(e,n,t),n.prototype.__className=e}}var Pf=class e{constructor(t,n,r){if(r){if(!(n instanceof q))throw Error(e.error.persistentNeedForSubCollection);this.collectionName=`${n.className}/${n.id}/${r}`}else this.collectionName=n instanceof q?n.className:n;this._stream=t}findById(e,t){return new Promise((n,r)=>{this._stream.findById(e,this.collectionName).then(e=>{e?(t?t.fromObject(e):t=q.createInstance(e),n(t)):n(void 0)}).catch(e=>r(e))})}save(e){let t=e.toObject();return this.collectionName!==t.__className&&(t.__rootCollections[this.collectionName]=t.__rootCollections[t.__className],delete t.__rootCollections[t.__className]),new Promise((e,n)=>{this._stream.save(t.__rootCollections).then(()=>e()).catch(e=>n(e))})}delete(e){return new Promise((t,n)=>{this._stream.delete(e,this.collectionName).then(()=>t()).catch(e=>n(e))})}find(){return new If(this)}query(e={},t){if(t){let n=t instanceof q?t.className:t;e.operations||=[],e.operations.push({property:`__className`,operator:`==`,value:n})}return this.mapToInstance(()=>this._stream.find(this.preprocessQueryObject(e),this.collectionName))}count(e){return this._stream.count(e,this.collectionName)}next(e){return this.mapToInstance(()=>this._stream.next(e))}onDocumentChange(e,t){return this._stream.onDocumentChange(this.collectionName,e,e=>t(Bf.toPersistentDocumentChange(e)))}onCollectionChange(e,t){return this._stream.onCollectionChange(this.preprocessQueryObject(e.getQueryObject()),this.collectionName,e=>t(e.map(e=>Bf.toPersistentDocumentChange(e))))}onCollectionTemplateChange(e,t){return this._stream.onDocumentTemplateChange(e,e=>t(Bf.toPersistentDocumentChange(e)))}mapToInstance(e){return new Promise((t,n)=>{e().then(e=>t(e.map(e=>q.createInstance(e)))).catch(e=>n(e))})}preprocessQueryObject(e){if(Object.values(e).length===0)return e;let t=e.operations?.map(e=>{let t=e.value[0]??e.value;return Bf.isArrayOperator(e.operator)&&t instanceof q?{property:q.searchableArrayNameFor(e.property),operator:e.operator,value:Array.isArray(e.value)?e.value.map(e=>e.id):t.id,aggregate:e.aggregate}:{property:e.property,operator:e.operator,value:e.value instanceof q?{id:e.value.id}:e.value,aggregate:e.aggregate}})??[];return{...e,operations:t}}};Pf.error={persistentNeedForSubCollection:`The document parameter for a sub-collection should be a Persistent instace`,invalidQueryOrder:`Cannot add where calls after or calls`};var Ff=Pf,If=class{constructor(e){this.queryObject={operations:[]},this.model=e}where(e,t,n,r){if(this.queryObject.operations?.at(-1)?.aggregate&&!r)throw Error(Ff.error.invalidQueryOrder);return this.queryObject.operations?.push({property:e,operator:t,value:n,aggregate:r}),this}whereDeepProp(e,t,n,r){if(this.queryObject.operations?.at(-1)?.aggregate&&!r)throw Error(Ff.error.invalidQueryOrder);let i=e.split(`.`),a={},o=i.length>1?a:n;return i.slice(1).forEach((e,t)=>{a[e]=t<i.length-2?{}:n,a=a[e]}),this.queryObject.operations?.push({property:i[0],operator:t,value:o,aggregate:r}),this}and(e,t,n){return this.where(e,t,n)}andDeepProp(e,t,n){return this.whereDeepProp(e,t,n)}or(e,t,n){return this.where(e,t,n,!0)}orDeepProp(e,t,n){return this.whereDeepProp(e,t,n,!0)}instanceOf(e){let t=e instanceof q?e.className:e;return this.queryObject.operations?.push({property:`__className`,operator:`==`,value:t}),this}get(e){return e&&(this.queryObject.limit=e),this.model.query(this.queryObject)}limit(e){return this.queryObject.limit=e,this}orderBy(e,t=`asc`){return this.queryObject.sort={propertyName:e,order:t},this}orderByDeepProp(e,t=`asc`){return this.queryObject.sort={propertyName:e,order:t},this}count(){return this.model.count(this.queryObject)}getQueryObject(){return this.queryObject}getQueryModel(){return this.model}},Lf=class e{constructor(){}static useDataSource(e){this._dataSource=e}static get dataSource(){return e._dataSource}static getModel(t){if(!e._dataSource)throw Error(this.error.shouldBeRegistered);return new Ff(e._dataSource,t)}static getModelForSubCollection(t,n){if(!e._dataSource)throw Error(this.error.shouldBeRegistered);return new Ff(e._dataSource,t,n)}static async populate(e){if(!e)return;let t=async e=>{let t=e;if(!t.__documentReference)return e;let n=await this.getModel(t.__documentReference.storedInCollection).findById(t.id,e);return n&&(n.__documentReference=void 0),n};return Array.isArray(e)?(await Promise.all(e.map(e=>t(e)))).filter(e=>e):t(e)}static isPopulated(e){return Array.isArray(e)?e.reduce((e,t)=>e&&t.__documentReference===void 0,!0):e.__documentReference===void 0}};Lf.error={shouldBeRegistered:`You should register a data source before using the data Store.`};var Rf=Lf,zf=class e{constructor(e){this._resolveCollectionPaths=()=>{throw Error(`The method collectionsMatchingTemplate has not been implemented in the concrete data source`)},this._disabledChangeListeners=new Set,this._collectionsToWatch={},e&&(this._beforeUpdate=e.beforeUpdateDocument,this._afterUpdate=e.afterUpdateDocument,this._afterDocumentChange=e.afterDocumentChange,this._beforeDocumentChange=e.beforeDocumentChange,this._beforeQueryOwnerCollection=e.beforeQueryOwnerCollection),this.installUpdaters()}installUpdaters(){let e=q.getSystemRegisteredReferencesWithCachedProps();this._collectionsToWatch={},Object.entries(e).forEach(([e,t])=>{t.forEach(t=>{t.typeName&&(Array.isArray(t.typeName)?t.typeName:[t?.typeName??e]).map(e=>q.collectionPath(q.createInstance(e),t)).forEach(e=>{this._collectionsToWatch[e]||(this._collectionsToWatch[e]=[]),this._collectionsToWatch[e].find(e=>e.name===t.name&&e.ownerClassName()===t.ownerClassName())||this._collectionsToWatch[e].push(t)})})})}set beforeDocumentChange(e){this._beforeDocumentChange=e}set afterDocumentChange(e){this._afterDocumentChange=e}set beforeUpdateDocument(e){this._beforeUpdate=e}set afterUpdateDocument(e){this._afterUpdate=e}set beforeQueryOwnerCollection(e){this._beforeQueryOwnerCollection=e}set resolveCollectionPaths(e){this._resolveCollectionPaths=e}get collectionsToWatch(){return this._collectionsToWatch}updateProps(e,t){let n=this._collectionsToWatch[e];return n?this.onDocumentChange(t,n):Promise.resolve()}async onDocumentChange(t,n){let r=Bf.toPersistentDocumentChange(t);this._beforeDocumentChange?.(r,n);let i={};t.type!==`update`||!r.before||r.after?.id&&this._disabledChangeListeners.has(r.after?.id)||(await Promise.all(n.map(async t=>{let n=e.ownerCollectionPath(q.createInstance(t.ownerClassName()),t,r.params),a=await this._resolveCollectionPaths(n);await Promise.all(a.map(async e=>{let n=Rf.getModel(e),a=n.find(),o=!1;t.cachedProps?.forEach(e=>{r.before[e]!==r.after[e]&&(o=!0)}),o&&(a=t.searchableArray?a.where(t.name,`contains`,r.before):a.where(t.name,`==`,r.before)),a=this._beforeQueryOwnerCollection?.(a)??a;let s=await a.get();return i[e]={totalDocumentsToUpdate:s.length,updatedDocuments:[],documentsToUpdate:s.map(e=>e.name??e.id)},Promise.all([s.map(async a=>{let o=!1;if(t.cachedProps?.forEach(e=>{r.before[e]!==r.after[e]&&(o=!0)}),o){if(t.searchableArray){let e=a[t.name].findIndex(e=>e.id===r.before.id);a[t.name][e]=r.after}else a[`_${t.name}`]=r.after;this._beforeUpdate?.(a,t),this.disableChangeListener(a),await n.save(a),this.enableChangeListener(a),i[e]?.updatedDocuments.push(a.id),this._afterUpdate?.(a,t)}else return Promise.resolve()})])}))})),this._afterDocumentChange?.(i,n))}disableChangeListener(e){this._disabledChangeListeners.add(e.id)}enableChangeListener(e){this._disabledChangeListeners.delete(e.id)}static ownerCollectionPath(e,t,n){let r;return r=typeof t.ownerCollection==`function`?t.ownerCollection(e,t,n):t.ownerCollection??e.className,r}},Bf=class e{constructor(){this._cachedPropsUpdater=void 0}installCachedPropsUpdater(e){return this._cachedPropsUpdater=new zf(e),this._cachedPropsUpdater.resolveCollectionPaths=this.resolveCollectionPaths.bind(this),this._cachedPropsUpdater}get cachedPropsUpdater(){return this._cachedPropsUpdater}static toPropertyPathOperations(t){return t?t.map(t=>{if(e.isArrayOperator(t.operator)&&t.value[0]instanceof q)return{property:q.searchableArrayNameFor(t.property),operator:t.operator,value:t.value.map(e=>e.id),aggregate:t.aggregate};let[n,r]=this.toPropertyPathValue(t.value);return{property:`${String(t.property)}${n?`.`+n:``}`,operator:t.operator,value:r,aggregate:t.aggregate}}):[]}static isArrayOperator(e){return e===`containsAny`||e===`contains`}static toPersistentDocumentChange(e){return{...e,before:e.before&&q.createInstance(e.before),after:e.after&&q.createInstance(e.after)}}static toPropertyPathValue(e){if(typeof e==`object`&&!Array.isArray(e)){let t=Object.keys(e)[0],[n,r]=this.toPropertyPathValue(e[t]);return[`${t}${n?`.`+n:``}`,r]}else return[void 0,e]}static isStringMatchingTemplate(e,t){let n=e.split(`/`),r=t.split(`/`);if(r.length>n.length)return!1;for(let e=0;e<r.length;e++){let t=n[e],i=r[e];if(!(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith("${")&&t.endsWith(`}`))&&t!==i)return!1}for(let e=r.length;e<n.length;e++){let t=n[e];if(!(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith("${")&&t.endsWith(`}`)))return!1}return!0}static extractTemplateParams(e,t){let n=t.split(`/`),r=e.split(`/`),i={};if(r.length>n.length)return i;for(let e=0;e<r.length;e++){let t=n[e],a=r[e];if(t.startsWith(`{`)&&t.endsWith(`}`))i[t.slice(1,-1)]=a;else if(t.startsWith("${")&&t.endsWith(`}`))i[t.slice(2,-1)]=a;else if(t!==a)return{}}for(let e=r.length;e<n.length;e++){let t=n[e];if(!(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith("${")&&t.endsWith(`}`)))return{}}return i}},Vf=class e{static registerCloudStorage(t,n){e._cloudStorageFactoryMap[t]=n}static createInstance(t){let n=e._cloudStorageFactoryMap[t];if(!n)throw Error(`You should register the ${t} cloud storage provider prior to use it`);return n()}get className(){return this.__className}static useCloudStorage(t){e._defaultCloudStorage=t}static get defaultCloudStorage(){if(!e._defaultCloudStorage)throw Error(`You should define a default cloud storage provider prior to use it`);return e._defaultCloudStorage}};Vf._cloudStorageFactoryMap={};var Hf=Vf;function Uf(e,t){return Hf.registerCloudStorage(e,t),t=>{t.prototype.__className=e}}var Wf=Object.getOwnPropertyDescriptor,Gf=(e,t,n,r)=>{for(var i=r>1?void 0:r?Wf(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=o(i)||i);return i},Kf=class extends Hf{constructor(e=``){super(),this._simulateDelay=0,this._pendingPromises=[],this.mockFileSystem={},this._pathToMockFiles=e}simulateDelay(e){return this._simulateDelay=e,this}resolveWithDelay(e){if(this._simulateDelay<=0)return Promise.resolve(e);let t=new Promise(t=>{setTimeout(()=>t(e),this._simulateDelay)});return this._pendingPromises.push(t),t.finally(()=>this._pendingPromises=this._pendingPromises.filter(e=>e===t)),t}save(e,t){let n=e;this._onProgress&&this._onProgress(0,100),this.mockFileSystem[e]=JSON.stringify(t),this._onProgress&&this._onProgress(100,100);let r=t instanceof File?t.name:n;return this.resolveWithDelay(r)}uploadControl(){return{resume:()=>{},pause:()=>{},cancel:()=>{},onProgress:e=>this._onProgress=e}}getUrl(e){return Promise.resolve(this._pathToMockFiles+e)}delete(e){return delete this.mockFileSystem[e],this.resolveWithDelay()}};Kf=Gf([Uf(`MockCloudStorage`,()=>new Kf)],Kf);var qf=Object.defineProperty,Jf=Object.getOwnPropertyDescriptor,Yf=(e,t,n,r)=>{for(var i=r>1?void 0:r?Jf(t,n):t,a=e.length-1,o;a>=0;a--)(o=e[a])&&(i=(r?o(t,n,i):o(i))||i);return r&&i&&qf(t,n,i),i},Xf=(e=>(e[e.stored=0]=`stored`,e[e.pendingDataSet=1]=`pendingDataSet`,e[e.deleted=2]=`deleted`,e))(Xf||{}),Zf=class extends q{constructor(){super(...arguments),this._onChange=new bf}async save({data:e,fileName:t,progress:n,cloudStorageProvider:r}={}){let i=e||this._pendingData;i&&(this._reference&&await this.delete(),this.provider=r||Hf.defaultCloudStorage,this._originalFileName=t||(i instanceof File?i.name:void 0),this._reference=await this.provider.save(this.id,i,n),this._url=await this.provider.getUrl(this._reference),this._pendingData=void 0,this._onChange.notify({event:0,storedFile:this}))}uploadControl(){return this.provider.uploadControl()}async delete(){if(!this._reference)throw Error(`Cannot delete a not stored file`);await this.provider.delete(this._reference),this._reference=void 0,this._url=void 0,this._onChange.notify({event:2,storedFile:this})}set provider(e){this._provider=e,this._cloudStorageProviderName=e.className}get provider(){if(!this._provider)try{this._provider=Hf.createInstance(this._cloudStorageProviderName)}catch{this._provider=Hf.defaultCloudStorage}return this._provider}get url(){return this._url}get mimeType(){return this._mimeType}setDataToStore(e){return this._pendingData=e,this._originalFileName=e instanceof File?e.name:void 0,this._mimeType=e instanceof Blob?e.type:void 0,this._onChange.notify({event:1,pendingData:e,storedFile:this}),this}get originalFileName(){return this._originalFileName}onChange(e){return this._onChange.subscribe(e)}};Yf([jf],Zf.prototype,`_reference`,2),Yf([jf],Zf.prototype,`_url`,2),Yf([jf],Zf.prototype,`_cloudStorageProviderName`,2),Yf([jf],Zf.prototype,`_originalFileName`,2),Yf([jf],Zf.prototype,`_mimeType`,2),Zf=Yf([Nf(`StoredFile`)],Zf);var Qf=class{},$f=class e extends Qf{constructor(){if(super(),this._onAuthStateChange=new bf,!e._authService)throw Error(e.error.shouldBeRegistered);e._authService.onAuthStateChange(e=>this.authStateChanged(e))}static useAuthService(t){e._authService!=t&&(e._authService=t,this._instance=void 0)}static get instance(){return this._instance||=new this}signUp(t){return e._authService.signUp(t)}login(t){return e._authService.login(t)}logout(){return e._authService.logout()}resetEmailPassword(t){return e._authService.resetEmailPassword(t)}resendVerificationEmail(t,n,r){return e._authService.resendVerificationEmail(t,n,r)}refreshToken(){return e._authService.refreshToken()}onAuthStateChange(e){return this._onAuthStateChange.subscribe(e)}removeAuthStateChange(e){this._onAuthStateChange.unsubscribe(e)}linkAdditionalProvider(t){return e._authService.linkAdditionalProvider(t)}unlinkProvider(t){return e._authService.unlinkProvider(t)}authStateChanged(e){this._onAuthStateChange.notify(e)}};$f.error={shouldBeRegistered:`You should register an auth service before using Auth.`},$f._instance=void 0;var ep=class e{constructor(){}static useCloudFunctionsService(e){this._cloudFunctionsService!=e&&(this._cloudFunctionsService=e)}static get instance(){if(!this._cloudFunctionsService)throw Error(e.error.shouldBeRegistered);return e._instance||=new e}getRawFunction(t){return e._cloudFunctionsService.retrieveFunction(t)}getFunction(t){let n=e._cloudFunctionsService.callFunction,r=this.getRawFunction(t);return async e=>{let t=await n(r,this.processParam(e));return this.processResult(t)}}processParam(e){if(e!=null)return e instanceof q?e.toObject():Array.isArray(e)?e.map(e=>this.processParam(e)):typeof e==`object`?Object.entries(e).reduce((e,[t,n])=>(e[t]=this.processParam(n),e),{}):e}processResult(e){if(e!=null)return e.__className?q.createInstance(e):Array.isArray(e)?e.map(e=>this.processResult(e)):typeof e==`object`?Object.entries(e).reduce((e,[t,n])=>(e[t]=this.processResult(n),e),{}):e}};ep.error={shouldBeRegistered:`You should register a cloud functions service with useCloudFunctionsService static method before using CloudFunctions.`};var tp=class{},np=class e extends tp{constructor(){super()}static useServerAuthService(t){e._authService!=t&&(e._authService=t,this._instance=void 0)}static get instance(){if(!e._authService)throw Error(e.error.shouldBeRegistered);return this._instance||=new e}getUser(t){return e._authService.getUser(t)}updateUser(t,n){return e._authService.updateUser(t,n)}setCustomCredentials(t,n){return e._authService.setCustomCredentials(t,n)}deleteUser(t){return e._authService.deleteUser(t)}};np.error={shouldBeRegistered:`You should register a Server Auth service before using the Server Auth.`},np._instance=void 0;function rp(e){return e?e.replace(/([-_ ][\w])/g,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``).replace(` `,``)):``}$t(`firebase`,`12.11.0`,`app`);function ip(){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 ap=ip,op=new pe(`auth`,`Firebase`,ip()),sp=new Re(`@firebase/auth`);function cp(e,...t){sp.logLevel<=b.WARN&&sp.warn(`Auth (${Xt}): ${e}`,...t)}function lp(e,...t){sp.logLevel<=b.ERROR&&sp.error(`Auth (${Xt}): ${e}`,...t)}function up(e,...t){throw hp(e,...t)}function dp(e,...t){return hp(e,...t)}function fp(e,t,n){return new pe(`auth`,`Firebase`,{...ap(),[t]:n}).create(t,{appName:e.name})}function pp(e){return fp(e,`operation-not-supported-in-this-environment`,`Operations that alter the current user are not supported in conjunction with FirebaseServerApp`)}function mp(e,t,n){let r=n;if(!(t instanceof r))throw r.name!==t.constructor.name&&up(e,`argument-error`),fp(e,`argument-error`,`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function hp(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 op.create(e,...t)}function J(e,t,...n){if(!e)throw hp(t,...n)}function gp(e){let t=`INTERNAL ASSERTION FAILED: `+e;throw lp(t),Error(t)}function _p(e,t){e||gp(t)}function vp(){return typeof self<`u`&&self.location?.href||``}function yp(){return bp()===`http:`||bp()===`https:`}function bp(){return typeof self<`u`&&self.location?.protocol||null}function xp(){return typeof navigator<`u`&&navigator&&`onLine`in navigator&&typeof navigator.onLine==`boolean`&&(yp()||oe()||`connection`in navigator)?navigator.onLine:!0}function Sp(){if(typeof navigator>`u`)return null;let e=navigator;return e.languages&&e.languages[0]||e.language||null}var Cp=class{constructor(e,t){this.shortDelay=e,this.longDelay=t,_p(t>e,`Short delay should be less than long delay!`),this.isMobile=re()||se()}get(){return xp()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}};function wp(e,t){_p(e.emulator,`Emulator should always be set here`);let{url:n}=e.emulator;return t?`${n}${t.startsWith(`/`)?t.slice(1):t}`:n}var Tp=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;gp(`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;gp(`Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill`)}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<`u`&&`Response`in self)return self.Response;if(typeof globalThis<`u`&&globalThis.Response)return globalThis.Response;if(typeof Response<`u`)return Response;gp(`Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill`)}},Ep={CREDENTIAL_MISMATCH:`custom-token-mismatch`,MISSING_CUSTOM_TOKEN:`internal-error`,INVALID_IDENTIFIER:`invalid-email`,MISSING_CONTINUE_URI:`internal-error`,INVALID_PASSWORD:`wrong-password`,MISSING_PASSWORD:`missing-password`,INVALID_LOGIN_CREDENTIALS:`invalid-credential`,EMAIL_EXISTS:`email-already-in-use`,PASSWORD_LOGIN_DISABLED:`operation-not-allowed`,INVALID_IDP_RESPONSE:`invalid-credential`,INVALID_PENDING_TOKEN:`invalid-credential`,FEDERATED_USER_ID_ALREADY_LINKED:`credential-already-in-use`,MISSING_REQ_TYPE:`internal-error`,EMAIL_NOT_FOUND:`user-not-found`,RESET_PASSWORD_EXCEED_LIMIT:`too-many-requests`,EXPIRED_OOB_CODE:`expired-action-code`,INVALID_OOB_CODE:`invalid-action-code`,MISSING_OOB_CODE:`internal-error`,CREDENTIAL_TOO_OLD_LOGIN_AGAIN:`requires-recent-login`,INVALID_ID_TOKEN:`invalid-user-token`,TOKEN_EXPIRED:`user-token-expired`,USER_NOT_FOUND:`user-token-expired`,TOO_MANY_ATTEMPTS_TRY_LATER:`too-many-requests`,PASSWORD_DOES_NOT_MEET_REQUIREMENTS:`password-does-not-meet-requirements`,INVALID_CODE:`invalid-verification-code`,INVALID_SESSION_INFO:`invalid-verification-id`,INVALID_TEMPORARY_PROOF:`invalid-credential`,MISSING_SESSION_INFO:`missing-verification-id`,SESSION_EXPIRED:`code-expired`,MISSING_ANDROID_PACKAGE_NAME:`missing-android-pkg-name`,UNAUTHORIZED_DOMAIN:`unauthorized-continue-uri`,INVALID_OAUTH_CLIENT_ID:`invalid-oauth-client-id`,ADMIN_ONLY_OPERATION:`admin-restricted-operation`,INVALID_MFA_PENDING_CREDENTIAL:`invalid-multi-factor-session`,MFA_ENROLLMENT_NOT_FOUND:`multi-factor-info-not-found`,MISSING_MFA_ENROLLMENT_ID:`missing-multi-factor-info`,MISSING_MFA_PENDING_CREDENTIAL:`missing-multi-factor-session`,SECOND_FACTOR_EXISTS:`second-factor-already-in-use`,SECOND_FACTOR_LIMIT_EXCEEDED:`maximum-second-factor-count-exceeded`,BLOCKING_FUNCTION_ERROR_RESPONSE:`internal-error`,RECAPTCHA_NOT_ENABLED:`recaptcha-not-enabled`,MISSING_RECAPTCHA_TOKEN:`missing-recaptcha-token`,INVALID_RECAPTCHA_TOKEN:`invalid-recaptcha-token`,INVALID_RECAPTCHA_ACTION:`invalid-recaptcha-action`,MISSING_CLIENT_TYPE:`missing-client-type`,MISSING_RECAPTCHA_VERSION:`missing-recaptcha-version`,INVALID_RECAPTCHA_VERSION:`invalid-recaptcha-version`,INVALID_REQ_TYPE:`invalid-req-type`},Dp=[`/v1/accounts:signInWithCustomToken`,`/v1/accounts:signInWithEmailLink`,`/v1/accounts:signInWithIdp`,`/v1/accounts:signInWithPassword`,`/v1/accounts:signInWithPhoneNumber`,`/v1/token`],Op=new Cp(3e4,6e4);function Y(e,t){return e.tenantId&&!t.tenantId?{...t,tenantId:e.tenantId}:t}async function X(e,t,n,r,i={}){return kp(e,i,async()=>{let i={},a={};r&&(t===`GET`?a=r:i={body:JSON.stringify(r)});let o=ye({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 ae()||(c.referrerPolicy=`no-referrer`),e.emulatorConfig&&Ee(e.emulatorConfig.host)&&(c.credentials=`include`),Tp.fetch()(await jp(e,e.config.apiHost,n,o),c)})}async function kp(e,t,n){e._canInitEmulator=!1;let r={...Ep,...t};try{let t=new Np(e),i=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();let a=await i.json();if(`needConfirmation`in a)throw Pp(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 Pp(e,`credential-already-in-use`,a);if(t===`EMAIL_EXISTS`)throw Pp(e,`email-already-in-use`,a);if(t===`USER_DISABLED`)throw Pp(e,`user-disabled`,a);let o=r[t]||t.toLowerCase().replace(/[_\s]+/g,`-`);if(n)throw fp(e,o,n);up(e,o)}}catch(t){if(t instanceof fe)throw t;up(e,`network-request-failed`,{message:String(t)})}}async function Ap(e,t,n,r,i={}){let a=await X(e,t,n,r,i);return`mfaPendingCredential`in a&&up(e,`multi-factor-auth-required`,{_serverResponse:a}),a}async function jp(e,t,n,r){let i=`${t}${n}?${r}`,a=e,o=a.config.emulator?wp(e.config,i):`${e.config.apiScheme}://${i}`;return Dp.includes(n)&&(await a._persistenceManagerAvailable,a._getPersistenceType()===`COOKIE`)?a._getPersistence()._getFinalTarget(o).toString():o}function Mp(e){switch(e){case`ENFORCE`:return`ENFORCE`;case`AUDIT`:return`AUDIT`;case`OFF`:return`OFF`;default:return`ENFORCEMENT_STATE_UNSPECIFIED`}}var Np=class{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(dp(this.auth,`network-request-failed`)),Op.get())})}};function Pp(e,t,n){let r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);let i=dp(e,t,r);return i.customData._tokenResponse=n,i}function Fp(e){return e!==void 0&&e.enterprise!==void 0}var Ip=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 Mp(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 Lp(e,t){return X(e,`GET`,`/v2/recaptchaConfig`,Y(e,t))}async function Rp(e,t){return X(e,`POST`,`/v1/accounts:delete`,t)}async function zp(e,t){return X(e,`POST`,`/v1/accounts:update`,t)}async function Bp(e,t){return X(e,`POST`,`/v1/accounts:lookup`,t)}function Vp(e){if(e)try{let t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch{}}async function Hp(e,t=!1){let n=y(e),r=await n.getIdToken(t),i=Wp(r);J(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:Vp(Up(i.auth_time)),issuedAtTime:Vp(Up(i.iat)),expirationTime:Vp(Up(i.exp)),signInProvider:o||null,signInSecondFactor:a?.sign_in_second_factor||null}}function Up(e){return Number(e)*1e3}function Wp(e){let[t,n,r]=e.split(`.`);if(t===void 0||n===void 0||r===void 0)return lp(`JWT malformed, contained fewer than 3 sections`),null;try{let e=c(n);return e?JSON.parse(e):(lp(`Failed to decode base64 JWT payload`),null)}catch(e){return lp(`Caught error parsing JWT payload as JSON`,e?.toString()),null}}function Gp(e){let t=Wp(e);return J(t,`internal-error`),J(t.exp!==void 0,`internal-error`),J(t.iat!==void 0,`internal-error`),Number(t.exp)-Number(t.iat)}async function Kp(e,t,n=!1){if(n)return t;try{return await t}catch(t){throw t instanceof fe&&qp(t)&&e.auth.currentUser===e&&await e.auth.signOut(),t}}function qp({code:e}){return e===`auth/user-disabled`||e===`auth/user-token-expired`}var Jp=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()}},Yp=class{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Vp(this.lastLoginAt),this.creationTime=Vp(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}};async function Xp(e){let t=e.auth,n=await Kp(e,Bp(t,{idToken:await e.getIdToken()}));J(n?.users.length,t,`internal-error`);let r=n.users[0];e._notifyReloadListener(r);let i=r.providerUserInfo?.length?$p(r.providerUserInfo):[],a=Qp(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 Yp(r.createdAt,r.lastLoginAt),isAnonymous:c};Object.assign(e,l)}async function Zp(e){let t=y(e);await Xp(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}function Qp(e,t){return[...e.filter(e=>!t.some(t=>t.providerId===e.providerId)),...t]}function $p(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 em(e,t){let n=await kp(e,{},async()=>{let n=ye({grant_type:`refresh_token`,refresh_token:t}).slice(1),{tokenApiHost:r,apiKey:i}=e.config,a=await jp(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&&Ee(e.emulatorConfig.host)&&(s.credentials=`include`),Tp.fetch()(a,s)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function tm(e,t){return X(e,`POST`,`/v2/accounts:revokeToken`,Y(e,t))}var nm=class e{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){J(e.idToken,`internal-error`),J(e.idToken!==void 0,`internal-error`),J(e.refreshToken!==void 0,`internal-error`);let t=`expiresIn`in e&&e.expiresIn!==void 0?Number(e.expiresIn):Gp(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){J(e.length!==0,`internal-error`);let t=Gp(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(J(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 em(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&&(J(typeof r==`string`,`internal-error`,{appName:t}),o.refreshToken=r),i&&(J(typeof i==`string`,`internal-error`,{appName:t}),o.accessToken=i),a&&(J(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 gp(`not implemented`)}};function rm(e,t){J(typeof e==`string`||e===void 0,`internal-error`,{appName:t})}var im=class e{constructor({uid:e,auth:t,stsTokenManager:n,...r}){this.providerId=`firebase`,this.proactiveRefresh=new Jp(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 Yp(r.createdAt||void 0,r.lastLoginAt||void 0)}async getIdToken(e){let t=await Kp(this,this.stsTokenManager.getToken(this.auth,e));return J(t,this.auth,`internal-error`),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return Hp(this,e)}reload(){return Zp(this)}_assign(e){this!==e&&(J(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){J(!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 Xp(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(S(this.auth.app))return Promise.reject(pp(this.auth));let e=await this.getIdToken();return await Kp(this,Rp(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;J(d&&h,t,`internal-error`);let g=nm.fromJSON(this.name,h);J(typeof d==`string`,t,`internal-error`),rm(r,t.name),rm(i,t.name),J(typeof f==`boolean`,t,`internal-error`),J(typeof p==`boolean`,t,`internal-error`),rm(a,t.name),rm(o,t.name),rm(s,t.name),rm(c,t.name),rm(l,t.name),rm(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 nm;i.updateFromServerResponse(n);let a=new e({uid:n.localId,auth:t,stsTokenManager:i,isAnonymous:r});return await Xp(a),a}static async _fromGetAccountInfoResponse(t,n,r){let i=n.users[0];J(i.localId!==void 0,`internal-error`);let a=i.providerUserInfo===void 0?[]:$p(i.providerUserInfo),o=!(i.email&&i.passwordHash)&&!a?.length,s=new nm;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 Yp(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash)&&!a?.length};return Object.assign(c,l),c}},am=new Map;function om(e){_p(e instanceof Function,`Expected a class definition`);let t=am.get(e);return t?(_p(t instanceof e,`Instance stored in cache mismatched with class`),t):(t=new e,am.set(e,t),t)}var sm=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){}};sm.type=`NONE`;var cm=sm;function lm(e,t,n){return`firebase:${e}:${t}:${n}`}var um=class e{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;let{config:r,name:i}=this.auth;this.fullUserKey=lm(this.userKey,r.apiKey,i),this.fullPersistenceKey=lm(`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 Bp(this.auth,{idToken:e}).catch(()=>void 0);return t?im._fromGetAccountInfoResponse(this.auth,t,e):null}return im._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(om(cm),t,r);let i=(await Promise.all(n.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e),a=i[0]||om(cm),o=lm(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 Bp(t,{idToken:n}).catch(()=>void 0);if(!e)break;r=await im._fromGetAccountInfoResponse(t,e,n)}else r=im._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 dm(e){let t=e.toLowerCase();if(t.includes(`opera/`)||t.includes(`opr/`)||t.includes(`opios/`))return`Opera`;if(hm(t))return`IEMobile`;if(t.includes(`msie`)||t.includes(`trident/`))return`IE`;if(t.includes(`edge/`))return`Edge`;if(fm(t))return`Firefox`;if(t.includes(`silk/`))return`Silk`;if(_m(t))return`Blackberry`;if(vm(t))return`Webos`;if(pm(t))return`Safari`;if((t.includes(`chrome/`)||mm(t))&&!t.includes(`edge/`))return`Chrome`;if(gm(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 fm(e=_()){return/firefox\//i.test(e)}function pm(e=_()){let t=e.toLowerCase();return t.includes(`safari/`)&&!t.includes(`chrome/`)&&!t.includes(`crios/`)&&!t.includes(`android`)}function mm(e=_()){return/crios\//i.test(e)}function hm(e=_()){return/iemobile/i.test(e)}function gm(e=_()){return/android/i.test(e)}function _m(e=_()){return/blackberry/i.test(e)}function vm(e=_()){return/webos/i.test(e)}function ym(e=_()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function bm(e=_()){return ym(e)&&!!window.navigator?.standalone}function xm(){return ce()&&document.documentMode===10}function Sm(e=_()){return ym(e)||gm(e)||vm(e)||_m(e)||/windows phone/i.test(e)||hm(e)}function Cm(e,t=[]){let n;switch(e){case`Browser`:n=dm(_());break;case`Worker`:n=`${dm(_())}-${e}`;break;default:n=e}let r=t.length?t.join(`,`):`FirebaseCore-web`;return`${n}/JsCore/${Xt}/${r}`}var wm=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 Tm(e,t={}){return X(e,`GET`,`/v2/passwordPolicy`,Y(e,t))}var Em=6,Dm=class{constructor(e){let t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??Em,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)}},Om=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 Am(this),this.idTokenSubscription=new Am(this),this.beforeStateQueue=new wm(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=op,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=om(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await um.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 Bp(this,{idToken:e}),n=await im._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(S(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 J(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 Xp(e)}catch(e){if(e?.code!==`auth/network-request-failed`)return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=Sp()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(S(this.app))return Promise.reject(pp(this));let t=e?y(e):null;return t&&J(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&&J(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 S(this.app)?Promise.reject(pp(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return S(this.app)?Promise.reject(pp(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(om(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 Dm(await Tm(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 pe(`auth`,`Firebase`,e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{let n=this.onAuthStateChanged(()=>{n(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){let t={providerId:`apple.com`,tokenType:`ACCESS_TOKEN`,token:e,idToken:await this.currentUser.getIdToken()};this.tenantId!=null&&(t.tenantId=this.tenantId),await tm(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&&om(e)||this._popupRedirectResolver;J(t,this,`argument-error`),this.redirectPersistenceManager=await um.create(this,[om(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(J(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 J(this.persistenceManager,this,`internal-error`),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=Cm(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(S(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;let e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&cp(`Error while retrieving App Check token: ${e.error}`),e?.token}};function km(e){return y(e)}var Am=class{constructor(e){this.auth=e,this.observer=null,this.addObserver=Se(e=>this.observer=e)}get next(){return J(this.observer,this.auth,`internal-error`),this.observer.next.bind(this.observer)}},jm={async loadJS(){throw Error(`Unable to load external scripts`)},recaptchaV2Script:``,recaptchaEnterpriseScript:``,gapiScript:``};function Mm(e){jm=e}function Nm(e){return jm.loadJS(e)}function Pm(){return jm.recaptchaEnterpriseScript}function Fm(){return jm.gapiScript}function Im(e){return`__${e}${Math.floor(Math.random()*1e6)}`}var Lm=class{constructor(){this.enterprise=new Rm}ready(e){e()}execute(e,t){return Promise.resolve(`token`)}render(e,t){return``}},Rm=class{ready(e){e()}execute(e,t){return Promise.resolve(`token`)}render(e,t){return``}},zm=`recaptcha-enterprise`,Bm=`NO_RECAPTCHA`,Vm=class{constructor(e){this.type=zm,this.auth=km(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)=>{Lp(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 Ip(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;Fp(i)?i.enterprise.ready(()=>{i.enterprise.execute(t,{action:e}).then(e=>{n(e)}).catch(()=>{n(Bm)})}):r(Error(`No reCAPTCHA enterprise script loaded.`))}return this.auth.settings.appVerificationDisabledForTesting?new Lm().execute(`siteKey`,{action:`verify`}):new Promise((e,i)=>{n(this.auth).then(n=>{if(!t&&Fp(window.grecaptcha))r(n,e,i);else{if(typeof window>`u`){i(Error(`RecaptchaVerifier is only supported in browser`));return}let t=Pm();t.length!==0&&(t+=n),Nm(t).then(()=>{r(n,e,i)}).catch(e=>{i(e)})}}).catch(e=>{i(e)})})}};async function Hm(e,t,n,r=!1,i=!1){let a=new Vm(e),o;if(i)o=Bm;else try{o=await a.verify(n)}catch{o=await a.verify(n,!0)}let s={...t};if(n===`mfaSmsEnrollment`||n===`mfaSmsSignIn`){if(`phoneEnrollmentInfo`in s){let e=s.phoneEnrollmentInfo.phoneNumber,t=s.phoneEnrollmentInfo.recaptchaToken;Object.assign(s,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:t,captchaResponse:o,clientType:`CLIENT_TYPE_WEB`,recaptchaVersion:`RECAPTCHA_ENTERPRISE`}})}else if(`phoneSignInInfo`in s){let e=s.phoneSignInInfo.recaptchaToken;Object.assign(s,{phoneSignInInfo:{recaptchaToken:e,captchaResponse:o,clientType:`CLIENT_TYPE_WEB`,recaptchaVersion:`RECAPTCHA_ENTERPRISE`}})}return s}return r?Object.assign(s,{captchaResp:o}):Object.assign(s,{captchaResponse:o}),Object.assign(s,{clientType:`CLIENT_TYPE_WEB`}),Object.assign(s,{recaptchaVersion:`RECAPTCHA_ENTERPRISE`}),s}async function Um(e,t,n,r,i){return i===`EMAIL_PASSWORD_PROVIDER`?e._getRecaptchaConfig()?.isProviderEnabled(`EMAIL_PASSWORD_PROVIDER`)?r(e,await Hm(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 Hm(e,t,n,n===`getOobCode`))):Promise.reject(i)):i===`PHONE_PROVIDER`?e._getRecaptchaConfig()?.isProviderEnabled(`PHONE_PROVIDER`)?r(e,await Hm(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 Hm(e,t,n,!1,!0))):Promise.reject(i)):r(e,await Hm(e,t,n,!1,!0)):Promise.reject(i+` provider is not supported.`)}async function Wm(e){let t=km(e),n=new Ip(await Lp(t,{clientType:`CLIENT_TYPE_WEB`,version:`RECAPTCHA_ENTERPRISE`}));t.tenantId==null?t._agentRecaptchaConfig=n:t._tenantRecaptchaConfigs[t.tenantId]=n,n.isAnyProviderEnabled()&&new Vm(t).verify()}function Gm(e,t){let n=qt(e,`auth`);if(n.isInitialized()){let e=n.getImmediate();if(_e(n.getOptions(),t??{}))return e;up(e,`already-initialized`)}return n.initialize({options:t})}function Km(e,t){let n=t?.persistence||[],r=(Array.isArray(n)?n:[n]).map(om);t?.errorMap&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,t?.popupRedirectResolver)}function qm(e,t,n){let r=km(e);J(/^https?:\/\//.test(t),r,`invalid-emulator-scheme`);let i=!!n?.disableWarnings,a=Jm(t),{host:o,port:s}=Ym(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){J(r.config.emulator&&r.emulatorConfig,r,`emulator-config-failed`),J(_e(l,r.config.emulator)&&_e(u,r.emulatorConfig),r,`emulator-config-failed`);return}r.config.emulator=l,r.emulatorConfig=u,r.settings.appVerificationDisabledForTesting=!0,Ee(o)?De(`${a}//${o}${c}`):i||Zm()}function Jm(e){let t=e.indexOf(`:`);return t<0?``:e.substr(0,t+1)}function Ym(e){let t=Jm(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:Xm(r.substr(e.length+1))}}else{let[e,t]=r.split(`:`);return{host:e,port:Xm(t)}}}function Xm(e){if(!e)return null;let t=Number(e);return isNaN(t)?null:t}function Zm(){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 Qm=class{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return gp(`not implemented`)}_getIdTokenResponse(e){return gp(`not implemented`)}_linkToIdToken(e,t){return gp(`not implemented`)}_getReauthenticationResolver(e){return gp(`not implemented`)}};async function $m(e,t){return X(e,`POST`,`/v1/accounts:signUp`,t)}async function eh(e,t){return Ap(e,`POST`,`/v1/accounts:signInWithPassword`,Y(e,t))}async function th(e,t){return X(e,`POST`,`/v1/accounts:sendOobCode`,Y(e,t))}async function nh(e,t){return th(e,t)}async function rh(e,t){return th(e,t)}async function ih(e,t){return Ap(e,`POST`,`/v1/accounts:signInWithEmailLink`,Y(e,t))}async function ah(e,t){return Ap(e,`POST`,`/v1/accounts:signInWithEmailLink`,Y(e,t))}var oh=class e extends Qm{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 Um(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:`CLIENT_TYPE_WEB`},`signInWithPassword`,eh,`EMAIL_PASSWORD_PROVIDER`);case`emailLink`:return ih(e,{email:this._email,oobCode:this._password});default:up(e,`internal-error`)}}async _linkToIdToken(e,t){switch(this.signInMethod){case`password`:return Um(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:`CLIENT_TYPE_WEB`},`signUpPassword`,$m,`EMAIL_PASSWORD_PROVIDER`);case`emailLink`:return ah(e,{idToken:t,email:this._email,oobCode:this._password});default:up(e,`internal-error`)}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}};async function sh(e,t){return Ap(e,`POST`,`/v1/accounts:signInWithIdp`,Y(e,t))}var ch=`http://localhost`,lh=class e extends Qm{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):up(`argument-error`),n}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(t){let{providerId:n,signInMethod:r,...i}=typeof t==`string`?JSON.parse(t):t;if(!n||!r)return null;let a=new e(n,r);return a.idToken=i.idToken||void 0,a.accessToken=i.accessToken||void 0,a.secret=i.secret,a.nonce=i.nonce,a.pendingToken=i.pendingToken||null,a}_getIdTokenResponse(e){return sh(e,this.buildRequest())}_linkToIdToken(e,t){let n=this.buildRequest();return n.idToken=t,sh(e,n)}_getReauthenticationResolver(e){let t=this.buildRequest();return t.autoCreate=!1,sh(e,t)}buildRequest(){let e={requestUri:ch,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=ye(t)}return e}};async function uh(e,t){return X(e,`POST`,`/v1/accounts:sendVerificationCode`,Y(e,t))}async function dh(e,t){return Ap(e,`POST`,`/v1/accounts:signInWithPhoneNumber`,Y(e,t))}async function fh(e,t){let n=await Ap(e,`POST`,`/v1/accounts:signInWithPhoneNumber`,Y(e,t));if(n.temporaryProof)throw Pp(e,`account-exists-with-different-credential`,n);return n}var ph={USER_NOT_FOUND:`user-not-found`};async function mh(e,t){return Ap(e,`POST`,`/v1/accounts:signInWithPhoneNumber`,Y(e,{...t,operation:`REAUTH`}),ph)}var hh=class e extends Qm{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 dh(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return fh(e,{idToken:t,...this._makeVerificationRequest()})}_getReauthenticationResolver(e){return mh(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 gh(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 _h(e){let t=be(xe(e)).link,n=t?be(xe(t)).deep_link_id:null,r=be(xe(e)).deep_link_id;return(r?be(xe(r)).link:null)||r||n||t||e}var vh=class e{constructor(e){let t=be(xe(e)),n=t.apiKey??null,r=t.oobCode??null,i=gh(t.mode??null);J(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=_h(t);try{return new e(n)}catch{return null}}},yh=class e{constructor(){this.providerId=e.PROVIDER_ID}static credential(e,t){return oh._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){let n=vh.parseLink(t);return J(n,`argument-error`),oh._fromEmailAndCode(e,n.code,n.tenantId)}};yh.PROVIDER_ID=`password`,yh.EMAIL_PASSWORD_SIGN_IN_METHOD=`password`,yh.EMAIL_LINK_SIGN_IN_METHOD=`emailLink`;var bh=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}},xh=class extends bh{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}},Sh=class e extends xh{constructor(){super(`facebook.com`)}static credential(t){return lh._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}}};Sh.FACEBOOK_SIGN_IN_METHOD=`facebook.com`,Sh.PROVIDER_ID=`facebook.com`;var Ch=class e extends xh{constructor(){super(`google.com`),this.addScope(`profile`)}static credential(t,n){return lh._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}}};Ch.GOOGLE_SIGN_IN_METHOD=`google.com`,Ch.PROVIDER_ID=`google.com`;var wh=class e extends xh{constructor(){super(`github.com`)}static credential(t){return lh._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}}};wh.GITHUB_SIGN_IN_METHOD=`github.com`,wh.PROVIDER_ID=`github.com`;var Th=class e extends xh{constructor(){super(`twitter.com`)}static credential(t,n){return lh._fromParams({providerId:e.PROVIDER_ID,signInMethod:e.TWITTER_SIGN_IN_METHOD,oauthToken:t,oauthTokenSecret:n})}static credentialFromResult(t){return e.credentialFromTaggedObject(t)}static credentialFromError(t){return e.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;let{oauthAccessToken:n,oauthTokenSecret:r}=t;if(!n||!r)return null;try{return e.credential(n,r)}catch{return null}}};Th.TWITTER_SIGN_IN_METHOD=`twitter.com`,Th.PROVIDER_ID=`twitter.com`;async function Eh(e,t){return Ap(e,`POST`,`/v1/accounts:signUp`,Y(e,t))}var Dh=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 im._fromIdTokenResponse(t,r,i),providerId:Oh(r),_tokenResponse:r,operationType:n})}static async _forOperation(t,n,r){return await t._updateTokensIfNecessary(r,!0),new e({user:t,providerId:Oh(r),_tokenResponse:r,operationType:n})}};function Oh(e){return e.providerId?e.providerId:`phoneNumber`in e?`phone`:null}async function kh(e){if(S(e.app))return Promise.reject(pp(e));let t=km(e);if(await t._initializationPromise,t.currentUser?.isAnonymous)return new Dh({user:t.currentUser,providerId:null,operationType:`signIn`});let n=await Eh(t,{returnSecureToken:!0}),r=await Dh._fromIdTokenResponse(t,`signIn`,n,!0);return await t._updateCurrentUser(r.user),r}var Ah=class e extends fe{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 jh(e,t,n,r){return(t===`reauthenticate`?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(n=>{throw n.code===`auth/multi-factor-auth-required`?Ah._fromErrorAndOperation(e,n,t,r):n})}function Mh(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function Nh(e,t){let n=y(e);await Fh(!0,n,t);let{providerUserInfo:r}=await zp(n.auth,{idToken:await n.getIdToken(),deleteProvider:[t]}),i=Mh(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 Ph(e,t,n=!1){let r=await Kp(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return Dh._forOperation(e,`link`,r)}async function Fh(e,t,n){await Xp(t);let r=Mh(t.providerData),i=e===!1?`provider-already-linked`:`no-such-provider`;J(r.has(n)===e,t.auth,i)}async function Ih(e,t,n=!1){let{auth:r}=e;if(S(r.app))return Promise.reject(pp(r));let i=`reauthenticate`;try{let a=await Kp(e,jh(r,i,t,e),n);J(a.idToken,r,`internal-error`);let o=Wp(a.idToken);J(o,r,`internal-error`);let{sub:s}=o;return J(e.uid===s,r,`user-mismatch`),Dh._forOperation(e,i,a)}catch(e){throw e?.code===`auth/user-not-found`&&up(r,`user-mismatch`),e}}async function Lh(e,t,n=!1){if(S(e.app))return Promise.reject(pp(e));let r=`signIn`,i=await jh(e,r,t),a=await Dh._fromIdTokenResponse(e,r,i);return n||await e._updateCurrentUser(a.user),a}async function Rh(e,t){return Lh(km(e),t)}function zh(e,t,n){J(n.url?.length>0,e,`invalid-continue-uri`),J(n.dynamicLinkDomain===void 0||n.dynamicLinkDomain.length>0,e,`invalid-dynamic-link-domain`),J(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&&(J(n.iOS.bundleId.length>0,e,`missing-ios-bundle-id`),t.iOSBundleId=n.iOS.bundleId),n.android&&(J(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 Bh(e){let t=km(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function Vh(e,t,n){let r=km(e),i={requestType:`PASSWORD_RESET`,email:t,clientType:`CLIENT_TYPE_WEB`};n&&zh(r,i,n),await Um(r,i,`getOobCode`,rh,`EMAIL_PASSWORD_PROVIDER`)}async function Hh(e,t,n){if(S(e.app))return Promise.reject(pp(e));let r=km(e),i=await Um(r,{returnSecureToken:!0,email:t,password:n,clientType:`CLIENT_TYPE_WEB`},`signUpPassword`,Eh,`EMAIL_PASSWORD_PROVIDER`).catch(t=>{throw t.code===`auth/password-does-not-meet-requirements`&&Bh(e),t}),a=await Dh._fromIdTokenResponse(r,`signIn`,i);return await r._updateCurrentUser(a.user),a}function Uh(e,t,n){return S(e.app)?Promise.reject(pp(e)):Rh(y(e),yh.credential(t,n)).catch(async t=>{throw t.code===`auth/password-does-not-meet-requirements`&&Bh(e),t})}async function Wh(e,t){let n=y(e),r={requestType:`VERIFY_EMAIL`,idToken:await e.getIdToken()};t&&zh(n.auth,r,t);let{email:i}=await nh(n.auth,r);i!==e.email&&await e.reload()}async function Gh(e,t){return X(e,`POST`,`/v1/accounts:update`,t)}async function Kh(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 Kp(r,Gh(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 qh(e,t,n,r){return y(e).onIdTokenChanged(t,n,r)}function Jh(e,t,n){return y(e).beforeAuthStateChanged(t,n)}function Yh(e,t){return X(e,`POST`,`/v2/accounts/mfaEnrollment:start`,Y(e,t))}function Xh(e,t){return X(e,`POST`,`/v2/accounts/mfaEnrollment:finalize`,Y(e,t))}function Zh(e,t){return X(e,`POST`,`/v2/accounts/mfaEnrollment:start`,Y(e,t))}function Qh(e,t){return X(e,`POST`,`/v2/accounts/mfaEnrollment:finalize`,Y(e,t))}var $h=`__sak`,eg=class{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem($h,`1`),this.storage.removeItem($h),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()}},tg=1e3,ng=10,rg=class extends eg{constructor(){super(()=>window.localStorage,`LOCAL`),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=Sm(),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);xm()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(r,ng):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)})},tg)}stopPolling(){this.pollTimer&&=(clearInterval(this.pollTimer),null)}attachListener(){window.addEventListener(`storage`,this.boundEventHandler)}detachListener(){window.removeEventListener(`storage`,this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){let t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}};rg.type=`LOCAL`;var ig=rg,ag=1e3;function og(e){let t=e.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`),n=RegExp(`${t}=([^;]+)`);return document.cookie.match(n)?.[1]??null}function sg(e){return`${window.location.protocol===`http:`?`__dev_`:`__HOST-`}FIREBASE_${e.split(`:`)[3]}`}var cg=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=sg(e);return window.cookieStore?(await window.cookieStore.get(t))?.value:og(t)}async _remove(e){if(!this._isAvailable()||!await this._get(e))return;let t=sg(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=sg(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=og(n),i=setInterval(()=>{let e=og(n);e!==r&&(t(e),r=e)},ag);this.listenerUnsubscribes.set(t,()=>clearInterval(i))}_removeListener(e,t){let n=this.listenerUnsubscribes.get(t);n&&(n(),this.listenerUnsubscribes.delete(t))}};cg.type=`COOKIE`;var lg=class extends eg{constructor(){super(()=>window.sessionStorage,`SESSION`)}_addListener(e,t){}_removeListener(e,t){}};lg.type=`SESSION`;var ug=lg;function dg(e){return Promise.all(e.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}}))}var fg=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 dg(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)}};fg.receivers=[];function pg(e=``,t=10){let n=``;for(let e=0;e<t;e++)n+=Math.floor(Math.random()*10);return e+n}var mg=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=pg(``,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 hg(){return window}function gg(e){hg().location.href=e}function _g(){return hg().WorkerGlobalScope!==void 0&&typeof hg().importScripts==`function`}async function vg(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function yg(){return navigator?.serviceWorker?.controller||null}function bg(){return _g()?self:null}var xg=`firebaseLocalStorageDb`,Sg=1,Cg=`firebaseLocalStorage`,wg=`fbase_key`,Tg=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 Eg(e,t){return e.transaction([Cg],t?`readwrite`:`readonly`).objectStore(Cg)}function Dg(){return new Tg(indexedDB.deleteDatabase(xg)).toPromise()}function Og(){let e=indexedDB.open(xg,Sg);return new Promise((t,n)=>{e.addEventListener(`error`,()=>{n(e.error)}),e.addEventListener(`upgradeneeded`,()=>{let t=e.result;try{t.createObjectStore(Cg,{keyPath:wg})}catch(e){n(e)}}),e.addEventListener(`success`,async()=>{let n=e.result;n.objectStoreNames.contains(Cg)?t(n):(n.close(),await Dg(),t(await Og()))})})}async function kg(e,t,n){return new Tg(Eg(e,!0).put({[wg]:t,value:n})).toPromise()}async function Ag(e,t){let n=await new Tg(Eg(e,!1).get(t)).toPromise();return n===void 0?null:n.value}function jg(e,t){return new Tg(Eg(e,!0).delete(t)).toPromise()}var Mg=800,Ng=3,Pg=class{constructor(){this.type=`LOCAL`,this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db||=await Og(),this.db}async _withRetries(e){let t=0;for(;;)try{return await e(await this._openDb())}catch(e){if(t++>Ng)throw e;this.db&&=(this.db.close(),void 0)}}async initializeServiceWorkerMessaging(){return _g()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=fg._getInstance(bg()),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 vg(),!this.activeServiceWorker)return;this.sender=new mg(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||yg()!==this.activeServiceWorker))try{await this.sender._send(`keyChanged`,{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{if(!indexedDB)return!1;let e=await Og();return await kg(e,$h,`1`),await jg(e,$h),!0}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(n=>kg(n,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){let t=await this._withRetries(t=>Ag(t,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>jg(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){let e=await this._withRetries(e=>new Tg(Eg(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(),Mg)}stopPolling(){this.pollTimer&&=(clearInterval(this.pollTimer),null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&this.stopPolling()}};Pg.type=`LOCAL`;var Fg=Pg;function Ig(e,t){return X(e,`POST`,`/v2/accounts/mfaSignIn:start`,Y(e,t))}function Lg(e,t){return X(e,`POST`,`/v2/accounts/mfaSignIn:finalize`,Y(e,t))}function Rg(e,t){return X(e,`POST`,`/v2/accounts/mfaSignIn:finalize`,Y(e,t))}Im(`rcb`),new Cp(3e4,6e4);var zg=`recaptcha`;async function Bg(e,t,n){if(!e._getRecaptchaConfig())try{await Wm(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 J(t.type===`enroll`,e,`internal-error`),(await Um(e,{idToken:t.credential,phoneEnrollmentInfo:{phoneNumber:r.phoneNumber,clientType:`CLIENT_TYPE_WEB`}},`mfaSmsEnrollment`,async(e,t)=>t.phoneEnrollmentInfo.captchaResponse===Bm?(J(n?.type===zg,e,`argument-error`),Yh(e,await Vg(e,t,n))):Yh(e,t),`PHONE_PROVIDER`).catch(e=>Promise.reject(e))).phoneSessionInfo.sessionInfo;{J(t.type===`signin`,e,`internal-error`);let i=r.multiFactorHint?.uid||r.multiFactorUid;return J(i,e,`missing-multi-factor-info`),(await Um(e,{mfaPendingCredential:t.credential,mfaEnrollmentId:i,phoneSignInInfo:{clientType:`CLIENT_TYPE_WEB`}},`mfaSmsSignIn`,async(e,t)=>t.phoneSignInInfo.captchaResponse===Bm?(J(n?.type===zg,e,`argument-error`),Ig(e,await Vg(e,t,n))):Ig(e,t),`PHONE_PROVIDER`).catch(e=>Promise.reject(e))).phoneResponseInfo.sessionInfo}}else return(await Um(e,{phoneNumber:r.phoneNumber,clientType:`CLIENT_TYPE_WEB`},`sendVerificationCode`,async(e,t)=>t.captchaResponse===Bm?(J(n?.type===zg,e,`argument-error`),uh(e,await Vg(e,t,n))):uh(e,t),`PHONE_PROVIDER`).catch(e=>Promise.reject(e))).sessionInfo}finally{n?._reset()}}async function Vg(e,t,n){J(n.type===zg,e,`argument-error`);let r=await n.verify();J(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 Hg=class e{constructor(t){this.providerId=e.PROVIDER_ID,this.auth=km(t)}verifyPhoneNumber(e,t){return Bg(this.auth,e,y(t))}static credential(e,t){return hh._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?hh._fromTokenResponse(t,n):null}};Hg.PROVIDER_ID=`phone`,Hg.PHONE_SIGN_IN_METHOD=`phone`;function Ug(e,t){return t?om(t):(J(e._popupRedirectResolver,e,`argument-error`),e._popupRedirectResolver)}var Wg=class extends Qm{constructor(e){super(`custom`,`custom`),this.params=e}_getIdTokenResponse(e){return sh(e,this._buildIdpRequest())}_linkToIdToken(e,t){return sh(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return sh(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 Gg(e){return Lh(e.auth,new Wg(e),e.bypassAuthState)}function Kg(e){let{auth:t,user:n}=e;return J(n,t,`internal-error`),Ih(n,new Wg(e),e.bypassAuthState)}async function qg(e){let{auth:t,user:n}=e;return J(n,t,`internal-error`),Ph(n,new Wg(e),e.bypassAuthState)}var Jg=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 Gg;case`linkViaPopup`:case`linkViaRedirect`:return qg;case`reauthViaPopup`:case`reauthViaRedirect`:return Kg;default:up(this.auth,`internal-error`)}}resolve(e){_p(this.pendingPromise,`Pending promise was never set`),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){_p(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()}},Yg=new Cp(2e3,1e4);async function Xg(e,t,n){if(S(e.app))return Promise.reject(dp(e,`operation-not-supported-in-this-environment`));let r=km(e);return mp(e,t,bh),new Qg(r,`signInViaPopup`,t,Ug(r,n)).executeNotNull()}async function Zg(e,t,n){let r=y(e);mp(r.auth,t,bh);let i=Ug(r.auth,n);return new Qg(r.auth,`linkViaPopup`,t,i,r).executeNotNull()}var Qg=class e extends Jg{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 J(e,this.auth,`internal-error`),e}async onExecution(){_p(this.filter.length===1,`Popup operations only handle one event`);let e=pg();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(dp(this.auth,`web-storage-unsupported`))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(dp(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(dp(this.auth,`popup-closed-by-user`))},8e3);return}this.pollId=window.setTimeout(e,Yg.get())};e()}};Qg.currentPopupAction=null;var $g=`pendingRedirect`,e_=new Map,t_=class extends Jg{constructor(e,t,n=!1){super(e,[`signInViaRedirect`,`linkViaRedirect`,`reauthViaRedirect`,`unknown`],t,void 0,n),this.eventId=null}async execute(){let e=e_.get(this.auth._key());if(!e){try{let t=await n_(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(t)}catch(t){e=()=>Promise.reject(t)}e_.set(this.auth._key(),e)}return this.bypassAuthState||e_.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 n_(e,t){let n=a_(t),r=i_(e);if(!await r._isAvailable())return!1;let i=await r._get(n)===`true`;return await r._remove(n),i}function r_(e,t){e_.set(e._key(),t)}function i_(e){return om(e._redirectPersistence)}function a_(e){return lm($g,e.config.apiKey,e.name)}async function o_(e,t,n=!1){if(S(e.app))return Promise.reject(pp(e));let r=km(e),i=await new t_(r,Ug(r,t),n).execute();return i&&!n&&(delete i.user._redirectEventId,await r._persistUserIfCurrent(i.user),await r._setRedirectUser(null,t)),i}var s_=600*1e3,c_=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||!d_(e)?t:(this.hasHandledPotentialRedirect=!0,t||=(this.queuedRedirectEvent=e,!0),t)}sendToConsumer(e,t){if(e.error&&!u_(e)){let n=e.error.code?.split(`auth/`)[1]||`internal-error`;t.onError(dp(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>=s_&&this.cachedEventUids.clear(),this.cachedEventUids.has(l_(e))}saveEventToCache(e){this.cachedEventUids.add(l_(e)),this.lastProcessedEventTime=Date.now()}};function l_(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join(`-`)}function u_({type:e,error:t}){return e===`unknown`&&t?.code===`auth/no-auth-event`}function d_(e){switch(e.type){case`signInViaRedirect`:case`linkViaRedirect`:case`reauthViaRedirect`:return!0;case`unknown`:return u_(e);default:return!1}}async function f_(e,t={}){return X(e,`GET`,`/v1/projects`,t)}var p_=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,m_=/^https?/;async function h_(e){if(e.config.emulator)return;let{authorizedDomains:t}=await f_(e);for(let e of t)try{if(g_(e))return}catch{}up(e,`unauthorized-domain`)}function g_(e){let t=vp(),{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(!m_.test(n))return!1;if(p_.test(e))return r===e;let i=e.replace(/\./g,`\\.`);return RegExp(`^(.+\\.`+i+`|`+i+`)$`,`i`).test(r)}var __=new Cp(3e4,6e4);function v_(){let e=hg().___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 y_(e){return new Promise((t,n)=>{function r(){v_(),gapi.load(`gapi.iframes`,{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{v_(),n(dp(e,`network-request-failed`))},timeout:__.get()})}if(hg().gapi?.iframes?.Iframe)t(gapi.iframes.getContext());else if(hg().gapi?.load)r();else{let t=Im(`iframefcb`);return hg()[t]=()=>{gapi.load?r():n(dp(e,`network-request-failed`))},Nm(`${Fm()}?onload=${t}`).catch(e=>n(e))}}).catch(e=>{throw b_=null,e})}var b_=null;function x_(e){return b_||=y_(e),b_}var S_=new Cp(5e3,15e3),C_=`__/auth/iframe`,w_=`emulator/auth/iframe`,T_={style:{position:`absolute`,top:`-100px`,width:`1px`,height:`1px`},"aria-hidden":`true`,tabindex:`-1`},E_=new Map([[`identitytoolkit.googleapis.com`,`p`],[`staging-identitytoolkit.sandbox.googleapis.com`,`s`],[`test-identitytoolkit.sandbox.googleapis.com`,`t`]]);function D_(e){let t=e.config;J(t.authDomain,e,`auth-domain-config-required`);let n=t.emulator?wp(t,w_):`https://${e.config.authDomain}/${C_}`,r={apiKey:t.apiKey,appName:e.name,v:Xt},i=E_.get(e.config.apiHost);i&&(r.eid=i);let a=e._getFrameworks();return a.length&&(r.fw=a.join(`,`)),`${n}?${ye(r).slice(1)}`}async function O_(e){let t=await x_(e),n=hg().gapi;return J(n,e,`internal-error`),t.open({where:document.body,url:D_(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:T_,dontclear:!0},t=>new Promise(async(n,r)=>{await t.restyle({setHideOnLeave:!1});let i=dp(e,`network-request-failed`),a=hg().setTimeout(()=>{r(i)},S_.get());function o(){hg().clearTimeout(a),n(t)}t.ping(o).then(o,()=>{r(i)})}))}var k_={location:`yes`,resizable:`yes`,statusbar:`yes`,toolbar:`no`},A_=500,j_=600,M_=`_blank`,N_=`http://localhost`,P_=class{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}};function F_(e,t,n,r=A_,i=j_){let a=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString(),s=``,c={...k_,width:r.toString(),height:i.toString(),top:a,left:o},l=_().toLowerCase();n&&(s=mm(l)?M_:n),fm(l)&&(t||=N_,c.scrollbars=`yes`);let u=Object.entries(c).reduce((e,[t,n])=>`${e}${t}=${n},`,``);if(bm(l)&&s!==`_self`)return I_(t||``,s),new P_(null);let d=window.open(t||``,s,u);J(d,e,`popup-blocked`);try{d.focus()}catch{}return new P_(d)}function I_(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 L_=`__/auth/handler`,R_=`emulator/auth/handler`,z_=`fac`;async function B_(e,t,n,r,i,a){J(e.config.authDomain,e,`auth-domain-config-required`),J(e.config.apiKey,e,`invalid-api-key`);let o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:Xt,eventId:i};if(t instanceof bh){t.setDefaultLanguage(e.languageCode),o.providerId=t.providerId||``,ge(t.getCustomParameters())||(o.customParameters=JSON.stringify(t.getCustomParameters()));for(let[e,t]of Object.entries(a||{}))o[e]=t}if(t instanceof xh){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?`#${z_}=${encodeURIComponent(c)}`:``;return`${V_(e)}?${ye(s).slice(1)}${l}`}function V_({config:e}){return e.emulator?wp(e,R_):`https://${e.authDomain}/${L_}`}var H_=`webStorageSupport`,U_=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=ug,this._completeRedirectFn=o_,this._overrideRedirectResult=r_}async _openPopup(e,t,n,r){return _p(this.eventManagers[e._key()]?.manager,`_initialize() not called before _openPopup()`),F_(e,await B_(e,t,n,vp(),r),pg())}async _openRedirect(e,t,n,r){return await this._originValidation(e),gg(await B_(e,t,n,vp(),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):(_p(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 O_(e),n=new c_(e);return t.register(`authEvent`,t=>(J(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(H_,{type:H_},n=>{let r=n?.[0]?.[H_];r!==void 0&&t(!!r),up(e,`internal-error`)},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){let t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=h_(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return Sm()||pm()||ym()}},W_=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 gp(`unexpected MultiFactorSessionType`)}}},G_=class e extends W_{constructor(e){super(`phone`),this.credential=e}static _fromCredential(t){return new e(t)}_finalizeEnroll(e,t,n){return Xh(e,{idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()})}_finalizeSignIn(e,t){return Lg(e,{mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()})}},K_=class{constructor(){}static assertion(e){return G_._fromCredential(e)}};K_.FACTOR_ID=`phone`;var q_=class{static assertionForEnrollment(e,t){return J_._fromSecret(e,t)}static assertionForSignIn(e,t){return J_._fromEnrollmentId(e,t)}static async generateSecret(e){let t=e;J(t.user?.auth!==void 0,`internal-error`);let n=await Zh(t.user.auth,{idToken:t.credential,totpEnrollmentInfo:{}});return Y_._fromStartTotpMfaEnrollmentResponse(n,t.user.auth)}};q_.FACTOR_ID=`totp`;var J_=class e extends W_{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 J(this.secret!==void 0,e,`argument-error`),Qh(e,{idToken:t,displayName:n,totpVerificationInfo:this.secret._makeTotpVerificationInfo(this.otp)})}async _finalizeSignIn(e,t){J(this.enrollmentId!==void 0&&this.otp!==void 0,e,`argument-error`);let n={verificationCode:this.otp};return Rg(e,{mfaPendingCredential:t,mfaEnrollmentId:this.enrollmentId,totpVerificationInfo:n})}},Y_=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(X_(e)||X_(t))&&(n=!0),n&&(X_(e)&&(e=this.auth.currentUser?.email||`unknownuser`),X_(t)&&(t=this.auth.name)),`otpauth://totp/${t}:${e}?secret=${this.secretKey}&issuer=${t}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`}};function X_(e){return e===void 0||e?.length===0}var Z_=`@firebase/auth`,Q_=`1.12.2`,$_=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(){J(this.auth._initializationPromise,`dependent-sdk-initialized-before-auth`)}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}};function ev(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 tv(e){Kt(new Oe(`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;J(o&&!o.includes(`:`),`invalid-api-key`,{appName:r.name});let c=new Om(r,i,a,{apiKey:o,authDomain:s,clientPlatform:e,apiHost:`identitytoolkit.googleapis.com`,tokenApiHost:`securetoken.googleapis.com`,apiScheme:`https`,sdkClientVersion:Cm(e)});return Km(c,n),c},`PUBLIC`).setInstantiationMode(`EXPLICIT`).setInstanceCreatedCallback((e,t,n)=>{e.getProvider(`auth-internal`).initialize()})),Kt(new Oe(`auth-internal`,e=>(e=>new $_(e))(km(e.getProvider(`auth`).getImmediate())),`PRIVATE`).setInstantiationMode(`EXPLICIT`)),$t(Z_,Q_,ev(e)),$t(Z_,Q_,`esm2020`)}var nv=ee(`authIdTokenMaxAge`)||300,rv=null,iv=e=>async t=>{let n=t&&await t.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>nv)return;let i=n?.token;rv!==i&&(rv=i,await fetch(e,{method:i?`POST`:`DELETE`,headers:i?{Authorization:`Bearer ${i}`}:{}}))};function av(e=Qt()){let t=qt(e,`auth`);if(t.isInitialized())return t.getImmediate();let n=Gm(e,{popupRedirectResolver:U_,persistence:[Fg,ig,ug]}),r=ee(`authTokenSyncURL`);if(r&&typeof isSecureContext==`boolean`&&isSecureContext){let e=new URL(r,location.origin);if(location.origin===e.origin){let t=iv(e.toString());Jh(n,t,()=>t(n.currentUser)),qh(n,e=>t(e))}}let i=m(`auth`);return i&&qm(n,`http://${i}`),n}function ov(){return document.getElementsByTagName(`head`)?.[0]??document}Mm({loadJS(e){return new Promise((t,n)=>{let r=document.createElement(`script`);r.setAttribute(`src`,e),r.onload=t,r.onerror=e=>{let t=dp(`internal-error`);t.customData=e,n(t)},r.type=`text/javascript`,r.charset=`UTF-8`,ov().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=`}),tv(`Browser`);var sv=`firebasestorage.googleapis.com`,cv=`storageBucket`,lv=120*1e3,uv=600*1e3,dv=1e3,Z=class e extends fe{constructor(t,n,r=0){super(fv(t),`Firebase Storage: ${n} (${fv(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 fv(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}\n${this.customData.serverResponse}`:this.message=this._baseMessage}},Q;(function(e){e.UNKNOWN=`unknown`,e.OBJECT_NOT_FOUND=`object-not-found`,e.BUCKET_NOT_FOUND=`bucket-not-found`,e.PROJECT_NOT_FOUND=`project-not-found`,e.QUOTA_EXCEEDED=`quota-exceeded`,e.UNAUTHENTICATED=`unauthenticated`,e.UNAUTHORIZED=`unauthorized`,e.UNAUTHORIZED_APP=`unauthorized-app`,e.RETRY_LIMIT_EXCEEDED=`retry-limit-exceeded`,e.INVALID_CHECKSUM=`invalid-checksum`,e.CANCELED=`canceled`,e.INVALID_EVENT_NAME=`invalid-event-name`,e.INVALID_URL=`invalid-url`,e.INVALID_DEFAULT_BUCKET=`invalid-default-bucket`,e.NO_DEFAULT_BUCKET=`no-default-bucket`,e.CANNOT_SLICE_BLOB=`cannot-slice-blob`,e.SERVER_FILE_WRONG_SIZE=`server-file-wrong-size`,e.NO_DOWNLOAD_URL=`no-download-url`,e.INVALID_ARGUMENT=`invalid-argument`,e.INVALID_ARGUMENT_COUNT=`invalid-argument-count`,e.APP_DELETED=`app-deleted`,e.INVALID_ROOT_OPERATION=`invalid-root-operation`,e.INVALID_FORMAT=`invalid-format`,e.INTERNAL_ERROR=`internal-error`,e.UNSUPPORTED_ENVIRONMENT=`unsupported-environment`})(Q||={});function fv(e){return`storage/`+e}function pv(){return new Z(Q.UNKNOWN,`An unknown error occurred, please check the error payload for server response.`)}function mv(e){return new Z(Q.OBJECT_NOT_FOUND,`Object '`+e+`' does not exist.`)}function hv(e){return new Z(Q.QUOTA_EXCEEDED,`Quota for bucket '`+e+`' exceeded, please view quota on https://firebase.google.com/pricing/.`)}function gv(){return new Z(Q.UNAUTHENTICATED,`User is not authenticated, please authenticate using Firebase Authentication and try again.`)}function _v(){return new Z(Q.UNAUTHORIZED_APP,`This app does not have permission to access Firebase Storage on this project.`)}function vv(e){return new Z(Q.UNAUTHORIZED,`User does not have permission to access '`+e+`'.`)}function yv(){return new Z(Q.RETRY_LIMIT_EXCEEDED,`Max retry time for operation exceeded, please try again.`)}function bv(){return new Z(Q.CANCELED,`User canceled the upload/download.`)}function xv(e){return new Z(Q.INVALID_URL,`Invalid URL '`+e+`'.`)}function Sv(e){return new Z(Q.INVALID_DEFAULT_BUCKET,`Invalid default bucket '`+e+`'.`)}function Cv(){return new Z(Q.NO_DEFAULT_BUCKET,`No default bucket found. Did you set the '`+cv+`' property when initializing the app?`)}function wv(){return new Z(Q.CANNOT_SLICE_BLOB,`Cannot slice blob for upload. Please retry the upload.`)}function Tv(){return new Z(Q.SERVER_FILE_WRONG_SIZE,`Server recorded incorrect upload file size, please retry the upload.`)}function Ev(){return new Z(Q.NO_DOWNLOAD_URL,`The given file does not have any download URLs.`)}function Dv(e){return new Z(Q.UNSUPPORTED_ENVIRONMENT,`${e} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function Ov(e){return new Z(Q.INVALID_ARGUMENT,e)}function kv(){return new Z(Q.APP_DELETED,`The Firebase app was deleted.`)}function Av(e){return new Z(Q.INVALID_ROOT_OPERATION,`The operation '`+e+`' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').`)}function jv(e,t){return new Z(Q.INVALID_FORMAT,`String does not match format '`+e+`': `+t)}function Mv(e){throw new Z(Q.INTERNAL_ERROR,`Internal error: `+e)}var Nv=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 Sv(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://`+i+`(/(.*))?$`,`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===sv?`(?: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 xv(t);return r}},Pv=class{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}};function Fv(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 Iv(e){e(!1)}function Lv(e){return e!==void 0}function Rv(e){return typeof e==`function`}function zv(e){return typeof e==`object`&&!Array.isArray(e)}function Bv(e){return typeof e==`string`||e instanceof String}function Vv(e){return Hv()&&e instanceof Blob}function Hv(){return typeof Blob<`u`}function Uv(e,t,n,r){if(r<t)throw Ov(`Invalid value for '${e}'. Expected ${t} or greater.`);if(r>n)throw Ov(`Invalid value for '${e}'. Expected ${n} or less.`)}function Wv(e,t,n){let r=t;return n??(r=`https://${t}`),`${n}://${r}/v0${e}`}function Gv(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 Kv;(function(e){e[e.NO_ERROR=0]=`NO_ERROR`,e[e.NETWORK_ERROR=1]=`NETWORK_ERROR`,e[e.ABORT=2]=`ABORT`})(Kv||={});function qv(e,t){let n=e>=500&&e<600,r=[408,429].indexOf(e)!==-1,i=t.indexOf(e)!==-1;return n||r||i}var Jv=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 Yv(!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()===Kv.NO_ERROR,i=n.getStatus();if(!t||qv(i,this.additionalRetryCodes_)&&this.retry){e(!1,new Yv(!1,null,n.getErrorCode()===Kv.ABORT));return}e(!0,new Yv(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());Lv(e)?n(e):n()}catch(e){r(e)}else if(i!==null){let e=pv();e.serverResponse=i.getErrorText(),this.errorCallback_?r(this.errorCallback_(i,e)):r(e)}else t.canceled?r(this.appDelete_?kv():bv()):r(yv())};this.canceled_?t(!1,new Yv(!1,null,!0)):this.backoffId_=Fv(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&Iv(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}},Yv=class{constructor(e,t,n){this.wasSuccessCode=e,this.connection=t,this.canceled=!!n}};function Xv(e,t){t!==null&&t.length>0&&(e.Authorization=`Firebase `+t)}function Zv(e,t){e[`X-Firebase-Storage-Version`]=`webjs/`+(t??`AppManager`)}function Qv(e,t){t&&(e[`X-Firebase-GMPID`]=t)}function $v(e,t){t!==null&&(e[`X-Firebase-AppCheck`]=t)}function ey(e,t,n,r,i,a,o=!0,s=!1){let c=Gv(e.urlParams),l=e.url+c,u=Object.assign({},e.headers);return Qv(u,t),Xv(u,n),Zv(u,a),$v(u,r),new Jv(l,e.method,u,e.body,e.successCodes,e.additionalRetryCodes,e.handler,e.errorHandler,e.timeout,e.progressCallback,i,o,s)}function ty(){if(typeof BlobBuilder<`u`)return BlobBuilder;if(typeof WebKitBlobBuilder<`u`)return WebKitBlobBuilder}function ny(...e){let t=ty();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(Hv())return new Blob(e);else throw new Z(Q.UNSUPPORTED_ENVIRONMENT,`This browser doesn't seem to support creating Blobs`)}function ry(e,t,n){return e.webkitSlice?e.webkitSlice(t,n):e.mozSlice?e.mozSlice(t,n):e.slice?e.slice(t,n):null}function iy(e){if(typeof atob>`u`)throw Dv(`base-64`);return atob(e)}var ay={RAW:`raw`,BASE64:`base64`,BASE64URL:`base64url`,DATA_URL:`data_url`},oy=class{constructor(e,t){this.data=e,this.contentType=t||null}};function sy(e,t){switch(e){case ay.RAW:return new oy(cy(t));case ay.BASE64:case ay.BASE64URL:return new oy(uy(e,t));case ay.DATA_URL:return new oy(fy(t),py(t))}throw pv()}function cy(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 ly(e){let t;try{t=decodeURIComponent(e)}catch{throw jv(ay.DATA_URL,`Malformed data URL.`)}return cy(t)}function uy(e,t){switch(e){case ay.BASE64:{let n=t.indexOf(`-`)!==-1,r=t.indexOf(`_`)!==-1;if(n||r)throw jv(e,`Invalid character '`+(n?`-`:`_`)+`' found: is it base64url encoded?`);break}case ay.BASE64URL:{let n=t.indexOf(`+`)!==-1,r=t.indexOf(`/`)!==-1;if(n||r)throw jv(e,`Invalid character '`+(n?`+`:`/`)+`' found: is it base64 encoded?`);t=t.replace(/-/g,`+`).replace(/_/g,`/`);break}}let n;try{n=iy(t)}catch(t){throw t.message.includes(`polyfill`)?t:jv(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 dy=class{constructor(e){this.base64=!1,this.contentType=null;let t=e.match(/^data:([^,]+)?,/);if(t===null)throw jv(ay.DATA_URL,`Must be formatted 'data:[<mediatype>][;base64],<data>`);let n=t[1]||null;n!=null&&(this.base64=my(n,`;base64`),this.contentType=this.base64?n.substring(0,n.length-7):n),this.rest=e.substring(e.indexOf(`,`)+1)}};function fy(e){let t=new dy(e);return t.base64?uy(ay.BASE64,t.rest):ly(t.rest)}function py(e){return new dy(e).contentType}function my(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}var hy=class e{constructor(e,t){let n=0,r=``;Vv(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(Vv(this.data_)){let r=this.data_,i=ry(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(Hv()){let n=t.map(t=>t instanceof e?t.data_:t);return new e(ny.apply(null,n))}else{let n=t.map(e=>Bv(e)?sy(ay.RAW,e).data:e.data_),r=0;n.forEach(e=>{r+=e.byteLength});let i=new Uint8Array(r),a=0;return n.forEach(e=>{for(let t=0;t<e.length;t++)i[a++]=e[t]}),new e(i,!0)}}uploadData(){return this.data_}};function gy(e){let t;try{t=JSON.parse(e)}catch{return null}return zv(t)?t:null}function _y(e){if(e.length===0)return null;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function vy(e,t){let n=t.split(`/`).filter(e=>e.length>0).join(`/`);return e.length===0?n:e+`/`+n}function yy(e){let t=e.lastIndexOf(`/`,e.length-2);return t===-1?e:e.slice(t+1)}function by(e,t){return t}var xy=class{constructor(e,t,n,r){this.server=e,this.local=t||e,this.writable=!!n,this.xform=r||by}},Sy=null;function Cy(e){return!Bv(e)||e.length<2?e:yy(e)}function wy(){if(Sy)return Sy;let e=[];e.push(new xy(`bucket`)),e.push(new xy(`generation`)),e.push(new xy(`metageneration`)),e.push(new xy(`name`,`fullPath`,!0));function t(e,t){return Cy(t)}let n=new xy(`name`);n.xform=t,e.push(n);function r(e,t){return t===void 0?t:Number(t)}let i=new xy(`size`);return i.xform=r,e.push(i),e.push(new xy(`timeCreated`)),e.push(new xy(`updated`)),e.push(new xy(`md5Hash`,null,!0)),e.push(new xy(`cacheControl`,null,!0)),e.push(new xy(`contentDisposition`,null,!0)),e.push(new xy(`contentEncoding`,null,!0)),e.push(new xy(`contentLanguage`,null,!0)),e.push(new xy(`contentType`,null,!0)),e.push(new xy(`metadata`,`customMetadata`,!0)),Sy=e,Sy}function Ty(e,t){function n(){let n=e.bucket,r=e.fullPath,i=new Nv(n,r);return t._makeStorageReference(i)}Object.defineProperty(e,`ref`,{get:n})}function Ey(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 Ty(r,e),r}function Dy(e,t,n){let r=gy(t);return r===null?null:Ey(e,r,n)}function Oy(e,t,n,r){let i=gy(t);if(i===null||!Bv(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 Wv(`/b/`+o(i)+`/o/`+o(a),n,r)+Gv({alt:`media`,token:t})})[0]}function ky(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 Ay=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 jy(e){if(!e)throw pv()}function My(e,t){function n(n,r){let i=Dy(e,r,t);return jy(i!==null),i}return n}function Ny(e,t){function n(n,r){let i=Dy(e,r,t);return jy(i!==null),Oy(i,r,e.host,e._protocol)}return n}function Py(e){function t(t,n){let r;return r=t.getStatus()===401?t.getErrorText().includes(`Firebase App Check token is invalid`)?_v():gv():t.getStatus()===402?hv(e.bucket):t.getStatus()===403?vv(e.path):n,r.status=t.getStatus(),r.serverResponse=n.serverResponse,r}return t}function Fy(e){let t=Py(e);function n(n,r){let i=t(n,r);return n.getStatus()===404&&(i=mv(e.path)),i.serverResponse=r.serverResponse,i}return n}function Iy(e,t,n){let r=Wv(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime,a=new Ay(r,`GET`,My(e,n),i);return a.errorHandler=Fy(t),a}function Ly(e,t,n){let r=Wv(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime,a=new Ay(r,`GET`,Ny(e,n),i);return a.errorHandler=Fy(t),a}function Ry(e,t){let n=Wv(t.fullServerUrl(),e.host,e._protocol),r=e.maxOperationRetryTime;function i(e,t){}let a=new Ay(n,`DELETE`,i,r);return a.successCodes=[200,204],a.errorHandler=Fy(t),a}function zy(e,t){return e&&e.contentType||t&&t.type()||`application/octet-stream`}function By(e,t,n){let r=Object.assign({},n);return r.fullPath=e.path,r.size=t.size(),r.contentType||=zy(null,t),r}function Vy(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=By(t,r,i),u=ky(l,n),d=`--`+c+`\r
32
+ )`}copy(t,n){let r=new e;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r}},Dm=class{constructor(){this.au=new V(R.comparator)}track(e){let t=e.doc.key,n=this.au.get(t);n?e.type!==0&&n.type===3?this.au=this.au.insert(t,e):e.type===3&&n.type!==1?this.au=this.au.insert(t,{type:n.type,doc:e.doc}):e.type===2&&n.type===2?this.au=this.au.insert(t,{type:2,doc:e.doc}):e.type===2&&n.type===0?this.au=this.au.insert(t,{type:0,doc:e.doc}):e.type===1&&n.type===0?this.au=this.au.remove(t):e.type===1&&n.type===2?this.au=this.au.insert(t,{type:1,doc:n.doc}):e.type===0&&n.type===1?this.au=this.au.insert(t,{type:2,doc:e.doc}):j(63341,{ft:e,uu:n}):this.au=this.au.insert(t,e)}cu(){let e=[];return this.au.inorderTraversal(((t,n)=>{e.push(n)})),e}},Om=class e{constructor(e,t,n,r,i,a,o,s,c){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=o,this.excludesMetadataChanges=s,this.hasCachedResults=c}static fromInitialDocuments(t,n,r,i,a){let o=[];return n.forEach((e=>{o.push({type:0,doc:e})})),new e(t,n,Em.emptySet(n),o,r,i,!0,!1,a)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Hf(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==n[e].type||!t[e].doc.isEqual(n[e].doc))return!1;return!0}},km=class{constructor(){this.lu=void 0,this.Eu=[]}hu(){return this.Eu.some((e=>e.Tu()))}},Am=class{constructor(){this.queries=jm(),this.onlineState=`Unknown`,this.Pu=new Set}terminate(){(function(e,t){let n=N(e),r=n.queries;n.queries=jm(),r.forEach(((e,n)=>{for(let e of n.Eu)e.onError(t)}))})(this,new F(P.ABORTED,`Firestore shutting down`))}};function jm(){return new bs((e=>Vf(e)),Hf)}async function Mm(e,t){let n=N(e),r=3,i=t.query,a=n.queries.get(i);a?!a.hu()&&t.Tu()&&(r=2):(a=new km,r=+!t.Tu());try{switch(r){case 0:a.lu=await n.onListen(i,!0);break;case 1:a.lu=await n.onListen(i,!1);break;case 2:await n.onFirstRemoteStoreListen(i)}}catch(e){let n=Tm(e,`Initialization of query '${zf(t.query)?Lf(t.query):fs(t.query)}' failed`);t.onError(n);return}n.queries.set(i,a),a.Eu.push(t),t.Ru(n.onlineState),a.lu&&t.Iu(a.lu)&&Im(n)}async function Nm(e,t){let n=N(e),r=t.query,i=3,a=n.queries.get(r);if(a){let e=a.Eu.indexOf(t);e>=0&&(a.Eu.splice(e,1),a.Eu.length===0?i=+!t.Tu():!a.hu()&&t.Tu()&&(i=2))}switch(i){case 0:return n.queries.delete(r),n.onUnlisten(r,!0);case 1:return n.queries.delete(r),n.onUnlisten(r,!1);case 2:return n.onLastRemoteStoreUnlisten(r);default:return}}function Pm(e,t){let n=N(e),r=!1;for(let e of t){let t=e.query,i=n.queries.get(t);if(i){for(let t of i.Eu)t.Iu(e)&&(r=!0);i.lu=e}}r&&Im(n)}function Fm(e,t,n){let r=N(e),i=r.queries.get(t);if(i)for(let e of i.Eu)e.onError(n);r.queries.delete(t)}function Im(e){e.Pu.forEach((e=>{e.next()}))}var Lm;(function(e){e.Default=`default`,e.Cache=`cache`})(Lm||={});var Rm=class{constructor(e,t,n){this.query=e,this.Au=t,this.Vu=!1,this.du=null,this.onlineState=`Unknown`,this.options=n||{}}Iu(e){if(!this.options.includeMetadataChanges){let t=[];for(let n of e.docChanges)n.type!==3&&t.push(n);e=new Om(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Vu?this.fu(e)&&(this.Au.next(e),t=!0):this.mu(e,this.onlineState)&&(this.pu(e),t=!0),this.du=e,t}onError(e){this.Au.error(e)}Ru(e){this.onlineState=e;let t=!1;return this.du&&!this.Vu&&this.mu(this.du,e)&&(this.pu(this.du),t=!0),t}mu(e,t){if(!e.fromCache||!this.Tu())return!0;let n=t!==`Offline`;return(!this.options.waitForSyncWhenOnline||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||t===`Offline`)}fu(e){if(e.docChanges.length>0)return!0;let t=this.du&&this.du.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}pu(e){e=Om.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Vu=!0,this.Au.next(e)}Tu(){return this.options.source!==Lm.Cache}},zm=class{constructor(e){this.key=e}},Bm=class{constructor(e){this.key=e}},Vm=class{constructor(e,t){this.query=e,this.Ou=t,this.Mu=null,this.hasCachedResults=!1,this.current=!1,this.Nu=W(),this.mutatedKeys=W(),this.Lu=zf(e)?op(e):ms(e),this.Bu=new Em(this.Lu)}get Uu(){return this.Ou}ku(e,t){let n=t?t.qu:new Dm,r=t?t.Bu:this.Bu,i=t?t.mutatedKeys:this.mutatedKeys,a=r,o=!1,[s,c]=this.$u(this.query,r);e.inorderTraversal(((e,t)=>{let l=r.get(e),u=ip(this.query,t)?t:null,d=!!l&&this.mutatedKeys.has(l.key),f=!!u&&(u.hasLocalMutations||this.mutatedKeys.has(u.key)&&u.hasCommittedMutations),p=!1;l&&u?l.data.isEqual(u.data)?d!==f&&(n.track({type:3,doc:u}),p=!0):this.Ku(l,u)||(n.track({type:2,doc:u}),p=!0,(s&&this.Lu(u,s)>0||c&&this.Lu(u,c)<0)&&(o=!0)):!l&&u?(n.track({type:0,doc:u}),p=!0):l&&!u&&(n.track({type:1,doc:l}),p=!0,(s||c)&&(o=!0)),p&&(u?(a=a.add(u),i=f?i.add(e):i.delete(e)):(a=a.delete(e),i=i.delete(e)))}));let l=this.Wu(this.query);if(l)if(zf(this.query)){let e=[];a.forEach((t=>e.push(t)));let t=np(this.query,e),r=new Em(op(this.query));for(let e of t)r=r.add(e);a.forEach((e=>{r.has(e.key)||(i=i.delete(e.key),n.track({type:1,doc:e}))})),a=r}else{let e=this.Qu(this.query);for(;a.size>l;){let t=e===`F`?a.last():a.first();a=a.delete(t.key),i=i.delete(t.key),n.track({type:1,doc:t})}}return{Bu:a,qu:n,Uo:o,mutatedKeys:i}}Wu(e){return zf(e)?sp(e)?.limit:e.limit||void 0}Qu(e){if(zf(e)){let t=sp(e);return t&&t.limit<0?`L`:`F`}return e.limitType}$u(e,t){if(zf(e)){let n=sp(e)?.limit;return[t.size===n?t.last():null,null]}return[e.limitType===`F`&&t.size===this.Wu(this.query)?t.last():null,e.limitType===`L`&&t.size===this.Wu(this.query)?t.first():null]}Ku(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){let i=this.Bu;this.Bu=e.Bu,this.mutatedKeys=e.mutatedKeys;let a=e.qu.cu();a.sort(((e,t)=>function(e,t){let n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return j(20277,{ft:e})}};return n(e)-n(t)}(e.type,t.type)||this.Lu(e.doc,t.doc))),this.Gu(n),r??=!1;let o=t&&!r?this.zu():[],s=this.Nu.size===0&&this.current&&!r?1:0,c=s!==this.Mu;return this.Mu=s,a.length!==0||c?{snapshot:new Om(this.query,e.Bu,i,a,e.mutatedKeys,s===0,c,!1,!!n&&n.resumeToken.approximateByteSize()>0),ju:o}:{ju:o}}Ru(e){return this.current&&e===`Offline`?(this.current=!1,this.applyChanges({Bu:this.Bu,qu:new Dm,mutatedKeys:this.mutatedKeys,Uo:!1},!1)):{ju:[]}}Hu(e){return!this.Ou.has(e)&&!!this.Bu.has(e)&&!this.Bu.get(e).hasLocalMutations}Gu(e){e&&(e.addedDocuments.forEach((e=>this.Ou=this.Ou.add(e))),e.modifiedDocuments.forEach((e=>{})),e.removedDocuments.forEach((e=>this.Ou=this.Ou.delete(e))),this.current=e.current)}zu(){if(!this.current)return[];let e=this.Nu;this.Nu=W(),this.Bu.forEach((e=>{this.Hu(e.key)&&(this.Nu=this.Nu.add(e.key))}));let t=[];return e.forEach((e=>{this.Nu.has(e)||t.push(new Bm(e))})),this.Nu.forEach((n=>{e.has(n)||t.push(new zm(n))})),t}Ju(e){this.Ou=e.Jo,this.Nu=W();let t=this.ku(e.documents);return this.applyChanges(t,!0)}Yu(){return Om.fromInitialDocuments(this.query,this.Bu,this.mutatedKeys,this.Mu===0,this.hasCachedResults)}},Hm=`SyncEngine`,Um=class{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}},Wm=class{constructor(e){this.key=e,this.Zu=!1}},Gm=class{constructor(e,t,n,r,i,a){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=a,this.Xu={},this.ec=new bs((e=>Vf(e)),Hf),this.tc=new Map,this.nc=new Set,this.rc=new V(R.comparator),this.sc=new Map,this._c=new mp,this.oc={},this.ac=new Map,this.uc=tp.Cs(),this.onlineState=`Unknown`,this.cc=void 0}get isPrimaryClient(){return!0===this.cc}};async function Km(e,t,n=!0){let r=mh(e),i,a=r.ec.get(t);return a?(r.sharedClientState.addLocalQueryTarget(a.targetId),i=a.view.Yu()):i=await Jm(r,t,n,!0),i}async function qm(e,t){await Jm(mh(e),t,!0,!1)}async function Jm(e,t,n,r){let i=await Rp(e.localStore,zf(t)?t:is(t)),a=i.targetId,o=e.sharedClientState.addLocalQueryTarget(a,n),s;return r&&(s=await Ym(e,t,a,o===`current`,i.resumeToken)),e.isPrimaryClient&&n&&Zp(e.remoteStore,i),s}async function Ym(e,t,n,r,i){e.lc=(t,n,r)=>async function(e,t,n,r){let i=t.view.ku(n);i.Uo&&(i=await Bp(e.localStore,t.query,!1).then((({documents:e})=>t.view.ku(e,i))));let a=r&&r.targetChanges.get(t.targetId),o=r&&r.targetMismatches.get(t.targetId)!=null,s=t.view.applyChanges(i,e.isPrimaryClient,a,o);return ch(e,t.targetId,s.ju),s.snapshot}(e,t,n,r);let a=await Bp(e.localStore,t,!0),o=new Vm(t,a.Jo),s=o.ku(a.documents),c=Vs.createSynthesizedTargetChangeForCurrentChange(n,r&&e.onlineState!==`Offline`,i),l=o.applyChanges(s,e.isPrimaryClient,c);ch(e,n,l.ju);let u=new Um(t,n,o);return e.ec.set(t,u),e.tc.has(n)?e.tc.get(n).push(t):e.tc.set(n,[t]),l.snapshot}async function Xm(e,t,n){let r=N(e),i=r.ec.get(t),a=r.tc.get(i.targetId);if(a.length>1)return r.tc.set(i.targetId,a.filter((e=>!Hf(e,t)))),void r.ec.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)||await zp(r.localStore,i.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(i.targetId),n&&Qp(r.remoteStore,i.targetId),oh(r,i.targetId)})).catch(Ci)):(oh(r,i.targetId),await zp(r.localStore,i.targetId,!0))}async function Zm(e,t){let n=N(e),r=n.ec.get(t),i=n.tc.get(r.targetId);n.isPrimaryClient&&i.length===1&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),Qp(n.remoteStore,r.targetId))}async function Qm(e,t,n){let r=hh(e);try{let e=await function(e,t){let n=N(e),r=mi.now(),i=t.reduce(((e,t)=>e.add(t.key)),W()),a,o;return n.persistence.runTransaction(`Locally write mutations`,`readwrite`,(e=>{let s=Ss(),c=W();return n.Qo.getEntries(e,i).next((e=>{s=e,s.forEach(((e,t)=>{t.isValidDocument()||(c=c.add(e))}))})).next((()=>n.localDocuments.getOverlayedDocuments(e,s))).next((i=>{a=i;let o=[];for(let e of t){let t=fo(e,a.get(e.key).overlayedDocument);t!=null&&o.push(new ho(e.key,t,La(t.value.mapValue),ao.exists(!0)))}return n.mutationQueue.addMutationBatch(e,r,o,t)})).next((t=>{o=t;let r=t.applyToLocalDocumentSet(a,c);return n.documentOverlayCache.saveOverlays(e,t.batchId,r)}))})).then((()=>({batchId:o.batchId,changes:Ts(a)})))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.oc[e.currentUser.toKey()];r||=new V(I),r=r.insert(t,n),e.oc[e.currentUser.toKey()]=r}(r,e.batchId,n),await dh(r,e.changes),await dm(r.remoteStore)}catch(e){let t=Tm(e,`Failed to persist write`);n.reject(t)}}async function $m(e,t){let n=N(e);try{let e=await Fp(n.localStore,t);t.targetChanges.forEach(((e,t)=>{let r=n.sc.get(t);r&&(M(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1,22616),e.addedDocuments.size>0?r.Zu=!0:e.modifiedDocuments.size>0?M(r.Zu,14607):e.removedDocuments.size>0&&(M(r.Zu,42227),r.Zu=!1))})),await dh(n,e,t)}catch(e){await Ci(e)}}function eh(e,t,n){let r=N(e);if(r.isPrimaryClient&&n===0||!r.isPrimaryClient&&n===1){let e=[];r.ec.forEach(((n,r)=>{let i=r.view.Ru(t);i.snapshot&&e.push(i.snapshot)})),function(e,t){let n=N(e);n.onlineState=t;let r=!1;n.queries.forEach(((e,n)=>{for(let e of n.Eu)e.Ru(t)&&(r=!0)})),r&&Im(n)}(r.eventManager,t),e.length&&r.Xu.zn(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function th(e,t,n){let r=N(e);r.sharedClientState.updateQueryState(t,`rejected`,n);let i=r.sc.get(t),a=i&&i.key;if(a){let e=new V(R.comparator);e=e.insert(a,Wo.newNoDocument(a,z.min()));let n=W().add(a);await $m(r,new Bs(z.min(),new Map,new V(I),e,Ss(),n)),r.rc=r.rc.remove(a),r.sc.delete(t),uh(r)}else await zp(r.localStore,t,!1).then((()=>oh(r,t,n))).catch(Ci)}async function nh(e,t){let n=N(e),r=t.batch.batchId;try{let e=await Np(n.localStore,t);ah(n,r,null),ih(n,r),n.sharedClientState.updateMutationState(r,`acknowledged`),await dh(n,e)}catch(e){await Ci(e)}}async function rh(e,t,n){let r=N(e);try{let e=await function(e,t){let n=N(e);return n.persistence.runTransaction(`Reject batch`,`readwrite-primary`,(e=>{let r;return n.mutationQueue.lookupMutationBatch(e,t).next((t=>(M(t!==null,37113),r=t.keys(),n.mutationQueue.removeMutationBatch(e,t)))).next((()=>n.mutationQueue.performConsistencyCheck(e))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,r))).next((()=>n.localDocuments.getDocuments(e,r)))}))}(r.localStore,t);ah(r,t,n),ih(r,t),r.sharedClientState.updateMutationState(t,`rejected`,n),await dh(r,e)}catch(e){await Ci(e)}}function ih(e,t){(e.ac.get(t)||[]).forEach((e=>{e.resolve()})),e.ac.delete(t)}function ah(e,t,n){let r=N(e),i=r.oc[r.currentUser.toKey()];if(i){let e=i.get(t);e&&(n?e.reject(n):e.resolve(),i=i.remove(t)),r.oc[r.currentUser.toKey()]=i}}function oh(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(let r of e.tc.get(t))e.ec.delete(r),n&&e.Xu.Ec(r,n);e.tc.delete(t),e.isPrimaryClient&&e._c.s_(t).forEach((t=>{e._c.containsKey(t)||sh(e,t)}))}function sh(e,t){e.nc.delete(t.path.canonicalString());let n=e.rc.get(t);n!==null&&(Qp(e.remoteStore,n),e.rc=e.rc.remove(t),e.sc.delete(n),uh(e))}function ch(e,t,n){for(let r of n)r instanceof zm?(e._c.addReference(r.key,t),lh(e,r)):r instanceof Bm?(A(Hm,`Document no longer in limbo: `+r.key),e._c.removeReference(r.key,t),e._c.containsKey(r.key)||sh(e,r.key)):j(19791,{hc:r})}function lh(e,t){let n=t.key,r=n.path.canonicalString();e.rc.get(n)||e.nc.has(r)||(A(Hm,`New document in limbo: `+n),e.nc.add(r),uh(e))}function uh(e){for(;e.nc.size>0&&e.rc.size<e.maxConcurrentLimboResolutions;){let t=e.nc.values().next().value;e.nc.delete(t);let n=new R(L.fromString(t)),r=e.uc.next();e.sc.set(r,new Wm(n)),e.rc=e.rc.insert(n,r),Zp(e.remoteStore,new Yf(is($o(n.path)),r,`TargetPurposeLimboResolution`,Ei.ce))}}async function dh(e,t,n){let r=N(e),i=[],a=[],o=[];r.ec.isEmpty()||(r.ec.forEach(((e,s)=>{o.push(r.lc(s,t,n).then((e=>{if((e||n)&&r.isPrimaryClient){let t=e?!e.fromCache:n?.targetChanges.get(s.targetId)?.current;r.sharedClientState.updateQueryState(s.targetId,t?`current`:`not-current`)}if(e){i.push(e);let t=wp.vo(s.targetId,e);a.push(t)}})))})),await Promise.all(o),r.Xu.zn(i),await async function(e,t){let n=N(e);try{await n.persistence.runTransaction(`notifyLocalViewChanges`,`readwrite`,(e=>B.forEach(t,(t=>B.forEach(t.wo,(r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=>B.forEach(t.bo,(r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!Ti(e))throw e;A(Op,`Failed to update sequence numbers: `+e)}for(let e of t){let t=e.targetId;if(!e.fromCache){let e=n.$o.get(t),r=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(r);n.$o=n.$o.insert(t,i)}}}(r.localStore,a))}async function fh(e,t){let n=N(e);if(!n.currentUser.isEqual(t)){A(Hm,`User change. New user:`,t.toKey());let e=await Mp(n.localStore,t);n.currentUser=t,function(e,t){e.ac.forEach((e=>{e.forEach((e=>{e.reject(new F(P.CANCELLED,t))}))})),e.ac.clear()}(n,`'waitForPendingWrites' promise is rejected due to a user change.`),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await dh(n,e.zo)}}function ph(e,t){let n=N(e),r=n.sc.get(t);if(r&&r.Zu)return W().add(r.key);{let e=W(),r=n.tc.get(t);if(!r)return e;for(let t of r??[]){let r=n.ec.get(t);e=e.unionWith(r.view.Uu)}return e}}function mh(e){let t=N(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=$m.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=ph.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=th.bind(null,t),t.Xu.zn=Pm.bind(null,t.eventManager),t.Xu.Ec=Fm.bind(null,t.eventManager),t}function hh(e){let t=N(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=nh.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=rh.bind(null,t),t}var gh=class{constructor(){this.kind=`memory`,this.synchronizeTabs=!1}async initialize(e){this.serializer=Lc(e.databaseInfo.databaseId),this.sharedClientState=this.Rc(e),this.persistence=this.Ic(e),await this.persistence.start(),this.localStore=this.Ac(e),this.gcScheduler=this.Vc(e,this.localStore),this.indexBackfillerScheduler=this.dc(e,this.localStore)}Vc(e,t){return null}dc(e,t){return null}Ac(e){return jp(this.persistence,new Dp,e.initialUser,this.serializer)}Ic(e){return new bp(Sp.C_,this.serializer)}Rc(e){return new Up}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}};gh.provider={build:()=>new gh};var _h=class extends gh{constructor(e){super(),this.cacheSizeBytes=e}Vc(e,t){M(this.persistence.referenceDelegate instanceof Cp,46915);let n=this.persistence.referenceDelegate.garbageCollector;return new xl(n,e.asyncQueue,t)}Ic(e){let t=this.cacheSizeBytes===void 0?gl.DEFAULT:gl.withCacheSize(this.cacheSizeBytes);return new bp((e=>Cp.C_(e,t)),this.serializer)}},vh=class{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>eh(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=fh.bind(null,this.syncEngine),await xm(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new Am}()}createDatastore(e){let t=Lc(e.databaseInfo.databaseId),n=nl(e.databaseInfo);return ul(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,r,i){return new qp(e,t,n,r,i)}(this.localStore,this.datastore,e.asyncQueue,(e=>eh(this.syncEngine,e,0)),function(){return Kc.C()?new Kc:new Wc}())}createSyncEngine(e,t){return function(e,t,n,r,i,a,o){let s=new Gm(e,t,n,r,i,a);return o&&(s.cc=!0),s}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await async function(e){let t=N(e);A(Kp,`RemoteStore shutting down.`),t.tu.add(5),await Yp(t),t.ru.shutdown(),t.iu.set(`Unknown`)}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}};vh.provider={build:()=>new vh};var yh=class{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.mc(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.mc(this.observer.error,e):Mr(`Uncaught Error in snapshot listener:`,e.toString()))}gc(){this.muted=!0}mc(e,t){setTimeout((()=>{this.muted||e(t)}),0)}},bh=`FirestoreClient`,xh=class{constructor(e,t,n,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this._databaseInfo=r,this.user=Dr.UNAUTHENTICATED,this.clientId=Kr.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,(async e=>{A(bh,`Received user=`,e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=>(A(bh,`Received new app check token=`,e),this.appCheckCredentialListener(e,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new Ir;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){let n=Tm(t,`Failed to shutdown persistence`);e.reject(n)}})),e.promise}};async function Sh(e,t){e.asyncQueue.verifyOperationInProgress(),A(bh,`Initializing OfflineComponentProvider`);let n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=>{r.isEqual(e)||(await Mp(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e._offlineComponents=t}async function Ch(e,t){e.asyncQueue.verifyOperationInProgress();let n=await wh(e);A(bh,`Initializing OnlineComponentProvider`),await t.initialize(n,e.configuration),e.setCredentialChangeListener((e=>bm(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=>bm(t.remoteStore,n))),e._onlineComponents=t}async function wh(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){A(bh,`Using user provided OfflineComponentProvider`);try{await Sh(e,e._uninitializedComponentsProvider._offline)}catch(t){let n=t;if(!function(e){return e.name===`FirebaseError`?e.code===P.FAILED_PRECONDITION||e.code===P.UNIMPLEMENTED:!(typeof DOMException<`u`&&e instanceof DOMException)||e.code===22||e.code===20||e.code===11}(n))throw n;Nr(`Error using user provided cache. Falling back to memory cache: `+n),await Sh(e,new gh)}}else A(bh,`Using default OfflineComponentProvider`),await Sh(e,new _h(void 0));return e._offlineComponents}async function Th(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(A(bh,`Using user provided OnlineComponentProvider`),await Ch(e,e._uninitializedComponentsProvider._online)):(A(bh,`Using default OnlineComponentProvider`),await Ch(e,new vh))),e._onlineComponents}function Eh(e){return Th(e).then((e=>e.syncEngine))}function Dh(e){return Th(e).then((e=>e.datastore))}async function Oh(e){let t=await Th(e),n=t.eventManager;return n.onListen=Km.bind(null,t.syncEngine),n.onUnlisten=Xm.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=qm.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=Zm.bind(null,t.syncEngine),n}function kh(e,t,n,r){let i=new yh(r),a=new Rm(t,i,n);return e.asyncQueue.enqueueAndForget((async()=>Mm(await Oh(e),a))),()=>{i.gc(),e.asyncQueue.enqueueAndForget((async()=>Nm(await Oh(e),a)))}}function Ah(e,t,n={}){let r=new Ir;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new yh({next:s=>{a.gc(),t.enqueueAndForget((()=>Nm(e,o)));let c=s.docs.has(n);!c&&s.fromCache?i.reject(new F(P.UNAVAILABLE,`Failed to get document because the client is offline.`)):c&&s.fromCache&&r&&r.source===`server`?i.reject(new F(P.UNAVAILABLE,`Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)`)):i.resolve(s)},error:e=>i.reject(e)}),o=new Rm($o(n.path),a,{includeMetadataChanges:!0,waitForSyncWhenOnline:!0});return Mm(e,o)}(await Oh(e),e.asyncQueue,t,n,r))),r.promise}function jh(e,t,n={}){let r=new Ir;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new yh({next:n=>{a.gc(),t.enqueueAndForget((()=>Nm(e,o))),n.fromCache&&r.source===`server`?i.reject(new F(P.UNAVAILABLE,`Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)`)):i.resolve(n)},error:e=>i.reject(e)}),o=new Rm(n instanceof Yu?Gf(n):n,a,{includeMetadataChanges:!0,waitForSyncWhenOnline:!0});return Mm(e,o)}(await Oh(e),e.asyncQueue,t,n,r))),r.promise}function Mh(e,t,n){let r=new Ir;return e.asyncQueue.enqueueAndForget((async()=>{try{let i=await Dh(e);r.resolve(async function(e,t,n){let r=N(e),{request:i,wt:a,parent:o}=xc(r.serializer,as(t),n);r.connection.Ot||delete i.parent;let s=(await r.$t(`RunAggregationQuery`,r.serializer.databaseId,o,i,1)).filter((e=>!!e.result));M(s.length===1,64727);let c=s[0].result?.aggregateFields;return Object.keys(c).reduce(((e,t)=>(e[a[t]]=c[t],e)),{})}(i,t,n))}catch(e){r.reject(e)}})),r.promise}function Nh(e,t){let n=new Ir;return e.asyncQueue.enqueueAndForget((async()=>Qm(await Eh(e),t,n))),n.promise}var Ph=`AsyncQueue`,Fh=class{constructor(e=Promise.resolve()){this.qc=[],this.$c=!1,this.Kc=[],this.Wc=null,this.Qc=!1,this.Gc=!1,this.zc=[],this.xn=new rl(this,`async_queue_retry`),this.jc=()=>{let e=Wp();e&&A(Ph,`Visibility state changed to `+e.visibilityState),this.xn.gn()},this.Hc=e;let t=Wp();t&&typeof t.addEventListener==`function`&&t.addEventListener(`visibilitychange`,this.jc)}get isShuttingDown(){return this.$c}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Jc(),this.Yc(e)}enterRestrictedMode(e){if(!this.$c){this.$c=!0,this.Gc=e||!1;let t=Wp();t&&typeof t.removeEventListener==`function`&&t.removeEventListener(`visibilitychange`,this.jc)}}enqueue(e){if(this.Jc(),this.$c)return new Promise((()=>{}));let t=new Ir;return this.Yc((()=>this.$c&&this.Gc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.qc.push(e),this.Zc())))}async Zc(){if(this.qc.length!==0){try{await this.qc[0](),this.qc.shift(),this.xn.reset()}catch(e){if(!Ti(e))throw e;A(Ph,`Operation failed with retryable error: `+e)}this.qc.length>0&&this.xn.mn((()=>this.Zc()))}}Yc(e){let t=this.Hc.then((()=>(this.Qc=!0,e().catch((e=>{throw this.Wc=e,this.Qc=!1,Mr(`INTERNAL UNHANDLED ERROR: `,Ih(e)),e})).then((e=>(this.Qc=!1,e))))));return this.Hc=t,t}enqueueAfterDelay(e,t,n){this.Jc(),this.zc.indexOf(e)>-1&&(t=0);let r=wm.createAndSchedule(this,e,t,n,(e=>this.Xc(e)));return this.Kc.push(r),r}Jc(){this.Wc&&j(47125,{el:Ih(this.Wc)})}verifyOperationInProgress(){}async tl(){let e;do e=this.Hc,await e;while(e!==this.Hc)}nl(e){for(let t of this.Kc)if(t.timerId===e)return!0;return!1}rl(e){return this.tl().then((()=>{this.Kc.sort(((e,t)=>e.targetTimeMs-t.targetTimeMs));for(let t of this.Kc)if(t.skipDelay(),e!==`all`&&t.timerId===e)break;return this.tl()}))}il(e){this.zc.push(e)}Xc(e){let t=this.Kc.indexOf(e);this.Kc.splice(t,1)}};function Ih(e){let t=e.message||``;return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+`
33
+ `+e.stack),t}var Lh=class extends Dl{constructor(e,t,n,r){super(e,t,n,r),this.type=`firestore`,this._queue=new Fh,this._persistenceKey=r?.name||`[DEFAULT]`}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new Fh(e),this._firestoreClient=void 0,await e}}};function Rh(e,t){let n=typeof e==`object`?e:tn(),r=typeof e==`string`?e:t||ia,i=Xt(n,`firestore`).getImmediate({identifier:r});if(!i._initialized){let e=h(`firestore`);e&&Ol(i,...e)}return i}function zh(e){if(e._terminated)throw new F(P.FAILED_PRECONDITION,`The client has already been terminated.`);return e._firestoreClient||Bh(e),e._firestoreClient}function Bh(e){let t=e._freezeSettings(),n=pl(e._databaseId,e._app?.options.appId||``,e._persistenceKey,e._app?.options.apiKey,t);e._componentsProvider||t.localCache?._offlineComponentProvider&&t.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:t.localCache._offlineComponentProvider,_online:t.localCache._onlineComponentProvider}),e._firestoreClient=new xh(e._authCredentials,e._appCheckCredentials,e._queue,n,e._componentsProvider&&function(e){let t=e?._online.build();return{_offline:e?._offline.build(t),_online:t}}(e._componentsProvider))}var Vh=class{convertValue(e,t=`none`){switch(ha(e)){case 0:return null;case 1:return e.booleanValue;case 2:return H(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Yi(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw j(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t=`none`){let n={};return Hi(e,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertVectorValue(e){let t=e.fields?.[da].arrayValue?.values?.map((e=>H(e.doubleValue)));return new Pl(t)}convertGeoPoint(e){return new Hc(H(e.latitude),H(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=>this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case`previous`:let n=ta(e);return n==null?null:this.convertValue(n,t);case`estimate`:return this.convertTimestamp(na(e));default:return null}}convertTimestamp(e){let t=Ji(e);return new mi(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=L.fromString(e);M(Nc(n),9688,{name:e});let r=new aa(n.get(1),n.get(3)),i=new R(n.popFirst(5));return r.isEqual(t)||Mr(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}},Hh=class extends Vh{constructor(e){super(),this.firestore=e}convertBytes(e){return new Rc(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new Al(this.firestore,null,t)}},Uh=`@firebase/firestore`,Wh=`4.16.0`;function Gh(e){return function(e,t){if(typeof e!=`object`||!e)return!1;let n=e;for(let e of t)if(e in n&&typeof n[e]==`function`)return!0;return!1}(e,[`next`,`error`,`complete`])}var Kh=class{constructor(e=`count`,t){this._internalFieldPath=t,this.type=`AggregateField`,this.aggregateType=e}},qh=class{constructor(e,t,n){this._userDataWriter=t,this._data=n,this.type=`AggregateQuerySnapshot`,this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}_fieldsProto(){return new Ia({mapValue:{fields:this._data}}).clone().value.mapValue.fields}},Jh=class{constructor(e,t,n,r,i){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new Al(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new Yh(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){let t=this._document.data.field(Zl(`DocumentSnapshot.get`,e));if(t!==null)return this._userDataWriter.convertValue(t)}}},Yh=class extends Jh{data(){return super.data()}};function Xh(e){if(e.limitType===`L`&&e.explicitOrderBy.length===0)throw new F(P.UNIMPLEMENTED,`limitToLast() queries require specifying at least one orderBy() clause`)}var Zh=class{},Qh=class extends Zh{};function $h(e,t,...n){let r=[];t instanceof Zh&&r.push(t),r=r.concat(n),function(e){let t=e.filter((e=>e instanceof ng)).length,n=e.filter((e=>e instanceof eg)).length;if(t>1||t>0&&n>0)throw new F(P.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(let t of r)e=t._apply(e);return e}var eg=class e extends Qh{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type=`where`}static _create(t,n,r){return new e(t,n,r)}_apply(e){let t=this._parse(e);return mg(e._query,t),new kl(e.firestore,e.converter,ss(e._query,t))}_parse(e){let t=Vl(e.firestore);return function(e,t,n,r,i,a,o){let s;if(i.isKeyField()){if(a===`array-contains`||a===`array-contains-any`)throw new F(P.INVALID_ARGUMENT,`Invalid Query. You can't perform '${a}' queries on documentId().`);if(a===`in`||a===`not-in`){pg(o,a);let t=[];for(let n of o)t.push(fg(r,e,n));s={arrayValue:{values:t}}}else s=fg(r,e,o)}else a!==`in`&&a!==`not-in`&&a!==`array-contains-any`||pg(o,a),s=Kl(n,t,o,a===`in`||a===`not-in`);return Eo.create(i,a,s)}(e._query,`where`,t,e.firestore._databaseId,this._field,this._op,this._value)}};function tg(e,t,n){let r=t,i=Zl(`where`,e);return eg._create(i,r,n)}var ng=class e extends Zh{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(t,n){return new e(t,n)}_parse(e){let t=this._queryConstraints.map((t=>t._parse(e))).filter((e=>e.getFilters().length>0));return t.length===1?t[0]:Do.create(t,this._getOperator())}_apply(e){let t=this._parse(e);return t.getFilters().length===0?e:(function(e,t){let n=e,r=t.getFlattenedFilters();for(let e of r)mg(n,e),n=ss(n,e)}(e._query,t),new kl(e.firestore,e.converter,ss(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type===`and`?`and`:`or`}};function rg(...e){return e.forEach((e=>hg(`or`,e))),ng._create(`or`,e)}function ig(...e){return e.forEach((e=>hg(`and`,e))),ng._create(`and`,e)}var ag=class e extends Qh{constructor(e,t){super(),this._field=e,this._direction=t,this.type=`orderBy`}static _create(t,n){return new e(t,n)}_apply(e){let t=function(e,t,n){if(e.startAt!==null)throw new F(P.INVALID_ARGUMENT,`Invalid query. You must not call startAt() or startAfter() before calling orderBy().`);if(e.endAt!==null)throw new F(P.INVALID_ARGUMENT,`Invalid query. You must not call endAt() or endBefore() before calling orderBy().`);return new Ho(t,n)}(e._query,this._field,this._direction);return new kl(e.firestore,e.converter,cs(e._query,t))}};function og(e,t=`asc`){let n=t,r=Zl(`orderBy`,e);return ag._create(r,n)}var sg=class e extends Qh{constructor(e,t,n){super(),this.type=e,this._limit=t,this._limitType=n}static _create(t,n,r){return new e(t,n,r)}_apply(e){return new kl(e.firestore,e.converter,ls(e._query,this._limit,this._limitType))}};function cg(e){return li(`limit`,e),sg._create(`limit`,e,`F`)}var lg=class e extends Qh{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(t,n,r){return new e(t,n,r)}_apply(e){let t=dg(e,this.type,this._docOrFields,this._inclusive);return new kl(e.firestore,e.converter,us(e._query,t))}};function ug(...e){return lg._create(`startAfter`,e,!1)}function dg(e,t,n,r){if(n[0]=_(n[0]),n[0]instanceof Jh)return function(e,t,n,r,i){if(!r)throw new F(P.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);let a=[];for(let n of rs(e))if(n.field.isKeyField())a.push(wa(t,r.key));else{let e=r.data.field(n.field);if(ea(e))throw new F(P.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field "`+n.field+`" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)`);if(e===null){let e=n.field.canonicalString();throw new F(P.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${e}' (used as the orderBy) does not exist.`)}a.push(e)}return new So(a,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);{let i=Vl(e.firestore);return function(e,t,n,r,i,a){let o=e.explicitOrderBy;if(i.length>o.length)throw new F(P.INVALID_ARGUMENT,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);let s=[];for(let a=0;a<i.length;a++){let c=i[a];if(o[a].field.isKeyField()){if(typeof c!=`string`)throw new F(P.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);if(!ns(e)&&c.indexOf(`/`)!==-1)throw new F(P.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);let n=e.path.child(L.fromString(c));if(!R.isDocumentKey(n))throw new F(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);let i=new R(n);s.push(wa(t,i))}else{let e=Kl(n,r,c);s.push(e)}}return new So(s,a)}(e._query,e.firestore._databaseId,i,t,n,r)}}function fg(e,t,n){if(typeof(n=_(n))==`string`){if(n===``)throw new F(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.`);if(!ns(t)&&n.indexOf(`/`)!==-1)throw new F(P.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);let r=t.path.child(L.fromString(n));if(!R.isDocumentKey(r))throw new F(P.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return wa(e,new R(r))}if(n instanceof Al)return wa(e,n._key);throw new F(P.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${si(n)}.`)}function pg(e,t){if(!Array.isArray(e)||e.length===0)throw new F(P.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function mg(e,t){let n=function(e,t){for(let n of e)for(let e of n.getFlattenedFilters())if(t.indexOf(e.op)>=0)return e.op;return null}(e.filters,function(e){switch(e){case`!=`:return[`!=`,`not-in`];case`array-contains-any`:case`in`:return[`not-in`];case`not-in`:return[`array-contains-any`,`in`,`not-in`,`!=`];default:return[]}}(t.op));if(n!==null)throw n===t.op?new F(P.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new F(P.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}function hg(e,t){if(!(t instanceof eg||t instanceof ng))throw new F(P.INVALID_ARGUMENT,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}function gg(e,t,n){let r;return r=e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,r}function _g(){return new Kh(`count`)}function vg(e){return yg(e,{count:_g()})}function yg(e,t){let n=ci(e.firestore,Lh),r=zh(n),i=Ui(t,((e,t)=>new xo(t,e.aggregateType,e._internalFieldPath)));return Mh(r,e._query,i).then((t=>function(e,t,n){return new qh(t,new Hh(e),n)}(n,e,t)))}var bg=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},xg=class e extends Jh{constructor(e,t,n,r,i,a){super(e,t,n,r,a),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new Sg(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){let n=this._document.data.field(Zl(`DocumentSnapshot.get`,e));if(n!==null)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new F(P.FAILED_PRECONDITION,`DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().`);let t=this._document,n={};return n.type=e._jsonSchemaVersion,n.bundle=``,n.bundleSource=`DocumentSnapshot`,n.bundleName=this._key.toString(),!t||!t.isValidDocument()||!t.isFoundDocument()?n:(this._userDataWriter.convertObjectMap(t.data.value.mapValue.fields,`previous`),n.bundle=(this._firestore,this.ref.path,`NOT SUPPORTED`),n)}};xg._jsonSchemaVersion=`firestore/documentSnapshot/1.0`,xg._jsonSchema={type:ui(`string`,xg._jsonSchemaVersion),bundleSource:ui(`string`,`DocumentSnapshot`),bundleName:ui(`string`),bundle:ui(`string`)};var Sg=class extends xg{data(e={}){return super.data(e)}},Cg=class e{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new bg(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){let e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach((n=>{e.call(t,new Sg(this._firestore,this._userDataWriter,n.key,n,new bg(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new F(P.INVALID_ARGUMENT,`To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().`);return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map((n=>{zf(e._snapshot.query)?op(e._snapshot.query):e.query._query;let r=new Sg(e._firestore,e._userDataWriter,n.doc.key,n.doc,new bg(e._snapshot.mutatedKeys.has(n.doc.key),e._snapshot.fromCache),e.query.converter);return n.doc,{type:`added`,doc:r,oldIndex:-1,newIndex:t++}}))}{let n=e._snapshot.oldDocs;return e._snapshot.docChanges.filter((e=>t||e.type!==3)).map((t=>{let r=new Sg(e._firestore,e._userDataWriter,t.doc.key,t.doc,new bg(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),i=-1,a=-1;return t.type!==0&&(i=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),t.type!==1&&(n=n.add(t.doc),a=n.indexOf(t.doc.key)),{type:wg(t.type),doc:r,oldIndex:i,newIndex:a}}))}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new F(P.FAILED_PRECONDITION,`QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().`);let t={};t.type=e._jsonSchemaVersion,t.bundleSource=`QuerySnapshot`,t.bundleName=Kr.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;let n=[],r=[],i=[];return this.docs.forEach((e=>{e._document!==null&&(n.push(e._document),r.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,`previous`)),i.push(e.ref.path))})),t.bundle=(this._firestore,this.query._query,t.bundleName,`NOT SUPPORTED`),t}};function wg(e){switch(e){case 0:return`added`;case 2:case 3:return`modified`;case 1:return`removed`;default:return j(61501,{type:e})}}Cg._jsonSchemaVersion=`firestore/querySnapshot/1.0`,Cg._jsonSchema={type:ui(`string`,Cg._jsonSchemaVersion),bundleSource:ui(`string`,`QuerySnapshot`),bundleName:ui(`string`),bundle:ui(`string`)};var Tg=class{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=Vl(e)}set(e,t,n){this._verifyNotCommitted();let r=Eg(e,this._firestore),i=gg(r.converter,t,n),a=Hl(this._dataReader,`WriteBatch.set`,r._key,i,r.converter!==null,n);return this._mutations.push(a.toMutation(r._key,ao.none())),this}update(e,t,n,...r){this._verifyNotCommitted();let i=Eg(e,this._firestore),a;return a=typeof(t=_(t))==`string`||t instanceof zc?Gl(this._dataReader,`WriteBatch.update`,i._key,t,n,r):Wl(this._dataReader,`WriteBatch.update`,i._key,t),this._mutations.push(a.toMutation(i._key,ao.exists(!0))),this}delete(e){this._verifyNotCommitted();let t=Eg(e,this._firestore);return this._mutations=this._mutations.concat(new yo(t._key,ao.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new F(P.FAILED_PRECONDITION,`A write batch can no longer be used after commit() has been called.`)}};function Eg(e,t){if((e=_(e)).firestore!==t)throw new F(P.INVALID_ARGUMENT,`Provided document reference is from a different Firestore instance.`);return e}function Dg(e){e=ci(e,Al);let t=ci(e.firestore,Lh);return Ah(zh(t),e._key).then((n=>Mg(t,e,n)))}function Og(e){e=ci(e,kl);let t=ci(e.firestore,Lh),n=zh(t),r=new Hh(t);return Xh(e._query),jh(n,e._query).then((n=>new Cg(t,r,e,n)))}function kg(e){return jg(ci(e.firestore,Lh),[new yo(e._key,ao.none())])}function Ag(e,...t){e=_(e);let n={includeMetadataChanges:!1,source:`default`},r=0;typeof t[r]!=`object`||Gh(t[r])||(n=t[r++]);let i={includeMetadataChanges:n.includeMetadataChanges,source:n.source};if(Gh(t[r])){let e=t[r];t[r]=e.next?.bind(e),t[r+1]=e.error?.bind(e),t[r+2]=e.complete?.bind(e)}let a,o,s;if(e instanceof Al)o=ci(e.firestore,Lh),s=$o(e._key.path),a={next:n=>{t[r]&&t[r](Mg(o,e,n))},error:t[r+1],complete:t[r+2]};else{let n=ci(e,kl);o=ci(n.firestore,Lh),s=n._query;let i=new Hh(o);a={next:e=>{t[r]&&t[r](new Cg(o,i,n,e))},error:t[r+1],complete:t[r+2]},Xh(e._query)}return kh(zh(o),s,i,a)}function jg(e,t){return Nh(zh(e),t)}function Mg(e,t,n){let r=n.docs.get(t._key);return new xg(e,new Hh(e),t._key,r,new bg(n.hasPendingWrites,n.fromCache),t.converter)}function Ng(e){return e=ci(e,Lh),zh(e),new Tg(e,(t=>jg(e,t)))}(function(e,t=!0){kr($t),Yt(new Ae(`firestore`,((e,{instanceIdentifier:n,options:r})=>{let i=e.getProvider(`app`).getImmediate(),a=new Lh(new Br(e.getProvider(`auth-internal`)),new Wr(i,e.getProvider(`app-check-internal`)),oa(i,n),i);return r={useFetchStreams:t,...r},a._setSettings(r),a}),`PUBLIC`).setMultipleInstances(!0)),nn(Uh,Wh,e),nn(Uh,Wh,`esm2020`)})();var Pg=class{constructor(){this.subscribers=new Set}subscribe(e){return this.subscribers.add(e),()=>this.unsubscribe(e)}unsubscribe(e){this.subscribers.delete(e)}notify(e){this.subscribers.forEach(t=>t(e))}get subscribersCount(){return this.subscribers.size}},Fg=new Uint8Array(16);function Ig(){return crypto.getRandomValues(Fg)}var Lg=[];for(let e=0;e<256;++e)Lg.push((e+256).toString(16).slice(1));function Rg(e,t=0){return(Lg[e[t+0]]+Lg[e[t+1]]+Lg[e[t+2]]+Lg[e[t+3]]+`-`+Lg[e[t+4]]+Lg[e[t+5]]+`-`+Lg[e[t+6]]+Lg[e[t+7]]+`-`+Lg[e[t+8]]+Lg[e[t+9]]+`-`+Lg[e[t+10]]+Lg[e[t+11]]+Lg[e[t+12]]+Lg[e[t+13]]+Lg[e[t+14]]+Lg[e[t+15]]).toLowerCase()}function zg(e,t,n){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():Bg(e,t,n)}function Bg(e,t,n){e||={};let r=e.random??e.rng?.()??Ig();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Rg(r)}function Vg(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var Y=class e{static registerFactory(e,t,n,r=!1){this._factoryMap[e]={factory:t,annotation:n,isLegacy:r}}static classFactory(e){if(!e)throw Error(`You should provide a class name.`);if(!this._factoryMap[e])throw Error(`You should register class ${e} prior to use.`);return this._factoryMap[e].factory}static registeredClasses(){return Object.entries(this._factoryMap).filter(([,e])=>!e.isLegacy).map(([e])=>e)}static registeredClassesAndLegacyNames(){return Object.keys(this._factoryMap)}static classesExtending(e){return Object.entries(this._factoryMap).filter(([,t])=>new t.factory instanceof e&&!t.isLegacy).map(([e])=>e)}static isInstanceOf(t,n){let r=e.classFactory(n);return t instanceof e?t instanceof r:e.createInstance(t)instanceof r}static annotations(t){if(t instanceof e?t=t.className:typeof t==`string`||(t=new t().className),!this._factoryMap[t])throw Error(`You should register class ${t} prior to use.`);return this._factoryMap[t].annotation}constructor(e=zg()){this._id=e}get className(){return this.__className}setId(e){this._id=e}get id(){return this._id}afterDeserialize(){}beforeSerialize(){}getPersistentProperties(){return this._persistentProperties?this._persistentProperties.map(e=>({...e,name:e.name.slice(1)})):[]}getPropInfo(e){let t=this.getPersistentProperties().find(t=>t.name===e);if(!t)throw Error(`Property "${e}" has not been registered.`);return t}isRequired(e){return this.getPropInfo(e).validator!=null}isPropValueValid(e){let t=this.getPropInfo(e);return t.validator?t.validator(this[t.name],t,this):!0}clone(e){let t=e.toObject();return delete t.id,this.fromObject(t)}fromObject(e){return this.fromObj(e),this.afterDeserialize(),this}fromObj(e){return this._persistentProperties&&this._persistentProperties.forEach(t=>{let n=e[this.removeUnderscore(t)];n!=null&&(this[t.name]=this.fromDeepObject(n))}),this}toObject(){let e={},t=this.toObj(e);return this.pushDocument(e,this.className,t),{...t,__rootCollections:e}}toObj(t){if(!this._persistentProperties)return{};this.beforeSerialize();let n={};if(!this.className)throw Error(`You should register \`${this.constructor.name||this.toString()||`this`}\` class prior to streaming it.`);return this._persistentProperties.forEach(r=>{let i=this[r.name],a=this.removeUnderscore(r);i!=null&&(r.isReference?n[a]=this.toReferenceObj(r,t):n[a]=this.toDeepObj(i,t),r.searchableArray&&(n[e.searchableArrayNameFor(a)]=i.map(e=>e.id)))}),n.__className=this.className,n}static searchableArrayNameFor(e){return`__${e}_searchable`}fromDeepObject(t){if(t==null)return t;if(Array.isArray(t))return t.map(e=>this.fromDeepObject(e));if(t.__documentReference){let n=t,r=e.createInstance(n);return r.__documentReference=t.__documentReference,r}if(t.__className)return e.createInstance(t);if(typeof t==`object`){let e={};return Object.entries(t).forEach(([t,n])=>e[t]=this.fromDeepObject(n)),e}return t}toDeepObj(t,n){if(t!=null){if(Array.isArray(t))return t.map(e=>this.toDeepObj(e,n));if(t.__documentReference)return t;if(t instanceof e)return t.toObj(n);if(typeof t==`object`){let e={};return Object.entries(t).forEach(([t,r])=>e[t]=this.toDeepObj(r,n)),e}return t}}static collectionPath(e,t,n){let r;return r=typeof t.storeInCollection==`function`?t.storeInCollection(e,t,n):t.storeInCollection??e.className,r}toReferenceObj(t,n){let r=this[t.name];return Array.isArray(r)?r.map(r=>(t.isPureReference||this.pushDocument(n,e.collectionPath(r,t),r),this.buildRefObject(r,e.collectionPath(r,t),t.cachedProps))):(t.isPureReference||this.pushDocument(n,e.collectionPath(r,t),r),this.buildRefObject(r,e.collectionPath(r,t),t.cachedProps))}buildRefObject(e,t,n){let r=n?.reduce((t,n)=>(e[n]!==void 0&&(t[n]=e[n]),t),{});return{id:e.id,__className:e.className||e.__className,__documentReference:{storedInCollection:t},...r}}pushDocument(e,t,n){if(`__documentReference`in n&&n.__documentReference)return;e[t]||(e[t]=[]);let r=this.toDeepObj(n,e);e[t].push(r)}removeUnderscore(e){return e.name.slice(1)}static createReference(t){let n=e.createInstance(t);return n.__documentReference=t.__documentReference||{storedInCollection:n.className},n}static createInstance(t){if(typeof t==`string`)return new(e.classFactory(t));try{return new(e.classFactory(t.__className))().fromObject(t)}catch(e){let n=Object.entries(t).filter(([e,t])=>t!=null&&typeof t!=`function`).map(([e,t])=>`${e}: ${t}`).join(`,
34
+ `);throw Error(`${e}\n-----> Class name not found in object:\n{\n\t ${n} \n}\n`)}}static propInfo(t,n){return e.createInstance(t).getPropInfo(n)}static propType(t){if(t.typeName)return Array.isArray(t.typeName)?`undefined[]`:t.typeName??`undefined`;let n=e.createInstance(t.ownerClassName())[t.name];if(Array.isArray(n)){if(n.length===0)return`undefined[]`;let t=n[0];return t instanceof e?t.className+`[]`:typeof t+`[]`}else if(n instanceof e)return n.className;else return typeof n}static getSystemRegisteredReferencesWithCachedProps(){return e.registeredClasses().reduce((t,n)=>{let r=e.createInstance(n).getPersistentProperties().filter(e=>e.cachedProps);return r.length>0&&(t[n]=r),t},{})}static{this._factoryMap={}}};Vg([Hg],Y.prototype,`_id`,void 0);function Hg(e,t){return Ug()(e,t)}function Ug(e){return function(t,n){Object.getOwnPropertyDescriptor(t,`_persistentProperties`)||(t._persistentProperties?t._persistentProperties=[...t._persistentProperties]:t._persistentProperties=[]);let r=t._persistentProperties.find(e=>e.name===n);r?Object.assign(r,e):t._persistentProperties.push({name:n,ownerClassName:()=>t.className,...e})}}function Wg(e,t){return n=>{Y.registerFactory(e,n,t),n.prototype.__className=e}}var Gg=class e{static{this.error={persistentNeedForSubCollection:`The document parameter for a sub-collection should be a Persistent instace`,invalidQueryOrder:`Cannot add where calls after or calls`}}constructor(t,n,r){if(r){if(!(n instanceof Y))throw Error(e.error.persistentNeedForSubCollection);this.collectionName=`${n.className}/${n.id}/${r}`}else this.collectionName=n instanceof Y?n.className:n;this._stream=t}findById(e,t){return new Promise((n,r)=>{this._stream.findById(e,this.collectionName).then(e=>{e?(t?t.fromObject(e):t=Y.createInstance(e),n(t)):n(void 0)}).catch(e=>r(e))})}save(e){let t=e.toObject();return this.collectionName!==t.__className&&(t.__rootCollections[this.collectionName]=t.__rootCollections[t.__className],delete t.__rootCollections[t.__className]),new Promise((e,n)=>{this._stream.save(t.__rootCollections).then(()=>e()).catch(e=>n(e))})}delete(e){return new Promise((t,n)=>{this._stream.delete(e,this.collectionName).then(()=>t()).catch(e=>n(e))})}find(){return new Kg(this)}query(e={},t){if(t){let n=t instanceof Y?t.className:t;e.operations||=[],e.operations.push({property:`__className`,operator:`==`,value:n})}return this.mapToInstance(()=>this._stream.find(this.preprocessQueryObject(e),this.collectionName))}count(e){return this._stream.count(e,this.collectionName)}next(e){return this.mapToInstance(()=>this._stream.next(e))}onDocumentChange(e,t){return this._stream.onDocumentChange(this.collectionName,e,e=>t(Yg.toPersistentDocumentChange(e)))}onCollectionChange(e,t){return this._stream.onCollectionChange(this.preprocessQueryObject(e.getQueryObject()),this.collectionName,e=>t(e.map(e=>Yg.toPersistentDocumentChange(e))))}onCollectionTemplateChange(e,t){return this._stream.onDocumentTemplateChange(e,e=>t(Yg.toPersistentDocumentChange(e)))}mapToInstance(e){return new Promise((t,n)=>{e().then(e=>t(e.map(e=>Y.createInstance(e)))).catch(e=>n(e))})}preprocessQueryObject(e){if(Object.values(e).length===0)return e;let t=e.operations?.map(e=>{let t=e.value[0]??e.value;return Yg.isArrayOperator(e.operator)&&t instanceof Y?{property:Y.searchableArrayNameFor(e.property),operator:e.operator,value:Array.isArray(e.value)?e.value.map(e=>e.id):t.id,aggregate:e.aggregate}:{property:e.property,operator:e.operator,value:e.value instanceof Y?{id:e.value.id}:e.value,aggregate:e.aggregate}})??[];return{...e,operations:t}}},Kg=class{constructor(e){this.queryObject={operations:[]},this.model=e}where(e,t,n,r){if(this.queryObject.operations?.at(-1)?.aggregate&&!r)throw Error(Gg.error.invalidQueryOrder);return this.queryObject.operations?.push({property:e,operator:t,value:n,aggregate:r}),this}whereDeepProp(e,t,n,r){if(this.queryObject.operations?.at(-1)?.aggregate&&!r)throw Error(Gg.error.invalidQueryOrder);let i=e.split(`.`),a={},o=i.length>1?a:n;return i.slice(1).forEach((e,t)=>{a[e]=t<i.length-2?{}:n,a=a[e]}),this.queryObject.operations?.push({property:i[0],operator:t,value:o,aggregate:r}),this}and(e,t,n){return this.where(e,t,n)}andDeepProp(e,t,n){return this.whereDeepProp(e,t,n)}or(e,t,n){return this.where(e,t,n,!0)}orDeepProp(e,t,n){return this.whereDeepProp(e,t,n,!0)}instanceOf(e){let t=e instanceof Y?e.className:e;return this.queryObject.operations?.push({property:`__className`,operator:`==`,value:t}),this}get(e){return e&&(this.queryObject.limit=e),this.model.query(this.queryObject)}limit(e){return this.queryObject.limit=e,this}orderBy(e,t=`asc`){return this.queryObject.sort={propertyName:e,order:t},this}orderByDeepProp(e,t=`asc`){return this.queryObject.sort={propertyName:e,order:t},this}count(){return this.model.count(this.queryObject)}getQueryObject(){return this.queryObject}getQueryModel(){return this.model}},qg=class e{constructor(){}static{this.error={shouldBeRegistered:`You should register a data source before using the data Store.`}}static useDataSource(e){this._dataSource=e}static get dataSource(){return e._dataSource}static getModel(t){if(!e._dataSource)throw Error(this.error.shouldBeRegistered);return new Gg(e._dataSource,t)}static getModelForSubCollection(t,n){if(!e._dataSource)throw Error(this.error.shouldBeRegistered);return new Gg(e._dataSource,t,n)}static async populate(e){if(!e)return;let t=async e=>{let t=e;if(!t.__documentReference)return e;let n=await this.getModel(t.__documentReference.storedInCollection).findById(t.id,e);return n&&(n.__documentReference=void 0),n};return Array.isArray(e)?(await Promise.all(e.map(e=>t(e)))).filter(e=>e):t(e)}static isPopulated(e){return Array.isArray(e)?e.reduce((e,t)=>e&&t.__documentReference===void 0,!0):e.__documentReference===void 0}},Jg=class e{constructor(e){this._resolveCollectionPaths=()=>{throw Error(`The method collectionsMatchingTemplate has not been implemented in the concrete data source`)},this._disabledChangeListeners=new Set,this._collectionsToWatch={},e&&(this._beforeUpdateDocument=e.beforeUpdateDocument,this._afterUpdateDocument=e.afterUpdateDocument,this._afterDocumentChange=e.afterDocumentChange,this._beforeDocumentChange=e.beforeDocumentChange,this._beforeQueryOwnerCollection=e.beforeQueryOwnerCollection),this.installUpdaters()}installUpdaters(){let e=Y.getSystemRegisteredReferencesWithCachedProps();this._collectionsToWatch={},Object.entries(e).forEach(([e,t])=>{t.forEach(t=>{t.typeName&&(Array.isArray(t.typeName)?t.typeName:[t?.typeName??e]).map(e=>Y.collectionPath(Y.createInstance(e),t)).forEach(e=>{this._collectionsToWatch[e]||(this._collectionsToWatch[e]=[]),this._collectionsToWatch[e].find(e=>e.name===t.name&&e.ownerClassName()===t.ownerClassName())||this._collectionsToWatch[e].push(t)})})})}set beforeDocumentChange(e){this._beforeDocumentChange=e}set afterDocumentChange(e){this._afterDocumentChange=e}set beforeUpdateDocument(e){this._beforeUpdateDocument=e}set afterUpdateDocument(e){this._afterUpdateDocument=e}set beforeQueryOwnerCollection(e){this._beforeQueryOwnerCollection=e}set resolveCollectionPaths(e){this._resolveCollectionPaths=e}get collectionsToWatch(){return this._collectionsToWatch}updateProps(e,t){let n=this._collectionsToWatch[e];return n?this.onDocumentChange(t,n):Promise.resolve()}async onDocumentChange(t,n){let r=Yg.toPersistentDocumentChange(t);this._beforeDocumentChange?.(r,n);let i={};t.type!==`update`||!r.before||r.after?.id&&this._disabledChangeListeners.has(r.after?.id)||(await Promise.all(n.map(async t=>{let n=e.ownerCollectionPath(Y.createInstance(t.ownerClassName()),t,r.params),a=await this._resolveCollectionPaths(n);await Promise.all(a.map(async e=>{let n=qg.getModel(e),a=n.find(),o=!1;t.cachedProps?.forEach(e=>{r.before[e]!==r.after[e]&&(o=!0)}),o&&(a=t.searchableArray?a.where(t.name,`contains`,r.before):a.where(t.name,`==`,r.before)),a=this._beforeQueryOwnerCollection?.(a)??a;let s=await a.get();return i[e]={totalDocumentsToUpdate:s.length,updatedDocuments:[],documentsToUpdate:s.map(e=>e.name??e.id)},Promise.all([s.map(async a=>{let o=!1;if(t.cachedProps?.forEach(e=>{r.before[e]!==r.after[e]&&(o=!0)}),o){if(t.searchableArray){let e=a[t.name].findIndex(e=>e.id===r.before.id);a[t.name][e]=r.after}else a[`_${t.name}`]=r.after;this._beforeUpdateDocument?.(a,t,r.after),this.disableChangeListener(a),await n.save(a),this.enableChangeListener(a),i[e]?.updatedDocuments.push(a.id),this._afterUpdateDocument?.(a,t,r.after)}else return Promise.resolve()})])}))})),this._afterDocumentChange?.(i,n))}disableChangeListener(e){this._disabledChangeListeners.add(e.id)}enableChangeListener(e){this._disabledChangeListeners.delete(e.id)}static ownerCollectionPath(e,t,n){let r;return r=typeof t.ownerCollection==`function`?t.ownerCollection(e,t,n):t.ownerCollection??e.className,r}},Yg=class e{constructor(){this._cachedPropsUpdater=void 0}installCachedPropsUpdater(e){return this._cachedPropsUpdater=new Jg(e),this._cachedPropsUpdater.resolveCollectionPaths=this.resolveCollectionPaths.bind(this),this._cachedPropsUpdater}get cachedPropsUpdater(){return this._cachedPropsUpdater}static toPropertyPathOperations(t){return t?t.map(t=>{if(e.isArrayOperator(t.operator)&&t.value[0]instanceof Y)return{property:Y.searchableArrayNameFor(t.property),operator:t.operator,value:t.value.map(e=>e.id),aggregate:t.aggregate};let[n,r]=this.toPropertyPathValue(t.value);return{property:`${String(t.property)}${n?`.`+n:``}`,operator:t.operator,value:r,aggregate:t.aggregate}}):[]}static isArrayOperator(e){return e===`containsAny`||e===`contains`}static toPersistentDocumentChange(e){return{...e,before:e.before&&Y.createInstance(e.before),after:e.after&&Y.createInstance(e.after)}}static toPropertyPathValue(e){if(typeof e==`object`&&!Array.isArray(e)){let t=Object.keys(e)[0],[n,r]=this.toPropertyPathValue(e[t]);return[`${t}${n?`.`+n:``}`,r]}else return[void 0,e]}static isStringMatchingTemplate(e,t){let n=e.split(`/`),r=t.split(`/`);if(r.length>n.length)return!1;for(let e=0;e<r.length;e++){let t=n[e],i=r[e];if(!(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith("${")&&t.endsWith(`}`))&&t!==i)return!1}for(let e=r.length;e<n.length;e++){let t=n[e];if(!(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith("${")&&t.endsWith(`}`)))return!1}return!0}static extractTemplateParams(e,t){let n=t.split(`/`),r=e.split(`/`),i={};if(r.length>n.length)return i;for(let e=0;e<r.length;e++){let t=n[e],a=r[e];if(t.startsWith(`{`)&&t.endsWith(`}`))i[t.slice(1,-1)]=a;else if(t.startsWith("${")&&t.endsWith(`}`))i[t.slice(2,-1)]=a;else if(t!==a)return{}}for(let e=r.length;e<n.length;e++){let t=n[e];if(!(t.startsWith(`{`)&&t.endsWith(`}`)||t.startsWith("${")&&t.endsWith(`}`)))return{}}return i}},Xg=class e{static registerCloudStorage(t,n){e._cloudStorageFactoryMap[t]=n}static createInstance(t){let n=e._cloudStorageFactoryMap[t];if(!n)throw Error(`You should register the ${t} cloud storage provider prior to use it`);return n()}get className(){return this.__className}static useCloudStorage(t){e._defaultCloudStorage=t}static get defaultCloudStorage(){if(!e._defaultCloudStorage)throw Error(`You should define a default cloud storage provider prior to use it`);return e._defaultCloudStorage}static{this._cloudStorageFactoryMap={}}};function Zg(e,t){return Xg.registerCloudStorage(e,t),t=>{t.prototype.__className=e}}var Qg=class extends Xg{constructor(e=``){super(),this._simulateDelay=0,this._pendingPromises=[],this.mockFileSystem={},this._pathToMockFiles=e}simulateDelay(e){return this._simulateDelay=e,this}resolveWithDelay(e){if(this._simulateDelay<=0)return Promise.resolve(e);let t=new Promise(t=>{setTimeout(()=>t(e),this._simulateDelay)});return this._pendingPromises.push(t),t.finally(()=>this._pendingPromises=this._pendingPromises.filter(e=>e===t)),t}save(e,t){let n=e;this._onProgress&&this._onProgress(0,100),this.mockFileSystem[e]=JSON.stringify(t),this._onProgress&&this._onProgress(100,100);let r=t instanceof File?t.name:n;return this.resolveWithDelay(r)}uploadControl(){return{resume:()=>{},pause:()=>{},cancel:()=>{},onProgress:e=>this._onProgress=e}}getUrl(e){return Promise.resolve(this._pathToMockFiles+e)}delete(e){return delete this.mockFileSystem[e],this.resolveWithDelay()}};Qg=Vg([Zg(`MockCloudStorage`,()=>new Qg)],Qg);var $g=class extends Y{constructor(...e){super(...e),this._onChange=new Pg}async save({data:e,fileName:t,progress:n,cloudStorageProvider:r}={}){let i=e||this._pendingData;i&&(this._reference&&await this.delete(),this.provider=r||Xg.defaultCloudStorage,this._originalFileName=t||(i instanceof File?i.name:void 0),this._reference=await this.provider.save(this.id,i,n),this._url=await this.provider.getUrl(this._reference),this._pendingData=void 0,this._onChange.notify({event:0,storedFile:this}))}uploadControl(){return this.provider.uploadControl()}async delete(){if(!this._reference)throw Error(`Cannot delete a not stored file`);await this.provider.delete(this._reference),this._reference=void 0,this._url=void 0,this._onChange.notify({event:2,storedFile:this})}set provider(e){this._provider=e,this._cloudStorageProviderName=e.className}get provider(){if(!this._provider)try{this._provider=Xg.createInstance(this._cloudStorageProviderName)}catch{this._provider=Xg.defaultCloudStorage}return this._provider}get url(){return this._url}get mimeType(){return this._mimeType}setDataToStore(e){return this._pendingData=e,this._originalFileName=e instanceof File?e.name:void 0,this._mimeType=e instanceof Blob?e.type:void 0,this._onChange.notify({event:1,pendingData:e,storedFile:this}),this}get originalFileName(){return this._originalFileName}onChange(e){return this._onChange.subscribe(e)}};Vg([Hg],$g.prototype,`_reference`,void 0),Vg([Hg],$g.prototype,`_url`,void 0),Vg([Hg],$g.prototype,`_cloudStorageProviderName`,void 0),Vg([Hg],$g.prototype,`_originalFileName`,void 0),Vg([Hg],$g.prototype,`_mimeType`,void 0),$g=Vg([Wg(`StoredFile`)],$g);var e_=class{};(class e extends e_{static{this.error={shouldBeRegistered:`You should register an auth service before using Auth.`}}constructor(){if(super(),this._onAuthStateChange=new Pg,!e._authService)throw Error(e.error.shouldBeRegistered);e._authService.onAuthStateChange(e=>this.authStateChanged(e))}static useAuthService(t){e._authService!=t&&(e._authService=t,this._instance=void 0)}static get instance(){return this._instance||=new this}signUp(t){return e._authService.signUp(t)}login(t){return e._authService.login(t)}logout(){return e._authService.logout()}resetEmailPassword(t){return e._authService.resetEmailPassword(t)}resendVerificationEmail(t,n,r){return e._authService.resendVerificationEmail(t,n,r)}refreshToken(){return e._authService.refreshToken()}onAuthStateChange(e){return this._onAuthStateChange.subscribe(e)}removeAuthStateChange(e){this._onAuthStateChange.unsubscribe(e)}linkAdditionalProvider(t){return e._authService.linkAdditionalProvider(t)}unlinkProvider(t){return e._authService.unlinkProvider(t)}authStateChanged(e){this._onAuthStateChange.notify(e)}static{this._instance=void 0}}),class e{constructor(){}static{this.error={shouldBeRegistered:`You should register a cloud functions service with useCloudFunctionsService static method before using CloudFunctions.`}}static useCloudFunctionsService(e){this._cloudFunctionsService!=e&&(this._cloudFunctionsService=e)}static get instance(){if(!this._cloudFunctionsService)throw Error(e.error.shouldBeRegistered);return e._instance||=new e}getRawFunction(t){return e._cloudFunctionsService.retrieveFunction(t)}getFunction(t){let n=e._cloudFunctionsService.callFunction,r=this.getRawFunction(t);return async e=>{let t=await n(r,this.processParam(e));return this.processResult(t)}}processParam(e){if(e!=null)return e instanceof Y?e.toObject():Array.isArray(e)?e.map(e=>this.processParam(e)):typeof e==`object`?Object.entries(e).reduce((e,[t,n])=>(e[t]=this.processParam(n),e),{}):e}processResult(e){if(e!=null)return e.__className?Y.createInstance(e):Array.isArray(e)?e.map(e=>this.processResult(e)):typeof e==`object`?Object.entries(e).reduce((e,[t,n])=>(e[t]=this.processResult(n),e),{}):e}};var t_=class{};(class e extends t_{static{this.error={shouldBeRegistered:`You should register a Server Auth service before using the Server Auth.`}}constructor(){super()}static useServerAuthService(t){e._authService!=t&&(e._authService=t,this._instance=void 0)}static get instance(){if(!e._authService)throw Error(e.error.shouldBeRegistered);return this._instance||=new e}getUser(t){return e._authService.getUser(t)}updateUser(t,n){return e._authService.updateUser(t,n)}setCustomCredentials(t,n){return e._authService.setCustomCredentials(t,n)}deleteUser(t){return e._authService.deleteUser(t)}static{this._instance=void 0}});function n_(e){return e?e.replace(/([-_ ][\w])/g,e=>e.toUpperCase().replace(`-`,``).replace(`_`,``).replace(` `,``)):``}nn(`firebase`,`12.15.0`,`app`);function r_(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}var i_=r_,a_=new he(`auth`,`Firebase`,r_()),o_=new Ve(`@firebase/auth`);function s_(e,...t){o_.logLevel<=v.WARN&&o_.warn(`Auth (${$t}): ${e}`,...t)}function c_(e,...t){o_.logLevel<=v.ERROR&&o_.error(`Auth (${$t}): ${e}`,...t)}function l_(e,...t){throw m_(e,...t)}function u_(e,...t){return m_(e,...t)}function d_(e,t,n){return new he(`auth`,`Firebase`,{...i_(),[t]:n}).create(t,{appName:e.name})}function f_(e){return d_(e,`operation-not-supported-in-this-environment`,`Operations that alter the current user are not supported in conjunction with FirebaseServerApp`)}function p_(e,t,n){let r=n;if(!(t instanceof r))throw r.name!==t.constructor.name&&l_(e,`argument-error`),d_(e,`argument-error`,`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function m_(e,...t){if(typeof e!=`string`){let n=t[0],r=[...t.slice(1)];return r[0]&&(r[0].appName=e.name),e._errorFactory.create(n,...r)}return a_.create(e,...t)}function X(e,t,...n){if(!e)throw m_(t,...n)}function h_(e){let t=`INTERNAL ASSERTION FAILED: `+e;throw c_(t),Error(t)}function g_(e,t){e||h_(t)}function __(){return typeof self<`u`&&self.location?.href||``}function v_(){return y_()===`http:`||y_()===`https:`}function y_(){return typeof self<`u`&&self.location?.protocol||null}function b_(){return typeof navigator<`u`&&navigator&&`onLine`in navigator&&typeof navigator.onLine==`boolean`&&(v_()||se()||`connection`in navigator)?navigator.onLine:!0}function x_(){if(typeof navigator>`u`)return null;let e=navigator;return e.languages&&e.languages[0]||e.language||null}var S_=class{constructor(e,t){this.shortDelay=e,this.longDelay=t,g_(t>e,`Short delay should be less than long delay!`),this.isMobile=ie()||ce()}get(){return b_()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}};function C_(e,t){g_(e.emulator,`Emulator should always be set here`);let{url:n}=e.emulator;return t?`${n}${t.startsWith(`/`)?t.slice(1):t}`:n}var w_=class{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<`u`&&`fetch`in self)return self.fetch;if(typeof globalThis<`u`&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<`u`)return fetch;h_(`Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill`)}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<`u`&&`Headers`in self)return self.Headers;if(typeof globalThis<`u`&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<`u`)return Headers;h_(`Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill`)}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<`u`&&`Response`in self)return self.Response;if(typeof globalThis<`u`&&globalThis.Response)return globalThis.Response;if(typeof Response<`u`)return Response;h_(`Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill`)}},T_={CREDENTIAL_MISMATCH:`custom-token-mismatch`,MISSING_CUSTOM_TOKEN:`internal-error`,INVALID_IDENTIFIER:`invalid-email`,MISSING_CONTINUE_URI:`internal-error`,INVALID_PASSWORD:`wrong-password`,MISSING_PASSWORD:`missing-password`,INVALID_LOGIN_CREDENTIALS:`invalid-credential`,EMAIL_EXISTS:`email-already-in-use`,PASSWORD_LOGIN_DISABLED:`operation-not-allowed`,INVALID_IDP_RESPONSE:`invalid-credential`,INVALID_PENDING_TOKEN:`invalid-credential`,FEDERATED_USER_ID_ALREADY_LINKED:`credential-already-in-use`,MISSING_REQ_TYPE:`internal-error`,EMAIL_NOT_FOUND:`user-not-found`,RESET_PASSWORD_EXCEED_LIMIT:`too-many-requests`,EXPIRED_OOB_CODE:`expired-action-code`,INVALID_OOB_CODE:`invalid-action-code`,MISSING_OOB_CODE:`internal-error`,CREDENTIAL_TOO_OLD_LOGIN_AGAIN:`requires-recent-login`,INVALID_ID_TOKEN:`invalid-user-token`,TOKEN_EXPIRED:`user-token-expired`,USER_NOT_FOUND:`user-token-expired`,TOO_MANY_ATTEMPTS_TRY_LATER:`too-many-requests`,PASSWORD_DOES_NOT_MEET_REQUIREMENTS:`password-does-not-meet-requirements`,INVALID_CODE:`invalid-verification-code`,INVALID_SESSION_INFO:`invalid-verification-id`,INVALID_TEMPORARY_PROOF:`invalid-credential`,MISSING_SESSION_INFO:`missing-verification-id`,SESSION_EXPIRED:`code-expired`,MISSING_ANDROID_PACKAGE_NAME:`missing-android-pkg-name`,UNAUTHORIZED_DOMAIN:`unauthorized-continue-uri`,INVALID_OAUTH_CLIENT_ID:`invalid-oauth-client-id`,ADMIN_ONLY_OPERATION:`admin-restricted-operation`,INVALID_MFA_PENDING_CREDENTIAL:`invalid-multi-factor-session`,MFA_ENROLLMENT_NOT_FOUND:`multi-factor-info-not-found`,MISSING_MFA_ENROLLMENT_ID:`missing-multi-factor-info`,MISSING_MFA_PENDING_CREDENTIAL:`missing-multi-factor-session`,SECOND_FACTOR_EXISTS:`second-factor-already-in-use`,SECOND_FACTOR_LIMIT_EXCEEDED:`maximum-second-factor-count-exceeded`,BLOCKING_FUNCTION_ERROR_RESPONSE:`internal-error`,RECAPTCHA_NOT_ENABLED:`recaptcha-not-enabled`,MISSING_RECAPTCHA_TOKEN:`missing-recaptcha-token`,INVALID_RECAPTCHA_TOKEN:`invalid-recaptcha-token`,INVALID_RECAPTCHA_ACTION:`invalid-recaptcha-action`,MISSING_CLIENT_TYPE:`missing-client-type`,MISSING_RECAPTCHA_VERSION:`missing-recaptcha-version`,INVALID_RECAPTCHA_VERSION:`invalid-recaptcha-version`,INVALID_REQ_TYPE:`invalid-req-type`},E_=[`/v1/accounts:signInWithCustomToken`,`/v1/accounts:signInWithEmailLink`,`/v1/accounts:signInWithIdp`,`/v1/accounts:signInWithPassword`,`/v1/accounts:signInWithPhoneNumber`,`/v1/token`],D_=new S_(3e4,6e4);function O_(e,t){return e.tenantId&&!t.tenantId?{...t,tenantId:e.tenantId}:t}async function k_(e,t,n,r,i={}){return A_(e,i,async()=>{let i={},a={};r&&(t===`GET`?a=r:i={body:JSON.stringify(r)});let o=xe({...a,key:e.config.apiKey}).slice(1),s=await e._getAdditionalHeaders();s[`Content-Type`]=`application/json`,e.languageCode&&(s[`X-Firebase-Locale`]=e.languageCode);let c={method:t,headers:s,...i};return oe()||(c.referrerPolicy=`strict-origin-when-cross-origin`),e.emulatorConfig&&Oe(e.emulatorConfig.host)&&(c.credentials=`include`),w_.fetch()(await M_(e,e.config.apiHost,n,o),c)})}async function A_(e,t,n){e._canInitEmulator=!1;let r={...T_,...t};try{let t=new P_(e),i=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();let a=await i.json();if(`needConfirmation`in a)throw F_(e,`account-exists-with-different-credential`,a);if(i.ok&&!(`errorMessage`in a))return a;{let[t,n]=(i.ok?a.errorMessage:a.error.message).split(` : `);if(t===`FEDERATED_USER_ID_ALREADY_LINKED`)throw F_(e,`credential-already-in-use`,a);if(t===`EMAIL_EXISTS`)throw F_(e,`email-already-in-use`,a);if(t===`USER_DISABLED`)throw F_(e,`user-disabled`,a);let o=r[t]||t.toLowerCase().replace(/[_\s]+/g,`-`);if(n)throw d_(e,o,n);l_(e,o)}}catch(t){if(t instanceof me)throw t;l_(e,`network-request-failed`,{message:String(t)})}}async function j_(e,t,n,r,i={}){let a=await k_(e,t,n,r,i);return`mfaPendingCredential`in a&&l_(e,`multi-factor-auth-required`,{_serverResponse:a}),a}async function M_(e,t,n,r){let i=`${t}${n}?${r}`,a=e,o=a.config.emulator?C_(e.config,i):`${e.config.apiScheme}://${i}`;return E_.includes(n)&&(await a._persistenceManagerAvailable,a._getPersistenceType()===`COOKIE`)?a._getPersistence()._getFinalTarget(o).toString():o}function N_(e){switch(e){case`ENFORCE`:return`ENFORCE`;case`AUDIT`:return`AUDIT`;case`OFF`:return`OFF`;default:return`ENFORCEMENT_STATE_UNSPECIFIED`}}var P_=class{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>{this.timer=setTimeout(()=>t(u_(this.auth,`network-request-failed`)),D_.get())})}};function F_(e,t,n){let r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);let i=u_(e,t,r);return i.customData._tokenResponse=n,i}function I_(e){return e!==void 0&&e.enterprise!==void 0}var L_=class{constructor(e){if(this.siteKey=``,this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw Error(`recaptchaKey undefined`);this.siteKey=e.recaptchaKey.split(`/`)[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(let t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return N_(t.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)===`ENFORCE`||this.getProviderEnforcementState(e)===`AUDIT`}isAnyProviderEnabled(){return this.isProviderEnabled(`EMAIL_PASSWORD_PROVIDER`)||this.isProviderEnabled(`PHONE_PROVIDER`)}};async function R_(e,t){return k_(e,`GET`,`/v2/recaptchaConfig`,O_(e,t))}async function z_(e,t){return k_(e,`POST`,`/v1/accounts:delete`,t)}async function B_(e,t){return k_(e,`POST`,`/v1/accounts:update`,t)}async function V_(e,t){return k_(e,`POST`,`/v1/accounts:lookup`,t)}function H_(e){if(e)try{let t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch{}}async function U_(e,t=!1){let n=_(e),r=await n.getIdToken(t),i=G_(r);X(i&&i.exp&&i.auth_time&&i.iat,n.auth,`internal-error`);let a=typeof i.firebase==`object`?i.firebase:void 0,o=a?.sign_in_provider;return{claims:i,token:r,authTime:H_(W_(i.auth_time)),issuedAtTime:H_(W_(i.iat)),expirationTime:H_(W_(i.exp)),signInProvider:o||null,signInSecondFactor:a?.sign_in_second_factor||null}}function W_(e){return Number(e)*1e3}function G_(e){let[t,n,r]=e.split(`.`);if(t===void 0||n===void 0||r===void 0)return c_(`JWT malformed, contained fewer than 3 sections`),null;try{let e=c(n);return e?JSON.parse(e):(c_(`Failed to decode base64 JWT payload`),null)}catch(e){return c_(`Caught error parsing JWT payload as JSON`,e?.toString()),null}}function K_(e){let t=G_(e);return X(t,`internal-error`),X(t.exp!==void 0,`internal-error`),X(t.iat!==void 0,`internal-error`),Number(t.exp)-Number(t.iat)}async function q_(e,t,n=!1){if(n)return t;try{return await t}catch(t){throw t instanceof me&&J_(t)&&e.auth.currentUser===e&&await e.auth.signOut(),t}}function J_({code:e}){return e===`auth/user-disabled`||e===`auth/user-token-expired`}var Y_=class{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){if(e){let e=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),e}else{this.errorBackoff=3e4;let e=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,e)}}schedule(e=!1){if(!this.isRunning)return;let t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){e?.code===`auth/network-request-failed`&&this.schedule(!0);return}this.schedule()}},X_=class{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=H_(this.lastLoginAt),this.creationTime=H_(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}};async function Z_(e){let t=e.auth,n=await q_(e,V_(t,{idToken:await e.getIdToken()}));X(n?.users.length,t,`internal-error`);let r=n.users[0];e._notifyReloadListener(r);let i=r.providerUserInfo?.length?ev(r.providerUserInfo):[],a=$_(e.providerData,i),o=e.isAnonymous,s=!(e.email&&r.passwordHash)&&!a?.length,c=o?s:!1,l={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:a,metadata:new X_(r.createdAt,r.lastLoginAt),isAnonymous:c};Object.assign(e,l)}async function Q_(e){let t=_(e);await Z_(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}function $_(e,t){return[...e.filter(e=>!t.some(t=>t.providerId===e.providerId)),...t]}function ev(e){return e.map(({providerId:e,...t})=>({providerId:e,uid:t.rawId||``,displayName:t.displayName||null,email:t.email||null,phoneNumber:t.phoneNumber||null,photoURL:t.photoUrl||null}))}async function tv(e,t){let n=await A_(e,{},async()=>{let n=xe({grant_type:`refresh_token`,refresh_token:t}).slice(1),{tokenApiHost:r,apiKey:i}=e.config,a=await M_(e,r,`/v1/token`,`key=${i}`),o=await e._getAdditionalHeaders();o[`Content-Type`]=`application/x-www-form-urlencoded`;let s={method:`POST`,headers:o,body:n};return e.emulatorConfig&&Oe(e.emulatorConfig.host)&&(s.credentials=`include`),w_.fetch()(a,s)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function nv(e,t){return k_(e,`POST`,`/v2/accounts:revokeToken`,O_(e,t))}var rv=class e{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){X(e.idToken,`internal-error`),X(e.idToken!==void 0,`internal-error`),X(e.refreshToken!==void 0,`internal-error`);let t=`expiresIn`in e&&e.expiresIn!==void 0?Number(e.expiresIn):K_(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){X(e.length!==0,`internal-error`);let t=K_(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return!t&&this.accessToken&&!this.isExpired?this.accessToken:(X(this.refreshToken,e,`user-token-expired`),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){let{accessToken:n,refreshToken:r,expiresIn:i}=await tv(e,t);this.updateTokensAndExpiration(n,r,Number(i))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+n*1e3}static fromJSON(t,n){let{refreshToken:r,accessToken:i,expirationTime:a}=n,o=new e;return r&&(X(typeof r==`string`,`internal-error`,{appName:t}),o.refreshToken=r),i&&(X(typeof i==`string`,`internal-error`,{appName:t}),o.accessToken=i),a&&(X(typeof a==`number`,`internal-error`,{appName:t}),o.expirationTime=a),o}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new e,this.toJSON())}_performRefresh(){return h_(`not implemented`)}};function iv(e,t){X(typeof e==`string`||e===void 0,`internal-error`,{appName:t})}var av=class e{constructor({uid:e,auth:t,stsTokenManager:n,...r}){this.providerId=`firebase`,this.proactiveRefresh=new Y_(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=t,this.stsTokenManager=n,this.accessToken=n.accessToken,this.displayName=r.displayName||null,this.email=r.email||null,this.emailVerified=r.emailVerified||!1,this.phoneNumber=r.phoneNumber||null,this.photoURL=r.photoURL||null,this.isAnonymous=r.isAnonymous||!1,this.tenantId=r.tenantId||null,this.providerData=r.providerData?[...r.providerData]:[],this.metadata=new X_(r.createdAt||void 0,r.lastLoginAt||void 0)}async getIdToken(e){let t=await q_(this,this.stsTokenManager.getToken(this.auth,e));return X(t,this.auth,`internal-error`),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return U_(this,e)}reload(){return Q_(this)}_assign(e){this!==e&&(X(this.uid===e.uid,this.auth,`internal-error`),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(e=>({...e})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(t){let n=new e({...this,auth:t,stsTokenManager:this.stsTokenManager._clone()});return n.metadata._copy(this.metadata),n}_onReload(e){X(!this.reloadListener,this.auth,`internal-error`),this.reloadListener=e,this.reloadUserInfo&&=(this._notifyReloadListener(this.reloadUserInfo),null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let n=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),n=!0),t&&await Z_(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(y(this.auth.app))return Promise.reject(f_(this.auth));let e=await this.getIdToken();return await q_(this,z_(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>({...e})),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId,...this.metadata.toJSON(),apiKey:this.auth.config.apiKey,appName:this.auth.name}}get refreshToken(){return this.stsTokenManager.refreshToken||``}static _fromJSON(t,n){let r=n.displayName??void 0,i=n.email??void 0,a=n.phoneNumber??void 0,o=n.photoURL??void 0,s=n.tenantId??void 0,c=n._redirectEventId??void 0,l=n.createdAt??void 0,u=n.lastLoginAt??void 0,{uid:d,emailVerified:f,isAnonymous:p,providerData:m,stsTokenManager:h}=n;X(d&&h,t,`internal-error`);let g=rv.fromJSON(this.name,h);X(typeof d==`string`,t,`internal-error`),iv(r,t.name),iv(i,t.name),X(typeof f==`boolean`,t,`internal-error`),X(typeof p==`boolean`,t,`internal-error`),iv(a,t.name),iv(o,t.name),iv(s,t.name),iv(c,t.name),iv(l,t.name),iv(u,t.name);let ee=new e({uid:d,auth:t,email:i,emailVerified:f,displayName:r,isAnonymous:p,photoURL:o,phoneNumber:a,tenantId:s,stsTokenManager:g,createdAt:l,lastLoginAt:u});return m&&Array.isArray(m)&&(ee.providerData=m.map(e=>({...e}))),c&&(ee._redirectEventId=c),ee}static async _fromIdTokenResponse(t,n,r=!1){let i=new rv;i.updateFromServerResponse(n);let a=new e({uid:n.localId,auth:t,stsTokenManager:i,isAnonymous:r});return await Z_(a),a}static async _fromGetAccountInfoResponse(t,n,r){let i=n.users[0];X(i.localId!==void 0,`internal-error`);let a=i.providerUserInfo===void 0?[]:ev(i.providerUserInfo),o=!(i.email&&i.passwordHash)&&!a?.length,s=new rv;s.updateFromIdToken(r);let c=new e({uid:i.localId,auth:t,stsTokenManager:s,isAnonymous:o}),l={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:a,metadata:new X_(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash)&&!a?.length};return Object.assign(c,l),c}},ov=new Map;function sv(e){g_(e instanceof Function,`Expected a class definition`);let t=ov.get(e);return t?(g_(t instanceof e,`Instance stored in cache mismatched with class`),t):(t=new e,ov.set(e,t),t)}var cv=class{constructor(){this.type=`NONE`,this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){let t=this.storage[e];return t===void 0?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}};cv.type=`NONE`;var lv=cv;function uv(e,t,n){return`firebase:${e}:${t}:${n}`}var dv=class e{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;let{config:r,name:i}=this.auth;this.fullUserKey=uv(this.userKey,r.apiKey,i),this.fullPersistenceKey=uv(`persistence`,r.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){let e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e==`string`){let t=await V_(this.auth,{idToken:e}).catch(()=>void 0);return t?av._fromGetAccountInfoResponse(this.auth,t,e):null}return av._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;let t=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,t)return this.setCurrentUser(t)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(t,n,r=`authUser`){if(!n.length)return new e(sv(lv),t,r);let i=(await Promise.all(n.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e),a=i[0]||sv(lv),o=uv(r,t.config.apiKey,t.name),s=null;for(let e of n)try{let n=await e._get(o);if(n){let r;if(typeof n==`string`){let e=await V_(t,{idToken:n}).catch(()=>void 0);if(!e)break;r=await av._fromGetAccountInfoResponse(t,e,n)}else r=av._fromJSON(t,n);e!==a&&(s=r),a=e;break}}catch{}let c=i.filter(e=>e._shouldAllowMigration);return!a._shouldAllowMigration||!c.length?new e(a,t,r):(a=c[0],s&&await a._set(o,s.toJSON()),await Promise.all(n.map(async e=>{if(e!==a)try{await e._remove(o)}catch{}})),new e(a,t,r))}};function fv(e){let t=e.toLowerCase();if(t.includes(`opera/`)||t.includes(`opr/`)||t.includes(`opios/`))return`Opera`;if(gv(t))return`IEMobile`;if(t.includes(`msie`)||t.includes(`trident/`))return`IE`;if(t.includes(`edge/`))return`Edge`;if(pv(t))return`Firefox`;if(t.includes(`silk/`))return`Silk`;if(vv(t))return`Blackberry`;if(yv(t))return`Webos`;if(mv(t))return`Safari`;if((t.includes(`chrome/`)||hv(t))&&!t.includes(`edge/`))return`Chrome`;if(_v(t))return`Android`;{let t=e.match(/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/);if(t?.length===2)return t[1]}return`Other`}function pv(e=re()){return/firefox\//i.test(e)}function mv(e=re()){let t=e.toLowerCase();return t.includes(`safari/`)&&!t.includes(`chrome/`)&&!t.includes(`crios/`)&&!t.includes(`android`)}function hv(e=re()){return/crios\//i.test(e)}function gv(e=re()){return/iemobile/i.test(e)}function _v(e=re()){return/android/i.test(e)}function vv(e=re()){return/blackberry/i.test(e)}function yv(e=re()){return/webos/i.test(e)}function bv(e=re()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function xv(e=re()){return bv(e)&&!!window.navigator?.standalone}function Sv(){return le()&&document.documentMode===10}function Cv(e=re()){return bv(e)||_v(e)||yv(e)||vv(e)||/windows phone/i.test(e)||gv(e)}function wv(e,t=[]){let n;switch(e){case`Browser`:n=fv(re());break;case`Worker`:n=`${fv(re())}-${e}`;break;default:n=e}let r=t.length?t.join(`,`):`FirebaseCore-web`;return`${n}/JsCore/${$t}/${r}`}var Tv=class{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){let n=t=>new Promise((n,r)=>{try{n(e(t))}catch(e){r(e)}});n.onAbort=t,this.queue.push(n);let r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;let t=[];try{for(let n of this.queue)await n(e),n.onAbort&&t.push(n.onAbort)}catch(e){t.reverse();for(let e of t)try{e()}catch{}throw this.auth._errorFactory.create(`login-blocked`,{originalMessage:e?.message})}}};async function Ev(e,t={}){return k_(e,`GET`,`/v2/passwordPolicy`,O_(e,t))}var Dv=6,Ov=class{constructor(e){let t=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=t.minPasswordLength??Dv,t.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=t.maxPasswordLength),t.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=t.containsLowercaseCharacter),t.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=t.containsUppercaseCharacter),t.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=t.containsNumericCharacter),t.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=t.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState===`ENFORCEMENT_STATE_UNSPECIFIED`&&(this.enforcementState=`OFF`),this.allowedNonAlphanumericCharacters=e.allowedNonAlphanumericCharacters?.join(``)??``,this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){let t={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,t),this.validatePasswordCharacterOptions(e,t),t.isValid&&=t.meetsMinPasswordLength??!0,t.isValid&&=t.meetsMaxPasswordLength??!0,t.isValid&&=t.containsLowercaseLetter??!0,t.isValid&&=t.containsUppercaseLetter??!0,t.isValid&&=t.containsNumericCharacter??!0,t.isValid&&=t.containsNonAlphanumericCharacter??!0,t}validatePasswordLengthOptions(e,t){let n=this.customStrengthOptions.minPasswordLength,r=this.customStrengthOptions.maxPasswordLength;n&&(t.meetsMinPasswordLength=e.length>=n),r&&(t.meetsMaxPasswordLength=e.length<=r)}validatePasswordCharacterOptions(e,t){this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);let n;for(let r=0;r<e.length;r++)n=e.charAt(r),this.updatePasswordCharacterOptionsStatuses(t,n>=`a`&&n<=`z`,n>=`A`&&n<=`Z`,n>=`0`&&n<=`9`,this.allowedNonAlphanumericCharacters.includes(n))}updatePasswordCharacterOptionsStatuses(e,t,n,r,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||=t),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||=n),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||=r),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||=i)}},kv=class{constructor(e,t,n,r){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=n,this.config=r,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new jv(this),this.idTokenSubscription=new jv(this),this.beforeStateQueue=new Tv(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=a_,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=r.sdkClientVersion,this._persistenceManagerAvailable=new Promise(e=>this._resolvePersistenceManagerAvailable=e)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=sv(t)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await dv.create(this,e),this._resolvePersistenceManagerAvailable?.(),!this._deleted)){if(this._popupRedirectResolver?._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(t),this.lastNotifiedUid=this.currentUser?.uid||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;let e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{let t=await V_(this,{idToken:e}),n=await av._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(n)}catch(e){console.warn(`FirebaseServerApp could not login user with provided authIdToken: `,e),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(y(this.app)){let e=this.app.settings.authIdToken;return e?new Promise(t=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(e).then(t,t))}):this.directlySetCurrentUser(null)}let t=await this.assertedPersistence.getCurrentUser(),n=t,r=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();let t=this.redirectUser?._redirectEventId,i=n?._redirectEventId,a=await this.tryRedirectSignIn(e);(!t||t===i)&&a?.user&&(n=a.user,r=!0)}if(!n)return this.directlySetCurrentUser(null);if(!n._redirectEventId){if(r)try{await this.beforeStateQueue.runMiddleware(n)}catch(e){n=t,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(e))}return n?this.reloadAndSetCurrentUserOrClear(n):this.directlySetCurrentUser(null)}return X(this._popupRedirectResolver,this,`argument-error`),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===n._redirectEventId?this.directlySetCurrentUser(n):this.reloadAndSetCurrentUserOrClear(n)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await Z_(e)}catch(e){if(e?.code!==`auth/network-request-failed`)return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=x_()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(y(this.app))return Promise.reject(f_(this));let t=e?_(e):null;return t&&X(t.auth.config.apiKey===this.config.apiKey,this,`invalid-user-token`),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&X(this.tenantId===e.tenantId,this,`tenant-id-mismatch`),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return y(this.app)?Promise.reject(f_(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return y(this.app)?Promise.reject(f_(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(sv(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();let t=this._getPasswordPolicyInternal();return t.schemaVersion===this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?t.validatePassword(e):Promise.reject(this._errorFactory.create(`unsupported-password-policy-schema-version`,{}))}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){let e=new Ov(await Ev(this));this.tenantId===null?this._projectPasswordPolicy=e:this._tenantPasswordPolicies[this.tenantId]=e}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new he(`auth`,`Firebase`,e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}authStateReady(){return new Promise((e,t)=>{if(this.currentUser)e();else{let n=this.onAuthStateChanged(()=>{n(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){let t={providerId:`apple.com`,tokenType:`ACCESS_TOKEN`,token:e,idToken:await this.currentUser.getIdToken()};this.tenantId!=null&&(t.tenantId=this.tenantId),await nv(this,t)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,t){let n=await this.getOrInitRedirectPersistenceManager(t);return e===null?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){let t=e&&sv(e)||this._popupRedirectResolver;X(t,this,`argument-error`),this.redirectPersistenceManager=await dv.create(this,[sv(t._redirectPersistence)],`redirectUser`),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){return this._isInitialized&&await this.queue(async()=>{}),this._currentUser?._redirectEventId===e?this._currentUser:this.redirectUser?._redirectEventId===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);let e=this.currentUser?.uid??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,n,r){if(this._deleted)return()=>{};let i=typeof t==`function`?t:t.next.bind(t),a=!1,o=this._isInitialized?Promise.resolve():this._initializationPromise;if(X(o,this,`internal-error`),o.then(()=>{a||i(this.currentUser)}),typeof t==`function`){let i=e.addObserver(t,n,r);return()=>{a=!0,i()}}else{let n=e.addObserver(t);return()=>{a=!0,n()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return X(this.persistenceManager,this,`internal-error`),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=wv(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){let e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e[`X-Firebase-gmpid`]=this.app.options.appId);let t=await this.heartbeatServiceProvider.getImmediate({optional:!0})?.getHeartbeatsHeader();t&&(e[`X-Firebase-Client`]=t);let n=await this._getAppCheckToken();return n&&(e[`X-Firebase-AppCheck`]=n),e}async _getAppCheckToken(){if(y(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;let e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&s_(`Error while retrieving App Check token: ${e.error}`),e?.token}};function Av(e){return _(e)}var jv=class{constructor(e){this.auth=e,this.observer=null,this.addObserver=we(e=>this.observer=e)}get next(){return X(this.observer,this.auth,`internal-error`),this.observer.next.bind(this.observer)}},Mv={async loadJS(){throw Error(`Unable to load external scripts`)},recaptchaV2Script:``,recaptchaEnterpriseScript:``,gapiScript:``};function Nv(e){Mv=e}function Pv(e){return Mv.loadJS(e)}function Fv(){return Mv.recaptchaEnterpriseScript}function Iv(){return Mv.gapiScript}function Lv(e){return`__${e}${Math.floor(Math.random()*1e6)}`}var Rv=class{constructor(){this.enterprise=new zv}ready(e){e()}execute(e,t){return Promise.resolve(`token`)}render(e,t){return``}},zv=class{ready(e){e()}execute(e,t){return Promise.resolve(`token`)}render(e,t){return``}},Bv=`recaptcha-enterprise`,Vv=`NO_RECAPTCHA`,Hv=`onFirebaseAuthREInstanceReady`,Uv=class e{constructor(e){this.type=Bv,this.auth=Av(e)}async verify(t=`verify`,n=!1){async function r(e){if(!n){if(e.tenantId==null&&e._agentRecaptchaConfig!=null)return e._agentRecaptchaConfig.siteKey;if(e.tenantId!=null&&e._tenantRecaptchaConfigs[e.tenantId]!==void 0)return e._tenantRecaptchaConfigs[e.tenantId].siteKey}return new Promise(async(t,n)=>{R_(e,{clientType:`CLIENT_TYPE_WEB`,version:`RECAPTCHA_ENTERPRISE`}).then(r=>{if(r.recaptchaKey===void 0)n(Error(`recaptcha Enterprise site key undefined`));else{let n=new L_(r);return e.tenantId==null?e._agentRecaptchaConfig=n:e._tenantRecaptchaConfigs[e.tenantId]=n,t(n.siteKey)}}).catch(e=>{n(e)})})}function i(e,n,r){let i=window.grecaptcha;I_(i)?i.enterprise.ready(()=>{i.enterprise.execute(e,{action:t}).then(e=>{n(e)}).catch(()=>{n(Vv)})}):r(Error(`No reCAPTCHA enterprise script loaded.`))}return this.auth.settings.appVerificationDisabledForTesting?new Rv().execute(`siteKey`,{action:`verify`}):new Promise((t,a)=>{r(this.auth).then(async r=>{if(!n&&I_(window.grecaptcha)&&e.scriptInjectionDeferred)await e.scriptInjectionDeferred.promise,i(r,t,a);else{if(typeof window>`u`){a(Error(`RecaptchaVerifier is only supported in browser`));return}let n=Fv();n.length!==0&&(n+=r+`&onload=${Hv}`),e.scriptInjectionDeferred=new te,window[Hv]=()=>{e.scriptInjectionDeferred?.resolve()},Pv(n).then(()=>e.scriptInjectionDeferred?.promise).then(()=>{i(r,t,a)}).catch(e=>{a(e)})}}).catch(e=>{a(e)})})}};Uv.scriptInjectionDeferred=null;async function Wv(e,t,n,r=!1,i=!1){let a=new Uv(e),o;if(i)o=Vv;else try{o=await a.verify(n)}catch{o=await a.verify(n,!0)}let s={...t};if(n===`mfaSmsEnrollment`||n===`mfaSmsSignIn`){if(`phoneEnrollmentInfo`in s){let e=s.phoneEnrollmentInfo.phoneNumber,t=s.phoneEnrollmentInfo.recaptchaToken;Object.assign(s,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:t,captchaResponse:o,clientType:`CLIENT_TYPE_WEB`,recaptchaVersion:`RECAPTCHA_ENTERPRISE`}})}else if(`phoneSignInInfo`in s){let e=s.phoneSignInInfo.recaptchaToken;Object.assign(s,{phoneSignInInfo:{recaptchaToken:e,captchaResponse:o,clientType:`CLIENT_TYPE_WEB`,recaptchaVersion:`RECAPTCHA_ENTERPRISE`}})}return s}return r?Object.assign(s,{captchaResp:o}):Object.assign(s,{captchaResponse:o}),Object.assign(s,{clientType:`CLIENT_TYPE_WEB`}),Object.assign(s,{recaptchaVersion:`RECAPTCHA_ENTERPRISE`}),s}async function Gv(e,t,n,r,i){return i===`EMAIL_PASSWORD_PROVIDER`?e._getRecaptchaConfig()?.isProviderEnabled(`EMAIL_PASSWORD_PROVIDER`)?r(e,await Wv(e,t,n,n===`getOobCode`)):r(e,t).catch(async i=>i.code===`auth/missing-recaptcha-token`?(console.log(`${n} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`),r(e,await Wv(e,t,n,n===`getOobCode`))):Promise.reject(i)):i===`PHONE_PROVIDER`?e._getRecaptchaConfig()?.isProviderEnabled(`PHONE_PROVIDER`)?r(e,await Wv(e,t,n)).catch(async i=>e._getRecaptchaConfig()?.getProviderEnforcementState(`PHONE_PROVIDER`)===`AUDIT`&&(i.code===`auth/missing-recaptcha-token`||i.code===`auth/invalid-app-credential`)?(console.log(`Failed to verify with reCAPTCHA Enterprise. Automatically triggering the reCAPTCHA v2 flow to complete the ${n} flow.`),r(e,await Wv(e,t,n,!1,!0))):Promise.reject(i)):r(e,await Wv(e,t,n,!1,!0)):Promise.reject(i+` provider is not supported.`)}async function Kv(e){let t=Av(e),n=new L_(await R_(t,{clientType:`CLIENT_TYPE_WEB`,version:`RECAPTCHA_ENTERPRISE`}));t.tenantId==null?t._agentRecaptchaConfig=n:t._tenantRecaptchaConfigs[t.tenantId]=n,n.isAnyProviderEnabled()&&new Uv(t).verify()}function qv(e,t){let n=Xt(e,`auth`);if(n.isInitialized()){let e=n.getImmediate();if(ye(n.getOptions(),t??{}))return e;l_(e,`already-initialized`)}return n.initialize({options:t})}function Jv(e,t){let n=t?.persistence||[],r=(Array.isArray(n)?n:[n]).map(sv);t?.errorMap&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,t?.popupRedirectResolver)}function Yv(e,t,n){let r=Av(e);X(/^https?:\/\//.test(t),r,`invalid-emulator-scheme`);let i=!!n?.disableWarnings,a=Xv(t),{host:o,port:s}=Zv(t),c=s===null?``:`:${s}`,l={url:`${a}//${o}${c}/`},u=Object.freeze({host:o,port:s,protocol:a.replace(`:`,``),options:Object.freeze({disableWarnings:i})});if(!r._canInitEmulator){X(r.config.emulator&&r.emulatorConfig,r,`emulator-config-failed`),X(ye(l,r.config.emulator)&&ye(u,r.emulatorConfig),r,`emulator-config-failed`);return}r.config.emulator=l,r.emulatorConfig=u,r.settings.appVerificationDisabledForTesting=!0,Oe(o)?ke(`${a}//${o}${c}`):i||$v()}function Xv(e){let t=e.indexOf(`:`);return t<0?``:e.substr(0,t+1)}function Zv(e){let t=Xv(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:``,port:null};let r=n[2].split(`@`).pop()||``,i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){let e=i[1];return{host:e,port:Qv(r.substr(e.length+1))}}else{let[e,t]=r.split(`:`);return{host:e,port:Qv(t)}}}function Qv(e){if(!e)return null;let t=Number(e);return isNaN(t)?null:t}function $v(){function e(){let e=document.createElement(`p`),t=e.style;e.innerText=`Running in emulator mode. Do not use with production credentials.`,t.position=`fixed`,t.width=`100%`,t.backgroundColor=`#ffffff`,t.border=`.1em solid #000000`,t.color=`#b50000`,t.bottom=`0px`,t.left=`0px`,t.margin=`0px`,t.zIndex=`10000`,t.textAlign=`center`,e.classList.add(`firebase-emulator-warning`),document.body.appendChild(e)}typeof console<`u`&&typeof console.info==`function`&&console.info(`WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials.`),typeof window<`u`&&typeof document<`u`&&(document.readyState===`loading`?window.addEventListener(`DOMContentLoaded`,e):e())}var ey=class{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return h_(`not implemented`)}_getIdTokenResponse(e){return h_(`not implemented`)}_linkToIdToken(e,t){return h_(`not implemented`)}_getReauthenticationResolver(e){return h_(`not implemented`)}};async function ty(e,t){return k_(e,`POST`,`/v1/accounts:signUp`,t)}async function ny(e,t){return j_(e,`POST`,`/v1/accounts:signInWithPassword`,O_(e,t))}async function ry(e,t){return k_(e,`POST`,`/v1/accounts:sendOobCode`,O_(e,t))}async function iy(e,t){return ry(e,t)}async function ay(e,t){return ry(e,t)}async function oy(e,t){return j_(e,`POST`,`/v1/accounts:signInWithEmailLink`,O_(e,t))}async function sy(e,t){return j_(e,`POST`,`/v1/accounts:signInWithEmailLink`,O_(e,t))}var cy=class e extends ey{constructor(e,t,n,r=null){super(`password`,n),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(t,n){return new e(t,n,`password`)}static _fromEmailAndCode(t,n,r=null){return new e(t,n,`emailLink`,r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){let t=typeof e==`string`?JSON.parse(e):e;if(t?.email&&t?.password){if(t.signInMethod===`password`)return this._fromEmailAndPassword(t.email,t.password);if(t.signInMethod===`emailLink`)return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case`password`:return Gv(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:`CLIENT_TYPE_WEB`},`signInWithPassword`,ny,`EMAIL_PASSWORD_PROVIDER`);case`emailLink`:return oy(e,{email:this._email,oobCode:this._password});default:l_(e,`internal-error`)}}async _linkToIdToken(e,t){switch(this.signInMethod){case`password`:return Gv(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:`CLIENT_TYPE_WEB`},`signUpPassword`,ty,`EMAIL_PASSWORD_PROVIDER`);case`emailLink`:return sy(e,{idToken:t,email:this._email,oobCode:this._password});default:l_(e,`internal-error`)}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}};async function ly(e,t){return j_(e,`POST`,`/v1/accounts:signInWithIdp`,O_(e,t))}var uy=`http://localhost`,dy=class e extends ey{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(t){let n=new e(t.providerId,t.signInMethod);return t.idToken||t.accessToken?(t.idToken&&(n.idToken=t.idToken),t.accessToken&&(n.accessToken=t.accessToken),t.nonce&&!t.pendingToken&&(n.nonce=t.nonce),t.pendingToken&&(n.pendingToken=t.pendingToken)):t.oauthToken&&t.oauthTokenSecret?(n.accessToken=t.oauthToken,n.secret=t.oauthTokenSecret):l_(`argument-error`),n}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(t){let{providerId:n,signInMethod:r,...i}=typeof t==`string`?JSON.parse(t):t;if(!n||!r)return null;let a=new e(n,r);return a.idToken=i.idToken||void 0,a.accessToken=i.accessToken||void 0,a.secret=i.secret,a.nonce=i.nonce,a.pendingToken=i.pendingToken||null,a}_getIdTokenResponse(e){return ly(e,this.buildRequest())}_linkToIdToken(e,t){let n=this.buildRequest();return n.idToken=t,ly(e,n)}_getReauthenticationResolver(e){let t=this.buildRequest();return t.autoCreate=!1,ly(e,t)}buildRequest(){let e={requestUri:uy,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{let t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=xe(t)}return e}};async function fy(e,t){return k_(e,`POST`,`/v1/accounts:sendVerificationCode`,O_(e,t))}async function py(e,t){return j_(e,`POST`,`/v1/accounts:signInWithPhoneNumber`,O_(e,t))}async function my(e,t){let n=await j_(e,`POST`,`/v1/accounts:signInWithPhoneNumber`,O_(e,t));if(n.temporaryProof)throw F_(e,`account-exists-with-different-credential`,n);return n}var hy={USER_NOT_FOUND:`user-not-found`};async function gy(e,t){return j_(e,`POST`,`/v1/accounts:signInWithPhoneNumber`,O_(e,{...t,operation:`REAUTH`}),hy)}var _y=class e extends ey{constructor(e){super(`phone`,`phone`),this.params=e}static _fromVerification(t,n){return new e({verificationId:t,verificationCode:n})}static _fromTokenResponse(t,n){return new e({phoneNumber:t,temporaryProof:n})}_getIdTokenResponse(e){return py(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return my(e,{idToken:t,...this._makeVerificationRequest()})}_getReauthenticationResolver(e){return gy(e,this._makeVerificationRequest())}_makeVerificationRequest(){let{temporaryProof:e,phoneNumber:t,verificationId:n,verificationCode:r}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:n,code:r}}toJSON(){let e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}static fromJSON(t){typeof t==`string`&&(t=JSON.parse(t));let{verificationId:n,verificationCode:r,phoneNumber:i,temporaryProof:a}=t;return!r&&!n&&!i&&!a?null:new e({verificationId:n,verificationCode:r,phoneNumber:i,temporaryProof:a})}};function vy(e){switch(e){case`recoverEmail`:return`RECOVER_EMAIL`;case`resetPassword`:return`PASSWORD_RESET`;case`signIn`:return`EMAIL_SIGNIN`;case`verifyEmail`:return`VERIFY_EMAIL`;case`verifyAndChangeEmail`:return`VERIFY_AND_CHANGE_EMAIL`;case`revertSecondFactorAddition`:return`REVERT_SECOND_FACTOR_ADDITION`;default:return null}}function yy(e){let t=Se(Ce(e)).link,n=t?Se(Ce(t)).deep_link_id:null,r=Se(Ce(e)).deep_link_id;return(r?Se(Ce(r)).link:null)||r||n||t||e}var by=class e{constructor(e){let t=Se(Ce(e)),n=t.apiKey??null,r=t.oobCode??null,i=vy(t.mode??null);X(n&&r&&i,`argument-error`),this.apiKey=n,this.operation=i,this.code=r,this.continueUrl=t.continueUrl??null,this.languageCode=t.lang??null,this.tenantId=t.tenantId??null}static parseLink(t){let n=yy(t);try{return new e(n)}catch{return null}}},xy=class e{constructor(){this.providerId=e.PROVIDER_ID}static credential(e,t){return cy._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){let n=by.parseLink(t);return X(n,`argument-error`),cy._fromEmailAndCode(e,n.code,n.tenantId)}};xy.PROVIDER_ID=`password`,xy.EMAIL_PASSWORD_SIGN_IN_METHOD=`password`,xy.EMAIL_LINK_SIGN_IN_METHOD=`emailLink`;var Sy=class{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}},Cy=class extends Sy{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}},wy=class e extends Cy{constructor(){super(`facebook.com`)}static credential(t){return dy._fromParams({providerId:e.PROVIDER_ID,signInMethod:e.FACEBOOK_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return e.credentialFromTaggedObject(t)}static credentialFromError(t){return e.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!(`oauthAccessToken`in t)||!t.oauthAccessToken)return null;try{return e.credential(t.oauthAccessToken)}catch{return null}}};wy.FACEBOOK_SIGN_IN_METHOD=`facebook.com`,wy.PROVIDER_ID=`facebook.com`;var Ty=class e extends Cy{constructor(){super(`google.com`),this.addScope(`profile`)}static credential(t,n){return dy._fromParams({providerId:e.PROVIDER_ID,signInMethod:e.GOOGLE_SIGN_IN_METHOD,idToken:t,accessToken:n})}static credentialFromResult(t){return e.credentialFromTaggedObject(t)}static credentialFromError(t){return e.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;let{oauthIdToken:n,oauthAccessToken:r}=t;if(!n&&!r)return null;try{return e.credential(n,r)}catch{return null}}};Ty.GOOGLE_SIGN_IN_METHOD=`google.com`,Ty.PROVIDER_ID=`google.com`;var Ey=class e extends Cy{constructor(){super(`github.com`)}static credential(t){return dy._fromParams({providerId:e.PROVIDER_ID,signInMethod:e.GITHUB_SIGN_IN_METHOD,accessToken:t})}static credentialFromResult(t){return e.credentialFromTaggedObject(t)}static credentialFromError(t){return e.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t||!(`oauthAccessToken`in t)||!t.oauthAccessToken)return null;try{return e.credential(t.oauthAccessToken)}catch{return null}}};Ey.GITHUB_SIGN_IN_METHOD=`github.com`,Ey.PROVIDER_ID=`github.com`;var Dy=class e extends Cy{constructor(){super(`twitter.com`)}static credential(t,n){return dy._fromParams({providerId:e.PROVIDER_ID,signInMethod:e.TWITTER_SIGN_IN_METHOD,oauthToken:t,oauthTokenSecret:n})}static credentialFromResult(t){return e.credentialFromTaggedObject(t)}static credentialFromError(t){return e.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:t}){if(!t)return null;let{oauthAccessToken:n,oauthTokenSecret:r}=t;if(!n||!r)return null;try{return e.credential(n,r)}catch{return null}}};Dy.TWITTER_SIGN_IN_METHOD=`twitter.com`,Dy.PROVIDER_ID=`twitter.com`;async function Oy(e,t){return j_(e,`POST`,`/v1/accounts:signUp`,O_(e,t))}var ky=class e{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(t,n,r,i=!1){return new e({user:await av._fromIdTokenResponse(t,r,i),providerId:Ay(r),_tokenResponse:r,operationType:n})}static async _forOperation(t,n,r){return await t._updateTokensIfNecessary(r,!0),new e({user:t,providerId:Ay(r),_tokenResponse:r,operationType:n})}};function Ay(e){return e.providerId?e.providerId:`phoneNumber`in e?`phone`:null}async function jy(e){if(y(e.app))return Promise.reject(f_(e));let t=Av(e);if(await t._initializationPromise,t.currentUser?.isAnonymous)return new ky({user:t.currentUser,providerId:null,operationType:`signIn`});let n=await Oy(t,{returnSecureToken:!0}),r=await ky._fromIdTokenResponse(t,`signIn`,n,!0);return await t._updateCurrentUser(r.user),r}var My=class e extends me{constructor(t,n,r,i){super(n.code,n.message),this.operationType=r,this.user=i,Object.setPrototypeOf(this,e.prototype),this.customData={appName:t.name,tenantId:t.tenantId??void 0,_serverResponse:n.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(t,n,r,i){return new e(t,n,r,i)}};function Ny(e,t,n,r){return(t===`reauthenticate`?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(n=>{throw n.code===`auth/multi-factor-auth-required`?My._fromErrorAndOperation(e,n,t,r):n})}function Py(e){return new Set(e.map(({providerId:e})=>e).filter(e=>!!e))}async function Fy(e,t){let n=_(e);await Ly(!0,n,t);let{providerUserInfo:r}=await B_(n.auth,{idToken:await n.getIdToken(),deleteProvider:[t]}),i=Py(r||[]);return n.providerData=n.providerData.filter(e=>i.has(e.providerId)),i.has(`phone`)||(n.phoneNumber=null),await n.auth._persistUserIfCurrent(n),n}async function Iy(e,t,n=!1){let r=await q_(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return ky._forOperation(e,`link`,r)}async function Ly(e,t,n){await Z_(t);let r=Py(t.providerData),i=e===!1?`provider-already-linked`:`no-such-provider`;X(r.has(n)===e,t.auth,i)}async function Ry(e,t,n=!1){let{auth:r}=e;if(y(r.app))return Promise.reject(f_(r));let i=`reauthenticate`;try{let a=await q_(e,Ny(r,i,t,e),n);X(a.idToken,r,`internal-error`);let o=G_(a.idToken);X(o,r,`internal-error`);let{sub:s}=o;return X(e.uid===s,r,`user-mismatch`),ky._forOperation(e,i,a)}catch(e){throw e?.code===`auth/user-not-found`&&l_(r,`user-mismatch`),e}}async function zy(e,t,n=!1){if(y(e.app))return Promise.reject(f_(e));let r=`signIn`,i=await Ny(e,r,t),a=await ky._fromIdTokenResponse(e,r,i);return n||await e._updateCurrentUser(a.user),a}async function By(e,t){return zy(Av(e),t)}function Vy(e,t,n){X(n.url?.length>0,e,`invalid-continue-uri`),X(n.dynamicLinkDomain===void 0||n.dynamicLinkDomain.length>0,e,`invalid-dynamic-link-domain`),X(n.linkDomain===void 0||n.linkDomain.length>0,e,`invalid-hosting-link-domain`),t.continueUrl=n.url,t.dynamicLinkDomain=n.dynamicLinkDomain,t.linkDomain=n.linkDomain,t.canHandleCodeInApp=n.handleCodeInApp,n.iOS&&(X(n.iOS.bundleId.length>0,e,`missing-ios-bundle-id`),t.iOSBundleId=n.iOS.bundleId),n.android&&(X(n.android.packageName.length>0,e,`missing-android-pkg-name`),t.androidInstallApp=n.android.installApp,t.androidMinimumVersionCode=n.android.minimumVersion,t.androidPackageName=n.android.packageName)}async function Hy(e){let t=Av(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function Uy(e,t,n){let r=Av(e),i={requestType:`PASSWORD_RESET`,email:t,clientType:`CLIENT_TYPE_WEB`};n&&Vy(r,i,n),await Gv(r,i,`getOobCode`,ay,`EMAIL_PASSWORD_PROVIDER`)}async function Wy(e,t,n){if(y(e.app))return Promise.reject(f_(e));let r=Av(e),i=await Gv(r,{returnSecureToken:!0,email:t,password:n,clientType:`CLIENT_TYPE_WEB`},`signUpPassword`,Oy,`EMAIL_PASSWORD_PROVIDER`).catch(t=>{throw t.code===`auth/password-does-not-meet-requirements`&&Hy(e),t}),a=await ky._fromIdTokenResponse(r,`signIn`,i);return await r._updateCurrentUser(a.user),a}function Gy(e,t,n){return y(e.app)?Promise.reject(f_(e)):By(_(e),xy.credential(t,n)).catch(async t=>{throw t.code===`auth/password-does-not-meet-requirements`&&Hy(e),t})}async function Ky(e,t){let n=_(e),r={requestType:`VERIFY_EMAIL`,idToken:await e.getIdToken()};t&&Vy(n.auth,r,t);let{email:i}=await iy(n.auth,r);i!==e.email&&await e.reload()}async function qy(e,t){return k_(e,`POST`,`/v1/accounts:update`,t)}async function Jy(e,{displayName:t,photoURL:n}){if(t===void 0&&n===void 0)return;let r=_(e),i={idToken:await r.getIdToken(),displayName:t,photoUrl:n,returnSecureToken:!0},a=await q_(r,qy(r.auth,i));r.displayName=a.displayName||null,r.photoURL=a.photoUrl||null;let o=r.providerData.find(({providerId:e})=>e===`password`);o&&(o.displayName=r.displayName,o.photoURL=r.photoURL),await r._updateTokensIfNecessary(a)}function Yy(e,t,n,r){return _(e).onIdTokenChanged(t,n,r)}function Xy(e,t,n){return _(e).beforeAuthStateChanged(t,n)}function Zy(e,t){return k_(e,`POST`,`/v2/accounts/mfaEnrollment:start`,O_(e,t))}function Qy(e,t){return k_(e,`POST`,`/v2/accounts/mfaEnrollment:finalize`,O_(e,t))}function $y(e,t){return k_(e,`POST`,`/v2/accounts/mfaEnrollment:start`,O_(e,t))}function eb(e,t){return k_(e,`POST`,`/v2/accounts/mfaEnrollment:finalize`,O_(e,t))}var tb=`__sak`,nb=class{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(tb,`1`),this.storage.removeItem(tb),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){let t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}},rb=1e3,ib=10,ab=class extends nb{constructor(){super(()=>window.localStorage,`LOCAL`),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=Cv(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(let t of Object.keys(this.listeners)){let n=this.storage.getItem(t),r=this.localCache[t];n!==r&&e(t,r,n)}}onStorageEvent(e,t=!1){if(!e.key){this.forAllChangedKeys((e,t,n)=>{this.notifyListeners(e,n)});return}let n=e.key;t?this.detachListener():this.stopPolling();let r=()=>{let e=this.storage.getItem(n);!t&&this.localCache[n]===e||this.notifyListeners(n,e)},i=this.storage.getItem(n);Sv()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(r,ib):r()}notifyListeners(e,t){this.localCache[e]=t;let n=this.listeners[e];if(n)for(let e of Array.from(n))e(t&&JSON.parse(t))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,n)=>{this.onStorageEvent(new StorageEvent(`storage`,{key:e,oldValue:t,newValue:n}),!0)})},rb)}stopPolling(){this.pollTimer&&=(clearInterval(this.pollTimer),null)}attachListener(){window.addEventListener(`storage`,this.boundEventHandler)}detachListener(){window.removeEventListener(`storage`,this.boundEventHandler)}_addListener(e,t){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){let t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}};ab.type=`LOCAL`;var ob=ab,sb=1e3;function cb(e){let t=e.replace(/[\\^$.*+?()[\]{}|]/g,`\\$&`),n=RegExp(`${t}=([^;]+)`);return document.cookie.match(n)?.[1]??null}function lb(e){return`${window.location.protocol===`http:`?`__dev_`:`__HOST-`}FIREBASE_${e.split(`:`)[3]}`}var ub=class{constructor(){this.type=`COOKIE`,this.listenerUnsubscribes=new Map}_getFinalTarget(e){let t=new URL(`${window.location.origin}/__cookies__`);return t.searchParams.set(`finalTarget`,e),t}async _isAvailable(){return typeof isSecureContext==`boolean`&&!isSecureContext||typeof navigator>`u`||typeof document>`u`?!1:navigator.cookieEnabled??!0}async _set(e,t){}async _get(e){if(!this._isAvailable())return null;let t=lb(e);return window.cookieStore?(await window.cookieStore.get(t))?.value:cb(t)}async _remove(e){if(!this._isAvailable()||!await this._get(e))return;let t=lb(e);document.cookie=`${t}=;Max-Age=34560000;Partitioned;Secure;SameSite=Strict;Path=/;Priority=High`,await fetch(`/__cookies__`,{method:`DELETE`}).catch(()=>void 0)}_addListener(e,t){if(!this._isAvailable())return;let n=lb(e);if(window.cookieStore){let e=(e=>{let r=e.changed.find(e=>e.name===n);r&&t(r.value),e.deleted.find(e=>e.name===n)&&t(null)});return this.listenerUnsubscribes.set(t,()=>window.cookieStore.removeEventListener(`change`,e)),window.cookieStore.addEventListener(`change`,e)}let r=cb(n),i=setInterval(()=>{let e=cb(n);e!==r&&(t(e),r=e)},sb);this.listenerUnsubscribes.set(t,()=>clearInterval(i))}_removeListener(e,t){let n=this.listenerUnsubscribes.get(t);n&&(n(),this.listenerUnsubscribes.delete(t))}};ub.type=`COOKIE`;var db=class extends nb{constructor(){super(()=>window.sessionStorage,`SESSION`)}_addListener(e,t){}_removeListener(e,t){}};db.type=`SESSION`;var fb=db;function pb(e){return Promise.all(e.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}}))}var mb=class e{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(t){let n=this.receivers.find(e=>e.isListeningto(t));if(n)return n;let r=new e(t);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){let t=e,{eventId:n,eventType:r,data:i}=t.data,a=this.handlersMap[r];if(!a?.size)return;t.ports[0].postMessage({status:`ack`,eventId:n,eventType:r});let o=await pb(Array.from(a).map(async e=>e(t.origin,i)));t.ports[0].postMessage({status:`done`,eventId:n,eventType:r,response:o})}_subscribe(e,t){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener(`message`,this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),(!t||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener(`message`,this.boundEventHandler)}};mb.receivers=[];function hb(e=``,t=10){let n=``;for(let e=0;e<t;e++)n+=Math.floor(Math.random()*10);return e+n}var gb=class{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener(`message`,e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,n=50){let r=typeof MessageChannel<`u`?new MessageChannel:null;if(!r)throw Error(`connection_unavailable`);let i,a;return new Promise((o,s)=>{let c=hb(``,20);r.port1.start();let l=setTimeout(()=>{s(Error(`unsupported_event`))},n);a={messageChannel:r,onMessage(e){let t=e;if(t.data.eventId===c)switch(t.data.status){case`ack`:clearTimeout(l),i=setTimeout(()=>{s(Error(`timeout`))},3e3);break;case`done`:clearTimeout(i),o(t.data.response);break;default:clearTimeout(l),clearTimeout(i),s(Error(`invalid_response`));break}}},this.handlers.add(a),r.port1.addEventListener(`message`,a.onMessage),this.target.postMessage({eventType:e,eventId:c,data:t},[r.port2])}).finally(()=>{a&&this.removeMessageHandler(a)})}};function _b(){return window}function vb(e){_b().location.href=e}function yb(){return _b().WorkerGlobalScope!==void 0&&typeof _b().importScripts==`function`}async function bb(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function xb(){return navigator?.serviceWorker?.controller||null}function Sb(){return yb()?self:null}var Cb=`firebaseLocalStorageDb`,wb=1,Tb=`firebaseLocalStorage`,Eb=`fbase_key`,Db=class{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener(`success`,()=>{e(this.request.result)}),this.request.addEventListener(`error`,()=>{t(this.request.error)})})}};function Ob(e,t){return e.transaction([Tb],t?`readwrite`:`readonly`).objectStore(Tb)}function kb(){return new Db(indexedDB.deleteDatabase(Cb)).toPromise()}function Ab(){let e=indexedDB.open(Cb,wb);return new Promise((t,n)=>{e.addEventListener(`error`,()=>{n(e.error)}),e.addEventListener(`upgradeneeded`,()=>{let t=e.result;try{t.createObjectStore(Tb,{keyPath:Eb})}catch(e){n(e)}}),e.addEventListener(`success`,async()=>{let n=e.result;n.objectStoreNames.contains(Tb)?t(n):(n.close(),await kb(),t(await Ab()))})})}async function jb(e,t,n){return new Db(Ob(e,!0).put({[Eb]:t,value:n})).toPromise()}async function Mb(e,t){let n=await new Db(Ob(e,!1).get(t)).toPromise();return n===void 0?null:n.value}function Nb(e,t){return new Db(Ob(e,!0).delete(t)).toPromise()}var Pb=800,Fb=3,Ib=class{constructor(){this.type=`LOCAL`,this.dbPromise=null,this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.dbPromise?this.dbPromise:(this.dbPromise=Ab(),this.dbPromise.catch(()=>{this.dbPromise=null}),this.dbPromise)}async _withRetries(e){let t=0;for(;;)try{return await e(await this._openDb())}catch(e){if(t++>Fb)throw e;this.dbPromise&&=((await this.dbPromise).close(),null)}}async initializeServiceWorkerMessaging(){return yb()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=mb._getInstance(Sb()),this.receiver._subscribe(`keyChanged`,async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe(`ping`,async(e,t)=>[`keyChanged`])}async initializeSender(){if(this.activeServiceWorker=await bb(),!this.activeServiceWorker)return;this.sender=new gb(this.activeServiceWorker);let e=await this.sender._send(`ping`,{},800);e&&e[0]?.fulfilled&&e[0]?.value.includes(`keyChanged`)&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||xb()!==this.activeServiceWorker))try{await this.sender._send(`keyChanged`,{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{return indexedDB?(await this._withRetries(async e=>{await jb(e,tb,`1`),await Nb(e,tb)}),!0):!1}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(n=>jb(n,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){let t=await this._withRetries(t=>Mb(t,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Nb(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){let e=await this._withRetries(e=>new Db(Ob(e,!1).getAll()).toPromise());if(!e||this.pendingWrites!==0)return[];let t=[],n=new Set;if(e.length!==0)for(let{fbase_key:r,value:i}of e)n.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),t.push(r));for(let e of Object.keys(this.localCache))this.localCache[e]&&!n.has(e)&&(this.notifyListeners(e,null),t.push(e));return t}notifyListeners(e,t){this.localCache[e]=t;let n=this.listeners[e];if(n)for(let e of Array.from(n))e(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),Pb)}stopPolling(){this.pollTimer&&=(clearInterval(this.pollTimer),null)}_addListener(e,t){Object.keys(this.listeners).length===0&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&this.stopPolling()}};Ib.type=`LOCAL`;var Lb=Ib;function Rb(e,t){return k_(e,`POST`,`/v2/accounts/mfaSignIn:start`,O_(e,t))}function zb(e,t){return k_(e,`POST`,`/v2/accounts/mfaSignIn:finalize`,O_(e,t))}function Bb(e,t){return k_(e,`POST`,`/v2/accounts/mfaSignIn:finalize`,O_(e,t))}Lv(`rcb`),new S_(3e4,6e4);var Vb=`recaptcha`;async function Hb(e,t,n){if(!e._getRecaptchaConfig())try{await Kv(e)}catch{console.log(`Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.`)}try{let r;if(r=typeof t==`string`?{phoneNumber:t}:t,`session`in r){let t=r.session;if(`phoneNumber`in r)return X(t.type===`enroll`,e,`internal-error`),(await Gv(e,{idToken:t.credential,phoneEnrollmentInfo:{phoneNumber:r.phoneNumber,clientType:`CLIENT_TYPE_WEB`}},`mfaSmsEnrollment`,async(e,t)=>t.phoneEnrollmentInfo.captchaResponse===Vv?(X(n?.type===Vb,e,`argument-error`),Zy(e,await Ub(e,t,n))):Zy(e,t),`PHONE_PROVIDER`).catch(e=>Promise.reject(e))).phoneSessionInfo.sessionInfo;{X(t.type===`signin`,e,`internal-error`);let i=r.multiFactorHint?.uid||r.multiFactorUid;return X(i,e,`missing-multi-factor-info`),(await Gv(e,{mfaPendingCredential:t.credential,mfaEnrollmentId:i,phoneSignInInfo:{clientType:`CLIENT_TYPE_WEB`}},`mfaSmsSignIn`,async(e,t)=>t.phoneSignInInfo.captchaResponse===Vv?(X(n?.type===Vb,e,`argument-error`),Rb(e,await Ub(e,t,n))):Rb(e,t),`PHONE_PROVIDER`).catch(e=>Promise.reject(e))).phoneResponseInfo.sessionInfo}}else return(await Gv(e,{phoneNumber:r.phoneNumber,clientType:`CLIENT_TYPE_WEB`},`sendVerificationCode`,async(e,t)=>t.captchaResponse===Vv?(X(n?.type===Vb,e,`argument-error`),fy(e,await Ub(e,t,n))):fy(e,t),`PHONE_PROVIDER`).catch(e=>Promise.reject(e))).sessionInfo}finally{n?._reset()}}async function Ub(e,t,n){X(n.type===Vb,e,`argument-error`);let r=await n.verify();X(typeof r==`string`,e,`argument-error`);let i={...t};if(`phoneEnrollmentInfo`in i){let e=i.phoneEnrollmentInfo.phoneNumber,t=i.phoneEnrollmentInfo.captchaResponse,n=i.phoneEnrollmentInfo.clientType,a=i.phoneEnrollmentInfo.recaptchaVersion;return Object.assign(i,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:r,captchaResponse:t,clientType:n,recaptchaVersion:a}}),i}else if(`phoneSignInInfo`in i){let e=i.phoneSignInInfo.captchaResponse,t=i.phoneSignInInfo.clientType,n=i.phoneSignInInfo.recaptchaVersion;return Object.assign(i,{phoneSignInInfo:{recaptchaToken:r,captchaResponse:e,clientType:t,recaptchaVersion:n}}),i}else return Object.assign(i,{recaptchaToken:r}),i}var Wb=class e{constructor(t){this.providerId=e.PROVIDER_ID,this.auth=Av(t)}verifyPhoneNumber(e,t){return Hb(this.auth,e,_(t))}static credential(e,t){return _y._fromVerification(e,t)}static credentialFromResult(t){let n=t;return e.credentialFromTaggedObject(n)}static credentialFromError(t){return e.credentialFromTaggedObject(t.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;let{phoneNumber:t,temporaryProof:n}=e;return t&&n?_y._fromTokenResponse(t,n):null}};Wb.PROVIDER_ID=`phone`,Wb.PHONE_SIGN_IN_METHOD=`phone`;function Gb(e,t){return t?sv(t):(X(e._popupRedirectResolver,e,`argument-error`),e._popupRedirectResolver)}var Kb=class extends ey{constructor(e){super(`custom`,`custom`),this.params=e}_getIdTokenResponse(e){return ly(e,this._buildIdpRequest())}_linkToIdToken(e,t){return ly(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return ly(e,this._buildIdpRequest())}_buildIdpRequest(e){let t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}};function qb(e){return zy(e.auth,new Kb(e),e.bypassAuthState)}function Jb(e){let{auth:t,user:n}=e;return X(n,t,`internal-error`),Ry(n,new Kb(e),e.bypassAuthState)}async function Yb(e){let{auth:t,user:n}=e;return X(n,t,`internal-error`),Iy(n,new Kb(e),e.bypassAuthState)}var Xb=class{constructor(e,t,n,r,i=!1){this.auth=e,this.resolver=n,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(e){this.reject(e)}})}async onAuthEvent(e){let{urlResponse:t,sessionId:n,postBody:r,tenantId:i,error:a,type:o}=e;if(a){this.reject(a);return}let s={auth:this.auth,requestUri:t,sessionId:n,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(o)(s))}catch(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case`signInViaPopup`:case`signInViaRedirect`:return qb;case`linkViaPopup`:case`linkViaRedirect`:return Yb;case`reauthViaPopup`:case`reauthViaRedirect`:return Jb;default:l_(this.auth,`internal-error`)}}resolve(e){g_(this.pendingPromise,`Pending promise was never set`),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){g_(this.pendingPromise,`Pending promise was never set`),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}},Zb=new S_(2e3,1e4);async function Qb(e,t,n){if(y(e.app))return Promise.reject(u_(e,`operation-not-supported-in-this-environment`));let r=Av(e);return p_(e,t,Sy),new ex(r,`signInViaPopup`,t,Gb(r,n)).executeNotNull()}async function $b(e,t,n){let r=_(e);p_(r.auth,t,Sy);let i=Gb(r.auth,n);return new ex(r.auth,`linkViaPopup`,t,i,r).executeNotNull()}var ex=class e extends Xb{constructor(t,n,r,i,a){super(t,n,i,a),this.provider=r,this.authWindow=null,this.pollId=null,e.currentPopupAction&&e.currentPopupAction.cancel(),e.currentPopupAction=this}async executeNotNull(){let e=await this.execute();return X(e,this.auth,`internal-error`),e}async onExecution(){g_(this.filter.length===1,`Popup operations only handle one event`);let e=hb();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(e=>{this.reject(e)}),this.resolver._isIframeWebStorageSupported(this.auth,e=>{e||this.reject(u_(this.auth,`web-storage-unsupported`))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(u_(this.auth,`cancelled-popup-request`))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,e.currentPopupAction=null}pollUserCancellation(){let e=()=>{if(this.authWindow?.window?.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(u_(this.auth,`popup-closed-by-user`))},8e3);return}this.pollId=window.setTimeout(e,Zb.get())};e()}};ex.currentPopupAction=null;var tx=`pendingRedirect`,nx=new Map,rx=class extends Xb{constructor(e,t,n=!1){super(e,[`signInViaRedirect`,`linkViaRedirect`,`reauthViaRedirect`,`unknown`],t,void 0,n),this.eventId=null}async execute(){let e=nx.get(this.auth._key());if(!e){try{let t=await ix(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(t)}catch(t){e=()=>Promise.reject(t)}nx.set(this.auth._key(),e)}return this.bypassAuthState||nx.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type===`signInViaRedirect`)return super.onAuthEvent(e);if(e.type===`unknown`){this.resolve(null);return}if(e.eventId){let t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}};async function ix(e,t){let n=sx(t),r=ox(e);if(!await r._isAvailable())return!1;let i=await r._get(n)===`true`;return await r._remove(n),i}function ax(e,t){nx.set(e._key(),t)}function ox(e){return sv(e._redirectPersistence)}function sx(e){return uv(tx,e.config.apiKey,e.name)}async function cx(e,t,n=!1){if(y(e.app))return Promise.reject(f_(e));let r=Av(e),i=await new rx(r,Gb(r,t),n).execute();return i&&!n&&(delete i.user._redirectEventId,await r._persistUserIfCurrent(i.user),await r._setRedirectUser(null,t)),i}var lx=600*1e3,ux=class{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(n=>{this.isEventForConsumer(e,n)&&(t=!0,this.sendToConsumer(e,n),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!px(e)?t:(this.hasHandledPotentialRedirect=!0,t||=(this.queuedRedirectEvent=e,!0),t)}sendToConsumer(e,t){if(e.error&&!fx(e)){let n=e.error.code?.split(`auth/`)[1]||`internal-error`;t.onError(u_(this.auth,n))}else t.onAuthEvent(e)}isEventForConsumer(e,t){let n=t.eventId===null||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=lx&&this.cachedEventUids.clear(),this.cachedEventUids.has(dx(e))}saveEventToCache(e){this.cachedEventUids.add(dx(e)),this.lastProcessedEventTime=Date.now()}};function dx(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join(`-`)}function fx({type:e,error:t}){return e===`unknown`&&t?.code===`auth/no-auth-event`}function px(e){switch(e.type){case`signInViaRedirect`:case`linkViaRedirect`:case`reauthViaRedirect`:return!0;case`unknown`:return fx(e);default:return!1}}async function mx(e,t={}){return k_(e,`GET`,`/v1/projects`,t)}var hx=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,gx=/^https?/;async function _x(e){if(e.config.emulator)return;let{authorizedDomains:t}=await mx(e);for(let e of t)try{if(vx(e))return}catch{}l_(e,`unauthorized-domain`)}function vx(e){let t=__(),{protocol:n,hostname:r}=new URL(t);if(e.startsWith(`chrome-extension://`)){let i=new URL(e);return i.hostname===``&&r===``?n===`chrome-extension:`&&e.replace(`chrome-extension://`,``)===t.replace(`chrome-extension://`,``):n===`chrome-extension:`&&i.hostname===r}if(!gx.test(n))return!1;if(hx.test(e))return r===e;let i=e.replace(/\./g,`\\.`);return RegExp(`^(.+\\.`+i+`|`+i+`)$`,`i`).test(r)}var yx=new S_(3e4,6e4);function bx(){let e=_b().___jsl;if(e?.H){for(let t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let t=0;t<e.CP.length;t++)e.CP[t]=null}}function xx(e){return new Promise((t,n)=>{function r(){bx(),gapi.load(`gapi.iframes`,{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{bx(),n(u_(e,`network-request-failed`))},timeout:yx.get()})}if(_b().gapi?.iframes?.Iframe)t(gapi.iframes.getContext());else if(_b().gapi?.load)r();else{let t=Lv(`iframefcb`);return _b()[t]=()=>{gapi.load?r():n(u_(e,`network-request-failed`))},Pv(`${Iv()}?onload=${t}`).catch(e=>n(e))}}).catch(e=>{throw Sx=null,e})}var Sx=null;function Cx(e){return Sx||=xx(e),Sx}var wx=new S_(5e3,15e3),Tx=`__/auth/iframe`,Ex=`emulator/auth/iframe`,Dx={style:{position:`absolute`,top:`-100px`,width:`1px`,height:`1px`},"aria-hidden":`true`,tabindex:`-1`},Ox=new Map([[`identitytoolkit.googleapis.com`,`p`],[`staging-identitytoolkit.sandbox.googleapis.com`,`s`],[`test-identitytoolkit.sandbox.googleapis.com`,`t`]]);function kx(e){let t=e.config;X(t.authDomain,e,`auth-domain-config-required`);let n=t.emulator?C_(t,Ex):`https://${e.config.authDomain}/${Tx}`,r={apiKey:t.apiKey,appName:e.name,v:$t},i=Ox.get(e.config.apiHost);i&&(r.eid=i);let a=e._getFrameworks();return a.length&&(r.fw=a.join(`,`)),`${n}?${xe(r).slice(1)}`}async function Ax(e){let t=await Cx(e),n=_b().gapi;return X(n,e,`internal-error`),t.open({where:document.body,url:kx(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Dx,dontclear:!0},t=>new Promise(async(n,r)=>{await t.restyle({setHideOnLeave:!1});let i=u_(e,`network-request-failed`),a=_b().setTimeout(()=>{r(i)},wx.get());function o(){_b().clearTimeout(a),n(t)}t.ping(o).then(o,()=>{r(i)})}))}var jx={location:`yes`,resizable:`yes`,statusbar:`yes`,toolbar:`no`},Mx=500,Nx=600,Px=`_blank`,Fx=`http://localhost`,Ix=class{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}};function Lx(e,t,n,r=Mx,i=Nx){let a=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString(),s=``,c={...jx,width:r.toString(),height:i.toString(),top:a,left:o},l=re().toLowerCase();n&&(s=hv(l)?Px:n),pv(l)&&(t||=Fx,c.scrollbars=`yes`);let u=Object.entries(c).reduce((e,[t,n])=>`${e}${t}=${n},`,``);if(xv(l)&&s!==`_self`)return Rx(t||``,s),new Ix(null);let d=window.open(t||``,s,u);X(d,e,`popup-blocked`);try{d.focus()}catch{}return new Ix(d)}function Rx(e,t){let n=document.createElement(`a`);n.href=e,n.target=t;let r=document.createEvent(`MouseEvent`);r.initMouseEvent(`click`,!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}var zx=`__/auth/handler`,Bx=`emulator/auth/handler`,Vx=`fac`;async function Hx(e,t,n,r,i,a){X(e.config.authDomain,e,`auth-domain-config-required`),X(e.config.apiKey,e,`invalid-api-key`);let o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:$t,eventId:i};if(t instanceof Sy){t.setDefaultLanguage(e.languageCode),o.providerId=t.providerId||``,ve(t.getCustomParameters())||(o.customParameters=JSON.stringify(t.getCustomParameters()));for(let[e,t]of Object.entries(a||{}))o[e]=t}if(t instanceof Cy){let e=t.getScopes().filter(e=>e!==``);e.length>0&&(o.scopes=e.join(`,`))}e.tenantId&&(o.tid=e.tenantId);let s=o;for(let e of Object.keys(s))s[e]===void 0&&delete s[e];let c=await e._getAppCheckToken(),l=c?`#${Vx}=${encodeURIComponent(c)}`:``;return`${Ux(e)}?${xe(s).slice(1)}${l}`}function Ux({config:e}){return e.emulator?C_(e,Bx):`https://${e.authDomain}/${zx}`}var Wx=`webStorageSupport`,Gx=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=fb,this._completeRedirectFn=cx,this._overrideRedirectResult=ax}async _openPopup(e,t,n,r){return g_(this.eventManagers[e._key()]?.manager,`_initialize() not called before _openPopup()`),Lx(e,await Hx(e,t,n,__(),r),hb())}async _openRedirect(e,t,n,r){return await this._originValidation(e),vb(await Hx(e,t,n,__(),r)),new Promise(()=>{})}_initialize(e){let t=e._key();if(this.eventManagers[t]){let{manager:e,promise:n}=this.eventManagers[t];return e?Promise.resolve(e):(g_(n,`If manager is not set, promise should be`),n)}let n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n.catch(()=>{delete this.eventManagers[t]}),n}async initAndGetManager(e){let t=await Ax(e),n=new ux(e);return t.register(`authEvent`,t=>(X(t?.authEvent,e,`invalid-auth-event`),{status:n.onEvent(t.authEvent)?`ACK`:`ERROR`}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:n},this.iframes[e._key()]=t,n}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(Wx,{type:Wx},n=>{let r=n?.[0]?.[Wx];r!==void 0&&t(!!r),l_(e,`internal-error`)},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){let t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=_x(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return Cv()||mv()||bv()}},Kx=class{constructor(e){this.factorId=e}_process(e,t,n){switch(t.type){case`enroll`:return this._finalizeEnroll(e,t.credential,n);case`signin`:return this._finalizeSignIn(e,t.credential);default:return h_(`unexpected MultiFactorSessionType`)}}},qx=class e extends Kx{constructor(e){super(`phone`),this.credential=e}static _fromCredential(t){return new e(t)}_finalizeEnroll(e,t,n){return Qy(e,{idToken:t,displayName:n,phoneVerificationInfo:this.credential._makeVerificationRequest()})}_finalizeSignIn(e,t){return zb(e,{mfaPendingCredential:t,phoneVerificationInfo:this.credential._makeVerificationRequest()})}},Jx=class{constructor(){}static assertion(e){return qx._fromCredential(e)}};Jx.FACTOR_ID=`phone`;var Yx=class{static assertionForEnrollment(e,t){return Xx._fromSecret(e,t)}static assertionForSignIn(e,t){return Xx._fromEnrollmentId(e,t)}static async generateSecret(e){let t=e;X(t.user?.auth!==void 0,`internal-error`);let n=await $y(t.user.auth,{idToken:t.credential,totpEnrollmentInfo:{}});return Zx._fromStartTotpMfaEnrollmentResponse(n,t.user.auth)}};Yx.FACTOR_ID=`totp`;var Xx=class e extends Kx{constructor(e,t,n){super(`totp`),this.otp=e,this.enrollmentId=t,this.secret=n}static _fromSecret(t,n){return new e(n,void 0,t)}static _fromEnrollmentId(t,n){return new e(n,t)}async _finalizeEnroll(e,t,n){return X(this.secret!==void 0,e,`argument-error`),eb(e,{idToken:t,displayName:n,totpVerificationInfo:this.secret._makeTotpVerificationInfo(this.otp)})}async _finalizeSignIn(e,t){X(this.enrollmentId!==void 0&&this.otp!==void 0,e,`argument-error`);let n={verificationCode:this.otp};return Bb(e,{mfaPendingCredential:t,mfaEnrollmentId:this.enrollmentId,totpVerificationInfo:n})}},Zx=class e{constructor(e,t,n,r,i,a,o){this.sessionInfo=a,this.auth=o,this.secretKey=e,this.hashingAlgorithm=t,this.codeLength=n,this.codeIntervalSeconds=r,this.enrollmentCompletionDeadline=i}static _fromStartTotpMfaEnrollmentResponse(t,n){return new e(t.totpSessionInfo.sharedSecretKey,t.totpSessionInfo.hashingAlgorithm,t.totpSessionInfo.verificationCodeLength,t.totpSessionInfo.periodSec,new Date(t.totpSessionInfo.finalizeEnrollmentTime).toUTCString(),t.totpSessionInfo.sessionInfo,n)}_makeTotpVerificationInfo(e){return{sessionInfo:this.sessionInfo,verificationCode:e}}generateQrCodeUrl(e,t){let n=!1;return(Qx(e)||Qx(t))&&(n=!0),n&&(Qx(e)&&(e=this.auth.currentUser?.email||`unknownuser`),Qx(t)&&(t=this.auth.name)),`otpauth://totp/${t}:${e}?secret=${this.secretKey}&issuer=${t}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`}};function Qx(e){return e===void 0||e?.length===0}var $x=`@firebase/auth`,eS=`1.13.3`,tS=class{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){return this.assertAuthConfigured(),this.auth.currentUser?.uid||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;let t=this.auth.onIdTokenChanged(t=>{e(t?.stsTokenManager.accessToken||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();let t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){X(this.auth._initializationPromise,`dependent-sdk-initialized-before-auth`)}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}};function nS(e){switch(e){case`Node`:return`node`;case`ReactNative`:return`rn`;case`Worker`:return`webworker`;case`Cordova`:return`cordova`;case`WebExtension`:return`web-extension`;default:return}}function rS(e){Yt(new Ae(`auth`,(t,{options:n})=>{let r=t.getProvider(`app`).getImmediate(),i=t.getProvider(`heartbeat`),a=t.getProvider(`app-check-internal`),{apiKey:o,authDomain:s}=r.options;X(o&&!o.includes(`:`),`invalid-api-key`,{appName:r.name});let c=new kv(r,i,a,{apiKey:o,authDomain:s,clientPlatform:e,apiHost:`identitytoolkit.googleapis.com`,tokenApiHost:`securetoken.googleapis.com`,apiScheme:`https`,sdkClientVersion:wv(e)});return Jv(c,n),c},`PUBLIC`).setInstantiationMode(`EXPLICIT`).setInstanceCreatedCallback((e,t,n)=>{e.getProvider(`auth-internal`).initialize()})),Yt(new Ae(`auth-internal`,e=>(e=>new tS(e))(Av(e.getProvider(`auth`).getImmediate())),`PRIVATE`).setInstantiationMode(`EXPLICIT`)),nn($x,eS,nS(e)),nn($x,eS,`esm2020`)}var iS=ee(`authIdTokenMaxAge`)||300,aS=null,oS=e=>async t=>{let n=t&&await t.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>iS)return;let i=n?.token;aS!==i&&(aS=i,await fetch(e,{method:i?`POST`:`DELETE`,headers:i?{Authorization:`Bearer ${i}`}:{}}))};function sS(e=tn()){let t=Xt(e,`auth`);if(t.isInitialized())return t.getImmediate();let n=qv(e,{popupRedirectResolver:Gx,persistence:[Lb,ob,fb]}),r=ee(`authTokenSyncURL`);if(r&&typeof isSecureContext==`boolean`&&isSecureContext){let e=new URL(r,location.origin);if(location.origin===e.origin){let t=oS(e.toString());Xy(n,t,()=>t(n.currentUser)),Yy(n,e=>t(e))}}let i=m(`auth`);return i&&Yv(n,`http://${i}`),n}function cS(){return document.getElementsByTagName(`head`)?.[0]??document}Nv({loadJS(e){return new Promise((t,n)=>{let r=document.createElement(`script`);r.setAttribute(`src`,e),r.onload=t,r.onerror=e=>{let t=u_(`internal-error`);t.customData=e,n(t)},r.type=`text/javascript`,r.charset=`UTF-8`,cS().appendChild(r)})},gapiScript:`https://apis.google.com/js/api.js`,recaptchaV2Script:`https://www.google.com/recaptcha/api.js`,recaptchaEnterpriseScript:`https://www.google.com/recaptcha/enterprise.js?render=`}),rS(`Browser`);var lS=`firebasestorage.googleapis.com`,uS=`storageBucket`,dS=120*1e3,fS=600*1e3,pS=1e3,Z=class e extends me{constructor(t,n,r=0){super(mS(t),`Firebase Storage: ${n} (${mS(t)})`),this.status_=r,this.customData={serverResponse:null},this._baseMessage=this.message,Object.setPrototypeOf(this,e.prototype)}get status(){return this.status_}set status(e){this.status_=e}_codeEquals(e){return mS(e)===this.code}get serverResponse(){return this.customData.serverResponse}set serverResponse(e){this.customData.serverResponse=e,this.customData.serverResponse?this.message=`${this._baseMessage}\n${this.customData.serverResponse}`:this.message=this._baseMessage}},Q;(function(e){e.UNKNOWN=`unknown`,e.OBJECT_NOT_FOUND=`object-not-found`,e.BUCKET_NOT_FOUND=`bucket-not-found`,e.PROJECT_NOT_FOUND=`project-not-found`,e.QUOTA_EXCEEDED=`quota-exceeded`,e.UNAUTHENTICATED=`unauthenticated`,e.UNAUTHORIZED=`unauthorized`,e.UNAUTHORIZED_APP=`unauthorized-app`,e.RETRY_LIMIT_EXCEEDED=`retry-limit-exceeded`,e.INVALID_CHECKSUM=`invalid-checksum`,e.CANCELED=`canceled`,e.INVALID_EVENT_NAME=`invalid-event-name`,e.INVALID_URL=`invalid-url`,e.INVALID_DEFAULT_BUCKET=`invalid-default-bucket`,e.NO_DEFAULT_BUCKET=`no-default-bucket`,e.CANNOT_SLICE_BLOB=`cannot-slice-blob`,e.SERVER_FILE_WRONG_SIZE=`server-file-wrong-size`,e.NO_DOWNLOAD_URL=`no-download-url`,e.INVALID_ARGUMENT=`invalid-argument`,e.INVALID_ARGUMENT_COUNT=`invalid-argument-count`,e.APP_DELETED=`app-deleted`,e.INVALID_ROOT_OPERATION=`invalid-root-operation`,e.INVALID_FORMAT=`invalid-format`,e.INTERNAL_ERROR=`internal-error`,e.UNSUPPORTED_ENVIRONMENT=`unsupported-environment`})(Q||={});function mS(e){return`storage/`+e}function hS(){return new Z(Q.UNKNOWN,`An unknown error occurred, please check the error payload for server response.`)}function gS(e){return new Z(Q.OBJECT_NOT_FOUND,`Object '`+e+`' does not exist.`)}function _S(e){return new Z(Q.QUOTA_EXCEEDED,`Quota for bucket '`+e+`' exceeded, please view quota on https://firebase.google.com/pricing/.`)}function vS(){return new Z(Q.UNAUTHENTICATED,`User is not authenticated, please authenticate using Firebase Authentication and try again.`)}function yS(){return new Z(Q.UNAUTHORIZED_APP,`This app does not have permission to access Firebase Storage on this project.`)}function bS(e){return new Z(Q.UNAUTHORIZED,`User does not have permission to access '`+e+`'.`)}function xS(){return new Z(Q.RETRY_LIMIT_EXCEEDED,`Max retry time for operation exceeded, please try again.`)}function SS(){return new Z(Q.CANCELED,`User canceled the upload/download.`)}function CS(e){return new Z(Q.INVALID_URL,`Invalid URL '`+e+`'.`)}function wS(e){return new Z(Q.INVALID_DEFAULT_BUCKET,`Invalid default bucket '`+e+`'.`)}function TS(){return new Z(Q.NO_DEFAULT_BUCKET,`No default bucket found. Did you set the 'storageBucket' property when initializing the app?`)}function ES(){return new Z(Q.CANNOT_SLICE_BLOB,`Cannot slice blob for upload. Please retry the upload.`)}function DS(){return new Z(Q.SERVER_FILE_WRONG_SIZE,`Server recorded incorrect upload file size, please retry the upload.`)}function OS(){return new Z(Q.NO_DOWNLOAD_URL,`The given file does not have any download URLs.`)}function kS(e){return new Z(Q.UNSUPPORTED_ENVIRONMENT,`${e} is missing. Make sure to install the required polyfills. See https://firebase.google.com/docs/web/environments-js-sdk#polyfills for more information.`)}function AS(e){return new Z(Q.INVALID_ARGUMENT,e)}function jS(){return new Z(Q.APP_DELETED,`The Firebase app was deleted.`)}function MS(e){return new Z(Q.INVALID_ROOT_OPERATION,`The operation '`+e+`' cannot be performed on a root reference, create a non-root reference using child, such as .child('file.png').`)}function NS(e,t){return new Z(Q.INVALID_FORMAT,`String does not match format '`+e+`': `+t)}function PS(e){throw new Z(Q.INTERNAL_ERROR,`Internal error: `+e)}var FS=class e{constructor(e,t){this.bucket=e,this.path_=t}get path(){return this.path_}get isRoot(){return this.path.length===0}fullServerUrl(){let e=encodeURIComponent;return`/b/`+e(this.bucket)+`/o/`+e(this.path)}bucketOnlyServerUrl(){return`/b/`+encodeURIComponent(this.bucket)+`/o`}static makeFromBucketSpec(t,n){let r;try{r=e.makeFromUrl(t,n)}catch{return new e(t,``)}if(r.path===``)return r;throw wS(t)}static makeFromUrl(t,n){let r=null,i=`([A-Za-z0-9.\\-_]+)`;function a(e){e.path.charAt(e.path.length-1)===`/`&&(e.path_=e.path_.slice(0,-1))}let o=RegExp(`^gs://([A-Za-z0-9.\\-_]+)(/(.*))?$`,`i`),s={bucket:1,path:3};function c(e){e.path_=decodeURIComponent(e.path)}let l=n.replace(/[.]/g,`\\.`),u=RegExp(`^https?://${l}/v[A-Za-z0-9_]+/b/${i}/o(/([^?#]*).*)?\$`,`i`),d={bucket:1,path:3},f=RegExp(`^https?://${n===lS?`(?:storage.googleapis.com|storage.cloud.google.com)`:n}/${i}/([^?#]*)`,`i`),p=[{regex:o,indices:s,postModify:a},{regex:u,indices:d,postModify:c},{regex:f,indices:{bucket:1,path:2},postModify:c}];for(let n=0;n<p.length;n++){let i=p[n],a=i.regex.exec(t);if(a){let t=a[i.indices.bucket],n=a[i.indices.path];n||=``,r=new e(t,n),i.postModify(r);break}}if(r==null)throw CS(t);return r}},IS=class{constructor(e){this.promise_=Promise.reject(e)}getPromise(){return this.promise_}cancel(e=!1){}};function LS(e,t,n){let r=1,i=null,a=null,o=!1,s=0;function c(){return s===2}let l=!1;function u(...e){l||(l=!0,t.apply(null,e))}function d(t){i=setTimeout(()=>{i=null,e(p,c())},t)}function f(){a&&clearTimeout(a)}function p(e,...t){if(l){f();return}if(e){f(),u.call(null,e,...t);return}if(c()||o){f(),u.call(null,e,...t);return}r<64&&(r*=2);let n;s===1?(s=2,n=0):n=(r+Math.random())*1e3,d(n)}let m=!1;function h(e){m||(m=!0,f(),!l&&(i===null?e||(s=1):(e||(s=2),clearTimeout(i),d(0))))}return d(0),a=setTimeout(()=>{o=!0,h(!0)},n),h}function RS(e){e(!1)}function zS(e){return e!==void 0}function BS(e){return typeof e==`function`}function VS(e){return typeof e==`object`&&!Array.isArray(e)}function HS(e){return typeof e==`string`||e instanceof String}function US(e){return WS()&&e instanceof Blob}function WS(){return typeof Blob<`u`}function GS(e,t,n,r){if(r<t)throw AS(`Invalid value for '${e}'. Expected ${t} or greater.`);if(r>n)throw AS(`Invalid value for '${e}'. Expected ${n} or less.`)}function KS(e,t,n){let r=t;return n??(r=`https://${t}`),`${n}://${r}/v0${e}`}function qS(e){let t=encodeURIComponent,n=`?`;for(let r in e)if(e.hasOwnProperty(r)){let i=t(r)+`=`+t(e[r]);n=n+i+`&`}return n=n.slice(0,-1),n}var JS;(function(e){e[e.NO_ERROR=0]=`NO_ERROR`,e[e.NETWORK_ERROR=1]=`NETWORK_ERROR`,e[e.ABORT=2]=`ABORT`})(JS||={});function YS(e,t){let n=e>=500&&e<600,r=[408,429].indexOf(e)!==-1,i=t.indexOf(e)!==-1;return n||r||i}var XS=class{constructor(e,t,n,r,i,a,o,s,c,l,u,d=!0,f=!1){this.url_=e,this.method_=t,this.headers_=n,this.body_=r,this.successCodes_=i,this.additionalRetryCodes_=a,this.callback_=o,this.errorCallback_=s,this.timeout_=c,this.progressCallback_=l,this.connectionFactory_=u,this.retry=d,this.isUsingEmulator=f,this.pendingConnection_=null,this.backoffId_=null,this.canceled_=!1,this.appDelete_=!1,this.promise_=new Promise((e,t)=>{this.resolve_=e,this.reject_=t,this.start_()})}start_(){let e=(e,t)=>{if(t){e(!1,new ZS(!1,null,!0));return}let n=this.connectionFactory_();this.pendingConnection_=n;let r=e=>{let t=e.loaded,n=e.lengthComputable?e.total:-1;this.progressCallback_!==null&&this.progressCallback_(t,n)};this.progressCallback_!==null&&n.addUploadProgressListener(r),n.send(this.url_,this.method_,this.isUsingEmulator,this.body_,this.headers_).then(()=>{this.progressCallback_!==null&&n.removeUploadProgressListener(r),this.pendingConnection_=null;let t=n.getErrorCode()===JS.NO_ERROR,i=n.getStatus();if(!t||YS(i,this.additionalRetryCodes_)&&this.retry){e(!1,new ZS(!1,null,n.getErrorCode()===JS.ABORT));return}e(!0,new ZS(this.successCodes_.indexOf(i)!==-1,n))})},t=(e,t)=>{let n=this.resolve_,r=this.reject_,i=t.connection;if(t.wasSuccessCode)try{let e=this.callback_(i,i.getResponse());zS(e)?n(e):n()}catch(e){r(e)}else if(i!==null){let e=hS();e.serverResponse=i.getErrorText(),this.errorCallback_?r(this.errorCallback_(i,e)):r(e)}else t.canceled?r(this.appDelete_?jS():SS()):r(xS())};this.canceled_?t(!1,new ZS(!1,null,!0)):this.backoffId_=LS(e,t,this.timeout_)}getPromise(){return this.promise_}cancel(e){this.canceled_=!0,this.appDelete_=e||!1,this.backoffId_!==null&&RS(this.backoffId_),this.pendingConnection_!==null&&this.pendingConnection_.abort()}},ZS=class{constructor(e,t,n){this.wasSuccessCode=e,this.connection=t,this.canceled=!!n}};function QS(e,t){t!==null&&t.length>0&&(e.Authorization=`Firebase `+t)}function $S(e,t){e[`X-Firebase-Storage-Version`]=`webjs/`+(t??`AppManager`)}function eC(e,t){t&&(e[`X-Firebase-GMPID`]=t)}function tC(e,t){t!==null&&(e[`X-Firebase-AppCheck`]=t)}function nC(e,t,n,r,i,a,o=!0,s=!1){let c=qS(e.urlParams),l=e.url+c,u=Object.assign({},e.headers);return eC(u,t),QS(u,n),$S(u,a),tC(u,r),new XS(l,e.method,u,e.body,e.successCodes,e.additionalRetryCodes,e.handler,e.errorHandler,e.timeout,e.progressCallback,i,o,s)}function rC(){if(typeof BlobBuilder<`u`)return BlobBuilder;if(typeof WebKitBlobBuilder<`u`)return WebKitBlobBuilder}function iC(...e){let t=rC();if(t!==void 0){let n=new t;for(let t=0;t<e.length;t++)n.append(e[t]);return n.getBlob()}else if(WS())return new Blob(e);else throw new Z(Q.UNSUPPORTED_ENVIRONMENT,`This browser doesn't seem to support creating Blobs`)}function aC(e,t,n){return e.webkitSlice?e.webkitSlice(t,n):e.mozSlice?e.mozSlice(t,n):e.slice?e.slice(t,n):null}function oC(e){if(typeof atob>`u`)throw kS(`base-64`);return atob(e)}var sC={RAW:`raw`,BASE64:`base64`,BASE64URL:`base64url`,DATA_URL:`data_url`},cC=class{constructor(e,t){this.data=e,this.contentType=t||null}};function lC(e,t){switch(e){case sC.RAW:return new cC(uC(t));case sC.BASE64:case sC.BASE64URL:return new cC(fC(e,t));case sC.DATA_URL:return new cC(mC(t),hC(t))}throw hS()}function uC(e){let t=[];for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<=127)t.push(r);else if(r<=2047)t.push(192|r>>6,128|r&63);else if((r&64512)==55296)if(!(n<e.length-1&&(e.charCodeAt(n+1)&64512)==56320))t.push(239,191,189);else{let i=r,a=e.charCodeAt(++n);r=65536|(i&1023)<<10|a&1023,t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63)}else(r&64512)==56320?t.push(239,191,189):t.push(224|r>>12,128|r>>6&63,128|r&63)}return new Uint8Array(t)}function dC(e){let t;try{t=decodeURIComponent(e)}catch{throw NS(sC.DATA_URL,`Malformed data URL.`)}return uC(t)}function fC(e,t){switch(e){case sC.BASE64:{let n=t.indexOf(`-`)!==-1,r=t.indexOf(`_`)!==-1;if(n||r)throw NS(e,`Invalid character '`+(n?`-`:`_`)+`' found: is it base64url encoded?`);break}case sC.BASE64URL:{let n=t.indexOf(`+`)!==-1,r=t.indexOf(`/`)!==-1;if(n||r)throw NS(e,`Invalid character '`+(n?`+`:`/`)+`' found: is it base64 encoded?`);t=t.replace(/-/g,`+`).replace(/_/g,`/`);break}}let n;try{n=oC(t)}catch(t){throw t.message.includes(`polyfill`)?t:NS(e,`Invalid character found`)}let r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r}var pC=class{constructor(e){this.base64=!1,this.contentType=null;let t=e.match(/^data:([^,]+)?,/);if(t===null)throw NS(sC.DATA_URL,`Must be formatted 'data:[<mediatype>][;base64],<data>`);let n=t[1]||null;n!=null&&(this.base64=gC(n,`;base64`),this.contentType=this.base64?n.substring(0,n.length-7):n),this.rest=e.substring(e.indexOf(`,`)+1)}};function mC(e){let t=new pC(e);return t.base64?fC(sC.BASE64,t.rest):dC(t.rest)}function hC(e){return new pC(e).contentType}function gC(e,t){return e.length>=t.length?e.substring(e.length-t.length)===t:!1}var _C=class e{constructor(e,t){let n=0,r=``;US(e)?(this.data_=e,n=e.size,r=e.type):e instanceof ArrayBuffer?(t?this.data_=new Uint8Array(e):(this.data_=new Uint8Array(e.byteLength),this.data_.set(new Uint8Array(e))),n=this.data_.length):e instanceof Uint8Array&&(t?this.data_=e:(this.data_=new Uint8Array(e.length),this.data_.set(e)),n=e.length),this.size_=n,this.type_=r}size(){return this.size_}type(){return this.type_}slice(t,n){if(US(this.data_)){let r=this.data_,i=aC(r,t,n);return i===null?null:new e(i)}else return new e(new Uint8Array(this.data_.buffer,t,n-t),!0)}static getBlob(...t){if(WS()){let n=t.map(t=>t instanceof e?t.data_:t);return new e(iC.apply(null,n))}else{let n=t.map(e=>HS(e)?lC(sC.RAW,e).data:e.data_),r=0;n.forEach(e=>{r+=e.byteLength});let i=new Uint8Array(r),a=0;return n.forEach(e=>{for(let t=0;t<e.length;t++)i[a++]=e[t]}),new e(i,!0)}}uploadData(){return this.data_}};function vC(e){let t;try{t=JSON.parse(e)}catch{return null}return VS(t)?t:null}function yC(e){if(e.length===0)return null;let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function bC(e,t){let n=t.split(`/`).filter(e=>e.length>0).join(`/`);return e.length===0?n:e+`/`+n}function xC(e){let t=e.lastIndexOf(`/`,e.length-2);return t===-1?e:e.slice(t+1)}function SC(e,t){return t}var CC=class{constructor(e,t,n,r){this.server=e,this.local=t||e,this.writable=!!n,this.xform=r||SC}},wC=null;function TC(e){return!HS(e)||e.length<2?e:xC(e)}function EC(){if(wC)return wC;let e=[];e.push(new CC(`bucket`)),e.push(new CC(`generation`)),e.push(new CC(`metageneration`)),e.push(new CC(`name`,`fullPath`,!0));function t(e,t){return TC(t)}let n=new CC(`name`);n.xform=t,e.push(n);function r(e,t){return t===void 0?t:Number(t)}let i=new CC(`size`);return i.xform=r,e.push(i),e.push(new CC(`timeCreated`)),e.push(new CC(`updated`)),e.push(new CC(`md5Hash`,null,!0)),e.push(new CC(`cacheControl`,null,!0)),e.push(new CC(`contentDisposition`,null,!0)),e.push(new CC(`contentEncoding`,null,!0)),e.push(new CC(`contentLanguage`,null,!0)),e.push(new CC(`contentType`,null,!0)),e.push(new CC(`metadata`,`customMetadata`,!0)),wC=e,wC}function DC(e,t){function n(){let n=e.bucket,r=e.fullPath,i=new FS(n,r);return t._makeStorageReference(i)}Object.defineProperty(e,"ref",{get:n})}function OC(e,t,n){let r={};r.type=`file`;let i=n.length;for(let e=0;e<i;e++){let i=n[e];r[i.local]=i.xform(r,t[i.server])}return DC(r,e),r}function kC(e,t,n){let r=vC(t);return r===null?null:OC(e,r,n)}function AC(e,t,n,r){let i=vC(t);if(i===null||!HS(i.downloadTokens))return null;let a=i.downloadTokens;if(a.length===0)return null;let o=encodeURIComponent;return a.split(`,`).map(t=>{let i=e.bucket,a=e.fullPath;return KS(`/b/`+o(i)+`/o/`+o(a),n,r)+qS({alt:`media`,token:t})})[0]}function jC(e,t){let n={},r=t.length;for(let i=0;i<r;i++){let r=t[i];r.writable&&(n[r.server]=e[r.local])}return JSON.stringify(n)}var MC=class{constructor(e,t,n,r){this.url=e,this.method=t,this.handler=n,this.timeout=r,this.urlParams={},this.headers={},this.body=null,this.errorHandler=null,this.progressCallback=null,this.successCodes=[200],this.additionalRetryCodes=[]}};function NC(e){if(!e)throw hS()}function PC(e,t){function n(n,r){let i=kC(e,r,t);return NC(i!==null),i}return n}function FC(e,t){function n(n,r){let i=kC(e,r,t);return NC(i!==null),AC(i,r,e.host,e._protocol)}return n}function IC(e){function t(t,n){let r;return r=t.getStatus()===401?t.getErrorText().includes(`Firebase App Check token is invalid`)?yS():vS():t.getStatus()===402?_S(e.bucket):t.getStatus()===403?bS(e.path):n,r.status=t.getStatus(),r.serverResponse=n.serverResponse,r}return t}function LC(e){let t=IC(e);function n(n,r){let i=t(n,r);return n.getStatus()===404&&(i=gS(e.path)),i.serverResponse=r.serverResponse,i}return n}function RC(e,t,n){let r=KS(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime,a=new MC(r,`GET`,PC(e,n),i);return a.errorHandler=LC(t),a}function zC(e,t,n){let r=KS(t.fullServerUrl(),e.host,e._protocol),i=e.maxOperationRetryTime,a=new MC(r,`GET`,FC(e,n),i);return a.errorHandler=LC(t),a}function BC(e,t){let n=KS(t.fullServerUrl(),e.host,e._protocol),r=e.maxOperationRetryTime;function i(e,t){}let a=new MC(n,`DELETE`,i,r);return a.successCodes=[200,204],a.errorHandler=LC(t),a}function VC(e,t){return e&&e.contentType||t&&t.type()||`application/octet-stream`}function HC(e,t,n){let r=Object.assign({},n);return r.fullPath=e.path,r.size=t.size(),r.contentType||=VC(null,t),r}function UC(e,t,n,r,i){let a=t.bucketOnlyServerUrl(),o={"X-Goog-Upload-Protocol":`multipart`};function s(){let e=``;for(let t=0;t<2;t++)e+=Math.random().toString().slice(2);return e}let c=s();o[`Content-Type`]=`multipart/related; boundary=`+c;let l=HC(t,r,i),u=jC(l,n),d=`--`+c+`\r
23
35
  Content-Type: application/json; charset=utf-8\r
24
36
  \r
25
37
  `+u+`\r
@@ -27,6 +39,6 @@ Content-Type: application/json; charset=utf-8\r
27
39
  Content-Type: `+l.contentType+`\r
28
40
  \r
29
41
  `,f=`\r
30
- --`+c+`--`,p=hy.getBlob(d,r,f);if(p===null)throw wv();let m={name:l.fullPath},h=Wv(a,e.host,e._protocol),g=e.maxUploadRetryTime,ee=new Ay(h,`POST`,My(e,n),g);return ee.urlParams=m,ee.headers=o,ee.body=p.uploadData(),ee.errorHandler=Py(t),ee}var Hy=class{constructor(e,t,n,r){this.current=e,this.total=t,this.finalized=!!n,this.metadata=r||null}};function Uy(e,t){let n=null;try{n=e.getResponseHeader(`X-Goog-Upload-Status`)}catch{jy(!1)}return jy(!!n&&(t||[`active`]).indexOf(n)!==-1),n}function Wy(e,t,n,r,i){let a=t.bucketOnlyServerUrl(),o=By(t,r,i),s={name:o.fullPath},c=Wv(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=ky(o,n),d=e.maxUploadRetryTime;function f(e){Uy(e);let t;try{t=e.getResponseHeader(`X-Goog-Upload-URL`)}catch{jy(!1)}return jy(Bv(t)),t}let p=new Ay(c,`POST`,f,d);return p.urlParams=s,p.headers=l,p.body=u,p.errorHandler=Py(t),p}function Gy(e,t,n,r){let i={"X-Goog-Upload-Command":`query`};function a(e){let t=Uy(e,[`active`,`final`]),n=null;try{n=e.getResponseHeader(`X-Goog-Upload-Size-Received`)}catch{jy(!1)}n||jy(!1);let i=Number(n);return jy(!isNaN(i)),new Hy(i,r.size(),t===`final`)}let o=e.maxUploadRetryTime,s=new Ay(n,`POST`,a,o);return s.headers=i,s.errorHandler=Py(t),s}var Ky=256*1024;function qy(e,t,n,r,i,a,o,s){let c=new Hy(0,0);if(o?(c.current=o.current,c.total=o.total):(c.current=0,c.total=r.size()),r.size()!==c.total)throw Tv();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 wv();function g(e,n){let i=Uy(e,[`active`,`final`]),o=c.current+u,s=r.size(),l;return l=i===`final`?My(t,a)(e,n):null,new Hy(o,s,i===`final`,l)}let ee=t.maxUploadRetryTime,te=new Ay(n,`POST`,g,ee);return te.headers=m,te.body=h.uploadData(),te.progressCallback=s||null,te.errorHandler=Py(e),te}var Jy={RUNNING:`running`,PAUSED:`paused`,SUCCESS:`success`,CANCELED:`canceled`,ERROR:`error`};function Yy(e){switch(e){case`running`:case`pausing`:case`canceling`:return Jy.RUNNING;case`paused`:return Jy.PAUSED;case`success`:return Jy.SUCCESS;case`canceled`:return Jy.CANCELED;case`error`:return Jy.ERROR;default:return Jy.ERROR}}var Xy=class{constructor(e,t,n){if(Rv(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 Zy(e){return(...t)=>{Promise.resolve().then(()=>e(...t))}}var Qy=class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=Kv.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener(`abort`,()=>{this.errorCode_=Kv.ABORT,e()}),this.xhr_.addEventListener(`error`,()=>{this.errorCode_=Kv.NETWORK_ERROR,e()}),this.xhr_.addEventListener(`load`,()=>{e()})})}send(e,t,n,r,i){if(this.sent_)throw Mv(`cannot .send() more than once`);if(Ee(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 Mv(`cannot .getErrorCode() before sending`);return this.errorCode_}getStatus(){if(!this.sent_)throw Mv(`cannot .getStatus() before sending`);try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw Mv(`cannot .getResponse() before sending`);return this.xhr_.response}getErrorText(){if(!this.sent_)throw Mv(`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)}},$y=class extends Qy{initXhr(){this.xhr_.responseType=`text`}};function eb(){return new $y}var tb=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=wy(),this._resumable=this._shouldDoResumable(this._blob),this._state=`running`,this._errorHandler=e=>{if(this._request=void 0,this._chunkMultiplier=1,e._codeEquals(Q.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{let t=this.isExponentialBackoffExpired();if(qv(e.status,[]))if(t)e=yv();else{this.sleepTime=Math.max(this.sleepTime*2,dv),this._needToFetchStatus=!0,this.completeTransitions_();return}this._error=e,this._transition(`error`)}},this._metadataErrorHandler=e=>{this._request=void 0,e._codeEquals(Q.CANCELED)?this.completeTransitions_():(this._error=e,this._transition(`error`))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){let e=this._transferred;return t=>this._updateProgress(e+t)}_shouldDoResumable(e){return e.size()>256*1024}_start(){this._state===`running`&&this._request===void 0&&(this._resumable?this._uploadUrl===void 0?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(e){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([t,n])=>{switch(this._state){case`running`:e(t,n);break;case`canceling`:this._transition(`canceled`);break;case`pausing`:this._transition(`paused`);break}})}_createResumable(){this._resolveToken((e,t)=>{let n=Wy(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,eb,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=Gy(this._ref.storage,this._ref._location,e,this._blob),i=this._ref.storage._makeRequest(r,eb,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=Ky*this._chunkMultiplier,t=new Hy(this._transferred,this._blob.size()),n=this._uploadUrl;this._resolveToken((r,i)=>{let a;try{a=qy(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,eb,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(){Ky*this._chunkMultiplier*2<32*1024*1024&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{let n=Iy(this._ref.storage,this._ref._location,this._mappings),r=this._ref.storage._makeRequest(n,eb,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=Vy(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,eb,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=bv(),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=Yy(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 Xy(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(Yy(this._state)){case Jy.SUCCESS:Zy(this._resolve.bind(null,this.snapshot))();break;case Jy.CANCELED:case Jy.ERROR:let t=this._reject;Zy(t.bind(null,this._error))();break;default:e=!1;break}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(Yy(this._state)){case Jy.RUNNING:case Jy.PAUSED:e.next&&Zy(e.next.bind(e,this.snapshot))();break;case Jy.SUCCESS:e.complete&&Zy(e.complete.bind(e))();break;case Jy.CANCELED:case Jy.ERROR:e.error&&Zy(e.error.bind(e,this._error))();break;default:e.error&&Zy(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}},nb=class e{constructor(e,t){this._service=e,t instanceof Nv?this._location=t:this._location=Nv.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 Nv(this._location.bucket,``);return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return yy(this._location.path)}get storage(){return this._service}get parent(){let t=_y(this._location.path);if(t===null)return null;let n=new Nv(this._location.bucket,t);return new e(this._service,n)}_throwIfRoot(e){if(this._location.path===``)throw Av(e)}};function rb(e,t,n){return e._throwIfRoot(`uploadBytesResumable`),new tb(e,new hy(t),n)}function ib(e){e._throwIfRoot(`getDownloadURL`);let t=Ly(e.storage,e._location,wy());return e.storage.makeRequestWithTokens(t,eb).then(e=>{if(e===null)throw Ev();return e})}function ab(e){e._throwIfRoot(`deleteObject`);let t=Ry(e.storage,e._location);return e.storage.makeRequestWithTokens(t,eb)}function ob(e,t){let n=vy(e._location.path,t),r=new Nv(e._location.bucket,n);return new nb(e.storage,r)}function sb(e){return/^[A-Za-z]+:\/\//.test(e)}function cb(e,t){return new nb(e,t)}function lb(e,t){if(e instanceof pb){let n=e;if(n._bucket==null)throw Cv();let r=new nb(n,n._bucket);return t==null?r:lb(r,t)}else if(t!==void 0)return ob(e,t);else return e}function ub(e,t){if(t&&sb(t)){if(e instanceof pb)return cb(e,t);throw Ov(`To use ref(service, url), the first argument must be a Storage instance.`)}else return lb(e,t)}function db(e,t){let n=t?.[cv];return n==null?null:Nv.makeFromBucketSpec(n,e)}function fb(e,t,n,r={}){e.host=`${t}:${n}`;let i=Ee(t);i&&De(`https://${e.host}/b`),e._isUsingEmulator=!0,e._protocol=i?`https`:`http`;let{mockUserToken:a}=r;a&&(e._overrideAuthToken=typeof a==`string`?a:ne(a,e.app.options.projectId))}var pb=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=sv,this._protocol=`https`,this._appId=null,this._deleted=!1,this._maxOperationRetryTime=lv,this._maxUploadRetryTime=uv,this._requests=new Set,r==null?this._bucket=db(this._host,this.app.options):this._bucket=Nv.makeFromBucketSpec(r,this._host)}get host(){return this._host}set host(e){this._host=e,this._url==null?this._bucket=db(e,this.app.options):this._bucket=Nv.makeFromBucketSpec(this._url,e)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){Uv(`time`,0,1/0,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){Uv(`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(S(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 nb(this,e)}_makeRequest(e,t,n,r,i=!0){if(this._deleted)return new Pv(kv());{let a=ey(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()}},mb=`@firebase/storage`,hb=`0.14.2`,gb=`storage`;function _b(e,t,n){return e=y(e),rb(e,t,n)}function vb(e){return e=y(e),ib(e)}function yb(e){return e=y(e),ab(e)}function bb(e,t){return e=y(e),ub(e,t)}function xb(e=Qt(),t){e=y(e);let n=qt(e,gb).getImmediate({identifier:t}),r=h(`storage`);return r&&Sb(n,...r),n}function Sb(e,t,n,r={}){fb(e,t,n,r)}function Cb(e,{instanceIdentifier:t}){return new pb(e.getProvider(`app`).getImmediate(),e.getProvider(`auth-internal`),e.getProvider(`app-check-internal`),t,Xt)}function wb(){Kt(new Oe(gb,Cb,`PUBLIC`).setMultipleInstances(!0)),$t(mb,hb,``),$t(mb,hb,`esm2020`)}wb();var Tb=`type.googleapis.com/google.protobuf.Int64Value`,Eb=`type.googleapis.com/google.protobuf.UInt64Value`;function Db(e,t){let n={};for(let r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r]));return n}function Ob(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=>Ob(e));if(typeof e==`function`||typeof e==`object`)return Db(e,e=>Ob(e));throw Error(`Data cannot be encoded in JSON: `+e)}function kb(e){if(e==null)return e;if(e[`@type`])switch(e[`@type`]){case Tb:case Eb:{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=>kb(e)):typeof e==`function`||typeof e==`object`?Db(e,e=>kb(e)):e}var Ab=`functions`,jb={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`},Mb=class e extends fe{constructor(t,n,r){super(`${Ab}/${t}`,n||``),this.details=r,Object.setPrototypeOf(this,e.prototype)}};function Nb(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 Pb(e,t){let n=Nb(e),r=n,i;try{let e=t&&t.error;if(e){let t=e.status;if(typeof t==`string`){if(!jb[t])return new Mb(`internal`,`internal`);n=jb[t],r=t}let a=e.message;typeof a==`string`&&(r=a),i=e.details,i!==void 0&&(i=kb(i))}}catch{}return n===`ok`?null:new Mb(n,r,i)}var Fb=class{constructor(e,t,n,r){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,S(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)}}},Ib=`us-central1`,Lb=/^data: (.*?)(?:\n|$)/;function Rb(e){let t=null;return{promise:new Promise((n,r)=>{t=setTimeout(()=>{r(new Mb(`deadline-exceeded`,`deadline-exceeded`))},e)}),cancel:()=>{t&&clearTimeout(t)}}}var zb=class{constructor(e,t,n,r,i=Ib,a=(...e)=>fetch(...e)){this.app=e,this.fetchImpl=a,this.emulatorOrigin=null,this.contextProvider=new Fb(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=Ib}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 Bb(e,t,n){let r=Ee(t);e.emulatorOrigin=`http${r?`s`:``}://${t}:${n}`,r&&De(e.emulatorOrigin+`/backends`)}function Vb(e,t,n){let r=r=>Gb(e,t,r,n||{});return r.stream=(n,r)=>qb(e,t,n,r),r}function Hb(e){return e.emulatorOrigin&&Ee(e.emulatorOrigin)?`include`:void 0}async function Ub(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:Hb(i)})}catch{return{status:0,json:null}}let o=null;try{o=await a.json()}catch{}return{status:a.status,json:o}}async function Wb(e,t){let n={},r=await e.contextProvider.getContext(t.limitedUseAppCheckTokens);return r.authToken&&(n.Authorization=`Bearer `+r.authToken),r.messagingToken&&(n[`Firebase-Instance-ID-Token`]=r.messagingToken),r.appCheckToken!==null&&(n[`X-Firebase-AppCheck`]=r.appCheckToken),n}function Gb(e,t,n,r){return Kb(e,e._url(t),n,r)}async function Kb(e,t,n,r){n=Ob(n);let i={data:n},a=await Wb(e,r),o=Rb(r.timeout||7e4),s=await Promise.race([Ub(t,i,a,e.fetchImpl,e),o.promise,e.cancelAllRequests]);if(o.cancel(),!s)throw new Mb(`cancelled`,`Firebase Functions instance was deleted.`);let c=Pb(s.status,s.json);if(c)throw c;if(!s.json)throw new Mb(`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 Mb(`internal`,`Response is missing data field.`);return{data:kb(l)}}function qb(e,t,n,r){return Jb(e,e._url(t),n,r||{})}async function Jb(e,t,n,r){n=Ob(n);let i={data:n},a=await Wb(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:Hb(e)})}catch(e){if(e instanceof Error&&e.name===`AbortError`){let e=new Mb(`cancelled`,`Request was cancelled.`);return{data:Promise.reject(e),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(e)}}}}}}let t=Pb(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 Mb(`cancelled`,`Request was cancelled.`);c(e)});let u=Yb(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 Yb(e,t,n,r){let i=(e,r)=>{let i=e.match(Lb);if(!i)return;let a=i[1];try{let e=JSON.parse(a);if(`result`in e){t(kb(e.result));return}if(`message`in e){r.enqueue(kb(e.message));return}if(`error`in e){let t=Pb(0,e);r.error(t),n(t);return}}catch(e){if(e instanceof Mb){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 Mb(`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 Mb(`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 Mb?e:Pb(0,null);t.error(r),n(r)}}},cancel(){return e.cancel()}})}var Xb=`@firebase/functions`,Zb=`0.13.3`,Qb=`auth-internal`,$b=`app-check-internal`,ex=`messaging-internal`;function tx(e){Kt(new Oe(Ab,(e,{instanceIdentifier:t})=>new zb(e.getProvider(`app`).getImmediate(),e.getProvider(Qb),e.getProvider(ex),e.getProvider($b),t),`PUBLIC`).setMultipleInstances(!0)),$t(Xb,Zb,e),$t(Xb,Zb,`esm2020`)}function nx(e=Qt(),t=Ib){let n=qt(y(e),Ab).getImmediate({identifier:t}),r=h(`functions`);return r&&rx(n,...r),n}function rx(e,t,n){Bb(y(e),t,n)}function ix(e,t,n){return Vb(y(e),t,n)}tx();var $=class e{static setFirebaseConfig(t){e._firebaseConfig=t}static{this.defaultEmulatorConfig={host:`localhost`,firestorePort:8080,storagePort:9199,authPort:9099,functionsPort:5001,emulate:!1}}static useEmulator(t){this._emulatorConfig={...e.defaultEmulatorConfig,emulate:!0,...t}}static get emulator(){return this._emulatorConfig}constructor(){if(!e._firebaseConfig)throw Error(`You should set a firebase config object before using Firebase`);this._firebaseApp=Zt(e._firebaseConfig)}static get instance(){return this._instance||=new e}firestore(){return Zu(this._firebaseApp)}storage(){return xb(this._firebaseApp)}auth(){return av(this._firebaseApp)}functions(){return nx(this._firebaseApp,e._region)}static setRegion(e){this._region=e}static{this._emulatorConfig=e.defaultEmulatorConfig}},ax=class extends Bf{constructor(e){if(super(),this._lastLimit=0,e&&$.useEmulator(e),$.emulator?.emulate){let{host:e,firestorePort:t}=$.emulator;Vu($.instance.firestore(),e,t)}}findById(e,t){let n=$.instance.firestore();return new Promise(async r=>{try{r((await pf(Ku(n,t,e))).data())}catch(e){return console.log(e),null}})}save(e){let t=$.instance.firestore(),n=yf(t);return Object.entries(e).forEach(([e,r])=>{r?.forEach(r=>{let i=Ku(t,e,r.id);n.set(i,r)})}),n.commit()}find(e,t){let n=this.queryObjectToQueryConstraints(e,t);return this.getFromQuery(n)}async count(e,t){return(await rf(this.queryObjectToQueryConstraints(e,t))).data().count}delete(e,t){return hf(Ku($.instance.firestore(),t,e))}next(e){if(!this._lastConstraints||!this._lastCollectionName)throw Error(`You should perform a query prior to using method next`);if(!this._lastDocRetrieved)return Promise.resolve([]);let t=$.instance.firestore();this._lastLimit=e||this._lastLimit;let n=this._lastConstraints.nonFilterConstraints.concat(qd(this._lastLimit),Yd(this._lastDocRetrieved));return this.getFromQuery(Rd(Gu(t,this._lastCollectionName),Hd(...this._lastConstraints.orConstraints,Ud(...this._lastConstraints.andConstraints)),...n))}onCollectionChange(e,t,n){return gf(this.queryObjectToQueryConstraints(e,t),e=>{n(e.docChanges().map(e=>({after:e.doc.data(),type:e.type===`added`?`create`:e.type===`removed`?`delete`:`update`,before:void 0,params:{}})))})}onDocumentChange(e,t,n){return gf(Ku($.instance.firestore(),e,t),t=>{n({type:`update`,before:void 0,after:t.data(),params:t.metadata,collectionPath:e})})}onDocumentTemplateChange(e,t){throw Error(`Method not implemented.`)}queryObjectToQueryConstraints(e,t){let n=$.instance.firestore(),r=[],i=[],a=[];return Bf.toPropertyPathOperations(e.operations).forEach(e=>{let t=this.toFirebaseOperator(e.operator);e.aggregate?i.push(Bd(e.property,t,e.value)):r.push(Bd(e.property,t,e.value))}),e.sort?.propertyName&&a.push(Gd(e.sort.propertyName,e.sort.order)),this._lastConstraints={orConstraints:i,andConstraints:r,nonFilterConstraints:a},this._lastCollectionName=t,e.limit&&(this._lastLimit=e.limit,a.push(qd(e.limit))),Rd(Gu(n,t),Hd(...i,Ud(...r)),...a)}toFirebaseOperator(e){switch(e){case`==`:case`!=`:case`<`:case`<=`:case`>`:case`>=`:return e;case`contains`:return`array-contains`;case`containsAny`:return`array-contains-any`;default:return e}}getFromQuery(e){return new Promise(async t=>{let n=await mf(e);n.empty?(this._lastDocRetrieved=void 0,t([])):(this._lastDocRetrieved=n.docs[n.docs.length-1],t(n.docs.map(e=>e.data())))})}resolveCollectionPaths(e){throw Error(`Method not implemented.`)}};function ox(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var sx=class extends Hf{constructor(e){if(super(),e&&$.useEmulator(e),$.emulator?.emulate){let{host:e,storagePort:t}=$.emulator;Sb($.instance.storage(),e,t)}}save(e,t,n){let r=$.instance.storage();return new Promise((i,a)=>{if(this._uploadTask=_b(bb(r,e),t),n)var o=this._uploadTask.on(`state_changed`,e=>{n(e.bytesTransferred,e.totalBytes)},null,()=>o());this._uploadTask.then(()=>i(e)).catch(e=>a(e))})}getUrl(e){return e?vb(bb($.instance.storage(),e)):Promise.reject(`needs a reference`)}uploadControl(){if(!this._uploadTask)throw Error(`You should call save() before uploadControl()`);return{cancel:()=>this._uploadTask?.cancel(),pause:()=>this._uploadTask?.pause(),resume:()=>this._uploadTask?.resume(),onProgress:e=>this._uploadTask?.on(`state_changed`,t=>{e&&e(t.bytesTransferred,t.totalBytes)})}}delete(e){return yb(bb($.instance.storage(),e))}};sx=ox([Uf(`FirebaseCloudStorage`,()=>new sx)],sx);var cx={twitter:()=>new Th,facebook:()=>new Sh,google:()=>new Ch},lx=class e extends Qf{constructor(e){if(super(),this.credentialProviders={},e&&$.useEmulator(e),$.emulator?.emulate){let{host:e,authPort:t}=$.emulator;if(!e||!t)throw Error(`You should define a host and an auth emulator port to use the emulator`);qm($.instance.auth(),`http://${e}:${t}`)}this.registerCredentialProviders()}signUp(e){let{authProvider:t,verificationLink:n}=e;return t.slice(0,5)===`email`?new Promise(async(r,i)=>{try{let i=this.credentialProviders[`email-sign-up`];if(!i)throw Error(`The provider ${t} is not registered`);let a=await i(e);e.name&&await Kh(a.user,{displayName:e.name}),n&&await Wh(a.user,{url:n}),r(await this.toUserCredentials(a.user))}catch(e){i({code:rp(e.code.slice(5)),message:e.message})}}):this.login(e)}login(e){let{authProvider:t}=e;return new Promise(async(n,r)=>{try{let r=this.credentialProviders[t];if(!r)throw Error(`The provider ${t} is not registered`);let i=await r(e);n(await this.toUserCredentials(i.user))}catch(e){r({code:e.code===400?`missingPassword`:rp(e.code.slice(5)),message:e.message})}})}logout(){return $.instance.auth().signOut()}resetEmailPassword(e){return new Promise(async(t,n)=>{try{await Vh($.instance.auth(),e),t()}catch(e){n({code:rp(e.code.slice(5)),message:e.message})}})}resendVerificationEmail(e,t,n){return new Promise(async(r,i)=>{try{await Uh($.instance.auth(),e,t);let a=$.instance.auth().currentUser;if(!a){i({code:`userNotFound`,message:`There is no logged in user`});return}await Wh(a,{url:n}),r()}catch(e){i({code:rp(e.code.slice(5)),message:n})}})}refreshToken(){return $.instance.auth().currentUser?.getIdToken(!0)}onAuthStateChange(e){$.instance.auth().onAuthStateChanged(async t=>{e(t?await this.toUserCredentials(t):void 0)})}linkAdditionalProvider(e){let t=cx[e](),n=$.instance.auth().currentUser;if(!n)throw Error(`There is no logged in user`);return Zg(n,t)}unlinkProvider(e){let{currentUser:t}=$.instance.auth();if(!t)throw Error(`There is no logged in user`);return t.providerData,Nh(t,cx[e]().providerId)}async toUserCredentials(t){if(!t)throw Error(`The user in user credentials is not defined`);let n=(await t.getIdTokenResult()).claims;return e.convertCredentials(t,n)}static convertCredentials(e,t){return{id:e.uid,email:e.email??``,name:e.displayName??void 0,pictureUrl:e.photoURL??void 0,phoneNumber:e.phoneNumber??void 0,emailVerified:e.emailVerified,customData:{...t},lastLogin:Date.now(),creationDate:e.metadata.creationTime?new Date(e.metadata.creationTime).getTime():void 0}}registerCredentialProvider(e,t){this.credentialProviders[e]=t}registerCredentialProviders(){this.registerCredentialProvider(`email-sign-up`,e=>{if(!e.email||!e.password)throw Error(`Email and password are required`);return Hh($.instance.auth(),e.email,e.password)}),this.registerCredentialProvider(`email`,e=>{if(!e.email||!e.password)throw Error(`Email and password are required`);return Uh($.instance.auth(),e.email,e.password)}),this.registerCredentialProvider(`google`,()=>Xg($.instance.auth(),new Ch)),this.registerCredentialProvider(`facebook`,()=>Xg($.instance.auth(),new Sh)),this.registerCredentialProvider(`twitter`,()=>Xg($.instance.auth(),new Th)),this.registerCredentialProvider(`link-twitter`,()=>{let e=$.instance.auth().currentUser;if(!e)throw Error(`There is no logged in user`);return Zg(e,new Th)}),this.registerCredentialProvider(`anonymous`,()=>kh($.instance.auth()))}},ux=class{constructor(e,t){if(e&&$.setRegion(e),t&&$.useEmulator(t),$.emulator?.emulate){let{host:e,functionsPort:t}=$.emulator;rx($.instance.functions(),e,t)}}retrieveFunction(e){return ix($.instance.functions(),e)}async callFunction(e,t){return(await e(t)).data}};e.FirebaseAuth=lx,e.FirebaseCloudFunctions=ux,Object.defineProperty(e,`FirebaseCloudStorage`,{enumerable:!0,get:function(){return sx}}),e.FirebaseDatasource=ax,e.FirebaseHelper=$});
42
+ --`+c+`--`,p=_C.getBlob(d,r,f);if(p===null)throw ES();let m={name:l.fullPath},h=KS(a,e.host,e._protocol),g=e.maxUploadRetryTime,ee=new MC(h,`POST`,PC(e,n),g);return ee.urlParams=m,ee.headers=o,ee.body=p.uploadData(),ee.errorHandler=IC(t),ee}var WC=class{constructor(e,t,n,r){this.current=e,this.total=t,this.finalized=!!n,this.metadata=r||null}};function GC(e,t){let n=null;try{n=e.getResponseHeader(`X-Goog-Upload-Status`)}catch{NC(!1)}return NC(!!n&&(t||[`active`]).indexOf(n)!==-1),n}function KC(e,t,n,r,i){let a=t.bucketOnlyServerUrl(),o=HC(t,r,i),s={name:o.fullPath},c=KS(a,e.host,e._protocol),l={"X-Goog-Upload-Protocol":`resumable`,"X-Goog-Upload-Command":`start`,"X-Goog-Upload-Header-Content-Length":`${r.size()}`,"X-Goog-Upload-Header-Content-Type":o.contentType,"Content-Type":`application/json; charset=utf-8`},u=jC(o,n),d=e.maxUploadRetryTime;function f(e){GC(e);let t;try{t=e.getResponseHeader(`X-Goog-Upload-URL`)}catch{NC(!1)}return NC(HS(t)),t}let p=new MC(c,`POST`,f,d);return p.urlParams=s,p.headers=l,p.body=u,p.errorHandler=IC(t),p}function qC(e,t,n,r){let i={"X-Goog-Upload-Command":`query`};function a(e){let t=GC(e,[`active`,`final`]),n=null;try{n=e.getResponseHeader(`X-Goog-Upload-Size-Received`)}catch{NC(!1)}n||NC(!1);let i=Number(n);return NC(!isNaN(i)),new WC(i,r.size(),t===`final`)}let o=e.maxUploadRetryTime,s=new MC(n,`POST`,a,o);return s.headers=i,s.errorHandler=IC(t),s}var JC=256*1024;function YC(e,t,n,r,i,a,o,s){let c=new WC(0,0);if(o?(c.current=o.current,c.total=o.total):(c.current=0,c.total=r.size()),r.size()!==c.total)throw DS();let l=c.total-c.current,u=l;i>0&&(u=Math.min(u,i));let d=c.current,f=d+u,p=``;p=u===0?`finalize`:l===u?`upload, finalize`:`upload`;let m={"X-Goog-Upload-Command":p,"X-Goog-Upload-Offset":`${c.current}`},h=r.slice(d,f);if(h===null)throw ES();function g(e,n){let i=GC(e,[`active`,`final`]),o=c.current+u,s=r.size(),l;return l=i===`final`?PC(t,a)(e,n):null,new WC(o,s,i===`final`,l)}let ee=t.maxUploadRetryTime,te=new MC(n,`POST`,g,ee);return te.headers=m,te.body=h.uploadData(),te.progressCallback=s||null,te.errorHandler=IC(e),te}var XC={RUNNING:`running`,PAUSED:`paused`,SUCCESS:`success`,CANCELED:`canceled`,ERROR:`error`};function ZC(e){switch(e){case`running`:case`pausing`:case`canceling`:return XC.RUNNING;case`paused`:return XC.PAUSED;case`success`:return XC.SUCCESS;case`canceled`:return XC.CANCELED;case`error`:return XC.ERROR;default:return XC.ERROR}}var QC=class{constructor(e,t,n){if(BS(e)||t!=null||n!=null)this.next=e,this.error=t??void 0,this.complete=n??void 0;else{let t=e;this.next=t.next,this.error=t.error,this.complete=t.complete}}};function $C(e){return(...t)=>{Promise.resolve().then(()=>e(...t))}}var ew=class{constructor(){this.sent_=!1,this.xhr_=new XMLHttpRequest,this.initXhr(),this.errorCode_=JS.NO_ERROR,this.sendPromise_=new Promise(e=>{this.xhr_.addEventListener(`abort`,()=>{this.errorCode_=JS.ABORT,e()}),this.xhr_.addEventListener(`error`,()=>{this.errorCode_=JS.NETWORK_ERROR,e()}),this.xhr_.addEventListener(`load`,()=>{e()})})}send(e,t,n,r,i){if(this.sent_)throw PS(`cannot .send() more than once`);if(Oe(e)&&n&&(this.xhr_.withCredentials=!0),this.sent_=!0,this.xhr_.open(t,e,!0),i!==void 0)for(let e in i)i.hasOwnProperty(e)&&this.xhr_.setRequestHeader(e,i[e].toString());return r===void 0?this.xhr_.send():this.xhr_.send(r),this.sendPromise_}getErrorCode(){if(!this.sent_)throw PS(`cannot .getErrorCode() before sending`);return this.errorCode_}getStatus(){if(!this.sent_)throw PS(`cannot .getStatus() before sending`);try{return this.xhr_.status}catch{return-1}}getResponse(){if(!this.sent_)throw PS(`cannot .getResponse() before sending`);return this.xhr_.response}getErrorText(){if(!this.sent_)throw PS(`cannot .getErrorText() before sending`);return this.xhr_.statusText}abort(){this.xhr_.abort()}getResponseHeader(e){return this.xhr_.getResponseHeader(e)}addUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.addEventListener(`progress`,e)}removeUploadProgressListener(e){this.xhr_.upload!=null&&this.xhr_.upload.removeEventListener(`progress`,e)}},tw=class extends ew{initXhr(){this.xhr_.responseType=`text`}};function nw(){return new tw}var rw=class{isExponentialBackoffExpired(){return this.sleepTime>this.maxSleepTime}constructor(e,t,n=null){this._transferred=0,this._needToFetchStatus=!1,this._needToFetchMetadata=!1,this._observers=[],this._error=void 0,this._uploadUrl=void 0,this._request=void 0,this._chunkMultiplier=1,this._resolve=void 0,this._reject=void 0,this._ref=e,this._blob=t,this._metadata=n,this._mappings=EC(),this._resumable=this._shouldDoResumable(this._blob),this._state=`running`,this._errorHandler=e=>{if(this._request=void 0,this._chunkMultiplier=1,e._codeEquals(Q.CANCELED))this._needToFetchStatus=!0,this.completeTransitions_();else{let t=this.isExponentialBackoffExpired();if(YS(e.status,[]))if(t)e=xS();else{this.sleepTime=Math.max(this.sleepTime*2,pS),this._needToFetchStatus=!0,this.completeTransitions_();return}this._error=e,this._transition(`error`)}},this._metadataErrorHandler=e=>{this._request=void 0,e._codeEquals(Q.CANCELED)?this.completeTransitions_():(this._error=e,this._transition(`error`))},this.sleepTime=0,this.maxSleepTime=this._ref.storage.maxUploadRetryTime,this._promise=new Promise((e,t)=>{this._resolve=e,this._reject=t,this._start()}),this._promise.then(null,()=>{})}_makeProgressCallback(){let e=this._transferred;return t=>this._updateProgress(e+t)}_shouldDoResumable(e){return e.size()>256*1024}_start(){this._state===`running`&&this._request===void 0&&(this._resumable?this._uploadUrl===void 0?this._createResumable():this._needToFetchStatus?this._fetchStatus():this._needToFetchMetadata?this._fetchMetadata():this.pendingTimeout=setTimeout(()=>{this.pendingTimeout=void 0,this._continueUpload()},this.sleepTime):this._oneShotUpload())}_resolveToken(e){Promise.all([this._ref.storage._getAuthToken(),this._ref.storage._getAppCheckToken()]).then(([t,n])=>{switch(this._state){case`running`:e(t,n);break;case`canceling`:this._transition(`canceled`);break;case`pausing`:this._transition(`paused`);break}})}_createResumable(){this._resolveToken((e,t)=>{let n=KC(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,nw,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._uploadUrl=e,this._needToFetchStatus=!1,this.completeTransitions_()},this._errorHandler)})}_fetchStatus(){let e=this._uploadUrl;this._resolveToken((t,n)=>{let r=qC(this._ref.storage,this._ref._location,e,this._blob),i=this._ref.storage._makeRequest(r,nw,t,n);this._request=i,i.getPromise().then(e=>{e=e,this._request=void 0,this._updateProgress(e.current),this._needToFetchStatus=!1,e.finalized&&(this._needToFetchMetadata=!0),this.completeTransitions_()},this._errorHandler)})}_continueUpload(){let e=JC*this._chunkMultiplier,t=new WC(this._transferred,this._blob.size()),n=this._uploadUrl;this._resolveToken((r,i)=>{let a;try{a=YC(this._ref._location,this._ref.storage,n,this._blob,e,this._mappings,t,this._makeProgressCallback())}catch(e){this._error=e,this._transition(`error`);return}let o=this._ref.storage._makeRequest(a,nw,r,i,!1);this._request=o,o.getPromise().then(e=>{this._increaseMultiplier(),this._request=void 0,this._updateProgress(e.current),e.finalized?(this._metadata=e.metadata,this._transition(`success`)):this.completeTransitions_()},this._errorHandler)})}_increaseMultiplier(){JC*this._chunkMultiplier*2<32*1024*1024&&(this._chunkMultiplier*=2)}_fetchMetadata(){this._resolveToken((e,t)=>{let n=RC(this._ref.storage,this._ref._location,this._mappings),r=this._ref.storage._makeRequest(n,nw,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._metadata=e,this._transition(`success`)},this._metadataErrorHandler)})}_oneShotUpload(){this._resolveToken((e,t)=>{let n=UC(this._ref.storage,this._ref._location,this._mappings,this._blob,this._metadata),r=this._ref.storage._makeRequest(n,nw,e,t);this._request=r,r.getPromise().then(e=>{this._request=void 0,this._metadata=e,this._updateProgress(this._blob.size()),this._transition(`success`)},this._errorHandler)})}_updateProgress(e){let t=this._transferred;this._transferred=e,this._transferred!==t&&this._notifyObservers()}_transition(e){if(this._state!==e)switch(e){case`canceling`:case`pausing`:this._state=e,this._request===void 0?this.pendingTimeout&&(clearTimeout(this.pendingTimeout),this.pendingTimeout=void 0,this.completeTransitions_()):this._request.cancel();break;case`running`:let t=this._state===`paused`;this._state=e,t&&(this._notifyObservers(),this._start());break;case`paused`:this._state=e,this._notifyObservers();break;case`canceled`:this._error=SS(),this._state=e,this._notifyObservers();break;case`error`:this._state=e,this._notifyObservers();break;case`success`:this._state=e,this._notifyObservers();break}}completeTransitions_(){switch(this._state){case`pausing`:this._transition(`paused`);break;case`canceling`:this._transition(`canceled`);break;case`running`:this._start();break}}get snapshot(){let e=ZC(this._state);return{bytesTransferred:this._transferred,totalBytes:this._blob.size(),state:e,metadata:this._metadata,task:this,ref:this._ref}}on(e,t,n,r){let i=new QC(t||void 0,n||void 0,r||void 0);return this._addObserver(i),()=>{this._removeObserver(i)}}then(e,t){return this._promise.then(e,t)}catch(e){return this.then(null,e)}_addObserver(e){this._observers.push(e),this._notifyObserver(e)}_removeObserver(e){let t=this._observers.indexOf(e);t!==-1&&this._observers.splice(t,1)}_notifyObservers(){this._finishPromise(),this._observers.slice().forEach(e=>{this._notifyObserver(e)})}_finishPromise(){if(this._resolve!==void 0){let e=!0;switch(ZC(this._state)){case XC.SUCCESS:$C(this._resolve.bind(null,this.snapshot))();break;case XC.CANCELED:case XC.ERROR:let t=this._reject;$C(t.bind(null,this._error))();break;default:e=!1;break}e&&(this._resolve=void 0,this._reject=void 0)}}_notifyObserver(e){switch(ZC(this._state)){case XC.RUNNING:case XC.PAUSED:e.next&&$C(e.next.bind(e,this.snapshot))();break;case XC.SUCCESS:e.complete&&$C(e.complete.bind(e))();break;case XC.CANCELED:case XC.ERROR:e.error&&$C(e.error.bind(e,this._error))();break;default:e.error&&$C(e.error.bind(e,this._error))()}}resume(){let e=this._state===`paused`||this._state===`pausing`;return e&&this._transition(`running`),e}pause(){let e=this._state===`running`;return e&&this._transition(`pausing`),e}cancel(){let e=this._state===`running`||this._state===`pausing`;return e&&this._transition(`canceling`),e}},iw=class e{constructor(e,t){this._service=e,t instanceof FS?this._location=t:this._location=FS.makeFromUrl(t,e.host)}toString(){return`gs://`+this._location.bucket+`/`+this._location.path}_newRef(t,n){return new e(t,n)}get root(){let e=new FS(this._location.bucket,``);return this._newRef(this._service,e)}get bucket(){return this._location.bucket}get fullPath(){return this._location.path}get name(){return xC(this._location.path)}get storage(){return this._service}get parent(){let t=yC(this._location.path);if(t===null)return null;let n=new FS(this._location.bucket,t);return new e(this._service,n)}_throwIfRoot(e){if(this._location.path===``)throw MS(e)}};function aw(e,t,n){return e._throwIfRoot(`uploadBytesResumable`),new rw(e,new _C(t),n)}function ow(e){e._throwIfRoot(`getDownloadURL`);let t=zC(e.storage,e._location,EC());return e.storage.makeRequestWithTokens(t,nw).then(e=>{if(e===null)throw OS();return e})}function sw(e){e._throwIfRoot(`deleteObject`);let t=BC(e.storage,e._location);return e.storage.makeRequestWithTokens(t,nw)}function cw(e,t){let n=bC(e._location.path,t),r=new FS(e._location.bucket,n);return new iw(e.storage,r)}function lw(e){return/^[A-Za-z]+:\/\//.test(e)}function uw(e,t){return new iw(e,t)}function dw(e,t){if(e instanceof hw){let n=e;if(n._bucket==null)throw TS();let r=new iw(n,n._bucket);return t==null?r:dw(r,t)}else if(t!==void 0)return cw(e,t);else return e}function fw(e,t){if(t&&lw(t)){if(e instanceof hw)return uw(e,t);throw AS(`To use ref(service, url), the first argument must be a Storage instance.`)}else return dw(e,t)}function pw(e,t){let n=t?.[uS];return n==null?null:FS.makeFromBucketSpec(n,e)}function mw(e,t,n,r={}){e.host=`${t}:${n}`;let i=Oe(t);i&&ke(`https://${e.host}/b`),e._isUsingEmulator=!0,e._protocol=i?`https`:`http`;let{mockUserToken:a}=r;a&&(e._overrideAuthToken=typeof a==`string`?a:ne(a,e.app.options.projectId))}var hw=class{constructor(e,t,n,r,i,a=!1){this.app=e,this._authProvider=t,this._appCheckProvider=n,this._url=r,this._firebaseVersion=i,this._isUsingEmulator=a,this._bucket=null,this._host=lS,this._protocol=`https`,this._appId=null,this._deleted=!1,this._maxOperationRetryTime=dS,this._maxUploadRetryTime=fS,this._requests=new Set,r==null?this._bucket=pw(this._host,this.app.options):this._bucket=FS.makeFromBucketSpec(r,this._host)}get host(){return this._host}set host(e){this._host=e,this._url==null?this._bucket=pw(e,this.app.options):this._bucket=FS.makeFromBucketSpec(this._url,e)}get maxUploadRetryTime(){return this._maxUploadRetryTime}set maxUploadRetryTime(e){GS(`time`,0,1/0,e),this._maxUploadRetryTime=e}get maxOperationRetryTime(){return this._maxOperationRetryTime}set maxOperationRetryTime(e){GS(`time`,0,1/0,e),this._maxOperationRetryTime=e}async _getAuthToken(){if(this._overrideAuthToken)return this._overrideAuthToken;let e=this._authProvider.getImmediate({optional:!0});if(e){let t=await e.getToken();if(t!==null)return t.accessToken}return null}async _getAppCheckToken(){if(y(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;let e=this._appCheckProvider.getImmediate({optional:!0});return e?(await e.getToken()).token:null}_delete(){return this._deleted||(this._deleted=!0,this._requests.forEach(e=>e.cancel()),this._requests.clear()),Promise.resolve()}_makeStorageReference(e){return new iw(this,e)}_makeRequest(e,t,n,r,i=!0){if(this._deleted)return new IS(jS());{let a=nC(e,this._appId,n,r,t,this._firebaseVersion,i,this._isUsingEmulator);return this._requests.add(a),a.getPromise().then(()=>this._requests.delete(a),()=>this._requests.delete(a)),a}}async makeRequestWithTokens(e,t){let[n,r]=await Promise.all([this._getAuthToken(),this._getAppCheckToken()]);return this._makeRequest(e,t,n,r).getPromise()}},gw=`@firebase/storage`,_w=`0.14.3`,vw=`storage`;function yw(e,t,n){return e=_(e),aw(e,t,n)}function bw(e){return e=_(e),ow(e)}function xw(e){return e=_(e),sw(e)}function Sw(e,t){return e=_(e),fw(e,t)}function Cw(e=tn(),t){e=_(e);let n=Xt(e,vw).getImmediate({identifier:t}),r=h(`storage`);return r&&ww(n,...r),n}function ww(e,t,n,r={}){mw(e,t,n,r)}function Tw(e,{instanceIdentifier:t}){return new hw(e.getProvider(`app`).getImmediate(),e.getProvider(`auth-internal`),e.getProvider(`app-check-internal`),t,$t)}function Ew(){Yt(new Ae(vw,Tw,`PUBLIC`).setMultipleInstances(!0)),nn(gw,_w,``),nn(gw,_w,`esm2020`)}Ew();var Dw=`type.googleapis.com/google.protobuf.Int64Value`,Ow=`type.googleapis.com/google.protobuf.UInt64Value`;function kw(e,t){let n={};for(let r in e)e.hasOwnProperty(r)&&(n[r]=t(e[r]));return n}function Aw(e){if(e==null)return null;if(e instanceof Number&&(e=e.valueOf()),typeof e==`number`&&isFinite(e)||e===!0||e===!1||Object.prototype.toString.call(e)===`[object String]`)return e;if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(e=>Aw(e));if(typeof e==`function`||typeof e==`object`)return kw(e,e=>Aw(e));throw Error(`Data cannot be encoded in JSON: `+e)}function jw(e){if(e==null)return e;if(e[`@type`])switch(e[`@type`]){case Dw:case Ow:{let t=Number(e.value);if(isNaN(t))throw Error(`Data cannot be decoded from JSON: `+e);return t}default:throw Error(`Data cannot be decoded from JSON: `+e)}return Array.isArray(e)?e.map(e=>jw(e)):typeof e==`function`||typeof e==`object`?kw(e,e=>jw(e)):e}var Mw=`functions`,Nw={OK:`ok`,CANCELLED:`cancelled`,UNKNOWN:`unknown`,INVALID_ARGUMENT:`invalid-argument`,DEADLINE_EXCEEDED:`deadline-exceeded`,NOT_FOUND:`not-found`,ALREADY_EXISTS:`already-exists`,PERMISSION_DENIED:`permission-denied`,UNAUTHENTICATED:`unauthenticated`,RESOURCE_EXHAUSTED:`resource-exhausted`,FAILED_PRECONDITION:`failed-precondition`,ABORTED:`aborted`,OUT_OF_RANGE:`out-of-range`,UNIMPLEMENTED:`unimplemented`,INTERNAL:`internal`,UNAVAILABLE:`unavailable`,DATA_LOSS:`data-loss`},Pw=class e extends me{constructor(t,n,r){super(`${Mw}/${t}`,n||``),this.details=r,Object.setPrototypeOf(this,e.prototype)}};function Fw(e){if(e>=200&&e<300)return`ok`;switch(e){case 0:return`internal`;case 400:return`invalid-argument`;case 401:return`unauthenticated`;case 403:return`permission-denied`;case 404:return`not-found`;case 409:return`aborted`;case 429:return`resource-exhausted`;case 499:return`cancelled`;case 500:return`internal`;case 501:return`unimplemented`;case 503:return`unavailable`;case 504:return`deadline-exceeded`}return`unknown`}function Iw(e,t){let n=Fw(e),r=n,i;try{let e=t&&t.error;if(e){let t=e.status;if(typeof t==`string`){if(!Nw[t])return new Pw(`internal`,`internal`);n=Nw[t],r=t}let a=e.message;typeof a==`string`&&(r=a),i=e.details,i!==void 0&&(i=jw(i))}}catch{}return n===`ok`?null:new Pw(n,r,i)}var Lw=class{constructor(e,t,n,r){this.app=e,this.auth=null,this.messaging=null,this.appCheck=null,this.serverAppAppCheckToken=null,y(e)&&e.settings.appCheckToken&&(this.serverAppAppCheckToken=e.settings.appCheckToken),this.auth=t.getImmediate({optional:!0}),this.messaging=n.getImmediate({optional:!0}),this.auth||t.get().then(e=>this.auth=e,()=>{}),this.messaging||n.get().then(e=>this.messaging=e,()=>{}),this.appCheck||r?.get().then(e=>this.appCheck=e,()=>{})}async getAuthToken(){if(this.auth)try{return(await this.auth.getToken())?.accessToken}catch{return}}async getMessagingToken(){if(!(!this.messaging||!(`Notification`in self)||Notification.permission!==`granted`))try{return await this.messaging.getToken()}catch{return}}async getAppCheckToken(e){if(this.serverAppAppCheckToken)return this.serverAppAppCheckToken;if(this.appCheck){let t=e?await this.appCheck.getLimitedUseToken():await this.appCheck.getToken();return t.error?null:t.token}return null}async getContext(e){return{authToken:await this.getAuthToken(),messagingToken:await this.getMessagingToken(),appCheckToken:await this.getAppCheckToken(e)}}},Rw=`us-central1`,zw=/^data: (.*?)(?:\n|$)/;function Bw(e){let t=null;return{promise:new Promise((n,r)=>{t=setTimeout(()=>{r(new Pw(`deadline-exceeded`,`deadline-exceeded`))},e)}),cancel:()=>{t&&clearTimeout(t)}}}var Vw=class{constructor(e,t,n,r,i=Rw,a=(...e)=>fetch(...e)){this.app=e,this.fetchImpl=a,this.emulatorOrigin=null,this.contextProvider=new Lw(e,t,n,r),this.cancelAllRequests=new Promise(e=>{this.deleteService=()=>Promise.resolve(e())});try{let e=new URL(i);this.customDomain=e.origin+(e.pathname===`/`?``:e.pathname),this.region=Rw}catch{this.customDomain=null,this.region=i}}_delete(){return this.deleteService()}_url(e){let t=this.app.options.projectId;return this.emulatorOrigin===null?this.customDomain===null?`https://${this.region}-${t}.cloudfunctions.net/${e}`:`${this.customDomain}/${e}`:`${this.emulatorOrigin}/${t}/${this.region}/${e}`}};function Hw(e,t,n){let r=Oe(t);e.emulatorOrigin=`http${r?`s`:``}://${t}:${n}`,r&&ke(e.emulatorOrigin+`/backends`)}function Uw(e,t,n){let r=r=>qw(e,t,r,n||{});return r.stream=(n,r)=>Yw(e,t,n,r),r}function Ww(e){return e.emulatorOrigin&&Oe(e.emulatorOrigin)?`include`:void 0}async function Gw(e,t,n,r,i){n[`Content-Type`]=`application/json`;let a;try{a=await r(e,{method:`POST`,body:JSON.stringify(t),headers:n,credentials:Ww(i)})}catch{return{status:0,json:null}}let o=null;try{o=await a.json()}catch{}return{status:a.status,json:o}}async function Kw(e,t){let n={},r=await e.contextProvider.getContext(t.limitedUseAppCheckTokens);return r.authToken&&(n.Authorization=`Bearer `+r.authToken),r.messagingToken&&(n[`Firebase-Instance-ID-Token`]=r.messagingToken),r.appCheckToken!==null&&(n[`X-Firebase-AppCheck`]=r.appCheckToken),n}function qw(e,t,n,r){return Jw(e,e._url(t),n,r)}async function Jw(e,t,n,r){n=Aw(n);let i={data:n},a=await Kw(e,r),o=Bw(r.timeout||7e4),s=await Promise.race([Gw(t,i,a,e.fetchImpl,e),o.promise,e.cancelAllRequests]);if(o.cancel(),!s)throw new Pw(`cancelled`,`Firebase Functions instance was deleted.`);let c=Iw(s.status,s.json);if(c)throw c;if(!s.json)throw new Pw(`internal`,`Response is not valid JSON object.`);let l=s.json.data;if(l===void 0&&(l=s.json.result),l===void 0)throw new Pw(`internal`,`Response is missing data field.`);return{data:jw(l)}}function Yw(e,t,n,r){return Xw(e,e._url(t),n,r||{})}async function Xw(e,t,n,r){n=Aw(n);let i={data:n},a=await Kw(e,r);a[`Content-Type`]=`application/json`,a.Accept=`text/event-stream`;let o;try{o=await e.fetchImpl(t,{method:`POST`,body:JSON.stringify(i),headers:a,signal:r?.signal,credentials:Ww(e)})}catch(e){if(e instanceof Error&&e.name===`AbortError`){let e=new Pw(`cancelled`,`Request was cancelled.`);return{data:Promise.reject(e),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(e)}}}}}}let t=Iw(0,null);return{data:Promise.reject(t),stream:{[Symbol.asyncIterator](){return{next(){return Promise.reject(t)}}}}}}let s,c,l=new Promise((e,t)=>{s=e,c=t});r?.signal?.addEventListener(`abort`,()=>{let e=new Pw(`cancelled`,`Request was cancelled.`);c(e)});let u=Zw(o.body.getReader(),s,c,r?.signal);return{stream:{[Symbol.asyncIterator](){let e=u.getReader();return{async next(){let{value:t,done:n}=await e.read();return{value:t,done:n}},async return(){return await e.cancel(),{done:!0,value:void 0}}}}},data:l}}function Zw(e,t,n,r){let i=(e,r)=>{let i=e.match(zw);if(!i)return;let a=i[1];try{let e=JSON.parse(a);if(`result`in e){t(jw(e.result));return}if(`message`in e){r.enqueue(jw(e.message));return}if(`error`in e){let t=Iw(0,e);r.error(t),n(t);return}}catch(e){if(e instanceof Pw){r.error(e),n(e);return}}},a=new TextDecoder;return new ReadableStream({start(t){let o=``;return s();async function s(){if(r?.aborted){let e=new Pw(`cancelled`,`Request was cancelled`);return t.error(e),n(e),Promise.resolve()}try{let{value:c,done:l}=await e.read();if(l){o.trim()&&i(o.trim(),t),t.close();return}if(r?.aborted){let r=new Pw(`cancelled`,`Request was cancelled`);t.error(r),n(r),await e.cancel();return}o+=a.decode(c,{stream:!0});let u=o.split(`
43
+ `);o=u.pop()||``;for(let e of u)e.trim()&&i(e.trim(),t);return s()}catch(e){let r=e instanceof Pw?e:Iw(0,null);t.error(r),n(r)}}},cancel(){return e.cancel()}})}var Qw=`@firebase/functions`,$w=`0.13.5`,eT=`auth-internal`,tT=`app-check-internal`,nT=`messaging-internal`;function rT(e){Yt(new Ae(Mw,(e,{instanceIdentifier:t})=>new Vw(e.getProvider(`app`).getImmediate(),e.getProvider(eT),e.getProvider(nT),e.getProvider(tT),t),`PUBLIC`).setMultipleInstances(!0)),nn(Qw,$w,e),nn(Qw,$w,`esm2020`)}function iT(e=tn(),t=Rw){let n=Xt(_(e),Mw).getImmediate({identifier:t}),r=h(`functions`);return r&&aT(n,...r),n}function aT(e,t,n){Hw(_(e),t,n)}function oT(e,t,n){return Uw(_(e),t,n)}rT();var $=class e{static setFirebaseConfig(t){e._firebaseConfig=t}static{this.defaultEmulatorConfig={host:`localhost`,firestorePort:8080,storagePort:9199,authPort:9099,functionsPort:5001,emulate:!1}}static useEmulator(t){this._emulatorConfig={...e.defaultEmulatorConfig,emulate:!0,...t}}static get emulator(){return this._emulatorConfig}constructor(){if(!e._firebaseConfig)throw Error(`You should set a firebase config object before using Firebase`);this._firebaseApp=en(e._firebaseConfig)}static get instance(){return this._instance||=new e}firestore(){return Rh(this._firebaseApp)}storage(){return Cw(this._firebaseApp)}auth(){return sS(this._firebaseApp)}functions(){return iT(this._firebaseApp,e._region)}static setRegion(e){this._region=e}static{this._emulatorConfig=e.defaultEmulatorConfig}},sT=class extends Yg{constructor(e){if(super(),this._lastLimit=0,e&&$.useEmulator(e),$.emulator?.emulate){let{host:e,firestorePort:t}=$.emulator;Ol($.instance.firestore(),e,t)}}findById(e,t){let n=$.instance.firestore();return new Promise(async r=>{try{r((await Dg(Nl(n,t,e))).data())}catch(e){return console.log(e),null}})}save(e){let t=$.instance.firestore(),n=Ng(t);return Object.entries(e).forEach(([e,r])=>{r?.forEach(r=>{let i=Nl(t,e,r.id);n.set(i,r)})}),n.commit()}find(e,t){let n=this.queryObjectToQueryConstraints(e,t);return this.getFromQuery(n)}async count(e,t){return(await vg(this.queryObjectToQueryConstraints(e,t))).data().count}delete(e,t){return kg(Nl($.instance.firestore(),t,e))}next(e){if(!this._lastConstraints||!this._lastCollectionName)throw Error(`You should perform a query prior to using method next`);if(!this._lastDocRetrieved)return Promise.resolve([]);let t=$.instance.firestore();this._lastLimit=e||this._lastLimit;let n=this._lastConstraints.nonFilterConstraints.concat(cg(this._lastLimit),ug(this._lastDocRetrieved));return this.getFromQuery($h(Ml(t,this._lastCollectionName),rg(...this._lastConstraints.orConstraints,ig(...this._lastConstraints.andConstraints)),...n))}onCollectionChange(e,t,n){return Ag(this.queryObjectToQueryConstraints(e,t),e=>{n(e.docChanges().map(e=>({after:e.doc.data(),type:e.type===`added`?`create`:e.type===`removed`?`delete`:`update`,before:void 0,params:{}})))})}onDocumentChange(e,t,n){return Ag(Nl($.instance.firestore(),e,t),t=>{n({type:`update`,before:void 0,after:t.data(),params:t.metadata,collectionPath:e})})}onDocumentTemplateChange(e,t){throw Error(`Method not implemented.`)}queryObjectToQueryConstraints(e,t){let n=$.instance.firestore(),r=[],i=[],a=[];return Yg.toPropertyPathOperations(e.operations).forEach(e=>{let t=this.toFirebaseOperator(e.operator);e.aggregate?i.push(tg(e.property,t,e.value)):r.push(tg(e.property,t,e.value))}),e.sort?.propertyName&&a.push(og(e.sort.propertyName,e.sort.order)),this._lastConstraints={orConstraints:i,andConstraints:r,nonFilterConstraints:a},this._lastCollectionName=t,e.limit&&(this._lastLimit=e.limit,a.push(cg(e.limit))),$h(Ml(n,t),rg(...i,ig(...r)),...a)}toFirebaseOperator(e){switch(e){case`==`:case`!=`:case`<`:case`<=`:case`>`:case`>=`:return e;case`contains`:return`array-contains`;case`containsAny`:return`array-contains-any`;default:return e}}getFromQuery(e){return new Promise(async t=>{let n=await Og(e);n.empty?(this._lastDocRetrieved=void 0,t([])):(this._lastDocRetrieved=n.docs[n.docs.length-1],t(n.docs.map(e=>e.data())))})}resolveCollectionPaths(e){throw Error(`Method not implemented.`)}};function cT(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var lT=class extends Xg{constructor(e){if(super(),e&&$.useEmulator(e),$.emulator?.emulate){let{host:e,storagePort:t}=$.emulator;ww($.instance.storage(),e,t)}}save(e,t,n){let r=$.instance.storage();return new Promise((i,a)=>{if(this._uploadTask=yw(Sw(r,e),t),n)var o=this._uploadTask.on(`state_changed`,e=>{n(e.bytesTransferred,e.totalBytes)},null,()=>o());this._uploadTask.then(()=>i(e)).catch(e=>a(e))})}getUrl(e){return e?bw(Sw($.instance.storage(),e)):Promise.reject(`needs a reference`)}uploadControl(){if(!this._uploadTask)throw Error(`You should call save() before uploadControl()`);return{cancel:()=>this._uploadTask?.cancel(),pause:()=>this._uploadTask?.pause(),resume:()=>this._uploadTask?.resume(),onProgress:e=>this._uploadTask?.on(`state_changed`,t=>{e&&e(t.bytesTransferred,t.totalBytes)})}}delete(e){return xw(Sw($.instance.storage(),e))}};lT=cT([Zg(`FirebaseCloudStorage`,()=>new lT)],lT);var uT={twitter:()=>new Dy,facebook:()=>new wy,google:()=>new Ty},dT=class e extends e_{constructor(e){if(super(),this.credentialProviders={},e&&$.useEmulator(e),$.emulator?.emulate){let{host:e,authPort:t}=$.emulator;if(!e||!t)throw Error(`You should define a host and an auth emulator port to use the emulator`);Yv($.instance.auth(),`http://${e}:${t}`)}this.registerCredentialProviders()}signUp(e){let{authProvider:t,verificationLink:n}=e;return t.slice(0,5)===`email`?new Promise(async(r,i)=>{try{let i=this.credentialProviders[`email-sign-up`];if(!i)throw Error(`The provider ${t} is not registered`);let a=await i(e);e.name&&await Jy(a.user,{displayName:e.name}),n&&await Ky(a.user,{url:n}),r(await this.toUserCredentials(a.user))}catch(e){i({code:n_(e.code.slice(5)),message:e.message})}}):this.login(e)}login(e){let{authProvider:t}=e;return new Promise(async(n,r)=>{try{let r=this.credentialProviders[t];if(!r)throw Error(`The provider ${t} is not registered`);let i=await r(e);n(await this.toUserCredentials(i.user))}catch(e){r({code:e.code===400?`missingPassword`:n_(e.code.slice(5)),message:e.message})}})}logout(){return $.instance.auth().signOut()}resetEmailPassword(e){return new Promise(async(t,n)=>{try{await Uy($.instance.auth(),e),t()}catch(e){n({code:n_(e.code.slice(5)),message:e.message})}})}resendVerificationEmail(e,t,n){return new Promise(async(r,i)=>{try{await Gy($.instance.auth(),e,t);let a=$.instance.auth().currentUser;if(!a){i({code:`userNotFound`,message:`There is no logged in user`});return}await Ky(a,{url:n}),r()}catch(e){i({code:n_(e.code.slice(5)),message:n})}})}refreshToken(){return $.instance.auth().currentUser?.getIdToken(!0)}onAuthStateChange(e){$.instance.auth().onAuthStateChanged(async t=>{e(t?await this.toUserCredentials(t):void 0)})}linkAdditionalProvider(e){let t=uT[e](),n=$.instance.auth().currentUser;if(!n)throw Error(`There is no logged in user`);return $b(n,t)}unlinkProvider(e){let{currentUser:t}=$.instance.auth();if(!t)throw Error(`There is no logged in user`);return t.providerData,Fy(t,uT[e]().providerId)}async toUserCredentials(t){if(!t)throw Error(`The user in user credentials is not defined`);let n=(await t.getIdTokenResult()).claims;return e.convertCredentials(t,n)}static convertCredentials(e,t){return{id:e.uid,email:e.email??``,name:e.displayName??void 0,pictureUrl:e.photoURL??void 0,phoneNumber:e.phoneNumber??void 0,emailVerified:e.emailVerified,customData:{...t},lastLogin:Date.now(),creationDate:e.metadata.creationTime?new Date(e.metadata.creationTime).getTime():void 0}}registerCredentialProvider(e,t){this.credentialProviders[e]=t}registerCredentialProviders(){this.registerCredentialProvider(`email-sign-up`,e=>{if(!e.email||!e.password)throw Error(`Email and password are required`);return Wy($.instance.auth(),e.email,e.password)}),this.registerCredentialProvider(`email`,e=>{if(!e.email||!e.password)throw Error(`Email and password are required`);return Gy($.instance.auth(),e.email,e.password)}),this.registerCredentialProvider(`google`,()=>Qb($.instance.auth(),new Ty)),this.registerCredentialProvider(`facebook`,()=>Qb($.instance.auth(),new wy)),this.registerCredentialProvider(`twitter`,()=>Qb($.instance.auth(),new Dy)),this.registerCredentialProvider(`link-twitter`,()=>{let e=$.instance.auth().currentUser;if(!e)throw Error(`There is no logged in user`);return $b(e,new Dy)}),this.registerCredentialProvider(`anonymous`,()=>jy($.instance.auth()))}},fT=class{constructor(e,t){if(e&&$.setRegion(e),t&&$.useEmulator(t),$.emulator?.emulate){let{host:e,functionsPort:t}=$.emulator;aT($.instance.functions(),e,t)}}retrieveFunction(e){return oT($.instance.functions(),e)}async callFunction(e,t){return(await e(t)).data}};e.FirebaseAuth=dT,e.FirebaseCloudFunctions=fT,Object.defineProperty(e,"FirebaseCloudStorage",{enumerable:!0,get:function(){return lT}}),e.FirebaseDatasource=sT,e.FirebaseHelper=$});
32
44
  //# sourceMappingURL=entropic-bond-firebase.umd.cjs.map