PageSourceSearch

https://xynergy.ai/_next/static/chunks/77213e72-67298ee8b4f67883.js

js xynergy.ai collected 2026-10-05 16:00:31 UTC 171,676 bytes, 7 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8721],{6173:(e,t,r)=>{r.d(t,{$:()=>iK,A:()=>i2,B:()=>iI,C:()=>tn,D:()=>im,F:()=>iT,H:()=>i3,N:()=>M,Q:()=>id,R:()=>z,U:()=>_,W:()=>iF,X:()=>t5,Y:()=>iC,Z:()=>iG,_:()=>g,a:()=>x,a$:()=>i6,a0:()=>ro,a2:()=>is,a4:()=>ii,a6:()=>iy,a7:()=>tE,a8:()=>ir,aL:()=>i8,aM:()=>i5,aO:()=>ip,aR:()=>i4,aT:()=>ib,aX:()=>i_,aY:()=>i9,ac:()=>ia,an:()=>te,az:()=>er,b:()=>O,c:()=>eF,d:()=>b,e:()=>C,f:()=>tC,g:()=>iM,h:()=>ij,i:()=>tr,j:()=>iJ,k:()=>tb,l:()=>tA,m:()=>Z,n:()=>tN,o:()=>tD,p:()=>ee,q:()=>tS,r:()=>eY,s:()=>ex,t:()=>e8,u:()=>t_,v:()=>j,w:()=>J,y:()=>X,z:()=>iS});var n,s,i,a,o=r(85384),l=r(75291),u=r(96521),h=r(23650),c=r(51053);r(32407);var d=r(9291).Buffer;class f{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}}f.UNAUTHENTICATED=new f(null),f.GOOGLE_CREDENTIALS=new f("google-credentials-uid"),f.FIRST_PARTY=new f("first-party-uid"),f.MOCK_USER=new f("mock-user");let m="12.13.0";function g(e){m=e}let p=new h.Vy("@firebase/firestore");function y(){return p.logLevel}function v(e,...t){if(p.logLevel<=h.$b.DEBUG){let r=t.map(T);p.debug(`Firestore (${m}): ${e}`,...r)}}function w(e,...t){if(p.logLevel<=h.$b.ERROR){let r=t.map(T);p.error(`Firestore (${m}): ${e}`,...r)}}function E(e,...t){if(p.logLevel<=h.$b.WARN){let r=t.map(T);p.warn(`Firestore (${m}): ${e}`,...r)}}function T(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return e}}function _(e,t,r){let n="Unexpected state";"string"==typeof t?n=t:r=t,S(e,n,r)}function S(e,t,r){let n=`FIRESTORE (${m}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==r)try{n+=" CONTEXT: "+JSON.stringify(r)}catch(e){n+=" CONTEXT: "+r}throw w(n),Error(n)}function I(e,t,r,n){let s="Unexpected state";"string"==typeof r?s=r:n=r,e||S(t,s,n)}let C={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENTED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class b extends l.g{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class A{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class N{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class D{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(f.UNAUTHENTICATED))}shutdown(){}}class k{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}}class x{constructor(e){this.t=e,this.currentUser=f.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){I(void 0===this.o,42304);let r=this.i,n=e=>this.i!==r?(r=this.i,t(e)):Promise.resolve(),s=new A;this.o=()=>{this.i++,this.currentUser=this.u(),s.resolve(),s=new A,e.enqueueRetryable(()=>n(this.currentUser))};let i=()=>{let t=s;e.enqueueRetryable(async()=>{await t.promise,await n(this.currentUser)})},a=e=>{v("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),i())};this.t.onInit(e=>a(e)),setTimeout(()=>{if(!this.auth){let e=this.t.getImmediate({optional:!0});e?a(e):(v("FirebaseAuthCredentialsProvider","Auth not yet detected"),s.resolve(),s=new A)}},0),i()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(t=>this.i!==e?(v("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(I("str
1ing"==typeof t.accessToken,31837,{l:t}),new N(t.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){let e=this.auth&&this.auth.getUid();return I(null===e||"string"==typeof e,2055,{h:e}),new f(e)}}class R{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=f.FIRST_PARTY,this.R=new Map}A(){return this.I?this.I():null}get headers(){this.R.set("X-Goog-AuthUser",this.P);let e=this.A();return e&&this.R.set("Authorization",e),this.T&&this.R.set("X-Goog-Iam-Authorization-Token",this.T),this.R}}class V{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new R(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(f.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class L{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(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,(0,o.xZ)(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){I(void 0===this.o,3512);let r=e=>{null!=e.error&&v("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);let r=e.token!==this.m;return this.m=e.token,v("FirebaseAppCheckTokenProvider",`Received ${r?"new":"existing"} token.`),r?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable(()=>r(t))};let n=e=>{v("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(e=>n(e)),setTimeout(()=>{if(!this.appCheck){let e=this.V.getImmediate({optional:!0});e?n(e):v("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new L(this.p));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(I("string"==typeof e.token,44558,{tokenResult:e}),this.m=e.token,new L(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}class M{static newId(){let e=62*Math.floor(256/62),t="";for(;t.length<20;){let r=function(){let e="u">typeof self&&(self.crypto||self.msCrypto),t=new Uint8Array(40);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(t);else for(let e=0;e<40;e++)t[e]=Math.floor(256*Math.random());return t}();for(let n=0;n<r.length;++n)t.length<20&&r[n]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(r[n]%62))}return t}}function F(e,t){return e<t?-1:+(e>t)}function P(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++){let r=e.charAt(n),s=t.charAt(n);if(r!==s)return U(r)===U(s)?F(r,s):U(r)?1:-1}return F(e.length,t.length)}function U(e){let t=e.charCodeAt(0);return t>=55296&&t<=57343}function q(e,t,r){return e.length===t.length&&e.every((e,n)=>r(e,t[n]))}let $="__name__";class B{constructor(e,t,r){void 0===t?t=0:t>e.length&&_(637,{offset:t,range:e.length}),void 0===r?r=e.length-t:r>e.length-t&&_(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return 0===B.comparator(this,e)}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof B?e.forEach(e=>{t.push(e)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++){let r=B.compareSegments(e.get(n),t.get(n));if(0!==r)return r}return F(e.length,t.length)}static compareSegments(e,t){let r=B.isNumericId(e),n=B.isNumericId(t);return r&&!n?-1:!r&&n?1:r&&n?B.extractNumericId(e).compare(B.extractNumericId(t)):P(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return u.jz.fromString(e.substring(4,e.length-2))}}class z extends B{construct(e,t,r){return new z(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}
1toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let r of e){if(r.indexOf("//")>=0)throw new b(C.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter(e=>e.length>0))}return new z(t)}static emptyPath(){return new z([])}}let K=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class G extends B{construct(e,t,r){return new G(e,t,r)}static isValidIdentifier(e){return K.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),G.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===$}static keyField(){return new G([$])}static fromServerFormat(e){let t=[],r="",n=0,s=()=>{if(0===r.length)throw new b(C.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""},i=!1;for(;n<e.length;){let t=e[n];if("\\"===t){if(n+1===e.length)throw new b(C.INVALID_ARGUMENT,"Path has trailing escape character: "+e);let t=e[n+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new b(C.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=t,n+=2}else"`"===t?i=!i:"."!==t||i?r+=t:s(),n++}if(s(),i)throw new b(C.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new G(t)}static emptyPath(){return new G([])}}class j{constructor(e){this.path=e}static fromPath(e){return new j(z.fromString(e))}static fromName(e){return new j(z.fromString(e).popFirst(5))}static empty(){return new j(z.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===z.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return z.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new j(new z(e.slice()))}}function Q(e,t,r){if(!r)throw new b(C.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function H(e){if(!j.isDocumentKey(e))throw new b(C.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function W(e){if(j.isDocumentKey(e))throw new b(C.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function Y(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function J(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";{var t;let r=(t=e).constructor?t.constructor.name:null;return r?`a custom ${r} object`:"an object"}}return"function"==typeof e?"a function":_(12329,{type:typeof e})}function X(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new b(C.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let r=J(e);throw new b(C.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${r}`)}}return e}function Z(e,t){if(t<=0)throw new b(C.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}function ee(e,t){let r={typeString:e};return t&&(r.value=t),r}function et(e,t){let r;if(!Y(e))throw new b(C.INVALID_ARGUMENT,"JSON must be an object");for(let n in t)if(t[n]){let s=t[n].typeString,i="value"in t[n]?{value:t[n].value}:void 0;if(!(n in e)){r=`JSON missing required field: '${n}'`;break}let a=e[n];if(s&&typeof a!==s){r=`JSON field '${n}' must be a ${s}.`;break}if(void 0!==i&&a!==i.value){r=`Expected '${n}' field to equal '${i.value}'`;break}}if(r)throw new b(C.INVALID_ARGUMENT,r);return!0}class er{static now(){return er.fromMillis(Date.now())}static fromDate(e){return er.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*1e6);return new er(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0||t>=1e9)throw new b(C.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-0xe7791f700||e>=0x3afff44180)throw new b(C.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?F(this.nanoseconds,e.nanoseconds):F(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:er._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(et(e,er._jsonSchema))return new er(e.seconds,e.nanoseconds)}valueOf(){return String(this.seconds- -0xe7791f700).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}
1}er._jsonSchemaVersion="firestore/timestamp/1.0",er._jsonSchema={type:ee("string",er._jsonSchemaVersion),seconds:ee("number"),nanoseconds:ee("number")};class en{static fromTimestamp(e){return new en(e)}static min(){return new en(new er(0,0))}static max(){return new en(new er(0x3afff4417f,0x3b9ac9ff))}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 es{constructor(e,t,r,n){this.indexId=e,this.collectionGroup=t,this.fields=r,this.indexState=n}}es.UNKNOWN_ID=-1;class ei{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new ei(en.min(),j.empty(),-1)}static max(){return new ei(en.max(),j.empty(),-1)}}class ea{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}async function eo(e){if(e.code!==C.FAILED_PRECONDITION||"The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab."!==e.message)throw e;v("LocalStore","Unexpectedly lost primary lease")}class el{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)},e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&_(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new el((r,n)=>{this.nextCallback=t=>{this.wrapSuccess(e,t).next(r,n)},this.catchCallback=e=>{this.wrapFailure(t,e).next(r,n)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{let t=e();return t instanceof el?t:el.resolve(t)}catch(e){return el.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):el.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):el.reject(t)}static resolve(e){return new el((t,r)=>{t(e)})}static reject(e){return new el((t,r)=>{r(e)})}static waitFor(e){return new el((t,r)=>{let n=0,s=0,i=!1;e.forEach(e=>{++n,e.next(()=>{++s,i&&s===n&&t()},e=>r(e))}),i=!0,s===n&&t()})}static or(e){let t=el.resolve(!1);for(let r of e)t=t.next(e=>e?el.resolve(e):r());return t}static forEach(e,t){let r=[];return e.forEach((e,n)=>{r.push(t.call(this,e,n))}),this.waitFor(r)}static mapArray(e,t){return new el((r,n)=>{let s=e.length,i=Array(s),a=0;for(let o=0;o<s;o++){let l=o;t(e[l]).next(e=>{i[l]=e,++a===s&&r(i)},e=>n(e))}})}static doWhile(e,t){return new el((r,n)=>{let s=()=>{!0===e()?t().next(()=>{s()},n):r()};s()})}}function eu(e){return"IndexedDbTransactionError"===e.name}class eh{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.ae(e),this.ue=e=>t.writeSequenceNumber(e))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this.ue&&this.ue(e),e}}eh.ce=-1;function ec(e){return 0===e&&1/e==-1/0}function ed(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function ef(e,t){for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t(r,e[r])}function em(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class eg{constructor(e,t){this.comparator=e,this.root=t||ey.EMPTY}insert(e,t){return new eg(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,ey.BLACK,null,null))}remove(e){return new eg(this.comparator,this.root.remove(e,this.comparator).copy(null,null,ey.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let r=this.comparator(e,t.key);if(0===r)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){let n=this.comparator(e,r.key);if(0===n)return t+r.left.size;n<0?r=r.left:(t+=r.left.size+1,r=r.right)}return -1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,r)=>(e(t,r),!1))}toString(){let e=[];return this.inorderTraversal((t,r)=>(e.push(`${t}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new ep(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new ep(this.root,e,this.comparator,!1)}getReverseIterator(){return new ep(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new ep(this.root,e,this.comparator,!0)}}class ep{constructor(e,t,r,n){this.isReverse=n,this.nodeStack=[];let s=1;for(;!e.isEmpty();)if(s=t?r(e.key,t):1,t&&n&&(s*=-1),s<0)e=this.isReverse?e.left:e.right;else{if(0===s){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class ey{constructor(e,t,r,n,s){this.key=e,this.value=t,this.color=null!=r?r:ey.RED,this.left=null!=n?n:ey.EMPTY,this.right=null!=s?s:ey.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,n,s){return new ey(null!=e?e:this.key,null!=t?t:this.value,
1null!=r?r:this.color,null!=n?n:this.left,null!=s?s:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,r){let n=this,s=r(e,n.key);return(n=s<0?n.copy(null,null,null,n.left.insert(e,t,r),null):0===s?n.copy(null,t,null,null,null):n.copy(null,null,null,null,n.right.insert(e,t,r))).fixUp()}removeMin(){if(this.left.isEmpty())return ey.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)).fixUp()}remove(e,t){let r,n=this;if(0>t(e,n.key))n.left.isEmpty()||n.left.isRed()||n.left.left.isRed()||(n=n.moveRedLeft()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed()&&(n=n.rotateRight()),n.right.isEmpty()||n.right.isRed()||n.right.left.isRed()||(n=n.moveRedRight()),0===t(e,n.key)){if(n.right.isEmpty())return ey.EMPTY;r=n.right.min(),n=n.copy(r.key,r.value,null,null,n.right.removeMin())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!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=(e=e.copy(null,null,null,null,e.right.rotateRight())).rotateLeft()).colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=(e=e.rotateRight()).colorFlip()),e}rotateLeft(){let e=this.copy(null,null,ey.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,ey.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){let e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){return Math.pow(2,this.check())<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw _(43730,{key:this.key,value:this.value});if(this.right.isRed())throw _(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw _(27949);return e+ +!this.isRed()}}ey.EMPTY=null,ey.RED=!0,ey.BLACK=!1,ey.EMPTY=new class{constructor(){this.size=0}get key(){throw _(57766)}get value(){throw _(16141)}get color(){throw _(16727)}get left(){throw _(29726)}get right(){throw _(36894)}copy(e,t,r,n,s){return this}insert(e,t,r){return new ey(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class ev{constructor(e){this.comparator=e,this.data=new eg(this.comparator)}has(e){return null!==this.data.get(e)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,r)=>(e(t),!1))}forEachInRange(e,t){let r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){let n=r.getNext();if(this.comparator(n.key,e[1])>=0)return;t(n.key)}}forEachWhile(e,t){let r;for(r=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new ew(this.data.getIterator())}getIteratorFrom(e){return new ew(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(e=>{t=t.add(e)}),t}isEqual(e){if(!(e instanceof ev)||this.size!==e.size)return!1;let t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){let e=t.getNext().key,n=r.getNext().key;if(0!==this.comparator(e,n))return!1}return!0}toArray(){let e=[];return this.forEach(t=>{e.push(t)}),e}toString(){let e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){let t=new ev(this.comparator);return t.data=e,t}}
1class ew{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class eE{constructor(e){this.fields=e,e.sort(G.comparator)}static empty(){return new eE([])}unionWith(e){let t=new ev(G.comparator);for(let e of this.fields)t=t.add(e);for(let r of e)t=t.add(r);return new eE(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return q(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class eT extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class e_{constructor(e){this.binaryString=e}static fromBase64String(e){return new e_(function(e){try{return atob(e)}catch(e){throw"u">typeof DOMException&&e instanceof DOMException?new eT("Invalid base64 string: "+e):e}}(e))}static fromUint8Array(e){return new e_(function(e){let t="";for(let r=0;r<e.length;++r)t+=String.fromCharCode(e[r]);return t}(e))}[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 btoa(this.binaryString)}toUint8Array(){var e=this.binaryString;let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return F(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}e_.EMPTY_BYTE_STRING=new e_("");let eS=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function eI(e){if(I(!!e,39018),"string"==typeof e){let t=0,r=eS.exec(e);if(I(!!r,46558,{timestamp:e}),r[1]){let e=r[1];t=Number(e=(e+"000000000").substr(0,9))}return{seconds:Math.floor(new Date(e).getTime()/1e3),nanos:t}}return{seconds:eC(e.seconds),nanos:eC(e.nanos)}}function eC(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function eb(e){return"string"==typeof e?e_.fromBase64String(e):e_.fromUint8Array(e)}let eA="server_timestamp",eN="__type__",eD="__previous_value__",ek="__local_write_time__";function ex(e){return(e?.mapValue?.fields||{})[eN]?.stringValue===eA}function eR(e){let t=e.mapValue.fields[eD];return ex(t)?eR(t):t}function eV(e){let t=eI(e.mapValue.fields[ek].timestampValue);return new er(t.seconds,t.nanos)}class eL{constructor(e,t,r,n,s,i,a,o,l,u,h){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=n,this.ssl=s,this.forceLongPolling=i,this.autoDetectLongPolling=a,this.longPollingOptions=o,this.useFetchStreams=l,this.isUsingEmulator=u,this.apiKey=h}}let eO="(default)";class eM{constructor(e,t){this.projectId=e,this.database=t||eO}static empty(){return new eM("","")}get isDefaultDatabase(){return this.database===eO}isEqual(e){return e instanceof eM&&e.projectId===this.projectId&&e.database===this.database}}function eF(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new b(C.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new eM(e.options.projectId,t)}let eP="__type__",eU="__max__",eq={fields:{__type__:{stringValue:eU}}},e$="__vector__",eB="value";function ez(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?ex(e)?4:e4(e)?0x1fffffffffffff:e2(e)?10:11:_(28295,{value:e})}function eK(e,t){if(e===t)return!0;let r=ez(e);if(r!==ez(t))return!1;switch(r){case 0:case 0x1fffffffffffff:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return eV(e).isEqual(eV(t));case 3:if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;let n=eI(e.timestampValue),s=eI(t.timestampValue);return n.seconds===s.seconds&&n.nanos===s.nanos;case 5:return e.stringValue===t.stringValue;case 6:return eb(e.bytesValue).isEqual(eb(t.bytesValue));case 7:return e.referenceValue===t.referenceValue;case 8:return eC(e.geoPointValue.latitude)===eC(t.geoPointValue.latitude)&&eC(e.geoPointValue.longitude)===eC(t.geoPointValue.longitude);case 2:if("integerValue"in e&&"integerValue"in t)return eC(e.integerValue)===eC(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){let r=eC(e.doubleValue),n=eC(t.doubleValue);return r===n?ec(r)===ec(n):isNaN(r)&&isNaN(n)}return!1;case 9:return q(e.arrayValue.values||[],t.arrayValue.values||[],eK);case 10:case 11:let i=e.mapValue.fields||{},a=t.mapValue.fields||{};if(ed(i)!==ed(a))return!1;for(let e in i)if(i.hasOwnProperty(e)&&(void 0===a[e]||!eK(i[e],a[e])))return!1;return!0;default:return _(52216,{left:e})}}function eG(e,t){return void 0!==(e.values||[]).find(e=>eK(e,t))}function ej(e,t){var r,n,s,i,a,o;if(e===t)return 0;let l=ez(e),u=ez(t);if(l!==u)return F(l,u);switch(l){case 0:case 0x1fffffffffffff:return 0;case 1:return F(e.booleanValue,t.booleanValue);case 2:let h,c;return h=eC(e.integerValue||e.doubleValue),h<(c=eC(t.integerValue||t.doubleValue))?-1:h>c?1:h===c?0:isNaN(h)?isNaN(c)?0:-1:1;case 3:return eQ(e.timestampValue,t.timestampValue);case 4:return eQ(eV(e),eV(t));case 5:return P(e.stringValue,t.stringValue);case 6:let d,f;return r=e.bytesValue,n=t.bytesValue,d=eb(r),f=eb(n),d.compareTo(f);case 7:return function(e,t){let r=e.split("/"),n=t.split("/");for(let e=0;e<r.length&&e<n.length;e++){let t=F(r[e],n[e]);if(0!==t)return t}return F(r.length,n.length)}(e.referenceValue,t.referenceValue);case 8:let m;return s=e.geoPointValue,i=t.geoPointValue,0!==(m=F(eC(s.latitude),eC(i.latitude)))?m:F(eC(s.longitude),eC(i.longitude));case 9:return eH(e.arrayValue,t.arrayValue);case 10:let g,p,y,v,w;return a=e.mapValue,o=t.mapValue,g=a.fields||{},p=o.fields||{},y=g[eB]?.arrayValue,v=p[eB]?.arrayValue,0!==(w=F(y?.values?.length||0,v?.values?.length||0))?w:eH(y,v);case 11:return function(e,t){if(e===eq&&t===eq)return 0;if(e===eq)return 1;if(t===eq)return -1;let r=e.fields||{},n=Object.keys(r),s=t.fields||{},i=Object.keys(s);n.sort(),i.sort();for(let e=0;e<n.length&&e<i.length;++e){let t=P(n[e],i[e]);if(0!==t)return t;let a=ej(r[n[e]],s[i[e]]);if(0!==a)return a}return F(n.length,i.length)}(e.mapValue,t.mapValue);default:throw _(23264,{he:l})}}function eQ(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return F(e,t);let r=eI(e),n=eI(t),s=F(r.seconds,n.seconds);return 0!==s?s:F(r.nanos,n.nanos)}function eH(e,t){let r=e.values||[],n=t.values||[];for(let e=0;e<r.length&&e<n.length;++e){let t=ej(r[e],n[e]);if(t)return t}return F(r.length,n.length)}function eW(e){var t,r;let n;return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?(n=eI(e.timestampValue),`time(${n.seconds},${n.nanos}
1)`):"stringValue"in e?e.stringValue:"bytesValue"in e?eb(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,j.fromName(t).toString()):"geoPointValue"in e?(r=e.geoPointValue,`geo(${r.latitude},${r.longitude})`):"arrayValue"in e?function(e){let t="[",r=!0;for(let n of e.values||[])r?r=!1:t+=",",t+=eW(n);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){let t=Object.keys(e.fields||{}).sort(),r="{",n=!0;for(let s of t)n?n=!1:r+=",",r+=`${s}:${eW(e.fields[s])}`;return r+"}"}(e.mapValue):_(61005,{value:e})}function eY(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function eJ(e){return!!e&&"integerValue"in e}function eX(e){return!!e&&"arrayValue"in e}function eZ(e){return!!e&&"nullValue"in e}function e0(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function e1(e){return!!e&&"mapValue"in e}function e2(e){return(e?.mapValue?.fields||{})[eP]?.stringValue===e$}function e3(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:{...e.timestampValue}};if(e.mapValue){let t={mapValue:{fields:{}}};return ef(e.mapValue.fields,(e,r)=>t.mapValue.fields[e]=e3(r)),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let r=0;r<(e.arrayValue.values||[]).length;++r)t.arrayValue.values[r]=e3(e.arrayValue.values[r]);return t}return{...e}}function e4(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===eU}class e6{constructor(e){this.value=e}static empty(){return new e6({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(!e1(t=(t.mapValue.fields||{})[e.get(r)]))return null;return(t=(t.mapValue.fields||{})[e.lastSegment()])||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=e3(t)}setAll(e){let t=G.emptyPath(),r={},n=[];e.forEach((e,s)=>{if(!t.isImmediateParentOf(s)){let e=this.getFieldsMap(t);this.applyChanges(e,r,n),r={},n=[],t=s.popLast()}e?r[s.lastSegment()]=e3(e):n.push(s.lastSegment())});let s=this.getFieldsMap(t);this.applyChanges(s,r,n)}delete(e){let t=this.field(e.popLast());e1(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return eK(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let n=t.mapValue.fields[e.get(r)];e1(n)&&n.mapValue.fields||(n={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=n),t=n}return t.mapValue.fields}applyChanges(e,t,r){for(let n of(ef(t,(t,r)=>e[t]=r),r))delete e[n]}clone(){return new e6(e3(this.value))}}class e5{constructor(e,t,r,n,s,i,a){this.key=e,this.documentType=t,this.version=r,this.readTime=n,this.createTime=s,this.data=i,this.documentState=a}static newInvalidDocument(e){return new e5(e,0,en.min(),en.min(),en.min(),e6.empty(),0)}static newFoundDocument(e,t,r,n){return new e5(e,1,t,en.min(),r,n,0)}static newNoDocument(e,t){return new e5(e,2,t,en.min(),en.min(),e6.empty(),0)}static newUnknownDocument(e,t){return new e5(e,3,t,en.min(),en.min(),e6.empty(),2)}convertToFoundDocument(e,t){return this.createTime.isEqual(en.min())&&(2===this.documentType||0===this.documentType)&&(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=e6.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=e6.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=en.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 e5&&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 e5(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}})`}}
1class e8{constructor(e,t){this.position=e,this.inclusive=t}}function e9(e,t,r){let n=0;for(let s=0;s<e.position.length;s++){let i=t[s],a=e.position[s];if(n=i.field.isKeyField()?j.comparator(j.fromName(a.referenceValue),r.key):ej(a,r.data.field(i.field)),"desc"===i.dir&&(n*=-1),0!==n)break}return n}function e7(e,t){if(null===e)return null===t;if(null===t||e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let r=0;r<e.position.length;r++)if(!eK(e.position[r],t.position[r]))return!1;return!0}class te{constructor(e,t="asc"){this.field=e,this.dir=t}}class tt{}class tr extends tt{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,r):new ta(e,t,r):"array-contains"===t?new th(e,r):"in"===t?new tc(e,r):"not-in"===t?new td(e,r):"array-contains-any"===t?new tf(e,r):new tr(e,t,r)}static createKeyFieldInFilter(e,t,r){return"in"===t?new to(e,r):new tl(e,r)}matches(e){let t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(ej(t,this.value)):null!==t&&ez(this.value)===ez(t)&&this.matchesComparison(ej(t,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 _(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class tn extends tt{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(e,t){return new tn(e,t)}matches(e){return ts(this)?void 0===this.filters.find(t=>!t.matches(e)):void 0!==this.filters.find(t=>t.matches(e))}getFlattenedFilters(){return null!==this.Pe||(this.Pe=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}}function ts(e){return"and"===e.op}function ti(e){for(let t of e.filters)if(t instanceof tn)return!1;return!0}class ta extends tr{constructor(e,t,r){super(e,t,r),this.key=j.fromName(r.referenceValue)}matches(e){let t=j.comparator(e.key,this.key);return this.matchesComparison(t)}}class to extends tr{constructor(e,t){super(e,"in",t),this.keys=tu("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class tl extends tr{constructor(e,t){super(e,"not-in",t),this.keys=tu("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function tu(e,t){return(t.arrayValue?.values||[]).map(e=>j.fromName(e.referenceValue))}class th extends tr{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return eX(t)&&eG(t.arrayValue,this.value)}}class tc extends tr{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return null!==t&&eG(this.value.arrayValue,t)}}class td extends tr{constructor(e,t){super(e,"not-in",t)}matches(e){if(eG(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return null!==t&&void 0===t.nullValue&&!eG(this.value.arrayValue,t)}}class tf extends tr{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!eX(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>eG(this.value.arrayValue,e))}}class tm{constructor(e,t=null,r=[],n=[],s=null,i=null,a=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=n,this.limit=s,this.startAt=i,this.endAt=a,this.Te=null}}function tg(e,t=null,r=[],n=[],s=null,i=null,a=null){return new tm(e,t,r,n,s,i,a)}function tp(e){if(null===e.Te){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(e=>(function e(t){if(t instanceof tr)return t.field.canonicalString()+t.op.toString()+eW(t.value);if(ti(t)&&ts(t))return t.filters.map(t=>e(t)).join(",");{let r=t.filters.map(t=>e(t)).join(",");return`${t.op}(${r})`}})(e)).join(","),t+="|ob:",t+=e.orderBy.map(e=>e.field.canonicalString()+e.dir).join(","),null==e.limit||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(e=>eW(e)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(e=>eW(e)).join(",")),e.Te=t}return e.Te}function ty(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let s=0;s<e.orderBy.length;s++){var r,n;if(r=e.orderBy[s],n=t.orderBy[s],!(r.dir===n.dir&&r.field.isEqual(n.field)))return!1}if(e.filters.length!==t.filters.length)return!1;for(let r=0;r<e.filters.length;r++)if(!function e(t,r){return t instanceof tr?r instanceof tr&&t.op===r.op&&t.field.isEqual(r.field)&&eK(t.value,r.value):t instanceof tn?r instanceof tn&&t.op===r.op&&t.filters.length===r.filters.length&&t.filters.reduce((t,n,s)=>t&&e(n,r.filters[s]),!0):void _(19439)}(e.filters[r],t.filters[r]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!e7(e.startAt,t.startAt)&&e7(e.endAt,t.endAt)}function tv(e){return j.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}class tw{constructor(e,t=null,r=[],n=[],s=null,i="F",a=null,o=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=n,this.limit=s,this.limitType=i,this.startAt=a,this.endAt=o,this.Ie=null,this.Ee=null,this.Re=null,this.startAt,this.endAt}}function tE(e){return new tw(e)}function tT(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function t_(e){return null!==e.collectionGroup}function tS(e){if(null===e.Ie){let t;e.Ie=[];let r=new Set;for(let t of e.explicitOrderBy)e.Ie.push(t),r.add(t.field.canonicalString());let n=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";
1(t=new ev(G.comparator),e.filters.forEach(e=>{e.getFlattenedFilters().forEach(e=>{e.isInequality()&&(t=t.add(e.field))})}),t).forEach(t=>{r.has(t.canonicalString())||t.isKeyField()||e.Ie.push(new te(t,n))}),r.has(G.keyField().canonicalString())||e.Ie.push(new te(G.keyField(),n))}return e.Ie}function tI(e){return e.Ee||(e.Ee=function(e,t){if("F"===e.limitType)return tg(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map(e=>{let t="desc"===e.dir?"asc":"desc";return new te(e.field,t)});let r=e.endAt?new e8(e.endAt.position,e.endAt.inclusive):null,n=e.startAt?new e8(e.startAt.position,e.startAt.inclusive):null;return tg(e.path,e.collectionGroup,t,e.filters,e.limit,r,n)}}(e,tS(e))),e.Ee}function tC(e,t){let r=e.filters.concat([t]);return new tw(e.path,e.collectionGroup,e.explicitOrderBy.slice(),r,e.limit,e.limitType,e.startAt,e.endAt)}function tb(e,t){let r=e.explicitOrderBy.concat([t]);return new tw(e.path,e.collectionGroup,r,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}function tA(e,t,r){return new tw(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,r,e.startAt,e.endAt)}function tN(e,t){return new tw(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,t,e.endAt)}function tD(e,t){return new tw(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,t)}function tk(e,t){return ty(tI(e),tI(t))&&e.limitType===t.limitType}function tx(e){return`${tp(tI(e))}|lt:${e.limitType}`}function tR(e){var t;let r;return`Query(target=${r=(t=tI(e)).path.canonicalString(),null!==t.collectionGroup&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map(e=>(function e(t){return t instanceof tr?`${t.field.canonicalString()} ${t.op} ${eW(t.value)}`:t instanceof tn?t.op.toString()+" {"+t.getFilters().map(e).join(" ,")+"}":"Filter"})(e)).join(", ")}]`),null==t.limit||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map(e=>`${e.field.canonicalString()} (${e.dir})`).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map(e=>eW(e)).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map(e=>eW(e)).join(",")),`Target(${r})`}; limitType=${e.limitType})`}function tV(e,t){var r,n,s,i;let a,o,l;return t.isFoundDocument()&&(a=t.key.path,null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(a):j.isDocumentKey(e.path)?e.path.isEqual(a):e.path.isImmediateParentOf(a))&&function(e,t){for(let r of tS(e))if(!r.field.isKeyField()&&null===t.data.field(r.field))return!1;return!0}(e,t)&&function(e,t){for(let r of e.filters)if(!r.matches(t))return!1;return!0}(e,t)&&(r=e,n=t,(!r.startAt||(s=r.startAt,o=e9(s,tS(r),n),s.inclusive?!!(o<=0):!!(o<0)))&&(!r.endAt||(i=r.endAt,l=e9(i,tS(r),n),i.inclusive?!!(l>=0):!!(l>0))))}function tL(e){return(t,r)=>{let n=!1;for(let s of tS(e)){let e=function(e,t,r){var n;let s,i,a=e.field.isKeyField()?j.comparator(t.key,r.key):(n=e.field,s=t.data.field(n),i=r.data.field(n),null!==s&&null!==i?ej(s,i):_(42886));switch(e.dir){case"asc":return a;case"desc":return -1*a;default:return _(19790,{direction:e.dir})}}(s,t,r);if(0!==e)return e;n=n||s.field.isKeyField()}return 0}}class tO{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),r=this.inner[t];if(void 0!==r){for(let[t,n]of r)if(this.equalsFn(t,e))return n}}has(e){return void 0!==this.get(e)}set(e,t){let r=this.mapKeyFn(e),n=this.inner[r];if(void 0===n)return this.inner[r]=[[e,t]],void this.innerSize++;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return void(n[r]=[e,t]);n.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),r=this.inner[t];if(void 0===r)return!1;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],e))return 1===r.length?delete this.inner[t]:r.splice(n,1),this.innerSize--,!0;return!1}forEach(e){ef(this.inner,(t,r)=>{for(let[t,n]of r)e(t,n)})}isEmpty(){return em(this.inner)}size(){return this.innerSize}}let tM=new eg(j.comparator),tF=new eg(j.comparator);function tP(...e){let t=tF;for(let r of e)t=t.insert(r.key,r);return t}function tU(e){let t=tF;return e.forEach((e,r)=>t=t.insert(e,r.overlayedDocument)),t}function tq(){return new tO(e=>e.toString(),(e,t)=>e.isEqual(t))}
1let t$=new eg(j.comparator),tB=new ev(j.comparator);function tz(...e){let t=tB;for(let r of e)t=t.add(r);return t}let tK=new ev(F);function tG(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:ec(t)?"-0":t}}function tj(e){return{integerValue:""+e}}function tQ(e,t){return"number"==typeof t&&Number.isInteger(t)&&!ec(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER?tj(t):tG(e,t)}class tH{constructor(){this._=void 0}}function tW(e,t){return e instanceof t1?eJ(t)||t&&"doubleValue"in t?t:{integerValue:0}:null}class tY extends tH{}class tJ extends tH{constructor(e){super(),this.elements=e}}function tX(e,t){let r=t3(t);for(let t of e.elements)r.some(e=>eK(e,t))||r.push(t);return{arrayValue:{values:r}}}class tZ extends tH{constructor(e){super(),this.elements=e}}function t0(e,t){let r=t3(t);for(let t of e.elements)r=r.filter(e=>!eK(e,t));return{arrayValue:{values:r}}}class t1 extends tH{constructor(e,t){super(),this.serializer=e,this.Ae=t}}function t2(e){return eC(e.integerValue||e.doubleValue)}function t3(e){return eX(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class t4{constructor(e,t){this.field=e,this.transform=t}}class t6{constructor(e,t){this.version=e,this.transformResults=t}}class t5{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new t5}static exists(e){return new t5(void 0,e)}static updateTime(e){return new t5(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)}}function t8(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class t9{}function t7(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new ro(e.key,t5.none()):new rr(e.key,e.data,t5.none());{let r=e.data,n=e6.empty(),s=new ev(G.comparator);for(let e of t.fields)if(!s.has(e)){let t=r.field(e);null===t&&e.length>1&&(e=e.popLast(),t=r.field(e)),null===t?n.delete(e):n.set(e,t),s=s.add(e)}return new rn(e.key,n,new eE(s.toArray()),t5.none())}}function re(e,t,r,n){return e instanceof rr?function(e,t,r,n){if(!t8(e.precondition,t))return r;let s=e.value.clone(),i=ra(e.fieldTransforms,n,t);return s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null}(e,t,r,n):e instanceof rn?function(e,t,r,n){if(!t8(e.precondition,t))return r;let s=ra(e.fieldTransforms,n,t),i=t.data;return(i.setAll(rs(e)),i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null===r)?null:r.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(e=>e.field))}(e,t,r,n):t8(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):r}function rt(e,t){var r,n;return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&(r=e.fieldTransforms,n=t.fieldTransforms,!!(void 0===r&&void 0===n||!(!r||!n)&&q(r,n,(e,t)=>{var r,n;return e.field.isEqual(t.field)&&(r=e.transform,n=t.transform,r instanceof tJ&&n instanceof tJ||r instanceof tZ&&n instanceof tZ?q(r.elements,n.elements,eK):r instanceof t1&&n instanceof t1?eK(r.Ae,n.Ae):r instanceof tY&&n instanceof tY)})))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class rr extends t9{constructor(e,t,r,n=[]){super(),this.key=e,this.value=t,this.precondition=r,this.fieldTransforms=n,this.type=0}getFieldMask(){return null}}class rn extends t9{constructor(e,t,r,n,s=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=n,this.fieldTransforms=s,this.type=1}getFieldMask(){return this.fieldMask}}function rs(e){let t=new Map;return e.fieldMask.fields.forEach(r=>{if(!r.isEmpty()){let n=e.data.field(r);t.set(r,n)}}),t}function ri(e,t,r){let n=new Map;I(e.length===r.length,32656,{Ve:r.length,de:e.length});for(let i=0;i<r.length;i++){var s;let a=e[i],o=a.transform,l=t.data.field(a.field);n.set(a.field,(s=r[i],o instanceof tJ?tX(o,l):o instanceof tZ?t0(o,l):s))}return n}function ra(e,t,r){let n=new Map;for(let s of e){let e=s.transform,i=r.data.field(s.field);n.set(s.field,function(e,t,r){var n;let s,i,a;return e instanceof tY?(n=t,s={fields:{[eN]:{stringValue:eA},[ek]:{timestampValue:{seconds:r.seconds,nanos:r.nanoseconds}}}},n&&ex(n)&&(n=eR(n)),n&&(s.fields[eD]=n),{mapValue:s}):e instanceof tJ?tX(e,t):e instanceof tZ?t0(e,t):(a=t2(i=tW(e,t))+t2(e.Ae),eJ(i)&&eJ(e.Ae)?tj(a):tG(e.serializer,a))}(e,i,t))}return n}class ro extends t9{constructor(e,t){super(),this.key=e,this.prec
1ondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class rl extends t9{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class ru{constructor(e,t,r,n){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=n}applyToRemoteDocument(e,t){let r=t.mutationResults;for(let t=0;t<this.mutations.length;t++){let n=this.mutations[t];n.key.isEqual(e.key)&&function(e,t,r){let n,s;e instanceof rr?(n=e.value.clone(),s=ri(e.fieldTransforms,t,r.transformResults),n.setAll(s),t.convertToFoundDocument(r.version,n).setHasCommittedMutations()):e instanceof rn?function(e,t,r){if(!t8(e.precondition,t))return t.convertToUnknownDocument(r.version);let n=ri(e.fieldTransforms,t,r.transformResults),s=t.data;s.setAll(rs(e)),s.setAll(n),t.convertToFoundDocument(r.version,s).setHasCommittedMutations()}(e,t,r):t.convertToNoDocument(r.version).setHasCommittedMutations()}(n,e,r[t])}}applyToLocalView(e,t){for(let r of this.baseMutations)r.key.isEqual(e.key)&&(t=re(r,e,t,this.localWriteTime));for(let r of this.mutations)r.key.isEqual(e.key)&&(t=re(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let r=tq();return this.mutations.forEach(n=>{let s=e.get(n.key),i=s.overlayedDocument,a=this.applyToLocalView(i,s.mutatedFields),o=t7(i,a=t.has(n.key)?null:a);null!==o&&r.set(n.key,o),i.isValidDocument()||i.convertToNoDocument(en.min())}),r}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),tz())}isEqual(e){return this.batchId===e.batchId&&q(this.mutations,e.mutations,(e,t)=>rt(e,t))&&q(this.baseMutations,e.baseMutations,(e,t)=>rt(e,t))}}class rh{constructor(e,t,r,n){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=n}static from(e,t,r){I(e.mutations.length===r.length,58842,{me:e.mutations.length,fe:r.length});let n=t$,s=e.mutations;for(let e=0;e<s.length;e++)n=n.insert(s[e].key,r[e].version);return new rh(e,t,r,n)}}class rc{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return null!==e&&this.mutation===e.mutation}toString(){return`Overlay{
2      largestBatchId: ${this.largestBatchId},
3      mutation: ${this.mutation.toString()}
4    }`}}class rd{constructor(e,t){this.count=e,this.unchangedNames=t}}function rf(e){if(void 0===e)return w("GRPC error has no .code"),C.UNKNOWN;switch(e){case n.OK:return C.OK;case n.CANCELLED:return C.CANCELLED;case n.UNKNOWN:return C.UNKNOWN;case n.DEADLINE_EXCEEDED:return C.DEADLINE_EXCEEDED;case n.RESOURCE_EXHAUSTED:return C.RESOURCE_EXHAUSTED;case n.INTERNAL:return C.INTERNAL;case n.UNAVAILABLE:return C.UNAVAILABLE;case n.UNAUTHENTICATED:return C.UNAUTHENTICATED;case n.INVALID_ARGUMENT:return C.INVALID_ARGUMENT;case n.NOT_FOUND:return C.NOT_FOUND;case n.ALREADY_EXISTS:return C.ALREADY_EXISTS;case n.PERMISSION_DENIED:return C.PERMISSION_DENIED;case n.FAILED_PRECONDITION:return C.FAILED_PRECONDITION;case n.ABORTED:return C.ABORTED;case n.OUT_OF_RANGE:return C.OUT_OF_RANGE;case n.UNIMPLEMENTED:return C.UNIMPLEMENTED;case n.DATA_LOSS:return C.DATA_LOSS;default:return _(39323,{code:e})}}(s=n||(n={}))[s.OK=0]="OK",s[s.CANCELLED=1]="CANCELLED",s[s.UNKNOWN=2]="UNKNOWN",s[s.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",s[s.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",s[s.NOT_FOUND=5]="NOT_FOUND",s[s.ALREADY_EXISTS=6]="ALREADY_EXISTS",s[s.PERMISSION_DENIED=7]="PERMISSION_DENIED",s[s.UNAUTHENTICATED=16]="UNAUTHENTICATED",s[s.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",s[s.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",s[s.ABORTED=10]="ABORTED",s[s.OUT_OF_RANGE=11]="OUT_OF_RANGE",s[s.UNIMPLEMENTED=12]="UNIMPLEMENTED",s[s.INTERNAL=13]="INTERNAL",s[s.UNAVAILABLE=14]="UNAVAILABLE",s[s.DATA_LOSS=15]="DATA_LOSS";let rm=new u.jz([0xffffffff,0xffffffff],0);function rg(e){let t=(new TextEncoder).encode(e),r=new u.VV;return r.update(t),new Uint8Array(r.digest())}function rp(e){let t=new DataView(e.buffer),r=t.getUint32(0,!0),n=t.getUint32(4,!0),s=t.getUint32(8,!0),i=t.getUint32(12,!0);return[new u.jz([r,n],0),new u.jz([s,i],0)]}class ry{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new rv(`Invalid padding: ${t}`);if(r<0||e.length>0&&0===this.hashCount)throw new rv(`Invalid hash count: ${r}`);if(0===e.length&&0!==t)throw new rv(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=u.jz.fromNumber(this.ge)}ye(e,t,r){let n=e.add(t.multiply(u.jz.fromNumber(r)));return 1===n.compare(rm)&&(n=new u.jz([n.getBits(0),n.getBits(1)],0)),n.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.ge)return!1;let[t,r]=rp(rg(e));for(let e=0;e<this.hashCount;e++){let n=this.ye(t,r,e);if(!this.we(n))return!1}return!0}static create(e,t,r){let n=new ry(new Uint8Array(Math.ceil(e/8)),e%8==0?0:8-e%8,t);
4return r.forEach(e=>n.insert(e)),n}insert(e){if(0===this.ge)return;let[t,r]=rp(rg(e));for(let e=0;e<this.hashCount;e++){let n=this.ye(t,r,e);this.Se(n)}}Se(e){let t=Math.floor(e/8);this.bitmap[t]|=1<<e%8}}class rv extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class rw{constructor(e,t,r,n,s){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=n,this.resolvedLimboDocuments=s}static createSynthesizedRemoteEventForCurrentChange(e,t,r){let n=new Map;return n.set(e,rE.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new rw(en.min(),n,new eg(F),tM,tz())}}class rE{constructor(e,t,r,n,s){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=n,this.removedDocuments=s}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new rE(r,t,tz(),tz(),tz())}}class rT{constructor(e,t,r,n){this.be=e,this.removedTargetIds=t,this.key=r,this.De=n}}class r_{constructor(e,t){this.targetId=e,this.Ce=t}}class rS{constructor(e,t,r=e_.EMPTY_BYTE_STRING,n=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=n}}class rI{constructor(){this.ve=0,this.Fe=rA(),this.Me=e_.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return 0!==this.ve}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=tz(),t=tz(),r=tz();return this.Fe.forEach((n,s)=>{switch(s){case 0:e=e.add(n);break;case 2:t=t.add(n);break;case 1:r=r.add(n);break;default:_(38017,{changeType:s})}}),new rE(this.Me,this.xe,e,t,r)}Ke(){this.Oe=!1,this.Fe=rA()}qe(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}Ue(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}$e(){this.ve+=1}We(){this.ve-=1,I(this.ve>=0,3241,{ve:this.ve})}Qe(){this.Oe=!0,this.xe=!0}}class rC{constructor(e){this.Ge=e,this.ze=new Map,this.je=tM,this.Je=rb(),this.He=rb(),this.Ze=new eg(F)}Xe(e){for(let t of e.be)e.De&&e.De.isFoundDocument()?this.Ye(t,e.De):this.et(t,e.key,e.De);for(let t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,t=>{let r=this.nt(t);switch(e.state){case 0:this.rt(t)&&r.Le(e.resumeToken);break;case 1:r.We(),r.Ne||r.Ke(),r.Le(e.resumeToken);break;case 2:r.We(),r.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(r.Qe(),r.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),r.Le(e.resumeToken));break;default:_(56790,{state:e.state})}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach((e,r)=>{this.rt(r)&&t(r)})}st(e){let t=e.targetId,r=e.Ce.count,n=this.ot(t);if(n){let s=n.target;if(tv(s))if(0===r){let e=new j(s.path);this.et(t,e,e5.newNoDocument(e,en.min()))}else I(1===r,20013,{expectedCount:r});else{let n=this._t(t);if(n!==r){let r=this.ut(e),s=r?this.ct(r,e,n):1;0!==s&&(this.it(t),this.Ze=this.Ze.insert(t,2===s?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch"))}}}}ut(e){let t,r,n=e.Ce.unchangedNames;if(!n||!n.bits)return null;let{bits:{bitmap:s="",padding:i=0},hashCount:a=0}=n;try{t=eb(s).toUint8Array()}catch(e){if(e instanceof eT)return E("Decoding the base64 bloom filter in existence filter failed ("+e.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw e}try{r=new ry(t,i,a)}catch(e){return E(e instanceof rv?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===r.ge?null:r}ct(e,t,r){return 2*(t.Ce.count!==r-this.Pt(e,t.targetId))}Pt(e,t){let r=this.Ge.getRemoteKeysForTarget(t),n=0;return r.forEach(r=>{let s=this.Ge.ht(),i=`projects/${s.projectId}/databases/${s.database}/documents/${r.path.canonicalString()}`;e.mightContain(i)||(this.et(t,r,null),n++)}),n}Tt(e){let t=new Map;this.ze.forEach((r,n)=>{let s=this.ot(n);if(s){if(r.current&&tv(s.target)){let t=new j(s.target.path);this.It(t).has(n)||this.Et(n,t)||this.et(n,t,e5.newNoDocument(t,e))}r.Be&&(t.set(n,r.ke()),r.Ke())}});let r=tz();this.He.forEach((e,t)=>{let n=!0;t.forEachWhile(e=>{let t=this.ot(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(n=!1,!1)}),n&&(r=r.add(e))}),this.je.forEach((t,r)=>r.setReadTime(e));let n=new rw(e,t,this.Ze,this.je,r);return this.je=tM,this.Je=rb(),this.He=rb(),this.Ze=new eg(F),n}Ye(e,t){if(!this.rt(e))return;
4let r=2*!!this.Et(e,t.key);this.nt(e).qe(t.key,r),this.je=this.je.insert(t.key,t),this.Je=this.Je.insert(t.key,this.It(t.key).add(e)),this.He=this.He.insert(t.key,this.Rt(t.key).add(e))}et(e,t,r){if(!this.rt(e))return;let n=this.nt(e);this.Et(e,t)?n.qe(t,1):n.Ue(t),this.He=this.He.insert(t,this.Rt(t).delete(e)),this.He=this.He.insert(t,this.Rt(t).add(e)),r&&(this.je=this.je.insert(t,r))}removeTarget(e){this.ze.delete(e)}_t(e){let t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.nt(e).$e()}nt(e){let t=this.ze.get(e);return t||(t=new rI,this.ze.set(e,t)),t}Rt(e){let t=this.He.get(e);return t||(t=new ev(F),this.He=this.He.insert(e,t)),t}It(e){let t=this.Je.get(e);return t||(t=new ev(F),this.Je=this.Je.insert(e,t)),t}rt(e){let t=null!==this.ot(e);return t||v("WatchChangeAggregator","Detected inactive target",e),t}ot(e){let t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new rI),this.Ge.getRemoteKeysForTarget(e).forEach(t=>{this.et(e,t,null)})}Et(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}}function rb(){return new eg(j.comparator)}function rA(){return new eg(j.comparator)}let rN={asc:"ASCENDING",desc:"DESCENDING"},rD={"<":"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"},rk={and:"AND",or:"OR"};class rx{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function rR(e,t){return e.useProto3Json||null==t?t:{value:t}}function rV(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function rL(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function rO(e){let t;return I(!!e,49232),en.fromTimestamp(new er((t=eI(e)).seconds,t.nanos))}function rM(e,t){return rF(e,t).canonicalString()}function rF(e,t){let r=new z(["projects",e.projectId,"databases",e.database]).child("documents");return void 0===t?r:r.child(t)}function rP(e){let t=z.fromString(e);return I(rQ(t),10190,{key:t.toString()}),t}function rU(e,t){return rM(e.databaseId,t.path)}function rq(e,t){let r=rP(t);if(r.get(1)!==e.databaseId.projectId)throw new b(C.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+r.get(1)+" vs "+e.databaseId.projectId);if(r.get(3)!==e.databaseId.database)throw new b(C.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+r.get(3)+" vs "+e.databaseId.database);return new j(rz(r))}function r$(e,t){return rM(e.databaseId,t)}function rB(e){return new z(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function rz(e){return I(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function rK(e,t,r){return{name:rU(e,t),fields:r.value.mapValue.fields}}function rG(e){return{fieldPath:e.canonicalString()}}function rj(e){return G.fromServerFormat(e.fieldPath)}function rQ(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}function rH(e){return!!e&&"function"==typeof e._toProto&&"ProtoValue"===e._protoValueType}class rW{constructor(e,t,r,n,s=en.min(),i=en.min(),a=e_.EMPTY_BYTE_STRING,o=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=n,this.snapshotVersion=s,this.lastLimboFreeSnapshotVersion=i,this.resumeToken=a,this.expectedCount=o}withSequenceNumber(e){return new rW(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new rW(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new rW(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new rW(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class rY{constructor(e){this.yt=e}}class rJ{Dt(e,t){this.Ct(e,t),t.vt()}Ct(e,t){if("nullValue"in e)this.Ft(t,5);else if("booleanValue"in e)this.Ft(t,10),t.Mt(+!!e.booleanValue);else if("integerValue"in e)this.Ft(t,15),t.Mt(eC(e.integerValue));else if("doubleValue"in e){let r=eC(e.doubleValue);isNaN(r)?this.Ft(t,13):(this.Ft(t,15),ec(r)?t.Mt(0):t.Mt(r))}else if("timestampValue"in e){let r=e.timestampValue;this.Ft(t,20),"string"==typeof r&&(r=eI(r)),t.xt(`${r.seconds||""}`),t.Mt(r.nanos||0)}else if("stringValue"in e)this.Ot(e.stringValue,t),this.Nt(t);else if("bytesValue"in e)this.Ft(t,30),t.Bt(eb(e.bytesValue)),this.Nt(t);else if("referenceValue"in e)this.Lt(e.referenceValue,t);else if("geoPointValue"in e){let r=e.geoPointValue;this.Ft(t,45),t.Mt(r.latitude||0),t.Mt(r.longitude||0)}else"mapValue"in e?e4(e)?this.Ft(t,Number.MAX_SAFE_INTEGER):e2(e)?this.kt(e.mapValue,t):(this.Kt(e.mapValue,t),this.Nt(t)):"arrayValue"in e?(this.qt(e.arrayValue,t),this.Nt(t)):_(19022,{Ut:e})}Ot(e,t){this.Ft(t,25),this.$t(e,t)}$t(e,t){t.xt(e)}Kt(e,t){let r=e.fields||{};for(let e of(this.Ft(t,55),Object.keys(r)))this.Ot(e,t),this.Ct(r[e],t)}kt(e,t){let r=e.fields||{};this.Ft(t,53);let n=r[eB].arrayValue?.values?.length||0;this.Ft(t,15),t.Mt(eC(n)),this.Ot(eB,t),this.Ct(r[eB],t)}qt(e,t){let r=e.values||[];for(let e of(this.Ft(t,50),r))this.Ct(e,t)}
4Lt(e,t){this.Ft(t,37),j.fromName(e).path.forEach(e=>{this.Ft(t,60),this.$t(e,t)})}Ft(e,t){e.Mt(t)}Nt(e){e.Mt(2)}}rJ.Wt=new rJ;class rX{constructor(){this.bn=new rZ}addToCollectionParentIndex(e,t){return this.bn.add(t),el.resolve()}getCollectionParents(e,t){return el.resolve(this.bn.getEntries(t))}addFieldIndex(e,t){return el.resolve()}deleteFieldIndex(e,t){return el.resolve()}deleteAllFieldIndexes(e){return el.resolve()}createTargetIndexes(e,t){return el.resolve()}getDocumentsMatchingTarget(e,t){return el.resolve(null)}getIndexType(e,t){return el.resolve(0)}getFieldIndexes(e,t){return el.resolve([])}getNextCollectionGroupToUpdate(e){return el.resolve(null)}getMinOffset(e,t){return el.resolve(ei.min())}getMinOffsetFromCollectionGroup(e,t){return el.resolve(ei.min())}updateCollectionGroup(e,t,r){return el.resolve()}updateIndexEntries(e,t){return el.resolve()}}class rZ{constructor(){this.index={}}add(e){let t=e.lastSegment(),r=e.popLast(),n=this.index[t]||new ev(z.comparator),s=!n.has(r);return this.index[t]=n.add(r),s}has(e){let t=e.lastSegment(),r=e.popLast(),n=this.index[t];return n&&n.has(r)}getEntries(e){return(this.index[e]||new ev(z.comparator)).toArray()}}new Uint8Array(0);let r0={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class r1{static withCacheSize(e){return new r1(e,r1.DEFAULT_COLLECTION_PERCENTILE,r1.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}r1.DEFAULT_COLLECTION_PERCENTILE=10,r1.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,r1.DEFAULT=new r1(0x2800000,r1.DEFAULT_COLLECTION_PERCENTILE,r1.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),r1.DISABLED=new r1(-1,0,0);class r2{constructor(e){this.sr=e}next(){return this.sr+=2,this.sr}static _r(){return new r2(0)}static ar(){return new r2(-1)}}let r3="LruGarbageCollector";function r4([e,t],[r,n]){let s=F(e,r);return 0===s?F(t,n):s}class r6{constructor(e){this.Pr=e,this.buffer=new ev(r4),this.Tr=0}Ir(){return++this.Tr}Er(e){let t=[e,this.Ir()];if(this.buffer.size<this.Pr)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();0>r4(t,e)&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class r5{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Rr=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Ar(6e4)}stop(){this.Rr&&(this.Rr.cancel(),this.Rr=null)}get started(){return null!==this.Rr}Ar(e){v(r3,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){eu(e)?v(r3,"Ignoring IndexedDB error during garbage collection: ",e):await eo(e)}await this.Ar(3e5)})}}class r8{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.dr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return el.resolve(eh.ce);let r=new r6(t);return this.Vr.forEachTarget(e,e=>r.Er(e.sequenceNumber)).next(()=>this.Vr.mr(e,e=>r.Er(e))).next(()=>r.maxValue)}removeTargets(e,t,r){return this.Vr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return -1===this.params.cacheSizeCollectionThreshold?(v("LruGarbageCollector","Garbage collection skipped; disabled"),el.resolve(r0)):this.getCacheSize(e).next(r=>r<this.params.cacheSizeCollectionThreshold?(v("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),r0):this.gr(e,t))}getCacheSize(e){return this.Vr.getCacheSize(e)}gr(e,t){let r,n,s,i,a,o,l,u=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(t=>(t>this.params.maximumSequenceNumbersToCollect?(v("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),n=this.params.maximumSequenceNumbersToCollect):n=t,i=Date.now(),this.nthSequenceNumber(e,n))).next(n=>(r=n,a=Date.now(),this.removeTargets(e,r,t))).next(t=>(s=t,o=Date.now(),this.removeOrphanedDocuments(e,r))).next(e=>(l=Date.now(),y()<=h.$b.DEBUG&&v("LruGarbageCollector",`LRU Garbage Collection
5	Counted targets in ${i-u}ms
6	Determined least recently used ${n} in `+(a-i)+"ms\n"+`	Removed ${s} targets in `+(o-a)+"ms\n"+`	Removed ${e} documents in `+(l-o)+"ms\n"+`Total Duration: ${l-u}ms`),el.resolve({didRun:!0,sequenceNumbersCollected:n,targetsRemoved:s,documentsRemoved:e})))}}class r9{constructor(){this.changes=new tO(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,e5.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let r=this.changes.get(t);return void 0!==r?el.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}
6assertNotApplied(){}}class r7{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class ne{constructor(e,t,r,n){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=n}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next(n=>(r=n,this.remoteDocumentCache.getEntry(e,t))).next(e=>(null!==r&&re(r.mutation,e,eE.empty(),er.now()),e))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.getLocalViewOfDocuments(e,t,tz()).next(()=>t))}getLocalViewOfDocuments(e,t,r=tz()){let n=tq();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,r).next(e=>{let t=tP();return e.forEach((e,r)=>{t=t.insert(e,r.overlayedDocument)}),t}))}getOverlayedDocuments(e,t){let r=tq();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,tz()))}populateOverlays(e,t,r){let n=[];return r.forEach(e=>{t.has(e)||n.push(e)}),this.documentOverlayCache.getOverlays(e,n).next(e=>{e.forEach((e,r)=>{t.set(e,r)})})}computeViews(e,t,r,n){let s=tM,i=tq(),a=tq();return t.forEach((e,t)=>{let a=r.get(t.key);n.has(t.key)&&(void 0===a||a.mutation instanceof rn)?s=s.insert(t.key,t):void 0!==a?(i.set(t.key,a.mutation.getFieldMask()),re(a.mutation,t,a.mutation.getFieldMask(),er.now())):i.set(t.key,eE.empty())}),this.recalculateAndSaveOverlays(e,s).next(e=>(e.forEach((e,t)=>i.set(e,t)),t.forEach((e,t)=>a.set(e,new r7(t,i.get(e)??null))),a))}recalculateAndSaveOverlays(e,t){let r=tq(),n=new eg((e,t)=>e-t),s=tz();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>{for(let s of e)s.keys().forEach(e=>{let i=t.get(e);if(null===i)return;let a=r.get(e)||eE.empty();a=s.applyToLocalView(i,a),r.set(e,a);let o=(n.get(s.batchId)||tz()).add(e);n=n.insert(s.batchId,o)})}).next(()=>{let i=[],a=n.getReverseIterator();for(;a.hasNext();){let n=a.getNext(),o=n.key,l=n.value,u=tq();l.forEach(e=>{if(!s.has(e)){let n=t7(t.get(e),r.get(e));null!==n&&u.set(e,n),s=s.add(e)}}),i.push(this.documentOverlayCache.saveOverlays(e,o,u))}return el.waitFor(i)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.recalculateAndSaveOverlays(e,t))}getDocumentsMatchingQuery(e,t,r,n){return j.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length?this.getDocumentsMatchingDocumentQuery(e,t.path):t_(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,n):this.getDocumentsMatchingCollectionQuery(e,t,r,n)}getNextDocuments(e,t,r,n){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,n).next(s=>{let i=n-s.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,n-s.size):el.resolve(tq()),a=-1,o=s;return i.next(t=>el.forEach(t,(t,r)=>(a<r.largestBatchId&&(a=r.largestBatchId),s.get(t)?el.resolve():this.remoteDocumentCache.getEntry(e,t).next(e=>{o=o.insert(t,e)}))).next(()=>this.populateOverlays(e,t,s)).next(()=>this.computeViews(e,o,t,tz())).next(e=>({batchId:a,changes:tU(e)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new j(t)).next(e=>{let t=tP();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}getDocumentsMatchingCollectionGroupQuery(e,t,r,n){let s=t.collectionGroup,i=tP();return this.indexManager.getCollectionParents(e,s).next(a=>el.forEach(a,a=>{let o=new tw(a.child(s),null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt);return this.getDocumentsMatchingCollectionQuery(e,o,r,n).next(e=>{e.forEach((e,t)=>{i=i.insert(e,t)})})}).next(()=>i))}getDocumentsMatchingCollectionQuery(e,t,r,n){let s;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next(i=>(s=i,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,s,n))).next(e=>{s.forEach((t,r)=>{let n=r.getKey();null===e.get(n)&&(e=e.insert(n,e5.newInvalidDocument(n)))});let r=tP();return e.forEach((e,n)=>{let i=s.get(e);void 0!==i&&re(i.mutation,n,eE.empty(),er.now()),tV(t,n)&&(r=r.insert(e,n))}),r})}}class nt{constructor(e){this.serializer=e,this.Nr=new Map,this.Br=new Map}getBundleMetadata(e,t){return el.resolve(this.Nr.get(t))}
6saveBundleMetadata(e,t){return this.Nr.set(t.id,{id:t.id,version:t.version,createTime:rO(t.createTime)}),el.resolve()}getNamedQuery(e,t){return el.resolve(this.Br.get(t))}saveNamedQuery(e,t){var r;let n;return this.Br.set(t.name,{name:t.name,query:(n=function(e){var t,r,n,s;let i,a,o,l,u,h=4===(i=rP(e.parent)).length?z.emptyPath():rz(i),c=e.structuredQuery,d=c.from?c.from.length:0,f=null;if(d>0){I(1===d,65062);let e=c.from[0];e.allDescendants?f=e.collectionId:h=h.child(e.collectionId)}let m=[];c.where&&(m=(a=function e(t){return void 0!==t.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":let t=rj(e.unaryFilter.field);return tr.create(t,"==",{doubleValue:NaN});case"IS_NULL":let r=rj(e.unaryFilter.field);return tr.create(r,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let n=rj(e.unaryFilter.field);return tr.create(n,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let s=rj(e.unaryFilter.field);return tr.create(s,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return _(61313);default:return _(60726)}}(t):void 0!==t.fieldFilter?tr.create(rj(t.fieldFilter.field),function(e){switch(e){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":return _(58110);default:return _(50506)}}(t.fieldFilter.op),t.fieldFilter.value):void 0!==t.compositeFilter?tn.create(t.compositeFilter.filters.map(t=>e(t)),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return _(1026)}}(t.compositeFilter.op)):_(30097,{filter:t})}(c.where))instanceof tn&&ti(t=a)&&ts(t)?a.getFilters():[a]);let g=[];c.orderBy&&(g=c.orderBy.map(e=>new te(rj(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))));let p=null;c.limit&&(p=null==(o="object"==typeof(r=c.limit)?r.value:r)?null:o);let y=null;c.startAt&&(l=!!(n=c.startAt).before,y=new e8(n.values||[],l));let v=null;return c.endAt&&(u=!(s=c.endAt).before,v=new e8(s.values||[],u)),new tw(h,f,g,m,p,"F",y,v)}({parent:(r=t.bundledQuery).parent,structuredQuery:r.structuredQuery}),"LAST"===r.limitType?tA(n,n.limit,"L"):n),readTime:rO(t.readTime)}),el.resolve()}}class nr{constructor(){this.overlays=new eg(j.comparator),this.Lr=new Map}getOverlay(e,t){return el.resolve(this.overlays.get(t))}getOverlays(e,t){let r=tq();return el.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&r.set(t,e)})).next(()=>r)}saveOverlays(e,t,r){return r.forEach((r,n)=>{this.St(e,t,n)}),el.resolve()}removeOverlaysForBatchId(e,t,r){let n=this.Lr.get(r);return void 0!==n&&(n.forEach(e=>this.overlays=this.overlays.remove(e)),this.Lr.delete(r)),el.resolve()}getOverlaysForCollection(e,t,r){let n=tq(),s=t.length+1,i=new j(t.child("")),a=this.overlays.getIteratorFrom(i);for(;a.hasNext();){let e=a.getNext().value,i=e.getKey();if(!t.isPrefixOf(i.path))break;i.path.length===s&&e.largestBatchId>r&&n.set(e.getKey(),e)}return el.resolve(n)}getOverlaysForCollectionGroup(e,t,r,n){let s=new eg((e,t)=>e-t),i=this.overlays.getIterator();for(;i.hasNext();){let e=i.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>r){let t=s.get(e.largestBatchId);null===t&&(t=tq(),s=s.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let a=tq(),o=s.getIterator();for(;o.hasNext()&&(o.getNext().value.forEach((e,t)=>a.set(e,t)),!(a.size()>=n)););return el.resolve(a)}St(e,t,r){let n=this.overlays.get(r.key);if(null!==n){let e=this.Lr.get(n.largestBatchId).delete(r.key);this.Lr.set(n.largestBatchId,e)}this.overlays=this.overlays.insert(r.key,new rc(t,r));let s=this.Lr.get(t);void 0===s&&(s=tz(),this.Lr.set(t,s)),this.Lr.set(t,s.add(r.key))}}class nn{constructor(){this.sessionToken=e_.EMPTY_BYTE_STRING}getSessionToken(e){return el.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,el.resolve()}}class ns{constructor(){this.kr=new ev(ni.Kr),this.qr=new ev(ni.Ur)}isEmpty(){return this.kr.isEmpty()}addReference(e,t){let r=new ni(e,t);this.kr=this.kr.add(r),this.qr=this.qr.add(r)}
6$r(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.Wr(new ni(e,t))}Qr(e,t){e.forEach(e=>this.removeReference(e,t))}Gr(e){let t=new j(new z([])),r=new ni(t,e),n=new ni(t,e+1),s=[];return this.qr.forEachInRange([r,n],e=>{this.Wr(e),s.push(e.key)}),s}zr(){this.kr.forEach(e=>this.Wr(e))}Wr(e){this.kr=this.kr.delete(e),this.qr=this.qr.delete(e)}jr(e){let t=new j(new z([])),r=new ni(t,e),n=new ni(t,e+1),s=tz();return this.qr.forEachInRange([r,n],e=>{s=s.add(e.key)}),s}containsKey(e){let t=new ni(e,0),r=this.kr.firstAfterOrEqual(t);return null!==r&&e.isEqual(r.key)}}class ni{constructor(e,t){this.key=e,this.Jr=t}static Kr(e,t){return j.comparator(e.key,t.key)||F(e.Jr,t.Jr)}static Ur(e,t){return F(e.Jr,t.Jr)||j.comparator(e.key,t.key)}}class na{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.Yn=1,this.Hr=new ev(ni.Kr)}checkEmpty(e){return el.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,r,n){let s=this.Yn;this.Yn++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let i=new ru(s,t,r,n);for(let t of(this.mutationQueue.push(i),n))this.Hr=this.Hr.add(new ni(t.key,s)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return el.resolve(i)}lookupMutationBatch(e,t){return el.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){let r=this.Xr(t+1),n=r<0?0:r;return el.resolve(this.mutationQueue.length>n?this.mutationQueue[n]:null)}getHighestUnacknowledgedBatchId(){return el.resolve(0===this.mutationQueue.length?-1:this.Yn-1)}getAllMutationBatches(e){return el.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let r=new ni(t,0),n=new ni(t,1/0),s=[];return this.Hr.forEachInRange([r,n],e=>{let t=this.Zr(e.Jr);s.push(t)}),el.resolve(s)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new ev(F);return t.forEach(e=>{let t=new ni(e,0),n=new ni(e,1/0);this.Hr.forEachInRange([t,n],e=>{r=r.add(e.Jr)})}),el.resolve(this.Yr(r))}getAllMutationBatchesAffectingQuery(e,t){let r=t.path,n=r.length+1,s=r;j.isDocumentKey(s)||(s=s.child(""));let i=new ni(new j(s),0),a=new ev(F);return this.Hr.forEachWhile(e=>{let t=e.key.path;return!!r.isPrefixOf(t)&&(t.length===n&&(a=a.add(e.Jr)),!0)},i),el.resolve(this.Yr(a))}Yr(e){let t=[];return e.forEach(e=>{let r=this.Zr(e);null!==r&&t.push(r)}),t}removeMutationBatch(e,t){I(0===this.ei(t.batchId,"removed"),55003),this.mutationQueue.shift();let r=this.Hr;return el.forEach(t.mutations,n=>{let s=new ni(n.key,t.batchId);return r=r.delete(s),this.referenceDelegate.markPotentiallyOrphaned(e,n.key)}).next(()=>{this.Hr=r})}nr(e){}containsKey(e,t){let r=new ni(t,0),n=this.Hr.firstAfterOrEqual(r);return el.resolve(t.isEqual(n&&n.key))}performConsistencyCheck(e){return this.mutationQueue.length,el.resolve()}ei(e,t){return this.Xr(e)}Xr(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Zr(e){let t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class no{constructor(e){this.ti=e,this.docs=new eg(j.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let r=t.key,n=this.docs.get(r),s=n?n.size:0,i=this.ti(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:i}),this.size+=i-s,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let r=this.docs.get(t);return el.resolve(r?r.document.mutableCopy():e5.newInvalidDocument(t))}getEntries(e,t){let r=tM;return t.forEach(e=>{let t=this.docs.get(e);r=r.insert(e,t?t.document.mutableCopy():e5.newInvalidDocument(e))}),el.resolve(r)}getDocumentsMatchingQuery(e,t,r,n){let s=tM,i=t.path,a=new j(i.child("__id-9223372036854775808__")),o=this.docs.getIteratorFrom(a);for(;o.hasNext();){let{key:e,value:{document:a}}=o.getNext();if(!i.isPrefixOf(e.path))break;e.path.length>i.length+1||0>=function(e,t){let r=e.readTime.compareTo(t.readTime);return 0!==r||0!==(r=j.comparator(e.documentKey,t.documentKey))?r:F(e.largestBatchId,t.largestBatchId)}(new ei(a.readTime,a.key,-1),r)||(n.has(a.key)||tV(t,a))&&(s=s.insert(a.key,a.mutableCopy()))}return el.resolve(s)}getAllFromCollectionGroup(e,t,r,n){_(9500)}ni(e,t){return el.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new nl(this)}getSize(e){return el.resolve(this.size)}}class nl extends r9{constructor(e){super(),this.Mr=e}applyChanges(e){let t=[];
vendor: 4,119 bytes, line 6
6return this.changes.forEach((r,n)=>{n.isValidDocument()?t.push(this.Mr.addEntry(e,n)):this.Mr.removeEntry(r)}),el.waitFor(t)}getFromCache(e,t){return this.Mr.getEntry(e,t)}getAllFromCache(e,t){return this.Mr.getEntries(e,t)}}class nu{constructor(e){this.persistence=e,this.ri=new tO(e=>tp(e),ty),this.lastRemoteSnapshotVersion=en.min(),this.highestTargetId=0,this.ii=0,this.si=new ns,this.targetCount=0,this.oi=r2._r()}forEachTarget(e,t){return this.ri.forEach((e,r)=>t(r)),el.resolve()}getLastRemoteSnapshotVersion(e){return el.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return el.resolve(this.ii)}allocateTargetId(e){return this.highestTargetId=this.oi.next(),el.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.ii&&(this.ii=t),el.resolve()}lr(e){this.ri.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.oi=new r2(t),this.highestTargetId=t),e.sequenceNumber>this.ii&&(this.ii=e.sequenceNumber)}addTargetData(e,t){return this.lr(t),this.targetCount+=1,el.resolve()}updateTargetData(e,t){return this.lr(t),el.resolve()}removeTargetData(e,t){return this.ri.delete(t.target),this.si.Gr(t.targetId),this.targetCount-=1,el.resolve()}removeTargets(e,t,r){let n=0,s=[];return this.ri.forEach((i,a)=>{a.sequenceNumber<=t&&null===r.get(a.targetId)&&(this.ri.delete(i),s.push(this.removeMatchingKeysForTargetId(e,a.targetId)),n++)}),el.waitFor(s).next(()=>n)}getTargetCount(e){return el.resolve(this.targetCount)}getTargetData(e,t){let r=this.ri.get(t)||null;return el.resolve(r)}addMatchingKeys(e,t,r){return this.si.$r(t,r),el.resolve()}removeMatchingKeys(e,t,r){this.si.Qr(t,r);let n=this.persistence.referenceDelegate,s=[];return n&&t.forEach(t=>{s.push(n.markPotentiallyOrphaned(e,t))}),el.waitFor(s)}removeMatchingKeysForTargetId(e,t){return this.si.Gr(t),el.resolve()}getMatchingKeysForTargetId(e,t){let r=this.si.jr(t);return el.resolve(r)}containsKey(e,t){return el.resolve(this.si.containsKey(t))}}class nh{constructor(e,t){this._i={},this.overlays={},this.ai=new eh(0),this.ui=!1,this.ui=!0,this.ci=new nn,this.referenceDelegate=e(this),this.li=new nu(this),this.indexManager=new rX,this.remoteDocumentCache=function(e){return new no(e)}(e=>this.referenceDelegate.hi(e)),this.serializer=new rY(t),this.Pi=new nt(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ui=!1,Promise.resolve()}get started(){return this.ui}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new nr,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this._i[e.toKey()];return r||(r=new na(t,this.referenceDelegate),this._i[e.toKey()]=r),r}getGlobalsCache(){return this.ci}getTargetCache(){return this.li}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Pi}runTransaction(e,t,r){v("MemoryPersistence","Starting transaction:",e);let n=new nc(this.ai.next());return this.referenceDelegate.Ti(),r(n).next(e=>this.referenceDelegate.Ii(n).next(()=>e)).toPromise().then(e=>(n.raiseOnCommittedEvent(),e))}Ei(e,t){return el.or(Object.values(this._i).map(r=>()=>r.containsKey(e,t)))}}class nc extends ea{constructor(e){super(),this.currentSequenceNumber=e}}class nd{constructor(e){this.persistence=e,this.Ri=new ns,this.Ai=null}static Vi(e){return new nd(e)}get di(){if(this.Ai)return this.Ai;throw _(60996)}addReference(e,t,r){return this.Ri.addReference(r,t),this.di.delete(r.toString()),el.resolve()}removeReference(e,t,r){return this.Ri.removeReference(r,t),this.di.add(r.toString()),el.resolve()}markPotentiallyOrphaned(e,t){return this.di.add(t.toString()),el.resolve()}removeTarget(e,t){this.Ri.Gr(t.targetId).forEach(e=>this.di.add(e.toString()));let r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.di.add(e.toString()))}).next(()=>r.removeTargetData(e,t))}Ti(){this.Ai=new Set}Ii(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return el.forEach(this.di,r=>{let n=j.fromPath(r);
6return this.mi(e,n).next(e=>{e||t.removeEntry(n,en.min())})}).next(()=>(this.Ai=null,t.apply(e)))}updateLimboDocument(e,t){return this.mi(e,t).next(e=>{e?this.di.delete(t.toString()):this.di.add(t.toString())})}hi(e){return 0}mi(e,t){return el.or([()=>el.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class nf{constructor(e,t){this.persistence=e,this.fi=new tO(e=>(function(e){let t="";for(let r=0;r<e.length;r++)t.length>0&&(t+="\x01\x01"),t=function(e,t){let r=t,n=e.length;for(let t=0;t<n;t++){let n=e.charAt(t);switch(n){case"\0":r+="\x01\x10";break;case"\x01":r+="\x01\x11";break;default:r+=n}}return r}(e.get(r),t);return t+"\x01\x01"})(e.path),(e,t)=>e.isEqual(t)),this.garbageCollector=function(e,t){return new r8(e,t)}(this,t)}static Vi(e,t){return new nf(e,t)}Ti(){}Ii(e){return el.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}dr(e){let t=this.pr(e);return this.persistence.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}pr(e){let t=0;return this.mr(e,e=>{t++}).next(()=>t)}mr(e,t){return el.forEach(this.fi,(r,n)=>this.wr(e,r,n).next(e=>e?el.resolve():t(n)))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0,n=this.persistence.getRemoteDocumentCache(),s=n.newChangeBuffer();return n.ni(e,n=>this.wr(e,n,t).next(e=>{e||(r++,s.removeEntry(n,en.min()))})).next(()=>s.apply(e)).next(()=>r)}markPotentiallyOrphaned(e,t){return this.fi.set(t,e.currentSequenceNumber),el.resolve()}removeTarget(e,t){let r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),el.resolve()}removeReference(e,t,r){return this.fi.set(r,e.currentSequenceNumber),el.resolve()}updateLimboDocument(e,t){return this.fi.set(t,e.currentSequenceNumber),el.resolve()}hi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=function e(t){switch(ez(t)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let r=eR(t);return r?16+e(r):16;case 5:return 2*t.stringValue.length;case 6:return eb(t.bytesValue).approximateByteSize();case 7:return t.referenceValue.length;case 9:return(t.arrayValue.values||[]).reduce((t,r)=>t+e(r),0);case 10:case 11:var n;let s;return n=t.mapValue,s=0,ef(n.fields,(t,r)=>{s+=t.length+e(r)}),s;default:throw _(13486,{value:t})}}(e.data.value)),t}wr(e,t,r){return el.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.fi.get(t);return el.resolve(void 0!==e&&e>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class nm{constructor(e,t,r,n){this.targetId=e,this.fromCache=t,this.Ts=r,this.Is=n}static Es(e,t){let r=tz(),n=tz();for(let e of t.docChanges)switch(e.type){case 0:r=r.add(e.doc.key);break;case 1:n=n.add(e.doc.key)}return new nm(e,t.fromCache,r,n)}}class ng{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class np{constructor(){this.Rs=!1,this.As=!1,this.Vs=100,this.ds=function(){let e;return(0,l.nr)()?8:Number((e=(0,l.ZQ)().match(/Android ([\d.]+)/i))?e[1].split(".").slice(0,2).join("."):"-1")>0?6:4}()}initialize(e,t){this.fs=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,r,n){let s={result:null};return this.gs(e,t).next(e=>{s.result=e}).next(()=>{if(!s.result)return this.ps(e,t,n,r).next(e=>{s.result=e})}).next(()=>{if(s.result)return;let r=new ng;return this.ys(e,t,r).next(n=>{if(s.result=n,this.As)return this.ws(e,t,r,n.size)})}).next(()=>s.result)}ws(e,t,r,n){return r.documentReadCount<this.Vs?(y()<=h.$b.DEBUG&&v("QueryEngine","SDK will not create cache indexes for query:",tR(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),el.resolve()):(y()<=h.$b.DEBUG&&v("QueryEngine","Query:",tR(t),"scans",r.documentReadCount,"local documents and returns",n,"documents as results."),r.documentReadCount>this.ds*n?(y()<=h.$b.DEBUG&&v("QueryEngine","The SDK decides to create cache indexes for query:",tR(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,tI(t))):el.resolve())}gs(e,t){if(tT(t))return el.resolve(null);let r=tI(t);return this.indexManager.getIndexType(e,r).next(n=>0===n?null:(null!==t.limit&&1===n&&(r=tI(t=tA(t,null,"F"))),this.indexManager.getDocumentsMatchingTarget(e,r).next(n=>{let s=tz(...n);return this.fs.getDocuments(e,s).next(n=>this.indexManager.getMinOffset(e,r).next(r=>{let i=this.Ss(t,n);return this.bs(t,i,s,r.readTime)?this.gs(e,tA(t,null,"F")):this.Ds(e,i,t,r)}))})))}ps(e,t,r,n){return tT(t)||n.isEqual(en.min())?el.resolve(null):this.fs.getDocuments(e,r).next(s=>{let i,a,o=this.Ss(t,s);return this.bs(t,o,r,n)?el.resolve(null):(y()<=h.$b.DEBUG&&v("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),tR(t)),this.Ds(e,o,t,(i=n.toTimestamp().seconds,a=n.toTimestamp().nanoseconds+1,new ei(en.fromTimestamp(1e9===a?new er(i+1,0):new er(i,a)),j.empty(),-1))
6).next(e=>e))})}Ss(e,t){let r=new ev(tL(e));return t.forEach((t,n)=>{tV(e,n)&&(r=r.add(n))}),r}bs(e,t,r,n){if(null===e.limit)return!1;if(r.size!==t.size)return!0;let s="F"===e.limitType?t.last():t.first();return!!s&&(s.hasPendingWrites||s.version.compareTo(n)>0)}ys(e,t,r){return y()<=h.$b.DEBUG&&v("QueryEngine","Using full collection scan to execute query:",tR(t)),this.fs.getDocumentsMatchingQuery(e,t,ei.min(),r)}Ds(e,t,r,n){return this.fs.getDocumentsMatchingQuery(e,r,n).next(e=>(t.forEach(t=>{e=e.insert(t.key,t)}),e))}}let ny="LocalStore";class nv{constructor(e,t,r,n){this.persistence=e,this.Cs=t,this.serializer=n,this.vs=new eg(F),this.Fs=new tO(e=>tp(e),ty),this.Ms=new Map,this.xs=e.getRemoteDocumentCache(),this.li=e.getTargetCache(),this.Pi=e.getBundleCache(),this.Os(r)}Os(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new ne(this.xs,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.xs.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.vs))}}async function nw(e,t){return await e.persistence.runTransaction("Handle user change","readonly",r=>{let n;return e.mutationQueue.getAllMutationBatches(r).next(s=>(n=s,e.Os(t),e.mutationQueue.getAllMutationBatches(r))).next(t=>{let s=[],i=[],a=tz();for(let e of n)for(let t of(s.push(e.batchId),e.mutations))a=a.add(t.key);for(let e of t)for(let t of(i.push(e.batchId),e.mutations))a=a.add(t.key);return e.localDocuments.getDocuments(r,a).next(e=>({Ns:e,removedBatchIds:s,addedBatchIds:i}))})})}function nE(e){return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.li.getLastRemoteSnapshotVersion(t))}async function nT(e,t,r){let n=e.vs.get(t);try{r||await e.persistence.runTransaction("Release target",r?"readwrite":"readwrite-primary",t=>e.persistence.referenceDelegate.removeTarget(t,n))}catch(e){if(!eu(e))throw e;v(ny,`Failed to update sequence numbers for target ${t}: ${e}`)}e.vs=e.vs.remove(t),e.Fs.delete(n.target)}function n_(e,t,r){let n=en.min(),s=tz();return e.persistence.runTransaction("Execute query","readwrite",i=>{var a;let o;return(a=tI(t),void 0!==(o=e.Fs.get(a))?el.resolve(e.vs.get(o)):e.li.getTargetData(i,a)).next(t=>{if(t)return n=t.lastLimboFreeSnapshotVersion,e.li.getMatchingKeysForTargetId(i,t.targetId).next(e=>{s=e})}).next(()=>e.Cs.getDocumentsMatchingQuery(i,t,r?n:en.min(),r?s:tz())).next(r=>{var n,i,a;let o;return n=e,i=t.collectionGroup||(t.path.length%2==1?t.path.lastSegment():t.path.get(t.path.length-2)),a=r,o=n.Ms.get(i)||en.min(),a.forEach((e,t)=>{t.readTime.compareTo(o)>0&&(o=t.readTime)}),n.Ms.set(i,o),{documents:r,ks:s}})})}class nS{constructor(){this.activeTargetIds=tK}Qs(e){this.activeTargetIds=this.activeTargetIds.add(e)}Gs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){return JSON.stringify({activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()})}}class nI{constructor(){this.vo=new nS,this.Fo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.vo.Qs(e),this.Fo[e]||"not-current"}updateQueryState(e,t,r){this.Fo[e]=t}removeLocalQueryTarget(e){this.vo.Gs(e)}isLocalQueryTarget(e){return this.vo.activeTargetIds.has(e)}clearQueryState(e){delete this.Fo[e]}getAllActiveQueryTargets(){return this.vo.activeTargetIds}isActiveQueryTarget(e){return this.vo.activeTargetIds.has(e)}start(){return this.vo=new nS,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class nC{Mo(e){}shutdown(){}}let nb="ConnectivityMonitor";class nA{constructor(){this.xo=()=>this.Oo(),this.No=()=>this.Bo(),this.Lo=[],this.ko()}Mo(e){this.Lo.push(e)}shutdown(){window.removeEventListener("online",this.xo),window.removeEventListener("offline",this.No)}
6ko(){window.addEventListener("online",this.xo),window.addEventListener("offline",this.No)}Oo(){for(let e of(v(nb,"Network connectivity changed: AVAILABLE"),this.Lo))e(0)}Bo(){for(let e of(v(nb,"Network connectivity changed: UNAVAILABLE"),this.Lo))e(1)}static v(){return"u">typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let nN=null;function nD(){return null===nN?nN=0x10000000+Math.round(0x80000000*Math.random()):nN++,"0x"+nN.toString(16)}let nk="RestConnection",nx={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregationQuery:"runAggregationQuery",ExecutePipeline:"executePipeline"};class nR{get Ko(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),n=encodeURIComponent(this.databaseId.database);this.qo=t+"://"+e.host,this.Uo=`projects/${r}/databases/${n}`,this.$o=this.databaseId.database===eO?`project_id=${r}`:`project_id=${r}&database_id=${n}`}Wo(e,t,r,n,s){let i=nD(),a=this.Qo(e,t.toUriEncodedString());v(nk,`Sending RPC '${e}' ${i}:`,a,r);let o={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.$o};this.Go(o,n,s);let{host:u}=new URL(a),h=(0,l.zJ)(u);return this.zo(e,a,o,r,h).then(t=>(v(nk,`Received RPC '${e}' ${i}: `,t),t),t=>{throw E(nk,`RPC '${e}' ${i} failed with error: `,t,"url: ",a,"request:",r),t})}jo(e,t,r,n,s,i){return this.Wo(e,t,r,n,s)}Go(e,t,r){e["X-Goog-Api-Client"]="gl-js/ fire/"+m,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((t,r)=>e[r]=t),r&&r.headers.forEach((t,r)=>e[r]=t)}Qo(e,t){let r=nx[e],n=`${this.qo}/v1/${t}:${r}`;return this.databaseInfo.apiKey&&(n=`${n}?key=${encodeURIComponent(this.databaseInfo.apiKey)}`),n}terminate(){}}class nV{constructor(e){this.Jo=e.Jo,this.Ho=e.Ho}Zo(e){this.Xo=e}Yo(e){this.e_=e}t_(e){this.n_=e}onMessage(e){this.r_=e}close(){this.Ho()}send(e){this.Jo(e)}i_(){this.Xo()}s_(){this.e_()}o_(e){this.n_(e)}__(e){this.r_(e)}}let nL="WebChannelConnection",nO=(e,t,r)=>{e.listen(t,e=>{try{r(e)}catch(e){setTimeout(()=>{throw e},0)}})};class nM extends nR{constructor(e){super(e),this.a_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}static u_(){nM.c_||(nO((0,c.Ao)(),c.Jh.STAT_EVENT,e=>{e.stat===c.ro.PROXY?v(nL,"STAT_EVENT: detected buffering proxy"):e.stat===c.ro.NOPROXY&&v(nL,"STAT_EVENT: detected no buffering proxy")}),nM.c_=!0)}zo(e,t,r,n,s){let i=nD();return new Promise((s,a)=>{let o=new c.ZS;o.setWithCredentials(!0),o.listenOnce(c.Bx.COMPLETE,()=>{try{switch(o.getLastErrorCode()){case c.O4.NO_ERROR:let t=o.getResponseJson();v(nL,`XHR for RPC '${e}' ${i} received:`,JSON.stringify(t)),s(t);break;case c.O4.TIMEOUT:v(nL,`RPC '${e}' ${i} timed out`),a(new b(C.DEADLINE_EXCEEDED,"Request time out"));break;case c.O4.HTTP_ERROR:let r=o.getStatus();if(v(nL,`RPC '${e}' ${i} failed with status:`,r,"response text:",o.getResponseText()),r>0){let e=o.getResponseJson();Array.isArray(e)&&(e=e[0]);let t=e?.error;if(t&&t.status&&t.message){let e,r=(e=t.status.toLowerCase().replace(/_/g,"-"),Object.values(C).indexOf(e)>=0?e:C.UNKNOWN);a(new b(r,t.message))}else a(new b(C.UNKNOWN,"Server responded with status "+o.getStatus()))}else a(new b(C.UNAVAILABLE,"Connection failed."));break;default:_(9055,{l_:e,streamId:i,h_:o.getLastErrorCode(),P_:o.getLastError()})}}finally{v(nL,`RPC '${e}' ${i} completed.`)}});let l=JSON.stringify(n);v(nL,`RPC '${e}' ${i} sending request:`,n),o.send(t,"POST",l,r,15)})}T_(e,t,r){let s=nD(),i=[this.qo,"/","google.firestore.v1.Firestore","/",e,"/channel"],a=this.createWebChannelTransport(),o={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:`projects/${this.databaseId.projectId}/databases/${this.databaseId.database}`},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling},l=this.longPollingOptions.timeoutSeconds;void 0!==l&&(o.longPollingTimeout=Math.round(1e3*l)),this.useFetchStreams&&(o.useFetchStreams=!0),this.Go(o.initMessageHeaders,t,r),o.encodeInitMessageHeaders=!0;let u=i.join("");v(nL,`Creating RPC '${e}' stream ${s}: ${u}`,o);let h=a.createWebChannel(u,o);this.I_(h);let d=!1,f=!1,m=new nV({Jo:t=>{f?v(nL,`Not sending because RPC '${e}' stream ${s} is closed:`,t):(d||(v(nL,`Opening RPC '${e}' stream ${s} transport.`),h.open(),d=!0),v(nL,`RPC '${e}' stream ${s} sending:`,t),h.send(t))},Ho:()=>h.close()});return nO(h,c.iO.EventType.OPEN,()=>{f||(v(nL,`RPC '${e}' stream ${s} transport opened.`),m.i_())}),nO(h,c.iO.EventType.CLOSE,()=>{f||(f=!0,v(nL,`RPC '${e}' stream ${s} transport closed`),m.o_(),this.E_(h))}
6),nO(h,c.iO.EventType.ERROR,t=>{f||(f=!0,E(nL,`RPC '${e}' stream ${s} transport errored. Name:`,t.name,"Message:",t.message),m.o_(new b(C.UNAVAILABLE,"The operation could not be completed")))}),nO(h,c.iO.EventType.MESSAGE,t=>{if(!f){let r=t.data[0];I(!!r,16349);let i=r?.error||r[0]?.error;if(i){v(nL,`RPC '${e}' stream ${s} received error:`,i);let t=i.status,r=function(e){let t=n[e];if(void 0!==t)return rf(t)}(t),a=i.message;"NOT_FOUND"===t&&a.includes("database")&&a.includes("does not exist")&&a.includes(this.databaseId.database)&&E(`Database '${this.databaseId.database}' not found. Please check your project configuration.`),void 0===r&&(r=C.INTERNAL,a="Unknown error status: "+t+" with message "+i.message),f=!0,m.o_(new b(r,a)),h.close()}else v(nL,`RPC '${e}' stream ${s} received:`,r),m.__(r)}}),nM.u_(),setTimeout(()=>{m.s_()},0),m}terminate(){this.a_.forEach(e=>e.close()),this.a_=[]}I_(e){this.a_.push(e)}E_(e){this.a_=this.a_.filter(t=>t===e)}Go(e,t,r){super.Go(e,t,r),this.databaseInfo.apiKey&&(e["x-goog-api-key"]=this.databaseInfo.apiKey)}createWebChannelTransport(){return(0,c.fF)()}}function nF(){return"u">typeof document?document:null}function nP(e){return new rx(e,!0)}nM.c_=!1;class nU{constructor(e,t,r=1e3,n=1.5,s=6e4){this.Ci=e,this.timerId=t,this.R_=r,this.A_=n,this.V_=s,this.d_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.d_=0}g_(){this.d_=this.V_}p_(e){this.cancel();let t=Math.floor(this.d_+this.y_()),r=Math.max(0,Date.now()-this.f_),n=Math.max(0,t-r);n>0&&v("ExponentialBackoff",`Backing off for ${n} ms (base delay: ${this.d_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.m_=this.Ci.enqueueAfterDelay(this.timerId,n,()=>(this.f_=Date.now(),e())),this.d_*=this.A_,this.d_<this.R_&&(this.d_=this.R_),this.d_>this.V_&&(this.d_=this.V_)}w_(){null!==this.m_&&(this.m_.skipDelay(),this.m_=null)}cancel(){null!==this.m_&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.d_}}let nq="PersistentStream";class n${constructor(e,t,r,n,s,i,a,o){this.Ci=e,this.S_=r,this.b_=n,this.connection=s,this.authCredentialsProvider=i,this.appCheckCredentialsProvider=a,this.listener=o,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new nU(e,t)}x_(){return 1===this.state||5===this.state||this.O_()}O_(){return 2===this.state||3===this.state}start(){this.F_=0,4!==this.state?this.auth():this.N_()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&null===this.C_&&(this.C_=this.Ci.enqueueAfterDelay(this.S_,6e4,()=>this.k_()))}K_(e){this.q_(),this.stream.send(e)}async k_(){if(this.O_())return this.close(0)}q_(){this.C_&&(this.C_.cancel(),this.C_=null)}U_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.U_(),this.M_.cancel(),this.D_++,4!==e?this.M_.reset():t&&t.code===C.RESOURCE_EXHAUSTED?(w(t.toString()),w("Using maximum backoff delay to prevent overloading the backend."),this.M_.g_()):t&&t.code===C.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.W_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.t_(t)}W_(){}auth(){this.state=1;let e=this.Q_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,r])=>{this.D_===t&&this.G_(e,r)},t=>{e(()=>{let e=new b(C.UNKNOWN,"Fetching auth token failed: "+t.message);return this.z_(e)})})}G_(e,t){let r=this.Q_(this.D_);this.stream=this.j_(e,t),this.stream.Zo(()=>{r(()=>this.listener.Zo())}),this.stream.Yo(()=>{r(()=>(this.state=2,this.v_=this.Ci.enqueueAfterDelay(this.b_,1e4,()=>(this.O_()&&(this.state=3),Promise.resolve())),this.listener.Yo()))}),this.stream.t_(e=>{r(()=>this.z_(e))}),this.stream.onMessage(e=>{r(()=>1==++this.F_?this.J_(e):this.onNext(e))})}N_(){this.state=5,this.M_.p_(async()=>{this.state=0,this.start()})}z_(e){return v(nq,`close with error: ${e}`),this.stream=null,this.close(4,e)}Q_(e){return t=>{this.Ci.enqueueAndForget(()=>this.D_===e?t():(v(nq,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class nB extends n${constructor(e,t,r,n,s,i){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,n,i),this.serializer
6=s}j_(e,t){return this.connection.T_("Listen",e,t)}J_(e){return this.onNext(e)}onNext(e){this.M_.reset();let t=function(e,t){let r;if("targetChange"in t){var n,s;t.targetChange;let i="NO_CHANGE"===(n=t.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===n?1:"REMOVE"===n?2:"CURRENT"===n?3:"RESET"===n?4:_(39313,{state:n}),a=t.targetChange.targetIds||[],o=(s=t.targetChange.resumeToken,e.useProto3Json?(I(void 0===s||"string"==typeof s,58123),e_.fromBase64String(s||"")):(I(void 0===s||s instanceof d||s instanceof Uint8Array,16193),e_.fromUint8Array(s||new Uint8Array))),l=t.targetChange.cause;r=new rS(i,a,o,l&&new b(void 0===l.code?C.UNKNOWN:rf(l.code),l.message||"")||null)}else if("documentChange"in t){t.documentChange;let n=t.documentChange;n.document,n.document.name,n.document.updateTime;let s=rq(e,n.document.name),i=rO(n.document.updateTime),a=n.document.createTime?rO(n.document.createTime):en.min(),o=new e6({mapValue:{fields:n.document.fields}}),l=e5.newFoundDocument(s,i,a,o);r=new rT(n.targetIds||[],n.removedTargetIds||[],l.key,l)}else if("documentDelete"in t){t.documentDelete;let n=t.documentDelete;n.document;let s=rq(e,n.document),i=n.readTime?rO(n.readTime):en.min(),a=e5.newNoDocument(s,i);r=new rT([],n.removedTargetIds||[],a.key,a)}else if("documentRemove"in t){t.documentRemove;let n=t.documentRemove;n.document;let s=rq(e,n.document);r=new rT([],n.removedTargetIds||[],s,null)}else{if(!("filter"in t))return _(11601,{Vt:t});{t.filter;let e=t.filter;e.targetId;let{count:n=0,unchangedNames:s}=e,i=new rd(n,s);r=new r_(e.targetId,i)}}return r}(this.serializer,e),r=function(e){if(!("targetChange"in e))return en.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?en.min():t.readTime?rO(t.readTime):en.min()}(e);return this.listener.H_(t,r)}Z_(e){let t,r={};r.database=rB(this.serializer),r.addTarget=function(e,t){var r,n;let s,i,a,o,l,u,h,c=t.target;if((s=tv(c)?{documents:{documents:[r$(e,c.path)]}}:{query:(a={structuredQuery:{}},o=c.path,null!==c.collectionGroup?(i=o,a.structuredQuery.from=[{collectionId:c.collectionGroup,allDescendants:!0}]):(i=o.popLast(),a.structuredQuery.from=[{collectionId:o.lastSegment()}]),a.parent=r$(e,i),(l=function(e){if(0!==e.length)return function e(t){var r;let n;return t instanceof tr?function(e){if("=="===e.op){if(e0(e.value))return{unaryFilter:{field:rG(e.field),op:"IS_NAN"}};if(eZ(e.value))return{unaryFilter:{field:rG(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(e0(e.value))return{unaryFilter:{field:rG(e.field),op:"IS_NOT_NAN"}};if(eZ(e.value))return{unaryFilter:{field:rG(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:rG(e.field),op:rD[e.op],value:e.value}}}(t):t instanceof tn?1===(n=(r=t).getFilters().map(t=>e(t))).length?n[0]:{compositeFilter:{op:rk[r.op],filters:n}}:_(54877,{filter:t})}(tn.create(e,"and"))}(c.filters))&&(a.structuredQuery.where=l),(u=function(e){if(0!==e.length)return e.map(e=>({field:rG(e.field),direction:rN[e.dir]}))}(c.orderBy))&&(a.structuredQuery.orderBy=u),null!==(h=rR(e,c.limit))&&(a.structuredQuery.limit=h),c.startAt&&(a.structuredQuery.startAt={before:(r=c.startAt).inclusive,values:r.position}),c.endAt&&(a.structuredQuery.endAt={before:!(n=c.endAt).inclusive,values:n.position}),{ft:a,parent:i}).ft}).targetId=t.targetId,t.resumeToken.approximateByteSize()>0){s.resumeToken=rL(e,t.resumeToken);let r=rR(e,t.expectedCount);null!==r&&(s.expectedCount=r)}else if(t.snapshotVersion.compareTo(en.min())>0){s.readTime=rV(e,t.snapshotVersion.toTimestamp());let r=rR(e,t.expectedCount);null!==r&&(s.expectedCount=r)}return s}(this.serializer,e);let n=(this.serializer,null==(t=function(e){switch(e){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return _(28987,{purpose:e})}}(e.purpose))?null:{"goog-listen-tags":t});n&&(r.labels=n),this.K_(r)}X_(e){let t={};t.database=rB(this.serializer),t.removeTarget=e,this.K_(t)}}class nz extends n${constructor(e,t,r,n,s,i){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,n,i),this.serializer
6=s}get Y_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}W_(){this.Y_&&this.ea([])}j_(e,t){return this.connection.T_("Write",e,t)}J_(e){return I(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,I(!e.writeResults||0===e.writeResults.length,55816),this.listener.ta()}onNext(e){var t,r;I(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();let n=(t=e.writeResults,r=e.commitTime,t&&t.length>0?(I(void 0!==r,14353),t.map(e=>{let t;return(t=e.updateTime?rO(e.updateTime):rO(r)).isEqual(en.min())&&(t=rO(r)),new t6(t,e.transformResults||[])})):[]),s=rO(e.commitTime);return this.listener.na(s,n)}ra(){let e={};e.database=rB(this.serializer),this.K_(e)}ea(e){let t={streamToken:this.lastStreamToken,writes:e.map(e=>(function(e,t){var r,n;let s;if(t instanceof rr)s={update:rK(e,t.key,t.value)};else if(t instanceof ro)s={delete:rU(e,t.key)};else if(t instanceof rn){let r;s={update:rK(e,t.key,t.data),updateMask:(n=t.fieldMask,r=[],n.fields.forEach(e=>r.push(e.canonicalString())),{fieldPaths:r})}}else{if(!(t instanceof rl))return _(16599,{dt:t.type});s={verify:rU(e,t.key)}}return t.fieldTransforms.length>0&&(s.updateTransforms=t.fieldTransforms.map(e=>(function(e){let t=e.transform;if(t instanceof tY)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(t instanceof tJ)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:t.elements}};if(t instanceof tZ)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:t.elements}};if(t instanceof t1)return{fieldPath:e.field.canonicalString(),increment:t.Ae};throw _(20930,{transform:e.transform})})(e))),t.precondition.isNone||(s.currentDocument=void 0!==(r=t.precondition).updateTime?{updateTime:rV(e,r.updateTime.toTimestamp())}:void 0!==r.exists?{exists:r.exists}:_(27497)),s})(this.serializer,e))};this.K_(t)}}class nK{}class nG extends nK{constructor(e,t,r,n){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=n,this.ia=!1}sa(){if(this.ia)throw new b(C.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,r,n){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,i])=>this.connection.Wo(e,rF(t,r),n,s,i)).catch(e=>{throw"FirebaseError"===e.name?(e.code===C.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new b(C.UNKNOWN,e.toString())})}jo(e,t,r,n,s){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,a])=>this.connection.jo(e,rF(t,r),n,i,a,s)).catch(e=>{throw"FirebaseError"===e.name?(e.code===C.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new b(C.UNKNOWN,e.toString())})}terminate(){this.ia=!0,this.connection.terminate()}}class nj{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.oa=0,this._a=null,this.aa=!0}ua(){0===this.oa&&(this.ca("Unknown"),this._a=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this._a=null,this.la("Backend didn't respond within 10 seconds."),this.ca("Offline"),Promise.resolve())))}ha(e){"Online"===this.state?this.ca("Unknown"):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca("Offline")))}set(e){this.Pa(),this.oa=0,"Online"===e&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){let t=`Could not reach Cloud Firestore backend. ${e}
7This typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.aa?(w(t),this.aa=!1):v("OnlineStateTracker",t)}Pa(){null!==this._a&&(this._a.cancel(),this._a=null)}}let nQ="RemoteStore";class nH{constructor(e,t,r,n,s){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Ta=[],this.Ia=new Map,this.Ea=new Map,this.Ra=new Map,this.Aa=new r2(1e3),this.Va=new r2(1001),this.da=new Set,this.ma=[],this.fa=s,this.fa.Mo(e=>{r.enqueueAndForget(async()=>
7{n4(this)&&(v(nQ,"Restarting streams for network reachability change."),await async function(e){e.da.add(4),await nY(e),e.ga.set("Unknown"),e.da.delete(4),await nW(e)}(this))})}),this.ga=new nj(r,n)}}async function nW(e){if(n4(e))for(let t of e.ma)await t(!0)}async function nY(e){for(let t of e.ma)await t(!1)}function nJ(e,t){return e.Ea.get(t)||void 0}function nX(e,t){var r;let n,s,i=nJ(e,t.targetId);if(void 0!==i&&e.Ia.has(i))return;let a=(void 0!==(n=nJ(e,r=t.targetId))&&e.Ra.delete(n),s=r%2!=0?e.Va.next():e.Aa.next(),e.Ea.set(r,s),e.Ra.set(s,r),s);v(nQ,"remoteStoreListen mapping SDK target ID to remote",t.targetId,a);let o=new rW(t.target,a,t.purpose,t.sequenceNumber,t.snapshotVersion,t.lastLimboFreeSnapshotVersion,t.resumeToken);e.Ia.set(a,o),n3(e)?n2(e):sh(e).O_()&&n0(e,o)}function nZ(e,t){let r=sh(e),n=nJ(e,t);v(nQ,"remoteStoreUnlisten removing mapping of SDK target ID to remote",t,n),e.Ia.delete(n),e.Ea.delete(t),e.Ra.delete(n),r.O_()&&n1(e,n),0===e.Ia.size&&(r.O_()?r.L_():n4(e)&&e.ga.set("Unknown"))}function n0(e,t){if(e.pa.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(en.min())>0){let r=e.Ra.get(t.targetId);if(void 0===r)return void v(nQ,"SDK target ID not found for remote ID: "+t.targetId);let n=e.remoteSyncer.getRemoteKeysForTarget(r).size;t=t.withExpectedCount(n)}sh(e).Z_(t)}function n1(e,t){e.pa.$e(t),sh(e).X_(t)}function n2(e){e.pa=new rC({getRemoteKeysForTarget:t=>{let r=e.Ra.get(t);return void 0!==r?e.remoteSyncer.getRemoteKeysForTarget(r):tz()},At:t=>e.Ia.get(t)||null,ht:()=>e.datastore.serializer.databaseId}),sh(e).start(),e.ga.ua()}function n3(e){return n4(e)&&!sh(e).x_()&&e.Ia.size>0}function n4(e){return 0===e.da.size}async function n6(e){e.ga.set("Online")}async function n5(e){e.Ia.forEach((t,r)=>{n0(e,t)})}async function n8(e,t){e.pa=void 0,n3(e)?(e.ga.ha(t),n2(e)):e.ga.set("Unknown")}async function n9(e,t,r){if(e.ga.set("Online"),t instanceof rS&&2===t.state&&t.cause)try{await async function(e,t){let r=t.cause;for(let n of t.targetIds){if(e.Ia.has(n)){let t=e.Ra.get(n);void 0!==t&&(await e.remoteSyncer.rejectListen(t,r),e.Ea.delete(t),e.Ra.delete(n)),e.Ia.delete(n)}e.pa.removeTarget(n)}}(e,t)}catch(r){v(nQ,"Failed to remove targets %s: %s ",t.targetIds.join(","),r),await n7(e,r)}else if(t instanceof rT?e.pa.Xe(t):t instanceof r_?e.pa.st(t):e.pa.tt(t),!r.isEqual(en.min()))try{let t,n,s,i,a=await nE(e.localStore);r.compareTo(a)>
7=0&&await ((t=e.pa.Tt(r)).targetChanges.forEach((t,n)=>{if(t.resumeToken.approximateByteSize()>0){let s=e.Ia.get(n);s&&e.Ia.set(n,s.withResumeToken(t.resumeToken,r))}}),t.targetMismatches.forEach((t,r)=>{let n=e.Ia.get(t);if(!n)return;e.Ia.set(t,n.withResumeToken(e_.EMPTY_BYTE_STRING,n.snapshotVersion)),n1(e,t);let s=new rW(n.target,t,r,n.sequenceNumber);n0(e,s)}),n=new Map,t.targetChanges.forEach((t,r)=>{let s=e.Ra.get(r);void 0!==s&&n.set(s,t)}),s=new eg(F),t.targetMismatches.forEach((t,r)=>{let n=e.Ra.get(t);void 0!==n&&(s=s.insert(n,r))}),i=new rw(t.snapshotVersion,n,s,t.documentUpdates,t.resolvedLimboDocuments),e.remoteSyncer.applyRemoteEvent(i))}catch(t){v(nQ,"Failed to raise snapshot:",t),await n7(e,t)}}async function n7(e,t,r){if(!eu(t))throw t;e.da.add(1),await nY(e),e.ga.set("Offline"),r||(r=()=>nE(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{v(nQ,"Retrying IndexedDB access"),await r(),e.da.delete(1),await nW(e)})}function se(e,t){return t().catch(r=>n7(e,r,t))}async function st(e){var t;let r=sc(e),n=e.Ta.length>0?e.Ta[e.Ta.length-1].batchId:-1;for(;n4(t=e)&&t.Ta.length<10;)try{let t=await function(e,t){return e.persistence.runTransaction("Get next mutation batch","readonly",r=>(void 0===t&&(t=-1),e.mutationQueue.getNextMutationBatchAfterBatchId(r,t)))}(e.localStore,n);if(null===t){0===e.Ta.length&&r.L_();break}n=t.batchId,function(e,t){e.Ta.push(t);let r=sc(e);r.O_()&&r.Y_&&r.ea(t.mutations)}(e,t)}catch(t){await n7(e,t)}sr(e)&&sn(e)}function sr(e){return n4(e)&&!sc(e).x_()&&e.Ta.length>0}function sn(e){sc(e).start()}async function ss(e){sc(e).ra()}async function si(e){let t=sc(e);for(let r of e.Ta)t.ea(r.mutations)}async function sa(e,t,r){let n=e.Ta.shift(),s=rh.from(n,t,r);await se(e,()=>e.remoteSyncer.applySuccessfulWrite(s)),await st(e)}async function so(e,t){t&&sc(e).Y_&&await async function(e,t){var r;if(function(e){switch(e){case C.OK:return _(64938);case C.CANCELLED:case C.UNKNOWN:case C.DEADLINE_EXCEEDED:case C.RESOURCE_EXHAUSTED:case C.INTERNAL:case C.UNAVAILABLE:case C.UNAUTHENTICATED:return!1;case C.INVALID_ARGUMENT:case C.NOT_FOUND:case C.ALREADY_EXISTS:case C.PERMISSION_DENIED:case C.FAILED_PRECONDITION:case C.ABORTED:case C.OUT_OF_RANGE:case C.UNIMPLEMENTED:case C.DATA_LOSS:return!0;default:return _(15467,{code:e})}}(r=t.code)&&r!==C.ABORTED){let r=e.Ta.shift();sc(e).B_(),await se(e,()=>e.remoteSyncer.rejectFailedWrite(r.batchId,t)),await st(e)}}(e,t),sr(e)&&sn(e)}async function sl(e,t){e.asyncQueue.verifyOperationInProgress(),v(nQ,"RemoteStore received new credentials");let r=n4(e);e.da.add(3),await nY(e),r&&e.ga.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.da.delete(3),await nW(e)}async function su(e,t){t?(e.da.delete(2),await nW(e)):t||(e.da.add(2),await nY(e),e.ga.set("Unknown"))}function sh(e){var t,r,n;return e.ya||(t=e.datastore,r=e.asyncQueue,n={Zo:n6.bind(null,e),Yo:n5.bind(null,e),t_:n8.bind(null,e),H_:n9.bind(null,e)},t.sa(),e.ya=new nB(r,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,n),e.ma.push(async t=>{t?(e.ya.B_(),n3(e)?n2(e):e.ga.set("Unknown")):(await e.ya.stop(),e.pa=void 0)})),e.ya}function sc(e){var t,r,n;return e.wa||(t=e.datastore,r=e.asyncQueue,n={Zo:()=>Promise.resolve(),Yo:ss.bind(null,e),t_:so.bind(null,e),ta:si.bind(null,e),na:sa.bind(null,e)},t.sa(),e.wa=new nz(r,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,n),e.ma.push(async t=>{t?(e.wa.B_(),await st(e)):(await e.wa.stop(),e.Ta.length>0&&(v(nQ,`Stopping write stream with ${e.Ta.length} pending writes`),e.Ta=[]))})),e.wa}class sd{constructor(e,t,r,n,s){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=n,this.removalCallback=s,this.deferred=new A,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(e=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,n,s){let i=new sd(e,t,Date.now()+r,n,s);return i.start(r),i}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new b(C.CANCELLED,"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)}}function sf(e,t){if(w("AsyncQueue",`${t}: ${e}`),eu(e))return new b(C.UNAVAILABLE,`${t}: ${e}`);throw e}class sm{static emptySet(e){return new sm(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||j.comparator(t.key,r.key):(e,t)=>j.comparator(e.key,t.key),this.keyedMap=tP(),this.sortedSet=new eg(this.comparator)}has(e){return null!=this.keyedMap.get(e)}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){let t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,r)=>(e(t),!1))}add(e){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof sm)||this.size!==e.size)return!1;let t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){let e=t.getNext().key,n=r.getNext().key;if(!e.isEqual(n))return!1}return!0}toString(){let e=[];return this.forEach(t=>{e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n  "+e.join("  \n")+"\n)"}copy(e,t){let r=new sm;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}class sg{constructor(){this.Sa=new eg(j.comparator)}track(e){let t=e.doc.key,r=this.Sa.get(t);r?0!==e.type&&3===r.type?this.Sa=this.Sa.insert(t,e):3===e.type&&1!==r.type?this.Sa=this.Sa.insert(t,{type:r.type,doc:e.doc}):2===e.type&&2===r.type?this.Sa=this.Sa.insert(t,{type:2,doc:e.doc}):2===e.type&&0===r.type?this.Sa=this.Sa.insert(t,{type:0,doc:e.doc}):1===e.type&&0===r.type?this.Sa=this.Sa.remove(t):1===e.type&&2===r.type?this.Sa=this.Sa.insert(t,{type:1,doc:r.doc}):0===e.type&&1===r.type?this.Sa=this.Sa.insert(t,{type:2,doc:e.doc}):_(63341,{Vt:e,ba:r}):this.Sa=this.Sa.insert(t,e)}Da(){let e=[];return this.Sa.inorderTraversal((t,r)=>{e.push(r)}),e}}class sp{constructor(e,t,r,n,s,i,a,o,l){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=n,this.mutatedKeys=s,this.fromCache=i,this.syncStateChanged=a,this.excludesMetadataChanges=o,this.hasCachedResults=l}static fromInitialDocuments(e,t,r,n,s){let i=[];
7return t.forEach(e=>{i.push({type:0,doc:e})}),new sp(e,t,sm.emptySet(t),i,r,n,!0,!1,s)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&tk(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==r[e].type||!t[e].doc.isEqual(r[e].doc))return!1;return!0}}class sy{constructor(){this.Ca=void 0,this.va=[]}Fa(){return this.va.some(e=>e.Ma())}}class sv{constructor(){this.queries=sw(),this.onlineState="Unknown",this.xa=new Set}terminate(){var e;let t;e=new b(C.ABORTED,"Firestore shutting down"),t=this.queries,this.queries=sw(),t.forEach((t,r)=>{for(let t of r.va)t.onError(e)})}}function sw(){return new tO(e=>tx(e),tk)}async function sE(e,t){let r=3,n=t.query,s=e.queries.get(n);s?!s.Fa()&&t.Ma()&&(r=2):(s=new sy,r=+!t.Ma());try{switch(r){case 0:s.Ca=await e.onListen(n,!0);break;case 1:s.Ca=await e.onListen(n,!1);break;case 2:await e.onFirstRemoteStoreListen(n)}}catch(r){let e=sf(r,`Initialization of query '${tR(t.query)}' failed`);return void t.onError(e)}e.queries.set(n,s),s.va.push(t),t.Oa(e.onlineState),s.Ca&&t.Na(s.Ca)&&sI(e)}async function sT(e,t){let r=t.query,n=3,s=e.queries.get(r);if(s){let e=s.va.indexOf(t);e>=0&&(s.va.splice(e,1),0===s.va.length?n=+!t.Ma():!s.Fa()&&t.Ma()&&(n=2))}switch(n){case 0:return e.queries.delete(r),e.onUnlisten(r,!0);case 1:return e.queries.delete(r),e.onUnlisten(r,!1);case 2:return e.onLastRemoteStoreUnlisten(r);default:return}}function s_(e,t){let r=!1;for(let n of t){let t=n.query,s=e.queries.get(t);if(s){for(let e of s.va)e.Na(n)&&(r=!0);s.Ca=n}}r&&sI(e)}function sS(e,t,r){let n=e.queries.get(t);if(n)for(let e of n.va)e.onError(r);e.queries.delete(t)}function sI(e){e.xa.forEach(e=>{e.next()})}(a=i||(i={})).Ba="default",a.Cache="cache";class sC{constructor(e,t,r){this.query=e,this.La=t,this.ka=!1,this.Ka=null,this.onlineState="Unknown",this.options=r||{}}Na(e){if(!this.options.includeMetadataChanges){let t=[];for(let r of e.docChanges)3!==r.type&&t.push(r);e=new sp(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.ka?this.qa(e)&&(this.La.next(e),t=!0):this.Ua(e,this.onlineState)&&(this.$a(e),t=!0),this.Ka=e,t}onError(e){this.La.error(e)}Oa(e){this.onlineState=e;let t=!1;return this.Ka&&!this.ka&&this.Ua(this.Ka,e)&&(this.$a(this.Ka),t=!0),t}Ua(e,t){return!(e.fromCache&&this.Ma())||(!this.options.Wa||"Offline"===t)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}qa(e){if(e.docChanges.length>0)return!0;let t=this.Ka&&this.Ka.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}$a(e){e=sp.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.ka=!0,this.La.next(e)}Ma(){return this.options.source!==i.Cache}}class sb{constructor(e){this.key=e}}class sA{constructor(e){this.key=e}}class sN{constructor(e,t){this.query=e,this.tu=t,this.nu=null,this.hasCachedResults=!1,this.current=!1,this.ru=tz(),this.mutatedKeys=tz(),this.iu=tL(e),this.su=new sm(this.iu)}get ou(){return this.tu}_u(e,t){let r=t?t.au:new sg,n=t?t.su:this.su,s=t?t.mutatedKeys:this.mutatedKeys,i=n,a=!1,o="F"===this.query.limitType&&n.size===this.query.limit?n.last():null,l="L"===this.query.limitType&&n.size===this.query.limit?n.first():null;if(e.inorderTraversal((e,t)=>{let u=n.get(e),h=tV(this.query,t)?t:null,c=!!u&&this.mutatedKeys.has(u.key),d=!!h&&(h.hasLocalMutations||this.mutatedKeys.has(h.key)&&h.hasCommittedMutations),f=!1;u&&h?u.data.isEqual(h.data)?c!==d&&(r.track({type:3,doc:h}),f=!0):this.uu(u,h)||(r.track({type:2,doc:h}),f=!0,(o&&this.iu(h,o)>0||l&&0>this.iu(h,l))&&(a=!0)):!u&&h?(r.track({type:0,doc:h}),f=!0):u&&!h&&(r.track({type:1,doc:u}),f=!0,(o||l)&&(a=!0)),f&&(h?(i=i.add(h),s=d?s.add(e):s.delete(e)):(i=i.delete(e),s=s.delete(e)))}),null!==this.query.limit)for(;i.size>this.query.limit;
7){let e="F"===this.query.limitType?i.last():i.first();i=i.delete(e.key),s=s.delete(e.key),r.track({type:1,doc:e})}return{su:i,au:r,bs:a,mutatedKeys:s}}uu(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,n){let s=this.su;this.su=e.su,this.mutatedKeys=e.mutatedKeys;let i=e.au.Da();i.sort((e,t)=>{var r,n;let s;return r=e.type,n=t.type,(s=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return _(20277,{Vt:e})}})(r)-s(n)||this.iu(e.doc,t.doc)}),this.cu(r),n=n??!1;let a=t&&!n?this.lu():[],o=0===this.ru.size&&this.current&&!n?1:0,l=o!==this.nu;return(this.nu=o,0!==i.length||l)?{snapshot:new sp(this.query,e.su,s,i,e.mutatedKeys,0===o,l,!1,!!r&&r.resumeToken.approximateByteSize()>0),hu:a}:{hu:a}}Oa(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({su:this.su,au:new sg,mutatedKeys:this.mutatedKeys,bs:!1},!1)):{hu:[]}}Pu(e){return!this.tu.has(e)&&!!this.su.has(e)&&!this.su.get(e).hasLocalMutations}cu(e){e&&(e.addedDocuments.forEac
7h(e=>this.tu=this.tu.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.tu=this.tu.delete(e)),this.current=e.current)}lu(){if(!this.current)return[];let e=this.ru;this.ru=tz(),this.su.forEach(e=>{this.Pu(e.key)&&(this.ru=this.ru.add(e.key))});let t=[];return e.forEach(e=>{this.ru.has(e)||t.push(new sA(e))}),this.ru.forEach(r=>{e.has(r)||t.push(new sb(r))}),t}Tu(e){this.tu=e.ks,this.ru=tz();let t=this._u(e.documents);return this.applyChanges(t,!0)}Iu(){return sp.fromInitialDocuments(this.query,this.su,this.mutatedKeys,0===this.nu,this.hasCachedResults)}}let sD="SyncEngine";class sk{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class sx{constructor(e){this.key=e,this.Eu=!1}}class sR{constructor(e,t,r,n,s,i){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=n,this.currentUser=s,this.maxConcurrentLimboResolutions=i,this.Ru={},this.Au=new tO(e=>tx(e),tk),this.Vu=new Map,this.du=new Set,this.mu=new eg(j.comparator),this.fu=new Map,this.gu=new ns,this.pu={},this.yu=new Map,this.wu=r2.ar(),this.onlineState="Unknown",this.Su=void 0}get isPrimaryClient(){return!0===this.Su}}async function sV(e,t,r=!0){let n,s=s0(e),i=s.Au.get(t);return i?(s.sharedClientState.addLocalQueryTarget(i.targetId),n=i.view.Iu()):n=await sO(s,t,r,!0),n}async function sL(e,t){let r=s0(e);await sO(r,t,!0,!1)}async function sO(e,t,r,n){var s,i;let a,o=await (s=e.localStore,i=tI(t),s.persistence.runTransaction("Allocate target","readwrite",e=>{let t;return s.li.getTargetData(e,i).next(r=>r?(t=r,el.resolve(t)):s.li.allocateTargetId(e).next(r=>(t=new rW(i,r,"TargetPurposeListen",e.currentSequenceNumber),s.li.addTargetData(e,t).next(()=>t))))}).then(e=>{let t=s.vs.get(e.targetId);return(null===t||e.snapshotVersion.compareTo(t.snapshotVersion)>0)&&(s.vs=s.vs.insert(e.targetId,e),s.Fs.set(i,e.targetId)),e})),l=o.targetId,u=e.sharedClientState.addLocalQueryTarget(l,r);return n&&(a=await sM(e,t,l,"current"===u,o.resumeToken)),e.isPrimaryClient&&r&&nX(e.remoteStore,o),a}async function sM(e,t,r,n,s){e.bu=(t,r,n)=>(async function(e,t,r,n){let s=t.view._u(r);s.bs&&(s=await n_(e.localStore,t.query,!1).then(({documents:e})=>t.view._u(e,s)));let i=n&&n.targetChanges.get(t.targetId),a=n&&null!=n.targetMismatches.get(t.targetId),o=t.view.applyChanges(s,e.isPrimaryClient,i,a);return sW(e,t.targetId,o.hu),o.snapshot})(e,t,r,n);let i=await n_(e.localStore,t,!0),a=new sN(t,i.ks),o=a._u(i.documents),l=rE.createSynthesizedTargetChangeForCurrentChange(r,n&&"Offline"!==e.onlineState,s),u=a.applyChanges(o,e.isPrimaryClient,l);sW(e,r,u.hu);let h=new sk(t,r,a);return e.Au.set(t,h),e.Vu.has(r)?e.Vu.get(r).push(t):e.Vu.set(r,[t]),u.snapshot}async function sF(e,t,r){let n=e.Au.get(t),s=e.Vu.get(n.targetId);s.length>1?(e.Vu.set(n.targetId,s.filter(e=>!tk(e,t))),e.Au.delete(t)):e.isPrimaryClient?(e.sharedClientState.removeLocalQueryTarget(n.targetId),e.sharedClientState.isActiveQueryTarget(n.targetId)||await nT(e.localStore,n.targetId,!1).then(()=>{e.sharedClientState.clearQueryState(n.targetId),r&&nZ(e.remoteStore,n.targetId),sQ(e,n.targetId)}).catch(eo)):(sQ(e,n.targetId),await nT(e.localStore,n.targetId,!0))}async function sP(e,t){let r=e.Au.get(t),n=e.Vu.get(r.targetId);e.isPrimaryClient&&1===n.length&&(e.sharedClientState.removeLocalQueryTarget(r.targetId),nZ(e.remoteStore,r.targetId))}async function sU(e,t,r){var n,s,i;let a=((n=e).remoteStore.remoteSyncer.applySuccessfulWrite=sz.bind(null,n),n.remoteStore.remoteSyncer.rejectFailedWrite=sK.bind(null,n),n);try{let e,n,o,l,u,h=await (s=a.localStore,o=er.now(),l=t.reduce((e,t)=>e.add(t.key),tz()),s.persistence.runTransaction("Locally write mutations","readwrite",r=>{let i=tM,a=tz();return s.xs.getEntries(r,l).next(e=>{(i=e).forEach((e,t)=>{t.isValidDocument()||(a=a.add(e))})}).next(()=>s.localDocuments.getOverlayedDocuments(r,i)).next(n=>{e=n;let i=[];for(let r of t){let t=function(e,t){let r=null;for(let n of e.fieldTransforms){let e=t.data.field(n.field),s=tW(n.transform,e||null);null!=s&&(null===r&&(r=e6.empty()),r.set(n.field,s))}return r||null}(r,e.get(r.key).overlayedDocument);null!=t&&i.push(new rn(r.key,t,function e(t){let r=[];return ef(t.fields,(t,n)=>{let s=new G([t]);if(e1(n)){let t=e(n.mapValue).fields;if(0===t.length)r.push(s);else for(let e of t)r.push(s.child(e))}else r.push(s)}),new eE(r)}(t.value.mapValue),t5.exists(!0)))}
7return s.mutationQueue.addMutationBatch(r,o,i,t)}).next(t=>{n=t;let i=t.applyToLocalDocumentSet(e,a);return s.documentOverlayCache.saveOverlays(r,t.batchId,i)})}).then(()=>({batchId:n.batchId,changes:tU(e)})));a.sharedClientState.addPendingMutation(h.batchId),i=h.batchId,(u=a.pu[a.currentUser.toKey()])||(u=new eg(F)),u=u.insert(i,r),a.pu[a.currentUser.toKey()]=u,await sJ(a,h.changes),await st(a.remoteStore)}catch(t){let e=sf(t,"Failed to persist write");r.reject(e)}}async function sq(e,t){try{var r,n;let s,i,a=await (r=e.localStore,s=(n=t).snapshotVersion,i=r.vs,r.persistence.runTransaction("Apply remote event","readwrite-primary",e=>{var t,a,o;let l,u,h=r.xs.newChangeBuffer({trackRemovals:!0});i=r.vs;let c=[];n.targetChanges.forEach((t,a)=>{var o;let l=i.get(a);if(!l)return;c.push(r.li.removeMatchingKeys(e,t.removedDocuments,a).next(()=>r.li.addMatchingKeys(e,t.addedDocuments,a)));let u=l.withSequenceNumber(e.currentSequenceNumber);null!==n.targetMismatches.get(a)?u=u.withResumeToken(e_.EMPTY_BYTE_STRING,en.min()).withLastLimboFreeSnapshotVersion(en.min()):t.resumeToken.approximateByteSize()>0&&(u=u.withResumeToken(t.resumeToken,s)),i=i.insert(a,u),o=u,(0===l.resumeToken.approximateByteSize()||o.snapshotVersion.toMicroseconds()-l.snapshotVersion.toMicroseconds()>=3e8||t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size>0)&&c.push(r.li.updateTargetData(e,u))});let d=tM,f=tz();if(n.documentUpdates.forEach(t=>{n.resolvedLimboDocuments.has(t)&&c.push(r.persistence.referenceDelegate.updateLimboDocument(e,t))}),c.push((t=e,a=h,o=n.documentUpdates,l=tz(),u=tz(),o.forEach(e=>l=l.add(e)),a.getEntries(t,l).next(e=>{let t=tM;return o.forEach((r,n)=>{let s=e.get(r);n.isFoundDocument()!==s.isFoundDocument()&&(u=u.add(r)),n.isNoDocument()&&n.version.isEqual(en.min())?(a.removeEntry(r,n.readTime),t=t.insert(r,n)):!s.isValidDocument()||n.version.compareTo(s.version)>0||0===n.version.compareTo(s.version)&&s.hasPendingWrites?(a.addEntry(n),t=t.insert(r,n)):v(ny,"Ignoring outdated watch update for ",r,". Current version:",s.version," Watch version:",n.version)}),{Bs:t,Ls:u}})).next(e=>{d=e.Bs,f=e.Ls})),!s.isEqual(en.min())){let t=r.li.getLastRemoteSnapshotVersion(e).next(t=>r.li.setTargetsMetadata(e,e.currentSequenceNumber,s));c.push(t)}return el.waitFor(c).next(()=>h.apply(e)).next(()=>r.localDocuments.getLocalViewOfDocuments(e,d,f)).next(()=>d)}).then(e=>(r.vs=i,e)));
7t.targetChanges.forEach((t,r)=>{let n=e.fu.get(r);n&&(I(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1,22616),t.addedDocuments.size>0?n.Eu=!0:t.modifiedDocuments.size>0?I(n.Eu,14607):t.removedDocuments.size>0&&(I(n.Eu,42227),n.Eu=!1))}),await sJ(e,a,t)}catch(e){await eo(e)}}function s$(e,t,r){if(e.isPrimaryClient&&0===r||!e.isPrimaryClient&&1===r){var n;let r,s=[];e.Au.forEach((e,r)=>{let n=r.view.Oa(t);n.snapshot&&s.push(n.snapshot)}),(n=e.eventManager).onlineState=t,r=!1,n.queries.forEach((e,n)=>{for(let e of n.va)e.Oa(t)&&(r=!0)}),r&&sI(n),s.length&&e.Ru.H_(s),e.onlineState=t,e.isPrimaryClient&&e.sharedClientState.setOnlineState(t)}}async function sB(e,t,r){e.sharedClientState.updateQueryState(t,"rejected",r);let n=e.fu.get(t),s=n&&n.key;if(s){let r=new eg(j.comparator);r=r.insert(s,e5.newNoDocument(s,en.min()));let n=tz().add(s),i=new rw(en.min(),new Map,new eg(F),r,n);await sq(e,i),e.mu=e.mu.remove(s),e.fu.delete(t),sY(e)}else await nT(e.localStore,t,!1).then(()=>sQ(e,t,r)).catch(eo)}async function sz(e,t){let r=t.batch.batchId;try{var n,s;let i=await (n=e.localStore,s=t,n.persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{let t,r,i,a=s.batch.keys(),o=n.xs.newChangeBuffer({trackRemovals:!0});
7return(r=(t=s.batch).keys(),i=el.resolve(),r.forEach(r=>{i=i.next(()=>o.getEntry(e,r)).next(e=>{let n=s.docVersions.get(r);I(null!==n,48541),0>e.version.compareTo(n)&&(t.applyToRemoteDocument(e,s),e.isValidDocument()&&(e.setReadTime(s.commitVersion),o.addEntry(e)))})}),i.next(()=>n.mutationQueue.removeMutationBatch(e,t))).next(()=>o.apply(e)).next(()=>n.mutationQueue.performConsistencyCheck(e)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(e,a,s.batch.batchId)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=tz();for(let r=0;r<e.mutationResults.length;++r)e.mutationResults[r].transformResults.length>0&&(t=t.add(e.batch.mutations[r].key));return t}(s))).next(()=>n.localDocuments.getDocuments(e,a))}));sj(e,r,null),sG(e,r),e.sharedClientState.updateMutationState(r,"acknowledged"),await sJ(e,i)}catch(e){await eo(e)}}async function sK(e,t,r){try{var n;let s=await (n=e.localStore,n.persistence.runTransaction("Reject batch","readwrite-primary",e=>{let r;return n.mutationQueue.lookupMutationBatch(e,t).next(t=>(I(null!==t,37113),r=t.keys(),n.mutationQueue.removeMutationBatch(e,t))).next(()=>n.mutationQueue.performConsistencyCheck(e)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,r)).next(()=>n.localDocuments.getDocuments(e,r))}));sj(e,t,r),sG(e,t),e.sharedClientState.updateMutationState(t,"rejected",r),await sJ(e,s)}catch(e){await eo(e)}}function sG(e,t){(e.yu.get(t)||[]).forEach(e=>{e.resolve()}),e.yu.delete(t)}function sj(e,t,r){let n=e.pu[e.currentUser.toKey()];if(n){let s=n.get(t);s&&(r?s.reject(r):s.resolve(),n=n.remove(t)),e.pu[e.currentUser.toKey()]=n}}function sQ(e,t,r=null){for(let n of(e.sharedClientState.removeLocalQueryTarget(t),e.Vu.get(t)))e.Au.delete(n),r&&e.Ru.Du(n,r);e.Vu.delete(t),e.isPrimaryClient&&e.gu.Gr(t).forEach(t=>{e.gu.containsKey(t)||sH(e,t)})}function sH(e,t){e.du.delete(t.path.canonicalString());let r=e.mu.get(t);null!==r&&(nZ(e.remoteStore,r),e.mu=e.mu.remove(t),e.fu.delete(r),sY(e))}function sW(e,t,r){for(let n of r)n instanceof sb?(e.gu.addReference(n.key,t),function(e,t){let r=t.key,n=r.path.canonicalString();e.mu.get(r)||e.du.has(n)||(v(sD,"New document in limbo: "+r),e.du.add(n),sY(e))}(e,n)):n instanceof sA?(v(sD,"Document no longer in limbo: "+n.key),e.gu.removeReference(n.key,t),e.gu.containsKey(n.key)||sH(e,n.key)):_(19791,{Cu:n})}function sY(e){for(;e.du.size>0&&e.mu.size<e.maxConcurrentLimboResolutions;){let t=e.du.values().next().value;e.du.delete(t);let r=new j(z.fromString(t)),n=e.wu.next();e.fu.set(n,new sx(r)),e.mu=e.mu.insert(r,n),nX(e.remoteStore,new rW(tI(tE(r.path)),n,"TargetPurposeLimboResolution",eh.ce))}}async function sJ(e,t,r){let n=[],s=[],i=[];e.Au.isEmpty()||(e.Au.forEach((a,o)=>{i.push(e.bu(o,t,r).then(t=>{if((t||r)&&e.isPrimaryClient){let n=t?!t.fromCache:r?.targetChanges.get(o.targetId)?.current;e.sharedClientState.updateQueryState(o.targetId,n?"current":"not-current")}if(t){n.push(t);let e=nm.Es(o.targetId,t);s.push(e)}}))}),await Promise.all(i),e.Ru.H_(n),await async function(e,t){try{await e.persistence.runTransaction("notifyLocalViewChanges","readwrite",r=>el.forEach(t,t=>el.forEach(t.Ts,n=>e.persistence.referenceDelegate.addReference(r,t.targetId,n)).next(()=>el.forEach(t.Is,n=>e.persistence.referenceDelegate.removeReference(r,t.targetId,n)))))}catch(e){if(!eu(e))throw e;v(ny,"Failed to update sequence numbers: "+e)}for(let r of t){let t=r.targetId;if(!r.fromCache){let r=e.vs.get(t),n=r.snapshotVersion,s=r.withLastLimboFreeSnapshotVersion(n);e.vs=e.vs.insert(t,s)}}}(e.localStore,s))}async function sX(e,t){if(!e.currentUser.isEqual(t)){v(sD,"User change. New user:",t.toKey());let r=await nw(e.localStore,t);e.currentUser=t,e.yu.forEach(e=>{e.forEach(e=>{e.reject(new b(C.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.yu.clear(),e.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await sJ(e,r.Ns)}}function sZ(e,t){let r=e.fu.get(t);if(r&&r.Eu)return tz().add(r.key);{let r=tz(),n=e.Vu.get(t);if(!n)return r;for(let t of n){let n=e.Au.get(t);r=r.unionWith(n.view.ou)}return r}}function s0(e){return e.remoteStore.remoteSyncer.applyRemoteEvent=sq.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=sZ.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=sB.bind(null,e),e.Ru.H_=s_.bind(null,e.eventManager),e.Ru.Du=sS.bind(null,e.eventManager),e}class s1{constructor(){this.kind="memory",this.synchronizeTabs=!1}
7async initialize(e){this.serializer=nP(e.databaseInfo.databaseId),this.sharedClientState=this.Mu(e),this.persistence=this.xu(e),await this.persistence.start(),this.localStore=this.Ou(e),this.gcScheduler=this.Nu(e,this.localStore),this.indexBackfillerScheduler=this.Bu(e,this.localStore)}Nu(e,t){return null}Bu(e,t){return null}Ou(e){var t,r;return t=this.persistence,r=new np,new nv(t,r,e.initialUser,this.serializer)}xu(e){return new nh(nd.Vi,this.serializer)}Mu(e){return new nI}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}s1.provider={build:()=>new s1};class s2 extends s1{constructor(e){super(),this.cacheSizeBytes=e}Nu(e,t){return I(this.persistence.referenceDelegate instanceof nf,46915),new r5(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}xu(e){let t=void 0!==this.cacheSizeBytes?r1.withCacheSize(this.cacheSizeBytes):r1.DEFAULT;return new nh(e=>nf.Vi(e,t),this.serializer)}}class s3{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>s$(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=sX.bind(null,this.syncEngine),await su(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new sv}createDatastore(e){var t;let r=nP(e.databaseInfo.databaseId),n=new nM(e.databaseInfo);return t=e.authCredentials,new nG(t,e.appCheckCredentials,n,r)}createRemoteStore(e){var t,r;return t=this.localStore,r=this.datastore,new nH(t,r,e.asyncQueue,e=>s$(this.syncEngine,e,0),nA.v()?new nA:new nC)}createSyncEngine(e,t){var r,n,s,i,a,o;let l;return r=this.localStore,n=this.remoteStore,s=this.eventManager,i=this.sharedClientState,a=e.initialUser,o=e.maxConcurrentLimboResolutions,l=new sR(r,n,s,i,a,o),t&&(l.Su=!0),l}async terminate(){await async function(e){v(nQ,"RemoteStore shutting down."),e.da.add(5),await nY(e),e.fa.shutdown(),e.ga.set("Unknown")}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}}s3.provider={build:()=>new s3};class s4{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.ku(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.ku(this.observer.error,e):w("Uncaught Error in snapshot listener:",e.toString()))}Ku(){this.muted=!0}ku(e,t){setTimeout(()=>{this.muted||e(t)},0)}}let s6="FirestoreClient";class s5{constructor(e,t,r,n,s){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this._databaseInfo=n,this.user=f.UNAUTHENTICATED,this.clientId=M.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=s,this.authCredentials.start(r,async e=>{v(s6,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(r,e=>(v(s6,"Received new app check token=",e),this.appCheckCredentialListener(e,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new A;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(r){let t=sf(r,"Failed to shutdown persistence");e.reject(t)}}),e.promise}}async function s8(e,t){e.asyncQueue.verifyOperationInProgress(),v(s6,"Initializing OfflineComponentProvider");let r=e.configuration;await t.initialize(r);let n=r.initialUser;e.setCredentialChangeListener(async e=>{n.isEqual(e)||(await nw(t.localStore,e),n=e)}),t.persistence.setDatabaseDeletedListener(()=>e.terminate()),e._offlineComponents=t}async function s9(e,t){e.asyncQueue.verifyOperationInProgress();let r=await s7(e);v(s6,"Initializing OnlineComponentProvider"),await t.initialize(r,e.configuration),e.setCredentialChangeListener(e=>sl(t.remoteStore,e)),e.setAppCheckTokenChangeListener((e,r)=>sl(t.remoteStore,r)),e._onlineComponents=t}async function s7(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){v(s6,"Using user provided OfflineComponentProvider");try{await s8(e,e._uninitializedComponentsProvider._offline)}catch(t){if(!("FirebaseError"===t.name?t.code===C.FAILED_PRECONDITION||t.code===C.UNIMPLEMENT
7ED:!("u">typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code))throw t;E("Error using user provided cache. Falling back to memory cache: "+t),await s8(e,new s1)}}else v(s6,"Using default OfflineComponentProvider"),await s8(e,new s2(void 0));return e._offlineComponents}async function ie(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(v(s6,"Using user provided OnlineComponentProvider"),await s9(e,e._uninitializedComponentsProvider._online)):(v(s6,"Using default OnlineComponentProvider"),await s9(e,new s3))),e._onlineComponents}async function it(e){let t=await ie(e),r=t.eventManager;return r.onListen=sV.bind(null,t.syncEngine),r.onUnlisten=sF.bind(null,t.syncEngine),r.onFirstRemoteStoreListen=sL.bind(null,t.syncEngine),r.onLastRemoteStoreUnlisten=sP.bind(null,t.syncEngine),r}function ir(e,t,r,n){let s=new s4(n),i=new sC(t,s,r);return e.asyncQueue.enqueueAndForget(async()=>sE(await it(e),i)),()=>{s.Ku(),e.asyncQueue.enqueueAndForget(async()=>sT(await it(e),i))}}function is(e,t,r={}){let n=new A;return e.asyncQueue.enqueueAndForget(async()=>{var s,i;let a,o;return s=await it(e),i=e.asyncQueue,a=new s4({next:e=>{a.Ku(),i.enqueueAndForget(()=>sT(s,o));let l=e.docs.has(t);!l&&e.fromCache?n.reject(new b(C.UNAVAILABLE,"Failed to get document because the client is offline.")):l&&e.fromCache&&r&&"server"===r.source?n.reject(new b(C.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):n.resolve(e)},error:e=>n.reject(e)}),sE(s,o=new sC(tE(t.path),a,{includeMetadataChanges:!0,Wa:!0}))}),n.promise}function ii(e,t,r={}){let n=new A;return e.asyncQueue.enqueueAndForget(async()=>{var s,i;let a,o;return s=await it(e),i=e.asyncQueue,o=new sC(t,a=new s4({next:e=>{a.Ku(),i.enqueueAndForget(()=>sT(s,o)),e.fromCache&&"server"===r.source?n.reject(new b(C.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):n.resolve(e)},error:e=>n.reject(e)}),{includeMetadataChanges:!0,Wa:!0}),sE(s,o)}),n.promise}function ia(e,t){let r=new A;return e.asyncQueue.enqueueAndForget(async()=>sU(await ie(e).then(e=>e.syncEngine),t,r)),r.promise}function io(e){let t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}let il=new Map,iu="firestore.googleapis.com";class ih{constructor(e){if(void 0===e.host){if(void 0!==e.ssl)throw new b(C.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=iu,this.ssl=!0}else this.host=e.host,this.ssl=e.ssl??!0;if(this.isUsingEmulator=void 0!==e.emulatorOptions,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,void 0===e.cacheSizeBytes)this.cacheSizeBytes=0x2800000;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new b(C.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}(function(e,t,r,n){if(!0===t&&!0===n)throw new b(C.INVALID_ARGUMENT,`${e} and ${r} 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=io(e.experimentalLongPollingOptions??{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new b(C.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new b(C.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new b(C.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){var t,r;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&&(t=this.experimentalLongPollingOptions,r=e.experimentalLongPollingOptions,t.timeoutSeconds===r.timeoutSeconds)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class ic{constructor(e,t,r,n){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new ih({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new b(C.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new b(C.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new ih(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new D;switch(e.type){case"firstParty":return new V(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new b(C.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
7d 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(){let e;return(e=il.get(this))&&(v("ComponentProvider","Removing Datastore"),il.delete(this),e.terminate()),Promise.resolve()}}class id{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new id(this.firestore,e,this._query)}}class im{constructor(e,t,r){this.converter=t,this._key=r,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 ig(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new im(this.firestore,e,this._key)}toJSON(){return{type:im._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(et(t,im._jsonSchema))return new im(e,r||null,new j(z.fromString(t.referencePath)))}}im._jsonSchemaVersion="firestore/documentReference/1.0",im._jsonSchema={type:ee("string",im._jsonSchemaVersion),referencePath:ee("string")};class ig extends id{constructor(e,t,r){super(e,t,tE(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new im(this.firestore,null,new j(e))}withConverter(e){return new ig(this.firestore,e,this._path)}}function ip(e,t,...r){if(e=(0,l.Ku)(e),Q("collection","path",t),e instanceof ic){let n=z.fromString(t,...r);return W(n),new ig(e,null,n)}{if(!(e instanceof im||e instanceof ig))throw new b(C.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=e._path.child(z.fromString(t,...r));return W(n),new ig(e.firestore,null,n)}}function iy(e,t,...r){if(e=(0,l.Ku)(e),1==arguments.length&&(t=M.newId()),Q("doc","path",t),e instanceof ic){let n=z.fromString(t,...r);return H(n),new im(e,null,new j(n))}{if(!(e instanceof im||e instanceof ig))throw new b(C.INVALID_ARGUMENT,"Expected first argument to doc() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=e._path.child(z.fromString(t,...r));return H(n),new im(e.firestore,e instanceof ig?e.converter:null,new j(n))}}let iv="AsyncQueue";class iw{constructor(e=Promise.resolve()){this.rc=[],this.sc=!1,this.oc=[],this._c=null,this.ac=!1,this.uc=!1,this.cc=[],this.M_=new nU(this,"async_queue_retry"),this.lc=()=>{let e=nF();e&&v(iv,"Visibility state changed to "+e.visibilityState),this.M_.w_()},this.hc=e;const t=nF();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.lc)}get isShuttingDown(){return this.sc}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.Pc(),this.Tc(e)}enterRestrictedMode(e){if(!this.sc){this.sc=!0,this.uc=e||!1;let t=nF();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.lc)}}enqueue(e){if(this.Pc(),this.sc)return new Promise(()=>{});let t=new A;return this.Tc(()=>this.sc&&this.uc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.rc.push(e),this.Ic()))}async Ic(){if(0!==this.rc.length){try{await this.rc[0](),this.rc.shift(),this.M_.reset()}catch(e){if(!eu(e))throw e;v(iv,"Operation failed with retryable error: "+e)}this.rc.length>0&&this.M_.p_(()=>this.Ic())}}Tc(e){let t=this.hc.then(()=>(this.ac=!0,e().catch(e=>{throw this._c=e,this.ac=!1,w("INTERNAL UNHANDLED ERROR: ",iE(e)),e}).then(e=>(this.ac=!1,e))));return this.hc=t,t}enqueueAfterDelay(e,t,r){this.Pc(),this.cc.indexOf(e)>-1&&(t=0);let n=sd.createAndSchedule(this,e,t,r,e=>this.Ec(e));return this.oc.push(n),n}Pc(){this._c&&_(47125,{Rc:iE(this._c)})}verifyOperationInProgress(){}async Ac(){let e;do e=this.hc,await e;while(e!==this.hc)}Vc(e){for(let t of this.oc)if(t.timerId===e)return!0;return!1}dc(e){return this.Ac().then(()=>{for(let t of(this.oc.sort((e,t)=>
7e.targetTimeMs-t.targetTimeMs),this.oc))if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.Ac()})}mc(e){this.cc.push(e)}Ec(e){let t=this.oc.indexOf(e);this.oc.splice(t,1)}}function iE(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}class iT extends ic{constructor(e,t,r,n){super(e,t,r,n),this.type="firestore",this._queue=new iw,this._persistenceKey=n?.name||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new iw(e),this._firestoreClient=void 0,await e}}}function i_(e,t){let r="object"==typeof e?e:(0,o.Sx)(),n=(0,o.j6)(r,"firestore").getImmediate({identifier:"string"==typeof e?e:t||eO});if(!n._initialized){let e=(0,l.yU)("firestore");e&&function(e,t,r,n={}){e=X(e,ic);let s=(0,l.zJ)(t),i=e._getSettings(),a={...i,emulatorOptions:e._getEmulatorOptions()},o=`${t}:${r}`;s&&(0,l.gE)(`https://${o}`),i.host!==iu&&i.host!==o&&E("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");let u={...i,host:o,ssl:s,emulatorOptions:n};if(!(0,l.bD)(u,a)&&(e._setSettings(u),n.mockUserToken)){let t,r;if("string"==typeof n.mockUserToken)t=n.mockUserToken,r=f.MOCK_USER;else{t=(0,l.Fy)(n.mockUserToken,e._app?.options.projectId);let s=n.mockUserToken.sub||n.mockUserToken.user_id;if(!s)throw new b(C.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");r=new f(s)}e._authCredentials=new k(new N(t,r))}}(n,...e)}return n}function iS(e){if(e._terminated)throw new b(C.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||function(e){var t,r,n,s,i;let a,o=e._freezeSettings(),l=(t=e._databaseId,r=e._app?.options.appId||"",n=e._persistenceKey,s=e._app?.options.apiKey,new eL(t,r,n,o.host,o.ssl,o.experimentalForceLongPolling,o.experimentalAutoDetectLongPolling,io(o.experimentalLongPollingOptions),o.useFetchStreams,o.isUsingEmulator,s));e._componentsProvider||o.localCache?._offlineComponentProvider&&o.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:o.localCache._offlineComponentProvider,_online:o.localCache._onlineComponentProvider}),e._firestoreClient=new s5(e._authCredentials,e._appCheckCredentials,e._queue,l,e._componentsProvider&&(i=e._componentsProvider,a=i?._online.build(),{_offline:i?._offline.build(a),_online:a}))}(e),e._firestoreClient}class iI{constructor(e){this._byteString=e}static fromBase64String(e){try{return new iI(e_.fromBase64String(e))}catch(e){throw new b(C.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new iI(e_.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:iI._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(et(e,iI._jsonSchema))return iI.fromBase64String(e.bytes)}}iI._jsonSchemaVersion="firestore/bytes/1.0",iI._jsonSchema={type:ee("string",iI._jsonSchemaVersion),bytes:ee("string")};class iC{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new b(C.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new G(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}function ib(){return new iC($)}class iA{constructor(e){this._methodName=e}}class iN{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new b(C.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new b(C.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return F(this._lat,e._lat)||F(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:iN._jsonSchemaVersion}}static fromJSON(e){if(et(e,iN._jsonSchema))return new iN(e.latitude,e.longitude)}}
7iN._jsonSchemaVersion="firestore/geoPoint/1.0",iN._jsonSchema={type:ee("string",iN._jsonSchemaVersion),latitude:ee("number"),longitude:ee("number")};class iD{constructor(e){this._values=(e||[]).map(e=>e)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}(this._values,e._values)}toJSON(){return{type:iD._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(e){if(et(e,iD._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(e=>"number"==typeof e))return new iD(e.vectorValues);throw new b(C.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}iD._jsonSchemaVersion="firestore/vectorValue/1.0",iD._jsonSchema={type:ee("string",iD._jsonSchemaVersion),vectorValues:ee("object")};let ik=/^__.*__$/;class ix{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return null!==this.fieldMask?new rn(e,this.data,this.fieldMask,t,this.fieldTransforms):new rr(e,this.data,t,this.fieldTransforms)}}class iR{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new rn(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function iV(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw _(40011,{dataSource:e})}}class iL{constructor(e,t,r,n,s,i){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=n,void 0===s&&this.fc(),this.fieldTransforms=s||[],this.fieldMask=i||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}i(e){return new iL({...this.settings,...e},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}yc(e){let t=this.path?.child(e),r=this.i({path:t,arrayElement:!1});return r.wc(e),r}Sc(e){let t=this.path?.child(e),r=this.i({path:t,arrayElement:!1});return r.fc(),r}bc(e){return this.i({path:void 0,arrayElement:!0})}Dc(e){return i0(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return void 0!==this.fieldMask.find(t=>e.isPrefixOf(t))||void 0!==this.fieldTransforms.find(t=>e.isPrefixOf(t.field))}fc(){if(this.path)for(let e=0;e<this.path.length;e++)this.wc(this.path.get(e))}wc(e){if(0===e.length)throw this.Dc("Document fields must not be empty");if(iV(this.dataSource)&&ik.test(e))throw this.Dc('Document fields cannot begin and end with "__"')}}class iO{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||nP(e)}V(e,t,r,n=!1){return new iL({dataSource:e,methodName:t,targetDoc:r,path:G.emptyPath(),arrayElement:!1,hasConverter:n},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function iM(e){let t=e._freezeSettings(),r=nP(e._databaseId);return new iO(e._databaseId,!!t.ignoreUndefinedProperties,r)}function iF(e,t,r,n,s,i={}){let a,o,l=e.V(i.merge||i.mergeFields?2:0,t,r,s);iY("Data must be an object, but it was:",l,n);let u=iH(n,l);if(i.merge)a=new eE(l.fieldMask),o=l.fieldTransforms;else if(i.mergeFields){let e=[];for(let n of i.mergeFields){let s=iJ(t,n,r);if(!l.contains(s))throw new b(C.INVALID_ARGUMENT,`Field '${s}' is specified in your field mask but missing from your input data.`);i1(e,s)||e.push(s)}a=new eE(e),o=l.fieldTransforms.filter(e=>a.covers(e.field))}else a=null,o=l.fieldTransforms;return new ix(new e6(u),a,o)}class iP extends iA{_toFieldTransform(e){if(2!==e.dataSource)throw 1===e.dataSource?e.Dc(`${this._methodName}() can only appear at the top level of your update data`):e.Dc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof iP}}function iU(e,t,r){return new iL({dataSource:3,targetDoc:t.settings.targetDoc,methodName:e._methodName,arrayElement:r},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class iq extends iA{_toFieldTransform(e){return new t4(e.path,new tY)}isEqual(e){return e instanceof iq}}class i$ extends iA{constructor(e,t){super(e),this.vc=t}_toFieldTransform(e){let t=iU(this,e,!0),r=new tJ(this.vc.map(e=>iQ(e,t)));return new t4(e.path,r)}isEqual(e){return e instanceof i$&&(0,l.bD)(this.vc,e.vc)}}class iB extends iA{constructor(e,t){super(e),this.vc=t}_toFieldTransform(e){let t=iU(this,e,!0),r=new tZ(this.vc.map(e=>iQ(e,t)));return new t4(e.path,r)}isEqual(e){return e instanceof iB&&(0,l.bD)(this.vc,e.vc)}}class iz extends iA{constructor(e,t){super(e),this.Fc=t}_toFieldTransform(e){let t=new t1(e.serializer,tQ(e.serializer,this.Fc));return new t4(e.path,t)}isEqual(e){return e instanceof iz&&this.Fc===e.Fc}}function iK(e,t,r,n){let s=e.V(1,t,r);iY("Data must be an object, but it was:",s,n);let i=[],a=e6.empty();return ef(n,(e,n)=>{let o=iZ(t,e,r);n=(0,l.Ku)(n);let u=s.Sc(o);if(n instanceof iP)i.push(o);else{let e=iQ(n,u);null!=e&&(i.push(o),a.set(o,e))}}),new iR(a,new eE(i),s.fieldTransforms)}function iG(e,t,r,n,s,i){let a=e.V(1,t,r),o=[iJ(t,n,r)],u=[s];if(i.length%2!=0)throw new b(C.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<i.length;e+=2)o.push(iJ(t,i[e])),u.push(i[e+1]);let h=[],c=e6.empty();for(let e=o.length-1;e>=0;
7--e)if(!i1(h,o[e])){let t=o[e],r=u[e];r=(0,l.Ku)(r);let n=a.Sc(t);if(r instanceof iP)h.push(t);else{let e=iQ(r,n);null!=e&&(h.push(t),c.set(t,e))}}return new iR(c,new eE(h),a.fieldTransforms)}function ij(e,t,r,n=!1){return iQ(r,e.V(n?4:3,t))}function iQ(e,t){if(iW(e=(0,l.Ku)(e)))return iY("Unsupported field value:",t,e),iH(e,t);if(e instanceof iA)return function(e,t){if(!iV(t.dataSource))throw t.Dc(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.Dc(`${e._methodName}() is not currently supported inside arrays`);let r=e._toFieldTransform(t);r&&t.fieldTransforms.push(r)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.arrayElement&&4!==t.dataSource)throw t.Dc("Nested arrays are not supported");let r=[],n=0;for(let s of e){let e=iQ(s,t.bc(n));null==e&&(e={nullValue:"NULL_VALUE"}),r.push(e),n++}return{arrayValue:{values:r}}}return function(e,t){if(null===(e=(0,l.Ku)(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return tQ(t.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){let r=er.fromDate(e);return{timestampValue:rV(t.serializer,r)}}if(e instanceof er){let r=new er(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:rV(t.serializer,r)}}if(e instanceof iN)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof iI)return{bytesValue:rL(t.serializer,e._byteString)};if(e instanceof im){let r=t.databaseId,n=e.firestore._databaseId;if(!n.isEqual(r))throw t.Dc(`Document reference is for database ${n.projectId}/${n.database} but should be for database ${r.projectId}/${r.database}`);return{referenceValue:rM(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof iD){var r;return{mapValue:{fields:{[eP]:{stringValue:e$},[eB]:{arrayValue:{values:((r=e)instanceof iD?r.toArray():r).map(e=>{if("number"!=typeof e)throw t.Dc("VectorValues must only contain numeric values.");return tG(t.serializer,e)})}}}}}}if(rH(e))return e._toProto(t.serializer);throw t.Dc(`Unsupported field value: ${J(e)}`)}(e,t)}function iH(e,t){let r={};return em(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):ef(e,(e,n)=>{let s=iQ(n,t.yc(e));null!=s&&(r[e]=s)}),{mapValue:{fields:r}}}function iW(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof er||e instanceof iN||e instanceof iI||e instanceof im||e instanceof iA||e instanceof iD||rH(e))}function iY(e,t,r){if(!iW(r)||!Y(r)){let n=J(r);throw"an object"===n?t.Dc(e+" a custom object"):t.Dc(e+" "+n)}}function iJ(e,t,r){if((t=(0,l.Ku)(t))instanceof iC)return t._internalPath;if("string"==typeof t)return iZ(e,t);throw i0("Field path arguments must be of type string or ",e,!1,void 0,r)}let iX=RegExp("[~\\*/\\[\\]]");function iZ(e,t,r){if(t.search(iX)>=0)throw i0(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,r);try{return new iC(...t.split("."))._internalPath}catch(n){throw i0(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,r)}}function i0(e,t,r,n,s){let i=n&&!n.isEmpty(),a=void 0!==s,o=`Function ${t}() called with invalid data`;r&&(o+=" (via `toFirestore()`)"),o+=". ";let l="";return(i||a)&&(l+=" (found",i&&(l+=` in field ${n}`),a&&(l+=` in document ${s}`),l+=")"),new b(C.INVALID_ARGUMENT,o+e+l)}function i1(e,t){return e.some(e=>e.isEqual(t))}class i2{convertValue(e,t="none"){switch(ez(e)){case 0:return null;case 1:return e.booleanValue;case 2:return eC(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(eb(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw _(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let r={};return ef(e,(e,n)=>{r[e]=this.convertValue(n,t)}),r}convertVectorValue(e){return new iD(e.fields?.[eB].arrayValue?.values?.map(e=>eC(e.doubleValue)))}convertGeoPoint(e){return new iN(eC(e.latitude),eC(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":let r=eR(e);return null==r?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(eV(e));default:return null}}convertTimestamp(e){let t=eI(e);return new er(t.seconds,t.nanos)}convertDocumentKey(e,t){let r=z.fromString(e);I(rQ(r),9688,{name:e});let n=new eM(r.get(1),r.get(3)),s=new j(r.popFirst(5));return n.isEqual(t)||w(`Document ${s} contains a document reference within a different database (${n.projectId}/${n.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),s}}class i3 extends i2{constructor(e){super(),this.firestore=e}convertBytes(e){return new iI(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);
7return new im(this.firestore,null,t)}}function i4(){return new iP("deleteField")}function i6(){return new iq("serverTimestamp")}function i5(...e){return new i$("arrayUnion",e)}function i8(...e){return new iB("arrayRemove",e)}function i9(e){return new iz("increment",e)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.