firebase
Version:
Firebase JavaScript library for web and Node.js
4 lines • 158 kB
JavaScript
import{_isFirebaseServerApp as e,getApp as i,_getProvider,_removeServiceInstance as s,_registerComponent as T,registerVersion as E,SDK_VERSION as V}from"https://www.gstatic.com/firebasejs/13.3.0/firebase-app.js";const stringToByteArray$1=function(e){const i=[];let s=0;for(let T=0;T<e.length;T++){let E=e.charCodeAt(T);E<128?i[s++]=E:E<2048?(i[s++]=E>>6|192,i[s++]=63&E|128):55296==(64512&E)&&T+1<e.length&&56320==(64512&e.charCodeAt(T+1))?(E=65536+((1023&E)<<10)+(1023&e.charCodeAt(++T)),i[s++]=E>>18|240,i[s++]=E>>12&63|128,i[s++]=E>>6&63|128,i[s++]=63&E|128):(i[s++]=E>>12|224,i[s++]=E>>6&63|128,i[s++]=63&E|128)}return i},R={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(e,i){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const s=i?this.byteToCharMapWebSafe_:this.byteToCharMap_,T=[];for(let i=0;i<e.length;i+=3){const E=e[i],V=i+1<e.length,R=V?e[i+1]:0,N=i+2<e.length,M=N?e[i+2]:0,Q=E>>2,L=(3&E)<<4|R>>4;let U=(15&R)<<2|M>>6,$=63&M;N||($=64,V||(U=64)),T.push(s[Q],s[L],s[U],s[$])}return T.join("")},encodeString(e,i){return this.HAS_NATIVE_SUPPORT&&!i?btoa(e):this.encodeByteArray(stringToByteArray$1(e),i)},decodeString(e,i){return this.HAS_NATIVE_SUPPORT&&!i?atob(e):function(e){const i=[];let s=0,T=0;for(;s<e.length;){const E=e[s++];if(E<128)i[T++]=String.fromCharCode(E);else if(E>191&&E<224){const V=e[s++];i[T++]=String.fromCharCode((31&E)<<6|63&V)}else if(E>239&&E<365){const V=((7&E)<<18|(63&e[s++])<<12|(63&e[s++])<<6|63&e[s++])-65536;i[T++]=String.fromCharCode(55296+(V>>10)),i[T++]=String.fromCharCode(56320+(1023&V))}else{const V=e[s++],R=e[s++];i[T++]=String.fromCharCode((15&E)<<12|(63&V)<<6|63&R)}}return i.join("")}(this.decodeStringToByteArray(e,i))},decodeStringToByteArray(e,i){this.init_();const s=i?this.charToByteMapWebSafe_:this.charToByteMap_,T=[];for(let i=0;i<e.length;){const E=s[e.charAt(i++)],V=i<e.length?s[e.charAt(i)]:0;++i;const R=i<e.length?s[e.charAt(i)]:64;++i;const N=i<e.length?s[e.charAt(i)]:64;if(++i,null==E||null==V||null==R||null==N)throw new DecodeBase64StringError;const M=E<<2|V>>4;if(T.push(M),64!==R){const e=V<<4&240|R>>2;if(T.push(e),64!==N){const e=R<<6&192|N;T.push(e)}}}return T},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class DecodeBase64StringError extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const base64urlEncodeWithoutPadding=function(e){return function(e){const i=stringToByteArray$1(e);return R.encodeByteArray(i,!0)}(e).replace(/\./g,"")};const getDefaultsFromGlobal=()=>function getGlobal(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("Unable to locate global object.")}().__FIREBASE_DEFAULTS__,getDefaultsFromCookie=()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const i=e&&function(e){try{return R.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null}(e[1]);return i&&JSON.parse(i)},getDefaults=()=>{try{return getDefaultsFromGlobal()||(()=>{if("undefined"==typeof process||void 0===process.env)return;const e=process.env.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||getDefaultsFromCookie()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},getDefaultEmulatorHostnameAndPort=e=>{const i=(e=>getDefaults()?.emulatorHosts?.[e])(e);if(!i)return;const s=i.lastIndexOf(":");if(s<=0||s+1===i.length)throw new Error(`Invalid host ${i} with no separate hostname and port!`);const T=parseInt(i.substring(s+1),10);return"["===i[0]?[i.substring(1,s-1),T]:[i.substring(0,s),T]};class FirebaseError extends Error{constructor(e,i,s){super(i),this.code=e,this.customData=s,this.name="FirebaseError",Object.setPrototypeOf(this,FirebaseError.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,ErrorFactory.prototype.create)}}class ErrorFactory{constructor(e,i,s){this.service=e,this.serviceName=i,this.errors=s}create(e,...i){const s=i[0]||{},T=`${this.service}/${e}`,E=this.errors[e],V=E?function replaceTemplate(e,i){try{let s=0,T="";for(;s<e.length;){const E=e.indexOf("{$",s);if(-1===E){T+=e.substring(s);break}const V=e.indexOf("}",E+2);if(-1===V){T+=e.substring(s);break}const R=e.substring(E+2,V),N=i[R];T+=e.substring(s,E)+(null!=N?String(N):`<${R}?>`),s=V+1}return T}catch(i){return e}}(E,s):"Error",R=`${this.serviceName}: ${V} (${T}).`;return new FirebaseError(T,R,s)}}function deepEqual(e,i){if(e===i)return!0;const s=Object.keys(e),T=Object.keys(i);for(const E of s){if(!T.includes(E))return!1;const s=e[E],V=i[E];if(isObject(s)&&isObject(V)){if(!deepEqual(s,V))return!1}else if(s!==V)return!1}for(const e of T)if(!s.includes(e))return!1;return!0}function isObject(e){return null!==e&&"object"==typeof e}function getModularInstance(e){return e&&e._delegate?e._delegate:e}function isCloudWorkstation(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch{return!1}}class Component{constructor(e,i,s){this.name=e,this.instanceFactory=i,this.type=s,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}}var N,M,Q;!function(e){e.LAZY="LAZY",e.EAGER="EAGER",e.EXPLICIT="EXPLICIT"}(N||(N={})),function(e){e.PUBLIC="PUBLIC",e.PRIVATE="PRIVATE",e.VERSION="VERSION"}(M||(M={})),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"}(Q||(Q={}));const L={debug:Q.DEBUG,verbose:Q.VERBOSE,info:Q.INFO,warn:Q.WARN,error:Q.ERROR,silent:Q.SILENT},U=Q.INFO,$={[Q.DEBUG]:"log",[Q.VERBOSE]:"log",[Q.INFO]:"info",[Q.WARN]:"warn",[Q.ERROR]:"error"},defaultLogHandler=(e,i,...s)=>{if(i<e.logLevel)return;const T=(new Date).toISOString(),E=$[i];if(!E)throw new Error(`Attempted to log a message with an invalid logType (value: ${i})`);console[E](`[${T}] ${e.name}:`,...s)};var W,K="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function __classPrivateFieldGet(e,i,s,T){if("a"===s&&!T)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof i?e!==i||!T:!i.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===s?T:"a"===s?T.call(e):T?T.value:i.get(e)}(function(){var e;function m(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.C=Array(this.blockSize),this.o=this.h=0,this.u()}function n(e,i,s){s||(s=0);const T=Array(16);if("string"==typeof i)for(var E=0;E<16;++E)T[E]=i.charCodeAt(s++)|i.charCodeAt(s++)<<8|i.charCodeAt(s++)<<16|i.charCodeAt(s++)<<24;else for(E=0;E<16;++E)T[E]=i[s++]|i[s++]<<8|i[s++]<<16|i[s++]<<24;i=e.g[0],s=e.g[1],E=e.g[2];let V,R=e.g[3];V=i+(R^s&(E^R))+T[0]+3614090360&4294967295,V=R+(E^(i=s+(V<<7&4294967295|V>>>25))&(s^E))+T[1]+3905402710&4294967295,R=i+(V<<12&4294967295|V>>>20),V=E+(s^R&(i^s))+T[2]+606105819&4294967295,V=s+(i^(E=R+(V<<17&4294967295|V>>>15))&(R^i))+T[3]+3250441966&4294967295,V=i+(R^(s=E+(V<<22&4294967295|V>>>10))&(E^R))+T[4]+4118548399&4294967295,V=R+(E^(i=s+(V<<7&4294967295|V>>>25))&(s^E))+T[5]+1200080426&4294967295,R=i+(V<<12&4294967295|V>>>20),V=E+(s^R&(i^s))+T[6]+2821735955&4294967295,V=s+(i^(E=R+(V<<17&4294967295|V>>>15))&(R^i))+T[7]+4249261313&4294967295,V=i+(R^(s=E+(V<<22&4294967295|V>>>10))&(E^R))+T[8]+1770035416&4294967295,V=R+(E^(i=s+(V<<7&4294967295|V>>>25))&(s^E))+T[9]+2336552879&4294967295,R=i+(V<<12&4294967295|V>>>20),V=E+(s^R&(i^s))+T[10]+4294925233&4294967295,V=s+(i^(E=R+(V<<17&4294967295|V>>>15))&(R^i))+T[11]+2304563134&4294967295,V=i+(R^(s=E+(V<<22&4294967295|V>>>10))&(E^R))+T[12]+1804603682&4294967295,V=R+(E^(i=s+(V<<7&4294967295|V>>>25))&(s^E))+T[13]+4254626195&4294967295,R=i+(V<<12&4294967295|V>>>20),V=E+(s^R&(i^s))+T[14]+2792965006&4294967295,V=s+(i^(E=R+(V<<17&4294967295|V>>>15))&(R^i))+T[15]+1236535329&4294967295,V=i+(E^R&((s=E+(V<<22&4294967295|V>>>10))^E))+T[1]+4129170786&4294967295,V=R+(s^E&((i=s+(V<<5&4294967295|V>>>27))^s))+T[6]+3225465664&4294967295,R=i+(V<<9&4294967295|V>>>23),V=E+(i^s&(R^i))+T[11]+643717713&4294967295,V=s+(R^i&((E=R+(V<<14&4294967295|V>>>18))^R))+T[0]+3921069994&4294967295,V=i+(E^R&((s=E+(V<<20&4294967295|V>>>12))^E))+T[5]+3593408605&4294967295,V=R+(s^E&((i=s+(V<<5&4294967295|V>>>27))^s))+T[10]+38016083&4294967295,R=i+(V<<9&4294967295|V>>>23),V=E+(i^s&(R^i))+T[15]+3634488961&4294967295,V=s+(R^i&((E=R+(V<<14&4294967295|V>>>18))^R))+T[4]+3889429448&4294967295,V=i+(E^R&((s=E+(V<<20&4294967295|V>>>12))^E))+T[9]+568446438&4294967295,V=R+(s^E&((i=s+(V<<5&4294967295|V>>>27))^s))+T[14]+3275163606&4294967295,R=i+(V<<9&4294967295|V>>>23),V=E+(i^s&(R^i))+T[3]+4107603335&4294967295,V=s+(R^i&((E=R+(V<<14&4294967295|V>>>18))^R))+T[8]+1163531501&4294967295,V=i+(E^R&((s=E+(V<<20&4294967295|V>>>12))^E))+T[13]+2850285829&4294967295,V=R+(s^E&((i=s+(V<<5&4294967295|V>>>27))^s))+T[2]+4243563512&4294967295,R=i+(V<<9&4294967295|V>>>23),V=E+(i^s&(R^i))+T[7]+1735328473&4294967295,V=s+(R^i&((E=R+(V<<14&4294967295|V>>>18))^R))+T[12]+2368359562&4294967295,V=i+((s=E+(V<<20&4294967295|V>>>12))^E^R)+T[5]+4294588738&4294967295,V=R+((i=s+(V<<4&4294967295|V>>>28))^s^E)+T[8]+2272392833&4294967295,R=i+(V<<11&4294967295|V>>>21),V=E+(R^i^s)+T[11]+1839030562&4294967295,V=s+((E=R+(V<<16&4294967295|V>>>16))^R^i)+T[14]+4259657740&4294967295,V=i+((s=E+(V<<23&4294967295|V>>>9))^E^R)+T[1]+2763975236&4294967295,V=R+((i=s+(V<<4&4294967295|V>>>28))^s^E)+T[4]+1272893353&4294967295,R=i+(V<<11&4294967295|V>>>21),V=E+(R^i^s)+T[7]+4139469664&4294967295,V=s+((E=R+(V<<16&4294967295|V>>>16))^R^i)+T[10]+3200236656&4294967295,V=i+((s=E+(V<<23&4294967295|V>>>9))^E^R)+T[13]+681279174&4294967295,V=R+((i=s+(V<<4&4294967295|V>>>28))^s^E)+T[0]+3936430074&4294967295,R=i+(V<<11&4294967295|V>>>21),V=E+(R^i^s)+T[3]+3572445317&4294967295,V=s+((E=R+(V<<16&4294967295|V>>>16))^R^i)+T[6]+76029189&4294967295,V=i+((s=E+(V<<23&4294967295|V>>>9))^E^R)+T[9]+3654602809&4294967295,V=R+((i=s+(V<<4&4294967295|V>>>28))^s^E)+T[12]+3873151461&4294967295,R=i+(V<<11&4294967295|V>>>21),V=E+(R^i^s)+T[15]+530742520&4294967295,V=s+((E=R+(V<<16&4294967295|V>>>16))^R^i)+T[2]+3299628645&4294967295,V=i+(E^((s=E+(V<<23&4294967295|V>>>9))|~R))+T[0]+4096336452&4294967295,V=R+(s^((i=s+(V<<6&4294967295|V>>>26))|~E))+T[7]+1126891415&4294967295,R=i+(V<<10&4294967295|V>>>22),V=E+(i^(R|~s))+T[14]+2878612391&4294967295,V=s+(R^((E=R+(V<<15&4294967295|V>>>17))|~i))+T[5]+4237533241&4294967295,V=i+(E^((s=E+(V<<21&4294967295|V>>>11))|~R))+T[12]+1700485571&4294967295,V=R+(s^((i=s+(V<<6&4294967295|V>>>26))|~E))+T[3]+2399980690&4294967295,R=i+(V<<10&4294967295|V>>>22),V=E+(i^(R|~s))+T[10]+4293915773&4294967295,V=s+(R^((E=R+(V<<15&4294967295|V>>>17))|~i))+T[1]+2240044497&4294967295,V=i+(E^((s=E+(V<<21&4294967295|V>>>11))|~R))+T[8]+1873313359&4294967295,V=R+(s^((i=s+(V<<6&4294967295|V>>>26))|~E))+T[15]+4264355552&4294967295,R=i+(V<<10&4294967295|V>>>22),V=E+(i^(R|~s))+T[6]+2734768916&4294967295,V=s+(R^((E=R+(V<<15&4294967295|V>>>17))|~i))+T[13]+1309151649&4294967295,V=i+(E^((s=E+(V<<21&4294967295|V>>>11))|~R))+T[4]+4149444226&4294967295,V=R+(s^((i=s+(V<<6&4294967295|V>>>26))|~E))+T[11]+3174756917&4294967295,R=i+(V<<10&4294967295|V>>>22),V=E+(i^(R|~s))+T[2]+718787259&4294967295,V=s+(R^((E=R+(V<<15&4294967295|V>>>17))|~i))+T[9]+3951481745&4294967295,e.g[0]=e.g[0]+i&4294967295,e.g[1]=e.g[1]+(E+(V<<21&4294967295|V>>>11))&4294967295,e.g[2]=e.g[2]+E&4294967295,e.g[3]=e.g[3]+R&4294967295}function t(e,i){this.h=i;const s=[];let T=!0;for(let E=e.length-1;E>=0;E--){const V=0|e[E];T&&V==i||(s[E]=V,T=!1)}this.g=s}!function k(e,i){function c(){}c.prototype=i.prototype,e.F=i.prototype,e.prototype=new c,e.prototype.constructor=e,e.D=function(e,s,T){for(var E=Array(arguments.length-2),V=2;V<arguments.length;V++)E[V-2]=arguments[V];return i.prototype[s].apply(e,E)}}(m,(function l(){this.blockSize=-1})),m.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0},m.prototype.v=function(e,i){void 0===i&&(i=e.length);const s=i-this.blockSize,T=this.C;let E=this.h,V=0;for(;V<i;){if(0==E)for(;V<=s;)n(this,e,V),V+=this.blockSize;if("string"==typeof e){for(;V<i;)if(T[E++]=e.charCodeAt(V++),E==this.blockSize){n(this,T),E=0;break}}else for(;V<i;)if(T[E++]=e[V++],E==this.blockSize){n(this,T),E=0;break}}this.h=E,this.o+=i},m.prototype.A=function(){var e=Array((this.h<56?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var i=1;i<e.length-8;++i)e[i]=0;i=8*this.o;for(var s=e.length-8;s<e.length;++s)e[s]=255&i,i/=256;for(this.v(e),e=Array(16),i=0,s=0;s<4;++s)for(let T=0;T<32;T+=8)e[i++]=this.g[s]>>>T&255;return e};var i={};function u(e){return-128<=e&&e<128?function p(e,s){var T=i;return Object.prototype.hasOwnProperty.call(T,e)?T[e]:T[e]=s(e)}(e,(function(e){return new t([0|e],e<0?-1:0)})):new t([0|e],e<0?-1:0)}function v(e){if(isNaN(e)||!isFinite(e))return s;if(e<0)return x(v(-e));const i=[];let T=1;for(let s=0;e>=T;s++)i[s]=e/T|0,T*=4294967296;return new t(i,0)}var s=u(0),T=u(1),E=u(16777216);function C(e){if(0!=e.h)return!1;for(let i=0;i<e.g.length;i++)if(0!=e.g[i])return!1;return!0}function B(e){return-1==e.h}function x(e){const i=e.g.length,s=[];for(let T=0;T<i;T++)s[T]=~e.g[T];return new t(s,~e.h).add(T)}function F(e,i){return e.add(x(i))}function G(e,i){for(;(65535&e[i])!=e[i];)e[i+1]+=e[i]>>>16,e[i]&=65535,i++}function H(e,i){this.g=e,this.h=i}function D(e,i){if(C(i))throw Error("division by zero");if(C(e))return new H(s,s);if(B(e))return i=D(x(e),i),new H(x(i.g),x(i.h));if(B(i))return i=D(e,x(i)),new H(x(i.g),i.h);if(e.g.length>30){if(B(e)||B(i))throw Error("slowDivide_ only works with positive integers.");for(var E=T,V=i;V.l(e)<=0;)E=I(E),V=I(V);var R=J(E,1),N=J(V,1);for(V=J(V,2),E=J(E,2);!C(V);){var M=N.add(V);M.l(e)<=0&&(R=R.add(E),N=M),V=J(V,1),E=J(E,1)}return i=F(e,R.j(i)),new H(R,i)}for(R=s;e.l(i)>=0;){for(E=Math.max(1,Math.floor(e.m()/i.m())),V=(V=Math.ceil(Math.log(E)/Math.LN2))<=48?1:Math.pow(2,V-48),M=(N=v(E)).j(i);B(M)||M.l(e)>0;)M=(N=v(E-=V)).j(i);C(N)&&(N=T),R=R.add(N),e=F(e,M)}return new H(R,e)}function I(e){const i=e.g.length+1,s=[];for(let T=0;T<i;T++)s[T]=e.i(T)<<1|e.i(T-1)>>>31;return new t(s,e.h)}function J(e,i){const s=i>>5;i%=32;const T=e.g.length-s,E=[];for(let V=0;V<T;V++)E[V]=i>0?e.i(V+s)>>>i|e.i(V+s+1)<<32-i:e.i(V+s);return new t(E,e.h)}(e=t.prototype).m=function(){if(B(this))return-x(this).m();let e=0,i=1;for(let s=0;s<this.g.length;s++){const T=this.i(s);e+=(T>=0?T:4294967296+T)*i,i*=4294967296}return e},e.toString=function(e){if((e=e||10)<2||36<e)throw Error("radix out of range: "+e);if(C(this))return"0";if(B(this))return"-"+x(this).toString(e);const i=v(Math.pow(e,6));var s=this;let T="";for(;;){const E=D(s,i).g;let V=(((s=F(s,E.j(i))).g.length>0?s.g[0]:s.h)>>>0).toString(e);if(C(s=E))return V+T;for(;V.length<6;)V="0"+V;T=V+T}},e.i=function(e){return e<0?0:e<this.g.length?this.g[e]:this.h},e.l=function(e){return B(e=F(this,e))?-1:C(e)?0:1},e.abs=function(){return B(this)?x(this):this},e.add=function(e){const i=Math.max(this.g.length,e.g.length),s=[];let T=0;for(let E=0;E<=i;E++){let i=T+(65535&this.i(E))+(65535&e.i(E)),V=(i>>>16)+(this.i(E)>>>16)+(e.i(E)>>>16);T=V>>>16,i&=65535,V&=65535,s[E]=V<<16|i}return new t(s,-2147483648&s[s.length-1]?-1:0)},e.j=function(e){if(C(this)||C(e))return s;if(B(this))return B(e)?x(this).j(x(e)):x(x(this).j(e));if(B(e))return x(this.j(x(e)));if(this.l(E)<0&&e.l(E)<0)return v(this.m()*e.m());const i=this.g.length+e.g.length,T=[];for(var V=0;V<2*i;V++)T[V]=0;for(V=0;V<this.g.length;V++)for(let i=0;i<e.g.length;i++){const s=this.i(V)>>>16,E=65535&this.i(V),R=e.i(i)>>>16,N=65535&e.i(i);T[2*V+2*i]+=E*N,G(T,2*V+2*i),T[2*V+2*i+1]+=s*N,G(T,2*V+2*i+1),T[2*V+2*i+1]+=E*R,G(T,2*V+2*i+1),T[2*V+2*i+2]+=s*R,G(T,2*V+2*i+2)}for(e=0;e<i;e++)T[e]=T[2*e+1]<<16|T[2*e];for(e=i;e<2*i;e++)T[e]=0;return new t(T,0)},e.B=function(e){return D(this,e).h},e.and=function(e){const i=Math.max(this.g.length,e.g.length),s=[];for(let T=0;T<i;T++)s[T]=this.i(T)&e.i(T);return new t(s,this.h&e.h)},e.or=function(e){const i=Math.max(this.g.length,e.g.length),s=[];for(let T=0;T<i;T++)s[T]=this.i(T)|e.i(T);return new t(s,this.h|e.h)},e.xor=function(e){const i=Math.max(this.g.length,e.g.length),s=[];for(let T=0;T<i;T++)s[T]=this.i(T)^e.i(T);return new t(s,this.h^e.h)},m.prototype.digest=m.prototype.A,m.prototype.reset=m.prototype.u,m.prototype.update=m.prototype.v,t.prototype.add=t.prototype.add,t.prototype.multiply=t.prototype.j,t.prototype.modulo=t.prototype.B,t.prototype.compare=t.prototype.l,t.prototype.toNumber=t.prototype.m,t.prototype.toString=t.prototype.toString,t.prototype.getBits=t.prototype.i,t.fromNumber=v,t.fromString=function y(e,i){if(0==e.length)throw Error("number format error: empty string");if((i=i||10)<2||36<i)throw Error("radix out of range: "+i);if("-"==e.charAt(0))return x(y(e.substring(1),i));if(e.indexOf("-")>=0)throw Error('number format error: interior "-" character');const T=v(Math.pow(i,8));let E=s;for(let s=0;s<e.length;s+=8){var V=Math.min(8,e.length-s);const R=parseInt(e.substring(s,s+V),i);V<8?(V=v(Math.pow(i,V)),E=E.j(V).add(v(R))):(E=E.j(T),E=E.add(v(R)))}return E},W=t}).apply(void 0!==K?K:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{}),"function"==typeof SuppressedError&&SuppressedError;class User{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}}User.UNAUTHENTICATED=new User(null),User.GOOGLE_CREDENTIALS=new User("google-credentials-uid"),User.FIRST_PARTY=new User("first-party-uid"),User.MOCK_USER=new User("mock-user");let Y="13.3.0";const X=new class Logger{constructor(e){this.name=e,this._logLevel=U,this._logHandler=defaultLogHandler,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in Q))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?L[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&&this._userLogHandler(this,Q.DEBUG,...e),this._logHandler(this,Q.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,Q.VERBOSE,...e),this._logHandler(this,Q.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,Q.INFO,...e),this._logHandler(this,Q.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,Q.WARN,...e),this._logHandler(this,Q.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,Q.ERROR,...e),this._logHandler(this,Q.ERROR,...e)}}("@firebase/firestore");function setLogLevel(e){X.setLogLevel(e)}function a(e,...i){if(X.logLevel<=Q.DEBUG){const s=i.map(__PRIVATE_argToString);X.debug(`Firestore (${Y}): ${e}`,...s)}}function st(e,...i){if(X.logLevel<=Q.ERROR){const s=i.map(__PRIVATE_argToString);X.error(`Firestore (${Y}): ${e}`,...s)}}function __PRIVATE_logWarn(e,...i){if(X.logLevel<=Q.WARN){const s=i.map(__PRIVATE_argToString);X.warn(`Firestore (${Y}): ${e}`,...s)}}function __PRIVATE_argToString(e){if("string"==typeof e)return e;try{return function __PRIVATE_formatJSON(e){return JSON.stringify(e)}(e)}catch(i){return e}}function z(e,i,s){let T="Unexpected state";"string"==typeof i?T=i:s=i,__PRIVATE__fail(e,T,s)}function __PRIVATE__fail(e,i,s){let T=`FIRESTORE (${Y}) INTERNAL ASSERTION FAILED: ${i} (ID: ${e.toString(16)})`;if(void 0!==s)try{T+=" CONTEXT: "+JSON.stringify(s)}catch(e){T+=" CONTEXT: "+s}throw st(T),new Error(T)}function __PRIVATE_hardAssert(e,i,s,T){let E="Unexpected state";"string"==typeof s?E=s:T=s,e||__PRIVATE__fail(i,E,T)}function __PRIVATE_debugCast(e,i){return e}const Z="ok",ee="cancelled",te="unknown",re="invalid-argument",ne="deadline-exceeded",ie="not-found",se="already-exists",ae="permission-denied",oe="unauthenticated",ue="resource-exhausted",le="failed-precondition",ce="aborted",_e="out-of-range",he="unimplemented",de="internal",fe="unavailable",me="data-loss";class k extends FirebaseError{constructor(e,i){super(e,i),this.code=e,this.message=i,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class __PRIVATE_OAuthToken{constructor(e,i){this.user=i,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class __PRIVATE_EmptyAuthCredentialsProvider{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,i){e.enqueueRetryable((()=>i(User.UNAUTHENTICATED)))}shutdown(){}}class __PRIVATE_EmulatorAuthCredentialsProvider{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,i){this.changeListener=i,e.enqueueRetryable((()=>i(this.token.user)))}shutdown(){this.changeListener=null}}class r{constructor(e){this.auth=null,e.onInit((e=>{this.auth=e}))}getToken(){return this.auth?this.auth.getToken().then((e=>e?(__PRIVATE_hardAssert("string"==typeof e.accessToken,42297,{Z:e}),new __PRIVATE_OAuthToken(e.accessToken,new User(this.auth.getUid()))):null)):Promise.resolve(null)}invalidateToken(){}start(e,i){}shutdown(){}}class __PRIVATE_FirstPartyToken{constructor(e,i,s){this.ee=e,this.te=i,this.re=s,this.type="FirstParty",this.user=User.FIRST_PARTY,this.ne=new Map}ie(){return this.re?this.re():null}get headers(){this.ne.set("X-Goog-AuthUser",this.ee);const e=this.ie();return e&&this.ne.set("Authorization",e),this.te&&this.ne.set("X-Goog-Iam-Authorization-Token",this.te),this.ne}}class __PRIVATE_FirstPartyAuthCredentialsProvider{constructor(e,i,s){this.ee=e,this.te=i,this.re=s}getToken(){return Promise.resolve(new __PRIVATE_FirstPartyToken(this.ee,this.te,this.re))}start(e,i){e.enqueueRetryable((()=>i(User.FIRST_PARTY)))}shutdown(){}invalidateToken(){}}class AppCheckToken{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class o{constructor(i,s){this.se=s,this.appCheck=null,this.oe=null,e(i)&&i.settings.appCheckToken&&(this.oe=i.settings.appCheckToken),s.onInit((e=>{this.appCheck=e}))}getToken(){return this.oe?Promise.resolve(new AppCheckToken(this.oe)):this.appCheck?this.appCheck.getToken().then((e=>e?(__PRIVATE_hardAssert("string"==typeof e.token,3470,{tokenResult:e}),new AppCheckToken(e.token)):null)):Promise.resolve(null)}invalidateToken(){}start(e,i){}shutdown(){}}class DatabaseInfo{constructor(e,i,s,T,E,V,R,N,M,Q,L,U,$){this.databaseId=e,this.appId=i,this.persistenceKey=s,this.host=T,this.ssl=E,this.forceLongPolling=V,this.autoDetectLongPolling=R,this.longPollingOptions=N,this.useFetchStreams=M,this.isUsingEmulator=Q,this.apiKey=L,this._customHeaders=U,this.grpcFlowControlWindow=$}}const pe="(default)";class DatabaseId{constructor(e,i){this.projectId=e,this.database=i||pe}static empty(){return new DatabaseId("","")}get isDefaultDatabase(){return this.database===pe}isEqual(e){return e instanceof DatabaseId&&e.projectId===this.projectId&&e.database===this.database}}function __PRIVATE_randomBytes(e){const i="undefined"!=typeof self&&(self.crypto||self.msCrypto),s=new Uint8Array(e);if(i&&"function"==typeof i.getRandomValues)i.getRandomValues(s);else for(let i=0;i<e;i++)s[i]=Math.floor(256*Math.random());return s}class __PRIVATE_AutoId{static newId(){const e=62*Math.floor(256/62);let i="";for(;i.length<20;){const s=__PRIVATE_randomBytes(40);for(let T=0;T<s.length;++T)i.length<20&&s[T]<e&&(i+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(s[T]%62))}return i}}function __PRIVATE_primitiveComparator(e,i){return e<i?-1:e>i?1:0}function __PRIVATE_compareUtf8Strings(e,i){const s=Math.min(e.length,i.length);for(let T=0;T<s;T++){const s=e.charAt(T),E=i.charAt(T);if(s!==E)return __PRIVATE_isSurrogate(s)===__PRIVATE_isSurrogate(E)?__PRIVATE_primitiveComparator(s,E):__PRIVATE_isSurrogate(s)?1:-1}return __PRIVATE_primitiveComparator(e.length,i.length)}const ge=55296,Te=57343;function __PRIVATE_isSurrogate(e){const i=e.charCodeAt(0);return i>=ge&&i<=Te}function __PRIVATE_arrayEquals(e,i,s){return e.length===i.length&&e.every(((e,T)=>s(e,i[T])))}const Ee="__name__";class BasePath{constructor(e,i,s){void 0===i?i=0:i>e.length&&z(637,{offset:i,range:e.length}),void 0===s?s=e.length-i:s>e.length-i&&z(1746,{length:s,range:e.length-i}),this.segments=e,this.offset=i,this.len=s}get length(){return this.len}isEqual(e){return 0===BasePath.comparator(this,e)}child(e){const i=this.segments.slice(this.offset,this.limit());return e instanceof BasePath?e.forEach((e=>{i.push(e)})):i.push(e),this.construct(i)}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<this.length)return!1;for(let i=0;i<this.length;i++)if(this.get(i)!==e.get(i))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let i=0;i<this.length;i++)if(this.get(i)!==e.get(i))return!1;return!0}forEach(e){for(let i=this.offset,s=this.limit();i<s;i++)e(this.segments[i])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,i){const s=Math.min(e.length,i.length);for(let T=0;T<s;T++){const s=BasePath.compareSegments(e.get(T),i.get(T));if(0!==s)return s}return __PRIVATE_primitiveComparator(e.length,i.length)}static compareSegments(e,i){const s=BasePath.isNumericId(e),T=BasePath.isNumericId(i);return s&&!T?-1:!s&&T?1:s&&T?BasePath.extractNumericId(e).compare(BasePath.extractNumericId(i)):__PRIVATE_compareUtf8Strings(e,i)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return W.fromString(e.substring(4,e.length-2))}}class ResourcePath extends BasePath{construct(e,i,s){return new ResourcePath(e,i,s)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toStringWithLeadingSlash(){return`/${this.canonicalString()}`}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const i=[];for(const s of e){if(s.indexOf("//")>=0)throw new k(re,`Invalid segment (${s}). Paths must not contain // in them.`);i.push(...s.split("/").filter((e=>e.length>0)))}return new ResourcePath(i)}static emptyPath(){return new ResourcePath([])}}const ye=/^[_a-zA-Z][_a-zA-Z0-9]*$/;let Ve=class FieldPath extends BasePath{construct(e,i,s){return new FieldPath(e,i,s)}static isValidIdentifier(e){return ye.test(e)}canonicalString(){return this.toArray().map((e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),FieldPath.isValidIdentifier(e)||(e="`"+e+"`"),e))).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===Ee}static keyField(){return new FieldPath([Ee])}static fromServerFormat(e){const i=[];let s="",T=0;const __PRIVATE_addCurrentSegment=()=>{if(0===s.length)throw new k(re,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);i.push(s),s=""};let E=!1;for(;T<e.length;){const i=e[T];if("\\"===i){if(T+1===e.length)throw new k(re,"Path has trailing escape character: "+e);const i=e[T+1];if("\\"!==i&&"."!==i&&"`"!==i)throw new k(re,"Path has invalid escape sequence: "+e);s+=i,T+=2}else"`"===i?(E=!E,T++):"."!==i||E?(s+=i,T++):(__PRIVATE_addCurrentSegment(),T++)}if(__PRIVATE_addCurrentSegment(),E)throw new k(re,"Unterminated ` in path: "+e);return new FieldPath(i)}static emptyPath(){return new FieldPath([])}};class S{constructor(e){this.path=e}static fromPath(e){return new S(ResourcePath.fromString(e))}static fromName(e){return new S(ResourcePath.fromString(e).popFirst(5))}static empty(){return new S(ResourcePath.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return null!==e&&0===ResourcePath.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,i){return ResourcePath.comparator(e.path,i.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new S(new ResourcePath(e.slice()))}}function __PRIVATE_validateNonEmptyArgument(e,i,s){if(!s)throw new k(re,`Function ${e}() cannot be called with an empty ${i}.`)}function __PRIVATE_validateDocumentPath(e){if(!S.isDocumentKey(e))throw new k(re,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function __PRIVATE_validateCollectionPath(e){if(S.isDocumentKey(e))throw new k(re,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function __PRIVATE_isPlainObject(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function __PRIVATE_valueDescription(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(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 i=function __PRIVATE_tryGetCustomObjectType(e){return e.constructor?e.constructor.name:null}(e);return i?`a custom ${i} object`:"an object"}}return"function"==typeof e?"a function":z(12329,{type:typeof e})}function f(e,i){if("_delegate"in e&&(e=e._delegate),!(e instanceof i)){if(i.name===e.constructor.name)throw new k(re,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const s=__PRIVATE_valueDescription(e);throw new k(re,`Expected type '${i.name}', but it was: ${s}`)}}return e}function __PRIVATE_validatePositiveNumber(e,i){if(i<=0)throw new k(re,`Function ${e}() requires a positive number, but it was: ${i}.`)}function __PRIVATE_cloneLongPollingOptions(e){const i={};return void 0!==e.timeoutSeconds&&(i.timeoutSeconds=e.timeoutSeconds),i}let Ae=null;function tt(e){return null==e}function __PRIVATE_isNegativeZero(e){return 0===e&&1/e==-1/0}const Ie="RestConnection",Pe={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class __PRIVATE_RestConnection{get ae(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const i=e.ssl?"https":"http",s=encodeURIComponent(this.databaseId.projectId),T=encodeURIComponent(this.databaseId.database);this.ue=i+"://"+e.host,this._e=`projects/${s}/databases/${T}`,this.ce=this.databaseId.database===pe?`project_id=${s}`:`project_id=${s}&database_id=${T}`}le(e,i,s,T,E){const V=function __PRIVATE_generateUniqueDebugId(){return null===Ae?Ae=function __PRIVATE_generateInitialUniqueDebugId(){return 268435456+Math.round(2147483648*Math.random())}():Ae++,"0x"+Ae.toString(16)}(),R=this.fe(e,i.toUriEncodedString());a(Ie,`Sending RPC '${e}' ${V}:`,R,s);const N={"google-cloud-resource-prefix":this._e,"x-goog-request-params":this.ce};this.he(N,T,E);const{host:M}=new URL(R),Q=isCloudWorkstation(M);return this.de(e,R,N,s,Q).then((i=>(a(Ie,`Received RPC '${e}' ${V}: `,i),i)),(i=>{throw __PRIVATE_logWarn(Ie,`RPC '${e}' ${V} failed with error: `,i,"url: ",R,"request:",s),i}))}me(e,i,s,T,E,V){return this.le(e,i,s,T,E)}he(e,i,s){if(e["X-Goog-Api-Client"]=function __PRIVATE_getGoogApiClientValue(){return"gl-js/ fire/"+Y}(),e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),i&&i.headers.forEach(((i,s)=>e[s]=i)),s&&s.headers.forEach(((i,s)=>e[s]=i)),this.databaseInfo._customHeaders)for(const i of Object.keys(this.databaseInfo._customHeaders))e[i]=this.databaseInfo._customHeaders[i]}fe(e,i){const s=Pe[e];let T=`${this.ue}/v1/${i}:${s}`;return this.databaseInfo.apiKey&&(T=`${T}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),T}terminate(){}}var Re,be,we,ve,Se,xe,Fe,Ne;function __PRIVATE_mapCodeFromHttpStatus(e){if(void 0===e)return st("RPC_ERROR","HTTP error has no status"),te;switch(e){case 200:return Z;case 400:return le;case 401:return oe;case 403:return ae;case 404:return ie;case 409:return ce;case 416:return _e;case 429:return ue;case 499:return ee;case 500:return te;case 501:return he;case 503:return fe;case 504:return ne;default:return e>=200&&e<300?Z:e>=400&&e<500?le:e>=500&&e<600?de:te}}(be=Re||(Re={}))[be.OK=0]="OK",be[be.CANCELLED=1]="CANCELLED",be[be.UNKNOWN=2]="UNKNOWN",be[be.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",be[be.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",be[be.NOT_FOUND=5]="NOT_FOUND",be[be.ALREADY_EXISTS=6]="ALREADY_EXISTS",be[be.PERMISSION_DENIED=7]="PERMISSION_DENIED",be[be.UNAUTHENTICATED=16]="UNAUTHENTICATED",be[be.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",be[be.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",be[be.ABORTED=10]="ABORTED",be[be.OUT_OF_RANGE=11]="OUT_OF_RANGE",be[be.UNIMPLEMENTED=12]="UNIMPLEMENTED",be[be.INTERNAL=13]="INTERNAL",be[be.UNAVAILABLE=14]="UNAVAILABLE",be[be.DATA_LOSS=15]="DATA_LOSS";class __PRIVATE_FetchConnection extends __PRIVATE_RestConnection{Ee(e,i){throw new Error("Not supported by FetchConnection")}async de(e,i,s,T,E){const V=JSON.stringify(T);let R;try{const e={method:"POST",headers:s,body:V};E&&(e.credentials="include"),R=await fetch(i,e)}catch(e){const i=e,s=i?.message,T=i?.cause?String(i.cause):void 0,E=(s&&T?`${s} (${T})`:s??T)??i?.statusText??String(e);throw new k(__PRIVATE_mapCodeFromHttpStatus(i?.status),`Request failed with error: ${E}`)}if(!R.ok){let e=await R.json();Array.isArray(e)&&(e=e[0]);const i=e?.error?.message;throw new k(__PRIVATE_mapCodeFromHttpStatus(R.status),`Request failed with error: ${i??R.statusText}`)}return R.json()}}class __PRIVATE_Base64DecodeError extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class ByteString{constructor(e){this.binaryString=e}static fromBase64String(e){const i=function __PRIVATE_decodeBase64(e){try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&&e instanceof DOMException?new __PRIVATE_Base64DecodeError("Invalid base64 string: "+e):e}}(e);return new ByteString(i)}static fromUint8Array(e){const i=function __PRIVATE_binaryStringFromUint8Array(e){let i="";for(let s=0;s<e.length;++s)i+=String.fromCharCode(e[s]);return i}(e);return new ByteString(i)}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return function __PRIVATE_encodeBase64(e){return btoa(e)}(this.binaryString)}toUint8Array(){return function __PRIVATE_uint8ArrayFromBinaryString(e){const i=new Uint8Array(e.length);for(let s=0;s<e.length;s++)i[s]=e.charCodeAt(s);return i}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return __PRIVATE_primitiveComparator(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}function __PRIVATE_objectSize(e){let i=0;for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&i++;return i}function forEach(e,i){for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&i(s,e[s])}ByteString.EMPTY_BYTE_STRING=new ByteString("");class __PRIVATE_QuadrupleBuilder{constructor(){this.exponent=0,this.Ve=0n,this.Te=0n,this.Ie=new Array(4).fill(0n),this.Ae=new Array(6).fill(0n),this.Re=new Array(6).fill(0n),this.Pe=new Array(6).fill(0n),this.pe=new Array(12).fill(0n)}static ye(e,i){let s=new __PRIVATE_QuadrupleBuilder;return s.parse(e,i),s}parse(e,i){i+=e.length-1,this.exponent=0,this.Ve=0n,this.Te=0n;let s=this.Pe,T=this.be(e,s);if(0==T&&this.isEmpty(s))return;if((i+=T)<__PRIVATE_QuadrupleBuilder.we)return;if(i>__PRIVATE_QuadrupleBuilder.ge)return void(this.exponent=Number(__PRIVATE_QuadrupleBuilder.Fe));let E=this.ve(i,s);this.xe(i,E,s)}be(e,i){for(let e=0;e<6;e++)i[e]=0n;let s=0;for(;s<e.length&&0==e[s];)s+=1;if(s==e.length)return 0;let T=-s;if(e.length-s>__PRIVATE_QuadrupleBuilder.De){let i=e[__PRIVATE_QuadrupleBuilder.De]>=5,E=new Array(__PRIVATE_QuadrupleBuilder.De).fill(0);for(let i=0;i<__PRIVATE_QuadrupleBuilder.De;i++)E[i]=e[i+s];i&&(T+=this.Ne(E)),e=E,s=0}for(let T=e.length-1;T>=s;T--)i[0]|=BigInt(e[T])<<32n,this.Se(i);return T}Se(e){let i=e.length;for(let s=0;s<i;s++){let T=e[s]%10n;e[s]=e[s]/10n,s+1<i&&(e[s+1]+=T<<32n)}}isEmpty(e){for(let i=0;i<e.length;i++)if(0n!=e[i])return!1;return!0}Ne(e){for(let i=e.length-1;i>=0;i--){if(9!=e[i])return e[i]=e[i]+1,0;e[i]=0}return e[0]=1,1}ve(e,i){let s=i[0]<<31n|i[1]>>1n,T=Number(s)/__PRIVATE_QuadrupleBuilder.Ce;return Math.floor(Number(e)*__PRIVATE_QuadrupleBuilder.Be+this.log2(T))}log2(e){return __PRIVATE_QuadrupleBuilder.Qe*Math.log(e)}xe(e,i,s){let T=this.Ie;this.Oe(-i,T);let E=this.pe;this.Me(s,T,E),this.qe(E),BigInt(T[0])!=BigInt(-e)&&this.qe(E),i+=this.Le(E),(i+=__PRIVATE_QuadrupleBuilder.Ue)<=0||(i+=this.$e(E),BigInt(i)>=__PRIVATE_QuadrupleBuilder.Fe?this.exponent=Number(__PRIVATE_QuadrupleBuilder.Fe):(this.exponent=Number(i),this.Ve=(E[0]<<32n)+E[1]&0xffffffffffffffffn,this.Te=(E[2]<<32n)+E[3]&0xffffffffffffffffn))}Oe(e,i){if(0==e)return void this.ke(__PRIVATE_QuadrupleBuilder.je[0],i);let s=__PRIVATE_QuadrupleBuilder.je;e<0&&(e=-e,s=__PRIVATE_QuadrupleBuilder.Ke);let T=__PRIVATE_QuadrupleBuilder.ze,E=32,V=!0;for(;e>0;)e>=T&&(V?(this.ke(s[E],i),V=!1):this.We(i,s[E],i),e-=T),E-=1,T*=.5}ke(e,i){for(let s=0;s<i.length;s++)i[s]=e[s]}We(e,i,s){this.Ge(e,i,this.pe);let T=this.Je(this.pe);this.He(this.pe,s),s[0]=e[0]+i[0]+BigInt(T)}Ge(e,i,s){for(let e=0;e<s.length;e++)s[e]=0n;this.Ye(e,this.Ae),this.Ye(i,this.Re);for(let e=5;e>=0;e--)for(let i=5;i>=0;i--){let T=this.Ae[e]*this.Re[i];s[i+e+1]=s[i+e+1]+(T&__PRIVATE_QuadrupleBuilder.Xe)&0xffffffffffffffffn,s[i+e]=s[i+e]+(T>>32n)&0xffffffffffffffffn}for(let e=11;e>=1;e--)s[e-1]=s[e-1]+(s[e]>>32n)&0xffffffffffffffffn,s[e]&=__PRIVATE_QuadrupleBuilder.Xe}Je(e){let i=0;for(;this.Ze(e);)this.qe(e),i-=1;return i}Ze(e){if(e[0]<0x19999999n)return!0;if(e[0]>0x19999999n)return!1;for(let i=1;i<e.length;i++){if(e[i]<0x99999999n)return!0;if(e[i]>0x99999999n)return!1}return!1}Me(e,i,s){for(let e=0;e<s.length;e++)s[e]=0n;let T=this.Re;this.Ye(i,T);let E=e.length;for(let i=E-1;i>=0;i--)for(let V=E-1;V>=0;V--){let E=e[i]*T[V];s[V+i+1]=s[V+i+1]+(E&__PRIVATE_QuadrupleBuilder.Xe)&0xffffffffffffffffn,s[V+i]=s[V+i]+(E>>32n)&0xffffffffffffffffn}for(let e=11;e>=1;e--)s[e-1]=s[e-1]+(s[e]>>32n)&0xffffffffffffffffn,s[e]&=__PRIVATE_QuadrupleBuilder.Xe}qe(e){let i=e.length-1;e[0]&=__PRIVATE_QuadrupleBuilder.Xe,e[i]*=10n;for(let s=i-1;s>=0;s--)e[s]=10n*e[s]+(e[s+1]>>32n)&0xffffffffffffffffn,e[s+1]&=__PRIVATE_QuadrupleBuilder.Xe}Le(e){let i=31-__PRIVATE_QuadrupleBuilder.et(e[0]);return 0!=i&&this.tt(e,i),i}$e(e){return this.rt(e,5,100n),this.rt(e,4,0x80000000n),0n!=(e[0]&__PRIVATE_QuadrupleBuilder.nt<<1n)?(this.tt(e,1),1):0}He(e,i){i[1]=(e[0]<<32n)+e[1],i[2]=(e[2]<<32n)+e[3],i[3]=(e[4]<<32n)+e[5]}Ye(e,i){i[0]=e[1]>>32n,i[1]=e[1]&__PRIVATE_QuadrupleBuilder.Xe,i[2]=e[2]>>32n,i[3]=e[2]&__PRIVATE_QuadrupleBuilder.Xe,i[4]=e[3]>>32n,i[5]=e[3]&__PRIVATE_QuadrupleBuilder.Xe}tt(e,i){let s=e.length-1,T=BigInt(32-Math.abs(i));if(i>0){let E=BigInt(i);for(let i=s+1-1;i>=1;i--)e[i]=e[i]>>E|e[i-1]<<T&__PRIVATE_QuadrupleBuilder.Xe;e[0]=e[0]>>E}else if(i<0){let E=BigInt(-i);e[0]=0xffffffffffffffffn&(e[0]<<E|e[1]>>T);for(let i=1;i<s;i++)e[i]=0xffffffffffffffffn&(e[i]<<E&__PRIVATE_QuadrupleBuilder.Xe|e[i+1]>>T);e[s]=e[s]<<E&__PRIVATE_QuadrupleBuilder.Xe}}rt(e,i,s){let T=i;e[T]=e[T]+s&0xffffffffffffffffn;for(let i=T+1-1;i>=1&&0n!=(e[i]&__PRIVATE_QuadrupleBuilder.nt);i--)e[i]&=__PRIVATE_QuadrupleBuilder.Xe,e[i-1]+=1n}static et(e){let i=Number(e>>32n);return 0==i?32+Math.clz32(Number(BigInt.asUintN(32,e))):Math.clz32(i)}}__PRIVATE_QuadrupleBuilder.De=59,__PRIVATE_QuadrupleBuilder.ge=646456993,__PRIVATE_QuadrupleBuilder.we=-646457032,__PRIVATE_QuadrupleBuilder.Ce=0xccccccccccccd00,__PRIVATE_QuadrupleBuilder.it=0x8000000000000000n,__PRIVATE_QuadrupleBuilder.ze=2147483648,__PRIVATE_QuadrupleBuilder.Xe=0x00000000ffffffffn,__PRIVATE_QuadrupleBuilder.nt=0xffffffff00000000n,__PRIVATE_QuadrupleBuilder.Be=Math.log(10)/Math.log(2),__PRIVATE_QuadrupleBuilder.Qe=1/Math.log(2),__PRIVATE_QuadrupleBuilder.Ue=2147483647,__PRIVATE_QuadrupleBuilder.Fe=0xffffffffn,__PRIVATE_QuadrupleBuilder.je=[[1n,0x1999999999999999n,0x9999999999999999n,0x999999999999999an],[1n,0x3333333333333333n,0x3333333333333333n,0x3333333333333334n],[1n,0x6666666666666666n,0x6666666666666666n,0x6666666666666667n],[2n,0x28f5c28f5c28f5c2n,0x8f5c28f5c28f5c28n,0xf5c28f5c28f5c290n],[3n,0x4189374bc6a7ef9dn,0xb22d0e5604189374n,0xbc6a7ef9db22d0e6n],[5n,0xa7c5ac471b478423n,0x0fcf80dc33721d53n,0xcddd6e04c0592104n],[10n,0x6df37f675ef6eadfn,0x5ab9a2072d44268dn,0x97df837e6748956en],[20n,0x2f394219248446ban,0xa23d2ec729af3d61n,0x0607aa0167dd94cbn],[39n,0x571cbec554b60dbbn,0xd5f64baf0506840dn,0x451db70d5904029bn],[78n,0x1da48ce468e7c702n,0x6520247d3556476dn,0x1469caf6db224cfan],[155n,0x2252f0e5b39769dcn,0x9ae2eea30ca3ade0n,0xeeaa3c08dfe84e30n],[309n,0x2e055c9a3f6ba793n,0x16583a816eb60a59n,0x22c4b0826cf1ebf7n],[617n,0x52bb45e9cf23f17fn,0x7688c07606e50364n,0xb34479aa9d449a57n],[1234n,0x1abc81c8ff5f846cn,0x8f5e3c9853e38c97n,0x45060097f3bf9296n],[2467n,0x1bec53b510daa7b4n,0x48369ed77dbb0eb1n,0x3b05587b2187b41en],[4933n,0x1e75063a5ba91326n,0x8abfb8e460016ae3n,0x28008702d29e8a3cn],[9865n,0x243c5d8bb5c5fa55n,0x40c6d248c5881915n,0x4c0fd99fd5befc22n],[19729n,0x334a5570c3f4ef3cn,0xa13c36c43f979c90n,0xda7ac473555fb7a8n],[39457n,0x66c304445dd98f3bn,0xa8c293a20e47a41bn,0x4c5b03dc12604964n],[78914n,0x293ffbf5fb028cc4n,0x89d3e5ff44238406n,0x369a339e1bfe8c9bn],[157827n,0x427792fbb68e5d20n,0x7b297cd9fc154b62n,0xf09142114aa9a20cn],[315653n,0xac92bc65ad5c08fcn,0x00beeb115a566c19n,0x4ba882d8a4622437n],[631306n,0x745581440f92e80en,0x4da822cf7f896f41n,0x509d598678164ecdn],[1262612n,0x34dd99b4c69523a5n,0x64bc2e8f0d8b1044n,0xb03b1c96da5dd349n],[2525223n,0x6d2bbea9d6d25a08n,0xa0a4606a88e96b70n,0x182063bbc2fe8520n],[5050446n,0x2e8e47d63bfdd6e3n,0x2b55fa8976eaa3e9n,0x1a6b9d3086412a73n],[10100891n,0x54aa68efa1d719dfn,0xd8505806612c5c8fn,0xad068837fee8b43an],[20201782n,0x1c00464ccb7bae77n,0x9e3877784c77982cn,0xd94af3b61717404fn],[40403563n,0x1ea099c8be2b6cd0n,0x8bfb6d539fa50466n,0x6d3bc37e69a84218n],[80807125n,0x24a457f466ce8d18n,0xf2c8f3b81bc6bb59n,0xa78c757692e02d49n],[161614249n,0x347256677aba6b53n,0x3fbf90d30611a67cn,0x1e039d87e0bdb32bn],[323228497n,0x6b727daf0fd3432an,0x71f71121f9e4200fn,0x8fcd9942d486c10cn],[646456994n,0x2d18e84484d91f78n,0x4079bfe7829dec6fn,0x21551643e365abc6n]],__PRIVATE_QuadrupleBuilder.Ke=[[1n,0x1999999999999999n,0x9999999999999999n,0x999999999999999an],[0n,0x8000000000000000n,0x0000000000000000n,0x0000000000000000n],[0n,0x4000000000000000n,0x0000000000000000n,0x0000000000000001n],[-1n,0xa000000000000000n,0x0000000000000000n,0x0000000000000000n],[-2n,0x6400000000000000n,0x0000000000000000n,0x0000000000000000n],[-4n,0x2710000000000000n,0x0000000000000000n,0x0000000000000001n],[-9n,0x3b9aca0000000000n,0x0000000000000000n,0x0000000000000001n],[-19n,0x8ac7230489e80000n,0x0000000000000000n,0x0000000000000000n],[-38n,0x4b3b4ca85a86c47an,0x098a224000000000n,0x0000000000000001n],[-77n,0xdd15fe86affad912n,0x49ef0eb713f39eben,0xaa987b6e6fd2a002n],[-154n,0xbeeefb584aff8603n,0xaafb550ffacfd8fan,0x5ca47e4f88d45371n],[-308n,0x8e679c2f5e44ff8fn,0x570f09eaa7ea7648n,0x5961db50c6d2b888n],[-616n,0x4f371b3399fc2ab0n,0x8170041c9feb05aan,0xc7c343447c75bcf6n],[-1233n,0xf51e928179013fd3n,0xde4bd12cde4d985cn,0x4a573ca6f94bff14n],[-2466n,0xeab388127bccaff7n,0x1667639142b9fbaen,0x775ec9995e1039fbn],[-4932n,0xd72cb2a95c7ef6ccn,0xe81bf1e825ba7515n,0xc2feb521d6cb5dcdn],[-9864n,0xb4dc1be6604502dcn,0xd491079b8eef6535n,0x578d3965d24de84dn],[-19728n,0x7fc6447bee60ea43n,0x2548da5c8b125b27n,0x5f42d1142f41d349n],[-39456n,0x3fc65180f88af8fbn,0x6a6915f383349413n,0x063c3708b6ceb291n],[-78913n,0x9ee0197c8dcd55bfn,0x2b2b9b942c38f4a2n,0x0f8ba634e9c706aen],[-157826n,0x629963a25b8b2d79n,0xd00b9d2286f70876n,0xe97004700c3644fcn],[-315652n,0x25f9cc308ceef4f3n,0x40f19543911a4546n,0xa2cd389452cfc366n],[-631305n,0x385597b0d47e76b8n,0x1b9f67e103bf2329n,0xc3119848595985f7n],[-1262611n,0x7bf795d276c12f66n,0x66a61d62a446659an,0xa1a4d73bebf093d5n],[-2525222n,0x3c07d96ab1ed7799n,0xcb7355c22cc05ac0n,0x4ffc0ab73b1f6a49n],[-5050445n,0x8cc4cd8c3edefb9an,0x6c8ff86a90a97e0cn,0x166cfddbf98b71bfn],[-10100890n,0x4d67d81cc88e1228n,0x1d7cfb06666b79b3n,0x7b916728aaa4e70dn],[-20201781n,0xea0c55494e7a552dn,0xb88cb9484bb86c61n,0x8d44893c610bb7dfn],[-40403562n,0xd5fa8c821ec0c24an,0xa80e46e764e0f8b0n,0xa7276bfa432fac7en],[-80807124n,0xb2dae307426f6791n,0xc970b82f58b12918n,0x0472592f7f39190en],[-161614248n,0x7cf51edd8a15f1c9n,0x656dab3498f8e697n,0x12daa2a80e53c807n],[-323228496n,0x3cfe609ab5883c50n,0xbec8b5d22b198871n,0xe18477703b4622b4n],[-646456993n,0x9152447b9d7cda9an,0x3b4d3f6110d77aadn,0xfa81bad1c394adb4n]];class __PRIVATE_Quadruple{constructor(e,i,s,T){this.negative=e,this.st=i,this.Ve=s,this.Te=T}exponent(){return this.st-__PRIVATE_QuadrupleBuilder.Ue}ot(){return 0===this.st&&0n===this.Ve&&0n===this.Te}ut(){return this.st===__classPrivateFieldGet(__PRIVATE_Quadruple,we,"f",ve)&&0n===this.Ve&&0n===this.Te}isNaN(){return this.st===__classPrivateFieldGet(__PRIVATE_Quadruple,we,"f",ve)&&!(0n===this.Ve&&0n===this.Te)}compareTo(e){if(this.isNaN())return e.isNaN()?0:1;if(e.isNaN())return-1;let i,s;if(this.negative){if(!e.negative)return-1;i=1,s=-1}else{if(e.negative)return 1;i=-1,s=1}return this.st<e.st?i:this.st>e.st?s:this.Ve<e.Ve?i:this.Ve>e.Ve?s:this.Te<e.Te?i:this.Te>e.Te?s:0}debug(){return(this.negative?"+":"-")+__classPrivateFieldGet(__PRIVATE_Quadruple,we,"m",Se).call(__PRIVATE_Quadruple,this.Ve)+__classPrivateFieldGet(__PRIVATE_Quadruple,we,"m",Se).call(__PRIVATE_Quadruple,this.Te)+"*2^"+this.exponent()}static fromNumber(e){if(isNaN(e))return __PRIVATE_Quadruple.NaN;if(!isFinite(e))return e<0?__PRIVATE_Quadruple._t:__PRIVATE_Quadruple.ct;if(0===e)return Math.sign(1/e)>0?__PRIVATE_Quadruple.lt:__PRIVATE_Quadruple.ft;const i=new DataView(new ArrayBuffer(8));i.setFloat64(0,e);const s=i.getBigUint64(0);let T=BigInt.asUintN(64,s<<12n),E=2047&Number(s>>52n);if(0===E){const e=__PRIVATE_QuadrupleBuilder.et(T);T=e<63?T<<BigInt(e+1):0n,E=-e}return new __PRIVATE_Quadruple(e<0,__classPrivateFieldGet(__PRIVATE_Quadruple,we,"m",Ne).call(__PRIVATE_Quadruple,E-1023),T,0n)}static fromString(e){if("NaN"===e)return __PRIVATE_Quadruple.NaN;if("-Infinity"===e)return __PRIVATE_Quadruple._t;if("Infinity"===e||"+Infinity"===e)return __PRIVATE_Quadruple.ct;const i=new Array(e.length).fill(0);let s=0,T=0,E=0,V=!1;for("-"===e[s]?(V=!0,s++):"+"===e[s]&&s++;__classPrivateFieldGet(__PRIVATE_Quadruple,we,"m",xe).call(__PRIVATE_Quadruple,e,s);)i[T++]=__classPrivateFieldGet(__PRIVATE_Quadruple,we,"m",Fe).call(__PRIVATE_Quadruple,e,s++);if("."===e[s]){const V=++s;for(;__classPrivateFieldGet(__PRIVATE_Quadruple,we,"m",xe).call(__PRIVATE_Quadruple,e,s);)i[T++]=__classPrivateFieldGet(__PRIVATE_Quadruple,we,"m",Fe).call(__PRIVATE_Quadruple,e,s++);E=V-s}if("e"===e[s]||"E"===e[s]){let i=0;s++;let T=1;"-"===e[s]?(T=-1,s++):"+"===e[s]&&s++;const V=s;for(;__classPrivateFieldGet(__PRIVATE_Quadruple,we,"m",xe).call(__PRIVATE_Quadruple,e,s);)if(i=10*i+__classPrivateFieldGet(__PRIVATE_Quadruple,we,"m",Fe).call(__PRIVATE_Quadruple,e,s++),s-V>9)throw new Error("Exponent too large "+e);if(s===V)throw new Error("Invalid number "+e);E+=i*T}if(0===T||s!==e.length)throw new Error("Invalid number "+e);const R=__PRIVATE_QuadrupleBuilder.ye(i.slice(0,T),E);return new __PRIVATE_Quadruple(V,R.exponent,R.Ve,R.Te)}}we=__PRIVATE_Quadruple,Se=function ___PRIVATE_Quadruple_hex(e){return e.toString(16).padStart(16,"0")},xe=function ___PRIVATE_Quadruple_isDigit(e,i){const s=e.codePointAt(i);return void 0!==s&&s>=48&&s<=57},Fe=function ___PRIVATE_Quadruple_digit(e,i){return e.codePointAt(i)-48},Ne=function ___PRIVATE_Quadruple_bias(e){return e+__PRIVATE_QuadrupleBuilder.Ue},ve={value:Number(__PRIVATE_QuadrupleBuilder.Fe)},__PRIVATE_Quadruple.lt=new __PRIVATE_Quadruple(!1,0,0n,0n),__PRIVATE_Quadruple.ft=new __PRIVATE_Quadruple(!0,0,0n,0n),__PRIVATE_Quadruple.NaN=new __PRIVATE_Quadruple(!1,__classPrivateFieldGet(__PRIVATE_Quadruple,we,"f",ve),1n<<63n,0n),__PRIVATE_Quadruple._t=new __PRIVATE_Quadruple(!0,__classPrivateFieldGet(__PRIVATE_Quadruple,we,"f",ve),0n,0n),__PRIVATE_Quadruple.ct=new __PRIVATE_Quadruple(!1,__classPrivateFieldGet(__PRIVATE_Quadruple,we,"f",ve),0n,0n),new __PRIVATE_Quadruple(!0,__classPrivateFieldGet(__PRIVATE_Quadruple,we,"m",Ne).call(__PRIVATE_Quadruple,63),0n,0n),new __PRIVATE_Quadruple(!1,__classPrivateFieldGet(__PRIVATE_Quadruple,we,"m",Ne).call(__PRIVATE_Quadruple,0),0n,0n),new __PRIVATE_Quadruple(!0,__classPrivateFieldGet(__PRIVATE_Quadruple,we,"m",Ne).call(__PRIVATE_Quadruple,0),0n,0n);const ke=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function __PRIVATE_normalizeTimestamp(e){if(__PRIVATE_hardAssert(!!e,39018),"string"==typeof e){let i=0;const s=ke.exec(e);if(__PRIVATE_hardAssert(!!s,46558,{timestamp:e}),s[1]){let e=s[1];e=(e+"000000000").substr(0,9),i=Number(e)}const T=new Date(e);return{seconds:Math.floor(T.getTime()/1e3),nanos:i}}return{seconds:__PRIVATE_normalizeNumber(e.seconds),nanos:__PRIVATE_normalizeNumber(e.nanos)}}function __PRIVATE_normalizeNumber(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function __PRIVATE_normalizeByteString(e){return"string"==typeof e?ByteString.fromBase64String(e):ByteString.fromUint8Array(e)}function property(e,i){const s={typeString:e};return i&&(s.value=i),s}function __PRIVATE_validateJSON(e,i){if(!__PRIVATE_isPlainObject(e))throw new k(re,"JSON must be an object");let s;for(const T in i)if(i[T]){const E=i[T].typeString,V="value"in i[T]?{value:i[T].value}:void 0,R=i[T].optional;if(!(T in e)){if(R)continue;s=`JSON missing required field: '${T}'`;break}const N=e[T];if(E&&typeof N!==E){s=`JSON field '${T}' must be a ${E}.`;break}if(void 0!==V&&N!==V.value){s=`Expected '${T}' field to equal '${V.value}'`;break}}if(s)throw new k(re,s);return!0}const Ce=-62135596800,De=1e6;class Timestamp{static now(){return Timestamp.fromMillis(Date.now())}static fromDate(e){return Timestamp.fromMillis(e.getTime())}static fromMillis(e){const i=Math.floor(e/1e3),s=Math.floor((e-1e3*i)*De);return new Timestamp(i,s)}static fromInstant(e){if(!e||"bigint"!=typeof e.ht)throw new k(re,"Invalid Temporal.Instant object provided.");return Timestamp._fromEpochNanoseconds(e.ht)}static _fromEpochNanoseconds(e){let i,s;if(e>=0n)i=Number(e/1000000000n),s=Number(e%1000000000n);else{const T=e%1000000000n;0n===T?(i=Number(e/1000000000n),s=0):(i=Number(e/1000000000n-1n),s=Number(T+1000000000n))}return new Timestamp(i,s)}constructor(e,i){if(this.seconds=e,this.nanoseconds=i,i<0)throw new k(re,"Timestamp nanoseconds out of range: "+i);if(i>=1e9)throw new k(re,"Timestamp nanoseconds out of range: "+i);if(e<Ce)throw new k(re,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new k(re,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/De}toInstant(){if("undefined"==typeof Temporal||!Temporal.Instant)throw new k(le,"The Temporal object is not available in the current environment.");const e=1000000000n*BigInt(this.seconds)+BigInt(this.nanoseconds);return Temporal.Instant.__PRIVATE_fromEpochNanoseconds(e)}_compareTo(e){return this.seconds===e.seconds?__PRIVATE_primitiveComparator(this.nanoseconds,e.nanoseconds):__PRIVATE_primitiveComparator(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:Timestamp._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(__PRIVATE_validateJSON(e,Timestamp._jsonSchema))return new Timestamp(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-Ce;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}}function __PRIVATE_isServerTimestamp(e){const i=(e?.mapValue?.fields||{}).__type__?.stringValue;return"server_timestamp"===i}function __PRIVATE_getPreviousValue(e){const i=e.mapValue.fields.__previous_value__;return __PRIVATE_isServerTimestamp(i)?__PRIVATE_getPreviousValue(i):i}function __PRIVATE_getLocalWriteTime(e){const i=__PRIVATE_normalizeTimestamp(e.mapValue.fields.__local_write_time__.timestampValue);return new Timestamp(i.seconds,i.nanos)}Timestamp._jsonSchemaVersion="firestore/timestamp/1.0",Timestamp._jsonSchema={type:property("string",Timestamp._jsonSchemaVersion),seconds:property("number"),nanoseconds:property("number")};const Be="__type__",Oe="__vector__",Me="value",Qe="server_timestamp",Le="__min__",qe="__max__",je="__regex__",Ue="pattern",ze="options",$e="__oid__",We="__int__",Ge="__decimal128__",Ke="__request_timestamp__",He="seconds",Je="increment",Ye="__binary__",Xe={};var Ze,rt;(rt=Ze||(Ze={})).dt="regexValue",rt.Et="bsonObjectIdValue",rt.Vt="int32Value",rt.Tt="decimal128Value",rt.It="bsonTimestampValue",rt.At="bsonBinaryValue",rt.Rt="minKeyValue",rt.Pt="maxKeyValue",rt.yt="maxValue",rt.bt="vectorValue",rt.wt="serverTimestampValue",rt.gt="regularMapValue";const nt={[Oe]:Ze.bt,[qe]:Ze.yt,[Qe]:Ze.wt},at={[je]:Ze.dt,[$e]:Ze.Et,[We]:Ze.Vt,[Ge]:Ze.Tt,[Ke]:Ze.It,[Ye]:Ze.At,[Le]:Ze.Rt,[qe]:Ze.Pt};function __PRIVATE_typeOrder(e){if("nullValue"in e)return 0;if("booleanValue"in e)return 2;if("integerValue"in e||"doubleValue"in e)return 3;if("timestampValue"in e)return 4;if("stringValue"in e)return 7;if("bytesValue"in e)return 8;if("referenceValue"in e)return 9;if("geoPointValue"in e)return 11;if("arrayValue"in e)return 13;if(!("mapValue"in e))return z(28295,{value:e});{const i=function __PRIVATE_detectMapRepresentation(e){if(!e.mapValue?.fields)return Ze.gt;const i=e.mapValue.fields,s=i[Be]?.stringValue;if(s&&nt[s])return nt[s];if(1===__PRIVATE_objectSize(i)){const e=Object.keys(i);return at[e[0]]??Ze.gt}return Ze.gt}(e);switch(i){case Ze.wt:return 6;case Ze.yt:return 9007199254740991;case Ze.bt:return 14;case Ze.dt:return 12;case Ze.Et:return 10;case Ze.Vt:case Ze.Tt:return 3;case Ze.It:return 5;case Ze.At:return 8;case Ze.Rt:return 1;case Ze.Pt:return 16;default:return 15}}}function __PRIVATE_valueEquals(e,i,s){if(e===i)return!0;const T=__PRIVATE_typeOrder(e);if(T!==__PRIVATE_typeOrder(i))return!1;switch(T){case 0:case 9007199254740991:case 16:case 1:return!0;case 2:return e.booleanValue===i.booleanValue;case 6:return __PRIVATE_getLocalWriteTime(e).isEqual(__PRIVATE_getLocalWriteTime(i));case 4:return function __PRIVATE_timestampEquals(e,i){if("string"==typeof e.timestampValue&&"string"==typeof i.timestampValue&&e.timestampValue.length===i.timestampValue.length)return e.timestampValue===i.timestampValue;const s=__PRIVATE_normalizeTimestamp(e.timestampValue),T=__PRIVATE_normalizeTimestamp(i.timestampValue);return s.seconds===T.seconds&&s.nanos===T.nanos}(e,i);case 7:return e.stringValue===i.stringValue;case 8:return function __PRIVATE_blobEquals(e,i){return 0===__PRIVATE_compareBlobsAndSubtype(e,i)}(e,i);case 9:return e.referenceValue===i.referenceValue;case 11:return function __PRIVATE_geoPointEquals(e,i){return __PRIVATE_normalizeNumber(e.geoPointValue.latitude)===__PRIVATE_normalizeNumber(i.geoPointValue.latitude)&&__PRIVATE_normalizeNumber(e.geoPointValue.longitude)===__PRIVATE_normalizeNumber(i.geoPointValue.longitude)}(e,i);case 3:return function __PRIVATE_numberEquals(e,i,s){if(__PRIVATE_isDecimal128Value(e)&&__PRIVATE_isDecimal128Value(i))return 0===__PRIVATE_compareQuadruples(e,i);if("integerValue"in e&&"integerValue"in i||__PRIVATE_isInt32Value(e)&&__PRIVATE_isInt32Value(i))return __PRIVATE_extractNumber(e)===__PRIVATE_extractNumber(i);let T,E;return"doubleValue"in e&&"doubleValue"in i&&(T=__PRIVATE_normalizeNumber(e.doubleValue),E=__PRIVATE_normalizeNumber(i.doubleValue),T===E?__PRIVATE_isNegativeZero(T)===__PRIVATE_isNegativeZero(E):!(void 0!==s&&!s.vt)&&isNaN(T)&&isNaN(E))}(e,i,s);case 13:return __PRIVATE_arrayEquals(e.arrayValue.values||[],i.arrayValue.values||[],((e,i)=>__PRIVATE_valueEquals(e,i,s)));case 14:case 15:return function __PRIVATE_objectEquals(e,i,s){const T=e.mapValue.fields||{},E=i.mapValue.fields||{};if(__PRIVATE_objectSize(T)!==__PRIVATE_objectSize(E))return!1;for(const e in T)if(T.hasOwnProperty(e)&&(void 0===E[e]||!__PRIVATE_valueEquals(T[e],E[e],s)))return!1;return!0}(e,i,s);case 5:return 0===__PRIVATE_compareBsonTimestamps(e,i);case 12:return 0===__PRIVATE_compareRegex(e,i);case 10:return 0===__PRIVATE_compareBsonObjectIds(e,i);default:return z(52216,{left:e})}}function __PRIVATE_arrayValueContains(e,i){return void 0!==(e.values||[]).find((e=>__PRIVATE_valueEquals(e,i)))}function __PRIVATE_valueCompare(e,i){if(e===i)return 0;const s=__PRIVATE_typeOrder(e),T=__PRIVATE_typeOrder(i);if(s!==T)return __PRIVATE_primitiveComparator(s,T);switch(s){case 0:case 1:case 16:case 9007199254740991:return 0;case 2:return __PRIVATE_primitiveComparator(e.booleanValue,i.booleanValue);case 3:return __PRIVATE_compareNumbers(e,i);case 4:return __PRIVATE_compareTimestamps(e.timestampValue,i.timestampValue);case 6:return __PRIVATE_compareTimestamps(__PRIVATE_getLocalWriteTime(e),__PRIVATE_getLocalWriteTime(i));case 7:return __PRIVATE_compareUtf8Strings(e.stringValue,i.stringValue);case 8:return __PRIVATE_compareBlobsAndSubtype(e,i);case 9:return function __PRIVATE_compareReferences(e,i){const s=e.split("/"),T=i.split("/");for(let e=0;e<s.length&&e<T.length;e++){const i=__PRIVATE_primitiveComparator(s[e],T[e]);if(0!==i)return i}return __PRIVATE_primitiveComparator(s.length,T.length)}(e.referenceValue,i.referenceValue);case 11:return function __PRIVATE_compareGeoPoints(e,i){const s=__PRIVATE_primitiveComparator(__PRIVATE_normalizeNumber(e.latitude),__PRIVATE_normalizeNumber(i.latitude));return 0!==s?s:__PRIVATE_primitiveComparator(__PRIVATE_normalizeNumber(e.longitude),__PRIVATE_normalizeNumber(i.longitude))}(e.geoPointValue,i.geoPointValue);case 13:return __PRIVATE_compareArrays(e.arrayValue,i.arrayValue);case 14:return function __PRIVATE_compareVectors(e,i){const s=e.fields||{},T=i.fields||{},E=s[Me]?.arrayValue,V=T[Me]?.arrayValue,R=__PRIVATE_primitiveComparator(E?.values?.length||0,V?.values?.length||0);return 0!==R?R:__PRIVATE_compareArrays(E,V)}(e.mapValue,i.mapValue);case 15:return function __PRIVATE_compareMaps(e,i){if(e===Xe&&i===Xe)return 0;if(e===Xe)return 1;if(i===Xe)return-1;const s=e.fields||{},T=Object.keys(s),E=i.fields||{},V=Object.keys(E);T.sort(),V.sort();for(let e=0;e<T.length&&e<V.length;++e){const i=__PRIVATE_compareUtf8Strings(T[e],V[e]);if(0!==i)return i;const R=__PRIVATE_valueCompare(s[T[e]],E[V[e]]);if(0!==R)return R}return __PRIVATE_primitiveComparator(T.length,V.length)}(e.mapValue,i.mapValue);case 5:return __PRIVATE_compareBsonTimestamps(e,i);case 12:return __PRIVATE_compareRegex(e,i);case 10:return __PRIVATE_compareBsonObjectIds(e,i);default:throw z(23264,{xt:s})}}function __PRIVATE_extractNumber(e){let i;return i=__PRIVATE_isInt32Value(e)?e.mapValue.fields[We].integerValue:e.integerValue||e.doubleValue,__PRIVATE_normalizeNumber(i)}function __PRIVATE_getDecimal128StringValue(e){return e.mapValue.fields[Ge].stringValue}function __PRIVATE_compareNumbers(e,i){if(__PRIVATE_isDecimal128Value(e)||__PRIVATE_isDecimal128Value(i))return __PRIVATE_compareQuadruples(e,i);const s=__PRIVATE_extractNumber(e),T=__PRIVATE_extractNumber(i);return isNaN(s)?isNaN(T)?0:-1:isNaN(T)?1:__PRIVATE_primitiveComparator(s,T)}function __PRIVATE_compareQuadruples(e,i){const s=__PRIVATE_convertNumberToQuadruple(e),T=__PRIVATE_convertNumberToQuadruple(i);return s.ot()&&T.ot()?0:s.isNaN()?T.isNaN()?0:-1:T.isNaN()?1:s.compareTo(T)}function __PRIVATE_convertNumberToQuadruple(e){return __PRIVATE_isDecimal128Value(e)?__PRIVATE_Quadruple.fromString(__PRIVATE_getDecimal128StringValue(e)):__PRIVATE_Quadruple.fromNumber(__PRIVATE_extractNumber(e))}function __PRIVATE_compareTimestamps(e,i){if("string"==typeof e&&"string"==typeof i&&e.length===i.length)return __PRIVATE_primitiveComparator(e,i);const s=__PRIVATE_normalizeTimestamp(e),T=__PRIVATE_normalizeTimestamp(i),E=__PRIVATE_primitiveComparator(s.seconds,T.seconds);return 0!==E?E:__PRIVATE_primitiveComparator(s.nanos,T.nanos)}function __PRIVATE_compareArrays(e,i){const s=e.values||[],T=i.values||[];for(let e=0;e<s.length&&e<T.length;++e){const i=__PRIVATE_valueCompare(s[e],T[e]);if(void 0!==i&&0!==i)return i}return __PRIVATE_primitiveComparator(s.length,T.length)}function __PRIVATE_compareBsonTimestamps(e,i){const s=e.mapValue.fields?.[Ke].mapValue?.fields?.[He],T=i.mapValue.fields?.[Ke].mapValue?.fields?.[He],E=e.mapValue.fields?.[Ke].mapValue?.fields?.[Je],V=i.mapValue.fields?.[Ke].mapValue?.fields?.[Je],R=__PRIVATE_compareNumbers(s,T);return 0!==R?R:__PRIVATE_compareNumbers(E,V)}function __PRIVATE_getBytesAndSubtype(e){if("bytesValue"in e)return{subtype:0,bytes:__PRIVATE_normalizeByteString(e.bytesValue)};const i=e.mapValue?.fields,s=i?.[Ye],T=s?.bytesValue;if(!T)throw new Error("Received incorrect value for BsonBinaryData");const E=__PRIVATE_normalizeByteString(T).toUint8Array();if(0===E.length)throw new Error("Received empty bytesValue for BsonBinaryData");const V=E[0],R=E.slice(1);return{subtype:V,bytes:ByteString.fromUint8Array(R)}}function __PRIVATE_compareBlobsAndSubtype(e,i){const s=__PRIVATE_getBytesAndSubtype(e),T=__PRIVATE_getBytesAndSubtype(i);return s.subtype!==T.subtype?s.subtype<T.subtype?-1:1:s.bytes.compareTo(T.bytes)}function __PRIVATE_compareRegex(e,i){const s=e.mapValue.fields,T=s?.[je]?.mapValue?.fields?.[Ue]?.stringValue??"",E=s?.[je]?.mapValue?.fields?.[ze]?.stringValue??"",V=i.mapValue.fields,R=V?.[je]?.mapValue?.fields?.[Ue]?.stringValue??"",N=V?.[je]?.mapValue?.fields?.[ze]?.stringValue??"",M=__PRIVATE_compareUtf8Strings(T,R);return 0!==M?M:__PRIVATE_primitiveComparator(E,N)}function __PRIVATE_compareBsonObjectIds(e,i){return __PRIVATE_compareUtf8Strings(e.mapValue.fields?.[$e]?.stringValue??"",i.mapValue.fields?.[$e]?.stringValue??"")}function __PRIVATE_refValue(e,i){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${i.path.canonicalString()}`}}function __PRIVATE_isDecimal128Value(e){if(!e.mapValue?.fields)return!1;const i=e.mapValue.fields;return 1===__PRIVATE_objectSize(i)&&i[Ge]&&!!i[Ge].stringValue}function __PRIVATE_isInt32Value(e){if(!e.mapValue?.fields)return!1;const i=e.mapValue.fields;return 1===__PRIVATE_objectSize(i)&&void 0!==i[We]?.integerValue}function isArray(e){return!!e&&"arrayValue"in e}function __PRIVATE_isNullValue(e){return!!e&&"nullValue"in e}function __PRIVATE_isNanValue(e){return!(!function __PRIVATE_isDoubleValue(e){return!!e&&"doubleValue"in e}(e)||!isNaN(Number(e.doubleValue)))||!(!__PRIVATE_isDecimal128Value(e)||"NaN"!==__PRIVATE_getDecimal128StringValue(e))}function __PRIVATE_isMapValue(e){return!!e&&"mapValue"in e}function __PRIVATE_deepClone(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:{...e.timestampValue}};if(e.mapValue){const i={mapValue:{fields:{}}};return forEach(e.mapValue.fields,((e,s)=>i.mapValue.fields[e]=__PRIVATE_deepClone(s))),i}if(e.arrayValue){const i={arrayValue:{values:[]}};for(let s=0;s<(e.arrayValue.values||[]).length;++s)i.arrayValue.values[s]=__PRIVATE_deepClone(e.arrayValue.values[s]);return i}return{...e}}new Set(Object.values(at));class Bound{constructor(e,i){this.position=e,this.inclusive=i}}function __PRIVATE_boundEquals(e,i){if(null===e)return null===i;if(null===i)return!1;if(e.inclusive!==i.inclusive||e.position.length!==i.position.length)return!1;for(let s=0;s<e.position.length;s++)if(!__PRIVATE_valueEquals(e.position[s],i.position[s]))return!1;return!0}class Filter{}class FieldFilter extends Filter{constructor(e,i,s){super(),this.field=e,this.op=i,this.value=s}static create(e,i,s){return e.isKeyField()?"in"===i||"not-in"===i?this.createKeyFieldInFilter(e,i,s):new __PRIVATE_KeyFieldFilter(e,i,s):"array-contains"===i?new __PRIVATE_ArrayContainsFilter(e,s):"in"===i?new __PRIVATE_InFilter(e,s):"not-in"===i?new __PRIVATE_NotInFilter(e,s):"array-contains-any"===i?new __PRIVATE_ArrayContainsAnyFilter(e,s):new FieldFilter(e,i,s)}static createKeyFieldInFilter(e,i,s){return"in"===i?new __PRIVATE_KeyFieldInFilter(e,s):new __PRIVATE_KeyFieldNotInFilter(e,s)}matches(e){const i=e.data.field(this.field);return"!="===this.op?null!==i&&void 0===i.nullValue&&this.matchesComparison(__PRIVATE_valueCompare(i,this.value)):null!==i&&__PRIVATE_typeOrder(this.value)===__PRIVATE_typeOrder(i)&&this.matchesComparison(__PRIVATE_valueCompare(i,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return z(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class CompositeFilter extends Filter{constructor(e,i){super(),this.filters=e,this.op=i,this.Dt=null}static create(e,i){return new CompositeFilter(e,i)}matches(e){return function __PRIVATE_compositeFilterIsConjunction(e){return"and"===e.op}(this)?void 0===this.filters.find((i=>!i.matches(e))):void 0!==this.filters.find((i=>i.matches(e)))}getFlattenedFilters(){return null!==this.Dt||(this.Dt=this.filters.reduce(((e,i)=>e.concat(i.getFlattenedFilters())),[])),this.Dt}getFilters(){return Object.assign([],this.filters)}}function __PRIVATE_filterEquals(e,i){return e instanceof FieldFilter?function __PRIVATE_fieldFilterEquals(e,i){return i instanceof FieldFilter&&e.op===i.op&&e.field.isEqual(i.field)&&__PRIVATE_valueEquals(e.value,i.value)}(e,i):e instanceof CompositeFilter?function __PRIVATE_compositeFilterEquals(e,i){return i instanceof CompositeFilter&&e.op===i.op&&e.filters.length===i.filters.length&&e.filters.reduce(((e,s,T)=>e&&__PRIVATE_filterEquals(s,i.filters[T])),!0)}(e,i):void z(19439)}class __PRIVATE_KeyFieldFilter extends FieldFilter{constructor(e,i,s){super(e,i,s),this.key=S.fromName(s.referenceValue)}matches(e){const i=S.comparator(e.key,this.key);return this.matchesComparison(i)}}class __PRIVATE_KeyFieldInFilter extends FieldFilter{constructor(e,i){super(e,"in",i),this.keys=__PRIVATE_extractDocumentKeysFromArrayValue("in",i)}matches(e){return this.keys.some((i=>i.isEqual(e.key)))}}class __PRIVATE_KeyFieldNotInFilter extends FieldFilter{constructor(e,i){super(e,"not-in",i),this.keys=__PRIVATE_extractDocumentKeysFromArrayValue("not-in",i)}matches(e){return!this.keys.some((i=>i.isEqual(e.key)))}}function __PRIVATE_extractDocumentKeysFromArrayValue(e,i){return(i.arrayValue?.values||[]).map((e=>S.fromName(e.referenceValue)))}class __PRIVATE_ArrayContainsFilter extends FieldFilter{constructor(e,i){super(e,"array-contains",i)}matches(e){const i=e.data.field(this.field);return isArray(i)&&__PRIVATE_arrayValueContains(i.arrayValue,this.value)}}class __PRIVATE_InFilter extends FieldFilter{constructor(e,i){super(e,"in",i)}matches(e){const i=e.data.field(this.field);return null!==i&&__PRIVATE_arrayValueContains(this.value.arrayValue,i)}}class __PRIVATE_NotInFilter extends FieldFilter{constructor(e,i){super(e,"not-in",i)}matches(e){if(__PRIVATE_arrayValueContains(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const i=e.data.field(this.field);return null!==i&&void 0===i.nullValue&&!__PRIVATE_arrayValueContains(this.value.arrayValue,i)}}class __PRIVATE_ArrayContainsAnyFilter extends FieldFilter{constructor(e,i){super(e,"array-contains-any",i)}matches(e){const i=e.data.field(this.field);return!(!isArray(i)||!i.arrayValue.values)&&i.arrayValue.values.some((e=>__PRIVATE_arrayValueContains(this.value.arrayValue,e)))}}class OrderBy{constructor(e,i="asc"){this.field=e,this.dir=i}}function __PRIVATE_orderByEquals(e,i){return e.dir===i.dir&&e.field.isEqual(i.field)}class j{static fromTimestamp(e){return new j(e)}static min(){return new j(new Timestamp(0,0))}static max(){return new j(new Timestamp(253402300799,999999999))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}class SortedMap{constructor(e,i){this.comparator=e,this.root=i||LLRBNode.EMPTY}insert(e,i){return new SortedMap(this.comparator,this.root.insert(e,i,this.comparator).copy(null,null,LLRBNode.BLACK,null,null))}remove(e){return new SortedMap(this.comparator,this.root.remove(e,this.comparator).copy(null,null,LLRBNode.BLACK,null,null))}get(e){let i=this.root;for(;!i.isEmpty();){const s=this.comparator(e,i.key);if(0===s)return i.value;s<0?i=i.left:s>0&&(i=i.right)}return null}indexOf(e){let i=0,s=this.root;for(;!s.isEmpty();){const T=this.comparator(e,s.key);if(0===T)return i+s.left.size;T<0?s=s.left:(i+=s.left.size+1,s=s.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(((i,s)=>(e(i,s),!1)))}toString(){const e=[];return this.inorderTraversal(((i,s)=>(e.push(`${i}:${s}`),!1))),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new SortedMapIterator(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new SortedMapIterator(this.root,e,this.comparator,!1)}getReverseIterator(){return new SortedMapIterator(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new SortedMapIterator(this.root,e,this.comparator,!0)}}class SortedMapIterator{constructor(e,i,s,T){this.isReverse=T,this.nodeStack=[];let E=1;for(;!e.isEmpty();)if(E=i?s(e.key,i):1,i&&T&&(E*=-1),E<0)e=this.isReverse?e.left:e.right;else{if(0===E){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const i={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 i}hasNext(){return this.nodeStack.length>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 LLRBNode{constructor(e,i,s,T,E){this.key=e,this.value=i,this.color=null!=s?s:LLRBNode.RED,this.left=null!=T?T:LLRBNode.EMPTY,this.right=null!=E?E:LLRBNode.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,i,s,T,E){return new LLRBNode(null!=e?e:this.key,null!=i?i:this.value,null!=s?s:this.color,null!=T?T:this.left,null!=E?E: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,i,s){let T=this;const E=s(e,T.key);return T=E<0?T.copy(null,null,null,T.left.insert(e,i,s),null):0===E?T.copy(null,i,null,null,null):T.copy(null,null,null,null,T.right.insert(e,i,s)),T.fixUp()}removeMin(){if(this.left.isEmpty())return LLRBNode.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,i){let s,T=this;if(i(e,T.key)<0)T.left.isEmpty()||T.left.isRed()||T.left.left.isRed()||(T=T.moveRedLeft()),T=T.copy(null,null,null,T.left.remove(e,i),null);else{if(T.left.isRed()&&(T=T.rotateRight()),T.right.isEmpty()||T.right.isRed()||T.right.left.isRed()||(T=T.moveRedRight()),0===i(e,T.key)){if(T.right.isEmpty())return LLRBNode.EMPTY;s=T.right.min(),T=T.copy(s.key,s.value,null,null,T.right.removeMin())}T=T.copy(null,null,null,null,T.right.remove(e,i))}return T.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=e.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){const e=this.copy(null,null,LLRBNode.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,LLRBNode.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),i=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,i)}checkMaxDepth(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw z(43730,{key:this.key,value:this.value});if(this.right.isRed())throw z(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw z(27949);return e+(this.isRed()?0:1)}}LLRBNode.EMPTY=null,LLRBNode.RED=!0,LLRBNode.BLACK=!1,LLRBNode.EMPTY=new class LLRBEmptyNode{constructor(){this.size=0}get key(){throw z(57766)}get value(){throw z(16141)}get color(){throw z(16727)}get left(){throw z(29726)}get right(){throw z(36894)}copy(e,i,s,T,E){return this}insert(e,i,s){return new LLRBNode(e,i)}remove(e,i){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 SortedSet{constructor(e){this.comparator=e,this.data=new SortedMap(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(((i,s)=>(e(i),!1)))}forEachInRange(e,i){const s=this.data.getIteratorFrom(e[0]);for(;s.hasNext();){const T=s.getNext();if(this.comparator(T.key,e[1])>=0)return;i(T.key)}}forEachWhile(e,i){let s;for(s=void 0!==i?this.data.getIteratorFrom(i):this.data.getIterator();s.hasNext();)if(!e(s.getNext().key))return}firstAfterOrEqual(e){const i=this.data.getIteratorFrom(e);return i.hasNext()?i.getNext().key:null}getIterator(){return new SortedSetIterator(this.data.getIterator())}getIteratorFrom(e){return new SortedSetIterator(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 i=this;return i.size<e.size&&(i=e,e=this),e.forEach((e=>{i=i.add(e)})),i}isEqual(e){if(!(e instanceof SortedSet))return!1;if(this.size!==e.size)return!1;const i=this.data.getIterator(),s=e.data.getIterator();for(;i.hasNext();){const e=i.getNext().key,T=s.getNext().key;if(0!==this.comparator(e,T))return!1}return!0}toArray(){const e=[];return this.forEach((i=>{e.push(i)})),e}toString(){const e=[];return this.forEach((i=>e.push(i))),"SortedSet("+e.toString()+")"}copy(e){const i=new SortedSet(this.comparator);return i.data=e,i}}class SortedSetIterator{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class FieldMask{constructor(e){this.fields=e,e.sort(Ve.comparator)}static empty(){return new FieldMask([])}unionWith(e){let i=new SortedSet(Ve.comparator);for(const e of this.fields)i=i.add(e);for(const s of e)i=i.add(s);return new FieldMask(i.toArray())}covers(e){for(const i of this.fields)if(i.isPrefixOf(e))return!0;return!1}isEqual(e){return __PRIVATE_arrayEquals(this.fields,e.fields,((e,i)=>e.isEqual(i)))}}class u{constructor(e){this.value=e}static empty(){return new u({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let i=this.value;for(let s=0;s<e.length-1;++s)if(i=(i.mapValue.fields||{})[e.get(s)],!__PRIVATE_isMapValue(i))return null;return i=(i.mapValue.fields||{})[e.lastSegment()],i||null}}set(e,i){this.getFieldsMap(e.popLast())[e.lastSegment()]=__PRIVATE_deepClone(i)}setAll(e){let i=Ve.emptyPath(),s={},T=[];e.forEach(((e,E)=>{if(!i.isImmediateParentOf(E)){const e=this.getFieldsMap(i);this.applyChanges(e,s,T),s={},T=[],i=E.popLast()}e?s[E.lastSegment()]=__PRIVATE_deepClone(e):T.push(E.lastSegment())}));const E=this.getFieldsMap(i);this.applyChanges(E,s,T)}delete(e){const i=this.field(e.popLast());__PRIVATE_isMapValue(i)&&i.mapValue.fields&&delete i.mapValue.fields[e.lastSegment()]}isEqual(e){return __PRIVATE_valueEquals(this.value,e.value)}getFieldsMap(e){let i=this.value;i.mapValue.fields||(i.mapValue={fields:{}});for(let s=0;s<e.length;++s){let T=i.mapValue.fields[e.get(s)];__PRIVATE_isMapValue(T)&&T.mapValue.fields||(T={mapValue:{fields:{}}},i.mapValue.fields[e.get(s)]=T),i=T}return i.mapValue.fields}applyChanges(e,i,s){forEach(i,((i,s)=>e[i]=s));for(const i of s)delete e[i]}clone(){return new u(__PRIVATE_deepClone(this.value))}}class MutableDocument{constructor(e,i,s,T,E,V,R){this.key=e,this.documentType=i,this.version=s,this.readTime=T,this.createTime=E,this.data=V,this.documentState=R}static newInvalidDocument(e){return new MutableDocument(e,0,j.min(),j.min(),j.min(),u.empty(),0)}static newFoundDocument(e,i,s,T){return new MutableDocument(e,1,i,j.min(),s,T,0)}static newNoDocument(e,i){return new MutableDocument(e,2,i,j.min(),j.min(),u.empty(),0)}static newUnknownDocument(e,i){return new MutableDocument(e,3,i,j.min(),j.min(),u.empty(),2)}convertToFoundDocument(e,i){return!this.createTime.isEqual(j.min())||2!==this.documentType&&0!==this.documentType||(this.createTime=e),this.version=e,this.documentType=1,this.data=i,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=u.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=u.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=j.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 MutableDocument&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new MutableDocument(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 __PRIVATE_TargetImpl{constructor(e,i=null,s=[],T=[],E=null,V=null,R=null){this.path=e,this.collectionGroup=i,this.orderBy=s,this.filters=T,this.limit=E,this.startAt=V,this.endAt=R,this.Nt=null}}function __PRIVATE_newTarget(e,i=null,s=[],T=[],E=null,V=null,R=null){return new __PRIVATE_TargetImpl(e,i,s,T,E,V,R)}class __PRIVATE_QueryImpl{constructor(e,i=null,s=[],T=[],E=null,V="F",R=null,N=null){this.path=e,this.collectionGroup=i,this.explicitOrderBy=s,this.filters=T,this.limit=E,this.limitType=V,this.startAt=R,this.endAt=N,this.St=null,this.Ct=null,this.Bt=null,this.startAt,this.endAt}}function __PRIVATE_isCollectionGroupQuery(e){return null!==e.collectionGroup}function __PRIVATE_queryNormalizedOrderBy(e){const i=__PRIVATE_debugCast(e);if(null===i.St){i.St=[];const e=new Set;for(const s of i.explicitOrderBy)i.St.push(s),e.add(s.field.canonicalString());const s=i.explicitOrderBy.length>0?i.explicitOrderBy[i.explicitOrderBy.length-1].dir:"asc",T=function __PRIVATE_getInequalityFilterFields(e){let i=new SortedSet(Ve.comparator);return e.filters.forEach((e=>{e.getFlattenedFilters().forEach((e=>{e.isInequality()&&(i=i.add(e.field))}))})),i}(i);T.forEach((T=>{e.has(T.canonicalString())||T.isKeyField()||i.St.push(new OrderBy(T,s))})),e.has(Ve.keyField().canonicalString())||i.St.push(new OrderBy(Ve.keyField(),s))}return i.St}function __PRIVATE_queryToTarget(e){const i=__PRIVATE_debugCast(e);return i.Ct||(i.Ct=__PRIVATE__queryToTarget(i,__PRIVATE_queryNormalizedOrderBy(e))),i.Ct}function __PRIVATE__queryToTarget(e,i){if("F"===e.limitType)return __PRIVATE_newTarget(e.path,e.collectionGroup,i,e.filters,e.limit,e.startAt,e.endAt);{i=i.map((e=>{const i="desc"===e.dir?"asc":"desc";return new OrderBy(e.field,i)}));const s=e.endAt?new Bound(e.endAt.position,e.endAt.inclusive):null,T=e.startAt?new Bound(e.startAt.position,e.startAt.inclusive):null;return __PRIVATE_newTarget(e.path,e.collectionGroup,i,e.filters,e.limit,s,T)}}function __PRIVATE_queryWithAddedFilter(e,i){const s=e.filters.concat([i]);return new __PRIVATE_QueryImpl(e.path,e.collectionGroup,e.explicitOrderBy.slice(),s,e.limit,e.limitType,e.startAt,e.endAt)}function __PRIVATE_toDouble(e,i){if(e.useProto3Json){if(isNaN(i))return{doubleValue:"NaN"};if(i===1/0)return{doubleValue:"Infinity"};if(i===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:__PRIVATE_isNegativeZero(i)?"-0":i}}function __PRIVATE_toInteger(e){return{integerValue:""+e}}function toNumber(e,i,s){return function isSafeInteger(e){return"number"==typeof e&&Number.isInteger(e)&&!__PRIVATE_isNegativeZero(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}(i)?__PRIVATE_toInteger(i):__PRIVATE_toDouble(e,i)}class TransformOperation{constructor(){this._=void 0}}class __PRIVATE_ServerTimestampTransform extends TransformOperation{}class __PRIVATE_ArrayUnionTransformOperation extends TransformOperation{constructor(e){super(),this.elements=e}}class __PRIVATE_ArrayRemoveTransformOperation extends TransformOperation{constructor(e){super(),this.elements=e}}class __PRIVATE_NumericTransformOperation extends TransformOperation{constructor(e,i){super(),this.serializer=e,this.Qt=i}}class __PRIVATE_NumericIncrementTransformOperation extends __PRIVATE_NumericTransformOperation{}class __PRIVATE_NumericMinimumTransformOperation extends __PRIVATE_NumericTransformOperation{}class __PRIVATE_NumericMaximumTransformOperation extends __PRIVATE_NumericTransformOperation{}class FieldTransform{constructor(e,i){this.field=e,this.transform=i}}class P{constructor(e,i){this.updateTime=e,this.exists=i}static none(){return new P}static exists(e){return new P(void 0,e)}static updateTime(e){return new P(e)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}class Mutation{}class __PRIVATE_SetMutation extends Mutation{constructor(e,i,s,T=[]){super(),this.key=e,this.value=i,this.precondition=s,this.fieldTransforms=T,this.type=0}getFieldMask(){return null}}class __PRIVATE_PatchMutation extends Mutation{constructor(e,i,s,T,E=[]){super(),this.key=e,this.data=i,this.fieldMask=s,this.precondition=T,this.fieldTransforms=E,this.type=1}getFieldMask(){return this.fieldMask}}class F extends Mutation{constructor(e,i){super(),this.key=e,this.precondition=i,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class q extends Mutation{constructor(e,i){super(),this.key=e,this.precondition=i,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}const ot={asc:"ASCENDING",desc:"DESCENDING"},ut={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},lt={and:"AND",or:"OR"};class JsonProtoSerializer{constructor(e,i){this.databaseId=e,this.useProto3Json=i}}function toTimestamp(e,i){return e.useProto3Json?`${new Date(1e3*i.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+i.nanoseconds).slice(-9)}Z`:{seconds:""+i.seconds,nanos:i.nanoseconds}}function __PRIVATE_toBytes(e,i){return e.useProto3Json?i.toBase64():i.toUint8Array()}function __PRIVATE_toVersion(e,i){return toTimestamp(e,i.toTimestamp())}function __PRIVATE_fromVersion(e){return __PRIVATE_hardAssert(!!e,49232),j.fromTimestamp(function fromTimestamp(e){const i=__PRIVATE_normalizeTimestamp(e);return new Timestamp(i.seconds,i.nanos)}(e))}function __PRIVATE_toResourceName(e,i){return __PRIVATE_toResourcePath(e,i).canonicalString()}function __PRIVATE_toResourcePath(e,i){const s=function __PRIVATE_fullyQualifiedPrefixPath(e){return new ResourcePath(["projects",e.projectId,"databases",e.database])}(e).child("documents");return void 0===i?s:s.child(i)}function __PRIVATE_toName(e,i){return __PRIVATE_toResourceName(e.databaseId,i.path)}function fromName(e,i){const s=function __PRIVATE_fromResourceName(e){const i=ResourcePath.fromString(e);return __PRIVATE_hardAssert(__PRIVATE_isValidResourceName(i),10190,{key:i.toString()}),i}(i);if(s.get(1)!==e.databaseId.projectId)throw new k(re,"Tried to deserialize key from different project: "+s.get(1)+" vs "+e.databaseId.projectId);if(s.get(3)!==e.databaseId.database)throw new k(re,"Tried to deserialize key from different database: "+s.get(3)+" vs "+e.databaseId.database);return new S(function __PRIVATE_extractLocalPathFromResourceName(e){return __PRIVATE_hardAssert(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}(s))}function __PRIVATE_toMutationDocument(e,i,s){return{name:__PRIVATE_toName(e,i),fields:s.value.mapValue.fields}}function __PRIVATE_toQueryTarget(e,i){const s={structuredQuery:{}},T=i.path;let E;null!==i.collectionGroup?(E=T,s.structuredQuery.from=[{collectionId:i.collectionGroup,allDescendants:!0}]):(E=T.popLast(),s.structuredQuery.from=[{collectionId:T.lastSegment()}]),s.parent=function __PRIVATE_toQueryPath(e,i){return __PRIVATE_toResourceName(e.databaseId,i)}(e,E);const V=function __PRIVATE_toFilters(e){if(0!==e.length)return __PRIVATE_toFilter(CompositeFilter.create(e,"and"))}(i.filters);V&&(s.structuredQuery.where=V);const R=function __PRIVATE_toOrder(e){if(0!==e.length)return e.map((e=>function __PRIVATE_toPropertyOrder(e){return{field:__PRIVATE_toFieldPathReference(e.field),direction:__PRIVATE_toDirection(e.dir)}}(e)))}(i.orderBy);R&&(s.structuredQuery.orderBy=R);const N=function __PRIVATE_toInt32Proto(e,i){return e.useProto3Json||tt(i)?i:{value:i}}(e,i.limit);return null!==N&&(s.structuredQuery.limit=N),i.startAt&&(s.structuredQuery.startAt=function __PRIVATE_toStartAtCursor(e){return{before:e.inclusive,values:e.position}}(i.startAt)),i.endAt&&(s.structuredQuery.endAt=function __PRIVATE_toEndAtCursor(e){return{before:!e.inclusive,values:e.position}}(i.endAt)),{Mt:s,parent:E}}function __PRIVATE_toDirection(e){return ot[e]}function __PRIVATE_toOperatorName(e){return ut[e]}function __PRIVATE_toCompositeOperatorName(e){return lt[e]}function __PRIVATE_toFieldPathReference(e){return{fieldPath:e.canonicalString()}}function __PRIVATE_toFilter(e){return e instanceof FieldFilter?function __PRIVATE_toUnaryOrFieldFilter(e){if("=="===e.op){if(__PRIVATE_isNanValue(e.value))return{unaryFilter:{field:__PRIVATE_toFieldPathReference(e.field),op:"IS_NAN"}};if(__PRIVATE_isNullValue(e.value))return{unaryFilter:{field:__PRIVATE_toFieldPathReference(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(__PRIVATE_isNanValue(e.value))return{unaryFilter:{field:__PRIVATE_toFieldPathReference(e.field),op:"IS_NOT_NAN"}};if(__PRIVATE_isNullValue(e.value))return{unaryFilter:{field:__PRIVATE_toFieldPathReference(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:__PRIVATE_toFieldPathReference(e.field),op:__PRIVATE_toOperatorName(e.op),value:e.value}}}(e):e instanceof CompositeFilter?function __PRIVATE_toCompositeFilter(e){const i=e.getFilters().map((e=>__PRIVATE_toFilter(e)));return 1===i.length?i[0]:{compositeFilter:{op:__PRIVATE_toCompositeOperatorName(e.op),filters:i}}}(e):z(54877,{filter:e})}function __PRIVATE_toDocumentMask(e){const i=[];return e.fields.forEach((e=>i.push(e.canonicalString()))),{fieldPaths:i}}function __PRIVATE_isValidResourceName(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}function __PRIVATE_isProtoValueSerializable(e){return!!e&&"function"==typeof e._toProto&&"ProtoValue"===e._protoValueType}function __PRIVATE_newSerializer(e){return new JsonProtoSerializer(e,!0)}class Datastore{}class __PRIVATE_DatastoreImpl extends Datastore{constructor(e,i,s,T){super(),this.authCredentials=e,this.appCheckCredentials=i,this.connection=s,this.serializer=T,this.qt=!1}Lt(){if(this.qt)throw new k(le,"The client has already been terminated.")}le(e,i,s,T){return this.Lt(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([E,V])=>this.connection.le(e,__PRIVATE_toResourcePath(i,s),T,E,V))).catch((e=>{throw"FirebaseError"===e.name?(e.code===oe&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new k(te,e.toString())}))}me(e,i,s,T,E){return this.Lt(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([V,R])=>this.connection.me(e,__PRIVATE_toResourcePath(i,s),T,V,R,E))).catch((e=>{throw"FirebaseError"===e.name?(e.code===oe&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new k(te,e.toString())}))}terminate(){this.qt=!0,this.connection.terminate()}}async function O(e,i){const s=__PRIVATE_debugCast(e),T={writes:i.map((e=>function toMutation(e,i){let s;if(i instanceof __PRIVATE_SetMutation)s={update:__PRIVATE_toMutationDocument(e,i.key,i.value)};else if(i instanceof F)s={delete:__PRIVATE_toName(e,i.key)};else if(i instanceof __PRIVATE_PatchMutation)s={update:__PRIVATE_toMutationDocument(e,i.key,i.data),updateMask:__PRIVATE_toDocumentMask(i.fieldMask)};else{if(!(i instanceof q))return z(16599,{Ot:i.type});s={verify:__PRIVATE_toName(e,i.key)}}return i.fieldTransforms.length>0&&(s.updateTransforms=i.fieldTransforms.map((e=>function __PRIVATE_toFieldTransform(e,i){const s=i.transform;if(s instanceof __PRIVATE_ServerTimestampTransform)return{fieldPath:i.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(s instanceof __PRIVATE_ArrayUnionTransformOperation)return{fieldPath:i.field.canonicalString(),appendMissingElements:{values:s.elements}};if(s instanceof __PRIVATE_ArrayRemoveTransformOperation)return{fieldPath:i.field.canonicalString(),removeAllFromArray:{values:s.elements}};if(s instanceof __PRIVATE_NumericIncrementTransformOperation)return{fieldPath:i.field.canonicalString(),increment:s.Qt};if(s instanceof __PRIVATE_NumericMinimumTransformOperation)return{fieldPath:i.field.canonicalString(),minimum:s.Qt};if(s instanceof __PRIVATE_NumericMaximumTransformOperation)return{fieldPath:i.field.canonicalString(),maximum:s.Qt};throw z(20930,{transform:i.transform})}(0,e)))),i.precondition.isNone||(s.currentDocument=function __PRIVATE_toPrecondition(e,i){return void 0!==i.updateTime?{updateTime:__PRIVATE_toVersion(e,i.updateTime)}:void 0!==i.exists?{exists:i.exists}:z(27497)}(e,i.precondition)),s}(s.serializer,e)))};await s.le("Commit",s.serializer.databaseId,ResourcePath.emptyPath(),T)}async function C(e,i){const s=__PRIVATE_debugCast(e),T={documents:i.map((e=>__PRIVATE_toName(s.serializer,e)))},E=await s.me("BatchGetDocuments",s.serializer.databaseId,ResourcePath.emptyPath(),T,i.length),V=new Map;E.forEach((e=>{const i=function __PRIVATE_fromBatchGetDocumentsResponse(e,i){return"found"in i?function __PRIVATE_fromFound(e,i){__PRIVATE_hardAssert(!!i.found,43571),i.found.name,i.found.updateTime;const s=fromName(e,i.found.name),T=__PRIVATE_fromVersion(i.found.updateTime),E=i.found.createTime?__PRIVATE_fromVersion(i.found.createTime):j.min(),V=new u({mapValue:{fields:i.found.fields}});return MutableDocument.newFoundDocument(s,T,E,V)}(e,i):"missing"in i?function __PRIVATE_fromMissing(e,i){__PRIVATE_hardAssert(!!i.missing,3894),__PRIVATE_hardAssert(!!i.readTime,22933);const s=fromName(e,i.missing),T=__PRIVATE_fromVersion(i.readTime);return MutableDocument.newNoDocument(s,T)}(e,i):z(7234,{result:i})}(s.serializer,e);V.set(i.key.toString(),i)}));const R=[];return i.forEach((e=>{const i=V.get(e.toString());__PRIVATE_hardAssert(!!i,55234,{key:e}),R.push(i)})),R}const ct="ComponentProvider",_t=new Map;function d(e){if(e._terminated)throw new k(le,"The client has already been terminated.");if(!_t.has(e)){a(ct,"Initializing Datastore");const i=function __PRIVATE_newConnection(e){return new __PRIVATE_FetchConnection(e)}(function __PRIVATE_makeDatabaseInfo(e,i,s,T,E){return new DatabaseInfo(e,i,s,E.host,E.ssl,E.experimentalForceLongPolling,E.experimentalAutoDetectLongPolling,__PRIVATE_cloneLongPollingOptions(E.experimentalLongPollingOptions),E.useFetchStreams,E.isUsingEmulator,T,E._customHeaders,E.grpcFlowControlWindow)}(e._databaseId,e.app.options.appId||"",e._persistenceKey,e.app.options.apiKey,e._freezeSettings())),s=__PRIVATE_newSerializer(e._databaseId),T=function __PRIVATE_newDatastore(e,i,s,T){return new __PRIVATE_DatastoreImpl(e,i,s,T)}(e._authCredentials,e._appCheckCredentials,i,s);_t.set(e,T)}return _t.get(e)}const ht="firestore.googleapis.com",dt=!0;class FirestoreSettingsImpl{constructor(e){if(void 0===e.host){if(void 0!==e.ssl)throw new k(re,"Can't provide ssl option if host option is not set");this.host=ht,this.ssl=dt}else this.host=e.host,this.ssl=e.ssl??dt;if(this.isUsingEmulator=void 0!==e.emulatorOptions,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e._customHeaders&&(this._customHeaders={...e._customHeaders}),void 0===e.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new k(re,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}if(function __PRIVATE_validateIsNotUsedTogether(e,i,s,T){if(!0===i&&!0===T)throw new k(re,`${e} and ${s} cannot be used together.`)}("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=__PRIVATE_cloneLongPollingOptions(e.experimentalLongPollingOptions??{}),function __PRIVATE_validateLongPollingOptions(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new k(re,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new k(re,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new k(re,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams,void 0!==e.grpcFlowControlWindow){if("number"!=typeof e.grpcFlowControlWindow||e.grpcFlowControlWindow<=0||e.grpcFlowControlWindow>2147483647||!Number.isInteger(e.grpcFlowControlWindow))throw new k(re,"grpcFlowControlWindow must be a positive integer and cannot exceed 2147483647");this.grpcFlowControlWindow=e.grpcFlowControlWindow}}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function __PRIVATE_longPollingOptionsEqual(e,i){return e.timeoutSeconds===i.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams&&this.grpcFlowControlWindow===e.grpcFlowControlWindow&&function __PRIVATE_customHeadersEqual(e,i){if(e===i)return!0;if(!e||!i)return!1;const s=Object.keys(e),T=Object.keys(i);if(s.length!==T.length)return!1;for(const T of s)if(e[T]!==i[T])return!1;return!0}(this._customHeaders,e._customHeaders)}}class n{constructor(e,i,s,T){this._authCredentials=e,this._appCheckCredentials=i,this._databaseId=s,this._app=T,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new FirestoreSettingsImpl({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new k(le,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new k(le,"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 FirestoreSettingsImpl(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function __PRIVATE_makeAuthCredentialsProvider(e){if(!e)return new __PRIVATE_EmptyAuthCredentialsProvider;switch(e.type){case"firstParty":return new __PRIVATE_FirstPartyAuthCredentialsProvider(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new k(re,"makeAuthCredentialsProvider failed due to invalid credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function __PRIVATE_removeComponents(e){const i=_t.get(e);i&&(a(ct,"Removing Datastore"),_t.delete(e),i.terminate())}(this),Promise.resolve()}}function initializeFirestore(e,i,s){s||(s=pe);const T=_getProvider(e,"firestore/lite");if(T.isInitialized(s))throw new k(le,"Firestore can only be initialized once per app.");return T.initialize({options:i,instanceIdentifier:s})}function getFirestore(e,s){const T="object"==typeof e?e:i(),E="string"==typeof e?e:s||"(default)",V=_getProvider(T,"firestore/lite").getImmediate({identifier:E});if(!V._initialized){const e=getDefaultEmulatorHostnameAndPort("firestore");e&&connectFirestoreEmulator(V,...e)}return V}function connectFirestoreEmulator(e,i,s,T={}){e=f(e,n);const E=isCloudWorkstation(i),V=e._getSettings(),R={...V,emulatorOptions:e._getEmulatorOptions()},N=`${i}:${s}`;E&&async function pingServer(e){return(await fetch(e,{credentials:"include"})).ok}(`https://${N}`),V.host!==ht&&V.host!==N&&__PRIVATE_logWarn("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const M={...V,host:N,ssl:E,emulatorOptions:T};if(!deepEqual(M,R)&&(e._setSettings(M),T.mockUserToken)){let i,s;if("string"==typeof T.mockUserToken)i=T.mockUserToken,s=User.MOCK_USER;else{i=function createMockUserToken(e,i){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 s=i||"demo-project",T=e.iat||0,E=e.sub||e.user_id;if(!E)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const V={iss:`https://securetoken.google.com/${s}`,aud:s,iat:T,exp:T+3600,auth_time:T,sub:E,user_id:E,firebase:{sign_in_provider:"custom",identities:{}},...e};return[base64urlEncodeWithoutPadding(JSON.stringify({alg:"none",type:"JWT"})),base64urlEncodeWithoutPadding(JSON.stringify(V)),""].join(".")}(T.mockUserToken,e._app?.options.projectId);const E=T.mockUserToken.sub||T.mockUserToken.user_id;if(!E)throw new k(re,"mockUserToken must contain 'sub' or 'user_id' field!");s=new User(E)}e._authCredentials=new __PRIVATE_EmulatorAuthCredentialsProvider(new __PRIVATE_OAuthToken(i,s))}}function terminate(e){return e=f(e,n),s(e.app,"firestore/lite"),e._delete()}class Query{constructor(e,i,s){this.converter=i,this._query=s,this.type="query",this.firestore=e}withConverter(e){return new Query(this.firestore,e,this._query)}}class DocumentReference{constructor(e,i,s){this.converter=i,this._key=s,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 CollectionReference(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new DocumentReference(this.firestore,e,this._key)}toJSON(){return{type:DocumentReference._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,i,s){if(__PRIVATE_validateJSON(i,DocumentReference._jsonSchema))return new DocumentReference(e,s||null,new S(ResourcePath.fromString(i.referencePath)))}}DocumentReference._jsonSchemaVersion="firestore/documentReference/1.0",DocumentReference._jsonSchema={type:property("string",DocumentReference._jsonSchemaVersion),referencePath:property("string")};class CollectionReference extends Query{constructor(e,i,s){super(e,i,function __PRIVATE_newQueryForPath(e){return new __PRIVATE_QueryImpl(e)}(s)),this._path=s,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 DocumentReference(this.firestore,null,new S(e))}withConverter(e){return new CollectionReference(this.firestore,e,this._path)}}function collection(e,i,...s){if(e=getModularInstance(e),__PRIVATE_validateNonEmptyArgument("collection","path",i),e instanceof n){const T=ResourcePath.fromString(i,...s);return __PRIVATE_validateCollectionPath(T),new CollectionReference(e,null,T)}{if(!(e instanceof DocumentReference||e instanceof CollectionReference))throw new k(re,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const T=e._path.child(ResourcePath.fromString(i,...s));return __PRIVATE_validateCollectionPath(T),new CollectionReference(e.firestore,null,T)}}function collectionGroup(e,i){if(e=f(e,n),__PRIVATE_validateNonEmptyArgument("collectionGroup","collection id",i),i.indexOf("/")>=0)throw new k(re,`Invalid collection ID '${i}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new Query(e,null,function __PRIVATE_newQueryForCollectionGroup(e){return new __PRIVATE_QueryImpl(ResourcePath.emptyPath(),e)}(i))}function doc(e,i,...s){if(e=getModularInstance(e),1===arguments.length&&(i=__PRIVATE_AutoId.newId()),__PRIVATE_validateNonEmptyArgument("doc","path",i),e instanceof n){const T=ResourcePath.fromString(i,...s);return __PRIVATE_validateDocumentPath(T),new DocumentReference(e,null,new S(T))}{if(!(e instanceof DocumentReference||e instanceof CollectionReference))throw new k(re,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const T=e._path.child(ResourcePath.fromString(i,...s));return __PRIVATE_validateDocumentPath(T),new DocumentReference(e.firestore,e instanceof CollectionReference?e.converter:null,new S(T))}}function refEqual(e,i){return e=getModularInstance(e),i=getModularInstance(i),(e instanceof DocumentReference||e instanceof CollectionReference)&&(i instanceof DocumentReference||i instanceof CollectionReference)&&e.firestore===i.firestore&&e.path===i.path&&e.converter===i.converter}function l(e,i){return e=getModularInstance(e),i=getModularInstance(i),e instanceof Query&&i instanceof Query&&e.firestore===i.firestore&&function __PRIVATE_queryEquals(e,i){return function __PRIVATE_targetEquals(e,i){if(e.limit!==i.limit)return!1;if(e.orderBy.length!==i.orderBy.length)return!1;for(let s=0;s<e.orderBy.length;s++)if(!__PRIVATE_orderByEquals(e.orderBy[s],i.orderBy[s]))return!1;if(e.filters.length!==i.filters.length)return!1;for(let s=0;s<e.filters.length;s++)if(!__PRIVATE_filterEquals(e.filters[s],i.filters[s]))return!1;return e.collectionGroup===i.collectionGroup&&!!e.path.isEqual(i.path)&&!!__PRIVATE_boundEquals(e.startAt,i.startAt)&&__PRIVATE_boundEquals(e.endAt,i.endAt)}(__PRIVATE_queryToTarget(e),__PRIVATE_queryToTarget(i))&&e.limitType===i.limitType}(e._query,i._query)&&e.converter===i.converter}class Bytes{constructor(e,i=0){if(this.subtype=i,!Number.isInteger(i)||i<0||i>255)throw new k(re,"The subtype for Bytes must be a value in the inclusive [0, 255] range.");this._byteString=e}static fromBase64String(e,i=0){try{return new Bytes(ByteString.fromBase64String(e),i)}catch(e){throw new k(re,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e,i=0){return new Bytes(ByteString.fromUint8Array(e),i)}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}get data(){return this.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+", subtype: "+this.subtype+")"}isEqual(e){return this.subtype===e.subtype&&this._byteString.isEqual(e._byteString)}toJSON(){const e={type:Bytes._jsonSchemaVersion,bytes:this.toBase64()};return 0!==this.subtype&&(e.subtype=this.subtype),e}static fromJSON(e){if(__PRIVATE_validateJSON(e,Bytes._jsonSchema)){const i=e.subtype??0;return Bytes.fromBase64String(e.bytes,i)}}}Bytes._jsonSchemaVersion="firestore/bytes/1.0",Bytes._jsonSchema={type:property("string",Bytes._jsonSchemaVersion),bytes:property("string"),subtype:{...property("number"),optional:!0}};class D{constructor(...e){for(let i=0;i<e.length;++i)if(0===e[i].length)throw new k(re,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new Ve(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}function documentId(){return new D(Ee)}class BsonObjectId{constructor(e){this.value=e}isEqual(e){return this.value===e.value}}class BsonTimestamp{constructor(e,i){if(this.seconds=e,this.increment=i,!Number.isInteger(e)||e<0||e>4294967295)throw new Error("BsonTimestamp 'seconds' must be in the range of a 32-bit unsigned integer (0-4294967295).");if(!Number.isInteger(i)||i<0||i>4294967295)throw new Error("BsonTimestamp 'increment' must be in the range of a 32-bit unsigned integer (0-4294967295).")}isEqual(e){return this.seconds===e.seconds&&this.increment===e.increment}}class Decimal128Value{constructor(e){this.stringValue=e,this.value=__PRIVATE_Quadruple.fromString(e)}isEqual(e){return!(!this.value.ot()||!e.value.ot())||0===this.value.compareTo(e.value)}toJSON(){return{$t:{stringValue:this.stringValue}}}}class FieldValue{constructor(e){this._methodName=e}}class GeoPoint{constructor(e,i){if(!isFinite(e)||e<-90||e>90)throw new k(re,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(i)||i<-180||i>180)throw new k(re,"Longitude must be a number between -180 and 180, but was: "+i);this._lat=e,this._long=i}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return __PRIVATE_primitiveComparator(this._lat,e._lat)||__PRIVATE_primitiveComparator(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:GeoPoint._jsonSchemaVersion}}static fromJSON(e){if(__PRIVATE_validateJSON(e,GeoPoint._jsonSchema))return new GeoPoint(e.latitude,e.longitude)}}GeoPoint._jsonSchemaVersion="firestore/geoPoint/1.0",GeoPoint._jsonSchema={type:property("string",GeoPoint._jsonSchemaVersion),latitude:property("number"),longitude:property("number")};class Int32Value{constructor(e){this.value=e}isEqual(e){return this.value===e.value}}class MaxKey{constructor(){this.type="MaxKey"}static instance(){return MaxKey.MAX_KEY_VALUE_INSTANCE||(MaxKey.MAX_KEY_VALUE_INSTANCE=new MaxKey),MaxKey.MAX_KEY_VALUE_INSTANCE}}MaxKey.MAX_KEY_VALUE_INSTANCE=null;class MinKey{constructor(){this.type="MinKey"}static instance(){return MinKey.MIN_KEY_VALUE_INSTANCE||(MinKey.MIN_KEY_VALUE_INSTANCE=new MinKey),MinKey.MIN_KEY_VALUE_INSTANCE}}MinKey.MIN_KEY_VALUE_INSTANCE=null;class RegexValue{constructor(e,i){this.pattern=e,this.options=i}isEqual(e){return this.pattern===e.pattern&&this.options===e.options}}class VectorValue{constructor(e){this._values=(e||[]).map((e=>e))}toArray(){return this._values.map((e=>e))}isEqual(e){return function __PRIVATE_isPrimitiveArrayEqual(e,i){if(e.length!==i.length)return!1;for(let s=0;s<e.length;++s)if(e[s]!==i[s])return!1;return!0}(this._values,e._values)}toJSON(){return{type:VectorValue._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(__PRIVATE_validateJSON(e,VectorValue._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every((e=>"number"==typeof e)))return new VectorValue(e.vectorValues);throw new k(re,"Expected 'vectorValues' field to be a number array")}}}VectorValue._jsonSchemaVersion="firestore/vectorValue/1.0",VectorValue._jsonSchema={type:property("string",VectorValue._jsonSchemaVersion),vectorValues:property("object")};const ft=/^__.*__$/;class ParsedSetData{constructor(e,i,s){this.data=e,this.fieldMask=i,this.fieldTransforms=s}toMutation(e,i){return null!==this.fieldMask?new __PRIVATE_PatchMutation(e,this.data,this.fieldMask,i,this.fieldTransforms):new __PRIVATE_SetMutation(e,this.data,i,this.fieldTransforms)}}class ParsedUpdateData{constructor(e,i,s){this.data=e,this.fieldMask=i,this.fieldTransforms=s}toMutation(e,i){return new __PRIVATE_PatchMutation(e,this.data,this.fieldMask,i,this.fieldTransforms)}}function __PRIVATE_isWrite(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw z(40011,{dataSource:e})}}class ParseContextImpl{constructor(e,i,s,T,E,V){this.settings=e,this.databaseId=i,this.serializer=s,this.ignoreUndefinedProperties=T,void 0===E&&this.validatePath(),this.fieldTransforms=E||[],this.fieldMask=V||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}contextWith(e){return new ParseContextImpl({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}childContextForField(e){const i=this.path?.child(e),s=this.contextWith({path:i,arrayElement:!1});return s.validatePathSegment(e),s}childContextForFieldPath(e){const i=this.path?.child(e),s=this.contextWith({path:i,arrayElement:!1});return s.validatePath(),s}childContextForArray(e){return this.contextWith({path:void 0,arrayElement:!0})}createError(e){return createError(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return void 0!==this.fieldMask.find((i=>e.isPrefixOf(i)))||void 0!==this.fieldTransforms.find((i=>e.isPrefixOf(i.field)))}validatePath(){if(this.path)for(let e=0;e<this.path.length;e++)this.validatePathSegment(this.path.get(e))}validatePathSegment(e){if(0===e.length)throw this.createError("Document fields must not be empty");if(__PRIVATE_isWrite(this.dataSource)&&ft.test(e))throw this.createError('Document fields cannot begin and end with "__"')}}class UserDataReader{constructor(e,i,s){this.databaseId=e,this.ignoreUndefinedProperties=i,this.serializer=s||__PRIVATE_newSerializer(e)}createContext(e,i,s,T=!1){return new ParseContextImpl({dataSource:e,methodName:i,targetDoc:s,path:Ve.emptyPath(),arrayElement:!1,hasConverter:T},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function p(e){const i=e._freezeSettings(),s=__PRIVATE_newSerializer(e._databaseId);return new UserDataReader(e._databaseId,!!i.ignoreUndefinedProperties,s)}function y(e,i,s,T,E,V={}){const R=e.createContext(V.merge||V.mergeFields?2:0,i,s,E);__PRIVATE_validatePlainObject("Data must be an object, but it was:",R,T);const N=__PRIVATE_parseObject(T,R);let M,Q;if(V.merge)M=new FieldMask(R.fieldMask),Q=R.fieldTransforms;else if(V.mergeFields){const e=[];for(const T of V.mergeFields){const E=_(i,T,s);if(!R.contains(E))throw new k(re,`Field '${E}' is specified in your field mask but missing from your input data.`);__PRIVATE_fieldMaskContains(e,E)||e.push(E)}M=new FieldMask(e),Q=R.fieldTransforms.filter((e=>M.covers(e.field)))}else M=null,Q=R.fieldTransforms;return new ParsedSetData(new u(N),M,Q)}class __PRIVATE_DeleteFieldValueImpl extends FieldValue{_toFieldTransform(e){if(2!==e.dataSource)throw 1===e.dataSource?e.createError(`${this._methodName}() can only appear at the top level of your update data`):e.createError(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof __PRIVATE_DeleteFieldValueImpl}}function __PRIVATE_createSentinelChildContext(e,i,s){return new ParseContextImpl({dataSource:3,targetDoc:i.settings.targetDoc,methodName:e._methodName,arrayElement:s},i.databaseId,i.serializer,i.ignoreUndefinedProperties)}class __PRIVATE_ServerTimestampFieldValueImpl extends FieldValue{_toFieldTransform(e){return new FieldTransform(e.path,new __PRIVATE_ServerTimestampTransform)}isEqual(e){return e instanceof __PRIVATE_ServerTimestampFieldValueImpl}}class __PRIVATE_ArrayUnionFieldValueImpl extends FieldValue{constructor(e,i){super(e),this.kt=i}_toFieldTransform(e){const i=__PRIVATE_createSentinelChildContext(this,e,!0),s=this.kt.map((e=>__PRIVATE_parseData(e,i))),T=new __PRIVATE_ArrayUnionTransformOperation(s);return new FieldTransform(e.path,T)}isEqual(e){return e instanceof __PRIVATE_ArrayUnionFieldValueImpl&&deepEqual(this.kt,e.kt)}}class __PRIVATE_ArrayRemoveFieldValueImpl extends FieldValue{constructor(e,i){super(e),this.kt=i}_toFieldTransform(e){const i=__PRIVATE_createSentinelChildContext(this,e,!0),s=this.kt.map((e=>__PRIVATE_parseData(e,i))),T=new __PRIVATE_ArrayRemoveTransformOperation(s);return new FieldTransform(e.path,T)}isEqual(e){return e instanceof __PRIVATE_ArrayRemoveFieldValueImpl&&deepEqual(this.kt,e.kt)}}class __PRIVATE_NumericIncrementFieldValueImpl extends FieldValue{constructor(e,i){super(e),this.jt=i}_toFieldTransform(e){const i=new __PRIVATE_NumericIncrementTransformOperation(e.serializer,toNumber(e.serializer,this.jt));return new FieldTransform(e.path,i)}isEqual(e){return e instanceof __PRIVATE_NumericIncrementFieldValueImpl&&(this.jt===e.jt||Number.isNaN(this.jt)&&Number.isNaN(e.jt))}}class __PRIVATE_NumericMinimumFieldValueImpl extends FieldValue{constructor(e,i){super(e),this.jt=i}_toFieldTransform(e){const i=new __PRIVATE_NumericMinimumTransformOperation(e.serializer,toNumber(e.serializer,this.jt));return new FieldTransform(e.path,i)}isEqual(e){return e instanceof __PRIVATE_NumericMinimumFieldValueImpl&&(this.jt===e.jt||Number.isNaN(this.jt)&&Number.isNaN(e.jt))}}class __PRIVATE_NumericMaximumFieldValueImpl extends FieldValue{constructor(e,i){super(e),this.jt=i}_toFieldTransform(e){const i=new __PRIVATE_NumericMaximumTransformOperation(e.serializer,toNumber(e.serializer,this.jt));return new FieldTransform(e.path,i)}isEqual(e){return e instanceof __PRIVATE_NumericMaximumFieldValueImpl&&(this.jt===e.jt||Number.isNaN(this.jt)&&Number.isNaN(e.jt))}}function v(e,i,s,T){const E=e.createContext(1,i,s);__PRIVATE_validatePlainObject("Data must be an object, but it was:",E,T);const V=[],R=u.empty();forEach(T,((e,T)=>{const N=__PRIVATE_fieldPathFromDotSeparatedString(i,e,s);T=getModularInstance(T);const M=E.childContextForFieldPath(N);if(T instanceof __PRIVATE_DeleteFieldValueImpl)V.push(N);else{const e=__PRIVATE_parseData(T,M);null!=e&&(V.push(N),R.set(N,e))}}));const N=new FieldMask(V);return new ParsedUpdateData(R,N,E.fieldTransforms)}function b(e,i,s,T,E,V){const R=e.createContext(1,i,s),N=[_(i,T,s)],M=[E];if(V.length%2!=0)throw new k(re,`Function ${i}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<V.length;e+=2)N.push(_(i,V[e])),M.push(V[e+1]);const Q=[],L=u.empty();for(let e=N.length-1;e>=0;--e)if(!__PRIVATE_fieldMaskContains(Q,N[e])){const i=N[e];let s=M[e];s=getModularInstance(s);const T=R.childContextForFieldPath(i);if(s instanceof __PRIVATE_DeleteFieldValueImpl)Q.push(i);else{const e=__PRIVATE_parseData(s,T);null!=e&&(Q.push(i),L.set(i,e))}}const U=new FieldMask(Q);return new ParsedUpdateData(L,U,R.fieldTransforms)}function __PRIVATE_parseQueryValue(e,i,s,T=!1){return __PRIVATE_parseData(s,e.createContext(T?4:3,i))}function __PRIVATE_parseData(e,i,s){if(__PRIVATE_looksLikeJsonObject(e=getModularInstance(e)))return __PRIVATE_validatePlainObject("Unsupported field value:",i,e),__PRIVATE_parseObject(e,i);if(e instanceof FieldValue)return function __PRIVATE_parseSentinelFieldValue(e,i){if(!__PRIVATE_isWrite(i.dataSource))throw i.createError(`${e._methodName}() can only be used with update() and set()`);if(!i.path)throw i.createError(`${e._methodName}() is not currently supported inside arrays`);const s=e._toFieldTransform(i);s&&i.fieldTransforms.push(s)}(e,i),null;if(void 0===e&&i.ignoreUndefinedProperties)return null;if(i.path&&i.fieldMask.push(i.path),e instanceof Array){if(i.settings.arrayElement&&4!==i.dataSource)throw i.createError("Nested arrays are not supported");return function __PRIVATE_parseArray(e,i){const s=[];let T=0;for(const E of e){let e=__PRIVATE_parseData(E,i.childContextForArray(T));null==e&&(e={nullValue:"NULL_VALUE"}),s.push(e),T++}return{arrayValue:{values:s}}}(e,i)}return function __PRIVATE_parseScalarValue(e,i){if(null===(e=getModularInstance(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return toNumber(i.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){const s=Timestamp.fromDate(e);return{timestampValue:toTimestamp(i.serializer,s)}}if(e instanceof Timestamp){const s=new Timestamp(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:toTimestamp(i.serializer,s)}}if(__PRIVATE_isTemporalInstant(e)){const s=Timestamp.fromInstant(e),T=new Timestamp(s.seconds,1e3*Math.floor(s.nanoseconds/1e3));return{timestampValue:toTimestamp(i.serializer,T)}}if(e instanceof GeoPoint)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Bytes)return 0===e.subtype?{bytesValue:__PRIVATE_toBytes(i.serializer,e._byteString)}:function __PRIVATE_parseBytesWithSubtype(e,i){const s=i.toUint8Array(),T=new Uint8Array(s.length+1);return T[0]=i.subtype,T.set(s,1),{mapValue:{fields:{[Ye]:{bytesValue:__PRIVATE_toBytes(e,ByteString.fromUint8Array(T))}}}}}(i.serializer,e);if(e instanceof DocumentReference){const s=i.databaseId,T=e.firestore._databaseId;if(!T.isEqual(s))throw i.createError(`Document reference is for database ${T.projectId}/${T.database} but should be for database ${s.projectId}/${s.database}`);return{referenceValue:__PRIVATE_toResourceName(e.firestore._databaseId||i.databaseId,e._key.path)}}if(e instanceof VectorValue)return function __PRIVATE_parseVectorValue(e,i){const s=e instanceof VectorValue?e.toArray():e,T={fields:{[Be]:{stringValue:Oe},[Me]:{arrayValue:{values:s.map((e=>{if("number"!=typeof e)throw i.createError("VectorValues must only contain numeric values.");return __PRIVATE_toDouble(i.serializer,e)}))}}}};return{mapValue:T}}(e,i);if(e instanceof RegexValue)return function __PRIVATE_parseRegexValue(e){return{mapValue:{fields:{[je]:{mapValue:{fields:{[Ue]:{stringValue:e.pattern},[ze]:{stringValue:e.options}}}}}}}}(e);if(e instanceof BsonObjectId)return function __PRIVATE_parseBsonObjectId(e){return{mapValue:{fields:{[$e]:{stringValue:e.value}}}}}(e);if(e instanceof Int32Value)return function __PRIVATE_parseInt32Value(e){return{mapValue:{fields:{[We]:__PRIVATE_toInteger(e.value)}}}}(e);if(e instanceof Decimal128Value)return function __PRIVATE_parseDecimal128Value(e){return{mapValue:{fields:{[Ge]:{stringValue:e.stringValue}}}}}(e);if(e instanceof BsonTimestamp)return function __PRIVATE_parseBsonTimestamp(e){return{mapValue:{fields:{[Ke]:{mapValue:{fields:{[He]:__PRIVATE_toInteger(e.seconds),[Je]:__PRIVATE_toInteger(e.increment)}}}}}}}(e);if(e instanceof MinKey)return function __PRIVATE_parseMinKey(){return{mapValue:{fields:{[Le]:{nullValue:"NULL_VALUE"}}}}}();if(e instanceof MaxKey)return function __PRIVATE_parseMaxKey(){return{mapValue:{fields:{[qe]:{nullValue:"NULL_VALUE"}}}}}();if(__PRIVATE_isProtoValueSerializable(e))return e._toProto(i.serializer);throw i.createError(`Unsupported field value: ${__PRIVATE_valueDescription(e)}`)}(e,i)}function __PRIVATE_parseObject(e,i){const s={};return function isEmpty(e){for(const i in e)if(Object.prototype.hasOwnProperty.call(e,i))return!1;return!0}(e)?i.path&&i.path.length>0&&i.fieldMask.push(i.path):forEach(e,((e,T)=>{const E=__PRIVATE_parseData(T,i.childContextForField(e));null!=E&&(s[e]=E)})),{mapValue:{fields:s}}}function __PRIVATE_isTemporalInstant(e){if("object"!=typeof e||null===e)return!1;if("undefined"!=typeof Temporal&&"function"==typeof Temporal.Instant&&e instanceof Temporal.Instant)return!0;const i=e;return"Temporal.Instant"===i[Symbol.toStringTag]&&"bigint"==typeof i.ht}function __PRIVATE_looksLikeJsonObject(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof Timestamp||e instanceof GeoPoint||e instanceof Bytes||e instanceof DocumentReference||e instanceof FieldValue||e instanceof VectorValue||e instanceof MinKey||e instanceof MaxKey||e instanceof Int32Value||e instanceof Decimal128Value||e instanceof RegexValue||e instanceof BsonObjectId||e instanceof BsonTimestamp||__PRIVATE_isTemporalInstant(e)||__PRIVATE_isProtoValueSerializable(e))}function __PRIVATE_validatePlainObject(e,i,s){if(!__PRIVATE_looksLikeJsonObject(s)||!__PRIVATE_isPlainObject(s)){const T=__PRIVATE_valueDescription(s);throw"an object"===T?i.createError(e+" a custom object"):i.createError(e+" "+T)}}function _(e,i,s){if((i=getModularInstance(i))instanceof D)return i._internalPath;if("string"==typeof i)return __PRIVATE_fieldPathFromDotSeparatedString(e,i);throw createError("Field path arguments must be of type string or ",e,!1,void 0,s)}const mt=new RegExp("[~\\*/\\[\\]]");function __PRIVATE_fieldPathFromDotSeparatedString(e,i,s){if(i.search(mt)>=0)throw createError(`Invalid field path (${i}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,s);try{return new D(...i.split("."))._internalPath}catch(T){throw createError(`Invalid field path (${i}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,s)}}function createError(e,i,s,T,E){const V=T&&!T.isEmpty(),R=void 0!==E;let N=`Function ${i}() called with invalid data`;s&&(N+=" (via `toFirestore()`)"),N+=". ";let M="";return(V||R)&&(M+=" (found",V&&(M+=` in field ${T}`),R&&(M+=` in document ${E}`),M+=")"),new k(re,N+e+M)}function __PRIVATE_fieldMaskContains(e,i){return e.some((e=>e.isEqual(i)))}class it{constructor(e,i,s,T,E){this._firestore=e,this._userDataWriter=i,this._key=s,this._document=T,this._converter=E}get id(){return this._key.path.lastSegment()}get ref(){return new DocumentReference(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const e=new QueryDocumentSnapshot(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){const i=this._document.data.field(_("DocumentSnapshot.get",e));if(null!==i)return this._userDataWriter.convertValue(i)}}}class QueryDocumentSnapshot extends it{data(){return super.data()}}class QuerySnapshot{constructor(e,i){this._docs=i,this.query=e}get docs(){return[...this._docs]}get size(){return this.docs.length}get empty(){return 0===this.docs.length}forEach(e,i){this._docs.forEach(e,i)}}function snapshotEqual(e,i){return e=getModularInstance(e),i=getModularInstance(i),e instanceof it&&i instanceof it?e._firestore===i._firestore&&e._key.isEqual(i._key)&&(null===e._document?null===i._document:e._document.isEqual(i._document))&&e._converter===i._converter:e instanceof QuerySnapshot&&i instanceof QuerySnapshot&&l(e.query,i.query)&&__PRIVATE_arrayEquals(e.docs,i.docs,snapshotEqual)}class AppliableConstraint{}class QueryConstraint extends AppliableConstraint{}function query(e,i,...s){let T=[];i instanceof AppliableConstraint&&T.push(i),T=T.concat(s),function __PRIVATE_validateQueryConstraintArray(e){const i=e.filter((e=>e instanceof QueryCompositeFilterConstraint)).length,s=e.filter((e=>e instanceof QueryFieldFilterConstraint)).length;if(i>1||i>0&&s>0)throw new k(re,"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(...)))`.")}(T);for(const i of T)e=i._apply(e);return e}class QueryFieldFilterConstraint extends QueryConstraint{constructor(e,i,s){super(),this._field=e,this._op=i,this._value=s,this.type="where"}static _create(e,i,s){return new QueryFieldFilterConstraint(e,i,s)}_apply(e){const i=this._parse(e);return __PRIVATE_validateNewFieldFilter(e._query,i),new Query(e.firestore,e.converter,__PRIVATE_queryWithAddedFilter(e._query,i))}_parse(e){const i=p(e.firestore),s=function __PRIVATE_newQueryFilter(e,i,s,T,E,V,R){let N;if(function __PRIVATE_validateQueryOperator(e,i){if("number"==typeof e&&isNaN(e)&&"=="!==i&&"!="!==i&&"array-contains"!==i)throw new Error("Invalid query. You can only perform '==' and '!=' comparisons on NaN.");if(null===e&&"=="!==i&&"!="!==i&&"array-contains"!==i)throw new Error("Invalid query. You can only perform '==' and '!=' comparisons on Null.")}(R,V),E.isKeyField()){if("array-contains"===V||"array-contains-any"===V)throw new k(re,`Invalid Query. You can't perform '${V}' queries on documentId().`);if("in"===V||"not-in"===V){__PRIVATE_validateDisjunctiveFilterElements(R,V);const i=[];for(const s of R)i.push(__PRIVATE_parseDocumentIdValue(T,e,s));N={arrayValue:{values:i}}}else N=__PRIVATE_parseDocumentIdValue(T,e,R)}else"in"!==V&&"not-in"!==V&&"array-contains-any"!==V||__PRIVATE_validateDisjunctiveFilterElements(R,V),N=__PRIVATE_parseQueryValue(s,i,R,"in"===V||"not-in"===V);return FieldFilter.create(E,V,N)}(e._query,"where",i,e.firestore._databaseId,this._field,this._op,this._value);return s}}function where(e,i,s){const T=i,E=_("where",e);return QueryFieldFilterConstraint._create(E,T,s)}class QueryCompositeFilterConstraint extends AppliableConstraint{constructor(e,i){super(),this.type=e,this._queryConstraints=i}static _create(e,i){return new QueryCompositeFilterConstraint(e,i)}_parse(e){const i=this._queryConstraints.map((i=>i._parse(e))).filter((e=>e.getFilters().length>0));return 1===i.length?i[0]:CompositeFilter.create(i,this._getOperator())}_apply(e){const i=this._parse(e);return 0===i.getFilters().length?e:(function __PRIVATE_validateNewFilter(e,i){let s=e;const T=i.getFlattenedFilters();for(const e of T)__PRIVATE_validateNewFieldFilter(s,e),s=__PRIVATE_queryWithAddedFilter(s,e)}(e._query,i),new Query(e.firestore,e.converter,__PRIVATE_queryWithAddedFilter(e._query,i)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}function or(...e){return e.forEach((e=>__PRIVATE_validateQueryFilterConstraint("or",e))),QueryCompositeFilterConstraint._create("or",e)}function and(...e){return e.forEach((e=>__PRIVATE_validateQueryFilterConstraint("and",e))),QueryCompositeFilterConstraint._create("and",e)}class QueryOrderByConstraint extends QueryConstraint{constructor(e,i){super(),this._field=e,this._direction=i,this.type="orderBy"}static _create(e,i){return new QueryOrderByConstraint(e,i)}_apply(e){const i=function __PRIVATE_newQueryOrderBy(e,i,s){if(null!==e.startAt)throw new k(re,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new k(re,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new OrderBy(i,s)}(e._query,this._field,this._direction);return new Query(e.firestore,e.converter,function __PRIVATE_queryWithAddedOrderBy(e,i){const s=e.explicitOrderBy.concat([i]);return new __PRIVATE_QueryImpl(e.path,e.collectionGroup,s,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(e._query,i))}}function orderBy(e,i="asc"){const s=i,T=_("orderBy",e);return QueryOrderByConstraint._create(T,s)}class QueryLimitConstraint extends QueryConstraint{constructor(e,i,s){super(),this.type=e,this._limit=i,this._limitType=s}static _create(e,i,s){return new QueryLimitConstraint(e,i,s)}_apply(e){return new Query(e.firestore,e.converter,function __PRIVATE_queryWithLimit(e,i,s){return new __PRIVATE_QueryImpl(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),i,s,e.startAt,e.endAt)}(e._query,this._limit,this._limitType))}}function limit(e){return __PRIVATE_validatePositiveNumber("limit",e),QueryLimitConstraint._create("limit",e,"F")}function limitToLast(e){return __PRIVATE_validatePositiveNumber("limitToLast",e),QueryLimitConstraint._create("limitToLast",e,"L")}class QueryStartAtConstraint extends QueryConstraint{constructor(e,i,s){super(),this.type=e,this._docOrFields=i,this._inclusive=s}static _create(e,i,s){return new QueryStartAtConstraint(e,i,s)}_apply(e){const i=__PRIVATE_newQueryBoundFromDocOrFields(e,this.type,this._docOrFields,this._inclusive);return new Query(e.firestore,e.converter,function __PRIVATE_queryWithStartAt(e,i){return new __PRIVATE_QueryImpl(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,i,e.endAt)}(e._query,i))}}function startAt(...e){return QueryStartAtConstraint._create("startAt",e,!0)}function startAfter(...e){return QueryStartAtConstraint._create("startAfter",e,!1)}class QueryEndAtConstraint extends QueryConstraint{constructor(e,i,s){super(),this.type=e,this._docOrFields=i,this._inclusive=s}static _create(e,i,s){return new QueryEndAtConstraint(e,i,s)}_apply(e){const i=__PRIVATE_newQueryBoundFromDocOrFields(e,this.type,this._docOrFields,this._inclusive);return new Query(e.firestore,e.converter,function __PRIVATE_queryWithEndAt(e,i){return new __PRIVATE_QueryImpl(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,i)}(e._query,i))}}function endBefore(...e){return QueryEndAtConstraint._create("endBefore",e,!1)}function endAt(...e){return QueryEndAtConstraint._create("endAt",e,!0)}function __PRIVATE_newQueryBoundFromDocOrFields(e,i,s,T){if(s[0]=getModularInstance(s[0]),s[0]instanceof it)return function __PRIVATE_newQueryBoundFromDocument(e,i,s,T,E){if(!T)throw new k(ie,`Can't use a DocumentSnapshot that doesn't exist for ${s}().`);const V=[];for(const s of __PRIVATE_queryNormalizedOrderBy(e))if(s.field.isKeyField())V.push(__PRIVATE_refValue(i,T.key));else{const e=T.data.field(s.field);if(__PRIVATE_isServerTimestamp(e))throw new k(re,'Invalid query. You are trying to start or end a query using a document for which the field "'+s.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=s.field.canonicalString();throw new k(re,`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.`)}V.push(e)}return new Bound(V,E)}(e._query,e.firestore._databaseId,i,s[0]._document,T);{const E=p(e.firestore);return function __PRIVATE_newQueryBoundFromFields(e,i,s,T,E,V){const R=e.explicitOrderBy;if(E.length>R.length)throw new k(re,`Too many arguments provided to ${T}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);const N=[];for(let V=0;V<E.length;V++){const M=E[V];if(R[V].field.isKeyField()){if("string"!=typeof M)throw new k(re,`Invalid query. Expected a string for document ID in ${T}(), but got a ${typeof M}`);if(!__PRIVATE_isCollectionGroupQuery(e)&&-1!==M.indexOf("/"))throw new k(re,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${T}() must be a plain document ID, but '${M}' contains a slash.`);const s=e.path.child(ResourcePath.fromString(M));if(!S.isDocumentKey(s))throw new k(re,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${T}() must result in a valid document path, but '${s}' is not because it contains an odd number of segments.`);const E=new S(s);N.push(__PRIVATE_refValue(i,E))}else{const e=__PRIVATE_parseQueryValue(s,T,M);N.push(e)}}return new Bound(N,V)}(e._query,e.firestore._databaseId,E,i,s,T)}}function __PRIVATE_parseDocumentIdValue(e,i,s){if("string"==typeof(s=getModularInstance(s))){if(""===s)throw new k(re,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!__PRIVATE_isCollectionGroupQuery(i)&&-1!==s.indexOf("/"))throw new k(re,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${s}' contains a '/' character.`);const T=i.path.child(ResourcePath.fromString(s));if(!S.isDocumentKey(T))throw new k(re,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${T}' is not because it has an odd number of segments (${T.length}).`);return __PRIVATE_refValue(e,new S(T))}if(s instanceof DocumentReference)return __PRIVATE_refValue(e,s._key);throw new k(re,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${__PRIVATE_valueDescription(s)}.`)}function __PRIVATE_validateDisjunctiveFilterElements(e,i){if(!Array.isArray(e)||0===e.length)throw new k(re,`Invalid Query. A non-empty array is required for '${i.toString()}' filters.`)}function __PRIVATE_validateNewFieldFilter(e,i){const s=function __PRIVATE_findOpInsideFilters(e,i){for(const s of e)for(const e of s.getFlattenedFilters())if(i.indexOf(e.op)>=0)return e.op;return null}(e.filters,function __PRIVATE_conflictingOps(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[]}}(i.op));if(null!==s)throw s===i.op?new k(re,`Invalid query. You cannot use more than one '${i.op.toString()}' filter.`):new k(re,`Invalid query. You cannot use '${i.op.toString()}' filters with '${s.toString()}' filters.`)}function __PRIVATE_validateQueryFilterConstraint(e,i){if(!(i instanceof QueryFieldFilterConstraint||i instanceof QueryCompositeFilterConstraint))throw new k(re,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}class AbstractUserDataWriter{convertValue(e,i="none"){switch(__PRIVATE_typeOrder(e)){case 0:return null;case 2:return e.booleanValue;case 3:if("mapValue"in e){if(__PRIVATE_isInt32Value(e))return this.convertToInt32Value(e.mapValue);if(__PRIVATE_isDecimal128Value(e))return this.convertToDecimal128Value(e.mapValue)}return __PRIVATE_normalizeNumber(e.integerValue||e.doubleValue);case 4:return this.convertTimestamp(e.timestampValue);case 6:return this.convertServerTimestamp(e,i);case 7:return e.stringValue;case 8:return"bytesValue"in e?this.convertBytes(__PRIVATE_normalizeByteString(e.bytesValue)):this.convertToBytesWithSubtype(e.mapValue);case 9:return this.convertReference(e.referenceValue);case 11:return this.convertGeoPoint(e.geoPointValue);case 13:return this.convertArray(e.arrayValue,i);case 15:return this.convertObject(e.mapValue,i);case 14:return this.convertVectorValue(e.mapValue);case 12:return this.convertToRegexValue(e.mapValue);case 10:return this.convertToBsonObjectId(e.mapValue);case 5:return this.convertToBsonTimestamp(e.mapValue);case 16:return MaxKey.instance();case 1:return MinKey.instance();default:throw z(62114,{value:e})}}convertObject(e,i){return this.convertObjectMap(e.fields,i)}convertObjectMap(e,i="none"){const s={};return forEach(e,((e,T)=>{s[e]=this.convertValue(T,i)})),s}convertVectorValue(e){const i=e.fields?.[Me].arrayValue?.values?.map((e=>__PRIVATE_normalizeNumber(e.doubleValue)));return new VectorValue(i)}convertToBsonObjectId(e){const i=e.fields?.[$e]?.stringValue??"";return new BsonObjectId(i)}convertToBytesWithSubtype(e){const i=e.fields?.[Ye],s=i?.bytesValue;if(!s)throw new Error("Received incorrect bytesValue for Bytes with subtype");const T=__PRIVATE_normalizeByteString(s).toUint8Array();if(0===T.length)throw new Error("Received empty bytesValue for Bytes with subtype");const E=T[0],V=T.slice(1);return new Bytes(ByteString.fromUint8Array(V),E)}convertToBsonTimestamp(e){const i=e.fields?.[Ke],s=Number(i?.mapValue?.fields?.[He]?.integerValue),T=Number(i?.mapValue?.fields?.[Je]?.integerValue);return new BsonTimestamp(s,T)}convertToRegexValue(e){const i=e.fields?.[je]?.mapValue?.fields?.[Ue]?.stringValue??"",s=e.fields?.[je]?.mapValue?.fields?.[ze]?.stringValue??"";return new RegexValue(i,s)}convertToInt32Value(e){const i=Number(e.fields?.[We]?.integerValue);return new Int32Value(i)}convertToDecimal128Value(e){const i=e.fields?.[Ge]?.stringValue??"";return new Decimal128Value(i)}convertGeoPoint(e){return new GeoPoint(__PRIVATE_normalizeNumber(e.latitude),__PRIVATE_normalizeNumber(e.longitude))}convertArray(e,i){return(e.values||[]).map((e=>this.convertValue(e,i)))}convertServerTimestamp(e,i){switch(i){case"previous":const s=__PRIVATE_getPreviousValue(e);return null==s?null:this.convertValue(s,i);case"estimate":return this.convertTimestamp(__PRIVATE_getLocalWriteTime(e));default:return null}}convertTimestamp(e){const i=__PRIVATE_normalizeTimestamp(e);return new Timestamp(i.seconds,i.nanos)}convertDocumentKey(e,i){const s=ResourcePath.fromString(e);__PRIVATE_hardAssert(__PRIVATE_isValidResourceName(s),9688,{name:e});const T=new DatabaseId(s.get(1),s.get(3)),E=new S(s.popFirst(5));return T.isEqual(i)||st(`A document reference to ${E} refers to a different database (${T.projectId}/${T.database}), which is not supported. It will be treated as a reference in the current database (${i.projectId}/${i.database}) instead.`),E}}function w(e,i,s){let T;return T=e?s&&(s.merge||s.mergeFields)?e.toFirestore(i,s):e.toFirestore(i):i,T}class A extends AbstractUserDataWriter{constructor(e){super(),this.firestore=e}convertBytes(e){return new Bytes(e)}convertReference(e){const i=this.convertDocumentKey(e,this.firestore._databaseId);return new DocumentReference(this.firestore,null,i)}}function getDoc(e){const i=d((e=f(e,DocumentReference)).firestore),s=new A(e.firestore);return C(i,[e._key]).then((i=>{__PRIVATE_hardAssert(1===i.length,15618);const T=i[0];return new it(e.firestore,s,e._key,T.isFoundDocument()?T:null,e.converter)}))}function getDocs(e){!function __PRIVATE_validateHasExplicitOrderByForLimitToLast(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new k(he,"limitToLast() queries require specifying at least one orderBy() clause")}((e=f(e,Query))._query);const i=d(e.firestore),s=new A(e.firestore);return async function __PRIVATE_invokeRunQueryRpc(e,i){const s=__PRIVATE_debugCast(e),{Mt:T,parent:E}=__PRIVATE_toQueryTarget(s.serializer,__PRIVATE_queryToTarget(i));return(await s.me("RunQuery",s.serializer.databaseId,E,{structuredQuery:T.structuredQuery})).filter((e=>!!e.document)).map((e=>function fromDocument(e,i,s){const T=fromName(e,i.name),E=__PRIVATE_fromVersion(i.updateTime),V=i.createTime?__PRIVATE_fromVersion(i.createTime):j.min(),R=new u({mapValue:{fields:i.fields}}),N=MutableDocument.newFoundDocument(T,E,V,R);return s?N.setHasCommittedMutations():N}(s.serializer,e.document,void 0)))}(i,e._query).then((i=>{const T=i.map((i=>new QueryDocumentSnapshot(e.firestore,s,i.key,i,e.converter)));return"L"===e._query.limitType&&T.reverse(),new QuerySnapshot(e,T)}))}function setDoc(e,i,s){const T=w((e=f(e,DocumentReference)).converter,i,s),E=y(p(e.firestore),"setDoc",e._key,T,null!==e.converter,s);return O(d(e.firestore),[E.toMutation(e._key,P.none())])}function updateDoc(e,i,s,...T){const E=p((e=f(e,DocumentReference)).firestore);let V;return V="string"==typeof(i=getModularInstance(i))||i instanceof D?b(E,"updateDoc",e._key,i,s,T):v(E,"updateDoc",e._key,i),O(d(e.firestore),[V.toMutation(e._key,P.exists(!0))])}function deleteDoc(e){return O(d((e=f(e,DocumentReference)).firestore),[new F(e._key,P.none())])}function addDoc(e,i){const s=doc(e=f(e,CollectionReference)),T=w(e.converter,i),E=y(p(e.firestore),"addDoc",s._key,T,null!==s.converter,{});return O(d(e.firestore),[E.toMutation(s._key,P.exists(!1))]).then((()=>s))}function deleteField(){return new __PRIVATE_DeleteFieldValueImpl("deleteField")}function serverTimestamp(){return new __PRIVATE_ServerTimestampFieldValueImpl("serverTimestamp")}function arrayUnion(...e){return new __PRIVATE_ArrayUnionFieldValueImpl("arrayUnion",e)}function arrayRemove(...e){return new __PRIVATE_ArrayRemoveFieldValueImpl("arrayRemove",e)}function increment(e){return new __PRIVATE_NumericIncrementFieldValueImpl("increment",e)}function minimum(e){return new __PRIVATE_NumericMinimumFieldValueImpl("minimum",e)}function maximum(e){return new __PRIVATE_NumericMaximumFieldValueImpl("maximum",e)}function vector(e){return new VectorValue(e)}const pt="4.20.0";class __PRIVATE_Deferred{constructor(){this.promise=new Promise(((e,i)=>{this.resolve=e,this.reject=i}))}}class __PRIVATE_AggregateImpl{constructor(e,i,s){this.alias=e,this.aggregateType=i,this.fieldPath=s}}class __PRIVATE_ExponentialBackoff{constructor(e,i,s=1e3,T=1.5,E=6e4){this.t=e,this.timerId=i,this.i=s,this.o=T,this.h=E,this.u=0,this.l=null,this._=Date.now(),this.reset()}reset(){this.u=0}m(){this.u=this.h}A(e){this.cancel();const i=Math.floor(this.u+this.p()),s=Math.max(0,Date.now()-this._),T=Math.max(0,i-s);T>0&&a("ExponentialBackoff",`Backing off for ${T} ms (base delay: ${this.u} ms, delay with jitter: ${i} ms, last attempt: ${s} ms ago)`),this.l=this.t.enqueueAfterDelay(this.timerId,T,(()=>(this._=Date.now(),e()))),this.u*=this.o,this.u<this.i&&(this.u=this.i),this.u>this.h&&(this.u=this.h)}T(){null!==this.l&&(this.l.skipDelay(),this.l=null)}cancel(){null!==this.l&&(this.l.cancel(),this.l=null)}p(){return(Math.random()-.5)*this.u}}class AggregateField{constructor(e="count",i){this._internalFieldPath=i,this.type="AggregateField",this.aggregateType=e}}class AggregateQuerySnapshot{constructor(e,i,s){this._userDataWriter=i,this._data=s,this.type="AggregateQuerySnapshot",this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}_fieldsProto(){return new u({mapValue:{fields:this._data}}).clone().value.mapValue.fields}}function getCount(e){return getAggregate(e,{count:count()})}function getAggregate(e,i){const s=f(e.firestore,n),T=d(s),E=function g(e,i){const s=[];for(const T in e)Object.prototype.hasOwnProperty.call(e,T)&&s.push(i(e[T],T,e));return s}(i,((e,i)=>new __PRIVATE_AggregateImpl(i,e.aggregateType,e._internalFieldPath)));return async function m(e,i,s){const T=__PRIVATE_debugCast(e),{request:E,Ut:V,parent:R}=function __PRIVATE_toRunAggregationQueryRequest(e,i,s){const{Mt:T,parent:E}=__PRIVATE_toQueryTarget(e,i),V={},R=[];let N=0;return s.forEach((e=>{const i="aggregate_"+N++;V[i]=e.alias,"count"===e.aggregateType?R.push({alias:i,count:{}}):"avg"===e.aggregateType?R.push({alias:i,avg:{field:__PRIVATE_toFieldPathReference(e.fieldPath)}}):"sum"===e.aggregateType&&R.push({alias:i,sum:{field:__PRIVATE_toFieldPathReference(e.fieldPath)}})})),{request:{structuredAggregationQuery:{aggregations:R,structuredQuery:T.structuredQuery},parent:T.parent},Ut:V,parent:E}}(T.serializer,function __PRIVATE_queryToAggregateTarget(e){const i=__PRIVATE_debugCast(e);return i.Bt||(i.Bt=__PRIVATE__queryToTarget(i,e.explicitOrderBy)),i.Bt}(i),s);T.connection.ae||delete E.parent;const N=(await T.me("RunAggregationQuery",T.serializer.databaseId,R,E,1)).filter((e=>!!e.result));__PRIVATE_hardAssert(1===N.length,64727);const M=N[0].result?.aggregateFields;return Object.keys(M).reduce(((e,i)=>(e[V[i]]=M[i],e)),{})}(T,e._query,E).then((i=>function __PRIVATE_convertToAggregateQuerySnapshot(e,i,s){const T=new A(e);return new AggregateQuerySnapshot(i,T,s)}(s,e,i)))}function sum(e){return new AggregateField("sum",_("sum",e))}function average(e){return new AggregateField("avg",_("average",e))}function count(){return new AggregateField("count")}function aggregateFieldEqual(e,i){return e instanceof AggregateField&&i instanceof AggregateField&&e.aggregateType===i.aggregateType&&e._internalFieldPath?.canonicalString()===i._internalFieldPath?.canonicalString()}function aggregateQuerySnapshotEqual(e,i){return l(e.query,i.query)&&deepEqual(e.data(),i.data())}class WriteBatch{constructor(e,i){this._firestore=e,this._commitHandler=i,this._mutations=[],this._committed=!1,this._dataReader=p(e)}set(e,i,s){this._verifyNotCommitted();const T=__PRIVATE_validateReference(e,this._firestore),E=w(T.converter,i,s),V=y(this._dataReader,"WriteBatch.set",T._key,E,null!==T.converter,s);return this._mutations.push(V.toMutation(T._key,P.none())),this}update(e,i,s,...T){this._verifyNotCommitted();const E=__PRIVATE_validateReference(e,this._firestore);let V;return V="string"==typeof(i=getModularInstance(i))||i instanceof D?b(this._dataReader,"WriteBatch.update",E._key,i,s,T):v(this._dataReader,"WriteBatch.update",E._key,i),this._mutations.push(V.toMutation(E._key,P.exists(!0))),this}delete(e){this._verifyNotCommitted();const i=__PRIVATE_validateReference(e,this._firestore);return this._mutations=this._mutations.concat(new F(i._key,P.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new k(le,"A write batch can no longer be used after commit() has been called.")}}function __PRIVATE_validateReference(e,i){if((e=getModularInstance(e)).firestore!==i)throw new k(re,"Provided document reference is from a different Firestore instance.");return e}function writeBatch(e){const i=d(e=f(e,n));return new WriteBatch(e,(e=>O(i,e)))}let gt=class Transaction{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new k(re,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;const i=await C(this.datastore,e);return i.forEach((e=>this.recordVersion(e))),i}set(e,i){this.write(i.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}update(e,i){try{this.write(i.toMutation(e,this.preconditionForUpdate(e)))}catch(e){this.lastTransactionError=e}this.writtenDocs.add(e.toString())}delete(e){this.write(new F(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;const e=this.readVersions;this.mutations.forEach((i=>{e.delete(i.key.toString())})),e.forEach(((e,i)=>{const s=S.fromPath(i);this.mutations.push(new q(s,this.precondition(s)))})),await O(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let i;if(e.isFoundDocument())i=e.version;else{if(!e.isNoDocument())throw z(50498,{R:e.constructor.name});i=j.min()}const s=this.readVersions.get(e.key.toString());if(s){if(!i.isEqual(s))throw new k(ce,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),i)}precondition(e){const i=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&i?i.isEqual(j.min())?P.exists(!1):P.updateTime(i):P.none()}preconditionForUpdate(e){const i=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&i){if(i.isEqual(j.min()))throw new k(re,"Can't update a document that doesn't exist.");return P.updateTime(i)}return P.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}};const Tt={maxAttempts:5};class __PRIVATE_TransactionRunner{constructor(e,i,s,T,E){this.asyncQueue=e,this.datastore=i,this.options=s,this.updateFunction=T,this.deferred=E,this.I=s.maxAttempts,this.P=new __PRIVATE_ExponentialBackoff(this.asyncQueue,"transaction_retry")}V(){this.I-=1,this.D()}D(){this.P.A((async()=>{const e=new gt(this.datastore),i=this.v(e);i&&i.then((i=>{this.asyncQueue.enqueueAndForget((()=>e.commit().then((()=>{this.deferred.resolve(i)})).catch((e=>{this.F(e)}))))})).catch((e=>{this.F(e)}))}))}v(e){try{const i=this.updateFunction(e);return!tt(i)&&i.catch&&i.then?i:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}F(e){this.I>0&&this.B(e)?(this.I-=1,this.asyncQueue.enqueueAndForget((()=>(this.D(),Promise.resolve())))):this.deferred.reject(e)}B(e){if("FirebaseError"===e?.name){const i=e.code;return"aborted"===i||"failed-precondition"===i||"already-exists"===i||!function et(e){switch(e){case Z:return z(64938);case ee:case te:case ne:case ue:case de:case fe:case oe:return!1;case re:case ie:case se:case ae:case le:case ce:case _e:case he:case me:return!0;default:return z(15467,{code:e})}}(i)}return!1}}function getDocument(){return"undefined"!=typeof document?document:null}class DelayedOperation{constructor(e,i,s,T,E){this.asyncQueue=e,this.timerId=i,this.targetTimeMs=s,this.op=T,this.removalCallback=E,this.deferred=new __PRIVATE_Deferred,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((e=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(e,i,s,T,E){const V=Date.now()+s,R=new DelayedOperation(e,i,V,T,E);return R.start(s),R}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new k(ee,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then((e=>this.deferred.resolve(e)))):Promise.resolve()))}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}const Et="AsyncQueue";class __PRIVATE_AsyncQueueImpl{constructor(e=Promise.resolve()){this.k=[],this.O=!1,this.C=[],this.S=null,this.q=!1,this.M=!1,this.N=[],this.P=new __PRIVATE_ExponentialBackoff(this,"async_queue_retry"),this.L=()=>{const e=getDocument();e&&a(Et,"Visibility state changed to "+e.visibilityState),this.P.T()},this.W=e;const i=getDocument();i&&"function"==typeof i.addEventListener&&i.addEventListener("visibilitychange",this.L)}get isShuttingDown(){return this.O}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.U(),this.j(e)}enterRestrictedMode(e){if(!this.O){this.O=!0,this.M=e||!1;const i=getDocument();i&&"function"==typeof i.removeEventListener&&i.removeEventListener("visibilitychange",this.L)}}enqueue(e){if(this.U(),this.O)return new Promise((()=>{}));const i=new __PRIVATE_Deferred;return this.j((()=>this.O&&this.M?Promise.resolve():(e().then(i.resolve,i.reject),i.promise))).then((()=>i.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.k.push(e),this.$())))}async $(){if(0!==this.k.length){try{await this.k[0](),this.k.shift(),this.P.reset()}catch(e){if(!function __PRIVATE_isIndexedDbTransactionError(e){return"IndexedDbTransactionError"===e.name}(e))throw e;a(Et,"Operation failed with retryable error: "+e)}this.k.length>0&&this.P.A((()=>this.$()))}}j(e){const i=this.W.then((()=>(this.q=!0,e().catch((e=>{this.S=e,this.q=!1;throw st("INTERNAL UNHANDLED ERROR: ",__PRIVATE_getMessageOrStack(e)),e})).then((e=>(this.q=!1,e))))));return this.W=i,i}enqueueAfterDelay(e,i,s){this.U(),this.N.indexOf(e)>-1&&(i=0);const T=DelayedOperation.createAndSchedule(this,e,i,s,(e=>this.G(e)));return this.C.push(T),T}U(){this.S&&z(47125,{K:__PRIVATE_getMessageOrStack(this.S)})}verifyOperationInProgress(){}async H(){let e;do{e=this.W,await e}while(e!==this.W)}J(e){for(const i of this.C)if(i.timerId===e)return!0;return!1}X(e){return this.H().then((()=>{this.C.sort(((e,i)=>e.targetTimeMs-i.targetTimeMs));for(const i of this.C)if(i.skipDelay(),"all"!==e&&i.timerId===e)break;return this.H()}))}Y(e){this.N.push(e)}G(e){const i=this.C.indexOf(e);this.C.splice(i,1)}}function __PRIVATE_getMessageOrStack(e){let i=e.message||"";return e.stack&&(i=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),i}class Transaction{constructor(e,i){this._firestore=e,this._transaction=i,this._dataReader=p(e)}get(e){const i=__PRIVATE_validateReference(e,this._firestore),s=new A(this._firestore);return this._transaction.lookup([i._key]).then((e=>{if(!e||1!==e.length)return z(24041);const T=e[0];if(T.isFoundDocument())return new it(this._firestore,s,T.key,T,i.converter);if(T.isNoDocument())return new it(this._firestore,s,i._key,null,i.converter);throw z(18433,{doc:T})}))}set(e,i,s){const T=__PRIVATE_validateReference(e,this._firestore),E=w(T.converter,i,s),V=y(this._dataReader,"Transaction.set",T._key,E,null!==T.converter,s);return this._transaction.set(T._key,V),this}update(e,i,s,...T){const E=__PRIVATE_validateReference(e,this._firestore);let V;return V="string"==typeof(i=getModularInstance(i))||i instanceof D?b(this._dataReader,"Transaction.update",E._key,i,s,T):v(this._dataReader,"Transaction.update",E._key,i),this._transaction.update(E._key,V),this}delete(e){const i=__PRIVATE_validateReference(e,this._firestore);return this._transaction.delete(i._key),this}}function runTransaction(e,i,s){const T=d(e=f(e,n)),E={...Tt,...s};!function __PRIVATE_validateTransactionOptions(e){if(e.maxAttempts<1)throw new k(re,"Max attempts must be at least 1")}(E);const V=new __PRIVATE_Deferred;return new __PRIVATE_TransactionRunner(function __PRIVATE_newAsyncQueue(){return new __PRIVATE_AsyncQueueImpl}(),T,E,(s=>i(new Transaction(e,s))),V).V(),V.promise}!function __PRIVATE_registerFirestore(){(function c(e){Y=e})(`${V}_lite`),T(new Component("firestore/lite",((e,{instanceIdentifier:i,options:s})=>{const T=e.getProvider("app").getImmediate(),E=new n(new r(e.getProvider("auth-internal")),new o(T,e.getProvider("app-check-internal")),function h(e,i){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new k(re,'"projectId" not provided in firebase.initializeApp.');return new DatabaseId(e.options.projectId,i)}(T,i),T);return s&&E._setSettings(s),E}),"PUBLIC").setMultipleInstances(!0)),E("firestore-lite",pt,""),E("firestore-lite",pt,"esm2020")}();export{AggregateField,AggregateQuerySnapshot,BsonObjectId,BsonTimestamp,Bytes,CollectionReference,Decimal128Value,DocumentReference,it as DocumentSnapshot,D as FieldPath,FieldValue,n as Firestore,k as FirestoreError,GeoPoint,Int32Value,MaxKey,MinKey,Query,QueryCompositeFilterConstraint,QueryConstraint,QueryDocumentSnapshot,QueryEndAtConstraint,QueryFieldFilterConstraint,QueryLimitConstraint,QueryOrderByConstraint,QuerySnapshot,QueryStartAtConstraint,RegexValue,Timestamp,Transaction,VectorValue,WriteBatch,addDoc,aggregateFieldEqual,aggregateQuerySnapshotEqual,and,arrayRemove,arrayUnion,average,collection,collectionGroup,connectFirestoreEmulator,count,deleteDoc,deleteField,doc,documentId,endAt,endBefore,getAggregate,getCount,getDoc,getDocs,getFirestore,increment,initializeFirestore,limit,limitToLast,maximum,minimum,or,orderBy,query,l as queryEqual,refEqual,runTransaction,serverTimestamp,setDoc,setLogLevel,snapshotEqual,startAfter,startAt,sum,terminate,updateDoc,vector,where,writeBatch};
//# sourceMappingURL=firebase-firestore-lite.js.map