<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/*! For license information please see dasa-nsw-module-firebase.js.LICENSE.txt */
System.register([],(function(e,t){return{execute:function(){e((()=&gt;{var e={444:(e,t,n)=&gt;{"use strict";n.d(t,{$s:()=&gt;Q,BH:()=&gt;y,DV:()=&gt;F,G6:()=&gt;C,GJ:()=&gt;R,L:()=&gt;l,LL:()=&gt;x,P0:()=&gt;g,Sg:()=&gt;_,UI:()=&gt;L,US:()=&gt;a,Wl:()=&gt;N,Yr:()=&gt;I,ZR:()=&gt;S,aH:()=&gt;m,b$:()=&gt;b,cI:()=&gt;D,dS:()=&gt;z,eu:()=&gt;E,g5:()=&gt;s,gK:()=&gt;j,gQ:()=&gt;U,h$:()=&gt;u,hl:()=&gt;T,hu:()=&gt;i,m9:()=&gt;Y,p$:()=&gt;d,r3:()=&gt;M,uI:()=&gt;w,ug:()=&gt;$,vZ:()=&gt;q,w9:()=&gt;P,xO:()=&gt;B,xb:()=&gt;O,z$:()=&gt;v});const r={NODE_CLIENT:!1,NODE_ADMIN:!1,SDK_VERSION:"${JSCORE_VERSION}"},i=function(e,t){if(!e)throw s(t)},s=function(e){return new Error("Firebase Database ("+r.SDK_VERSION+") INTERNAL ASSERT FAILED: "+e)},o=function(e){const t=[];let n=0;for(let r=0;r&lt;e.length;r++){let i=e.charCodeAt(r);i&lt;128?t[n++]=i:i&lt;2048?(t[n++]=i&gt;&gt;6|192,t[n++]=63&amp;i|128):55296==(64512&amp;i)&amp;&amp;r+1&lt;e.length&amp;&amp;56320==(64512&amp;e.charCodeAt(r+1))?(i=65536+((1023&amp;i)&lt;&lt;10)+(1023&amp;e.charCodeAt(++r)),t[n++]=i&gt;&gt;18|240,t[n++]=i&gt;&gt;12&amp;63|128,t[n++]=i&gt;&gt;6&amp;63|128,t[n++]=63&amp;i|128):(t[n++]=i&gt;&gt;12|224,t[n++]=i&gt;&gt;6&amp;63|128,t[n++]=63&amp;i|128)}return t},a={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let t=0;t&lt;e.length;t+=3){const i=e[t],s=t+1&lt;e.length,o=s?e[t+1]:0,a=t+2&lt;e.length,c=a?e[t+2]:0,u=i&gt;&gt;2,l=(3&amp;i)&lt;&lt;4|o&gt;&gt;4;let h=(15&amp;o)&lt;&lt;2|c&gt;&gt;6,d=63&amp;c;a||(d=64,s||(h=64)),r.push(n[u],n[l],n[h],n[d])}return r.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&amp;&amp;!t?btoa(e):this.encodeByteArray(o(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&amp;&amp;!t?atob(e):function(e){const t=[];let n=0,r=0;for(;n&lt;e.length;){const i=e[n++];if(i&lt;128)t[r++]=String.fromCharCode(i);else if(i&gt;191&amp;&amp;i&lt;224){const s=e[n++];t[r++]=String.fromCharCode((31&amp;i)&lt;&lt;6|63&amp;s)}else if(i&gt;239&amp;&amp;i&lt;365){const s=((7&amp;i)&lt;&lt;18|(63&amp;e[n++])&lt;&lt;12|(63&amp;e[n++])&lt;&lt;6|63&amp;e[n++])-65536;t[r++]=String.fromCharCode(55296+(s&gt;&gt;10)),t[r++]=String.fromCharCode(56320+(1023&amp;s))}else{const s=e[n++],o=e[n++];t[r++]=String.fromCharCode((15&amp;i)&lt;&lt;12|(63&amp;s)&lt;&lt;6|63&amp;o)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const n=t?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let t=0;t&lt;e.length;){const i=n[e.charAt(t++)],s=t&lt;e.length?n[e.charAt(t)]:0;++t;const o=t&lt;e.length?n[e.charAt(t)]:64;++t;const a=t&lt;e.length?n[e.charAt(t)]:64;if(++t,null==i||null==s||null==o||null==a)throw new c;const u=i&lt;&lt;2|s&gt;&gt;4;if(r.push(u),64!==o){const e=s&lt;&lt;4&amp;240|o&gt;&gt;2;if(r.push(e),64!==a){const e=o&lt;&lt;6&amp;192|a;r.push(e)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e&lt;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&gt;=this.ENCODED_VALS_BASE.length&amp;&amp;(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class c extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const u=function(e){const t=o(e);return a.encodeByteArray(t,!0)},l=function(e){return u(e).replace(/\./g,"")},h=function(e){try{return a.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function d(e){return f(void 0,e)}function f(e,t){if(!(t instanceof Object))return t;switch(t.constructor){case Date:return new Date(t.getTime());case Object:void 0===e&amp;&amp;(e={});break;case Array:e=[];break;default:return t}for(const n in t)t.hasOwnProperty(n)&amp;&amp;"__proto__"!==n&amp;&amp;(e[n]=f(e[n],t[n]));return e}const p=()=&gt;{try{return function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n.g)return n.g;throw new Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__||(()=&gt;{if("undefined"==typeof process||void 0===process.env)return;const e=process.env.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||(()=&gt;{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&amp;&amp;h(e[1]);return t&amp;&amp;JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},g=e=&gt;{const t=(e=&gt;{var t,n;return null===(n=null===(t=p())||void 0===t?void 0:t.emulatorHosts)||void 0===n?void 0:n[e]})(e);if(!t)return;const n=t.lastIndexOf(":");if(n&lt;=0||n+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const r=parseInt(t.substring(n+1),10);return"["===t[0]?[t.substring(1,n-1),r]:[t.substring(0,n),r]},m=()=&gt;{var e;return null===(e=p())||void 0===e?void 0:e.config};class y{constructor(){this.reject=()=&gt;{},this.resolve=()=&gt;{},this.promise=new Promise(((e,t)=&gt;{this.resolve=e,this.reject=t}))}wrapCallback(e){return(t,n)=&gt;{t?this.reject(t):this.resolve(n),"function"==typeof e&amp;&amp;(this.promise.catch((()=&gt;{})),1===e.length?e(t):e(t,n))}}}function _(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=t||"demo-project",r=e.iat||0,i=e.sub||e.user_id;if(!i)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const s=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:r,exp:r+3600,auth_time:r,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},e);return[l(JSON.stringify({alg:"none",type:"JWT"})),l(JSON.stringify(s)),""].join(".")}function v(){return"undefined"!=typeof navigator&amp;&amp;"string"==typeof navigator.userAgent?navigator.userAgent:""}function w(){return"undefined"!=typeof window&amp;&amp;!!(window.cordova||window.phonegap||window.PhoneGap)&amp;&amp;/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(v())}function b(){return"object"==typeof navigator&amp;&amp;"ReactNative"===navigator.product}function I(){return!0===r.NODE_CLIENT||!0===r.NODE_ADMIN}function C(){return!function(){var e;const t=null===(e=p())||void 0===e?void 0:e.forceEnvironment;if("node"===t)return!0;if("browser"===t)return!1;try{return"[object process]"===Object.prototype.toString.call(n.g.process)}catch(e){return!1}}()&amp;&amp;navigator.userAgent.includes("Safari")&amp;&amp;!navigator.userAgent.includes("Chrome")}function T(){try{return"object"==typeof indexedDB}catch(e){return!1}}function E(){return new Promise(((e,t)=&gt;{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=&gt;{i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=()=&gt;{n=!1},i.onerror=()=&gt;{var e;t((null===(e=i.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}}))}class S extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,S.prototype),Error.captureStackTrace&amp;&amp;Error.captureStackTrace(this,x.prototype.create)}}class x{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){const n=t[0]||{},r=`${this.service}/${e}`,i=this.errors[e],s=i?function(e,t){return e.replace(k,((e,n)=&gt;{const r=t[n];return null!=r?String(r):`&lt;${n}?&gt;`}))}(i,n):"Error",o=`${this.serviceName}: ${s} (${r}).`;return new S(r,o,n)}}const k=/\{\$([^}]+)}/g;function D(e){return JSON.parse(e)}function N(e){return JSON.stringify(e)}const A=function(e){let t={},n={},r={},i="";try{const s=e.split(".");t=D(h(s[0])||""),n=D(h(s[1])||""),i=s[2],r=n.d||{},delete n.d}catch(e){}return{header:t,claims:n,data:r,signature:i}},P=function(e){const t=A(e).claims;return!!t&amp;&amp;"object"==typeof t&amp;&amp;t.hasOwnProperty("iat")},R=function(e){const t=A(e).claims;return"object"==typeof t&amp;&amp;!0===t.admin};function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function F(e,t){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function O(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}function L(e,t,n){const r={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&amp;&amp;(r[i]=t.call(n,e[i],i,e));return r}function q(e,t){if(e===t)return!0;const n=Object.keys(e),r=Object.keys(t);for(const i of n){if(!r.includes(i))return!1;const n=e[i],s=t[i];if(V(n)&amp;&amp;V(s)){if(!q(n,s))return!1}else if(n!==s)return!1}for(const e of r)if(!n.includes(e))return!1;return!0}function V(e){return null!==e&amp;&amp;"object"==typeof e}function B(e){const t=[];for(const[n,r]of Object.entries(e))Array.isArray(r)?r.forEach((e=&gt;{t.push(encodeURIComponent(n)+"="+encodeURIComponent(e))})):t.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return t.length?"&amp;"+t.join("&amp;"):""}class U{constructor(){this.chain_=[],this.buf_=[],this.W_=[],this.pad_=[],this.inbuf_=0,this.total_=0,this.blockSize=64,this.pad_[0]=128;for(let e=1;e&lt;this.blockSize;++e)this.pad_[e]=0;this.reset()}reset(){this.chain_[0]=1732584193,this.chain_[1]=4023233417,this.chain_[2]=2562383102,this.chain_[3]=271733878,this.chain_[4]=3285377520,this.inbuf_=0,this.total_=0}compress_(e,t){t||(t=0);const n=this.W_;if("string"==typeof e)for(let r=0;r&lt;16;r++)n[r]=e.charCodeAt(t)&lt;&lt;24|e.charCodeAt(t+1)&lt;&lt;16|e.charCodeAt(t+2)&lt;&lt;8|e.charCodeAt(t+3),t+=4;else for(let r=0;r&lt;16;r++)n[r]=e[t]&lt;&lt;24|e[t+1]&lt;&lt;16|e[t+2]&lt;&lt;8|e[t+3],t+=4;for(let e=16;e&lt;80;e++){const t=n[e-3]^n[e-8]^n[e-14]^n[e-16];n[e]=4294967295&amp;(t&lt;&lt;1|t&gt;&gt;&gt;31)}let r,i,s=this.chain_[0],o=this.chain_[1],a=this.chain_[2],c=this.chain_[3],u=this.chain_[4];for(let e=0;e&lt;80;e++){e&lt;40?e&lt;20?(r=c^o&amp;(a^c),i=1518500249):(r=o^a^c,i=1859775393):e&lt;60?(r=o&amp;a|c&amp;(o|a),i=2400959708):(r=o^a^c,i=3395469782);const t=(s&lt;&lt;5|s&gt;&gt;&gt;27)+r+u+i+n[e]&amp;4294967295;u=c,c=a,a=4294967295&amp;(o&lt;&lt;30|o&gt;&gt;&gt;2),o=s,s=t}this.chain_[0]=this.chain_[0]+s&amp;4294967295,this.chain_[1]=this.chain_[1]+o&amp;4294967295,this.chain_[2]=this.chain_[2]+a&amp;4294967295,this.chain_[3]=this.chain_[3]+c&amp;4294967295,this.chain_[4]=this.chain_[4]+u&amp;4294967295}update(e,t){if(null==e)return;void 0===t&amp;&amp;(t=e.length);const n=t-this.blockSize;let r=0;const i=this.buf_;let s=this.inbuf_;for(;r&lt;t;){if(0===s)for(;r&lt;=n;)this.compress_(e,r),r+=this.blockSize;if("string"==typeof e){for(;r&lt;t;)if(i[s]=e.charCodeAt(r),++s,++r,s===this.blockSize){this.compress_(i),s=0;break}}else for(;r&lt;t;)if(i[s]=e[r],++s,++r,s===this.blockSize){this.compress_(i),s=0;break}}this.inbuf_=s,this.total_+=t}digest(){const e=[];let t=8*this.total_;this.inbuf_&lt;56?this.update(this.pad_,56-this.inbuf_):this.update(this.pad_,this.blockSize-(this.inbuf_-56));for(let e=this.blockSize-1;e&gt;=56;e--)this.buf_[e]=255&amp;t,t/=256;this.compress_(this.buf_);let n=0;for(let t=0;t&lt;5;t++)for(let r=24;r&gt;=0;r-=8)e[n]=this.chain_[t]&gt;&gt;r&amp;255,++n;return e}}function j(e,t){return`${e} failed: ${t} argument `}const z=function(e){const t=[];let n=0;for(let r=0;r&lt;e.length;r++){let s=e.charCodeAt(r);if(s&gt;=55296&amp;&amp;s&lt;=56319){const t=s-55296;r++,i(r&lt;e.length,"Surrogate pair missing trail surrogate."),s=65536+(t&lt;&lt;10)+(e.charCodeAt(r)-56320)}s&lt;128?t[n++]=s:s&lt;2048?(t[n++]=s&gt;&gt;6|192,t[n++]=63&amp;s|128):s&lt;65536?(t[n++]=s&gt;&gt;12|224,t[n++]=s&gt;&gt;6&amp;63|128,t[n++]=63&amp;s|128):(t[n++]=s&gt;&gt;18|240,t[n++]=s&gt;&gt;12&amp;63|128,t[n++]=s&gt;&gt;6&amp;63|128,t[n++]=63&amp;s|128)}return t},$=function(e){let t=0;for(let n=0;n&lt;e.length;n++){const r=e.charCodeAt(n);r&lt;128?t++:r&lt;2048?t+=2:r&gt;=55296&amp;&amp;r&lt;=56319?(t+=4,n++):t+=3}return t},K=1e3,G=2,W=144e5,H=.5;function Q(e,t=K,n=G){const r=t*Math.pow(n,e),i=Math.round(H*r*(Math.random()-.5)*2);return Math.min(W,r+i)}function Y(e){return e&amp;&amp;e._delegate?e._delegate:e}},722:(e,t,n)=&gt;{const r=n(905).R;t.s=function(e){if(e||(e=1),!n.y.meta||!n.y.meta.url)throw console.error("__system_context__",n.y),Error("systemjs-webpack-interop was provided an unknown SystemJS context. Expected context.meta.url, but none was provided");n.p=r(n.y.meta.url,e)}},905:(e,t,n)=&gt;{t.R=function(e,t){var n=document.createElement("a");n.href=e;for(var r="/"===n.pathname[0]?n.pathname:"/"+n.pathname,i=0,s=r.length;i!==t&amp;&amp;s&gt;=0;)"/"===r[--s]&amp;&amp;i++;if(i!==t)throw Error("systemjs-webpack-interop: rootDirectoryLevel ("+t+") is greater than the number of directories ("+i+") in the URL path "+e);var o=r.slice(0,s+1);return n.protocol+"//"+n.host+o};Number.isInteger},657:(e,t,n)=&gt;{"use strict";n.d(t,{Jn:()=&gt;L,qX:()=&gt;R,Xd:()=&gt;P,wN:()=&gt;M,Mq:()=&gt;V,C6:()=&gt;B,ZF:()=&gt;q,KN:()=&gt;U});var r=n(463),i=n(333),s=n(444);const o=(e,t)=&gt;t.some((t=&gt;e instanceof t));let a,c;const u=new WeakMap,l=new WeakMap,h=new WeakMap,d=new WeakMap,f=new WeakMap;let p={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return l.get(e);if("objectStoreNames"===t)return e.objectStoreNames||h.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return m(e[t])},set:(e,t,n)=&gt;(e[t]=n,!0),has:(e,t)=&gt;e instanceof IDBTransaction&amp;&amp;("done"===t||"store"===t)||t in e};function g(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(c||(c=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(y(this),e),m(u.get(this))}:function(...e){return m(t.apply(y(this),e))}:function(e,...n){const r=t.call(y(this),e,...n);return h.set(r,e.sort?e.sort():[e]),m(r)}:(e instanceof IDBTransaction&amp;&amp;function(e){if(l.has(e))return;const t=new Promise(((t,n)=&gt;{const r=()=&gt;{e.removeEventListener("complete",i),e.removeEventListener("error",s),e.removeEventListener("abort",s)},i=()=&gt;{t(),r()},s=()=&gt;{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",s),e.addEventListener("abort",s)}));l.set(e,t)}(e),o(e,a||(a=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,p):e);var t}function m(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=&gt;{const r=()=&gt;{e.removeEventListener("success",i),e.removeEventListener("error",s)},i=()=&gt;{t(m(e.result)),r()},s=()=&gt;{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",s)}));return t.then((t=&gt;{t instanceof IDBCursor&amp;&amp;u.set(t,e)})).catch((()=&gt;{})),f.set(t,e),t}(e);if(d.has(e))return d.get(e);const t=g(e);return t!==e&amp;&amp;(d.set(e,t),f.set(t,e)),t}const y=e=&gt;f.get(e),_=["get","getKey","getAll","getAllKeys","count"],v=["put","add","delete","clear"],w=new Map;function b(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(w.get(t))return w.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=v.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&amp;&amp;!_.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,i?"readwrite":"readonly");let o=s.store;return r&amp;&amp;(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&amp;&amp;s.done]))[0]};return w.set(t,s),s}var I;I=p,p={...I,get:(e,t,n)=&gt;b(e,t)||I.get(e,t,n),has:(e,t)=&gt;!!b(e,t)||I.has(e,t)};class C{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map((e=&gt;{if(function(e){const t=e.getComponent();return"VERSION"===(null==t?void 0:t.type)}(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null})).filter((e=&gt;e)).join(" ")}}const T="@firebase/app",E="0.9.9",S=new i.Yd("@firebase/app"),x="[DEFAULT]",k={[T]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","fire-js":"fire-js",firebase:"fire-js-all"},D=new Map,N=new Map;function A(e,t){try{e.container.addComponent(t)}catch(n){S.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function P(e){const t=e.name;if(N.has(t))return S.debug(`There were multiple attempts to register component ${t}.`),!1;N.set(t,e);for(const t of D.values())A(t,e);return!0}function R(e,t){const n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&amp;&amp;n.triggerHeartbeat(),e.container.getProvider(t)}function M(e,t,n=x){R(e,t).clearInstance(n)}const F=new s.LL("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call Firebase App.initializeApp()","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","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}."});class O{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new r.wA("app",(()=&gt;this),"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw F.create("app-deleted",{appName:this._name})}}const L="9.21.0";function q(e,t={}){let n=e;"object"!=typeof t&amp;&amp;(t={name:t});const i=Object.assign({name:x,automaticDataCollectionEnabled:!1},t),o=i.name;if("string"!=typeof o||!o)throw F.create("bad-app-name",{appName:String(o)});if(n||(n=(0,s.aH)()),!n)throw F.create("no-options");const a=D.get(o);if(a){if((0,s.vZ)(n,a.options)&amp;&amp;(0,s.vZ)(i,a.config))return a;throw F.create("duplicate-app",{appName:o})}const c=new r.H0(o);for(const e of N.values())c.addComponent(e);const u=new O(n,i,c);return D.set(o,u),u}function V(e=x){const t=D.get(e);if(!t&amp;&amp;e===x)return q();if(!t)throw F.create("no-app",{appName:e});return t}function B(){return Array.from(D.values())}function U(e,t,n){var i;let s=null!==(i=k[e])&amp;&amp;void 0!==i?i:e;n&amp;&amp;(s+=`-${n}`);const o=s.match(/\s|\//),a=t.match(/\s|\//);if(o||a){const e=[`Unable to register library "${s}" with version "${t}":`];return o&amp;&amp;e.push(`library name "${s}" contains illegal characters (whitespace or "/")`),o&amp;&amp;a&amp;&amp;e.push("and"),a&amp;&amp;e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void S.warn(e.join(" "))}P(new r.wA(`${s}-version`,(()=&gt;({library:s,version:t})),"VERSION"))}const j="firebase-heartbeat-database",z=1,$="firebase-heartbeat-store";let K=null;function G(){return K||(K=function(e,t,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(e,t),a=m(o);return r&amp;&amp;o.addEventListener("upgradeneeded",(e=&gt;{r(m(o.result),e.oldVersion,e.newVersion,m(o.transaction),e)})),n&amp;&amp;o.addEventListener("blocked",(e=&gt;n(e.oldVersion,e.newVersion,e))),a.then((e=&gt;{s&amp;&amp;e.addEventListener("close",(()=&gt;s())),i&amp;&amp;e.addEventListener("versionchange",(e=&gt;i(e.oldVersion,e.newVersion,e)))})).catch((()=&gt;{})),a}(j,z,{upgrade:(e,t)=&gt;{0===t&amp;&amp;e.createObjectStore($)}}).catch((e=&gt;{throw F.create("idb-open",{originalErrorMessage:e.message})}))),K}async function W(e,t){try{const n=(await G()).transaction($,"readwrite"),r=n.objectStore($);return await r.put(t,H(e)),n.done}catch(e){if(e instanceof s.ZR)S.warn(e.message);else{const t=F.create("idb-set",{originalErrorMessage:null==e?void 0:e.message});S.warn(t.message)}}}function H(e){return`${e.name}!${e.options.appId}`}class Q{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new X(t),this._heartbeatsCachePromise=this._storage.read().then((e=&gt;(this._heartbeatsCache=e,e)))}async triggerHeartbeat(){const e=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),t=Y();if(null===this._heartbeatsCache&amp;&amp;(this._heartbeatsCache=await this._heartbeatsCachePromise),this._heartbeatsCache.lastSentHeartbeatDate!==t&amp;&amp;!this._heartbeatsCache.heartbeats.some((e=&gt;e.date===t)))return this._heartbeatsCache.heartbeats.push({date:t,agent:e}),this._heartbeatsCache.heartbeats=this._heartbeatsCache.heartbeats.filter((e=&gt;{const t=new Date(e.date).valueOf();return Date.now()-t&lt;=2592e6})),this._storage.overwrite(this._heartbeatsCache)}async getHeartbeatsHeader(){if(null===this._heartbeatsCache&amp;&amp;await this._heartbeatsCachePromise,null===this._heartbeatsCache||0===this._heartbeatsCache.heartbeats.length)return"";const e=Y(),{heartbeatsToSend:t,unsentEntries:n}=function(e,t=1024){const n=[];let r=e.slice();for(const i of e){const e=n.find((e=&gt;e.agent===i.agent));if(e){if(e.dates.push(i.date),J(n)&gt;t){e.dates.pop();break}}else if(n.push({agent:i.agent,dates:[i.date]}),J(n)&gt;t){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}(this._heartbeatsCache.heartbeats),r=(0,s.L)(JSON.stringify({version:2,heartbeats:t}));return this._heartbeatsCache.lastSentHeartbeatDate=e,n.length&gt;0?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),r}}function Y(){return(new Date).toISOString().substring(0,10)}class X{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!(0,s.hl)()&amp;&amp;(0,s.eu)().then((()=&gt;!0)).catch((()=&gt;!1))}async read(){return await this._canUseIndexedDBPromise&amp;&amp;await async function(e){try{return(await G()).transaction($).objectStore($).get(H(e))}catch(e){if(e instanceof s.ZR)S.warn(e.message);else{const t=F.create("idb-get",{originalErrorMessage:null==e?void 0:e.message});S.warn(t.message)}}}(this.app)||{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const n=await this.read();return W(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&amp;&amp;void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){var t;if(await this._canUseIndexedDBPromise){const n=await this.read();return W(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&amp;&amp;void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:[...n.heartbeats,...e.heartbeats]})}}}function J(e){return(0,s.L)(JSON.stringify({version:2,heartbeats:e})).length}P(new r.wA("platform-logger",(e=&gt;new C(e)),"PRIVATE")),P(new r.wA("heartbeat",(e=&gt;new Q(e)),"PRIVATE")),U(T,E,""),U(T,E,"esm2017"),U("fire-js","")},463:(e,t,n)=&gt;{"use strict";n.d(t,{H0:()=&gt;a,wA:()=&gt;i});var r=n(444);class i{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}}const s="[DEFAULT]";class o{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const e=new r.BH;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{const n=this.getOrInitializeService({instanceIdentifier:t});n&amp;&amp;e.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const n=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),r=null!==(t=null==e?void 0:e.optional)&amp;&amp;void 0!==t&amp;&amp;t;if(!this.isInitialized(n)&amp;&amp;!this.shouldAutoInitialize()){if(r)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(e){if(r)return null;throw e}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if(function(e){return"EAGER"===e.instantiationMode}(e))try{this.getOrInitializeService({instanceIdentifier:s})}catch(e){}for(const[e,t]of this.instancesDeferred.entries()){const n=this.normalizeInstanceIdentifier(e);try{const e=this.getOrInitializeService({instanceIdentifier:n});t.resolve(e)}catch(e){}}}}clearInstance(e=s){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter((e=&gt;"INTERNAL"in e)).map((e=&gt;e.INTERNAL.delete())),...e.filter((e=&gt;"_delete"in e)).map((e=&gt;e._delete()))])}isComponentSet(){return null!=this.component}isInitialized(e=s){return this.instances.has(e)}getOptions(e=s){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:n,options:t});for(const[e,t]of this.instancesDeferred.entries())n===this.normalizeInstanceIdentifier(e)&amp;&amp;t.resolve(r);return r}onInit(e,t){var n;const r=this.normalizeInstanceIdentifier(t),i=null!==(n=this.onInitCallbacks.get(r))&amp;&amp;void 0!==n?n:new Set;i.add(e),this.onInitCallbacks.set(r,i);const s=this.instances.get(r);return s&amp;&amp;e(s,r),()=&gt;{i.delete(e)}}invokeOnInitCallbacks(e,t){const n=this.onInitCallbacks.get(t);if(n)for(const r of n)try{r(e,t)}catch(e){}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&amp;&amp;this.component&amp;&amp;(n=this.component.instanceFactory(this.container,{instanceIdentifier:(r=e,r===s?void 0:r),options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch(e){}var r;return n||null}normalizeInstanceIdentifier(e=s){return this.component?this.component.multipleInstances?e:s:e}shouldAutoInitialize(){return!!this.component&amp;&amp;"EXPLICIT"!==this.component.instantiationMode}}class a{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&amp;&amp;this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new o(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}},333:(e,t,n)=&gt;{"use strict";n.d(t,{Yd:()=&gt;u,in:()=&gt;i});const r=[];var i;!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"}(i||(i={}));const s={debug:i.DEBUG,verbose:i.VERBOSE,info:i.INFO,warn:i.WARN,error:i.ERROR,silent:i.SILENT},o=i.INFO,a={[i.DEBUG]:"log",[i.VERBOSE]:"log",[i.INFO]:"info",[i.WARN]:"warn",[i.ERROR]:"error"},c=(e,t,...n)=&gt;{if(t&lt;e.logLevel)return;const r=(new Date).toISOString(),i=a[t];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[i](`[${r}]  ${e.name}:`,...n)};class u{constructor(e){this.name=e,this._logLevel=o,this._logHandler=c,this._userLogHandler=null,r.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in i))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?s[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&amp;&amp;this._userLogHandler(this,i.DEBUG,...e),this._logHandler(this,i.DEBUG,...e)}log(...e){this._userLogHandler&amp;&amp;this._userLogHandler(this,i.VERBOSE,...e),this._logHandler(this,i.VERBOSE,...e)}info(...e){this._userLogHandler&amp;&amp;this._userLogHandler(this,i.INFO,...e),this._logHandler(this,i.INFO,...e)}warn(...e){this._userLogHandler&amp;&amp;this._userLogHandler(this,i.WARN,...e),this._logHandler(this,i.WARN,...e)}error(...e){this._userLogHandler&amp;&amp;this._userLogHandler(this,i.ERROR,...e),this._logHandler(this,i.ERROR,...e)}}},977:(e,t,n)=&gt;{"use strict";n.d(t,{C6:()=&gt;r.C6,ZF:()=&gt;r.ZF});var r=n(657);(0,r.KN)("firebase","9.21.0","app")},679:(e,t,n)=&gt;{"use strict";n.r(t),n.d(t,{DataSnapshot:()=&gt;Pi,Database:()=&gt;xs,OnDisconnect:()=&gt;Si,QueryConstraint:()=&gt;Zi,TransactionResult:()=&gt;Vs,_QueryImpl:()=&gt;xi,_QueryParams:()=&gt;yt,_ReferenceImpl:()=&gt;Ai,_TEST_ACCESS_forceRestClient:()=&gt;js,_TEST_ACCESS_hijackHash:()=&gt;Us,_repoManagerDatabaseFromApp:()=&gt;Ss,_setSDKVersion:()=&gt;l,_validatePathString:()=&gt;Lr,_validateWritablePath:()=&gt;Vr,child:()=&gt;Fi,connectDatabaseEmulator:()=&gt;Ps,enableLogging:()=&gt;Fs,endAt:()=&gt;ts,endBefore:()=&gt;rs,equalTo:()=&gt;bs,forceLongPolling:()=&gt;Ns,forceWebSockets:()=&gt;Ds,get:()=&gt;zi,getDatabase:()=&gt;As,goOffline:()=&gt;Rs,goOnline:()=&gt;Ms,increment:()=&gt;qs,limitToFirst:()=&gt;us,limitToLast:()=&gt;hs,off:()=&gt;Ji,onChildAdded:()=&gt;Hi,onChildChanged:()=&gt;Qi,onChildMoved:()=&gt;Yi,onChildRemoved:()=&gt;Xi,onDisconnect:()=&gt;Oi,onValue:()=&gt;Wi,orderByChild:()=&gt;fs,orderByKey:()=&gt;gs,orderByPriority:()=&gt;ys,orderByValue:()=&gt;vs,push:()=&gt;Li,query:()=&gt;Is,ref:()=&gt;Ri,refFromURL:()=&gt;Mi,remove:()=&gt;qi,runTransaction:()=&gt;Bs,serverTimestamp:()=&gt;Ls,set:()=&gt;Vi,setPriority:()=&gt;Bi,setWithPriority:()=&gt;Ui,startAfter:()=&gt;as,startAt:()=&gt;ss,update:()=&gt;ji});var r=n(657),i=n(463),s=n(444),o=n(333);const a="@firebase/database",c="0.14.4";let u="";function l(e){u=e}class h{constructor(e){this.domStorage_=e,this.prefix_="firebase:"}set(e,t){null==t?this.domStorage_.removeItem(this.prefixedName_(e)):this.domStorage_.setItem(this.prefixedName_(e),(0,s.Wl)(t))}get(e){const t=this.domStorage_.getItem(this.prefixedName_(e));return null==t?null:(0,s.cI)(t)}remove(e){this.domStorage_.removeItem(this.prefixedName_(e))}prefixedName_(e){return this.prefix_+e}toString(){return this.domStorage_.toString()}}class d{constructor(){this.cache_={},this.isInMemoryStorage=!0}set(e,t){null==t?delete this.cache_[e]:this.cache_[e]=t}get(e){return(0,s.r3)(this.cache_,e)?this.cache_[e]:null}remove(e){delete this.cache_[e]}}const f=function(e){try{if("undefined"!=typeof window&amp;&amp;void 0!==window[e]){const t=window[e];return t.setItem("firebase:sentinel","cache"),t.removeItem("firebase:sentinel"),new h(t)}}catch(e){}return new d},p=f("localStorage"),g=f("sessionStorage"),m=new o.Yd("@firebase/database"),y=function(){let e=1;return function(){return e++}}(),_=function(e){const t=(0,s.dS)(e),n=new s.gQ;n.update(t);const r=n.digest();return s.US.encodeByteArray(r)},v=function(...e){let t="";for(let n=0;n&lt;e.length;n++){const r=e[n];Array.isArray(r)||r&amp;&amp;"object"==typeof r&amp;&amp;"number"==typeof r.length?t+=v.apply(null,r):t+="object"==typeof r?(0,s.Wl)(r):r,t+=" "}return t};let w=null,b=!0;const I=function(e,t){(0,s.hu)(!t||!0===e||!1===e,"Can't turn on custom loggers persistently."),!0===e?(m.logLevel=o.in.VERBOSE,w=m.log.bind(m),t&amp;&amp;g.set("logging_enabled",!0)):"function"==typeof e?w=e:(w=null,g.remove("logging_enabled"))},C=function(...e){if(!0===b&amp;&amp;(b=!1,null===w&amp;&amp;!0===g.get("logging_enabled")&amp;&amp;I(!0)),w){const t=v.apply(null,e);w(t)}},T=function(e){return function(...t){C(e,...t)}},E=function(...e){const t="FIREBASE INTERNAL ERROR: "+v(...e);m.error(t)},S=function(...e){const t=`FIREBASE FATAL ERROR: ${v(...e)}`;throw m.error(t),new Error(t)},x=function(...e){const t="FIREBASE WARNING: "+v(...e);m.warn(t)},k=function(e){return"number"==typeof e&amp;&amp;(e!=e||e===Number.POSITIVE_INFINITY||e===Number.NEGATIVE_INFINITY)},D="[MIN_NAME]",N="[MAX_NAME]",A=function(e,t){if(e===t)return 0;if(e===D||t===N)return-1;if(t===D||e===N)return 1;{const n=V(e),r=V(t);return null!==n?null!==r?n-r==0?e.length-t.length:n-r:-1:null!==r?1:e&lt;t?-1:1}},P=function(e,t){return e===t?0:e&lt;t?-1:1},R=function(e,t){if(t&amp;&amp;e in t)return t[e];throw new Error("Missing required key ("+e+") in object: "+(0,s.Wl)(t))},M=function(e){if("object"!=typeof e||null===e)return(0,s.Wl)(e);const t=[];for(const n in e)t.push(n);t.sort();let n="{";for(let r=0;r&lt;t.length;r++)0!==r&amp;&amp;(n+=","),n+=(0,s.Wl)(t[r]),n+=":",n+=M(e[t[r]]);return n+="}",n},F=function(e,t){const n=e.length;if(n&lt;=t)return[e];const r=[];for(let i=0;i&lt;n;i+=t)i+t&gt;n?r.push(e.substring(i,n)):r.push(e.substring(i,i+t));return r};function O(e,t){for(const n in e)e.hasOwnProperty(n)&amp;&amp;t(n,e[n])}const L=function(e){(0,s.hu)(!k(e),"Invalid JSON number");let t,n,r,i,o;0===e?(n=0,r=0,t=1/e==-1/0?1:0):(t=e&lt;0,(e=Math.abs(e))&gt;=Math.pow(2,-1022)?(i=Math.min(Math.floor(Math.log(e)/Math.LN2),1023),n=i+1023,r=Math.round(e*Math.pow(2,52-i)-Math.pow(2,52))):(n=0,r=Math.round(e/Math.pow(2,-1074))));const a=[];for(o=52;o;o-=1)a.push(r%2?1:0),r=Math.floor(r/2);for(o=11;o;o-=1)a.push(n%2?1:0),n=Math.floor(n/2);a.push(t?1:0),a.reverse();const c=a.join("");let u="";for(o=0;o&lt;64;o+=8){let e=parseInt(c.substr(o,8),2).toString(16);1===e.length&amp;&amp;(e="0"+e),u+=e}return u.toLowerCase()},q=new RegExp("^-?(0*)\\d{1,10}$"),V=function(e){if(q.test(e)){const t=Number(e);if(t&gt;=-2147483648&amp;&amp;t&lt;=2147483647)return t}return null},B=function(e){try{e()}catch(e){setTimeout((()=&gt;{const t=e.stack||"";throw x("Exception was thrown by user callback.",t),e}),Math.floor(0))}},U=function(e,t){const n=setTimeout(e,t);return"number"==typeof n&amp;&amp;"undefined"!=typeof Deno&amp;&amp;Deno.unrefTimer?Deno.unrefTimer(n):"object"==typeof n&amp;&amp;n.unref&amp;&amp;n.unref(),n};class j{constructor(e,t){this.appName_=e,this.appCheckProvider=t,this.appCheck=null==t?void 0:t.getImmediate({optional:!0}),this.appCheck||null==t||t.get().then((e=&gt;this.appCheck=e))}getToken(e){return this.appCheck?this.appCheck.getToken(e):new Promise(((t,n)=&gt;{setTimeout((()=&gt;{this.appCheck?this.getToken(e).then(t,n):t(null)}),0)}))}addTokenChangeListener(e){var t;null===(t=this.appCheckProvider)||void 0===t||t.get().then((t=&gt;t.addTokenListener(e)))}notifyForInvalidToken(){x(`Provided AppCheck credentials for the app named "${this.appName_}" are invalid. This usually indicates your app was not initialized correctly.`)}}class z{constructor(e,t,n){this.appName_=e,this.firebaseOptions_=t,this.authProvider_=n,this.auth_=null,this.auth_=n.getImmediate({optional:!0}),this.auth_||n.onInit((e=&gt;this.auth_=e))}getToken(e){return this.auth_?this.auth_.getToken(e).catch((e=&gt;e&amp;&amp;"auth/token-not-initialized"===e.code?(C("Got auth/token-not-initialized error.  Treating as null token."),null):Promise.reject(e))):new Promise(((t,n)=&gt;{setTimeout((()=&gt;{this.auth_?this.getToken(e).then(t,n):t(null)}),0)}))}addTokenChangeListener(e){this.auth_?this.auth_.addAuthTokenListener(e):this.authProvider_.get().then((t=&gt;t.addAuthTokenListener(e)))}removeTokenChangeListener(e){this.authProvider_.get().then((t=&gt;t.removeAuthTokenListener(e)))}notifyForInvalidToken(){let e='Provided authentication credentials for the app named "'+this.appName_+'" are invalid. This usually indicates your app was not initialized correctly. ';"credential"in this.firebaseOptions_?e+='Make sure the "credential" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':"serviceAccount"in this.firebaseOptions_?e+='Make sure the "serviceAccount" property provided to initializeApp() is authorized to access the specified "databaseURL" and is from the correct project.':e+='Make sure the "apiKey" and "databaseURL" properties provided to initializeApp() match the values provided for your app at https://console.firebase.google.com/.',x(e)}}class ${constructor(e){this.accessToken=e}getToken(e){return Promise.resolve({accessToken:this.accessToken})}addTokenChangeListener(e){e(this.accessToken)}removeTokenChangeListener(e){}notifyForInvalidToken(){}}$.OWNER="owner";const K="5",G=/(console\.firebase|firebase-console-\w+\.corp|firebase\.corp)\.google\.com/,W="ac",H="websocket",Q="long_polling";class Y{constructor(e,t,n,r,i=!1,s="",o=!1,a=!1){this.secure=t,this.namespace=n,this.webSocketOnly=r,this.nodeAdmin=i,this.persistenceKey=s,this.includeNamespaceInQueryParams=o,this.isUsingEmulator=a,this._host=e.toLowerCase(),this._domain=this._host.substr(this._host.indexOf(".")+1),this.internalHost=p.get("host:"+e)||this._host}isCacheableHost(){return"s-"===this.internalHost.substr(0,2)}isCustomHost(){return"firebaseio.com"!==this._domain&amp;&amp;"firebaseio-demo.com"!==this._domain}get host(){return this._host}set host(e){e!==this.internalHost&amp;&amp;(this.internalHost=e,this.isCacheableHost()&amp;&amp;p.set("host:"+this._host,this.internalHost))}toString(){let e=this.toURLString();return this.persistenceKey&amp;&amp;(e+="&lt;"+this.persistenceKey+"&gt;"),e}toURLString(){const e=this.secure?"https://":"http://",t=this.includeNamespaceInQueryParams?`?ns=${this.namespace}`:"";return`${e}${this.host}/${t}`}}function X(e,t,n){let r;if((0,s.hu)("string"==typeof t,"typeof type must == string"),(0,s.hu)("object"==typeof n,"typeof params must == object"),t===H)r=(e.secure?"wss://":"ws://")+e.internalHost+"/.ws?";else{if(t!==Q)throw new Error("Unknown connection type: "+t);r=(e.secure?"https://":"http://")+e.internalHost+"/.lp?"}(function(e){return e.host!==e.internalHost||e.isCustomHost()||e.includeNamespaceInQueryParams})(e)&amp;&amp;(n.ns=e.namespace);const i=[];return O(n,((e,t)=&gt;{i.push(e+"="+t)})),r+i.join("&amp;")}class J{constructor(){this.counters_={}}incrementCounter(e,t=1){(0,s.r3)(this.counters_,e)||(this.counters_[e]=0),this.counters_[e]+=t}get(){return(0,s.p$)(this.counters_)}}const Z={},ee={};function te(e){const t=e.toString();return Z[t]||(Z[t]=new J),Z[t]}class ne{constructor(e){this.onMessage_=e,this.pendingResponses=[],this.currentResponseNum=0,this.closeAfterResponse=-1,this.onClose=null}closeAfter(e,t){this.closeAfterResponse=e,this.onClose=t,this.closeAfterResponse&lt;this.currentResponseNum&amp;&amp;(this.onClose(),this.onClose=null)}handleResponse(e,t){for(this.pendingResponses[e]=t;this.pendingResponses[this.currentResponseNum];){const e=this.pendingResponses[this.currentResponseNum];delete this.pendingResponses[this.currentResponseNum];for(let t=0;t&lt;e.length;++t)e[t]&amp;&amp;B((()=&gt;{this.onMessage_(e[t])}));if(this.currentResponseNum===this.closeAfterResponse){this.onClose&amp;&amp;(this.onClose(),this.onClose=null);break}this.currentResponseNum++}}}const re="start";class ie{constructor(e,t,n,r,i,s,o){this.connId=e,this.repoInfo=t,this.applicationId=n,this.appCheckToken=r,this.authToken=i,this.transportSessionId=s,this.lastSessionId=o,this.bytesSent=0,this.bytesReceived=0,this.everConnected_=!1,this.log_=T(e),this.stats_=te(t),this.urlFn=e=&gt;(this.appCheckToken&amp;&amp;(e[W]=this.appCheckToken),X(t,Q,e))}open(e,t){this.curSegmentNum=0,this.onDisconnect_=t,this.myPacketOrderer=new ne(e),this.isClosed_=!1,this.connectTimeoutTimer_=setTimeout((()=&gt;{this.log_("Timed out trying to connect."),this.onClosed_(),this.connectTimeoutTimer_=null}),Math.floor(3e4)),function(e){if((0,s.Yr)()||"complete"===document.readyState)e();else{let t=!1;const n=function(){document.body?t||(t=!0,e()):setTimeout(n,Math.floor(10))};document.addEventListener?(document.addEventListener("DOMContentLoaded",n,!1),window.addEventListener("load",n,!1)):document.attachEvent&amp;&amp;(document.attachEvent("onreadystatechange",(()=&gt;{"complete"===document.readyState&amp;&amp;n()})),window.attachEvent("onload",n))}}((()=&gt;{if(this.isClosed_)return;this.scriptTagHolder=new se(((...e)=&gt;{const[t,n,r,i,s]=e;if(this.incrementIncomingBytes_(e),this.scriptTagHolder)if(this.connectTimeoutTimer_&amp;&amp;(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null),this.everConnected_=!0,t===re)this.id=n,this.password=r;else{if("close"!==t)throw new Error("Unrecognized command received: "+t);n?(this.scriptTagHolder.sendNewPolls=!1,this.myPacketOrderer.closeAfter(n,(()=&gt;{this.onClosed_()}))):this.onClosed_()}}),((...e)=&gt;{const[t,n]=e;this.incrementIncomingBytes_(e),this.myPacketOrderer.handleResponse(t,n)}),(()=&gt;{this.onClosed_()}),this.urlFn);const e={};e[re]="t",e.ser=Math.floor(1e8*Math.random()),this.scriptTagHolder.uniqueCallbackIdentifier&amp;&amp;(e.cb=this.scriptTagHolder.uniqueCallbackIdentifier),e.v=K,this.transportSessionId&amp;&amp;(e.s=this.transportSessionId),this.lastSessionId&amp;&amp;(e.ls=this.lastSessionId),this.applicationId&amp;&amp;(e.p=this.applicationId),this.appCheckToken&amp;&amp;(e[W]=this.appCheckToken),"undefined"!=typeof location&amp;&amp;location.hostname&amp;&amp;G.test(location.hostname)&amp;&amp;(e.r="f");const t=this.urlFn(e);this.log_("Connecting via long-poll to "+t),this.scriptTagHolder.addTag(t,(()=&gt;{}))}))}start(){this.scriptTagHolder.startLongPoll(this.id,this.password),this.addDisconnectPingFrame(this.id,this.password)}static forceAllow(){ie.forceAllow_=!0}static forceDisallow(){ie.forceDisallow_=!0}static isAvailable(){return!((0,s.Yr)()||!ie.forceAllow_&amp;&amp;(ie.forceDisallow_||"undefined"==typeof document||null==document.createElement||"object"==typeof window&amp;&amp;window.chrome&amp;&amp;window.chrome.extension&amp;&amp;!/^chrome/.test(window.location.href)||"object"==typeof Windows&amp;&amp;"object"==typeof Windows.UI))}markConnectionHealthy(){}shutdown_(){this.isClosed_=!0,this.scriptTagHolder&amp;&amp;(this.scriptTagHolder.close(),this.scriptTagHolder=null),this.myDisconnFrame&amp;&amp;(document.body.removeChild(this.myDisconnFrame),this.myDisconnFrame=null),this.connectTimeoutTimer_&amp;&amp;(clearTimeout(this.connectTimeoutTimer_),this.connectTimeoutTimer_=null)}onClosed_(){this.isClosed_||(this.log_("Longpoll is closing itself"),this.shutdown_(),this.onDisconnect_&amp;&amp;(this.onDisconnect_(this.everConnected_),this.onDisconnect_=null))}close(){this.isClosed_||(this.log_("Longpoll is being closed."),this.shutdown_())}send(e){const t=(0,s.Wl)(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const n=(0,s.h$)(t),r=F(n,1840);for(let e=0;e&lt;r.length;e++)this.scriptTagHolder.enqueueSegment(this.curSegmentNum,r.length,r[e]),this.curSegmentNum++}addDisconnectPingFrame(e,t){if((0,s.Yr)())return;this.myDisconnFrame=document.createElement("iframe");const n={dframe:"t"};n.id=e,n.pw=t,this.myDisconnFrame.src=this.urlFn(n),this.myDisconnFrame.style.display="none",document.body.appendChild(this.myDisconnFrame)}incrementIncomingBytes_(e){const t=(0,s.Wl)(e).length;this.bytesReceived+=t,this.stats_.incrementCounter("bytes_received",t)}}class se{constructor(e,t,n,r){if(this.onDisconnect=n,this.urlFn=r,this.outstandingRequests=new Set,this.pendingSegs=[],this.currentSerial=Math.floor(1e8*Math.random()),this.sendNewPolls=!0,(0,s.Yr)())this.commandCB=e,this.onMessageCB=t;else{this.uniqueCallbackIdentifier=y(),window["pLPCommand"+this.uniqueCallbackIdentifier]=e,window["pRTLPCB"+this.uniqueCallbackIdentifier]=t,this.myIFrame=se.createIFrame_();let n="";this.myIFrame.src&amp;&amp;"javascript:"===this.myIFrame.src.substr(0,11)&amp;&amp;(n='&lt;script&gt;document.domain="'+document.domain+'";&lt;\/script&gt;');const r="&lt;html&gt;&lt;body&gt;"+n+"&lt;/body&gt;&lt;/html&gt;";try{this.myIFrame.doc.open(),this.myIFrame.doc.write(r),this.myIFrame.doc.close()}catch(e){C("frame writing exception"),e.stack&amp;&amp;C(e.stack),C(e)}}}static createIFrame_(){const e=document.createElement("iframe");if(e.style.display="none",!document.body)throw"Document body has not initialized. Wait to initialize Firebase until after the document is ready.";document.body.appendChild(e);try{e.contentWindow.document||C("No IE domain setting required")}catch(t){const n=document.domain;e.src="javascript:void((function(){document.open();document.domain='"+n+"';document.close();})())"}return e.contentDocument?e.doc=e.contentDocument:e.contentWindow?e.doc=e.contentWindow.document:e.document&amp;&amp;(e.doc=e.document),e}close(){this.alive=!1,this.myIFrame&amp;&amp;(this.myIFrame.doc.body.textContent="",setTimeout((()=&gt;{null!==this.myIFrame&amp;&amp;(document.body.removeChild(this.myIFrame),this.myIFrame=null)}),Math.floor(0)));const e=this.onDisconnect;e&amp;&amp;(this.onDisconnect=null,e())}startLongPoll(e,t){for(this.myID=e,this.myPW=t,this.alive=!0;this.newRequest_(););}newRequest_(){if(this.alive&amp;&amp;this.sendNewPolls&amp;&amp;this.outstandingRequests.size&lt;(this.pendingSegs.length&gt;0?2:1)){this.currentSerial++;const e={};e.id=this.myID,e.pw=this.myPW,e.ser=this.currentSerial;let t=this.urlFn(e),n="",r=0;for(;this.pendingSegs.length&gt;0&amp;&amp;this.pendingSegs[0].d.length+30+n.length&lt;=1870;){const e=this.pendingSegs.shift();n=n+"&amp;seg"+r+"="+e.seg+"&amp;ts"+r+"="+e.ts+"&amp;d"+r+"="+e.d,r++}return t+=n,this.addLongPollTag_(t,this.currentSerial),!0}return!1}enqueueSegment(e,t,n){this.pendingSegs.push({seg:e,ts:t,d:n}),this.alive&amp;&amp;this.newRequest_()}addLongPollTag_(e,t){this.outstandingRequests.add(t);const n=()=&gt;{this.outstandingRequests.delete(t),this.newRequest_()},r=setTimeout(n,Math.floor(25e3));this.addTag(e,(()=&gt;{clearTimeout(r),n()}))}addTag(e,t){(0,s.Yr)()?this.doNodeLongPoll(e,t):setTimeout((()=&gt;{try{if(!this.sendNewPolls)return;const n=this.myIFrame.doc.createElement("script");n.type="text/javascript",n.async=!0,n.src=e,n.onload=n.onreadystatechange=function(){const e=n.readyState;e&amp;&amp;"loaded"!==e&amp;&amp;"complete"!==e||(n.onload=n.onreadystatechange=null,n.parentNode&amp;&amp;n.parentNode.removeChild(n),t())},n.onerror=()=&gt;{C("Long-poll script failed to load: "+e),this.sendNewPolls=!1,this.close()},this.myIFrame.doc.body.appendChild(n)}catch(e){}}),Math.floor(1))}}let oe=null;"undefined"!=typeof MozWebSocket?oe=MozWebSocket:"undefined"!=typeof WebSocket&amp;&amp;(oe=WebSocket);class ae{constructor(e,t,n,r,i,s,o){this.connId=e,this.applicationId=n,this.appCheckToken=r,this.authToken=i,this.keepaliveTimer=null,this.frames=null,this.totalFrames=0,this.bytesSent=0,this.bytesReceived=0,this.log_=T(this.connId),this.stats_=te(t),this.connURL=ae.connectionURL_(t,s,o,r,n),this.nodeAdmin=t.nodeAdmin}static connectionURL_(e,t,n,r,i){const o={};return o.v=K,!(0,s.Yr)()&amp;&amp;"undefined"!=typeof location&amp;&amp;location.hostname&amp;&amp;G.test(location.hostname)&amp;&amp;(o.r="f"),t&amp;&amp;(o.s=t),n&amp;&amp;(o.ls=n),r&amp;&amp;(o[W]=r),i&amp;&amp;(o.p=i),X(e,H,o)}open(e,t){this.onDisconnect=t,this.onMessage=e,this.log_("Websocket connecting to "+this.connURL),this.everConnected_=!1,p.set("previous_websocket_failure",!0);try{let e;if((0,s.Yr)()){const t=this.nodeAdmin?"AdminNode":"Node";e={headers:{"User-Agent":`Firebase/${K}/${u}/${process.platform}/${t}`,"X-Firebase-GMPID":this.applicationId||""}},this.authToken&amp;&amp;(e.headers.Authorization=`Bearer ${this.authToken}`),this.appCheckToken&amp;&amp;(e.headers["X-Firebase-AppCheck"]=this.appCheckToken);const n=process.env,r=0===this.connURL.indexOf("wss://")?n.HTTPS_PROXY||n.https_proxy:n.HTTP_PROXY||n.http_proxy;r&amp;&amp;(e.proxy={origin:r})}this.mySock=new oe(this.connURL,[],e)}catch(e){this.log_("Error instantiating WebSocket.");const t=e.message||e.data;return t&amp;&amp;this.log_(t),void this.onClosed_()}this.mySock.onopen=()=&gt;{this.log_("Websocket connected."),this.everConnected_=!0},this.mySock.onclose=()=&gt;{this.log_("Websocket connection was disconnected."),this.mySock=null,this.onClosed_()},this.mySock.onmessage=e=&gt;{this.handleIncomingFrame(e)},this.mySock.onerror=e=&gt;{this.log_("WebSocket error.  Closing connection.");const t=e.message||e.data;t&amp;&amp;this.log_(t),this.onClosed_()}}start(){}static forceDisallow(){ae.forceDisallow_=!0}static isAvailable(){let e=!1;if("undefined"!=typeof navigator&amp;&amp;navigator.userAgent){const t=/Android ([0-9]{0,}\.[0-9]{0,})/,n=navigator.userAgent.match(t);n&amp;&amp;n.length&gt;1&amp;&amp;parseFloat(n[1])&lt;4.4&amp;&amp;(e=!0)}return!e&amp;&amp;null!==oe&amp;&amp;!ae.forceDisallow_}static previouslyFailed(){return p.isInMemoryStorage||!0===p.get("previous_websocket_failure")}markConnectionHealthy(){p.remove("previous_websocket_failure")}appendFrame_(e){if(this.frames.push(e),this.frames.length===this.totalFrames){const e=this.frames.join("");this.frames=null;const t=(0,s.cI)(e);this.onMessage(t)}}handleNewFrameCount_(e){this.totalFrames=e,this.frames=[]}extractFrameCount_(e){if((0,s.hu)(null===this.frames,"We already have a frame buffer"),e.length&lt;=6){const t=Number(e);if(!isNaN(t))return this.handleNewFrameCount_(t),null}return this.handleNewFrameCount_(1),e}handleIncomingFrame(e){if(null===this.mySock)return;const t=e.data;if(this.bytesReceived+=t.length,this.stats_.incrementCounter("bytes_received",t.length),this.resetKeepAlive(),null!==this.frames)this.appendFrame_(t);else{const e=this.extractFrameCount_(t);null!==e&amp;&amp;this.appendFrame_(e)}}send(e){this.resetKeepAlive();const t=(0,s.Wl)(e);this.bytesSent+=t.length,this.stats_.incrementCounter("bytes_sent",t.length);const n=F(t,16384);n.length&gt;1&amp;&amp;this.sendString_(String(n.length));for(let e=0;e&lt;n.length;e++)this.sendString_(n[e])}shutdown_(){this.isClosed_=!0,this.keepaliveTimer&amp;&amp;(clearInterval(this.keepaliveTimer),this.keepaliveTimer=null),this.mySock&amp;&amp;(this.mySock.close(),this.mySock=null)}onClosed_(){this.isClosed_||(this.log_("WebSocket is closing itself"),this.shutdown_(),this.onDisconnect&amp;&amp;(this.onDisconnect(this.everConnected_),this.onDisconnect=null))}close(){this.isClosed_||(this.log_("WebSocket is being closed"),this.shutdown_())}resetKeepAlive(){clearInterval(this.keepaliveTimer),this.keepaliveTimer=setInterval((()=&gt;{this.mySock&amp;&amp;this.sendString_("0"),this.resetKeepAlive()}),Math.floor(45e3))}sendString_(e){try{this.mySock.send(e)}catch(e){this.log_("Exception thrown from WebSocket.send():",e.message||e.data,"Closing connection."),setTimeout(this.onClosed_.bind(this),0)}}}ae.responsesRequiredToBeHealthy=2,ae.healthyTimeout=3e4;class ce{constructor(e){this.initTransports_(e)}static get ALL_TRANSPORTS(){return[ie,ae]}static get IS_TRANSPORT_INITIALIZED(){return this.globalTransportInitialized_}initTransports_(e){const t=ae&amp;&amp;ae.isAvailable();let n=t&amp;&amp;!ae.previouslyFailed();if(e.webSocketOnly&amp;&amp;(t||x("wss:// URL used, but browser isn't known to support websockets.  Trying anyway."),n=!0),n)this.transports_=[ae];else{const e=this.transports_=[];for(const t of ce.ALL_TRANSPORTS)t&amp;&amp;t.isAvailable()&amp;&amp;e.push(t);ce.globalTransportInitialized_=!0}}initialTransport(){if(this.transports_.length&gt;0)return this.transports_[0];throw new Error("No transports available")}upgradeTransport(){return this.transports_.length&gt;1?this.transports_[1]:null}}ce.globalTransportInitialized_=!1;class ue{constructor(e,t,n,r,i,s,o,a,c,u){this.id=e,this.repoInfo_=t,this.applicationId_=n,this.appCheckToken_=r,this.authToken_=i,this.onMessage_=s,this.onReady_=o,this.onDisconnect_=a,this.onKill_=c,this.lastSessionId=u,this.connectionCount=0,this.pendingDataMessages=[],this.state_=0,this.log_=T("c:"+this.id+":"),this.transportManager_=new ce(t),this.log_("Connection created"),this.start_()}start_(){const e=this.transportManager_.initialTransport();this.conn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,null,this.lastSessionId),this.primaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.conn_),n=this.disconnReceiver_(this.conn_);this.tx_=this.conn_,this.rx_=this.conn_,this.secondaryConn_=null,this.isHealthy_=!1,setTimeout((()=&gt;{this.conn_&amp;&amp;this.conn_.open(t,n)}),Math.floor(0));const r=e.healthyTimeout||0;r&gt;0&amp;&amp;(this.healthyTimeout_=U((()=&gt;{this.healthyTimeout_=null,this.isHealthy_||(this.conn_&amp;&amp;this.conn_.bytesReceived&gt;102400?(this.log_("Connection exceeded healthy timeout but has received "+this.conn_.bytesReceived+" bytes.  Marking connection healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()):this.conn_&amp;&amp;this.conn_.bytesSent&gt;10240?this.log_("Connection exceeded healthy timeout but has sent "+this.conn_.bytesSent+" bytes.  Leaving connection alive."):(this.log_("Closing unhealthy connection after timeout."),this.close()))}),Math.floor(r)))}nextTransportId_(){return"c:"+this.id+":"+this.connectionCount++}disconnReceiver_(e){return t=&gt;{e===this.conn_?this.onConnectionLost_(t):e===this.secondaryConn_?(this.log_("Secondary connection lost."),this.onSecondaryConnectionLost_()):this.log_("closing an old connection")}}connReceiver_(e){return t=&gt;{2!==this.state_&amp;&amp;(e===this.rx_?this.onPrimaryMessageReceived_(t):e===this.secondaryConn_?this.onSecondaryMessageReceived_(t):this.log_("message on old connection"))}}sendRequest(e){const t={t:"d",d:e};this.sendData_(t)}tryCleanupConnection(){this.tx_===this.secondaryConn_&amp;&amp;this.rx_===this.secondaryConn_&amp;&amp;(this.log_("cleaning up and promoting a connection: "+this.secondaryConn_.connId),this.conn_=this.secondaryConn_,this.secondaryConn_=null)}onSecondaryControl_(e){if("t"in e){const t=e.t;"a"===t?this.upgradeIfSecondaryHealthy_():"r"===t?(this.log_("Got a reset on secondary, closing it"),this.secondaryConn_.close(),this.tx_!==this.secondaryConn_&amp;&amp;this.rx_!==this.secondaryConn_||this.close()):"o"===t&amp;&amp;(this.log_("got pong on secondary."),this.secondaryResponsesRequired_--,this.upgradeIfSecondaryHealthy_())}}onSecondaryMessageReceived_(e){const t=R("t",e),n=R("d",e);if("c"===t)this.onSecondaryControl_(n);else{if("d"!==t)throw new Error("Unknown protocol layer: "+t);this.pendingDataMessages.push(n)}}upgradeIfSecondaryHealthy_(){this.secondaryResponsesRequired_&lt;=0?(this.log_("Secondary connection is healthy."),this.isHealthy_=!0,this.secondaryConn_.markConnectionHealthy(),this.proceedWithUpgrade_()):(this.log_("sending ping on secondary."),this.secondaryConn_.send({t:"c",d:{t:"p",d:{}}}))}proceedWithUpgrade_(){this.secondaryConn_.start(),this.log_("sending client ack on secondary"),this.secondaryConn_.send({t:"c",d:{t:"a",d:{}}}),this.log_("Ending transmission on primary"),this.conn_.send({t:"c",d:{t:"n",d:{}}}),this.tx_=this.secondaryConn_,this.tryCleanupConnection()}onPrimaryMessageReceived_(e){const t=R("t",e),n=R("d",e);"c"===t?this.onControl_(n):"d"===t&amp;&amp;this.onDataMessage_(n)}onDataMessage_(e){this.onPrimaryResponse_(),this.onMessage_(e)}onPrimaryResponse_(){this.isHealthy_||(this.primaryResponsesRequired_--,this.primaryResponsesRequired_&lt;=0&amp;&amp;(this.log_("Primary connection is healthy."),this.isHealthy_=!0,this.conn_.markConnectionHealthy()))}onControl_(e){const t=R("t",e);if("d"in e){const n=e.d;if("h"===t){const e=Object.assign({},n);this.repoInfo_.isUsingEmulator&amp;&amp;(e.h=this.repoInfo_.host),this.onHandshake_(e)}else if("n"===t){this.log_("recvd end transmission on primary"),this.rx_=this.secondaryConn_;for(let e=0;e&lt;this.pendingDataMessages.length;++e)this.onDataMessage_(this.pendingDataMessages[e]);this.pendingDataMessages=[],this.tryCleanupConnection()}else"s"===t?this.onConnectionShutdown_(n):"r"===t?this.onReset_(n):"e"===t?E("Server Error: "+n):"o"===t?(this.log_("got pong on primary."),this.onPrimaryResponse_(),this.sendPingOnPrimaryIfNecessary_()):E("Unknown control packet command: "+t)}}onHandshake_(e){const t=e.ts,n=e.v,r=e.h;this.sessionId=e.s,this.repoInfo_.host=r,0===this.state_&amp;&amp;(this.conn_.start(),this.onConnectionEstablished_(this.conn_,t),K!==n&amp;&amp;x("Protocol version mismatch detected"),this.tryStartUpgrade_())}tryStartUpgrade_(){const e=this.transportManager_.upgradeTransport();e&amp;&amp;this.startUpgrade_(e)}startUpgrade_(e){this.secondaryConn_=new e(this.nextTransportId_(),this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,this.sessionId),this.secondaryResponsesRequired_=e.responsesRequiredToBeHealthy||0;const t=this.connReceiver_(this.secondaryConn_),n=this.disconnReceiver_(this.secondaryConn_);this.secondaryConn_.open(t,n),U((()=&gt;{this.secondaryConn_&amp;&amp;(this.log_("Timed out trying to upgrade."),this.secondaryConn_.close())}),Math.floor(6e4))}onReset_(e){this.log_("Reset packet received.  New host: "+e),this.repoInfo_.host=e,1===this.state_?this.close():(this.closeConnections_(),this.start_())}onConnectionEstablished_(e,t){this.log_("Realtime connection established."),this.conn_=e,this.state_=1,this.onReady_&amp;&amp;(this.onReady_(t,this.sessionId),this.onReady_=null),0===this.primaryResponsesRequired_?(this.log_("Primary connection is healthy."),this.isHealthy_=!0):U((()=&gt;{this.sendPingOnPrimaryIfNecessary_()}),Math.floor(5e3))}sendPingOnPrimaryIfNecessary_(){this.isHealthy_||1!==this.state_||(this.log_("sending ping on primary."),this.sendData_({t:"c",d:{t:"p",d:{}}}))}onSecondaryConnectionLost_(){const e=this.secondaryConn_;this.secondaryConn_=null,this.tx_!==e&amp;&amp;this.rx_!==e||this.close()}onConnectionLost_(e){this.conn_=null,e||0!==this.state_?1===this.state_&amp;&amp;this.log_("Realtime connection lost."):(this.log_("Realtime connection failed."),this.repoInfo_.isCacheableHost()&amp;&amp;(p.remove("host:"+this.repoInfo_.host),this.repoInfo_.internalHost=this.repoInfo_.host)),this.close()}onConnectionShutdown_(e){this.log_("Connection shutdown command received. Shutting down..."),this.onKill_&amp;&amp;(this.onKill_(e),this.onKill_=null),this.onDisconnect_=null,this.close()}sendData_(e){if(1!==this.state_)throw"Connection is not connected";this.tx_.send(e)}close(){2!==this.state_&amp;&amp;(this.log_("Closing realtime connection."),this.state_=2,this.closeConnections_(),this.onDisconnect_&amp;&amp;(this.onDisconnect_(),this.onDisconnect_=null))}closeConnections_(){this.log_("Shutting down all connections"),this.conn_&amp;&amp;(this.conn_.close(),this.conn_=null),this.secondaryConn_&amp;&amp;(this.secondaryConn_.close(),this.secondaryConn_=null),this.healthyTimeout_&amp;&amp;(clearTimeout(this.healthyTimeout_),this.healthyTimeout_=null)}}class le{put(e,t,n,r){}merge(e,t,n,r){}refreshAuthToken(e){}refreshAppCheckToken(e){}onDisconnectPut(e,t,n){}onDisconnectMerge(e,t,n){}onDisconnectCancel(e,t){}reportStats(e){}}class he{constructor(e){this.allowedEvents_=e,this.listeners_={},(0,s.hu)(Array.isArray(e)&amp;&amp;e.length&gt;0,"Requires a non-empty array")}trigger(e,...t){if(Array.isArray(this.listeners_[e])){const n=[...this.listeners_[e]];for(let e=0;e&lt;n.length;e++)n[e].callback.apply(n[e].context,t)}}on(e,t,n){this.validateEventType_(e),this.listeners_[e]=this.listeners_[e]||[],this.listeners_[e].push({callback:t,context:n});const r=this.getInitialEvent(e);r&amp;&amp;t.apply(n,r)}off(e,t,n){this.validateEventType_(e);const r=this.listeners_[e]||[];for(let e=0;e&lt;r.length;e++)if(r[e].callback===t&amp;&amp;(!n||n===r[e].context))return void r.splice(e,1)}validateEventType_(e){(0,s.hu)(this.allowedEvents_.find((t=&gt;t===e)),"Unknown event: "+e)}}class de extends he{constructor(){super(["online"]),this.online_=!0,"undefined"==typeof window||void 0===window.addEventListener||(0,s.uI)()||(window.addEventListener("online",(()=&gt;{this.online_||(this.online_=!0,this.trigger("online",!0))}),!1),window.addEventListener("offline",(()=&gt;{this.online_&amp;&amp;(this.online_=!1,this.trigger("online",!1))}),!1))}static getInstance(){return new de}getInitialEvent(e){return(0,s.hu)("online"===e,"Unknown event type: "+e),[this.online_]}currentlyOnline(){return this.online_}}class fe{constructor(e,t){if(void 0===t){this.pieces_=e.split("/");let t=0;for(let e=0;e&lt;this.pieces_.length;e++)this.pieces_[e].length&gt;0&amp;&amp;(this.pieces_[t]=this.pieces_[e],t++);this.pieces_.length=t,this.pieceNum_=0}else this.pieces_=e,this.pieceNum_=t}toString(){let e="";for(let t=this.pieceNum_;t&lt;this.pieces_.length;t++)""!==this.pieces_[t]&amp;&amp;(e+="/"+this.pieces_[t]);return e||"/"}}function pe(){return new fe("")}function ge(e){return e.pieceNum_&gt;=e.pieces_.length?null:e.pieces_[e.pieceNum_]}function me(e){return e.pieces_.length-e.pieceNum_}function ye(e){let t=e.pieceNum_;return t&lt;e.pieces_.length&amp;&amp;t++,new fe(e.pieces_,t)}function _e(e){return e.pieceNum_&lt;e.pieces_.length?e.pieces_[e.pieces_.length-1]:null}function ve(e,t=0){return e.pieces_.slice(e.pieceNum_+t)}function we(e){if(e.pieceNum_&gt;=e.pieces_.length)return null;const t=[];for(let n=e.pieceNum_;n&lt;e.pieces_.length-1;n++)t.push(e.pieces_[n]);return new fe(t,0)}function be(e,t){const n=[];for(let t=e.pieceNum_;t&lt;e.pieces_.length;t++)n.push(e.pieces_[t]);if(t instanceof fe)for(let e=t.pieceNum_;e&lt;t.pieces_.length;e++)n.push(t.pieces_[e]);else{const e=t.split("/");for(let t=0;t&lt;e.length;t++)e[t].length&gt;0&amp;&amp;n.push(e[t])}return new fe(n,0)}function Ie(e){return e.pieceNum_&gt;=e.pieces_.length}function Ce(e,t){const n=ge(e),r=ge(t);if(null===n)return t;if(n===r)return Ce(ye(e),ye(t));throw new Error("INTERNAL ERROR: innerPath ("+t+") is not within outerPath ("+e+")")}function Te(e,t){const n=ve(e,0),r=ve(t,0);for(let e=0;e&lt;n.length&amp;&amp;e&lt;r.length;e++){const t=A(n[e],r[e]);if(0!==t)return t}return n.length===r.length?0:n.length&lt;r.length?-1:1}function Ee(e,t){if(me(e)!==me(t))return!1;for(let n=e.pieceNum_,r=t.pieceNum_;n&lt;=e.pieces_.length;n++,r++)if(e.pieces_[n]!==t.pieces_[r])return!1;return!0}function Se(e,t){let n=e.pieceNum_,r=t.pieceNum_;if(me(e)&gt;me(t))return!1;for(;n&lt;e.pieces_.length;){if(e.pieces_[n]!==t.pieces_[r])return!1;++n,++r}return!0}class xe{constructor(e,t){this.errorPrefix_=t,this.parts_=ve(e,0),this.byteLength_=Math.max(1,this.parts_.length);for(let e=0;e&lt;this.parts_.length;e++)this.byteLength_+=(0,s.ug)(this.parts_[e]);ke(this)}}function ke(e){if(e.byteLength_&gt;768)throw new Error(e.errorPrefix_+"has a key path longer than 768 bytes ("+e.byteLength_+").");if(e.parts_.length&gt;32)throw new Error(e.errorPrefix_+"path specified exceeds the maximum depth that can be written (32) or object contains a cycle "+De(e))}function De(e){return 0===e.parts_.length?"":"in property '"+e.parts_.join(".")+"'"}class Ne extends he{constructor(){let e,t;super(["visible"]),"undefined"!=typeof document&amp;&amp;void 0!==document.addEventListener&amp;&amp;(void 0!==document.hidden?(t="visibilitychange",e="hidden"):void 0!==document.mozHidden?(t="mozvisibilitychange",e="mozHidden"):void 0!==document.msHidden?(t="msvisibilitychange",e="msHidden"):void 0!==document.webkitHidden&amp;&amp;(t="webkitvisibilitychange",e="webkitHidden")),this.visible_=!0,t&amp;&amp;document.addEventListener(t,(()=&gt;{const t=!document[e];t!==this.visible_&amp;&amp;(this.visible_=t,this.trigger("visible",t))}),!1)}static getInstance(){return new Ne}getInitialEvent(e){return(0,s.hu)("visible"===e,"Unknown event type: "+e),[this.visible_]}}const Ae=1e3;class Pe extends le{constructor(e,t,n,r,i,o,a,c){if(super(),this.repoInfo_=e,this.applicationId_=t,this.onDataUpdate_=n,this.onConnectStatus_=r,this.onServerInfoUpdate_=i,this.authTokenProvider_=o,this.appCheckTokenProvider_=a,this.authOverride_=c,this.id=Pe.nextPersistentConnectionId_++,this.log_=T("p:"+this.id+":"),this.interruptReasons_={},this.listens=new Map,this.outstandingPuts_=[],this.outstandingGets_=[],this.outstandingPutCount_=0,this.outstandingGetCount_=0,this.onDisconnectRequestQueue_=[],this.connected_=!1,this.reconnectDelay_=Ae,this.maxReconnectDelay_=3e5,this.securityDebugCallback_=null,this.lastSessionId=null,this.establishConnectionTimer_=null,this.visible_=!1,this.requestCBHash_={},this.requestNumber_=0,this.realtime_=null,this.authToken_=null,this.appCheckToken_=null,this.forceTokenRefresh_=!1,this.invalidAuthTokenCount_=0,this.invalidAppCheckTokenCount_=0,this.firstConnection_=!0,this.lastConnectionAttemptTime_=null,this.lastConnectionEstablishedTime_=null,c&amp;&amp;!(0,s.Yr)())throw new Error("Auth override specified in options, but not supported on non Node.js platforms");Ne.getInstance().on("visible",this.onVisible_,this),-1===e.host.indexOf("fblocal")&amp;&amp;de.getInstance().on("online",this.onOnline_,this)}sendRequest(e,t,n){const r=++this.requestNumber_,i={r,a:e,b:t};this.log_((0,s.Wl)(i)),(0,s.hu)(this.connected_,"sendRequest call when we're not connected not allowed."),this.realtime_.sendRequest(i),n&amp;&amp;(this.requestCBHash_[r]=n)}get(e){this.initConnection_();const t=new s.BH,n={action:"g",request:{p:e._path.toString(),q:e._queryObject},onComplete:e=&gt;{const n=e.d;"ok"===e.s?t.resolve(n):t.reject(n)}};this.outstandingGets_.push(n),this.outstandingGetCount_++;const r=this.outstandingGets_.length-1;return this.connected_&amp;&amp;this.sendGet_(r),t.promise}listen(e,t,n,r){this.initConnection_();const i=e._queryIdentifier,o=e._path.toString();this.log_("Listen called for "+o+" "+i),this.listens.has(o)||this.listens.set(o,new Map),(0,s.hu)(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"listen() called for non-default but complete query"),(0,s.hu)(!this.listens.get(o).has(i),"listen() called twice for same path/queryId.");const a={onComplete:r,hashFn:t,query:e,tag:n};this.listens.get(o).set(i,a),this.connected_&amp;&amp;this.sendListen_(a)}sendGet_(e){const t=this.outstandingGets_[e];this.sendRequest("g",t.request,(n=&gt;{delete this.outstandingGets_[e],this.outstandingGetCount_--,0===this.outstandingGetCount_&amp;&amp;(this.outstandingGets_=[]),t.onComplete&amp;&amp;t.onComplete(n)}))}sendListen_(e){const t=e.query,n=t._path.toString(),r=t._queryIdentifier;this.log_("Listen on "+n+" for "+r);const i={p:n};e.tag&amp;&amp;(i.q=t._queryObject,i.t=e.tag),i.h=e.hashFn(),this.sendRequest("q",i,(i=&gt;{const s=i.d,o=i.s;Pe.warnOnListenWarnings_(s,t),(this.listens.get(n)&amp;&amp;this.listens.get(n).get(r))===e&amp;&amp;(this.log_("listen response",i),"ok"!==o&amp;&amp;this.removeListen_(n,r),e.onComplete&amp;&amp;e.onComplete(o,s))}))}static warnOnListenWarnings_(e,t){if(e&amp;&amp;"object"==typeof e&amp;&amp;(0,s.r3)(e,"w")){const n=(0,s.DV)(e,"w");if(Array.isArray(n)&amp;&amp;~n.indexOf("no_index")){const e='".indexOn": "'+t._queryParams.getIndex().toString()+'"',n=t._path.toString();x(`Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding ${e} at ${n} to your security rules for better performance.`)}}}refreshAuthToken(e){this.authToken_=e,this.log_("Auth token refreshed"),this.authToken_?this.tryAuth():this.connected_&amp;&amp;this.sendRequest("unauth",{},(()=&gt;{})),this.reduceReconnectDelayIfAdminCredential_(e)}reduceReconnectDelayIfAdminCredential_(e){(e&amp;&amp;40===e.length||(0,s.GJ)(e))&amp;&amp;(this.log_("Admin auth credential detected.  Reducing max reconnect time."),this.maxReconnectDelay_=3e4)}refreshAppCheckToken(e){this.appCheckToken_=e,this.log_("App check token refreshed"),this.appCheckToken_?this.tryAppCheck():this.connected_&amp;&amp;this.sendRequest("unappeck",{},(()=&gt;{}))}tryAuth(){if(this.connected_&amp;&amp;this.authToken_){const e=this.authToken_,t=(0,s.w9)(e)?"auth":"gauth",n={cred:e};null===this.authOverride_?n.noauth=!0:"object"==typeof this.authOverride_&amp;&amp;(n.authvar=this.authOverride_),this.sendRequest(t,n,(t=&gt;{const n=t.s,r=t.d||"error";this.authToken_===e&amp;&amp;("ok"===n?this.invalidAuthTokenCount_=0:this.onAuthRevoked_(n,r))}))}}tryAppCheck(){this.connected_&amp;&amp;this.appCheckToken_&amp;&amp;this.sendRequest("appcheck",{token:this.appCheckToken_},(e=&gt;{const t=e.s,n=e.d||"error";"ok"===t?this.invalidAppCheckTokenCount_=0:this.onAppCheckRevoked_(t,n)}))}unlisten(e,t){const n=e._path.toString(),r=e._queryIdentifier;this.log_("Unlisten called for "+n+" "+r),(0,s.hu)(e._queryParams.isDefault()||!e._queryParams.loadsAllData(),"unlisten() called for non-default but complete query"),this.removeListen_(n,r)&amp;&amp;this.connected_&amp;&amp;this.sendUnlisten_(n,r,e._queryObject,t)}sendUnlisten_(e,t,n,r){this.log_("Unlisten on "+e+" for "+t);const i={p:e};r&amp;&amp;(i.q=n,i.t=r),this.sendRequest("n",i)}onDisconnectPut(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("o",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"o",data:t,onComplete:n})}onDisconnectMerge(e,t,n){this.initConnection_(),this.connected_?this.sendOnDisconnect_("om",e,t,n):this.onDisconnectRequestQueue_.push({pathString:e,action:"om",data:t,onComplete:n})}onDisconnectCancel(e,t){this.initConnection_(),this.connected_?this.sendOnDisconnect_("oc",e,null,t):this.onDisconnectRequestQueue_.push({pathString:e,action:"oc",data:null,onComplete:t})}sendOnDisconnect_(e,t,n,r){const i={p:t,d:n};this.log_("onDisconnect "+e,i),this.sendRequest(e,i,(e=&gt;{r&amp;&amp;setTimeout((()=&gt;{r(e.s,e.d)}),Math.floor(0))}))}put(e,t,n,r){this.putInternal("p",e,t,n,r)}merge(e,t,n,r){this.putInternal("m",e,t,n,r)}putInternal(e,t,n,r,i){this.initConnection_();const s={p:t,d:n};void 0!==i&amp;&amp;(s.h=i),this.outstandingPuts_.push({action:e,request:s,onComplete:r}),this.outstandingPutCount_++;const o=this.outstandingPuts_.length-1;this.connected_?this.sendPut_(o):this.log_("Buffering put: "+t)}sendPut_(e){const t=this.outstandingPuts_[e].action,n=this.outstandingPuts_[e].request,r=this.outstandingPuts_[e].onComplete;this.outstandingPuts_[e].queued=this.connected_,this.sendRequest(t,n,(n=&gt;{this.log_(t+" response",n),delete this.outstandingPuts_[e],this.outstandingPutCount_--,0===this.outstandingPutCount_&amp;&amp;(this.outstandingPuts_=[]),r&amp;&amp;r(n.s,n.d)}))}reportStats(e){if(this.connected_){const t={c:e};this.log_("reportStats",t),this.sendRequest("s",t,(e=&gt;{if("ok"!==e.s){const t=e.d;this.log_("reportStats","Error sending stats: "+t)}}))}}onDataMessage_(e){if("r"in e){this.log_("from server: "+(0,s.Wl)(e));const t=e.r,n=this.requestCBHash_[t];n&amp;&amp;(delete this.requestCBHash_[t],n(e.b))}else{if("error"in e)throw"A server-side error has occurred: "+e.error;"a"in e&amp;&amp;this.onDataPush_(e.a,e.b)}}onDataPush_(e,t){this.log_("handleServerMessage",e,t),"d"===e?this.onDataUpdate_(t.p,t.d,!1,t.t):"m"===e?this.onDataUpdate_(t.p,t.d,!0,t.t):"c"===e?this.onListenRevoked_(t.p,t.q):"ac"===e?this.onAuthRevoked_(t.s,t.d):"apc"===e?this.onAppCheckRevoked_(t.s,t.d):"sd"===e?this.onSecurityDebugPacket_(t):E("Unrecognized action received from server: "+(0,s.Wl)(e)+"\nAre you using the latest client?")}onReady_(e,t){this.log_("connection ready"),this.connected_=!0,this.lastConnectionEstablishedTime_=(new Date).getTime(),this.handleTimestamp_(e),this.lastSessionId=t,this.firstConnection_&amp;&amp;this.sendConnectStats_(),this.restoreState_(),this.firstConnection_=!1,this.onConnectStatus_(!0)}scheduleConnect_(e){(0,s.hu)(!this.realtime_,"Scheduling a connect when we're already connected/ing?"),this.establishConnectionTimer_&amp;&amp;clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=setTimeout((()=&gt;{this.establishConnectionTimer_=null,this.establishConnection_()}),Math.floor(e))}initConnection_(){!this.realtime_&amp;&amp;this.firstConnection_&amp;&amp;this.scheduleConnect_(0)}onVisible_(e){e&amp;&amp;!this.visible_&amp;&amp;this.reconnectDelay_===this.maxReconnectDelay_&amp;&amp;(this.log_("Window became visible.  Reducing delay."),this.reconnectDelay_=Ae,this.realtime_||this.scheduleConnect_(0)),this.visible_=e}onOnline_(e){e?(this.log_("Browser went online."),this.reconnectDelay_=Ae,this.realtime_||this.scheduleConnect_(0)):(this.log_("Browser went offline.  Killing connection."),this.realtime_&amp;&amp;this.realtime_.close())}onRealtimeDisconnect_(){if(this.log_("data client disconnected"),this.connected_=!1,this.realtime_=null,this.cancelSentTransactions_(),this.requestCBHash_={},this.shouldReconnect_()){this.visible_?this.lastConnectionEstablishedTime_&amp;&amp;((new Date).getTime()-this.lastConnectionEstablishedTime_&gt;3e4&amp;&amp;(this.reconnectDelay_=Ae),this.lastConnectionEstablishedTime_=null):(this.log_("Window isn't visible.  Delaying reconnect."),this.reconnectDelay_=this.maxReconnectDelay_,this.lastConnectionAttemptTime_=(new Date).getTime());const e=(new Date).getTime()-this.lastConnectionAttemptTime_;let t=Math.max(0,this.reconnectDelay_-e);t=Math.random()*t,this.log_("Trying to reconnect in "+t+"ms"),this.scheduleConnect_(t),this.reconnectDelay_=Math.min(this.maxReconnectDelay_,1.3*this.reconnectDelay_)}this.onConnectStatus_(!1)}async establishConnection_(){if(this.shouldReconnect_()){this.log_("Making a connection attempt"),this.lastConnectionAttemptTime_=(new Date).getTime(),this.lastConnectionEstablishedTime_=null;const e=this.onDataMessage_.bind(this),t=this.onReady_.bind(this),n=this.onRealtimeDisconnect_.bind(this),r=this.id+":"+Pe.nextConnectionId_++,i=this.lastSessionId;let o=!1,a=null;const c=function(){a?a.close():(o=!0,n())},u=function(e){(0,s.hu)(a,"sendRequest call when we're not connected not allowed."),a.sendRequest(e)};this.realtime_={close:c,sendRequest:u};const l=this.forceTokenRefresh_;this.forceTokenRefresh_=!1;try{const[s,c]=await Promise.all([this.authTokenProvider_.getToken(l),this.appCheckTokenProvider_.getToken(l)]);o?C("getToken() completed but was canceled"):(C("getToken() completed. Creating connection."),this.authToken_=s&amp;&amp;s.accessToken,this.appCheckToken_=c&amp;&amp;c.token,a=new ue(r,this.repoInfo_,this.applicationId_,this.appCheckToken_,this.authToken_,e,t,n,(e=&gt;{x(e+" ("+this.repoInfo_.toString()+")"),this.interrupt("server_kill")}),i))}catch(e){this.log_("Failed to get token: "+e),o||(this.repoInfo_.nodeAdmin&amp;&amp;x(e),c())}}}interrupt(e){C("Interrupting connection for reason: "+e),this.interruptReasons_[e]=!0,this.realtime_?this.realtime_.close():(this.establishConnectionTimer_&amp;&amp;(clearTimeout(this.establishConnectionTimer_),this.establishConnectionTimer_=null),this.connected_&amp;&amp;this.onRealtimeDisconnect_())}resume(e){C("Resuming connection for reason: "+e),delete this.interruptReasons_[e],(0,s.xb)(this.interruptReasons_)&amp;&amp;(this.reconnectDelay_=Ae,this.realtime_||this.scheduleConnect_(0))}handleTimestamp_(e){const t=e-(new Date).getTime();this.onServerInfoUpdate_({serverTimeOffset:t})}cancelSentTransactions_(){for(let e=0;e&lt;this.outstandingPuts_.length;e++){const t=this.outstandingPuts_[e];t&amp;&amp;"h"in t.request&amp;&amp;t.queued&amp;&amp;(t.onComplete&amp;&amp;t.onComplete("disconnect"),delete this.outstandingPuts_[e],this.outstandingPutCount_--)}0===this.outstandingPutCount_&amp;&amp;(this.outstandingPuts_=[])}onListenRevoked_(e,t){let n;n=t?t.map((e=&gt;M(e))).join("$"):"default";const r=this.removeListen_(e,n);r&amp;&amp;r.onComplete&amp;&amp;r.onComplete("permission_denied")}removeListen_(e,t){const n=new fe(e).toString();let r;if(this.listens.has(n)){const e=this.listens.get(n);r=e.get(t),e.delete(t),0===e.size&amp;&amp;this.listens.delete(n)}else r=void 0;return r}onAuthRevoked_(e,t){C("Auth token revoked: "+e+"/"+t),this.authToken_=null,this.forceTokenRefresh_=!0,this.realtime_.close(),"invalid_token"!==e&amp;&amp;"permission_denied"!==e||(this.invalidAuthTokenCount_++,this.invalidAuthTokenCount_&gt;=3&amp;&amp;(this.reconnectDelay_=3e4,this.authTokenProvider_.notifyForInvalidToken()))}onAppCheckRevoked_(e,t){C("App check token revoked: "+e+"/"+t),this.appCheckToken_=null,this.forceTokenRefresh_=!0,"invalid_token"!==e&amp;&amp;"permission_denied"!==e||(this.invalidAppCheckTokenCount_++,this.invalidAppCheckTokenCount_&gt;=3&amp;&amp;this.appCheckTokenProvider_.notifyForInvalidToken())}onSecurityDebugPacket_(e){this.securityDebugCallback_?this.securityDebugCallback_(e):"msg"in e&amp;&amp;console.log("FIREBASE: "+e.msg.replace("\n","\nFIREBASE: "))}restoreState_(){this.tryAuth(),this.tryAppCheck();for(const e of this.listens.values())for(const t of e.values())this.sendListen_(t);for(let e=0;e&lt;this.outstandingPuts_.length;e++)this.outstandingPuts_[e]&amp;&amp;this.sendPut_(e);for(;this.onDisconnectRequestQueue_.length;){const e=this.onDisconnectRequestQueue_.shift();this.sendOnDisconnect_(e.action,e.pathString,e.data,e.onComplete)}for(let e=0;e&lt;this.outstandingGets_.length;e++)this.outstandingGets_[e]&amp;&amp;this.sendGet_(e)}sendConnectStats_(){const e={};let t="js";(0,s.Yr)()&amp;&amp;(t=this.repoInfo_.nodeAdmin?"admin_node":"node"),e["sdk."+t+"."+u.replace(/\./g,"-")]=1,(0,s.uI)()?e["framework.cordova"]=1:(0,s.b$)()&amp;&amp;(e["framework.reactnative"]=1),this.reportStats(e)}shouldReconnect_(){const e=de.getInstance().currentlyOnline();return(0,s.xb)(this.interruptReasons_)&amp;&amp;e}}Pe.nextPersistentConnectionId_=0,Pe.nextConnectionId_=0;class Re{constructor(e,t){this.name=e,this.node=t}static Wrap(e,t){return new Re(e,t)}}class Me{getCompare(){return this.compare.bind(this)}indexedValueChanged(e,t){const n=new Re(D,e),r=new Re(D,t);return 0!==this.compare(n,r)}minPost(){return Re.MIN}}let Fe;class Oe extends Me{static get __EMPTY_NODE(){return Fe}static set __EMPTY_NODE(e){Fe=e}compare(e,t){return A(e.name,t.name)}isDefinedOn(e){throw(0,s.g5)("KeyIndex.isDefinedOn not expected to be called.")}indexedValueChanged(e,t){return!1}minPost(){return Re.MIN}maxPost(){return new Re(N,Fe)}makePost(e,t){return(0,s.hu)("string"==typeof e,"KeyIndex indexValue must always be a string."),new Re(e,Fe)}toString(){return".key"}}const Le=new Oe;class qe{constructor(e,t,n,r,i=null){this.isReverse_=r,this.resultGenerator_=i,this.nodeStack_=[];let s=1;for(;!e.isEmpty();)if(s=t?n(e.key,t):1,r&amp;&amp;(s*=-1),s&lt;0)e=this.isReverse_?e.left:e.right;else{if(0===s){this.nodeStack_.push(e);break}this.nodeStack_.push(e),e=this.isReverse_?e.right:e.left}}getNext(){if(0===this.nodeStack_.length)return null;let e,t=this.nodeStack_.pop();if(e=this.resultGenerator_?this.resultGenerator_(t.key,t.value):{key:t.key,value:t.value},this.isReverse_)for(t=t.left;!t.isEmpty();)this.nodeStack_.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack_.push(t),t=t.left;return e}hasNext(){return this.nodeStack_.length&gt;0}peek(){if(0===this.nodeStack_.length)return null;const e=this.nodeStack_[this.nodeStack_.length-1];return this.resultGenerator_?this.resultGenerator_(e.key,e.value):{key:e.key,value:e.value}}}class Ve{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:Ve.RED,this.left=null!=r?r:Be.EMPTY_NODE,this.right=null!=i?i:Be.EMPTY_NODE}copy(e,t,n,r,i){return new Ve(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)}count(){return this.left.count()+1+this.right.count()}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;const i=n(e,r.key);return r=i&lt;0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===i?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 Be.EMPTY_NODE;let e=this;return e.left.isRed_()||e.left.left.isRed_()||(e=e.moveRedLeft_()),e=e.copy(null,null,null,e.left.removeMin_(),null),e.fixUp_()}remove(e,t){let n,r;if(n=this,t(e,n.key)&lt;0)n.left.isEmpty()||n.left.isRed_()||n.left.left.isRed_()||(n=n.moveRedLeft_()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed_()&amp;&amp;(n=n.rotateRight_()),n.right.isEmpty()||n.right.isRed_()||n.right.left.isRed_()||(n=n.moveRedRight_()),0===t(e,n.key)){if(n.right.isEmpty())return Be.EMPTY_NODE;r=n.right.min_(),n=n.copy(r.key,r.value,null,null,n.right.removeMin_())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp_()}isRed_(){return this.color}fixUp_(){let e=this;return e.right.isRed_()&amp;&amp;!e.left.isRed_()&amp;&amp;(e=e.rotateLeft_()),e.left.isRed_()&amp;&amp;e.left.left.isRed_()&amp;&amp;(e=e.rotateRight_()),e.left.isRed_()&amp;&amp;e.right.isRed_()&amp;&amp;(e=e.colorFlip_()),e}moveRedLeft_(){let e=this.colorFlip_();return e.right.left.isRed_()&amp;&amp;(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_()&amp;&amp;(e=e.rotateRight_(),e=e.colorFlip_()),e}rotateLeft_(){const e=this.copy(null,null,Ve.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight_(){const e=this.copy(null,null,Ve.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip_(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth_(){const e=this.check_();return Math.pow(2,e)&lt;=this.count()+1}check_(){if(this.isRed_()&amp;&amp;this.left.isRed_())throw new Error("Red node has red child("+this.key+","+this.value+")");if(this.right.isRed_())throw new Error("Right child of ("+this.key+","+this.value+") is red");const e=this.left.check_();if(e!==this.right.check_())throw new Error("Black depths differ");return e+(this.isRed_()?0:1)}}Ve.RED=!0,Ve.BLACK=!1;class Be{constructor(e,t=Be.EMPTY_NODE){this.comparator_=e,this.root_=t}insert(e,t){return new Be(this.comparator_,this.root_.insert(e,t,this.comparator_).copy(null,null,Ve.BLACK,null,null))}remove(e){return new Be(this.comparator_,this.root_.remove(e,this.comparator_).copy(null,null,Ve.BLACK,null,null))}get(e){let t,n=this.root_;for(;!n.isEmpty();){if(t=this.comparator_(e,n.key),0===t)return n.value;t&lt;0?n=n.left:t&gt;0&amp;&amp;(n=n.right)}return null}getPredecessorKey(e){let t,n=this.root_,r=null;for(;!n.isEmpty();){if(t=this.comparator_(e,n.key),0===t){if(n.left.isEmpty())return r?r.key:null;for(n=n.left;!n.right.isEmpty();)n=n.right;return n.key}t&lt;0?n=n.left:t&gt;0&amp;&amp;(r=n,n=n.right)}throw new Error("Attempted to find predecessor key for a nonexistent key.  What gives?")}isEmpty(){return this.root_.isEmpty()}count(){return this.root_.count()}minKey(){return this.root_.minKey()}maxKey(){return this.root_.maxKey()}inorderTraversal(e){return this.root_.inorderTraversal(e)}reverseTraversal(e){return this.root_.reverseTraversal(e)}getIterator(e){return new qe(this.root_,null,this.comparator_,!1,e)}getIteratorFrom(e,t){return new qe(this.root_,e,this.comparator_,!1,t)}getReverseIteratorFrom(e,t){return new qe(this.root_,e,this.comparator_,!0,t)}getReverseIterator(e){return new qe(this.root_,null,this.comparator_,!0,e)}}function Ue(e,t){return A(e.name,t.name)}function je(e,t){return A(e,t)}let ze;Be.EMPTY_NODE=new class{copy(e,t,n,r,i){return this}insert(e,t,n){return new Ve(e,t,null)}remove(e,t){return this}count(){return 0}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}check_(){return 0}isRed_(){return!1}};const $e=function(e){return"number"==typeof e?"number:"+L(e):"string:"+e},Ke=function(e){if(e.isLeafNode()){const t=e.val();(0,s.hu)("string"==typeof t||"number"==typeof t||"object"==typeof t&amp;&amp;(0,s.r3)(t,".sv"),"Priority must be a string or number.")}else(0,s.hu)(e===ze||e.isEmpty(),"priority of unexpected type.");(0,s.hu)(e===ze||e.getPriority().isEmpty(),"Priority nodes can't have a priority of their own.")};let Ge,We,He;class Qe{constructor(e,t=Qe.__childrenNodeConstructor.EMPTY_NODE){this.value_=e,this.priorityNode_=t,this.lazyHash_=null,(0,s.hu)(void 0!==this.value_&amp;&amp;null!==this.value_,"LeafNode shouldn't be created with null/undefined value."),Ke(this.priorityNode_)}static set __childrenNodeConstructor(e){Ge=e}static get __childrenNodeConstructor(){return Ge}isLeafNode(){return!0}getPriority(){return this.priorityNode_}updatePriority(e){return new Qe(this.value_,e)}getImmediateChild(e){return".priority"===e?this.priorityNode_:Qe.__childrenNodeConstructor.EMPTY_NODE}getChild(e){return Ie(e)?this:".priority"===ge(e)?this.priorityNode_:Qe.__childrenNodeConstructor.EMPTY_NODE}hasChild(){return!1}getPredecessorChildName(e,t){return null}updateImmediateChild(e,t){return".priority"===e?this.updatePriority(t):t.isEmpty()&amp;&amp;".priority"!==e?this:Qe.__childrenNodeConstructor.EMPTY_NODE.updateImmediateChild(e,t).updatePriority(this.priorityNode_)}updateChild(e,t){const n=ge(e);return null===n?t:t.isEmpty()&amp;&amp;".priority"!==n?this:((0,s.hu)(".priority"!==n||1===me(e),".priority must be the last token in a path"),this.updateImmediateChild(n,Qe.__childrenNodeConstructor.EMPTY_NODE.updateChild(ye(e),t)))}isEmpty(){return!1}numChildren(){return 0}forEachChild(e,t){return!1}val(e){return e&amp;&amp;!this.getPriority().isEmpty()?{".value":this.getValue(),".priority":this.getPriority().val()}:this.getValue()}hash(){if(null===this.lazyHash_){let e="";this.priorityNode_.isEmpty()||(e+="priority:"+$e(this.priorityNode_.val())+":");const t=typeof this.value_;e+=t+":",e+="number"===t?L(this.value_):this.value_,this.lazyHash_=_(e)}return this.lazyHash_}getValue(){return this.value_}compareTo(e){return e===Qe.__childrenNodeConstructor.EMPTY_NODE?1:e instanceof Qe.__childrenNodeConstructor?-1:((0,s.hu)(e.isLeafNode(),"Unknown node type"),this.compareToLeafNode_(e))}compareToLeafNode_(e){const t=typeof e.value_,n=typeof this.value_,r=Qe.VALUE_TYPE_ORDER.indexOf(t),i=Qe.VALUE_TYPE_ORDER.indexOf(n);return(0,s.hu)(r&gt;=0,"Unknown leaf type: "+t),(0,s.hu)(i&gt;=0,"Unknown leaf type: "+n),r===i?"object"===n?0:this.value_&lt;e.value_?-1:this.value_===e.value_?0:1:i-r}withIndex(){return this}isIndexed(){return!0}equals(e){if(e===this)return!0;if(e.isLeafNode()){const t=e;return this.value_===t.value_&amp;&amp;this.priorityNode_.equals(t.priorityNode_)}return!1}}Qe.VALUE_TYPE_ORDER=["object","boolean","number","string"];const Ye=new class extends Me{compare(e,t){const n=e.node.getPriority(),r=t.node.getPriority(),i=n.compareTo(r);return 0===i?A(e.name,t.name):i}isDefinedOn(e){return!e.getPriority().isEmpty()}indexedValueChanged(e,t){return!e.getPriority().equals(t.getPriority())}minPost(){return Re.MIN}maxPost(){return new Re(N,new Qe("[PRIORITY-POST]",He))}makePost(e,t){const n=We(e);return new Re(t,new Qe("[PRIORITY-POST]",n))}toString(){return".priority"}},Xe=Math.log(2);class Je{constructor(e){var t;this.count=(t=e+1,parseInt(Math.log(t)/Xe,10)),this.current_=this.count-1;const n=(r=this.count,parseInt(Array(r+1).join("1"),2));var r;this.bits_=e+1&amp;n}nextBitIsOne(){const e=!(this.bits_&amp;1&lt;&lt;this.current_);return this.current_--,e}}const Ze=function(e,t,n,r){e.sort(t);const i=function(t,r){const s=r-t;let o,a;if(0===s)return null;if(1===s)return o=e[t],a=n?n(o):o,new Ve(a,o.node,Ve.BLACK,null,null);{const c=parseInt(s/2,10)+t,u=i(t,c),l=i(c+1,r);return o=e[c],a=n?n(o):o,new Ve(a,o.node,Ve.BLACK,u,l)}},s=function(t){let r=null,s=null,o=e.length;const a=function(t,r){const s=o-t,a=o;o-=t;const u=i(s+1,a),l=e[s],h=n?n(l):l;c(new Ve(h,l.node,r,null,u))},c=function(e){r?(r.left=e,r=e):(s=e,r=e)};for(let e=0;e&lt;t.count;++e){const n=t.nextBitIsOne(),r=Math.pow(2,t.count-(e+1));n?a(r,Ve.BLACK):(a(r,Ve.BLACK),a(r,Ve.RED))}return s}(new Je(e.length));return new Be(r||t,s)};let et;const tt={};class nt{constructor(e,t){this.indexes_=e,this.indexSet_=t}static get Default(){return(0,s.hu)(tt&amp;&amp;Ye,"ChildrenNode.ts has not been loaded"),et=et||new nt({".priority":tt},{".priority":Ye}),et}get(e){const t=(0,s.DV)(this.indexes_,e);if(!t)throw new Error("No index defined for "+e);return t instanceof Be?t:null}hasIndex(e){return(0,s.r3)(this.indexSet_,e.toString())}addIndex(e,t){(0,s.hu)(e!==Le,"KeyIndex always exists and isn't meant to be added to the IndexMap.");const n=[];let r=!1;const i=t.getIterator(Re.Wrap);let o,a=i.getNext();for(;a;)r=r||e.isDefinedOn(a.node),n.push(a),a=i.getNext();o=r?Ze(n,e.getCompare()):tt;const c=e.toString(),u=Object.assign({},this.indexSet_);u[c]=e;const l=Object.assign({},this.indexes_);return l[c]=o,new nt(l,u)}addToIndexes(e,t){const n=(0,s.UI)(this.indexes_,((n,r)=&gt;{const i=(0,s.DV)(this.indexSet_,r);if((0,s.hu)(i,"Missing index implementation for "+r),n===tt){if(i.isDefinedOn(e.node)){const n=[],r=t.getIterator(Re.Wrap);let s=r.getNext();for(;s;)s.name!==e.name&amp;&amp;n.push(s),s=r.getNext();return n.push(e),Ze(n,i.getCompare())}return tt}{const r=t.get(e.name);let i=n;return r&amp;&amp;(i=i.remove(new Re(e.name,r))),i.insert(e,e.node)}}));return new nt(n,this.indexSet_)}removeFromIndexes(e,t){const n=(0,s.UI)(this.indexes_,(n=&gt;{if(n===tt)return n;{const r=t.get(e.name);return r?n.remove(new Re(e.name,r)):n}}));return new nt(n,this.indexSet_)}}let rt;class it{constructor(e,t,n){this.children_=e,this.priorityNode_=t,this.indexMap_=n,this.lazyHash_=null,this.priorityNode_&amp;&amp;Ke(this.priorityNode_),this.children_.isEmpty()&amp;&amp;(0,s.hu)(!this.priorityNode_||this.priorityNode_.isEmpty(),"An empty node cannot have a priority")}static get EMPTY_NODE(){return rt||(rt=new it(new Be(je),null,nt.Default))}isLeafNode(){return!1}getPriority(){return this.priorityNode_||rt}updatePriority(e){return this.children_.isEmpty()?this:new it(this.children_,e,this.indexMap_)}getImmediateChild(e){if(".priority"===e)return this.getPriority();{const t=this.children_.get(e);return null===t?rt:t}}getChild(e){const t=ge(e);return null===t?this:this.getImmediateChild(t).getChild(ye(e))}hasChild(e){return null!==this.children_.get(e)}updateImmediateChild(e,t){if((0,s.hu)(t,"We should always be passing snapshot nodes"),".priority"===e)return this.updatePriority(t);{const n=new Re(e,t);let r,i;t.isEmpty()?(r=this.children_.remove(e),i=this.indexMap_.removeFromIndexes(n,this.children_)):(r=this.children_.insert(e,t),i=this.indexMap_.addToIndexes(n,this.children_));const s=r.isEmpty()?rt:this.priorityNode_;return new it(r,s,i)}}updateChild(e,t){const n=ge(e);if(null===n)return t;{(0,s.hu)(".priority"!==ge(e)||1===me(e),".priority must be the last token in a path");const r=this.getImmediateChild(n).updateChild(ye(e),t);return this.updateImmediateChild(n,r)}}isEmpty(){return this.children_.isEmpty()}numChildren(){return this.children_.count()}val(e){if(this.isEmpty())return null;const t={};let n=0,r=0,i=!0;if(this.forEachChild(Ye,((s,o)=&gt;{t[s]=o.val(e),n++,i&amp;&amp;it.INTEGER_REGEXP_.test(s)?r=Math.max(r,Number(s)):i=!1})),!e&amp;&amp;i&amp;&amp;r&lt;2*n){const e=[];for(const n in t)e[n]=t[n];return e}return e&amp;&amp;!this.getPriority().isEmpty()&amp;&amp;(t[".priority"]=this.getPriority().val()),t}hash(){if(null===this.lazyHash_){let e="";this.getPriority().isEmpty()||(e+="priority:"+$e(this.getPriority().val())+":"),this.forEachChild(Ye,((t,n)=&gt;{const r=n.hash();""!==r&amp;&amp;(e+=":"+t+":"+r)})),this.lazyHash_=""===e?"":_(e)}return this.lazyHash_}getPredecessorChildName(e,t,n){const r=this.resolveIndex_(n);if(r){const n=r.getPredecessorKey(new Re(e,t));return n?n.name:null}return this.children_.getPredecessorKey(e)}getFirstChildName(e){const t=this.resolveIndex_(e);if(t){const e=t.minKey();return e&amp;&amp;e.name}return this.children_.minKey()}getFirstChild(e){const t=this.getFirstChildName(e);return t?new Re(t,this.children_.get(t)):null}getLastChildName(e){const t=this.resolveIndex_(e);if(t){const e=t.maxKey();return e&amp;&amp;e.name}return this.children_.maxKey()}getLastChild(e){const t=this.getLastChildName(e);return t?new Re(t,this.children_.get(t)):null}forEachChild(e,t){const n=this.resolveIndex_(e);return n?n.inorderTraversal((e=&gt;t(e.name,e.node))):this.children_.inorderTraversal(t)}getIterator(e){return this.getIteratorFrom(e.minPost(),e)}getIteratorFrom(e,t){const n=this.resolveIndex_(t);if(n)return n.getIteratorFrom(e,(e=&gt;e));{const n=this.children_.getIteratorFrom(e.name,Re.Wrap);let r=n.peek();for(;null!=r&amp;&amp;t.compare(r,e)&lt;0;)n.getNext(),r=n.peek();return n}}getReverseIterator(e){return this.getReverseIteratorFrom(e.maxPost(),e)}getReverseIteratorFrom(e,t){const n=this.resolveIndex_(t);if(n)return n.getReverseIteratorFrom(e,(e=&gt;e));{const n=this.children_.getReverseIteratorFrom(e.name,Re.Wrap);let r=n.peek();for(;null!=r&amp;&amp;t.compare(r,e)&gt;0;)n.getNext(),r=n.peek();return n}}compareTo(e){return this.isEmpty()?e.isEmpty()?0:-1:e.isLeafNode()||e.isEmpty()?1:e===st?-1:0}withIndex(e){if(e===Le||this.indexMap_.hasIndex(e))return this;{const t=this.indexMap_.addIndex(e,this.children_);return new it(this.children_,this.priorityNode_,t)}}isIndexed(e){return e===Le||this.indexMap_.hasIndex(e)}equals(e){if(e===this)return!0;if(e.isLeafNode())return!1;{const t=e;if(this.getPriority().equals(t.getPriority())){if(this.children_.count()===t.children_.count()){const e=this.getIterator(Ye),n=t.getIterator(Ye);let r=e.getNext(),i=n.getNext();for(;r&amp;&amp;i;){if(r.name!==i.name||!r.node.equals(i.node))return!1;r=e.getNext(),i=n.getNext()}return null===r&amp;&amp;null===i}return!1}return!1}}resolveIndex_(e){return e===Le?null:this.indexMap_.get(e.toString())}}it.INTEGER_REGEXP_=/^(0|[1-9]\d*)$/;const st=new class extends it{constructor(){super(new Be(je),it.EMPTY_NODE,nt.Default)}compareTo(e){return e===this?0:1}equals(e){return e===this}getPriority(){return this}getImmediateChild(e){return it.EMPTY_NODE}isEmpty(){return!1}};Object.defineProperties(Re,{MIN:{value:new Re(D,it.EMPTY_NODE)},MAX:{value:new Re(N,st)}}),Oe.__EMPTY_NODE=it.EMPTY_NODE,Qe.__childrenNodeConstructor=it,ze=st,He=st;const ot=!0;function at(e,t=null){if(null===e)return it.EMPTY_NODE;if("object"==typeof e&amp;&amp;".priority"in e&amp;&amp;(t=e[".priority"]),(0,s.hu)(null===t||"string"==typeof t||"number"==typeof t||"object"==typeof t&amp;&amp;".sv"in t,"Invalid priority type found: "+typeof t),"object"==typeof e&amp;&amp;".value"in e&amp;&amp;null!==e[".value"]&amp;&amp;(e=e[".value"]),"object"!=typeof e||".sv"in e)return new Qe(e,at(t));if(e instanceof Array||!ot){let n=it.EMPTY_NODE;return O(e,((t,r)=&gt;{if((0,s.r3)(e,t)&amp;&amp;"."!==t.substring(0,1)){const e=at(r);!e.isLeafNode()&amp;&amp;e.isEmpty()||(n=n.updateImmediateChild(t,e))}})),n.updatePriority(at(t))}{const n=[];let r=!1;if(O(e,((e,t)=&gt;{if("."!==e.substring(0,1)){const i=at(t);i.isEmpty()||(r=r||!i.getPriority().isEmpty(),n.push(new Re(e,i)))}})),0===n.length)return it.EMPTY_NODE;const i=Ze(n,Ue,(e=&gt;e.name),je);if(r){const e=Ze(n,Ye.getCompare());return new it(i,at(t),new nt({".priority":e},{".priority":Ye}))}return new it(i,at(t),nt.Default)}}!function(e){We=e}(at);class ct extends Me{constructor(e){super(),this.indexPath_=e,(0,s.hu)(!Ie(e)&amp;&amp;".priority"!==ge(e),"Can't create PathIndex with empty path or .priority key")}extractChild(e){return e.getChild(this.indexPath_)}isDefinedOn(e){return!e.getChild(this.indexPath_).isEmpty()}compare(e,t){const n=this.extractChild(e.node),r=this.extractChild(t.node),i=n.compareTo(r);return 0===i?A(e.name,t.name):i}makePost(e,t){const n=at(e),r=it.EMPTY_NODE.updateChild(this.indexPath_,n);return new Re(t,r)}maxPost(){const e=it.EMPTY_NODE.updateChild(this.indexPath_,st);return new Re(N,e)}toString(){return ve(this.indexPath_,0).join("/")}}const ut=new class extends Me{compare(e,t){const n=e.node.compareTo(t.node);return 0===n?A(e.name,t.name):n}isDefinedOn(e){return!0}indexedValueChanged(e,t){return!e.equals(t)}minPost(){return Re.MIN}maxPost(){return Re.MAX}makePost(e,t){const n=at(e);return new Re(t,n)}toString(){return".value"}};function lt(e){return{type:"value",snapshotNode:e}}function ht(e,t){return{type:"child_added",snapshotNode:t,childName:e}}function dt(e,t){return{type:"child_removed",snapshotNode:t,childName:e}}function ft(e,t,n){return{type:"child_changed",snapshotNode:t,childName:e,oldSnap:n}}class pt{constructor(e){this.index_=e}updateChild(e,t,n,r,i,o){(0,s.hu)(e.isIndexed(this.index_),"A node must be indexed if only a child is updated");const a=e.getImmediateChild(t);return a.getChild(r).equals(n.getChild(r))&amp;&amp;a.isEmpty()===n.isEmpty()?e:(null!=o&amp;&amp;(n.isEmpty()?e.hasChild(t)?o.trackChildChange(dt(t,a)):(0,s.hu)(e.isLeafNode(),"A child remove without an old child only makes sense on a leaf node"):a.isEmpty()?o.trackChildChange(ht(t,n)):o.trackChildChange(ft(t,n,a))),e.isLeafNode()&amp;&amp;n.isEmpty()?e:e.updateImmediateChild(t,n).withIndex(this.index_))}updateFullNode(e,t,n){return null!=n&amp;&amp;(e.isLeafNode()||e.forEachChild(Ye,((e,r)=&gt;{t.hasChild(e)||n.trackChildChange(dt(e,r))})),t.isLeafNode()||t.forEachChild(Ye,((t,r)=&gt;{if(e.hasChild(t)){const i=e.getImmediateChild(t);i.equals(r)||n.trackChildChange(ft(t,r,i))}else n.trackChildChange(ht(t,r))}))),t.withIndex(this.index_)}updatePriority(e,t){return e.isEmpty()?it.EMPTY_NODE:e.updatePriority(t)}filtersNodes(){return!1}getIndexedFilter(){return this}getIndex(){return this.index_}}class gt{constructor(e){this.indexedFilter_=new pt(e.getIndex()),this.index_=e.getIndex(),this.startPost_=gt.getStartPost_(e),this.endPost_=gt.getEndPost_(e),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}getStartPost(){return this.startPost_}getEndPost(){return this.endPost_}matches(e){const t=this.startIsInclusive_?this.index_.compare(this.getStartPost(),e)&lt;=0:this.index_.compare(this.getStartPost(),e)&lt;0,n=this.endIsInclusive_?this.index_.compare(e,this.getEndPost())&lt;=0:this.index_.compare(e,this.getEndPost())&lt;0;return t&amp;&amp;n}updateChild(e,t,n,r,i,s){return this.matches(new Re(t,n))||(n=it.EMPTY_NODE),this.indexedFilter_.updateChild(e,t,n,r,i,s)}updateFullNode(e,t,n){t.isLeafNode()&amp;&amp;(t=it.EMPTY_NODE);let r=t.withIndex(this.index_);r=r.updatePriority(it.EMPTY_NODE);const i=this;return t.forEachChild(Ye,((e,t)=&gt;{i.matches(new Re(e,t))||(r=r.updateImmediateChild(e,it.EMPTY_NODE))})),this.indexedFilter_.updateFullNode(e,r,n)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.indexedFilter_}getIndex(){return this.index_}static getStartPost_(e){if(e.hasStart()){const t=e.getIndexStartName();return e.getIndex().makePost(e.getIndexStartValue(),t)}return e.getIndex().minPost()}static getEndPost_(e){if(e.hasEnd()){const t=e.getIndexEndName();return e.getIndex().makePost(e.getIndexEndValue(),t)}return e.getIndex().maxPost()}}class mt{constructor(e){this.withinDirectionalStart=e=&gt;this.reverse_?this.withinEndPost(e):this.withinStartPost(e),this.withinDirectionalEnd=e=&gt;this.reverse_?this.withinStartPost(e):this.withinEndPost(e),this.withinStartPost=e=&gt;{const t=this.index_.compare(this.rangedFilter_.getStartPost(),e);return this.startIsInclusive_?t&lt;=0:t&lt;0},this.withinEndPost=e=&gt;{const t=this.index_.compare(e,this.rangedFilter_.getEndPost());return this.endIsInclusive_?t&lt;=0:t&lt;0},this.rangedFilter_=new gt(e),this.index_=e.getIndex(),this.limit_=e.getLimit(),this.reverse_=!e.isViewFromLeft(),this.startIsInclusive_=!e.startAfterSet_,this.endIsInclusive_=!e.endBeforeSet_}updateChild(e,t,n,r,i,s){return this.rangedFilter_.matches(new Re(t,n))||(n=it.EMPTY_NODE),e.getImmediateChild(t).equals(n)?e:e.numChildren()&lt;this.limit_?this.rangedFilter_.getIndexedFilter().updateChild(e,t,n,r,i,s):this.fullLimitUpdateChild_(e,t,n,i,s)}updateFullNode(e,t,n){let r;if(t.isLeafNode()||t.isEmpty())r=it.EMPTY_NODE.withIndex(this.index_);else if(2*this.limit_&lt;t.numChildren()&amp;&amp;t.isIndexed(this.index_)){let e;r=it.EMPTY_NODE.withIndex(this.index_),e=this.reverse_?t.getReverseIteratorFrom(this.rangedFilter_.getEndPost(),this.index_):t.getIteratorFrom(this.rangedFilter_.getStartPost(),this.index_);let n=0;for(;e.hasNext()&amp;&amp;n&lt;this.limit_;){const t=e.getNext();if(this.withinDirectionalStart(t)){if(!this.withinDirectionalEnd(t))break;r=r.updateImmediateChild(t.name,t.node),n++}}}else{let e;r=t.withIndex(this.index_),r=r.updatePriority(it.EMPTY_NODE),e=this.reverse_?r.getReverseIterator(this.index_):r.getIterator(this.index_);let n=0;for(;e.hasNext();){const t=e.getNext();n&lt;this.limit_&amp;&amp;this.withinDirectionalStart(t)&amp;&amp;this.withinDirectionalEnd(t)?n++:r=r.updateImmediateChild(t.name,it.EMPTY_NODE)}}return this.rangedFilter_.getIndexedFilter().updateFullNode(e,r,n)}updatePriority(e,t){return e}filtersNodes(){return!0}getIndexedFilter(){return this.rangedFilter_.getIndexedFilter()}getIndex(){return this.index_}fullLimitUpdateChild_(e,t,n,r,i){let o;if(this.reverse_){const e=this.index_.getCompare();o=(t,n)=&gt;e(n,t)}else o=this.index_.getCompare();const a=e;(0,s.hu)(a.numChildren()===this.limit_,"");const c=new Re(t,n),u=this.reverse_?a.getFirstChild(this.index_):a.getLastChild(this.index_),l=this.rangedFilter_.matches(c);if(a.hasChild(t)){const e=a.getImmediateChild(t);let s=r.getChildAfterChild(this.index_,u,this.reverse_);for(;null!=s&amp;&amp;(s.name===t||a.hasChild(s.name));)s=r.getChildAfterChild(this.index_,s,this.reverse_);const h=null==s?1:o(s,c);if(l&amp;&amp;!n.isEmpty()&amp;&amp;h&gt;=0)return null!=i&amp;&amp;i.trackChildChange(ft(t,n,e)),a.updateImmediateChild(t,n);{null!=i&amp;&amp;i.trackChildChange(dt(t,e));const n=a.updateImmediateChild(t,it.EMPTY_NODE);return null!=s&amp;&amp;this.rangedFilter_.matches(s)?(null!=i&amp;&amp;i.trackChildChange(ht(s.name,s.node)),n.updateImmediateChild(s.name,s.node)):n}}return n.isEmpty()?e:l&amp;&amp;o(u,c)&gt;=0?(null!=i&amp;&amp;(i.trackChildChange(dt(u.name,u.node)),i.trackChildChange(ht(t,n))),a.updateImmediateChild(t,n).updateImmediateChild(u.name,it.EMPTY_NODE)):e}}class yt{constructor(){this.limitSet_=!1,this.startSet_=!1,this.startNameSet_=!1,this.startAfterSet_=!1,this.endSet_=!1,this.endNameSet_=!1,this.endBeforeSet_=!1,this.limit_=0,this.viewFrom_="",this.indexStartValue_=null,this.indexStartName_="",this.indexEndValue_=null,this.indexEndName_="",this.index_=Ye}hasStart(){return this.startSet_}isViewFromLeft(){return""===this.viewFrom_?this.startSet_:"l"===this.viewFrom_}getIndexStartValue(){return(0,s.hu)(this.startSet_,"Only valid if start has been set"),this.indexStartValue_}getIndexStartName(){return(0,s.hu)(this.startSet_,"Only valid if start has been set"),this.startNameSet_?this.indexStartName_:D}hasEnd(){return this.endSet_}getIndexEndValue(){return(0,s.hu)(this.endSet_,"Only valid if end has been set"),this.indexEndValue_}getIndexEndName(){return(0,s.hu)(this.endSet_,"Only valid if end has been set"),this.endNameSet_?this.indexEndName_:N}hasLimit(){return this.limitSet_}hasAnchoredLimit(){return this.limitSet_&amp;&amp;""!==this.viewFrom_}getLimit(){return(0,s.hu)(this.limitSet_,"Only valid if limit has been set"),this.limit_}getIndex(){return this.index_}loadsAllData(){return!(this.startSet_||this.endSet_||this.limitSet_)}isDefault(){return this.loadsAllData()&amp;&amp;this.index_===Ye}copy(){const e=new yt;return e.limitSet_=this.limitSet_,e.limit_=this.limit_,e.startSet_=this.startSet_,e.startAfterSet_=this.startAfterSet_,e.indexStartValue_=this.indexStartValue_,e.startNameSet_=this.startNameSet_,e.indexStartName_=this.indexStartName_,e.endSet_=this.endSet_,e.endBeforeSet_=this.endBeforeSet_,e.indexEndValue_=this.indexEndValue_,e.endNameSet_=this.endNameSet_,e.indexEndName_=this.indexEndName_,e.index_=this.index_,e.viewFrom_=this.viewFrom_,e}}function _t(e,t,n){const r=e.copy();return r.startSet_=!0,void 0===t&amp;&amp;(t=null),r.indexStartValue_=t,null!=n?(r.startNameSet_=!0,r.indexStartName_=n):(r.startNameSet_=!1,r.indexStartName_=""),r}function vt(e,t,n){const r=e.copy();return r.endSet_=!0,void 0===t&amp;&amp;(t=null),r.indexEndValue_=t,void 0!==n?(r.endNameSet_=!0,r.indexEndName_=n):(r.endNameSet_=!1,r.indexEndName_=""),r}function wt(e,t){const n=e.copy();return n.index_=t,n}function bt(e){const t={};if(e.isDefault())return t;let n;if(e.index_===Ye?n="$priority":e.index_===ut?n="$value":e.index_===Le?n="$key":((0,s.hu)(e.index_ instanceof ct,"Unrecognized index type!"),n=e.index_.toString()),t.orderBy=(0,s.Wl)(n),e.startSet_){const n=e.startAfterSet_?"startAfter":"startAt";t[n]=(0,s.Wl)(e.indexStartValue_),e.startNameSet_&amp;&amp;(t[n]+=","+(0,s.Wl)(e.indexStartName_))}if(e.endSet_){const n=e.endBeforeSet_?"endBefore":"endAt";t[n]=(0,s.Wl)(e.indexEndValue_),e.endNameSet_&amp;&amp;(t[n]+=","+(0,s.Wl)(e.indexEndName_))}return e.limitSet_&amp;&amp;(e.isViewFromLeft()?t.limitToFirst=e.limit_:t.limitToLast=e.limit_),t}function It(e){const t={};if(e.startSet_&amp;&amp;(t.sp=e.indexStartValue_,e.startNameSet_&amp;&amp;(t.sn=e.indexStartName_),t.sin=!e.startAfterSet_),e.endSet_&amp;&amp;(t.ep=e.indexEndValue_,e.endNameSet_&amp;&amp;(t.en=e.indexEndName_),t.ein=!e.endBeforeSet_),e.limitSet_){t.l=e.limit_;let n=e.viewFrom_;""===n&amp;&amp;(n=e.isViewFromLeft()?"l":"r"),t.vf=n}return e.index_!==Ye&amp;&amp;(t.i=e.index_.toString()),t}class Ct extends le{constructor(e,t,n,r){super(),this.repoInfo_=e,this.onDataUpdate_=t,this.authTokenProvider_=n,this.appCheckTokenProvider_=r,this.log_=T("p:rest:"),this.listens_={}}reportStats(e){throw new Error("Method not implemented.")}static getListenId_(e,t){return void 0!==t?"tag$"+t:((0,s.hu)(e._queryParams.isDefault(),"should have a tag if it's not a default query."),e._path.toString())}listen(e,t,n,r){const i=e._path.toString();this.log_("Listen called for "+i+" "+e._queryIdentifier);const o=Ct.getListenId_(e,n),a={};this.listens_[o]=a;const c=bt(e._queryParams);this.restRequest_(i+".json",c,((e,t)=&gt;{let c=t;if(404===e&amp;&amp;(c=null,e=null),null===e&amp;&amp;this.onDataUpdate_(i,c,!1,n),(0,s.DV)(this.listens_,o)===a){let t;t=e?401===e?"permission_denied":"rest_error:"+e:"ok",r(t,null)}}))}unlisten(e,t){const n=Ct.getListenId_(e,t);delete this.listens_[n]}get(e){const t=bt(e._queryParams),n=e._path.toString(),r=new s.BH;return this.restRequest_(n+".json",t,((e,t)=&gt;{let i=t;404===e&amp;&amp;(i=null,e=null),null===e?(this.onDataUpdate_(n,i,!1,null),r.resolve(i)):r.reject(new Error(i))})),r.promise}refreshAuthToken(e){}restRequest_(e,t={},n){return t.format="export",Promise.all([this.authTokenProvider_.getToken(!1),this.appCheckTokenProvider_.getToken(!1)]).then((([r,i])=&gt;{r&amp;&amp;r.accessToken&amp;&amp;(t.auth=r.accessToken),i&amp;&amp;i.token&amp;&amp;(t.ac=i.token);const o=(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host+e+"?ns="+this.repoInfo_.namespace+(0,s.xO)(t);this.log_("Sending REST request for "+o);const a=new XMLHttpRequest;a.onreadystatechange=()=&gt;{if(n&amp;&amp;4===a.readyState){this.log_("REST Response for "+o+" received. status:",a.status,"response:",a.responseText);let e=null;if(a.status&gt;=200&amp;&amp;a.status&lt;300){try{e=(0,s.cI)(a.responseText)}catch(e){x("Failed to parse JSON response for "+o+": "+a.responseText)}n(null,e)}else 401!==a.status&amp;&amp;404!==a.status&amp;&amp;x("Got unsuccessful REST response for "+o+" Status: "+a.status),n(a.status);n=null}},a.open("GET",o,!0),a.send()}))}}class Tt{constructor(){this.rootNode_=it.EMPTY_NODE}getNode(e){return this.rootNode_.getChild(e)}updateSnapshot(e,t){this.rootNode_=this.rootNode_.updateChild(e,t)}}function Et(){return{value:null,children:new Map}}function St(e,t,n){if(Ie(t))e.value=n,e.children.clear();else if(null!==e.value)e.value=e.value.updateChild(t,n);else{const r=ge(t);e.children.has(r)||e.children.set(r,Et()),St(e.children.get(r),t=ye(t),n)}}function xt(e,t){if(Ie(t))return e.value=null,e.children.clear(),!0;if(null!==e.value){if(e.value.isLeafNode())return!1;{const n=e.value;return e.value=null,n.forEachChild(Ye,((t,n)=&gt;{St(e,new fe(t),n)})),xt(e,t)}}if(e.children.size&gt;0){const n=ge(t);return t=ye(t),e.children.has(n)&amp;&amp;xt(e.children.get(n),t)&amp;&amp;e.children.delete(n),0===e.children.size}return!0}function kt(e,t,n){null!==e.value?n(t,e.value):function(e,t){e.children.forEach(((e,n)=&gt;{t(n,e)}))}(e,((e,r)=&gt;{kt(r,new fe(t.toString()+"/"+e),n)}))}class Dt{constructor(e){this.collection_=e,this.last_=null}get(){const e=this.collection_.get(),t=Object.assign({},e);return this.last_&amp;&amp;O(this.last_,((e,n)=&gt;{t[e]=t[e]-n})),this.last_=e,t}}class Nt{constructor(e,t){this.server_=t,this.statsToReport_={},this.statsListener_=new Dt(e);const n=1e4+2e4*Math.random();U(this.reportStats_.bind(this),Math.floor(n))}reportStats_(){const e=this.statsListener_.get(),t={};let n=!1;O(e,((e,r)=&gt;{r&gt;0&amp;&amp;(0,s.r3)(this.statsToReport_,e)&amp;&amp;(t[e]=r,n=!0)})),n&amp;&amp;this.server_.reportStats(t),U(this.reportStats_.bind(this),Math.floor(2*Math.random()*3e5))}}var At;function Pt(e){return{fromUser:!1,fromServer:!0,queryId:e,tagged:!0}}!function(e){e[e.OVERWRITE=0]="OVERWRITE",e[e.MERGE=1]="MERGE",e[e.ACK_USER_WRITE=2]="ACK_USER_WRITE",e[e.LISTEN_COMPLETE=3]="LISTEN_COMPLETE"}(At||(At={}));class Rt{constructor(e,t,n){this.path=e,this.affectedTree=t,this.revert=n,this.type=At.ACK_USER_WRITE,this.source={fromUser:!0,fromServer:!1,queryId:null,tagged:!1}}operationForChild(e){if(Ie(this.path)){if(null!=this.affectedTree.value)return(0,s.hu)(this.affectedTree.children.isEmpty(),"affectedTree should not have overlapping affected paths."),this;{const t=this.affectedTree.subtree(new fe(e));return new Rt(pe(),t,this.revert)}}return(0,s.hu)(ge(this.path)===e,"operationForChild called for unrelated child."),new Rt(ye(this.path),this.affectedTree,this.revert)}}class Mt{constructor(e,t){this.source=e,this.path=t,this.type=At.LISTEN_COMPLETE}operationForChild(e){return Ie(this.path)?new Mt(this.source,pe()):new Mt(this.source,ye(this.path))}}class Ft{constructor(e,t,n){this.source=e,this.path=t,this.snap=n,this.type=At.OVERWRITE}operationForChild(e){return Ie(this.path)?new Ft(this.source,pe(),this.snap.getImmediateChild(e)):new Ft(this.source,ye(this.path),this.snap)}}class Ot{constructor(e,t,n){this.source=e,this.path=t,this.children=n,this.type=At.MERGE}operationForChild(e){if(Ie(this.path)){const t=this.children.subtree(new fe(e));return t.isEmpty()?null:t.value?new Ft(this.source,pe(),t.value):new Ot(this.source,pe(),t)}return(0,s.hu)(ge(this.path)===e,"Can't get a merge for a child not on the path of the operation"),new Ot(this.source,ye(this.path),this.children)}toString(){return"Operation("+this.path+": "+this.source.toString()+" merge: "+this.children.toString()+")"}}class Lt{constructor(e,t,n){this.node_=e,this.fullyInitialized_=t,this.filtered_=n}isFullyInitialized(){return this.fullyInitialized_}isFiltered(){return this.filtered_}isCompleteForPath(e){if(Ie(e))return this.isFullyInitialized()&amp;&amp;!this.filtered_;const t=ge(e);return this.isCompleteForChild(t)}isCompleteForChild(e){return this.isFullyInitialized()&amp;&amp;!this.filtered_||this.node_.hasChild(e)}getNode(){return this.node_}}class qt{constructor(e){this.query_=e,this.index_=this.query_._queryParams.getIndex()}}function Vt(e,t,n,r,i,o){const a=r.filter((e=&gt;e.type===n));a.sort(((t,n)=&gt;function(e,t,n){if(null==t.childName||null==n.childName)throw(0,s.g5)("Should only compare child_ events.");const r=new Re(t.childName,t.snapshotNode),i=new Re(n.childName,n.snapshotNode);return e.index_.compare(r,i)}(e,t,n))),a.forEach((n=&gt;{const r=function(e,t,n){return"value"===t.type||"child_removed"===t.type||(t.prevName=n.getPredecessorChildName(t.childName,t.snapshotNode,e.index_)),t}(e,n,o);i.forEach((i=&gt;{i.respondsTo(n.type)&amp;&amp;t.push(i.createEvent(r,e.query_))}))}))}function Bt(e,t){return{eventCache:e,serverCache:t}}function Ut(e,t,n,r){return Bt(new Lt(t,n,r),e.serverCache)}function jt(e,t,n,r){return Bt(e.eventCache,new Lt(t,n,r))}function zt(e){return e.eventCache.isFullyInitialized()?e.eventCache.getNode():null}function $t(e){return e.serverCache.isFullyInitialized()?e.serverCache.getNode():null}let Kt;class Gt{constructor(e,t=(()=&gt;(Kt||(Kt=new Be(P)),Kt))()){this.value=e,this.children=t}static fromObject(e){let t=new Gt(null);return O(e,((e,n)=&gt;{t=t.set(new fe(e),n)})),t}isEmpty(){return null===this.value&amp;&amp;this.children.isEmpty()}findRootMostMatchingPathAndValue(e,t){if(null!=this.value&amp;&amp;t(this.value))return{path:pe(),value:this.value};if(Ie(e))return null;{const n=ge(e),r=this.children.get(n);if(null!==r){const i=r.findRootMostMatchingPathAndValue(ye(e),t);return null!=i?{path:be(new fe(n),i.path),value:i.value}:null}return null}}findRootMostValueAndPath(e){return this.findRootMostMatchingPathAndValue(e,(()=&gt;!0))}subtree(e){if(Ie(e))return this;{const t=ge(e),n=this.children.get(t);return null!==n?n.subtree(ye(e)):new Gt(null)}}set(e,t){if(Ie(e))return new Gt(t,this.children);{const n=ge(e),r=(this.children.get(n)||new Gt(null)).set(ye(e),t),i=this.children.insert(n,r);return new Gt(this.value,i)}}remove(e){if(Ie(e))return this.children.isEmpty()?new Gt(null):new Gt(null,this.children);{const t=ge(e),n=this.children.get(t);if(n){const r=n.remove(ye(e));let i;return i=r.isEmpty()?this.children.remove(t):this.children.insert(t,r),null===this.value&amp;&amp;i.isEmpty()?new Gt(null):new Gt(this.value,i)}return this}}get(e){if(Ie(e))return this.value;{const t=ge(e),n=this.children.get(t);return n?n.get(ye(e)):null}}setTree(e,t){if(Ie(e))return t;{const n=ge(e),r=(this.children.get(n)||new Gt(null)).setTree(ye(e),t);let i;return i=r.isEmpty()?this.children.remove(n):this.children.insert(n,r),new Gt(this.value,i)}}fold(e){return this.fold_(pe(),e)}fold_(e,t){const n={};return this.children.inorderTraversal(((r,i)=&gt;{n[r]=i.fold_(be(e,r),t)})),t(e,this.value,n)}findOnPath(e,t){return this.findOnPath_(e,pe(),t)}findOnPath_(e,t,n){const r=!!this.value&amp;&amp;n(t,this.value);if(r)return r;if(Ie(e))return null;{const r=ge(e),i=this.children.get(r);return i?i.findOnPath_(ye(e),be(t,r),n):null}}foreachOnPath(e,t){return this.foreachOnPath_(e,pe(),t)}foreachOnPath_(e,t,n){if(Ie(e))return this;{this.value&amp;&amp;n(t,this.value);const r=ge(e),i=this.children.get(r);return i?i.foreachOnPath_(ye(e),be(t,r),n):new Gt(null)}}foreach(e){this.foreach_(pe(),e)}foreach_(e,t){this.children.inorderTraversal(((n,r)=&gt;{r.foreach_(be(e,n),t)})),this.value&amp;&amp;t(e,this.value)}foreachChild(e){this.children.inorderTraversal(((t,n)=&gt;{n.value&amp;&amp;e(t,n.value)}))}}class Wt{constructor(e){this.writeTree_=e}static empty(){return new Wt(new Gt(null))}}function Ht(e,t,n){if(Ie(t))return new Wt(new Gt(n));{const r=e.writeTree_.findRootMostValueAndPath(t);if(null!=r){const i=r.path;let s=r.value;const o=Ce(i,t);return s=s.updateChild(o,n),new Wt(e.writeTree_.set(i,s))}{const r=new Gt(n),i=e.writeTree_.setTree(t,r);return new Wt(i)}}}function Qt(e,t,n){let r=e;return O(n,((e,n)=&gt;{r=Ht(r,be(t,e),n)})),r}function Yt(e,t){if(Ie(t))return Wt.empty();{const n=e.writeTree_.setTree(t,new Gt(null));return new Wt(n)}}function Xt(e,t){return null!=Jt(e,t)}function Jt(e,t){const n=e.writeTree_.findRootMostValueAndPath(t);return null!=n?e.writeTree_.get(n.path).getChild(Ce(n.path,t)):null}function Zt(e){const t=[],n=e.writeTree_.value;return null!=n?n.isLeafNode()||n.forEachChild(Ye,((e,n)=&gt;{t.push(new Re(e,n))})):e.writeTree_.children.inorderTraversal(((e,n)=&gt;{null!=n.value&amp;&amp;t.push(new Re(e,n.value))})),t}function en(e,t){if(Ie(t))return e;{const n=Jt(e,t);return new Wt(null!=n?new Gt(n):e.writeTree_.subtree(t))}}function tn(e){return e.writeTree_.isEmpty()}function nn(e,t){return rn(pe(),e.writeTree_,t)}function rn(e,t,n){if(null!=t.value)return n.updateChild(e,t.value);{let r=null;return t.children.inorderTraversal(((t,i)=&gt;{".priority"===t?((0,s.hu)(null!==i.value,"Priority writes must always be leaf nodes"),r=i.value):n=rn(be(e,t),i,n)})),n.getChild(e).isEmpty()||null===r||(n=n.updateChild(be(e,".priority"),r)),n}}function sn(e,t){return mn(t,e)}function on(e,t){if(e.snap)return Se(e.path,t);for(const n in e.children)if(e.children.hasOwnProperty(n)&amp;&amp;Se(be(e.path,n),t))return!0;return!1}function an(e){return e.visible}function cn(e,t,n){let r=Wt.empty();for(let i=0;i&lt;e.length;++i){const o=e[i];if(t(o)){const e=o.path;let t;if(o.snap)Se(n,e)?(t=Ce(n,e),r=Ht(r,t,o.snap)):Se(e,n)&amp;&amp;(t=Ce(e,n),r=Ht(r,pe(),o.snap.getChild(t)));else{if(!o.children)throw(0,s.g5)("WriteRecord should have .snap or .children");if(Se(n,e))t=Ce(n,e),r=Qt(r,t,o.children);else if(Se(e,n))if(t=Ce(e,n),Ie(t))r=Qt(r,pe(),o.children);else{const e=(0,s.DV)(o.children,ge(t));if(e){const n=e.getChild(ye(t));r=Ht(r,pe(),n)}}}}}return r}function un(e,t,n,r,i){if(r||i){const s=en(e.visibleWrites,t);if(!i&amp;&amp;tn(s))return n;if(i||null!=n||Xt(s,pe())){const s=function(e){return(e.visible||i)&amp;&amp;(!r||!~r.indexOf(e.writeId))&amp;&amp;(Se(e.path,t)||Se(t,e.path))};return nn(cn(e.allWrites,s,t),n||it.EMPTY_NODE)}return null}{const r=Jt(e.visibleWrites,t);if(null!=r)return r;{const r=en(e.visibleWrites,t);return tn(r)?n:null!=n||Xt(r,pe())?nn(r,n||it.EMPTY_NODE):null}}}function ln(e,t,n,r){return un(e.writeTree,e.treePath,t,n,r)}function hn(e,t){return function(e,t,n){let r=it.EMPTY_NODE;const i=Jt(e.visibleWrites,t);if(i)return i.isLeafNode()||i.forEachChild(Ye,((e,t)=&gt;{r=r.updateImmediateChild(e,t)})),r;if(n){const i=en(e.visibleWrites,t);return n.forEachChild(Ye,((e,t)=&gt;{const n=nn(en(i,new fe(e)),t);r=r.updateImmediateChild(e,n)})),Zt(i).forEach((e=&gt;{r=r.updateImmediateChild(e.name,e.node)})),r}return Zt(en(e.visibleWrites,t)).forEach((e=&gt;{r=r.updateImmediateChild(e.name,e.node)})),r}(e.writeTree,e.treePath,t)}function dn(e,t,n,r){return function(e,t,n,r,i){(0,s.hu)(r||i,"Either existingEventSnap or existingServerSnap must exist");const o=be(t,n);if(Xt(e.visibleWrites,o))return null;{const t=en(e.visibleWrites,o);return tn(t)?i.getChild(n):nn(t,i.getChild(n))}}(e.writeTree,e.treePath,t,n,r)}function fn(e,t){return function(e,t){return Jt(e.visibleWrites,t)}(e.writeTree,be(e.treePath,t))}function pn(e,t,n){return function(e,t,n,r){const i=be(t,n),s=Jt(e.visibleWrites,i);return null!=s?s:r.isCompleteForChild(n)?nn(en(e.visibleWrites,i),r.getNode().getImmediateChild(n)):null}(e.writeTree,e.treePath,t,n)}function gn(e,t){return mn(be(e.treePath,t),e.writeTree)}function mn(e,t){return{treePath:e,writeTree:t}}class yn{constructor(){this.changeMap=new Map}trackChildChange(e){const t=e.type,n=e.childName;(0,s.hu)("child_added"===t||"child_changed"===t||"child_removed"===t,"Only child changes supported for tracking"),(0,s.hu)(".priority"!==n,"Only non-priority child changes can be tracked.");const r=this.changeMap.get(n);if(r){const i=r.type;if("child_added"===t&amp;&amp;"child_removed"===i)this.changeMap.set(n,ft(n,e.snapshotNode,r.snapshotNode));else if("child_removed"===t&amp;&amp;"child_added"===i)this.changeMap.delete(n);else if("child_removed"===t&amp;&amp;"child_changed"===i)this.changeMap.set(n,dt(n,r.oldSnap));else if("child_changed"===t&amp;&amp;"child_added"===i)this.changeMap.set(n,ht(n,e.snapshotNode));else{if("child_changed"!==t||"child_changed"!==i)throw(0,s.g5)("Illegal combination of changes: "+e+" occurred after "+r);this.changeMap.set(n,ft(n,e.snapshotNode,r.oldSnap))}}else this.changeMap.set(n,e)}getChanges(){return Array.from(this.changeMap.values())}}const _n=new class{getCompleteChild(e){return null}getChildAfterChild(e,t,n){return null}};class vn{constructor(e,t,n=null){this.writes_=e,this.viewCache_=t,this.optCompleteServerCache_=n}getCompleteChild(e){const t=this.viewCache_.eventCache;if(t.isCompleteForChild(e))return t.getNode().getImmediateChild(e);{const t=null!=this.optCompleteServerCache_?new Lt(this.optCompleteServerCache_,!0,!1):this.viewCache_.serverCache;return pn(this.writes_,e,t)}}getChildAfterChild(e,t,n){const r=null!=this.optCompleteServerCache_?this.optCompleteServerCache_:$t(this.viewCache_),i=function(e,t,n,r,i,s){return function(e,t,n,r,i,s,o){let a;const c=en(e.visibleWrites,t),u=Jt(c,pe());if(null!=u)a=u;else{if(null==n)return[];a=nn(c,n)}if(a=a.withIndex(o),a.isEmpty()||a.isLeafNode())return[];{const e=[],t=o.getCompare(),n=s?a.getReverseIteratorFrom(r,o):a.getIteratorFrom(r,o);let c=n.getNext();for(;c&amp;&amp;e.length&lt;i;)0!==t(c,r)&amp;&amp;e.push(c),c=n.getNext();return e}}(e.writeTree,e.treePath,t,n,r,i,s)}(this.writes_,r,t,1,n,e);return 0===i.length?null:i[0]}}function wn(e,t,n,r,i,o){const a=t.eventCache;if(null!=fn(r,n))return t;{let c,u;if(Ie(n))if((0,s.hu)(t.serverCache.isFullyInitialized(),"If change path is empty, we must have complete server data"),t.serverCache.isFiltered()){const n=$t(t),i=hn(r,n instanceof it?n:it.EMPTY_NODE);c=e.filter.updateFullNode(t.eventCache.getNode(),i,o)}else{const n=ln(r,$t(t));c=e.filter.updateFullNode(t.eventCache.getNode(),n,o)}else{const l=ge(n);if(".priority"===l){(0,s.hu)(1===me(n),"Can't have a priority with additional path components");const i=a.getNode();u=t.serverCache.getNode();const o=dn(r,n,i,u);c=null!=o?e.filter.updatePriority(i,o):a.getNode()}else{const s=ye(n);let h;if(a.isCompleteForChild(l)){u=t.serverCache.getNode();const e=dn(r,n,a.getNode(),u);h=null!=e?a.getNode().getImmediateChild(l).updateChild(s,e):a.getNode().getImmediateChild(l)}else h=pn(r,l,t.serverCache);c=null!=h?e.filter.updateChild(a.getNode(),l,h,s,i,o):a.getNode()}}return Ut(t,c,a.isFullyInitialized()||Ie(n),e.filter.filtersNodes())}}function bn(e,t,n,r,i,s,o,a){const c=t.serverCache;let u;const l=o?e.filter:e.filter.getIndexedFilter();if(Ie(n))u=l.updateFullNode(c.getNode(),r,null);else if(l.filtersNodes()&amp;&amp;!c.isFiltered()){const e=c.getNode().updateChild(n,r);u=l.updateFullNode(c.getNode(),e,null)}else{const e=ge(n);if(!c.isCompleteForPath(n)&amp;&amp;me(n)&gt;1)return t;const i=ye(n),s=c.getNode().getImmediateChild(e).updateChild(i,r);u=".priority"===e?l.updatePriority(c.getNode(),s):l.updateChild(c.getNode(),e,s,i,_n,null)}const h=jt(t,u,c.isFullyInitialized()||Ie(n),l.filtersNodes());return wn(e,h,n,i,new vn(i,h,s),a)}function In(e,t,n,r,i,s,o){const a=t.eventCache;let c,u;const l=new vn(i,t,s);if(Ie(n))u=e.filter.updateFullNode(t.eventCache.getNode(),r,o),c=Ut(t,u,!0,e.filter.filtersNodes());else{const i=ge(n);if(".priority"===i)u=e.filter.updatePriority(t.eventCache.getNode(),r),c=Ut(t,u,a.isFullyInitialized(),a.isFiltered());else{const s=ye(n),u=a.getNode().getImmediateChild(i);let h;if(Ie(s))h=r;else{const e=l.getCompleteChild(i);h=null!=e?".priority"===_e(s)&amp;&amp;e.getChild(we(s)).isEmpty()?e:e.updateChild(s,r):it.EMPTY_NODE}c=u.equals(h)?t:Ut(t,e.filter.updateChild(a.getNode(),i,h,s,l,o),a.isFullyInitialized(),e.filter.filtersNodes())}}return c}function Cn(e,t){return e.eventCache.isCompleteForChild(t)}function Tn(e,t,n){return n.foreach(((e,n)=&gt;{t=t.updateChild(e,n)})),t}function En(e,t,n,r,i,s,o,a){if(t.serverCache.getNode().isEmpty()&amp;&amp;!t.serverCache.isFullyInitialized())return t;let c,u=t;c=Ie(n)?r:new Gt(null).setTree(n,r);const l=t.serverCache.getNode();return c.children.inorderTraversal(((n,r)=&gt;{if(l.hasChild(n)){const c=Tn(0,t.serverCache.getNode().getImmediateChild(n),r);u=bn(e,u,new fe(n),c,i,s,o,a)}})),c.children.inorderTraversal(((n,r)=&gt;{const c=!t.serverCache.isCompleteForChild(n)&amp;&amp;null===r.value;if(!l.hasChild(n)&amp;&amp;!c){const c=Tn(0,t.serverCache.getNode().getImmediateChild(n),r);u=bn(e,u,new fe(n),c,i,s,o,a)}})),u}class Sn{constructor(e,t){this.query_=e,this.eventRegistrations_=[];const n=this.query_._queryParams,r=new pt(n.getIndex()),i=(s=n).loadsAllData()?new pt(s.getIndex()):s.hasLimit()?new mt(s):new gt(s);var s;this.processor_=function(e){return{filter:e}}(i);const o=t.serverCache,a=t.eventCache,c=r.updateFullNode(it.EMPTY_NODE,o.getNode(),null),u=i.updateFullNode(it.EMPTY_NODE,a.getNode(),null),l=new Lt(c,o.isFullyInitialized(),r.filtersNodes()),h=new Lt(u,a.isFullyInitialized(),i.filtersNodes());this.viewCache_=Bt(h,l),this.eventGenerator_=new qt(this.query_)}get query(){return this.query_}}function xn(e,t){const n=$t(e.viewCache_);return n&amp;&amp;(e.query._queryParams.loadsAllData()||!Ie(t)&amp;&amp;!n.getImmediateChild(ge(t)).isEmpty())?n.getChild(t):null}function kn(e){return 0===e.eventRegistrations_.length}function Dn(e,t,n){const r=[];if(n){(0,s.hu)(null==t,"A cancel should cancel all event registrations.");const i=e.query._path;e.eventRegistrations_.forEach((e=&gt;{const t=e.createCancelEvent(n,i);t&amp;&amp;r.push(t)}))}if(t){let n=[];for(let r=0;r&lt;e.eventRegistrations_.length;++r){const i=e.eventRegistrations_[r];if(i.matches(t)){if(t.hasAnyCallback()){n=n.concat(e.eventRegistrations_.slice(r+1));break}}else n.push(i)}e.eventRegistrations_=n}else e.eventRegistrations_=[];return r}function Nn(e,t,n,r){t.type===At.MERGE&amp;&amp;null!==t.source.queryId&amp;&amp;((0,s.hu)($t(e.viewCache_),"We should always have a full cache before handling merges"),(0,s.hu)(zt(e.viewCache_),"Missing event cache, even though we have a server cache"));const i=e.viewCache_,o=function(e,t,n,r,i){const o=new yn;let a,c;if(n.type===At.OVERWRITE){const u=n;u.source.fromUser?a=In(e,t,u.path,u.snap,r,i,o):((0,s.hu)(u.source.fromServer,"Unknown source."),c=u.source.tagged||t.serverCache.isFiltered()&amp;&amp;!Ie(u.path),a=bn(e,t,u.path,u.snap,r,i,c,o))}else if(n.type===At.MERGE){const u=n;u.source.fromUser?a=function(e,t,n,r,i,s,o){let a=t;return r.foreach(((r,c)=&gt;{const u=be(n,r);Cn(t,ge(u))&amp;&amp;(a=In(e,a,u,c,i,s,o))})),r.foreach(((r,c)=&gt;{const u=be(n,r);Cn(t,ge(u))||(a=In(e,a,u,c,i,s,o))})),a}(e,t,u.path,u.children,r,i,o):((0,s.hu)(u.source.fromServer,"Unknown source."),c=u.source.tagged||t.serverCache.isFiltered(),a=En(e,t,u.path,u.children,r,i,c,o))}else if(n.type===At.ACK_USER_WRITE){const c=n;a=c.revert?function(e,t,n,r,i,o){let a;if(null!=fn(r,n))return t;{const c=new vn(r,t,i),u=t.eventCache.getNode();let l;if(Ie(n)||".priority"===ge(n)){let n;if(t.serverCache.isFullyInitialized())n=ln(r,$t(t));else{const e=t.serverCache.getNode();(0,s.hu)(e instanceof it,"serverChildren would be complete if leaf node"),n=hn(r,e)}l=e.filter.updateFullNode(u,n,o)}else{const i=ge(n);let s=pn(r,i,t.serverCache);null==s&amp;&amp;t.serverCache.isCompleteForChild(i)&amp;&amp;(s=u.getImmediateChild(i)),l=null!=s?e.filter.updateChild(u,i,s,ye(n),c,o):t.eventCache.getNode().hasChild(i)?e.filter.updateChild(u,i,it.EMPTY_NODE,ye(n),c,o):u,l.isEmpty()&amp;&amp;t.serverCache.isFullyInitialized()&amp;&amp;(a=ln(r,$t(t)),a.isLeafNode()&amp;&amp;(l=e.filter.updateFullNode(l,a,o)))}return a=t.serverCache.isFullyInitialized()||null!=fn(r,pe()),Ut(t,l,a,e.filter.filtersNodes())}}(e,t,c.path,r,i,o):function(e,t,n,r,i,s,o){if(null!=fn(i,n))return t;const a=t.serverCache.isFiltered(),c=t.serverCache;if(null!=r.value){if(Ie(n)&amp;&amp;c.isFullyInitialized()||c.isCompleteForPath(n))return bn(e,t,n,c.getNode().getChild(n),i,s,a,o);if(Ie(n)){let r=new Gt(null);return c.getNode().forEachChild(Le,((e,t)=&gt;{r=r.set(new fe(e),t)})),En(e,t,n,r,i,s,a,o)}return t}{let u=new Gt(null);return r.foreach(((e,t)=&gt;{const r=be(n,e);c.isCompleteForPath(r)&amp;&amp;(u=u.set(e,c.getNode().getChild(r)))})),En(e,t,n,u,i,s,a,o)}}(e,t,c.path,c.affectedTree,r,i,o)}else{if(n.type!==At.LISTEN_COMPLETE)throw(0,s.g5)("Unknown operation type: "+n.type);a=function(e,t,n,r,i){const s=t.serverCache;return wn(e,jt(t,s.getNode(),s.isFullyInitialized()||Ie(n),s.isFiltered()),n,r,_n,i)}(e,t,n.path,r,o)}const u=o.getChanges();return function(e,t,n){const r=t.eventCache;if(r.isFullyInitialized()){const i=r.getNode().isLeafNode()||r.getNode().isEmpty(),s=zt(e);(n.length&gt;0||!e.eventCache.isFullyInitialized()||i&amp;&amp;!r.getNode().equals(s)||!r.getNode().getPriority().equals(s.getPriority()))&amp;&amp;n.push(lt(zt(t)))}}(t,a,u),{viewCache:a,changes:u}}(e.processor_,i,t,n,r);var a,c;return a=e.processor_,c=o.viewCache,(0,s.hu)(c.eventCache.getNode().isIndexed(a.filter.getIndex()),"Event snap not indexed"),(0,s.hu)(c.serverCache.getNode().isIndexed(a.filter.getIndex()),"Server snap not indexed"),(0,s.hu)(o.viewCache.serverCache.isFullyInitialized()||!i.serverCache.isFullyInitialized(),"Once a server snap is complete, it should never go back"),e.viewCache_=o.viewCache,An(e,o.changes,o.viewCache.eventCache.getNode(),null)}function An(e,t,n,r){const i=r?[r]:e.eventRegistrations_;return function(e,t,n,r){const i=[],s=[];return t.forEach((t=&gt;{var n;"child_changed"===t.type&amp;&amp;e.index_.indexedValueChanged(t.oldSnap,t.snapshotNode)&amp;&amp;s.push((n=t.childName,{type:"child_moved",snapshotNode:t.snapshotNode,childName:n}))})),Vt(e,i,"child_removed",t,r,n),Vt(e,i,"child_added",t,r,n),Vt(e,i,"child_moved",s,r,n),Vt(e,i,"child_changed",t,r,n),Vt(e,i,"value",t,r,n),i}(e.eventGenerator_,t,n,i)}let Pn,Rn;class Mn{constructor(){this.views=new Map}}function Fn(e,t,n,r){const i=t.source.queryId;if(null!==i){const o=e.views.get(i);return(0,s.hu)(null!=o,"SyncTree gave us an op for an invalid query."),Nn(o,t,n,r)}{let i=[];for(const s of e.views.values())i=i.concat(Nn(s,t,n,r));return i}}function On(e,t,n,r,i){const s=t._queryIdentifier,o=e.views.get(s);if(!o){let e=ln(n,i?r:null),s=!1;e?s=!0:r instanceof it?(e=hn(n,r),s=!1):(e=it.EMPTY_NODE,s=!1);const o=Bt(new Lt(e,s,!1),new Lt(r,i,!1));return new Sn(t,o)}return o}function Ln(e){const t=[];for(const n of e.views.values())n.query._queryParams.loadsAllData()||t.push(n);return t}function qn(e,t){let n=null;for(const r of e.views.values())n=n||xn(r,t);return n}function Vn(e,t){if(t._queryParams.loadsAllData())return jn(e);{const n=t._queryIdentifier;return e.views.get(n)}}function Bn(e,t){return null!=Vn(e,t)}function Un(e){return null!=jn(e)}function jn(e){for(const t of e.views.values())if(t.query._queryParams.loadsAllData())return t;return null}let zn=1;class $n{constructor(e){this.listenProvider_=e,this.syncPointTree_=new Gt(null),this.pendingWriteTree_={visibleWrites:Wt.empty(),allWrites:[],lastWriteId:-1},this.tagToQueryMap=new Map,this.queryToTagMap=new Map}}function Kn(e,t,n,r,i){return function(e,t,n,r,i){(0,s.hu)(r&gt;e.lastWriteId,"Stacking an older write on top of newer ones"),void 0===i&amp;&amp;(i=!0),e.allWrites.push({path:t,snap:n,writeId:r,visible:i}),i&amp;&amp;(e.visibleWrites=Ht(e.visibleWrites,t,n)),e.lastWriteId=r}(e.pendingWriteTree_,t,n,r,i),i?Jn(e,new Ft({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},t,n)):[]}function Gn(e,t,n=!1){const r=function(e,t){for(let n=0;n&lt;e.allWrites.length;n++){const r=e.allWrites[n];if(r.writeId===t)return r}return null}(e.pendingWriteTree_,t);if(function(e,t){const n=e.allWrites.findIndex((e=&gt;e.writeId===t));(0,s.hu)(n&gt;=0,"removeWrite called with nonexistent writeId.");const r=e.allWrites[n];e.allWrites.splice(n,1);let i=r.visible,o=!1,a=e.allWrites.length-1;for(;i&amp;&amp;a&gt;=0;){const t=e.allWrites[a];t.visible&amp;&amp;(a&gt;=n&amp;&amp;on(t,r.path)?i=!1:Se(r.path,t.path)&amp;&amp;(o=!0)),a--}return!!i&amp;&amp;(o?(function(e){e.visibleWrites=cn(e.allWrites,an,pe()),e.allWrites.length&gt;0?e.lastWriteId=e.allWrites[e.allWrites.length-1].writeId:e.lastWriteId=-1}(e),!0):(r.snap?e.visibleWrites=Yt(e.visibleWrites,r.path):O(r.children,(t=&gt;{e.visibleWrites=Yt(e.visibleWrites,be(r.path,t))})),!0))}(e.pendingWriteTree_,t)){let t=new Gt(null);return null!=r.snap?t=t.set(pe(),!0):O(r.children,(e=&gt;{t=t.set(new fe(e),!0)})),Jn(e,new Rt(r.path,t,n))}return[]}function Wn(e,t,n){return Jn(e,new Ft({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,n))}function Hn(e,t,n,r,i=!1){const o=t._path,a=e.syncPointTree_.get(o);let c=[];if(a&amp;&amp;("default"===t._queryIdentifier||Bn(a,t))){const u=function(e,t,n,r){const i=t._queryIdentifier,o=[];let a=[];const c=Un(e);if("default"===i)for(const[t,i]of e.views.entries())a=a.concat(Dn(i,n,r)),kn(i)&amp;&amp;(e.views.delete(t),i.query._queryParams.loadsAllData()||o.push(i.query));else{const t=e.views.get(i);t&amp;&amp;(a=a.concat(Dn(t,n,r)),kn(t)&amp;&amp;(e.views.delete(i),t.query._queryParams.loadsAllData()||o.push(t.query)))}return c&amp;&amp;!Un(e)&amp;&amp;o.push(new((0,s.hu)(Pn,"Reference.ts has not been loaded"),Pn)(t._repo,t._path)),{removed:o,events:a}}(a,t,n,r);0===a.views.size&amp;&amp;(e.syncPointTree_=e.syncPointTree_.remove(o));const l=u.removed;if(c=u.events,!i){const n=-1!==l.findIndex((e=&gt;e._queryParams.loadsAllData())),i=e.syncPointTree_.findOnPath(o,((e,t)=&gt;Un(t)));if(n&amp;&amp;!i){const t=e.syncPointTree_.subtree(o);if(!t.isEmpty()){const n=function(e){return e.fold(((e,t,n)=&gt;{if(t&amp;&amp;Un(t))return[jn(t)];{let e=[];return t&amp;&amp;(e=Ln(t)),O(n,((t,n)=&gt;{e=e.concat(n)})),e}}))}(t);for(let t=0;t&lt;n.length;++t){const r=n[t],i=r.query,s=tr(e,r);e.listenProvider_.startListening(ar(i),nr(e,i),s.hashFn,s.onComplete)}}}if(!i&amp;&amp;l.length&gt;0&amp;&amp;!r)if(n){const n=null;e.listenProvider_.stopListening(ar(t),n)}else l.forEach((t=&gt;{const n=e.queryToTagMap.get(rr(t));e.listenProvider_.stopListening(ar(t),n)}))}!function(e,t){for(let n=0;n&lt;t.length;++n){const r=t[n];if(!r._queryParams.loadsAllData()){const t=rr(r),n=e.queryToTagMap.get(t);e.queryToTagMap.delete(t),e.tagToQueryMap.delete(n)}}}(e,l)}return c}function Qn(e,t,n,r){const i=ir(e,r);if(null!=i){const r=sr(i),s=r.path,o=r.queryId,a=Ce(s,t);return or(e,s,new Ft(Pt(o),a,n))}return[]}function Yn(e,t,n,r=!1){const i=t._path;let o=null,a=!1;e.syncPointTree_.foreachOnPath(i,((e,t)=&gt;{const n=Ce(e,i);o=o||qn(t,n),a=a||Un(t)}));let c,u=e.syncPointTree_.get(i);u?(a=a||Un(u),o=o||qn(u,pe())):(u=new Mn,e.syncPointTree_=e.syncPointTree_.set(i,u)),null!=o?c=!0:(c=!1,o=it.EMPTY_NODE,e.syncPointTree_.subtree(i).foreachChild(((e,t)=&gt;{const n=qn(t,pe());n&amp;&amp;(o=o.updateImmediateChild(e,n))})));const l=Bn(u,t);if(!l&amp;&amp;!t._queryParams.loadsAllData()){const n=rr(t);(0,s.hu)(!e.queryToTagMap.has(n),"View does not exist, but we have a tag");const r=zn++;e.queryToTagMap.set(n,r),e.tagToQueryMap.set(r,n)}let h=function(e,t,n,r,i,s){const o=On(e,t,r,i,s);return e.views.has(t._queryIdentifier)||e.views.set(t._queryIdentifier,o),function(e,t){e.eventRegistrations_.push(t)}(o,n),function(e,t){const n=e.viewCache_.eventCache,r=[];return n.getNode().isLeafNode()||n.getNode().forEachChild(Ye,((e,t)=&gt;{r.push(ht(e,t))})),n.isFullyInitialized()&amp;&amp;r.push(lt(n.getNode())),An(e,r,n.getNode(),t)}(o,n)}(u,t,n,sn(e.pendingWriteTree_,i),o,c);if(!l&amp;&amp;!a&amp;&amp;!r){const n=Vn(u,t);h=h.concat(function(e,t,n){const r=t._path,i=nr(e,t),o=tr(e,n),a=e.listenProvider_.startListening(ar(t),i,o.hashFn,o.onComplete),c=e.syncPointTree_.subtree(r);if(i)(0,s.hu)(!Un(c.value),"If we're adding a query, it shouldn't be shadowed");else{const t=c.fold(((e,t,n)=&gt;{if(!Ie(e)&amp;&amp;t&amp;&amp;Un(t))return[jn(t).query];{let e=[];return t&amp;&amp;(e=e.concat(Ln(t).map((e=&gt;e.query)))),O(n,((t,n)=&gt;{e=e.concat(n)})),e}}));for(let n=0;n&lt;t.length;++n){const r=t[n];e.listenProvider_.stopListening(ar(r),nr(e,r))}}return a}(e,t,n))}return h}function Xn(e,t,n){const r=e.pendingWriteTree_,i=e.syncPointTree_.findOnPath(t,((e,n)=&gt;{const r=qn(n,Ce(e,t));if(r)return r}));return un(r,t,i,n,!0)}function Jn(e,t){return Zn(t,e.syncPointTree_,null,sn(e.pendingWriteTree_,pe()))}function Zn(e,t,n,r){if(Ie(e.path))return er(e,t,n,r);{const i=t.get(pe());null==n&amp;&amp;null!=i&amp;&amp;(n=qn(i,pe()));let s=[];const o=ge(e.path),a=e.operationForChild(o),c=t.children.get(o);if(c&amp;&amp;a){const e=n?n.getImmediateChild(o):null,t=gn(r,o);s=s.concat(Zn(a,c,e,t))}return i&amp;&amp;(s=s.concat(Fn(i,e,r,n))),s}}function er(e,t,n,r){const i=t.get(pe());null==n&amp;&amp;null!=i&amp;&amp;(n=qn(i,pe()));let s=[];return t.children.inorderTraversal(((t,i)=&gt;{const o=n?n.getImmediateChild(t):null,a=gn(r,t),c=e.operationForChild(t);c&amp;&amp;(s=s.concat(er(c,i,o,a)))})),i&amp;&amp;(s=s.concat(Fn(i,e,r,n))),s}function tr(e,t){const n=t.query,r=nr(e,n);return{hashFn:()=&gt;{const e=function(e){return e.viewCache_.serverCache.getNode()}(t)||it.EMPTY_NODE;return e.hash()},onComplete:t=&gt;{if("ok"===t)return r?function(e,t,n){const r=ir(e,n);if(r){const n=sr(r),i=n.path,s=n.queryId,o=Ce(i,t);return or(e,i,new Mt(Pt(s),o))}return[]}(e,n._path,r):function(e,t){return Jn(e,new Mt({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t))}(e,n._path);{const r=function(e,t){let n="Unknown Error";"too_big"===e?n="The data requested exceeds the maximum size that can be accessed with a single request.":"permission_denied"===e?n="Client doesn't have permission to access the desired data.":"unavailable"===e&amp;&amp;(n="The service is unavailable");const r=new Error(e+" at "+t._path.toString()+": "+n);return r.code=e.toUpperCase(),r}(t,n);return Hn(e,n,null,r)}}}}function nr(e,t){const n=rr(t);return e.queryToTagMap.get(n)}function rr(e){return e._path.toString()+"$"+e._queryIdentifier}function ir(e,t){return e.tagToQueryMap.get(t)}function sr(e){const t=e.indexOf("$");return(0,s.hu)(-1!==t&amp;&amp;t&lt;e.length-1,"Bad queryKey."),{queryId:e.substr(t+1),path:new fe(e.substr(0,t))}}function or(e,t,n){const r=e.syncPointTree_.get(t);return(0,s.hu)(r,"Missing sync point for query tag that we're tracking"),Fn(r,n,sn(e.pendingWriteTree_,t),null)}function ar(e){return e._queryParams.loadsAllData()&amp;&amp;!e._queryParams.isDefault()?new((0,s.hu)(Rn,"Reference.ts has not been loaded"),Rn)(e._repo,e._path):e}class cr{constructor(e){this.node_=e}getImmediateChild(e){const t=this.node_.getImmediateChild(e);return new cr(t)}node(){return this.node_}}class ur{constructor(e,t){this.syncTree_=e,this.path_=t}getImmediateChild(e){const t=be(this.path_,e);return new ur(this.syncTree_,t)}node(){return Xn(this.syncTree_,this.path_)}}const lr=function(e){return(e=e||{}).timestamp=e.timestamp||(new Date).getTime(),e},hr=function(e,t,n){return e&amp;&amp;"object"==typeof e?((0,s.hu)(".sv"in e,"Unexpected leaf node or priority contents"),"string"==typeof e[".sv"]?dr(e[".sv"],t,n):"object"==typeof e[".sv"]?fr(e[".sv"],t):void(0,s.hu)(!1,"Unexpected server value: "+JSON.stringify(e,null,2))):e},dr=function(e,t,n){if("timestamp"===e)return n.timestamp;(0,s.hu)(!1,"Unexpected server value: "+e)},fr=function(e,t,n){e.hasOwnProperty("increment")||(0,s.hu)(!1,"Unexpected server value: "+JSON.stringify(e,null,2));const r=e.increment;"number"!=typeof r&amp;&amp;(0,s.hu)(!1,"Unexpected increment value: "+r);const i=t.node();if((0,s.hu)(null!=i,"Expected ChildrenNode.EMPTY_NODE for nulls"),!i.isLeafNode())return r;const o=i.getValue();return"number"!=typeof o?r:o+r},pr=function(e,t,n,r){return mr(t,new ur(n,e),r)},gr=function(e,t,n){return mr(e,new cr(t),n)};function mr(e,t,n){const r=e.getPriority().val(),i=hr(r,t.getImmediateChild(".priority"),n);let s;if(e.isLeafNode()){const r=e,s=hr(r.getValue(),t,n);return s!==r.getValue()||i!==r.getPriority().val()?new Qe(s,at(i)):e}{const r=e;return s=r,i!==r.getPriority().val()&amp;&amp;(s=s.updatePriority(new Qe(i))),r.forEachChild(Ye,((e,r)=&gt;{const i=mr(r,t.getImmediateChild(e),n);i!==r&amp;&amp;(s=s.updateImmediateChild(e,i))})),s}}class yr{constructor(e="",t=null,n={children:{},childCount:0}){this.name=e,this.parent=t,this.node=n}}function _r(e,t){let n=t instanceof fe?t:new fe(t),r=e,i=ge(n);for(;null!==i;){const e=(0,s.DV)(r.node.children,i)||{children:{},childCount:0};r=new yr(i,r,e),n=ye(n),i=ge(n)}return r}function vr(e){return e.node.value}function wr(e,t){e.node.value=t,Er(e)}function br(e){return e.node.childCount&gt;0}function Ir(e,t){O(e.node.children,((n,r)=&gt;{t(new yr(n,e,r))}))}function Cr(e,t,n,r){n&amp;&amp;!r&amp;&amp;t(e),Ir(e,(e=&gt;{Cr(e,t,!0,r)})),n&amp;&amp;r&amp;&amp;t(e)}function Tr(e){return new fe(null===e.parent?e.name:Tr(e.parent)+"/"+e.name)}function Er(e){null!==e.parent&amp;&amp;function(e,t,n){const r=function(e){return void 0===vr(e)&amp;&amp;!br(e)}(n),i=(0,s.r3)(e.node.children,t);r&amp;&amp;i?(delete e.node.children[t],e.node.childCount--,Er(e)):r||i||(e.node.children[t]=n.node,e.node.childCount++,Er(e))}(e.parent,e.name,e)}const Sr=/[\[\].#$\/\u0000-\u001F\u007F]/,xr=/[\[\].#$\u0000-\u001F\u007F]/,kr=10485760,Dr=function(e){return"string"==typeof e&amp;&amp;0!==e.length&amp;&amp;!Sr.test(e)},Nr=function(e){return"string"==typeof e&amp;&amp;0!==e.length&amp;&amp;!xr.test(e)},Ar=function(e){return null===e||"string"==typeof e||"number"==typeof e&amp;&amp;!k(e)||e&amp;&amp;"object"==typeof e&amp;&amp;(0,s.r3)(e,".sv")},Pr=function(e,t,n,r){r&amp;&amp;void 0===t||Rr((0,s.gK)(e,"value"),t,n)},Rr=function(e,t,n){const r=n instanceof fe?new xe(n,e):n;if(void 0===t)throw new Error(e+"contains undefined "+De(r));if("function"==typeof t)throw new Error(e+"contains a function "+De(r)+" with contents = "+t.toString());if(k(t))throw new Error(e+"contains "+t.toString()+" "+De(r));if("string"==typeof t&amp;&amp;t.length&gt;kr/3&amp;&amp;(0,s.ug)(t)&gt;kr)throw new Error(e+"contains a string greater than "+kr+" utf8 bytes "+De(r)+" ('"+t.substring(0,50)+"...')");if(t&amp;&amp;"object"==typeof t){let n=!1,i=!1;if(O(t,((t,o)=&gt;{if(".value"===t)n=!0;else if(".priority"!==t&amp;&amp;".sv"!==t&amp;&amp;(i=!0,!Dr(t)))throw new Error(e+" contains an invalid key ("+t+") "+De(r)+'.  Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"');!function(e,t){e.parts_.length&gt;0&amp;&amp;(e.byteLength_+=1),e.parts_.push(t),e.byteLength_+=(0,s.ug)(t),ke(e)}(r,t),Rr(e,o,r),function(e){const t=e.parts_.pop();e.byteLength_-=(0,s.ug)(t),e.parts_.length&gt;0&amp;&amp;(e.byteLength_-=1)}(r)})),n&amp;&amp;i)throw new Error(e+' contains ".value" child '+De(r)+" in addition to actual children.")}},Mr=function(e,t,n,r){if(r&amp;&amp;void 0===t)return;const i=(0,s.gK)(e,"values");if(!t||"object"!=typeof t||Array.isArray(t))throw new Error(i+" must be an object containing the children to replace.");const o=[];O(t,((e,t)=&gt;{const r=new fe(e);if(Rr(i,t,be(n,r)),".priority"===_e(r)&amp;&amp;!Ar(t))throw new Error(i+"contains an invalid value for '"+r.toString()+"', which must be a valid Firebase priority (a string, finite number, server value, or null).");o.push(r)})),function(e,t){let n,r;for(n=0;n&lt;t.length;n++){r=t[n];const i=ve(r);for(let t=0;t&lt;i.length;t++)if(".priority"===i[t]&amp;&amp;t===i.length-1);else if(!Dr(i[t]))throw new Error(e+"contains an invalid key ("+i[t]+") in path "+r.toString()+'. Keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]"')}t.sort(Te);let i=null;for(n=0;n&lt;t.length;n++){if(r=t[n],null!==i&amp;&amp;Se(i,r))throw new Error(e+"contains a path "+i.toString()+" that is ancestor of another path "+r.toString());i=r}}(i,o)},Fr=function(e,t,n){if(!n||void 0!==t){if(k(t))throw new Error((0,s.gK)(e,"priority")+"is "+t.toString()+", but must be a valid Firebase priority (a string, finite number, server value, or null).");if(!Ar(t))throw new Error((0,s.gK)(e,"priority")+"must be a valid Firebase priority (a string, finite number, server value, or null).")}},Or=function(e,t,n,r){if(!(r&amp;&amp;void 0===n||Dr(n)))throw new Error((0,s.gK)(e,t)+'was an invalid key = "'+n+'".  Firebase keys must be non-empty strings and can\'t contain ".", "#", "$", "/", "[", or "]").')},Lr=function(e,t,n,r){if(!(r&amp;&amp;void 0===n||Nr(n)))throw new Error((0,s.gK)(e,t)+'was an invalid path = "'+n+'". Paths must be non-empty strings and can\'t contain ".", "#", "$", "[", or "]"')},qr=function(e,t,n,r){n&amp;&amp;(n=n.replace(/^\/*\.info(\/|$)/,"/")),Lr(e,t,n,r)},Vr=function(e,t){if(".info"===ge(t))throw new Error(e+" failed = Can't modify data under /.info/")},Br=function(e,t){const n=t.path.toString();if("string"!=typeof t.repoInfo.host||0===t.repoInfo.host.length||!Dr(t.repoInfo.namespace)&amp;&amp;"localhost"!==t.repoInfo.host.split(":")[0]||0!==n.length&amp;&amp;!function(e){return e&amp;&amp;(e=e.replace(/^\/*\.info(\/|$)/,"/")),Nr(e)}(n))throw new Error((0,s.gK)(e,"url")+'must be a valid firebase URL and the path can\'t contain ".", "#", "$", "[", or "]".')};class Ur{constructor(){this.eventLists_=[],this.recursionDepth_=0}}function jr(e,t){let n=null;for(let r=0;r&lt;t.length;r++){const i=t[r],s=i.getPath();null===n||Ee(s,n.path)||(e.eventLists_.push(n),n=null),null===n&amp;&amp;(n={events:[],path:s}),n.events.push(i)}n&amp;&amp;e.eventLists_.push(n)}function zr(e,t,n){jr(e,n),Kr(e,(e=&gt;Ee(e,t)))}function $r(e,t,n){jr(e,n),Kr(e,(e=&gt;Se(e,t)||Se(t,e)))}function Kr(e,t){e.recursionDepth_++;let n=!0;for(let r=0;r&lt;e.eventLists_.length;r++){const i=e.eventLists_[r];i&amp;&amp;(t(i.path)?(Gr(e.eventLists_[r]),e.eventLists_[r]=null):n=!1)}n&amp;&amp;(e.eventLists_=[]),e.recursionDepth_--}function Gr(e){for(let t=0;t&lt;e.events.length;t++){const n=e.events[t];if(null!==n){e.events[t]=null;const r=n.getEventRunner();w&amp;&amp;C("event: "+n.toString()),B(r)}}}const Wr="repo_interrupt",Hr=25;class Qr{constructor(e,t,n,r){this.repoInfo_=e,this.forceRestClient_=t,this.authTokenProvider_=n,this.appCheckProvider_=r,this.dataUpdateCount=0,this.statsListener_=null,this.eventQueue_=new Ur,this.nextWriteId_=1,this.interceptServerDataCallback_=null,this.onDisconnect_=Et(),this.transactionQueueTree_=new yr,this.persistentConnection_=null,this.key=this.repoInfo_.toURLString()}toString(){return(this.repoInfo_.secure?"https://":"http://")+this.repoInfo_.host}}function Yr(e,t,n){if(e.stats_=te(e.repoInfo_),e.forceRestClient_||("object"==typeof window&amp;&amp;window.navigator&amp;&amp;window.navigator.userAgent||"").search(/googlebot|google webmaster tools|bingbot|yahoo! slurp|baiduspider|yandexbot|duckduckbot/i)&gt;=0)e.server_=new Ct(e.repoInfo_,((t,n,r,i)=&gt;{Zr(e,t,n,r,i)}),e.authTokenProvider_,e.appCheckProvider_),setTimeout((()=&gt;ei(e,!0)),0);else{if(null!=n){if("object"!=typeof n)throw new Error("Only objects are supported for option databaseAuthVariableOverride");try{(0,s.Wl)(n)}catch(e){throw new Error("Invalid authOverride provided: "+e)}}e.persistentConnection_=new Pe(e.repoInfo_,t,((t,n,r,i)=&gt;{Zr(e,t,n,r,i)}),(t=&gt;{ei(e,t)}),(t=&gt;{!function(e,t){O(t,((t,n)=&gt;{ti(e,t,n)}))}(e,t)}),e.authTokenProvider_,e.appCheckProvider_,n),e.server_=e.persistentConnection_}e.authTokenProvider_.addTokenChangeListener((t=&gt;{e.server_.refreshAuthToken(t)})),e.appCheckProvider_.addTokenChangeListener((t=&gt;{e.server_.refreshAppCheckToken(t.token)})),e.statsReporter_=function(t,n){const r=t.toString();return ee[r]||(ee[r]=new Nt(e.stats_,e.server_)),ee[r]}(e.repoInfo_),e.infoData_=new Tt,e.infoSyncTree_=new $n({startListening:(t,n,r,i)=&gt;{let s=[];const o=e.infoData_.getNode(t._path);return o.isEmpty()||(s=Wn(e.infoSyncTree_,t._path,o),setTimeout((()=&gt;{i("ok")}),0)),s},stopListening:()=&gt;{}}),ti(e,"connected",!1),e.serverSyncTree_=new $n({startListening:(t,n,r,i)=&gt;(e.server_.listen(t,r,n,((n,r)=&gt;{const s=i(n,r);$r(e.eventQueue_,t._path,s)})),[]),stopListening:(t,n)=&gt;{e.server_.unlisten(t,n)}})}function Xr(e){const t=e.infoData_.getNode(new fe(".info/serverTimeOffset")).val()||0;return(new Date).getTime()+t}function Jr(e){return lr({timestamp:Xr(e)})}function Zr(e,t,n,r,i){e.dataUpdateCount++;const o=new fe(t);n=e.interceptServerDataCallback_?e.interceptServerDataCallback_(t,n):n;let a=[];if(i)if(r){const t=(0,s.UI)(n,(e=&gt;at(e)));a=function(e,t,n,r){const i=ir(e,r);if(i){const r=sr(i),s=r.path,o=r.queryId,a=Ce(s,t),c=Gt.fromObject(n);return or(e,s,new Ot(Pt(o),a,c))}return[]}(e.serverSyncTree_,o,t,i)}else{const t=at(n);a=Qn(e.serverSyncTree_,o,t,i)}else if(r){const t=(0,s.UI)(n,(e=&gt;at(e)));a=function(e,t,n){const r=Gt.fromObject(n);return Jn(e,new Ot({fromUser:!1,fromServer:!0,queryId:null,tagged:!1},t,r))}(e.serverSyncTree_,o,t)}else{const t=at(n);a=Wn(e.serverSyncTree_,o,t)}let c=o;a.length&gt;0&amp;&amp;(c=di(e,o)),$r(e.eventQueue_,c,a)}function ei(e,t){ti(e,"connected",t),!1===t&amp;&amp;function(e){ci(e,"onDisconnectEvents");const t=Jr(e),n=Et();kt(e.onDisconnect_,pe(),((r,i)=&gt;{const s=pr(r,i,e.serverSyncTree_,t);St(n,r,s)}));let r=[];kt(n,pe(),((t,n)=&gt;{r=r.concat(Wn(e.serverSyncTree_,t,n));const i=yi(e,t);di(e,i)})),e.onDisconnect_=Et(),$r(e.eventQueue_,pe(),r)}(e)}function ti(e,t,n){const r=new fe("/.info/"+t),i=at(n);e.infoData_.updateSnapshot(r,i);const s=Wn(e.infoSyncTree_,r,i);$r(e.eventQueue_,r,s)}function ni(e){return e.nextWriteId_++}function ri(e,t,n,r,i){ci(e,"set",{path:t.toString(),value:n,priority:r});const s=Jr(e),o=at(n,r),a=Xn(e.serverSyncTree_,t),c=gr(o,a,s),u=ni(e),l=Kn(e.serverSyncTree_,t,c,u,!0);jr(e.eventQueue_,l),e.server_.put(t.toString(),o.val(!0),((n,r)=&gt;{const s="ok"===n;s||x("set at "+t+" failed: "+n);const o=Gn(e.serverSyncTree_,u,!s);$r(e.eventQueue_,t,o),ui(0,i,n,r)}));const h=yi(e,t);di(e,h),$r(e.eventQueue_,h,[])}function ii(e,t,n){e.server_.onDisconnectCancel(t.toString(),((r,i)=&gt;{"ok"===r&amp;&amp;xt(e.onDisconnect_,t),ui(0,n,r,i)}))}function si(e,t,n,r){const i=at(n);e.server_.onDisconnectPut(t.toString(),i.val(!0),((n,s)=&gt;{"ok"===n&amp;&amp;St(e.onDisconnect_,t,i),ui(0,r,n,s)}))}function oi(e,t,n){let r;r=".info"===ge(t._path)?Hn(e.infoSyncTree_,t,n):Hn(e.serverSyncTree_,t,n),zr(e.eventQueue_,t._path,r)}function ai(e){e.persistentConnection_&amp;&amp;e.persistentConnection_.interrupt(Wr)}function ci(e,...t){let n="";e.persistentConnection_&amp;&amp;(n=e.persistentConnection_.id+":"),C(n,...t)}function ui(e,t,n,r){t&amp;&amp;B((()=&gt;{if("ok"===n)t(null);else{const e=(n||"error").toUpperCase();let i=e;r&amp;&amp;(i+=": "+r);const s=new Error(i);s.code=e,t(s)}}))}function li(e,t,n){return Xn(e.serverSyncTree_,t,n)||it.EMPTY_NODE}function hi(e,t=e.transactionQueueTree_){if(t||mi(e,t),vr(t)){const n=pi(e,t);(0,s.hu)(n.length&gt;0,"Sending zero length transaction queue"),n.every((e=&gt;0===e.status))&amp;&amp;function(e,t,n){const r=n.map((e=&gt;e.currentWriteId)),i=li(e,t,r);let o=i;const a=i.hash();for(let e=0;e&lt;n.length;e++){const r=n[e];(0,s.hu)(0===r.status,"tryToSendTransactionQueue_: items in queue should all be run."),r.status=1,r.retryCount++;const i=Ce(t,r.path);o=o.updateChild(i,r.currentOutputSnapshotRaw)}const c=o.val(!0),u=t;e.server_.put(u.toString(),c,(r=&gt;{ci(e,"transaction put response",{path:u.toString(),status:r});let i=[];if("ok"===r){const r=[];for(let t=0;t&lt;n.length;t++)n[t].status=2,i=i.concat(Gn(e.serverSyncTree_,n[t].currentWriteId)),n[t].onComplete&amp;&amp;r.push((()=&gt;n[t].onComplete(null,!0,n[t].currentOutputSnapshotResolved))),n[t].unwatcher();mi(e,_r(e.transactionQueueTree_,t)),hi(e,e.transactionQueueTree_),$r(e.eventQueue_,t,i);for(let e=0;e&lt;r.length;e++)B(r[e])}else{if("datastale"===r)for(let e=0;e&lt;n.length;e++)3===n[e].status?n[e].status=4:n[e].status=0;else{x("transaction at "+u.toString()+" failed: "+r);for(let e=0;e&lt;n.length;e++)n[e].status=4,n[e].abortReason=r}di(e,t)}}),a)}(e,Tr(t),n)}else br(t)&amp;&amp;Ir(t,(t=&gt;{hi(e,t)}))}function di(e,t){const n=fi(e,t),r=Tr(n);return function(e,t,n){if(0===t.length)return;const r=[];let i=[];const o=t.filter((e=&gt;0===e.status)).map((e=&gt;e.currentWriteId));for(let c=0;c&lt;t.length;c++){const u=t[c],l=Ce(n,u.path);let h,d=!1;if((0,s.hu)(null!==l,"rerunTransactionsUnderNode_: relativePath should not be null."),4===u.status)d=!0,h=u.abortReason,i=i.concat(Gn(e.serverSyncTree_,u.currentWriteId,!0));else if(0===u.status)if(u.retryCount&gt;=Hr)d=!0,h="maxretry",i=i.concat(Gn(e.serverSyncTree_,u.currentWriteId,!0));else{const n=li(e,u.path,o);u.currentInputSnapshot=n;const r=t[c].update(n.val());if(void 0!==r){Rr("transaction failed: Data returned ",r,u.path);let t=at(r);"object"==typeof r&amp;&amp;null!=r&amp;&amp;(0,s.r3)(r,".priority")||(t=t.updatePriority(n.getPriority()));const a=u.currentWriteId,c=Jr(e),l=gr(t,n,c);u.currentOutputSnapshotRaw=t,u.currentOutputSnapshotResolved=l,u.currentWriteId=ni(e),o.splice(o.indexOf(a),1),i=i.concat(Kn(e.serverSyncTree_,u.path,l,u.currentWriteId,u.applyLocally)),i=i.concat(Gn(e.serverSyncTree_,a,!0))}else d=!0,h="nodata",i=i.concat(Gn(e.serverSyncTree_,u.currentWriteId,!0))}$r(e.eventQueue_,n,i),i=[],d&amp;&amp;(t[c].status=2,a=t[c].unwatcher,setTimeout(a,Math.floor(0)),t[c].onComplete&amp;&amp;("nodata"===h?r.push((()=&gt;t[c].onComplete(null,!1,t[c].currentInputSnapshot))):r.push((()=&gt;t[c].onComplete(new Error(h),!1,null)))))}var a;mi(e,e.transactionQueueTree_);for(let e=0;e&lt;r.length;e++)B(r[e]);hi(e,e.transactionQueueTree_)}(e,pi(e,n),r),r}function fi(e,t){let n,r=e.transactionQueueTree_;for(n=ge(t);null!==n&amp;&amp;void 0===vr(r);)r=_r(r,n),n=ge(t=ye(t));return r}function pi(e,t){const n=[];return gi(e,t,n),n.sort(((e,t)=&gt;e.order-t.order)),n}function gi(e,t,n){const r=vr(t);if(r)for(let e=0;e&lt;r.length;e++)n.push(r[e]);Ir(t,(t=&gt;{gi(e,t,n)}))}function mi(e,t){const n=vr(t);if(n){let e=0;for(let t=0;t&lt;n.length;t++)2!==n[t].status&amp;&amp;(n[e]=n[t],e++);n.length=e,wr(t,n.length&gt;0?n:void 0)}Ir(t,(t=&gt;{mi(e,t)}))}function yi(e,t){const n=Tr(fi(e,t)),r=_r(e.transactionQueueTree_,t);return function(e,t,n){let r=e.parent;for(;null!==r;){if(t(r))return!0;r=r.parent}}(r,(t=&gt;{_i(e,t)})),_i(e,r),Cr(r,(t=&gt;{_i(e,t)})),n}function _i(e,t){const n=vr(t);if(n){const r=[];let i=[],o=-1;for(let t=0;t&lt;n.length;t++)3===n[t].status||(1===n[t].status?((0,s.hu)(o===t-1,"All SENT items should be at beginning of queue."),o=t,n[t].status=3,n[t].abortReason="set"):((0,s.hu)(0===n[t].status,"Unexpected transaction status in abort"),n[t].unwatcher(),i=i.concat(Gn(e.serverSyncTree_,n[t].currentWriteId,!0)),n[t].onComplete&amp;&amp;r.push(n[t].onComplete.bind(null,new Error("set"),!1,null))));-1===o?wr(t,void 0):n.length=o+1,$r(e.eventQueue_,Tr(t),i);for(let e=0;e&lt;r.length;e++)B(r[e])}}const vi=function(e,t){const n=wi(e),r=n.namespace;"firebase.com"===n.domain&amp;&amp;S(n.host+" is no longer supported. Please use &lt;YOUR FIREBASE&gt;.firebaseio.com instead"),r&amp;&amp;"undefined"!==r||"localhost"===n.domain||S("Cannot parse Firebase url. Please use https://&lt;YOUR FIREBASE&gt;.firebaseio.com"),n.secure||"undefined"!=typeof window&amp;&amp;window.location&amp;&amp;window.location.protocol&amp;&amp;-1!==window.location.protocol.indexOf("https:")&amp;&amp;x("Insecure Firebase access from a secure page. Please use https in calls to new Firebase().");const i="ws"===n.scheme||"wss"===n.scheme;return{repoInfo:new Y(n.host,n.secure,r,i,t,"",r!==n.subdomain),path:new fe(n.pathString)}},wi=function(e){let t="",n="",r="",i="",s="",o=!0,a="https",c=443;if("string"==typeof e){let u=e.indexOf("//");u&gt;=0&amp;&amp;(a=e.substring(0,u-1),e=e.substring(u+2));let l=e.indexOf("/");-1===l&amp;&amp;(l=e.length);let h=e.indexOf("?");-1===h&amp;&amp;(h=e.length),t=e.substring(0,Math.min(l,h)),l&lt;h&amp;&amp;(i=function(e){let t="";const n=e.split("/");for(let e=0;e&lt;n.length;e++)if(n[e].length&gt;0){let r=n[e];try{r=decodeURIComponent(r.replace(/\+/g," "))}catch(e){}t+="/"+r}return t}(e.substring(l,h)));const d=function(e){const t={};"?"===e.charAt(0)&amp;&amp;(e=e.substring(1));for(const n of e.split("&amp;")){if(0===n.length)continue;const r=n.split("=");2===r.length?t[decodeURIComponent(r[0])]=decodeURIComponent(r[1]):x(`Invalid query segment '${n}' in query '${e}'`)}return t}(e.substring(Math.min(e.length,h)));u=t.indexOf(":"),u&gt;=0?(o="https"===a||"wss"===a,c=parseInt(t.substring(u+1),10)):u=t.length;const f=t.slice(0,u);if("localhost"===f.toLowerCase())n="localhost";else if(f.split(".").length&lt;=2)n=f;else{const e=t.indexOf(".");r=t.substring(0,e).toLowerCase(),n=t.substring(e+1),s=r}"ns"in d&amp;&amp;(s=d.ns)}return{host:t,port:c,domain:n,subdomain:r,secure:o,scheme:a,pathString:i,namespace:s}},bi="-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz",Ii=function(){let e=0;const t=[];return function(n){const r=n===e;let i;e=n;const o=new Array(8);for(i=7;i&gt;=0;i--)o[i]=bi.charAt(n%64),n=Math.floor(n/64);(0,s.hu)(0===n,"Cannot push at time == 0");let a=o.join("");if(r){for(i=11;i&gt;=0&amp;&amp;63===t[i];i--)t[i]=0;t[i]++}else for(i=0;i&lt;12;i++)t[i]=Math.floor(64*Math.random());for(i=0;i&lt;12;i++)a+=bi.charAt(t[i]);return(0,s.hu)(20===a.length,"nextPushId: Length should be 20."),a}}();class Ci{constructor(e,t,n,r){this.eventType=e,this.eventRegistration=t,this.snapshot=n,this.prevName=r}getPath(){const e=this.snapshot.ref;return"value"===this.eventType?e._path:e.parent._path}getEventType(){return this.eventType}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.getPath().toString()+":"+this.eventType+":"+(0,s.Wl)(this.snapshot.exportVal())}}class Ti{constructor(e,t,n){this.eventRegistration=e,this.error=t,this.path=n}getPath(){return this.path}getEventType(){return"cancel"}getEventRunner(){return this.eventRegistration.getEventRunner(this)}toString(){return this.path.toString()+":cancel"}}class Ei{constructor(e,t){this.snapshotCallback=e,this.cancelCallback=t}onValue(e,t){this.snapshotCallback.call(null,e,t)}onCancel(e){return(0,s.hu)(this.hasCancelCallback,"Raising a cancel event on a listener with no cancel callback"),this.cancelCallback.call(null,e)}get hasCancelCallback(){return!!this.cancelCallback}matches(e){return this.snapshotCallback===e.snapshotCallback||void 0!==this.snapshotCallback.userCallback&amp;&amp;this.snapshotCallback.userCallback===e.snapshotCallback.userCallback&amp;&amp;this.snapshotCallback.context===e.snapshotCallback.context}}class Si{constructor(e,t){this._repo=e,this._path=t}cancel(){const e=new s.BH;return ii(this._repo,this._path,e.wrapCallback((()=&gt;{}))),e.promise}remove(){Vr("OnDisconnect.remove",this._path);const e=new s.BH;return si(this._repo,this._path,null,e.wrapCallback((()=&gt;{}))),e.promise}set(e){Vr("OnDisconnect.set",this._path),Pr("OnDisconnect.set",e,this._path,!1);const t=new s.BH;return si(this._repo,this._path,e,t.wrapCallback((()=&gt;{}))),t.promise}setWithPriority(e,t){Vr("OnDisconnect.setWithPriority",this._path),Pr("OnDisconnect.setWithPriority",e,this._path,!1),Fr("OnDisconnect.setWithPriority",t,!1);const n=new s.BH;return function(e,t,n,r,i){const s=at(n,r);e.server_.onDisconnectPut(t.toString(),s.val(!0),((n,r)=&gt;{"ok"===n&amp;&amp;St(e.onDisconnect_,t,s),ui(0,i,n,r)}))}(this._repo,this._path,e,t,n.wrapCallback((()=&gt;{}))),n.promise}update(e){Vr("OnDisconnect.update",this._path),Mr("OnDisconnect.update",e,this._path,!1);const t=new s.BH;return function(e,t,n,r){if((0,s.xb)(n))return C("onDisconnect().update() called with empty data.  Don't do anything."),void ui(0,r,"ok",void 0);e.server_.onDisconnectMerge(t.toString(),n,((i,s)=&gt;{"ok"===i&amp;&amp;O(n,((n,r)=&gt;{const i=at(r);St(e.onDisconnect_,be(t,n),i)})),ui(0,r,i,s)}))}(this._repo,this._path,e,t.wrapCallback((()=&gt;{}))),t.promise}}class xi{constructor(e,t,n,r){this._repo=e,this._path=t,this._queryParams=n,this._orderByCalled=r}get key(){return Ie(this._path)?null:_e(this._path)}get ref(){return new Ai(this._repo,this._path)}get _queryIdentifier(){const e=It(this._queryParams),t=M(e);return"{}"===t?"default":t}get _queryObject(){return It(this._queryParams)}isEqual(e){if(!((e=(0,s.m9)(e))instanceof xi))return!1;const t=this._repo===e._repo,n=Ee(this._path,e._path),r=this._queryIdentifier===e._queryIdentifier;return t&amp;&amp;n&amp;&amp;r}toJSON(){return this.toString()}toString(){return this._repo.toString()+function(e){let t="";for(let n=e.pieceNum_;n&lt;e.pieces_.length;n++)""!==e.pieces_[n]&amp;&amp;(t+="/"+encodeURIComponent(String(e.pieces_[n])));return t||"/"}(this._path)}}function ki(e,t){if(!0===e._orderByCalled)throw new Error(t+": You can't combine multiple orderBy calls.")}function Di(e){let t=null,n=null;if(e.hasStart()&amp;&amp;(t=e.getIndexStartValue()),e.hasEnd()&amp;&amp;(n=e.getIndexEndValue()),e.getIndex()===Le){const r="Query: When ordering by key, you may only pass one argument to startAt(), endAt(), or equalTo().",i="Query: When ordering by key, the argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() must be a string.";if(e.hasStart()){if(e.getIndexStartName()!==D)throw new Error(r);if("string"!=typeof t)throw new Error(i)}if(e.hasEnd()){if(e.getIndexEndName()!==N)throw new Error(r);if("string"!=typeof n)throw new Error(i)}}else if(e.getIndex()===Ye){if(null!=t&amp;&amp;!Ar(t)||null!=n&amp;&amp;!Ar(n))throw new Error("Query: When ordering by priority, the first argument passed to startAt(), startAfter() endAt(), endBefore(), or equalTo() must be a valid priority value (null, a number, or a string).")}else if((0,s.hu)(e.getIndex()instanceof ct||e.getIndex()===ut,"unknown index type."),null!=t&amp;&amp;"object"==typeof t||null!=n&amp;&amp;"object"==typeof n)throw new Error("Query: First argument passed to startAt(), startAfter(), endAt(), endBefore(), or equalTo() cannot be an object.")}function Ni(e){if(e.hasStart()&amp;&amp;e.hasEnd()&amp;&amp;e.hasLimit()&amp;&amp;!e.hasAnchoredLimit())throw new Error("Query: Can't combine startAt(), startAfter(), endAt(), endBefore(), and limit(). Use limitToFirst() or limitToLast() instead.")}class Ai extends xi{constructor(e,t){super(e,t,new yt,!1)}get parent(){const e=we(this._path);return null===e?null:new Ai(this._repo,e)}get root(){let e=this;for(;null!==e.parent;)e=e.parent;return e}}class Pi{constructor(e,t,n){this._node=e,this.ref=t,this._index=n}get priority(){return this._node.getPriority().val()}get key(){return this.ref.key}get size(){return this._node.numChildren()}child(e){const t=new fe(e),n=Fi(this.ref,e);return new Pi(this._node.getChild(t),n,Ye)}exists(){return!this._node.isEmpty()}exportVal(){return this._node.val(!0)}forEach(e){return!this._node.isLeafNode()&amp;&amp;!!this._node.forEachChild(this._index,((t,n)=&gt;e(new Pi(n,Fi(this.ref,t),Ye))))}hasChild(e){const t=new fe(e);return!this._node.getChild(t).isEmpty()}hasChildren(){return!this._node.isLeafNode()&amp;&amp;!this._node.isEmpty()}toJSON(){return this.exportVal()}val(){return this._node.val()}}function Ri(e,t){return(e=(0,s.m9)(e))._checkNotDeleted("ref"),void 0!==t?Fi(e._root,t):e._root}function Mi(e,t){(e=(0,s.m9)(e))._checkNotDeleted("refFromURL");const n=vi(t,e._repo.repoInfo_.nodeAdmin);Br("refFromURL",n);const r=n.repoInfo;return e._repo.repoInfo_.isCustomHost()||r.host===e._repo.repoInfo_.host||S("refFromURL: Host name does not match the current database: (found "+r.host+" but expected "+e._repo.repoInfo_.host+")"),Ri(e,n.path.toString())}function Fi(e,t){return null===ge((e=(0,s.m9)(e))._path)?qr("child","path",t,!1):Lr("child","path",t,!1),new Ai(e._repo,be(e._path,t))}function Oi(e){return e=(0,s.m9)(e),new Si(e._repo,e._path)}function Li(e,t){e=(0,s.m9)(e),Vr("push",e._path),Pr("push",t,e._path,!0);const n=Xr(e._repo),r=Ii(n),i=Fi(e,r),o=Fi(e,r);let a;return a=null!=t?Vi(o,t).then((()=&gt;o)):Promise.resolve(o),i.then=a.then.bind(a),i.catch=a.then.bind(a,void 0),i}function qi(e){return Vr("remove",e._path),Vi(e,null)}function Vi(e,t){e=(0,s.m9)(e),Vr("set",e._path),Pr("set",t,e._path,!1);const n=new s.BH;return ri(e._repo,e._path,t,null,n.wrapCallback((()=&gt;{}))),n.promise}function Bi(e,t){e=(0,s.m9)(e),Vr("setPriority",e._path),Fr("setPriority",t,!1);const n=new s.BH;return ri(e._repo,be(e._path,".priority"),t,null,n.wrapCallback((()=&gt;{}))),n.promise}function Ui(e,t,n){if(Vr("setWithPriority",e._path),Pr("setWithPriority",t,e._path,!1),Fr("setWithPriority",n,!1),".length"===e.key||".keys"===e.key)throw"setWithPriority failed: "+e.key+" is a read-only object.";const r=new s.BH;return ri(e._repo,e._path,t,n,r.wrapCallback((()=&gt;{}))),r.promise}function ji(e,t){Mr("update",t,e._path,!1);const n=new s.BH;return function(e,t,n,r){ci(e,"update",{path:t.toString(),value:n});let i=!0;const o=Jr(e),a={};if(O(n,((n,r)=&gt;{i=!1,a[n]=pr(be(t,n),at(r),e.serverSyncTree_,o)})),i)C("update() called with empty data.  Don't do anything."),ui(0,r,"ok",void 0);else{const i=ni(e),o=function(e,t,n,r){!function(e,t,n,r){(0,s.hu)(r&gt;e.lastWriteId,"Stacking an older merge on top of newer ones"),e.allWrites.push({path:t,children:n,writeId:r,visible:!0}),e.visibleWrites=Qt(e.visibleWrites,t,n),e.lastWriteId=r}(e.pendingWriteTree_,t,n,r);const i=Gt.fromObject(n);return Jn(e,new Ot({fromUser:!0,fromServer:!1,queryId:null,tagged:!1},t,i))}(e.serverSyncTree_,t,a,i);jr(e.eventQueue_,o),e.server_.merge(t.toString(),n,((n,s)=&gt;{const o="ok"===n;o||x("update at "+t+" failed: "+n);const a=Gn(e.serverSyncTree_,i,!o),c=a.length&gt;0?di(e,t):t;$r(e.eventQueue_,c,a),ui(0,r,n,s)})),O(n,(n=&gt;{const r=yi(e,be(t,n));di(e,r)})),$r(e.eventQueue_,t,[])}}(e._repo,e._path,t,n.wrapCallback((()=&gt;{}))),n.promise}function zi(e){e=(0,s.m9)(e);const t=new Ei((()=&gt;{})),n=new $i(t);return function(e,t,n){const r=function(e,t){const n=t._path;let r=null;e.syncPointTree_.foreachOnPath(n,((e,t)=&gt;{const i=Ce(e,n);r=r||qn(t,i)}));let i=e.syncPointTree_.get(n);i?r=r||qn(i,pe()):(i=new Mn,e.syncPointTree_=e.syncPointTree_.set(n,i));const s=null!=r,o=s?new Lt(r,!0,!1):null;return zt(On(i,t,sn(e.pendingWriteTree_,t._path),s?o.getNode():it.EMPTY_NODE,s).viewCache_)}(e.serverSyncTree_,t);return null!=r?Promise.resolve(r):e.server_.get(t).then((r=&gt;{const i=at(r).withIndex(t._queryParams.getIndex());let s;if(Yn(e.serverSyncTree_,t,n,!0),t._queryParams.loadsAllData())s=Wn(e.serverSyncTree_,t._path,i);else{const n=nr(e.serverSyncTree_,t);s=Qn(e.serverSyncTree_,t._path,i,n)}return $r(e.eventQueue_,t._path,s),Hn(e.serverSyncTree_,t,n,null,!0),i}),(n=&gt;(ci(e,"get for query "+(0,s.Wl)(t)+" failed: "+n),Promise.reject(new Error(n)))))}(e._repo,e,n).then((t=&gt;new Pi(t,new Ai(e._repo,e._path),e._queryParams.getIndex())))}class $i{constructor(e){this.callbackContext=e}respondsTo(e){return"value"===e}createEvent(e,t){const n=t._queryParams.getIndex();return new Ci("value",this,new Pi(e.snapshotNode,new Ai(t._repo,t._path),n))}getEventRunner(e){return"cancel"===e.getEventType()?()=&gt;this.callbackContext.onCancel(e.error):()=&gt;this.callbackContext.onValue(e.snapshot,null)}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new Ti(this,e,t):null}matches(e){return e instanceof $i&amp;&amp;(!e.callbackContext||!this.callbackContext||e.callbackContext.matches(this.callbackContext))}hasAnyCallback(){return null!==this.callbackContext}}class Ki{constructor(e,t){this.eventType=e,this.callbackContext=t}respondsTo(e){let t="children_added"===e?"child_added":e;return t="children_removed"===t?"child_removed":t,this.eventType===t}createCancelEvent(e,t){return this.callbackContext.hasCancelCallback?new Ti(this,e,t):null}createEvent(e,t){(0,s.hu)(null!=e.childName,"Child events should have a childName.");const n=Fi(new Ai(t._repo,t._path),e.childName),r=t._queryParams.getIndex();return new Ci(e.type,this,new Pi(e.snapshotNode,n,r),e.prevName)}getEventRunner(e){return"cancel"===e.getEventType()?()=&gt;this.callbackContext.onCancel(e.error):()=&gt;this.callbackContext.onValue(e.snapshot,e.prevName)}matches(e){return e instanceof Ki&amp;&amp;this.eventType===e.eventType&amp;&amp;(!this.callbackContext||!e.callbackContext||this.callbackContext.matches(e.callbackContext))}hasAnyCallback(){return!!this.callbackContext}}function Gi(e,t,n,r,i){let s;if("object"==typeof r&amp;&amp;(s=void 0,i=r),"function"==typeof r&amp;&amp;(s=r),i&amp;&amp;i.onlyOnce){const t=n,r=(n,r)=&gt;{oi(e._repo,e,a),t(n,r)};r.userCallback=n.userCallback,r.context=n.context,n=r}const o=new Ei(n,s||void 0),a="value"===t?new $i(o):new Ki(t,o);return function(e,t,n){let r;r=".info"===ge(t._path)?Yn(e.infoSyncTree_,t,n):Yn(e.serverSyncTree_,t,n),zr(e.eventQueue_,t._path,r)}(e._repo,e,a),()=&gt;oi(e._repo,e,a)}function Wi(e,t,n,r){return Gi(e,"value",t,n,r)}function Hi(e,t,n,r){return Gi(e,"child_added",t,n,r)}function Qi(e,t,n,r){return Gi(e,"child_changed",t,n,r)}function Yi(e,t,n,r){return Gi(e,"child_moved",t,n,r)}function Xi(e,t,n,r){return Gi(e,"child_removed",t,n,r)}function Ji(e,t,n){let r=null;const i=n?new Ei(n):null;"value"===t?r=new $i(i):t&amp;&amp;(r=new Ki(t,i)),oi(e._repo,e,r)}class Zi{}class es extends Zi{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){Pr("endAt",this._value,e._path,!0);const t=vt(e._queryParams,this._value,this._key);if(Ni(t),Di(t),e._queryParams.hasEnd())throw new Error("endAt: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new xi(e._repo,e._path,t,e._orderByCalled)}}function ts(e,t){return Or("endAt","key",t,!0),new es(e,t)}class ns extends Zi{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){Pr("endBefore",this._value,e._path,!1);const t=function(e,t,n){let r;return r=e.index_===Le||n?vt(e,t,n):vt(e,t,D),r.endBeforeSet_=!0,r}(e._queryParams,this._value,this._key);if(Ni(t),Di(t),e._queryParams.hasEnd())throw new Error("endBefore: Starting point was already set (by another call to endAt, endBefore or equalTo).");return new xi(e._repo,e._path,t,e._orderByCalled)}}function rs(e,t){return Or("endBefore","key",t,!0),new ns(e,t)}class is extends Zi{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){Pr("startAt",this._value,e._path,!0);const t=_t(e._queryParams,this._value,this._key);if(Ni(t),Di(t),e._queryParams.hasStart())throw new Error("startAt: Starting point was already set (by another call to startAt, startBefore or equalTo).");return new xi(e._repo,e._path,t,e._orderByCalled)}}function ss(e=null,t){return Or("startAt","key",t,!0),new is(e,t)}class os extends Zi{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){Pr("startAfter",this._value,e._path,!1);const t=function(e,t,n){let r;return r=e.index_===Le||n?_t(e,t,n):_t(e,t,N),r.startAfterSet_=!0,r}(e._queryParams,this._value,this._key);if(Ni(t),Di(t),e._queryParams.hasStart())throw new Error("startAfter: Starting point was already set (by another call to startAt, startAfter, or equalTo).");return new xi(e._repo,e._path,t,e._orderByCalled)}}function as(e,t){return Or("startAfter","key",t,!0),new os(e,t)}class cs extends Zi{constructor(e){super(),this._limit=e}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToFirst: Limit was already set (by another call to limitToFirst or limitToLast).");return new xi(e._repo,e._path,function(e,t){const n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="l",n}(e._queryParams,this._limit),e._orderByCalled)}}function us(e){if("number"!=typeof e||Math.floor(e)!==e||e&lt;=0)throw new Error("limitToFirst: First argument must be a positive integer.");return new cs(e)}class ls extends Zi{constructor(e){super(),this._limit=e}_apply(e){if(e._queryParams.hasLimit())throw new Error("limitToLast: Limit was already set (by another call to limitToFirst or limitToLast).");return new xi(e._repo,e._path,function(e,t){const n=e.copy();return n.limitSet_=!0,n.limit_=t,n.viewFrom_="r",n}(e._queryParams,this._limit),e._orderByCalled)}}function hs(e){if("number"!=typeof e||Math.floor(e)!==e||e&lt;=0)throw new Error("limitToLast: First argument must be a positive integer.");return new ls(e)}class ds extends Zi{constructor(e){super(),this._path=e}_apply(e){ki(e,"orderByChild");const t=new fe(this._path);if(Ie(t))throw new Error("orderByChild: cannot pass in empty path. Use orderByValue() instead.");const n=new ct(t),r=wt(e._queryParams,n);return Di(r),new xi(e._repo,e._path,r,!0)}}function fs(e){if("$key"===e)throw new Error('orderByChild: "$key" is invalid.  Use orderByKey() instead.');if("$priority"===e)throw new Error('orderByChild: "$priority" is invalid.  Use orderByPriority() instead.');if("$value"===e)throw new Error('orderByChild: "$value" is invalid.  Use orderByValue() instead.');return Lr("orderByChild","path",e,!1),new ds(e)}class ps extends Zi{_apply(e){ki(e,"orderByKey");const t=wt(e._queryParams,Le);return Di(t),new xi(e._repo,e._path,t,!0)}}function gs(){return new ps}class ms extends Zi{_apply(e){ki(e,"orderByPriority");const t=wt(e._queryParams,Ye);return Di(t),new xi(e._repo,e._path,t,!0)}}function ys(){return new ms}class _s extends Zi{_apply(e){ki(e,"orderByValue");const t=wt(e._queryParams,ut);return Di(t),new xi(e._repo,e._path,t,!0)}}function vs(){return new _s}class ws extends Zi{constructor(e,t){super(),this._value=e,this._key=t}_apply(e){if(Pr("equalTo",this._value,e._path,!1),e._queryParams.hasStart())throw new Error("equalTo: Starting point was already set (by another call to startAt/startAfter or equalTo).");if(e._queryParams.hasEnd())throw new Error("equalTo: Ending point was already set (by another call to endAt/endBefore or equalTo).");return new es(this._value,this._key)._apply(new is(this._value,this._key)._apply(e))}}function bs(e,t){return Or("equalTo","key",t,!0),new ws(e,t)}function Is(e,...t){let n=(0,s.m9)(e);for(const e of t)n=e._apply(n);return n}!function(e){(0,s.hu)(!Pn,"__referenceConstructor has already been defined"),Pn=e}(Ai),function(e){(0,s.hu)(!Rn,"__referenceConstructor has already been defined"),Rn=e}(Ai);const Cs="FIREBASE_DATABASE_EMULATOR_HOST",Ts={};let Es=!1;function Ss(e,t,n,r,i){let s=r||e.options.databaseURL;void 0===s&amp;&amp;(e.options.projectId||S("Can't determine Firebase Database URL. Be sure to include  a Project ID when calling firebase.initializeApp()."),C("Using default host for project ",e.options.projectId),s=`${e.options.projectId}-default-rtdb.firebaseio.com`);let o,a,c=vi(s,i),u=c.repoInfo;"undefined"!=typeof process&amp;&amp;process.env&amp;&amp;(a=process.env[Cs]),a?(o=!0,s=`http://${a}?ns=${u.namespace}`,c=vi(s,i),u=c.repoInfo):o=!c.repoInfo.secure;const l=i&amp;&amp;o?new $($.OWNER):new z(e.name,e.options,t);Br("Invalid Firebase Database URL",c),Ie(c.path)||S("Database URL must point to the root of a Firebase Database (not including a child path).");const h=function(e,t,n,r){let i=Ts[t.name];i||(i={},Ts[t.name]=i);let s=i[e.toURLString()];return s&amp;&amp;S("Database initialized multiple times. Please make sure the format of the database URL matches with each database() call."),s=new Qr(e,Es,n,r),i[e.toURLString()]=s,s}(u,e,l,new j(e.name,n));return new xs(h,e)}class xs{constructor(e,t){this._repoInternal=e,this.app=t,this.type="database",this._instanceStarted=!1}get _repo(){return this._instanceStarted||(Yr(this._repoInternal,this.app.options.appId,this.app.options.databaseAuthVariableOverride),this._instanceStarted=!0),this._repoInternal}get _root(){return this._rootInternal||(this._rootInternal=new Ai(this._repo,pe())),this._rootInternal}_delete(){return null!==this._rootInternal&amp;&amp;(function(e,t){const n=Ts[t];n&amp;&amp;n[e.key]===e||S(`Database ${t}(${e.repoInfo_}) has already been deleted.`),ai(e),delete n[e.key]}(this._repo,this.app.name),this._repoInternal=null,this._rootInternal=null),Promise.resolve()}_checkNotDeleted(e){null===this._rootInternal&amp;&amp;S("Cannot call "+e+" on a deleted database.")}}function ks(){ce.IS_TRANSPORT_INITIALIZED&amp;&amp;x("Transport has already been initialized. Please call this function before calling ref or setting up a listener")}function Ds(){ks(),ie.forceDisallow()}function Ns(){ks(),ae.forceDisallow(),ie.forceAllow()}function As(e=(0,r.Mq)(),t){const n=(0,r.qX)(e,"database").getImmediate({identifier:t});if(!n._instanceStarted){const e=(0,s.P0)("database");e&amp;&amp;Ps(n,...e)}return n}function Ps(e,t,n,r={}){(e=(0,s.m9)(e))._checkNotDeleted("useEmulator"),e._instanceStarted&amp;&amp;S("Cannot call useEmulator() after instance has already been initialized.");const i=e._repoInternal;let o;if(i.repoInfo_.nodeAdmin)r.mockUserToken&amp;&amp;S('mockUserToken is not supported by the Admin SDK. For client access with mock users, please use the "firebase" package instead of "firebase-admin".'),o=new $($.OWNER);else if(r.mockUserToken){const t="string"==typeof r.mockUserToken?r.mockUserToken:(0,s.Sg)(r.mockUserToken,e.app.options.projectId);o=new $(t)}!function(e,t,n,r){e.repoInfo_=new Y(`${t}:${n}`,!1,e.repoInfo_.namespace,e.repoInfo_.webSocketOnly,e.repoInfo_.nodeAdmin,e.repoInfo_.persistenceKey,e.repoInfo_.includeNamespaceInQueryParams,!0),r&amp;&amp;(e.authTokenProvider_=r)}(i,t,n,o)}function Rs(e){(e=(0,s.m9)(e))._checkNotDeleted("goOffline"),ai(e._repo)}function Ms(e){var t;(e=(0,s.m9)(e))._checkNotDeleted("goOnline"),(t=e._repo).persistentConnection_&amp;&amp;t.persistentConnection_.resume(Wr)}function Fs(e,t){I(e,t)}const Os={".sv":"timestamp"};function Ls(){return Os}function qs(e){return{".sv":{increment:e}}}class Vs{constructor(e,t){this.committed=e,this.snapshot=t}toJSON(){return{committed:this.committed,snapshot:this.snapshot.toJSON()}}}function Bs(e,t,n){var r;if(e=(0,s.m9)(e),Vr("Reference.transaction",e._path),".length"===e.key||".keys"===e.key)throw"Reference.transaction failed: "+e.key+" is a read-only object.";const i=null===(r=null==n?void 0:n.applyLocally)||void 0===r||r,o=new s.BH,a=Wi(e,(()=&gt;{}));return function(t,n,r,i,a,c){ci(t,"transaction on "+n);const u={path:n,update:r,onComplete:(t,n,r)=&gt;{let i=null;t?o.reject(t):(i=new Pi(r,new Ai(e._repo,e._path),Ye),o.resolve(new Vs(n,i)))},status:null,order:y(),applyLocally:c,retryCount:0,unwatcher:a,abortReason:null,currentWriteId:null,currentInputSnapshot:null,currentOutputSnapshotRaw:null,currentOutputSnapshotResolved:null},l=li(t,n,void 0);u.currentInputSnapshot=l;const h=u.update(l.val());if(void 0===h)u.unwatcher(),u.currentOutputSnapshotRaw=null,u.currentOutputSnapshotResolved=null,u.onComplete&amp;&amp;u.onComplete(null,!1,u.currentInputSnapshot);else{Rr("transaction failed: Data returned ",h,u.path),u.status=0;const e=_r(t.transactionQueueTree_,n),r=vr(e)||[];let i;r.push(u),wr(e,r),"object"==typeof h&amp;&amp;null!==h&amp;&amp;(0,s.r3)(h,".priority")?(i=(0,s.DV)(h,".priority"),(0,s.hu)(Ar(i),"Invalid priority returned by transaction. Priority must be a valid string, finite number, server value, or null.")):i=(Xn(t.serverSyncTree_,n)||it.EMPTY_NODE).getPriority().val();const o=Jr(t),a=at(h,i),c=gr(a,l,o);u.currentOutputSnapshotRaw=a,u.currentOutputSnapshotResolved=c,u.currentWriteId=ni(t);const d=Kn(t.serverSyncTree_,n,c,u.currentWriteId,u.applyLocally);$r(t.eventQueue_,n,d),hi(t,t.transactionQueueTree_)}}(e._repo,e._path,t,0,a,i),o.promise}Pe.prototype.simpleListen=function(e,t){this.sendRequest("q",{p:e},t)},Pe.prototype.echo=function(e,t){this.sendRequest("echo",{d:e},t)};const Us=function(e){const t=Pe.prototype.put;return Pe.prototype.put=function(n,r,i,s){void 0!==s&amp;&amp;(s=e()),t.call(this,n,r,i,s)},function(){Pe.prototype.put=t}},js=function(e){!function(e){Es=e}(e)};l(r.Jn),(0,r.Xd)(new i.wA("database",((e,{instanceIdentifier:t})=&gt;Ss(e.getProvider("app").getImmediate(),e.getProvider("auth-internal"),e.getProvider("app-check-internal"),t)),"PUBLIC").setMultipleInstances(!0)),(0,r.KN)(a,c,undefined),(0,r.KN)(a,c,"esm2017")},953:(e,t,n)=&gt;{"use strict";n.r(t),n.d(t,{AbstractUserDataWriter:()=&gt;kg,AggregateField:()=&gt;wp,AggregateQuerySnapshot:()=&gt;bp,Bytes:()=&gt;Ip,CACHE_SIZE_UNLIMITED:()=&gt;rp,CollectionReference:()=&gt;Hf,DocumentReference:()=&gt;Gf,DocumentSnapshot:()=&gt;Lg,FieldPath:()=&gt;Cp,FieldValue:()=&gt;Ep,Firestore:()=&gt;ip,FirestoreError:()=&gt;Kr,GeoPoint:()=&gt;Sp,LoadBundleTask:()=&gt;np,Query:()=&gt;Wf,QueryCompositeFilterConstraint:()=&gt;cg,QueryConstraint:()=&gt;ig,QueryDocumentSnapshot:()=&gt;qg,QueryEndAtConstraint:()=&gt;vg,QueryFieldFilterConstraint:()=&gt;og,QueryLimitConstraint:()=&gt;fg,QueryOrderByConstraint:()=&gt;hg,QuerySnapshot:()=&gt;Vg,QueryStartAtConstraint:()=&gt;mg,SnapshotMetadata:()=&gt;Og,Timestamp:()=&gt;ai,Transaction:()=&gt;wm,WriteBatch:()=&gt;_m,_DatabaseId:()=&gt;Bs,_DocumentKey:()=&gt;fi,_EmptyAppCheckTokenProvider:()=&gt;ti,_EmptyAuthCredentialsProvider:()=&gt;Hr,_FieldPath:()=&gt;di,_TestingHooks:()=&gt;lc,_cast:()=&gt;Uf,_debugAssert:()=&gt;jr,_isBase64Available:()=&gt;Ns,_logWarn:()=&gt;qr,_validateIsNotUsedTogether:()=&gt;Lf,addDoc:()=&gt;Jg,aggregateFieldEqual:()=&gt;Mg,aggregateQuerySnapshotEqual:()=&gt;Fg,and:()=&gt;lg,arrayRemove:()=&gt;Em,arrayUnion:()=&gt;Tm,average:()=&gt;Pg,clearIndexedDbPersistence:()=&gt;dp,collection:()=&gt;Qf,collectionGroup:()=&gt;Yf,connectFirestoreEmulator:()=&gt;Kf,count:()=&gt;Rg,deleteDoc:()=&gt;Xg,deleteField:()=&gt;Im,disableNetwork:()=&gt;gp,doc:()=&gt;Xf,documentId:()=&gt;Tp,enableIndexedDbPersistence:()=&gt;up,enableMultiTabIndexedDbPersistence:()=&gt;lp,enableNetwork:()=&gt;pp,endAt:()=&gt;bg,endBefore:()=&gt;wg,ensureFirestoreConfigured:()=&gt;ap,executeWrite:()=&gt;tm,getAggregateFromServer:()=&gt;im,getCountFromServer:()=&gt;rm,getDoc:()=&gt;jg,getDocFromCache:()=&gt;$g,getDocFromServer:()=&gt;Kg,getDocs:()=&gt;Gg,getDocsFromCache:()=&gt;Wg,getDocsFromServer:()=&gt;Hg,getFirestore:()=&gt;op,increment:()=&gt;Sm,initializeFirestore:()=&gt;sp,limit:()=&gt;pg,limitToLast:()=&gt;gg,loadBundle:()=&gt;yp,memoryEagerGarbageCollector:()=&gt;um,memoryLocalCache:()=&gt;hm,memoryLruGarbageCollector:()=&gt;lm,namedQuery:()=&gt;_p,onSnapshot:()=&gt;Zg,onSnapshotsInSync:()=&gt;em,or:()=&gt;ug,orderBy:()=&gt;dg,persistentLocalCache:()=&gt;dm,persistentMultipleTabManager:()=&gt;mm,persistentSingleTabManager:()=&gt;gm,query:()=&gt;sg,queryEqual:()=&gt;Zf,refEqual:()=&gt;Jf,runTransaction:()=&gt;bm,serverTimestamp:()=&gt;Cm,setDoc:()=&gt;Qg,setIndexConfiguration:()=&gt;km,setLogLevel:()=&gt;Fr,snapshotEqual:()=&gt;Ug,startAfter:()=&gt;_g,startAt:()=&gt;yg,sum:()=&gt;Ag,terminate:()=&gt;mp,updateDoc:()=&gt;Yg,waitForPendingWrites:()=&gt;fp,where:()=&gt;ag,writeBatch:()=&gt;xm});var r,i=n(657),s=n(463),o=n(333),a=n(444),c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},u={},l=l||{},h=c||self;function d(){}function f(e){var t=typeof e;return"array"==(t="object"!=t?t:e?Array.isArray(e)?"array":t:"null")||"object"==t&amp;&amp;"number"==typeof e.length}function p(e){var t=typeof e;return"object"==t&amp;&amp;null!=e||"function"==t}var g="closure_uid_"+(1e9*Math.random()&gt;&gt;&gt;0),m=0;function y(e,t,n){return e.call.apply(e.bind,arguments)}function _(e,t,n){if(!e)throw Error();if(2&lt;arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),e.apply(t,n)}}return function(){return e.apply(t,arguments)}}function v(e,t,n){return(v=Function.prototype.bind&amp;&amp;-1!=Function.prototype.bind.toString().indexOf("native code")?y:_).apply(null,arguments)}function w(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 b(e,t){function n(){}n.prototype=t.prototype,e.$=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.ac=function(e,n,r){for(var i=Array(arguments.length-2),s=2;s&lt;arguments.length;s++)i[s-2]=arguments[s];return t.prototype[n].apply(e,i)}}function I(){this.s=this.s,this.o=this.o}I.prototype.s=!1,I.prototype.ra=function(){var e;!this.s&amp;&amp;(this.s=!0,this.N(),0)&amp;&amp;(e=this,Object.prototype.hasOwnProperty.call(e,g)&amp;&amp;e[g]||(e[g]=++m))},I.prototype.N=function(){if(this.o)for(;this.o.length;)this.o.shift()()};const C=Array.prototype.indexOf?function(e,t){return Array.prototype.indexOf.call(e,t,void 0)}:function(e,t){if("string"==typeof e)return"string"!=typeof t||1!=t.length?-1:e.indexOf(t,0);for(let n=0;n&lt;e.length;n++)if(n in e&amp;&amp;e[n]===t)return n;return-1};function T(e){const t=e.length;if(0&lt;t){const n=Array(t);for(let r=0;r&lt;t;r++)n[r]=e[r];return n}return[]}function E(e,t){for(let t=1;t&lt;arguments.length;t++){const n=arguments[t];if(f(n)){const t=e.length||0,r=n.length||0;e.length=t+r;for(let i=0;i&lt;r;i++)e[t+i]=n[i]}else e.push(n)}}function S(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}S.prototype.h=function(){this.defaultPrevented=!0};var x=function(){if(!h.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{h.addEventListener("test",d,t),h.removeEventListener("test",d,t)}catch(e){}return e}();function k(e){return/^[\s\xa0]*$/.test(e)}var D=String.prototype.trim?function(e){return e.trim()}:function(e){return/^[\s\xa0]*([\s\S]*?)[\s\xa0]*$/.exec(e)[1]};function N(e,t){return e&lt;t?-1:e&gt;t?1:0}function A(){var e=h.navigator;return e&amp;&amp;(e=e.userAgent)?e:""}function P(e){return-1!=A().indexOf(e)}function R(e){return R[" "](e),e}function M(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)?e[t]:e[t]=n(t)}R[" "]=d;var F,O,L=P("Opera"),q=P("Trident")||P("MSIE"),V=P("Edge"),B=V||q,U=P("Gecko")&amp;&amp;!(-1!=A().toLowerCase().indexOf("webkit")&amp;&amp;!P("Edge"))&amp;&amp;!(P("Trident")||P("MSIE"))&amp;&amp;!P("Edge"),j=-1!=A().toLowerCase().indexOf("webkit")&amp;&amp;!P("Edge");function z(){var e=h.document;return e?e.documentMode:void 0}e:{var $="",K=(O=A(),U?/rv:([^\);]+)(\)|;)/.exec(O):V?/Edge\/([\d\.]+)/.exec(O):q?/\b(?:MSIE|rv)[: ]([^\);]+)(\)|;)/.exec(O):j?/WebKit\/(\S+)/.exec(O):L?/(?:Version)[ \/]?(\S+)/.exec(O):void 0);if(K&amp;&amp;($=K?K[1]:""),q){var G=z();if(null!=G&amp;&amp;G&gt;parseFloat($)){F=String(G);break e}}F=$}var W,H={};h.document&amp;&amp;q?W=z()||parseInt(F,10)||void 0:W=void 0;var Q=W;function Y(e,t){if(S.call(this,e?e.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,e){var n=this.type=e.type,r=e.changedTouches&amp;&amp;e.changedTouches.length?e.changedTouches[0]:null;if(this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget){if(U){e:{try{R(t.nodeName);var i=!0;break e}catch(e){}i=!1}i||(t=null)}}else"mouseover"==n?t=e.fromElement:"mouseout"==n&amp;&amp;(t=e.toElement);this.relatedTarget=t,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||"",this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType="string"==typeof e.pointerType?e.pointerType:X[e.pointerType]||"",this.state=e.state,this.i=e,e.defaultPrevented&amp;&amp;Y.$.h.call(this)}}b(Y,S);var X={2:"touch",3:"pen",4:"mouse"};Y.prototype.h=function(){Y.$.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var J="closure_listenable_"+(1e6*Math.random()|0),Z=0;function ee(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.la=i,this.key=++Z,this.fa=this.ia=!1}function te(e){e.fa=!0,e.listener=null,e.proxy=null,e.src=null,e.la=null}function ne(e,t,n){for(const r in e)t.call(n,e[r],r,e)}function re(e){const t={};for(const n in e)t[n]=e[n];return t}const ie="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function se(e,t){let n,r;for(let t=1;t&lt;arguments.length;t++){for(n in r=arguments[t],r)e[n]=r[n];for(let t=0;t&lt;ie.length;t++)n=ie[t],Object.prototype.hasOwnProperty.call(r,n)&amp;&amp;(e[n]=r[n])}}function oe(e){this.src=e,this.g={},this.h=0}function ae(e,t){var n=t.type;if(n in e.g){var r,i=e.g[n],s=C(i,t);(r=0&lt;=s)&amp;&amp;Array.prototype.splice.call(i,s,1),r&amp;&amp;(te(t),0==e.g[n].length&amp;&amp;(delete e.g[n],e.h--))}}function ce(e,t,n,r){for(var i=0;i&lt;e.length;++i){var s=e[i];if(!s.fa&amp;&amp;s.listener==t&amp;&amp;s.capture==!!n&amp;&amp;s.la==r)return i}return-1}oe.prototype.add=function(e,t,n,r,i){var s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);var o=ce(e,t,r,i);return-1&lt;o?(t=e[o],n||(t.ia=!1)):((t=new ee(t,this.src,s,!!r,i)).ia=n,e.push(t)),t};var ue="closure_lm_"+(1e6*Math.random()|0),le={};function he(e,t,n,r,i){if(r&amp;&amp;r.once)return fe(e,t,n,r,i);if(Array.isArray(t)){for(var s=0;s&lt;t.length;s++)he(e,t[s],n,r,i);return null}return n=we(n),e&amp;&amp;e[J]?e.O(t,n,p(r)?!!r.capture:!!r,i):de(e,t,n,!1,r,i)}function de(e,t,n,r,i,s){if(!t)throw Error("Invalid event type");var o=p(i)?!!i.capture:!!i,a=_e(e);if(a||(e[ue]=a=new oe(e)),(n=a.add(t,n,r,o,s)).proxy)return n;if(r=function(){const e=ye;return function t(n){return e.call(t.src,t.listener,n)}}(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)x||(i=o),void 0===i&amp;&amp;(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(me(t.toString()),r);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(r)}return n}function fe(e,t,n,r,i){if(Array.isArray(t)){for(var s=0;s&lt;t.length;s++)fe(e,t[s],n,r,i);return null}return n=we(n),e&amp;&amp;e[J]?e.P(t,n,p(r)?!!r.capture:!!r,i):de(e,t,n,!0,r,i)}function pe(e,t,n,r,i){if(Array.isArray(t))for(var s=0;s&lt;t.length;s++)pe(e,t[s],n,r,i);else r=p(r)?!!r.capture:!!r,n=we(n),e&amp;&amp;e[J]?(e=e.i,(t=String(t).toString())in e.g&amp;&amp;-1&lt;(n=ce(s=e.g[t],n,r,i))&amp;&amp;(te(s[n]),Array.prototype.splice.call(s,n,1),0==s.length&amp;&amp;(delete e.g[t],e.h--))):e&amp;&amp;(e=_e(e))&amp;&amp;(t=e.g[t.toString()],e=-1,t&amp;&amp;(e=ce(t,n,r,i)),(n=-1&lt;e?t[e]:null)&amp;&amp;ge(n))}function ge(e){if("number"!=typeof e&amp;&amp;e&amp;&amp;!e.fa){var t=e.src;if(t&amp;&amp;t[J])ae(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(me(n),r):t.addListener&amp;&amp;t.removeListener&amp;&amp;t.removeListener(r),(n=_e(t))?(ae(n,e),0==n.h&amp;&amp;(n.src=null,t[ue]=null)):te(e)}}}function me(e){return e in le?le[e]:le[e]="on"+e}function ye(e,t){if(e.fa)e=!0;else{t=new Y(t,this);var n=e.listener,r=e.la||e.src;e.ia&amp;&amp;ge(e),e=n.call(r,t)}return e}function _e(e){return(e=e[ue])instanceof oe?e:null}var ve="__closure_events_fn_"+(1e9*Math.random()&gt;&gt;&gt;0);function we(e){return"function"==typeof e?e:(e[ve]||(e[ve]=function(t){return e.handleEvent(t)}),e[ve])}function be(){I.call(this),this.i=new oe(this),this.S=this,this.J=null}function Ie(e,t){var n,r=e.J;if(r)for(n=[];r;r=r.J)n.push(r);if(e=e.S,r=t.type||t,"string"==typeof t)t=new S(t,e);else if(t instanceof S)t.target=t.target||e;else{var i=t;se(t=new S(r,e),i)}if(i=!0,n)for(var s=n.length-1;0&lt;=s;s--){var o=t.g=n[s];i=Ce(o,r,!0,t)&amp;&amp;i}if(i=Ce(o=t.g=e,r,!0,t)&amp;&amp;i,i=Ce(o,r,!1,t)&amp;&amp;i,n)for(s=0;s&lt;n.length;s++)i=Ce(o=t.g=n[s],r,!1,t)&amp;&amp;i}function Ce(e,t,n,r){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();for(var i=!0,s=0;s&lt;t.length;++s){var o=t[s];if(o&amp;&amp;!o.fa&amp;&amp;o.capture==n){var a=o.listener,c=o.la||o.src;o.ia&amp;&amp;ae(e.i,o),i=!1!==a.call(c,r)&amp;&amp;i}}return i&amp;&amp;!r.defaultPrevented}b(be,I),be.prototype[J]=!0,be.prototype.removeEventListener=function(e,t,n,r){pe(this,e,t,n,r)},be.prototype.N=function(){if(be.$.N.call(this),this.i){var e,t=this.i;for(e in t.g){for(var n=t.g[e],r=0;r&lt;n.length;r++)te(n[r]);delete t.g[e],t.h--}}this.J=null},be.prototype.O=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},be.prototype.P=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};var Te=h.JSON.stringify;function Ee(){var e=Pe;let t=null;return e.g&amp;&amp;(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}var Se,xe=new class{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return 0&lt;this.h?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}((()=&gt;new ke),(e=&gt;e.reset()));class ke{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}}function De(e){h.setTimeout((()=&gt;{throw e}),0)}function Ne(e,t){Se||function(){var e=h.Promise.resolve(void 0);Se=function(){e.then(Re)}}(),Ae||(Se(),Ae=!0),Pe.add(e,t)}var Ae=!1,Pe=new class{constructor(){this.h=this.g=null}add(e,t){const n=xe.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}};function Re(){for(var e;e=Ee();){try{e.h.call(e.g)}catch(e){De(e)}var t=xe;t.j(e),100&gt;t.h&amp;&amp;(t.h++,e.next=t.g,t.g=e)}Ae=!1}function Me(e,t){be.call(this),this.h=e||1,this.g=t||h,this.j=v(this.qb,this),this.l=Date.now()}function Fe(e){e.ga=!1,e.T&amp;&amp;(e.g.clearTimeout(e.T),e.T=null)}function Oe(e,t,n){if("function"==typeof e)n&amp;&amp;(e=v(e,n));else{if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=v(e.handleEvent,e)}return 2147483647&lt;Number(t)?-1:h.setTimeout(e,t||0)}function Le(e){e.g=Oe((()=&gt;{e.g=null,e.i&amp;&amp;(e.i=!1,Le(e))}),e.j);const t=e.h;e.h=null,e.m.apply(null,t)}b(Me,be),(r=Me.prototype).ga=!1,r.T=null,r.qb=function(){if(this.ga){var e=Date.now()-this.l;0&lt;e&amp;&amp;e&lt;.8*this.h?this.T=this.g.setTimeout(this.j,this.h-e):(this.T&amp;&amp;(this.g.clearTimeout(this.T),this.T=null),Ie(this,"tick"),this.ga&amp;&amp;(Fe(this),this.start()))}},r.start=function(){this.ga=!0,this.T||(this.T=this.g.setTimeout(this.j,this.h),this.l=Date.now())},r.N=function(){Me.$.N.call(this),Fe(this),delete this.g};class qe extends I{constructor(e,t){super(),this.m=e,this.j=t,this.h=null,this.i=!1,this.g=null}l(e){this.h=arguments,this.g?this.i=!0:Le(this)}N(){super.N(),this.g&amp;&amp;(h.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function Ve(e){I.call(this),this.h=e,this.g={}}b(Ve,I);var Be=[];function Ue(e,t,n,r){Array.isArray(n)||(n&amp;&amp;(Be[0]=n.toString()),n=Be);for(var i=0;i&lt;n.length;i++){var s=he(t,n[i],r||e.handleEvent,!1,e.h||e);if(!s)break;e.g[s.key]=s}}function je(e){ne(e.g,(function(e,t){this.g.hasOwnProperty(t)&amp;&amp;ge(e)}),e),e.g={}}function ze(){this.g=!0}function $e(e,t,n,r){e.info((function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{var n=JSON.parse(t);if(n)for(e=0;e&lt;n.length;e++)if(Array.isArray(n[e])){var r=n[e];if(!(2&gt;r.length)){var i=r[1];if(Array.isArray(i)&amp;&amp;!(1&gt;i.length)){var s=i[0];if("noop"!=s&amp;&amp;"stop"!=s&amp;&amp;"close"!=s)for(var o=1;o&lt;i.length;o++)i[o]=""}}}return Te(n)}catch(e){return t}}(e,n)+(r?" "+r:"")}))}Ve.prototype.N=function(){Ve.$.N.call(this),je(this)},Ve.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")},ze.prototype.Ea=function(){this.g=!1},ze.prototype.info=function(){};var Ke={},Ge=null;function We(){return Ge=Ge||new be}function He(e){S.call(this,Ke.Ta,e)}function Qe(e){const t=We();Ie(t,new He(t))}function Ye(e,t){S.call(this,Ke.STAT_EVENT,e),this.stat=t}function Xe(e){const t=We();Ie(t,new Ye(t,e))}function Je(e,t){S.call(this,Ke.Ua,e),this.size=t}function Ze(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return h.setTimeout((function(){e()}),t)}Ke.Ta="serverreachability",b(He,S),Ke.STAT_EVENT="statevent",b(Ye,S),Ke.Ua="timingevent",b(Je,S);var et={NO_ERROR:0,rb:1,Eb:2,Db:3,yb:4,Cb:5,Fb:6,Qa:7,TIMEOUT:8,Ib:9},tt={wb:"complete",Sb:"success",Ra:"error",Qa:"abort",Kb:"ready",Lb:"readystatechange",TIMEOUT:"timeout",Gb:"incrementaldata",Jb:"progress",zb:"downloadprogress",$b:"uploadprogress"};function nt(){}function rt(e){return e.h||(e.h=e.i())}function it(){}nt.prototype.h=null;var st,ot={OPEN:"a",vb:"b",Ra:"c",Hb:"d"};function at(){S.call(this,"d")}function ct(){S.call(this,"c")}function ut(){}function lt(e,t,n,r){this.l=e,this.j=t,this.m=n,this.W=r||1,this.U=new Ve(this),this.P=dt,e=B?125:void 0,this.V=new Me(e),this.I=null,this.i=!1,this.s=this.A=this.v=this.L=this.G=this.Y=this.B=null,this.F=[],this.g=null,this.C=0,this.o=this.u=null,this.aa=-1,this.J=!1,this.O=0,this.M=null,this.ca=this.K=this.ba=this.S=!1,this.h=new ht}function ht(){this.i=null,this.g="",this.h=!1}b(at,S),b(ct,S),b(ut,nt),ut.prototype.g=function(){return new XMLHttpRequest},ut.prototype.i=function(){return{}},st=new ut;var dt=45e3,ft={},pt={};function gt(e,t,n){e.L=1,e.v=Mt(Dt(t)),e.s=n,e.S=!0,mt(e,null)}function mt(e,t){e.G=Date.now(),wt(e),e.A=Dt(e.v);var n=e.A,r=e.W;Array.isArray(r)||(r=[String(r)]),Wt(n.i,"t",r),e.C=0,n=e.l.I,e.h=new ht,e.g=Wn(e.l,n?t:null,!e.s),0&lt;e.O&amp;&amp;(e.M=new qe(v(e.Pa,e,e.g),e.O)),Ue(e.U,e.g,"readystatechange",e.nb),t=e.I?re(e.I):{},e.s?(e.u||(e.u="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ha(e.A,e.u,e.s,t)):(e.u="GET",e.g.ha(e.A,e.u,null,t)),Qe(),function(e,t,n,r,i,s){e.info((function(){if(e.g)if(s)for(var o="",a=s.split("&amp;"),c=0;c&lt;a.length;c++){var u=a[c].split("=");if(1&lt;u.length){var l=u[0];u=u[1];var h=l.split("_");o=2&lt;=h.length&amp;&amp;"type"==h[1]?o+(l+"=")+u+"&amp;":o+(l+"=redacted&amp;")}}else o=null;else o=s;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+t+"\n"+n+"\n"+o}))}(e.j,e.u,e.A,e.m,e.W,e.s)}function yt(e){return!!e.g&amp;&amp;"GET"==e.u&amp;&amp;2!=e.L&amp;&amp;e.l.Ha}function _t(e,t,n){let r,i=!0;for(;!e.J&amp;&amp;e.C&lt;n.length;){if(r=vt(e,n),r==pt){4==t&amp;&amp;(e.o=4,Xe(14),i=!1),$e(e.j,e.m,null,"[Incomplete Response]");break}if(r==ft){e.o=4,Xe(15),$e(e.j,e.m,n,"[Invalid Chunk]"),i=!1;break}$e(e.j,e.m,r,null),Et(e,r)}yt(e)&amp;&amp;r!=pt&amp;&amp;r!=ft&amp;&amp;(e.h.g="",e.C=0),4!=t||0!=n.length||e.h.h||(e.o=1,Xe(16),i=!1),e.i=e.i&amp;&amp;i,i?0&lt;n.length&amp;&amp;!e.ca&amp;&amp;(e.ca=!0,(t=e.l).g==e&amp;&amp;t.ca&amp;&amp;!t.L&amp;&amp;(t.j.info("Great, no buffering proxy detected. Bytes received: "+n.length),Vn(t),t.L=!0,Xe(11))):($e(e.j,e.m,n,"[Invalid Chunked Response]"),Tt(e),Ct(e))}function vt(e,t){var n=e.C,r=t.indexOf("\n",n);return-1==r?pt:(n=Number(t.substring(n,r)),isNaN(n)?ft:(r+=1)+n&gt;t.length?pt:(t=t.substr(r,n),e.C=r+n,t))}function wt(e){e.Y=Date.now()+e.P,bt(e,e.P)}function bt(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=Ze(v(e.lb,e),t)}function It(e){e.B&amp;&amp;(h.clearTimeout(e.B),e.B=null)}function Ct(e){0==e.l.H||e.J||jn(e.l,e)}function Tt(e){It(e);var t=e.M;t&amp;&amp;"function"==typeof t.ra&amp;&amp;t.ra(),e.M=null,Fe(e.V),je(e.U),e.g&amp;&amp;(t=e.g,e.g=null,t.abort(),t.ra())}function Et(e,t){try{var n=e.l;if(0!=n.H&amp;&amp;(n.g==e||Zt(n.h,e)))if(!e.K&amp;&amp;Zt(n.h,e)&amp;&amp;3==n.H){try{var r=n.Ja.g.parse(t)}catch(e){r=null}if(Array.isArray(r)&amp;&amp;3==r.length){var i=r;if(0==i[0]){e:if(!n.u){if(n.g){if(!(n.g.G+3e3&lt;e.G))break e;Un(n),An(n)}qn(n),Xe(18)}}else n.Fa=i[1],0&lt;n.Fa-n.V&amp;&amp;37500&gt;i[2]&amp;&amp;n.M&amp;&amp;0==n.A&amp;&amp;!n.v&amp;&amp;(n.v=Ze(v(n.ib,n),6e3));if(1&gt;=Jt(n.h)&amp;&amp;n.na){try{n.na()}catch(e){}n.na=void 0}}else $n(n,11)}else if((e.K||n.g==e)&amp;&amp;Un(n),!k(t))for(i=n.Ja.g.parse(t),t=0;t&lt;i.length;t++){let u=i[t];if(n.V=u[0],u=u[1],2==n.H)if("c"==u[0]){n.J=u[1],n.oa=u[2];const t=u[3];null!=t&amp;&amp;(n.qa=t,n.j.info("VER="+n.qa));const i=u[4];null!=i&amp;&amp;(n.Ga=i,n.j.info("SVER="+n.Ga));const l=u[5];null!=l&amp;&amp;"number"==typeof l&amp;&amp;0&lt;l&amp;&amp;(r=1.5*l,n.K=r,n.j.info("backChannelRequestTimeoutMs_="+r)),r=n;const h=e.g;if(h){const e=h.g?h.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(e){var s=r.h;s.g||-1==e.indexOf("spdy")&amp;&amp;-1==e.indexOf("quic")&amp;&amp;-1==e.indexOf("h2")||(s.j=s.l,s.g=new Set,s.h&amp;&amp;(en(s,s.h),s.h=null))}if(r.F){const e=h.g?h.g.getResponseHeader("X-HTTP-Session-Id"):null;e&amp;&amp;(r.Da=e,Rt(r.G,r.F,e))}}n.H=3,n.l&amp;&amp;n.l.Ba(),n.ca&amp;&amp;(n.S=Date.now()-e.G,n.j.info("Handshake RTT: "+n.S+"ms"));var o=e;if((r=n).wa=Gn(r,r.I?r.oa:null,r.Y),o.K){tn(r.h,o);var a=o,c=r.K;c&amp;&amp;a.setTimeout(c),a.B&amp;&amp;(It(a),wt(a)),r.g=o}else Ln(r);0&lt;n.i.length&amp;&amp;Rn(n)}else"stop"!=u[0]&amp;&amp;"close"!=u[0]||$n(n,7);else 3==n.H&amp;&amp;("stop"==u[0]||"close"==u[0]?"stop"==u[0]?$n(n,7):Nn(n):"noop"!=u[0]&amp;&amp;n.l&amp;&amp;n.l.Aa(u),n.A=0)}Qe()}catch(e){}}function St(e,t){if(e.forEach&amp;&amp;"function"==typeof e.forEach)e.forEach(t,void 0);else if(f(e)||"string"==typeof e)Array.prototype.forEach.call(e,t,void 0);else for(var n=function(e){if(e.sa&amp;&amp;"function"==typeof e.sa)return e.sa();if(!e.Z||"function"!=typeof e.Z){if("undefined"!=typeof Map&amp;&amp;e instanceof Map)return Array.from(e.keys());if(!("undefined"!=typeof Set&amp;&amp;e instanceof Set)){if(f(e)||"string"==typeof e){var t=[];e=e.length;for(var n=0;n&lt;e;n++)t.push(n);return t}t=[],n=0;for(const r in e)t[n++]=r;return t}}}(e),r=function(e){if(e.Z&amp;&amp;"function"==typeof e.Z)return e.Z();if("undefined"!=typeof Map&amp;&amp;e instanceof Map||"undefined"!=typeof Set&amp;&amp;e instanceof Set)return Array.from(e.values());if("string"==typeof e)return e.split("");if(f(e)){for(var t=[],n=e.length,r=0;r&lt;n;r++)t.push(e[r]);return t}for(r in t=[],n=0,e)t[n++]=e[r];return t}(e),i=r.length,s=0;s&lt;i;s++)t.call(void 0,r[s],n&amp;&amp;n[s],e)}(r=lt.prototype).setTimeout=function(e){this.P=e},r.nb=function(e){e=e.target;const t=this.M;t&amp;&amp;3==Tn(e)?t.l():this.Pa(e)},r.Pa=function(e){try{if(e==this.g)e:{const l=Tn(this.g);var t=this.g.Ia();if(this.g.da(),!(3&gt;l)&amp;&amp;(3!=l||B||this.g&amp;&amp;(this.h.h||this.g.ja()||En(this.g)))){this.J||4!=l||7==t||Qe(),It(this);var n=this.g.da();this.aa=n;t:if(yt(this)){var r=En(this.g);e="";var i=r.length,s=4==Tn(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){Tt(this),Ct(this);var o="";break t}this.h.i=new h.TextDecoder}for(t=0;t&lt;i;t++)this.h.h=!0,e+=this.h.i.decode(r[t],{stream:s&amp;&amp;t==i-1});r.splice(0,i),this.h.g+=e,this.C=0,o=this.h.g}else o=this.g.ja();if(this.i=200==n,function(e,t,n,r,i,s,o){e.info((function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+t+"\n"+n+"\n"+s+" "+o}))}(this.j,this.u,this.A,this.m,this.W,l,n),this.i){if(this.ba&amp;&amp;!this.K){t:{if(this.g){var a,c=this.g;if((a=c.g?c.g.getResponseHeader("X-HTTP-Initial-Response"):null)&amp;&amp;!k(a)){var u=a;break t}}u=null}if(!(n=u)){this.i=!1,this.o=3,Xe(12),Tt(this),Ct(this);break e}$e(this.j,this.m,n,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,Et(this,n)}this.S?(_t(this,l,o),B&amp;&amp;this.i&amp;&amp;3==l&amp;&amp;(Ue(this.U,this.V,"tick",this.mb),this.V.start())):($e(this.j,this.m,o,null),Et(this,o)),4==l&amp;&amp;Tt(this),this.i&amp;&amp;!this.J&amp;&amp;(4==l?jn(this.l,this):(this.i=!1,wt(this)))}else 400==n&amp;&amp;0&lt;o.indexOf("Unknown SID")?(this.o=3,Xe(12)):(this.o=0,Xe(13)),Tt(this),Ct(this)}}}catch(e){}},r.mb=function(){if(this.g){var e=Tn(this.g),t=this.g.ja();this.C&lt;t.length&amp;&amp;(It(this),_t(this,e,t),this.i&amp;&amp;4!=e&amp;&amp;wt(this))}},r.cancel=function(){this.J=!0,Tt(this)},r.lb=function(){this.B=null;const e=Date.now();0&lt;=e-this.Y?(function(e,t){e.info((function(){return"TIMEOUT: "+t}))}(this.j,this.A),2!=this.L&amp;&amp;(Qe(),Xe(17)),Tt(this),this.o=2,Ct(this)):bt(this,this.Y-e)};var xt=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function kt(e,t){if(this.g=this.s=this.j="",this.m=null,this.o=this.l="",this.h=!1,e instanceof kt){this.h=void 0!==t?t:e.h,Nt(this,e.j),this.s=e.s,this.g=e.g,At(this,e.m),this.l=e.l,t=e.i;var n=new zt;n.i=t.i,t.g&amp;&amp;(n.g=new Map(t.g),n.h=t.h),Pt(this,n),this.o=e.o}else e&amp;&amp;(n=String(e).match(xt))?(this.h=!!t,Nt(this,n[1]||"",!0),this.s=Ft(n[2]||""),this.g=Ft(n[3]||"",!0),At(this,n[4]),this.l=Ft(n[5]||"",!0),Pt(this,n[6]||"",!0),this.o=Ft(n[7]||"")):(this.h=!!t,this.i=new zt(null,this.h))}function Dt(e){return new kt(e)}function Nt(e,t,n){e.j=n?Ft(t,!0):t,e.j&amp;&amp;(e.j=e.j.replace(/:$/,""))}function At(e,t){if(t){if(t=Number(t),isNaN(t)||0&gt;t)throw Error("Bad port number "+t);e.m=t}else e.m=null}function Pt(e,t,n){t instanceof zt?(e.i=t,function(e,t){t&amp;&amp;!e.j&amp;&amp;($t(e),e.i=null,e.g.forEach((function(e,t){var n=t.toLowerCase();t!=n&amp;&amp;(Kt(this,t),Wt(this,n,e))}),e)),e.j=t}(e.i,e.h)):(n||(t=Ot(t,Ut)),e.i=new zt(t,e.h))}function Rt(e,t,n){e.i.set(t,n)}function Mt(e){return Rt(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function Ft(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function Ot(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,Lt),n&amp;&amp;(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function Lt(e){return"%"+((e=e.charCodeAt(0))&gt;&gt;4&amp;15).toString(16)+(15&amp;e).toString(16)}kt.prototype.toString=function(){var e=[],t=this.j;t&amp;&amp;e.push(Ot(t,qt,!0),":");var n=this.g;return(n||"file"==t)&amp;&amp;(e.push("//"),(t=this.s)&amp;&amp;e.push(Ot(t,qt,!0),"@"),e.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.m)&amp;&amp;e.push(":",String(n))),(n=this.l)&amp;&amp;(this.g&amp;&amp;"/"!=n.charAt(0)&amp;&amp;e.push("/"),e.push(Ot(n,"/"==n.charAt(0)?Bt:Vt,!0))),(n=this.i.toString())&amp;&amp;e.push("?",n),(n=this.o)&amp;&amp;e.push("#",Ot(n,jt)),e.join("")};var qt=/[#\/\?@]/g,Vt=/[#\?:]/g,Bt=/[#\?]/g,Ut=/[#\?@]/g,jt=/#/g;function zt(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function $t(e){e.g||(e.g=new Map,e.h=0,e.i&amp;&amp;function(e,t){if(e){e=e.split("&amp;");for(var n=0;n&lt;e.length;n++){var r=e[n].indexOf("="),i=null;if(0&lt;=r){var s=e[n].substring(0,r);i=e[n].substring(r+1)}else s=e[n];t(s,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(e.i,(function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)})))}function Kt(e,t){$t(e),t=Ht(e,t),e.g.has(t)&amp;&amp;(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function Gt(e,t){return $t(e),t=Ht(e,t),e.g.has(t)}function Wt(e,t,n){Kt(e,t),0&lt;n.length&amp;&amp;(e.i=null,e.g.set(Ht(e,t),T(n)),e.h+=n.length)}function Ht(e,t){return t=String(t),e.j&amp;&amp;(t=t.toLowerCase()),t}function Qt(e){this.l=e||Yt,e=h.PerformanceNavigationTiming?0&lt;(e=h.performance.getEntriesByType("navigation")).length&amp;&amp;("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(h.g&amp;&amp;h.g.Ka&amp;&amp;h.g.Ka()&amp;&amp;h.g.Ka().ec),this.j=e?this.l:1,this.g=null,1&lt;this.j&amp;&amp;(this.g=new Set),this.h=null,this.i=[]}(r=zt.prototype).add=function(e,t){$t(this),this.i=null,e=Ht(this,e);var n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this},r.forEach=function(e,t){$t(this),this.g.forEach((function(n,r){n.forEach((function(n){e.call(t,n,r,this)}),this)}),this)},r.sa=function(){$t(this);const e=Array.from(this.g.values()),t=Array.from(this.g.keys()),n=[];for(let r=0;r&lt;t.length;r++){const i=e[r];for(let e=0;e&lt;i.length;e++)n.push(t[r])}return n},r.Z=function(e){$t(this);let t=[];if("string"==typeof e)Gt(this,e)&amp;&amp;(t=t.concat(this.g.get(Ht(this,e))));else{e=Array.from(this.g.values());for(let n=0;n&lt;e.length;n++)t=t.concat(e[n])}return t},r.set=function(e,t){return $t(this),this.i=null,Gt(this,e=Ht(this,e))&amp;&amp;(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},r.get=function(e,t){return e&amp;&amp;0&lt;(e=this.Z(e)).length?String(e[0]):t},r.toString=function(){if(this.i)return this.i;if(!this.g)return"";const e=[],t=Array.from(this.g.keys());for(var n=0;n&lt;t.length;n++){var r=t[n];const s=encodeURIComponent(String(r)),o=this.Z(r);for(r=0;r&lt;o.length;r++){var i=s;""!==o[r]&amp;&amp;(i+="="+encodeURIComponent(String(o[r]))),e.push(i)}}return this.i=e.join("&amp;")};var Yt=10;function Xt(e){return!!e.h||!!e.g&amp;&amp;e.g.size&gt;=e.j}function Jt(e){return e.h?1:e.g?e.g.size:0}function Zt(e,t){return e.h?e.h==t:!!e.g&amp;&amp;e.g.has(t)}function en(e,t){e.g?e.g.add(t):e.h=t}function tn(e,t){e.h&amp;&amp;e.h==t?e.h=null:e.g&amp;&amp;e.g.has(t)&amp;&amp;e.g.delete(t)}function nn(e){if(null!=e.h)return e.i.concat(e.h.F);if(null!=e.g&amp;&amp;0!==e.g.size){let t=e.i;for(const n of e.g.values())t=t.concat(n.F);return t}return T(e.i)}function rn(){}function sn(){this.g=new rn}function on(e,t,n){const r=n||"";try{St(e,(function(e,n){let i=e;p(e)&amp;&amp;(i=Te(e)),t.push(r+n+"="+encodeURIComponent(i))}))}catch(e){throw t.push(r+"type="+encodeURIComponent("_badmap")),e}}function an(e,t,n,r,i){try{t.onload=null,t.onerror=null,t.onabort=null,t.ontimeout=null,i(r)}catch(e){}}function cn(e){this.l=e.fc||null,this.j=e.ob||!1}function un(e,t){be.call(this),this.F=e,this.u=t,this.m=void 0,this.readyState=ln,this.status=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.v=new Headers,this.h=null,this.C="GET",this.B="",this.g=!1,this.A=this.j=this.l=null}Qt.prototype.cancel=function(){if(this.i=nn(this),this.h)this.h.cancel(),this.h=null;else if(this.g&amp;&amp;0!==this.g.size){for(const e of this.g.values())e.cancel();this.g.clear()}},rn.prototype.stringify=function(e){return h.JSON.stringify(e,void 0)},rn.prototype.parse=function(e){return h.JSON.parse(e,void 0)},b(cn,nt),cn.prototype.g=function(){return new un(this.l,this.j)},cn.prototype.i=function(e){return function(){return e}}({}),b(un,be);var ln=0;function hn(e){e.j.read().then(e.Xa.bind(e)).catch(e.ka.bind(e))}function dn(e){e.readyState=4,e.l=null,e.j=null,e.A=null,fn(e)}function fn(e){e.onreadystatechange&amp;&amp;e.onreadystatechange.call(e)}(r=un.prototype).open=function(e,t){if(this.readyState!=ln)throw this.abort(),Error("Error reopening a connection");this.C=e,this.B=t,this.readyState=1,fn(this)},r.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const t={headers:this.v,method:this.C,credentials:this.m,cache:void 0};e&amp;&amp;(t.body=e),(this.F||h).fetch(new Request(this.B,t)).then(this.$a.bind(this),this.ka.bind(this))},r.abort=function(){this.response=this.responseText="",this.v=new Headers,this.status=0,this.j&amp;&amp;this.j.cancel("Request was aborted.").catch((()=&gt;{})),1&lt;=this.readyState&amp;&amp;this.g&amp;&amp;4!=this.readyState&amp;&amp;(this.g=!1,dn(this)),this.readyState=ln},r.$a=function(e){if(this.g&amp;&amp;(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,fn(this)),this.g&amp;&amp;(this.readyState=3,fn(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Ya.bind(this),this.ka.bind(this));else if(void 0!==h.ReadableStream&amp;&amp;"body"in e){if(this.j=e.body.getReader(),this.u){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.A=new TextDecoder;hn(this)}else e.text().then(this.Za.bind(this),this.ka.bind(this))},r.Xa=function(e){if(this.g){if(this.u&amp;&amp;e.value)this.response.push(e.value);else if(!this.u){var t=e.value?e.value:new Uint8Array(0);(t=this.A.decode(t,{stream:!e.done}))&amp;&amp;(this.response=this.responseText+=t)}e.done?dn(this):fn(this),3==this.readyState&amp;&amp;hn(this)}},r.Za=function(e){this.g&amp;&amp;(this.response=this.responseText=e,dn(this))},r.Ya=function(e){this.g&amp;&amp;(this.response=e,dn(this))},r.ka=function(){this.g&amp;&amp;dn(this)},r.setRequestHeader=function(e,t){this.v.append(e,t)},r.getResponseHeader=function(e){return this.h&amp;&amp;this.h.get(e.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";const e=[],t=this.h.entries();for(var n=t.next();!n.done;)n=n.value,e.push(n[0]+": "+n[1]),n=t.next();return e.join("\r\n")},Object.defineProperty(un.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}});var pn=h.JSON.parse;function gn(e){be.call(this),this.headers=new Map,this.u=e||null,this.h=!1,this.C=this.g=null,this.I="",this.m=0,this.j="",this.l=this.G=this.v=this.F=!1,this.B=0,this.A=null,this.K=mn,this.L=this.M=!1}b(gn,be);var mn="",yn=/^https?$/i,_n=["POST","PUT"];function vn(e,t){e.h=!1,e.g&amp;&amp;(e.l=!0,e.g.abort(),e.l=!1),e.j=t,e.m=5,wn(e),In(e)}function wn(e){e.F||(e.F=!0,Ie(e,"complete"),Ie(e,"error"))}function bn(e){if(e.h&amp;&amp;void 0!==l&amp;&amp;(!e.C[1]||4!=Tn(e)||2!=e.da()))if(e.v&amp;&amp;4==Tn(e))Oe(e.La,0,e);else if(Ie(e,"readystatechange"),4==Tn(e)){e.h=!1;try{const a=e.da();e:switch(a){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var t=!0;break e;default:t=!1}var n;if(!(n=t)){var r;if(r=0===a){var i=String(e.I).match(xt)[1]||null;if(!i&amp;&amp;h.self&amp;&amp;h.self.location){var s=h.self.location.protocol;i=s.substr(0,s.length-1)}r=!yn.test(i?i.toLowerCase():"")}n=r}if(n)Ie(e,"complete"),Ie(e,"success");else{e.m=6;try{var o=2&lt;Tn(e)?e.g.statusText:""}catch(e){o=""}e.j=o+" ["+e.da()+"]",wn(e)}}finally{In(e)}}}function In(e,t){if(e.g){Cn(e);const n=e.g,r=e.C[0]?d:null;e.g=null,e.C=null,t||Ie(e,"ready");try{n.onreadystatechange=r}catch(e){}}}function Cn(e){e.g&amp;&amp;e.L&amp;&amp;(e.g.ontimeout=null),e.A&amp;&amp;(h.clearTimeout(e.A),e.A=null)}function Tn(e){return e.g?e.g.readyState:0}function En(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.K){case mn:case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}function Sn(e){let t="";return ne(e,(function(e,n){t+=n,t+=":",t+=e,t+="\r\n"})),t}function xn(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=Sn(n),"string"==typeof e?null!=n&amp;&amp;encodeURIComponent(String(n)):Rt(e,t,n))}function kn(e,t,n){return n&amp;&amp;n.internalChannelParams&amp;&amp;n.internalChannelParams[e]||t}function Dn(e){this.Ga=0,this.i=[],this.j=new ze,this.oa=this.wa=this.G=this.Y=this.g=this.Da=this.F=this.ma=this.o=this.U=this.s=null,this.fb=this.W=0,this.cb=kn("failFast",!1,e),this.M=this.v=this.u=this.m=this.l=null,this.aa=!0,this.ta=this.Fa=this.V=-1,this.ba=this.A=this.C=0,this.ab=kn("baseRetryDelayMs",5e3,e),this.hb=kn("retryDelaySeedMs",1e4,e),this.eb=kn("forwardChannelMaxRetries",2,e),this.xa=kn("forwardChannelRequestTimeoutMs",2e4,e),this.va=e&amp;&amp;e.xmlHttpFactory||void 0,this.Ha=e&amp;&amp;e.dc||!1,this.K=void 0,this.I=e&amp;&amp;e.supportsCrossDomainXhr||!1,this.J="",this.h=new Qt(e&amp;&amp;e.concurrentRequestLimit),this.Ja=new sn,this.P=e&amp;&amp;e.fastHandshake||!1,this.O=e&amp;&amp;e.encodeInitMessageHeaders||!1,this.P&amp;&amp;this.O&amp;&amp;(this.O=!1),this.bb=e&amp;&amp;e.bc||!1,e&amp;&amp;e.Ea&amp;&amp;this.j.Ea(),e&amp;&amp;e.forceLongPolling&amp;&amp;(this.aa=!1),this.ca=!this.P&amp;&amp;this.aa&amp;&amp;e&amp;&amp;e.detectBufferingProxy||!1,this.na=void 0,this.S=0,this.L=!1,this.pa=this.B=null}function Nn(e){if(Pn(e),3==e.H){var t=e.W++,n=Dt(e.G);Rt(n,"SID",e.J),Rt(n,"RID",t),Rt(n,"TYPE","terminate"),Fn(e,n),(t=new lt(e,e.j,t,void 0)).L=2,t.v=Mt(Dt(n)),n=!1,h.navigator&amp;&amp;h.navigator.sendBeacon&amp;&amp;(n=h.navigator.sendBeacon(t.v.toString(),"")),!n&amp;&amp;h.Image&amp;&amp;((new Image).src=t.v,n=!0),n||(t.g=Wn(t.l,null),t.g.ha(t.v)),t.G=Date.now(),wt(t)}Kn(e)}function An(e){e.g&amp;&amp;(Vn(e),e.g.cancel(),e.g=null)}function Pn(e){An(e),e.u&amp;&amp;(h.clearTimeout(e.u),e.u=null),Un(e),e.h.cancel(),e.m&amp;&amp;("number"==typeof e.m&amp;&amp;h.clearTimeout(e.m),e.m=null)}function Rn(e){Xt(e.h)||e.m||(e.m=!0,Ne(e.Na,e),e.C=0)}function Mn(e,t){var n;n=t?t.m:e.W++;const r=Dt(e.G);Rt(r,"SID",e.J),Rt(r,"RID",n),Rt(r,"AID",e.V),Fn(e,r),e.o&amp;&amp;e.s&amp;&amp;xn(r,e.o,e.s),n=new lt(e,e.j,n,e.C+1),null===e.o&amp;&amp;(n.I=e.s),t&amp;&amp;(e.i=t.F.concat(e.i)),t=On(e,n,1e3),n.setTimeout(Math.round(.5*e.xa)+Math.round(.5*e.xa*Math.random())),en(e.h,n),gt(n,r,t)}function Fn(e,t){e.ma&amp;&amp;ne(e.ma,(function(e,n){Rt(t,n,e)})),e.l&amp;&amp;St({},(function(e,n){Rt(t,n,e)}))}function On(e,t,n){n=Math.min(e.i.length,n);var r=e.l?v(e.l.Va,e.l,e):null;e:{var i=e.i;let t=-1;for(;;){const e=["count="+n];-1==t?0&lt;n?(t=i[0].h,e.push("ofs="+t)):t=0:e.push("ofs="+t);let s=!0;for(let o=0;o&lt;n;o++){let n=i[o].h;const a=i[o].g;if(n-=t,0&gt;n)t=Math.max(0,i[o].h-100),s=!1;else try{on(a,e,"req"+n+"_")}catch(e){r&amp;&amp;r(a)}}if(s){r=e.join("&amp;");break e}}}return e=e.i.splice(0,n),t.F=e,r}function Ln(e){e.g||e.u||(e.ba=1,Ne(e.Ma,e),e.A=0)}function qn(e){return!(e.g||e.u||3&lt;=e.A||(e.ba++,e.u=Ze(v(e.Ma,e),zn(e,e.A)),e.A++,0))}function Vn(e){null!=e.B&amp;&amp;(h.clearTimeout(e.B),e.B=null)}function Bn(e){e.g=new lt(e,e.j,"rpc",e.ba),null===e.o&amp;&amp;(e.g.I=e.s),e.g.O=0;var t=Dt(e.wa);Rt(t,"RID","rpc"),Rt(t,"SID",e.J),Rt(t,"CI",e.M?"0":"1"),Rt(t,"AID",e.V),Rt(t,"TYPE","xmlhttp"),Fn(e,t),e.o&amp;&amp;e.s&amp;&amp;xn(t,e.o,e.s),e.K&amp;&amp;e.g.setTimeout(e.K);var n=e.g;e=e.oa,n.L=1,n.v=Mt(Dt(t)),n.s=null,n.S=!0,mt(n,e)}function Un(e){null!=e.v&amp;&amp;(h.clearTimeout(e.v),e.v=null)}function jn(e,t){var n=null;if(e.g==t){Un(e),Vn(e),e.g=null;var r=2}else{if(!Zt(e.h,t))return;n=t.F,tn(e.h,t),r=1}if(0!=e.H)if(e.ta=t.aa,t.i)if(1==r){n=t.s?t.s.length:0,t=Date.now()-t.G;var i=e.C;Ie(r=We(),new Je(r,n)),Rn(e)}else Ln(e);else if(3==(i=t.o)||0==i&amp;&amp;0&lt;e.ta||!(1==r&amp;&amp;function(e,t){return!(Jt(e.h)&gt;=e.h.j-(e.m?1:0)||(e.m?(e.i=t.F.concat(e.i),0):1==e.H||2==e.H||e.C&gt;=(e.cb?0:e.eb)||(e.m=Ze(v(e.Na,e,t),zn(e,e.C)),e.C++,0)))}(e,t)||2==r&amp;&amp;qn(e)))switch(n&amp;&amp;0&lt;n.length&amp;&amp;(t=e.h,t.i=t.i.concat(n)),i){case 1:$n(e,5);break;case 4:$n(e,10);break;case 3:$n(e,6);break;default:$n(e,2)}}function zn(e,t){let n=e.ab+Math.floor(Math.random()*e.hb);return e.l||(n*=2),n*t}function $n(e,t){if(e.j.info("Error code "+t),2==t){var n=null;e.l&amp;&amp;(n=null);var r=v(e.pb,e);n||(n=new kt("//www.google.com/images/cleardot.gif"),h.location&amp;&amp;"http"==h.location.protocol||Nt(n,"https"),Mt(n)),function(e,t){const n=new ze;if(h.Image){const r=new Image;r.onload=w(an,n,r,"TestLoadImage: loaded",!0,t),r.onerror=w(an,n,r,"TestLoadImage: error",!1,t),r.onabort=w(an,n,r,"TestLoadImage: abort",!1,t),r.ontimeout=w(an,n,r,"TestLoadImage: timeout",!1,t),h.setTimeout((function(){r.ontimeout&amp;&amp;r.ontimeout()}),1e4),r.src=e}else t(!1)}(n.toString(),r)}else Xe(2);e.H=0,e.l&amp;&amp;e.l.za(t),Kn(e),Pn(e)}function Kn(e){if(e.H=0,e.pa=[],e.l){const t=nn(e.h);0==t.length&amp;&amp;0==e.i.length||(E(e.pa,t),E(e.pa,e.i),e.h.i.length=0,T(e.i),e.i.length=0),e.l.ya()}}function Gn(e,t,n){var r=n instanceof kt?Dt(n):new kt(n,void 0);if(""!=r.g)t&amp;&amp;(r.g=t+"."+r.g),At(r,r.m);else{var i=h.location;r=i.protocol,t=t?t+"."+i.hostname:i.hostname,i=+i.port;var s=new kt(null,void 0);r&amp;&amp;Nt(s,r),t&amp;&amp;(s.g=t),i&amp;&amp;At(s,i),n&amp;&amp;(s.l=n),r=s}return n=e.F,t=e.Da,n&amp;&amp;t&amp;&amp;Rt(r,n,t),Rt(r,"VER",e.qa),Fn(e,r),r}function Wn(e,t,n){if(t&amp;&amp;!e.I)throw Error("Can't create secondary domain capable XhrIo object.");return(t=n&amp;&amp;e.Ha&amp;&amp;!e.va?new gn(new cn({ob:!0})):new gn(e.va)).Oa(e.I),t}function Hn(){}function Qn(){if(q&amp;&amp;!(10&lt;=Number(Q)))throw Error("Environmental error: no available transport.")}function Yn(e,t){be.call(this),this.g=new Dn(t),this.l=e,this.h=t&amp;&amp;t.messageUrlParams||null,e=t&amp;&amp;t.messageHeaders||null,t&amp;&amp;t.clientProtocolHeaderRequired&amp;&amp;(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.g.s=e,e=t&amp;&amp;t.initMessageHeaders||null,t&amp;&amp;t.messageContentType&amp;&amp;(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&amp;&amp;t.Ca&amp;&amp;(e?e["X-WebChannel-Client-Profile"]=t.Ca:e={"X-WebChannel-Client-Profile":t.Ca}),this.g.U=e,(e=t&amp;&amp;t.cc)&amp;&amp;!k(e)&amp;&amp;(this.g.o=e),this.A=t&amp;&amp;t.supportsCrossDomainXhr||!1,this.v=t&amp;&amp;t.sendRawJson||!1,(t=t&amp;&amp;t.httpSessionIdParam)&amp;&amp;!k(t)&amp;&amp;(this.g.F=t,null!==(e=this.h)&amp;&amp;t in e&amp;&amp;t in(e=this.h)&amp;&amp;delete e[t]),this.j=new Zn(this)}function Xn(e){at.call(this);var t=e.__sm__;if(t){e:{for(const n in t){e=n;break e}e=void 0}(this.i=e)&amp;&amp;(e=this.i,t=null!==t&amp;&amp;e in t?t[e]:void 0),this.data=t}else this.data=e}function Jn(){ct.call(this),this.status=1}function Zn(e){this.g=e}function er(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.m=Array(this.blockSize),this.i=this.h=0,this.reset()}function tr(e,t,n){n||(n=0);var r=Array(16);if("string"==typeof t)for(var i=0;16&gt;i;++i)r[i]=t.charCodeAt(n++)|t.charCodeAt(n++)&lt;&lt;8|t.charCodeAt(n++)&lt;&lt;16|t.charCodeAt(n++)&lt;&lt;24;else for(i=0;16&gt;i;++i)r[i]=t[n++]|t[n++]&lt;&lt;8|t[n++]&lt;&lt;16|t[n++]&lt;&lt;24;t=e.g[0],n=e.g[1],i=e.g[2];var s=e.g[3],o=t+(s^n&amp;(i^s))+r[0]+3614090360&amp;4294967295;o=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=n+(o&lt;&lt;7&amp;4294967295|o&gt;&gt;&gt;25))+((o=s+(i^t&amp;(n^i))+r[1]+3905402710&amp;4294967295)&lt;&lt;12&amp;4294967295|o&gt;&gt;&gt;20))+((o=i+(n^s&amp;(t^n))+r[2]+606105819&amp;4294967295)&lt;&lt;17&amp;4294967295|o&gt;&gt;&gt;15))+((o=n+(t^i&amp;(s^t))+r[3]+3250441966&amp;4294967295)&lt;&lt;22&amp;4294967295|o&gt;&gt;&gt;10))+((o=t+(s^n&amp;(i^s))+r[4]+4118548399&amp;4294967295)&lt;&lt;7&amp;4294967295|o&gt;&gt;&gt;25))+((o=s+(i^t&amp;(n^i))+r[5]+1200080426&amp;4294967295)&lt;&lt;12&amp;4294967295|o&gt;&gt;&gt;20))+((o=i+(n^s&amp;(t^n))+r[6]+2821735955&amp;4294967295)&lt;&lt;17&amp;4294967295|o&gt;&gt;&gt;15))+((o=n+(t^i&amp;(s^t))+r[7]+4249261313&amp;4294967295)&lt;&lt;22&amp;4294967295|o&gt;&gt;&gt;10))+((o=t+(s^n&amp;(i^s))+r[8]+1770035416&amp;4294967295)&lt;&lt;7&amp;4294967295|o&gt;&gt;&gt;25))+((o=s+(i^t&amp;(n^i))+r[9]+2336552879&amp;4294967295)&lt;&lt;12&amp;4294967295|o&gt;&gt;&gt;20))+((o=i+(n^s&amp;(t^n))+r[10]+4294925233&amp;4294967295)&lt;&lt;17&amp;4294967295|o&gt;&gt;&gt;15))+((o=n+(t^i&amp;(s^t))+r[11]+2304563134&amp;4294967295)&lt;&lt;22&amp;4294967295|o&gt;&gt;&gt;10))+((o=t+(s^n&amp;(i^s))+r[12]+1804603682&amp;4294967295)&lt;&lt;7&amp;4294967295|o&gt;&gt;&gt;25))+((o=s+(i^t&amp;(n^i))+r[13]+4254626195&amp;4294967295)&lt;&lt;12&amp;4294967295|o&gt;&gt;&gt;20))+((o=i+(n^s&amp;(t^n))+r[14]+2792965006&amp;4294967295)&lt;&lt;17&amp;4294967295|o&gt;&gt;&gt;15))+((o=n+(t^i&amp;(s^t))+r[15]+1236535329&amp;4294967295)&lt;&lt;22&amp;4294967295|o&gt;&gt;&gt;10))+((o=t+(i^s&amp;(n^i))+r[1]+4129170786&amp;4294967295)&lt;&lt;5&amp;4294967295|o&gt;&gt;&gt;27))+((o=s+(n^i&amp;(t^n))+r[6]+3225465664&amp;4294967295)&lt;&lt;9&amp;4294967295|o&gt;&gt;&gt;23))+((o=i+(t^n&amp;(s^t))+r[11]+643717713&amp;4294967295)&lt;&lt;14&amp;4294967295|o&gt;&gt;&gt;18))+((o=n+(s^t&amp;(i^s))+r[0]+3921069994&amp;4294967295)&lt;&lt;20&amp;4294967295|o&gt;&gt;&gt;12))+((o=t+(i^s&amp;(n^i))+r[5]+3593408605&amp;4294967295)&lt;&lt;5&amp;4294967295|o&gt;&gt;&gt;27))+((o=s+(n^i&amp;(t^n))+r[10]+38016083&amp;4294967295)&lt;&lt;9&amp;4294967295|o&gt;&gt;&gt;23))+((o=i+(t^n&amp;(s^t))+r[15]+3634488961&amp;4294967295)&lt;&lt;14&amp;4294967295|o&gt;&gt;&gt;18))+((o=n+(s^t&amp;(i^s))+r[4]+3889429448&amp;4294967295)&lt;&lt;20&amp;4294967295|o&gt;&gt;&gt;12))+((o=t+(i^s&amp;(n^i))+r[9]+568446438&amp;4294967295)&lt;&lt;5&amp;4294967295|o&gt;&gt;&gt;27))+((o=s+(n^i&amp;(t^n))+r[14]+3275163606&amp;4294967295)&lt;&lt;9&amp;4294967295|o&gt;&gt;&gt;23))+((o=i+(t^n&amp;(s^t))+r[3]+4107603335&amp;4294967295)&lt;&lt;14&amp;4294967295|o&gt;&gt;&gt;18))+((o=n+(s^t&amp;(i^s))+r[8]+1163531501&amp;4294967295)&lt;&lt;20&amp;4294967295|o&gt;&gt;&gt;12))+((o=t+(i^s&amp;(n^i))+r[13]+2850285829&amp;4294967295)&lt;&lt;5&amp;4294967295|o&gt;&gt;&gt;27))+((o=s+(n^i&amp;(t^n))+r[2]+4243563512&amp;4294967295)&lt;&lt;9&amp;4294967295|o&gt;&gt;&gt;23))+((o=i+(t^n&amp;(s^t))+r[7]+1735328473&amp;4294967295)&lt;&lt;14&amp;4294967295|o&gt;&gt;&gt;18))+((o=n+(s^t&amp;(i^s))+r[12]+2368359562&amp;4294967295)&lt;&lt;20&amp;4294967295|o&gt;&gt;&gt;12))+((o=t+(n^i^s)+r[5]+4294588738&amp;4294967295)&lt;&lt;4&amp;4294967295|o&gt;&gt;&gt;28))+((o=s+(t^n^i)+r[8]+2272392833&amp;4294967295)&lt;&lt;11&amp;4294967295|o&gt;&gt;&gt;21))+((o=i+(s^t^n)+r[11]+1839030562&amp;4294967295)&lt;&lt;16&amp;4294967295|o&gt;&gt;&gt;16))+((o=n+(i^s^t)+r[14]+4259657740&amp;4294967295)&lt;&lt;23&amp;4294967295|o&gt;&gt;&gt;9))+((o=t+(n^i^s)+r[1]+2763975236&amp;4294967295)&lt;&lt;4&amp;4294967295|o&gt;&gt;&gt;28))+((o=s+(t^n^i)+r[4]+1272893353&amp;4294967295)&lt;&lt;11&amp;4294967295|o&gt;&gt;&gt;21))+((o=i+(s^t^n)+r[7]+4139469664&amp;4294967295)&lt;&lt;16&amp;4294967295|o&gt;&gt;&gt;16))+((o=n+(i^s^t)+r[10]+3200236656&amp;4294967295)&lt;&lt;23&amp;4294967295|o&gt;&gt;&gt;9))+((o=t+(n^i^s)+r[13]+681279174&amp;4294967295)&lt;&lt;4&amp;4294967295|o&gt;&gt;&gt;28))+((o=s+(t^n^i)+r[0]+3936430074&amp;4294967295)&lt;&lt;11&amp;4294967295|o&gt;&gt;&gt;21))+((o=i+(s^t^n)+r[3]+3572445317&amp;4294967295)&lt;&lt;16&amp;4294967295|o&gt;&gt;&gt;16))+((o=n+(i^s^t)+r[6]+76029189&amp;4294967295)&lt;&lt;23&amp;4294967295|o&gt;&gt;&gt;9))+((o=t+(n^i^s)+r[9]+3654602809&amp;4294967295)&lt;&lt;4&amp;4294967295|o&gt;&gt;&gt;28))+((o=s+(t^n^i)+r[12]+3873151461&amp;4294967295)&lt;&lt;11&amp;4294967295|o&gt;&gt;&gt;21))+((o=i+(s^t^n)+r[15]+530742520&amp;4294967295)&lt;&lt;16&amp;4294967295|o&gt;&gt;&gt;16))+((o=n+(i^s^t)+r[2]+3299628645&amp;4294967295)&lt;&lt;23&amp;4294967295|o&gt;&gt;&gt;9))+((o=t+(i^(n|~s))+r[0]+4096336452&amp;4294967295)&lt;&lt;6&amp;4294967295|o&gt;&gt;&gt;26))+((o=s+(n^(t|~i))+r[7]+1126891415&amp;4294967295)&lt;&lt;10&amp;4294967295|o&gt;&gt;&gt;22))+((o=i+(t^(s|~n))+r[14]+2878612391&amp;4294967295)&lt;&lt;15&amp;4294967295|o&gt;&gt;&gt;17))+((o=n+(s^(i|~t))+r[5]+4237533241&amp;4294967295)&lt;&lt;21&amp;4294967295|o&gt;&gt;&gt;11))+((o=t+(i^(n|~s))+r[12]+1700485571&amp;4294967295)&lt;&lt;6&amp;4294967295|o&gt;&gt;&gt;26))+((o=s+(n^(t|~i))+r[3]+2399980690&amp;4294967295)&lt;&lt;10&amp;4294967295|o&gt;&gt;&gt;22))+((o=i+(t^(s|~n))+r[10]+4293915773&amp;4294967295)&lt;&lt;15&amp;4294967295|o&gt;&gt;&gt;17))+((o=n+(s^(i|~t))+r[1]+2240044497&amp;4294967295)&lt;&lt;21&amp;4294967295|o&gt;&gt;&gt;11))+((o=t+(i^(n|~s))+r[8]+1873313359&amp;4294967295)&lt;&lt;6&amp;4294967295|o&gt;&gt;&gt;26))+((o=s+(n^(t|~i))+r[15]+4264355552&amp;4294967295)&lt;&lt;10&amp;4294967295|o&gt;&gt;&gt;22))+((o=i+(t^(s|~n))+r[6]+2734768916&amp;4294967295)&lt;&lt;15&amp;4294967295|o&gt;&gt;&gt;17))+((o=n+(s^(i|~t))+r[13]+1309151649&amp;4294967295)&lt;&lt;21&amp;4294967295|o&gt;&gt;&gt;11))+((s=(t=n+((o=t+(i^(n|~s))+r[4]+4149444226&amp;4294967295)&lt;&lt;6&amp;4294967295|o&gt;&gt;&gt;26))+((o=s+(n^(t|~i))+r[11]+3174756917&amp;4294967295)&lt;&lt;10&amp;4294967295|o&gt;&gt;&gt;22))^((i=s+((o=i+(t^(s|~n))+r[2]+718787259&amp;4294967295)&lt;&lt;15&amp;4294967295|o&gt;&gt;&gt;17))|~t))+r[9]+3951481745&amp;4294967295,e.g[0]=e.g[0]+t&amp;4294967295,e.g[1]=e.g[1]+(i+(o&lt;&lt;21&amp;4294967295|o&gt;&gt;&gt;11))&amp;4294967295,e.g[2]=e.g[2]+i&amp;4294967295,e.g[3]=e.g[3]+s&amp;4294967295}function nr(e,t){this.h=t;for(var n=[],r=!0,i=e.length-1;0&lt;=i;i--){var s=0|e[i];r&amp;&amp;s==t||(n[i]=s,r=!1)}this.g=n}(r=gn.prototype).Oa=function(e){this.M=e},r.ha=function(e,t,n,r){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.I+"; newUri="+e);t=t?t.toUpperCase():"GET",this.I=e,this.j="",this.m=0,this.F=!1,this.h=!0,this.g=this.u?this.u.g():st.g(),this.C=this.u?rt(this.u):rt(st),this.g.onreadystatechange=v(this.La,this);try{this.G=!0,this.g.open(t,String(e),!0),this.G=!1}catch(e){return void vn(this,e)}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("function"!=typeof r.keys||"function"!=typeof r.get)throw Error("Unknown input type for opt_headers: "+String(r));for(const e of r.keys())n.set(e,r.get(e))}r=Array.from(n.keys()).find((e=&gt;"content-type"==e.toLowerCase())),i=h.FormData&amp;&amp;e instanceof h.FormData,!(0&lt;=C(_n,t))||r||i||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[e,t]of n)this.g.setRequestHeader(e,t);this.K&amp;&amp;(this.g.responseType=this.K),"withCredentials"in this.g&amp;&amp;this.g.withCredentials!==this.M&amp;&amp;(this.g.withCredentials=this.M);try{Cn(this),0&lt;this.B&amp;&amp;((this.L=function(e){return q&amp;&amp;M(H,9,(function(){let e=0;const t=D(String(F)).split("."),n=D("9").split("."),r=Math.max(t.length,n.length);for(let o=0;0==e&amp;&amp;o&lt;r;o++){var i=t[o]||"",s=n[o]||"";do{if(i=/(\d*)(\D*)(.*)/.exec(i)||["","","",""],s=/(\d*)(\D*)(.*)/.exec(s)||["","","",""],0==i[0].length&amp;&amp;0==s[0].length)break;e=N(0==i[1].length?0:parseInt(i[1],10),0==s[1].length?0:parseInt(s[1],10))||N(0==i[2].length,0==s[2].length)||N(i[2],s[2]),i=i[3],s=s[3]}while(0==e)}return 0&lt;=e}))&amp;&amp;"number"==typeof e.timeout&amp;&amp;void 0!==e.ontimeout}(this.g))?(this.g.timeout=this.B,this.g.ontimeout=v(this.ua,this)):this.A=Oe(this.ua,this.B,this)),this.v=!0,this.g.send(e),this.v=!1}catch(e){vn(this,e)}},r.ua=function(){void 0!==l&amp;&amp;this.g&amp;&amp;(this.j="Timed out after "+this.B+"ms, aborting",this.m=8,Ie(this,"timeout"),this.abort(8))},r.abort=function(e){this.g&amp;&amp;this.h&amp;&amp;(this.h=!1,this.l=!0,this.g.abort(),this.l=!1,this.m=e||7,Ie(this,"complete"),Ie(this,"abort"),In(this))},r.N=function(){this.g&amp;&amp;(this.h&amp;&amp;(this.h=!1,this.l=!0,this.g.abort(),this.l=!1),In(this,!0)),gn.$.N.call(this)},r.La=function(){this.s||(this.G||this.v||this.l?bn(this):this.kb())},r.kb=function(){bn(this)},r.da=function(){try{return 2&lt;Tn(this)?this.g.status:-1}catch(e){return-1}},r.ja=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},r.Wa=function(e){if(this.g){var t=this.g.responseText;return e&amp;&amp;0==t.indexOf(e)&amp;&amp;(t=t.substring(e.length)),pn(t)}},r.Ia=function(){return this.m},r.Sa=function(){return"string"==typeof this.j?this.j:String(this.j)},(r=Dn.prototype).qa=8,r.H=1,r.Na=function(e){if(this.m)if(this.m=null,1==this.H){if(!e){this.W=Math.floor(1e5*Math.random()),e=this.W++;const i=new lt(this,this.j,e,void 0);let s=this.s;if(this.U&amp;&amp;(s?(s=re(s),se(s,this.U)):s=this.U),null!==this.o||this.O||(i.I=s,s=null),this.P)e:{for(var t=0,n=0;n&lt;this.i.length;n++){var r=this.i[n];if(void 0===(r="__data__"in r.g&amp;&amp;"string"==typeof(r=r.g.__data__)?r.length:void 0))break;if(4096&lt;(t+=r)){t=n;break e}if(4096===t||n===this.i.length-1){t=n+1;break e}}t=1e3}else t=1e3;t=On(this,i,t),Rt(n=Dt(this.G),"RID",e),Rt(n,"CVER",22),this.F&amp;&amp;Rt(n,"X-HTTP-Session-Id",this.F),Fn(this,n),s&amp;&amp;(this.O?t="headers="+encodeURIComponent(String(Sn(s)))+"&amp;"+t:this.o&amp;&amp;xn(n,this.o,s)),en(this.h,i),this.bb&amp;&amp;Rt(n,"TYPE","init"),this.P?(Rt(n,"$req",t),Rt(n,"SID","null"),i.ba=!0,gt(i,n,null)):gt(i,n,t),this.H=2}}else 3==this.H&amp;&amp;(e?Mn(this,e):0==this.i.length||Xt(this.h)||Mn(this))},r.Ma=function(){if(this.u=null,Bn(this),this.ca&amp;&amp;!(this.L||null==this.g||0&gt;=this.S)){var e=2*this.S;this.j.info("BP detection timer enabled: "+e),this.B=Ze(v(this.jb,this),e)}},r.jb=function(){this.B&amp;&amp;(this.B=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.M=!1,this.L=!0,Xe(10),An(this),Bn(this))},r.ib=function(){null!=this.v&amp;&amp;(this.v=null,An(this),qn(this),Xe(19))},r.pb=function(e){e?(this.j.info("Successfully pinged google.com"),Xe(2)):(this.j.info("Failed to ping google.com"),Xe(1))},(r=Hn.prototype).Ba=function(){},r.Aa=function(){},r.za=function(){},r.ya=function(){},r.Va=function(){},Qn.prototype.g=function(e,t){return new Yn(e,t)},b(Yn,be),Yn.prototype.m=function(){this.g.l=this.j,this.A&amp;&amp;(this.g.I=!0);var e=this.g,t=this.l,n=this.h||void 0;Xe(0),e.Y=t,e.ma=n||{},e.M=e.aa,e.G=Gn(e,null,e.Y),Rn(e)},Yn.prototype.close=function(){Nn(this.g)},Yn.prototype.u=function(e){var t=this.g;if("string"==typeof e){var n={};n.__data__=e,e=n}else this.v&amp;&amp;((n={}).__data__=Te(e),e=n);t.i.push(new class{constructor(e,t){this.h=e,this.g=t}}(t.fb++,e)),3==t.H&amp;&amp;Rn(t)},Yn.prototype.N=function(){this.g.l=null,delete this.j,Nn(this.g),delete this.g,Yn.$.N.call(this)},b(Xn,at),b(Jn,ct),b(Zn,Hn),Zn.prototype.Ba=function(){Ie(this.g,"a")},Zn.prototype.Aa=function(e){Ie(this.g,new Xn(e))},Zn.prototype.za=function(e){Ie(this.g,new Jn)},Zn.prototype.ya=function(){Ie(this.g,"b")},b(er,(function(){this.blockSize=-1})),er.prototype.reset=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.i=this.h=0},er.prototype.j=function(e,t){void 0===t&amp;&amp;(t=e.length);for(var n=t-this.blockSize,r=this.m,i=this.h,s=0;s&lt;t;){if(0==i)for(;s&lt;=n;)tr(this,e,s),s+=this.blockSize;if("string"==typeof e){for(;s&lt;t;)if(r[i++]=e.charCodeAt(s++),i==this.blockSize){tr(this,r),i=0;break}}else for(;s&lt;t;)if(r[i++]=e[s++],i==this.blockSize){tr(this,r),i=0;break}}this.h=i,this.i+=t},er.prototype.l=function(){var e=Array((56&gt;this.h?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var t=1;t&lt;e.length-8;++t)e[t]=0;var n=8*this.i;for(t=e.length-8;t&lt;e.length;++t)e[t]=255&amp;n,n/=256;for(this.j(e),e=Array(16),t=n=0;4&gt;t;++t)for(var r=0;32&gt;r;r+=8)e[n++]=this.g[t]&gt;&gt;&gt;r&amp;255;return e};var rr={};function ir(e){return-128&lt;=e&amp;&amp;128&gt;e?M(rr,e,(function(e){return new nr([0|e],0&gt;e?-1:0)})):new nr([0|e],0&gt;e?-1:0)}function sr(e){if(isNaN(e)||!isFinite(e))return ar;if(0&gt;e)return dr(sr(-e));for(var t=[],n=1,r=0;e&gt;=n;r++)t[r]=e/n|0,n*=or;return new nr(t,0)}var or=4294967296,ar=ir(0),cr=ir(1),ur=ir(16777216);function lr(e){if(0!=e.h)return!1;for(var t=0;t&lt;e.g.length;t++)if(0!=e.g[t])return!1;return!0}function hr(e){return-1==e.h}function dr(e){for(var t=e.g.length,n=[],r=0;r&lt;t;r++)n[r]=~e.g[r];return new nr(n,~e.h).add(cr)}function fr(e,t){return e.add(dr(t))}function pr(e,t){for(;(65535&amp;e[t])!=e[t];)e[t+1]+=e[t]&gt;&gt;&gt;16,e[t]&amp;=65535,t++}function gr(e,t){this.g=e,this.h=t}function mr(e,t){if(lr(t))throw Error("division by zero");if(lr(e))return new gr(ar,ar);if(hr(e))return t=mr(dr(e),t),new gr(dr(t.g),dr(t.h));if(hr(t))return t=mr(e,dr(t)),new gr(dr(t.g),t.h);if(30&lt;e.g.length){if(hr(e)||hr(t))throw Error("slowDivide_ only works with positive integers.");for(var n=cr,r=t;0&gt;=r.X(e);)n=yr(n),r=yr(r);var i=_r(n,1),s=_r(r,1);for(r=_r(r,2),n=_r(n,2);!lr(r);){var o=s.add(r);0&gt;=o.X(e)&amp;&amp;(i=i.add(n),s=o),r=_r(r,1),n=_r(n,1)}return t=fr(e,i.R(t)),new gr(i,t)}for(i=ar;0&lt;=e.X(t);){for(n=Math.max(1,Math.floor(e.ea()/t.ea())),r=48&gt;=(r=Math.ceil(Math.log(n)/Math.LN2))?1:Math.pow(2,r-48),o=(s=sr(n)).R(t);hr(o)||0&lt;o.X(e);)o=(s=sr(n-=r)).R(t);lr(s)&amp;&amp;(s=cr),i=i.add(s),e=fr(e,o)}return new gr(i,e)}function yr(e){for(var t=e.g.length+1,n=[],r=0;r&lt;t;r++)n[r]=e.D(r)&lt;&lt;1|e.D(r-1)&gt;&gt;&gt;31;return new nr(n,e.h)}function _r(e,t){var n=t&gt;&gt;5;t%=32;for(var r=e.g.length-n,i=[],s=0;s&lt;r;s++)i[s]=0&lt;t?e.D(s+n)&gt;&gt;&gt;t|e.D(s+n+1)&lt;&lt;32-t:e.D(s+n);return new nr(i,e.h)}(r=nr.prototype).ea=function(){if(hr(this))return-dr(this).ea();for(var e=0,t=1,n=0;n&lt;this.g.length;n++){var r=this.D(n);e+=(0&lt;=r?r:or+r)*t,t*=or}return e},r.toString=function(e){if(2&gt;(e=e||10)||36&lt;e)throw Error("radix out of range: "+e);if(lr(this))return"0";if(hr(this))return"-"+dr(this).toString(e);for(var t=sr(Math.pow(e,6)),n=this,r="";;){var i=mr(n,t).g,s=((0&lt;(n=fr(n,i.R(t))).g.length?n.g[0]:n.h)&gt;&gt;&gt;0).toString(e);if(lr(n=i))return s+r;for(;6&gt;s.length;)s="0"+s;r=s+r}},r.D=function(e){return 0&gt;e?0:e&lt;this.g.length?this.g[e]:this.h},r.X=function(e){return hr(e=fr(this,e))?-1:lr(e)?0:1},r.abs=function(){return hr(this)?dr(this):this},r.add=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0,i=0;i&lt;=t;i++){var s=r+(65535&amp;this.D(i))+(65535&amp;e.D(i)),o=(s&gt;&gt;&gt;16)+(this.D(i)&gt;&gt;&gt;16)+(e.D(i)&gt;&gt;&gt;16);r=o&gt;&gt;&gt;16,s&amp;=65535,o&amp;=65535,n[i]=o&lt;&lt;16|s}return new nr(n,-2147483648&amp;n[n.length-1]?-1:0)},r.R=function(e){if(lr(this)||lr(e))return ar;if(hr(this))return hr(e)?dr(this).R(dr(e)):dr(dr(this).R(e));if(hr(e))return dr(this.R(dr(e)));if(0&gt;this.X(ur)&amp;&amp;0&gt;e.X(ur))return sr(this.ea()*e.ea());for(var t=this.g.length+e.g.length,n=[],r=0;r&lt;2*t;r++)n[r]=0;for(r=0;r&lt;this.g.length;r++)for(var i=0;i&lt;e.g.length;i++){var s=this.D(r)&gt;&gt;&gt;16,o=65535&amp;this.D(r),a=e.D(i)&gt;&gt;&gt;16,c=65535&amp;e.D(i);n[2*r+2*i]+=o*c,pr(n,2*r+2*i),n[2*r+2*i+1]+=s*c,pr(n,2*r+2*i+1),n[2*r+2*i+1]+=o*a,pr(n,2*r+2*i+1),n[2*r+2*i+2]+=s*a,pr(n,2*r+2*i+2)}for(r=0;r&lt;t;r++)n[r]=n[2*r+1]&lt;&lt;16|n[2*r];for(r=t;r&lt;2*t;r++)n[r]=0;return new nr(n,0)},r.gb=function(e){return mr(this,e).h},r.and=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r&lt;t;r++)n[r]=this.D(r)&amp;e.D(r);return new nr(n,this.h&amp;e.h)},r.or=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r&lt;t;r++)n[r]=this.D(r)|e.D(r);return new nr(n,this.h|e.h)},r.xor=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],r=0;r&lt;t;r++)n[r]=this.D(r)^e.D(r);return new nr(n,this.h^e.h)},Qn.prototype.createWebChannel=Qn.prototype.g,Yn.prototype.send=Yn.prototype.u,Yn.prototype.open=Yn.prototype.m,Yn.prototype.close=Yn.prototype.close,et.NO_ERROR=0,et.TIMEOUT=8,et.HTTP_ERROR=6,tt.COMPLETE="complete",it.EventType=ot,ot.OPEN="a",ot.CLOSE="b",ot.ERROR="c",ot.MESSAGE="d",be.prototype.listen=be.prototype.O,gn.prototype.listenOnce=gn.prototype.P,gn.prototype.getLastError=gn.prototype.Sa,gn.prototype.getLastErrorCode=gn.prototype.Ia,gn.prototype.getStatus=gn.prototype.da,gn.prototype.getResponseJson=gn.prototype.Wa,gn.prototype.getResponseText=gn.prototype.ja,gn.prototype.send=gn.prototype.ha,gn.prototype.setWithCredentials=gn.prototype.Oa,er.prototype.digest=er.prototype.l,er.prototype.reset=er.prototype.reset,er.prototype.update=er.prototype.j,nr.prototype.add=nr.prototype.add,nr.prototype.multiply=nr.prototype.R,nr.prototype.modulo=nr.prototype.gb,nr.prototype.compare=nr.prototype.X,nr.prototype.toNumber=nr.prototype.ea,nr.prototype.toString=nr.prototype.toString,nr.prototype.getBits=nr.prototype.D,nr.fromNumber=sr,nr.fromString=function e(t,n){if(0==t.length)throw Error("number format error: empty string");if(2&gt;(n=n||10)||36&lt;n)throw Error("radix out of range: "+n);if("-"==t.charAt(0))return dr(e(t.substring(1),n));if(0&lt;=t.indexOf("-"))throw Error('number format error: interior "-" character');for(var r=sr(Math.pow(n,8)),i=ar,s=0;s&lt;t.length;s+=8){var o=Math.min(8,t.length-s),a=parseInt(t.substring(s,s+o),n);8&gt;o?(o=sr(Math.pow(n,o)),i=i.R(o).add(sr(a))):i=(i=i.R(r)).add(sr(a))}return i};var vr=u.createWebChannelTransport=function(){return new Qn},wr=u.getStatEventTarget=function(){return We()},br=u.ErrorCode=et,Ir=u.EventType=tt,Cr=u.Event=Ke,Tr=u.Stat={xb:0,Ab:1,Bb:2,Ub:3,Zb:4,Wb:5,Xb:6,Vb:7,Tb:8,Yb:9,PROXY:10,NOPROXY:11,Rb:12,Nb:13,Ob:14,Mb:15,Pb:16,Qb:17,tb:18,sb:19,ub:20},Er=u.FetchXmlHttpFactory=cn,Sr=u.WebChannel=it,xr=u.XhrIo=gn,kr=u.Md5=er,Dr=u.Integer=nr;const Nr="@firebase/firestore";class Ar{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}Ar.UNAUTHENTICATED=new Ar(null),Ar.GOOGLE_CREDENTIALS=new Ar("google-credentials-uid"),Ar.FIRST_PARTY=new Ar("first-party-uid"),Ar.MOCK_USER=new Ar("mock-user");let Pr="9.21.0";const Rr=new o.Yd("@firebase/firestore");function Mr(){return Rr.logLevel}function Fr(e){Rr.setLogLevel(e)}function Or(e,...t){if(Rr.logLevel&lt;=o.in.DEBUG){const n=t.map(Vr);Rr.debug(`Firestore (${Pr}): ${e}`,...n)}}function Lr(e,...t){if(Rr.logLevel&lt;=o.in.ERROR){const n=t.map(Vr);Rr.error(`Firestore (${Pr}): ${e}`,...n)}}function qr(e,...t){if(Rr.logLevel&lt;=o.in.WARN){const n=t.map(Vr);Rr.warn(`Firestore (${Pr}): ${e}`,...n)}}function Vr(e){if("string"==typeof e)return e;try{return t=e,JSON.stringify(t)}catch(t){return e}var t}function Br(e="Unexpected state"){const t=`FIRESTORE (${Pr}) INTERNAL ASSERTION FAILED: `+e;throw Lr(t),new Error(t)}function Ur(e,t){e||Br()}function jr(e,t){e||Br()}function zr(e,t){return e}const $r={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class Kr extends a.ZR{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=&gt;`${this.name}: [code=${this.code}]: ${this.message}`}}class Gr{constructor(){this.promise=new Promise(((e,t)=&gt;{this.resolve=e,this.reject=t}))}}class Wr{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class Hr{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=&gt;t(Ar.UNAUTHENTICATED)))}shutdown(){}}class Qr{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable((()=&gt;t(this.token.user)))}shutdown(){this.changeListener=null}}class Yr{constructor(e){this.t=e,this.currentUser=Ar.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){let n=this.i;const r=e=&gt;this.i!==n?(n=this.i,t(e)):Promise.resolve();let i=new Gr;this.o=()=&gt;{this.i++,this.currentUser=this.u(),i.resolve(),i=new Gr,e.enqueueRetryable((()=&gt;r(this.currentUser)))};const s=()=&gt;{const t=i;e.enqueueRetryable((async()=&gt;{await t.promise,await r(this.currentUser)}))},o=e=&gt;{Or("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.auth.addAuthTokenListener(this.o),s()};this.t.onInit((e=&gt;o(e))),setTimeout((()=&gt;{if(!this.auth){const e=this.t.getImmediate({optional:!0});e?o(e):(Or("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new Gr)}}),0),s()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((t=&gt;this.i!==e?(Or("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(Ur("string"==typeof t.accessToken),new Wr(t.accessToken,this.currentUser)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&amp;&amp;this.auth.removeAuthTokenListener(this.o)}u(){const e=this.auth&amp;&amp;this.auth.getUid();return Ur(null===e||"string"==typeof e),new Ar(e)}}class Xr{constructor(e,t,n){this.h=e,this.l=t,this.m=n,this.type="FirstParty",this.user=Ar.FIRST_PARTY,this.g=new Map}p(){return this.m?this.m():null}get headers(){this.g.set("X-Goog-AuthUser",this.h);const e=this.p();return e&amp;&amp;this.g.set("Authorization",e),this.l&amp;&amp;this.g.set("X-Goog-Iam-Authorization-Token",this.l),this.g}}class Jr{constructor(e,t,n){this.h=e,this.l=t,this.m=n}getToken(){return Promise.resolve(new Xr(this.h,this.l,this.m))}start(e,t){e.enqueueRetryable((()=&gt;t(Ar.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class Zr{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&amp;&amp;e.length&gt;0&amp;&amp;this.headers.set("x-firebase-appcheck",this.value)}}class ei{constructor(e){this.I=e,this.forceRefresh=!1,this.appCheck=null,this.T=null}start(e,t){const n=e=&gt;{null!=e.error&amp;&amp;Or("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);const n=e.token!==this.T;return this.T=e.token,Or("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?t(e.token):Promise.resolve()};this.o=t=&gt;{e.enqueueRetryable((()=&gt;n(t)))};const r=e=&gt;{Or("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.appCheck.addTokenListener(this.o)};this.I.onInit((e=&gt;r(e))),setTimeout((()=&gt;{if(!this.appCheck){const e=this.I.getImmediate({optional:!0});e?r(e):Or("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}}),0)}getToken(){const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((e=&gt;e?(Ur("string"==typeof e.token),this.T=e.token,new Zr(e.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&amp;&amp;this.appCheck.removeTokenListener(this.o)}}class ti{getToken(){return Promise.resolve(new Zr(""))}invalidateToken(){}start(e,t){}shutdown(){}}function ni(e){const t="undefined"!=typeof self&amp;&amp;(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&amp;&amp;"function"==typeof t.getRandomValues)t.getRandomValues(n);else for(let t=0;t&lt;e;t++)n[t]=Math.floor(256*Math.random());return n}class ri{static A(){const e=62*Math.floor(256/62);let t="";for(;t.length&lt;20;){const n=ni(40);for(let r=0;r&lt;n.length;++r)t.length&lt;20&amp;&amp;n[r]&lt;e&amp;&amp;(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(n[r]%62))}return t}}function ii(e,t){return e&lt;t?-1:e&gt;t?1:0}function si(e,t,n){return e.length===t.length&amp;&amp;e.every(((e,r)=&gt;n(e,t[r])))}function oi(e){return e+"\0"}class ai{constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t&lt;0)throw new Kr($r.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t&gt;=1e9)throw new Kr($r.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e&lt;-62135596800)throw new Kr($r.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e&gt;=253402300800)throw new Kr($r.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}static now(){return ai.fromMillis(Date.now())}static fromDate(e){return ai.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),n=Math.floor(1e6*(e-1e3*t));return new ai(t,n)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?ii(this.nanoseconds,e.nanoseconds):ii(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&amp;&amp;e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}}valueOf(){const e=this.seconds- -62135596800;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}class ci{constructor(e){this.timestamp=e}static fromTimestamp(e){return new ci(e)}static min(){return new ci(new ai(0,0))}static max(){return new ci(new ai(253402300799,999999999))}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}}class ui{constructor(e,t,n){void 0===t?t=0:t&gt;e.length&amp;&amp;Br(),void 0===n?n=e.length-t:n&gt;e.length-t&amp;&amp;Br(),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===ui.comparator(this,e)}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof ui?e.forEach((e=&gt;{t.push(e)})):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return 0===this.length}isPrefixOf(e){if(e.length&lt;this.length)return!1;for(let t=0;t&lt;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&lt;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&lt;n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const n=Math.min(e.length,t.length);for(let r=0;r&lt;n;r++){const n=e.get(r),i=t.get(r);if(n&lt;i)return-1;if(n&gt;i)return 1}return e.length&lt;t.length?-1:e.length&gt;t.length?1:0}}class li extends ui{construct(e,t,n){return new li(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}static fromString(...e){const t=[];for(const n of e){if(n.indexOf("//")&gt;=0)throw new Kr($r.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter((e=&gt;e.length&gt;0)))}return new li(t)}static emptyPath(){return new li([])}}const hi=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class di extends ui{construct(e,t,n){return new di(e,t,n)}static isValidIdentifier(e){return hi.test(e)}canonicalString(){return this.toArray().map((e=&gt;(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),di.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&amp;&amp;"__name__"===this.get(0)}static keyField(){return new di(["__name__"])}static fromServerFormat(e){const t=[];let n="",r=0;const i=()=&gt;{if(0===n.length)throw new Kr($r.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""};let s=!1;for(;r&lt;e.length;){const t=e[r];if("\\"===t){if(r+1===e.length)throw new Kr($r.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const t=e[r+1];if("\\"!==t&amp;&amp;"."!==t&amp;&amp;"`"!==t)throw new Kr($r.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=t,r+=2}else"`"===t?(s=!s,r++):"."!==t||s?(n+=t,r++):(i(),r++)}if(i(),s)throw new Kr($r.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new di(t)}static emptyPath(){return new di([])}}class fi{constructor(e){this.path=e}static fromPath(e){return new fi(li.fromString(e))}static fromName(e){return new fi(li.fromString(e).popFirst(5))}static empty(){return new fi(li.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length&gt;=2&amp;&amp;this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return null!==e&amp;&amp;0===li.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return li.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new fi(new li(e.slice()))}}class pi{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}}function gi(e){return e.fields.find((e=&gt;2===e.kind))}function mi(e){return e.fields.filter((e=&gt;2!==e.kind))}function yi(e,t){let n=ii(e.collectionGroup,t.collectionGroup);if(0!==n)return n;for(let r=0;r&lt;Math.min(e.fields.length,t.fields.length);++r)if(n=vi(e.fields[r],t.fields[r]),0!==n)return n;return ii(e.fields.length,t.fields.length)}pi.UNKNOWN_ID=-1;class _i{constructor(e,t){this.fieldPath=e,this.kind=t}}function vi(e,t){const n=di.comparator(e.fieldPath,t.fieldPath);return 0!==n?n:ii(e.kind,t.kind)}class wi{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new wi(0,Ci.min())}}function bi(e,t){const n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1,i=ci.fromTimestamp(1e9===r?new ai(n+1,0):new ai(n,r));return new Ci(i,fi.empty(),t)}function Ii(e){return new Ci(e.readTime,e.key,-1)}class Ci{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new Ci(ci.min(),fi.empty(),-1)}static max(){return new Ci(ci.max(),fi.empty(),-1)}}function Ti(e,t){let n=e.readTime.compareTo(t.readTime);return 0!==n?n:(n=fi.comparator(e.documentKey,t.documentKey),0!==n?n:ii(e.largestBatchId,t.largestBatchId))}const Ei="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class Si{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=&gt;e()))}}async function xi(e){if(e.code!==$r.FAILED_PRECONDITION||e.message!==Ei)throw e;Or("LocalStore","Unexpectedly lost primary lease")}class ki{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e((e=&gt;{this.isDone=!0,this.result=e,this.nextCallback&amp;&amp;this.nextCallback(e)}),(e=&gt;{this.isDone=!0,this.error=e,this.catchCallback&amp;&amp;this.catchCallback(e)}))}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&amp;&amp;Br(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new ki(((n,r)=&gt;{this.nextCallback=t=&gt;{this.wrapSuccess(e,t).next(n,r)},this.catchCallback=e=&gt;{this.wrapFailure(t,e).next(n,r)}}))}toPromise(){return new Promise(((e,t)=&gt;{this.next(e,t)}))}wrapUserFunction(e){try{const t=e();return t instanceof ki?t:ki.resolve(t)}catch(e){return ki.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction((()=&gt;e(t))):ki.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction((()=&gt;e(t))):ki.reject(t)}static resolve(e){return new ki(((t,n)=&gt;{t(e)}))}static reject(e){return new ki(((t,n)=&gt;{n(e)}))}static waitFor(e){return new ki(((t,n)=&gt;{let r=0,i=0,s=!1;e.forEach((e=&gt;{++r,e.next((()=&gt;{++i,s&amp;&amp;i===r&amp;&amp;t()}),(e=&gt;n(e)))})),s=!0,i===r&amp;&amp;t()}))}static or(e){let t=ki.resolve(!1);for(const n of e)t=t.next((e=&gt;e?ki.resolve(e):n()));return t}static forEach(e,t){const n=[];return e.forEach(((e,r)=&gt;{n.push(t.call(this,e,r))})),this.waitFor(n)}static mapArray(e,t){return new ki(((n,r)=&gt;{const i=e.length,s=new Array(i);let o=0;for(let a=0;a&lt;i;a++){const c=a;t(e[c]).next((e=&gt;{s[c]=e,++o,o===i&amp;&amp;n(s)}),(e=&gt;r(e)))}}))}static doWhile(e,t){return new ki(((n,r)=&gt;{const i=()=&gt;{!0===e()?t().next((()=&gt;{i()}),r):n()};i()}))}}class Di{constructor(e,t){this.action=e,this.transaction=t,this.aborted=!1,this.R=new Gr,this.transaction.oncomplete=()=&gt;{this.R.resolve()},this.transaction.onabort=()=&gt;{t.error?this.R.reject(new Pi(e,t.error)):this.R.resolve()},this.transaction.onerror=t=&gt;{const n=Li(t.target.error);this.R.reject(new Pi(e,n))}}static open(e,t,n,r){try{return new Di(t,e.transaction(r,n))}catch(e){throw new Pi(t,e)}}get v(){return this.R.promise}abort(e){e&amp;&amp;this.R.reject(e),this.aborted||(Or("SimpleDb","Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}P(){const e=this.transaction;this.aborted||"function"!=typeof e.commit||e.commit()}store(e){const t=this.transaction.objectStore(e);return new Mi(t)}}class Ni{constructor(e,t,n){this.name=e,this.version=t,this.V=n,12.2===Ni.S((0,a.z$)())&amp;&amp;Lr("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}static delete(e){return Or("SimpleDb","Removing database:",e),Fi(window.indexedDB.deleteDatabase(e)).toPromise()}static D(){if(!(0,a.hl)())return!1;if(Ni.C())return!0;const e=(0,a.z$)(),t=Ni.S(e),n=0&lt;t&amp;&amp;t&lt;10,r=Ni.N(e),i=0&lt;r&amp;&amp;r&lt;4.5;return!(e.indexOf("MSIE ")&gt;0||e.indexOf("Trident/")&gt;0||e.indexOf("Edge/")&gt;0||n||i)}static C(){var e;return"undefined"!=typeof process&amp;&amp;"YES"===(null===(e=process.env)||void 0===e?void 0:e.k)}static M(e,t){return e.store(t)}static S(e){const t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=t?t[1].split("_").slice(0,2).join("."):"-1";return Number(n)}static N(e){const t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(n)}async O(e){return this.db||(Or("SimpleDb","Opening database:",this.name),this.db=await new Promise(((t,n)=&gt;{const r=indexedDB.open(this.name,this.version);r.onsuccess=e=&gt;{const n=e.target.result;t(n)},r.onblocked=()=&gt;{n(new Pi(e,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},r.onerror=t=&gt;{const r=t.target.error;"VersionError"===r.name?n(new Kr($r.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):"InvalidStateError"===r.name?n(new Kr($r.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+r)):n(new Pi(e,r))},r.onupgradeneeded=e=&gt;{Or("SimpleDb",'Database "'+this.name+'" requires upgrade from version:',e.oldVersion);const t=e.target.result;this.V.$(t,r.transaction,e.oldVersion,this.version).next((()=&gt;{Or("SimpleDb","Database upgrade to version "+this.version+" complete")}))}}))),this.F&amp;&amp;(this.db.onversionchange=e=&gt;this.F(e)),this.db}B(e){this.F=e,this.db&amp;&amp;(this.db.onversionchange=t=&gt;e(t))}async runTransaction(e,t,n,r){const i="readonly"===t;let s=0;for(;;){++s;try{this.db=await this.O(e);const t=Di.open(this.db,e,i?"readonly":"readwrite",n),s=r(t).next((e=&gt;(t.P(),e))).catch((e=&gt;(t.abort(e),ki.reject(e)))).toPromise();return s.catch((()=&gt;{})),await t.v,s}catch(e){const t=e,n="FirebaseError"!==t.name&amp;&amp;s&lt;3;if(Or("SimpleDb","Transaction failed with error:",t.message,"Retrying:",n),this.close(),!n)return Promise.reject(t)}}}close(){this.db&amp;&amp;this.db.close(),this.db=void 0}}class Ai{constructor(e){this.L=e,this.q=!1,this.U=null}get isDone(){return this.q}get K(){return this.U}set cursor(e){this.L=e}done(){this.q=!0}G(e){this.U=e}delete(){return Fi(this.L.delete())}}class Pi extends Kr{constructor(e,t){super($r.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function Ri(e){return"IndexedDbTransactionError"===e.name}class Mi{constructor(e){this.store=e}put(e,t){let n;return void 0!==t?(Or("SimpleDb","PUT",this.store.name,e,t),n=this.store.put(t,e)):(Or("SimpleDb","PUT",this.store.name,"&lt;auto-key&gt;",e),n=this.store.put(e)),Fi(n)}add(e){return Or("SimpleDb","ADD",this.store.name,e,e),Fi(this.store.add(e))}get(e){return Fi(this.store.get(e)).next((t=&gt;(void 0===t&amp;&amp;(t=null),Or("SimpleDb","GET",this.store.name,e,t),t)))}delete(e){return Or("SimpleDb","DELETE",this.store.name,e),Fi(this.store.delete(e))}count(){return Or("SimpleDb","COUNT",this.store.name),Fi(this.store.count())}j(e,t){const n=this.options(e,t);if(n.index||"function"!=typeof this.store.getAll){const e=this.cursor(n),t=[];return this.W(e,((e,n)=&gt;{t.push(n)})).next((()=&gt;t))}{const e=this.store.getAll(n.range);return new ki(((t,n)=&gt;{e.onerror=e=&gt;{n(e.target.error)},e.onsuccess=e=&gt;{t(e.target.result)}}))}}H(e,t){const n=this.store.getAll(e,null===t?void 0:t);return new ki(((e,t)=&gt;{n.onerror=e=&gt;{t(e.target.error)},n.onsuccess=t=&gt;{e(t.target.result)}}))}J(e,t){Or("SimpleDb","DELETE ALL",this.store.name);const n=this.options(e,t);n.Y=!1;const r=this.cursor(n);return this.W(r,((e,t,n)=&gt;n.delete()))}X(e,t){let n;t?n=e:(n={},t=e);const r=this.cursor(n);return this.W(r,t)}Z(e){const t=this.cursor({});return new ki(((n,r)=&gt;{t.onerror=e=&gt;{const t=Li(e.target.error);r(t)},t.onsuccess=t=&gt;{const r=t.target.result;r?e(r.primaryKey,r.value).next((e=&gt;{e?r.continue():n()})):n()}}))}W(e,t){const n=[];return new ki(((r,i)=&gt;{e.onerror=e=&gt;{i(e.target.error)},e.onsuccess=e=&gt;{const i=e.target.result;if(!i)return void r();const s=new Ai(i),o=t(i.primaryKey,i.value,s);if(o instanceof ki){const e=o.catch((e=&gt;(s.done(),ki.reject(e))));n.push(e)}s.isDone?r():null===s.K?i.continue():i.continue(s.K)}})).next((()=&gt;ki.waitFor(n)))}options(e,t){let n;return void 0!==e&amp;&amp;("string"==typeof e?n=e:t=e),{index:n,range:t}}cursor(e){let t="next";if(e.reverse&amp;&amp;(t="prev"),e.index){const n=this.store.index(e.index);return e.Y?n.openKeyCursor(e.range,t):n.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function Fi(e){return new ki(((t,n)=&gt;{e.onsuccess=e=&gt;{const n=e.target.result;t(n)},e.onerror=e=&gt;{const t=Li(e.target.error);n(t)}}))}let Oi=!1;function Li(e){const t=Ni.S((0,a.z$)());if(t&gt;=12.2&amp;&amp;t&lt;13){const t="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(t)&gt;=0){const e=new Kr("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${t}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return Oi||(Oi=!0,setTimeout((()=&gt;{throw e}),0)),e}}return e}class qi{constructor(e,t){this.asyncQueue=e,this.tt=t,this.task=null}start(){this.et(15e3)}stop(){this.task&amp;&amp;(this.task.cancel(),this.task=null)}get started(){return null!==this.task}et(e){Or("IndexBackiller",`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,(async()=&gt;{this.task=null;try{Or("IndexBackiller",`Documents written: ${await this.tt.nt()}`)}catch(e){Ri(e)?Or("IndexBackiller","Ignoring IndexedDB error during index backfill: ",e):await xi(e)}await this.et(6e4)}))}}class Vi{constructor(e,t){this.localStore=e,this.persistence=t}async nt(e=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",(t=&gt;this.st(t,e)))}st(e,t){const n=new Set;let r=t,i=!0;return ki.doWhile((()=&gt;!0===i&amp;&amp;r&gt;0),(()=&gt;this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next((t=&gt;{if(null!==t&amp;&amp;!n.has(t))return Or("IndexBackiller",`Processing collection: ${t}`),this.it(e,t,r).next((e=&gt;{r-=e,n.add(t)}));i=!1})))).next((()=&gt;t-r))}it(e,t,n){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e,t).next((r=&gt;this.localStore.localDocuments.getNextDocuments(e,t,r,n).next((n=&gt;{const i=n.changes;return this.localStore.indexManager.updateIndexEntries(e,i).next((()=&gt;this.rt(r,n))).next((n=&gt;(Or("IndexBackiller",`Updating offset: ${n}`),this.localStore.indexManager.updateCollectionGroup(e,t,n)))).next((()=&gt;i.size))}))))}rt(e,t){let n=e;return t.changes.forEach(((e,t)=&gt;{const r=Ii(t);Ti(r,n)&gt;0&amp;&amp;(n=r)})),new Ci(n.readTime,n.documentKey,Math.max(t.batchId,e.largestBatchId))}}class Bi{constructor(e,t){this.previousValue=e,t&amp;&amp;(t.sequenceNumberHandler=e=&gt;this.ot(e),this.ut=e=&gt;t.writeSequenceNumber(e))}ot(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ut&amp;&amp;this.ut(e),e}}function Ui(e){return null==e}function ji(e){return 0===e&amp;&amp;1/e==-1/0}function zi(e){return"number"==typeof e&amp;&amp;Number.isInteger(e)&amp;&amp;!ji(e)&amp;&amp;e&lt;=Number.MAX_SAFE_INTEGER&amp;&amp;e&gt;=Number.MIN_SAFE_INTEGER}function $i(e){let t="";for(let n=0;n&lt;e.length;n++)t.length&gt;0&amp;&amp;(t=Gi(t)),t=Ki(e.get(n),t);return Gi(t)}function Ki(e,t){let n=t;const r=e.length;for(let t=0;t&lt;r;t++){const r=e.charAt(t);switch(r){case"\0":n+="";break;case"":n+="";break;default:n+=r}}return n}function Gi(e){return e+""}function Wi(e){const t=e.length;if(Ur(t&gt;=2),2===t)return Ur(""===e.charAt(0)&amp;&amp;""===e.charAt(1)),li.emptyPath();const n=t-2,r=[];let i="";for(let s=0;s&lt;t;){const t=e.indexOf("",s);switch((t&lt;0||t&gt;n)&amp;&amp;Br(),e.charAt(t+1)){case"":const n=e.substring(s,t);let o;0===i.length?o=n:(i+=n,o=i,i=""),r.push(o);break;case"":i+=e.substring(s,t),i+="\0";break;case"":i+=e.substring(s,t+1);break;default:Br()}s=t+2}return new li(r)}Bi.ct=-1;const Hi=["userId","batchId"];function Qi(e,t){return[e,$i(t)]}function Yi(e,t,n){return[e,$i(t),n]}const Xi={},Ji=["prefixPath","collectionGroup","readTime","documentId"],Zi=["prefixPath","collectionGroup","documentId"],es=["collectionGroup","readTime","prefixPath","documentId"],ts=["canonicalId","targetId"],ns=["targetId","path"],rs=["path","targetId"],is=["collectionId","parent"],ss=["indexId","uid"],os=["uid","sequenceNumber"],as=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],cs=["indexId","uid","orderedDocumentKey"],us=["userId","collectionPath","documentId"],ls=["userId","collectionPath","largestBatchId"],hs=["userId","collectionGroup","largestBatchId"],ds=["mutationQueues","mutations","documentMutations","remoteDocuments","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries"],fs=[...ds,"documentOverlays"],ps=["mutationQueues","mutations","documentMutations","remoteDocumentsV14","targets","owner","targetGlobal","targetDocuments","clientMetadata","remoteDocumentGlobal","collectionParents","bundles","namedQueries","documentOverlays"],gs=ps,ms=[...gs,"indexConfiguration","indexState","indexEntries"];class ys extends Si{constructor(e,t){super(),this.at=e,this.currentSequenceNumber=t}}function _s(e,t){const n=zr(e);return Ni.M(n.at,t)}function vs(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&amp;&amp;t++;return t}function ws(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&amp;&amp;t(n,e[n])}function bs(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class Is{constructor(e,t){this.comparator=e,this.root=t||Ts.EMPTY}insert(e,t){return new Is(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,Ts.BLACK,null,null))}remove(e){return new Is(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Ts.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const n=this.comparator(e,t.key);if(0===n)return t.value;n&lt;0?t=t.left:n&gt;0&amp;&amp;(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){const r=this.comparator(e,n.key);if(0===r)return t+n.left.size;r&lt;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)=&gt;(e(t,n),!1)))}toString(){const e=[];return this.inorderTraversal(((t,n)=&gt;(e.push(`${t}:${n}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Cs(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Cs(this.root,e,this.comparator,!1)}getReverseIterator(){return new Cs(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Cs(this.root,e,this.comparator,!0)}}class Cs{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&amp;&amp;r&amp;&amp;(i*=-1),i&lt;0)e=this.isReverse?e.left:e.right;else{if(0===i){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length&gt;0}peek(){if(0===this.nodeStack.length)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class Ts{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:Ts.RED,this.left=null!=r?r:Ts.EMPTY,this.right=null!=i?i:Ts.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,i){return new Ts(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,n){let r=this;const i=n(e,r.key);return r=i&lt;0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===i?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 Ts.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let n,r=this;if(t(e,r.key)&lt;0)r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(e,t),null);else{if(r.left.isRed()&amp;&amp;(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===t(e,r.key)){if(r.right.isEmpty())return Ts.EMPTY;n=r.right.min(),r=r.copy(n.key,n.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(e,t))}return r.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&amp;&amp;!e.left.isRed()&amp;&amp;(e=e.rotateLeft()),e.left.isRed()&amp;&amp;e.left.left.isRed()&amp;&amp;(e=e.rotateRight()),e.left.isRed()&amp;&amp;e.right.isRed()&amp;&amp;(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&amp;&amp;(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()&amp;&amp;(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,Ts.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,Ts.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)&lt;=this.size+1}check(){if(this.isRed()&amp;&amp;this.left.isRed())throw Br();if(this.right.isRed())throw Br();const e=this.left.check();if(e!==this.right.check())throw Br();return e+(this.isRed()?0:1)}}Ts.EMPTY=null,Ts.RED=!0,Ts.BLACK=!1,Ts.EMPTY=new class{constructor(){this.size=0}get key(){throw Br()}get value(){throw Br()}get color(){throw Br()}get left(){throw Br()}get right(){throw Br()}copy(e,t,n,r,i){return this}insert(e,t,n){return new Ts(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class Es{constructor(e){this.comparator=e,this.data=new Is(this.comparator)}has(e){return null!==this.data.get(e)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal(((t,n)=&gt;(e(t),!1)))}forEachInRange(e,t){const n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){const r=n.getNext();if(this.comparator(r.key,e[1])&gt;=0)return;t(r.key)}}forEachWhile(e,t){let n;for(n=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new Ss(this.data.getIterator())}getIteratorFrom(e){return new Ss(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&lt;e.size&amp;&amp;(t=e,e=this),e.forEach((e=&gt;{t=t.add(e)})),t}isEqual(e){if(!(e instanceof Es))return!1;if(this.size!==e.size)return!1;const t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(0!==this.comparator(e,r))return!1}return!0}toArray(){const e=[];return this.forEach((t=&gt;{e.push(t)})),e}toString(){const e=[];return this.forEach((t=&gt;e.push(t))),"SortedSet("+e.toString()+")"}copy(e){const t=new Es(this.comparator);return t.data=e,t}}class Ss{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function xs(e){return e.hasNext()?e.getNext():void 0}class ks{constructor(e){this.fields=e,e.sort(di.comparator)}static empty(){return new ks([])}unionWith(e){let t=new Es(di.comparator);for(const e of this.fields)t=t.add(e);for(const n of e)t=t.add(n);return new ks(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return si(this.fields,e.fields,((e,t)=&gt;e.isEqual(t)))}}class Ds extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}function Ns(){return"undefined"!=typeof atob}class As{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(e){try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&amp;&amp;e instanceof DOMException?new Ds("Invalid base64 string: "+e):e}}(e);return new As(t)}static fromUint8Array(e){const t=function(e){let t="";for(let n=0;n&lt;e.length;++n)t+=String.fromCharCode(e[n]);return t}(e);return new As(t)}[Symbol.iterator](){let e=0;return{next:()=&gt;e&lt;this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return e=this.binaryString,btoa(e);var e}toUint8Array(){return function(e){const t=new Uint8Array(e.length);for(let n=0;n&lt;e.length;n++)t[n]=e.charCodeAt(n);return t}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return ii(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}As.EMPTY_BYTE_STRING=new As("");const Ps=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Rs(e){if(Ur(!!e),"string"==typeof e){let t=0;const n=Ps.exec(e);if(Ur(!!n),n[1]){let e=n[1];e=(e+"000000000").substr(0,9),t=Number(e)}const r=new Date(e);return{seconds:Math.floor(r.getTime()/1e3),nanos:t}}return{seconds:Ms(e.seconds),nanos:Ms(e.nanos)}}function Ms(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function Fs(e){return"string"==typeof e?As.fromBase64String(e):As.fromUint8Array(e)}function Os(e){var t,n;return"server_timestamp"===(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function Ls(e){const t=e.mapValue.fields.__previous_value__;return Os(t)?Ls(t):t}function qs(e){const t=Rs(e.mapValue.fields.__local_write_time__.timestampValue);return new ai(t.seconds,t.nanos)}class Vs{constructor(e,t,n,r,i,s,o,a){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=o,this.useFetchStreams=a}}class Bs{constructor(e,t){this.projectId=e,this.database=t||"(default)"}static empty(){return new Bs("","")}get isDefaultDatabase(){return"(default)"===this.database}isEqual(e){return e instanceof Bs&amp;&amp;e.projectId===this.projectId&amp;&amp;e.database===this.database}}const Us={mapValue:{fields:{__type__:{stringValue:"__max__"}}}},js={nullValue:"NULL_VALUE"};function zs(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?Os(e)?4:io(e)?9007199254740991:10:Br()}function $s(e,t){if(e===t)return!0;const n=zs(e);if(n!==zs(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return qs(e).isEqual(qs(t));case 3:return function(e,t){if("string"==typeof e.timestampValue&amp;&amp;"string"==typeof t.timestampValue&amp;&amp;e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;const n=Rs(e.timestampValue),r=Rs(t.timestampValue);return n.seconds===r.seconds&amp;&amp;n.nanos===r.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(e,t){return Fs(e.bytesValue).isEqual(Fs(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return Ms(e.geoPointValue.latitude)===Ms(t.geoPointValue.latitude)&amp;&amp;Ms(e.geoPointValue.longitude)===Ms(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if("integerValue"in e&amp;&amp;"integerValue"in t)return Ms(e.integerValue)===Ms(t.integerValue);if("doubleValue"in e&amp;&amp;"doubleValue"in t){const n=Ms(e.doubleValue),r=Ms(t.doubleValue);return n===r?ji(n)===ji(r):isNaN(n)&amp;&amp;isNaN(r)}return!1}(e,t);case 9:return si(e.arrayValue.values||[],t.arrayValue.values||[],$s);case 10:return function(e,t){const n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(vs(n)!==vs(r))return!1;for(const e in n)if(n.hasOwnProperty(e)&amp;&amp;(void 0===r[e]||!$s(n[e],r[e])))return!1;return!0}(e,t);default:return Br()}}function Ks(e,t){return void 0!==(e.values||[]).find((e=&gt;$s(e,t)))}function Gs(e,t){if(e===t)return 0;const n=zs(e),r=zs(t);if(n!==r)return ii(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return ii(e.booleanValue,t.booleanValue);case 2:return function(e,t){const n=Ms(e.integerValue||e.doubleValue),r=Ms(t.integerValue||t.doubleValue);return n&lt;r?-1:n&gt;r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(e,t);case 3:return Ws(e.timestampValue,t.timestampValue);case 4:return Ws(qs(e),qs(t));case 5:return ii(e.stringValue,t.stringValue);case 6:return function(e,t){const n=Fs(e),r=Fs(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){const n=e.split("/"),r=t.split("/");for(let e=0;e&lt;n.length&amp;&amp;e&lt;r.length;e++){const t=ii(n[e],r[e]);if(0!==t)return t}return ii(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){const n=ii(Ms(e.latitude),Ms(t.latitude));return 0!==n?n:ii(Ms(e.longitude),Ms(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return function(e,t){const n=e.values||[],r=t.values||[];for(let e=0;e&lt;n.length&amp;&amp;e&lt;r.length;++e){const t=Gs(n[e],r[e]);if(t)return t}return ii(n.length,r.length)}(e.arrayValue,t.arrayValue);case 10:return function(e,t){if(e===Us.mapValue&amp;&amp;t===Us.mapValue)return 0;if(e===Us.mapValue)return 1;if(t===Us.mapValue)return-1;const n=e.fields||{},r=Object.keys(n),i=t.fields||{},s=Object.keys(i);r.sort(),s.sort();for(let e=0;e&lt;r.length&amp;&amp;e&lt;s.length;++e){const t=ii(r[e],s[e]);if(0!==t)return t;const o=Gs(n[r[e]],i[s[e]]);if(0!==o)return o}return ii(r.length,s.length)}(e.mapValue,t.mapValue);default:throw Br()}}function Ws(e,t){if("string"==typeof e&amp;&amp;"string"==typeof t&amp;&amp;e.length===t.length)return ii(e,t);const n=Rs(e),r=Rs(t),i=ii(n.seconds,r.seconds);return 0!==i?i:ii(n.nanos,r.nanos)}function Hs(e){return Qs(e)}function Qs(e){return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?function(e){const t=Rs(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?Fs(e.bytesValue).toBase64():"referenceValue"in e?(n=e.referenceValue,fi.fromName(n).toString()):"geoPointValue"in e?`geo(${(t=e.geoPointValue).latitude},${t.longitude})`:"arrayValue"in e?function(e){let t="[",n=!0;for(const r of e.values||[])n?n=!1:t+=",",t+=Qs(r);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){const t=Object.keys(e.fields||{}).sort();let n="{",r=!0;for(const i of t)r?r=!1:n+=",",n+=`${i}:${Qs(e.fields[i])}`;return n+"}"}(e.mapValue):Br();var t,n}function Ys(e){switch(zs(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const t=Ls(e);return t?16+Ys(t):16;case 5:return 2*e.stringValue.length;case 6:return Fs(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return(e.arrayValue.values||[]).reduce(((e,t)=&gt;e+Ys(t)),0);case 10:return function(e){let t=0;return ws(e.fields,((e,n)=&gt;{t+=e.length+Ys(n)})),t}(e.mapValue);default:throw Br()}}function Xs(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Js(e){return!!e&amp;&amp;"integerValue"in e}function Zs(e){return!!e&amp;&amp;"arrayValue"in e}function eo(e){return!!e&amp;&amp;"nullValue"in e}function to(e){return!!e&amp;&amp;"doubleValue"in e&amp;&amp;isNaN(Number(e.doubleValue))}function no(e){return!!e&amp;&amp;"mapValue"in e}function ro(e){if(e.geoPointValue)return{geoPointValue:Object.assign({},e.geoPointValue)};if(e.timestampValue&amp;&amp;"object"==typeof e.timestampValue)return{timestampValue:Object.assign({},e.timestampValue)};if(e.mapValue){const t={mapValue:{fields:{}}};return ws(e.mapValue.fields,((e,n)=&gt;t.mapValue.fields[e]=ro(n))),t}if(e.arrayValue){const t={arrayValue:{values:[]}};for(let n=0;n&lt;(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=ro(e.arrayValue.values[n]);return t}return Object.assign({},e)}function io(e){return"__max__"===(((e.mapValue||{}).fields||{}).__type__||{}).stringValue}function so(e){return"nullValue"in e?js:"booleanValue"in e?{booleanValue:!1}:"integerValue"in e||"doubleValue"in e?{doubleValue:NaN}:"timestampValue"in e?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in e?{stringValue:""}:"bytesValue"in e?{bytesValue:""}:"referenceValue"in e?Xs(Bs.empty(),fi.empty()):"geoPointValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in e?{arrayValue:{}}:"mapValue"in e?{mapValue:{}}:Br()}function oo(e){return"nullValue"in e?{booleanValue:!1}:"booleanValue"in e?{doubleValue:NaN}:"integerValue"in e||"doubleValue"in e?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in e?{stringValue:""}:"stringValue"in e?{bytesValue:""}:"bytesValue"in e?Xs(Bs.empty(),fi.empty()):"referenceValue"in e?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in e?{arrayValue:{}}:"arrayValue"in e?{mapValue:{}}:"mapValue"in e?Us:Br()}function ao(e,t){const n=Gs(e.value,t.value);return 0!==n?n:e.inclusive&amp;&amp;!t.inclusive?-1:!e.inclusive&amp;&amp;t.inclusive?1:0}function co(e,t){const n=Gs(e.value,t.value);return 0!==n?n:e.inclusive&amp;&amp;!t.inclusive?1:!e.inclusive&amp;&amp;t.inclusive?-1:0}class uo{constructor(e){this.value=e}static empty(){return new uo({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n&lt;e.length-1;++n)if(t=(t.mapValue.fields||{})[e.get(n)],!no(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=ro(t)}setAll(e){let t=di.emptyPath(),n={},r=[];e.forEach(((e,i)=&gt;{if(!t.isImmediateParentOf(i)){const e=this.getFieldsMap(t);this.applyChanges(e,n,r),n={},r=[],t=i.popLast()}e?n[i.lastSegment()]=ro(e):r.push(i.lastSegment())}));const i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){const t=this.field(e.popLast());no(t)&amp;&amp;t.mapValue.fields&amp;&amp;delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return $s(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n&lt;e.length;++n){let r=t.mapValue.fields[e.get(n)];no(r)&amp;&amp;r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){ws(t,((t,n)=&gt;e[t]=n));for(const t of n)delete e[t]}clone(){return new uo(ro(this.value))}}function lo(e){const t=[];return ws(e.fields,((e,n)=&gt;{const r=new di([e]);if(no(n)){const e=lo(n.mapValue).fields;if(0===e.length)t.push(r);else for(const n of e)t.push(r.child(n))}else t.push(r)})),new ks(t)}class ho{constructor(e,t,n,r,i,s,o){this.key=e,this.documentType=t,this.version=n,this.readTime=r,this.createTime=i,this.data=s,this.documentState=o}static newInvalidDocument(e){return new ho(e,0,ci.min(),ci.min(),ci.min(),uo.empty(),0)}static newFoundDocument(e,t,n,r){return new ho(e,1,t,ci.min(),n,r,0)}static newNoDocument(e,t){return new ho(e,2,t,ci.min(),ci.min(),uo.empty(),0)}static newUnknownDocument(e,t){return new ho(e,3,t,ci.min(),ci.min(),uo.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(ci.min())||2!==this.documentType&amp;&amp;0!==this.documentType||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=uo.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=uo.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=ci.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(e){return e instanceof ho&amp;&amp;this.key.isEqual(e.key)&amp;&amp;this.version.isEqual(e.version)&amp;&amp;this.documentType===e.documentType&amp;&amp;this.documentState===e.documentState&amp;&amp;this.data.isEqual(e.data)}mutableCopy(){return new ho(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}class fo{constructor(e,t){this.position=e,this.inclusive=t}}function po(e,t,n){let r=0;for(let i=0;i&lt;e.position.length;i++){const s=t[i],o=e.position[i];if(r=s.field.isKeyField()?fi.comparator(fi.fromName(o.referenceValue),n.key):Gs(o,n.data.field(s.field)),"desc"===s.dir&amp;&amp;(r*=-1),0!==r)break}return r}function go(e,t){if(null===e)return null===t;if(null===t)return!1;if(e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n&lt;e.position.length;n++)if(!$s(e.position[n],t.position[n]))return!1;return!0}class mo{constructor(e,t="asc"){this.field=e,this.dir=t}}function yo(e,t){return e.dir===t.dir&amp;&amp;e.field.isEqual(t.field)}class _o{}class vo extends _o{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(e,t,n){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,n):new Do(e,t,n):"array-contains"===t?new Ro(e,n):"in"===t?new Mo(e,n):"not-in"===t?new Fo(e,n):"array-contains-any"===t?new Oo(e,n):new vo(e,t,n)}static createKeyFieldInFilter(e,t,n){return"in"===t?new No(e,n):new Ao(e,n)}matches(e){const t=e.data.field(this.field);return"!="===this.op?null!==t&amp;&amp;this.matchesComparison(Gs(t,this.value)):null!==t&amp;&amp;zs(this.value)===zs(t)&amp;&amp;this.matchesComparison(Gs(t,this.value))}matchesComparison(e){switch(this.op){case"&lt;":return e&lt;0;case"&lt;=":return e&lt;=0;case"==":return 0===e;case"!=":return 0!==e;case"&gt;":return e&gt;0;case"&gt;=":return e&gt;=0;default:return Br()}}isInequality(){return["&lt;","&lt;=","&gt;","&gt;=","!=","not-in"].indexOf(this.op)&gt;=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}getFirstInequalityField(){return this.isInequality()?this.field:null}}class wo extends _o{constructor(e,t){super(),this.filters=e,this.op=t,this.ht=null}static create(e,t){return new wo(e,t)}matches(e){return bo(this)?void 0===this.filters.find((t=&gt;!t.matches(e))):void 0!==this.filters.find((t=&gt;t.matches(e)))}getFlattenedFilters(){return null!==this.ht||(this.ht=this.filters.reduce(((e,t)=&gt;e.concat(t.getFlattenedFilters())),[])),this.ht}getFilters(){return Object.assign([],this.filters)}getFirstInequalityField(){const e=this.lt((e=&gt;e.isInequality()));return null!==e?e.field:null}lt(e){for(const t of this.getFlattenedFilters())if(e(t))return t;return null}}function bo(e){return"and"===e.op}function Io(e){return"or"===e.op}function Co(e){return To(e)&amp;&amp;bo(e)}function To(e){for(const t of e.filters)if(t instanceof wo)return!1;return!0}function Eo(e){if(e instanceof vo)return e.field.canonicalString()+e.op.toString()+Hs(e.value);if(Co(e))return e.filters.map((e=&gt;Eo(e))).join(",");{const t=e.filters.map((e=&gt;Eo(e))).join(",");return`${e.op}(${t})`}}function So(e,t){return e instanceof vo?function(e,t){return t instanceof vo&amp;&amp;e.op===t.op&amp;&amp;e.field.isEqual(t.field)&amp;&amp;$s(e.value,t.value)}(e,t):e instanceof wo?function(e,t){return t instanceof wo&amp;&amp;e.op===t.op&amp;&amp;e.filters.length===t.filters.length&amp;&amp;e.filters.reduce(((e,n,r)=&gt;e&amp;&amp;So(n,t.filters[r])),!0)}(e,t):void Br()}function xo(e,t){const n=e.filters.concat(t);return wo.create(n,e.op)}function ko(e){return e instanceof vo?function(e){return`${e.field.canonicalString()} ${e.op} ${Hs(e.value)}`}(e):e instanceof wo?function(e){return e.op.toString()+" {"+e.getFilters().map(ko).join(" ,")+"}"}(e):"Filter"}class Do extends vo{constructor(e,t,n){super(e,t,n),this.key=fi.fromName(n.referenceValue)}matches(e){const t=fi.comparator(e.key,this.key);return this.matchesComparison(t)}}class No extends vo{constructor(e,t){super(e,"in",t),this.keys=Po(0,t)}matches(e){return this.keys.some((t=&gt;t.isEqual(e.key)))}}class Ao extends vo{constructor(e,t){super(e,"not-in",t),this.keys=Po(0,t)}matches(e){return!this.keys.some((t=&gt;t.isEqual(e.key)))}}function Po(e,t){var n;return((null===(n=t.arrayValue)||void 0===n?void 0:n.values)||[]).map((e=&gt;fi.fromName(e.referenceValue)))}class Ro extends vo{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Zs(t)&amp;&amp;Ks(t.arrayValue,this.value)}}class Mo extends vo{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return null!==t&amp;&amp;Ks(this.value.arrayValue,t)}}class Fo extends vo{constructor(e,t){super(e,"not-in",t)}matches(e){if(Ks(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return null!==t&amp;&amp;!Ks(this.value.arrayValue,t)}}class Oo extends vo{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Zs(t)||!t.arrayValue.values)&amp;&amp;t.arrayValue.values.some((e=&gt;Ks(this.value.arrayValue,e)))}}class Lo{constructor(e,t=null,n=[],r=[],i=null,s=null,o=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=s,this.endAt=o,this.ft=null}}function qo(e,t=null,n=[],r=[],i=null,s=null,o=null){return new Lo(e,t,n,r,i,s,o)}function Vo(e){const t=zr(e);if(null===t.ft){let e=t.path.canonicalString();null!==t.collectionGroup&amp;&amp;(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map((e=&gt;Eo(e))).join(","),e+="|ob:",e+=t.orderBy.map((e=&gt;function(e){return e.field.canonicalString()+e.dir}(e))).join(","),Ui(t.limit)||(e+="|l:",e+=t.limit),t.startAt&amp;&amp;(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map((e=&gt;Hs(e))).join(",")),t.endAt&amp;&amp;(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map((e=&gt;Hs(e))).join(",")),t.ft=e}return t.ft}function Bo(e,t){if(e.limit!==t.limit)return!1;if(e.orderBy.length!==t.orderBy.length)return!1;for(let n=0;n&lt;e.orderBy.length;n++)if(!yo(e.orderBy[n],t.orderBy[n]))return!1;if(e.filters.length!==t.filters.length)return!1;for(let n=0;n&lt;e.filters.length;n++)if(!So(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&amp;&amp;!!e.path.isEqual(t.path)&amp;&amp;!!go(e.startAt,t.startAt)&amp;&amp;go(e.endAt,t.endAt)}function Uo(e){return fi.isDocumentKey(e.path)&amp;&amp;null===e.collectionGroup&amp;&amp;0===e.filters.length}function jo(e,t){return e.filters.filter((e=&gt;e instanceof vo&amp;&amp;e.field.isEqual(t)))}function zo(e,t,n){let r=js,i=!0;for(const n of jo(e,t)){let e=js,t=!0;switch(n.op){case"&lt;":case"&lt;=":e=so(n.value);break;case"==":case"in":case"&gt;=":e=n.value;break;case"&gt;":e=n.value,t=!1;break;case"!=":case"not-in":e=js}ao({value:r,inclusive:i},{value:e,inclusive:t})&lt;0&amp;&amp;(r=e,i=t)}if(null!==n)for(let s=0;s&lt;e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){const e=n.position[s];ao({value:r,inclusive:i},{value:e,inclusive:n.inclusive})&lt;0&amp;&amp;(r=e,i=n.inclusive);break}return{value:r,inclusive:i}}function $o(e,t,n){let r=Us,i=!0;for(const n of jo(e,t)){let e=Us,t=!0;switch(n.op){case"&gt;=":case"&gt;":e=oo(n.value),t=!1;break;case"==":case"in":case"&lt;=":e=n.value;break;case"&lt;":e=n.value,t=!1;break;case"!=":case"not-in":e=Us}co({value:r,inclusive:i},{value:e,inclusive:t})&gt;0&amp;&amp;(r=e,i=t)}if(null!==n)for(let s=0;s&lt;e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){const e=n.position[s];co({value:r,inclusive:i},{value:e,inclusive:n.inclusive})&gt;0&amp;&amp;(r=e,i=n.inclusive);break}return{value:r,inclusive:i}}class Ko{constructor(e,t=null,n=[],r=[],i=null,s="F",o=null,a=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=s,this.startAt=o,this.endAt=a,this.dt=null,this._t=null,this.startAt,this.endAt}}function Go(e,t,n,r,i,s,o,a){return new Ko(e,t,n,r,i,s,o,a)}function Wo(e){return new Ko(e)}function Ho(e){return 0===e.filters.length&amp;&amp;null===e.limit&amp;&amp;null==e.startAt&amp;&amp;null==e.endAt&amp;&amp;(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&amp;&amp;e.explicitOrderBy[0].field.isKeyField())}function Qo(e){return e.explicitOrderBy.length&gt;0?e.explicitOrderBy[0].field:null}function Yo(e){for(const t of e.filters){const e=t.getFirstInequalityField();if(null!==e)return e}return null}function Xo(e){return null!==e.collectionGroup}function Jo(e){const t=zr(e);if(null===t.dt){t.dt=[];const e=Yo(t),n=Qo(t);if(null!==e&amp;&amp;null===n)e.isKeyField()||t.dt.push(new mo(e)),t.dt.push(new mo(di.keyField(),"asc"));else{let e=!1;for(const n of t.explicitOrderBy)t.dt.push(n),n.field.isKeyField()&amp;&amp;(e=!0);if(!e){const e=t.explicitOrderBy.length&gt;0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";t.dt.push(new mo(di.keyField(),e))}}}return t.dt}function Zo(e){const t=zr(e);if(!t._t)if("F"===t.limitType)t._t=qo(t.path,t.collectionGroup,Jo(t),t.filters,t.limit,t.startAt,t.endAt);else{const e=[];for(const n of Jo(t)){const t="desc"===n.dir?"asc":"desc";e.push(new mo(n.field,t))}const n=t.endAt?new fo(t.endAt.position,t.endAt.inclusive):null,r=t.startAt?new fo(t.startAt.position,t.startAt.inclusive):null;t._t=qo(t.path,t.collectionGroup,e,t.filters,t.limit,n,r)}return t._t}function ea(e,t){t.getFirstInequalityField(),Yo(e);const n=e.filters.concat([t]);return new Ko(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function ta(e,t,n){return new Ko(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function na(e,t){return Bo(Zo(e),Zo(t))&amp;&amp;e.limitType===t.limitType}function ra(e){return`${Vo(Zo(e))}|lt:${e.limitType}`}function ia(e){return`Query(target=${function(e){let t=e.path.canonicalString();return null!==e.collectionGroup&amp;&amp;(t+=" collectionGroup="+e.collectionGroup),e.filters.length&gt;0&amp;&amp;(t+=`, filters: [${e.filters.map((e=&gt;ko(e))).join(", ")}]`),Ui(e.limit)||(t+=", limit: "+e.limit),e.orderBy.length&gt;0&amp;&amp;(t+=`, orderBy: [${e.orderBy.map((e=&gt;function(e){return`${e.field.canonicalString()} (${e.dir})`}(e))).join(", ")}]`),e.startAt&amp;&amp;(t+=", startAt: ",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map((e=&gt;Hs(e))).join(",")),e.endAt&amp;&amp;(t+=", endAt: ",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map((e=&gt;Hs(e))).join(",")),`Target(${t})`}(Zo(e))}; limitType=${e.limitType})`}function sa(e,t){return t.isFoundDocument()&amp;&amp;function(e,t){const n=t.key.path;return null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&amp;&amp;e.path.isPrefixOf(n):fi.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n)}(e,t)&amp;&amp;function(e,t){for(const n of Jo(e))if(!n.field.isKeyField()&amp;&amp;null===t.data.field(n.field))return!1;return!0}(e,t)&amp;&amp;function(e,t){for(const n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&amp;&amp;function(e,t){return!(e.startAt&amp;&amp;!function(e,t,n){const r=po(e,t,n);return e.inclusive?r&lt;=0:r&lt;0}(e.startAt,Jo(e),t)||e.endAt&amp;&amp;!function(e,t,n){const r=po(e,t,n);return e.inclusive?r&gt;=0:r&gt;0}(e.endAt,Jo(e),t))}(e,t)}function oa(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function aa(e){return(t,n)=&gt;{let r=!1;for(const i of Jo(e)){const e=ca(i,t,n);if(0!==e)return e;r=r||i.field.isKeyField()}return 0}}function ca(e,t,n){const r=e.field.isKeyField()?fi.comparator(t.key,n.key):function(e,t,n){const r=t.data.field(e),i=n.data.field(e);return null!==r&amp;&amp;null!==i?Gs(r,i):Br()}(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return-1*r;default:return Br()}}class ua{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0!==n)for(const[t,r]of n)if(this.equalsFn(t,e))return r}has(e){return void 0!==this.get(e)}set(e,t){const n=this.mapKeyFn(e),r=this.inner[n];if(void 0===r)return this.inner[n]=[[e,t]],void this.innerSize++;for(let n=0;n&lt;r.length;n++)if(this.equalsFn(r[n][0],e))return void(r[n]=[e,t]);r.push([e,t]),this.innerSize++}delete(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0===n)return!1;for(let r=0;r&lt;n.length;r++)if(this.equalsFn(n[r][0],e))return 1===n.length?delete this.inner[t]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(e){ws(this.inner,((t,n)=&gt;{for(const[t,r]of n)e(t,r)}))}isEmpty(){return bs(this.inner)}size(){return this.innerSize}}const la=new Is(fi.comparator);function ha(){return la}const da=new Is(fi.comparator);function fa(...e){let t=da;for(const n of e)t=t.insert(n.key,n);return t}function pa(e){let t=da;return e.forEach(((e,n)=&gt;t=t.insert(e,n.overlayedDocument))),t}function ga(){return ya()}function ma(){return ya()}function ya(){return new ua((e=&gt;e.toString()),((e,t)=&gt;e.isEqual(t)))}const _a=new Is(fi.comparator),va=new Es(fi.comparator);function wa(...e){let t=va;for(const n of e)t=t.add(n);return t}const ba=new Es(ii);function Ia(){return ba}function Ca(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:ji(t)?"-0":t}}function Ta(e){return{integerValue:""+e}}function Ea(e,t){return zi(t)?Ta(t):Ca(e,t)}class Sa{constructor(){this._=void 0}}function xa(e,t,n){return e instanceof Na?function(e,t){const n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&amp;&amp;Os(t)&amp;&amp;(t=Ls(t)),t&amp;&amp;(n.fields.__previous_value__=t),{mapValue:n}}(n,t):e instanceof Aa?Pa(e,t):e instanceof Ra?Ma(e,t):function(e,t){const n=Da(e,t),r=Oa(n)+Oa(e.wt);return Js(n)&amp;&amp;Js(e.wt)?Ta(r):Ca(e.serializer,r)}(e,t)}function ka(e,t,n){return e instanceof Aa?Pa(e,t):e instanceof Ra?Ma(e,t):n}function Da(e,t){return e instanceof Fa?Js(n=t)||function(e){return!!e&amp;&amp;"doubleValue"in e}(n)?t:{integerValue:0}:null;var n}class Na extends Sa{}class Aa extends Sa{constructor(e){super(),this.elements=e}}function Pa(e,t){const n=La(t);for(const t of e.elements)n.some((e=&gt;$s(e,t)))||n.push(t);return{arrayValue:{values:n}}}class Ra extends Sa{constructor(e){super(),this.elements=e}}function Ma(e,t){let n=La(t);for(const t of e.elements)n=n.filter((e=&gt;!$s(e,t)));return{arrayValue:{values:n}}}class Fa extends Sa{constructor(e,t){super(),this.serializer=e,this.wt=t}}function Oa(e){return Ms(e.integerValue||e.doubleValue)}function La(e){return Zs(e)&amp;&amp;e.arrayValue.values?e.arrayValue.values.slice():[]}class qa{constructor(e,t){this.field=e,this.transform=t}}class Va{constructor(e,t){this.version=e,this.transformResults=t}}class Ba{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new Ba}static exists(e){return new Ba(void 0,e)}static updateTime(e){return new Ba(e)}get isNone(){return void 0===this.updateTime&amp;&amp;void 0===this.exists}isEqual(e){return this.exists===e.exists&amp;&amp;(this.updateTime?!!e.updateTime&amp;&amp;this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function Ua(e,t){return void 0!==e.updateTime?t.isFoundDocument()&amp;&amp;t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class ja{}function za(e,t){if(!e.hasLocalMutations||t&amp;&amp;0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new Za(e.key,Ba.none()):new Ha(e.key,e.data,Ba.none());{const n=e.data,r=uo.empty();let i=new Es(di.comparator);for(let e of t.fields)if(!i.has(e)){let t=n.field(e);null===t&amp;&amp;e.length&gt;1&amp;&amp;(e=e.popLast(),t=n.field(e)),null===t?r.delete(e):r.set(e,t),i=i.add(e)}return new Qa(e.key,r,new ks(i.toArray()),Ba.none())}}function $a(e,t,n){e instanceof Ha?function(e,t,n){const r=e.value.clone(),i=Xa(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof Qa?function(e,t,n){if(!Ua(e.precondition,t))return void t.convertToUnknownDocument(n.version);const r=Xa(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(Ya(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 Ka(e,t,n,r){return e instanceof Ha?function(e,t,n,r){if(!Ua(e.precondition,t))return n;const i=e.value.clone(),s=Ja(e.fieldTransforms,r,t);return i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof Qa?function(e,t,n,r){if(!Ua(e.precondition,t))return n;const i=Ja(e.fieldTransforms,r,t),s=t.data;return s.setAll(Ya(e)),s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null===n?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map((e=&gt;e.field)))}(e,t,n,r):function(e,t,n){return Ua(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function Ga(e,t){let n=null;for(const r of e.fieldTransforms){const e=t.data.field(r.field),i=Da(r.transform,e||null);null!=i&amp;&amp;(null===n&amp;&amp;(n=uo.empty()),n.set(r.field,i))}return n||null}function Wa(e,t){return e.type===t.type&amp;&amp;!!e.key.isEqual(t.key)&amp;&amp;!!e.precondition.isEqual(t.precondition)&amp;&amp;!!function(e,t){return void 0===e&amp;&amp;void 0===t||!(!e||!t)&amp;&amp;si(e,t,((e,t)=&gt;function(e,t){return e.field.isEqual(t.field)&amp;&amp;function(e,t){return e instanceof Aa&amp;&amp;t instanceof Aa||e instanceof Ra&amp;&amp;t instanceof Ra?si(e.elements,t.elements,$s):e instanceof Fa&amp;&amp;t instanceof Fa?$s(e.wt,t.wt):e instanceof Na&amp;&amp;t instanceof Na}(e.transform,t.transform)}(e,t)))}(e.fieldTransforms,t.fieldTransforms)&amp;&amp;(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&amp;&amp;e.fieldMask.isEqual(t.fieldMask))}class Ha extends ja{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class Qa extends ja{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 Ya(e){const t=new Map;return e.fieldMask.fields.forEach((n=&gt;{if(!n.isEmpty()){const r=e.data.field(n);t.set(n,r)}})),t}function Xa(e,t,n){const r=new Map;Ur(e.length===n.length);for(let i=0;i&lt;n.length;i++){const s=e[i],o=s.transform,a=t.data.field(s.field);r.set(s.field,ka(o,a,n[i]))}return r}function Ja(e,t,n){const r=new Map;for(const i of e){const e=i.transform,s=n.data.field(i.field);r.set(i.field,xa(e,s,t))}return r}class Za extends ja{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class ec extends ja{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class tc{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){const n=t.mutationResults;for(let t=0;t&lt;this.mutations.length;t++){const r=this.mutations[t];r.key.isEqual(e.key)&amp;&amp;$a(r,e,n[t])}}applyToLocalView(e,t){for(const n of this.baseMutations)n.key.isEqual(e.key)&amp;&amp;(t=Ka(n,e,t,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(e.key)&amp;&amp;(t=Ka(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const n=ma();return this.mutations.forEach((r=&gt;{const i=e.get(r.key),s=i.overlayedDocument;let o=this.applyToLocalView(s,i.mutatedFields);o=t.has(r.key)?null:o;const a=za(s,o);null!==a&amp;&amp;n.set(r.key,a),s.isValidDocument()||s.convertToNoDocument(ci.min())})),n}keys(){return this.mutations.reduce(((e,t)=&gt;e.add(t.key)),wa())}isEqual(e){return this.batchId===e.batchId&amp;&amp;si(this.mutations,e.mutations,((e,t)=&gt;Wa(e,t)))&amp;&amp;si(this.baseMutations,e.baseMutations,((e,t)=&gt;Wa(e,t)))}}class nc{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){Ur(e.mutations.length===n.length);let r=_a;const i=e.mutations;for(let e=0;e&lt;i.length;e++)r=r.insert(i[e].key,n[e].version);return new nc(e,t,n,r)}}class rc{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return null!==e&amp;&amp;this.mutation===e.mutation}toString(){return`Overlay{\n      largestBatchId: ${this.largestBatchId},\n      mutation: ${this.mutation.toString()}\n    }`}}class ic{constructor(e,t,n){this.alias=e,this.gt=t,this.fieldPath=n}}class sc{constructor(e,t){this.count=e,this.unchangedNames=t}}var oc,ac;function cc(e){switch(e){default:return Br();case $r.CANCELLED:case $r.UNKNOWN:case $r.DEADLINE_EXCEEDED:case $r.RESOURCE_EXHAUSTED:case $r.INTERNAL:case $r.UNAVAILABLE:case $r.UNAUTHENTICATED:return!1;case $r.INVALID_ARGUMENT:case $r.NOT_FOUND:case $r.ALREADY_EXISTS:case $r.PERMISSION_DENIED:case $r.FAILED_PRECONDITION:case $r.ABORTED:case $r.OUT_OF_RANGE:case $r.UNIMPLEMENTED:case $r.DATA_LOSS:return!0}}function uc(e){if(void 0===e)return Lr("GRPC error has no .code"),$r.UNKNOWN;switch(e){case oc.OK:return $r.OK;case oc.CANCELLED:return $r.CANCELLED;case oc.UNKNOWN:return $r.UNKNOWN;case oc.DEADLINE_EXCEEDED:return $r.DEADLINE_EXCEEDED;case oc.RESOURCE_EXHAUSTED:return $r.RESOURCE_EXHAUSTED;case oc.INTERNAL:return $r.INTERNAL;case oc.UNAVAILABLE:return $r.UNAVAILABLE;case oc.UNAUTHENTICATED:return $r.UNAUTHENTICATED;case oc.INVALID_ARGUMENT:return $r.INVALID_ARGUMENT;case oc.NOT_FOUND:return $r.NOT_FOUND;case oc.ALREADY_EXISTS:return $r.ALREADY_EXISTS;case oc.PERMISSION_DENIED:return $r.PERMISSION_DENIED;case oc.FAILED_PRECONDITION:return $r.FAILED_PRECONDITION;case oc.ABORTED:return $r.ABORTED;case oc.OUT_OF_RANGE:return $r.OUT_OF_RANGE;case oc.UNIMPLEMENTED:return $r.UNIMPLEMENTED;case oc.DATA_LOSS:return $r.DATA_LOSS;default:return Br()}}(ac=oc||(oc={}))[ac.OK=0]="OK",ac[ac.CANCELLED=1]="CANCELLED",ac[ac.UNKNOWN=2]="UNKNOWN",ac[ac.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",ac[ac.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",ac[ac.NOT_FOUND=5]="NOT_FOUND",ac[ac.ALREADY_EXISTS=6]="ALREADY_EXISTS",ac[ac.PERMISSION_DENIED=7]="PERMISSION_DENIED",ac[ac.UNAUTHENTICATED=16]="UNAUTHENTICATED",ac[ac.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",ac[ac.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",ac[ac.ABORTED=10]="ABORTED",ac[ac.OUT_OF_RANGE=11]="OUT_OF_RANGE",ac[ac.UNIMPLEMENTED=12]="UNIMPLEMENTED",ac[ac.INTERNAL=13]="INTERNAL",ac[ac.UNAVAILABLE=14]="UNAVAILABLE",ac[ac.DATA_LOSS=15]="DATA_LOSS";class lc{constructor(){this.onExistenceFilterMismatchCallbacks=new Map}static get instance(){return hc}static getOrCreateInstance(){return null===hc&amp;&amp;(hc=new lc),hc}onExistenceFilterMismatch(e){const t=Symbol();return this.onExistenceFilterMismatchCallbacks.set(t,e),()=&gt;this.onExistenceFilterMismatchCallbacks.delete(t)}notifyOnExistenceFilterMismatch(e){this.onExistenceFilterMismatchCallbacks.forEach((t=&gt;t(e)))}}let hc=null;function dc(){return new TextEncoder}const fc=new Dr([4294967295,4294967295],0);function pc(e){const t=dc().encode(e),n=new kr;return n.update(t),new Uint8Array(n.digest())}function gc(e){const t=new DataView(e.buffer),n=t.getUint32(0,!0),r=t.getUint32(4,!0),i=t.getUint32(8,!0),s=t.getUint32(12,!0);return[new Dr([n,r],0),new Dr([i,s],0)]}class mc{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t&lt;0||t&gt;=8)throw new yc(`Invalid padding: ${t}`);if(n&lt;0)throw new yc(`Invalid hash count: ${n}`);if(e.length&gt;0&amp;&amp;0===this.hashCount)throw new yc(`Invalid hash count: ${n}`);if(0===e.length&amp;&amp;0!==t)throw new yc(`Invalid padding when bitmap length is 0: ${t}`);this.yt=8*e.length-t,this.It=Dr.fromNumber(this.yt)}Tt(e,t,n){let r=e.add(t.multiply(Dr.fromNumber(n)));return 1===r.compare(fc)&amp;&amp;(r=new Dr([r.getBits(0),r.getBits(1)],0)),r.modulo(this.It).toNumber()}Et(e){return 0!=(this.bitmap[Math.floor(e/8)]&amp;1&lt;&lt;e%8)}At(e){if(0===this.yt)return!1;const t=pc(e),[n,r]=gc(t);for(let e=0;e&lt;this.hashCount;e++){const t=this.Tt(n,r,e);if(!this.Et(t))return!1}return!0}static create(e,t,n){const r=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),s=new mc(i,r,t);return n.forEach((e=&gt;s.insert(e))),s}insert(e){if(0===this.yt)return;const t=pc(e),[n,r]=gc(t);for(let e=0;e&lt;this.hashCount;e++){const t=this.Tt(n,r,e);this.Rt(t)}}Rt(e){const t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1&lt;&lt;n}}class yc extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class _c{constructor(e,t,n,r,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,n){const r=new Map;return r.set(e,vc.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new _c(ci.min(),r,new Is(ii),ha(),wa())}}class vc{constructor(e,t,n,r,i){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new vc(n,t,wa(),wa(),wa())}}class wc{constructor(e,t,n,r){this.vt=e,this.removedTargetIds=t,this.key=n,this.Pt=r}}class bc{constructor(e,t){this.targetId=e,this.bt=t}}class Ic{constructor(e,t,n=As.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class Cc{constructor(){this.Vt=0,this.St=Sc(),this.Dt=As.EMPTY_BYTE_STRING,this.Ct=!1,this.xt=!0}get current(){return this.Ct}get resumeToken(){return this.Dt}get Nt(){return 0!==this.Vt}get kt(){return this.xt}Mt(e){e.approximateByteSize()&gt;0&amp;&amp;(this.xt=!0,this.Dt=e)}Ot(){let e=wa(),t=wa(),n=wa();return this.St.forEach(((r,i)=&gt;{switch(i){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:Br()}})),new vc(this.Dt,this.Ct,e,t,n)}$t(){this.xt=!1,this.St=Sc()}Ft(e,t){this.xt=!0,this.St=this.St.insert(e,t)}Bt(e){this.xt=!0,this.St=this.St.remove(e)}Lt(){this.Vt+=1}qt(){this.Vt-=1}Ut(){this.xt=!0,this.Ct=!0}}class Tc{constructor(e){this.Kt=e,this.Gt=new Map,this.Qt=ha(),this.jt=Ec(),this.zt=new Is(ii)}Wt(e){for(const t of e.vt)e.Pt&amp;&amp;e.Pt.isFoundDocument()?this.Ht(t,e.Pt):this.Jt(t,e.key,e.Pt);for(const t of e.removedTargetIds)this.Jt(t,e.key,e.Pt)}Yt(e){this.forEachTarget(e,(t=&gt;{const n=this.Xt(t);switch(e.state){case 0:this.Zt(t)&amp;&amp;n.Mt(e.resumeToken);break;case 1:n.qt(),n.Nt||n.$t(),n.Mt(e.resumeToken);break;case 2:n.qt(),n.Nt||this.removeTarget(t);break;case 3:this.Zt(t)&amp;&amp;(n.Ut(),n.Mt(e.resumeToken));break;case 4:this.Zt(t)&amp;&amp;(this.te(t),n.Mt(e.resumeToken));break;default:Br()}}))}forEachTarget(e,t){e.targetIds.length&gt;0?e.targetIds.forEach(t):this.Gt.forEach(((e,n)=&gt;{this.Zt(n)&amp;&amp;t(n)}))}ee(e){var t;const n=e.targetId,r=e.bt.count,i=this.ne(n);if(i){const s=i.target;if(Uo(s))if(0===r){const e=new fi(s.path);this.Jt(n,e,ho.newNoDocument(e,ci.min()))}else Ur(1===r);else{const i=this.se(n);if(i!==r){const r=this.ie(e,i);if(0!==r){this.te(n);const e=2===r?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.zt=this.zt.insert(n,e)}null===(t=lc.instance)||void 0===t||t.notifyOnExistenceFilterMismatch(function(e,t,n){var r,i,s,o,a,c;const u={localCacheCount:t,existenceFilterCount:n.count},l=n.unchangedNames;return l&amp;&amp;(u.bloomFilter={applied:0===e,hashCount:null!==(r=null==l?void 0:l.hashCount)&amp;&amp;void 0!==r?r:0,bitmapLength:null!==(o=null===(s=null===(i=null==l?void 0:l.bits)||void 0===i?void 0:i.bitmap)||void 0===s?void 0:s.length)&amp;&amp;void 0!==o?o:0,padding:null!==(c=null===(a=null==l?void 0:l.bits)||void 0===a?void 0:a.padding)&amp;&amp;void 0!==c?c:0}),u}(r,i,e.bt))}}}}ie(e,t){const{unchangedNames:n,count:r}=e.bt;if(!n||!n.bits)return 1;const{bits:{bitmap:i="",padding:s=0},hashCount:o=0}=n;let a,c;try{a=Fs(i).toUint8Array()}catch(e){if(e instanceof Ds)return qr("Decoding the base64 bloom filter in existence filter failed ("+e.message+"); ignoring the bloom filter and falling back to full re-query."),1;throw e}try{c=new mc(a,s,o)}catch(e){return qr(e instanceof yc?"BloomFilter error: ":"Applying bloom filter failed: ",e),1}return 0===c.yt?1:r!==t-this.re(e.targetId,c)?2:0}re(e,t){const n=this.Kt.getRemoteKeysForTarget(e);let r=0;return n.forEach((n=&gt;{const i=this.Kt.oe(),s=`projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;t.At(s)||(this.Jt(e,n,null),r++)})),r}ue(e){const t=new Map;this.Gt.forEach(((n,r)=&gt;{const i=this.ne(r);if(i){if(n.current&amp;&amp;Uo(i.target)){const t=new fi(i.target.path);null!==this.Qt.get(t)||this.ce(r,t)||this.Jt(r,t,ho.newNoDocument(t,e))}n.kt&amp;&amp;(t.set(r,n.Ot()),n.$t())}}));let n=wa();this.jt.forEach(((e,t)=&gt;{let r=!0;t.forEachWhile((e=&gt;{const t=this.ne(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(r=!1,!1)})),r&amp;&amp;(n=n.add(e))})),this.Qt.forEach(((t,n)=&gt;n.setReadTime(e)));const r=new _c(e,t,this.zt,this.Qt,n);return this.Qt=ha(),this.jt=Ec(),this.zt=new Is(ii),r}Ht(e,t){if(!this.Zt(e))return;const n=this.ce(e,t.key)?2:0;this.Xt(e).Ft(t.key,n),this.Qt=this.Qt.insert(t.key,t),this.jt=this.jt.insert(t.key,this.ae(t.key).add(e))}Jt(e,t,n){if(!this.Zt(e))return;const r=this.Xt(e);this.ce(e,t)?r.Ft(t,1):r.Bt(t),this.jt=this.jt.insert(t,this.ae(t).delete(e)),n&amp;&amp;(this.Qt=this.Qt.insert(t,n))}removeTarget(e){this.Gt.delete(e)}se(e){const t=this.Xt(e).Ot();return this.Kt.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Lt(e){this.Xt(e).Lt()}Xt(e){let t=this.Gt.get(e);return t||(t=new Cc,this.Gt.set(e,t)),t}ae(e){let t=this.jt.get(e);return t||(t=new Es(ii),this.jt=this.jt.insert(e,t)),t}Zt(e){const t=null!==this.ne(e);return t||Or("WatchChangeAggregator","Detected inactive target",e),t}ne(e){const t=this.Gt.get(e);return t&amp;&amp;t.Nt?null:this.Kt.he(e)}te(e){this.Gt.set(e,new Cc),this.Kt.getRemoteKeysForTarget(e).forEach((t=&gt;{this.Jt(e,t,null)}))}ce(e,t){return this.Kt.getRemoteKeysForTarget(e).has(t)}}function Ec(){return new Is(fi.comparator)}function Sc(){return new Is(fi.comparator)}const xc={asc:"ASCENDING",desc:"DESCENDING"},kc={"&lt;":"LESS_THAN","&lt;=":"LESS_THAN_OR_EQUAL","&gt;":"GREATER_THAN","&gt;=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},Dc={and:"AND",or:"OR"};class Nc{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function Ac(e,t){return e.useProto3Json||Ui(t)?t:{value:t}}function Pc(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 Rc(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function Mc(e,t){return Pc(e,t.toTimestamp())}function Fc(e){return Ur(!!e),ci.fromTimestamp(function(e){const t=Rs(e);return new ai(t.seconds,t.nanos)}(e))}function Oc(e,t){return function(e){return new li(["projects",e.projectId,"databases",e.database])}(e).child("documents").child(t).canonicalString()}function Lc(e){const t=li.fromString(e);return Ur(su(t)),t}function qc(e,t){return Oc(e.databaseId,t.path)}function Vc(e,t){const n=Lc(t);if(n.get(1)!==e.databaseId.projectId)throw new Kr($r.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 Kr($r.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new fi(zc(n))}function Bc(e,t){return Oc(e.databaseId,t)}function Uc(e){const t=Lc(e);return 4===t.length?li.emptyPath():zc(t)}function jc(e){return new li(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function zc(e){return Ur(e.length&gt;4&amp;&amp;"documents"===e.get(4)),e.popFirst(5)}function $c(e,t,n){return{name:qc(e,t),fields:n.value.mapValue.fields}}function Kc(e,t,n){const r=Vc(e,t.name),i=Fc(t.updateTime),s=t.createTime?Fc(t.createTime):ci.min(),o=new uo({mapValue:{fields:t.fields}}),a=ho.newFoundDocument(r,i,s,o);return n&amp;&amp;a.setHasCommittedMutations(),n?a.setHasCommittedMutations():a}function Gc(e,t){let n;if(t instanceof Ha)n={update:$c(e,t.key,t.value)};else if(t instanceof Za)n={delete:qc(e,t.key)};else if(t instanceof Qa)n={update:$c(e,t.key,t.data),updateMask:iu(t.fieldMask)};else{if(!(t instanceof ec))return Br();n={verify:qc(e,t.key)}}return t.fieldTransforms.length&gt;0&amp;&amp;(n.updateTransforms=t.fieldTransforms.map((e=&gt;function(e,t){const n=t.transform;if(n instanceof Na)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof Aa)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof Ra)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof Fa)return{fieldPath:t.field.canonicalString(),increment:n.wt};throw Br()}(0,e)))),t.precondition.isNone||(n.currentDocument=function(e,t){return void 0!==t.updateTime?{updateTime:Mc(e,t.updateTime)}:void 0!==t.exists?{exists:t.exists}:Br()}(e,t.precondition)),n}function Wc(e,t){const n=t.currentDocument?function(e){return void 0!==e.updateTime?Ba.updateTime(Fc(e.updateTime)):void 0!==e.exists?Ba.exists(e.exists):Ba.none()}(t.currentDocument):Ba.none(),r=t.updateTransforms?t.updateTransforms.map((t=&gt;function(e,t){let n=null;if("setToServerValue"in t)Ur("REQUEST_TIME"===t.setToServerValue),n=new Na;else if("appendMissingElements"in t){const e=t.appendMissingElements.values||[];n=new Aa(e)}else if("removeAllFromArray"in t){const e=t.removeAllFromArray.values||[];n=new Ra(e)}else"increment"in t?n=new Fa(e,t.increment):Br();const r=di.fromServerFormat(t.fieldPath);return new qa(r,n)}(e,t))):[];if(t.update){t.update.name;const i=Vc(e,t.update.name),s=new uo({mapValue:{fields:t.update.fields}});if(t.updateMask){const e=function(e){const t=e.fieldPaths||[];return new ks(t.map((e=&gt;di.fromServerFormat(e))))}(t.updateMask);return new Qa(i,s,e,n,r)}return new Ha(i,s,n,r)}if(t.delete){const r=Vc(e,t.delete);return new Za(r,n)}if(t.verify){const r=Vc(e,t.verify);return new ec(r,n)}return Br()}function Hc(e,t){return{documents:[Bc(e,t.path)]}}function Qc(e,t){const n={structuredQuery:{}},r=t.path;null!==t.collectionGroup?(n.parent=Bc(e,r),n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(n.parent=Bc(e,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);const i=function(e){if(0!==e.length)return ru(wo.create(e,"and"))}(t.filters);i&amp;&amp;(n.structuredQuery.where=i);const s=function(e){if(0!==e.length)return e.map((e=&gt;function(e){return{field:tu(e.field),direction:Jc(e.dir)}}(e)))}(t.orderBy);s&amp;&amp;(n.structuredQuery.orderBy=s);const o=Ac(e,t.limit);var a;return null!==o&amp;&amp;(n.structuredQuery.limit=o),t.startAt&amp;&amp;(n.structuredQuery.startAt={before:(a=t.startAt).inclusive,values:a.position}),t.endAt&amp;&amp;(n.structuredQuery.endAt=function(e){return{before:!e.inclusive,values:e.position}}(t.endAt)),n}function Yc(e){let t=Uc(e.parent);const n=e.structuredQuery,r=n.from?n.from.length:0;let i=null;if(r&gt;0){Ur(1===r);const e=n.from[0];e.allDescendants?i=e.collectionId:t=t.child(e.collectionId)}let s=[];n.where&amp;&amp;(s=function(e){const t=Xc(e);return t instanceof wo&amp;&amp;Co(t)?t.getFilters():[t]}(n.where));let o=[];n.orderBy&amp;&amp;(o=n.orderBy.map((e=&gt;function(e){return new mo(nu(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))}(e))));let a=null;n.limit&amp;&amp;(a=function(e){let t;return t="object"==typeof e?e.value:e,Ui(t)?null:t}(n.limit));let c=null;n.startAt&amp;&amp;(c=function(e){const t=!!e.before,n=e.values||[];return new fo(n,t)}(n.startAt));let u=null;return n.endAt&amp;&amp;(u=function(e){const t=!e.before,n=e.values||[];return new fo(n,t)}(n.endAt)),Go(t,i,o,s,a,"F",c,u)}function Xc(e){return void 0!==e.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":const t=nu(e.unaryFilter.field);return vo.create(t,"==",{doubleValue:NaN});case"IS_NULL":const n=nu(e.unaryFilter.field);return vo.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const r=nu(e.unaryFilter.field);return vo.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const i=nu(e.unaryFilter.field);return vo.create(i,"!=",{nullValue:"NULL_VALUE"});default:return Br()}}(e):void 0!==e.fieldFilter?function(e){return vo.create(nu(e.fieldFilter.field),function(e){switch(e){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return"&gt;";case"GREATER_THAN_OR_EQUAL":return"&gt;=";case"LESS_THAN":return"&lt;";case"LESS_THAN_OR_EQUAL":return"&lt;=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return Br()}}(e.fieldFilter.op),e.fieldFilter.value)}(e):void 0!==e.compositeFilter?function(e){return wo.create(e.compositeFilter.filters.map((e=&gt;Xc(e))),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return Br()}}(e.compositeFilter.op))}(e):Br()}function Jc(e){return xc[e]}function Zc(e){return kc[e]}function eu(e){return Dc[e]}function tu(e){return{fieldPath:e.canonicalString()}}function nu(e){return di.fromServerFormat(e.fieldPath)}function ru(e){return e instanceof vo?function(e){if("=="===e.op){if(to(e.value))return{unaryFilter:{field:tu(e.field),op:"IS_NAN"}};if(eo(e.value))return{unaryFilter:{field:tu(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(to(e.value))return{unaryFilter:{field:tu(e.field),op:"IS_NOT_NAN"}};if(eo(e.value))return{unaryFilter:{field:tu(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:tu(e.field),op:Zc(e.op),value:e.value}}}(e):e instanceof wo?function(e){const t=e.getFilters().map((e=&gt;ru(e)));return 1===t.length?t[0]:{compositeFilter:{op:eu(e.op),filters:t}}}(e):Br()}function iu(e){const t=[];return e.fields.forEach((e=&gt;t.push(e.canonicalString()))),{fieldPaths:t}}function su(e){return e.length&gt;=4&amp;&amp;"projects"===e.get(0)&amp;&amp;"databases"===e.get(2)}class ou{constructor(e,t,n,r,i=ci.min(),s=ci.min(),o=As.EMPTY_BYTE_STRING,a=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o,this.expectedCount=a}withSequenceNumber(e){return new ou(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new ou(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new ou(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new ou(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class au{constructor(e){this.le=e}}function cu(e,t){const n=t.key,r={prefixPath:n.getCollectionPath().popLast().toArray(),collectionGroup:n.collectionGroup,documentId:n.path.lastSegment(),readTime:uu(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument())r.document=function(e,t){return{name:qc(e,t.key),fields:t.data.value.mapValue.fields,updateTime:Pc(e,t.version.toTimestamp()),createTime:Pc(e,t.createTime.toTimestamp())}}(e.le,t);else if(t.isNoDocument())r.noDocument={path:n.path.toArray(),readTime:lu(t.version)};else{if(!t.isUnknownDocument())return Br();r.unknownDocument={path:n.path.toArray(),version:lu(t.version)}}return r}function uu(e){const t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function lu(e){const t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function hu(e){const t=new ai(e.seconds,e.nanoseconds);return ci.fromTimestamp(t)}function du(e,t){const n=(t.baseMutations||[]).map((t=&gt;Wc(e.le,t)));for(let e=0;e&lt;t.mutations.length-1;++e){const n=t.mutations[e];if(e+1&lt;t.mutations.length&amp;&amp;void 0!==t.mutations[e+1].transform){const r=t.mutations[e+1];n.updateTransforms=r.transform.fieldTransforms,t.mutations.splice(e+1,1),++e}}const r=t.mutations.map((t=&gt;Wc(e.le,t))),i=ai.fromMillis(t.localWriteTimeMs);return new tc(t.batchId,i,n,r)}function fu(e){const t=hu(e.readTime),n=void 0!==e.lastLimboFreeSnapshotVersion?hu(e.lastLimboFreeSnapshotVersion):ci.min();let r;var i;return void 0!==e.query.documents?(Ur(1===(i=e.query).documents.length),r=Zo(Wo(Uc(i.documents[0])))):r=function(e){return Zo(Yc(e))}(e.query),new ou(r,e.targetId,"TargetPurposeListen",e.lastListenSequenceNumber,t,n,As.fromBase64String(e.resumeToken))}function pu(e,t){const n=lu(t.snapshotVersion),r=lu(t.lastLimboFreeSnapshotVersion);let i;i=Uo(t.target)?Hc(e.le,t.target):Qc(e.le,t.target);const s=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:Vo(t.target),readTime:n,resumeToken:s,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:r,query:i}}function gu(e){const t=Yc({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?ta(t,t.limit,"L"):t}function mu(e,t){return new rc(t.largestBatchId,Wc(e.le,t.overlayMutation))}function yu(e,t){const n=t.path.lastSegment();return[e,$i(t.path.popLast()),n]}function _u(e,t,n,r){return{indexId:e,uid:t.uid||"",sequenceNumber:n,readTime:lu(r.readTime),documentKey:$i(r.documentKey.path),largestBatchId:r.largestBatchId}}class vu{getBundleMetadata(e,t){return wu(e).get(t).next((e=&gt;{if(e)return{id:(t=e).bundleId,createTime:hu(t.createTime),version:t.version};var t}))}saveBundleMetadata(e,t){return wu(e).put({bundleId:(n=t).id,createTime:lu(Fc(n.createTime)),version:n.version});var n}getNamedQuery(e,t){return bu(e).get(t).next((e=&gt;{if(e)return{name:(t=e).name,query:gu(t.bundledQuery),readTime:hu(t.readTime)};var t}))}saveNamedQuery(e,t){return bu(e).put(function(e){return{name:e.name,readTime:lu(Fc(e.readTime)),bundledQuery:e.bundledQuery}}(t))}}function wu(e){return _s(e,"bundles")}function bu(e){return _s(e,"namedQueries")}class Iu{constructor(e,t){this.serializer=e,this.userId=t}static fe(e,t){const n=t.uid||"";return new Iu(e,n)}getOverlay(e,t){return Cu(e).get(yu(this.userId,t)).next((e=&gt;e?mu(this.serializer,e):null))}getOverlays(e,t){const n=ga();return ki.forEach(t,(t=&gt;this.getOverlay(e,t).next((e=&gt;{null!==e&amp;&amp;n.set(t,e)})))).next((()=&gt;n))}saveOverlays(e,t,n){const r=[];return n.forEach(((n,i)=&gt;{const s=new rc(t,i);r.push(this.de(e,s))})),ki.waitFor(r)}removeOverlaysForBatchId(e,t,n){const r=new Set;t.forEach((e=&gt;r.add($i(e.getCollectionPath()))));const i=[];return r.forEach((t=&gt;{const r=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,n+1],!1,!0);i.push(Cu(e).J("collectionPathOverlayIndex",r))})),ki.waitFor(i)}getOverlaysForCollection(e,t,n){const r=ga(),i=$i(t),s=IDBKeyRange.bound([this.userId,i,n],[this.userId,i,Number.POSITIVE_INFINITY],!0);return Cu(e).j("collectionPathOverlayIndex",s).next((e=&gt;{for(const t of e){const e=mu(this.serializer,t);r.set(e.getKey(),e)}return r}))}getOverlaysForCollectionGroup(e,t,n,r){const i=ga();let s;const o=IDBKeyRange.bound([this.userId,t,n],[this.userId,t,Number.POSITIVE_INFINITY],!0);return Cu(e).X({index:"collectionGroupOverlayIndex",range:o},((e,t,n)=&gt;{const o=mu(this.serializer,t);i.size()&lt;r||o.largestBatchId===s?(i.set(o.getKey(),o),s=o.largestBatchId):n.done()})).next((()=&gt;i))}de(e,t){return Cu(e).put(function(e,t,n){const[r,i,s]=yu(t,n.mutation.key);return{userId:t,collectionPath:i,documentId:s,collectionGroup:n.mutation.key.getCollectionGroup(),largestBatchId:n.largestBatchId,overlayMutation:Gc(e.le,n.mutation)}}(this.serializer,this.userId,t))}}function Cu(e){return _s(e,"documentOverlays")}class Tu{constructor(){}_e(e,t){this.we(e,t),t.me()}we(e,t){if("nullValue"in e)this.ge(t,5);else if("booleanValue"in e)this.ge(t,10),t.ye(e.booleanValue?1:0);else if("integerValue"in e)this.ge(t,15),t.ye(Ms(e.integerValue));else if("doubleValue"in e){const n=Ms(e.doubleValue);isNaN(n)?this.ge(t,13):(this.ge(t,15),ji(n)?t.ye(0):t.ye(n))}else if("timestampValue"in e){const n=e.timestampValue;this.ge(t,20),"string"==typeof n?t.pe(n):(t.pe(`${n.seconds||""}`),t.ye(n.nanos||0))}else if("stringValue"in e)this.Ie(e.stringValue,t),this.Te(t);else if("bytesValue"in e)this.ge(t,30),t.Ee(Fs(e.bytesValue)),this.Te(t);else if("referenceValue"in e)this.Ae(e.referenceValue,t);else if("geoPointValue"in e){const n=e.geoPointValue;this.ge(t,45),t.ye(n.latitude||0),t.ye(n.longitude||0)}else"mapValue"in e?io(e)?this.ge(t,Number.MAX_SAFE_INTEGER):(this.Re(e.mapValue,t),this.Te(t)):"arrayValue"in e?(this.ve(e.arrayValue,t),this.Te(t)):Br()}Ie(e,t){this.ge(t,25),this.Pe(e,t)}Pe(e,t){t.pe(e)}Re(e,t){const n=e.fields||{};this.ge(t,55);for(const e of Object.keys(n))this.Ie(e,t),this.we(n[e],t)}ve(e,t){const n=e.values||[];this.ge(t,50);for(const e of n)this.we(e,t)}Ae(e,t){this.ge(t,37),fi.fromName(e).path.forEach((e=&gt;{this.ge(t,60),this.Pe(e,t)}))}ge(e,t){e.ye(t)}Te(e){e.ye(2)}}function Eu(e){if(0===e)return 8;let t=0;return e&gt;&gt;4==0&amp;&amp;(t+=4,e&lt;&lt;=4),e&gt;&gt;6==0&amp;&amp;(t+=2,e&lt;&lt;=2),e&gt;&gt;7==0&amp;&amp;(t+=1),t}function Su(e){const t=64-function(e){let t=0;for(let n=0;n&lt;8;++n){const r=Eu(255&amp;e[n]);if(t+=r,8!==r)break}return t}(e);return Math.ceil(t/8)}Tu.be=new Tu;class xu{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Ve(e){const t=e[Symbol.iterator]();let n=t.next();for(;!n.done;)this.Se(n.value),n=t.next();this.De()}Ce(e){const t=e[Symbol.iterator]();let n=t.next();for(;!n.done;)this.xe(n.value),n=t.next();this.Ne()}ke(e){for(const t of e){const e=t.charCodeAt(0);if(e&lt;128)this.Se(e);else if(e&lt;2048)this.Se(960|e&gt;&gt;&gt;6),this.Se(128|63&amp;e);else if(t&lt;"\ud800"||"\udbff"&lt;t)this.Se(480|e&gt;&gt;&gt;12),this.Se(128|63&amp;e&gt;&gt;&gt;6),this.Se(128|63&amp;e);else{const e=t.codePointAt(0);this.Se(240|e&gt;&gt;&gt;18),this.Se(128|63&amp;e&gt;&gt;&gt;12),this.Se(128|63&amp;e&gt;&gt;&gt;6),this.Se(128|63&amp;e)}}this.De()}Me(e){for(const t of e){const e=t.charCodeAt(0);if(e&lt;128)this.xe(e);else if(e&lt;2048)this.xe(960|e&gt;&gt;&gt;6),this.xe(128|63&amp;e);else if(t&lt;"\ud800"||"\udbff"&lt;t)this.xe(480|e&gt;&gt;&gt;12),this.xe(128|63&amp;e&gt;&gt;&gt;6),this.xe(128|63&amp;e);else{const e=t.codePointAt(0);this.xe(240|e&gt;&gt;&gt;18),this.xe(128|63&amp;e&gt;&gt;&gt;12),this.xe(128|63&amp;e&gt;&gt;&gt;6),this.xe(128|63&amp;e)}}this.Ne()}Oe(e){const t=this.$e(e),n=Su(t);this.Fe(1+n),this.buffer[this.position++]=255&amp;n;for(let e=t.length-n;e&lt;t.length;++e)this.buffer[this.position++]=255&amp;t[e]}Be(e){const t=this.$e(e),n=Su(t);this.Fe(1+n),this.buffer[this.position++]=~(255&amp;n);for(let e=t.length-n;e&lt;t.length;++e)this.buffer[this.position++]=~(255&amp;t[e])}Le(){this.qe(255),this.qe(255)}Ue(){this.Ke(255),this.Ke(255)}reset(){this.position=0}seed(e){this.Fe(e.length),this.buffer.set(e,this.position),this.position+=e.length}Ge(){return this.buffer.slice(0,this.position)}$e(e){const t=function(e){const t=new DataView(new ArrayBuffer(8));return t.setFloat64(0,e,!1),new Uint8Array(t.buffer)}(e),n=0!=(128&amp;t[0]);t[0]^=n?255:128;for(let e=1;e&lt;t.length;++e)t[e]^=n?255:0;return t}Se(e){const t=255&amp;e;0===t?(this.qe(0),this.qe(255)):255===t?(this.qe(255),this.qe(0)):this.qe(t)}xe(e){const t=255&amp;e;0===t?(this.Ke(0),this.Ke(255)):255===t?(this.Ke(255),this.Ke(0)):this.Ke(e)}De(){this.qe(0),this.qe(1)}Ne(){this.Ke(0),this.Ke(1)}qe(e){this.Fe(1),this.buffer[this.position++]=e}Ke(e){this.Fe(1),this.buffer[this.position++]=~e}Fe(e){const t=e+this.position;if(t&lt;=this.buffer.length)return;let n=2*this.buffer.length;n&lt;t&amp;&amp;(n=t);const r=new Uint8Array(n);r.set(this.buffer),this.buffer=r}}class ku{constructor(e){this.Qe=e}Ee(e){this.Qe.Ve(e)}pe(e){this.Qe.ke(e)}ye(e){this.Qe.Oe(e)}me(){this.Qe.Le()}}class Du{constructor(e){this.Qe=e}Ee(e){this.Qe.Ce(e)}pe(e){this.Qe.Me(e)}ye(e){this.Qe.Be(e)}me(){this.Qe.Ue()}}class Nu{constructor(){this.Qe=new xu,this.je=new ku(this.Qe),this.ze=new Du(this.Qe)}seed(e){this.Qe.seed(e)}We(e){return 0===e?this.je:this.ze}Ge(){return this.Qe.Ge()}reset(){this.Qe.reset()}}class Au{constructor(e,t,n,r){this.indexId=e,this.documentKey=t,this.arrayValue=n,this.directionalValue=r}He(){const e=this.directionalValue.length,t=0===e||255===this.directionalValue[e-1]?e+1:e,n=new Uint8Array(t);return n.set(this.directionalValue,0),t!==e?n.set([0],this.directionalValue.length):++n[n.length-1],new Au(this.indexId,this.documentKey,this.arrayValue,n)}}function Pu(e,t){let n=e.indexId-t.indexId;return 0!==n?n:(n=Ru(e.arrayValue,t.arrayValue),0!==n?n:(n=Ru(e.directionalValue,t.directionalValue),0!==n?n:fi.comparator(e.documentKey,t.documentKey)))}function Ru(e,t){for(let n=0;n&lt;e.length&amp;&amp;n&lt;t.length;++n){const r=e[n]-t[n];if(0!==r)return r}return e.length-t.length}class Mu{constructor(e){this.collectionId=null!=e.collectionGroup?e.collectionGroup:e.path.lastSegment(),this.Je=e.orderBy,this.Ye=[];for(const t of e.filters){const e=t;e.isInequality()?this.Xe=e:this.Ye.push(e)}}Ze(e){Ur(e.collectionGroup===this.collectionId);const t=gi(e);if(void 0!==t&amp;&amp;!this.tn(t))return!1;const n=mi(e);let r=0,i=0;for(;r&lt;n.length&amp;&amp;this.tn(n[r]);++r);if(r===n.length)return!0;if(void 0!==this.Xe){const e=n[r];if(!this.en(this.Xe,e)||!this.nn(this.Je[i++],e))return!1;++r}for(;r&lt;n.length;++r){const e=n[r];if(i&gt;=this.Je.length||!this.nn(this.Je[i++],e))return!1}return!0}tn(e){for(const t of this.Ye)if(this.en(t,e))return!0;return!1}en(e,t){if(void 0===e||!e.field.isEqual(t.fieldPath))return!1;const n="array-contains"===e.op||"array-contains-any"===e.op;return 2===t.kind===n}nn(e,t){return!!e.field.isEqual(t.fieldPath)&amp;&amp;(0===t.kind&amp;&amp;"asc"===e.dir||1===t.kind&amp;&amp;"desc"===e.dir)}}function Fu(e){var t,n;if(Ur(e instanceof vo||e instanceof wo),e instanceof vo){if(e instanceof Mo){const r=(null===(n=null===(t=e.value.arrayValue)||void 0===t?void 0:t.values)||void 0===n?void 0:n.map((t=&gt;vo.create(e.field,"==",t))))||[];return wo.create(r,"or")}return e}const r=e.filters.map((e=&gt;Fu(e)));return wo.create(r,e.op)}function Ou(e){if(0===e.getFilters().length)return[];const t=Bu(Fu(e));return Ur(Vu(t)),Lu(t)||qu(t)?[t]:t.getFilters()}function Lu(e){return e instanceof vo}function qu(e){return e instanceof wo&amp;&amp;Co(e)}function Vu(e){return Lu(e)||qu(e)||function(e){if(e instanceof wo&amp;&amp;Io(e)){for(const t of e.getFilters())if(!Lu(t)&amp;&amp;!qu(t))return!1;return!0}return!1}(e)}function Bu(e){if(Ur(e instanceof vo||e instanceof wo),e instanceof vo)return e;if(1===e.filters.length)return Bu(e.filters[0]);const t=e.filters.map((e=&gt;Bu(e)));let n=wo.create(t,e.op);return n=zu(n),Vu(n)?n:(Ur(n instanceof wo),Ur(bo(n)),Ur(n.filters.length&gt;1),n.filters.reduce(((e,t)=&gt;Uu(e,t))))}function Uu(e,t){let n;return Ur(e instanceof vo||e instanceof wo),Ur(t instanceof vo||t instanceof wo),n=e instanceof vo?t instanceof vo?function(e,t){return wo.create([e,t],"and")}(e,t):ju(e,t):t instanceof vo?ju(t,e):function(e,t){if(Ur(e.filters.length&gt;0&amp;&amp;t.filters.length&gt;0),bo(e)&amp;&amp;bo(t))return xo(e,t.getFilters());const n=Io(e)?e:t,r=Io(e)?t:e,i=n.filters.map((e=&gt;Uu(e,r)));return wo.create(i,"or")}(e,t),zu(n)}function ju(e,t){if(bo(t))return xo(t,e.getFilters());{const n=t.filters.map((t=&gt;Uu(e,t)));return wo.create(n,"or")}}function zu(e){if(Ur(e instanceof vo||e instanceof wo),e instanceof vo)return e;const t=e.getFilters();if(1===t.length)return zu(t[0]);if(To(e))return e;const n=t.map((e=&gt;zu(e))),r=[];return n.forEach((t=&gt;{t instanceof vo?r.push(t):t instanceof wo&amp;&amp;(t.op===e.op?r.push(...t.filters):r.push(t))})),1===r.length?r[0]:wo.create(r,e.op)}class $u{constructor(){this.sn=new Ku}addToCollectionParentIndex(e,t){return this.sn.add(t),ki.resolve()}getCollectionParents(e,t){return ki.resolve(this.sn.getEntries(t))}addFieldIndex(e,t){return ki.resolve()}deleteFieldIndex(e,t){return ki.resolve()}getDocumentsMatchingTarget(e,t){return ki.resolve(null)}getIndexType(e,t){return ki.resolve(0)}getFieldIndexes(e,t){return ki.resolve([])}getNextCollectionGroupToUpdate(e){return ki.resolve(null)}getMinOffset(e,t){return ki.resolve(Ci.min())}getMinOffsetFromCollectionGroup(e,t){return ki.resolve(Ci.min())}updateCollectionGroup(e,t,n){return ki.resolve()}updateIndexEntries(e,t){return ki.resolve()}}class Ku{constructor(){this.index={}}add(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new Es(li.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}has(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&amp;&amp;r.has(n)}getEntries(e){return(this.index[e]||new Es(li.comparator)).toArray()}}const Gu=new Uint8Array(0);class Wu{constructor(e,t){this.user=e,this.databaseId=t,this.rn=new Ku,this.on=new ua((e=&gt;Vo(e)),((e,t)=&gt;Bo(e,t))),this.uid=e.uid||""}addToCollectionParentIndex(e,t){if(!this.rn.has(t)){const n=t.lastSegment(),r=t.popLast();e.addOnCommittedListener((()=&gt;{this.rn.add(t)}));const i={collectionId:n,parent:$i(r)};return Hu(e).put(i)}return ki.resolve()}getCollectionParents(e,t){const n=[],r=IDBKeyRange.bound([t,""],[oi(t),""],!1,!0);return Hu(e).j(r).next((e=&gt;{for(const r of e){if(r.collectionId!==t)break;n.push(Wi(r.parent))}return n}))}addFieldIndex(e,t){const n=Yu(e),r=function(e){return{indexId:e.indexId,collectionGroup:e.collectionGroup,fields:e.fields.map((e=&gt;[e.fieldPath.canonicalString(),e.kind]))}}(t);delete r.indexId;const i=n.add(r);if(t.indexState){const n=Xu(e);return i.next((e=&gt;{n.put(_u(e,this.user,t.indexState.sequenceNumber,t.indexState.offset))}))}return i.next()}deleteFieldIndex(e,t){const n=Yu(e),r=Xu(e),i=Qu(e);return n.delete(t.indexId).next((()=&gt;r.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0)))).next((()=&gt;i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))))}getDocumentsMatchingTarget(e,t){const n=Qu(e);let r=!0;const i=new Map;return ki.forEach(this.un(t),(t=&gt;this.cn(e,t).next((e=&gt;{r&amp;&amp;(r=!!e),i.set(t,e)})))).next((()=&gt;{if(r){let e=wa();const r=[];return ki.forEach(i,((i,s)=&gt;{var o;Or("IndexedDbIndexManager",`Using index ${o=i,`id=${o.indexId}|cg=${o.collectionGroup}|f=${o.fields.map((e=&gt;`${e.fieldPath}:${e.kind}`)).join(",")}`} to execute ${Vo(t)}`);const a=function(e,t){const n=gi(t);if(void 0===n)return null;for(const t of jo(e,n.fieldPath))switch(t.op){case"array-contains-any":return t.value.arrayValue.values||[];case"array-contains":return[t.value]}return null}(s,i),c=function(e,t){const n=new Map;for(const r of mi(t))for(const t of jo(e,r.fieldPath))switch(t.op){case"==":case"in":n.set(r.fieldPath.canonicalString(),t.value);break;case"not-in":case"!=":return n.set(r.fieldPath.canonicalString(),t.value),Array.from(n.values())}return null}(s,i),u=function(e,t){const n=[];let r=!0;for(const i of mi(t)){const t=0===i.kind?zo(e,i.fieldPath,e.startAt):$o(e,i.fieldPath,e.startAt);n.push(t.value),r&amp;&amp;(r=t.inclusive)}return new fo(n,r)}(s,i),l=function(e,t){const n=[];let r=!0;for(const i of mi(t)){const t=0===i.kind?$o(e,i.fieldPath,e.endAt):zo(e,i.fieldPath,e.endAt);n.push(t.value),r&amp;&amp;(r=t.inclusive)}return new fo(n,r)}(s,i),h=this.an(i,s,u),d=this.an(i,s,l),f=this.hn(i,s,c),p=this.ln(i.indexId,a,h,u.inclusive,d,l.inclusive,f);return ki.forEach(p,(i=&gt;n.H(i,t.limit).next((t=&gt;{t.forEach((t=&gt;{const n=fi.fromSegments(t.documentKey);e.has(n)||(e=e.add(n),r.push(n))}))}))))})).next((()=&gt;r))}return ki.resolve(null)}))}un(e){let t=this.on.get(e);return t||(t=0===e.filters.length?[e]:Ou(wo.create(e.filters,"and")).map((t=&gt;qo(e.path,e.collectionGroup,e.orderBy,t.getFilters(),e.limit,e.startAt,e.endAt))),this.on.set(e,t),t)}ln(e,t,n,r,i,s,o){const a=(null!=t?t.length:1)*Math.max(n.length,i.length),c=a/(null!=t?t.length:1),u=[];for(let l=0;l&lt;a;++l){const a=t?this.fn(t[l/c]):Gu,h=this.dn(e,a,n[l%c],r),d=this._n(e,a,i[l%c],s),f=o.map((t=&gt;this.dn(e,a,t,!0)));u.push(...this.createRange(h,d,f))}return u}dn(e,t,n,r){const i=new Au(e,fi.empty(),t,n);return r?i:i.He()}_n(e,t,n,r){const i=new Au(e,fi.empty(),t,n);return r?i.He():i}cn(e,t){const n=new Mu(t),r=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment();return this.getFieldIndexes(e,r).next((e=&gt;{let t=null;for(const r of e)n.Ze(r)&amp;&amp;(!t||r.fields.length&gt;t.fields.length)&amp;&amp;(t=r);return t}))}getIndexType(e,t){let n=2;const r=this.un(t);return ki.forEach(r,(t=&gt;this.cn(e,t).next((e=&gt;{e?0!==n&amp;&amp;e.fields.length&lt;function(e){let t=new Es(di.comparator),n=!1;for(const r of e.filters)for(const e of r.getFlattenedFilters())e.field.isKeyField()||("array-contains"===e.op||"array-contains-any"===e.op?n=!0:t=t.add(e.field));for(const n of e.orderBy)n.field.isKeyField()||(t=t.add(n.field));return t.size+(n?1:0)}(t)&amp;&amp;(n=1):n=0})))).next((()=&gt;function(e){return null!==e.limit}(t)&amp;&amp;r.length&gt;1&amp;&amp;2===n?1:n))}wn(e,t){const n=new Nu;for(const r of mi(e)){const e=t.data.field(r.fieldPath);if(null==e)return null;const i=n.We(r.kind);Tu.be._e(e,i)}return n.Ge()}fn(e){const t=new Nu;return Tu.be._e(e,t.We(0)),t.Ge()}mn(e,t){const n=new Nu;return Tu.be._e(Xs(this.databaseId,t),n.We(function(e){const t=mi(e);return 0===t.length?0:t[t.length-1].kind}(e))),n.Ge()}hn(e,t,n){if(null===n)return[];let r=[];r.push(new Nu);let i=0;for(const s of mi(e)){const e=n[i++];for(const n of r)if(this.gn(t,s.fieldPath)&amp;&amp;Zs(e))r=this.yn(r,s,e);else{const t=n.We(s.kind);Tu.be._e(e,t)}}return this.pn(r)}an(e,t,n){return this.hn(e,t,n.position)}pn(e){const t=[];for(let n=0;n&lt;e.length;++n)t[n]=e[n].Ge();return t}yn(e,t,n){const r=[...e],i=[];for(const e of n.arrayValue.values||[])for(const n of r){const r=new Nu;r.seed(n.Ge()),Tu.be._e(e,r.We(t.kind)),i.push(r)}return i}gn(e,t){return!!e.filters.find((e=&gt;e instanceof vo&amp;&amp;e.field.isEqual(t)&amp;&amp;("in"===e.op||"not-in"===e.op)))}getFieldIndexes(e,t){const n=Yu(e),r=Xu(e);return(t?n.j("collectionGroupIndex",IDBKeyRange.bound(t,t)):n.j()).next((e=&gt;{const t=[];return ki.forEach(e,(e=&gt;r.get([e.indexId,this.uid]).next((n=&gt;{t.push(function(e,t){const n=t?new wi(t.sequenceNumber,new Ci(hu(t.readTime),new fi(Wi(t.documentKey)),t.largestBatchId)):wi.empty(),r=e.fields.map((([e,t])=&gt;new _i(di.fromServerFormat(e),t)));return new pi(e.indexId,e.collectionGroup,r,n)}(e,n))})))).next((()=&gt;t))}))}getNextCollectionGroupToUpdate(e){return this.getFieldIndexes(e).next((e=&gt;0===e.length?null:(e.sort(((e,t)=&gt;{const n=e.indexState.sequenceNumber-t.indexState.sequenceNumber;return 0!==n?n:ii(e.collectionGroup,t.collectionGroup)})),e[0].collectionGroup)))}updateCollectionGroup(e,t,n){const r=Yu(e),i=Xu(e);return this.In(e).next((e=&gt;r.j("collectionGroupIndex",IDBKeyRange.bound(t,t)).next((t=&gt;ki.forEach(t,(t=&gt;i.put(_u(t.indexId,this.user,e,n))))))))}updateIndexEntries(e,t){const n=new Map;return ki.forEach(t,((t,r)=&gt;{const i=n.get(t.collectionGroup);return(i?ki.resolve(i):this.getFieldIndexes(e,t.collectionGroup)).next((i=&gt;(n.set(t.collectionGroup,i),ki.forEach(i,(n=&gt;this.Tn(e,t,n).next((t=&gt;{const i=this.En(r,n);return t.isEqual(i)?ki.resolve():this.An(e,r,n,t,i)})))))))}))}Rn(e,t,n,r){return Qu(e).put({indexId:r.indexId,uid:this.uid,arrayValue:r.arrayValue,directionalValue:r.directionalValue,orderedDocumentKey:this.mn(n,t.key),documentKey:t.key.path.toArray()})}vn(e,t,n,r){return Qu(e).delete([r.indexId,this.uid,r.arrayValue,r.directionalValue,this.mn(n,t.key),t.key.path.toArray()])}Tn(e,t,n){const r=Qu(e);let i=new Es(Pu);return r.X({index:"documentKeyIndex",range:IDBKeyRange.only([n.indexId,this.uid,this.mn(n,t)])},((e,r)=&gt;{i=i.add(new Au(n.indexId,t,r.arrayValue,r.directionalValue))})).next((()=&gt;i))}En(e,t){let n=new Es(Pu);const r=this.wn(t,e);if(null==r)return n;const i=gi(t);if(null!=i){const s=e.data.field(i.fieldPath);if(Zs(s))for(const i of s.arrayValue.values||[])n=n.add(new Au(t.indexId,e.key,this.fn(i),r))}else n=n.add(new Au(t.indexId,e.key,Gu,r));return n}An(e,t,n,r,i){Or("IndexedDbIndexManager","Updating index entries for document '%s'",t.key);const s=[];return function(e,t,n,r,i){const s=e.getIterator(),o=t.getIterator();let a=xs(s),c=xs(o);for(;a||c;){let e=!1,t=!1;if(a&amp;&amp;c){const r=n(a,c);r&lt;0?t=!0:r&gt;0&amp;&amp;(e=!0)}else null!=a?t=!0:e=!0;e?(r(c),c=xs(o)):t?(i(a),a=xs(s)):(a=xs(s),c=xs(o))}}(r,i,Pu,(r=&gt;{s.push(this.Rn(e,t,n,r))}),(r=&gt;{s.push(this.vn(e,t,n,r))})),ki.waitFor(s)}In(e){let t=1;return Xu(e).X({index:"sequenceNumberIndex",reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},((e,n,r)=&gt;{r.done(),t=n.sequenceNumber+1})).next((()=&gt;t))}createRange(e,t,n){n=n.sort(((e,t)=&gt;Pu(e,t))).filter(((e,t,n)=&gt;!t||0!==Pu(e,n[t-1])));const r=[];r.push(e);for(const i of n){const n=Pu(i,e),s=Pu(i,t);if(0===n)r[0]=e.He();else if(n&gt;0&amp;&amp;s&lt;0)r.push(i),r.push(i.He());else if(s&gt;0)break}r.push(t);const i=[];for(let e=0;e&lt;r.length;e+=2){if(this.Pn(r[e],r[e+1]))return[];const t=[r[e].indexId,this.uid,r[e].arrayValue,r[e].directionalValue,Gu,[]],n=[r[e+1].indexId,this.uid,r[e+1].arrayValue,r[e+1].directionalValue,Gu,[]];i.push(IDBKeyRange.bound(t,n))}return i}Pn(e,t){return Pu(e,t)&gt;0}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(Ju)}getMinOffset(e,t){return ki.mapArray(this.un(t),(t=&gt;this.cn(e,t).next((e=&gt;e||Br())))).next(Ju)}}function Hu(e){return _s(e,"collectionParents")}function Qu(e){return _s(e,"indexEntries")}function Yu(e){return _s(e,"indexConfiguration")}function Xu(e){return _s(e,"indexState")}function Ju(e){Ur(0!==e.length);let t=e[0].indexState.offset,n=t.largestBatchId;for(let r=1;r&lt;e.length;r++){const i=e[r].indexState.offset;Ti(i,t)&lt;0&amp;&amp;(t=i),n&lt;i.largestBatchId&amp;&amp;(n=i.largestBatchId)}return new Ci(t.readTime,t.documentKey,n)}const Zu={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class el{constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}static withCacheSize(e){return new el(e,el.DEFAULT_COLLECTION_PERCENTILE,el.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}}function tl(e,t,n){const r=e.store("mutations"),i=e.store("documentMutations"),s=[],o=IDBKeyRange.only(n.batchId);let a=0;const c=r.X({range:o},((e,t,n)=&gt;(a++,n.delete())));s.push(c.next((()=&gt;{Ur(1===a)})));const u=[];for(const e of n.mutations){const r=Yi(t,e.key.path,n.batchId);s.push(i.delete(r)),u.push(e.key)}return ki.waitFor(s).next((()=&gt;u))}function nl(e){if(!e)return 0;let t;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw Br();t=e.noDocument}return JSON.stringify(t).length}el.DEFAULT_COLLECTION_PERCENTILE=10,el.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,el.DEFAULT=new el(41943040,el.DEFAULT_COLLECTION_PERCENTILE,el.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),el.DISABLED=new el(-1,0,0);class rl{constructor(e,t,n,r){this.userId=e,this.serializer=t,this.indexManager=n,this.referenceDelegate=r,this.bn={}}static fe(e,t,n,r){Ur(""!==e.uid);const i=e.isAuthenticated()?e.uid:"";return new rl(i,t,n,r)}checkEmpty(e){let t=!0;const n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return sl(e).X({index:"userMutationsIndex",range:n},((e,n,r)=&gt;{t=!1,r.done()})).next((()=&gt;t))}addMutationBatch(e,t,n,r){const i=ol(e),s=sl(e);return s.add({}).next((o=&gt;{Ur("number"==typeof o);const a=new tc(o,t,n,r),c=function(e,t,n){const r=n.baseMutations.map((t=&gt;Gc(e.le,t))),i=n.mutations.map((t=&gt;Gc(e.le,t)));return{userId:t,batchId:n.batchId,localWriteTimeMs:n.localWriteTime.toMillis(),baseMutations:r,mutations:i}}(this.serializer,this.userId,a),u=[];let l=new Es(((e,t)=&gt;ii(e.canonicalString(),t.canonicalString())));for(const e of r){const t=Yi(this.userId,e.key.path,o);l=l.add(e.key.path.popLast()),u.push(s.put(c)),u.push(i.put(t,Xi))}return l.forEach((t=&gt;{u.push(this.indexManager.addToCollectionParentIndex(e,t))})),e.addOnCommittedListener((()=&gt;{this.bn[o]=a.keys()})),ki.waitFor(u).next((()=&gt;a))}))}lookupMutationBatch(e,t){return sl(e).get(t).next((e=&gt;e?(Ur(e.userId===this.userId),du(this.serializer,e)):null))}Vn(e,t){return this.bn[t]?ki.resolve(this.bn[t]):this.lookupMutationBatch(e,t).next((e=&gt;{if(e){const n=e.keys();return this.bn[t]=n,n}return null}))}getNextMutationBatchAfterBatchId(e,t){const n=t+1,r=IDBKeyRange.lowerBound([this.userId,n]);let i=null;return sl(e).X({index:"userMutationsIndex",range:r},((e,t,r)=&gt;{t.userId===this.userId&amp;&amp;(Ur(t.batchId&gt;=n),i=du(this.serializer,t)),r.done()})).next((()=&gt;i))}getHighestUnacknowledgedBatchId(e){const t=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]);let n=-1;return sl(e).X({index:"userMutationsIndex",range:t,reverse:!0},((e,t,r)=&gt;{n=t.batchId,r.done()})).next((()=&gt;n))}getAllMutationBatches(e){const t=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return sl(e).j("userMutationsIndex",t).next((e=&gt;e.map((e=&gt;du(this.serializer,e)))))}getAllMutationBatchesAffectingDocumentKey(e,t){const n=Qi(this.userId,t.path),r=IDBKeyRange.lowerBound(n),i=[];return ol(e).X({range:r},((n,r,s)=&gt;{const[o,a,c]=n,u=Wi(a);if(o===this.userId&amp;&amp;t.path.isEqual(u))return sl(e).get(c).next((e=&gt;{if(!e)throw Br();Ur(e.userId===this.userId),i.push(du(this.serializer,e))}));s.done()})).next((()=&gt;i))}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new Es(ii);const r=[];return t.forEach((t=&gt;{const i=Qi(this.userId,t.path),s=IDBKeyRange.lowerBound(i),o=ol(e).X({range:s},((e,r,i)=&gt;{const[s,o,a]=e,c=Wi(o);s===this.userId&amp;&amp;t.path.isEqual(c)?n=n.add(a):i.done()}));r.push(o)})),ki.waitFor(r).next((()=&gt;this.Sn(e,n)))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1,i=Qi(this.userId,n),s=IDBKeyRange.lowerBound(i);let o=new Es(ii);return ol(e).X({range:s},((e,t,i)=&gt;{const[s,a,c]=e,u=Wi(a);s===this.userId&amp;&amp;n.isPrefixOf(u)?u.length===r&amp;&amp;(o=o.add(c)):i.done()})).next((()=&gt;this.Sn(e,o)))}Sn(e,t){const n=[],r=[];return t.forEach((t=&gt;{r.push(sl(e).get(t).next((e=&gt;{if(null===e)throw Br();Ur(e.userId===this.userId),n.push(du(this.serializer,e))})))})),ki.waitFor(r).next((()=&gt;n))}removeMutationBatch(e,t){return tl(e.at,this.userId,t).next((n=&gt;(e.addOnCommittedListener((()=&gt;{this.Dn(t.batchId)})),ki.forEach(n,(t=&gt;this.referenceDelegate.markPotentiallyOrphaned(e,t))))))}Dn(e){delete this.bn[e]}performConsistencyCheck(e){return this.checkEmpty(e).next((t=&gt;{if(!t)return ki.resolve();const n=IDBKeyRange.lowerBound([this.userId]),r=[];return ol(e).X({range:n},((e,t,n)=&gt;{if(e[0]===this.userId){const t=Wi(e[1]);r.push(t)}else n.done()})).next((()=&gt;{Ur(0===r.length)}))}))}containsKey(e,t){return il(e,this.userId,t)}Cn(e){return al(e).get(this.userId).next((e=&gt;e||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""}))}}function il(e,t,n){const r=Qi(t,n.path),i=r[1],s=IDBKeyRange.lowerBound(r);let o=!1;return ol(e).X({range:s,Y:!0},((e,n,r)=&gt;{const[s,a,c]=e;s===t&amp;&amp;a===i&amp;&amp;(o=!0),r.done()})).next((()=&gt;o))}function sl(e){return _s(e,"mutations")}function ol(e){return _s(e,"documentMutations")}function al(e){return _s(e,"mutationQueues")}class cl{constructor(e){this.xn=e}next(){return this.xn+=2,this.xn}static Nn(){return new cl(0)}static kn(){return new cl(-1)}}class ul{constructor(e,t){this.referenceDelegate=e,this.serializer=t}allocateTargetId(e){return this.Mn(e).next((t=&gt;{const n=new cl(t.highestTargetId);return t.highestTargetId=n.next(),this.On(e,t).next((()=&gt;t.highestTargetId))}))}getLastRemoteSnapshotVersion(e){return this.Mn(e).next((e=&gt;ci.fromTimestamp(new ai(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds))))}getHighestSequenceNumber(e){return this.Mn(e).next((e=&gt;e.highestListenSequenceNumber))}setTargetsMetadata(e,t,n){return this.Mn(e).next((r=&gt;(r.highestListenSequenceNumber=t,n&amp;&amp;(r.lastRemoteSnapshotVersion=n.toTimestamp()),t&gt;r.highestListenSequenceNumber&amp;&amp;(r.highestListenSequenceNumber=t),this.On(e,r))))}addTargetData(e,t){return this.$n(e,t).next((()=&gt;this.Mn(e).next((n=&gt;(n.targetCount+=1,this.Fn(t,n),this.On(e,n))))))}updateTargetData(e,t){return this.$n(e,t)}removeTargetData(e,t){return this.removeMatchingKeysForTargetId(e,t.targetId).next((()=&gt;ll(e).delete(t.targetId))).next((()=&gt;this.Mn(e))).next((t=&gt;(Ur(t.targetCount&gt;0),t.targetCount-=1,this.On(e,t))))}removeTargets(e,t,n){let r=0;const i=[];return ll(e).X(((s,o)=&gt;{const a=fu(o);a.sequenceNumber&lt;=t&amp;&amp;null===n.get(a.targetId)&amp;&amp;(r++,i.push(this.removeTargetData(e,a)))})).next((()=&gt;ki.waitFor(i))).next((()=&gt;r))}forEachTarget(e,t){return ll(e).X(((e,n)=&gt;{const r=fu(n);t(r)}))}Mn(e){return hl(e).get("targetGlobalKey").next((e=&gt;(Ur(null!==e),e)))}On(e,t){return hl(e).put("targetGlobalKey",t)}$n(e,t){return ll(e).put(pu(this.serializer,t))}Fn(e,t){let n=!1;return e.targetId&gt;t.highestTargetId&amp;&amp;(t.highestTargetId=e.targetId,n=!0),e.sequenceNumber&gt;t.highestListenSequenceNumber&amp;&amp;(t.highestListenSequenceNumber=e.sequenceNumber,n=!0),n}getTargetCount(e){return this.Mn(e).next((e=&gt;e.targetCount))}getTargetData(e,t){const n=Vo(t),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]);let i=null;return ll(e).X({range:r,index:"queryTargetsIndex"},((e,n,r)=&gt;{const s=fu(n);Bo(t,s.target)&amp;&amp;(i=s,r.done())})).next((()=&gt;i))}addMatchingKeys(e,t,n){const r=[],i=dl(e);return t.forEach((t=&gt;{const s=$i(t.path);r.push(i.put({targetId:n,path:s})),r.push(this.referenceDelegate.addReference(e,n,t))})),ki.waitFor(r)}removeMatchingKeys(e,t,n){const r=dl(e);return ki.forEach(t,(t=&gt;{const i=$i(t.path);return ki.waitFor([r.delete([n,i]),this.referenceDelegate.removeReference(e,n,t)])}))}removeMatchingKeysForTargetId(e,t){const n=dl(e),r=IDBKeyRange.bound([t],[t+1],!1,!0);return n.delete(r)}getMatchingKeysForTargetId(e,t){const n=IDBKeyRange.bound([t],[t+1],!1,!0),r=dl(e);let i=wa();return r.X({range:n,Y:!0},((e,t,n)=&gt;{const r=Wi(e[1]),s=new fi(r);i=i.add(s)})).next((()=&gt;i))}containsKey(e,t){const n=$i(t.path),r=IDBKeyRange.bound([n],[oi(n)],!1,!0);let i=0;return dl(e).X({index:"documentTargetsIndex",Y:!0,range:r},(([e,t],n,r)=&gt;{0!==e&amp;&amp;(i++,r.done())})).next((()=&gt;i&gt;0))}he(e,t){return ll(e).get(t).next((e=&gt;e?fu(e):null))}}function ll(e){return _s(e,"targets")}function hl(e){return _s(e,"targetGlobal")}function dl(e){return _s(e,"targetDocuments")}function fl([e,t],[n,r]){const i=ii(e,n);return 0===i?ii(t,r):i}class pl{constructor(e){this.Bn=e,this.buffer=new Es(fl),this.Ln=0}qn(){return++this.Ln}Un(e){const t=[e,this.qn()];if(this.buffer.size&lt;this.Bn)this.buffer=this.buffer.add(t);else{const e=this.buffer.last();fl(t,e)&lt;0&amp;&amp;(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class gl{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Kn=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&amp;&amp;this.Gn(6e4)}stop(){this.Kn&amp;&amp;(this.Kn.cancel(),this.Kn=null)}get started(){return null!==this.Kn}Gn(e){Or("LruGarbageCollector",`Garbage collection scheduled in ${e}ms`),this.Kn=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,(async()=&gt;{this.Kn=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){Ri(e)?Or("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e):await xi(e)}await this.Gn(3e5)}))}}class ml{constructor(e,t){this.Qn=e,this.params=t}calculateTargetCount(e,t){return this.Qn.jn(e).next((e=&gt;Math.floor(t/100*e)))}nthSequenceNumber(e,t){if(0===t)return ki.resolve(Bi.ct);const n=new pl(t);return this.Qn.forEachTarget(e,(e=&gt;n.Un(e.sequenceNumber))).next((()=&gt;this.Qn.zn(e,(e=&gt;n.Un(e))))).next((()=&gt;n.maxValue))}removeTargets(e,t,n){return this.Qn.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.Qn.removeOrphanedDocuments(e,t)}collect(e,t){return-1===this.params.cacheSizeCollectionThreshold?(Or("LruGarbageCollector","Garbage collection skipped; disabled"),ki.resolve(Zu)):this.getCacheSize(e).next((n=&gt;n&lt;this.params.cacheSizeCollectionThreshold?(Or("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Zu):this.Wn(e,t)))}getCacheSize(e){return this.Qn.getCacheSize(e)}Wn(e,t){let n,r,i,s,a,c,u;const l=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((t=&gt;(t&gt;this.params.maximumSequenceNumbersToCollect?(Or("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),r=this.params.maximumSequenceNumbersToCollect):r=t,s=Date.now(),this.nthSequenceNumber(e,r)))).next((r=&gt;(n=r,a=Date.now(),this.removeTargets(e,n,t)))).next((t=&gt;(i=t,c=Date.now(),this.removeOrphanedDocuments(e,n)))).next((e=&gt;(u=Date.now(),Mr()&lt;=o.in.DEBUG&amp;&amp;Or("LruGarbageCollector",`LRU Garbage Collection\n\tCounted targets in ${s-l}ms\n\tDetermined least recently used ${r} in `+(a-s)+"ms\n"+`\tRemoved ${i} targets in `+(c-a)+"ms\n"+`\tRemoved ${e} documents in `+(u-c)+"ms\n"+`Total Duration: ${u-l}ms`),ki.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e}))))}}function yl(e,t){return new ml(e,t)}class _l{constructor(e,t){this.db=e,this.garbageCollector=yl(this,t)}jn(e){const t=this.Hn(e);return this.db.getTargetCache().getTargetCount(e).next((e=&gt;t.next((t=&gt;e+t))))}Hn(e){let t=0;return this.zn(e,(e=&gt;{t++})).next((()=&gt;t))}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}zn(e,t){return this.Jn(e,((e,n)=&gt;t(n)))}addReference(e,t,n){return vl(e,n)}removeReference(e,t,n){return vl(e,n)}removeTargets(e,t,n){return this.db.getTargetCache().removeTargets(e,t,n)}markPotentiallyOrphaned(e,t){return vl(e,t)}Yn(e,t){return function(e,t){let n=!1;return al(e).Z((r=&gt;il(e,r,t).next((e=&gt;(e&amp;&amp;(n=!0),ki.resolve(!e)))))).next((()=&gt;n))}(e,t)}removeOrphanedDocuments(e,t){const n=this.db.getRemoteDocumentCache().newChangeBuffer(),r=[];let i=0;return this.Jn(e,((s,o)=&gt;{if(o&lt;=t){const t=this.Yn(e,s).next((t=&gt;{if(!t)return i++,n.getEntry(e,s).next((()=&gt;(n.removeEntry(s,ci.min()),dl(e).delete([0,$i(s.path)]))))}));r.push(t)}})).next((()=&gt;ki.waitFor(r))).next((()=&gt;n.apply(e))).next((()=&gt;i))}removeTarget(e,t){const n=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,n)}updateLimboDocument(e,t){return vl(e,t)}Jn(e,t){const n=dl(e);let r,i=Bi.ct;return n.X({index:"documentTargetsIndex"},(([e,n],{path:s,sequenceNumber:o})=&gt;{0===e?(i!==Bi.ct&amp;&amp;t(new fi(Wi(r)),i),i=o,r=s):i=Bi.ct})).next((()=&gt;{i!==Bi.ct&amp;&amp;t(new fi(Wi(r)),i)}))}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function vl(e,t){return dl(e).put(function(e,t){return{targetId:0,path:$i(e.path),sequenceNumber:t}}(t,e.currentSequenceNumber))}class wl{constructor(){this.changes=new ua((e=&gt;e.toString()),((e,t)=&gt;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,ho.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const n=this.changes.get(t);return void 0!==n?ki.resolve(n):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class bl{constructor(e){this.serializer=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,n){return El(e).put(n)}removeEntry(e,t,n){return El(e).delete(function(e,t){const n=e.path.toArray();return[n.slice(0,n.length-2),n[n.length-2],uu(t),n[n.length-1]]}(t,n))}updateMetadata(e,t){return this.getMetadata(e).next((n=&gt;(n.byteSize+=t,this.Xn(e,n))))}getEntry(e,t){let n=ho.newInvalidDocument(t);return El(e).X({index:"documentKeyIndex",range:IDBKeyRange.only(Sl(t))},((e,r)=&gt;{n=this.Zn(t,r)})).next((()=&gt;n))}ts(e,t){let n={size:0,document:ho.newInvalidDocument(t)};return El(e).X({index:"documentKeyIndex",range:IDBKeyRange.only(Sl(t))},((e,r)=&gt;{n={document:this.Zn(t,r),size:nl(r)}})).next((()=&gt;n))}getEntries(e,t){let n=ha();return this.es(e,t,((e,t)=&gt;{const r=this.Zn(e,t);n=n.insert(e,r)})).next((()=&gt;n))}ns(e,t){let n=ha(),r=new Is(fi.comparator);return this.es(e,t,((e,t)=&gt;{const i=this.Zn(e,t);n=n.insert(e,i),r=r.insert(e,nl(t))})).next((()=&gt;({documents:n,ss:r})))}es(e,t,n){if(t.isEmpty())return ki.resolve();let r=new Es(kl);t.forEach((e=&gt;r=r.add(e)));const i=IDBKeyRange.bound(Sl(r.first()),Sl(r.last())),s=r.getIterator();let o=s.getNext();return El(e).X({index:"documentKeyIndex",range:i},((e,t,r)=&gt;{const i=fi.fromSegments([...t.prefixPath,t.collectionGroup,t.documentId]);for(;o&amp;&amp;kl(o,i)&lt;0;)n(o,null),o=s.getNext();o&amp;&amp;o.isEqual(i)&amp;&amp;(n(o,t),o=s.hasNext()?s.getNext():null),o?r.G(Sl(o)):r.done()})).next((()=&gt;{for(;o;)n(o,null),o=s.hasNext()?s.getNext():null}))}getDocumentsMatchingQuery(e,t,n,r){const i=t.path,s=[i.popLast().toArray(),i.lastSegment(),uu(n.readTime),n.documentKey.path.isEmpty()?"":n.documentKey.path.lastSegment()],o=[i.popLast().toArray(),i.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];return El(e).j(IDBKeyRange.bound(s,o,!0)).next((e=&gt;{let n=ha();for(const i of e){const e=this.Zn(fi.fromSegments(i.prefixPath.concat(i.collectionGroup,i.documentId)),i);e.isFoundDocument()&amp;&amp;(sa(t,e)||r.has(e.key))&amp;&amp;(n=n.insert(e.key,e))}return n}))}getAllFromCollectionGroup(e,t,n,r){let i=ha();const s=xl(t,n),o=xl(t,Ci.max());return El(e).X({index:"collectionGroupIndex",range:IDBKeyRange.bound(s,o,!0)},((e,t,n)=&gt;{const s=this.Zn(fi.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);i=i.insert(s.key,s),i.size===r&amp;&amp;n.done()})).next((()=&gt;i))}newChangeBuffer(e){return new Cl(this,!!e&amp;&amp;e.trackRemovals)}getSize(e){return this.getMetadata(e).next((e=&gt;e.byteSize))}getMetadata(e){return Tl(e).get("remoteDocumentGlobalKey").next((e=&gt;(Ur(!!e),e)))}Xn(e,t){return Tl(e).put("remoteDocumentGlobalKey",t)}Zn(e,t){if(t){const e=function(e,t){let n;if(t.document)n=Kc(e.le,t.document,!!t.hasCommittedMutations);else if(t.noDocument){const e=fi.fromSegments(t.noDocument.path),r=hu(t.noDocument.readTime);n=ho.newNoDocument(e,r),t.hasCommittedMutations&amp;&amp;n.setHasCommittedMutations()}else{if(!t.unknownDocument)return Br();{const e=fi.fromSegments(t.unknownDocument.path),r=hu(t.unknownDocument.version);n=ho.newUnknownDocument(e,r)}}return t.readTime&amp;&amp;n.setReadTime(function(e){const t=new ai(e[0],e[1]);return ci.fromTimestamp(t)}(t.readTime)),n}(this.serializer,t);if(!e.isNoDocument()||!e.version.isEqual(ci.min()))return e}return ho.newInvalidDocument(e)}}function Il(e){return new bl(e)}class Cl extends wl{constructor(e,t){super(),this.rs=e,this.trackRemovals=t,this.os=new ua((e=&gt;e.toString()),((e,t)=&gt;e.isEqual(t)))}applyChanges(e){const t=[];let n=0,r=new Es(((e,t)=&gt;ii(e.canonicalString(),t.canonicalString())));return this.changes.forEach(((i,s)=&gt;{const o=this.os.get(i);if(t.push(this.rs.removeEntry(e,i,o.readTime)),s.isValidDocument()){const a=cu(this.rs.serializer,s);r=r.add(i.path.popLast());const c=nl(a);n+=c-o.size,t.push(this.rs.addEntry(e,i,a))}else if(n-=o.size,this.trackRemovals){const n=cu(this.rs.serializer,s.convertToNoDocument(ci.min()));t.push(this.rs.addEntry(e,i,n))}})),r.forEach((n=&gt;{t.push(this.rs.indexManager.addToCollectionParentIndex(e,n))})),t.push(this.rs.updateMetadata(e,n)),ki.waitFor(t)}getFromCache(e,t){return this.rs.ts(e,t).next((e=&gt;(this.os.set(t,{size:e.size,readTime:e.document.readTime}),e.document)))}getAllFromCache(e,t){return this.rs.ns(e,t).next((({documents:e,ss:t})=&gt;(t.forEach(((t,n)=&gt;{this.os.set(t,{size:n,readTime:e.get(t).readTime})})),e)))}}function Tl(e){return _s(e,"remoteDocumentGlobal")}function El(e){return _s(e,"remoteDocumentsV14")}function Sl(e){const t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function xl(e,t){const n=t.documentKey.path.toArray();return[e,uu(t.readTime),n.slice(0,n.length-2),n.length&gt;0?n[n.length-1]:""]}function kl(e,t){const n=e.path.toArray(),r=t.path.toArray();let i=0;for(let e=0;e&lt;n.length-2&amp;&amp;e&lt;r.length-2;++e)if(i=ii(n[e],r[e]),i)return i;return i=ii(n.length,r.length),i||(i=ii(n[n.length-2],r[r.length-2]),i||ii(n[n.length-1],r[r.length-1]))}class Dl{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class Nl{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=&gt;(n=r,this.remoteDocumentCache.getEntry(e,t)))).next((e=&gt;(null!==n&amp;&amp;Ka(n.mutation,e,ks.empty(),ai.now()),e)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=&gt;this.getLocalViewOfDocuments(e,t,wa()).next((()=&gt;t))))}getLocalViewOfDocuments(e,t,n=wa()){const r=ga();return this.populateOverlays(e,r,t).next((()=&gt;this.computeViews(e,t,r,n).next((e=&gt;{let t=fa();return e.forEach(((e,n)=&gt;{t=t.insert(e,n.overlayedDocument)})),t}))))}getOverlayedDocuments(e,t){const n=ga();return this.populateOverlays(e,n,t).next((()=&gt;this.computeViews(e,t,n,wa())))}populateOverlays(e,t,n){const r=[];return n.forEach((e=&gt;{t.has(e)||r.push(e)})),this.documentOverlayCache.getOverlays(e,r).next((e=&gt;{e.forEach(((e,n)=&gt;{t.set(e,n)}))}))}computeViews(e,t,n,r){let i=ha();const s=ya(),o=ya();return t.forEach(((e,t)=&gt;{const o=n.get(t.key);r.has(t.key)&amp;&amp;(void 0===o||o.mutation instanceof Qa)?i=i.insert(t.key,t):void 0!==o?(s.set(t.key,o.mutation.getFieldMask()),Ka(o.mutation,t,o.mutation.getFieldMask(),ai.now())):s.set(t.key,ks.empty())})),this.recalculateAndSaveOverlays(e,i).next((e=&gt;(e.forEach(((e,t)=&gt;s.set(e,t))),t.forEach(((e,t)=&gt;{var n;return o.set(e,new Dl(t,null!==(n=s.get(e))&amp;&amp;void 0!==n?n:null))})),o)))}recalculateAndSaveOverlays(e,t){const n=ya();let r=new Is(((e,t)=&gt;e-t)),i=wa();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((e=&gt;{for(const i of e)i.keys().forEach((e=&gt;{const s=t.get(e);if(null===s)return;let o=n.get(e)||ks.empty();o=i.applyToLocalView(s,o),n.set(e,o);const a=(r.get(i.batchId)||wa()).add(e);r=r.insert(i.batchId,a)}))})).next((()=&gt;{const s=[],o=r.getReverseIterator();for(;o.hasNext();){const r=o.getNext(),a=r.key,c=r.value,u=ma();c.forEach((e=&gt;{if(!i.has(e)){const r=za(t.get(e),n.get(e));null!==r&amp;&amp;u.set(e,r),i=i.add(e)}})),s.push(this.documentOverlayCache.saveOverlays(e,a,u))}return ki.waitFor(s)})).next((()=&gt;n))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=&gt;this.recalculateAndSaveOverlays(e,t)))}getDocumentsMatchingQuery(e,t,n){return function(e){return fi.isDocumentKey(e.path)&amp;&amp;null===e.collectionGroup&amp;&amp;0===e.filters.length}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):Xo(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n):this.getDocumentsMatchingCollectionQuery(e,t,n)}getNextDocuments(e,t,n,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next((i=&gt;{const s=r-i.size&gt;0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-i.size):ki.resolve(ga());let o=-1,a=i;return s.next((t=&gt;ki.forEach(t,((t,n)=&gt;(o&lt;n.largestBatchId&amp;&amp;(o=n.largestBatchId),i.get(t)?ki.resolve():this.remoteDocumentCache.getEntry(e,t).next((e=&gt;{a=a.insert(t,e)}))))).next((()=&gt;this.populateOverlays(e,t,i))).next((()=&gt;this.computeViews(e,a,t,wa()))).next((e=&gt;({batchId:o,changes:pa(e)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new fi(t)).next((e=&gt;{let t=fa();return e.isFoundDocument()&amp;&amp;(t=t.insert(e.key,e)),t}))}getDocumentsMatchingCollectionGroupQuery(e,t,n){const r=t.collectionGroup;let i=fa();return this.indexManager.getCollectionParents(e,r).next((s=&gt;ki.forEach(s,(s=&gt;{const o=function(e,t){return new Ko(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,s.child(r));return this.getDocumentsMatchingCollectionQuery(e,o,n).next((e=&gt;{e.forEach(((e,t)=&gt;{i=i.insert(e,t)}))}))})).next((()=&gt;i))))}getDocumentsMatchingCollectionQuery(e,t,n){let r;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next((i=&gt;(r=i,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,r)))).next((e=&gt;{r.forEach(((t,n)=&gt;{const r=n.getKey();null===e.get(r)&amp;&amp;(e=e.insert(r,ho.newInvalidDocument(r)))}));let n=fa();return e.forEach(((e,i)=&gt;{const s=r.get(e);void 0!==s&amp;&amp;Ka(s.mutation,i,ks.empty(),ai.now()),sa(t,i)&amp;&amp;(n=n.insert(e,i))})),n}))}}class Al{constructor(e){this.serializer=e,this.us=new Map,this.cs=new Map}getBundleMetadata(e,t){return ki.resolve(this.us.get(t))}saveBundleMetadata(e,t){var n;return this.us.set(t.id,{id:(n=t).id,version:n.version,createTime:Fc(n.createTime)}),ki.resolve()}getNamedQuery(e,t){return ki.resolve(this.cs.get(t))}saveNamedQuery(e,t){return this.cs.set(t.name,function(e){return{name:e.name,query:gu(e.bundledQuery),readTime:Fc(e.readTime)}}(t)),ki.resolve()}}class Pl{constructor(){this.overlays=new Is(fi.comparator),this.hs=new Map}getOverlay(e,t){return ki.resolve(this.overlays.get(t))}getOverlays(e,t){const n=ga();return ki.forEach(t,(t=&gt;this.getOverlay(e,t).next((e=&gt;{null!==e&amp;&amp;n.set(t,e)})))).next((()=&gt;n))}saveOverlays(e,t,n){return n.forEach(((n,r)=&gt;{this.de(e,t,r)})),ki.resolve()}removeOverlaysForBatchId(e,t,n){const r=this.hs.get(n);return void 0!==r&amp;&amp;(r.forEach((e=&gt;this.overlays=this.overlays.remove(e))),this.hs.delete(n)),ki.resolve()}getOverlaysForCollection(e,t,n){const r=ga(),i=t.length+1,s=new fi(t.child("")),o=this.overlays.getIteratorFrom(s);for(;o.hasNext();){const e=o.getNext().value,s=e.getKey();if(!t.isPrefixOf(s.path))break;s.path.length===i&amp;&amp;e.largestBatchId&gt;n&amp;&amp;r.set(e.getKey(),e)}return ki.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new Is(((e,t)=&gt;e-t));const s=this.overlays.getIterator();for(;s.hasNext();){const e=s.getNext().value;if(e.getKey().getCollectionGroup()===t&amp;&amp;e.largestBatchId&gt;n){let t=i.get(e.largestBatchId);null===t&amp;&amp;(t=ga(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}const o=ga(),a=i.getIterator();for(;a.hasNext()&amp;&amp;(a.getNext().value.forEach(((e,t)=&gt;o.set(e,t))),!(o.size()&gt;=r)););return ki.resolve(o)}de(e,t,n){const r=this.overlays.get(n.key);if(null!==r){const e=this.hs.get(r.largestBatchId).delete(n.key);this.hs.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new rc(t,n));let i=this.hs.get(t);void 0===i&amp;&amp;(i=wa(),this.hs.set(t,i)),this.hs.set(t,i.add(n.key))}}class Rl{constructor(){this.ls=new Es(Ml.fs),this.ds=new Es(Ml._s)}isEmpty(){return this.ls.isEmpty()}addReference(e,t){const n=new Ml(e,t);this.ls=this.ls.add(n),this.ds=this.ds.add(n)}ws(e,t){e.forEach((e=&gt;this.addReference(e,t)))}removeReference(e,t){this.gs(new Ml(e,t))}ys(e,t){e.forEach((e=&gt;this.removeReference(e,t)))}ps(e){const t=new fi(new li([])),n=new Ml(t,e),r=new Ml(t,e+1),i=[];return this.ds.forEachInRange([n,r],(e=&gt;{this.gs(e),i.push(e.key)})),i}Is(){this.ls.forEach((e=&gt;this.gs(e)))}gs(e){this.ls=this.ls.delete(e),this.ds=this.ds.delete(e)}Ts(e){const t=new fi(new li([])),n=new Ml(t,e),r=new Ml(t,e+1);let i=wa();return this.ds.forEachInRange([n,r],(e=&gt;{i=i.add(e.key)})),i}containsKey(e){const t=new Ml(e,0),n=this.ls.firstAfterOrEqual(t);return null!==n&amp;&amp;e.isEqual(n.key)}}class Ml{constructor(e,t){this.key=e,this.Es=t}static fs(e,t){return fi.comparator(e.key,t.key)||ii(e.Es,t.Es)}static _s(e,t){return ii(e.Es,t.Es)||fi.comparator(e.key,t.key)}}class Fl{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.As=1,this.Rs=new Es(Ml.fs)}checkEmpty(e){return ki.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,n,r){const i=this.As;this.As++,this.mutationQueue.length&gt;0&amp;&amp;this.mutationQueue[this.mutationQueue.length-1];const s=new tc(i,t,n,r);this.mutationQueue.push(s);for(const t of r)this.Rs=this.Rs.add(new Ml(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return ki.resolve(s)}lookupMutationBatch(e,t){return ki.resolve(this.vs(t))}getNextMutationBatchAfterBatchId(e,t){const n=t+1,r=this.Ps(n),i=r&lt;0?0:r;return ki.resolve(this.mutationQueue.length&gt;i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return ki.resolve(0===this.mutationQueue.length?-1:this.As-1)}getAllMutationBatches(e){return ki.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const n=new Ml(t,0),r=new Ml(t,Number.POSITIVE_INFINITY),i=[];return this.Rs.forEachInRange([n,r],(e=&gt;{const t=this.vs(e.Es);i.push(t)})),ki.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new Es(ii);return t.forEach((e=&gt;{const t=new Ml(e,0),r=new Ml(e,Number.POSITIVE_INFINITY);this.Rs.forEachInRange([t,r],(e=&gt;{n=n.add(e.Es)}))})),ki.resolve(this.bs(n))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1;let i=n;fi.isDocumentKey(i)||(i=i.child(""));const s=new Ml(new fi(i),0);let o=new Es(ii);return this.Rs.forEachWhile((e=&gt;{const t=e.key.path;return!!n.isPrefixOf(t)&amp;&amp;(t.length===r&amp;&amp;(o=o.add(e.Es)),!0)}),s),ki.resolve(this.bs(o))}bs(e){const t=[];return e.forEach((e=&gt;{const n=this.vs(e);null!==n&amp;&amp;t.push(n)})),t}removeMutationBatch(e,t){Ur(0===this.Vs(t.batchId,"removed")),this.mutationQueue.shift();let n=this.Rs;return ki.forEach(t.mutations,(r=&gt;{const i=new Ml(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)})).next((()=&gt;{this.Rs=n}))}Dn(e){}containsKey(e,t){const n=new Ml(t,0),r=this.Rs.firstAfterOrEqual(n);return ki.resolve(t.isEqual(r&amp;&amp;r.key))}performConsistencyCheck(e){return this.mutationQueue.length,ki.resolve()}Vs(e,t){return this.Ps(e)}Ps(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}vs(e){const t=this.Ps(e);return t&lt;0||t&gt;=this.mutationQueue.length?null:this.mutationQueue[t]}}class Ol{constructor(e){this.Ss=e,this.docs=new Is(fi.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const n=t.key,r=this.docs.get(n),i=r?r.size:0,s=this.Ss(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:s}),this.size+=s-i,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&amp;&amp;(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const n=this.docs.get(t);return ki.resolve(n?n.document.mutableCopy():ho.newInvalidDocument(t))}getEntries(e,t){let n=ha();return t.forEach((e=&gt;{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():ho.newInvalidDocument(e))})),ki.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let i=ha();const s=t.path,o=new fi(s.child("")),a=this.docs.getIteratorFrom(o);for(;a.hasNext();){const{key:e,value:{document:o}}=a.getNext();if(!s.isPrefixOf(e.path))break;e.path.length&gt;s.length+1||Ti(Ii(o),n)&lt;=0||(r.has(o.key)||sa(t,o))&amp;&amp;(i=i.insert(o.key,o.mutableCopy()))}return ki.resolve(i)}getAllFromCollectionGroup(e,t,n,r){Br()}Ds(e,t){return ki.forEach(this.docs,(e=&gt;t(e)))}newChangeBuffer(e){return new Ll(this)}getSize(e){return ki.resolve(this.size)}}class Ll extends wl{constructor(e){super(),this.rs=e}applyChanges(e){const t=[];return this.changes.forEach(((n,r)=&gt;{r.isValidDocument()?t.push(this.rs.addEntry(e,r)):this.rs.removeEntry(n)})),ki.waitFor(t)}getFromCache(e,t){return this.rs.getEntry(e,t)}getAllFromCache(e,t){return this.rs.getEntries(e,t)}}class ql{constructor(e){this.persistence=e,this.Cs=new ua((e=&gt;Vo(e)),Bo),this.lastRemoteSnapshotVersion=ci.min(),this.highestTargetId=0,this.xs=0,this.Ns=new Rl,this.targetCount=0,this.ks=cl.Nn()}forEachTarget(e,t){return this.Cs.forEach(((e,n)=&gt;t(n))),ki.resolve()}getLastRemoteSnapshotVersion(e){return ki.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return ki.resolve(this.xs)}allocateTargetId(e){return this.highestTargetId=this.ks.next(),ki.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&amp;&amp;(this.lastRemoteSnapshotVersion=n),t&gt;this.xs&amp;&amp;(this.xs=t),ki.resolve()}$n(e){this.Cs.set(e.target,e);const t=e.targetId;t&gt;this.highestTargetId&amp;&amp;(this.ks=new cl(t),this.highestTargetId=t),e.sequenceNumber&gt;this.xs&amp;&amp;(this.xs=e.sequenceNumber)}addTargetData(e,t){return this.$n(t),this.targetCount+=1,ki.resolve()}updateTargetData(e,t){return this.$n(t),ki.resolve()}removeTargetData(e,t){return this.Cs.delete(t.target),this.Ns.ps(t.targetId),this.targetCount-=1,ki.resolve()}removeTargets(e,t,n){let r=0;const i=[];return this.Cs.forEach(((s,o)=&gt;{o.sequenceNumber&lt;=t&amp;&amp;null===n.get(o.targetId)&amp;&amp;(this.Cs.delete(s),i.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)})),ki.waitFor(i).next((()=&gt;r))}getTargetCount(e){return ki.resolve(this.targetCount)}getTargetData(e,t){const n=this.Cs.get(t)||null;return ki.resolve(n)}addMatchingKeys(e,t,n){return this.Ns.ws(t,n),ki.resolve()}removeMatchingKeys(e,t,n){this.Ns.ys(t,n);const r=this.persistence.referenceDelegate,i=[];return r&amp;&amp;t.forEach((t=&gt;{i.push(r.markPotentiallyOrphaned(e,t))})),ki.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.Ns.ps(t),ki.resolve()}getMatchingKeysForTargetId(e,t){const n=this.Ns.Ts(t);return ki.resolve(n)}containsKey(e,t){return ki.resolve(this.Ns.containsKey(t))}}class Vl{constructor(e,t){this.Ms={},this.overlays={},this.Os=new Bi(0),this.$s=!1,this.$s=!0,this.referenceDelegate=e(this),this.Fs=new ql(this),this.indexManager=new $u,this.remoteDocumentCache=function(e){return new Ol(e)}((e=&gt;this.referenceDelegate.Bs(e))),this.serializer=new au(t),this.Ls=new Al(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.$s=!1,Promise.resolve()}get started(){return this.$s}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new Pl,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.Ms[e.toKey()];return n||(n=new Fl(t,this.referenceDelegate),this.Ms[e.toKey()]=n),n}getTargetCache(){return this.Fs}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ls}runTransaction(e,t,n){Or("MemoryPersistence","Starting transaction:",e);const r=new Bl(this.Os.next());return this.referenceDelegate.qs(),n(r).next((e=&gt;this.referenceDelegate.Us(r).next((()=&gt;e)))).toPromise().then((e=&gt;(r.raiseOnCommittedEvent(),e)))}Ks(e,t){return ki.or(Object.values(this.Ms).map((n=&gt;()=&gt;n.containsKey(e,t))))}}class Bl extends Si{constructor(e){super(),this.currentSequenceNumber=e}}class Ul{constructor(e){this.persistence=e,this.Gs=new Rl,this.Qs=null}static js(e){return new Ul(e)}get zs(){if(this.Qs)return this.Qs;throw Br()}addReference(e,t,n){return this.Gs.addReference(n,t),this.zs.delete(n.toString()),ki.resolve()}removeReference(e,t,n){return this.Gs.removeReference(n,t),this.zs.add(n.toString()),ki.resolve()}markPotentiallyOrphaned(e,t){return this.zs.add(t.toString()),ki.resolve()}removeTarget(e,t){this.Gs.ps(t.targetId).forEach((e=&gt;this.zs.add(e.toString())));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next((e=&gt;{e.forEach((e=&gt;this.zs.add(e.toString())))})).next((()=&gt;n.removeTargetData(e,t)))}qs(){this.Qs=new Set}Us(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return ki.forEach(this.zs,(n=&gt;{const r=fi.fromPath(n);return this.Ws(e,r).next((e=&gt;{e||t.removeEntry(r,ci.min())}))})).next((()=&gt;(this.Qs=null,t.apply(e))))}updateLimboDocument(e,t){return this.Ws(e,t).next((e=&gt;{e?this.zs.delete(t.toString()):this.zs.add(t.toString())}))}Bs(e){return 0}Ws(e,t){return ki.or([()=&gt;ki.resolve(this.Gs.containsKey(t)),()=&gt;this.persistence.getTargetCache().containsKey(e,t),()=&gt;this.persistence.Ks(e,t)])}}class jl{constructor(e,t){this.persistence=e,this.Hs=new ua((e=&gt;$i(e.path)),((e,t)=&gt;e.isEqual(t))),this.garbageCollector=yl(this,t)}static js(e,t){return new jl(e,t)}qs(){}Us(e){return ki.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}jn(e){const t=this.Hn(e);return this.persistence.getTargetCache().getTargetCount(e).next((e=&gt;t.next((t=&gt;e+t))))}Hn(e){let t=0;return this.zn(e,(e=&gt;{t++})).next((()=&gt;t))}zn(e,t){return ki.forEach(this.Hs,((n,r)=&gt;this.Yn(e,n,r).next((e=&gt;e?ki.resolve():t(r)))))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0;const r=this.persistence.getRemoteDocumentCache(),i=r.newChangeBuffer();return r.Ds(e,(r=&gt;this.Yn(e,r,t).next((e=&gt;{e||(n++,i.removeEntry(r,ci.min()))})))).next((()=&gt;i.apply(e))).next((()=&gt;n))}markPotentiallyOrphaned(e,t){return this.Hs.set(t,e.currentSequenceNumber),ki.resolve()}removeTarget(e,t){const n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.Hs.set(n,e.currentSequenceNumber),ki.resolve()}removeReference(e,t,n){return this.Hs.set(n,e.currentSequenceNumber),ki.resolve()}updateLimboDocument(e,t){return this.Hs.set(t,e.currentSequenceNumber),ki.resolve()}Bs(e){let t=e.key.toString().length;return e.isFoundDocument()&amp;&amp;(t+=Ys(e.data.value)),t}Yn(e,t,n){return ki.or([()=&gt;this.persistence.Ks(e,t),()=&gt;this.persistence.getTargetCache().containsKey(e,t),()=&gt;{const e=this.Hs.get(t);return ki.resolve(void 0!==e&amp;&amp;e&gt;n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class zl{constructor(e){this.serializer=e}$(e,t,n,r){const i=new Di("createOrUpgrade",t);n&lt;1&amp;&amp;r&gt;=1&amp;&amp;(function(e){e.createObjectStore("owner")}(e),function(e){e.createObjectStore("mutationQueues",{keyPath:"userId"}),e.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Hi,{unique:!0}),e.createObjectStore("documentMutations")}(e),$l(e),function(e){e.createObjectStore("remoteDocuments")}(e));let s=ki.resolve();return n&lt;3&amp;&amp;r&gt;=3&amp;&amp;(0!==n&amp;&amp;(function(e){e.deleteObjectStore("targetDocuments"),e.deleteObjectStore("targets"),e.deleteObjectStore("targetGlobal")}(e),$l(e)),s=s.next((()=&gt;function(e){const t=e.store("targetGlobal"),n={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:ci.min().toTimestamp(),targetCount:0};return t.put("targetGlobalKey",n)}(i)))),n&lt;4&amp;&amp;r&gt;=4&amp;&amp;(0!==n&amp;&amp;(s=s.next((()=&gt;function(e,t){return t.store("mutations").j().next((n=&gt;{e.deleteObjectStore("mutations"),e.createObjectStore("mutations",{keyPath:"batchId",autoIncrement:!0}).createIndex("userMutationsIndex",Hi,{unique:!0});const r=t.store("mutations"),i=n.map((e=&gt;r.put(e)));return ki.waitFor(i)}))}(e,i)))),s=s.next((()=&gt;{!function(e){e.createObjectStore("clientMetadata",{keyPath:"clientId"})}(e)}))),n&lt;5&amp;&amp;r&gt;=5&amp;&amp;(s=s.next((()=&gt;this.Js(i)))),n&lt;6&amp;&amp;r&gt;=6&amp;&amp;(s=s.next((()=&gt;(function(e){e.createObjectStore("remoteDocumentGlobal")}(e),this.Ys(i))))),n&lt;7&amp;&amp;r&gt;=7&amp;&amp;(s=s.next((()=&gt;this.Xs(i)))),n&lt;8&amp;&amp;r&gt;=8&amp;&amp;(s=s.next((()=&gt;this.Zs(e,i)))),n&lt;9&amp;&amp;r&gt;=9&amp;&amp;(s=s.next((()=&gt;{!function(e){e.objectStoreNames.contains("remoteDocumentChanges")&amp;&amp;e.deleteObjectStore("remoteDocumentChanges")}(e)}))),n&lt;10&amp;&amp;r&gt;=10&amp;&amp;(s=s.next((()=&gt;this.ti(i)))),n&lt;11&amp;&amp;r&gt;=11&amp;&amp;(s=s.next((()=&gt;{!function(e){e.createObjectStore("bundles",{keyPath:"bundleId"})}(e),function(e){e.createObjectStore("namedQueries",{keyPath:"name"})}(e)}))),n&lt;12&amp;&amp;r&gt;=12&amp;&amp;(s=s.next((()=&gt;{!function(e){const t=e.createObjectStore("documentOverlays",{keyPath:us});t.createIndex("collectionPathOverlayIndex",ls,{unique:!1}),t.createIndex("collectionGroupOverlayIndex",hs,{unique:!1})}(e)}))),n&lt;13&amp;&amp;r&gt;=13&amp;&amp;(s=s.next((()=&gt;function(e){const t=e.createObjectStore("remoteDocumentsV14",{keyPath:Ji});t.createIndex("documentKeyIndex",Zi),t.createIndex("collectionGroupIndex",es)}(e))).next((()=&gt;this.ei(e,i))).next((()=&gt;e.deleteObjectStore("remoteDocuments")))),n&lt;14&amp;&amp;r&gt;=14&amp;&amp;(s=s.next((()=&gt;this.ni(e,i)))),n&lt;15&amp;&amp;r&gt;=15&amp;&amp;(s=s.next((()=&gt;function(e){e.createObjectStore("indexConfiguration",{keyPath:"indexId",autoIncrement:!0}).createIndex("collectionGroupIndex","collectionGroup",{unique:!1}),e.createObjectStore("indexState",{keyPath:ss}).createIndex("sequenceNumberIndex",os,{unique:!1}),e.createObjectStore("indexEntries",{keyPath:as}).createIndex("documentKeyIndex",cs,{unique:!1})}(e)))),s}Ys(e){let t=0;return e.store("remoteDocuments").X(((e,n)=&gt;{t+=nl(n)})).next((()=&gt;{const n={byteSize:t};return e.store("remoteDocumentGlobal").put("remoteDocumentGlobalKey",n)}))}Js(e){const t=e.store("mutationQueues"),n=e.store("mutations");return t.j().next((t=&gt;ki.forEach(t,(t=&gt;{const r=IDBKeyRange.bound([t.userId,-1],[t.userId,t.lastAcknowledgedBatchId]);return n.j("userMutationsIndex",r).next((n=&gt;ki.forEach(n,(n=&gt;{Ur(n.userId===t.userId);const r=du(this.serializer,n);return tl(e,t.userId,r).next((()=&gt;{}))}))))}))))}Xs(e){const t=e.store("targetDocuments"),n=e.store("remoteDocuments");return e.store("targetGlobal").get("targetGlobalKey").next((e=&gt;{const r=[];return n.X(((n,i)=&gt;{const s=new li(n),o=function(e){return[0,$i(e)]}(s);r.push(t.get(o).next((n=&gt;n?ki.resolve():(n=&gt;t.put({targetId:0,path:$i(n),sequenceNumber:e.highestListenSequenceNumber}))(s))))})).next((()=&gt;ki.waitFor(r)))}))}Zs(e,t){e.createObjectStore("collectionParents",{keyPath:is});const n=t.store("collectionParents"),r=new Ku,i=e=&gt;{if(r.add(e)){const t=e.lastSegment(),r=e.popLast();return n.put({collectionId:t,parent:$i(r)})}};return t.store("remoteDocuments").X({Y:!0},((e,t)=&gt;{const n=new li(e);return i(n.popLast())})).next((()=&gt;t.store("documentMutations").X({Y:!0},(([e,t,n],r)=&gt;{const s=Wi(t);return i(s.popLast())}))))}ti(e){const t=e.store("targets");return t.X(((e,n)=&gt;{const r=fu(n),i=pu(this.serializer,r);return t.put(i)}))}ei(e,t){const n=t.store("remoteDocuments"),r=[];return n.X(((e,n)=&gt;{const i=t.store("remoteDocumentsV14"),s=(o=n,o.document?new fi(li.fromString(o.document.name).popFirst(5)):o.noDocument?fi.fromSegments(o.noDocument.path):o.unknownDocument?fi.fromSegments(o.unknownDocument.path):Br()).path.toArray();var o;const a={prefixPath:s.slice(0,s.length-2),collectionGroup:s[s.length-2],documentId:s[s.length-1],readTime:n.readTime||[0,0],unknownDocument:n.unknownDocument,noDocument:n.noDocument,document:n.document,hasCommittedMutations:!!n.hasCommittedMutations};r.push(i.put(a))})).next((()=&gt;ki.waitFor(r)))}ni(e,t){const n=t.store("mutations"),r=Il(this.serializer),i=new Vl(Ul.js,this.serializer.le);return n.j().next((e=&gt;{const n=new Map;return e.forEach((e=&gt;{var t;let r=null!==(t=n.get(e.userId))&amp;&amp;void 0!==t?t:wa();du(this.serializer,e).keys().forEach((e=&gt;r=r.add(e))),n.set(e.userId,r)})),ki.forEach(n,((e,n)=&gt;{const s=new Ar(n),o=Iu.fe(this.serializer,s),a=i.getIndexManager(s),c=rl.fe(s,this.serializer,a,i.referenceDelegate);return new Nl(r,c,o,a).recalculateAndSaveOverlaysForDocumentKeys(new ys(t,Bi.ct),e).next()}))}))}}function $l(e){e.createObjectStore("targetDocuments",{keyPath:ns}).createIndex("documentTargetsIndex",rs,{unique:!0}),e.createObjectStore("targets",{keyPath:"targetId"}).createIndex("queryTargetsIndex",ts,{unique:!0}),e.createObjectStore("targetGlobal")}const Kl="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.";class Gl{constructor(e,t,n,r,i,s,o,a,c,u,l=15){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=n,this.si=i,this.window=s,this.document=o,this.ii=c,this.ri=u,this.oi=l,this.Os=null,this.$s=!1,this.isPrimary=!1,this.networkEnabled=!0,this.ui=null,this.inForeground=!1,this.ci=null,this.ai=null,this.hi=Number.NEGATIVE_INFINITY,this.li=e=&gt;Promise.resolve(),!Gl.D())throw new Kr($r.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new _l(this,r),this.fi=t+"main",this.serializer=new au(a),this.di=new Ni(this.fi,this.oi,new zl(this.serializer)),this.Fs=new ul(this.referenceDelegate,this.serializer),this.remoteDocumentCache=Il(this.serializer),this.Ls=new vu,this.window&amp;&amp;this.window.localStorage?this._i=this.window.localStorage:(this._i=null,!1===u&amp;&amp;Lr("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.wi().then((()=&gt;{if(!this.isPrimary&amp;&amp;!this.allowTabSynchronization)throw new Kr($r.FAILED_PRECONDITION,Kl);return this.mi(),this.gi(),this.yi(),this.runTransaction("getHighestListenSequenceNumber","readonly",(e=&gt;this.Fs.getHighestSequenceNumber(e)))})).then((e=&gt;{this.Os=new Bi(e,this.ii)})).then((()=&gt;{this.$s=!0})).catch((e=&gt;(this.di&amp;&amp;this.di.close(),Promise.reject(e))))}pi(e){return this.li=async t=&gt;{if(this.started)return e(t)},e(this.isPrimary)}setDatabaseDeletedListener(e){this.di.B((async t=&gt;{null===t.newVersion&amp;&amp;await e()}))}setNetworkEnabled(e){this.networkEnabled!==e&amp;&amp;(this.networkEnabled=e,this.si.enqueueAndForget((async()=&gt;{this.started&amp;&amp;await this.wi()})))}wi(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(e=&gt;Hl(e).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next((()=&gt;{if(this.isPrimary)return this.Ii(e).next((e=&gt;{e||(this.isPrimary=!1,this.si.enqueueRetryable((()=&gt;this.li(!1))))}))})).next((()=&gt;this.Ti(e))).next((t=&gt;this.isPrimary&amp;&amp;!t?this.Ei(e).next((()=&gt;!1)):!!t&amp;&amp;this.Ai(e).next((()=&gt;!0)))))).catch((e=&gt;{if(Ri(e))return Or("IndexedDbPersistence","Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return Or("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1})).then((e=&gt;{this.isPrimary!==e&amp;&amp;this.si.enqueueRetryable((()=&gt;this.li(e))),this.isPrimary=e}))}Ii(e){return Wl(e).get("owner").next((e=&gt;ki.resolve(this.Ri(e))))}vi(e){return Hl(e).delete(this.clientId)}async Pi(){if(this.isPrimary&amp;&amp;!this.bi(this.hi,18e5)){this.hi=Date.now();const e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(e=&gt;{const t=_s(e,"clientMetadata");return t.j().next((e=&gt;{const n=this.Vi(e,18e5),r=e.filter((e=&gt;-1===n.indexOf(e)));return ki.forEach(r,(e=&gt;t.delete(e.clientId))).next((()=&gt;r))}))})).catch((()=&gt;[]));if(this._i)for(const t of e)this._i.removeItem(this.Si(t.clientId))}}yi(){this.ai=this.si.enqueueAfterDelay("client_metadata_refresh",4e3,(()=&gt;this.wi().then((()=&gt;this.Pi())).then((()=&gt;this.yi()))))}Ri(e){return!!e&amp;&amp;e.ownerId===this.clientId}Ti(e){return this.ri?ki.resolve(!0):Wl(e).get("owner").next((t=&gt;{if(null!==t&amp;&amp;this.bi(t.leaseTimestampMs,5e3)&amp;&amp;!this.Di(t.ownerId)){if(this.Ri(t)&amp;&amp;this.networkEnabled)return!0;if(!this.Ri(t)){if(!t.allowTabSynchronization)throw new Kr($r.FAILED_PRECONDITION,Kl);return!1}}return!(!this.networkEnabled||!this.inForeground)||Hl(e).j().next((e=&gt;void 0===this.Vi(e,5e3).find((e=&gt;{if(this.clientId!==e.clientId){const t=!this.networkEnabled&amp;&amp;e.networkEnabled,n=!this.inForeground&amp;&amp;e.inForeground,r=this.networkEnabled===e.networkEnabled;if(t||n&amp;&amp;r)return!0}return!1}))))})).next((e=&gt;(this.isPrimary!==e&amp;&amp;Or("IndexedDbPersistence",`Client ${e?"is":"is not"} eligible for a primary lease.`),e)))}async shutdown(){this.$s=!1,this.Ci(),this.ai&amp;&amp;(this.ai.cancel(),this.ai=null),this.xi(),this.Ni(),await this.di.runTransaction("shutdown","readwrite",["owner","clientMetadata"],(e=&gt;{const t=new ys(e,Bi.ct);return this.Ei(t).next((()=&gt;this.vi(t)))})),this.di.close(),this.ki()}Vi(e,t){return e.filter((e=&gt;this.bi(e.updateTimeMs,t)&amp;&amp;!this.Di(e.clientId)))}Mi(){return this.runTransaction("getActiveClients","readonly",(e=&gt;Hl(e).j().next((e=&gt;this.Vi(e,18e5).map((e=&gt;e.clientId))))))}get started(){return this.$s}getMutationQueue(e,t){return rl.fe(e,this.serializer,t,this.referenceDelegate)}getTargetCache(){return this.Fs}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new Wu(e,this.serializer.le.databaseId)}getDocumentOverlayCache(e){return Iu.fe(this.serializer,e)}getBundleCache(){return this.Ls}runTransaction(e,t,n){Or("IndexedDbPersistence","Starting transaction:",e);const r="readonly"===t?"readonly":"readwrite",i=15===(s=this.oi)?ms:14===s?gs:13===s?ps:12===s?fs:11===s?ds:void Br();var s;let o;return this.di.runTransaction(e,r,i,(r=&gt;(o=new ys(r,this.Os?this.Os.next():Bi.ct),"readwrite-primary"===t?this.Ii(o).next((e=&gt;!!e||this.Ti(o))).next((t=&gt;{if(!t)throw Lr(`Failed to obtain primary lease for action '${e}'.`),this.isPrimary=!1,this.si.enqueueRetryable((()=&gt;this.li(!1))),new Kr($r.FAILED_PRECONDITION,Ei);return n(o)})).next((e=&gt;this.Ai(o).next((()=&gt;e)))):this.Oi(o).next((()=&gt;n(o)))))).then((e=&gt;(o.raiseOnCommittedEvent(),e)))}Oi(e){return Wl(e).get("owner").next((e=&gt;{if(null!==e&amp;&amp;this.bi(e.leaseTimestampMs,5e3)&amp;&amp;!this.Di(e.ownerId)&amp;&amp;!this.Ri(e)&amp;&amp;!(this.ri||this.allowTabSynchronization&amp;&amp;e.allowTabSynchronization))throw new Kr($r.FAILED_PRECONDITION,Kl)}))}Ai(e){const t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return Wl(e).put("owner",t)}static D(){return Ni.D()}Ei(e){const t=Wl(e);return t.get("owner").next((e=&gt;this.Ri(e)?(Or("IndexedDbPersistence","Releasing primary lease."),t.delete("owner")):ki.resolve()))}bi(e,t){const n=Date.now();return!(e&lt;n-t||e&gt;n&amp;&amp;(Lr(`Detected an update time that is in the future: ${e} &gt; ${n}`),1))}mi(){null!==this.document&amp;&amp;"function"==typeof this.document.addEventListener&amp;&amp;(this.ci=()=&gt;{this.si.enqueueAndForget((()=&gt;(this.inForeground="visible"===this.document.visibilityState,this.wi())))},this.document.addEventListener("visibilitychange",this.ci),this.inForeground="visible"===this.document.visibilityState)}xi(){this.ci&amp;&amp;(this.document.removeEventListener("visibilitychange",this.ci),this.ci=null)}gi(){var e;"function"==typeof(null===(e=this.window)||void 0===e?void 0:e.addEventListener)&amp;&amp;(this.ui=()=&gt;{this.Ci();const e=/(?:Version|Mobile)\/1[456]/;(0,a.G6)()&amp;&amp;(navigator.appVersion.match(e)||navigator.userAgent.match(e))&amp;&amp;this.si.enterRestrictedMode(!0),this.si.enqueueAndForget((()=&gt;this.shutdown()))},this.window.addEventListener("pagehide",this.ui))}Ni(){this.ui&amp;&amp;(this.window.removeEventListener("pagehide",this.ui),this.ui=null)}Di(e){var t;try{const n=null!==(null===(t=this._i)||void 0===t?void 0:t.getItem(this.Si(e)));return Or("IndexedDbPersistence",`Client '${e}' ${n?"is":"is not"} zombied in LocalStorage`),n}catch(e){return Lr("IndexedDbPersistence","Failed to get zombied client id.",e),!1}}Ci(){if(this._i)try{this._i.setItem(this.Si(this.clientId),String(Date.now()))}catch(e){Lr("Failed to set zombie client id.",e)}}ki(){if(this._i)try{this._i.removeItem(this.Si(this.clientId))}catch(e){}}Si(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function Wl(e){return _s(e,"owner")}function Hl(e){return _s(e,"clientMetadata")}function Ql(e,t){let n=e.projectId;return e.isDefaultDatabase||(n+="."+e.database),"firestore/"+t+"/"+n+"/"}class Yl{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.$i=n,this.Fi=r}static Bi(e,t){let n=wa(),r=wa();for(const e of t.docChanges)switch(e.type){case 0:n=n.add(e.doc.key);break;case 1:r=r.add(e.doc.key)}return new Yl(e,t.fromCache,n,r)}}class Xl{constructor(){this.Li=!1}initialize(e,t){this.qi=e,this.indexManager=t,this.Li=!0}getDocumentsMatchingQuery(e,t,n,r){return this.Ui(e,t).next((i=&gt;i||this.Ki(e,t,r,n))).next((n=&gt;n||this.Gi(e,t)))}Ui(e,t){if(Ho(t))return ki.resolve(null);let n=Zo(t);return this.indexManager.getIndexType(e,n).next((r=&gt;0===r?null:(null!==t.limit&amp;&amp;1===r&amp;&amp;(t=ta(t,null,"F"),n=Zo(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next((r=&gt;{const i=wa(...r);return this.qi.getDocuments(e,i).next((r=&gt;this.indexManager.getMinOffset(e,n).next((n=&gt;{const s=this.Qi(t,r);return this.ji(t,s,i,n.readTime)?this.Ui(e,ta(t,null,"F")):this.zi(e,s,t,n)}))))})))))}Ki(e,t,n,r){return Ho(t)||r.isEqual(ci.min())?this.Gi(e,t):this.qi.getDocuments(e,n).next((i=&gt;{const s=this.Qi(t,i);return this.ji(t,s,n,r)?this.Gi(e,t):(Mr()&lt;=o.in.DEBUG&amp;&amp;Or("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),ia(t)),this.zi(e,s,t,bi(r,-1)))}))}Qi(e,t){let n=new Es(aa(e));return t.forEach(((t,r)=&gt;{sa(e,r)&amp;&amp;(n=n.add(r))})),n}ji(e,t,n,r){if(null===e.limit)return!1;if(n.size!==t.size)return!0;const i="F"===e.limitType?t.last():t.first();return!!i&amp;&amp;(i.hasPendingWrites||i.version.compareTo(r)&gt;0)}Gi(e,t){return Mr()&lt;=o.in.DEBUG&amp;&amp;Or("QueryEngine","Using full collection scan to execute query:",ia(t)),this.qi.getDocumentsMatchingQuery(e,t,Ci.min())}zi(e,t,n,r){return this.qi.getDocumentsMatchingQuery(e,n,r).next((e=&gt;(t.forEach((t=&gt;{e=e.insert(t.key,t)})),e)))}}class Jl{constructor(e,t,n,r){this.persistence=e,this.Wi=t,this.serializer=r,this.Hi=new Is(ii),this.Ji=new ua((e=&gt;Vo(e)),Bo),this.Yi=new Map,this.Xi=e.getRemoteDocumentCache(),this.Fs=e.getTargetCache(),this.Ls=e.getBundleCache(),this.Zi(n)}Zi(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Nl(this.Xi,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Xi.setIndexManager(this.indexManager),this.Wi.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",(t=&gt;e.collect(t,this.Hi)))}}function Zl(e,t,n,r){return new Jl(e,t,n,r)}async function eh(e,t){const n=zr(e);return await n.persistence.runTransaction("Handle user change","readonly",(e=&gt;{let r;return n.mutationQueue.getAllMutationBatches(e).next((i=&gt;(r=i,n.Zi(t),n.mutationQueue.getAllMutationBatches(e)))).next((t=&gt;{const i=[],s=[];let o=wa();for(const e of r){i.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}for(const e of t){s.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}return n.localDocuments.getDocuments(e,o).next((e=&gt;({tr:e,removedBatchIds:i,addedBatchIds:s})))}))}))}function th(e){const t=zr(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",(e=&gt;t.Fs.getLastRemoteSnapshotVersion(e)))}function nh(e,t,n){let r=wa(),i=wa();return n.forEach((e=&gt;r=r.add(e))),t.getEntries(e,r).next((e=&gt;{let r=ha();return n.forEach(((n,s)=&gt;{const o=e.get(n);s.isFoundDocument()!==o.isFoundDocument()&amp;&amp;(i=i.add(n)),s.isNoDocument()&amp;&amp;s.version.isEqual(ci.min())?(t.removeEntry(n,s.readTime),r=r.insert(n,s)):!o.isValidDocument()||s.version.compareTo(o.version)&gt;0||0===s.version.compareTo(o.version)&amp;&amp;o.hasPendingWrites?(t.addEntry(s),r=r.insert(n,s)):Or("LocalStore","Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",s.version)})),{er:r,nr:i}}))}function rh(e,t){const n=zr(e);return n.persistence.runTransaction("Get next mutation batch","readonly",(e=&gt;(void 0===t&amp;&amp;(t=-1),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t))))}function ih(e,t){const n=zr(e);return n.persistence.runTransaction("Allocate target","readwrite",(e=&gt;{let r;return n.Fs.getTargetData(e,t).next((i=&gt;i?(r=i,ki.resolve(r)):n.Fs.allocateTargetId(e).next((i=&gt;(r=new ou(t,i,"TargetPurposeListen",e.currentSequenceNumber),n.Fs.addTargetData(e,r).next((()=&gt;r)))))))})).then((e=&gt;{const r=n.Hi.get(e.targetId);return(null===r||e.snapshotVersion.compareTo(r.snapshotVersion)&gt;0)&amp;&amp;(n.Hi=n.Hi.insert(e.targetId,e),n.Ji.set(t,e.targetId)),e}))}async function sh(e,t,n){const r=zr(e),i=r.Hi.get(t),s=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",s,(e=&gt;r.persistence.referenceDelegate.removeTarget(e,i)))}catch(e){if(!Ri(e))throw e;Or("LocalStore",`Failed to update sequence numbers for target ${t}: ${e}`)}r.Hi=r.Hi.remove(t),r.Ji.delete(i.target)}function oh(e,t,n){const r=zr(e);let i=ci.min(),s=wa();return r.persistence.runTransaction("Execute query","readonly",(e=&gt;function(e,t,n){const r=zr(e),i=r.Ji.get(n);return void 0!==i?ki.resolve(r.Hi.get(i)):r.Fs.getTargetData(t,n)}(r,e,Zo(t)).next((t=&gt;{if(t)return i=t.lastLimboFreeSnapshotVersion,r.Fs.getMatchingKeysForTargetId(e,t.targetId).next((e=&gt;{s=e}))})).next((()=&gt;r.Wi.getDocumentsMatchingQuery(e,t,n?i:ci.min(),n?s:wa()))).next((e=&gt;(uh(r,oa(t),e),{documents:e,sr:s})))))}function ah(e,t){const n=zr(e),r=zr(n.Fs),i=n.Hi.get(t);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(e=&gt;r.he(e,t).next((e=&gt;e?e.target:null))))}function ch(e,t){const n=zr(e),r=n.Yi.get(t)||ci.min();return n.persistence.runTransaction("Get new document changes","readonly",(e=&gt;n.Xi.getAllFromCollectionGroup(e,t,bi(r,-1),Number.MAX_SAFE_INTEGER))).then((e=&gt;(uh(n,t,e),e)))}function uh(e,t,n){let r=e.Yi.get(t)||ci.min();n.forEach(((e,t)=&gt;{t.readTime.compareTo(r)&gt;0&amp;&amp;(r=t.readTime)})),e.Yi.set(t,r)}async function lh(e,t,n=wa()){const r=await ih(e,Zo(gu(t.bundledQuery))),i=zr(e);return i.persistence.runTransaction("Save named query","readwrite",(e=&gt;{const s=Fc(t.readTime);if(r.snapshotVersion.compareTo(s)&gt;=0)return i.Ls.saveNamedQuery(e,t);const o=r.withResumeToken(As.EMPTY_BYTE_STRING,s);return i.Hi=i.Hi.insert(o.targetId,o),i.Fs.updateTargetData(e,o).next((()=&gt;i.Fs.removeMatchingKeysForTargetId(e,r.targetId))).next((()=&gt;i.Fs.addMatchingKeys(e,n,r.targetId))).next((()=&gt;i.Ls.saveNamedQuery(e,t)))}))}function hh(e,t){return`firestore_clients_${e}_${t}`}function dh(e,t,n){let r=`firestore_mutations_${e}_${n}`;return t.isAuthenticated()&amp;&amp;(r+=`_${t.uid}`),r}function fh(e,t){return`firestore_targets_${e}_${t}`}class ph{constructor(e,t,n,r){this.user=e,this.batchId=t,this.state=n,this.error=r}static cr(e,t,n){const r=JSON.parse(n);let i,s="object"==typeof r&amp;&amp;-1!==["pending","acknowledged","rejected"].indexOf(r.state)&amp;&amp;(void 0===r.error||"object"==typeof r.error);return s&amp;&amp;r.error&amp;&amp;(s="string"==typeof r.error.message&amp;&amp;"string"==typeof r.error.code,s&amp;&amp;(i=new Kr(r.error.code,r.error.message))),s?new ph(e,t,r.state,i):(Lr("SharedClientState",`Failed to parse mutation state for ID '${t}': ${n}`),null)}ar(){const e={state:this.state,updateTimeMs:Date.now()};return this.error&amp;&amp;(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class gh{constructor(e,t,n){this.targetId=e,this.state=t,this.error=n}static cr(e,t){const n=JSON.parse(t);let r,i="object"==typeof n&amp;&amp;-1!==["not-current","current","rejected"].indexOf(n.state)&amp;&amp;(void 0===n.error||"object"==typeof n.error);return i&amp;&amp;n.error&amp;&amp;(i="string"==typeof n.error.message&amp;&amp;"string"==typeof n.error.code,i&amp;&amp;(r=new Kr(n.error.code,n.error.message))),i?new gh(e,n.state,r):(Lr("SharedClientState",`Failed to parse target state for ID '${e}': ${t}`),null)}ar(){const e={state:this.state,updateTimeMs:Date.now()};return this.error&amp;&amp;(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class mh{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static cr(e,t){const n=JSON.parse(t);let r="object"==typeof n&amp;&amp;n.activeTargetIds instanceof Array,i=Ia();for(let e=0;r&amp;&amp;e&lt;n.activeTargetIds.length;++e)r=zi(n.activeTargetIds[e]),i=i.add(n.activeTargetIds[e]);return r?new mh(e,i):(Lr("SharedClientState",`Failed to parse client data for instance '${e}': ${t}`),null)}}class yh{constructor(e,t){this.clientId=e,this.onlineState=t}static cr(e){const t=JSON.parse(e);return"object"==typeof t&amp;&amp;-1!==["Unknown","Online","Offline"].indexOf(t.onlineState)&amp;&amp;"string"==typeof t.clientId?new yh(t.clientId,t.onlineState):(Lr("SharedClientState",`Failed to parse online state: ${e}`),null)}}class _h{constructor(){this.activeTargetIds=Ia()}hr(e){this.activeTargetIds=this.activeTargetIds.add(e)}lr(e){this.activeTargetIds=this.activeTargetIds.delete(e)}ar(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class vh{constructor(e,t,n,r,i){this.window=e,this.si=t,this.persistenceKey=n,this.dr=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this._r=this.wr.bind(this),this.mr=new Is(ii),this.started=!1,this.gr=[];const s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&amp;");this.storage=this.window.localStorage,this.currentUser=i,this.yr=hh(this.persistenceKey,this.dr),this.pr=function(e){return`firestore_sequence_number_${e}`}(this.persistenceKey),this.mr=this.mr.insert(this.dr,new _h),this.Ir=new RegExp(`^firestore_clients_${s}_([^_]*)$`),this.Tr=new RegExp(`^firestore_mutations_${s}_(\\d+)(?:_(.*))?$`),this.Er=new RegExp(`^firestore_targets_${s}_(\\d+)$`),this.Ar=function(e){return`firestore_online_state_${e}`}(this.persistenceKey),this.Rr=function(e){return`firestore_bundle_loaded_v2_${e}`}(this.persistenceKey),this.window.addEventListener("storage",this._r)}static D(e){return!(!e||!e.localStorage)}async start(){const e=await this.syncEngine.Mi();for(const t of e){if(t===this.dr)continue;const e=this.getItem(hh(this.persistenceKey,t));if(e){const n=mh.cr(t,e);n&amp;&amp;(this.mr=this.mr.insert(n.clientId,n))}}this.vr();const t=this.storage.getItem(this.Ar);if(t){const e=this.Pr(t);e&amp;&amp;this.br(e)}for(const e of this.gr)this.wr(e);this.gr=[],this.window.addEventListener("pagehide",(()=&gt;this.shutdown())),this.started=!0}writeSequenceNumber(e){this.setItem(this.pr,JSON.stringify(e))}getAllActiveQueryTargets(){return this.Vr(this.mr)}isActiveQueryTarget(e){let t=!1;return this.mr.forEach(((n,r)=&gt;{r.activeTargetIds.has(e)&amp;&amp;(t=!0)})),t}addPendingMutation(e){this.Sr(e,"pending")}updateMutationState(e,t,n){this.Sr(e,t,n),this.Dr(e)}addLocalQueryTarget(e){let t="not-current";if(this.isActiveQueryTarget(e)){const n=this.storage.getItem(fh(this.persistenceKey,e));if(n){const r=gh.cr(e,n);r&amp;&amp;(t=r.state)}}return this.Cr.hr(e),this.vr(),t}removeLocalQueryTarget(e){this.Cr.lr(e),this.vr()}isLocalQueryTarget(e){return this.Cr.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(fh(this.persistenceKey,e))}updateQueryState(e,t,n){this.Nr(e,t,n)}handleUserChange(e,t,n){t.forEach((e=&gt;{this.Dr(e)})),this.currentUser=e,n.forEach((e=&gt;{this.addPendingMutation(e)}))}setOnlineState(e){this.kr(e)}notifyBundleLoaded(e){this.Mr(e)}shutdown(){this.started&amp;&amp;(this.window.removeEventListener("storage",this._r),this.removeItem(this.yr),this.started=!1)}getItem(e){const t=this.storage.getItem(e);return Or("SharedClientState","READ",e,t),t}setItem(e,t){Or("SharedClientState","SET",e,t),this.storage.setItem(e,t)}removeItem(e){Or("SharedClientState","REMOVE",e),this.storage.removeItem(e)}wr(e){const t=e;if(t.storageArea===this.storage){if(Or("SharedClientState","EVENT",t.key,t.newValue),t.key===this.yr)return void Lr("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.si.enqueueRetryable((async()=&gt;{if(this.started){if(null!==t.key)if(this.Ir.test(t.key)){if(null==t.newValue){const e=this.Or(t.key);return this.$r(e,null)}{const e=this.Fr(t.key,t.newValue);if(e)return this.$r(e.clientId,e)}}else if(this.Tr.test(t.key)){if(null!==t.newValue){const e=this.Br(t.key,t.newValue);if(e)return this.Lr(e)}}else if(this.Er.test(t.key)){if(null!==t.newValue){const e=this.qr(t.key,t.newValue);if(e)return this.Ur(e)}}else if(t.key===this.Ar){if(null!==t.newValue){const e=this.Pr(t.newValue);if(e)return this.br(e)}}else if(t.key===this.pr){const e=function(e){let t=Bi.ct;if(null!=e)try{const n=JSON.parse(e);Ur("number"==typeof n),t=n}catch(e){Lr("SharedClientState","Failed to read sequence number from WebStorage",e)}return t}(t.newValue);e!==Bi.ct&amp;&amp;this.sequenceNumberHandler(e)}else if(t.key===this.Rr){const e=this.Kr(t.newValue);await Promise.all(e.map((e=&gt;this.syncEngine.Gr(e))))}}else this.gr.push(t)}))}}get Cr(){return this.mr.get(this.dr)}vr(){this.setItem(this.yr,this.Cr.ar())}Sr(e,t,n){const r=new ph(this.currentUser,e,t,n),i=dh(this.persistenceKey,this.currentUser,e);this.setItem(i,r.ar())}Dr(e){const t=dh(this.persistenceKey,this.currentUser,e);this.removeItem(t)}kr(e){const t={clientId:this.dr,onlineState:e};this.storage.setItem(this.Ar,JSON.stringify(t))}Nr(e,t,n){const r=fh(this.persistenceKey,e),i=new gh(e,t,n);this.setItem(r,i.ar())}Mr(e){const t=JSON.stringify(Array.from(e));this.setItem(this.Rr,t)}Or(e){const t=this.Ir.exec(e);return t?t[1]:null}Fr(e,t){const n=this.Or(e);return mh.cr(n,t)}Br(e,t){const n=this.Tr.exec(e),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return ph.cr(new Ar(i),r,t)}qr(e,t){const n=this.Er.exec(e),r=Number(n[1]);return gh.cr(r,t)}Pr(e){return yh.cr(e)}Kr(e){return JSON.parse(e)}async Lr(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.Qr(e.batchId,e.state,e.error);Or("SharedClientState",`Ignoring mutation for non-active user ${e.user.uid}`)}Ur(e){return this.syncEngine.jr(e.targetId,e.state,e.error)}$r(e,t){const n=t?this.mr.insert(e,t):this.mr.remove(e),r=this.Vr(this.mr),i=this.Vr(n),s=[],o=[];return i.forEach((e=&gt;{r.has(e)||s.push(e)})),r.forEach((e=&gt;{i.has(e)||o.push(e)})),this.syncEngine.zr(s,o).then((()=&gt;{this.mr=n}))}br(e){this.mr.get(e.clientId)&amp;&amp;this.onlineStateHandler(e.onlineState)}Vr(e){let t=Ia();return e.forEach(((e,n)=&gt;{t=t.unionWith(n.activeTargetIds)})),t}}class wh{constructor(){this.Wr=new _h,this.Hr={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e){return this.Wr.hr(e),this.Hr[e]||"not-current"}updateQueryState(e,t,n){this.Hr[e]=t}removeLocalQueryTarget(e){this.Wr.lr(e)}isLocalQueryTarget(e){return this.Wr.activeTargetIds.has(e)}clearQueryState(e){delete this.Hr[e]}getAllActiveQueryTargets(){return this.Wr.activeTargetIds}isActiveQueryTarget(e){return this.Wr.activeTargetIds.has(e)}start(){return this.Wr=new _h,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class bh{Jr(e){}shutdown(){}}class Ih{constructor(){this.Yr=()=&gt;this.Xr(),this.Zr=()=&gt;this.eo(),this.no=[],this.so()}Jr(e){this.no.push(e)}shutdown(){window.removeEventListener("online",this.Yr),window.removeEventListener("offline",this.Zr)}so(){window.addEventListener("online",this.Yr),window.addEventListener("offline",this.Zr)}Xr(){Or("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(const e of this.no)e(0)}eo(){Or("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(const e of this.no)e(1)}static D(){return"undefined"!=typeof window&amp;&amp;void 0!==window.addEventListener&amp;&amp;void 0!==window.removeEventListener}}let Ch=null;function Th(){return null===Ch?Ch=268435456+Math.round(2147483648*Math.random()):Ch++,"0x"+Ch.toString(16)}const Eh={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery"};class Sh{constructor(e){this.io=e.io,this.ro=e.ro}oo(e){this.uo=e}co(e){this.ao=e}onMessage(e){this.ho=e}close(){this.ro()}send(e){this.io(e)}lo(){this.uo()}fo(e){this.ao(e)}_o(e){this.ho(e)}}const xh="WebChannelConnection";class kh extends class{constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http";this.wo=t+"://"+e.host,this.mo="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}get yo(){return!1}po(e,t,n,r,i){const s=Th(),o=this.Io(e,t);Or("RestConnection",`Sending RPC '${e}' ${s}:`,o,n);const a={};return this.To(a,r,i),this.Eo(e,o,a,n).then((t=&gt;(Or("RestConnection",`Received RPC '${e}' ${s}: `,t),t)),(t=&gt;{throw qr("RestConnection",`RPC '${e}' ${s} failed with error: `,t,"url: ",o,"request:",n),t}))}Ao(e,t,n,r,i,s){return this.po(e,t,n,r,i)}To(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+Pr,e["Content-Type"]="text/plain",this.databaseInfo.appId&amp;&amp;(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&amp;&amp;t.headers.forEach(((t,n)=&gt;e[n]=t)),n&amp;&amp;n.headers.forEach(((t,n)=&gt;e[n]=t))}Io(e,t){const n=Eh[e];return`${this.wo}/v1/${t}:${n}`}}{constructor(e){super(e),this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams}Eo(e,t,n,r){const i=Th();return new Promise(((s,o)=&gt;{const a=new xr;a.setWithCredentials(!0),a.listenOnce(Ir.COMPLETE,(()=&gt;{try{switch(a.getLastErrorCode()){case br.NO_ERROR:const t=a.getResponseJson();Or(xh,`XHR for RPC '${e}' ${i} received:`,JSON.stringify(t)),s(t);break;case br.TIMEOUT:Or(xh,`RPC '${e}' ${i} timed out`),o(new Kr($r.DEADLINE_EXCEEDED,"Request time out"));break;case br.HTTP_ERROR:const n=a.getStatus();if(Or(xh,`RPC '${e}' ${i} failed with status:`,n,"response text:",a.getResponseText()),n&gt;0){let e=a.getResponseJson();Array.isArray(e)&amp;&amp;(e=e[0]);const t=null==e?void 0:e.error;if(t&amp;&amp;t.status&amp;&amp;t.message){const e=function(e){const t=e.toLowerCase().replace(/_/g,"-");return Object.values($r).indexOf(t)&gt;=0?t:$r.UNKNOWN}(t.status);o(new Kr(e,t.message))}else o(new Kr($r.UNKNOWN,"Server responded with status "+a.getStatus()))}else o(new Kr($r.UNAVAILABLE,"Connection failed."));break;default:Br()}}finally{Or(xh,`RPC '${e}' ${i} completed.`)}}));const c=JSON.stringify(r);Or(xh,`RPC '${e}' ${i} sending request:`,r),a.send(t,"POST",c,n,15)}))}Ro(e,t,n){const r=Th(),i=[this.wo,"/","google.firestore.v1.Firestore","/",e,"/channel"],s=vr(),o=wr(),a={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.useFetchStreams&amp;&amp;(a.xmlHttpFactory=new Er({})),this.To(a.initMessageHeaders,t,n),a.encodeInitMessageHeaders=!0;const c=i.join("");Or(xh,`Creating RPC '${e}' stream ${r}: ${c}`,a);const u=s.createWebChannel(c,a);let l=!1,h=!1;const d=new Sh({io:t=&gt;{h?Or(xh,`Not sending because RPC '${e}' stream ${r} is closed:`,t):(l||(Or(xh,`Opening RPC '${e}' stream ${r} transport.`),u.open(),l=!0),Or(xh,`RPC '${e}' stream ${r} sending:`,t),u.send(t))},ro:()=&gt;u.close()}),f=(e,t,n)=&gt;{e.listen(t,(e=&gt;{try{n(e)}catch(e){setTimeout((()=&gt;{throw e}),0)}}))};return f(u,Sr.EventType.OPEN,(()=&gt;{h||Or(xh,`RPC '${e}' stream ${r} transport opened.`)})),f(u,Sr.EventType.CLOSE,(()=&gt;{h||(h=!0,Or(xh,`RPC '${e}' stream ${r} transport closed`),d.fo())})),f(u,Sr.EventType.ERROR,(t=&gt;{h||(h=!0,qr(xh,`RPC '${e}' stream ${r} transport errored:`,t),d.fo(new Kr($r.UNAVAILABLE,"The operation could not be completed")))})),f(u,Sr.EventType.MESSAGE,(t=&gt;{var n;if(!h){const i=t.data[0];Ur(!!i);const s=i,o=s.error||(null===(n=s[0])||void 0===n?void 0:n.error);if(o){Or(xh,`RPC '${e}' stream ${r} received error:`,o);const t=o.status;let n=function(e){const t=oc[e];if(void 0!==t)return uc(t)}(t),i=o.message;void 0===n&amp;&amp;(n=$r.INTERNAL,i="Unknown error status: "+t+" with message "+o.message),h=!0,d.fo(new Kr(n,i)),u.close()}else Or(xh,`RPC '${e}' stream ${r} received:`,i),d._o(i)}})),f(o,Cr.STAT_EVENT,(t=&gt;{t.stat===Tr.PROXY?Or(xh,`RPC '${e}' stream ${r} detected buffering proxy`):t.stat===Tr.NOPROXY&amp;&amp;Or(xh,`RPC '${e}' stream ${r} detected no buffering proxy`)})),setTimeout((()=&gt;{d.lo()}),0),d}}function Dh(){return"undefined"!=typeof window?window:null}function Nh(){return"undefined"!=typeof document?document:null}function Ah(e){return new Nc(e,!0)}class Ph{constructor(e,t,n=1e3,r=1.5,i=6e4){this.si=e,this.timerId=t,this.vo=n,this.Po=r,this.bo=i,this.Vo=0,this.So=null,this.Do=Date.now(),this.reset()}reset(){this.Vo=0}Co(){this.Vo=this.bo}xo(e){this.cancel();const t=Math.floor(this.Vo+this.No()),n=Math.max(0,Date.now()-this.Do),r=Math.max(0,t-n);r&gt;0&amp;&amp;Or("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.Vo} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.So=this.si.enqueueAfterDelay(this.timerId,r,(()=&gt;(this.Do=Date.now(),e()))),this.Vo*=this.Po,this.Vo&lt;this.vo&amp;&amp;(this.Vo=this.vo),this.Vo&gt;this.bo&amp;&amp;(this.Vo=this.bo)}ko(){null!==this.So&amp;&amp;(this.So.skipDelay(),this.So=null)}cancel(){null!==this.So&amp;&amp;(this.So.cancel(),this.So=null)}No(){return(Math.random()-.5)*this.Vo}}class Rh{constructor(e,t,n,r,i,s,o,a){this.si=e,this.Mo=n,this.Oo=r,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.$o=0,this.Fo=null,this.Bo=null,this.stream=null,this.Lo=new Ph(e,t)}qo(){return 1===this.state||5===this.state||this.Uo()}Uo(){return 2===this.state||3===this.state}start(){4!==this.state?this.auth():this.Ko()}async stop(){this.qo()&amp;&amp;await this.close(0)}Go(){this.state=0,this.Lo.reset()}Qo(){this.Uo()&amp;&amp;null===this.Fo&amp;&amp;(this.Fo=this.si.enqueueAfterDelay(this.Mo,6e4,(()=&gt;this.jo())))}zo(e){this.Wo(),this.stream.send(e)}async jo(){if(this.Uo())return this.close(0)}Wo(){this.Fo&amp;&amp;(this.Fo.cancel(),this.Fo=null)}Ho(){this.Bo&amp;&amp;(this.Bo.cancel(),this.Bo=null)}async close(e,t){this.Wo(),this.Ho(),this.Lo.cancel(),this.$o++,4!==e?this.Lo.reset():t&amp;&amp;t.code===$r.RESOURCE_EXHAUSTED?(Lr(t.toString()),Lr("Using maximum backoff delay to prevent overloading the backend."),this.Lo.Co()):t&amp;&amp;t.code===$r.UNAUTHENTICATED&amp;&amp;3!==this.state&amp;&amp;(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&amp;&amp;(this.Jo(),this.stream.close(),this.stream=null),this.state=e,await this.listener.co(t)}Jo(){}auth(){this.state=1;const e=this.Yo(this.$o),t=this.$o;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([e,n])=&gt;{this.$o===t&amp;&amp;this.Xo(e,n)}),(t=&gt;{e((()=&gt;{const e=new Kr($r.UNKNOWN,"Fetching auth token failed: "+t.message);return this.Zo(e)}))}))}Xo(e,t){const n=this.Yo(this.$o);this.stream=this.tu(e,t),this.stream.oo((()=&gt;{n((()=&gt;(this.state=2,this.Bo=this.si.enqueueAfterDelay(this.Oo,1e4,(()=&gt;(this.Uo()&amp;&amp;(this.state=3),Promise.resolve()))),this.listener.oo())))})),this.stream.co((e=&gt;{n((()=&gt;this.Zo(e)))})),this.stream.onMessage((e=&gt;{n((()=&gt;this.onMessage(e)))}))}Ko(){this.state=5,this.Lo.xo((async()=&gt;{this.state=0,this.start()}))}Zo(e){return Or("PersistentStream",`close with error: ${e}`),this.stream=null,this.close(4,e)}Yo(e){return t=&gt;{this.si.enqueueAndForget((()=&gt;this.$o===e?t():(Or("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())))}}}class Mh extends Rh{constructor(e,t,n,r,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,r,s),this.serializer=i}tu(e,t){return this.connection.Ro("Listen",e,t)}onMessage(e){this.Lo.reset();const t=function(e,t){let n;if("targetChange"in t){t.targetChange;const r=function(e){return"NO_CHANGE"===e?0:"ADD"===e?1:"REMOVE"===e?2:"CURRENT"===e?3:"RESET"===e?4:Br()}(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],s=function(e,t){return e.useProto3Json?(Ur(void 0===t||"string"==typeof t),As.fromBase64String(t||"")):(Ur(void 0===t||t instanceof Uint8Array),As.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),o=t.targetChange.cause,a=o&amp;&amp;function(e){const t=void 0===e.code?$r.UNKNOWN:uc(e.code);return new Kr(t,e.message||"")}(o);n=new Ic(r,i,s,a||null)}else if("documentChange"in t){t.documentChange;const r=t.documentChange;r.document,r.document.name,r.document.updateTime;const i=Vc(e,r.document.name),s=Fc(r.document.updateTime),o=r.document.createTime?Fc(r.document.createTime):ci.min(),a=new uo({mapValue:{fields:r.document.fields}}),c=ho.newFoundDocument(i,s,o,a),u=r.targetIds||[],l=r.removedTargetIds||[];n=new wc(u,l,c.key,c)}else if("documentDelete"in t){t.documentDelete;const r=t.documentDelete;r.document;const i=Vc(e,r.document),s=r.readTime?Fc(r.readTime):ci.min(),o=ho.newNoDocument(i,s),a=r.removedTargetIds||[];n=new wc([],a,o.key,o)}else if("documentRemove"in t){t.documentRemove;const r=t.documentRemove;r.document;const i=Vc(e,r.document),s=r.removedTargetIds||[];n=new wc([],s,i,null)}else{if(!("filter"in t))return Br();{t.filter;const e=t.filter;e.targetId;const{count:r=0,unchangedNames:i}=e,s=new sc(r,i),o=e.targetId;n=new bc(o,s)}}return n}(this.serializer,e),n=function(e){if(!("targetChange"in e))return ci.min();const t=e.targetChange;return t.targetIds&amp;&amp;t.targetIds.length?ci.min():t.readTime?Fc(t.readTime):ci.min()}(e);return this.listener.eu(t,n)}nu(e){const t={};t.database=jc(this.serializer),t.addTarget=function(e,t){let n;const r=t.target;if(n=Uo(r)?{documents:Hc(e,r)}:{query:Qc(e,r)},n.targetId=t.targetId,t.resumeToken.approximateByteSize()&gt;0){n.resumeToken=Rc(e,t.resumeToken);const r=Ac(e,t.expectedCount);null!==r&amp;&amp;(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(ci.min())&gt;0){n.readTime=Pc(e,t.snapshotVersion.toTimestamp());const r=Ac(e,t.expectedCount);null!==r&amp;&amp;(n.expectedCount=r)}return n}(this.serializer,e);const n=function(e,t){const n=function(e){switch(e){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return Br()}}(t.purpose);return null==n?null:{"goog-listen-tags":n}}(this.serializer,e);n&amp;&amp;(t.labels=n),this.zo(t)}su(e){const t={};t.database=jc(this.serializer),t.removeTarget=e,this.zo(t)}}class Fh extends Rh{constructor(e,t,n,r,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,r,s),this.serializer=i,this.iu=!1}get ru(){return this.iu}start(){this.iu=!1,this.lastStreamToken=void 0,super.start()}Jo(){this.iu&amp;&amp;this.ou([])}tu(e,t){return this.connection.Ro("Write",e,t)}onMessage(e){if(Ur(!!e.streamToken),this.lastStreamToken=e.streamToken,this.iu){this.Lo.reset();const t=function(e,t){return e&amp;&amp;e.length&gt;0?(Ur(void 0!==t),e.map((e=&gt;function(e,t){let n=e.updateTime?Fc(e.updateTime):Fc(t);return n.isEqual(ci.min())&amp;&amp;(n=Fc(t)),new Va(n,e.transformResults||[])}(e,t)))):[]}(e.writeResults,e.commitTime),n=Fc(e.commitTime);return this.listener.uu(n,t)}return Ur(!e.writeResults||0===e.writeResults.length),this.iu=!0,this.listener.cu()}au(){const e={};e.database=jc(this.serializer),this.zo(e)}ou(e){const t={streamToken:this.lastStreamToken,writes:e.map((e=&gt;Gc(this.serializer,e)))};this.zo(t)}}class Oh extends class{}{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=r,this.hu=!1}lu(){if(this.hu)throw new Kr($r.FAILED_PRECONDITION,"The client has already been terminated.")}po(e,t,n){return this.lu(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([r,i])=&gt;this.connection.po(e,t,n,r,i))).catch((e=&gt;{throw"FirebaseError"===e.name?(e.code===$r.UNAUTHENTICATED&amp;&amp;(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new Kr($r.UNKNOWN,e.toString())}))}Ao(e,t,n,r){return this.lu(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,s])=&gt;this.connection.Ao(e,t,n,i,s,r))).catch((e=&gt;{throw"FirebaseError"===e.name?(e.code===$r.UNAUTHENTICATED&amp;&amp;(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new Kr($r.UNKNOWN,e.toString())}))}terminate(){this.hu=!0}}class Lh{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.du=0,this._u=null,this.wu=!0}mu(){0===this.du&amp;&amp;(this.gu("Unknown"),this._u=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(()=&gt;(this._u=null,this.yu("Backend didn't respond within 10 seconds."),this.gu("Offline"),Promise.resolve()))))}pu(e){"Online"===this.state?this.gu("Unknown"):(this.du++,this.du&gt;=1&amp;&amp;(this.Iu(),this.yu(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.gu("Offline")))}set(e){this.Iu(),this.du=0,"Online"===e&amp;&amp;(this.wu=!1),this.gu(e)}gu(e){e!==this.state&amp;&amp;(this.state=e,this.onlineStateHandler(e))}yu(e){const t=`Could not reach Cloud Firestore backend. ${e}\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.wu?(Lr(t),this.wu=!1):Or("OnlineStateTracker",t)}Iu(){null!==this._u&amp;&amp;(this._u.cancel(),this._u=null)}}class qh{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Tu=[],this.Eu=new Map,this.Au=new Set,this.Ru=[],this.vu=i,this.vu.Jr((e=&gt;{n.enqueueAndForget((async()=&gt;{Wh(this)&amp;&amp;(Or("RemoteStore","Restarting streams for network reachability change."),await async function(e){const t=zr(e);t.Au.add(4),await Bh(t),t.Pu.set("Unknown"),t.Au.delete(4),await Vh(t)}(this))}))})),this.Pu=new Lh(n,r)}}async function Vh(e){if(Wh(e))for(const t of e.Ru)await t(!0)}async function Bh(e){for(const t of e.Ru)await t(!1)}function Uh(e,t){const n=zr(e);n.Eu.has(t.targetId)||(n.Eu.set(t.targetId,t),Gh(n)?Kh(n):hd(n).Uo()&amp;&amp;zh(n,t))}function jh(e,t){const n=zr(e),r=hd(n);n.Eu.delete(t),r.Uo()&amp;&amp;$h(n,t),0===n.Eu.size&amp;&amp;(r.Uo()?r.Qo():Wh(n)&amp;&amp;n.Pu.set("Unknown"))}function zh(e,t){if(e.bu.Lt(t.targetId),t.resumeToken.approximateByteSize()&gt;0||t.snapshotVersion.compareTo(ci.min())&gt;0){const n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}hd(e).nu(t)}function $h(e,t){e.bu.Lt(t),hd(e).su(t)}function Kh(e){e.bu=new Tc({getRemoteKeysForTarget:t=&gt;e.remoteSyncer.getRemoteKeysForTarget(t),he:t=&gt;e.Eu.get(t)||null,oe:()=&gt;e.datastore.serializer.databaseId}),hd(e).start(),e.Pu.mu()}function Gh(e){return Wh(e)&amp;&amp;!hd(e).qo()&amp;&amp;e.Eu.size&gt;0}function Wh(e){return 0===zr(e).Au.size}function Hh(e){e.bu=void 0}async function Qh(e){e.Eu.forEach(((t,n)=&gt;{zh(e,t)}))}async function Yh(e,t){Hh(e),Gh(e)?(e.Pu.pu(t),Kh(e)):e.Pu.set("Unknown")}async function Xh(e,t,n){if(e.Pu.set("Online"),t instanceof Ic&amp;&amp;2===t.state&amp;&amp;t.cause)try{await async function(e,t){const n=t.cause;for(const r of t.targetIds)e.Eu.has(r)&amp;&amp;(await e.remoteSyncer.rejectListen(r,n),e.Eu.delete(r),e.bu.removeTarget(r))}(e,t)}catch(n){Or("RemoteStore","Failed to remove targets %s: %s ",t.targetIds.join(","),n),await Jh(e,n)}else if(t instanceof wc?e.bu.Wt(t):t instanceof bc?e.bu.ee(t):e.bu.Yt(t),!n.isEqual(ci.min()))try{const t=await th(e.localStore);n.compareTo(t)&gt;=0&amp;&amp;await function(e,t){const n=e.bu.ue(t);return n.targetChanges.forEach(((n,r)=&gt;{if(n.resumeToken.approximateByteSize()&gt;0){const i=e.Eu.get(r);i&amp;&amp;e.Eu.set(r,i.withResumeToken(n.resumeToken,t))}})),n.targetMismatches.forEach(((t,n)=&gt;{const r=e.Eu.get(t);if(!r)return;e.Eu.set(t,r.withResumeToken(As.EMPTY_BYTE_STRING,r.snapshotVersion)),$h(e,t);const i=new ou(r.target,t,n,r.sequenceNumber);zh(e,i)})),e.remoteSyncer.applyRemoteEvent(n)}(e,n)}catch(t){Or("RemoteStore","Failed to raise snapshot:",t),await Jh(e,t)}}async function Jh(e,t,n){if(!Ri(t))throw t;e.Au.add(1),await Bh(e),e.Pu.set("Offline"),n||(n=()=&gt;th(e.localStore)),e.asyncQueue.enqueueRetryable((async()=&gt;{Or("RemoteStore","Retrying IndexedDB access"),await n(),e.Au.delete(1),await Vh(e)}))}function Zh(e,t){return t().catch((n=&gt;Jh(e,n,t)))}async function ed(e){const t=zr(e),n=dd(t);let r=t.Tu.length&gt;0?t.Tu[t.Tu.length-1].batchId:-1;for(;td(t);)try{const e=await rh(t.localStore,r);if(null===e){0===t.Tu.length&amp;&amp;n.Qo();break}r=e.batchId,nd(t,e)}catch(e){await Jh(t,e)}rd(t)&amp;&amp;id(t)}function td(e){return Wh(e)&amp;&amp;e.Tu.length&lt;10}function nd(e,t){e.Tu.push(t);const n=dd(e);n.Uo()&amp;&amp;n.ru&amp;&amp;n.ou(t.mutations)}function rd(e){return Wh(e)&amp;&amp;!dd(e).qo()&amp;&amp;e.Tu.length&gt;0}function id(e){dd(e).start()}async function sd(e){dd(e).au()}async function od(e){const t=dd(e);for(const n of e.Tu)t.ou(n.mutations)}async function ad(e,t,n){const r=e.Tu.shift(),i=nc.from(r,t,n);await Zh(e,(()=&gt;e.remoteSyncer.applySuccessfulWrite(i))),await ed(e)}async function cd(e,t){t&amp;&amp;dd(e).ru&amp;&amp;await async function(e,t){if(cc(n=t.code)&amp;&amp;n!==$r.ABORTED){const n=e.Tu.shift();dd(e).Go(),await Zh(e,(()=&gt;e.remoteSyncer.rejectFailedWrite(n.batchId,t))),await ed(e)}var n}(e,t),rd(e)&amp;&amp;id(e)}async function ud(e,t){const n=zr(e);n.asyncQueue.verifyOperationInProgress(),Or("RemoteStore","RemoteStore received new credentials");const r=Wh(n);n.Au.add(3),await Bh(n),r&amp;&amp;n.Pu.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.Au.delete(3),await Vh(n)}async function ld(e,t){const n=zr(e);t?(n.Au.delete(2),await Vh(n)):t||(n.Au.add(2),await Bh(n),n.Pu.set("Unknown"))}function hd(e){return e.Vu||(e.Vu=function(e,t,n){const r=zr(e);return r.lu(),new Mh(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{oo:Qh.bind(null,e),co:Yh.bind(null,e),eu:Xh.bind(null,e)}),e.Ru.push((async t=&gt;{t?(e.Vu.Go(),Gh(e)?Kh(e):e.Pu.set("Unknown")):(await e.Vu.stop(),Hh(e))}))),e.Vu}function dd(e){return e.Su||(e.Su=function(e,t,n){const r=zr(e);return r.lu(),new Fh(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{oo:sd.bind(null,e),co:cd.bind(null,e),cu:od.bind(null,e),uu:ad.bind(null,e)}),e.Ru.push((async t=&gt;{t?(e.Su.Go(),await ed(e)):(await e.Su.stop(),e.Tu.length&gt;0&amp;&amp;(Or("RemoteStore",`Stopping write stream with ${e.Tu.length} pending writes`),e.Tu=[]))}))),e.Su}class fd{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new Gr,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((e=&gt;{}))}static createAndSchedule(e,t,n,r,i){const s=Date.now()+n,o=new fd(e,t,s,r,i);return o.start(n),o}start(e){this.timerHandle=setTimeout((()=&gt;this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&amp;&amp;(this.clearTimeout(),this.deferred.reject(new Kr($r.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=&gt;null!==this.timerHandle?(this.clearTimeout(),this.op().then((e=&gt;this.deferred.resolve(e)))):Promise.resolve()))}clearTimeout(){null!==this.timerHandle&amp;&amp;(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function pd(e,t){if(Lr("AsyncQueue",`${t}: ${e}`),Ri(e))return new Kr($r.UNAVAILABLE,`${t}: ${e}`);throw e}class gd{constructor(e){this.comparator=e?(t,n)=&gt;e(t,n)||fi.comparator(t.key,n.key):(e,t)=&gt;fi.comparator(e.key,t.key),this.keyedMap=fa(),this.sortedSet=new Is(this.comparator)}static emptySet(e){return new gd(e.comparator)}has(e){return null!=this.keyedMap.get(e)}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal(((t,n)=&gt;(e(t),!1)))}add(e){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof gd))return!1;if(this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(!e.isEqual(r))return!1}return!0}toString(){const e=[];return this.forEach((t=&gt;{e.push(t.toString())})),0===e.length?"DocumentSet ()":"DocumentSet (\n  "+e.join("  \n")+"\n)"}copy(e,t){const n=new gd;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class md{constructor(){this.Du=new Is(fi.comparator)}track(e){const t=e.doc.key,n=this.Du.get(t);n?0!==e.type&amp;&amp;3===n.type?this.Du=this.Du.insert(t,e):3===e.type&amp;&amp;1!==n.type?this.Du=this.Du.insert(t,{type:n.type,doc:e.doc}):2===e.type&amp;&amp;2===n.type?this.Du=this.Du.insert(t,{type:2,doc:e.doc}):2===e.type&amp;&amp;0===n.type?this.Du=this.Du.insert(t,{type:0,doc:e.doc}):1===e.type&amp;&amp;0===n.type?this.Du=this.Du.remove(t):1===e.type&amp;&amp;2===n.type?this.Du=this.Du.insert(t,{type:1,doc:n.doc}):0===e.type&amp;&amp;1===n.type?this.Du=this.Du.insert(t,{type:2,doc:e.doc}):Br():this.Du=this.Du.insert(t,e)}Cu(){const e=[];return this.Du.inorderTraversal(((t,n)=&gt;{e.push(n)})),e}}class yd{constructor(e,t,n,r,i,s,o,a,c){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=o,this.excludesMetadataChanges=a,this.hasCachedResults=c}static fromInitialDocuments(e,t,n,r,i){const s=[];return t.forEach((e=&gt;{s.push({type:0,doc:e})})),new yd(e,t,gd.emptySet(t),s,n,r,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&amp;&amp;this.hasCachedResults===e.hasCachedResults&amp;&amp;this.syncStateChanged===e.syncStateChanged&amp;&amp;this.mutatedKeys.isEqual(e.mutatedKeys)&amp;&amp;na(this.query,e.query)&amp;&amp;this.docs.isEqual(e.docs)&amp;&amp;this.oldDocs.isEqual(e.oldDocs)))return!1;const t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let e=0;e&lt;t.length;e++)if(t[e].type!==n[e].type||!t[e].doc.isEqual(n[e].doc))return!1;return!0}}class _d{constructor(){this.xu=void 0,this.listeners=[]}}class vd{constructor(){this.queries=new ua((e=&gt;ra(e)),na),this.onlineState="Unknown",this.Nu=new Set}}async function wd(e,t){const n=zr(e),r=t.query;let i=!1,s=n.queries.get(r);if(s||(i=!0,s=new _d),i)try{s.xu=await n.onListen(r)}catch(e){const n=pd(e,`Initialization of query '${ia(t.query)}' failed`);return void t.onError(n)}n.queries.set(r,s),s.listeners.push(t),t.ku(n.onlineState),s.xu&amp;&amp;t.Mu(s.xu)&amp;&amp;Td(n)}async function bd(e,t){const n=zr(e),r=t.query;let i=!1;const s=n.queries.get(r);if(s){const e=s.listeners.indexOf(t);e&gt;=0&amp;&amp;(s.listeners.splice(e,1),i=0===s.listeners.length)}if(i)return n.queries.delete(r),n.onUnlisten(r)}function Id(e,t){const n=zr(e);let r=!1;for(const e of t){const t=e.query,i=n.queries.get(t);if(i){for(const t of i.listeners)t.Mu(e)&amp;&amp;(r=!0);i.xu=e}}r&amp;&amp;Td(n)}function Cd(e,t,n){const r=zr(e),i=r.queries.get(t);if(i)for(const e of i.listeners)e.onError(n);r.queries.delete(t)}function Td(e){e.Nu.forEach((e=&gt;{e.next()}))}class Ed{constructor(e,t,n){this.query=e,this.Ou=t,this.$u=!1,this.Fu=null,this.onlineState="Unknown",this.options=n||{}}Mu(e){if(!this.options.includeMetadataChanges){const t=[];for(const n of e.docChanges)3!==n.type&amp;&amp;t.push(n);e=new yd(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.$u?this.Bu(e)&amp;&amp;(this.Ou.next(e),t=!0):this.Lu(e,this.onlineState)&amp;&amp;(this.qu(e),t=!0),this.Fu=e,t}onError(e){this.Ou.error(e)}ku(e){this.onlineState=e;let t=!1;return this.Fu&amp;&amp;!this.$u&amp;&amp;this.Lu(this.Fu,e)&amp;&amp;(this.qu(this.Fu),t=!0),t}Lu(e,t){if(!e.fromCache)return!0;const n="Offline"!==t;return(!this.options.Uu||!n)&amp;&amp;(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}Bu(e){if(e.docChanges.length&gt;0)return!0;const t=this.Fu&amp;&amp;this.Fu.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&amp;&amp;!t)&amp;&amp;!0===this.options.includeMetadataChanges}qu(e){e=yd.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.$u=!0,this.Ou.next(e)}}class Sd{constructor(e,t){this.Ku=e,this.byteLength=t}Gu(){return"metadata"in this.Ku}}class xd{constructor(e){this.serializer=e}ir(e){return Vc(this.serializer,e)}rr(e){return e.metadata.exists?Kc(this.serializer,e.document,!1):ho.newNoDocument(this.ir(e.metadata.name),this.ur(e.metadata.readTime))}ur(e){return Fc(e)}}class kd{constructor(e,t,n){this.Qu=e,this.localStore=t,this.serializer=n,this.queries=[],this.documents=[],this.collectionGroups=new Set,this.progress=Dd(e)}ju(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;if(e.Ku.namedQuery)this.queries.push(e.Ku.namedQuery);else if(e.Ku.documentMetadata){this.documents.push({metadata:e.Ku.documentMetadata}),e.Ku.documentMetadata.exists||++t;const n=li.fromString(e.Ku.documentMetadata.name);this.collectionGroups.add(n.get(n.length-2))}else e.Ku.document&amp;&amp;(this.documents[this.documents.length-1].document=e.Ku.document,++t);return t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,Object.assign({},this.progress)):null}zu(e){const t=new Map,n=new xd(this.serializer);for(const r of e)if(r.metadata.queries){const e=n.ir(r.metadata.name);for(const n of r.metadata.queries){const r=(t.get(n)||wa()).add(e);t.set(n,r)}}return t}async complete(){const e=await async function(e,t,n,r){const i=zr(e);let s=wa(),o=ha();for(const e of n){const n=t.ir(e.metadata.name);e.document&amp;&amp;(s=s.add(n));const r=t.rr(e);r.setReadTime(t.ur(e.metadata.readTime)),o=o.insert(n,r)}const a=i.Xi.newChangeBuffer({trackRemovals:!0}),c=await ih(i,function(e){return Zo(Wo(li.fromString(`__bundle__/docs/${e}`)))}(r));return i.persistence.runTransaction("Apply bundle documents","readwrite",(e=&gt;nh(e,a,o).next((t=&gt;(a.apply(e),t))).next((t=&gt;i.Fs.removeMatchingKeysForTargetId(e,c.targetId).next((()=&gt;i.Fs.addMatchingKeys(e,s,c.targetId))).next((()=&gt;i.localDocuments.getLocalViewOfDocuments(e,t.er,t.nr))).next((()=&gt;t.er))))))}(this.localStore,new xd(this.serializer),this.documents,this.Qu.id),t=this.zu(this.documents);for(const e of this.queries)await lh(this.localStore,e,t.get(e.name));return this.progress.taskState="Success",{progress:this.progress,Wu:this.collectionGroups,Hu:e}}}function Dd(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class Nd{constructor(e){this.key=e}}class Ad{constructor(e){this.key=e}}class Pd{constructor(e,t){this.query=e,this.Ju=t,this.Yu=null,this.hasCachedResults=!1,this.current=!1,this.Xu=wa(),this.mutatedKeys=wa(),this.Zu=aa(e),this.tc=new gd(this.Zu)}get ec(){return this.Ju}nc(e,t){const n=t?t.sc:new md,r=t?t.tc:this.tc;let i=t?t.mutatedKeys:this.mutatedKeys,s=r,o=!1;const a="F"===this.query.limitType&amp;&amp;r.size===this.query.limit?r.last():null,c="L"===this.query.limitType&amp;&amp;r.size===this.query.limit?r.first():null;if(e.inorderTraversal(((e,t)=&gt;{const u=r.get(e),l=sa(this.query,t)?t:null,h=!!u&amp;&amp;this.mutatedKeys.has(u.key),d=!!l&amp;&amp;(l.hasLocalMutations||this.mutatedKeys.has(l.key)&amp;&amp;l.hasCommittedMutations);let f=!1;u&amp;&amp;l?u.data.isEqual(l.data)?h!==d&amp;&amp;(n.track({type:3,doc:l}),f=!0):this.ic(u,l)||(n.track({type:2,doc:l}),f=!0,(a&amp;&amp;this.Zu(l,a)&gt;0||c&amp;&amp;this.Zu(l,c)&lt;0)&amp;&amp;(o=!0)):!u&amp;&amp;l?(n.track({type:0,doc:l}),f=!0):u&amp;&amp;!l&amp;&amp;(n.track({type:1,doc:u}),f=!0,(a||c)&amp;&amp;(o=!0)),f&amp;&amp;(l?(s=s.add(l),i=d?i.add(e):i.delete(e)):(s=s.delete(e),i=i.delete(e)))})),null!==this.query.limit)for(;s.size&gt;this.query.limit;){const e="F"===this.query.limitType?s.last():s.first();s=s.delete(e.key),i=i.delete(e.key),n.track({type:1,doc:e})}return{tc:s,sc:n,ji:o,mutatedKeys:i}}ic(e,t){return e.hasLocalMutations&amp;&amp;t.hasCommittedMutations&amp;&amp;!t.hasLocalMutations}applyChanges(e,t,n){const r=this.tc;this.tc=e.tc,this.mutatedKeys=e.mutatedKeys;const i=e.sc.Cu();i.sort(((e,t)=&gt;function(e,t){const n=e=&gt;{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return Br()}};return n(e)-n(t)}(e.type,t.type)||this.Zu(e.doc,t.doc))),this.rc(n);const s=t?this.oc():[],o=0===this.Xu.size&amp;&amp;this.current?1:0,a=o!==this.Yu;return this.Yu=o,0!==i.length||a?{snapshot:new yd(this.query,e.tc,r,i,e.mutatedKeys,0===o,a,!1,!!n&amp;&amp;n.resumeToken.approximateByteSize()&gt;0),uc:s}:{uc:s}}ku(e){return this.current&amp;&amp;"Offline"===e?(this.current=!1,this.applyChanges({tc:this.tc,sc:new md,mutatedKeys:this.mutatedKeys,ji:!1},!1)):{uc:[]}}cc(e){return!this.Ju.has(e)&amp;&amp;!!this.tc.has(e)&amp;&amp;!this.tc.get(e).hasLocalMutations}rc(e){e&amp;&amp;(e.addedDocuments.forEach((e=&gt;this.Ju=this.Ju.add(e))),e.modifiedDocuments.forEach((e=&gt;{})),e.removedDocuments.forEach((e=&gt;this.Ju=this.Ju.delete(e))),this.current=e.current)}oc(){if(!this.current)return[];const e=this.Xu;this.Xu=wa(),this.tc.forEach((e=&gt;{this.cc(e.key)&amp;&amp;(this.Xu=this.Xu.add(e.key))}));const t=[];return e.forEach((e=&gt;{this.Xu.has(e)||t.push(new Ad(e))})),this.Xu.forEach((n=&gt;{e.has(n)||t.push(new Nd(n))})),t}ac(e){this.Ju=e.sr,this.Xu=wa();const t=this.nc(e.documents);return this.applyChanges(t,!0)}hc(){return yd.fromInitialDocuments(this.query,this.tc,this.mutatedKeys,0===this.Yu,this.hasCachedResults)}}class Rd{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class Md{constructor(e){this.key=e,this.lc=!1}}class Fd{constructor(e,t,n,r,i,s){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.fc={},this.dc=new ua((e=&gt;ra(e)),na),this._c=new Map,this.wc=new Set,this.mc=new Is(fi.comparator),this.gc=new Map,this.yc=new Rl,this.Ic={},this.Tc=new Map,this.Ec=cl.kn(),this.onlineState="Unknown",this.Ac=void 0}get isPrimaryClient(){return!0===this.Ac}}async function Od(e,t){const n=uf(e);let r,i;const s=n.dc.get(t);if(s)r=s.targetId,n.sharedClientState.addLocalQueryTarget(r),i=s.view.hc();else{const e=await ih(n.localStore,Zo(t)),s=n.sharedClientState.addLocalQueryTarget(e.targetId);r=e.targetId,i=await Ld(n,t,r,"current"===s,e.resumeToken),n.isPrimaryClient&amp;&amp;Uh(n.remoteStore,e)}return i}async function Ld(e,t,n,r,i){e.Rc=(t,n,r)=&gt;async function(e,t,n,r){let i=t.view.nc(n);i.ji&amp;&amp;(i=await oh(e.localStore,t.query,!1).then((({documents:e})=&gt;t.view.nc(e,i))));const s=r&amp;&amp;r.targetChanges.get(t.targetId),o=t.view.applyChanges(i,e.isPrimaryClient,s);return Hd(e,t.targetId,o.uc),o.snapshot}(e,t,n,r);const s=await oh(e.localStore,t,!0),o=new Pd(t,s.sr),a=o.nc(s.documents),c=vc.createSynthesizedTargetChangeForCurrentChange(n,r&amp;&amp;"Offline"!==e.onlineState,i),u=o.applyChanges(a,e.isPrimaryClient,c);Hd(e,n,u.uc);const l=new Rd(t,n,o);return e.dc.set(t,l),e._c.has(n)?e._c.get(n).push(t):e._c.set(n,[t]),u.snapshot}async function qd(e,t){const n=zr(e),r=n.dc.get(t),i=n._c.get(r.targetId);if(i.length&gt;1)return n._c.set(r.targetId,i.filter((e=&gt;!na(e,t)))),void n.dc.delete(t);n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(r.targetId),n.sharedClientState.isActiveQueryTarget(r.targetId)||await sh(n.localStore,r.targetId,!1).then((()=&gt;{n.sharedClientState.clearQueryState(r.targetId),jh(n.remoteStore,r.targetId),Gd(n,r.targetId)})).catch(xi)):(Gd(n,r.targetId),await sh(n.localStore,r.targetId,!0))}async function Vd(e,t){const n=zr(e);try{const e=await function(e,t){const n=zr(e),r=t.snapshotVersion;let i=n.Hi;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(e=&gt;{const s=n.Xi.newChangeBuffer({trackRemovals:!0});i=n.Hi;const o=[];t.targetChanges.forEach(((s,a)=&gt;{const c=i.get(a);if(!c)return;o.push(n.Fs.removeMatchingKeys(e,s.removedDocuments,a).next((()=&gt;n.Fs.addMatchingKeys(e,s.addedDocuments,a))));let u=c.withSequenceNumber(e.currentSequenceNumber);null!==t.targetMismatches.get(a)?u=u.withResumeToken(As.EMPTY_BYTE_STRING,ci.min()).withLastLimboFreeSnapshotVersion(ci.min()):s.resumeToken.approximateByteSize()&gt;0&amp;&amp;(u=u.withResumeToken(s.resumeToken,r)),i=i.insert(a,u),function(e,t,n){return 0===e.resumeToken.approximateByteSize()||t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()&gt;=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size&gt;0}(c,u,s)&amp;&amp;o.push(n.Fs.updateTargetData(e,u))}));let a=ha(),c=wa();if(t.documentUpdates.forEach((r=&gt;{t.resolvedLimboDocuments.has(r)&amp;&amp;o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))})),o.push(nh(e,s,t.documentUpdates).next((e=&gt;{a=e.er,c=e.nr}))),!r.isEqual(ci.min())){const t=n.Fs.getLastRemoteSnapshotVersion(e).next((t=&gt;n.Fs.setTargetsMetadata(e,e.currentSequenceNumber,r)));o.push(t)}return ki.waitFor(o).next((()=&gt;s.apply(e))).next((()=&gt;n.localDocuments.getLocalViewOfDocuments(e,a,c))).next((()=&gt;a))})).then((e=&gt;(n.Hi=i,e)))}(n.localStore,t);t.targetChanges.forEach(((e,t)=&gt;{const r=n.gc.get(t);r&amp;&amp;(Ur(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size&lt;=1),e.addedDocuments.size&gt;0?r.lc=!0:e.modifiedDocuments.size&gt;0?Ur(r.lc):e.removedDocuments.size&gt;0&amp;&amp;(Ur(r.lc),r.lc=!1))})),await Xd(n,e,t)}catch(e){await xi(e)}}function Bd(e,t,n){const r=zr(e);if(r.isPrimaryClient&amp;&amp;0===n||!r.isPrimaryClient&amp;&amp;1===n){const e=[];r.dc.forEach(((n,r)=&gt;{const i=r.view.ku(t);i.snapshot&amp;&amp;e.push(i.snapshot)})),function(e,t){const n=zr(e);n.onlineState=t;let r=!1;n.queries.forEach(((e,n)=&gt;{for(const e of n.listeners)e.ku(t)&amp;&amp;(r=!0)})),r&amp;&amp;Td(n)}(r.eventManager,t),e.length&amp;&amp;r.fc.eu(e),r.onlineState=t,r.isPrimaryClient&amp;&amp;r.sharedClientState.setOnlineState(t)}}async function Ud(e,t,n){const r=zr(e);r.sharedClientState.updateQueryState(t,"rejected",n);const i=r.gc.get(t),s=i&amp;&amp;i.key;if(s){let e=new Is(fi.comparator);e=e.insert(s,ho.newNoDocument(s,ci.min()));const n=wa().add(s),i=new _c(ci.min(),new Map,new Is(ii),e,n);await Vd(r,i),r.mc=r.mc.remove(s),r.gc.delete(t),Yd(r)}else await sh(r.localStore,t,!1).then((()=&gt;Gd(r,t,n))).catch(xi)}async function jd(e,t){const n=zr(e),r=t.batch.batchId;try{const e=await function(e,t){const n=zr(e);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(e=&gt;{const r=t.batch.keys(),i=n.Xi.newChangeBuffer({trackRemovals:!0});return function(e,t,n,r){const i=n.batch,s=i.keys();let o=ki.resolve();return s.forEach((e=&gt;{o=o.next((()=&gt;r.getEntry(t,e))).next((t=&gt;{const s=n.docVersions.get(e);Ur(null!==s),t.version.compareTo(s)&lt;0&amp;&amp;(i.applyToRemoteDocument(t,n),t.isValidDocument()&amp;&amp;(t.setReadTime(n.commitVersion),r.addEntry(t)))}))})),o.next((()=&gt;e.mutationQueue.removeMutationBatch(t,i)))}(n,e,t,i).next((()=&gt;i.apply(e))).next((()=&gt;n.mutationQueue.performConsistencyCheck(e))).next((()=&gt;n.documentOverlayCache.removeOverlaysForBatchId(e,r,t.batch.batchId))).next((()=&gt;n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=wa();for(let n=0;n&lt;e.mutationResults.length;++n)e.mutationResults[n].transformResults.length&gt;0&amp;&amp;(t=t.add(e.batch.mutations[n].key));return t}(t)))).next((()=&gt;n.localDocuments.getDocuments(e,r)))}))}(n.localStore,t);Kd(n,r,null),$d(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await Xd(n,e)}catch(e){await xi(e)}}async function zd(e,t,n){const r=zr(e);try{const e=await function(e,t){const n=zr(e);return n.persistence.runTransaction("Reject batch","readwrite-primary",(e=&gt;{let r;return n.mutationQueue.lookupMutationBatch(e,t).next((t=&gt;(Ur(null!==t),r=t.keys(),n.mutationQueue.removeMutationBatch(e,t)))).next((()=&gt;n.mutationQueue.performConsistencyCheck(e))).next((()=&gt;n.documentOverlayCache.removeOverlaysForBatchId(e,r,t))).next((()=&gt;n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,r))).next((()=&gt;n.localDocuments.getDocuments(e,r)))}))}(r.localStore,t);Kd(r,t,n),$d(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),await Xd(r,e)}catch(n){await xi(n)}}function $d(e,t){(e.Tc.get(t)||[]).forEach((e=&gt;{e.resolve()})),e.Tc.delete(t)}function Kd(e,t,n){const r=zr(e);let i=r.Ic[r.currentUser.toKey()];if(i){const e=i.get(t);e&amp;&amp;(n?e.reject(n):e.resolve(),i=i.remove(t)),r.Ic[r.currentUser.toKey()]=i}}function Gd(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(const r of e._c.get(t))e.dc.delete(r),n&amp;&amp;e.fc.vc(r,n);e._c.delete(t),e.isPrimaryClient&amp;&amp;e.yc.ps(t).forEach((t=&gt;{e.yc.containsKey(t)||Wd(e,t)}))}function Wd(e,t){e.wc.delete(t.path.canonicalString());const n=e.mc.get(t);null!==n&amp;&amp;(jh(e.remoteStore,n),e.mc=e.mc.remove(t),e.gc.delete(n),Yd(e))}function Hd(e,t,n){for(const r of n)r instanceof Nd?(e.yc.addReference(r.key,t),Qd(e,r)):r instanceof Ad?(Or("SyncEngine","Document no longer in limbo: "+r.key),e.yc.removeReference(r.key,t),e.yc.containsKey(r.key)||Wd(e,r.key)):Br()}function Qd(e,t){const n=t.key,r=n.path.canonicalString();e.mc.get(n)||e.wc.has(r)||(Or("SyncEngine","New document in limbo: "+n),e.wc.add(r),Yd(e))}function Yd(e){for(;e.wc.size&gt;0&amp;&amp;e.mc.size&lt;e.maxConcurrentLimboResolutions;){const t=e.wc.values().next().value;e.wc.delete(t);const n=new fi(li.fromString(t)),r=e.Ec.next();e.gc.set(r,new Md(n)),e.mc=e.mc.insert(n,r),Uh(e.remoteStore,new ou(Zo(Wo(n.path)),r,"TargetPurposeLimboResolution",Bi.ct))}}async function Xd(e,t,n){const r=zr(e),i=[],s=[],o=[];r.dc.isEmpty()||(r.dc.forEach(((e,a)=&gt;{o.push(r.Rc(a,t,n).then((e=&gt;{if((e||n)&amp;&amp;r.isPrimaryClient&amp;&amp;r.sharedClientState.updateQueryState(a.targetId,(null==e?void 0:e.fromCache)?"not-current":"current"),e){i.push(e);const t=Yl.Bi(a.targetId,e);s.push(t)}})))})),await Promise.all(o),r.fc.eu(i),await async function(e,t){const n=zr(e);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(e=&gt;ki.forEach(t,(t=&gt;ki.forEach(t.$i,(r=&gt;n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=&gt;ki.forEach(t.Fi,(r=&gt;n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!Ri(e))throw e;Or("LocalStore","Failed to update sequence numbers: "+e)}for(const e of t){const t=e.targetId;if(!e.fromCache){const e=n.Hi.get(t),r=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(r);n.Hi=n.Hi.insert(t,i)}}}(r.localStore,s))}async function Jd(e,t){const n=zr(e);if(!n.currentUser.isEqual(t)){Or("SyncEngine","User change. New user:",t.toKey());const e=await eh(n.localStore,t);n.currentUser=t,function(e,t){e.Tc.forEach((e=&gt;{e.forEach((e=&gt;{e.reject(new Kr($r.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),e.Tc.clear()}(n),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await Xd(n,e.tr)}}function Zd(e,t){const n=zr(e),r=n.gc.get(t);if(r&amp;&amp;r.lc)return wa().add(r.key);{let e=wa();const r=n._c.get(t);if(!r)return e;for(const t of r){const r=n.dc.get(t);e=e.unionWith(r.view.ec)}return e}}async function ef(e,t){const n=zr(e),r=await oh(n.localStore,t.query,!0),i=t.view.ac(r);return n.isPrimaryClient&amp;&amp;Hd(n,t.targetId,i.uc),i}async function tf(e,t){const n=zr(e);return ch(n.localStore,t).then((e=&gt;Xd(n,e)))}async function nf(e,t,n,r){const i=zr(e),s=await function(e,t){const n=zr(e),r=zr(n.mutationQueue);return n.persistence.runTransaction("Lookup mutation documents","readonly",(e=&gt;r.Vn(e,t).next((t=&gt;t?n.localDocuments.getDocuments(e,t):ki.resolve(null)))))}(i.localStore,t);null!==s?("pending"===n?await ed(i.remoteStore):"acknowledged"===n||"rejected"===n?(Kd(i,t,r||null),$d(i,t),function(e,t){zr(zr(e).mutationQueue).Dn(t)}(i.localStore,t)):Br(),await Xd(i,s)):Or("SyncEngine","Cannot apply mutation batch with id: "+t)}async function rf(e,t,n){const r=zr(e),i=[],s=[];for(const e of t){let t;const n=r._c.get(e);if(n&amp;&amp;0!==n.length){t=await ih(r.localStore,Zo(n[0]));for(const e of n){const t=r.dc.get(e),n=await ef(r,t);n.snapshot&amp;&amp;s.push(n.snapshot)}}else{const n=await ah(r.localStore,e);t=await ih(r.localStore,n),await Ld(r,sf(n),e,!1,t.resumeToken)}i.push(t)}return r.fc.eu(s),i}function sf(e){return Go(e.path,e.collectionGroup,e.orderBy,e.filters,e.limit,"F",e.startAt,e.endAt)}function of(e){const t=zr(e);return zr(zr(t.localStore).persistence).Mi()}async function af(e,t,n,r){const i=zr(e);if(i.Ac)return void Or("SyncEngine","Ignoring unexpected query state notification.");const s=i._c.get(t);if(s&amp;&amp;s.length&gt;0)switch(n){case"current":case"not-current":{const e=await ch(i.localStore,oa(s[0])),r=_c.createSynthesizedRemoteEventForCurrentChange(t,"current"===n,As.EMPTY_BYTE_STRING);await Xd(i,e,r);break}case"rejected":await sh(i.localStore,t,!0),Gd(i,t,r);break;default:Br()}}async function cf(e,t,n){const r=uf(e);if(r.Ac){for(const e of t){if(r._c.has(e)){Or("SyncEngine","Adding an already active target "+e);continue}const t=await ah(r.localStore,e),n=await ih(r.localStore,t);await Ld(r,sf(t),n.targetId,!1,n.resumeToken),Uh(r.remoteStore,n)}for(const e of n)r._c.has(e)&amp;&amp;await sh(r.localStore,e,!1).then((()=&gt;{jh(r.remoteStore,e),Gd(r,e)})).catch(xi)}}function uf(e){const t=zr(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=Vd.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=Zd.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=Ud.bind(null,t),t.fc.eu=Id.bind(null,t.eventManager),t.fc.vc=Cd.bind(null,t.eventManager),t}function lf(e){const t=zr(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=jd.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=zd.bind(null,t),t}class hf{constructor(){this.synchronizeTabs=!1}async initialize(e){this.serializer=Ah(e.databaseInfo.databaseId),this.sharedClientState=this.createSharedClientState(e),this.persistence=this.createPersistence(e),await this.persistence.start(),this.localStore=this.createLocalStore(e),this.gcScheduler=this.createGarbageCollectionScheduler(e,this.localStore),this.indexBackfillerScheduler=this.createIndexBackfillerScheduler(e,this.localStore)}createGarbageCollectionScheduler(e,t){return null}createIndexBackfillerScheduler(e,t){return null}createLocalStore(e){return Zl(this.persistence,new Xl,e.initialUser,this.serializer)}createPersistence(e){return new Vl(Ul.js,this.serializer)}createSharedClientState(e){return new wh}async terminate(){this.gcScheduler&amp;&amp;this.gcScheduler.stop(),await this.sharedClientState.shutdown(),await this.persistence.shutdown()}}class df extends hf{constructor(e){super(),this.cacheSizeBytes=e}createGarbageCollectionScheduler(e,t){Ur(this.persistence.referenceDelegate instanceof jl);const n=this.persistence.referenceDelegate.garbageCollector;return new gl(n,e.asyncQueue,t)}createPersistence(e){const t=void 0!==this.cacheSizeBytes?el.withCacheSize(this.cacheSizeBytes):el.DEFAULT;return new Vl((e=&gt;jl.js(e,t)),this.serializer)}}class ff extends hf{constructor(e,t,n){super(),this.bc=e,this.cacheSizeBytes=t,this.forceOwnership=n,this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await this.bc.initialize(this,e),await lf(this.bc.syncEngine),await ed(this.bc.remoteStore),await this.persistence.pi((()=&gt;(this.gcScheduler&amp;&amp;!this.gcScheduler.started&amp;&amp;this.gcScheduler.start(),this.indexBackfillerScheduler&amp;&amp;!this.indexBackfillerScheduler.started&amp;&amp;this.indexBackfillerScheduler.start(),Promise.resolve())))}createLocalStore(e){return Zl(this.persistence,new Xl,e.initialUser,this.serializer)}createGarbageCollectionScheduler(e,t){const n=this.persistence.referenceDelegate.garbageCollector;return new gl(n,e.asyncQueue,t)}createIndexBackfillerScheduler(e,t){const n=new Vi(t,this.persistence);return new qi(e.asyncQueue,n)}createPersistence(e){const t=Ql(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?el.withCacheSize(this.cacheSizeBytes):el.DEFAULT;return new Gl(this.synchronizeTabs,t,e.clientId,n,e.asyncQueue,Dh(),Nh(),this.serializer,this.sharedClientState,!!this.forceOwnership)}createSharedClientState(e){return new wh}}class pf extends ff{constructor(e,t){super(e,t,!1),this.bc=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);const t=this.bc.syncEngine;this.sharedClientState instanceof vh&amp;&amp;(this.sharedClientState.syncEngine={Qr:nf.bind(null,t),jr:af.bind(null,t),zr:cf.bind(null,t),Mi:of.bind(null,t),Gr:tf.bind(null,t)},await this.sharedClientState.start()),await this.persistence.pi((async e=&gt;{await async function(e,t){const n=zr(e);if(uf(n),lf(n),!0===t&amp;&amp;!0!==n.Ac){const e=n.sharedClientState.getAllActiveQueryTargets(),t=await rf(n,e.toArray());n.Ac=!0,await ld(n.remoteStore,!0);for(const e of t)Uh(n.remoteStore,e)}else if(!1===t&amp;&amp;!1!==n.Ac){const e=[];let t=Promise.resolve();n._c.forEach(((r,i)=&gt;{n.sharedClientState.isLocalQueryTarget(i)?e.push(i):t=t.then((()=&gt;(Gd(n,i),sh(n.localStore,i,!0)))),jh(n.remoteStore,i)})),await t,await rf(n,e),function(e){const t=zr(e);t.gc.forEach(((e,n)=&gt;{jh(t.remoteStore,n)})),t.yc.Is(),t.gc=new Map,t.mc=new Is(fi.comparator)}(n),n.Ac=!1,await ld(n.remoteStore,!1)}}(this.bc.syncEngine,e),this.gcScheduler&amp;&amp;(e&amp;&amp;!this.gcScheduler.started?this.gcScheduler.start():e||this.gcScheduler.stop()),this.indexBackfillerScheduler&amp;&amp;(e&amp;&amp;!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():e||this.indexBackfillerScheduler.stop())}))}createSharedClientState(e){const t=Dh();if(!vh.D(t))throw new Kr($r.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");const n=Ql(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new vh(t,e.asyncQueue,n,e.clientId,e.initialUser)}}class gf{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=&gt;Bd(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=Jd.bind(null,this.syncEngine),await ld(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new vd}createDatastore(e){const t=Ah(e.databaseInfo.databaseId),n=(r=e.databaseInfo,new kh(r));var r;return function(e,t,n,r){return new Oh(e,t,n,r)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return t=this.localStore,n=this.datastore,r=e.asyncQueue,i=e=&gt;Bd(this.syncEngine,e,0),s=Ih.D()?new Ih:new bh,new qh(t,n,r,i,s);var t,n,r,i,s}createSyncEngine(e,t){return function(e,t,n,r,i,s,o){const a=new Fd(e,t,n,r,i,s);return o&amp;&amp;(a.Ac=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}terminate(){return async function(e){const t=zr(e);Or("RemoteStore","RemoteStore shutting down."),t.Au.add(5),await Bh(t),t.vu.shutdown(),t.Pu.set("Unknown")}(this.remoteStore)}}function mf(e,t=10240){let n=0;return{async read(){if(n&lt;e.byteLength){const r={value:e.slice(n,n+t),done:!1};return n+=t,r}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}class yf{constructor(e){this.observer=e,this.muted=!1}next(e){this.observer.next&amp;&amp;this.Vc(this.observer.next,e)}error(e){this.observer.error?this.Vc(this.observer.error,e):Lr("Uncaught Error in snapshot listener:",e.toString())}Sc(){this.muted=!0}Vc(e,t){this.muted||setTimeout((()=&gt;{this.muted||e(t)}),0)}}class _f{constructor(e,t){this.Dc=e,this.serializer=t,this.metadata=new Gr,this.buffer=new Uint8Array,this.Cc=new TextDecoder("utf-8"),this.xc().then((e=&gt;{e&amp;&amp;e.Gu()?this.metadata.resolve(e.Ku.metadata):this.metadata.reject(new Error(`The first element of the bundle is not a metadata, it is\n             ${JSON.stringify(null==e?void 0:e.Ku)}`))}),(e=&gt;this.metadata.reject(e)))}close(){return this.Dc.cancel()}async getMetadata(){return this.metadata.promise}async Pc(){return await this.getMetadata(),this.xc()}async xc(){const e=await this.Nc();if(null===e)return null;const t=this.Cc.decode(e),n=Number(t);isNaN(n)&amp;&amp;this.kc(`length string (${t}) is not valid number`);const r=await this.Mc(n);return new Sd(JSON.parse(r),e.length+n)}Oc(){return this.buffer.findIndex((e=&gt;e==="{".charCodeAt(0)))}async Nc(){for(;this.Oc()&lt;0&amp;&amp;!await this.$c(););if(0===this.buffer.length)return null;const e=this.Oc();e&lt;0&amp;&amp;this.kc("Reached the end of bundle when a length string is expected.");const t=this.buffer.slice(0,e);return this.buffer=this.buffer.slice(e),t}async Mc(e){for(;this.buffer.length&lt;e;)await this.$c()&amp;&amp;this.kc("Reached the end of bundle when more is expected.");const t=this.Cc.decode(this.buffer.slice(0,e));return this.buffer=this.buffer.slice(e),t}kc(e){throw this.Dc.cancel(),new Error(`Invalid bundle format: ${e}`)}async $c(){const e=await this.Dc.read();if(!e.done){const t=new Uint8Array(this.buffer.length+e.value.length);t.set(this.buffer),t.set(e.value,this.buffer.length),this.buffer=t}return e.done}}class vf{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),this.mutations.length&gt;0)throw new Kr($r.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");const t=await async function(e,t){const n=zr(e),r=jc(n.serializer)+"/documents",i={documents:t.map((e=&gt;qc(n.serializer,e)))},s=await n.Ao("BatchGetDocuments",r,i,t.length),o=new Map;s.forEach((e=&gt;{const t=function(e,t){return"found"in t?function(e,t){Ur(!!t.found),t.found.name,t.found.updateTime;const n=Vc(e,t.found.name),r=Fc(t.found.updateTime),i=t.found.createTime?Fc(t.found.createTime):ci.min(),s=new uo({mapValue:{fields:t.found.fields}});return ho.newFoundDocument(n,r,i,s)}(e,t):"missing"in t?function(e,t){Ur(!!t.missing),Ur(!!t.readTime);const n=Vc(e,t.missing),r=Fc(t.readTime);return ho.newNoDocument(n,r)}(e,t):Br()}(n.serializer,e);o.set(t.key.toString(),t)}));const a=[];return t.forEach((e=&gt;{const t=o.get(e.toString());Ur(!!t),a.push(t)})),a}(this.datastore,e);return t.forEach((e=&gt;this.recordVersion(e))),t}set(e,t){this.write(t.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}update(e,t){try{this.write(t.toMutation(e,this.preconditionForUpdate(e)))}catch(e){this.lastWriteError=e}this.writtenDocs.add(e.toString())}delete(e){this.write(new Za(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;const e=this.readVersions;this.mutations.forEach((t=&gt;{e.delete(t.key.toString())})),e.forEach(((e,t)=&gt;{const n=fi.fromPath(t);this.mutations.push(new ec(n,this.precondition(n)))})),await async function(e,t){const n=zr(e),r=jc(n.serializer)+"/documents",i={writes:t.map((e=&gt;Gc(n.serializer,e)))};await n.po("Commit",r,i)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw Br();t=ci.min()}const n=this.readVersions.get(e.key.toString());if(n){if(!t.isEqual(n))throw new Kr($r.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}precondition(e){const t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&amp;&amp;t?t.isEqual(ci.min())?Ba.exists(!1):Ba.updateTime(t):Ba.none()}preconditionForUpdate(e){const t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&amp;&amp;t){if(t.isEqual(ci.min()))throw new Kr($r.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Ba.updateTime(t)}return Ba.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class wf{constructor(e,t,n,r,i){this.asyncQueue=e,this.datastore=t,this.options=n,this.updateFunction=r,this.deferred=i,this.Fc=n.maxAttempts,this.Lo=new Ph(this.asyncQueue,"transaction_retry")}run(){this.Fc-=1,this.Bc()}Bc(){this.Lo.xo((async()=&gt;{const e=new vf(this.datastore),t=this.Lc(e);t&amp;&amp;t.then((t=&gt;{this.asyncQueue.enqueueAndForget((()=&gt;e.commit().then((()=&gt;{this.deferred.resolve(t)})).catch((e=&gt;{this.qc(e)}))))})).catch((e=&gt;{this.qc(e)}))}))}Lc(e){try{const t=this.updateFunction(e);return!Ui(t)&amp;&amp;t.catch&amp;&amp;t.then?t:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}qc(e){this.Fc&gt;0&amp;&amp;this.Uc(e)?(this.Fc-=1,this.asyncQueue.enqueueAndForget((()=&gt;(this.Bc(),Promise.resolve())))):this.deferred.reject(e)}Uc(e){if("FirebaseError"===e.name){const t=e.code;return"aborted"===t||"failed-precondition"===t||"already-exists"===t||!cc(t)}return!1}}class bf{constructor(e,t,n,r){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=Ar.UNAUTHENTICATED,this.clientId=ri.A(),this.authCredentialListener=()=&gt;Promise.resolve(),this.appCheckCredentialListener=()=&gt;Promise.resolve(),this.authCredentials.start(n,(async e=&gt;{Or("FirestoreClient","Received user=",e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=&gt;(Or("FirestoreClient","Received new app check token=",e),this.appCheckCredentialListener(e,this.user))))}async getConfiguration(){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}verifyNotTerminated(){if(this.asyncQueue.isShuttingDown)throw new Kr($r.FAILED_PRECONDITION,"The client has already been terminated.")}terminate(){this.asyncQueue.enterRestrictedMode();const e=new Gr;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=&gt;{try{this._onlineComponents&amp;&amp;await this._onlineComponents.terminate(),this._offlineComponents&amp;&amp;await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){const n=pd(t,"Failed to shutdown persistence");e.reject(n)}})),e.promise}}async function If(e,t){e.asyncQueue.verifyOperationInProgress(),Or("FirestoreClient","Initializing OfflineComponentProvider");const n=await e.getConfiguration();await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=&gt;{r.isEqual(e)||(await eh(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=&gt;e.terminate())),e._offlineComponents=t}async function Cf(e,t){e.asyncQueue.verifyOperationInProgress();const n=await Ef(e);Or("FirestoreClient","Initializing OnlineComponentProvider");const r=await e.getConfiguration();await t.initialize(n,r),e.setCredentialChangeListener((e=&gt;ud(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=&gt;ud(t.remoteStore,n))),e._onlineComponents=t}function Tf(e){return"FirebaseError"===e.name?e.code===$r.FAILED_PRECONDITION||e.code===$r.UNIMPLEMENTED:!("undefined"!=typeof DOMException&amp;&amp;e instanceof DOMException)||22===e.code||20===e.code||11===e.code}async function Ef(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){Or("FirestoreClient","Using user provided OfflineComponentProvider");try{await If(e,e._uninitializedComponentsProvider._offline)}catch(t){const n=t;if(!Tf(n))throw n;qr("Error using user provided cache. Falling back to memory cache: "+n),await If(e,new hf)}}else Or("FirestoreClient","Using default OfflineComponentProvider"),await If(e,new hf);return e._offlineComponents}async function Sf(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(Or("FirestoreClient","Using user provided OnlineComponentProvider"),await Cf(e,e._uninitializedComponentsProvider._online)):(Or("FirestoreClient","Using default OnlineComponentProvider"),await Cf(e,new gf))),e._onlineComponents}function xf(e){return Ef(e).then((e=&gt;e.persistence))}function kf(e){return Ef(e).then((e=&gt;e.localStore))}function Df(e){return Sf(e).then((e=&gt;e.remoteStore))}function Nf(e){return Sf(e).then((e=&gt;e.syncEngine))}function Af(e){return Sf(e).then((e=&gt;e.datastore))}async function Pf(e){const t=await Sf(e),n=t.eventManager;return n.onListen=Od.bind(null,t.syncEngine),n.onUnlisten=qd.bind(null,t.syncEngine),n}function Rf(e,t,n={}){const r=new Gr;return e.asyncQueue.enqueueAndForget((async()=&gt;function(e,t,n,r,i){const s=new yf({next:s=&gt;{t.enqueueAndForget((()=&gt;bd(e,o)));const a=s.docs.has(n);!a&amp;&amp;s.fromCache?i.reject(new Kr($r.UNAVAILABLE,"Failed to get document because the client is offline.")):a&amp;&amp;s.fromCache&amp;&amp;r&amp;&amp;"server"===r.source?i.reject(new Kr($r.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=&gt;i.reject(e)}),o=new Ed(Wo(n.path),s,{includeMetadataChanges:!0,Uu:!0});return wd(e,o)}(await Pf(e),e.asyncQueue,t,n,r))),r.promise}function Mf(e,t,n={}){const r=new Gr;return e.asyncQueue.enqueueAndForget((async()=&gt;function(e,t,n,r,i){const s=new yf({next:n=&gt;{t.enqueueAndForget((()=&gt;bd(e,o))),n.fromCache&amp;&amp;"server"===r.source?i.reject(new Kr($r.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=&gt;i.reject(e)}),o=new Ed(n,s,{includeMetadataChanges:!0,Uu:!0});return wd(e,o)}(await Pf(e),e.asyncQueue,t,n,r))),r.promise}const Ff=new Map;function Of(e,t,n){if(!n)throw new Kr($r.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function Lf(e,t,n,r){if(!0===t&amp;&amp;!0===r)throw new Kr($r.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function qf(e){if(!fi.isDocumentKey(e))throw new Kr($r.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function Vf(e){if(fi.isDocumentKey(e))throw new Kr($r.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function Bf(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length&gt;20&amp;&amp;(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{const t=function(e){return e.constructor?e.constructor.name:null}(e);return t?`a custom ${t} object`:"an object"}}return"function"==typeof e?"a function":Br()}function Uf(e,t){if("_delegate"in e&amp;&amp;(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new Kr($r.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=Bf(e);throw new Kr($r.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function jf(e,t){if(t&lt;=0)throw new Kr($r.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}class zf{constructor(e){var t;if(void 0===e.host){if(void 0!==e.ssl)throw new Kr($r.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=e.host,this.ssl=null===(t=e.ssl)||void 0===t||t;if(this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.cache=e.localCache,void 0===e.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==e.cacheSizeBytes&amp;&amp;e.cacheSizeBytes&lt;1048576)throw new Kr($r.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}Lf("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling||void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!1:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&amp;&amp;this.ssl===e.ssl&amp;&amp;this.credentials===e.credentials&amp;&amp;this.cacheSizeBytes===e.cacheSizeBytes&amp;&amp;this.experimentalForceLongPolling===e.experimentalForceLongPolling&amp;&amp;this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&amp;&amp;this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&amp;&amp;this.useFetchStreams===e.useFetchStreams}}class $f{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 zf({}),this._settingsFrozen=!1}get app(){if(!this._app)throw new Kr($r.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 void 0!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new Kr($r.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 zf(e),void 0!==e.credentials&amp;&amp;(this._authCredentials=function(e){if(!e)return new Hr;switch(e.type){case"firstParty":return new Jr(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new Kr($r.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){const t=Ff.get(e);t&amp;&amp;(Or("ComponentProvider","Removing Datastore"),Ff.delete(e),t.terminate())}(this),Promise.resolve()}}function Kf(e,t,n,r={}){var i;const s=(e=Uf(e,$f))._getSettings();if("firestore.googleapis.com"!==s.host&amp;&amp;s.host!==t&amp;&amp;qr("Host has been set in both settings() and useEmulator(), emulator host will be used"),e._setSettings(Object.assign(Object.assign({},s),{host:`${t}:${n}`,ssl:!1})),r.mockUserToken){let t,n;if("string"==typeof r.mockUserToken)t=r.mockUserToken,n=Ar.MOCK_USER;else{t=(0,a.Sg)(r.mockUserToken,null===(i=e._app)||void 0===i?void 0:i.options.projectId);const s=r.mockUserToken.sub||r.mockUserToken.user_id;if(!s)throw new Kr($r.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new Ar(s)}e._authCredentials=new Qr(new Wr(t,n))}}class Gf{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 Hf(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new Gf(this.firestore,e,this._key)}}class Wf{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new Wf(this.firestore,e,this._query)}}class Hf extends Wf{constructor(e,t,n){super(e,t,Wo(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new Gf(this.firestore,null,new fi(e))}withConverter(e){return new Hf(this.firestore,e,this._path)}}function Qf(e,t,...n){if(e=(0,a.m9)(e),Of("collection","path",t),e instanceof $f){const r=li.fromString(t,...n);return Vf(r),new Hf(e,null,r)}{if(!(e instanceof Gf||e instanceof Hf))throw new Kr($r.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(li.fromString(t,...n));return Vf(r),new Hf(e.firestore,null,r)}}function Yf(e,t){if(e=Uf(e,$f),Of("collectionGroup","collection id",t),t.indexOf("/")&gt;=0)throw new Kr($r.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new Wf(e,null,function(e){return new Ko(li.emptyPath(),e)}(t))}function Xf(e,t,...n){if(e=(0,a.m9)(e),1===arguments.length&amp;&amp;(t=ri.A()),Of("doc","path",t),e instanceof $f){const r=li.fromString(t,...n);return qf(r),new Gf(e,null,new fi(r))}{if(!(e instanceof Gf||e instanceof Hf))throw new Kr($r.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(li.fromString(t,...n));return qf(r),new Gf(e.firestore,e instanceof Hf?e.converter:null,new fi(r))}}function Jf(e,t){return e=(0,a.m9)(e),t=(0,a.m9)(t),(e instanceof Gf||e instanceof Hf)&amp;&amp;(t instanceof Gf||t instanceof Hf)&amp;&amp;e.firestore===t.firestore&amp;&amp;e.path===t.path&amp;&amp;e.converter===t.converter}function Zf(e,t){return e=(0,a.m9)(e),t=(0,a.m9)(t),e instanceof Wf&amp;&amp;t instanceof Wf&amp;&amp;e.firestore===t.firestore&amp;&amp;na(e._query,t._query)&amp;&amp;e.converter===t.converter}class ep{constructor(){this.Kc=Promise.resolve(),this.Gc=[],this.Qc=!1,this.jc=[],this.zc=null,this.Wc=!1,this.Hc=!1,this.Jc=[],this.Lo=new Ph(this,"async_queue_retry"),this.Yc=()=&gt;{const e=Nh();e&amp;&amp;Or("AsyncQueue","Visibility state changed to "+e.visibilityState),this.Lo.ko()};const e=Nh();e&amp;&amp;"function"==typeof e.addEventListener&amp;&amp;e.addEventListener("visibilitychange",this.Yc)}get isShuttingDown(){return this.Qc}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Xc(),this.Zc(e)}enterRestrictedMode(e){if(!this.Qc){this.Qc=!0,this.Hc=e||!1;const t=Nh();t&amp;&amp;"function"==typeof t.removeEventListener&amp;&amp;t.removeEventListener("visibilitychange",this.Yc)}}enqueue(e){if(this.Xc(),this.Qc)return new Promise((()=&gt;{}));const t=new Gr;return this.Zc((()=&gt;this.Qc&amp;&amp;this.Hc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=&gt;t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=&gt;(this.Gc.push(e),this.ta())))}async ta(){if(0!==this.Gc.length){try{await this.Gc[0](),this.Gc.shift(),this.Lo.reset()}catch(e){if(!Ri(e))throw e;Or("AsyncQueue","Operation failed with retryable error: "+e)}this.Gc.length&gt;0&amp;&amp;this.Lo.xo((()=&gt;this.ta()))}}Zc(e){const t=this.Kc.then((()=&gt;(this.Wc=!0,e().catch((e=&gt;{this.zc=e,this.Wc=!1;const t=function(e){let t=e.message||"";return e.stack&amp;&amp;(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}(e);throw Lr("INTERNAL UNHANDLED ERROR: ",t),e})).then((e=&gt;(this.Wc=!1,e))))));return this.Kc=t,t}enqueueAfterDelay(e,t,n){this.Xc(),this.Jc.indexOf(e)&gt;-1&amp;&amp;(t=0);const r=fd.createAndSchedule(this,e,t,n,(e=&gt;this.ea(e)));return this.jc.push(r),r}Xc(){this.zc&amp;&amp;Br()}verifyOperationInProgress(){}async na(){let e;do{e=this.Kc,await e}while(e!==this.Kc)}sa(e){for(const t of this.jc)if(t.timerId===e)return!0;return!1}ia(e){return this.na().then((()=&gt;{this.jc.sort(((e,t)=&gt;e.targetTimeMs-t.targetTimeMs));for(const t of this.jc)if(t.skipDelay(),"all"!==e&amp;&amp;t.timerId===e)break;return this.na()}))}ra(e){this.Jc.push(e)}ea(e){const t=this.jc.indexOf(e);this.jc.splice(t,1)}}function tp(e){return function(e,t){if("object"!=typeof e||null===e)return!1;const n=e;for(const e of["next","error","complete"])if(e in n&amp;&amp;"function"==typeof n[e])return!0;return!1}(e)}class np{constructor(){this._progressObserver={},this._taskCompletionResolver=new Gr,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(e,t,n){this._progressObserver={next:e,error:t,complete:n}}catch(e){return this._taskCompletionResolver.promise.catch(e)}then(e,t){return this._taskCompletionResolver.promise.then(e,t)}_completeWith(e){this._updateProgress(e),this._progressObserver.complete&amp;&amp;this._progressObserver.complete(),this._taskCompletionResolver.resolve(e)}_failWith(e){this._lastProgress.taskState="Error",this._progressObserver.next&amp;&amp;this._progressObserver.next(this._lastProgress),this._progressObserver.error&amp;&amp;this._progressObserver.error(e),this._taskCompletionResolver.reject(e)}_updateProgress(e){this._lastProgress=e,this._progressObserver.next&amp;&amp;this._progressObserver.next(e)}}const rp=-1;class ip extends $f{constructor(e,t,n,r){super(e,t,n,r),this.type="firestore",this._queue=new ep,this._persistenceKey=(null==r?void 0:r.name)||"[DEFAULT]"}_terminate(){return this._firestoreClient||cp(this),this._firestoreClient.terminate()}}function sp(e,t,n){n||(n="(default)");const r=(0,i.qX)(e,"firestore");if(r.isInitialized(n)){const e=r.getImmediate({identifier:n}),i=r.getOptions(n);if((0,a.vZ)(i,t))return e;throw new Kr($r.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(void 0!==t.cacheSizeBytes&amp;&amp;void 0!==t.localCache)throw new Kr($r.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(void 0!==t.cacheSizeBytes&amp;&amp;-1!==t.cacheSizeBytes&amp;&amp;t.cacheSizeBytes&lt;1048576)throw new Kr($r.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return r.initialize({options:t,instanceIdentifier:n})}function op(e,t){const n="object"==typeof e?e:(0,i.Mq)(),r="string"==typeof e?e:t||"(default)",s=(0,i.qX)(n,"firestore").getImmediate({identifier:r});if(!s._initialized){const e=(0,a.P0)("firestore");e&amp;&amp;Kf(s,...e)}return s}function ap(e){return e._firestoreClient||cp(e),e._firestoreClient.verifyNotTerminated(),e._firestoreClient}function cp(e){var t,n,r;const i=e._freezeSettings(),s=function(e,t,n,r){return new Vs(e,t,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,r.useFetchStreams)}(e._databaseId,(null===(t=e._app)||void 0===t?void 0:t.options.appId)||"",e._persistenceKey,i);e._firestoreClient=new bf(e._authCredentials,e._appCheckCredentials,e._queue,s),(null===(n=i.cache)||void 0===n?void 0:n._offlineComponentProvider)&amp;&amp;(null===(r=i.cache)||void 0===r?void 0:r._onlineComponentProvider)&amp;&amp;(e._firestoreClient._uninitializedComponentsProvider={_offlineKind:i.cache.kind,_offline:i.cache._offlineComponentProvider,_online:i.cache._onlineComponentProvider})}function up(e,t){vp(e=Uf(e,ip));const n=ap(e);if(n._uninitializedComponentsProvider)throw new Kr($r.FAILED_PRECONDITION,"SDK cache is already specified.");qr("enableIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const r=e._freezeSettings(),i=new gf;return hp(n,i,new ff(i,r.cacheSizeBytes,null==t?void 0:t.forceOwnership))}function lp(e){vp(e=Uf(e,ip));const t=ap(e);if(t._uninitializedComponentsProvider)throw new Kr($r.FAILED_PRECONDITION,"SDK cache is already specified.");qr("enableMultiTabIndexedDbPersistence() will be deprecated in the future, you can use `FirestoreSettings.cache` instead.");const n=e._freezeSettings(),r=new gf;return hp(t,r,new pf(r,n.cacheSizeBytes))}function hp(e,t,n){const r=new Gr;return e.asyncQueue.enqueue((async()=&gt;{try{await If(e,n),await Cf(e,t),r.resolve()}catch(e){const t=e;if(!Tf(t))throw t;qr("Error enabling indexeddb cache. Falling back to memory cache: "+t),r.reject(t)}})).then((()=&gt;r.promise))}function dp(e){if(e._initialized&amp;&amp;!e._terminated)throw new Kr($r.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");const t=new Gr;return e._queue.enqueueAndForgetEvenWhileRestricted((async()=&gt;{try{await async function(e){if(!Ni.D())return Promise.resolve();const t=e+"main";await Ni.delete(t)}(Ql(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}})),t.promise}function fp(e){return function(e){const t=new Gr;return e.asyncQueue.enqueueAndForget((async()=&gt;async function(e,t){const n=zr(e);Wh(n.remoteStore)||Or("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{const e=await function(e){const t=zr(e);return t.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(e=&gt;t.mutationQueue.getHighestUnacknowledgedBatchId(e)))}(n.localStore);if(-1===e)return void t.resolve();const r=n.Tc.get(e)||[];r.push(t),n.Tc.set(e,r)}catch(e){const n=pd(e,"Initialization of waitForPendingWrites() operation failed");t.reject(n)}}(await Nf(e),t))),t.promise}(ap(e=Uf(e,ip)))}function pp(e){return function(e){return e.asyncQueue.enqueue((async()=&gt;{const t=await xf(e),n=await Df(e);return t.setNetworkEnabled(!0),function(e){const t=zr(e);return t.Au.delete(0),Vh(t)}(n)}))}(ap(e=Uf(e,ip)))}function gp(e){return function(e){return e.asyncQueue.enqueue((async()=&gt;{const t=await xf(e),n=await Df(e);return t.setNetworkEnabled(!1),async function(e){const t=zr(e);t.Au.add(0),await Bh(t),t.Pu.set("Offline")}(n)}))}(ap(e=Uf(e,ip)))}function mp(e){return(0,i.wN)(e.app,"firestore",e._databaseId.database),e._delete()}function yp(e,t){const n=ap(e=Uf(e,ip)),r=new np;return function(e,t,n,r){const i=function(e,t){let n;return n="string"==typeof e?dc().encode(e):e,function(e,t){return new _f(e,t)}(function(e,t){if(e instanceof Uint8Array)return mf(e,t);if(e instanceof ArrayBuffer)return mf(new Uint8Array(e),t);if(e instanceof ReadableStream)return e.getReader();throw new Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}(n),t)}(n,Ah(t));e.asyncQueue.enqueueAndForget((async()=&gt;{!function(e,t,n){const r=zr(e);(async function(e,t,n){try{const r=await t.getMetadata();if(await function(e,t){const n=zr(e),r=Fc(t.createTime);return n.persistence.runTransaction("hasNewerBundle","readonly",(e=&gt;n.Ls.getBundleMetadata(e,t.id))).then((e=&gt;!!e&amp;&amp;e.createTime.compareTo(r)&gt;=0))}(e.localStore,r))return await t.close(),n._completeWith(function(e){return{taskState:"Success",documentsLoaded:e.totalDocuments,bytesLoaded:e.totalBytes,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}(r)),Promise.resolve(new Set);n._updateProgress(Dd(r));const i=new kd(r,e.localStore,t.serializer);let s=await t.Pc();for(;s;){const e=await i.ju(s);e&amp;&amp;n._updateProgress(e),s=await t.Pc()}const o=await i.complete();return await Xd(e,o.Hu,void 0),await function(e,t){const n=zr(e);return n.persistence.runTransaction("Save bundle","readwrite",(e=&gt;n.Ls.saveBundleMetadata(e,t)))}(e.localStore,r),n._completeWith(o.progress),Promise.resolve(o.Wu)}catch(e){return qr("SyncEngine",`Loading bundle failed with ${e}`),n._failWith(e),Promise.resolve(new Set)}})(r,t,n).then((e=&gt;{r.sharedClientState.notifyBundleLoaded(e)}))}(await Nf(e),i,r)}))}(n,e._databaseId,t,r),r}function _p(e,t){return function(e,t){return e.asyncQueue.enqueue((async()=&gt;function(e,t){const n=zr(e);return n.persistence.runTransaction("Get named query","readonly",(e=&gt;n.Ls.getNamedQuery(e,t)))}(await kf(e),t)))}(ap(e=Uf(e,ip)),t).then((t=&gt;t?new Wf(e,null,t.query):null))}function vp(e){if(e._initialized||e._terminated)throw new Kr($r.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}class wp{constructor(e="count",t){this._aggregateType=e,this._internalFieldPath=t,this.type="AggregateField"}}class bp{constructor(e,t,n){this._userDataWriter=t,this._data=n,this.type="AggregateQuerySnapshot",this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}}class Ip{constructor(e){this._byteString=e}static fromBase64String(e){try{return new Ip(As.fromBase64String(e))}catch(e){throw new Kr($r.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new Ip(As.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}}class Cp{constructor(...e){for(let t=0;t&lt;e.length;++t)if(0===e[t].length)throw new Kr($r.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new di(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}function Tp(){return new Cp("__name__")}class Ep{constructor(e){this._methodName=e}}class Sp{constructor(e,t){if(!isFinite(e)||e&lt;-90||e&gt;90)throw new Kr($r.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t&lt;-180||t&gt;180)throw new Kr($r.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&amp;&amp;this._long===e._long}toJSON(){return{latitude:this._lat,longitude:this._long}}_compareTo(e){return ii(this._lat,e._lat)||ii(this._long,e._long)}}const xp=/^__.*__$/;class kp{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return null!==this.fieldMask?new Qa(e,this.data,this.fieldMask,t,this.fieldTransforms):new Ha(e,this.data,t,this.fieldTransforms)}}class Dp{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Qa(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function Np(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw Br()}}class Ap{constructor(e,t,n,r,i,s){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,void 0===i&amp;&amp;this.oa(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get ua(){return this.settings.ua}ca(e){return new Ap(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}aa(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.ca({path:n,ha:!1});return r.la(e),r}fa(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.ca({path:n,ha:!1});return r.oa(),r}da(e){return this.ca({path:void 0,ha:!0})}_a(e){return Xp(e,this.settings.methodName,this.settings.wa||!1,this.path,this.settings.ma)}contains(e){return void 0!==this.fieldMask.find((t=&gt;e.isPrefixOf(t)))||void 0!==this.fieldTransforms.find((t=&gt;e.isPrefixOf(t.field)))}oa(){if(this.path)for(let e=0;e&lt;this.path.length;e++)this.la(this.path.get(e))}la(e){if(0===e.length)throw this._a("Document fields must not be empty");if(Np(this.ua)&amp;&amp;xp.test(e))throw this._a('Document fields cannot begin and end with "__"')}}class Pp{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Ah(e)}ga(e,t,n,r=!1){return new Ap({ua:e,methodName:t,ma:n,path:di.emptyPath(),ha:!1,wa:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function Rp(e){const t=e._freezeSettings(),n=Ah(e._databaseId);return new Pp(e._databaseId,!!t.ignoreUndefinedProperties,n)}function Mp(e,t,n,r,i,s={}){const o=e.ga(s.merge||s.mergeFields?2:0,t,n,i);Wp("Data must be an object, but it was:",o,r);const a=Kp(r,o);let c,u;if(s.merge)c=new ks(o.fieldMask),u=o.fieldTransforms;else if(s.mergeFields){const e=[];for(const r of s.mergeFields){const i=Hp(t,r,n);if(!o.contains(i))throw new Kr($r.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);Jp(e,i)||e.push(i)}c=new ks(e),u=o.fieldTransforms.filter((e=&gt;c.covers(e.field)))}else c=null,u=o.fieldTransforms;return new kp(new uo(a),c,u)}class Fp extends Ep{_toFieldTransform(e){if(2!==e.ua)throw 1===e.ua?e._a(`${this._methodName}() can only appear at the top level of your update data`):e._a(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof Fp}}function Op(e,t,n){return new Ap({ua:3,ma:t.settings.ma,methodName:e._methodName,ha:n},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class Lp extends Ep{_toFieldTransform(e){return new qa(e.path,new Na)}isEqual(e){return e instanceof Lp}}class qp extends Ep{constructor(e,t){super(e),this.ya=t}_toFieldTransform(e){const t=Op(this,e,!0),n=this.ya.map((e=&gt;$p(e,t))),r=new Aa(n);return new qa(e.path,r)}isEqual(e){return this===e}}class Vp extends Ep{constructor(e,t){super(e),this.ya=t}_toFieldTransform(e){const t=Op(this,e,!0),n=this.ya.map((e=&gt;$p(e,t))),r=new Ra(n);return new qa(e.path,r)}isEqual(e){return this===e}}class Bp extends Ep{constructor(e,t){super(e),this.pa=t}_toFieldTransform(e){const t=new Fa(e.serializer,Ea(e.serializer,this.pa));return new qa(e.path,t)}isEqual(e){return this===e}}function Up(e,t,n,r){const i=e.ga(1,t,n);Wp("Data must be an object, but it was:",i,r);const s=[],o=uo.empty();ws(r,((e,r)=&gt;{const c=Yp(t,e,n);r=(0,a.m9)(r);const u=i.fa(c);if(r instanceof Fp)s.push(c);else{const e=$p(r,u);null!=e&amp;&amp;(s.push(c),o.set(c,e))}}));const c=new ks(s);return new Dp(o,c,i.fieldTransforms)}function jp(e,t,n,r,i,s){const o=e.ga(1,t,n),c=[Hp(t,r,n)],u=[i];if(s.length%2!=0)throw new Kr($r.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e&lt;s.length;e+=2)c.push(Hp(t,s[e])),u.push(s[e+1]);const l=[],h=uo.empty();for(let e=c.length-1;e&gt;=0;--e)if(!Jp(l,c[e])){const t=c[e];let n=u[e];n=(0,a.m9)(n);const r=o.fa(t);if(n instanceof Fp)l.push(t);else{const e=$p(n,r);null!=e&amp;&amp;(l.push(t),h.set(t,e))}}const d=new ks(l);return new Dp(h,d,o.fieldTransforms)}function zp(e,t,n,r=!1){return $p(n,e.ga(r?4:3,t))}function $p(e,t){if(Gp(e=(0,a.m9)(e)))return Wp("Unsupported field value:",t,e),Kp(e,t);if(e instanceof Ep)return function(e,t){if(!Np(t.ua))throw t._a(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t._a(`${e._methodName}() is not currently supported inside arrays`);const n=e._toFieldTransform(t);n&amp;&amp;t.fieldTransforms.push(n)}(e,t),null;if(void 0===e&amp;&amp;t.ignoreUndefinedProperties)return null;if(t.path&amp;&amp;t.fieldMask.push(t.path),e instanceof Array){if(t.settings.ha&amp;&amp;4!==t.ua)throw t._a("Nested arrays are not supported");return function(e,t){const n=[];let r=0;for(const i of e){let e=$p(i,t.da(r));null==e&amp;&amp;(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if(null===(e=(0,a.m9)(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return Ea(t.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){const n=ai.fromDate(e);return{timestampValue:Pc(t.serializer,n)}}if(e instanceof ai){const n=new ai(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:Pc(t.serializer,n)}}if(e instanceof Sp)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Ip)return{bytesValue:Rc(t.serializer,e._byteString)};if(e instanceof Gf){const n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t._a(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Oc(e.firestore._databaseId||t.databaseId,e._key.path)}}throw t._a(`Unsupported field value: ${Bf(e)}`)}(e,t)}function Kp(e,t){const n={};return bs(e)?t.path&amp;&amp;t.path.length&gt;0&amp;&amp;t.fieldMask.push(t.path):ws(e,((e,r)=&gt;{const i=$p(r,t.aa(e));null!=i&amp;&amp;(n[e]=i)})),{mapValue:{fields:n}}}function Gp(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof ai||e instanceof Sp||e instanceof Ip||e instanceof Gf||e instanceof Ep)}function Wp(e,t,n){if(!Gp(n)||!function(e){return"object"==typeof e&amp;&amp;null!==e&amp;&amp;(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}(n)){const r=Bf(n);throw"an object"===r?t._a(e+" a custom object"):t._a(e+" "+r)}}function Hp(e,t,n){if((t=(0,a.m9)(t))instanceof Cp)return t._internalPath;if("string"==typeof t)return Yp(e,t);throw Xp("Field path arguments must be of type string or ",e,!1,void 0,n)}const Qp=new RegExp("[~\\*/\\[\\]]");function Yp(e,t,n){if(t.search(Qp)&gt;=0)throw Xp(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new Cp(...t.split("."))._internalPath}catch(r){throw Xp(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function Xp(e,t,n,r,i){const s=r&amp;&amp;!r.isEmpty(),o=void 0!==i;let a=`Function ${t}() called with invalid data`;n&amp;&amp;(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(s||o)&amp;&amp;(c+=" (found",s&amp;&amp;(c+=` in field ${r}`),o&amp;&amp;(c+=` in document ${i}`),c+=")"),new Kr($r.INVALID_ARGUMENT,a+e+c)}function Jp(e,t){return e.some((e=&gt;e.isEqual(t)))}class Zp{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 Gf(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const e=new eg(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){const t=this._document.data.field(tg("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class eg extends Zp{data(){return super.data()}}function tg(e,t){return"string"==typeof t?Yp(e,t):t instanceof Cp?t._internalPath:t._delegate._internalPath}function ng(e){if("L"===e.limitType&amp;&amp;0===e.explicitOrderBy.length)throw new Kr($r.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class rg{}class ig extends rg{}function sg(e,t,...n){let r=[];t instanceof rg&amp;&amp;r.push(t),r=r.concat(n),function(e){const t=e.filter((e=&gt;e instanceof cg)).length,n=e.filter((e=&gt;e instanceof og)).length;if(t&gt;1||t&gt;0&amp;&amp;n&gt;0)throw new Kr($r.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(const t of r)e=t._apply(e);return e}class og extends ig{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type="where"}static _create(e,t,n){return new og(e,t,n)}_apply(e){const t=this._parse(e);return Eg(e._query,t),new Wf(e.firestore,e.converter,ea(e._query,t))}_parse(e){const t=Rp(e.firestore),n=function(e,t,n,r,i,s,o){let a;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new Kr($r.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){Tg(o,s);const t=[];for(const n of o)t.push(Cg(r,e,n));a={arrayValue:{values:t}}}else a=Cg(r,e,o)}else"in"!==s&amp;&amp;"not-in"!==s&amp;&amp;"array-contains-any"!==s||Tg(o,s),a=zp(n,"where",o,"in"===s||"not-in"===s);return vo.create(i,s,a)}(e._query,0,t,e.firestore._databaseId,this._field,this._op,this._value);return n}}function ag(e,t,n){const r=t,i=tg("where",e);return og._create(i,r,n)}class cg extends rg{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new cg(e,t)}_parse(e){const t=this._queryConstraints.map((t=&gt;t._parse(e))).filter((e=&gt;e.getFilters().length&gt;0));return 1===t.length?t[0]:wo.create(t,this._getOperator())}_apply(e){const t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){let n=e;const r=t.getFlattenedFilters();for(const e of r)Eg(n,e),n=ea(n,e)}(e._query,t),new Wf(e.firestore,e.converter,ea(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}function ug(...e){return e.forEach((e=&gt;xg("or",e))),cg._create("or",e)}function lg(...e){return e.forEach((e=&gt;xg("and",e))),cg._create("and",e)}class hg extends ig{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new hg(e,t)}_apply(e){const t=function(e,t,n){if(null!==e.startAt)throw new Kr($r.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new Kr($r.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");const r=new mo(t,n);return function(e,t){if(null===Qo(e)){const n=Yo(e);null!==n&amp;&amp;Sg(0,n,t.field)}}(e,r),r}(e._query,this._field,this._direction);return new Wf(e.firestore,e.converter,function(e,t){const n=e.explicitOrderBy.concat([t]);return new Ko(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(e._query,t))}}function dg(e,t="asc"){const n=t,r=tg("orderBy",e);return hg._create(r,n)}class fg extends ig{constructor(e,t,n){super(),this.type=e,this._limit=t,this._limitType=n}static _create(e,t,n){return new fg(e,t,n)}_apply(e){return new Wf(e.firestore,e.converter,ta(e._query,this._limit,this._limitType))}}function pg(e){return jf("limit",e),fg._create("limit",e,"F")}function gg(e){return jf("limitToLast",e),fg._create("limitToLast",e,"L")}class mg extends ig{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new mg(e,t,n)}_apply(e){const t=Ig(e,this.type,this._docOrFields,this._inclusive);return new Wf(e.firestore,e.converter,function(e,t){return new Ko(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)}(e._query,t))}}function yg(...e){return mg._create("startAt",e,!0)}function _g(...e){return mg._create("startAfter",e,!1)}class vg extends ig{constructor(e,t,n){super(),this.type=e,this._docOrFields=t,this._inclusive=n}static _create(e,t,n){return new vg(e,t,n)}_apply(e){const t=Ig(e,this.type,this._docOrFields,this._inclusive);return new Wf(e.firestore,e.converter,function(e,t){return new Ko(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,t)}(e._query,t))}}function wg(...e){return vg._create("endBefore",e,!1)}function bg(...e){return vg._create("endAt",e,!0)}function Ig(e,t,n,r){if(n[0]=(0,a.m9)(n[0]),n[0]instanceof Zp)return function(e,t,n,r,i){if(!r)throw new Kr($r.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${n}().`);const s=[];for(const n of Jo(e))if(n.field.isKeyField())s.push(Xs(t,r.key));else{const e=r.data.field(n.field);if(Os(e))throw new Kr($r.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+n.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===e){const e=n.field.canonicalString();throw new Kr($r.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${e}' (used as the orderBy) does not exist.`)}s.push(e)}return new fo(s,i)}(e._query,e.firestore._databaseId,t,n[0]._document,r);{const i=Rp(e.firestore);return function(e,t,n,r,i,s){const o=e.explicitOrderBy;if(i.length&gt;o.length)throw new Kr($r.INVALID_ARGUMENT,`Too many arguments provided to ${r}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const a=[];for(let s=0;s&lt;i.length;s++){const c=i[s];if(o[s].field.isKeyField()){if("string"!=typeof c)throw new Kr($r.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${r}(), but got a ${typeof c}`);if(!Xo(e)&amp;&amp;-1!==c.indexOf("/"))throw new Kr($r.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${r}() must be a plain document ID, but '${c}' contains a slash.`);const n=e.path.child(li.fromString(c));if(!fi.isDocumentKey(n))throw new Kr($r.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${r}() must result in a valid document path, but '${n}' is not because it contains an odd number of segments.`);const i=new fi(n);a.push(Xs(t,i))}else{const e=zp(n,r,c);a.push(e)}}return new fo(a,s)}(e._query,e.firestore._databaseId,i,t,n,r)}}function Cg(e,t,n){if("string"==typeof(n=(0,a.m9)(n))){if(""===n)throw new Kr($r.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!Xo(t)&amp;&amp;-1!==n.indexOf("/"))throw new Kr($r.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);const r=t.path.child(li.fromString(n));if(!fi.isDocumentKey(r))throw new Kr($r.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 Xs(e,new fi(r))}if(n instanceof Gf)return Xs(e,n._key);throw new Kr($r.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Bf(n)}.`)}function Tg(e,t){if(!Array.isArray(e)||0===e.length)throw new Kr($r.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function Eg(e,t){if(t.isInequality()){const n=Yo(e),r=t.field;if(null!==n&amp;&amp;!n.isEqual(r))throw new Kr($r.INVALID_ARGUMENT,`Invalid query. All where filters with an inequality (&lt;, &lt;=, !=, not-in, &gt;, or &gt;=) must be on the same field. But you have inequality filters on '${n.toString()}' and '${r.toString()}'`);const i=Qo(e);null!==i&amp;&amp;Sg(0,r,i)}const n=function(e,t){for(const n of e)for(const e of n.getFlattenedFilters())if(t.indexOf(e.op)&gt;=0)return e.op;return null}(e.filters,function(e){switch(e){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(t.op));if(null!==n)throw n===t.op?new Kr($r.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new Kr($r.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}function Sg(e,t,n){if(!n.isEqual(t))throw new Kr($r.INVALID_ARGUMENT,`Invalid query. You have a where filter with an inequality (&lt;, &lt;=, !=, not-in, &gt;, or &gt;=) on field '${t.toString()}' and so you must also use '${t.toString()}' as your first argument to orderBy(), but your first orderBy() is on field '${n.toString()}' instead.`)}function xg(e,t){if(!(t instanceof og||t instanceof cg))throw new Kr($r.INVALID_ARGUMENT,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}class kg{convertValue(e,t="none"){switch(zs(e)){case 0:return null;case 1:return e.booleanValue;case 2:return Ms(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(Fs(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 10:return this.convertObject(e.mapValue,t);default:throw Br()}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const n={};return ws(e,((e,r)=&gt;{n[e]=this.convertValue(r,t)})),n}convertGeoPoint(e){return new Sp(Ms(e.latitude),Ms(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=&gt;this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const n=Ls(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(qs(e));default:return null}}convertTimestamp(e){const t=Rs(e);return new ai(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=li.fromString(e);Ur(su(n));const r=new Bs(n.get(1),n.get(3)),i=new fi(n.popFirst(5));return r.isEqual(t)||Lr(`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}}function Dg(e,t,n){let r;return r=e?n&amp;&amp;(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,r}class Ng extends kg{constructor(e){super(),this.firestore=e}convertBytes(e){return new Ip(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Gf(this.firestore,null,t)}}function Ag(e){return new wp("sum",Hp("sum",e))}function Pg(e){return new wp("avg",Hp("average",e))}function Rg(){return new wp("count")}function Mg(e,t){var n,r;return e instanceof wp&amp;&amp;t instanceof wp&amp;&amp;e._aggregateType===t._aggregateType&amp;&amp;(null===(n=e._internalFieldPath)||void 0===n?void 0:n.canonicalString())===(null===(r=t._internalFieldPath)||void 0===r?void 0:r.canonicalString())}function Fg(e,t){return Zf(e.query,t.query)&amp;&amp;(0,a.vZ)(e.data(),t.data())}class Og{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&amp;&amp;this.fromCache===e.fromCache}}class Lg extends Zp{constructor(e,t,n,r,i,s){super(e,t,n,r,s),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new qg(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const n=this._document.data.field(tg("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}}class qg extends Lg{data(e={}){return super.data(e)}}class Vg{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new Og(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){const e=[];return this.forEach((t=&gt;e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(e,t){this._snapshot.docs.forEach((n=&gt;{e.call(t,new qg(this._firestore,this._userDataWriter,n.key,n,new Og(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&amp;&amp;this._snapshot.excludesMetadataChanges)throw new Kr($r.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&amp;&amp;this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map((n=&gt;{const r=new qg(e._firestore,e._userDataWriter,n.doc.key,n.doc,new Og(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=&gt;t||3!==e.type)).map((t=&gt;{const r=new qg(e._firestore,e._userDataWriter,t.doc.key,t.doc,new Og(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter);let i=-1,s=-1;return 0!==t.type&amp;&amp;(i=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),1!==t.type&amp;&amp;(n=n.add(t.doc),s=n.indexOf(t.doc.key)),{type:Bg(t.type),doc:r,oldIndex:i,newIndex:s}}))}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}}function Bg(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return Br()}}function Ug(e,t){return e instanceof Lg&amp;&amp;t instanceof Lg?e._firestore===t._firestore&amp;&amp;e._key.isEqual(t._key)&amp;&amp;(null===e._document?null===t._document:e._document.isEqual(t._document))&amp;&amp;e._converter===t._converter:e instanceof Vg&amp;&amp;t instanceof Vg&amp;&amp;e._firestore===t._firestore&amp;&amp;Zf(e.query,t.query)&amp;&amp;e.metadata.isEqual(t.metadata)&amp;&amp;e._snapshot.isEqual(t._snapshot)}function jg(e){e=Uf(e,Gf);const t=Uf(e.firestore,ip);return Rf(ap(t),e._key).then((n=&gt;nm(t,e,n)))}class zg extends kg{constructor(e){super(),this.firestore=e}convertBytes(e){return new Ip(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Gf(this.firestore,null,t)}}function $g(e){e=Uf(e,Gf);const t=Uf(e.firestore,ip),n=ap(t),r=new zg(t);return function(e,t){const n=new Gr;return e.asyncQueue.enqueueAndForget((async()=&gt;async function(e,t,n){try{const r=await function(e,t){const n=zr(e);return n.persistence.runTransaction("read document","readonly",(e=&gt;n.localDocuments.getDocument(e,t)))}(e,t);r.isFoundDocument()?n.resolve(r):r.isNoDocument()?n.resolve(null):n.reject(new Kr($r.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)"))}catch(e){const r=pd(e,`Failed to get document '${t} from cache`);n.reject(r)}}(await kf(e),t,n))),n.promise}(n,e._key).then((n=&gt;new Lg(t,r,e._key,n,new Og(null!==n&amp;&amp;n.hasLocalMutations,!0),e.converter)))}function Kg(e){e=Uf(e,Gf);const t=Uf(e.firestore,ip);return Rf(ap(t),e._key,{source:"server"}).then((n=&gt;nm(t,e,n)))}function Gg(e){e=Uf(e,Wf);const t=Uf(e.firestore,ip),n=ap(t),r=new zg(t);return ng(e._query),Mf(n,e._query).then((n=&gt;new Vg(t,r,e,n)))}function Wg(e){e=Uf(e,Wf);const t=Uf(e.firestore,ip),n=ap(t),r=new zg(t);return function(e,t){const n=new Gr;return e.asyncQueue.enqueueAndForget((async()=&gt;async function(e,t,n){try{const r=await oh(e,t,!0),i=new Pd(t,r.sr),s=i.nc(r.documents),o=i.applyChanges(s,!1);n.resolve(o.snapshot)}catch(e){const r=pd(e,`Failed to execute query '${t} against cache`);n.reject(r)}}(await kf(e),t,n))),n.promise}(n,e._query).then((n=&gt;new Vg(t,r,e,n)))}function Hg(e){e=Uf(e,Wf);const t=Uf(e.firestore,ip),n=ap(t),r=new zg(t);return Mf(n,e._query,{source:"server"}).then((n=&gt;new Vg(t,r,e,n)))}function Qg(e,t,n){e=Uf(e,Gf);const r=Uf(e.firestore,ip),i=Dg(e.converter,t,n);return tm(r,[Mp(Rp(r),"setDoc",e._key,i,null!==e.converter,n).toMutation(e._key,Ba.none())])}function Yg(e,t,n,...r){e=Uf(e,Gf);const i=Uf(e.firestore,ip),s=Rp(i);let o;return o="string"==typeof(t=(0,a.m9)(t))||t instanceof Cp?jp(s,"updateDoc",e._key,t,n,r):Up(s,"updateDoc",e._key,t),tm(i,[o.toMutation(e._key,Ba.exists(!0))])}function Xg(e){return tm(Uf(e.firestore,ip),[new Za(e._key,Ba.none())])}function Jg(e,t){const n=Uf(e.firestore,ip),r=Xf(e),i=Dg(e.converter,t);return tm(n,[Mp(Rp(e.firestore),"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,Ba.exists(!1))]).then((()=&gt;r))}function Zg(e,...t){var n,r,i;e=(0,a.m9)(e);let s={includeMetadataChanges:!1},o=0;"object"!=typeof t[o]||tp(t[o])||(s=t[o],o++);const c={includeMetadataChanges:s.includeMetadataChanges};if(tp(t[o])){const e=t[o];t[o]=null===(n=e.next)||void 0===n?void 0:n.bind(e),t[o+1]=null===(r=e.error)||void 0===r?void 0:r.bind(e),t[o+2]=null===(i=e.complete)||void 0===i?void 0:i.bind(e)}let u,l,h;if(e instanceof Gf)l=Uf(e.firestore,ip),h=Wo(e._key.path),u={next:n=&gt;{t[o]&amp;&amp;t[o](nm(l,e,n))},error:t[o+1],complete:t[o+2]};else{const n=Uf(e,Wf);l=Uf(n.firestore,ip),h=n._query;const r=new zg(l);u={next:e=&gt;{t[o]&amp;&amp;t[o](new Vg(l,r,n,e))},error:t[o+1],complete:t[o+2]},ng(e._query)}return function(e,t,n,r){const i=new yf(r),s=new Ed(t,i,n);return e.asyncQueue.enqueueAndForget((async()=&gt;wd(await Pf(e),s))),()=&gt;{i.Sc(),e.asyncQueue.enqueueAndForget((async()=&gt;bd(await Pf(e),s)))}}(ap(l),h,c,u)}function em(e,t){return function(e,t){const n=new yf(t);return e.asyncQueue.enqueueAndForget((async()=&gt;function(e,t){zr(e).Nu.add(t),t.next()}(await Pf(e),n))),()=&gt;{n.Sc(),e.asyncQueue.enqueueAndForget((async()=&gt;function(e,t){zr(e).Nu.delete(t)}(await Pf(e),n)))}}(ap(e=Uf(e,ip)),tp(t)?t:{next:t})}function tm(e,t){return function(e,t){const n=new Gr;return e.asyncQueue.enqueueAndForget((async()=&gt;async function(e,t,n){const r=lf(e);try{const e=await function(e,t){const n=zr(e),r=ai.now(),i=t.reduce(((e,t)=&gt;e.add(t.key)),wa());let s,o;return n.persistence.runTransaction("Locally write mutations","readwrite",(e=&gt;{let a=ha(),c=wa();return n.Xi.getEntries(e,i).next((e=&gt;{a=e,a.forEach(((e,t)=&gt;{t.isValidDocument()||(c=c.add(e))}))})).next((()=&gt;n.localDocuments.getOverlayedDocuments(e,a))).next((i=&gt;{s=i;const o=[];for(const e of t){const t=Ga(e,s.get(e.key).overlayedDocument);null!=t&amp;&amp;o.push(new Qa(e.key,t,lo(t.value.mapValue),Ba.exists(!0)))}return n.mutationQueue.addMutationBatch(e,r,o,t)})).next((t=&gt;{o=t;const r=t.applyToLocalDocumentSet(s,c);return n.documentOverlayCache.saveOverlays(e,t.batchId,r)}))})).then((()=&gt;({batchId:o.batchId,changes:pa(s)})))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.Ic[e.currentUser.toKey()];r||(r=new Is(ii)),r=r.insert(t,n),e.Ic[e.currentUser.toKey()]=r}(r,e.batchId,n),await Xd(r,e.changes),await ed(r.remoteStore)}catch(e){const t=pd(e,"Failed to persist write");n.reject(t)}}(await Nf(e),t,n))),n.promise}(ap(e),t)}function nm(e,t,n){const r=n.docs.get(t._key),i=new zg(e);return new Lg(e,i,t._key,r,new Og(n.hasPendingWrites,n.fromCache),t.converter)}function rm(e){return im(e,{count:Rg()})}function im(e,t){const n=Uf(e.firestore,ip),r=ap(n),i=function(e,t){const n=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&amp;&amp;n.push(t(e[r],r));return n}(t,((e,t)=&gt;new ic(t,e._aggregateType,e._internalFieldPath)));return function(e,t,n){const r=new Gr;return e.asyncQueue.enqueueAndForget((async()=&gt;{try{const i=await Af(e);r.resolve(async function(e,t,n){var r;const i=zr(e),{request:s,fu:o}=function(e,t,n){const r=Qc(e,t),i={},s=[];let o=0;return n.forEach((e=&gt;{const t="aggregate_"+o++;i[t]=e.alias,"count"===e.gt?s.push({alias:t,count:{}}):"avg"===e.gt?s.push({alias:t,avg:{field:tu(e.fieldPath)}}):"sum"===e.gt&amp;&amp;s.push({alias:t,sum:{field:tu(e.fieldPath)}})})),{request:{structuredAggregationQuery:{aggregations:s,structuredQuery:r.structuredQuery},parent:r.parent},fu:i}}(i.serializer,Zo(t),n),a=s.parent;i.connection.yo||delete s.parent;const c=(await i.Ao("RunAggregationQuery",a,s,1)).filter((e=&gt;!!e.result));Ur(1===c.length);const u=null===(r=c[0].result)||void 0===r?void 0:r.aggregateFields;return Object.keys(u).reduce(((e,t)=&gt;(e[o[t]]=u[t],e)),{})}(i,t,n))}catch(e){r.reject(e)}})),r.promise}(r,e._query,i).then((t=&gt;function(e,t,n){const r=new zg(e);return new bp(t,r,n)}(n,e,t)))}class sm{constructor(e){this.kind="memory",this._onlineComponentProvider=new gf,(null==e?void 0:e.garbageCollector)?this._offlineComponentProvider=e.garbageCollector._offlineComponentProvider:this._offlineComponentProvider=new hf}toJSON(){return{kind:this.kind}}}class om{constructor(e){let t;this.kind="persistent",(null==e?void 0:e.tabManager)?(e.tabManager._initialize(e),t=e.tabManager):(t=gm(void 0),t._initialize(e)),this._onlineComponentProvider=t._onlineComponentProvider,this._offlineComponentProvider=t._offlineComponentProvider}toJSON(){return{kind:this.kind}}}class am{constructor(){this.kind="memoryEager",this._offlineComponentProvider=new hf}toJSON(){return{kind:this.kind}}}class cm{constructor(e){this.kind="memoryLru",this._offlineComponentProvider=new df(e)}toJSON(){return{kind:this.kind}}}function um(){return new am}function lm(e){return new cm(null==e?void 0:e.cacheSizeBytes)}function hm(e){return new sm(e)}function dm(e){return new om(e)}class fm{constructor(e){this.forceOwnership=e,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=new gf,this._offlineComponentProvider=new ff(this._onlineComponentProvider,null==e?void 0:e.cacheSizeBytes,this.forceOwnership)}}class pm{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=new gf,this._offlineComponentProvider=new pf(this._onlineComponentProvider,null==e?void 0:e.cacheSizeBytes)}}function gm(e){return new fm(null==e?void 0:e.forceOwnership)}function mm(){return new pm}const ym={maxAttempts:5};class _m{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=Rp(e)}set(e,t,n){this._verifyNotCommitted();const r=vm(e,this._firestore),i=Dg(r.converter,t,n),s=Mp(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(s.toMutation(r._key,Ba.none())),this}update(e,t,n,...r){this._verifyNotCommitted();const i=vm(e,this._firestore);let s;return s="string"==typeof(t=(0,a.m9)(t))||t instanceof Cp?jp(this._dataReader,"WriteBatch.update",i._key,t,n,r):Up(this._dataReader,"WriteBatch.update",i._key,t),this._mutations.push(s.toMutation(i._key,Ba.exists(!0))),this}delete(e){this._verifyNotCommitted();const t=vm(e,this._firestore);return this._mutations=this._mutations.concat(new Za(t._key,Ba.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length&gt;0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new Kr($r.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function vm(e,t){if((e=(0,a.m9)(e)).firestore!==t)throw new Kr($r.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class wm extends class{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=Rp(e)}get(e){const t=vm(e,this._firestore),n=new Ng(this._firestore);return this._transaction.lookup([t._key]).then((e=&gt;{if(!e||1!==e.length)return Br();const r=e[0];if(r.isFoundDocument())return new Zp(this._firestore,n,r.key,r,t.converter);if(r.isNoDocument())return new Zp(this._firestore,n,t._key,null,t.converter);throw Br()}))}set(e,t,n){const r=vm(e,this._firestore),i=Dg(r.converter,t,n),s=Mp(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,s),this}update(e,t,n,...r){const i=vm(e,this._firestore);let s;return s="string"==typeof(t=(0,a.m9)(t))||t instanceof Cp?jp(this._dataReader,"Transaction.update",i._key,t,n,r):Up(this._dataReader,"Transaction.update",i._key,t),this._transaction.update(i._key,s),this}delete(e){const t=vm(e,this._firestore);return this._transaction.delete(t._key),this}}{constructor(e,t){super(e,t),this._firestore=e}get(e){const t=vm(e,this._firestore),n=new zg(this._firestore);return super.get(e).then((e=&gt;new Lg(this._firestore,n,t._key,e._document,new Og(!1,!1),t.converter)))}}function bm(e,t,n){e=Uf(e,ip);const r=Object.assign(Object.assign({},ym),n);return function(e){if(e.maxAttempts&lt;1)throw new Kr($r.INVALID_ARGUMENT,"Max attempts must be at least 1")}(r),function(e,t,n){const r=new Gr;return e.asyncQueue.enqueueAndForget((async()=&gt;{const i=await Af(e);new wf(e.asyncQueue,i,n,t,r).run()})),r.promise}(ap(e),(n=&gt;t(new wm(e,n))),r)}function Im(){return new Fp("deleteField")}function Cm(){return new Lp("serverTimestamp")}function Tm(...e){return new qp("arrayUnion",e)}function Em(...e){return new Vp("arrayRemove",e)}function Sm(e){return new Bp("increment",e)}function xm(e){return ap(e=Uf(e,ip)),new _m(e,(t=&gt;tm(e,t)))}function km(e,t){var n;const r=ap(e=Uf(e,ip));if(!r._uninitializedComponentsProvider||"memory"===(null===(n=r._uninitializedComponentsProvider)||void 0===n?void 0:n._offlineKind))return qr("Cannot enable indexes when persistence is disabled"),Promise.resolve();const i=function(e){const t="string"==typeof e?function(e){try{return JSON.parse(e)}catch(e){throw new Kr($r.INVALID_ARGUMENT,"Failed to parse JSON: "+(null==e?void 0:e.message))}}(e):e,n=[];if(Array.isArray(t.indexes))for(const e of t.indexes){const t=Dm(e,"collectionGroup"),r=[];if(Array.isArray(e.fields))for(const t of e.fields){const e=Yp("setIndexConfiguration",Dm(t,"fieldPath"));"CONTAINS"===t.arrayConfig?r.push(new _i(e,2)):"ASCENDING"===t.order?r.push(new _i(e,0)):"DESCENDING"===t.order&amp;&amp;r.push(new _i(e,1))}n.push(new pi(pi.UNKNOWN_ID,t,r,wi.empty()))}return n}(t);return function(e,t){return e.asyncQueue.enqueue((async()=&gt;async function(e,t){const n=zr(e),r=n.indexManager,i=[];return n.persistence.runTransaction("Configure indexes","readwrite",(e=&gt;r.getFieldIndexes(e).next((n=&gt;function(e,t,n,r,i){e=[...e],t=[...t],e.sort(n),t.sort(n);const s=e.length,o=t.length;let a=0,c=0;for(;a&lt;o&amp;&amp;c&lt;s;){const s=n(e[c],t[a]);s&lt;0?i(e[c++]):s&gt;0?r(t[a++]):(a++,c++)}for(;a&lt;o;)r(t[a++]);for(;c&lt;s;)i(e[c++])}(n,t,yi,(t=&gt;{i.push(r.addFieldIndex(e,t))}),(t=&gt;{i.push(r.deleteFieldIndex(e,t))})))).next((()=&gt;ki.waitFor(i)))))}(await kf(e),t)))}(r,i)}function Dm(e,t){if("string"!=typeof e[t])throw new Kr($r.INVALID_ARGUMENT,"Missing string value for: "+t);return e[t]}!function(e,t=!0){!function(e){Pr=e}(i.Jn),(0,i.Xd)(new s.wA("firestore",((e,{instanceIdentifier:n,options:r})=&gt;{const i=e.getProvider("app").getImmediate(),s=new ip(new Yr(e.getProvider("auth-internal")),new ei(e.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new Kr($r.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new Bs(e.options.projectId,t)}(i,n),i);return r=Object.assign({useFetchStreams:t},r),s._setSettings(r),s}),"PUBLIC").setMultipleInstances(!0)),(0,i.KN)(Nr,"3.11.0",e),(0,i.KN)(Nr,"3.11.0","esm2017")}()},112:(e,t,n)=&gt;{"use strict";n.r(t),n.d(t,{activate:()=&gt;ve,ensureInitialized:()=&gt;we,fetchAndActivate:()=&gt;Le,fetchConfig:()=&gt;be,getAll:()=&gt;Ie,getBoolean:()=&gt;Ce,getNumber:()=&gt;Te,getRemoteConfig:()=&gt;_e,getString:()=&gt;Ee,getValue:()=&gt;Se,isSupported:()=&gt;qe,setLogLevel:()=&gt;xe});var r=n(657),i=n(444),s=n(463),o=n(333);const a=(e,t)=&gt;t.some((t=&gt;e instanceof t));let c,u;const l=new WeakMap,h=new WeakMap,d=new WeakMap,f=new WeakMap,p=new WeakMap;let g={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return h.get(e);if("objectStoreNames"===t)return e.objectStoreNames||d.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return y(e[t])},set:(e,t,n)=&gt;(e[t]=n,!0),has:(e,t)=&gt;e instanceof IDBTransaction&amp;&amp;("done"===t||"store"===t)||t in e};function m(e){return"function"==typeof e?(t=e)!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(u||(u=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(t)?function(...e){return t.apply(_(this),e),y(l.get(this))}:function(...e){return y(t.apply(_(this),e))}:function(e,...n){const r=t.call(_(this),e,...n);return d.set(r,e.sort?e.sort():[e]),y(r)}:(e instanceof IDBTransaction&amp;&amp;function(e){if(h.has(e))return;const t=new Promise(((t,n)=&gt;{const r=()=&gt;{e.removeEventListener("complete",i),e.removeEventListener("error",s),e.removeEventListener("abort",s)},i=()=&gt;{t(),r()},s=()=&gt;{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",s),e.addEventListener("abort",s)}));h.set(e,t)}(e),a(e,c||(c=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,g):e);var t}function y(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=&gt;{const r=()=&gt;{e.removeEventListener("success",i),e.removeEventListener("error",s)},i=()=&gt;{t(y(e.result)),r()},s=()=&gt;{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",s)}));return t.then((t=&gt;{t instanceof IDBCursor&amp;&amp;l.set(t,e)})).catch((()=&gt;{})),p.set(t,e),t}(e);if(f.has(e))return f.get(e);const t=m(e);return t!==e&amp;&amp;(f.set(e,t),p.set(t,e)),t}const _=e=&gt;p.get(e),v=["get","getKey","getAll","getAllKeys","count"],w=["put","add","delete","clear"],b=new Map;function I(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(b.get(t))return b.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=w.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&amp;&amp;!v.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,i?"readwrite":"readonly");let o=s.store;return r&amp;&amp;(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&amp;&amp;s.done]))[0]};return b.set(t,s),s}var C;C=g,g={...C,get:(e,t,n)=&gt;I(e,t)||C.get(e,t,n),has:(e,t)=&gt;!!I(e,t)||C.has(e,t)};const T="@firebase/installations",E="0.6.4",S=1e4,x=`w:${E}`,k="FIS_v2",D="https://firebaseinstallations.googleapis.com/v1",N=36e5,A=new i.LL("installations","Installations",{"missing-app-config-values":'Missing App configuration value: "{$valueName}"',"not-registered":"Firebase Installation is not registered.","installation-not-found":"Firebase Installation not found.","request-failed":'{$requestName} request failed with error "{$serverCode} {$serverStatus}: {$serverMessage}"',"app-offline":"Could not process request. Application offline.","delete-pending-registration":"Can't delete installation while there is a pending registration request."});function P(e){return e instanceof i.ZR&amp;&amp;e.code.includes("request-failed")}function R({projectId:e}){return`${D}/projects/${e}/installations`}function M(e){return{token:e.token,requestStatus:2,expiresIn:(t=e.expiresIn,Number(t.replace("s","000"))),creationTime:Date.now()};var t}async function F(e,t){const n=(await t.json()).error;return A.create("request-failed",{requestName:e,serverCode:n.code,serverMessage:n.message,serverStatus:n.status})}function O({apiKey:e}){return new Headers({"Content-Type":"application/json",Accept:"application/json","x-goog-api-key":e})}async function L(e){const t=await e();return t.status&gt;=500&amp;&amp;t.status&lt;600?e():t}function q(e){return new Promise((t=&gt;{setTimeout(t,e)}))}const V=/^[cdef][\w-]{21}$/,B="";function U(){try{const e=new Uint8Array(17);(self.crypto||self.msCrypto).getRandomValues(e),e[0]=112+e[0]%16;const t=function(e){var t;return(t=e,btoa(String.fromCharCode(...t)).replace(/\+/g,"-").replace(/\//g,"_")).substr(0,22)}(e);return V.test(t)?t:B}catch(e){return B}}function j(e){return`${e.appName}!${e.appId}`}const z=new Map;function $(e,t){const n=j(e);K(n,t),function(e,t){const n=(!G&amp;&amp;"BroadcastChannel"in self&amp;&amp;(G=new BroadcastChannel("[Firebase] FID Change"),G.onmessage=e=&gt;{K(e.data.key,e.data.fid)}),G);n&amp;&amp;n.postMessage({key:e,fid:t}),0===z.size&amp;&amp;G&amp;&amp;(G.close(),G=null)}(n,t)}function K(e,t){const n=z.get(e);if(n)for(const e of n)e(t)}let G=null;const W="firebase-installations-database",H=1,Q="firebase-installations-store";let Y=null;function X(){return Y||(Y=function(e,t,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(e,t),a=y(o);return r&amp;&amp;o.addEventListener("upgradeneeded",(e=&gt;{r(y(o.result),e.oldVersion,e.newVersion,y(o.transaction))})),n&amp;&amp;o.addEventListener("blocked",(()=&gt;n())),a.then((e=&gt;{s&amp;&amp;e.addEventListener("close",(()=&gt;s())),i&amp;&amp;e.addEventListener("versionchange",(()=&gt;i()))})).catch((()=&gt;{})),a}(W,H,{upgrade:(e,t)=&gt;{0===t&amp;&amp;e.createObjectStore(Q)}})),Y}async function J(e,t){const n=j(e),r=(await X()).transaction(Q,"readwrite"),i=r.objectStore(Q),s=await i.get(n);return await i.put(t,n),await r.done,s&amp;&amp;s.fid===t.fid||$(e,t.fid),t}async function Z(e){const t=j(e),n=(await X()).transaction(Q,"readwrite");await n.objectStore(Q).delete(t),await n.done}async function ee(e,t){const n=j(e),r=(await X()).transaction(Q,"readwrite"),i=r.objectStore(Q),s=await i.get(n),o=t(s);return void 0===o?await i.delete(n):await i.put(o,n),await r.done,!o||s&amp;&amp;s.fid===o.fid||$(e,o.fid),o}async function te(e){let t;const n=await ee(e.appConfig,(n=&gt;{const r=function(e){return ie(e||{fid:U(),registrationStatus:0})}(n),i=function(e,t){if(0===t.registrationStatus){if(!navigator.onLine)return{installationEntry:t,registrationPromise:Promise.reject(A.create("app-offline"))};const n={fid:t.fid,registrationStatus:1,registrationTime:Date.now()},r=async function(e,t){try{const n=await async function({appConfig:e,heartbeatServiceProvider:t},{fid:n}){const r=R(e),i=O(e),s=t.getImmediate({optional:!0});if(s){const e=await s.getHeartbeatsHeader();e&amp;&amp;i.append("x-firebase-client",e)}const o={fid:n,authVersion:k,appId:e.appId,sdkVersion:x},a={method:"POST",headers:i,body:JSON.stringify(o)},c=await L((()=&gt;fetch(r,a)));if(c.ok){const e=await c.json();return{fid:e.fid||n,registrationStatus:2,refreshToken:e.refreshToken,authToken:M(e.authToken)}}throw await F("Create Installation",c)}(e,t);return J(e.appConfig,n)}catch(n){throw P(n)&amp;&amp;409===n.customData.serverCode?await Z(e.appConfig):await J(e.appConfig,{fid:t.fid,registrationStatus:0}),n}}(e,n);return{installationEntry:n,registrationPromise:r}}return 1===t.registrationStatus?{installationEntry:t,registrationPromise:ne(e)}:{installationEntry:t}}(e,r);return t=i.registrationPromise,i.installationEntry}));return n.fid===B?{installationEntry:await t}:{installationEntry:n,registrationPromise:t}}async function ne(e){let t=await re(e.appConfig);for(;1===t.registrationStatus;)await q(100),t=await re(e.appConfig);if(0===t.registrationStatus){const{installationEntry:t,registrationPromise:n}=await te(e);return n||t}return t}function re(e){return ee(e,(e=&gt;{if(!e)throw A.create("installation-not-found");return ie(e)}))}function ie(e){return 1===(t=e).registrationStatus&amp;&amp;t.registrationTime+S&lt;Date.now()?{fid:e.fid,registrationStatus:0}:e;var t}async function se({appConfig:e,heartbeatServiceProvider:t},n){const r=function(e,{fid:t}){return`${R(e)}/${t}/authTokens:generate`}(e,n),i=function(e,{refreshToken:t}){const n=O(e);return n.append("Authorization",function(e){return`${k} ${e}`}(t)),n}(e,n),s=t.getImmediate({optional:!0});if(s){const e=await s.getHeartbeatsHeader();e&amp;&amp;i.append("x-firebase-client",e)}const o={installation:{sdkVersion:x,appId:e.appId}},a={method:"POST",headers:i,body:JSON.stringify(o)},c=await L((()=&gt;fetch(r,a)));if(c.ok)return M(await c.json());throw await F("Generate Auth Token",c)}async function oe(e,t=!1){let n;const r=await ee(e.appConfig,(r=&gt;{if(!ce(r))throw A.create("not-registered");const i=r.authToken;if(!t&amp;&amp;(2===(s=i).requestStatus&amp;&amp;!function(e){const t=Date.now();return t&lt;e.creationTime||e.creationTime+e.expiresIn&lt;t+N}(s)))return r;var s;if(1===i.requestStatus)return n=async function(e,t){let n=await ae(e.appConfig);for(;1===n.authToken.requestStatus;)await q(100),n=await ae(e.appConfig);const r=n.authToken;return 0===r.requestStatus?oe(e,t):r}(e,t),r;{if(!navigator.onLine)throw A.create("app-offline");const t=function(e){const t={requestStatus:1,requestTime:Date.now()};return Object.assign(Object.assign({},e),{authToken:t})}(r);return n=async function(e,t){try{const n=await se(e,t),r=Object.assign(Object.assign({},t),{authToken:n});return await J(e.appConfig,r),n}catch(n){if(!P(n)||401!==n.customData.serverCode&amp;&amp;404!==n.customData.serverCode){const n=Object.assign(Object.assign({},t),{authToken:{requestStatus:0}});await J(e.appConfig,n)}else await Z(e.appConfig);throw n}}(e,t),t}}));return n?await n:r.authToken}function ae(e){return ee(e,(e=&gt;{if(!ce(e))throw A.create("not-registered");return 1===(t=e.authToken).requestStatus&amp;&amp;t.requestTime+S&lt;Date.now()?Object.assign(Object.assign({},e),{authToken:{requestStatus:0}}):e;var t}))}function ce(e){return void 0!==e&amp;&amp;2===e.registrationStatus}function ue(e){return A.create("missing-app-config-values",{valueName:e})}const le="installations";(0,r.Xd)(new s.wA(le,(e=&gt;{const t=e.getProvider("app").getImmediate(),n=function(e){if(!e||!e.options)throw ue("App Configuration");if(!e.name)throw ue("App Name");const t=["projectId","apiKey","appId"];for(const n of t)if(!e.options[n])throw ue(n);return{appName:e.name,projectId:e.options.projectId,apiKey:e.options.apiKey,appId:e.options.appId}}(t);return{app:t,appConfig:n,heartbeatServiceProvider:(0,r.qX)(t,"heartbeat"),_delete:()=&gt;Promise.resolve()}}),"PUBLIC")),(0,r.Xd)(new s.wA("installations-internal",(e=&gt;{const t=e.getProvider("app").getImmediate(),n=(0,r.qX)(t,le).getImmediate();return{getId:()=&gt;async function(e){const t=e,{installationEntry:n,registrationPromise:r}=await te(t);return r?r.catch(console.error):oe(t).catch(console.error),n.fid}(n),getToken:e=&gt;async function(e,t=!1){const n=e;return await async function(e){const{registrationPromise:t}=await te(e);t&amp;&amp;await t}(n),(await oe(n,t)).token}(n,e)}}),"PRIVATE")),(0,r.KN)(T,E),(0,r.KN)(T,E,"esm2017");const he="@firebase/remote-config",de="0.4.4";class fe{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}abort(){this.listeners.forEach((e=&gt;e()))}}const pe="remote-config",ge=new i.LL("remoteconfig","Remote Config",{"registration-window":"Undefined window object. This SDK only supports usage in a browser environment.","registration-project-id":"Undefined project identifier. Check Firebase app initialization.","registration-api-key":"Undefined API key. Check Firebase app initialization.","registration-app-id":"Undefined app identifier. Check Firebase app initialization.","storage-open":"Error thrown when opening storage. Original error: {$originalErrorMessage}.","storage-get":"Error thrown when reading from storage. Original error: {$originalErrorMessage}.","storage-set":"Error thrown when writing to storage. Original error: {$originalErrorMessage}.","storage-delete":"Error thrown when deleting from storage. Original error: {$originalErrorMessage}.","fetch-client-network":"Fetch client failed to connect to a network. Check Internet connection. Original error: {$originalErrorMessage}.","fetch-timeout":'The config fetch request timed out.  Configure timeout using "fetchTimeoutMillis" SDK setting.',"fetch-throttle":'The config fetch request timed out while in an exponential backoff state. Configure timeout using "fetchTimeoutMillis" SDK setting. Unix timestamp in milliseconds when fetch request throttling ends: {$throttleEndTimeMillis}.',"fetch-client-parse":"Fetch client could not parse response. Original error: {$originalErrorMessage}.","fetch-status":"Fetch server returned an HTTP error status. HTTP status: {$httpStatus}.","indexed-db-unavailable":"Indexed DB is not supported by current browser"}),me=["1","true","t","yes","y","on"];class ye{constructor(e,t=""){this._source=e,this._value=t}asString(){return this._value}asBoolean(){return"static"!==this._source&amp;&amp;me.indexOf(this._value.toLowerCase())&gt;=0}asNumber(){if("static"===this._source)return 0;let e=Number(this._value);return isNaN(e)&amp;&amp;(e=0),e}getSource(){return this._source}}function _e(e=(0,r.Mq)()){return e=(0,i.m9)(e),(0,r.qX)(e,pe).getImmediate()}async function ve(e){const t=(0,i.m9)(e),[n,r]=await Promise.all([t._storage.getLastSuccessfulFetchResponse(),t._storage.getActiveConfigEtag()]);return!!(n&amp;&amp;n.config&amp;&amp;n.eTag&amp;&amp;n.eTag!==r)&amp;&amp;(await Promise.all([t._storageCache.setActiveConfig(n.config),t._storage.setActiveConfigEtag(n.eTag)]),!0)}function we(e){const t=(0,i.m9)(e);return t._initializePromise||(t._initializePromise=t._storageCache.loadFromStorage().then((()=&gt;{t._isInitializationComplete=!0}))),t._initializePromise}async function be(e){const t=(0,i.m9)(e),n=new fe;setTimeout((async()=&gt;{n.abort()}),t.settings.fetchTimeoutMillis);try{await t._client.fetch({cacheMaxAgeMillis:t.settings.minimumFetchIntervalMillis,signal:n}),await t._storageCache.setLastFetchStatus("success")}catch(e){const n=function(e,t){return e instanceof i.ZR&amp;&amp;-1!==e.code.indexOf("fetch-throttle")}(e)?"throttle":"failure";throw await t._storageCache.setLastFetchStatus(n),e}}function Ie(e){const t=(0,i.m9)(e);return function(e={},t={}){return Object.keys(Object.assign(Object.assign({},e),t))}(t._storageCache.getActiveConfig(),t.defaultConfig).reduce(((t,n)=&gt;(t[n]=Se(e,n),t)),{})}function Ce(e,t){return Se((0,i.m9)(e),t).asBoolean()}function Te(e,t){return Se((0,i.m9)(e),t).asNumber()}function Ee(e,t){return Se((0,i.m9)(e),t).asString()}function Se(e,t){const n=(0,i.m9)(e);n._isInitializationComplete||n._logger.debug(`A value was requested for key "${t}" before SDK initialization completed. Await on ensureInitialized if the intent was to get a previously activated value.`);const r=n._storageCache.getActiveConfig();return r&amp;&amp;void 0!==r[t]?new ye("remote",r[t]):n.defaultConfig&amp;&amp;void 0!==n.defaultConfig[t]?new ye("default",String(n.defaultConfig[t])):(n._logger.debug(`Returning static value for key "${t}". Define a default or remote value if this is unintentional.`),new ye("static"))}function xe(e,t){const n=(0,i.m9)(e);switch(t){case"debug":n._logger.logLevel=o.in.DEBUG;break;case"silent":n._logger.logLevel=o.in.SILENT;break;default:n._logger.logLevel=o.in.ERROR}}class ke{constructor(e,t,n,r){this.client=e,this.storage=t,this.storageCache=n,this.logger=r}isCachedDataFresh(e,t){if(!t)return this.logger.debug("Config fetch cache check. Cache unpopulated."),!1;const n=Date.now()-t,r=n&lt;=e;return this.logger.debug(`Config fetch cache check. Cache age millis: ${n}. Cache max age millis (minimumFetchIntervalMillis setting): ${e}. Is cache hit: ${r}.`),r}async fetch(e){const[t,n]=await Promise.all([this.storage.getLastSuccessfulFetchTimestampMillis(),this.storage.getLastSuccessfulFetchResponse()]);if(n&amp;&amp;this.isCachedDataFresh(e.cacheMaxAgeMillis,t))return n;e.eTag=n&amp;&amp;n.eTag;const r=await this.client.fetch(e),i=[this.storageCache.setLastSuccessfulFetchTimestampMillis(Date.now())];return 200===r.status&amp;&amp;i.push(this.storage.setLastSuccessfulFetchResponse(r)),await Promise.all(i),r}}function De(e=navigator){return e.languages&amp;&amp;e.languages[0]||e.language}class Ne{constructor(e,t,n,r,i,s){this.firebaseInstallations=e,this.sdkVersion=t,this.namespace=n,this.projectId=r,this.apiKey=i,this.appId=s}async fetch(e){const[t,n]=await Promise.all([this.firebaseInstallations.getId(),this.firebaseInstallations.getToken()]),r=`${window.FIREBASE_REMOTE_CONFIG_URL_BASE||"https://firebaseremoteconfig.googleapis.com"}/v1/projects/${this.projectId}/namespaces/${this.namespace}:fetch?key=${this.apiKey}`,i={"Content-Type":"application/json","Content-Encoding":"gzip","If-None-Match":e.eTag||"*"},s={sdk_version:this.sdkVersion,app_instance_id:t,app_instance_id_token:n,app_id:this.appId,language_code:De()},o={method:"POST",headers:i,body:JSON.stringify(s)},a=fetch(r,o),c=new Promise(((t,n)=&gt;{e.signal.addEventListener((()=&gt;{const e=new Error("The operation was aborted.");e.name="AbortError",n(e)}))}));let u;try{await Promise.race([a,c]),u=await a}catch(e){let t="fetch-client-network";throw"AbortError"===(null==e?void 0:e.name)&amp;&amp;(t="fetch-timeout"),ge.create(t,{originalErrorMessage:null==e?void 0:e.message})}let l=u.status;const h=u.headers.get("ETag")||void 0;let d,f;if(200===u.status){let e;try{e=await u.json()}catch(e){throw ge.create("fetch-client-parse",{originalErrorMessage:null==e?void 0:e.message})}d=e.entries,f=e.state}if("INSTANCE_STATE_UNSPECIFIED"===f?l=500:"NO_CHANGE"===f?l=304:"NO_TEMPLATE"!==f&amp;&amp;"EMPTY_CONFIG"!==f||(d={}),304!==l&amp;&amp;200!==l)throw ge.create("fetch-status",{httpStatus:l});return{status:l,eTag:h,config:d}}}class Ae{constructor(e,t){this.client=e,this.storage=t}async fetch(e){const t=await this.storage.getThrottleMetadata()||{backoffCount:0,throttleEndTimeMillis:Date.now()};return this.attemptFetch(e,t)}async attemptFetch(e,{throttleEndTimeMillis:t,backoffCount:n}){await function(e,t){return new Promise(((n,r)=&gt;{const i=Math.max(t-Date.now(),0),s=setTimeout(n,i);e.addEventListener((()=&gt;{clearTimeout(s),r(ge.create("fetch-throttle",{throttleEndTimeMillis:t}))}))}))}(e.signal,t);try{const t=await this.client.fetch(e);return await this.storage.deleteThrottleMetadata(),t}catch(t){if(!function(e){if(!(e instanceof i.ZR&amp;&amp;e.customData))return!1;const t=Number(e.customData.httpStatus);return 429===t||500===t||503===t||504===t}(t))throw t;const r={throttleEndTimeMillis:Date.now()+(0,i.$s)(n),backoffCount:n+1};return await this.storage.setThrottleMetadata(r),this.attemptFetch(e,r)}}}class Pe{constructor(e,t,n,r,i){this.app=e,this._client=t,this._storageCache=n,this._storage=r,this._logger=i,this._isInitializationComplete=!1,this.settings={fetchTimeoutMillis:6e4,minimumFetchIntervalMillis:432e5},this.defaultConfig={}}get fetchTimeMillis(){return this._storageCache.getLastSuccessfulFetchTimestampMillis()||-1}get lastFetchStatus(){return this._storageCache.getLastFetchStatus()||"no-fetch-yet"}}function Re(e,t){const n=e.target.error||void 0;return ge.create(t,{originalErrorMessage:n&amp;&amp;(null==n?void 0:n.message)})}const Me="app_namespace_store";class Fe{constructor(e,t,n,r=function(){return new Promise(((e,t)=&gt;{try{const n=indexedDB.open("firebase_remote_config",1);n.onerror=e=&gt;{t(Re(e,"storage-open"))},n.onsuccess=t=&gt;{e(t.target.result)},n.onupgradeneeded=e=&gt;{const t=e.target.result;0===e.oldVersion&amp;&amp;t.createObjectStore(Me,{keyPath:"compositeKey"})}}catch(e){t(ge.create("storage-open",{originalErrorMessage:null==e?void 0:e.message}))}}))}()){this.appId=e,this.appName=t,this.namespace=n,this.openDbPromise=r}getLastFetchStatus(){return this.get("last_fetch_status")}setLastFetchStatus(e){return this.set("last_fetch_status",e)}getLastSuccessfulFetchTimestampMillis(){return this.get("last_successful_fetch_timestamp_millis")}setLastSuccessfulFetchTimestampMillis(e){return this.set("last_successful_fetch_timestamp_millis",e)}getLastSuccessfulFetchResponse(){return this.get("last_successful_fetch_response")}setLastSuccessfulFetchResponse(e){return this.set("last_successful_fetch_response",e)}getActiveConfig(){return this.get("active_config")}setActiveConfig(e){return this.set("active_config",e)}getActiveConfigEtag(){return this.get("active_config_etag")}setActiveConfigEtag(e){return this.set("active_config_etag",e)}getThrottleMetadata(){return this.get("throttle_metadata")}setThrottleMetadata(e){return this.set("throttle_metadata",e)}deleteThrottleMetadata(){return this.delete("throttle_metadata")}async get(e){const t=await this.openDbPromise;return new Promise(((n,r)=&gt;{const i=t.transaction([Me],"readonly").objectStore(Me),s=this.createCompositeKey(e);try{const e=i.get(s);e.onerror=e=&gt;{r(Re(e,"storage-get"))},e.onsuccess=e=&gt;{const t=e.target.result;n(t?t.value:void 0)}}catch(e){r(ge.create("storage-get",{originalErrorMessage:null==e?void 0:e.message}))}}))}async set(e,t){const n=await this.openDbPromise;return new Promise(((r,i)=&gt;{const s=n.transaction([Me],"readwrite").objectStore(Me),o=this.createCompositeKey(e);try{const e=s.put({compositeKey:o,value:t});e.onerror=e=&gt;{i(Re(e,"storage-set"))},e.onsuccess=()=&gt;{r()}}catch(e){i(ge.create("storage-set",{originalErrorMessage:null==e?void 0:e.message}))}}))}async delete(e){const t=await this.openDbPromise;return new Promise(((n,r)=&gt;{const i=t.transaction([Me],"readwrite").objectStore(Me),s=this.createCompositeKey(e);try{const e=i.delete(s);e.onerror=e=&gt;{r(Re(e,"storage-delete"))},e.onsuccess=()=&gt;{n()}}catch(e){r(ge.create("storage-delete",{originalErrorMessage:null==e?void 0:e.message}))}}))}createCompositeKey(e){return[this.appId,this.appName,this.namespace,e].join()}}class Oe{constructor(e){this.storage=e}getLastFetchStatus(){return this.lastFetchStatus}getLastSuccessfulFetchTimestampMillis(){return this.lastSuccessfulFetchTimestampMillis}getActiveConfig(){return this.activeConfig}async loadFromStorage(){const e=this.storage.getLastFetchStatus(),t=this.storage.getLastSuccessfulFetchTimestampMillis(),n=this.storage.getActiveConfig(),r=await e;r&amp;&amp;(this.lastFetchStatus=r);const i=await t;i&amp;&amp;(this.lastSuccessfulFetchTimestampMillis=i);const s=await n;s&amp;&amp;(this.activeConfig=s)}setLastFetchStatus(e){return this.lastFetchStatus=e,this.storage.setLastFetchStatus(e)}setLastSuccessfulFetchTimestampMillis(e){return this.lastSuccessfulFetchTimestampMillis=e,this.storage.setLastSuccessfulFetchTimestampMillis(e)}setActiveConfig(e){return this.activeConfig=e,this.storage.setActiveConfig(e)}}async function Le(e){return e=(0,i.m9)(e),await be(e),ve(e)}async function qe(){if(!(0,i.hl)())return!1;try{return await(0,i.eu)()}catch(e){return!1}}(0,r.Xd)(new s.wA(pe,(function(e,{instanceIdentifier:t}){const n=e.getProvider("app").getImmediate(),s=e.getProvider("installations-internal").getImmediate();if("undefined"==typeof window)throw ge.create("registration-window");if(!(0,i.hl)())throw ge.create("indexed-db-unavailable");const{projectId:a,apiKey:c,appId:u}=n.options;if(!a)throw ge.create("registration-project-id");if(!c)throw ge.create("registration-api-key");if(!u)throw ge.create("registration-app-id");t=t||"firebase";const l=new Fe(u,n.name,t),h=new Oe(l),d=new o.Yd(he);d.logLevel=o.in.ERROR;const f=new Ne(s,r.Jn,t,a,c,u),p=new Ae(f,l),g=new ke(p,l,h,d),m=new Pe(n,g,h,l,d);return we(m),m}),"PUBLIC").setMultipleInstances(!0)),(0,r.KN)(he,de),(0,r.KN)(he,de,"esm2017")}},n={};function r(t){var i=n[t];if(void 0!==i)return i.exports;var s=n[t]={exports:{}};return e[t](s,s.exports,r),s.exports}r.y=t,r.d=(e,t)=&gt;{for(var n in t)r.o(t,n)&amp;&amp;!r.o(e,n)&amp;&amp;Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=&gt;Object.prototype.hasOwnProperty.call(e,t),r.r=e=&gt;{"undefined"!=typeof Symbol&amp;&amp;Symbol.toStringTag&amp;&amp;Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.p="";var i={};return(0,r(722).s)(1),(()=&gt;{"use strict";r.r(i),r.d(i,{database:()=&gt;e,firestore:()=&gt;t,getFirebaseAppInstance:()=&gt;l,getFirestoreDatabase:()=&gt;u,getRealtimeDatabase:()=&gt;a,getRemoteConfigInstance:()=&gt;c,remoteConfig:()=&gt;n});var e=r(679),t=r(953),n=r(112),s=r(977),o=function(e){var t=(0,s.C6)().find((function(t){return t.name===e}));return t||(t=(0,s.ZF)(function(e){return e.includes("RemoteConfig")?{apiKey:"AIzaSyAh31Pui9_kK5O68RzKql49PHtR8b7Md1A",authDomain:"nav-plataforma-web-prd.firebaseapp.com",projectId:"nav-plataforma-web-prd",storageBucket:"nav-plataforma-web-prd.appspot.com",messagingSenderId:"377744970344",appId:"1:377744970344:web:0a65d2bfb1217312d961dd"}:{apiKey:"AIzaSyC44IsV6BXhmxAgOZTQXAMtoh1DlGymrt8",authDomain:"nav-plataforma-shared-prd.firebaseapp.com",projectId:"nav-plataforma-shared-prd",storageBucket:"nav-plataforma-shared-prd.appspot.com",messagingSenderId:"806017201865",appId:"1:806017201865:web:4c4e642faa527de452ff18"}}(e),e)),t},a=function(t){return(0,e.getDatabase)(o(t))},c=function(e){return(0,n.getRemoteConfig)(o(e))},u=function(e){return(0,t.getFirestore)(o(e))},l=function(e){return o(e)}})(),i})())}}}));
//# sourceMappingURL=dasa-nsw-module-firebase.js.map</pre></body></html>