@ienlab/react-library 0.1.11 → 0.1.13
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.
- package/dist/my-library.cjs.js +1 -16
- package/dist/my-library.es.js +19 -8682
- package/dist/utils/firestore.d.ts +2 -2
- package/dist/utils/firestore.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/my-library.cjs.js
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=()=>void 0,t=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},n=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(``)},r={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`,get ENCODED_VALS(){return this.ENCODED_VALS_BASE+`+/=`},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+`-_.`},HAS_NATIVE_SUPPORT: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,n){return this.HAS_NATIVE_SUPPORT&&!n?btoa(e):this.encodeByteArray(t(e),n)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):n(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 a=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,a==null||o==null||s==null||c==null)throw new i;let l=a<<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)}}},i=class extends Error{constructor(){super(...arguments),this.name=`DecodeBase64StringError`}},a=function(e){let n=t(e);return r.encodeByteArray(n,!0)},o=function(e){return a(e).replace(/\./g,``)},s=function(e){try{return r.decodeString(e,!0)}catch(e){console.error(`base64Decode failed: `,e)}return null};function c(){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 l=()=>c().__FIREBASE_DEFAULTS__,u=()=>{if(typeof process>`u`||process.env===void 0)return;let e=process.env.__FIREBASE_DEFAULTS__;if(e)return JSON.parse(e)},d=()=>{if(typeof document>`u`)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}let t=e&&s(e[1]);return t&&JSON.parse(t)},f=()=>{try{return e()||l()||u()||d()}catch(e){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);return}};function p(){return typeof navigator<`u`&&typeof navigator.userAgent==`string`?navigator.userAgent:``}function m(){let e=f()?.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 h(){return!m()&&!!navigator.userAgent&&navigator.userAgent.includes(`Safari`)&&!navigator.userAgent.includes(`Chrome`)}function g(){try{return typeof indexedDB==`object`}catch{return!1}}function ee(){return new Promise((e,t)=>{try{let n=!0,r=`validate-browser-context-for-indexeddb-analytics-module`,i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{t(i.error?.message||``)}}catch(e){t(e)}})}var te=`FirebaseError`,ne=class e extends Error{constructor(t,n,r){super(n),this.code=t,this.customData=r,this.name=te,Object.setPrototypeOf(this,e.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,re.prototype.create)}},re=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?ie(i,n):`Error`;return new ne(r,`${this.serviceName}: ${a} (${r}).`,n)}};function ie(e,t){return e.replace(ae,(e,n)=>{let r=t[n];return r==null?`<${n}?>`:String(r)})}var ae=/\{\$([^}]+)}/g;function oe(e){return e&&e._delegate?e._delegate:e}function se(e){try{return(e.startsWith(`http://`)||e.startsWith(`https://`)?new URL(e).hostname:e).endsWith(`.cloudworkstations.dev`)}catch{return!1}}var ce=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}},le=[],_;(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`})(_||={});var ue={debug:_.DEBUG,verbose:_.VERBOSE,info:_.INFO,warn:_.WARN,error:_.ERROR,silent:_.SILENT},de=_.INFO,fe={[_.DEBUG]:`log`,[_.VERBOSE]:`log`,[_.INFO]:`info`,[_.WARN]:`warn`,[_.ERROR]:`error`},pe=(e,t,...n)=>{if(t<e.logLevel)return;let r=new Date().toISOString(),i=fe[t];if(i)console[i](`[${r}] ${e.name}:`,...n);else throw Error(`Attempted to log a message with an invalid logType (value: ${t})`)},me=class{constructor(e){this.name=e,this._logLevel=de,this._logHandler=pe,this._userLogHandler=null,le.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in _))throw TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e==`string`?ue[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,_.DEBUG,...e),this._logHandler(this,_.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,_.VERBOSE,...e),this._logHandler(this,_.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,_.INFO,...e),this._logHandler(this,_.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,_.WARN,...e),this._logHandler(this,_.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,_.ERROR,...e),this._logHandler(this,_.ERROR,...e)}},he=(e,t)=>t.some(t=>e instanceof t),ge,_e;function ve(){return ge||=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]}function ye(){return _e||=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey]}var be=new WeakMap,xe=new WeakMap,Se=new WeakMap,Ce=new WeakMap,we=new WeakMap;function Te(e){let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener(`success`,i),e.removeEventListener(`error`,a)},i=()=>{t(je(e.result)),r()},a=()=>{n(e.error),r()};e.addEventListener(`success`,i),e.addEventListener(`error`,a)});return t.then(t=>{t instanceof IDBCursor&&be.set(t,e)}).catch(()=>{}),we.set(t,e),t}function Ee(e){if(xe.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)});xe.set(e,t)}var De={get(e,t,n){if(e instanceof IDBTransaction){if(t===`done`)return xe.get(e);if(t===`objectStoreNames`)return e.objectStoreNames||Se.get(e);if(t===`store`)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return je(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 Oe(e){De=e(De)}function ke(e){return e===IDBDatabase.prototype.transaction&&!(`objectStoreNames`in IDBTransaction.prototype)?function(t,...n){let r=e.call(Me(this),t,...n);return Se.set(r,t.sort?t.sort():[t]),je(r)}:ye().includes(e)?function(...t){return e.apply(Me(this),t),je(be.get(this))}:function(...t){return je(e.apply(Me(this),t))}}function Ae(e){return typeof e==`function`?ke(e):(e instanceof IDBTransaction&&Ee(e),he(e,ve())?new Proxy(e,De):e)}function je(e){if(e instanceof IDBRequest)return Te(e);if(Ce.has(e))return Ce.get(e);let t=Ae(e);return t!==e&&(Ce.set(e,t),we.set(t,e)),t}var Me=e=>we.get(e);function Ne(e,t,{blocked:n,upgrade:r,blocking:i,terminated:a}={}){let o=indexedDB.open(e,t),s=je(o);return r&&o.addEventListener(`upgradeneeded`,e=>{r(je(o.result),e.oldVersion,e.newVersion,je(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 Pe=[`get`,`getKey`,`getAll`,`getAllKeys`,`count`],Fe=[`put`,`add`,`delete`,`clear`],Ie=new Map;function Le(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&typeof t==`string`))return;if(Ie.get(t))return Ie.get(t);let n=t.replace(/FromIndex$/,``),r=t!==n,i=Fe.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||Pe.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 Ie.set(t,a),a}Oe(e=>({...e,get:(t,n,r)=>Le(t,n)||e.get(t,n,r),has:(t,n)=>!!Le(t,n)||e.has(t,n)}));var v=class{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(y(e)){let t=e.getImmediate();return`${t.library}/${t.version}`}else return null}).filter(e=>e).join(` `)}};function y(e){return e.getComponent()?.type===`VERSION`}var Re=`@firebase/app`,ze=`0.14.11`,Be=new me(`@firebase/app`),Ve=`@firebase/app-compat`,He=`@firebase/analytics-compat`,Ue=`@firebase/analytics`,We=`@firebase/app-check-compat`,Ge=`@firebase/app-check`,Ke=`@firebase/auth`,qe=`@firebase/auth-compat`,Je=`@firebase/database`,Ye=`@firebase/data-connect`,Xe=`@firebase/database-compat`,Ze=`@firebase/functions`,Qe=`@firebase/functions-compat`,$e=`@firebase/installations`,et=`@firebase/installations-compat`,tt=`@firebase/messaging`,nt=`@firebase/messaging-compat`,rt=`@firebase/performance`,it=`@firebase/performance-compat`,b=`@firebase/remote-config`,at=`@firebase/remote-config-compat`,ot=`@firebase/storage`,st=`@firebase/storage-compat`,ct=`@firebase/firestore`,lt=`@firebase/ai`,ut=`@firebase/firestore-compat`,dt=`firebase`,ft=`12.12.0`,pt={[Re]:`fire-core`,[Ve]:`fire-core-compat`,[Ue]:`fire-analytics`,[He]:`fire-analytics-compat`,[Ge]:`fire-app-check`,[We]:`fire-app-check-compat`,[Ke]:`fire-auth`,[qe]:`fire-auth-compat`,[Je]:`fire-rtdb`,[Ye]:`fire-data-connect`,[Xe]:`fire-rtdb-compat`,[Ze]:`fire-fn`,[Qe]:`fire-fn-compat`,[$e]:`fire-iid`,[et]:`fire-iid-compat`,[tt]:`fire-fcm`,[nt]:`fire-fcm-compat`,[rt]:`fire-perf`,[it]:`fire-perf-compat`,[b]:`fire-rc`,[at]:`fire-rc-compat`,[ot]:`fire-gcs`,[st]:`fire-gcs-compat`,[ct]:`fire-fst`,[ut]:`fire-fst-compat`,[lt]:`fire-vertex`,"fire-js":`fire-js`,[dt]:`fire-js-all`},mt=new Map,ht=new Map,gt=new Map;function _t(e,t){try{e.container.addComponent(t)}catch(n){Be.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function vt(e){let t=e.name;if(gt.has(t))return Be.debug(`There were multiple attempts to register component ${t}.`),!1;gt.set(t,e);for(let t of mt.values())_t(t,e);for(let t of ht.values())_t(t,e);return!0}function yt(e){return e==null?!1:e.settings!==void 0}var bt=new re(`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.`}),xt=ft;function St(e,t,n){let r=pt[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 "/")`),Be.warn(e.join(` `));return}vt(new ce(`${r}-version`,()=>({library:r,version:t}),`VERSION`))}var Ct=`firebase-heartbeat-database`,wt=1,Tt=`firebase-heartbeat-store`,Et=null;function Dt(){return Et||=Ne(Ct,wt,{upgrade:(e,t)=>{switch(t){case 0:try{e.createObjectStore(Tt)}catch(e){console.warn(e)}}}}).catch(e=>{throw bt.create(`idb-open`,{originalErrorMessage:e.message})}),Et}async function Ot(e){try{let t=(await Dt()).transaction(Tt),n=await t.objectStore(Tt).get(At(e));return await t.done,n}catch(e){if(e instanceof ne)Be.warn(e.message);else{let t=bt.create(`idb-get`,{originalErrorMessage:e?.message});Be.warn(t.message)}}}async function kt(e,t){try{let n=(await Dt()).transaction(Tt,`readwrite`);await n.objectStore(Tt).put(t,At(e)),await n.done}catch(e){if(e instanceof ne)Be.warn(e.message);else{let t=bt.create(`idb-set`,{originalErrorMessage:e?.message});Be.warn(t.message)}}}function At(e){return`${e.name}!${e.options.appId}`}var jt=1024,Mt=30,Nt=class{constructor(e){this.container=e,this._heartbeatsCache=null;let t=this.container.getProvider(`app`).getImmediate();this._storage=new It(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=Pt();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>Mt){let e=Rt(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){Be.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return``;let e=Pt(),{heartbeatsToSend:t,unsentEntries:n}=Ft(this._heartbeatsCache.heartbeats),r=o(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 Be.warn(e),``}}};function Pt(){return new Date().toISOString().substring(0,10)}function Ft(e,t=jt){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]}),Lt(n)>t){n.pop();break}}else if(e.dates.push(i.date),Lt(n)>t){e.dates.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}var It=class{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return g()?ee().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){let e=await Ot(this.app);return e?.heartbeats?e:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){let t=await this.read();return kt(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 kt(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??t.lastSentHeartbeatDate,heartbeats:[...t.heartbeats,...e.heartbeats]})}else return}};function Lt(e){return o(JSON.stringify({version:2,heartbeats:e})).length}function Rt(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 zt(e){vt(new ce(`platform-logger`,e=>new v(e),`PRIVATE`)),vt(new ce(`heartbeat`,e=>new Nt(e),`PRIVATE`)),St(Re,ze,e),St(Re,ze,`esm2020`),St(`fire-js`,``)}zt(``);var Bt=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},Vt={},Ht,Ut;(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,Ut=Vt.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,Ht=Vt.Integer=o}).apply(Bt===void 0?typeof self<`u`?self:typeof window<`u`?window:{}:Bt);var Wt=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},Gt={},Kt,qt,Jt,Yt,Xt,Zt,Qt,$t;(function(){var e,t=Object.defineProperty;function n(e){e=[typeof globalThis==`object`&&globalThis,e,typeof window==`object`&&window,typeof self==`object`&&self,typeof Wt==`object`&&Wt];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 _(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}_.prototype.h=function(){this.defaultPrevented=!0};var ue=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 de(e){return/^[\s\xa0]*$/.test(e)}function fe(e,t){_.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(fe,_),fe.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&&fe.Z.h.call(this)},fe.prototype.h=function(){fe.Z.h.call(this);let e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var pe=`closure_listenable_`+(Math.random()*1e6|0),me=0;function he(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ha=i,this.key=++me,this.da=this.fa=!1}function ge(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function _e(e,t,n){for(let r in e)t.call(n,e[r],r,e)}function ve(e,t){for(let n in e)t.call(void 0,e[n],n,e)}function ye(e){let t={};for(let n in e)t[n]=e[n];return t}let be=`constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf`.split(` `);function xe(e,t){let n,r;for(let t=1;t<arguments.length;t++){for(n in r=arguments[t],r)e[n]=r[n];for(let t=0;t<be.length;t++)n=be[t],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function Se(e){this.src=e,this.g={},this.h=0}Se.prototype.add=function(e,t,n,r,i){let a=e.toString();e=this.g[a],e||(e=this.g[a]=[],this.h++);let o=we(e,t,r,i);return o>-1?(t=e[o],n||(t.fa=!1)):(t=new he(t,this.src,a,!!r,i),t.fa=n,e.push(t)),t};function Ce(e,t){let n=t.type;if(n in e.g){var r=e.g[n],i=Array.prototype.indexOf.call(r,t,void 0),a;(a=i>=0)&&Array.prototype.splice.call(r,i,1),a&&(ge(t),e.g[n].length==0&&(delete e.g[n],e.h--))}}function we(e,t,n,r){for(let i=0;i<e.length;++i){let a=e[i];if(!a.da&&a.listener==t&&a.capture==!!n&&a.ha==r)return i}return-1}var Te=`closure_lm_`+(Math.random()*1e6|0),Ee={};function De(e,t,n,r,i){if(r&&r.once)return Ae(e,t,n,r,i);if(Array.isArray(t)){for(let a=0;a<t.length;a++)De(e,t[a],n,r,i);return null}return n=Le(n),e&&e[pe]?e.J(t,n,s(r)?!!r.capture:!!r,i):Oe(e,t,n,!1,r,i)}function Oe(e,t,n,r,i,a){if(!t)throw Error(`Invalid event type`);let o=s(i)?!!i.capture:!!i,c=Fe(e);if(c||(e[Te]=c=new Se(e)),n=c.add(t,n,r,o,a),n.proxy)return n;if(r=ke(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)ue||(i=o),i===void 0&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(Ne(t.toString()),r);else if(e.addListener&&e.removeListener)e.addListener(r);else throw Error(`addEventListener and attachEvent are unavailable.`);return n}function ke(){function e(n){return t.call(e.src,e.listener,n)}let t=Pe;return e}function Ae(e,t,n,r,i){if(Array.isArray(t)){for(let a=0;a<t.length;a++)Ae(e,t[a],n,r,i);return null}return n=Le(n),e&&e[pe]?e.K(t,n,s(r)?!!r.capture:!!r,i):Oe(e,t,n,!0,r,i)}function je(e,t,n,r,i){if(Array.isArray(t))for(var a=0;a<t.length;a++)je(e,t[a],n,r,i);else r=s(r)?!!r.capture:!!r,n=Le(n),e&&e[pe]?(e=e.i,a=String(t).toString(),a in e.g&&(t=e.g[a],n=we(t,n,r,i),n>-1&&(ge(t[n]),Array.prototype.splice.call(t,n,1),t.length==0&&(delete e.g[a],e.h--)))):(e&&=Fe(e))&&(t=e.g[t.toString()],e=-1,t&&(e=we(t,n,r,i)),(n=e>-1?t[e]:null)&&Me(n))}function Me(e){if(typeof e!=`number`&&e&&!e.da){var t=e.src;if(t&&t[pe])Ce(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(Ne(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=Fe(t))?(Ce(n,e),n.h==0&&(n.src=null,t[Te]=null)):ge(e)}}}function Ne(e){return e in Ee?Ee[e]:Ee[e]=`on`+e}function Pe(e,t){if(e.da)e=!0;else{t=new fe(t,this);let n=e.listener,r=e.ha||e.src;e.fa&&Me(e),e=n.call(r,t)}return e}function Fe(e){return e=e[Te],e instanceof Se?e:null}var Ie=`__closure_events_fn_`+(Math.random()*1e9>>>0);function Le(e){return typeof e==`function`?e:(e[Ie]||(e[Ie]=function(t){return e.handleEvent(t)}),e[Ie])}function v(){le.call(this),this.i=new Se(this),this.M=this,this.G=null}d(v,le),v.prototype[pe]=!0,v.prototype.removeEventListener=function(e,t,n,r){je(this,e,t,n,r)};function y(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 _(t,e);else if(t instanceof _)t.target=t.target||e;else{var i=t;t=new _(r,e),xe(t,i)}i=!0;let a,o;if(n)for(o=n.length-1;o>=0;o--)a=t.g=n[o],i=Re(a,r,!0,t)&&i;if(a=t.g=e,i=Re(a,r,!0,t)&&i,i=Re(a,r,!1,t)&&i,n)for(o=0;o<n.length;o++)a=t.g=n[o],i=Re(a,r,!1,t)&&i}v.prototype.N=function(){if(v.Z.N.call(this),this.i){var e=this.i;for(let t in e.g){let n=e.g[t];for(let e=0;e<n.length;e++)ge(n[e]);delete e.g[t],e.h--}}this.G=null},v.prototype.J=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},v.prototype.K=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};function Re(e,t,n,r){if(t=e.i.g[String(t)],!t)return!0;t=t.concat();let i=!0;for(let a=0;a<t.length;++a){let o=t[a];if(o&&!o.da&&o.capture==n){let t=o.listener,n=o.ha||o.src;o.fa&&Ce(e.i,o),i=t.call(n,r)!==!1&&i}}return i&&!r.defaultPrevented}function ze(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 Be(e){e.g=ze(()=>{e.g=null,e.i&&(e.i=!1,Be(e))},e.l);let t=e.h;e.h=null,e.m.apply(null,t)}class Ve 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:Be(this)}N(){super.N(),this.g&&(o.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function He(e){le.call(this),this.h=e,this.g={}}d(He,le);var Ue=[];function We(e){_e(e.g,function(e,t){this.g.hasOwnProperty(t)&&Me(e)},e),e.g={}}He.prototype.N=function(){He.Z.N.call(this),We(this)},He.prototype.handleEvent=function(){throw Error(`EventHandler.handleEvent not implemented`)};var Ge=o.JSON.stringify,Ke=o.JSON.parse,qe=class{stringify(e){return o.JSON.stringify(e,void 0)}parse(e){return o.JSON.parse(e,void 0)}};function Je(){}function Ye(){}var Xe={OPEN:`a`,hb:`b`,ERROR:`c`,tb:`d`};function Ze(){_.call(this,`d`)}d(Ze,_);function Qe(){_.call(this,`c`)}d(Qe,_);var $e={},et=null;function tt(){return et||=new v}$e.Ia=`serverreachability`;function nt(e){_.call(this,$e.Ia,e)}d(nt,_);function rt(e){let t=tt();y(t,new nt(t))}$e.STAT_EVENT=`statevent`;function it(e,t){_.call(this,$e.STAT_EVENT,e),this.stat=t}d(it,_);function b(e){let t=tt();y(t,new it(t,e))}$e.Ja=`timingevent`;function at(e,t){_.call(this,$e.Ja,e),this.size=t}d(at,_);function ot(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 st(){this.g=!0}st.prototype.ua=function(){this.g=!1};function ct(e,t,n,r,i,a){e.info(function(){if(e.g)if(a){var o=``,s=a.split(`&`);for(let e=0;e<s.length;e++){var c=s[e].split(`=`);if(c.length>1){let e=c[0];c=c[1];let t=e.split(`_`);o=t.length>=2&&t[1]==`type`?o+(e+`=`+c+`&`):o+(e+`=redacted&`)}}}else o=null;else o=a;return`XMLHTTP REQ (`+r+`) [attempt `+i+`]: `+t+`
|
|
2
|
-
`+n+`
|
|
3
|
-
`+o})}function lt(e,t,n,r,i,a,o){e.info(function(){return`XMLHTTP RESP (`+r+`) [ attempt `+i+`]: `+t+`
|
|
4
|
-
`+n+`
|
|
5
|
-
`+a+` `+o})}function ut(e,t,n,r){e.info(function(){return`XMLHTTP TEXT (`+t+`): `+ft(e,n)+(r?` `+r:``)})}function dt(e,t){e.info(function(){return`TIMEOUT: `+t})}st.prototype.info=function(){};function ft(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 Ge(a)}catch{return t}}var pt={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},mt={ib:`complete`,Fb:`success`,ERROR:`error`,Ga:`abort`,xb:`ready`,yb:`readystatechange`,TIMEOUT:`timeout`,sb:`incrementaldata`,wb:`progress`,lb:`downloadprogress`,Nb:`uploadprogress`},ht;function gt(){}d(gt,Je),gt.prototype.g=function(){return new XMLHttpRequest},ht=new gt;function _t(e){return encodeURIComponent(String(e))}function vt(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 yt(e,t,n,r){this.j=e,this.i=t,this.l=n,this.S=r||1,this.V=new He(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 bt}function bt(){this.i=null,this.g=``,this.h=!1}var xt={},St={};function Ct(e,t,n){e.M=1,e.A=T(S(t)),e.u=n,e.R=!0,wt(e,null)}function wt(e,t){e.F=Date.now(),Ot(e),e.B=S(e.A);var n=e.B,r=e.S;Array.isArray(r)||(r=[String(r)]),un(n.i,`t`,r),e.C=0,n=e.j.L,e.h=new bt,e.g=Kn(e.j,n?t:null,!e.u),e.P>0&&(e.O=new Ve(l(e.Y,e,e.g),e.P)),t=e.V,n=e.g,r=e.ba;var i=`readystatechange`;Array.isArray(i)||(i&&(Ue[0]=i.toString()),i=Ue);for(let e=0;e<i.length;e++){let a=De(n,i[e],r||t.handleEvent,!1,t.h||t);if(!a)break;t.g[a.key]=a}t=e.J?ye(e.J):{},e.u?(e.v||=`POST`,t[`Content-Type`]=`application/x-www-form-urlencoded`,e.g.ea(e.B,e.v,e.u,t)):(e.v=`GET`,e.g.ea(e.B,e.v,null,t)),rt(),ct(e.i,e.v,e.B,e.l,e.S,e.u)}yt.prototype.ba=function(e){e=e.target;let t=this.O;t&&I(e)==3?t.j():this.Y(e)},yt.prototype.Y=function(e){try{if(e==this.g)a:{let s=I(this.g),c=this.g.ya(),l=this.g.ca();if(!(s<3)&&(s!=3||this.g&&(this.h.h||this.g.la()||L(this.g)))){this.K||s!=4||c==7||rt(c==8||l<=0?3:2),At(this);var t=this.g.ca();this.X=t;var n=Tt(this);if(this.o=t==200,lt(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)&&!de(r)){var a=r;break b}}a=null}if(e=a)ut(this.i,this.l,e,`Initial handshake response via X-HTTP-Initial-Response`),this.L=!0,Nt(this,e);else{this.o=!1,this.m=3,b(12),Mt(this),jt(this);break a}}if(this.R){e=!0;let t;for(;!this.K&&this.C<n.length;)if(t=Dt(this,n),t==St){s==4&&(this.m=4,b(14),e=!1),ut(this.i,this.l,null,`[Incomplete Response]`);break}else if(t==xt){this.m=4,b(15),ut(this.i,this.l,n,`[Invalid Chunk]`),e=!1;break}else ut(this.i,this.l,t,null),Nt(this,t);if(Et(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,b(16),e=!1),this.o=this.o&&e,!e)ut(this.i,this.l,n,`[Invalid Chunked Response]`),Mt(this),jt(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),zn(o),o.P=!0,b(11))}}else ut(this.i,this.l,n,null),Nt(this,n);s==4&&Mt(this),this.o&&!this.K&&(s==4?Vn(this.j,this):(this.o=!1,Ot(this)))}else On(this.g),t==400&&n.indexOf(`Unknown SID`)>0?(this.m=3,b(12)):(this.m=0,b(13)),Mt(this),jt(this)}}}catch{}};function Tt(e){if(!Et(e))return e.g.la();let t=L(e.g);if(t===``)return``;let n=``,r=t.length,i=I(e.g)==4;if(!e.h.i){if(typeof TextDecoder>`u`)return Mt(e),jt(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 Et(e){return e.g?e.v==`GET`&&e.M!=2&&e.j.Aa:!1}function Dt(e,t){var n=e.C,r=t.indexOf(`
|
|
6
|
-
`,n);return r==-1?St:(n=Number(t.substring(n,r)),isNaN(n)?xt:(r+=1,r+n>t.length?St:(t=t.slice(r,r+n),e.C=r+n,t)))}yt.prototype.cancel=function(){this.K=!0,Mt(this)};function Ot(e){e.T=Date.now()+e.H,kt(e,e.H)}function kt(e,t){if(e.D!=null)throw Error(`WatchDog timer not null`);e.D=ot(l(e.aa,e),t)}function At(e){e.D&&=(o.clearTimeout(e.D),null)}yt.prototype.aa=function(){this.D=null;let e=Date.now();e-this.T>=0?(dt(this.i,this.B),this.M!=2&&(rt(),b(17)),Mt(this),this.m=2,jt(this)):kt(this,this.T-e)};function jt(e){e.j.I==0||e.K||Vn(e.j,e)}function Mt(e){At(e);var t=e.O;t&&typeof t.dispose==`function`&&t.dispose(),e.O=null,We(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.dispose())}function Nt(e,t){try{var n=e.j;if(n.I!=0&&(n.g==e||Rt(n.h,e))){if(!e.L&&Rt(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)Bn(n),z(n);else break a;Rn(n),b(18)}}else n.xa=i[1],0<n.xa-n.K&&i[2]<37500&&n.F&&n.A==0&&!n.C&&(n.C=ot(l(n.Va,n),6e3));Lt(n.h)<=1&&n.ta&&(n.ta=void 0)}else Un(n,11)}else if((e.L||n.g==e)&&Bn(n),!de(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&&=(zt(a,a.h),null))}if(r.G){let e=d.g?d.g.getResponseHeader(`X-HTTP-Session-Id`):null;e&&(r.wa=e,w(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=Gn(r,r.L?r.ba:null,r.W),o.L){Bt(r.h,o);var s=o,c=r.O;c&&(s.H=c),s.D&&(At(s),Ot(s)),r.g=o}else Ln(r);n.i.length>0&&Mn(n)}else l[0]!=`stop`&&l[0]!=`close`||Un(n,7);else n.I==3&&(l[0]==`stop`||l[0]==`close`?l[0]==`stop`?Un(n,7):R(n):l[0]!=`noop`&&n.l&&n.l.qa(l),n.A=0)}}rt(4)}catch{}}var Pt=class{constructor(e,t){this.g=e,this.map=t}};function Ft(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 It(e){return e.h?!0:e.g?e.g.size>=e.j:!1}function Lt(e){return e.h?1:e.g?e.g.size:0}function Rt(e,t){return e.h?e.h==t:e.g?e.g.has(t):!1}function zt(e,t){e.g?e.g.add(t):e.h=t}function Bt(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}Ft.prototype.cancel=function(){if(this.i=Vt(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 Vt(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 Ht=RegExp(`^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$`);function Ut(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 x(e){this.g=this.o=this.j=``,this.u=null,this.m=this.h=``,this.l=!1;let t;e instanceof x?(this.l=e.l,en(this,e.j),this.o=e.o,this.g=e.g,C(this,e.u),this.h=e.h,tn(this,dn(e.i)),this.m=e.m):e&&(t=String(e).match(Ht))?(this.l=!1,en(this,t[1]||``,!0),this.o=nn(t[2]||``),this.g=nn(t[3]||``,!0),C(this,t[4]),this.h=nn(t[5]||``,!0),tn(this,t[6]||``,!0),this.m=nn(t[7]||``)):(this.l=!1,this.i=new j(null,this.l))}x.prototype.toString=function(){let e=[];var t=this.j;t&&e.push(rn(t,an,!0),`:`);var n=this.g;return(n||t==`file`)&&(e.push(`//`),(t=this.o)&&e.push(rn(t,an,!0),`@`),e.push(_t(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(rn(n,n.charAt(0)==`/`?O:D,!0))),(n=this.i.toString())&&e.push(`?`,n),(n=this.m)&&e.push(`#`,rn(n,A)),e.join(``)},x.prototype.resolve=function(e){let t=S(this),n=!!e.j;n?en(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)C(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?tn(t,dn(e.i)):n=!!e.m,n&&(t.m=e.m),t};function S(e){return new x(e)}function en(e,t,n){e.j=n?nn(t,!0):t,e.j&&=e.j.replace(/:$/,``)}function C(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 tn(e,t,n){t instanceof j?(e.i=t,pn(e.i,e.l)):(n||(t=rn(t,k)),e.i=new j(t,e.l))}function w(e,t,n){e.i.set(t,n)}function T(e){return w(e,`zx`,Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),e}function nn(e,t){return e?t?decodeURI(e.replace(/%25/g,`%2525`)):decodeURIComponent(e):``}function rn(e,t,n){return typeof e==`string`?(e=encodeURI(e).replace(t,E),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,`%$1`)),e):null}function E(e){return e=e.charCodeAt(0),`%`+(e>>4&15).toString(16)+(e&15).toString(16)}var an=/[#\/\?@]/g,D=/[#\?:]/g,O=/[#\?]/g,k=/[#\?@]/g,A=/#/g;function j(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function on(e){e.g||(e.g=new Map,e.h=0,e.i&&Ut(e.i,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g,` `)),n)}))}e=j.prototype,e.add=function(e,t){on(this),this.i=null,e=fn(this,e);let n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this};function sn(e,t){on(e),t=fn(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function cn(e,t){return on(e),t=fn(e,t),e.g.has(t)}e.forEach=function(e,t){on(this),this.g.forEach(function(n,r){n.forEach(function(n){e.call(t,n,r,this)},this)},this)};function ln(e,t){on(e);let n=[];if(typeof t==`string`)cn(e,t)&&(n=n.concat(e.g.get(fn(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 on(this),this.i=null,e=fn(this,e),cn(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=ln(this,e),e.length>0?String(e[0]):t):t};function un(e,t,n){sn(e,t),n.length>0&&(e.i=null,e.g.set(fn(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=_t(n);n=ln(this,n);for(let t=0;t<n.length;t++){let r=i;n[t]!==``&&(r+=`=`+_t(n[t])),e.push(r)}}return this.i=e.join(`&`)};function dn(e){let t=new j;return t.i=e.i,e.g&&(t.g=new Map(e.g),t.h=e.h),t}function fn(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function pn(e,t){t&&!e.j&&(on(e),e.i=null,e.g.forEach(function(e,t){let n=t.toLowerCase();t!=n&&(sn(this,t),un(this,n,e))},e)),e.j=t}function mn(e,t){let n=new st;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 M(e,t){let n=new st,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 qe}function _n(e){this.i=e.Sb||null,this.h=e.ab||!1}d(_n,Je),_n.prototype.g=function(){return new vn(this.i,this.h)};function vn(e,t){v.call(this),this.H=e,this.o=t,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText=``,this.onreadystatechange=null,this.A=new Headers,this.h=null,this.F=`GET`,this.D=``,this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}d(vn,v),e=vn.prototype,e.open=function(e,t){if(this.readyState!=0)throw this.abort(),Error(`Error reopening a connection`);this.F=e,this.D=t,this.readyState=1,xn(this)},e.send=function(e){if(this.readyState!=1)throw this.abort(),Error(`need to call open() first. `);if(this.v.signal.aborted)throw this.abort(),Error(`Request was aborted.`);this.g=!0;let t={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};e&&(t.body=e),(this.H||o).fetch(new Request(this.D,t)).then(this.Pa.bind(this),this.ga.bind(this))},e.abort=function(){this.response=this.responseText=``,this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel(`Request was aborted.`).catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,bn(this)),this.readyState=0},e.Pa=function(e){if(this.g&&(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,xn(this)),this.g&&(this.readyState=3,xn(this),this.g)))if(this.responseType===`arraybuffer`)e.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(o.ReadableStream!==void 0&&`body`in e){if(this.j=e.body.getReader(),this.o){if(this.responseType)throw Error(`responseType must be empty for "streamBinaryChunks" mode responses.`);this.response=[]}else this.response=this.responseText=``,this.B=new TextDecoder;yn(this)}else e.text().then(this.Oa.bind(this),this.ga.bind(this))};function yn(e){e.j.read().then(e.Ma.bind(e)).catch(e.ga.bind(e))}e.Ma=function(e){if(this.g){if(this.o&&e.value)this.response.push(e.value);else if(!this.o){var t=e.value?e.value:new Uint8Array;(t=this.B.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?bn(this):xn(this),this.readyState==3&&yn(this)}},e.Oa=function(e){this.g&&(this.response=this.responseText=e,bn(this))},e.Na=function(e){this.g&&(this.response=e,bn(this))},e.ga=function(){this.g&&bn(this)};function bn(e){e.readyState=4,e.l=null,e.j=null,e.B=null,xn(e)}e.setRequestHeader=function(e,t){this.A.append(e,t)},e.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||``},e.getAllResponseHeaders=function(){if(!this.h)return``;let e=[],t=this.h.entries();for(var n=t.next();!n.done;)n=n.value,e.push(n[0]+`: `+n[1]),n=t.next();return e.join(`\r
|
|
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 N(e){let t=``;return _e(e,function(e,n){t+=n,t+=`:`,t+=e,t+=`\r
|
|
8
|
-
`}),t}function Sn(e,t,n){a:{for(r in n){var r=!1;break a}r=!0}r||(n=N(n),typeof e==`string`||w(e,t,n))}function P(e){v.call(this),this.headers=new Map,this.L=e||null,this.h=!1,this.g=null,this.D=``,this.o=0,this.l=``,this.j=this.B=this.v=this.A=!1,this.m=null,this.F=``,this.H=!1}d(P,v);var F=/^https?$/i,Cn=[`POST`,`PUT`];e=P.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():ht.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){wn(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(Cn,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){wn(this,e)}};function wn(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.o=5,Tn(e),Dn(e)}function Tn(e){e.A||(e.A=!0,y(e,`complete`),y(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,y(this,`complete`),y(this,`abort`),Dn(this))},e.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),Dn(this,!0)),P.Z.N.call(this)},e.Ca=function(){this.u||(this.B||this.v||this.j?En(this):this.Xa())},e.Xa=function(){En(this)};function En(e){if(e.h&&a!==void 0){if(e.v&&I(e)==4)setTimeout(e.Ca.bind(e),0);else if(y(e,`readystatechange`),I(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(Ht)[1]||null;!t&&o.self&&o.self.location&&(t=o.self.location.protocol.slice(0,-1)),r=!F.test(t?t.toLowerCase():``)}n=r}if(n)y(e,`complete`),y(e,`success`);else{e.o=6;try{var i=I(e)>2?e.g.statusText:``}catch{i=``}e.l=i+` [`+e.ca()+`]`,Tn(e)}}finally{Dn(e)}}}}function Dn(e,t){if(e.g){e.m&&=(clearTimeout(e.m),null);let n=e.g;e.g=null,t||y(e,`ready`);try{n.onreadystatechange=null}catch{}}}e.isActive=function(){return!!this.g};function I(e){return e.g?e.g.readyState:0}e.ca=function(){try{return I(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)),Ke(t)}};function L(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 On(e){let t={};e=(e.g&&I(e)>=2&&e.g.getAllResponseHeaders()||``).split(`\r
|
|
9
|
-
`);for(let r=0;r<e.length;r++){if(de(e[r]))continue;var n=vt(e[r]);let i=n[0];if(n=n[1],typeof n!=`string`)continue;n=n.trim();let a=t[i]||[];t[i]=a,a.push(n)}ve(t,function(e){return e.join(`, `)})}e.ya=function(){return this.o},e.Ha=function(){return typeof this.l==`string`?this.l:String(this.l)};function kn(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function An(e){this.za=0,this.i=[],this.j=new st,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=kn(`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=kn(`baseRetryDelayMs`,5e3,e),this.Za=kn(`retryDelaySeedMs`,1e4,e),this.Ta=kn(`forwardChannelMaxRetries`,2,e),this.va=kn(`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 Ft(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=An.prototype,e.ka=8,e.I=1,e.connect=function(e,t,n,r){b(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=Gn(this,null,this.W),Mn(this)};function R(e){if(jn(e),e.I==3){var t=e.V++,n=S(e.J);if(w(n,`SID`,e.M),w(n,`RID`,t),w(n,`TYPE`,`terminate`),Fn(e,n),t=new yt(e,e.j,t),t.M=2,t.A=T(S(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=Kn(t.j,null),t.g.ea(t.A)),t.F=Date.now(),Ot(t)}Wn(e)}function z(e){e.g&&=(zn(e),e.g.cancel(),null)}function jn(e){z(e),e.v&&=(o.clearTimeout(e.v),null),Bn(e),e.h.cancel(),e.m&&=(typeof e.m==`number`&&o.clearTimeout(e.m),null)}function Mn(e){if(!It(e.h)&&!e.m){e.m=!0;var t=e.Ea;ie||se(),ae||=(ie(),!0),oe.add(t,e),e.D=0}}function Nn(e,t){return Lt(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=ot(l(e.Ea,e,t),Hn(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 yt(this,this.j,e),a=this.o;if(this.U&&(a?(a=ye(a),xe(a,this.U)):a=this.U),this.u!==null||this.R||(i.J=a,a=null),this.S)a:{for(var t=0,n=0;n<this.i.length;n++){b:{var r=this.i[n];if(`__data__`in r.map&&(r=r.map.__data__,typeof r==`string`)){r=r.length;break b}r=void 0}if(r===void 0)break;if(t+=r,t>4096){t=n;break a}if(t===4096||n===this.i.length-1){t=n+1;break a}}t=1e3}else t=1e3;t=In(this,i,t),n=S(this.J),w(n,`RID`,e),w(n,`CVER`,22),this.G&&w(n,`X-HTTP-Session-Id`,this.G),Fn(this,n),a&&(this.R?t=`headers=`+_t(N(a))+`&`+t:this.u&&Sn(n,this.u,a)),zt(this.h,i),this.Ra&&w(n,`TYPE`,`init`),this.S?(w(n,`$req`,t),w(n,`SID`,`null`),i.U=!0,Ct(i,n,null)):Ct(i,n,t),this.I=2}}else this.I==3&&(e?Pn(this,e):this.i.length==0||It(this.h)||Pn(this))};function Pn(e,t){var n=t?t.l:e.V++;let r=S(e.J);w(r,`SID`,e.M),w(r,`RID`,n),w(r,`AID`,e.K),Fn(e,r),e.u&&e.o&&Sn(r,e.u,e.o),n=new yt(e,e.j,n,e.D+1),e.u===null&&(n.J=e.o),t&&(e.i=t.G.concat(e.i)),t=In(e,n,1e3),n.H=Math.round(e.va*.5)+Math.round(e.va*.5*Math.random()),zt(e.h,n),Ct(n,r,t)}function Fn(e,t){e.H&&_e(e.H,function(e,n){w(t,n,e)}),e.l&&_e({},function(e,n){w(t,n,e)})}function In(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=Ge(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 Ln(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 Rn(e){return e.g||e.v||e.A>=3?!1:(e.Y++,e.v=ot(l(e.Da,e),Hn(e,e.A)),e.A++,!0)}e.Da=function(){if(this.v=null,B(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=ot(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,b(10),z(this),B(this))};function zn(e){e.B!=null&&(o.clearTimeout(e.B),e.B=null)}function B(e){e.g=new yt(e,e.j,`rpc`,e.Y),e.u===null&&(e.g.J=e.o),e.g.P=0;var t=S(e.na);w(t,`RID`,`rpc`),w(t,`SID`,e.M),w(t,`AID`,e.K),w(t,`CI`,e.F?`0`:`1`),!e.F&&e.ia&&w(t,`TO`,e.ia),w(t,`TYPE`,`xmlhttp`),Fn(e,t),e.u&&e.o&&Sn(t,e.u,e.o),e.O&&(e.g.H=e.O);var n=e.g;e=e.ba,n.M=1,n.A=T(S(t)),n.u=null,n.R=!0,wt(n,e)}e.Va=function(){this.C!=null&&(this.C=null,z(this),Rn(this),b(19))};function Bn(e){e.C!=null&&(o.clearTimeout(e.C),e.C=null)}function Vn(e,t){var n=null;if(e.g==t){Bn(e),zn(e),e.g=null;var r=2}else if(Rt(e.h,t))n=t.G,Bt(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=tt(),y(r,new at(r,n)),Mn(e)}else Ln(e);else if(i=t.m,i==3||i==0&&t.X>0||!(r==1&&Nn(e,t)||r==2&&Rn(e)))switch(n&&n.length>0&&(t=e.h,t.i=t.i.concat(n)),i){case 1:Un(e,5);break;case 4:Un(e,10);break;case 3:Un(e,6);break;default:Un(e,2)}}}function Hn(e,t){let n=e.Qa+Math.floor(Math.random()*e.Za);return e.isActive()||(n*=2),n*t}function Un(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 x(r||`//www.google.com/images/cleardot.gif`),o.location&&o.location.protocol==`http`||en(r,`https`),T(r),t?mn(r.toString(),n):M(r.toString(),n)}else b(2);e.I=0,e.l&&e.l.pa(t),Wn(e),jn(e)}e.bb=function(e){e?(this.j.info(`Successfully pinged google.com`),b(2)):(this.j.info(`Failed to ping google.com`),b(1))};function Wn(e){if(e.I=0,e.ja=[],e.l){let t=Vt(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 Gn(e,t,n){var r=n instanceof x?S(n):new x(n);if(r.g!=``)t&&(r.g=t+`.`+r.g),C(r,r.u);else{var i=o.location;r=i.protocol,t=t?t+`.`+i.hostname:i.hostname,i=+i.port;let e=new x(null);r&&en(e,r),t&&(e.g=t),i&&C(e,i),n&&(e.h=n),r=e}return n=e.G,t=e.wa,n&&t&&w(r,n,t),w(r,`VER`,e.ka),Fn(e,r),r}function Kn(e,t,n){if(t&&!e.L)throw Error(`Can't create secondary domain capable XhrIo object.`);return t=e.Aa&&!e.ma?new P(new _n({ab:n})):new P(e.ma),t.Fa(e.L),t}e.isActive=function(){return!!this.l&&this.l.isActive(this)};function qn(){}e=qn.prototype,e.ra=function(){},e.qa=function(){},e.pa=function(){},e.oa=function(){},e.isActive=function(){return!0},e.Ka=function(){};function Jn(){}Jn.prototype.g=function(e,t){return new V(e,t)};function V(e,t){v.call(this),this.g=new An(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)&&!de(e)&&(this.g.u=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t&&=t.httpSessionIdParam)&&!de(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 H(this)}d(V,v),V.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},V.prototype.close=function(){R(this.g)},V.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__=Ge(e),e=n);t.i.push(new Pt(t.Ya++,e)),t.I==3&&Mn(t)},V.prototype.N=function(){this.g.l=null,delete this.j,R(this.g),delete this.g,V.Z.N.call(this)};function Yn(e){Ze.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){a:{for(let n in t){e=n;break a}e=void 0}(this.i=e)&&(e=this.i,t=t!==null&&e in t?t[e]:void 0),this.data=t}else this.data=e}d(Yn,Ze);function Xn(){Qe.call(this),this.status=1}d(Xn,Qe);function H(e){this.g=e}d(H,qn),H.prototype.ra=function(){y(this.g,`a`)},H.prototype.qa=function(e){y(this.g,new Yn(e))},H.prototype.pa=function(e){y(this.g,new Xn)},H.prototype.oa=function(){y(this.g,`b`)},Jn.prototype.createWebChannel=Jn.prototype.g,V.prototype.send=V.prototype.o,V.prototype.open=V.prototype.m,V.prototype.close=V.prototype.close,$t=Gt.createWebChannelTransport=function(){return new Jn},Qt=Gt.getStatEventTarget=function(){return tt()},Zt=Gt.Event=$e,Xt=Gt.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},pt.NO_ERROR=0,pt.TIMEOUT=8,pt.HTTP_ERROR=6,Yt=Gt.ErrorCode=pt,mt.COMPLETE=`complete`,Jt=Gt.EventType=mt,Ye.EventType=Xe,Xe.OPEN=`a`,Xe.CLOSE=`b`,Xe.ERROR=`c`,Xe.MESSAGE=`d`,v.prototype.listen=v.prototype.J,qt=Gt.WebChannel=Ye,Gt.FetchXmlHttpFactory=_n,P.prototype.listenOnce=P.prototype.K,P.prototype.getLastError=P.prototype.Ha,P.prototype.getLastErrorCode=P.prototype.ya,P.prototype.getStatus=P.prototype.ca,P.prototype.getResponseJson=P.prototype.La,P.prototype.getResponseText=P.prototype.la,P.prototype.send=P.prototype.ea,P.prototype.setWithCredentials=P.prototype.Fa,Kt=Gt.XhrIo=P}).apply(Wt===void 0?typeof self<`u`?self:typeof window<`u`?window:{}:Wt);var x=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}};x.UNAUTHENTICATED=new x(null),x.GOOGLE_CREDENTIALS=new x(`google-credentials-uid`),x.FIRST_PARTY=new x(`first-party-uid`),x.MOCK_USER=new x(`mock-user`);var S=`12.12.0`;function en(e){S=e}var C=new me(`@firebase/firestore`);function tn(){return C.logLevel}function w(e,...t){if(C.logLevel<=_.DEBUG){let n=t.map(rn);C.debug(`Firestore (${S}): ${e}`,...n)}}function T(e,...t){if(C.logLevel<=_.ERROR){let n=t.map(rn);C.error(`Firestore (${S}): ${e}`,...n)}}function nn(e,...t){if(C.logLevel<=_.WARN){let n=t.map(rn);C.warn(`Firestore (${S}): ${e}`,...n)}}function rn(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,an(e,r,n)}function an(e,t,n){let r=`FIRESTORE (${S}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(n!==void 0)try{r+=` CONTEXT: `+JSON.stringify(n)}catch{r+=` CONTEXT: `+n}throw T(r),Error(r)}function D(e,t,n,r){let i=`Unexpected state`;typeof n==`string`?i=n:r=n,e||an(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 ne{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}},j=class{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}},on=class{constructor(e,t){this.user=t,this.type=`OAuth`,this.headers=new Map,this.headers.set(`Authorization`,`Bearer ${e}`)}},sn=class{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(x.UNAUTHENTICATED)))}shutdown(){}},cn=class{constructor(e){this.t=e,this.currentUser=x.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 j;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new j,e.enqueueRetryable((()=>r(this.currentUser)))};let a=()=>{let t=i;e.enqueueRetryable((async()=>{await t.promise,await r(this.currentUser)}))},o=e=>{w(`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):(w(`FirebaseAuthCredentialsProvider`,`Auth not yet detected`),i.resolve(),i=new j)}}),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 on(t.accessToken,this.currentUser)):null:(w(`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 x(e)}},ln=class{constructor(e,t,n){this.P=e,this.T=t,this.I=n,this.type=`FirstParty`,this.user=x.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}},un=class{constructor(e,t,n){this.P=e,this.T=t,this.I=n}getToken(){return Promise.resolve(new ln(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable((()=>t(x.FIRST_PARTY)))}shutdown(){}invalidateToken(){}},dn=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)}},fn=class{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,yt(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){D(this.o===void 0,3512);let n=e=>{e.error!=null&&w(`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,w(`FirebaseAppCheckTokenProvider`,`Received ${n?`new`:`existing`} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable((()=>n(t)))};let r=e=>{w(`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):w(`FirebaseAppCheckTokenProvider`,`AppCheck not yet detected`)}}),0)}getToken(){if(this.p)return Promise.resolve(new dn(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 dn(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 pn(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 mn=class{static newId(){let e=``;for(;e.length<20;){let t=pn(40);for(let n=0;n<t.length;++n)e.length<20&&t[n]<248&&(e+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(t[n]%62))}return e}};function M(e,t){return e<t?-1:+(e>t)}function hn(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 vn(n)===vn(i)?M(n,i):vn(n)?1:-1}return M(e.length,t.length)}var gn=55296,_n=57343;function vn(e){let t=e.charCodeAt(0);return t>=gn&&t<=_n}function yn(e,t,n){return e.length===t.length&&e.every(((e,r)=>n(e,t[r])))}var bn=`__name__`,xn=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 M(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)):hn(t,n)}static isNumericId(e){return e.startsWith(`__id`)&&e.endsWith(`__`)}static extractNumericId(e){return Ht.fromString(e.substring(4,e.length-2))}},N=class e extends xn{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([])}},Sn=/^[_a-zA-Z][_a-zA-Z0-9]*$/,P=class e extends xn{construct(t,n,r){return new e(t,n,r)}static isValidIdentifier(e){return Sn.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([bn])}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([])}},F=class e{constructor(e){this.path=e}static fromPath(t){return new e(N.fromString(t))}static fromName(t){return new e(N.fromString(t).popFirst(5))}static empty(){return new e(N.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&&N.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return N.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(t){return new e(new N(t.slice()))}};function Cn(e,t,n){if(!n)throw new A(k.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function wn(e,t,n,r){if(!0===t&&!0===r)throw new A(k.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function Tn(e){if(F.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 En(e){return typeof e==`object`&&!!e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}function Dn(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 I(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=Dn(e);throw new A(k.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function L(e,t){let n={typeString:e};return t&&(n.value=t),n}function On(e,t){if(!En(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 kn=-62135596800,An=1e6,R=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)*An))}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<kn||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/An}_compareTo(e){return this.seconds===e.seconds?M(this.nanoseconds,e.nanoseconds):M(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(On(t,e._jsonSchema))return new e(t.seconds,t.nanoseconds)}valueOf(){let e=this.seconds-kn;return String(e).padStart(12,`0`)+`.`+String(this.nanoseconds).padStart(9,`0`)}};R._jsonSchemaVersion=`firestore/timestamp/1.0`,R._jsonSchema={type:L(`string`,R._jsonSchemaVersion),seconds:L(`number`),nanoseconds:L(`number`)};var z=class e{static fromTimestamp(t){return new e(t)}static min(){return new e(new R(0,0))}static max(){return new e(new R(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}},jn=-1,Mn=class{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}};Mn.UNKNOWN_ID=-1;function Nn(e,t){let n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1;return new Fn(z.fromTimestamp(r===1e9?new R(n+1,0):new R(n,r)),F.empty(),t)}function Pn(e){return new Fn(e.readTime,e.key,jn)}var Fn=class e{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new e(z.min(),F.empty(),jn)}static max(){return new e(z.max(),F.empty(),jn)}};function In(e,t){let n=e.readTime.compareTo(t.readTime);return n===0?(n=F.comparator(e.documentKey,t.documentKey),n===0?M(e.largestBatchId,t.largestBatchId):n):n}var Ln=`The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.`,Rn=class{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}};async function zn(e){if(e.code!==k.FAILED_PRECONDITION||e.message!==Ln)throw e;w(`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&&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 Bn(e){let t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(`.`).slice(0,2).join(`.`):`-1`;return Number(n)}function Vn(e){return e.name===`IndexedDbTransactionError`}var Hn=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}};Hn.ce=-1;var Un=-1;function Wn(e){return e==null}function Gn(e){return e===0&&1/e==-1/0}function Kn(e){return typeof e==`number`&&Number.isInteger(e)&&!Gn(e)&&e<=2**53-1&&e>=-(2**53-1)}var qn=``;function Jn(e){let t=``;for(let n=0;n<e.length;n++)t.length>0&&(t=Yn(t)),t=V(e.get(n),t);return Yn(t)}function V(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 qn:n+=``;break;default:n+=r}}return n}function Yn(e){return e+qn+``}function Xn(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function H(e,t){for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function Zn(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}var U=class e{constructor(e,t){this.comparator=e,this.root=t||$n.EMPTY}insert(t,n){return new e(this.comparator,this.root.insert(t,n,this.comparator).copy(null,null,$n.BLACK,null,null))}remove(t){return new e(this.comparator,this.root.remove(t,this.comparator).copy(null,null,$n.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 Qn(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Qn(this.root,e,this.comparator,!1)}getReverseIterator(){return new Qn(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Qn(this.root,e,this.comparator,!0)}},Qn=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}}},$n=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()}};$n.EMPTY=null,$n.RED=!0,$n.BLACK=!1,$n.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 $n(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 W=class e{constructor(e){this.comparator=e,this.data=new U(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 er(this.data.getIterator())}getIteratorFrom(e){return new er(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}},er=class{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}},tr=class e{constructor(e){this.fields=e,e.sort(P.comparator)}static empty(){return new e([])}unionWith(t){let n=new W(P.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 yn(this.fields,e.fields,((e,t)=>e.isEqual(t)))}},nr=class extends Error{constructor(){super(...arguments),this.name=`Base64DecodeError`}},G=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 nr(`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 M(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}};G.EMPTY_BYTE_STRING=new G(``);var rr=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ir(e){if(D(!!e,39018),typeof e==`string`){let t=0,n=rr.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:K(e.seconds),nanos:K(e.nanos)}}function K(e){return typeof e==`number`?e:typeof e==`string`?Number(e):0}function ar(e){return typeof e==`string`?G.fromBase64String(e):G.fromUint8Array(e)}var or=`server_timestamp`,sr=`__type__`,cr=`__previous_value__`,lr=`__local_write_time__`;function ur(e){return(e?.mapValue?.fields||{})[sr]?.stringValue===or}function dr(e){let t=e.mapValue.fields[cr];return ur(t)?dr(t):t}function fr(e){let t=ir(e.mapValue.fields[lr].timestampValue);return new R(t.seconds,t.nanos)}var pr=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}},mr=`(default)`,hr=class e{constructor(e,t){this.projectId=e,this.database=t||mr}static empty(){return new e(``,``)}get isDefaultDatabase(){return this.database===mr}isEqual(t){return t instanceof e&&t.projectId===this.projectId&&t.database===this.database}};function gr(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,[`projectId`]))throw new A(k.INVALID_ARGUMENT,`"projectId" not provided in firebase.initializeApp.`);return new hr(e.options.projectId,t)}var _r=`__type__`,vr=`__max__`,yr={mapValue:{fields:{__type__:{stringValue:vr}}}},br=`__vector__`,xr=`value`;function Sr(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?ur(e)?4:zr(e)?9007199254740991:Lr(e)?10:11:E(28295,{value:e})}function Cr(e,t){if(e===t)return!0;let n=Sr(e);if(n!==Sr(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return fr(e).isEqual(fr(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=ir(e.timestampValue),r=ir(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 ar(e.bytesValue).isEqual(ar(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return K(e.geoPointValue.latitude)===K(t.geoPointValue.latitude)&&K(e.geoPointValue.longitude)===K(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if(`integerValue`in e&&`integerValue`in t)return K(e.integerValue)===K(t.integerValue);if(`doubleValue`in e&&`doubleValue`in t){let n=K(e.doubleValue),r=K(t.doubleValue);return n===r?Gn(n)===Gn(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return yn(e.arrayValue.values||[],t.arrayValue.values||[],Cr);case 10:case 11:return function(e,t){let n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(Xn(n)!==Xn(r))return!1;for(let e in n)if(n.hasOwnProperty(e)&&(r[e]===void 0||!Cr(n[e],r[e])))return!1;return!0}(e,t);default:return E(52216,{left:e})}}function wr(e,t){return(e.values||[]).find((e=>Cr(e,t)))!==void 0}function Tr(e,t){if(e===t)return 0;let n=Sr(e),r=Sr(t);if(n!==r)return M(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return M(e.booleanValue,t.booleanValue);case 2:return function(e,t){let n=K(e.integerValue||e.doubleValue),r=K(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 Er(e.timestampValue,t.timestampValue);case 4:return Er(fr(e),fr(t));case 5:return hn(e.stringValue,t.stringValue);case 6:return function(e,t){let n=ar(e),r=ar(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=M(n[e],r[e]);if(t!==0)return t}return M(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){let n=M(K(e.latitude),K(t.latitude));return n===0?M(K(e.longitude),K(t.longitude)):n}(e.geoPointValue,t.geoPointValue);case 9:return Dr(e.arrayValue,t.arrayValue);case 10:return function(e,t){let n=e.fields||{},r=t.fields||{},i=n[xr]?.arrayValue,a=r[xr]?.arrayValue,o=M(i?.values?.length||0,a?.values?.length||0);return o===0?Dr(i,a):o}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===yr.mapValue&&t===yr.mapValue)return 0;if(e===yr.mapValue)return 1;if(t===yr.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=hn(r[e],a[e]);if(t!==0)return t;let o=Tr(n[r[e]],i[a[e]]);if(o!==0)return o}return M(r.length,a.length)}(e.mapValue,t.mapValue);default:throw E(23264,{he:n})}}function Er(e,t){if(typeof e==`string`&&typeof t==`string`&&e.length===t.length)return M(e,t);let n=ir(e),r=ir(t),i=M(n.seconds,r.seconds);return i===0?M(n.nanos,r.nanos):i}function Dr(e,t){let n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){let t=Tr(n[e],r[e]);if(t)return t}return M(n.length,r.length)}function Or(e){return kr(e)}function kr(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=ir(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):`stringValue`in e?e.stringValue:`bytesValue`in e?function(e){return ar(e).toBase64()}(e.bytesValue):`referenceValue`in e?function(e){return F.fromName(e).toString()}(e.referenceValue):`geoPointValue`in e?function(e){return`geo(${e.latitude},${e.longitude})`}(e.geoPointValue):`arrayValue`in e?function(e){let t=`[`,n=!0;for(let r of e.values||[])n?n=!1:t+=`,`,t+=kr(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}:${kr(e.fields[i])}`;return n+`}`}(e.mapValue):E(61005,{value:e})}function Ar(e){switch(Sr(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let t=dr(e);return t?16+Ar(t):16;case 5:return 2*e.stringValue.length;case 6:return ar(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return function(e){return(e.values||[]).reduce(((e,t)=>e+Ar(t)),0)}(e.arrayValue);case 10:case 11:return function(e){let t=0;return H(e.fields,((e,n)=>{t+=e.length+Ar(n)})),t}(e.mapValue);default:throw E(13486,{value:e})}}function jr(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Mr(e){return!!e&&`integerValue`in e}function Nr(e){return!!e&&`arrayValue`in e}function Pr(e){return!!e&&`nullValue`in e}function Fr(e){return!!e&&`doubleValue`in e&&isNaN(Number(e.doubleValue))}function Ir(e){return!!e&&`mapValue`in e}function Lr(e){return(e?.mapValue?.fields||{})[_r]?.stringValue===br}function Rr(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 H(e.mapValue.fields,((e,n)=>t.mapValue.fields[e]=Rr(n))),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=Rr(e.arrayValue.values[n]);return t}return{...e}}function zr(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===vr}var Br=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)],!Ir(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=Rr(t)}setAll(e){let t=P.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()]=Rr(e):r.push(i.lastSegment())}));let i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){let t=this.field(e.popLast());Ir(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Cr(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)];Ir(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){H(t,((t,n)=>e[t]=n));for(let t of n)delete e[t]}clone(){return new e(Rr(this.value))}},Vr=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(),Br.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(),Br.empty(),0)}static newUnknownDocument(t,n){return new e(t,3,n,z.min(),z.min(),Br.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=Br.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=Br.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}})`}},Hr=class{constructor(e,t){this.position=e,this.inclusive=t}};function Ur(e,t,n){let r=0;for(let i=0;i<e.position.length;i++){let a=t[i],o=e.position[i];if(r=a.field.isKeyField()?F.comparator(F.fromName(o.referenceValue),n.key):Tr(o,n.data.field(a.field)),a.dir===`desc`&&(r*=-1),r!==0)break}return r}function Wr(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(!Cr(e.position[n],t.position[n]))return!1;return!0}var Gr=class{constructor(e,t=`asc`){this.field=e,this.dir=t}};function Kr(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}var qr=class{},q=class e extends qr{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 ti(t,n,r):n===`array-contains`?new ai(t,r):n===`in`?new oi(t,r):n===`not-in`?new si(t,r):n===`array-contains-any`?new ci(t,r):new e(t,n,r)}static createKeyFieldInFilter(e,t,n){return t===`in`?new ni(e,n):new ri(e,n)}matches(e){let t=e.data.field(this.field);return this.op===`!=`?t!==null&&t.nullValue===void 0&&this.matchesComparison(Tr(t,this.value)):t!==null&&Sr(this.value)===Sr(t)&&this.matchesComparison(Tr(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]}},Jr=class e extends qr{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 Yr(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 Yr(e){return e.op===`and`}function Xr(e){return Zr(e)&&Yr(e)}function Zr(e){for(let t of e.filters)if(t instanceof Jr)return!1;return!0}function Qr(e){if(e instanceof q)return e.field.canonicalString()+e.op.toString()+Or(e.value);if(Xr(e))return e.filters.map((e=>Qr(e))).join(`,`);{let t=e.filters.map((e=>Qr(e))).join(`,`);return`${e.op}(${t})`}}function $r(e,t){return e instanceof q?function(e,t){return t instanceof q&&e.op===t.op&&e.field.isEqual(t.field)&&Cr(e.value,t.value)}(e,t):e instanceof Jr?function(e,t){return t instanceof Jr&&e.op===t.op&&e.filters.length===t.filters.length?e.filters.reduce(((e,n,r)=>e&&$r(n,t.filters[r])),!0):!1}(e,t):void E(19439)}function ei(e){return e instanceof q?function(e){return`${e.field.canonicalString()} ${e.op} ${Or(e.value)}`}(e):e instanceof Jr?function(e){return e.op.toString()+` {`+e.getFilters().map(ei).join(` ,`)+`}`}(e):`Filter`}var ti=class extends q{constructor(e,t,n){super(e,t,n),this.key=F.fromName(n.referenceValue)}matches(e){let t=F.comparator(e.key,this.key);return this.matchesComparison(t)}},ni=class extends q{constructor(e,t){super(e,`in`,t),this.keys=ii(`in`,t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}},ri=class extends q{constructor(e,t){super(e,`not-in`,t),this.keys=ii(`not-in`,t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}};function ii(e,t){return(t.arrayValue?.values||[]).map((e=>F.fromName(e.referenceValue)))}var ai=class extends q{constructor(e,t){super(e,`array-contains`,t)}matches(e){let t=e.data.field(this.field);return Nr(t)&&wr(t.arrayValue,this.value)}},oi=class extends q{constructor(e,t){super(e,`in`,t)}matches(e){let t=e.data.field(this.field);return t!==null&&wr(this.value.arrayValue,t)}},si=class extends q{constructor(e,t){super(e,`not-in`,t)}matches(e){if(wr(this.value.arrayValue,{nullValue:`NULL_VALUE`}))return!1;let t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!wr(this.value.arrayValue,t)}},ci=class extends q{constructor(e,t){super(e,`array-contains-any`,t)}matches(e){let t=e.data.field(this.field);return!(!Nr(t)||!t.arrayValue.values)&&t.arrayValue.values.some((e=>wr(this.value.arrayValue,e)))}},li=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 ui(e,t=null,n=[],r=[],i=null,a=null,o=null){return new li(e,t,n,r,i,a,o)}function di(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=>Qr(e))).join(`,`),e+=`|ob:`,e+=t.orderBy.map((e=>function(e){return e.field.canonicalString()+e.dir}(e))).join(`,`),Wn(t.limit)||(e+=`|l:`,e+=t.limit),t.startAt&&(e+=`|lb:`,e+=t.startAt.inclusive?`b:`:`a:`,e+=t.startAt.position.map((e=>Or(e))).join(`,`)),t.endAt&&(e+=`|ub:`,e+=t.endAt.inclusive?`a:`:`b:`,e+=t.endAt.position.map((e=>Or(e))).join(`,`)),t.Te=e}return t.Te}function fi(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(!Kr(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(!$r(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!Wr(e.startAt,t.startAt)&&Wr(e.endAt,t.endAt)}function pi(e){return F.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}var mi=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 hi(e,t,n,r,i,a,o,s){return new mi(e,t,n,r,i,a,o,s)}function gi(e){return new mi(e)}function _i(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 vi(e){return F.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}function yi(e){return e.collectionGroup!==null}function bi(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 W(P.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 Gr(r,n))})),e.has(P.keyField().canonicalString())||t.Ee.push(new Gr(P.keyField(),n))}return t.Ee}function xi(e){let t=O(e);return t.Ie||=Si(t,bi(e)),t.Ie}function Si(e,t){if(e.limitType===`F`)return ui(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 Gr(e.field,t)}));let n=e.endAt?new Hr(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new Hr(e.startAt.position,e.startAt.inclusive):null;return ui(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function Ci(e,t){let n=e.filters.concat([t]);return new mi(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function wi(e,t,n){return new mi(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function Ti(e,t){return fi(xi(e),xi(t))&&e.limitType===t.limitType}function Ei(e){return`${di(xi(e))}|lt:${e.limitType}`}function Di(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=>ei(e))).join(`, `)}]`),Wn(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=>Or(e))).join(`,`)),e.endAt&&(t+=`, endAt: `,t+=e.endAt.inclusive?`a:`:`b:`,t+=e.endAt.position.map((e=>Or(e))).join(`,`)),`Target(${t})`}(xi(e))}; limitType=${e.limitType})`}function Oi(e,t){return t.isFoundDocument()&&function(e,t){let n=t.key.path;return e.collectionGroup===null?F.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n):t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n)}(e,t)&&function(e,t){for(let n of bi(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=Ur(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,bi(e),t)||e.endAt&&!function(e,t,n){let r=Ur(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,bi(e),t))}(e,t)}function ki(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function Ai(e){return(t,n)=>{let r=!1;for(let i of bi(e)){let e=ji(i,t,n);if(e!==0)return e;r||=i.field.isKeyField()}return 0}}function ji(e,t,n){let r=e.field.isKeyField()?F.comparator(t.key,n.key):function(e,t,n){let r=t.data.field(e),i=n.data.field(e);return r!==null&&i!==null?Tr(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 Mi=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){H(this.inner,((t,n)=>{for(let[t,r]of n)e(t,r)}))}isEmpty(){return Zn(this.inner)}size(){return this.innerSize}},Ni=new U(F.comparator);function Pi(){return Ni}var Fi=new U(F.comparator);function Ii(...e){let t=Fi;for(let n of e)t=t.insert(n.key,n);return t}function Li(e){let t=Fi;return e.forEach(((e,n)=>t=t.insert(e,n.overlayedDocument))),t}function Ri(){return Bi()}function zi(){return Bi()}function Bi(){return new Mi((e=>e.toString()),((e,t)=>e.isEqual(t)))}new U(F.comparator);var Vi=new W(F.comparator);function J(...e){let t=Vi;for(let n of e)t=t.add(n);return t}var Hi=new W(M);function Ui(){return Hi}function Wi(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:Gn(t)?`-0`:t}}function Gi(e){return{integerValue:``+e}}function Ki(e,t){return Kn(t)?Gi(t):Wi(e,t)}var qi=class{constructor(){this._=void 0}};function Ji(e,t,n){return e instanceof Zi?function(e,t){let n={fields:{[sr]:{stringValue:or},[lr]:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&ur(t)&&(t=dr(t)),t&&(n.fields[cr]=t),{mapValue:n}}(n,t):e instanceof Qi?$i(e,t):e instanceof ea?ta(e,t):function(e,t){let n=Xi(e,t),r=ra(n)+ra(e.Ae);return Mr(n)&&Mr(e.Ae)?Gi(r):Wi(e.serializer,r)}(e,t)}function Yi(e,t,n){return e instanceof Qi?$i(e,t):e instanceof ea?ta(e,t):n}function Xi(e,t){return e instanceof na?function(e){return Mr(e)||function(e){return!!e&&`doubleValue`in e}(e)}(t)?t:{integerValue:0}:null}var Zi=class extends qi{},Qi=class extends qi{constructor(e){super(),this.elements=e}};function $i(e,t){let n=ia(t);for(let t of e.elements)n.some((e=>Cr(e,t)))||n.push(t);return{arrayValue:{values:n}}}var ea=class extends qi{constructor(e){super(),this.elements=e}};function ta(e,t){let n=ia(t);for(let t of e.elements)n=n.filter((e=>!Cr(e,t)));return{arrayValue:{values:n}}}var na=class extends qi{constructor(e,t){super(),this.serializer=e,this.Ae=t}};function ra(e){return K(e.integerValue||e.doubleValue)}function ia(e){return Nr(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}var aa=class{constructor(e,t){this.field=e,this.transform=t}};function oa(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof Qi&&t instanceof Qi||e instanceof ea&&t instanceof ea?yn(e.elements,t.elements,Cr):e instanceof na&&t instanceof na?Cr(e.Ae,t.Ae):e instanceof Zi&&t instanceof Zi}(e.transform,t.transform)}var sa=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 ca(e,t){return e.updateTime===void 0?e.exists===void 0||e.exists===t.isFoundDocument():t.isFoundDocument()&&t.version.isEqual(e.updateTime)}var la=class{};function ua(e,t){if(!e.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return e.isNoDocument()?new ya(e.key,sa.none()):new ma(e.key,e.data,sa.none());{let n=e.data,r=Br.empty(),i=new W(P.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 ha(e.key,r,new tr(i.toArray()),sa.none())}}function da(e,t,n){e instanceof ma?function(e,t,n){let r=e.value.clone(),i=_a(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof ha?function(e,t,n){if(!ca(e.precondition,t))return void t.convertToUnknownDocument(n.version);let r=_a(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(ga(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 fa(e,t,n,r){return e instanceof ma?function(e,t,n,r){if(!ca(e.precondition,t))return n;let i=e.value.clone(),a=va(e.fieldTransforms,r,t);return i.setAll(a),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof ha?function(e,t,n,r){if(!ca(e.precondition,t))return n;let i=va(e.fieldTransforms,r,t),a=t.data;return a.setAll(ga(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 ca(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function pa(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)&&yn(e,t,((e,t)=>oa(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 ma=class extends la{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}},ha=class extends la{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 ga(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 _a(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,Yi(o,s,n[i]))}return r}function va(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,Ji(e,a,t))}return r}var ya=class extends la{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}},ba=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)&&da(r,e,n[t])}}applyToLocalView(e,t){for(let n of this.baseMutations)n.key.isEqual(e.key)&&(t=fa(n,e,t,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(e.key)&&(t=fa(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let n=zi();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=ua(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)),J())}isEqual(e){return this.batchId===e.batchId&&yn(this.mutations,e.mutations,((e,t)=>pa(e,t)))&&yn(this.baseMutations,e.baseMutations,((e,t)=>pa(e,t)))}},xa=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 }`}},Sa=class{constructor(e,t){this.count=e,this.unchangedNames=t}},Y,X;function Ca(e){if(e===void 0)return T(`GRPC error has no .code`),k.UNKNOWN;switch(e){case Y.OK:return k.OK;case Y.CANCELLED:return k.CANCELLED;case Y.UNKNOWN:return k.UNKNOWN;case Y.DEADLINE_EXCEEDED:return k.DEADLINE_EXCEEDED;case Y.RESOURCE_EXHAUSTED:return k.RESOURCE_EXHAUSTED;case Y.INTERNAL:return k.INTERNAL;case Y.UNAVAILABLE:return k.UNAVAILABLE;case Y.UNAUTHENTICATED:return k.UNAUTHENTICATED;case Y.INVALID_ARGUMENT:return k.INVALID_ARGUMENT;case Y.NOT_FOUND:return k.NOT_FOUND;case Y.ALREADY_EXISTS:return k.ALREADY_EXISTS;case Y.PERMISSION_DENIED:return k.PERMISSION_DENIED;case Y.FAILED_PRECONDITION:return k.FAILED_PRECONDITION;case Y.ABORTED:return k.ABORTED;case Y.OUT_OF_RANGE:return k.OUT_OF_RANGE;case Y.UNIMPLEMENTED:return k.UNIMPLEMENTED;case Y.DATA_LOSS:return k.DATA_LOSS;default:return E(39323,{code:e})}}(X=Y||={})[X.OK=0]=`OK`,X[X.CANCELLED=1]=`CANCELLED`,X[X.UNKNOWN=2]=`UNKNOWN`,X[X.INVALID_ARGUMENT=3]=`INVALID_ARGUMENT`,X[X.DEADLINE_EXCEEDED=4]=`DEADLINE_EXCEEDED`,X[X.NOT_FOUND=5]=`NOT_FOUND`,X[X.ALREADY_EXISTS=6]=`ALREADY_EXISTS`,X[X.PERMISSION_DENIED=7]=`PERMISSION_DENIED`,X[X.UNAUTHENTICATED=16]=`UNAUTHENTICATED`,X[X.RESOURCE_EXHAUSTED=8]=`RESOURCE_EXHAUSTED`,X[X.FAILED_PRECONDITION=9]=`FAILED_PRECONDITION`,X[X.ABORTED=10]=`ABORTED`,X[X.OUT_OF_RANGE=11]=`OUT_OF_RANGE`,X[X.UNIMPLEMENTED=12]=`UNIMPLEMENTED`,X[X.INTERNAL=13]=`INTERNAL`,X[X.UNAVAILABLE=14]=`UNAVAILABLE`,X[X.DATA_LOSS=15]=`DATA_LOSS`;var wa=null;function Ta(){return new TextEncoder}var Ea=new Ht([4294967295,4294967295],0);function Da(e){let t=Ta().encode(e),n=new Ut;return n.update(t),new Uint8Array(n.digest())}function Oa(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 Ht([n,r],0),new Ht([i,a],0)]}var ka=class e{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new Aa(`Invalid padding: ${t}`);if(n<0||e.length>0&&this.hashCount===0)throw new Aa(`Invalid hash count: ${n}`);if(e.length===0&&t!==0)throw new Aa(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=Ht.fromNumber(this.ge)}ye(e,t,n){let r=e.add(t.multiply(Ht.fromNumber(n)));return r.compare(Ea)===1&&(r=new Ht([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]=Oa(Da(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]=Oa(Da(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}},Aa=class extends Error{constructor(){super(...arguments),this.name=`BloomFilterError`}},ja=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,Ma.createSynthesizedTargetChangeForCurrentChange(t,n,r)),new e(z.min(),i,new U(M),Pi(),J())}},Ma=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,J(),J(),J())}},Na=class{constructor(e,t,n,r){this.be=e,this.removedTargetIds=t,this.key=n,this.De=r}},Pa=class{constructor(e,t){this.targetId=e,this.Ce=t}},Fa=class{constructor(e,t,n=G.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}},Ia=class{constructor(){this.ve=0,this.Fe=za(),this.Me=G.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=J(),t=J(),n=J();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 Ma(this.Me,this.xe,e,t,n)}qe(){this.Oe=!1,this.Fe=za()}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}},La=class{constructor(e){this.Ge=e,this.ze=new Map,this.je=Pi(),this.Je=Ra(),this.He=Ra(),this.Ze=new U(M)}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(pi(i))if(n===0){let e=new F(i.path);this.et(t,e,Vr.newNoDocument(e,z.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)}wa?.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=ar(n).toUint8Array()}catch(e){if(e instanceof nr)return nn(`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 ka(a,r,i)}catch(e){return nn(e instanceof Aa?`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&&pi(i.target)){let t=new F(i.target.path);this.Et(t).has(r)||this.It(r,t)||this.et(r,t,Vr.newNoDocument(t,e))}n.Be&&(t.set(r,n.ke()),n.qe())}}));let n=J();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 ja(e,t,this.Ze,this.je,n);return this.je=Pi(),this.Je=Ra(),this.He=Ra(),this.Ze=new U(M),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 Ia,this.ze.set(e,t)),t}Rt(e){let t=this.He.get(e);return t||(t=new W(M),this.He=this.He.insert(e,t)),t}Et(e){let t=this.Je.get(e);return t||(t=new W(M),this.Je=this.Je.insert(e,t)),t}rt(e){let t=this.ot(e)!==null;return t||w(`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 Ia),this.Ge.getRemoteKeysForTarget(e).forEach((t=>{this.et(e,t,null)}))}It(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}};function Ra(){return new U(F.comparator)}function za(){return new U(F.comparator)}var Ba={asc:`ASCENDING`,desc:`DESCENDING`},Va={"<":`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`},Ha={and:`AND`,or:`OR`},Ua=class{constructor(e,t){this.databaseId=e,this.useProto3Json=t}};function Wa(e,t){return e.useProto3Json||Wn(t)?t:{value:t}}function Ga(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 Ka(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function qa(e){return D(!!e,49232),z.fromTimestamp(function(e){let t=ir(e);return new R(t.seconds,t.nanos)}(e))}function Ja(e,t){return Ya(e,t).canonicalString()}function Ya(e,t){let n=function(e){return new N([`projects`,e.projectId,`databases`,e.database])}(e).child(`documents`);return t===void 0?n:n.child(t)}function Xa(e){let t=N.fromString(e);return D(ho(t),10190,{key:t.toString()}),t}function Za(e,t){let n=Xa(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 F(to(n))}function Qa(e,t){return Ja(e.databaseId,t)}function $a(e){let t=Xa(e);return t.length===4?N.emptyPath():to(t)}function eo(e){return new N([`projects`,e.databaseId.projectId,`databases`,e.databaseId.database]).canonicalString()}function to(e){return D(e.length>4&&e.get(4)===`documents`,29091,{key:e.toString()}),e.popFirst(5)}function no(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),G.fromBase64String(t||``)):(D(t===void 0||t instanceof Buffer||t instanceof Uint8Array,16193),G.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),o=t.targetChange.cause;n=new Fa(r,i,a,o&&function(e){return new A(e.code===void 0?k.UNKNOWN:Ca(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=Za(e,r.document.name),a=qa(r.document.updateTime),o=r.document.createTime?qa(r.document.createTime):z.min(),s=new Br({mapValue:{fields:r.document.fields}}),c=Vr.newFoundDocument(i,a,o,s);n=new Na(r.targetIds||[],r.removedTargetIds||[],c.key,c)}else if(`documentDelete`in t){t.documentDelete;let r=t.documentDelete;r.document;let i=Za(e,r.document),a=r.readTime?qa(r.readTime):z.min(),o=Vr.newNoDocument(i,a);n=new Na([],r.removedTargetIds||[],o.key,o)}else if(`documentRemove`in t){t.documentRemove;let r=t.documentRemove;r.document;let i=Za(e,r.document);n=new Na([],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 Sa(r,i),o=e.targetId;n=new Pa(o,a)}}return n}function ro(e,t){return{documents:[Qa(e,t.path)]}}function io(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=Qa(e,i);let a=function(e){if(e.length!==0)return mo(Jr.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:fo(e.field),direction:co(e.dir)}}(e)))}(t.orderBy);o&&(n.structuredQuery.orderBy=o);let s=Wa(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 ao(e){let t=$a(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=so(e);return t instanceof Jr&&Xr(t)?t.getFilters():[t]}(n.where));let o=[];n.orderBy&&(o=function(e){return e.map((e=>function(e){return new Gr(po(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,Wn(t)?null:t}(n.limit));let c=null;n.startAt&&(c=function(e){let t=!!e.before;return new Hr(e.values||[],t)}(n.startAt));let l=null;return n.endAt&&(l=function(e){let t=!e.before;return new Hr(e.values||[],t)}(n.endAt)),hi(t,i,o,a,s,`F`,c,l)}function oo(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 so(e){return e.unaryFilter===void 0?e.fieldFilter===void 0?e.compositeFilter===void 0?E(30097,{filter:e}):function(e){return Jr.create(e.compositeFilter.filters.map((e=>so(e))),function(e){switch(e){case`AND`:return`and`;case`OR`:return`or`;default:return E(1026)}}(e.compositeFilter.op))}(e):function(e){return q.create(po(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=po(e.unaryFilter.field);return q.create(t,`==`,{doubleValue:NaN});case`IS_NULL`:let n=po(e.unaryFilter.field);return q.create(n,`==`,{nullValue:`NULL_VALUE`});case`IS_NOT_NAN`:let r=po(e.unaryFilter.field);return q.create(r,`!=`,{doubleValue:NaN});case`IS_NOT_NULL`:let i=po(e.unaryFilter.field);return q.create(i,`!=`,{nullValue:`NULL_VALUE`});case`OPERATOR_UNSPECIFIED`:return E(61313);default:return E(60726)}}(e)}function co(e){return Ba[e]}function lo(e){return Va[e]}function uo(e){return Ha[e]}function fo(e){return{fieldPath:e.canonicalString()}}function po(e){return P.fromServerFormat(e.fieldPath)}function mo(e){return e instanceof q?function(e){if(e.op===`==`){if(Fr(e.value))return{unaryFilter:{field:fo(e.field),op:`IS_NAN`}};if(Pr(e.value))return{unaryFilter:{field:fo(e.field),op:`IS_NULL`}}}else if(e.op===`!=`){if(Fr(e.value))return{unaryFilter:{field:fo(e.field),op:`IS_NOT_NAN`}};if(Pr(e.value))return{unaryFilter:{field:fo(e.field),op:`IS_NOT_NULL`}}}return{fieldFilter:{field:fo(e.field),op:lo(e.op),value:e.value}}}(e):e instanceof Jr?function(e){let t=e.getFilters().map((e=>mo(e)));return t.length===1?t[0]:{compositeFilter:{op:uo(e.op),filters:t}}}(e):E(54877,{filter:e})}function ho(e){return e.length>=4&&e.get(0)===`projects`&&e.get(2)===`databases`}function go(e){return!!e&&typeof e._toProto==`function`&&e._protoValueType===`ProtoValue`}var _o=class e{constructor(e,t,n,r,i=z.min(),a=z.min(),o=G.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)}},vo=class{constructor(e){this.yt=e}};function yo(e){let t=ao({parent:e.parent,structuredQuery:e.structuredQuery});return e.limitType===`LAST`?wi(t,t.limit,`L`):t}var bo=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);else if(`integerValue`in e)this.Ft(t,15),t.Mt(K(e.integerValue));else if(`doubleValue`in e){let n=K(e.doubleValue);isNaN(n)?this.Ft(t,13):(this.Ft(t,15),Gn(n)?t.Mt(0):t.Mt(n))}else if(`timestampValue`in e){let n=e.timestampValue;this.Ft(t,20),typeof n==`string`&&(n=ir(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(ar(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?zr(e)?this.Ft(t,2**53-1):Lr(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=xr,i=n[r].arrayValue?.values?.length||0;this.Ft(t,15),t.Mt(K(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),F.fromName(e).path.forEach((e=>{this.Ft(t,60),this.$t(e,t)}))}Ft(e,t){e.Mt(t)}Nt(e){e.Mt(2)}};bo.Wt=new bo;var xo=class{constructor(){this.bn=new So}addToCollectionParentIndex(e,t){return this.bn.add(t),B.resolve()}getCollectionParents(e,t){return B.resolve(this.bn.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(Fn.min())}getMinOffsetFromCollectionGroup(e,t){return B.resolve(Fn.min())}updateCollectionGroup(e,t,n){return B.resolve()}updateIndexEntries(e,t){return B.resolve()}},So=class{constructor(){this.index={}}add(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new W(N.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 W(N.comparator)).toArray()}},Co={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},wo=41943040,To=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}};To.DEFAULT_COLLECTION_PERCENTILE=10,To.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,To.DEFAULT=new To(wo,To.DEFAULT_COLLECTION_PERCENTILE,To.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),To.DISABLED=new To(-1,0,0);var Eo=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)}},Do=`LruGarbageCollector`,Oo=1048576;function ko([e,t],[n,r]){let i=M(e,n);return i===0?M(t,r):i}var Ao=class{constructor(e){this.Pr=e,this.buffer=new W(ko),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();ko(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}},jo=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){w(Do,`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){Vn(e)?w(Do,`Ignoring IndexedDB error during garbage collection: `,e):await zn(e)}await this.Ar(3e5)}))}},Mo=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 B.resolve(Hn.ce);let n=new Ao(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?(w(`LruGarbageCollector`,`Garbage collection skipped; disabled`),B.resolve(Co)):this.getCacheSize(e).next((n=>n<this.params.cacheSizeCollectionThreshold?(w(`LruGarbageCollector`,`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Co):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?(w(`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(),tn()<=_.DEBUG&&w(`LruGarbageCollector`,`LRU Garbage Collection\n\tCounted targets in ${a-l}ms\n\tDetermined least recently used ${r} in `+(o-a)+`ms
|
|
10
|
-
\tRemoved ${i} targets in `+(s-o)+`ms
|
|
11
|
-
\tRemoved ${e} documents in `+(c-s)+`ms
|
|
12
|
-
Total Duration: ${c-l}ms`),B.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e}))))}};function No(e,t){return new Mo(e,t)}var Po=class{constructor(){this.changes=new Mi((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,Vr.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(){}},Fo=class{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}},Io=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&&fa(n.mutation,e,tr.empty(),R.now()),e)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.getLocalViewOfDocuments(e,t,J()).next((()=>t))))}getLocalViewOfDocuments(e,t,n=J()){let r=Ri();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,n).next((e=>{let t=Ii();return e.forEach(((e,n)=>{t=t.insert(e,n.overlayedDocument)})),t}))))}getOverlayedDocuments(e,t){let n=Ri();return this.populateOverlays(e,n,t).next((()=>this.computeViews(e,t,n,J())))}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=Pi(),a=Bi(),o=function(){return Bi()}();return t.forEach(((e,t)=>{let o=n.get(t.key);r.has(t.key)&&(o===void 0||o.mutation instanceof ha)?i=i.insert(t.key,t):o===void 0?a.set(t.key,tr.empty()):(a.set(t.key,o.mutation.getFieldMask()),fa(o.mutation,t,o.mutation.getFieldMask(),R.now()))})),this.recalculateAndSaveOverlays(e,i).next((e=>(e.forEach(((e,t)=>a.set(e,t))),t.forEach(((e,t)=>o.set(e,new Fo(t,a.get(e)??null)))),o)))}recalculateAndSaveOverlays(e,t){let n=Bi(),r=new U(((e,t)=>e-t)),i=J();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)||tr.empty();o=i.applyToLocalView(a,o),n.set(e,o);let s=(r.get(i.batchId)||J()).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=zi();c.forEach((e=>{if(!i.has(e)){let r=ua(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 vi(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):yi(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(Ri()),o=jn,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,J()))).next((e=>({batchId:o,changes:Li(e)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new F(t)).next((e=>{let t=Ii();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t}))}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){let i=t.collectionGroup,a=Ii();return this.indexManager.getCollectionParents(e,i).next((o=>B.forEach(o,(o=>{let s=function(e,t){return new mi(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,Vr.newInvalidDocument(r)))}));let n=Ii();return e.forEach(((e,r)=>{let a=i.get(e);a!==void 0&&fa(a.mutation,r,tr.empty(),R.now()),Oi(t,r)&&(n=n.insert(e,r))})),n}))}},Lo=class{constructor(e){this.serializer=e,this.Nr=new Map,this.Br=new Map}getBundleMetadata(e,t){return B.resolve(this.Nr.get(t))}saveBundleMetadata(e,t){return this.Nr.set(t.id,function(e){return{id:e.id,version:e.version,createTime:qa(e.createTime)}}(t)),B.resolve()}getNamedQuery(e,t){return B.resolve(this.Br.get(t))}saveNamedQuery(e,t){return this.Br.set(t.name,function(e){return{name:e.name,query:yo(e.bundledQuery),readTime:qa(e.readTime)}}(t)),B.resolve()}},Ro=class{constructor(){this.overlays=new U(F.comparator),this.Lr=new Map}getOverlay(e,t){return B.resolve(this.overlays.get(t))}getOverlays(e,t){let n=Ri();return B.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)})),B.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)),B.resolve()}getOverlaysForCollection(e,t,n){let r=Ri(),i=t.length+1,a=new F(t.child(``)),o=this.overlays.getIteratorFrom(a);for(;o.hasNext();){let e=o.getNext().value,a=e.getKey();if(!t.isPrefixOf(a.path))break;a.path.length===i&&e.largestBatchId>n&&r.set(e.getKey(),e)}return B.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new U(((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=Ri(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let o=Ri(),s=i.getIterator();for(;s.hasNext()&&(s.getNext().value.forEach(((e,t)=>o.set(e,t))),!(o.size()>=r)););return B.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 xa(t,n));let i=this.Lr.get(t);i===void 0&&(i=J(),this.Lr.set(t,i)),this.Lr.set(t,i.add(n.key))}},zo=class{constructor(){this.sessionToken=G.EMPTY_BYTE_STRING}getSessionToken(e){return B.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,B.resolve()}},Bo=class{constructor(){this.kr=new W(Z.qr),this.Kr=new W(Z.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(e,t){let n=new Z(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 Z(e,t))}Qr(e,t){e.forEach((e=>this.removeReference(e,t)))}Gr(e){let t=new F(new N([])),n=new Z(t,e),r=new Z(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 F(new N([])),n=new Z(t,e),r=new Z(t,e+1),i=J();return this.Kr.forEachInRange([n,r],(e=>{i=i.add(e.key)})),i}containsKey(e){let t=new Z(e,0),n=this.kr.firstAfterOrEqual(t);return n!==null&&e.isEqual(n.key)}},Z=class{constructor(e,t){this.key=e,this.Jr=t}static qr(e,t){return F.comparator(e.key,t.key)||M(e.Jr,t.Jr)}static Ur(e,t){return M(e.Jr,t.Jr)||F.comparator(e.key,t.key)}},Vo=class{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Yn=1,this.Hr=new W(Z.qr)}checkEmpty(e){return B.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 ba(i,t,n,r);this.mutationQueue.push(a);for(let t of r)this.Hr=this.Hr.add(new Z(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return B.resolve(a)}lookupMutationBatch(e,t){return B.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){let n=t+1,r=this.Xr(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?Un:this.Yn-1)}getAllMutationBatches(e){return B.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let n=new Z(t,0),r=new Z(t,1/0),i=[];return this.Hr.forEachInRange([n,r],(e=>{let t=this.Zr(e.Jr);i.push(t)})),B.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new W(M);return t.forEach((e=>{let t=new Z(e,0),r=new Z(e,1/0);this.Hr.forEachInRange([t,r],(e=>{n=n.add(e.Jr)}))})),B.resolve(this.Yr(n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=n;F.isDocumentKey(i)||(i=i.child(``));let a=new Z(new F(i),0),o=new W(M);return this.Hr.forEachWhile((e=>{let t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.Jr)),!0)}),a),B.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 B.forEach(t.mutations,(r=>{let i=new Z(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 Z(t,0),r=this.Hr.firstAfterOrEqual(n);return B.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,B.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]}},Ho=class{constructor(e){this.ti=e,this.docs=function(){return new U(F.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let n=t.key,r=this.docs.get(n),i=r?r.size:0,a=this.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 B.resolve(n?n.document.mutableCopy():Vr.newInvalidDocument(t))}getEntries(e,t){let n=Pi();return t.forEach((e=>{let t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():Vr.newInvalidDocument(e))})),B.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let i=Pi(),a=t.path,o=new F(a.child(`__id-9223372036854775808__`)),s=this.docs.getIteratorFrom(o);for(;s.hasNext();){let{key:e,value:{document:o}}=s.getNext();if(!a.isPrefixOf(e.path))break;e.path.length>a.length+1||In(Pn(o),n)<=0||(r.has(o.key)||Oi(t,o))&&(i=i.insert(o.key,o.mutableCopy()))}return B.resolve(i)}getAllFromCollectionGroup(e,t,n,r){E(9500)}ni(e,t){return B.forEach(this.docs,(e=>t(e)))}newChangeBuffer(e){return new Uo(this)}getSize(e){return B.resolve(this.size)}},Uo=class extends Po{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)})),B.waitFor(t)}getFromCache(e,t){return this.Mr.getEntry(e,t)}getAllFromCache(e,t){return this.Mr.getEntries(e,t)}},Wo=class{constructor(e){this.persistence=e,this.ri=new Mi((e=>di(e)),fi),this.lastRemoteSnapshotVersion=z.min(),this.highestTargetId=0,this.ii=0,this.si=new Bo,this.targetCount=0,this.oi=Eo._r()}forEachTarget(e,t){return this.ri.forEach(((e,n)=>t(n))),B.resolve()}getLastRemoteSnapshotVersion(e){return B.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return B.resolve(this.ii)}allocateTargetId(e){return this.highestTargetId=this.oi.next(),B.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.ii&&(this.ii=t),B.resolve()}lr(e){this.ri.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.oi=new Eo(t),this.highestTargetId=t),e.sequenceNumber>this.ii&&(this.ii=e.sequenceNumber)}addTargetData(e,t){return this.lr(t),this.targetCount+=1,B.resolve()}updateTargetData(e,t){return this.lr(t),B.resolve()}removeTargetData(e,t){return this.ri.delete(t.target),this.si.Gr(t.targetId),--this.targetCount,B.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++)})),B.waitFor(i).next((()=>r))}getTargetCount(e){return B.resolve(this.targetCount)}getTargetData(e,t){let n=this.ri.get(t)||null;return B.resolve(n)}addMatchingKeys(e,t,n){return this.si.$r(t,n),B.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))})),B.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.si.Gr(t),B.resolve()}getMatchingKeysForTargetId(e,t){let n=this.si.jr(t);return B.resolve(n)}containsKey(e,t){return B.resolve(this.si.containsKey(t))}},Go=class{constructor(e,t){this._i={},this.overlays={},this.ai=new Hn(0),this.ui=!1,this.ui=!0,this.ci=new zo,this.referenceDelegate=e(this),this.li=new Wo(this),this.indexManager=new xo,this.remoteDocumentCache=function(e){return new Ho(e)}((e=>this.referenceDelegate.hi(e))),this.serializer=new vo(t),this.Pi=new Lo(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 Ro,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this._i[e.toKey()];return n||(n=new Vo(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){w(`MemoryPersistence`,`Starting transaction:`,e);let r=new Ko(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 B.or(Object.values(this._i).map((n=>()=>n.containsKey(e,t))))}},Ko=class extends Rn{constructor(e){super(),this.currentSequenceNumber=e}},qo=class e{constructor(e){this.persistence=e,this.Ri=new Bo,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()),B.resolve()}removeReference(e,t,n){return this.Ri.removeReference(n,t),this.di.add(n.toString()),B.resolve()}markPotentiallyOrphaned(e,t){return this.di.add(t.toString()),B.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 B.forEach(this.di,(n=>{let r=F.fromPath(n);return this.mi(e,r).next((e=>{e||t.removeEntry(r,z.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 B.or([()=>B.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ii(e,t)])}},Jo=class e{constructor(e,t){this.persistence=e,this.fi=new Mi((e=>Jn(e.path)),((e,t)=>e.isEqual(t))),this.garbageCollector=No(this,t)}static Vi(t,n){return new e(t,n)}Ti(){}Ei(e){return B.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 B.forEach(this.fi,((n,r)=>this.wr(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.ni(e,(r=>this.wr(e,r,t).next((e=>{e||(n++,i.removeEntry(r,z.min()))})))).next((()=>i.apply(e))).next((()=>n))}markPotentiallyOrphaned(e,t){return this.fi.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.fi.set(n,e.currentSequenceNumber),B.resolve()}removeReference(e,t,n){return this.fi.set(n,e.currentSequenceNumber),B.resolve()}updateLimboDocument(e,t){return this.fi.set(t,e.currentSequenceNumber),B.resolve()}hi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Ar(e.data.value)),t}wr(e,t,n){return B.or([()=>this.persistence.Ii(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.fi.get(t);return B.resolve(e!==void 0&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}},Yo=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=J(),i=J();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)}},Xo=class{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}},Zo=class{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=function(){return h()?8:Bn(p())>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 Xo;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?(tn()<=_.DEBUG&&w(`QueryEngine`,`SDK will not create cache indexes for query:`,Di(t),`since it only creates cache indexes for collection contains`,`more than or equal to`,this.Vs,`documents`),B.resolve()):(tn()<=_.DEBUG&&w(`QueryEngine`,`Query:`,Di(t),`scans`,n.documentReadCount,`local documents and returns`,r,`documents as results.`),n.documentReadCount>this.ds*r?(tn()<=_.DEBUG&&w(`QueryEngine`,`The SDK decides to create cache indexes for query:`,Di(t),`as using cache indexes may help improve performance.`),this.indexManager.createTargetIndexes(e,xi(t))):B.resolve())}gs(e,t){if(_i(t))return B.resolve(null);let n=xi(t);return this.indexManager.getIndexType(e,n).next((r=>r===0?null:(t.limit!==null&&r===1&&(t=wi(t,null,`F`),n=xi(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next((r=>{let i=J(...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,wi(t,null,`F`)):this.Ds(e,a,t,n)}))))})))))}ps(e,t,n,r){return _i(t)||r.isEqual(z.min())?B.resolve(null):this.fs.getDocuments(e,n).next((i=>{let a=this.Ss(t,i);return this.bs(t,a,n,r)?B.resolve(null):(tn()<=_.DEBUG&&w(`QueryEngine`,`Re-using previous result from %s to execute query: %s`,r.toString(),Di(t)),this.Ds(e,a,t,Nn(r,jn)).next((e=>e)))}))}Ss(e,t){let n=new W(Ai(e));return t.forEach(((t,r)=>{Oi(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 tn()<=_.DEBUG&&w(`QueryEngine`,`Using full collection scan to execute query:`,Di(t)),this.fs.getDocumentsMatchingQuery(e,t,Fn.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)))}},Qo=`LocalStore`,$o=3e8,es=class{constructor(e,t,n,r){this.persistence=e,this.Cs=t,this.serializer=r,this.vs=new U(M),this.Fs=new Mi((e=>di(e)),fi),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 Io(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 ts(e,t,n,r){return new es(e,t,n,r)}async function ns(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=J();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 rs(e){let t=O(e);return t.persistence.runTransaction(`Get last remote snapshot version`,`readonly`,(e=>t.li.getLastRemoteSnapshotVersion(e)))}function is(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(G.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()>=$o?!0:n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(c,l,a)&&o.push(n.li.updateTargetData(e,l))}));let s=Pi(),c=J();if(t.documentUpdates.forEach((r=>{t.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))})),o.push(as(e,a,t.documentUpdates).next((e=>{s=e.Bs,c=e.Ls}))),!r.isEqual(z.min())){let t=n.li.getLastRemoteSnapshotVersion(e).next((t=>n.li.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.vs=i,e)))}function as(e,t,n){let r=J(),i=J();return n.forEach((e=>r=r.add(e))),t.getEntries(e,r).next((e=>{let r=Pi();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)):w(Qo,`Ignoring outdated watch update for `,n,`. Current version:`,o.version,` Watch version:`,a.version)})),{Bs:r,Ls:i}}))}function os(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,B.resolve(r)):n.li.allocateTargetId(e).next((i=>(r=new _o(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 ss(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(!Vn(e))throw e;w(Qo,`Failed to update sequence numbers for target ${t}: ${e}`)}r.vs=r.vs.remove(t),r.Fs.delete(i.target)}function cs(e,t,n){let r=O(e),i=z.min(),a=J();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):B.resolve(r.vs.get(i))}(r,e,xi(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:z.min(),n?a:J()))).next((e=>(ls(r,ki(t),e),{documents:e,ks:a})))))}function ls(e,t,n){let r=e.Ms.get(t)||z.min();n.forEach(((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)})),e.Ms.set(t,r)}var us=class{constructor(){this.activeTargetIds=Ui()}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)}},ds=class{constructor(){this.vo=new us,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 us,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}},fs=class{Mo(e){}shutdown(){}},ps=`ConnectivityMonitor`,ms=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(){w(ps,`Network connectivity changed: AVAILABLE`);for(let e of this.Lo)e(0)}Bo(){w(ps,`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}},hs=null;function gs(){return hs===null?hs=function(){return 268435456+Math.round(2147483648*Math.random())}():hs++,`0x`+hs.toString(16)}var _s=`RestConnection`,vs={BatchGetDocuments:`batchGet`,Commit:`commit`,RunQuery:`runQuery`,RunAggregationQuery:`runAggregationQuery`,ExecutePipeline:`executePipeline`},ys=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===mr?`project_id=${n}`:`project_id=${n}&database_id=${r}`}Wo(e,t,n,r,i){let a=gs(),o=this.Qo(e,t.toUriEncodedString());w(_s,`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=se(c);return this.zo(e,o,s,n,l).then((t=>(w(_s,`Received RPC '${e}' ${a}: `,t),t)),(t=>{throw nn(_s,`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/`+S}(),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=vs[e],r=`${this.Ko}/v1/${t}:${n}`;return this.databaseInfo.apiKey&&(r=`${r}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),r}terminate(){}},bs=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)}},Q=`WebChannelConnection`,xs=(e,t,n)=>{e.listen(t,(e=>{try{n(e)}catch(e){setTimeout((()=>{throw e}),0)}}))},Ss=class e extends ys{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_||=(xs(Qt(),Zt.STAT_EVENT,(e=>{e.stat===Xt.PROXY?w(Q,`STAT_EVENT: detected buffering proxy`):e.stat===Xt.NOPROXY&&w(Q,`STAT_EVENT: detected no buffering proxy`)})),!0)}zo(e,t,n,r,i){let a=gs();return new Promise(((i,o)=>{let s=new Kt;s.setWithCredentials(!0),s.listenOnce(Jt.COMPLETE,(()=>{try{switch(s.getLastErrorCode()){case Yt.NO_ERROR:let t=s.getResponseJson();w(Q,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(t)),i(t);break;case Yt.TIMEOUT:w(Q,`RPC '${e}' ${a} timed out`),o(new A(k.DEADLINE_EXCEEDED,`Request time out`));break;case Yt.HTTP_ERROR:let n=s.getStatus();if(w(Q,`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{w(Q,`RPC '${e}' ${a} completed.`)}}));let c=JSON.stringify(r);w(Q,`RPC '${e}' ${a} sending request:`,r),s.send(t,`POST`,c,n,15)}))}T_(t,n,r){let i=gs(),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(``);w(Q,`Creating RPC '${t}' stream ${i}: ${l}`,s);let u=o.createWebChannel(l,s);this.E_(u);let d=!1,f=!1,p=new bs({Jo:e=>{f?w(Q,`Not sending because RPC '${t}' stream ${i} is closed:`,e):(d||=(w(Q,`Opening RPC '${t}' stream ${i} transport.`),u.open(),!0),w(Q,`RPC '${t}' stream ${i} sending:`,e),u.send(e))},Ho:()=>u.close()});return xs(u,qt.EventType.OPEN,(()=>{f||(w(Q,`RPC '${t}' stream ${i} transport opened.`),p.i_())})),xs(u,qt.EventType.CLOSE,(()=>{f||(f=!0,w(Q,`RPC '${t}' stream ${i} transport closed`),p.o_(),this.I_(u))})),xs(u,qt.EventType.ERROR,(e=>{f||(f=!0,nn(Q,`RPC '${t}' stream ${i} transport errored. Name:`,e.name,`Message:`,e.message),p.o_(new A(k.UNAVAILABLE,`The operation could not be completed`)))})),xs(u,qt.EventType.MESSAGE,(e=>{if(!f){let n=e.data[0];D(!!n,16349);let r=n,a=r?.error||r[0]?.error;if(a){w(Q,`RPC '${t}' stream ${i} received error:`,a);let e=a.status,n=function(e){let t=Y[e];if(t!==void 0)return Ca(t)}(e),r=a.message;e===`NOT_FOUND`&&r.includes(`database`)&&r.includes(`does not exist`)&&r.includes(this.databaseId.database)&&nn(`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 w(Q,`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 $t()}};function Cs(e){return new Ss(e)}function ws(){return typeof document<`u`?document:null}function Ts(e){return new Ua(e,!0)}Ss.c_=!1;var Es=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&&w(`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_}},Ds=`PersistentStream`,Os=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 Es(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?(T(t.toString()),T(`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 w(Ds,`close with error: ${e}`),this.stream=null,this.close(4,e)}Q_(e){return t=>{this.Ci.enqueueAndForget((()=>this.D_===e?t():(w(Ds,`stream callback skipped by getCloseGuardedDispatcher.`),Promise.resolve())))}}},ks=class extends Os{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=no(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?qa(t.readTime):z.min()}(e);return this.listener.H_(t,n)}Z_(e){let t={};t.database=eo(this.serializer),t.addTarget=function(e,t){let n,r=t.target;if(n=pi(r)?{documents:ro(e,r)}:{query:io(e,r).ft},n.targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=Ka(e,t.resumeToken);let r=Wa(e,t.expectedCount);r!==null&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(z.min())>0){n.readTime=Ga(e,t.snapshotVersion.toTimestamp());let r=Wa(e,t.expectedCount);r!==null&&(n.expectedCount=r)}return n}(this.serializer,e);let n=oo(this.serializer,e);n&&(t.labels=n),this.q_(t)}X_(e){let t={};t.database=eo(this.serializer),t.removeTarget=e,this.q_(t)}},As=class{},js=class extends As{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,Ya(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,Ya(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 Ms(e,t,n,r){return new js(e,t,n,r)}var Ns=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?(T(t),this.aa=!1):w(`OnlineStateTracker`,t)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}},Ps=`RemoteStore`,Fs=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()=>{Ws(this)&&(w(Ps,`Restarting streams for network reachability change.`),await async function(e){let t=O(e);t.Ia.add(4),await Ls(t),t.Va.set(`Unknown`),t.Ia.delete(4),await Is(t)}(this))}))})),this.Va=new Ns(n,r)}};async function Is(e){if(Ws(e))for(let t of e.Ra)await t(!0)}async function Ls(e){for(let t of e.Ra)await t(!1)}function Rs(e,t){let n=O(e);n.Ea.has(t.targetId)||(n.Ea.set(t.targetId,t),Us(n)?Hs(n):$s(n).O_()&&Bs(n,t))}function zs(e,t){let n=O(e),r=$s(n);n.Ea.delete(t),r.O_()&&Vs(n,t),n.Ea.size===0&&(r.O_()?r.L_():Ws(n)&&n.Va.set(`Unknown`))}function Bs(e,t){if(e.da.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(z.min())>0){let n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}$s(e).Z_(t)}function Vs(e,t){e.da.$e(t),$s(e).X_(t)}function Hs(e){e.da=new La({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),At:t=>e.Ea.get(t)||null,ht:()=>e.datastore.serializer.databaseId}),$s(e).start(),e.Va.ua()}function Us(e){return Ws(e)&&!$s(e).x_()&&e.Ea.size>0}function Ws(e){return O(e).Ia.size===0}function Gs(e){e.da=void 0}async function Ks(e){e.Va.set(`Online`)}async function qs(e){e.Ea.forEach(((t,n)=>{Bs(e,t)}))}async function Js(e,t){Gs(e),Us(e)?(e.Va.ha(t),Hs(e)):e.Va.set(`Unknown`)}async function Ys(e,t,n){if(e.Va.set(`Online`),t instanceof Fa&&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){w(Ps,`Failed to remove targets %s: %s `,t.targetIds.join(`,`),n),await Xs(e,n)}else if(t instanceof Na?e.da.Xe(t):t instanceof Pa?e.da.st(t):e.da.tt(t),!n.isEqual(z.min()))try{let t=await rs(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(G.EMPTY_BYTE_STRING,r.snapshotVersion)),Vs(e,t),Bs(e,new _o(r.target,t,n,r.sequenceNumber)))})),e.remoteSyncer.applyRemoteEvent(n)}(e,n)}catch(t){w(Ps,`Failed to raise snapshot:`,t),await Xs(e,t)}}async function Xs(e,t,n){if(!Vn(t))throw t;e.Ia.add(1),await Ls(e),e.Va.set(`Offline`),n||=()=>rs(e.localStore),e.asyncQueue.enqueueRetryable((async()=>{w(Ps,`Retrying IndexedDB access`),await n(),e.Ia.delete(1),await Is(e)}))}async function Zs(e,t){let n=O(e);n.asyncQueue.verifyOperationInProgress(),w(Ps,`RemoteStore received new credentials`);let r=Ws(n);n.Ia.add(3),await Ls(n),r&&n.Va.set(`Unknown`),await n.remoteSyncer.handleCredentialChange(t),n.Ia.delete(3),await Is(n)}async function Qs(e,t){let n=O(e);t?(n.Ia.delete(2),await Is(n)):t||(n.Ia.add(2),await Ls(n),n.Va.set(`Unknown`))}function $s(e){return e.ma||(e.ma=function(e,t,n){let r=O(e);return r.sa(),new ks(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Zo:Ks.bind(null,e),Yo:qs.bind(null,e),t_:Js.bind(null,e),H_:Ys.bind(null,e)}),e.Ra.push((async t=>{t?(e.ma.B_(),Us(e)?Hs(e):e.Va.set(`Unknown`)):(await e.ma.stop(),Gs(e))}))),e.ma}var ec=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 j,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 tc(e,t){if(T(`AsyncQueue`,`${t}: ${e}`),Vn(e))return new A(k.UNAVAILABLE,`${t}: ${e}`);throw e}var nc=class e{static emptySet(t){return new e(t.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||F.comparator(t.key,n.key):(e,t)=>F.comparator(e.key,t.key),this.keyedMap=Ii(),this.sortedSet=new U(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
|
-
`+e.join(`
|
|
14
|
-
`)+`
|
|
15
|
-
)`}copy(t,n){let r=new e;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r}},rc=class{constructor(){this.ga=new U(F.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}},ic=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,nc.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)&&Ti(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}},ac=class{constructor(){this.wa=void 0,this.Sa=[]}ba(){return this.Sa.some((e=>e.Da()))}},oc=class{constructor(){this.queries=sc(),this.onlineState=`Unknown`,this.Ca=new Set}terminate(){(function(e,t){let n=O(e),r=n.queries;n.queries=sc(),r.forEach(((e,n)=>{for(let e of n.Sa)e.onError(t)}))})(this,new A(k.ABORTED,`Firestore shutting down`))}};function sc(){return new Mi((e=>Ei(e)),Ti)}async function cc(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 ac,r=+!t.Da());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=tc(e,`Initialization of query '${Di(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)&&fc(n)}async function lc(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():!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 uc(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&&fc(n)}function dc(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 fc(e){e.Ca.forEach((e=>{e.next()}))}var pc,mc;(mc=pc||={}).Ma=`default`,mc.Cache=`cache`;var hc=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 ic(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=ic.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==pc.Cache}},gc=class{constructor(e){this.key=e}},_c=class{constructor(e){this.key=e}},vc=class{constructor(e,t){this.query=e,this.Za=t,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=J(),this.mutatedKeys=J(),this.eu=Ai(e),this.tu=new nc(this.eu)}get nu(){return this.Za}ru(e,t){let n=t?t.iu:new rc,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=Oi(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 ic(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 rc,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=J(),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 _c(e))})),this.Ya.forEach((n=>{e.has(n)||t.push(new gc(n))})),t}cu(e){this.Za=e.ks,this.Ya=J();let t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return ic.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Xa===0,this.hasCachedResults)}},yc=`SyncEngine`,bc=class{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}},xc=class{constructor(e){this.key=e,this.hu=!1}},Sc=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 Mi((e=>Ei(e)),Ti),this.Eu=new Map,this.Iu=new Set,this.Ru=new U(F.comparator),this.Au=new Map,this.Vu=new Bo,this.du={},this.mu=new Map,this.fu=Eo.ar(),this.onlineState=`Unknown`,this.gu=void 0}get isPrimaryClient(){return!0===this.gu}};async function Cc(e,t,n=!0){let r=Bc(e),i,a=r.Tu.get(t);return a?(r.sharedClientState.addLocalQueryTarget(a.targetId),i=a.view.lu()):i=await Tc(r,t,n,!0),i}async function wc(e,t){await Tc(Bc(e),t,!0,!1)}async function Tc(e,t,n,r){let i=await os(e.localStore,xi(t)),a=i.targetId,o=e.sharedClientState.addLocalQueryTarget(a,n),s;return r&&(s=await Ec(e,t,a,o===`current`,i.resumeToken)),e.isPrimaryClient&&n&&Rs(e.remoteStore,i),s}async function Ec(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 cs(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 Pc(e,t.targetId,s.au),s.snapshot}(e,t,n,r);let a=await cs(e.localStore,t,!0),o=new vc(t,a.ks),s=o.ru(a.documents),c=Ma.createSynthesizedTargetChangeForCurrentChange(n,r&&e.onlineState!==`Offline`,i),l=o.applyChanges(s,e.isPrimaryClient,c);Pc(e,n,l.au);let u=new bc(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 Dc(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=>!Ti(e,t)))),void r.Tu.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)||await ss(r.localStore,i.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(i.targetId),n&&zs(r.remoteStore,i.targetId),Mc(r,i.targetId)})).catch(zn)):(Mc(r,i.targetId),await ss(r.localStore,i.targetId,!0))}async function Oc(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),zs(n.remoteStore,r.targetId))}async function kc(e,t){let n=O(e);try{let e=await is(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 Lc(n,e,t)}catch(e){await zn(e)}}function Ac(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&&fc(n)}(r.eventManager,t),e.length&&r.Pu.H_(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function jc(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 U(F.comparator);e=e.insert(a,Vr.newNoDocument(a,z.min()));let n=J().add(a);await kc(r,new ja(z.min(),new Map,new U(M),e,n)),r.Ru=r.Ru.remove(a),r.Au.delete(t),Ic(r)}else await ss(r.localStore,t,!1).then((()=>Mc(r,t,n))).catch(zn)}function Mc(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)||Nc(e,t)}))}function Nc(e,t){e.Iu.delete(t.path.canonicalString());let n=e.Ru.get(t);n!==null&&(zs(e.remoteStore,n),e.Ru=e.Ru.remove(t),e.Au.delete(n),Ic(e))}function Pc(e,t,n){for(let r of n)r instanceof gc?(e.Vu.addReference(r.key,t),Fc(e,r)):r instanceof _c?(w(yc,`Document no longer in limbo: `+r.key),e.Vu.removeReference(r.key,t),e.Vu.containsKey(r.key)||Nc(e,r.key)):E(19791,{wu:r})}function Fc(e,t){let n=t.key,r=n.path.canonicalString();e.Ru.get(n)||e.Iu.has(r)||(w(yc,`New document in limbo: `+n),e.Iu.add(r),Ic(e))}function Ic(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 F(N.fromString(t)),r=e.fu.next();e.Au.set(r,new xc(n)),e.Ru=e.Ru.insert(n,r),Rs(e.remoteStore,new _o(xi(gi(n.path)),r,`TargetPurposeLimboResolution`,Hn.ce))}}async function Lc(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=Yo.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=>B.forEach(t,(t=>B.forEach(t.Ts,(r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=>B.forEach(t.Es,(r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!Vn(e))throw e;w(Qo,`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 Rc(e,t){let n=O(e);if(!n.currentUser.isEqual(t)){w(yc,`User change. New user:`,t.toKey());let e=await ns(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 Lc(n,e.Ns)}}function zc(e,t){let n=O(e),r=n.Au.get(t);if(r&&r.hu)return J().add(r.key);{let e=J(),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 Bc(e){let t=O(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=kc.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=zc.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=jc.bind(null,t),t.Pu.H_=uc.bind(null,t.eventManager),t.Pu.yu=dc.bind(null,t.eventManager),t}var Vc=class{constructor(){this.kind=`memory`,this.synchronizeTabs=!1}async initialize(e){this.serializer=Ts(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 ts(this.persistence,new Zo,e.initialUser,this.serializer)}Cu(e){return new Go(qo.Vi,this.serializer)}Du(e){return new ds}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}};Vc.provider={build:()=>new Vc};var Hc=class extends Vc{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){D(this.persistence.referenceDelegate instanceof Jo,46915);let n=this.persistence.referenceDelegate.garbageCollector;return new jo(n,e.asyncQueue,t)}Cu(e){let t=this.cacheSizeBytes===void 0?To.DEFAULT:To.withCacheSize(this.cacheSizeBytes);return new Go((e=>Jo.Vi(e,t)),this.serializer)}},Uc=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=>Ac(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=Rc.bind(null,this.syncEngine),await Qs(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new oc}()}createDatastore(e){let t=Ts(e.databaseInfo.databaseId),n=Cs(e.databaseInfo);return Ms(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,r,i){return new Fs(e,t,n,r,i)}(this.localStore,this.datastore,e.asyncQueue,(e=>Ac(this.syncEngine,e,0)),function(){return ms.v()?new ms:new fs}())}createSyncEngine(e,t){return function(e,t,n,r,i,a,o){let s=new Sc(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);w(Ps,`RemoteStore shutting down.`),t.Ia.add(5),await Ls(t),t.Aa.shutdown(),t.Va.set(`Unknown`)}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}};Uc.provider={build:()=>new Uc};var Wc=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):T(`Uncaught Error in snapshot listener:`,e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout((()=>{this.muted||e(t)}),0)}},Gc=`FirestoreClient`,Kc=class{constructor(e,t,n,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this._databaseInfo=r,this.user=x.UNAUTHENTICATED,this.clientId=mn.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,(async e=>{w(Gc,`Received user=`,e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=>(w(Gc,`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 j;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=tc(t,`Failed to shutdown persistence`);e.reject(n)}})),e.promise}};async function qc(e,t){e.asyncQueue.verifyOperationInProgress(),w(Gc,`Initializing OfflineComponentProvider`);let n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=>{r.isEqual(e)||(await ns(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e._offlineComponents=t}async function Jc(e,t){e.asyncQueue.verifyOperationInProgress();let n=await Yc(e);w(Gc,`Initializing OnlineComponentProvider`),await t.initialize(n,e.configuration),e.setCredentialChangeListener((e=>Zs(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=>Zs(t.remoteStore,n))),e._onlineComponents=t}async function Yc(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){w(Gc,`Using user provided OfflineComponentProvider`);try{await qc(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;nn(`Error using user provided cache. Falling back to memory cache: `+n),await qc(e,new Vc)}}else w(Gc,`Using default OfflineComponentProvider`),await qc(e,new Hc(void 0));return e._offlineComponents}async function Xc(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(w(Gc,`Using user provided OnlineComponentProvider`),await Jc(e,e._uninitializedComponentsProvider._online)):(w(Gc,`Using default OnlineComponentProvider`),await Jc(e,new Uc))),e._onlineComponents}async function Zc(e){let t=await Xc(e),n=t.eventManager;return n.onListen=Cc.bind(null,t.syncEngine),n.onUnlisten=Dc.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=wc.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=Oc.bind(null,t.syncEngine),n}function Qc(e,t,n={}){let r=new j;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new Wc({next:s=>{a.Nu(),t.enqueueAndForget((()=>lc(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 hc(gi(n.path),a,{includeMetadataChanges:!0,qa:!0});return cc(e,o)}(await Zc(e),e.asyncQueue,t,n,r))),r.promise}function $c(e,t,n={}){let r=new j;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new Wc({next:n=>{a.Nu(),t.enqueueAndForget((()=>lc(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 hc(n,a,{includeMetadataChanges:!0,qa:!0});return cc(e,o)}(await Zc(e),e.asyncQueue,t,n,r))),r.promise}function el(e){let t={};return e.timeoutSeconds!==void 0&&(t.timeoutSeconds=e.timeoutSeconds),t}var tl=`ComponentProvider`,nl=new Map;function rl(e,t,n,r,i){return new pr(e,t,n,i.host,i.ssl,i.experimentalForceLongPolling,i.experimentalAutoDetectLongPolling,el(i.experimentalLongPollingOptions),i.useFetchStreams,i.isUsingEmulator,r)}var il=`firestore.googleapis.com`,al=!0,ol=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=il,this.ssl=al}else this.host=e.host,this.ssl=e.ssl??al;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=wo;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<Oo)throw new A(k.INVALID_ARGUMENT,`cacheSizeBytes must be at least 1048576`);this.cacheSizeBytes=e.cacheSizeBytes}wn(`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=el(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}},sl=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 ol({}),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 ol(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=function(e){if(!e)return new sn;switch(e.type){case`firstParty`:return new un(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=nl.get(e);t&&(w(tl,`Removing Datastore`),nl.delete(e),t.terminate())}(this),Promise.resolve()}},cl=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)}},$=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 ll(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(On(n,e._jsonSchema))return new e(t,r||null,new F(N.fromString(n.referencePath)))}};$._jsonSchemaVersion=`firestore/documentReference/1.0`,$._jsonSchema={type:L(`string`,$._jsonSchemaVersion),referencePath:L(`string`)};var ll=class e extends cl{constructor(e,t,n){super(e,t,gi(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 $(this.firestore,null,new F(e))}withConverter(t){return new e(this.firestore,t,this._path)}};function ul(e,t,...n){if(e=oe(e),Cn(`collection`,`path`,t),e instanceof sl){let r=N.fromString(t,...n);return Tn(r),new ll(e,null,r)}{if(!(e instanceof $||e instanceof ll))throw new A(k.INVALID_ARGUMENT,`Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore`);let r=e._path.child(N.fromString(t,...n));return Tn(r),new ll(e.firestore,null,r)}}var dl=`AsyncQueue`,fl=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 Es(this,`async_queue_retry`),this._c=()=>{let e=ws();e&&w(dl,`Visibility state changed to `+e.visibilityState),this.M_.w_()},this.ac=e;let t=ws();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=ws();t&&typeof t.removeEventListener==`function`&&t.removeEventListener(`visibilitychange`,this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise((()=>{}));let t=new j;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(!Vn(e))throw e;w(dl,`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,T(`INTERNAL UNHANDLED ERROR: `,pl(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=ec.createAndSchedule(this,e,t,n,(e=>this.hc(e)));return this.tc.push(r),r}uc(){this.nc&&E(47125,{Pc:pl(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 pl(e){let t=e.message||``;return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+`
|
|
16
|
-
`+e.stack),t}var ml=class extends sl{constructor(e,t,n,r){super(e,t,n,r),this.type=`firestore`,this._queue=new fl,this._persistenceKey=r?.name||`[DEFAULT]`}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new fl(e),this._firestoreClient=void 0,await e}}};function hl(e){if(e._terminated)throw new A(k.FAILED_PRECONDITION,`The client has already been terminated.`);return e._firestoreClient||gl(e),e._firestoreClient}function gl(e){let t=e._freezeSettings(),n=rl(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 Kc(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 _l=class e{constructor(e){this._byteString=e}static fromBase64String(t){try{return new e(G.fromBase64String(t))}catch(e){throw new A(k.INVALID_ARGUMENT,`Failed to construct data from Base64 string: `+e)}}static fromUint8Array(t){return new e(G.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(On(t,e._jsonSchema))return e.fromBase64String(t.bytes)}};_l._jsonSchemaVersion=`firestore/bytes/1.0`,_l._jsonSchema={type:L(`string`,_l._jsonSchemaVersion),bytes:L(`string`)};var vl=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 P(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}};function yl(){return new vl(bn)}var bl=class{constructor(e){this._methodName=e}},xl=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 M(this._lat,e._lat)||M(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:e._jsonSchemaVersion}}static fromJSON(t){if(On(t,e._jsonSchema))return new e(t.latitude,t.longitude)}};xl._jsonSchemaVersion=`firestore/geoPoint/1.0`,xl._jsonSchema={type:L(`string`,xl._jsonSchemaVersion),latitude:L(`number`),longitude:L(`number`)};var Sl=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(On(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`)}}};Sl._jsonSchemaVersion=`firestore/vectorValue/1.0`,Sl._jsonSchema={type:L(`string`,Sl._jsonSchemaVersion),vectorValues:L(`object`)};var Cl=/^__.*__$/;function wl(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw E(40011,{dataSource:e})}}var Tl=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 Ll(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(wl(this.dataSource)&&Cl.test(e))throw this.yc(`Document fields cannot begin and end with "__"`)}},El=class{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Ts(e)}I(e,t,n,r=!1){return new Tl({dataSource:e,methodName:t,targetDoc:n,path:P.emptyPath(),arrayElement:!1,hasConverter:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function Dl(e){let t=e._freezeSettings(),n=Ts(e._databaseId);return new El(e._databaseId,!!t.ignoreUndefinedProperties,n)}var Ol=class e extends bl{_toFieldTransform(e){return new aa(e.path,new Zi)}isEqual(t){return t instanceof e}};function kl(e,t,n,r=!1){return Al(n,e.I(r?4:3,t))}function Al(e,t){if(Ml(e=oe(e)))return Nl(`Unsupported field value:`,t,e),jl(e,t);if(e instanceof bl)return function(e,t){if(!wl(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=Al(i,t.gc(r));e??={nullValue:`NULL_VALUE`},n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if((e=oe(e))===null)return{nullValue:`NULL_VALUE`};if(typeof e==`number`)return Ki(t.serializer,e);if(typeof e==`boolean`)return{booleanValue:e};if(typeof e==`string`)return{stringValue:e};if(e instanceof Date){let n=R.fromDate(e);return{timestampValue:Ga(t.serializer,n)}}if(e instanceof R){let n=new R(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:Ga(t.serializer,n)}}if(e instanceof xl)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof _l)return{bytesValue:Ka(t.serializer,e._byteString)};if(e instanceof $){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:Ja(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof Sl)return function(e,t){let n=e instanceof Sl?e.toArray():e;return{mapValue:{fields:{[_r]:{stringValue:br},[xr]:{arrayValue:{values:n.map((e=>{if(typeof e!=`number`)throw t.yc(`VectorValues must only contain numeric values.`);return Wi(t.serializer,e)}))}}}}}}(e,t);if(go(e))return e._toProto(t.serializer);throw t.yc(`Unsupported field value: ${Dn(e)}`)}(e,t)}function jl(e,t){let n={};return Zn(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):H(e,((e,r)=>{let i=Al(r,t.dc(e));i!=null&&(n[e]=i)})),{mapValue:{fields:n}}}function Ml(e){return!(typeof e!=`object`||!e||e instanceof Array||e instanceof Date||e instanceof R||e instanceof xl||e instanceof _l||e instanceof $||e instanceof bl||e instanceof Sl||go(e))}function Nl(e,t,n){if(!Ml(n)||!En(n)){let r=Dn(n);throw r===`an object`?t.yc(e+` a custom object`):t.yc(e+` `+r)}}function Pl(e,t,n){if((t=oe(t))instanceof vl)return t._internalPath;if(typeof t==`string`)return Il(e,t);throw Ll(`Field path arguments must be of type string or `,e,!1,void 0,n)}var Fl=RegExp(`[~\\*/\\[\\]]`);function Il(e,t,n){if(t.search(Fl)>=0)throw Ll(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new vl(...t.split(`.`))._internalPath}catch{throw Ll(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function Ll(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)}var Rl=class{convertValue(e,t=`none`){switch(Sr(e)){case 0:return null;case 1:return e.booleanValue;case 2:return K(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(ar(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 H(e,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertVectorValue(e){let t=e.fields?.[xr].arrayValue?.values?.map((e=>K(e.doubleValue)));return new Sl(t)}convertGeoPoint(e){return new xl(K(e.latitude),K(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=>this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case`previous`:let n=dr(e);return n==null?null:this.convertValue(n,t);case`estimate`:return this.convertTimestamp(fr(e));default:return null}}convertTimestamp(e){let t=ir(e);return new R(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=N.fromString(e);D(ho(n),9688,{name:e});let r=new hr(n.get(1),n.get(3)),i=new F(n.popFirst(5));return r.isEqual(t)||T(`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}},zl=class extends Rl{constructor(e){super(),this.firestore=e}convertBytes(e){return new _l(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new $(this.firestore,null,t)}};function Bl(){return new Ol(`serverTimestamp`)}var Vl=`@firebase/firestore`,Hl=`4.14.0`,Ul=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 $(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new Wl(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(Pl(`DocumentSnapshot.get`,e));if(t!==null)return this._userDataWriter.convertValue(t)}}},Wl=class extends Ul{data(){return super.data()}};function Gl(e){if(e.limitType===`L`&&e.explicitOrderBy.length===0)throw new A(k.UNIMPLEMENTED,`limitToLast() queries require specifying at least one orderBy() clause`)}var Kl=class{},ql=class extends Kl{};function Jl(e,t,...n){let r=[];t instanceof Kl&&r.push(t),r=r.concat(n),function(e){let t=e.filter((e=>e instanceof Zl)).length,n=e.filter((e=>e instanceof Yl)).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 Yl=class e extends ql{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 eu(e._query,t),new cl(e.firestore,e.converter,Ci(e._query,t))}_parse(e){let t=Dl(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`){$l(o,a);let t=[];for(let n of o)t.push(Ql(r,e,n));s={arrayValue:{values:t}}}else s=Ql(r,e,o)}else a!==`in`&&a!==`not-in`&&a!==`array-contains-any`||$l(o,a),s=kl(n,t,o,a===`in`||a===`not-in`);return q.create(i,a,s)}(e._query,`where`,t,e.firestore._databaseId,this._field,this._op,this._value)}};function Xl(e,t,n){let r=t,i=Pl(`where`,e);return Yl._create(i,r,n)}var Zl=class e extends Kl{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]:Jr.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)eu(n,e),n=Ci(n,e)}(e._query,t),new cl(e.firestore,e.converter,Ci(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type===`and`?`and`:`or`}};function Ql(e,t,n){if(typeof(n=oe(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(!yi(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(N.fromString(n));if(!F.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 jr(e,new F(r))}if(n instanceof $)return jr(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: ${Dn(n)}.`)}function $l(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 eu(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.`)}var tu=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},nu=class e extends Ul{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 ru(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(Pl(`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)}};nu._jsonSchemaVersion=`firestore/documentSnapshot/1.0`,nu._jsonSchema={type:L(`string`,nu._jsonSchemaVersion),bundleSource:L(`string`,`DocumentSnapshot`),bundleName:L(`string`),bundle:L(`string`)};var ru=class extends nu{data(e={}){return super.data(e)}},iu=class e{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new tu(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 ru(this._firestore,this._userDataWriter,n.key,n,new tu(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 ru(e._firestore,e._userDataWriter,n.doc.key,n.doc,new tu(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 ru(e._firestore,e._userDataWriter,t.doc.key,t.doc,new tu(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:au(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=mn.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 au(e){switch(e){case 0:return`added`;case 2:case 3:return`modified`;case 1:return`removed`;default:return E(61501,{type:e})}}iu._jsonSchemaVersion=`firestore/querySnapshot/1.0`,iu._jsonSchema={type:L(`string`,iu._jsonSchemaVersion),bundleSource:L(`string`,`QuerySnapshot`),bundleName:L(`string`),bundle:L(`string`)};function ou(e){e=I(e,$);let t=I(e.firestore,ml);return Qc(hl(t),e._key).then((n=>cu(t,e,n)))}function su(e){e=I(e,cl);let t=I(e.firestore,ml),n=hl(t),r=new zl(t);return Gl(e._query),$c(n,e._query).then((n=>new iu(t,r,e,n)))}function cu(e,t,n){let r=n.docs.get(t._key);return new nu(e,new zl(e),t._key,r,new tu(n.hasPendingWrites,n.fromCache),t.converter)}(function(e,t=!0){en(xt),vt(new ce(`firestore`,((e,{instanceIdentifier:n,options:r})=>{let i=e.getProvider(`app`).getImmediate(),a=new ml(new cn(e.getProvider(`auth-internal`)),new fn(i,e.getProvider(`app-check-internal`)),gr(i,n),i);return r={useFetchStreams:t,...r},a._setSettings(r),a}),`PUBLIC`).setMultipleInstances(!0)),St(Vl,Hl,e),St(Vl,Hl,`esm2020`)})();function lu(e){return{...e.data(),id:e.id}}async function uu(e,t,n,r,i){let a=i.filter(e=>!!(e&&!r.has(e.path)));for(let i=0;i<a.length;i+=30){let o=a.slice(i,i+30);console.log(e),console.log(t),(await su(Jl(ul(e,t),Xl(yl(),`in`,o.map(e=>e.id))))).forEach(e=>{let t=n(e);r.set(e.ref.path,t)})}}async function du(e,t,n){let r=n.filter(e=>!!(e&&!t.has(e.path)));await Promise.all(r.map(async n=>{let r=e(await ou(n));t.set(n.path,r)}))}Array.prototype.mapNotNull=function(e){return this.flatMap((t,n)=>{let r=e(t,n);return r==null?[]:[r]})};var fu={updateAt:Bl(),delete:!0},pu={updateAt:Bl(),delete:!1};exports.deleteItem=fu,exports.fetchItems=uu,exports.fetchItemsByOne=du,exports.snapshotToData=lu,exports.undeleteItem=pu;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require(`firebase/firestore`);function t(e){return{...e.data(),id:e.id}}async function n(t,n,r,i,a){let o=a.filter(e=>!!(e&&!i.has(e.path)));for(let a=0;a<o.length;a+=30){let s=o.slice(a,a+30);console.log(t),console.log(n),(await(0,e.getDocs)((0,e.query)((0,e.collection)(t,n),(0,e.where)((0,e.documentId)(),`in`,s.map(e=>e.id))))).forEach(e=>{let t=r(e);i.set(e.ref.path,t)})}}async function r(t,n,r){let i=r.filter(e=>!!(e&&!n.has(e.path)));await Promise.all(i.map(async r=>{let i=t(await(0,e.getDoc)(r));n.set(r.path,i)}))}Array.prototype.mapNotNull=function(e){return this.flatMap((t,n)=>{let r=e(t,n);return r==null?[]:[r]})};var i={updateAt:(0,e.serverTimestamp)(),delete:!0},a={updateAt:(0,e.serverTimestamp)(),delete:!1};exports.deleteItem=i,exports.fetchItems=n,exports.fetchItemsByOne=r,exports.snapshotToData=t,exports.undeleteItem=a;
|