@ienlab/react-library 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,4 +13,4 @@ Total Duration: ${c-l}ms`),B.resolve({didRun:!0,sequenceNumbersCollected:r,targe
13
13
  `+e.join(`
14
14
  `)+`
15
15
  )`}copy(t,n){let r=new e;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r}},rc=class{constructor(){this.ga=new U(F.comparator)}track(e){let t=e.doc.key,n=this.ga.get(t);n?e.type!==0&&n.type===3?this.ga=this.ga.insert(t,e):e.type===3&&n.type!==1?this.ga=this.ga.insert(t,{type:n.type,doc:e.doc}):e.type===2&&n.type===2?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):e.type===2&&n.type===0?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):e.type===1&&n.type===0?this.ga=this.ga.remove(t):e.type===1&&n.type===2?this.ga=this.ga.insert(t,{type:1,doc:n.doc}):e.type===0&&n.type===1?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):E(63341,{Vt:e,pa:n}):this.ga=this.ga.insert(t,e)}ya(){let e=[];return this.ga.inorderTraversal(((t,n)=>{e.push(n)})),e}},ic=class e{constructor(e,t,n,r,i,a,o,s,c){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=o,this.excludesMetadataChanges=s,this.hasCachedResults=c}static fromInitialDocuments(t,n,r,i,a){let o=[];return n.forEach((e=>{o.push({type:0,doc:e})})),new e(t,n,nc.emptySet(n),o,r,i,!0,!1,a)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&Ti(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==n[e].type||!t[e].doc.isEqual(n[e].doc))return!1;return!0}},ac=class{constructor(){this.wa=void 0,this.Sa=[]}ba(){return this.Sa.some((e=>e.Da()))}},oc=class{constructor(){this.queries=sc(),this.onlineState=`Unknown`,this.Ca=new Set}terminate(){(function(e,t){let n=O(e),r=n.queries;n.queries=sc(),r.forEach(((e,n)=>{for(let e of n.Sa)e.onError(t)}))})(this,new A(k.ABORTED,`Firestore shutting down`))}};function sc(){return new Mi((e=>Ei(e)),Ti)}async function cc(e,t){let n=O(e),r=3,i=t.query,a=n.queries.get(i);a?!a.ba()&&t.Da()&&(r=2):(a=new ac,r=+!t.Da());try{switch(r){case 0:a.wa=await n.onListen(i,!0);break;case 1:a.wa=await n.onListen(i,!1);break;case 2:await n.onFirstRemoteStoreListen(i)}}catch(e){let n=tc(e,`Initialization of query '${Di(t.query)}' failed`);t.onError(n);return}n.queries.set(i,a),a.Sa.push(t),t.va(n.onlineState),a.wa&&t.Fa(a.wa)&&fc(n)}async function lc(e,t){let n=O(e),r=t.query,i=3,a=n.queries.get(r);if(a){let e=a.Sa.indexOf(t);e>=0&&(a.Sa.splice(e,1),a.Sa.length===0?i=+!t.Da():!a.ba()&&t.Da()&&(i=2))}switch(i){case 0:return n.queries.delete(r),n.onUnlisten(r,!0);case 1:return n.queries.delete(r),n.onUnlisten(r,!1);case 2:return n.onLastRemoteStoreUnlisten(r);default:return}}function uc(e,t){let n=O(e),r=!1;for(let e of t){let t=e.query,i=n.queries.get(t);if(i){for(let t of i.Sa)t.Fa(e)&&(r=!0);i.wa=e}}r&&fc(n)}function dc(e,t,n){let r=O(e),i=r.queries.get(t);if(i)for(let e of i.Sa)e.onError(n);r.queries.delete(t)}function fc(e){e.Ca.forEach((e=>{e.next()}))}var pc,mc;(mc=pc||={}).Ma=`default`,mc.Cache=`cache`;var hc=class{constructor(e,t,n){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState=`Unknown`,this.options=n||{}}Fa(e){if(!this.options.includeMetadataChanges){let t=[];for(let n of e.docChanges)n.type!==3&&t.push(n);e=new ic(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){if(!e.fromCache||!this.Da())return!0;let n=t!==`Offline`;return(!this.options.qa||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||t===`Offline`)}Ba(e){if(e.docChanges.length>0)return!0;let t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}ka(e){e=ic.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==pc.Cache}},gc=class{constructor(e){this.key=e}},_c=class{constructor(e){this.key=e}},vc=class{constructor(e,t){this.query=e,this.Za=t,this.Xa=null,this.hasCachedResults=!1,this.current=!1,this.Ya=J(),this.mutatedKeys=J(),this.eu=Ai(e),this.tu=new nc(this.eu)}get nu(){return this.Za}ru(e,t){let n=t?t.iu:new rc,r=t?t.tu:this.tu,i=t?t.mutatedKeys:this.mutatedKeys,a=r,o=!1,s=this.query.limitType===`F`&&r.size===this.query.limit?r.last():null,c=this.query.limitType===`L`&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal(((e,t)=>{let l=r.get(e),u=Oi(this.query,t)?t:null,d=!!l&&this.mutatedKeys.has(l.key),f=!!u&&(u.hasLocalMutations||this.mutatedKeys.has(u.key)&&u.hasCommittedMutations),p=!1;l&&u?l.data.isEqual(u.data)?d!==f&&(n.track({type:3,doc:u}),p=!0):this.su(l,u)||(n.track({type:2,doc:u}),p=!0,(s&&this.eu(u,s)>0||c&&this.eu(u,c)<0)&&(o=!0)):!l&&u?(n.track({type:0,doc:u}),p=!0):l&&!u&&(n.track({type:1,doc:l}),p=!0,(s||c)&&(o=!0)),p&&(u?(a=a.add(u),i=f?i.add(e):i.delete(e)):(a=a.delete(e),i=i.delete(e)))})),this.query.limit!==null)for(;a.size>this.query.limit;){let e=this.query.limitType===`F`?a.last():a.first();a=a.delete(e.key),i=i.delete(e.key),n.track({type:1,doc:e})}return{tu:a,iu:n,bs:o,mutatedKeys:i}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){let i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;let a=e.iu.ya();a.sort(((e,t)=>function(e,t){let n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return E(20277,{Vt:e})}};return n(e)-n(t)}(e.type,t.type)||this.eu(e.doc,t.doc))),this.ou(n),r??=!1;let o=t&&!r?this._u():[],s=this.Ya.size===0&&this.current&&!r?1:0,c=s!==this.Xa;return this.Xa=s,a.length!==0||c?{snapshot:new ic(this.query,e.tu,i,a,e.mutatedKeys,s===0,c,!1,!!n&&n.resumeToken.approximateByteSize()>0),au:o}:{au:o}}va(e){return this.current&&e===`Offline`?(this.current=!1,this.applyChanges({tu:this.tu,iu:new rc,mutatedKeys:this.mutatedKeys,bs:!1},!1)):{au:[]}}uu(e){return!this.Za.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach((e=>this.Za=this.Za.add(e))),e.modifiedDocuments.forEach((e=>{})),e.removedDocuments.forEach((e=>this.Za=this.Za.delete(e))),this.current=e.current)}_u(){if(!this.current)return[];let e=this.Ya;this.Ya=J(),this.tu.forEach((e=>{this.uu(e.key)&&(this.Ya=this.Ya.add(e.key))}));let t=[];return e.forEach((e=>{this.Ya.has(e)||t.push(new _c(e))})),this.Ya.forEach((n=>{e.has(n)||t.push(new gc(n))})),t}cu(e){this.Za=e.ks,this.Ya=J();let t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return ic.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Xa===0,this.hasCachedResults)}},yc=`SyncEngine`,bc=class{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}},xc=class{constructor(e){this.key=e,this.hu=!1}},Sc=class{constructor(e,t,n,r,i,a){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=a,this.Pu={},this.Tu=new Mi((e=>Ei(e)),Ti),this.Eu=new Map,this.Iu=new Set,this.Ru=new U(F.comparator),this.Au=new Map,this.Vu=new Bo,this.du={},this.mu=new Map,this.fu=Eo.ar(),this.onlineState=`Unknown`,this.gu=void 0}get isPrimaryClient(){return!0===this.gu}};async function Cc(e,t,n=!0){let r=Bc(e),i,a=r.Tu.get(t);return a?(r.sharedClientState.addLocalQueryTarget(a.targetId),i=a.view.lu()):i=await Tc(r,t,n,!0),i}async function wc(e,t){await Tc(Bc(e),t,!0,!1)}async function Tc(e,t,n,r){let i=await os(e.localStore,xi(t)),a=i.targetId,o=e.sharedClientState.addLocalQueryTarget(a,n),s;return r&&(s=await Ec(e,t,a,o===`current`,i.resumeToken)),e.isPrimaryClient&&n&&Rs(e.remoteStore,i),s}async function Ec(e,t,n,r,i){e.pu=(t,n,r)=>async function(e,t,n,r){let i=t.view.ru(n);i.bs&&(i=await cs(e.localStore,t.query,!1).then((({documents:e})=>t.view.ru(e,i))));let a=r&&r.targetChanges.get(t.targetId),o=r&&r.targetMismatches.get(t.targetId)!=null,s=t.view.applyChanges(i,e.isPrimaryClient,a,o);return Pc(e,t.targetId,s.au),s.snapshot}(e,t,n,r);let a=await cs(e.localStore,t,!0),o=new vc(t,a.ks),s=o.ru(a.documents),c=Ma.createSynthesizedTargetChangeForCurrentChange(n,r&&e.onlineState!==`Offline`,i),l=o.applyChanges(s,e.isPrimaryClient,c);Pc(e,n,l.au);let u=new bc(t,n,o);return e.Tu.set(t,u),e.Eu.has(n)?e.Eu.get(n).push(t):e.Eu.set(n,[t]),l.snapshot}async function Dc(e,t,n){let r=O(e),i=r.Tu.get(t),a=r.Eu.get(i.targetId);if(a.length>1)return r.Eu.set(i.targetId,a.filter((e=>!Ti(e,t)))),void r.Tu.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)||await ss(r.localStore,i.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(i.targetId),n&&zs(r.remoteStore,i.targetId),Mc(r,i.targetId)})).catch(zn)):(Mc(r,i.targetId),await ss(r.localStore,i.targetId,!0))}async function Oc(e,t){let n=O(e),r=n.Tu.get(t),i=n.Eu.get(r.targetId);n.isPrimaryClient&&i.length===1&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),zs(n.remoteStore,r.targetId))}async function kc(e,t){let n=O(e);try{let e=await is(n.localStore,t);t.targetChanges.forEach(((e,t)=>{let r=n.Au.get(t);r&&(D(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1,22616),e.addedDocuments.size>0?r.hu=!0:e.modifiedDocuments.size>0?D(r.hu,14607):e.removedDocuments.size>0&&(D(r.hu,42227),r.hu=!1))})),await Lc(n,e,t)}catch(e){await zn(e)}}function Ac(e,t,n){let r=O(e);if(r.isPrimaryClient&&n===0||!r.isPrimaryClient&&n===1){let e=[];r.Tu.forEach(((n,r)=>{let i=r.view.va(t);i.snapshot&&e.push(i.snapshot)})),function(e,t){let n=O(e);n.onlineState=t;let r=!1;n.queries.forEach(((e,n)=>{for(let e of n.Sa)e.va(t)&&(r=!0)})),r&&fc(n)}(r.eventManager,t),e.length&&r.Pu.H_(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function jc(e,t,n){let r=O(e);r.sharedClientState.updateQueryState(t,`rejected`,n);let i=r.Au.get(t),a=i&&i.key;if(a){let e=new U(F.comparator);e=e.insert(a,Vr.newNoDocument(a,z.min()));let n=J().add(a);await kc(r,new ja(z.min(),new Map,new U(M),e,n)),r.Ru=r.Ru.remove(a),r.Au.delete(t),Ic(r)}else await ss(r.localStore,t,!1).then((()=>Mc(r,t,n))).catch(zn)}function Mc(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(let r of e.Eu.get(t))e.Tu.delete(r),n&&e.Pu.yu(r,n);e.Eu.delete(t),e.isPrimaryClient&&e.Vu.Gr(t).forEach((t=>{e.Vu.containsKey(t)||Nc(e,t)}))}function Nc(e,t){e.Iu.delete(t.path.canonicalString());let n=e.Ru.get(t);n!==null&&(zs(e.remoteStore,n),e.Ru=e.Ru.remove(t),e.Au.delete(n),Ic(e))}function Pc(e,t,n){for(let r of n)r instanceof gc?(e.Vu.addReference(r.key,t),Fc(e,r)):r instanceof _c?(w(yc,`Document no longer in limbo: `+r.key),e.Vu.removeReference(r.key,t),e.Vu.containsKey(r.key)||Nc(e,r.key)):E(19791,{wu:r})}function Fc(e,t){let n=t.key,r=n.path.canonicalString();e.Ru.get(n)||e.Iu.has(r)||(w(yc,`New document in limbo: `+n),e.Iu.add(r),Ic(e))}function Ic(e){for(;e.Iu.size>0&&e.Ru.size<e.maxConcurrentLimboResolutions;){let t=e.Iu.values().next().value;e.Iu.delete(t);let n=new F(N.fromString(t)),r=e.fu.next();e.Au.set(r,new xc(n)),e.Ru=e.Ru.insert(n,r),Rs(e.remoteStore,new _o(xi(gi(n.path)),r,`TargetPurposeLimboResolution`,Hn.ce))}}async function Lc(e,t,n){let r=O(e),i=[],a=[],o=[];r.Tu.isEmpty()||(r.Tu.forEach(((e,s)=>{o.push(r.pu(s,t,n).then((e=>{if((e||n)&&r.isPrimaryClient){let t=e?!e.fromCache:n?.targetChanges.get(s.targetId)?.current;r.sharedClientState.updateQueryState(s.targetId,t?`current`:`not-current`)}if(e){i.push(e);let t=Yo.Is(s.targetId,e);a.push(t)}})))})),await Promise.all(o),r.Pu.H_(i),await async function(e,t){let n=O(e);try{await n.persistence.runTransaction(`notifyLocalViewChanges`,`readwrite`,(e=>B.forEach(t,(t=>B.forEach(t.Ts,(r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=>B.forEach(t.Es,(r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!Vn(e))throw e;w(Qo,`Failed to update sequence numbers: `+e)}for(let e of t){let t=e.targetId;if(!e.fromCache){let e=n.vs.get(t),r=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(r);n.vs=n.vs.insert(t,i)}}}(r.localStore,a))}async function Rc(e,t){let n=O(e);if(!n.currentUser.isEqual(t)){w(yc,`User change. New user:`,t.toKey());let e=await ns(n.localStore,t);n.currentUser=t,function(e,t){e.mu.forEach((e=>{e.forEach((e=>{e.reject(new A(k.CANCELLED,t))}))})),e.mu.clear()}(n,`'waitForPendingWrites' promise is rejected due to a user change.`),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await Lc(n,e.Ns)}}function zc(e,t){let n=O(e),r=n.Au.get(t);if(r&&r.hu)return J().add(r.key);{let e=J(),r=n.Eu.get(t);if(!r)return e;for(let t of r){let r=n.Tu.get(t);e=e.unionWith(r.view.nu)}return e}}function Bc(e){let t=O(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=kc.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=zc.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=jc.bind(null,t),t.Pu.H_=uc.bind(null,t.eventManager),t.Pu.yu=dc.bind(null,t.eventManager),t}var Vc=class{constructor(){this.kind=`memory`,this.synchronizeTabs=!1}async initialize(e){this.serializer=Ts(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){return ts(this.persistence,new Zo,e.initialUser,this.serializer)}Cu(e){return new Go(qo.Vi,this.serializer)}Du(e){return new ds}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}};Vc.provider={build:()=>new Vc};var Hc=class extends Vc{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){D(this.persistence.referenceDelegate instanceof Jo,46915);let n=this.persistence.referenceDelegate.garbageCollector;return new jo(n,e.asyncQueue,t)}Cu(e){let t=this.cacheSizeBytes===void 0?To.DEFAULT:To.withCacheSize(this.cacheSizeBytes);return new Go((e=>Jo.Vi(e,t)),this.serializer)}},Uc=class{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>Ac(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=Rc.bind(null,this.syncEngine),await Qs(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new oc}()}createDatastore(e){let t=Ts(e.databaseInfo.databaseId),n=Cs(e.databaseInfo);return Ms(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,r,i){return new Fs(e,t,n,r,i)}(this.localStore,this.datastore,e.asyncQueue,(e=>Ac(this.syncEngine,e,0)),function(){return ms.v()?new ms:new fs}())}createSyncEngine(e,t){return function(e,t,n,r,i,a,o){let s=new Sc(e,t,n,r,i,a);return o&&(s.gu=!0),s}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await async function(e){let t=O(e);w(Ps,`RemoteStore shutting down.`),t.Ia.add(5),await Ls(t),t.Aa.shutdown(),t.Va.set(`Unknown`)}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}};Uc.provider={build:()=>new Uc};var Wc=class{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):T(`Uncaught Error in snapshot listener:`,e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout((()=>{this.muted||e(t)}),0)}},Gc=`FirestoreClient`,Kc=class{constructor(e,t,n,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this._databaseInfo=r,this.user=x.UNAUTHENTICATED,this.clientId=mn.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,(async e=>{w(Gc,`Received user=`,e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=>(w(Gc,`Received new app check token=`,e),this.appCheckCredentialListener(e,this.user))))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this._databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new j;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(t){let n=tc(t,`Failed to shutdown persistence`);e.reject(n)}})),e.promise}};async function qc(e,t){e.asyncQueue.verifyOperationInProgress(),w(Gc,`Initializing OfflineComponentProvider`);let n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=>{r.isEqual(e)||(await ns(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e._offlineComponents=t}async function Jc(e,t){e.asyncQueue.verifyOperationInProgress();let n=await Yc(e);w(Gc,`Initializing OnlineComponentProvider`),await t.initialize(n,e.configuration),e.setCredentialChangeListener((e=>Zs(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=>Zs(t.remoteStore,n))),e._onlineComponents=t}async function Yc(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){w(Gc,`Using user provided OfflineComponentProvider`);try{await qc(e,e._uninitializedComponentsProvider._offline)}catch(t){let n=t;if(!function(e){return e.name===`FirebaseError`?e.code===k.FAILED_PRECONDITION||e.code===k.UNIMPLEMENTED:!(typeof DOMException<`u`&&e instanceof DOMException)||e.code===22||e.code===20||e.code===11}(n))throw n;nn(`Error using user provided cache. Falling back to memory cache: `+n),await qc(e,new Vc)}}else w(Gc,`Using default OfflineComponentProvider`),await qc(e,new Hc(void 0));return e._offlineComponents}async function Xc(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(w(Gc,`Using user provided OnlineComponentProvider`),await Jc(e,e._uninitializedComponentsProvider._online)):(w(Gc,`Using default OnlineComponentProvider`),await Jc(e,new Uc))),e._onlineComponents}async function Zc(e){let t=await Xc(e),n=t.eventManager;return n.onListen=Cc.bind(null,t.syncEngine),n.onUnlisten=Dc.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=wc.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=Oc.bind(null,t.syncEngine),n}function Qc(e,t,n={}){let r=new j;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new Wc({next:s=>{a.Nu(),t.enqueueAndForget((()=>lc(e,o)));let c=s.docs.has(n);!c&&s.fromCache?i.reject(new A(k.UNAVAILABLE,`Failed to get document because the client is offline.`)):c&&s.fromCache&&r&&r.source===`server`?i.reject(new A(k.UNAVAILABLE,`Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)`)):i.resolve(s)},error:e=>i.reject(e)}),o=new hc(gi(n.path),a,{includeMetadataChanges:!0,qa:!0});return cc(e,o)}(await Zc(e),e.asyncQueue,t,n,r))),r.promise}function $c(e,t,n={}){let r=new j;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new Wc({next:n=>{a.Nu(),t.enqueueAndForget((()=>lc(e,o))),n.fromCache&&r.source===`server`?i.reject(new A(k.UNAVAILABLE,`Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)`)):i.resolve(n)},error:e=>i.reject(e)}),o=new hc(n,a,{includeMetadataChanges:!0,qa:!0});return cc(e,o)}(await Zc(e),e.asyncQueue,t,n,r))),r.promise}function el(e){let t={};return e.timeoutSeconds!==void 0&&(t.timeoutSeconds=e.timeoutSeconds),t}var tl=`ComponentProvider`,nl=new Map;function rl(e,t,n,r,i){return new pr(e,t,n,i.host,i.ssl,i.experimentalForceLongPolling,i.experimentalAutoDetectLongPolling,el(i.experimentalLongPollingOptions),i.useFetchStreams,i.isUsingEmulator,r)}var il=`firestore.googleapis.com`,al=!0,ol=class{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new A(k.INVALID_ARGUMENT,`Can't provide ssl option if host option is not set`);this.host=il,this.ssl=al}else this.host=e.host,this.ssl=e.ssl??al;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=wo;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<Oo)throw new A(k.INVALID_ARGUMENT,`cacheSizeBytes must be at least 1048576`);this.cacheSizeBytes=e.cacheSizeBytes}wn(`experimentalForceLongPolling`,e.experimentalForceLongPolling,`experimentalAutoDetectLongPolling`,e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=el(e.experimentalLongPollingOptions??{}),function(e){if(e.timeoutSeconds!==void 0){if(isNaN(e.timeoutSeconds))throw new A(k.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new A(k.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new A(k.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&function(e,t){return e.timeoutSeconds===t.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}},sl=class{constructor(e,t,n,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=r,this.type=`firestore-lite`,this._persistenceKey=`(lite)`,this._settings=new ol({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask=`notTerminated`}get app(){if(!this._app)throw new A(k.FAILED_PRECONDITION,`Firestore was not initialized using the Firebase SDK. 'app' is not available`);return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return this._terminateTask!==`notTerminated`}_setSettings(e){if(this._settingsFrozen)throw new A(k.FAILED_PRECONDITION,`Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.`);this._settings=new ol(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=function(e){if(!e)return new sn;switch(e.type){case`firstParty`:return new un(e.sessionIndex||`0`,e.iamToken||null,e.authTokenFactory||null);case`provider`:return e.client;default:throw new A(k.INVALID_ARGUMENT,`makeAuthCredentialsProvider failed due to invalid credential type`)}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask===`notTerminated`&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask===`notTerminated`?await this._terminate():this._terminateTask=`notTerminated`}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){let t=nl.get(e);t&&(w(tl,`Removing Datastore`),nl.delete(e),t.terminate())}(this),Promise.resolve()}},cl=class e{constructor(e,t,n){this.converter=t,this._query=n,this.type=`query`,this.firestore=e}withConverter(t){return new e(this.firestore,t,this._query)}},$=class e{constructor(e,t,n){this.converter=t,this._key=n,this.type=`document`,this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new ll(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new e(this.firestore,t,this._key)}toJSON(){return{type:e._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(t,n,r){if(On(n,e._jsonSchema))return new e(t,r||null,new F(N.fromString(n.referencePath)))}};$._jsonSchemaVersion=`firestore/documentReference/1.0`,$._jsonSchema={type:L(`string`,$._jsonSchemaVersion),referencePath:L(`string`)};var ll=class e extends cl{constructor(e,t,n){super(e,t,gi(n)),this._path=n,this.type=`collection`}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new $(this.firestore,null,new F(e))}withConverter(t){return new e(this.firestore,t,this._path)}};function ul(e,t,...n){if(e=oe(e),Cn(`collection`,`path`,t),e instanceof sl){let r=N.fromString(t,...n);return Tn(r),new ll(e,null,r)}{if(!(e instanceof $||e instanceof ll))throw new A(k.INVALID_ARGUMENT,`Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore`);let r=e._path.child(N.fromString(t,...n));return Tn(r),new ll(e.firestore,null,r)}}var dl=`AsyncQueue`,fl=class{constructor(e=Promise.resolve()){this.Yu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new Es(this,`async_queue_retry`),this._c=()=>{let e=ws();e&&w(dl,`Visibility state changed to `+e.visibilityState),this.M_.w_()},this.ac=e;let t=ws();t&&typeof t.addEventListener==`function`&&t.addEventListener(`visibilitychange`,this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;let t=ws();t&&typeof t.removeEventListener==`function`&&t.removeEventListener(`visibilitychange`,this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise((()=>{}));let t=new j;return this.cc((()=>this.ec&&this.sc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.Yu.push(e),this.lc())))}async lc(){if(this.Yu.length!==0){try{await this.Yu[0](),this.Yu.shift(),this.M_.reset()}catch(e){if(!Vn(e))throw e;w(dl,`Operation failed with retryable error: `+e)}this.Yu.length>0&&this.M_.p_((()=>this.lc()))}}cc(e){let t=this.ac.then((()=>(this.rc=!0,e().catch((e=>{throw this.nc=e,this.rc=!1,T(`INTERNAL UNHANDLED ERROR: `,pl(e)),e})).then((e=>(this.rc=!1,e))))));return this.ac=t,t}enqueueAfterDelay(e,t,n){this.uc(),this.oc.indexOf(e)>-1&&(t=0);let r=ec.createAndSchedule(this,e,t,n,(e=>this.hc(e)));return this.tc.push(r),r}uc(){this.nc&&E(47125,{Pc:pl(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do e=this.ac,await e;while(e!==this.ac)}Ec(e){for(let t of this.tc)if(t.timerId===e)return!0;return!1}Ic(e){return this.Tc().then((()=>{this.tc.sort(((e,t)=>e.targetTimeMs-t.targetTimeMs));for(let t of this.tc)if(t.skipDelay(),e!==`all`&&t.timerId===e)break;return this.Tc()}))}Rc(e){this.oc.push(e)}hc(e){let t=this.tc.indexOf(e);this.tc.splice(t,1)}};function pl(e){let t=e.message||``;return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+`
16
- `+e.stack),t}var ml=class extends sl{constructor(e,t,n,r){super(e,t,n,r),this.type=`firestore`,this._queue=new fl,this._persistenceKey=r?.name||`[DEFAULT]`}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new fl(e),this._firestoreClient=void 0,await e}}};function hl(e){if(e._terminated)throw new A(k.FAILED_PRECONDITION,`The client has already been terminated.`);return e._firestoreClient||gl(e),e._firestoreClient}function gl(e){let t=e._freezeSettings(),n=rl(e._databaseId,e._app?.options.appId||``,e._persistenceKey,e._app?.options.apiKey,t);e._componentsProvider||t.localCache?._offlineComponentProvider&&t.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:t.localCache._offlineComponentProvider,_online:t.localCache._onlineComponentProvider}),e._firestoreClient=new Kc(e._authCredentials,e._appCheckCredentials,e._queue,n,e._componentsProvider&&function(e){let t=e?._online.build();return{_offline:e?._offline.build(t),_online:t}}(e._componentsProvider))}var _l=class e{constructor(e){this._byteString=e}static fromBase64String(t){try{return new e(G.fromBase64String(t))}catch(e){throw new A(k.INVALID_ARGUMENT,`Failed to construct data from Base64 string: `+e)}}static fromUint8Array(t){return new e(G.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return`Bytes(base64: `+this.toBase64()+`)`}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:e._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(t){if(On(t,e._jsonSchema))return e.fromBase64String(t.bytes)}};_l._jsonSchemaVersion=`firestore/bytes/1.0`,_l._jsonSchema={type:L(`string`,_l._jsonSchemaVersion),bytes:L(`string`)};var vl=class{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new A(k.INVALID_ARGUMENT,`Invalid field name at argument $(i + 1). Field names must not be empty.`);this._internalPath=new P(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}};function yl(){return new vl(bn)}var bl=class{constructor(e){this._methodName=e}},xl=class e{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new A(k.INVALID_ARGUMENT,`Latitude must be a number between -90 and 90, but was: `+e);if(!isFinite(t)||t<-180||t>180)throw new A(k.INVALID_ARGUMENT,`Longitude must be a number between -180 and 180, but was: `+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return M(this._lat,e._lat)||M(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:e._jsonSchemaVersion}}static fromJSON(t){if(On(t,e._jsonSchema))return new e(t.latitude,t.longitude)}};xl._jsonSchemaVersion=`firestore/geoPoint/1.0`,xl._jsonSchema={type:L(`string`,xl._jsonSchemaVersion),latitude:L(`number`),longitude:L(`number`)};var Sl=class e{constructor(e){this._values=(e||[]).map((e=>e))}toArray(){return this._values.map((e=>e))}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(this._values,e._values)}toJSON(){return{type:e._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(t){if(On(t,e._jsonSchema)){if(Array.isArray(t.vectorValues)&&t.vectorValues.every((e=>typeof e==`number`)))return new e(t.vectorValues);throw new A(k.INVALID_ARGUMENT,`Expected 'vectorValues' field to be a number array`)}}};Sl._jsonSchemaVersion=`firestore/vectorValue/1.0`,Sl._jsonSchema={type:L(`string`,Sl._jsonSchemaVersion),vectorValues:L(`object`)};var Cl=/^__.*__$/;function wl(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw E(40011,{dataSource:e})}}var Tl=class e{constructor(e,t,n,r,i,a){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,i===void 0&&this.Ac(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}i(t){return new e({...this.settings,...t},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}dc(e){let t=this.path?.child(e),n=this.i({path:t,arrayElement:!1});return n.mc(e),n}fc(e){let t=this.path?.child(e),n=this.i({path:t,arrayElement:!1});return n.Ac(),n}gc(e){return this.i({path:void 0,arrayElement:!0})}yc(e){return Ll(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find((t=>e.isPrefixOf(t)))!==void 0||this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))!==void 0}Ac(){if(this.path)for(let e=0;e<this.path.length;e++)this.mc(this.path.get(e))}mc(e){if(e.length===0)throw this.yc(`Document fields must not be empty`);if(wl(this.dataSource)&&Cl.test(e))throw this.yc(`Document fields cannot begin and end with "__"`)}},El=class{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Ts(e)}I(e,t,n,r=!1){return new Tl({dataSource:e,methodName:t,targetDoc:n,path:P.emptyPath(),arrayElement:!1,hasConverter:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function Dl(e){let t=e._freezeSettings(),n=Ts(e._databaseId);return new El(e._databaseId,!!t.ignoreUndefinedProperties,n)}var Ol=class e extends bl{_toFieldTransform(e){return new aa(e.path,new Zi)}isEqual(t){return t instanceof e}};function kl(e,t,n,r=!1){return Al(n,e.I(r?4:3,t))}function Al(e,t){if(Ml(e=oe(e)))return Nl(`Unsupported field value:`,t,e),jl(e,t);if(e instanceof bl)return function(e,t){if(!wl(t.dataSource))throw t.yc(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.yc(`${e._methodName}() is not currently supported inside arrays`);let n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(e===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.arrayElement&&t.dataSource!==4)throw t.yc(`Nested arrays are not supported`);return function(e,t){let n=[],r=0;for(let i of e){let e=Al(i,t.gc(r));e??={nullValue:`NULL_VALUE`},n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if((e=oe(e))===null)return{nullValue:`NULL_VALUE`};if(typeof e==`number`)return Ki(t.serializer,e);if(typeof e==`boolean`)return{booleanValue:e};if(typeof e==`string`)return{stringValue:e};if(e instanceof Date){let n=R.fromDate(e);return{timestampValue:Ga(t.serializer,n)}}if(e instanceof R){let n=new R(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:Ga(t.serializer,n)}}if(e instanceof xl)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof _l)return{bytesValue:Ka(t.serializer,e._byteString)};if(e instanceof $){let n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.yc(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Ja(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof Sl)return function(e,t){let n=e instanceof Sl?e.toArray():e;return{mapValue:{fields:{[_r]:{stringValue:br},[xr]:{arrayValue:{values:n.map((e=>{if(typeof e!=`number`)throw t.yc(`VectorValues must only contain numeric values.`);return Wi(t.serializer,e)}))}}}}}}(e,t);if(go(e))return e._toProto(t.serializer);throw t.yc(`Unsupported field value: ${Dn(e)}`)}(e,t)}function jl(e,t){let n={};return Zn(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):H(e,((e,r)=>{let i=Al(r,t.dc(e));i!=null&&(n[e]=i)})),{mapValue:{fields:n}}}function Ml(e){return!(typeof e!=`object`||!e||e instanceof Array||e instanceof Date||e instanceof R||e instanceof xl||e instanceof _l||e instanceof $||e instanceof bl||e instanceof Sl||go(e))}function Nl(e,t,n){if(!Ml(n)||!En(n)){let r=Dn(n);throw r===`an object`?t.yc(e+` a custom object`):t.yc(e+` `+r)}}function Pl(e,t,n){if((t=oe(t))instanceof vl)return t._internalPath;if(typeof t==`string`)return Il(e,t);throw Ll(`Field path arguments must be of type string or `,e,!1,void 0,n)}var Fl=RegExp(`[~\\*/\\[\\]]`);function Il(e,t,n){if(t.search(Fl)>=0)throw Ll(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new vl(...t.split(`.`))._internalPath}catch{throw Ll(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function Ll(e,t,n,r,i){let a=r&&!r.isEmpty(),o=i!==void 0,s=`Function ${t}() called with invalid data`;n&&(s+=" (via `toFirestore()`)"),s+=`. `;let c=``;return(a||o)&&(c+=` (found`,a&&(c+=` in field ${r}`),o&&(c+=` in document ${i}`),c+=`)`),new A(k.INVALID_ARGUMENT,s+e+c)}var Rl=class{convertValue(e,t=`none`){switch(Sr(e)){case 0:return null;case 1:return e.booleanValue;case 2:return K(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(ar(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw E(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t=`none`){let n={};return H(e,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertVectorValue(e){let t=e.fields?.[xr].arrayValue?.values?.map((e=>K(e.doubleValue)));return new Sl(t)}convertGeoPoint(e){return new xl(K(e.latitude),K(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=>this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case`previous`:let n=dr(e);return n==null?null:this.convertValue(n,t);case`estimate`:return this.convertTimestamp(fr(e));default:return null}}convertTimestamp(e){let t=ir(e);return new R(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=N.fromString(e);D(ho(n),9688,{name:e});let r=new hr(n.get(1),n.get(3)),i=new F(n.popFirst(5));return r.isEqual(t)||T(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}},zl=class extends Rl{constructor(e){super(),this.firestore=e}convertBytes(e){return new _l(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new $(this.firestore,null,t)}};function Bl(){return new Ol(`serverTimestamp`)}var Vl=`@firebase/firestore`,Hl=`4.14.0`,Ul=class{constructor(e,t,n,r,i){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new $(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new Wl(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){let t=this._document.data.field(Pl(`DocumentSnapshot.get`,e));if(t!==null)return this._userDataWriter.convertValue(t)}}},Wl=class extends Ul{data(){return super.data()}};function Gl(e){if(e.limitType===`L`&&e.explicitOrderBy.length===0)throw new A(k.UNIMPLEMENTED,`limitToLast() queries require specifying at least one orderBy() clause`)}var Kl=class{},ql=class extends Kl{};function Jl(e,t,...n){let r=[];t instanceof Kl&&r.push(t),r=r.concat(n),function(e){let t=e.filter((e=>e instanceof Zl)).length,n=e.filter((e=>e instanceof Yl)).length;if(t>1||t>0&&n>0)throw new A(k.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(let t of r)e=t._apply(e);return e}var Yl=class e extends ql{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type=`where`}static _create(t,n,r){return new e(t,n,r)}_apply(e){let t=this._parse(e);return eu(e._query,t),new cl(e.firestore,e.converter,Ci(e._query,t))}_parse(e){let t=Dl(e.firestore);return function(e,t,n,r,i,a,o){let s;if(i.isKeyField()){if(a===`array-contains`||a===`array-contains-any`)throw new A(k.INVALID_ARGUMENT,`Invalid Query. You can't perform '${a}' queries on documentId().`);if(a===`in`||a===`not-in`){$l(o,a);let t=[];for(let n of o)t.push(Ql(r,e,n));s={arrayValue:{values:t}}}else s=Ql(r,e,o)}else a!==`in`&&a!==`not-in`&&a!==`array-contains-any`||$l(o,a),s=kl(n,t,o,a===`in`||a===`not-in`);return q.create(i,a,s)}(e._query,`where`,t,e.firestore._databaseId,this._field,this._op,this._value)}};function Xl(e,t,n){let r=t,i=Pl(`where`,e);return Yl._create(i,r,n)}var Zl=class e extends Kl{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(t,n){return new e(t,n)}_parse(e){let t=this._queryConstraints.map((t=>t._parse(e))).filter((e=>e.getFilters().length>0));return t.length===1?t[0]:Jr.create(t,this._getOperator())}_apply(e){let t=this._parse(e);return t.getFilters().length===0?e:(function(e,t){let n=e,r=t.getFlattenedFilters();for(let e of r)eu(n,e),n=Ci(n,e)}(e._query,t),new cl(e.firestore,e.converter,Ci(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type===`and`?`and`:`or`}};function Ql(e,t,n){if(typeof(n=oe(n))==`string`){if(n===``)throw new A(k.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.`);if(!yi(t)&&n.indexOf(`/`)!==-1)throw new A(k.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);let r=t.path.child(N.fromString(n));if(!F.isDocumentKey(r))throw new A(k.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return jr(e,new F(r))}if(n instanceof $)return jr(e,n._key);throw new A(k.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Dn(n)}.`)}function $l(e,t){if(!Array.isArray(e)||e.length===0)throw new A(k.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function eu(e,t){let n=function(e,t){for(let n of e)for(let e of n.getFlattenedFilters())if(t.indexOf(e.op)>=0)return e.op;return null}(e.filters,function(e){switch(e){case`!=`:return[`!=`,`not-in`];case`array-contains-any`:case`in`:return[`not-in`];case`not-in`:return[`array-contains-any`,`in`,`not-in`,`!=`];default:return[]}}(t.op));if(n!==null)throw n===t.op?new A(k.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new A(k.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}var tu=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},nu=class e extends Ul{constructor(e,t,n,r,i,a){super(e,t,n,r,a),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new ru(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){let n=this._document.data.field(Pl(`DocumentSnapshot.get`,e));if(n!==null)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new A(k.FAILED_PRECONDITION,`DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().`);let t=this._document,n={};return n.type=e._jsonSchemaVersion,n.bundle=``,n.bundleSource=`DocumentSnapshot`,n.bundleName=this._key.toString(),!t||!t.isValidDocument()||!t.isFoundDocument()?n:(this._userDataWriter.convertObjectMap(t.data.value.mapValue.fields,`previous`),n.bundle=(this._firestore,this.ref.path,`NOT SUPPORTED`),n)}};nu._jsonSchemaVersion=`firestore/documentSnapshot/1.0`,nu._jsonSchema={type:L(`string`,nu._jsonSchemaVersion),bundleSource:L(`string`,`DocumentSnapshot`),bundleName:L(`string`),bundle:L(`string`)};var ru=class extends nu{data(e={}){return super.data(e)}},iu=class e{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new tu(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){let e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach((n=>{e.call(t,new ru(this._firestore,this._userDataWriter,n.key,n,new tu(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new A(k.INVALID_ARGUMENT,`To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().`);return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map((n=>{let r=new ru(e._firestore,e._userDataWriter,n.doc.key,n.doc,new tu(e._snapshot.mutatedKeys.has(n.doc.key),e._snapshot.fromCache),e.query.converter);return n.doc,{type:`added`,doc:r,oldIndex:-1,newIndex:t++}}))}{let n=e._snapshot.oldDocs;return e._snapshot.docChanges.filter((e=>t||e.type!==3)).map((t=>{let r=new ru(e._firestore,e._userDataWriter,t.doc.key,t.doc,new tu(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),i=-1,a=-1;return t.type!==0&&(i=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),t.type!==1&&(n=n.add(t.doc),a=n.indexOf(t.doc.key)),{type:au(t.type),doc:r,oldIndex:i,newIndex:a}}))}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new A(k.FAILED_PRECONDITION,`QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().`);let t={};t.type=e._jsonSchemaVersion,t.bundleSource=`QuerySnapshot`,t.bundleName=mn.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;let n=[],r=[],i=[];return this.docs.forEach((e=>{e._document!==null&&(n.push(e._document),r.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,`previous`)),i.push(e.ref.path))})),t.bundle=(this._firestore,this.query._query,t.bundleName,`NOT SUPPORTED`),t}};function au(e){switch(e){case 0:return`added`;case 2:case 3:return`modified`;case 1:return`removed`;default:return E(61501,{type:e})}}iu._jsonSchemaVersion=`firestore/querySnapshot/1.0`,iu._jsonSchema={type:L(`string`,iu._jsonSchemaVersion),bundleSource:L(`string`,`QuerySnapshot`),bundleName:L(`string`),bundle:L(`string`)};function ou(e){e=I(e,$);let t=I(e.firestore,ml);return Qc(hl(t),e._key).then((n=>cu(t,e,n)))}function su(e){e=I(e,cl);let t=I(e.firestore,ml),n=hl(t),r=new zl(t);return Gl(e._query),$c(n,e._query).then((n=>new iu(t,r,e,n)))}function cu(e,t,n){let r=n.docs.get(t._key);return new nu(e,new zl(e),t._key,r,new tu(n.hasPendingWrites,n.fromCache),t.converter)}(function(e,t=!0){en(xt),vt(new ce(`firestore`,((e,{instanceIdentifier:n,options:r})=>{let i=e.getProvider(`app`).getImmediate(),a=new ml(new cn(e.getProvider(`auth-internal`)),new fn(i,e.getProvider(`app-check-internal`)),gr(i,n),i);return r={useFetchStreams:t,...r},a._setSettings(r),a}),`PUBLIC`).setMultipleInstances(!0)),St(Vl,Hl,e),St(Vl,Hl,`esm2020`)})();function lu(e){return{...e.data(),id:e.id}}async function uu(e,t,n,r,i){let a=i.map(e=>r.get(e?.path??``)).filter(Boolean),o=new Set(a.map(e=>e.id)),s=i.filter(e=>e&&!o.has(e.path));for(let i=0;i<s.length;i+=30){let a=s.slice(i,i+30);(await su(Jl(ul(e,t),Xl(yl(),`in`,a)))).forEach(e=>{let t=n(e);r.set(t.id,t)})}}async function du(e,t,n){let r=n.map(e=>t.get(e?.path??``)).filter(Boolean),i=new Set(r.map(e=>e.id)),a=n.filter(e=>e&&!i.has(e.path));for(let n of a){if(!n)continue;let r=await ou(n).then(e);t.set(r.id,r)}}Array.prototype.mapNotNull=function(e){return this.flatMap((t,n)=>{let r=e(t,n);return r==null?[]:[r]})};var fu={updateAt:Bl(),delete:!0},pu={updateAt:Bl(),delete:!1};exports.deleteItem=fu,exports.fetchItems=uu,exports.fetchItemsByOne=du,exports.snapshotToData=lu,exports.undeleteItem=pu;
16
+ `+e.stack),t}var ml=class extends sl{constructor(e,t,n,r){super(e,t,n,r),this.type=`firestore`,this._queue=new fl,this._persistenceKey=r?.name||`[DEFAULT]`}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new fl(e),this._firestoreClient=void 0,await e}}};function hl(e){if(e._terminated)throw new A(k.FAILED_PRECONDITION,`The client has already been terminated.`);return e._firestoreClient||gl(e),e._firestoreClient}function gl(e){let t=e._freezeSettings(),n=rl(e._databaseId,e._app?.options.appId||``,e._persistenceKey,e._app?.options.apiKey,t);e._componentsProvider||t.localCache?._offlineComponentProvider&&t.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:t.localCache._offlineComponentProvider,_online:t.localCache._onlineComponentProvider}),e._firestoreClient=new Kc(e._authCredentials,e._appCheckCredentials,e._queue,n,e._componentsProvider&&function(e){let t=e?._online.build();return{_offline:e?._offline.build(t),_online:t}}(e._componentsProvider))}var _l=class e{constructor(e){this._byteString=e}static fromBase64String(t){try{return new e(G.fromBase64String(t))}catch(e){throw new A(k.INVALID_ARGUMENT,`Failed to construct data from Base64 string: `+e)}}static fromUint8Array(t){return new e(G.fromUint8Array(t))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return`Bytes(base64: `+this.toBase64()+`)`}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:e._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(t){if(On(t,e._jsonSchema))return e.fromBase64String(t.bytes)}};_l._jsonSchemaVersion=`firestore/bytes/1.0`,_l._jsonSchema={type:L(`string`,_l._jsonSchemaVersion),bytes:L(`string`)};var vl=class{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new A(k.INVALID_ARGUMENT,`Invalid field name at argument $(i + 1). Field names must not be empty.`);this._internalPath=new P(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}};function yl(){return new vl(bn)}var bl=class{constructor(e){this._methodName=e}},xl=class e{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new A(k.INVALID_ARGUMENT,`Latitude must be a number between -90 and 90, but was: `+e);if(!isFinite(t)||t<-180||t>180)throw new A(k.INVALID_ARGUMENT,`Longitude must be a number between -180 and 180, but was: `+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return M(this._lat,e._lat)||M(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:e._jsonSchemaVersion}}static fromJSON(t){if(On(t,e._jsonSchema))return new e(t.latitude,t.longitude)}};xl._jsonSchemaVersion=`firestore/geoPoint/1.0`,xl._jsonSchema={type:L(`string`,xl._jsonSchemaVersion),latitude:L(`number`),longitude:L(`number`)};var Sl=class e{constructor(e){this._values=(e||[]).map((e=>e))}toArray(){return this._values.map((e=>e))}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(this._values,e._values)}toJSON(){return{type:e._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(t){if(On(t,e._jsonSchema)){if(Array.isArray(t.vectorValues)&&t.vectorValues.every((e=>typeof e==`number`)))return new e(t.vectorValues);throw new A(k.INVALID_ARGUMENT,`Expected 'vectorValues' field to be a number array`)}}};Sl._jsonSchemaVersion=`firestore/vectorValue/1.0`,Sl._jsonSchema={type:L(`string`,Sl._jsonSchemaVersion),vectorValues:L(`object`)};var Cl=/^__.*__$/;function wl(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw E(40011,{dataSource:e})}}var Tl=class e{constructor(e,t,n,r,i,a){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,i===void 0&&this.Ac(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get dataSource(){return this.settings.dataSource}i(t){return new e({...this.settings,...t},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}dc(e){let t=this.path?.child(e),n=this.i({path:t,arrayElement:!1});return n.mc(e),n}fc(e){let t=this.path?.child(e),n=this.i({path:t,arrayElement:!1});return n.Ac(),n}gc(e){return this.i({path:void 0,arrayElement:!0})}yc(e){return Ll(e,this.settings.methodName,this.settings.hasConverter||!1,this.path,this.settings.targetDoc)}contains(e){return this.fieldMask.find((t=>e.isPrefixOf(t)))!==void 0||this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))!==void 0}Ac(){if(this.path)for(let e=0;e<this.path.length;e++)this.mc(this.path.get(e))}mc(e){if(e.length===0)throw this.yc(`Document fields must not be empty`);if(wl(this.dataSource)&&Cl.test(e))throw this.yc(`Document fields cannot begin and end with "__"`)}},El=class{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Ts(e)}I(e,t,n,r=!1){return new Tl({dataSource:e,methodName:t,targetDoc:n,path:P.emptyPath(),arrayElement:!1,hasConverter:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function Dl(e){let t=e._freezeSettings(),n=Ts(e._databaseId);return new El(e._databaseId,!!t.ignoreUndefinedProperties,n)}var Ol=class e extends bl{_toFieldTransform(e){return new aa(e.path,new Zi)}isEqual(t){return t instanceof e}};function kl(e,t,n,r=!1){return Al(n,e.I(r?4:3,t))}function Al(e,t){if(Ml(e=oe(e)))return Nl(`Unsupported field value:`,t,e),jl(e,t);if(e instanceof bl)return function(e,t){if(!wl(t.dataSource))throw t.yc(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.yc(`${e._methodName}() is not currently supported inside arrays`);let n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(e===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.arrayElement&&t.dataSource!==4)throw t.yc(`Nested arrays are not supported`);return function(e,t){let n=[],r=0;for(let i of e){let e=Al(i,t.gc(r));e??={nullValue:`NULL_VALUE`},n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if((e=oe(e))===null)return{nullValue:`NULL_VALUE`};if(typeof e==`number`)return Ki(t.serializer,e);if(typeof e==`boolean`)return{booleanValue:e};if(typeof e==`string`)return{stringValue:e};if(e instanceof Date){let n=R.fromDate(e);return{timestampValue:Ga(t.serializer,n)}}if(e instanceof R){let n=new R(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:Ga(t.serializer,n)}}if(e instanceof xl)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof _l)return{bytesValue:Ka(t.serializer,e._byteString)};if(e instanceof $){let n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.yc(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Ja(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof Sl)return function(e,t){let n=e instanceof Sl?e.toArray():e;return{mapValue:{fields:{[_r]:{stringValue:br},[xr]:{arrayValue:{values:n.map((e=>{if(typeof e!=`number`)throw t.yc(`VectorValues must only contain numeric values.`);return Wi(t.serializer,e)}))}}}}}}(e,t);if(go(e))return e._toProto(t.serializer);throw t.yc(`Unsupported field value: ${Dn(e)}`)}(e,t)}function jl(e,t){let n={};return Zn(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):H(e,((e,r)=>{let i=Al(r,t.dc(e));i!=null&&(n[e]=i)})),{mapValue:{fields:n}}}function Ml(e){return!(typeof e!=`object`||!e||e instanceof Array||e instanceof Date||e instanceof R||e instanceof xl||e instanceof _l||e instanceof $||e instanceof bl||e instanceof Sl||go(e))}function Nl(e,t,n){if(!Ml(n)||!En(n)){let r=Dn(n);throw r===`an object`?t.yc(e+` a custom object`):t.yc(e+` `+r)}}function Pl(e,t,n){if((t=oe(t))instanceof vl)return t._internalPath;if(typeof t==`string`)return Il(e,t);throw Ll(`Field path arguments must be of type string or `,e,!1,void 0,n)}var Fl=RegExp(`[~\\*/\\[\\]]`);function Il(e,t,n){if(t.search(Fl)>=0)throw Ll(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new vl(...t.split(`.`))._internalPath}catch{throw Ll(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function Ll(e,t,n,r,i){let a=r&&!r.isEmpty(),o=i!==void 0,s=`Function ${t}() called with invalid data`;n&&(s+=" (via `toFirestore()`)"),s+=`. `;let c=``;return(a||o)&&(c+=` (found`,a&&(c+=` in field ${r}`),o&&(c+=` in document ${i}`),c+=`)`),new A(k.INVALID_ARGUMENT,s+e+c)}var Rl=class{convertValue(e,t=`none`){switch(Sr(e)){case 0:return null;case 1:return e.booleanValue;case 2:return K(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(ar(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw E(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t=`none`){let n={};return H(e,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertVectorValue(e){let t=e.fields?.[xr].arrayValue?.values?.map((e=>K(e.doubleValue)));return new Sl(t)}convertGeoPoint(e){return new xl(K(e.latitude),K(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=>this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case`previous`:let n=dr(e);return n==null?null:this.convertValue(n,t);case`estimate`:return this.convertTimestamp(fr(e));default:return null}}convertTimestamp(e){let t=ir(e);return new R(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=N.fromString(e);D(ho(n),9688,{name:e});let r=new hr(n.get(1),n.get(3)),i=new F(n.popFirst(5));return r.isEqual(t)||T(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}},zl=class extends Rl{constructor(e){super(),this.firestore=e}convertBytes(e){return new _l(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new $(this.firestore,null,t)}};function Bl(){return new Ol(`serverTimestamp`)}var Vl=`@firebase/firestore`,Hl=`4.14.0`,Ul=class{constructor(e,t,n,r,i){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new $(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new Wl(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}_fieldsProto(){return this._document?.data.clone().value.mapValue.fields??void 0}get(e){if(this._document){let t=this._document.data.field(Pl(`DocumentSnapshot.get`,e));if(t!==null)return this._userDataWriter.convertValue(t)}}},Wl=class extends Ul{data(){return super.data()}};function Gl(e){if(e.limitType===`L`&&e.explicitOrderBy.length===0)throw new A(k.UNIMPLEMENTED,`limitToLast() queries require specifying at least one orderBy() clause`)}var Kl=class{},ql=class extends Kl{};function Jl(e,t,...n){let r=[];t instanceof Kl&&r.push(t),r=r.concat(n),function(e){let t=e.filter((e=>e instanceof Zl)).length,n=e.filter((e=>e instanceof Yl)).length;if(t>1||t>0&&n>0)throw new A(k.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(r);for(let t of r)e=t._apply(e);return e}var Yl=class e extends ql{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type=`where`}static _create(t,n,r){return new e(t,n,r)}_apply(e){let t=this._parse(e);return eu(e._query,t),new cl(e.firestore,e.converter,Ci(e._query,t))}_parse(e){let t=Dl(e.firestore);return function(e,t,n,r,i,a,o){let s;if(i.isKeyField()){if(a===`array-contains`||a===`array-contains-any`)throw new A(k.INVALID_ARGUMENT,`Invalid Query. You can't perform '${a}' queries on documentId().`);if(a===`in`||a===`not-in`){$l(o,a);let t=[];for(let n of o)t.push(Ql(r,e,n));s={arrayValue:{values:t}}}else s=Ql(r,e,o)}else a!==`in`&&a!==`not-in`&&a!==`array-contains-any`||$l(o,a),s=kl(n,t,o,a===`in`||a===`not-in`);return q.create(i,a,s)}(e._query,`where`,t,e.firestore._databaseId,this._field,this._op,this._value)}};function Xl(e,t,n){let r=t,i=Pl(`where`,e);return Yl._create(i,r,n)}var Zl=class e extends Kl{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(t,n){return new e(t,n)}_parse(e){let t=this._queryConstraints.map((t=>t._parse(e))).filter((e=>e.getFilters().length>0));return t.length===1?t[0]:Jr.create(t,this._getOperator())}_apply(e){let t=this._parse(e);return t.getFilters().length===0?e:(function(e,t){let n=e,r=t.getFlattenedFilters();for(let e of r)eu(n,e),n=Ci(n,e)}(e._query,t),new cl(e.firestore,e.converter,Ci(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type===`and`?`and`:`or`}};function Ql(e,t,n){if(typeof(n=oe(n))==`string`){if(n===``)throw new A(k.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.`);if(!yi(t)&&n.indexOf(`/`)!==-1)throw new A(k.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);let r=t.path.child(N.fromString(n));if(!F.isDocumentKey(r))throw new A(k.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return jr(e,new F(r))}if(n instanceof $)return jr(e,n._key);throw new A(k.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Dn(n)}.`)}function $l(e,t){if(!Array.isArray(e)||e.length===0)throw new A(k.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function eu(e,t){let n=function(e,t){for(let n of e)for(let e of n.getFlattenedFilters())if(t.indexOf(e.op)>=0)return e.op;return null}(e.filters,function(e){switch(e){case`!=`:return[`!=`,`not-in`];case`array-contains-any`:case`in`:return[`not-in`];case`not-in`:return[`array-contains-any`,`in`,`not-in`,`!=`];default:return[]}}(t.op));if(n!==null)throw n===t.op?new A(k.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new A(k.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}var tu=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},nu=class e extends Ul{constructor(e,t,n,r,i,a){super(e,t,n,r,a),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new ru(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){let n=this._document.data.field(Pl(`DocumentSnapshot.get`,e));if(n!==null)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new A(k.FAILED_PRECONDITION,`DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().`);let t=this._document,n={};return n.type=e._jsonSchemaVersion,n.bundle=``,n.bundleSource=`DocumentSnapshot`,n.bundleName=this._key.toString(),!t||!t.isValidDocument()||!t.isFoundDocument()?n:(this._userDataWriter.convertObjectMap(t.data.value.mapValue.fields,`previous`),n.bundle=(this._firestore,this.ref.path,`NOT SUPPORTED`),n)}};nu._jsonSchemaVersion=`firestore/documentSnapshot/1.0`,nu._jsonSchema={type:L(`string`,nu._jsonSchemaVersion),bundleSource:L(`string`,`DocumentSnapshot`),bundleName:L(`string`),bundle:L(`string`)};var ru=class extends nu{data(e={}){return super.data(e)}},iu=class e{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new tu(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){let e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach((n=>{e.call(t,new ru(this._firestore,this._userDataWriter,n.key,n,new tu(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new A(k.INVALID_ARGUMENT,`To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().`);return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map((n=>{let r=new ru(e._firestore,e._userDataWriter,n.doc.key,n.doc,new tu(e._snapshot.mutatedKeys.has(n.doc.key),e._snapshot.fromCache),e.query.converter);return n.doc,{type:`added`,doc:r,oldIndex:-1,newIndex:t++}}))}{let n=e._snapshot.oldDocs;return e._snapshot.docChanges.filter((e=>t||e.type!==3)).map((t=>{let r=new ru(e._firestore,e._userDataWriter,t.doc.key,t.doc,new tu(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),i=-1,a=-1;return t.type!==0&&(i=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),t.type!==1&&(n=n.add(t.doc),a=n.indexOf(t.doc.key)),{type:au(t.type),doc:r,oldIndex:i,newIndex:a}}))}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new A(k.FAILED_PRECONDITION,`QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().`);let t={};t.type=e._jsonSchemaVersion,t.bundleSource=`QuerySnapshot`,t.bundleName=mn.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;let n=[],r=[],i=[];return this.docs.forEach((e=>{e._document!==null&&(n.push(e._document),r.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,`previous`)),i.push(e.ref.path))})),t.bundle=(this._firestore,this.query._query,t.bundleName,`NOT SUPPORTED`),t}};function au(e){switch(e){case 0:return`added`;case 2:case 3:return`modified`;case 1:return`removed`;default:return E(61501,{type:e})}}iu._jsonSchemaVersion=`firestore/querySnapshot/1.0`,iu._jsonSchema={type:L(`string`,iu._jsonSchemaVersion),bundleSource:L(`string`,`QuerySnapshot`),bundleName:L(`string`),bundle:L(`string`)};function ou(e){e=I(e,$);let t=I(e.firestore,ml);return Qc(hl(t),e._key).then((n=>cu(t,e,n)))}function su(e){e=I(e,cl);let t=I(e.firestore,ml),n=hl(t),r=new zl(t);return Gl(e._query),$c(n,e._query).then((n=>new iu(t,r,e,n)))}function cu(e,t,n){let r=n.docs.get(t._key);return new nu(e,new zl(e),t._key,r,new tu(n.hasPendingWrites,n.fromCache),t.converter)}(function(e,t=!0){en(xt),vt(new ce(`firestore`,((e,{instanceIdentifier:n,options:r})=>{let i=e.getProvider(`app`).getImmediate(),a=new ml(new cn(e.getProvider(`auth-internal`)),new fn(i,e.getProvider(`app-check-internal`)),gr(i,n),i);return r={useFetchStreams:t,...r},a._setSettings(r),a}),`PUBLIC`).setMultipleInstances(!0)),St(Vl,Hl,e),St(Vl,Hl,`esm2020`)})();function lu(e){return{...e.data(),id:e.id}}async function uu(e,t,n,r,i){let a=i.filter(e=>!!(e&&!r.has(e.path)));for(let i=0;i<a.length;i+=30){let o=a.slice(i,i+30);console.log(e),console.log(t),(await su(Jl(ul(e,t),Xl(yl(),`in`,o.map(e=>e.id))))).forEach(e=>{let t=n(e);r.set(e.ref.path,t)})}}async function du(e,t,n){let r=n.filter(e=>!!(e&&!t.has(e.path)));await Promise.all(r.map(async n=>{let r=e(await ou(n));t.set(n.path,r)}))}Array.prototype.mapNotNull=function(e){return this.flatMap((t,n)=>{let r=e(t,n);return r==null?[]:[r]})};var fu={updateAt:Bl(),delete:!0},pu={updateAt:Bl(),delete:!1};exports.deleteItem=fu,exports.fetchItems=uu,exports.fetchItemsByOne=du,exports.snapshotToData=lu,exports.undeleteItem=pu;
@@ -8670,22 +8670,21 @@ function lu(e) {
8670
8670
  };
8671
8671
  }
8672
8672
  async function uu(e, t, n, r, i) {
8673
- let a = i.map((e) => r.get(e?.path ?? "")).filter(Boolean), o = new Set(a.map((e) => e.id)), s = i.filter((e) => e && !o.has(e.path));
8674
- for (let i = 0; i < s.length; i += 30) {
8675
- let a = s.slice(i, i + 30);
8676
- (await su(Jl(ul(e, t), Xl(yl(), "in", a)))).forEach((e) => {
8673
+ let a = i.filter((e) => !!(e && !r.has(e.path)));
8674
+ for (let i = 0; i < a.length; i += 30) {
8675
+ let o = a.slice(i, i + 30);
8676
+ console.log(e), console.log(t), (await su(Jl(ul(e, t), Xl(yl(), "in", o.map((e) => e.id))))).forEach((e) => {
8677
8677
  let t = n(e);
8678
- r.set(t.id, t);
8678
+ r.set(e.ref.path, t);
8679
8679
  });
8680
8680
  }
8681
8681
  }
8682
8682
  async function du(e, t, n) {
8683
- let r = n.map((e) => t.get(e?.path ?? "")).filter(Boolean), i = new Set(r.map((e) => e.id)), a = n.filter((e) => e && !i.has(e.path));
8684
- for (let n of a) {
8685
- if (!n) continue;
8686
- let r = await ou(n).then(e);
8687
- t.set(r.id, r);
8688
- }
8683
+ let r = n.filter((e) => !!(e && !t.has(e.path)));
8684
+ await Promise.all(r.map(async (n) => {
8685
+ let r = e(await ou(n));
8686
+ t.set(n.path, r);
8687
+ }));
8689
8688
  }
8690
8689
  //#endregion
8691
8690
  //#region src/utils/array.ts
@@ -1 +1 @@
1
- {"version":3,"file":"firestore.d.ts","sourceRoot":"","sources":["../../src/utils/firestore.ts"],"names":[],"mappings":"AAAA,OAAO,EACE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,KAAK,SAAS,EAAC,MAAM,oBAAoB,CAAC;AACjJ,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAE5C,wBAAgB,cAAc,CAAC,QAAQ,EAAE,qBAAqB,GAAG,gBAAgB,GAAG,YAAY,CAK/F;AAED,wBAAsB,UAAU,CAAC,CAAC,SAAS,aAAa,EACtD,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,CAAC,CAAC,QAAQ,EAAE,qBAAqB,GAAG,gBAAgB,KAAK,CAAC,CAAC,EACzE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,EACrB,cAAc,EAAE,CAAC,iBAAiB,GAAG,SAAS,CAAC,EAAE,iBA0BlD;AAED,wBAAsB,eAAe,CAAC,CAAC,SAAS,aAAa,EAC3D,YAAY,EAAE,CAAC,CAAC,QAAQ,EAAE,qBAAqB,GAAG,gBAAgB,KAAK,CAAC,CAAC,EACzE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,EACrB,cAAc,EAAE,CAAC,iBAAiB,GAAG,SAAS,CAAC,EAAE,iBAclD"}
1
+ {"version":3,"file":"firestore.d.ts","sourceRoot":"","sources":["../../src/utils/firestore.ts"],"names":[],"mappings":"AAAA,OAAO,EACE,KAAK,YAAY,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,KAAK,SAAS,EAAC,MAAM,oBAAoB,CAAC;AACjJ,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAE5C,wBAAgB,cAAc,CAAC,QAAQ,EAAE,qBAAqB,GAAG,gBAAgB,GAAG,YAAY,CAK/F;AAED,wBAAsB,UAAU,CAAC,CAAC,SAAS,aAAa,EACtD,SAAS,EAAE,SAAS,EACpB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,CAAC,CAAC,QAAQ,EAAE,qBAAqB,GAAG,gBAAgB,KAAK,CAAC,CAAC,EACzE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,EACrB,cAAc,EAAE,CAAC,iBAAiB,GAAG,SAAS,CAAC,EAAE,iBAkBlD;AAED,wBAAsB,eAAe,CAAC,CAAC,SAAS,aAAa,EAC3D,YAAY,EAAE,CAAC,CAAC,QAAQ,EAAE,qBAAqB,GAAG,gBAAgB,KAAK,CAAC,CAAC,EACzE,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,EACrB,cAAc,EAAE,CAAC,iBAAiB,GAAG,SAAS,CAAC,EAAE,iBAQlD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ienlab/react-library",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "My React component library",
5
5
  "main": "./dist/my-library.cjs.js",
6
6
  "module": "./dist/my-library.es.js",