PageSourceSearch

https://www.mkbservicedesk.nl/484bcb1e-686a5d2fc4b4a33ca491.js

js mkbservicedesk.nl collected 2026-10-02 03:16:07 UTC 249,776 bytes, 3 lines download raw bytes

1/*! For license information please see 484bcb1e-686a5d2fc4b4a33ca491.js.LICENSE.txt */
2"use strict";(self.webpackChunkmkbservicedesk_gatsby=self.webpackChunkmkbservicedesk_gatsby||[]).push([[7604],{1241:function(t,e,n){var r=n(5444),i=n(6199),o=n(2477),s=n(6336),u=n(7036),a=n(5319);var c=function(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}(i),h={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"},f=function(t){function e(e,n){var r=this;return(r=t.call(this,n)||this).code=e,r.message=n,r.name="FirebaseError",r.toString=function(){return r.name+": [code="+r.code+"]: "+r.message},r}return r.__extends(e,t),e}(Error),l=new o.Logger("@firebase/firestore");function p(){return l.logLevel}function d(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(l.logLevel<=o.LogLevel.DEBUG){var i=e.map(g);l.debug.apply(l,r.__spreadArrays(["Firestore (7.24.0): "+t],i))}}function v(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(l.logLevel<=o.LogLevel.ERROR){var i=e.map(g);l.error.apply(l,r.__spreadArrays(["Firestore (7.24.0): "+t],i))}}function y(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(l.logLevel<=o.LogLevel.WARN){var i=e.map(g);l.warn.apply(l,r.__spreadArrays(["Firestore (7.24.0): "+t],i))}}function g(t){if("string"==typeof t)return t;try{return e=t,JSON.stringify(e)}catch(e){return t}var e}function m(t){void 0===t&&(t="Unexpected state");var e="FIRESTORE (7.24.0) INTERNAL ASSERTION FAILED: "+t;throw v(e),new Error(e)}function w(t,e){t||m()}function _(t,e){return t}function b(t){var e=0;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function I(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function E(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}var T=function(){function t(t,e,n){void 0===e?e=0:e>t.length&&m(),void 0===n?n=t.length-e:n>t.length-e&&m(),this.segments=t,this.offset=e,this.t=n}return Object.defineProperty(t.prototype,"length",{get:function(){return this.t},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){return 0===t.i(this,e)},t.prototype.child=function(e){var n=this.segments.slice(this.offset,this.limit());return e instanceof t?e.forEach((function(t){n.push(t)})):n.push(e),this.o(n)},t.prototype.limit=function(){return this.offset+this.length},t.prototype.u=function(t){return t=void 0===t?1:t,this.o(this.segments,this.offset+t,this.length-t)},t.prototype.h=function(){return this.o(this.segments,this.offset,this.length-1)},t.prototype.l=function(){return this.segments[this.offset]},t.prototype._=function(){return this.get(this.length-1)},t.prototype.get=function(t){return this.segments[this.offset+t]},t.prototype.m=function(){return 0===this.length},t.prototype.T=function(t){if(t.length<this.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},t.prototype.I=function(t){if(this.length+1!==t.length)return!1;for(var e=0;e<this.length;e++)if(this.get(e)!==t.get(e))return!1;return!0},t.prototype.forEach=function(t){for(var e=this.offset,n=this.limit();e<n;e++)t(this.segments[e])},t.prototype.A=function(){return this.segments.slice(this.offset,this.limit())},t.i=function(t,e){for(var n=Math.min(t.length,e.length),r=0;r<n;r++){var i=t.get(r),o=e.get(r);if(i<o)return-1;if(i>o)return 1}return t.length<e.length?-1:t.length>e.length?1:0},t}(),N=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.o=function(t,n,r){return new e(t,n,r)},e.prototype.R=function(){return this.A().join("/")},e.prototype.toString=function(){return this.R()},e.g=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=[],i=0,o=t;i<o.length;i++){var s=o[i];if(s.indexOf("//")>=0)throw new f(h.INVALID_ARGUMENT,"Invalid segment ("+s+"). Paths must not contain // in them.");r.push.apply(r,s.split("/").filter((function(t){return t.length>0})))}return new e(r)},e.P=function(){return new e([])},e}(T),A=/^[_a-zA-Z][_a-zA-Z0-9]*$/,S=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.o=function(t,n,r){return new e(t,n,r)},e.V=function(t){return A.test(t)},e.prototype.R=function(){return this.A().map((function(t){return t=t.replace("\\","\\\\").replace("`","\\`"),e.V(t)||(t="`"+t+"`"),t})).join(".")},e.prototype.toString=function(){return this.R()},e.prototype.p=function(){return 1===this.length&&"__name__"===this.get(0)},e.v=function(){return new e(["__name__"])},e.S=function(t){for(var n=[],r="",i=0,o=function(){if(0===r.length)throw new f(h.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'");n.push(r),r=""},s=!1;i<t.length;){var u=t[i];if("\\"===u){if(i+1===t.length)throw new f(h.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var a=t[i+1];if("\\"!==a&&"."!==a&&"`"!==a)throw new f(h.INVALID_ARGUMENT,"Path has invali
2d escape sequence: "+t);r+=a,i+=2}else"`"===u?(s=!s,i++):"."!==u||s?(r+=u,i++):(o(),i++)}if(o(),s)throw new f(h.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)},e.P=function(){return new e([])},e}(T),D=function(){function t(t){this.path=t}return t.D=function(e){return new t(N.g(e))},t.C=function(e){return new t(N.g(e).u(5))},t.prototype.N=function(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t},t.prototype.isEqual=function(t){return null!==t&&0===N.i(this.path,t.path)},t.prototype.toString=function(){return this.path.toString()},t.i=function(t,e){return N.i(t.path,e.path)},t.F=function(t){return t.length%2==0},t.$=function(e){return new t(new N(e.slice()))},t}();function x(t,e){if(0!==e.length)throw new f(h.INVALID_ARGUMENT,"Function "+t+"() does not support arguments, but was called with "+Q(e.length,"argument")+".")}function L(t,e,n){if(e.length!==n)throw new f(h.INVALID_ARGUMENT,"Function "+t+"() requires "+Q(n,"argument")+", but was called with "+Q(e.length,"argument")+".")}function k(t,e,n){if(e.length<n)throw new f(h.INVALID_ARGUMENT,"Function "+t+"() requires at least "+Q(n,"argument")+", but was called with "+Q(e.length,"argument")+".")}function R(t,e,n,r){if(e.length<n||e.length>r)throw new f(h.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+Q(e.length,"argument")+".")}function O(t,e,n,r){M(t,e,K(n)+" argument",r)}function P(t,e,n,r){void 0!==r&&O(t,e,n,r)}function V(t,e,n,r){M(t,e,n+" option",r)}function U(t,e,n,r){void 0!==r&&V(t,e,n,r)}function C(t,e,n,r,i){void 0!==r&&function(t,e,n,r,i){for(var o=[],s=0,u=i;s<u.length;s++){var a=u[s];if(a===r)return;o.push(j(a))}var c=j(r);throw new f(h.INVALID_ARGUMENT,"Invalid value "+c+" provided to function "+t+'() for option "'+n+'". Acceptable values: '+o.join(", "))}(t,0,n,r,i)}function F(t,e,n,r){if(!e.some((function(t){return t===r})))throw new f(h.INVALID_ARGUMENT,"Invalid value "+j(r)+" provided to function "+t+"() for its "+K(n)+" argument. Acceptable values: "+e.join(", "));return r}function M(t,e,n,r){if(!("object"===e?q(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=j(r);throw new f(h.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" to be of type "+e+", but it was: "+i)}}function q(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}function j(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=t.substring(0,20)+"..."),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==typeof t){if(t instanceof Array)return"an array";var e=function(t){if(t.constructor){var e=/function\s+([^\s(]+)\s*\(/.exec(t.constructor.toString());if(e&&e.length>1)return e[1]}return null}(t);return e?"a custom "+e+" object":"an object"}return"function"==typeof t?"a function":m()}function G(t,e,n){if(void 0===n)throw new f(h.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+K(e)+" argument, but it was undefined.")}function z(t,e,n){I(e,(function(e,r){if(n.indexOf(e)<0)throw new f(h.INVALID_ARGUMENT,"Unknown option '"+e+"' passed to function "+t+"(). Available options: "+n.join(", "))}))}function B(t,e,n,r){var i=j(r);return new f(h.INVALID_ARGUMENT,"Function "+t+"() requires its "+K(n)+" argument to be a "+e+", but it was: "+i)}function W(t,e,n){if(n<=0)throw new f(h.INVALID_ARGUMENT,"Function "+t+"() requires its "+K(e)+" argument to be a positive number, but it was: "+n+".")}function K(t){switch(t){case 1:return"first";
2case 2:return"second";case 3:return"third";default:return t+"th"}}function Q(t,e){return t+" "+e+(1===t?"":"s")}function H(t){var e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(var r=0;r<t;r++)n[r]=Math.floor(256*Math.random());return n}var Y=function(){function t(){}return t.k=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=62*Math.floor(256/62),n="";n.length<20;)for(var r=H(40),i=0;i<r.length;++i)n.length<20&&r[i]<e&&(n+=t.charAt(r[i]%62));return n},t}();function $(t,e){return t<e?-1:t>e?1:0}function X(t,e,n){return t.length===e.length&&t.every((function(t,r){return n(t,e[r])}))}function J(t){return t+"\0"}var Z=function(){function t(t){this.M=t}return t.fromBase64String=function(e){return new t(atob(e))},t.fromUint8Array=function(e){return new t(function(t){for(var e="",n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(e))},t.prototype.toBase64=function(){return t=this.M,btoa(t);var t},t.prototype.toUint8Array=function(){return function(t){for(var e=new Uint8Array(t.length),n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}(this.M)},t.prototype.O=function(){return 2*this.M.length},t.prototype.L=function(t){return $(this.M,t.M)},t.prototype.isEqual=function(t){return this.M===t.M},t}();Z.B=new Z("");var tt=function(){function t(t){this.q=t}return t.fromBase64String=function(e){try{return new t(Z.fromBase64String(e))}catch(e){throw new f(h.INVALID_ARGUMENT,"Failed to construct Bytes from Base64 string: "+e)}},t.fromUint8Array=function(e){return new t(Z.fromUint8Array(e))},t.prototype.toBase64=function(){return this.q.toBase64()},t.prototype.toUint8Array=function(){return this.q.toUint8Array()},t.prototype.toString=function(){return"Bytes(base64: "+this.toBase64()+")"},t.prototype.isEqual=function(t){return this.q.isEqual(t.q)},t}();function et(){if("undefined"==typeof Uint8Array)throw new f(h.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function nt(){if("undefined"==typeof atob)throw new f(h.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.fromBase64String=function(t){L("Blob.fromBase64String",arguments,1),O("Blob.fromBase64String","string",1,t),nt();try{return new e(Z.fromBase64String(t))}catch(t){throw new f(h.INVALID_ARGUMENT,"Failed to construct Blob from Base64 string: "+t)}},e.fromUint8Array=function(t){if(L("Blob.fromUint8Array",arguments,1),et(),!(t instanceof Uint8Array))throw B("Blob.fromUint8Array","Uint8Array",1,t);return new e(Z.fromUint8Array(t))},e.prototype.toBase64=function(){return L("Blob.toBase64",arguments,0),nt(),t.prototype.toBase64.call(this)},e.prototype.toUint8Array=function(){return L("Blob.toUint8Array",arguments,0),et(),t.prototype.toUint8Array.call(this)},e.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},e}(tt),it=function(t,e,n,r,i,o){this.U=t,this.persistenceKey=e,this.host=n,this.ssl=r,this.forceLongPolling=i,this.W=o},ot=function(){function t(t,e){this.projectId=t,this.database=e||"(default)"}return Object.defineProperty(t.prototype,"j",{get:function(){return"(default)"===this.database},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){return e instanceof t&&e.projectId===this.projectId&&e.database===this.database},t.prototype.L=function(t){return $(this.projectId,t.projectId)||$(this.database,t.database)},t}(),st=function(){function t(t,e){this.K=t,this.G=e,this.H={}}return t.prototype.get=function(t){var e=this.K(t),n=this.H[e];if(void 0!==n)for(var r=0,i=n;r<i.length;r++){var o=i[r],s=o[0],u=o[1];if(this.G(s,t))return u}},t.prototype.has=function(t){return void 0!==this.get(t)},t.prototype.set=function(t,e){var n=this.K(t),r=this.H[n];if(void 0!==r){for(var i=0;i<r.length;i++)if(this.G(r[i][0],t))return void(r[i]=[t,e]);r.push([t,e])}else this.H[n]=[[t,e]]},t.prototype.delete=function(t){var e=this.K(t),n=this.H[e];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(this.G(n[r][0],t))return 1===n.length?delete this.H[e]:n.splice(r,1),!0;return!1}
2,t.prototype.forEach=function(t){I(this.H,(function(e,n){for(var r=0,i=n;r<i.length;r++){var o=i[r],s=o[0],u=o[1];t(s,u)}}))},t.prototype.m=function(){return E(this.H)},t}(),ut=function(){function t(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new f(h.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new f(h.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new f(h.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new f(h.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t)}return t.now=function(){return t.fromMillis(Date.now())},t.fromDate=function(e){return t.fromMillis(e.getTime())},t.fromMillis=function(e){var n=Math.floor(e/1e3);return new t(n,1e6*(e-1e3*n))},t.prototype.toDate=function(){return new Date(this.toMillis())},t.prototype.toMillis=function(){return 1e3*this.seconds+this.nanoseconds/1e6},t.prototype.Y=function(t){return this.seconds===t.seconds?$(this.nanoseconds,t.nanoseconds):$(this.seconds,t.seconds)},t.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},t.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},t.prototype.toJSON=function(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}},t.prototype.valueOf=function(){var t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")},t}(),at=function(){function t(t){this.timestamp=t}return t.J=function(e){return new t(e)},t.min=function(){return new t(new ut(0,0))},t.prototype.L=function(t){return this.timestamp.Y(t.timestamp)},t.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},t.prototype.X=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},t.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},t.prototype.Z=function(){return this.timestamp},t}();function ct(t){return null==t}function ht(t){return 0===t&&1/t==-1/0}function ft(t){return"number"==typeof t&&Number.isInteger(t)&&!ht(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}var lt=function(t,e,n,r,i,o,s){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===s&&(s=null),this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=s,this.tt=null};function pt(t,e,n,r,i,o,s){return void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===s&&(s=null),new lt(t,e,n,r,i,o,s)}function dt(t){var e=_(t);if(null===e.tt){var n=e.path.R();null!==e.collectionGroup&&(n+="|cg:"+e.collectionGroup),n+="|f:",n+=e.filters.map((function(t){return function(t){return t.field.R()+t.op.toString()+oe(t.value)}(t)})).join(","),n+="|ob:",n+=e.orderBy.map((function(t){return(e=t).field.R()+e.dir;var e})).join(","),ct(e.limit)||(n+="|l:",n+=e.limit),e.startAt&&(n+="|lb:",n+=hr(e.startAt)),e.endAt&&(n+="|ub:",n+=hr(e.endAt)),e.tt=n}return e.tt}function vt(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(var n=0;n<t.orderBy.length;n++)if(!vr(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(var r=0;r<t.filters.length;r++)if(i=t.filters[r],o=e.filters[r],i.op!==o.op||!i.field.isEqual(o.field)||!ee(i.value,o.value))return!1;var i,o;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!lr(t.startAt,e.startAt)&&lr(t.endAt,e.endAt)}function yt(t){return D.F(t.path)&&null===t.collectionGroup&&0===t.filters.length}var gt,mt,wt=function(){function t(t,e,n,r,i,o,s){void 0===i&&(i=at.min()),void 0===o&&(o=at.min()),void 0===s&&(s=Z.B),this.target=t,this.targetId=e,this.et=n,this.sequenceNumber=r,this.nt=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=s}return t.prototype.st=function(e){return new t(this.target,this.targetId,this.et,e,this.nt,this.lastLimboFreeSnapshotVersion,this.resumeToken)},t.prototype.it=function(e,n){return new t(this.target,this.targetId,this.et,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e)},t.prototype.rt=function(e){return new t(this.target,this.targetId,this.et,this.sequenceNumber,this.nt,e,this.resumeToken)},t}(),_t=function(t){this.count=t};function bt(t){switch(t){case h.OK:return m();case h.CANCELLED:case h.UNKNOWN:case h.DEADLINE_EXCEEDED:case h.RESOURCE_EXHAUSTED:case h.INTERNAL:case h.UNAVAILABLE:case h.UNAUTHENTICATED:return!1;case h.INVALID_ARGUMENT:case h.NOT_FOUND:case h.ALREADY_EXISTS:case h.PERMISSION_DENIED:case h.FAILED_PRECONDITION:case h.ABORTED:case h.OUT_OF_RANGE:case h.UNIMPLEMENT
2ED:case h.DATA_LOSS:return!0;default:return m()}}function It(t){if(void 0===t)return v("GRPC error has no .code"),h.UNKNOWN;switch(t){case gt.OK:return h.OK;case gt.CANCELLED:return h.CANCELLED;case gt.UNKNOWN:return h.UNKNOWN;case gt.DEADLINE_EXCEEDED:return h.DEADLINE_EXCEEDED;case gt.RESOURCE_EXHAUSTED:return h.RESOURCE_EXHAUSTED;case gt.INTERNAL:return h.INTERNAL;case gt.UNAVAILABLE:return h.UNAVAILABLE;case gt.UNAUTHENTICATED:return h.UNAUTHENTICATED;case gt.INVALID_ARGUMENT:return h.INVALID_ARGUMENT;case gt.NOT_FOUND:return h.NOT_FOUND;case gt.ALREADY_EXISTS:return h.ALREADY_EXISTS;case gt.PERMISSION_DENIED:return h.PERMISSION_DENIED;case gt.FAILED_PRECONDITION:return h.FAILED_PRECONDITION;case gt.ABORTED:return h.ABORTED;case gt.OUT_OF_RANGE:return h.OUT_OF_RANGE;case gt.UNIMPLEMENTED:return h.UNIMPLEMENTED;case gt.DATA_LOSS:return h.DATA_LOSS;default:return m()}}(mt=gt||(gt={}))[mt.OK=0]="OK",mt[mt.CANCELLED=1]="CANCELLED",mt[mt.UNKNOWN=2]="UNKNOWN",mt[mt.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",mt[mt.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",mt[mt.NOT_FOUND=5]="NOT_FOUND",mt[mt.ALREADY_EXISTS=6]="ALREADY_EXISTS",mt[mt.PERMISSION_DENIED=7]="PERMISSION_DENIED",mt[mt.UNAUTHENTICATED=16]="UNAUTHENTICATED",mt[mt.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",mt[mt.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",mt[mt.ABORTED=10]="ABORTED",mt[mt.OUT_OF_RANGE=11]="OUT_OF_RANGE",mt[mt.UNIMPLEMENTED=12]="UNIMPLEMENTED",mt[mt.INTERNAL=13]="INTERNAL",mt[mt.UNAVAILABLE=14]="UNAVAILABLE",mt[mt.DATA_LOSS=15]="DATA_LOSS";var Et=function(){function t(t,e){this.i=t,this.root=e||Nt.EMPTY}return t.prototype.ot=function(e,n){return new t(this.i,this.root.ot(e,n,this.i).copy(null,null,Nt.at,null,null))},t.prototype.remove=function(e){return new t(this.i,this.root.remove(e,this.i).copy(null,null,Nt.at,null,null))},t.prototype.get=function(t){for(var e=this.root;!e.m();){var n=this.i(t,e.key);if(0===n)return e.value;n<0?e=e.left:n>0&&(e=e.right)}return null},t.prototype.indexOf=function(t){for(var e=0,n=this.root;!n.m();){var r=this.i(t,n.key);if(0===r)return e+n.left.size;r<0?n=n.left:(e+=n.left.size+1,n=n.right)}return-1},t.prototype.m=function(){return this.root.m()},Object.defineProperty(t.prototype,"size",{get:function(){return this.root.size},enumerable:!1,configurable:!0}),t.prototype.ct=function(){return this.root.ct()},t.prototype.ut=function(){return this.root.ut()},t.prototype.ht=function(t){return this.root.ht(t)},t.prototype.forEach=function(t){this.ht((function(e,n){return t(e,n),!1}))},t.prototype.toString=function(){var t=[];return this.ht((function(e,n){return t.push(e+":"+n),!1})),"{"+t.join(", ")+"}"},t.prototype.lt=function(t){return this.root.lt(t)},t.prototype._t=function(){return new Tt(this.root,null,this.i,!1)},t.prototype.ft=function(t){return new Tt(this.root,t,this.i,!1)},t.prototype.dt=function(){return new Tt(this.root,null,this.i,!0)},t.prototype.wt=function(t){return new Tt(this.root,t,this.i,!0)},t}(),Tt=function(){function t(t,e,n,r){this.Tt=r,this.Et=[];for(var i=1;!t.m();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.Tt?t.left:t.right;else{if(0===i){this.Et.push(t);break}this.Et.push(t),t=this.Tt?t.right:t.left}}return t.prototype.It=function(){var t=this.Et.pop(),e={key:t.key,value:t.value};if(this.Tt)for(t=t.left;!t.m();)this.Et.push(t),t=t.right;else for(t=t.right;!t.m();)this.Et.push(t),t=t.left;return e},t.prototype.At=function(){return this.Et.length>0},t.prototype.Rt=function(){if(0===this.Et.length)return null;var t=this.Et[this.Et.length-1];return{key:t.key,value:t.value}},t}(),Nt=function(){function t(e,n,r,i,o){this.key=e,this.value=n,this.color=null!=r?r:t.RED,this.left=null!=i?i:t.EMPTY,this.right=null!=o?o:t.EMPTY,this.size=this.left.size+1+this.right.size}return t.prototype.copy=function(e,n,r,i,o){return new t(null!=e?e:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},t.prototype.m=function(){return!1},t.prototype.ht=function(t){return this.left.ht(t)||t(this.key,this.value)||this.right.ht(t)},t.prototype.lt=function(t){return this.right.lt(t)||t(this.key,this.value)||this.left.lt(t)},t.prototype.min=function(){return this.left.m()?this:this.left.min()},t.prototype.ct=function(){return this.min().key},t.prototype.ut=function(){return this.right.m()?this.key:this.right.ut()},t.prototype.ot=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.copy(null,null,null,r.left.ot(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.ot(t,e,n))).gt()},t.prototype.Pt=function(){if(this.left.m())return t.EMPTY;var e=this;return e.left.yt()||e.left.left.yt()||(e=e.Vt()),(e=e.copy(null,null,null,e.left.Pt(),null)).gt()},t.prototype.remove=function(e,n){var r,i=this;if(n(e,i.key)<0)i.left.m()||i.left.yt()||i.left.left.yt()||(i=i.Vt()),i=i.copy(null,null,null,i.left.remove(e,n),null);
2else{if(i.left.yt()&&(i=i.bt()),i.right.m()||i.right.yt()||i.right.left.yt()||(i=i.vt()),0===n(e,i.key)){if(i.right.m())return t.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.Pt())}i=i.copy(null,null,null,null,i.right.remove(e,n))}return i.gt()},t.prototype.yt=function(){return this.color},t.prototype.gt=function(){var t=this;return t.right.yt()&&!t.left.yt()&&(t=t.St()),t.left.yt()&&t.left.left.yt()&&(t=t.bt()),t.left.yt()&&t.right.yt()&&(t=t.Dt()),t},t.prototype.Vt=function(){var t=this.Dt();return t.right.left.yt()&&(t=(t=(t=t.copy(null,null,null,null,t.right.bt())).St()).Dt()),t},t.prototype.vt=function(){var t=this.Dt();return t.left.left.yt()&&(t=(t=t.bt()).Dt()),t},t.prototype.St=function(){var e=this.copy(null,null,t.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)},t.prototype.bt=function(){var e=this.copy(null,null,t.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)},t.prototype.Dt=function(){var t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)},t.prototype.Ct=function(){var t=this.Nt();return Math.pow(2,t)<=this.size+1},t.prototype.Nt=function(){if(this.yt()&&this.left.yt())throw m();if(this.right.yt())throw m();var t=this.left.Nt();if(t!==this.right.Nt())throw m();return t+(this.yt()?0:1)},t}();Nt.EMPTY=null,Nt.RED=!0,Nt.at=!1,Nt.EMPTY=new(function(){function t(){this.size=0}return Object.defineProperty(t.prototype,"key",{get:function(){throw m()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){throw m()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){throw m()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){throw m()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){throw m()},enumerable:!1,configurable:!0}),t.prototype.copy=function(t,e,n,r,i){return this},t.prototype.ot=function(t,e,n){return new Nt(t,e)},t.prototype.remove=function(t,e){return this},t.prototype.m=function(){return!0},t.prototype.ht=function(t){return!1},t.prototype.lt=function(t){return!1},t.prototype.ct=function(){return null},t.prototype.ut=function(){return null},t.prototype.yt=function(){return!1},t.prototype.Ct=function(){return!0},t.prototype.Nt=function(){return 0},t}());var At=function(){function t(t){this.i=t,this.data=new Et(this.i)}return t.prototype.has=function(t){return null!==this.data.get(t)},t.prototype.first=function(){return this.data.ct()},t.prototype.last=function(){return this.data.ut()},Object.defineProperty(t.prototype,"size",{get:function(){return this.data.size},enumerable:!1,configurable:!0}),t.prototype.indexOf=function(t){return this.data.indexOf(t)},t.prototype.forEach=function(t){this.data.ht((function(e,n){return t(e),!1}))},t.prototype.Ft=function(t,e){for(var n=this.data.ft(t[0]);n.At();){var r=n.It();if(this.i(r.key,t[1])>=0)return;e(r.key)}},t.prototype.xt=function(t,e){var n;for(n=void 0!==e?this.data.ft(e):this.data._t();n.At();)if(!t(n.It().key))return},t.prototype.$t=function(t){var e=this.data.ft(t);return e.At()?e.It().key:null},t.prototype._t=function(){return new St(this.data._t())},t.prototype.ft=function(t){return new St(this.data.ft(t))},t.prototype.add=function(t){return this.copy(this.data.remove(t).ot(t,!0))},t.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},t.prototype.m=function(){return this.data.m()},t.prototype.kt=function(t){var e=this;return e.size<t.size&&(e=t,t=this),t.forEach((function(t){e=e.add(t)})),e},t.prototype.isEqual=function(e){if(!(e instanceof t))return!1;if(this.size!==e.size)return!1;for(var n=this.data._t(),r=e.data._t();n.At();){var i=n.It().key,o=r.It().key;if(0!==this.i(i,o))return!1}return!0},t.prototype.A=function(){var t=[];return this.forEach((function(e){t.push(e)})),t},t.prototype.toString=function(){var t=[];return this.forEach((function(e){return t.push(e)})),"SortedSet("+t.toString()+")"},t.prototype.copy=function(e){var n=new t(this.i);return n.data=e,n},t}(),St=function(){function t(t){this.Mt=t}return t.prototype.It=function(){return this.Mt.It().key},t.prototype.At=function(){return this.Mt.At()},t}(),Dt=new Et(D.i);
2function xt(){return Dt}function Lt(){return xt()}var kt=new Et(D.i);function Rt(){return kt}var Ot=new Et(D.i),Pt=new At(D.i);function Vt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=Pt,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var Ut=new At($);function Ct(){return Ut}var Ft=function(){function t(t){this.i=t?function(e,n){return t(e,n)||D.i(e.key,n.key)}:function(t,e){return D.i(t.key,e.key)},this.Ot=Rt(),this.Lt=new Et(this.i)}return t.Bt=function(e){return new t(e.i)},t.prototype.has=function(t){return null!=this.Ot.get(t)},t.prototype.get=function(t){return this.Ot.get(t)},t.prototype.first=function(){return this.Lt.ct()},t.prototype.last=function(){return this.Lt.ut()},t.prototype.m=function(){return this.Lt.m()},t.prototype.indexOf=function(t){var e=this.Ot.get(t);return e?this.Lt.indexOf(e):-1},Object.defineProperty(t.prototype,"size",{get:function(){return this.Lt.size},enumerable:!1,configurable:!0}),t.prototype.forEach=function(t){this.Lt.ht((function(e,n){return t(e),!1}))},t.prototype.add=function(t){var e=this.delete(t.key);return e.copy(e.Ot.ot(t.key,t),e.Lt.ot(t,null))},t.prototype.delete=function(t){var e=this.get(t);return e?this.copy(this.Ot.remove(t),this.Lt.remove(e)):this},t.prototype.isEqual=function(e){if(!(e instanceof t))return!1;if(this.size!==e.size)return!1;for(var n=this.Lt._t(),r=e.Lt._t();n.At();){var i=n.It().key,o=r.It().key;if(!i.isEqual(o))return!1}return!0},t.prototype.toString=function(){var t=[];return this.forEach((function(e){t.push(e.toString())})),0===t.length?"DocumentSet ()":"DocumentSet (\n  "+t.join("  \n")+"\n)"},t.prototype.copy=function(e,n){var r=new t;return r.i=this.i,r.Ot=e,r.Lt=n,r},t}(),Mt=function(){function t(){this.qt=new Et(D.i)}return t.prototype.track=function(t){var e=t.doc.key,n=this.qt.get(e);n?0!==t.type&&3===n.type?this.qt=this.qt.ot(e,t):3===t.type&&1!==n.type?this.qt=this.qt.ot(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.qt=this.qt.ot(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.qt=this.qt.ot(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.qt=this.qt.remove(e):1===t.type&&2===n.type?this.qt=this.qt.ot(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.qt=this.qt.ot(e,{type:2,doc:t.doc}):m():this.qt=this.qt.ot(e,t)},t.prototype.Ut=function(){var t=[];return this.qt.ht((function(e,n){t.push(n)})),t},t}(),qt=function(){function t(t,e,n,r,i,o,s,u){this.query=t,this.docs=e,this.Qt=n,this.docChanges=r,this.Wt=i,this.fromCache=o,this.jt=s,this.Kt=u}return t.Gt=function(e,n,r,i){var o=[];return n.forEach((function(t){o.push({type:0,doc:t})})),new t(e,n,Ft.Bt(n),o,r,i,!0,!1)},Object.defineProperty(t.prototype,"hasPendingWrites",{get:function(){return!this.Wt.m()},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.jt===t.jt&&this.Wt.isEqual(t.Wt)&&Yn(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.Qt.isEqual(t.Qt)))return!1;var e=this.docChanges,n=t.docChanges;if(e.length!==n.length)return!1;for(var r=0;r<e.length;r++)if(e[r].type!==n[r].type||!e[r].doc.isEqual(n[r].doc))return!1;return!0},t}(),jt=function(){function t(t,e,n,r,i){this.nt=t,this.zt=e,this.Ht=n,this.Yt=r,this.Jt=i}return t.Xt=function(e,n){var r=new Map;return r.set(e,Gt.Zt(e,n)),new t(at.min(),r,Ct(),xt(),Vt())},t}(),Gt=function(){function t(t,e,n,r,i){this.resumeToken=t,this.te=e,this.ee=n,this.ne=r,this.se=i}return t.Zt=function(e,n){return new t(Z.B,n,Vt(),Vt(),Vt())},t}(),zt=function(t,e,n,r){this.ie=t,this.removedTargetIds=e,this.key=n,this.re=r},Bt=function(t,e){this.targetId=t,this.oe=e},Wt=function(t,e,n,r){void 0===n&&(n=Z.B),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},Kt=function(){function t(){this.ae=0,this.ce=Yt(),this.ue=Z.B,this.he=!1,this.le=!0}return Object.defineProperty(t.prototype,"te",{get:function(){return this.he},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resumeToken",{get:function(){return this.ue},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_e",{get:function(){return 0!==this.ae}
2,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fe",{get:function(){return this.le},enumerable:!1,configurable:!0}),t.prototype.de=function(t){t.O()>0&&(this.le=!0,this.ue=t)},t.prototype.we=function(){var t=Vt(),e=Vt(),n=Vt();return this.ce.forEach((function(r,i){switch(i){case 0:t=t.add(r);break;case 2:e=e.add(r);break;case 1:n=n.add(r);break;default:m()}})),new Gt(this.ue,this.he,t,e,n)},t.prototype.me=function(){this.le=!1,this.ce=Yt()},t.prototype.Te=function(t,e){this.le=!0,this.ce=this.ce.ot(t,e)},t.prototype.Ee=function(t){this.le=!0,this.ce=this.ce.remove(t)},t.prototype.Ie=function(){this.ae+=1},t.prototype.Ae=function(){this.ae-=1},t.prototype.Re=function(){this.le=!0,this.he=!0},t}(),Qt=function(){function t(t){this.ge=t,this.Pe=new Map,this.ye=xt(),this.Ve=Ht(),this.pe=new At($)}return t.prototype.be=function(t){for(var e=0,n=t.ie;e<n.length;e++){var r=n[e];t.re instanceof On?this.ve(r,t.re):t.re instanceof Pn&&this.Se(r,t.key,t.re)}for(var i=0,o=t.removedTargetIds;i<o.length;i++){var s=o[i];this.Se(s,t.key,t.re)}},t.prototype.De=function(t){var e=this;this.Ce(t,(function(n){var r=e.Ne(n);switch(t.state){case 0:e.Fe(n)&&r.de(t.resumeToken);break;case 1:r.Ae(),r._e||r.me(),r.de(t.resumeToken);break;case 2:r.Ae(),r._e||e.removeTarget(n);break;case 3:e.Fe(n)&&(r.Re(),r.de(t.resumeToken));break;case 4:e.Fe(n)&&(e.xe(n),r.de(t.resumeToken));break;default:m()}}))},t.prototype.Ce=function(t,e){var n=this;t.targetIds.length>0?t.targetIds.forEach(e):this.Pe.forEach((function(t,r){n.Fe(r)&&e(r)}))},t.prototype.$e=function(t){var e=t.targetId,n=t.oe.count,r=this.ke(e);if(r){var i=r.target;if(yt(i))if(0===n){var o=new D(i.path);this.Se(e,o,new Pn(o,at.min()))}else w(1===n);else this.Me(e)!==n&&(this.xe(e),this.pe=this.pe.add(e))}},t.prototype.Oe=function(t){var e=this,n=new Map;this.Pe.forEach((function(r,i){var o=e.ke(i);if(o){if(r.te&&yt(o.target)){var s=new D(o.target.path);null!==e.ye.get(s)||e.Le(i,s)||e.Se(i,s,new Pn(s,t))}r.fe&&(n.set(i,r.we()),r.me())}}));var r=Vt();this.Ve.forEach((function(t,n){var i=!0;n.xt((function(t){var n=e.ke(t);return!n||2===n.et||(i=!1,!1)})),i&&(r=r.add(t))}));var i=new jt(t,n,this.pe,this.ye,r);return this.ye=xt(),this.Ve=Ht(),this.pe=new At($),i},t.prototype.ve=function(t,e){if(this.Fe(t)){var n=this.Le(t,e.key)?2:0;this.Ne(t).Te(e.key,n),this.ye=this.ye.ot(e.key,e),this.Ve=this.Ve.ot(e.key,this.Be(e.key).add(t))}},t.prototype.Se=function(t,e,n){if(this.Fe(t)){var r=this.Ne(t);this.Le(t,e)?r.Te(e,1):r.Ee(e),this.Ve=this.Ve.ot(e,this.Be(e).delete(t)),n&&(this.ye=this.ye.ot(e,n))}},t.prototype.removeTarget=function(t){this.Pe.delete(t)},t.prototype.Me=function(t){var e=this.Ne(t).we();return this.ge.qe(t).size+e.ee.size-e.se.size},t.prototype.Ie=function(t){this.Ne(t).Ie()},t.prototype.Ne=function(t){var e=this.Pe.get(t);return e||(e=new Kt,this.Pe.set(t,e)),e},t.prototype.Be=function(t){var e=this.Ve.get(t);return e||(e=new At($),this.Ve=this.Ve.ot(t,e)),e},t.prototype.Fe=function(t){var e=null!==this.ke(t);return e||d("WatchChangeAggregator","Detected inactive target",t),e},t.prototype.ke=function(t){var e=this.Pe.get(t);return e&&e._e?null:this.ge.Ue(t)},t.prototype.xe=function(t){var e=this;this.Pe.set(t,new Kt),this.ge.qe(t).forEach((function(n){e.Se(t,n,null)}))},t.prototype.Le=function(t,e){return this.ge.qe(t).has(e)},t}();function Ht(){return new Et(D.i)}function Yt(){return new Et(D.i)}function $t(t){var e,n;return"server_timestamp"===(null===(n=((null===(e=null==t?void 0:t.mapValue)||void 0===e?void 0:e.fields)||{}).__type__)||void 0===n?void 0:n.stringValue)}function Xt(t){var e=t.mapValue.fields.__previous_value__;return $t(e)?Xt(e):e}function Jt(t){var e=ue(t.mapValue.fields.__local_write_time__.timestampValue);return new ut(e.seconds,e.nanos)}var Zt=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function te(t){return"nullValue"in t?0:"booleanValue"in t?1:"integerValue"in t||"doubleValue"in t?2:"timestampValue"in t?3:"stringValue"in t?5:"bytesValue"in t?6:"referenceValue"in t?7:"geoPointValue"in t?8:"arrayValue"in t?9:"mapValue"in t?$t(t)?4:10:m()}function ee(t,e){var n=te(t);if(n!==te(e))return!1;switch(n){case 0:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return Jt(t).isEqual(Jt(e));case 3:return function(t,e){if("string"==typeof t.timestampValue&&"string"==typeof e.timestampValue&&t.timestampValue.length===e.timestampValue.length)return t.timestampValue===e.timestampValue;var n=ue(t.timestampValue),r=ue(e.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return function(t,e){return ce(t.bytesValue).isEqual(ce(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return ae(t.geoPointValue.latitude)===ae(e.geoPointValue.latitude)&&ae(t.geoPointValue.longitude)===ae(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return ae(t.integerValue)===ae(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){var n=ae(t.doubleValue),r=ae(e.doubleValue);return n===r?ht(n)===ht(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return X(t.arrayValue.values||[],e.arrayValue.values||[],ee);case 10:return function(t,e){var n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(b(n)!==b(r))return!1;for(var i in n)if(n.hasOwnProperty(i)&&(void 0===r[i]||!ee(n[i],r[i])))return!1;return!0}(t,e);default:return m()}}function ne(t,e){return void 0!==(t.values||[]).find((function(t){return ee(t,e)}))}function re(t,e){var n=te(t),r=te(e);if(n!==r)return $(n,r);switch(n){case 0:return 0;case 1:return $(t.booleanValue,e.booleanValue);case 2:return function(t,e){var n=ae(t.integerValue||t.doubleValue),r=ae(e.integerValue||e.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(t,e);case 3:return ie(t.timestampValue,e.timestampValue);case 4:return ie(Jt(t),Jt(e));case 5:return $(t.stringValue,e.stringValue);case 6:return function(t,e){var n=ce(t),r=ce(e);return n.L(r)}(t.bytesValue,e.bytesValue);case 7:return function(t,e){for(var n=t.split("/"),r=e.split("/"),i=0;i<n.length&&i<r.length;i++){var o=$(n[i],r[i]);if(0!==o)return o}return $(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){var n=$(ae(t.latitude),ae(e.latitude));return 0!==n?n:$(ae(t.longitude),ae(e.longitude))}(t.geoPointValue,e.geoPointValue);case 9:return function(t,e){for(var n=t.values||[],r=e.values||[],i=0;i<n.length&&i<r.length;++i){var o=re(n[i],r[i]);if(o)return o}return $(n.length,r.length)}(t.arrayValue,e.arrayValue);case 10:return function(t,e){var n=t.fields||{},r=Object.keys(n),i=e.fields||{},o=Object.keys(i);r.sort(),o.sort();for(var s=0;s<r.length&&s<o.length;++s){var u=$(r[s],o[s]);if(0!==u)return u;var a=re(n[r[s]],i[o[s]]);if(0!==a)return a}return $(r.length,o.length)}(t.mapValue,e.mapValue);default:throw m()}}function ie(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return $(t,e);var n=ue(t),r=ue(e),i=$(n.seconds,r.seconds);return 0!==i?i:$(n.nanos,r.nanos)}function oe(t){return se(t)}function se(t){return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?function(t){var e=ue(t);return"time("+e.seconds+","+e.nanos+")"}
2(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?ce(t.bytesValue).toBase64():"referenceValue"in t?(n=t.referenceValue,D.C(n).toString()):"geoPointValue"in t?"geo("+(e=t.geoPointValue).latitude+","+e.longitude+")":"arrayValue"in t?function(t){for(var e="[",n=!0,r=0,i=t.values||[];r<i.length;r++)n?n=!1:e+=",",e+=se(i[r]);return e+"]"}(t.arrayValue):"mapValue"in t?function(t){for(var e="{",n=!0,r=0,i=Object.keys(t.fields||{}).sort();r<i.length;r++){var o=i[r];n?n=!1:e+=",",e+=o+":"+se(t.fields[o])}return e+"}"}(t.mapValue):m();var e,n}function ue(t){if(w(!!t),"string"==typeof t){var e=0,n=Zt.exec(t);if(w(!!n),n[1]){var r=n[1];r=(r+"000000000").substr(0,9),e=Number(r)}var i=new Date(t);return{seconds:Math.floor(i.getTime()/1e3),nanos:e}}return{seconds:ae(t.seconds),nanos:ae(t.nanos)}}function ae(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function ce(t){return"string"==typeof t?Z.fromBase64String(t):Z.fromUint8Array(t)}function he(t,e){return{referenceValue:"projects/"+t.projectId+"/databases/"+t.database+"/documents/"+e.path.R()}}function fe(t){return!!t&&"integerValue"in t}function le(t){return!!t&&"arrayValue"in t}function pe(t){return!!t&&"nullValue"in t}function de(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function ve(t){return!!t&&"mapValue"in t}var ye={asc:"ASCENDING",desc:"DESCENDING"},ge={"<":"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"},me=function(t,e){this.U=t,this.Qe=e};function we(t){return{integerValue:""+t}}function _e(t,e){if(t.Qe){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:ht(e)?"-0":e}}function be(t,e){return ft(e)?we(e):_e(t,e)}function Ie(t,e){return t.Qe?new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+e.nanoseconds).slice(-9)+"Z":{seconds:""+e.seconds,nanos:e.nanoseconds}}function Ee(t,e){return t.Qe?e.toBase64():e.toUint8Array()}function Te(t,e){return Ie(t,e.Z())}function Ne(t){return w(!!t),at.J(function(t){var e=ue(t);return new ut(e.seconds,e.nanos)}(t))}function Ae(t,e){return function(t){return new N(["projects",t.projectId,"databases",t.database])}(t).child("documents").child(e).R()}function Se(t){var e=N.g(t);return w($e(e)),e}function De(t,e){return Ae(t.U,e.path)}function xe(t,e){var n=Se(e);return w(n.get(1)===t.U.projectId),w(!n.get(3)&&!t.U.database||n.get(3)===t.U.database),new D(Oe(n))}function Le(t,e){return Ae(t.U,e)}function ke(t){var e=Se(t);return 4===e.length?N.P():Oe(e)}function Re(t){return new N(["projects",t.U.projectId,"databases",t.U.database]).R()}function Oe(t){return w(t.length>4&&"documents"===t.get(4)),t.u(5)}function Pe(t,e,n){return{name:De(t,e),fields:n.proto.mapValue.fields}}function Ve(t,e){var n;if(e instanceof bn)n={update:Pe(t,e.key,e.value)};else if(e instanceof Sn)n={delete:De(t,e.key)};else if(e instanceof In)n={update:Pe(t,e.key,e.data),updateMask:Ye(e.We)};else if(e instanceof Tn)n={transform:{document:De(t,e.key),fieldTransforms:e.fieldTransforms.map((function(t){return function(t,e){var n=e.transform;if(n instanceof en)return{fieldPath:e.field.R(),setToServerValue:"REQUEST_TIME"};if(n instanceof nn)return{fieldPath:e.field.R(),appendMissingElements:{values:n.elements}};if(n instanceof on)return{fieldPath:e.field.R(),removeAllFromArray:{values:n.elements}};if(n instanceof un)return{fieldPath:e.field.R(),increment:n.je};throw m()}(0,t)}))}};else{if(!(e instanceof Dn))return m();n={verify:De(t,e.key)}}return e.Ge.Ke||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:Te(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:m()}(t,e.Ge)),n}function Ue(t,e){var n=e.currentDocument?function(t){return void 0!==t.updateTime?pn.updateTime(Ne(t.updateTime)):void 0!==t.exists?pn.exists(t.exists):pn.ze()}(e.currentDocument):pn.ze();if(e.update){e.update.name;var r=xe(t,e.update.name),i=new xn({mapValue:{fields:e.update.fields}});if(e.updateMask){var o=function(t){var e=t.fieldPaths||[];return new hn(e.map((function(t){return S.S(t)})))}(e.updateMask);return new In(r,i,o,n)}return new bn(r,i,n)}if(e.delete){var s=xe(t,e.delete);return new Sn(s,n)}if(e.transform){var u=xe(t,e.transform.document),a=e.transform.fieldTransforms.map((function(e){return function(t,e){var n=null;if("setToServerValue"in e)w("REQUEST_TIME"===e.setToServerValue),n=new en;else if("appendMissingElements"in e){var r=e.appendMissingElements.values||[];n=new nn(r)}else if("removeAllFromArray"in e){var i=e.removeAllFromArray.values||[];n=new on(i)}else"increment"in e?n=new un(t,e.increment):m();var o=S.S(e.fieldPath);return new fn(o,n)}(t,e)}));return w(!0===n.exists),new Tn(u,a)}if(e.verify){var c=xe(t,e.verify);return new Dn(c,n)}return m()}function Ce(t,e){return{documents:[Le(t,e.path)]}}function Fe(t,e){var n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=Le(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=Le(t,r.h()),n.structuredQuery.from=[{collectionId:r._()}]);var i=function(t){if(0!==t.length){var e=t.map((function(t){return function(t){if("=="===t.op){if(de(t.value))return{unaryFilter:{field:We(t.field),op:"IS_NAN"}};if(pe(t.value))return{unaryFilter:{field:We(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(de(t.value))return{unaryFilter:{field:We(t.field),op:"IS_NOT_NA
2N"}};if(pe(t.value))return{unaryFilter:{field:We(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:We(t.field),op:Be(t.op),value:t.value}}}(t)}));return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}}(e.filters);i&&(n.structuredQuery.where=i);var o=function(t){if(0!==t.length)return t.map((function(t){return function(t){return{field:We(t.field),direction:ze(t.dir)}}(t)}))}(e.orderBy);o&&(n.structuredQuery.orderBy=o);var s=function(t,e){return t.Qe||ct(e)?e:{value:e}}(t,e.limit);return null!==s&&(n.structuredQuery.limit=s),e.startAt&&(n.structuredQuery.startAt=je(e.startAt)),e.endAt&&(n.structuredQuery.endAt=je(e.endAt)),n}function Me(t){var e=ke(t.parent),n=t.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){w(1===r);var o=n.from[0];o.allDescendants?i=o.collectionId:e=e.child(o.collectionId)}var s=[];n.where&&(s=qe(n.where));var u=[];n.orderBy&&(u=n.orderBy.map((function(t){return function(t){return new pr(Ke(t.field),function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(t.direction))}(t)})));var a=null;n.limit&&(a=function(t){var e;return ct(e="object"==typeof t?t.value:t)?null:e}(n.limit));var c=null;n.startAt&&(c=Ge(n.startAt));var h=null;return n.endAt&&(h=Ge(n.endAt)),Wn(Cn(e,i,u,s,a,"F",c,h))}function qe(t){return t?void 0!==t.unaryFilter?[He(t)]:void 0!==t.fieldFilter?[Qe(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map((function(t){return qe(t)})).reduce((function(t,e){return t.concat(e)})):m():[]}function je(t){return{before:t.before,values:t.position}}function Ge(t){var e=!!t.before,n=t.values||[];return new cr(n,e)}function ze(t){return ye[t]}function Be(t){return ge[t]}function We(t){return{fieldPath:t.R()}}function Ke(t){return S.S(t.fieldPath)}function Qe(t){return tr.create(Ke(t.fieldFilter.field),function(t){switch(t){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";default:return m()}}(t.fieldFilter.op),t.fieldFilter.value)}function He(t){switch(t.unaryFilter.op){case"IS_NAN":var e=Ke(t.unaryFilter.field);return tr.create(e,"==",{doubleValue:NaN});case"IS_NULL":var n=Ke(t.unaryFilter.field);return tr.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var r=Ke(t.unaryFilter.field);return tr.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":var i=Ke(t.unaryFilter.field);return tr.create(i,"!=",{nullValue:"NULL_VALUE"});default:return m()}}function Ye(t){var e=[];return t.fields.forEach((function(t){return e.push(t.R())})),{fieldPaths:e}}function $e(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}var Xe=function(){this.He=void 0};function Je(t,e,n){return t instanceof en?function(t,e){var n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:t.seconds,nanos:t.nanoseconds}}}};return e&&(n.fields.__previous_value__=e),{mapValue:n}}(n,e):t instanceof nn?rn(t,e):t instanceof on?sn(t,e):function(t,e){var n=tn(t,e),r=an(n)+an(t.je);return fe(n)&&fe(t.je)?we(r):_e(t.serializer,r)}(t,e)}function Ze(t,e,n){return t instanceof nn?rn(t,e):t instanceof on?sn(t,e):n}function tn(t,e){return t instanceof un?fe(n=e)||function(t){return!!t&&"doubleValue"in t}(n)?e:{integerValue:0}:null;var n}var en=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e}(Xe),nn=function(t){function e(e){var n=this;return(n=t.call(this)||this).elements=e,n}return r.__extends(e,t),e}(Xe);function rn(t,e){for(var n=cn(e),r=function(t){n.some((function(e){return ee(e,t)}))||n.push(t)},i=0,o=t.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var on=function(t){function e(e){var n=this;return(n=t.call(this)||this).elements=e,n}return r.__extends(e,t),e}(Xe);function sn(t,e){for(var n=cn(e),r=function(t){n=n.filter((function(e){return!ee(e,t)}))},i=0,o=t.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var un=function(t){function e(e,n){var r=this;
2return(r=t.call(this)||this).serializer=e,r.je=n,r}return r.__extends(e,t),e}(Xe);function an(t){return ae(t.integerValue||t.doubleValue)}function cn(t){return le(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}var hn=function(){function t(t){this.fields=t,t.sort(S.i)}return t.prototype.Ye=function(t){for(var e=0,n=this.fields;e<n.length;e++)if(n[e].T(t))return!0;return!1},t.prototype.isEqual=function(t){return X(this.fields,t.fields,(function(t,e){return t.isEqual(e)}))},t}(),fn=function(t,e){this.field=t,this.transform=e},ln=function(t,e){this.version=t,this.transformResults=e},pn=function(){function t(t,e){this.updateTime=t,this.exists=e}return t.ze=function(){return new t},t.exists=function(e){return new t(void 0,e)},t.updateTime=function(e){return new t(e)},Object.defineProperty(t.prototype,"Ke",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)},t}();function dn(t,e){return void 0!==t.updateTime?e instanceof On&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e instanceof On}var vn=function(){};function yn(t,e,n){return t instanceof bn?function(t,e,n){return new On(t.key,n.version,t.value,{hasCommittedMutations:!0})}(t,0,n):t instanceof In?function(t,e,n){if(!dn(t.Ge,e))return new Vn(t.key,n.version);var r=En(t,e);return new On(t.key,n.version,r,{hasCommittedMutations:!0})}(t,e,n):t instanceof Tn?function(t,e,n){if(w(null!=n.transformResults),!dn(t.Ge,e))return new Vn(t.key,n.version);var r=Nn(t,e),i=function(t,e,n){var r=[];w(t.length===n.length);for(var i=0;i<n.length;i++){var o=t[i],s=o.transform,u=null;e instanceof On&&(u=e.field(o.field)),r.push(Ze(s,u,n[i]))}return r}(t.fieldTransforms,e,n.transformResults),o=n.version,s=An(t,r.data(),i);return new On(t.key,o,s,{hasCommittedMutations:!0})}(t,e,n):function(t,e,n){return new Pn(t.key,n.version,{hasCommittedMutations:!0})}(t,0,n)}function gn(t,e,n,r){return t instanceof bn?function(t,e){if(!dn(t.Ge,e))return e;var n=_n(e);return new On(t.key,n,t.value,{Je:!0})}(t,e):t instanceof In?function(t,e){if(!dn(t.Ge,e))return e;var n=_n(e),r=En(t,e);return new On(t.key,n,r,{Je:!0})}(t,e):t instanceof Tn?function(t,e,n,r){if(!dn(t.Ge,e))return e;var i=Nn(t,e),o=function(t,e,n,r){for(var i=[],o=0,s=t;o<s.length;o++){var u=s[o],a=u.transform,c=null;n instanceof On&&(c=n.field(u.field)),null===c&&r instanceof On&&(c=r.field(u.field)),i.push(Je(a,c,e))}return i}(t.fieldTransforms,n,e,r),s=An(t,i.data(),o);return new On(t.key,i.version,s,{Je:!0})}(t,e,r,n):function(t,e){return dn(t.Ge,e)?new Pn(t.key,at.min()):e}(t,e)}function mn(t,e){return t instanceof Tn?function(t,e){for(var n=null,r=0,i=t.fieldTransforms;r<i.length;r++){var o=i[r],s=e instanceof On?e.field(o.field):void 0,u=tn(o.transform,s||null);null!=u&&(n=null==n?(new Ln).set(o.field,u):n.set(o.field,u))}return n?n.Xe():null}(t,e):null}function wn(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.Ge.isEqual(e.Ge)&&(0===t.type?t.value.isEqual(e.value):1===t.type?t.data.isEqual(e.data)&&t.We.isEqual(e.We):2!==t.type||X(t.fieldTransforms,t.fieldTransforms,(function(t,e){return function(t,e){return t.field.isEqual(e.field)&&function(t,e){return t instanceof nn&&e instanceof nn||t instanceof on&&e instanceof on?X(t.elements,e.elements,ee):t instanceof un&&e instanceof un?ee(t.je,e.je):t instanceof en&&e instanceof en}(t.transform,e.transform)}(t,e)})))}function _n(t){return t instanceof On?t.version:at.min()}var bn=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).key=e,i.value=n,i.Ge=r,i.type=0,i}return r.__extends(e,t),e}(vn),In=function(t){function e(e,n,r,i){var o=this;return(o=t.call(this)||this).key=e,o.data=n,o.We=r,o.Ge=i,o.type=1,o}return r.__extends(e,t),e}(vn);function En(t,e){return function(t,e){var n=new Ln(e);return t.We.fields.forEach((function(e){if(!e.m()){var r=t.data.field(e);null!==r?n.set(e,r):n.delete(e)}})),n.Xe()}(t,e instanceof On?e.data():xn.empty())}var Tn=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).key=e,r.fieldTransforms=n,r.type=2,r.Ge=pn.exists(!0),r}return r.__extends(e,t),e}(vn);function Nn(t,e){return e}function An(t,e,n){for(var r=new Ln(e),i=0;i<t.fieldTransforms.length;i++){var o=t.fieldTransforms[i];r.set(o.field,n[i])}return r.Xe()}var Sn=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).key=e,r.Ge=n,r.type=3,r}return r.__extends(e,t),e}(vn),Dn=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).key=e,r.Ge=n,r.type=4,r}return r.__extends(e,t),e}(vn),xn=function(){function t(t){this.proto=t}return t.empty=function(){return new t({mapValue:{}})},t.prototype.field=function(t){if(t.m())return this.proto;for(var e=this.proto,n=0;n<t.length-1;++n){if(!e.mapValue.fields)return null;if(!ve(e=e.mapValue.fields[t.get(n)]))return null}return(e=(e.mapValue.fields||{})[t._()])||null},t.prototype.isEqual=function(t){return ee(this.proto,t.proto)},t}(),Ln=function(){function t(t){void 0===t&&(t=xn.empty()),this.Ze=t,this.tn=new Map}return t.prototype.set=function(t,e){return this.en(t,e),this}
2,t.prototype.delete=function(t){return this.en(t,null),this},t.prototype.en=function(t,e){for(var n=this.tn,r=0;r<t.length-1;++r){var i=t.get(r),o=n.get(i);o instanceof Map?n=o:o&&10===te(o)?(o=new Map(Object.entries(o.mapValue.fields||{})),n.set(i,o),n=o):(o=new Map,n.set(i,o),n=o)}n.set(t._(),e)},t.prototype.Xe=function(){var t=this.nn(S.P(),this.tn);return null!=t?new xn(t):this.Ze},t.prototype.nn=function(t,e){var n=this,r=!1,i=this.Ze.field(t),o=ve(i)?Object.assign({},i.mapValue.fields):{};return e.forEach((function(e,i){if(e instanceof Map){var s=n.nn(t.child(i),e);null!=s&&(o[i]=s,r=!0)}else null!==e?(o[i]=e,r=!0):o.hasOwnProperty(i)&&(delete o[i],r=!0)})),r?{mapValue:{fields:o}}:null},t}();function kn(t){var e=[];return I(t.fields||{},(function(t,n){var r=new S([t]);if(ve(n)){var i=kn(n.mapValue).fields;if(0===i.length)e.push(r);else for(var o=0,s=i;o<s.length;o++){var u=s[o];e.push(r.child(u))}}else e.push(r)})),new hn(e)}var Rn=function(t,e){this.key=t,this.version=e},On=function(t){function e(e,n,r,i){var o=this;return(o=t.call(this,e,n)||this).sn=r,o.Je=!!i.Je,o.hasCommittedMutations=!!i.hasCommittedMutations,o}return r.__extends(e,t),e.prototype.field=function(t){return this.sn.field(t)},e.prototype.data=function(){return this.sn},e.prototype.rn=function(){return this.sn.proto},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.Je===t.Je&&this.hasCommittedMutations===t.hasCommittedMutations&&this.sn.isEqual(t.sn)},e.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.sn.toString()+", {hasLocalMutations: "+this.Je+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return this.Je||this.hasCommittedMutations},enumerable:!1,configurable:!0}),e}(Rn),Pn=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n)||this).hasCommittedMutations=!(!r||!r.hasCommittedMutations),i}return r.__extends(e,t),e.prototype.toString=function(){return"NoDocument("+this.key+", "+this.version+")"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return this.hasCommittedMutations},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){return t instanceof e&&t.hasCommittedMutations===this.hasCommittedMutations&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},e}(Rn),Vn=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.toString=function(){return"UnknownDocument("+this.key+", "+this.version+")"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return!0},enumerable:!1,configurable:!0}),e.prototype.isEqual=function(t){return t instanceof e&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},e}(Rn),Un=function(t,e,n,r,i,o,s,u){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o="F"),void 0===s&&(s=null),void 0===u&&(u=null),this.path=t,this.collectionGroup=e,this.on=n,this.filters=r,this.limit=i,this.an=o,this.startAt=s,this.endAt=u,this.cn=null,this.un=null,this.startAt,this.endAt};function Cn(t,e,n,r,i,o,s,u){return new Un(t,e,n,r,i,o,s,u)}function Fn(t){return new Un(t)}function Mn(t){return!ct(t.limit)&&"F"===t.an}function qn(t){return!ct(t.limit)&&"L"===t.an}function jn(t){return t.on.length>0?t.on[0].field:null}function Gn(t){for(var e=0,n=t.filters;e<n.length;e++){var r=n[e];if(r.hn())return r.field}return null}function zn(t){return null!==t.collectionGroup}function Bn(t){var e=_(t);if(null===e.cn){e.cn=[];var n=Gn(e),r=jn(e);if(null!==n&&null===r)n.p()||e.cn.push(new pr(n)),e.cn.push(new pr(S.v(),"asc"));else{for(var i=!1,o=0,s=e.on;o<s.length;o++){var u=s[o];e.cn.push(u),u.field.p()&&(i=!0)}if(!i){var a=e.on.length>0?e.on[e.on.length-1].dir:"asc";e.cn.push(new pr(S.v(),a))}}}return e.cn}function Wn(t){var e=_(t);if(!e.un)if("F"===e.an)e.un=pt(e.path,e.collectionGroup,Bn(e),e.filters,e.limit,e.startAt,e.endAt);else{for(var n=[],r=0,i=Bn(e);r<i.length;r++){var o=i[r],s="desc"===o.dir?"asc":"desc";n.push(new pr(o.field,s))}var u=e.endAt?new cr(e.endAt.position,!e.endAt.before):null,a=e.startAt?new cr(e.startAt.position,!e.startAt.before):null;e.un=pt(e.path,e.collectionGroup,n,e.filters,e.limit,u,a)}return e.un}function Kn(t,e,n){return new Un(t.path,t.collectionGroup,t.on.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Qn(t,e){return new Un(t.path,t.collectionGroup,t.on.slice(),t.filters.slice(),t.limit,t.an,e,t.endAt)}function Hn(t,e){return new Un(t.path,t.collectionGroup,t.on.slice(),t.filters.slice(),t.limit,t.an,t.startAt,e)}function Yn(t,e){return vt(Wn(t),Wn(e))&&t.an===e.an}function $n(t){return dt(Wn(t))+"|lt:"+t.an}function Xn(t){return"Query(target="+function(t){var e=t.path.R();return null!==t.collectionGroup&&(e+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(e+=", filters: ["+t.filters.map((function(t){return(e=t).field.R()+" "+e.op+" "+oe(e.value);var e})).join(", ")+"]"),ct(t.limit)||(e+=", limit: "+t.limit),t.orderBy.length>0&&(e+=", orderBy: ["+t.orderBy.map((function(t){return(e=t).field.R()+" ("+e.dir+")";var e})).join(", ")+"]"),t.startAt&&(e+=", startAt: "+hr(t.startAt)),t.endAt&&(e+=", endAt: "+hr(t.endAt)),"Target("+e+")"}(Wn(t))+"; limitType="+t.an+")"}function Jn(t,e){return function(t,e){var n=e.key.path;return null!==t.collectionGroup?e.key.N(t.collectionGroup)&&t.path.T(n):D.F(t.path)?t.path.isEqual(n):t.path.I(n)}(t,e)&&function(t,e){for(var n=0,r=t.on;n<r.length;n++){var i=r[n];if(!i.field.p()&&null===e.field(i.field))return!1}return!0}(t,e)&&function(t,e){for(var n=0,r=t.filters;n<r.length;n++)if(!r[n].matches(e))return!1;return!0}(t,e)&&function(t,e){return!(t.startAt&&!fr(t.startAt,Bn(t),e)||t.endAt&&fr(t.endAt,Bn(t),e))}(t,e)}function Zn(t){return function(e,n){for(var r=!1,i=0,o=Bn(t);i<o.length;i++){var s=o[i],u=dr(s,e,n);if(0!==u)return u;r=r||s.field.p()}return 0}}var tr=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).field=e,i.op=n,i.value=r,i}return r.__extends(e,t),e.create=function(t,n,r){if(t.p())return"in"===n||"not-in"===n?this.ln(t,
2n,r):new er(t,n,r);if(pe(r)){if("=="!==n&&"!="!==n)throw new f(h.INVALID_ARGUMENT,"Invalid query. Null only supports '==' and '!=' comparisons.");return new e(t,n,r)}if(de(r)){if("=="!==n&&"!="!==n)throw new f(h.INVALID_ARGUMENT,"Invalid query. NaN only supports '==' and '!=' comparisons.");return new e(t,n,r)}return"array-contains"===n?new or(t,r):"in"===n?new sr(t,r):"not-in"===n?new ur(t,r):"array-contains-any"===n?new ar(t,r):new e(t,n,r)},e.ln=function(t,e,n){return"in"===e?new nr(t,n):new rr(t,n)},e.prototype.matches=function(t){var e=t.field(this.field);return"!="===this.op?null!==e&&this._n(re(e,this.value)):null!==e&&te(this.value)===te(e)&&this._n(re(e,this.value))},e.prototype._n=function(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return t>0;case">=":return t>=0;default:return m()}},e.prototype.hn=function(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0},e}((function(){})),er=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n,r)||this).key=D.C(r.referenceValue),i}return r.__extends(e,t),e.prototype.matches=function(t){var e=D.i(t.key,this.key);return this._n(e)},e}(tr),nr=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"in",n)||this).keys=ir("in",n),r}return r.__extends(e,t),e.prototype.matches=function(t){return this.keys.some((function(e){return e.isEqual(t.key)}))},e}(tr),rr=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"not-in",n)||this).keys=ir("not-in",n),r}return r.__extends(e,t),e.prototype.matches=function(t){return!this.keys.some((function(e){return e.isEqual(t.key)}))},e}(tr);function ir(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map((function(t){return D.C(t.referenceValue)}))}var or=function(t){function e(e,n){return t.call(this,e,"array-contains",n)||this}return r.__extends(e,t),e.prototype.matches=function(t){var e=t.field(this.field);return le(e)&&ne(e.arrayValue,this.value)},e}(tr),sr=function(t){function e(e,n){return t.call(this,e,"in",n)||this}return r.__extends(e,t),e.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&ne(this.value.arrayValue,e)},e}(tr),ur=function(t){function e(e,n){return t.call(this,e,"not-in",n)||this}return r.__extends(e,t),e.prototype.matches=function(t){if(ne(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var e=t.field(this.field);return null!==e&&!ne(this.value.arrayValue,e)},e}(tr),ar=function(t){function e(e,n){return t.call(this,e,"array-contains-any",n)||this}return r.__extends(e,t),e.prototype.matches=function(t){var e=this,n=t.field(this.field);return!(!le(n)||!n.arrayValue.values)&&n.arrayValue.values.some((function(t){return ne(e.value.arrayValue,t)}))},e}(tr),cr=function(t,e){this.position=t,this.before=e};function hr(t){return(t.before?"b":"a")+":"+t.position.map((function(t){return oe(t)})).join(",")}function fr(t,e,n){for(var r=0,i=0;i<t.position.length;i++){var o=e[i],s=t.position[i];if(r=o.field.p()?D.i(D.C(s.referenceValue),n.key):re(s,n.field(o.field)),"desc"===o.dir&&(r*=-1),0!==r)break}return t.before?r<=0:r<0}function lr(t,e){if(null===t)return null===e;if(null===e)return!1;if(t.before!==e.before||t.position.length!==e.position.length)return!1;for(var n=0;n<t.position.length;n++)if(!ee(t.position[n],e.position[n]))return!1;return!0}var pr=function(t,e){void 0===e&&(e="asc"),this.field=t,this.dir=e};function dr(t,e,n){var r=t.field.p()?D.i(e.key,n.key):function(t,e,n){var r=e.field(t),i=n.field(t);return null!==r&&null!==i?re(r,i):m()}(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return m()}}function vr(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}var yr=function(){var t=this;this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))},gr=function(){function t(t,e,n,r,i){void 0===n&&(n=1e3),void 0===r&&(r=1.5),void 0===i&&(i=6e4),this.fn=t,this.dn=e,this.wn=n,this.mn=r,this.Tn=i,this.En=0,this.In=null,this.An=Date.now(),this.reset()}return t.prototype.reset=function(){this.En=0},t.prototype.Rn=function(){this.En=this.Tn},t.prototype.gn=function(t){var e=this;this.cancel();var n=Math.floor(this.En+this.Pn()),r=Math.max(0,Date.now()-this.An),i=Math.max(0,n-r);i>
20&&d("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.En+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.In=this.fn.yn(this.dn,i,(function(){return e.An=Date.now(),t()})),this.En*=this.mn,this.En<this.wn&&(this.En=this.wn),this.En>this.Tn&&(this.En=this.Tn)},t.prototype.Vn=function(){null!==this.In&&(this.In.pn(),this.In=null)},t.prototype.cancel=function(){null!==this.In&&(this.In.cancel(),this.In=null)},t.prototype.Pn=function(){return(Math.random()-.5)*this.En},t}(),mr=function(){function t(t){var e=this;this.bn=null,this.vn=null,this.result=void 0,this.error=void 0,this.Sn=!1,this.Dn=!1,t((function(t){e.Sn=!0,e.result=t,e.bn&&e.bn(t)}),(function(t){e.Sn=!0,e.error=t,e.vn&&e.vn(t)}))}return t.prototype.catch=function(t){return this.next(void 0,t)},t.prototype.next=function(e,n){var r=this;return this.Dn&&m(),this.Dn=!0,this.Sn?this.error?this.Cn(n,this.error):this.Nn(e,this.result):new t((function(t,i){r.bn=function(n){r.Nn(e,n).next(t,i)},r.vn=function(e){r.Cn(n,e).next(t,i)}}))},t.prototype.Fn=function(){var t=this;return new Promise((function(e,n){t.next(e,n)}))},t.prototype.xn=function(e){try{var n=e();return n instanceof t?n:t.resolve(n)}catch(e){return t.reject(e)}},t.prototype.Nn=function(e,n){return e?this.xn((function(){return e(n)})):t.resolve(n)},t.prototype.Cn=function(e,n){return e?this.xn((function(){return e(n)})):t.reject(n)},t.resolve=function(e){return new t((function(t,n){t(e)}))},t.reject=function(e){return new t((function(t,n){n(e)}))},t.$n=function(e){return new t((function(t,n){var r=0,i=0,o=!1;e.forEach((function(e){++r,e.next((function(){++i,o&&i===r&&t()}),(function(t){return n(t)}))})),o=!0,i===r&&t()}))},t.kn=function(e){for(var n=t.resolve(!1),r=function(e){n=n.next((function(n){return n?t.resolve(n):e()}))},i=0,o=e;i<o.length;i++)r(o[i]);return n},t.forEach=function(t,e){var n=this,r=[];return t.forEach((function(t,i){r.push(e.call(n,t,i))})),this.$n(r)},t}(),wr=function(){function t(e,n,r){this.name=e,this.version=n,this.Mn=r,12.2===t.On(s.getUA())&&v("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}return t.delete=function(t){return d("SimpleDb","Removing database:",t),Nr(window.indexedDB.deleteDatabase(t)).Fn()},t.Ln=function(){if("undefined"==typeof indexedDB)return!1;if(t.Bn())return!0;var e=s.getUA(),n=t.On(e),r=0<n&&n<10,i=t.qn(e),o=0<i&&i<4.5;return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||r||o)},t.Bn=function(){var t;return"undefined"!=typeof process&&"YES"===(null===(t={})||void 0===t?void 0:t.Un)},t.Qn=function(t,e){return t.store(e)},t.On=function(t){var e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)},t.qn=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},t.prototype.Wn=function(t){return r.__awaiter(this,void 0,void 0,(function(){var e,n=this;return r.__generator(this,(function(r){switch(r.label){case 0:return this.db?[3,2]:(d("SimpleDb","Opening database:",this.name),e=this,[4,new Promise((function(e,r){var i=indexedDB.open(n.name,n.version);i.onsuccess=function(t){var n=t.target.result;e(n)},i.onblocked=function(){r(new br(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=function(e){var n=e.target.error;"VersionError"===n.name?r(new f(h.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):r(new br(t,n))},i.onupgradeneeded=function(t){d("SimpleDb",'Database "'+n.name+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;n.Mn.createOrUpgrade(e,i.transaction,t.oldVersion,n.version).next((function(){d("SimpleDb","Database upgrade to version "+n.version+" complete")}
2))}}))]);case 1:e.db=r.sent(),r.label=2;case 2:return[2,(this.jn&&(this.db.onversionchange=function(t){return n.jn(t)}),this.db)]}}))}))},t.prototype.Kn=function(t){this.jn=t,this.db&&(this.db.onversionchange=function(e){return t(e)})},t.prototype.runTransaction=function(t,e,n,i){return r.__awaiter(this,void 0,void 0,(function(){var o,s,u,a,c;return r.__generator(this,(function(h){switch(h.label){case 0:o="readonly"===e,s=0,u=function(){var e,u,c,h,f;return r.__generator(this,(function(r){switch(r.label){case 0:++s,r.label=1;case 1:return r.trys.push([1,4,,5]),[4,a.Wn(t)];case 2:return a.db=r.sent(),e=Er.open(a.db,t,o?"readonly":"readwrite",n),u=i(e).catch((function(t){return e.abort(t),mr.reject(t)})).Fn(),c={},u.catch((function(){})),[4,e.Gn];case 3:return[2,(c.value=(r.sent(),u),c)];case 4:return h=r.sent(),f="FirebaseError"!==h.name&&s<3,d("SimpleDb","Transaction failed with error:",h.message,"Retrying:",f),a.close(),f?[3,5]:[2,{value:Promise.reject(h)}];case 5:return[2]}}))},a=this,h.label=1;case 1:return[5,u()];case 2:if("object"==typeof(c=h.sent()))return[2,c.value];h.label=3;case 3:return[3,1];case 4:return[2]}}
2))}))},t.prototype.close=function(){this.db&&this.db.close(),this.db=void 0},t}(),_r=function(){function t(t){this.zn=t,this.Hn=!1,this.Yn=null}return Object.defineProperty(t.prototype,"Sn",{get:function(){return this.Hn},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Jn",{get:function(){return this.Yn},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cursor",{set:function(t){this.zn=t},enumerable:!1,configurable:!0}),t.prototype.done=function(){this.Hn=!0},t.prototype.Xn=function(t){this.Yn=t},t.prototype.delete=function(){return Nr(this.zn.delete())},t}(),br=function(t){function e(e,n){var r=this;return(r=t.call(this,h.UNAVAILABLE,"IndexedDB transaction '"+e+"' failed: "+n)||this).name="IndexedDbTransactionError",r}return r.__extends(e,t),e}(f);function Ir(t){return"IndexedDbTransactionError"===t.name}var Er=function(){function t(t,e){var n=this;this.action=t,this.transaction=e,this.aborted=!1,this.Zn=new yr,this.transaction.oncomplete=function(){n.Zn.resolve()},this.transaction.onabort=function(){e.error?n.Zn.reject(new br(t,e.error)):n.Zn.resolve()},this.transaction.onerror=function(e){var r=Sr(e.target.error);n.Zn.reject(new br(t,r))}}return t.open=function(e,n,r,i){try{return new t(n,e.transaction(i,r))}catch(e){throw new br(n,e)}},Object.defineProperty(t.prototype,"Gn",{get:function(){return this.Zn.promise},enumerable:!1,configurable:!0}),t.prototype.abort=function(t){t&&this.Zn.reject(t),this.aborted||(d("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},t.prototype.store=function(t){var e=this.transaction.objectStore(t);return new Tr(e)},t}(),Tr=function(){function t(t){this.store=t}return t.prototype.put=function(t,e){var n;return void 0!==e?(d("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(d("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),Nr(n)},t.prototype.add=function(t){return d("SimpleDb","ADD",this.store.name,t,t),Nr(this.store.add(t))},t.prototype.get=function(t){var e=this;return Nr(this.store.get(t)).next((function(n){return void 0===n&&(n=null),d("SimpleDb","GET",e.store.name,t,n),n}))},t.prototype.delete=function(t){return d("SimpleDb","DELETE",this.store.name,t),Nr(this.store.delete(t))},t.prototype.count=function(){return d("SimpleDb","COUNT",this.store.name),Nr(this.store.count())},t.prototype.ts=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.es(n,(function(t,e){r.push(e)})).next((function(){return r}))},t.prototype.ns=function(t,e){d("SimpleDb","DELETE ALL",this.store.name);var n=this.options(t,e);n.ss=!1;var r=this.cursor(n);return this.es(r,(function(t,e,n){return n.delete()}))},t.prototype.rs=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.es(r,e)},t.prototype.os=function(t){var e=this.cursor({});return new mr((function(n,r){e.onerror=function(t){var e=Sr(t.target.error);r(e)},e.onsuccess=function(e){var r=e.target.result;r?t(r.primaryKey,r.value).next((function(t){t?r.continue():n()})):n()}}))},t.prototype.es=function(t,e){var n=[];return new mr((function(r,i){t.onerror=function(t){i(t.target.error)},t.onsuccess=function(t){var i=t.target.result;if(i){var o=new _r(i),s=e(i.primaryKey,i.value,o);if(s instanceof mr){var u=s.catch((function(t){return o.done(),mr.reject(t)}));n.push(u)}o.Sn?r():null===o.Jn?i.continue():i.continue(o.Jn)}else r()}})).next((function(){return mr.$n(n)}))},t.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}},t.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.ss?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},t}();function Nr(t){return new mr((function(e,n){t.onsuccess=function(t){var n=t.target.result;e(n)},t.onerror=function(t){var e=Sr(t.target.error);n(e)}}))}var Ar=!1;function Sr(t){var e=wr.On(s.getUA());if(e>=12.2&&e<13){var n="An internal error was encountered in the Indexed Database server";if(t.message.indexOf(n)>=0){var r=new f("internal","IOS_INDEXEDDB_BUG1: IndexedDb has thrown '"+n+"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.");return Ar||(Ar=!0,setTimeout((function(){throw r}),0)),r}}return t}function Dr(){return"undefined"!=typeof window?window:null}function xr(){return"undefined"!=typeof document?document:null}var Lr=function(){function t(t,e,n,r,i){this.cs=t,this.dn=e,this.us=n,this.op=r,this.hs=i,this.ls=new yr,this.then=this.ls.promise.then.bind(this.ls.promise),this.ls.promise.catch((function(t){}))}return t._s=function(e,n,r,i,o){var s=new t(e,n,Date.now()+r,i,o);return s.start(r),s},t.prototype.start=function(t){var e=this;this.fs=setTimeout((function(){return e.ds()}),t)},t.prototype.pn=function(){return this.ds()},t.prototype.cancel=function(t){null!==this.fs&&(this.clearTimeout(),this.ls.reject(new f(h.CANCELLED,"Operation cancelled"+(t?": "+t:"")))
2)},t.prototype.ds=function(){var t=this;this.cs.ws((function(){return null!==t.fs?(t.clearTimeout(),t.op().then((function(e){return t.ls.resolve(e)}))):Promise.resolve()}))},t.prototype.clearTimeout=function(){null!==this.fs&&(this.hs(this),clearTimeout(this.fs),this.fs=null)},t}(),kr=function(){function t(){var t=this;this.Ts=Promise.resolve(),this.Es=[],this.Is=!1,this.As=[],this.Rs=null,this.gs=!1,this.Ps=[],this.ys=new gr(this,"async_queue_retry"),this.Vs=function(){var e=xr();e&&d("AsyncQueue","Visibility state changed to  ",e.visibilityState),t.ys.Vn()};var e=xr();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.Vs)}return Object.defineProperty(t.prototype,"ps",{get:function(){return this.Is},enumerable:!1,configurable:!0}),t.prototype.ws=function(t){this.enqueue(t)},t.prototype.bs=function(t){this.vs(),this.Ss(t)},t.prototype.Ds=function(){if(!this.Is){this.Is=!0;var t=xr();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.Vs)}},t.prototype.enqueue=function(t){return this.vs(),this.Is?new Promise((function(t){})):this.Ss(t)},t.prototype.Cs=function(t){var e=this;this.ws((function(){return e.Es.push(t),e.Ns()}))},t.prototype.Ns=function(){return r.__awaiter(this,void 0,void 0,(function(){var t,e=this;return r.__generator(this,(function(n){switch(n.label){case 0:if(0===this.Es.length)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.Es[0]()];case 2:return n.sent(),this.Es.shift(),this.ys.reset(),[3,4];case 3:if(!Ir(t=n.sent()))throw t;return d("AsyncQueue","Operation failed with retryable error: "+t),[3,4];case 4:this.Es.length>0&&this.ys.gn((function(){return e.Ns()})),n.label=5;case 5:return[2]}}
2))}))},t.prototype.Ss=function(t){var e=this,n=this.Ts.then((function(){return e.gs=!0,t().catch((function(t){throw e.Rs=t,e.gs=!1,v("INTERNAL UNHANDLED ERROR: ",function(t){var e=t.message||"";return t.stack&&(e=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),e}(t)),t})).then((function(t){return e.gs=!1,t}))}));return this.Ts=n,n},t.prototype.yn=function(t,e,n){var r=this;this.vs(),this.Ps.indexOf(t)>-1&&(e=0);var i=Lr._s(this,t,e,n,(function(t){return r.Fs(t)}));return this.As.push(i),i},t.prototype.vs=function(){this.Rs&&m()},t.prototype.xs=function(){},t.prototype.$s=function(){return r.__awaiter(this,void 0,void 0,(function(){var t;return r.__generator(this,(function(e){switch(e.label){case 0:return[4,t=this.Ts];case 1:e.sent(),e.label=2;case 2:if(t!==this.Ts)return[3,0];e.label=3;case 3:return[2]}}))}))},t.prototype.ks=function(t){for(var e=0,n=this.As;e<n.length;e++)if(n[e].dn===t)return!0;return!1},t.prototype.Ms=function(t){var e=this;return this.$s().then((function(){e.As.sort((function(t,e){return t.us-e.us}));for(var n=0,r=e.As;n<r.length;n++){var i=r[n];if(i.pn(),"all"!==t&&i.dn===t)break}return e.$s()}))},t.prototype.Os=function(t){this.Ps.push(t)},t.prototype.Fs=function(t){var e=this.As.indexOf(t);this.As.splice(e,1)},t}();function Rr(t,e){if(v("AsyncQueue",e+": "+t),Ir(t))return new f(h.UNAVAILABLE,e+": "+t);throw t}var Or=function(){this.Ls=void 0,this.listeners=[]},Pr=function(){this.Bs=new st((function(t){return $n(t)}),Yn),this.onlineState="Unknown",this.qs=new Set};function Vr(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o,s,u,a,c;return r.__generator(this,(function(r){switch(r.label){case 0:if(n=_(t),i=e.query,o=!1,(s=n.Bs.get(i))||(o=!0,s=new Or),!o)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),u=s,[4,n.Us(i)];case 2:return u.Ls=r.sent(),[3,4];case 3:return a=r.sent(),c=Rr(a,"Initialization of query '"+Xn(e.query)+"' failed"),[2,void e.onError(c)];case 4:return n.Bs.set(i,s),s.listeners.push(e),e.Qs(n.onlineState),s.Ls&&e.Ws(s.Ls)&&Mr(n),[2]}}))}))}function Ur(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o,s,u;return r.__generator(this,(function(r){return n=_(t),i=e.query,o=!1,(s=n.Bs.get(i))&&(u=s.listeners.indexOf(e))>=0&&(s.listeners.splice(u,1),o=0===s.listeners.length),o?[2,(n.Bs.delete(i),n.js(i))]:[2]}))}))}function Cr(t,e){for(var n=_(t),r=!1,i=0,o=e;i<o.length;i++){var s=o[i],u=s.query,a=n.Bs.get(u);if(a){for(var c=0,h=a.listeners;c<h.length;c++)h[c].Ws(s)&&(r=!0);a.Ls=s}}r&&Mr(n)}function Fr(t,e,n){var r=_(t),i=r.Bs.get(e);if(i)for(var o=0,s=i.listeners;o<s.length;o++)s[o].onError(n);r.Bs.delete(e)}function Mr(t){t.qs.forEach((function(t){t.next()}))}var qr=function(){function t(t,e,n){this.query=t,this.Ks=e,this.Gs=!1,this.zs=null,this.onlineState="Unknown",this.options=n||{}}return t.prototype.Ws=function(t){if(!this.options.includeMetadataChanges){for(var e=[],n=0,r=t.docChanges;n<r.length;n++){var i=r[n];3!==i.type&&e.push(i)}t=new qt(t.query,t.docs,t.Qt,e,t.Wt,t.fromCache,t.jt,!0)}var o=!1;return this.Gs?this.Hs(t)&&(this.Ks.next(t),o=!0):this.Ys(t,this.onlineState)&&(this.Js(t),o=!0),this.zs=t,o},t.prototype.onError=function(t){this.Ks.error(t)},t.prototype.Qs=function(t){this.onlineState=t;var e=!1;return this.zs&&!this.Gs&&this.Ys(this.zs,t)&&(this.Js(this.zs),e=!0),e},t.prototype.Ys=function(t,e){if(!t.fromCache)return!0;var n="Offline"!==e;return!(this.options.Xs&&n||t.docs.m()&&"Offline"!==e)},t.prototype.Hs=function(t){if(t.docChanges.length>0)return!0;var e=this.zs&&this.zs.hasPendingWrites!==t.hasPendingWrites;return!(!t.jt&&!e)&&!0===this.options.includeMetadataChanges},t.prototype.Js=function(t){t=qt.Gt(t.query,t.docs,t.Wt,t.fromCache),this.Gs=!0,this.Ks.next(t)},t}(),jr=function(){function t(t){this.uid=t}return t.prototype.Zs=function(){return null!=this.uid},t.prototype.ti=function(){return this.Zs()?"uid:"+this.uid:"anonymous-user"},t.prototype.isEqual=function(t){return t.uid===this.uid},t}();jr.UNAUTHENTICATED=new jr(null),jr.ei=new jr("google-credentials-uid"),jr.ni=new jr("first-party-uid");var Gr=function(){function t(t,e){var n=this;this.previousValue=t,e&&(e.si=function(t){return n.ii(t)},this.ri=function(t){return e.oi(t)})}return t.prototype.ii=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},t.prototype.next=function(){var t=++this.previousValue;return this.ri&&this.ri(t),t},t}();function zr(t,e){return"firestore_clients_"+t+"_"+e}function Br(t,e,n){var r="firestore_mutations_"+t+"_"+n;return e.Zs()&&(r+="_"+e.uid),r}function Wr(t,e){return"firestore_targets_"+t+"_"+e}Gr.ai=-1;var Kr=function(){function t(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}return t.ci=function(e,n,r){var i=JSON.parse(r),o="object"==typeof i&&-1!==["pending","acknowledged","rejected"].indexOf(i.state)&&(void 0===i.error||"object"==typeof i.error),s=void 0;return o&&i.error&&(o="string"==typeof i.error.message&&"string"==typeof i.error.code)&&(s=new f(i.error.code,i.error.message)),o?new t(e,n,i.state,s):(v("SharedCl
2ientState","Failed to parse mutation state for ID '"+n+"': "+r),null)},t.prototype.ui=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},t}(),Qr=function(){function t(t,e,n){this.targetId=t,this.state=e,this.error=n}return t.ci=function(e,n){var r=JSON.parse(n),i="object"==typeof r&&-1!==["not-current","current","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error),o=void 0;return i&&r.error&&(i="string"==typeof r.error.message&&"string"==typeof r.error.code)&&(o=new f(r.error.code,r.error.message)),i?new t(e,r.state,o):(v("SharedClientState","Failed to parse target state for ID '"+e+"': "+n),null)},t.prototype.ui=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},t}(),Hr=function(){function t(t,e){this.clientId=t,this.activeTargetIds=e}return t.ci=function(e,n){for(var r=JSON.parse(n),i="object"==typeof r&&r.activeTargetIds instanceof Array,o=Ct(),s=0;i&&s<r.activeTargetIds.length;++s)i=ft(r.activeTargetIds[s]),o=o.add(r.activeTargetIds[s]);return i?new t(e,o):(v("SharedClientState","Failed to parse client data for instance '"+e+"': "+n),null)},t}(),Yr=function(){function t(t,e){this.clientId=t,this.onlineState=e}return t.ci=function(e){var n=JSON.parse(e);return"object"==typeof n&&-1!==["Unknown","Online","Offline"].indexOf(n.onlineState)&&"string"==typeof n.clientId?new t(n.clientId,n.onlineState):(v("SharedClientState","Failed to parse online state: "+e),null)},t}(),$r=function(){function t(){this.activeTargetIds=Ct()}return t.prototype.hi=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},t.prototype.li=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},t.prototype.ui=function(){var t={activeTargetIds:this.activeTargetIds.A(),updateTimeMs:Date.now()};return JSON.stringify(t)},t}(),Xr=function(){function t(t,e,n,r,i){this.window=t,this.fn=e,this.persistenceKey=n,this._i=r,this.fi=null,this.di=null,this.si=null,this.wi=this.mi.bind(this),this.Ti=new Et($),this.Ei=!1,this.Ii=[];var o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Ai=zr(this.persistenceKey,this._i),this.Ri=function(t){return"firestore_sequence_number_"+t}(this.persistenceKey),this.Ti=this.Ti.ot(this._i,new $r),this.gi=new RegExp("^firestore_clients_"+o+"_([^_]*)$"),this.Pi=new RegExp("^firestore_mutations_"+o+"_(\\d+)(?:_(.*))?$"),this.yi=new RegExp("^firestore_targets_"+o+"_(\\d+)$"),this.Vi=function(t){return"firestore_online_state_"+t}(this.persistenceKey),this.window.addEventListener("storage",this.wi)}return t.Ln=function(t){return!(!t||!t.localStorage)},t.prototype.start=function(){return r.__awaiter(this,void 0,void 0,(function(){var t,e,n,i,o,s,u,a,c,h,f,l=this;return r.__generator(this,(function(r){switch(r.label){case 0:return[4,this.fi.pi()];case 1:for(t=r.sent(),e=0,n=t;e<n.length;e++)(i=n[e])!==this._i&&(o=this.getItem(zr(this.persistenceKey,i)))&&(s=Hr.ci(i,o))&&(this.Ti=this.Ti.ot(s.clientId,s));for(this.bi(),(u=this.storage.getItem(this.Vi))&&(a=this.vi(u))&&this.Si(a),c=0,h=this.Ii;c<h.length;c++)f=h[c],this.mi(f);return this.Ii=[],this.window.addEventListener("unload",(function(){return l.Di()})),this.Ei=!0,[2]}}))}))},t.prototype.oi=function(t){this.setItem(this.Ri,JSON.stringify(t))},t.prototype.Ci=function(){return this.Ni(this.Ti)},t.prototype.Fi=function(t){var e=!1;return this.Ti.forEach((function(n,r){r.activeTargetIds.has(t)&&(e=!0)})),e},t.prototype.xi=function(t){this.$i(t,"pending")},t.prototype.ki=function(t,e,n){this.$i(t,e,n),this.Mi(t)},t.prototype.Oi=function(t){var e="not-current";if(this.Fi(t)){var n=this.storage.getItem(Wr(this.persistenceKey,t));if(n){var r=Qr.ci(t,n);r&&(e=r.state)}}return this.Li.hi(t),this.bi(),e},t.prototype.Bi=function(t){this.Li.li(t),this.bi()},t.prototype.qi=function(t){return this.Li.activeTargetIds.has(t)},t.prototype.Ui=function(t){this.removeItem(Wr(this.persistenceKey,t))},t.prototype.Qi=function(t,e,n){this.Wi(t,e,n)},t.prototype.ji=function(t,e,n){var r=this;e.forEach((function(t){r.Mi(t)}
2)),this.currentUser=t,n.forEach((function(t){r.xi(t)}))},t.prototype.Ki=function(t){this.Gi(t)},t.prototype.Di=function(){this.Ei&&(this.window.removeEventListener("storage",this.wi),this.removeItem(this.Ai),this.Ei=!1)},t.prototype.getItem=function(t){var e=this.storage.getItem(t);return d("SharedClientState","READ",t,e),e},t.prototype.setItem=function(t,e){d("SharedClientState","SET",t,e),this.storage.setItem(t,e)},t.prototype.removeItem=function(t){d("SharedClientState","REMOVE",t),this.storage.removeItem(t)},t.prototype.mi=function(t){var e=this,n=t;if(n.storageArea===this.storage){if(d("SharedClientState","EVENT",n.key,n.newValue),n.key===this.Ai)return void v("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.fn.Cs((function(){return r.__awaiter(e,void 0,void 0,(function(){var t,e,i,o,s,u;return r.__generator(this,(function(r){if(this.Ei){if(null!==n.key)if(this.gi.test(n.key)){if(null==n.newValue)return t=this.zi(n.key),[2,this.Hi(t,null)];if(e=this.Yi(n.key,n.newValue))return[2,this.Hi(e.clientId,e)]}else if(this.Pi.test(n.key)){if(null!==n.newValue&&(i=this.Ji(n.key,n.newValue)))return[2,this.Xi(i)]}else if(this.yi.test(n.key)){if(null!==n.newValue&&(o=this.Zi(n.key,n.newValue)))return[2,this.tr(o)]}else if(n.key===this.Vi){if(null!==n.newValue&&(s=this.vi(n.newValue)))return[2,this.Si(s)]}else n.key===this.Ri&&(u=function(t){var e=Gr.ai;if(null!=t)try{var n=JSON.parse(t);w("number"==typeof n),e=n}catch(t){v("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(n.newValue))!==Gr.ai&&this.si(u)}else this.Ii.push(n);return[2]}))}))}))}},Object.defineProperty(t.prototype,"Li",{get:function(){return this.Ti.get(this._i)},enumerable:!1,configurable:!0}),t.prototype.bi=function(){this.setItem(this.Ai,this.Li.ui())},t.prototype.$i=function(t,e,n){var r=new Kr(this.currentUser,t,e,n),i=Br(this.persistenceKey,this.currentUser,t);this.setItem(i,r.ui())},t.prototype.Mi=function(t){var e=Br(this.persistenceKey,this.currentUser,t);this.removeItem(e)},t.prototype.Gi=function(t){var e={clientId:this._i,onlineState:t};this.storage.setItem(this.Vi,JSON.stringify(e))},t.prototype.Wi=function(t,e,n){var r=Wr(this.persistenceKey,t),i=new Qr(t,e,n);this.setItem(r,i.ui())},t.prototype.zi=function(t){var e=this.gi.exec(t);return e?e[1]:null},t.prototype.Yi=function(t,e){var n=this.zi(t);return Hr.ci(n,e)},t.prototype.Ji=function(t,e){var n=this.Pi.exec(t),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return Kr.ci(new jr(i),r,e)},t.prototype.Zi=function(t,e){var n=this.yi.exec(t),r=Number(n[1]);return Qr.ci(r,e)},t.prototype.vi=function(t){return Yr.ci(t)},t.prototype.Xi=function(t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return t.user.uid===this.currentUser.uid?[2,this.fi.er(t.batchId,t.state,t.error)]:(d("SharedClientState","Ignoring mutation for non-active user "+t.user.uid),[2])}))}))},t.prototype.tr=function(t){return this.fi.nr(t.targetId,t.state,t.error)},t.prototype.Hi=function(t,e){var n=this,r=e?this.Ti.ot(t,e):this.Ti.remove(t),i=this.Ni(this.Ti),o=this.Ni(r),s=[],u=[];return o.forEach((function(t){i.has(t)||s.push(t)})),i.forEach((function(t){o.has(t)||u.push(t)})),this.fi.sr(s,u).then((function(){n.Ti=r}))},t.prototype.Si=function(t){this.Ti.get(t.clientId)&&this.di(t.onlineState)},t.prototype.Ni=function(t){var e=Ct();return t.forEach((function(t,n){e=e.kt(n.activeTargetIds)})),e},t}(),Jr=function(){function t(){this.ir=new $r,this.rr={},this.di=null,this.si=null}return t.prototype.xi=function(t){},t.prototype.ki=function(t,e,n){},t.prototype.Oi=function(t){return this.ir.hi(t),this.rr[t]||"not-current"},t.prototype.Qi=function(t,e,n){this.rr[t]=e},t.prototype.Bi=function(t){this.ir.li(t)},t.prototype.qi=function(t){return this.ir.activeTargetIds.has(t)},t.prototype.Ui=function(t){delete this.rr[t]},t.prototype.Ci=function(){return this.ir.activeTargetIds},t.prototype.Fi=function(t){return this.ir.activeTargetIds.has(t)},t.prototype.start=function(){return this.ir=new $r,Promise.resolve()},t.prototype.ji=function(t,e,n){},t.prototype.Ki=function(t){},t.prototype.Di=function(){},t.prototype.oi=function(t){},t}(),Zr=function(){function t(t,e,n,r){this.batchId=t,this.ar=e,this.baseMutations=n,this.mutations=r}return t.prototype.cr=function(t,e,n){for(var r=n.ur,i=0;i<this.mutations.length;i++){var o=this.mutations[i];o.key.isEqual(t)&&(e=yn(o,e,r[i]))}return e},t.prototype.hr=function(t,e){for(var n=0,r=this.baseMutations;n<r.length;n++){var i=r[n];i.key.isEqual(t)&&(e=gn(i,e,e,this.ar))}for(var o=e,s=0,u=this.mutations;s<u.length;s++){var a=u[s];a.key.isEqual(t)&&(e=gn(a,e,o,this.ar))}return e},t.prototype.lr=function(t){var e=this,n=t;return this.mutations.forEach((function(r){var i=e.hr(r.key,t.get(r.key));i&&(n=n.ot(r.key,i))})),n},t.prototype.keys=function(){return this.mutations.reduce((function(t,e){return t.add(e.key)}),Vt())},t.prototype.isEqual=function(t){return this.batchId===t.batchId&&X(this.mutations,t.mutations,(function(t,e){return wn(t,e)}))&&X(this.baseMutations,t.baseMutations,(function(t,e){return wn(t,e)}))},t}(),ti=function(){function t(t,e,n,r){this.batch=t,this._r=e,this.ur=n,this.dr=r}return t.from=function(e,n,r){w(e.mutations.length===r.length);for(var i=Ot,o=e.mutations,s=0;s<o.length;s++)i=i.ot(o[s].key,r[s].version);return new t(e,n,r,i)},t}(),ei=function(){function t(){this.wr=new st((function(t){return t.toString()}),(function(t,e){return t.isEqual(e)})),this.mr=!1}return Object.defineProperty(t.prototype,"readTime",{get:function(){return this.Tr},set:function(t){this.Tr=t}
2,enumerable:!1,configurable:!0}),t.prototype.Er=function(t,e){this.Ir(),this.readTime=e,this.wr.set(t.key,t)},t.prototype.Ar=function(t,e){this.Ir(),e&&(this.readTime=e),this.wr.set(t,null)},t.prototype.Rr=function(t,e){this.Ir();var n=this.wr.get(e);return void 0!==n?mr.resolve(n):this.gr(t,e)},t.prototype.getEntries=function(t,e){return this.Pr(t,e)},t.prototype.apply=function(t){return this.Ir(),this.mr=!0,this.yr(t)},t.prototype.Ir=function(){},t}(),ni="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",ri=function(){function t(){this.Vr=[]}return t.prototype.pr=function(t){this.Vr.push(t)},t.prototype.br=function(){this.Vr.forEach((function(t){return t()}))},t}(),ii=function(){function t(t,e,n){this.vr=t,this.Sr=e,this.Dr=n}return t.prototype.Cr=function(t,e){var n=this;return this.Sr.Nr(t,e).next((function(r){return n.Fr(t,e,r)}))},t.prototype.Fr=function(t,e,n){return this.vr.Rr(t,e).next((function(t){for(var r=0,i=n;r<i.length;r++)t=i[r].hr(e,t);return t}))},t.prototype.$r=function(t,e,n){var r=Lt();return e.forEach((function(t,e){for(var i=0,o=n;i<o.length;i++)e=o[i].hr(t,e);r=r.ot(t,e)})),r},t.prototype.kr=function(t,e){var n=this;return this.vr.getEntries(t,e).next((function(e){return n.Mr(t,e)}))},t.prototype.Mr=function(t,e){var n=this;return this.Sr.Or(t,e).next((function(r){var i=n.$r(t,e,r),o=xt();return i.forEach((function(t,e){e||(e=new Pn(t,at.min())),o=o.ot(t,e)})),o}))},t.prototype.Lr=function(t,e,n){return function(t){return D.F(t.path)&&null===t.collectionGroup&&0===t.filters.length}(e)?this.Br(t,e.path):zn(e)?this.qr(t,e,n):this.Ur(t,e,n)},t.prototype.Br=function(t,e){return this.Cr(t,new D(e)).next((function(t){var e=Rt();return t instanceof On&&(e=e.ot(t.key,t)),e}))},t.prototype.qr=function(t,e,n){var r=this,i=e.collectionGroup,o=Rt();return this.Dr.Qr(t,i).next((function(s){return mr.forEach(s,(function(s){var u=function(t,e){return new Un(e,null,t.on.slice(),t.filters.slice(),t.limit,t.an,t.startAt,t.endAt)}(e,s.child(i));return r.Ur(t,u,n).next((function(t){t.forEach((function(t,e){o=o.ot(t,e)}))}))})).next((function(){return o}))}))},t.prototype.Ur=function(t,e,n){var r,i,o=this;return this.vr.Lr(t,e,n).next((function(n){return r=n,o.Sr.Wr(t,e)})).next((function(e){return i=e,o.jr(t,i,r).next((function(t){r=t;for(var e=0,n=i;e<n.length;e++)for(var o=n[e],s=0,u=o.mutations;s<u.length;s++){var a=u[s],c=a.key,h=r.get(c),f=gn(a,h,h,o.ar);r=f instanceof On?r.ot(c,f):r.remove(c)}}))})).next((function(){return r.forEach((function(t,n){Jn(e,n)||(r=r.remove(t))})),r}))},t.prototype.jr=function(t,e,n){for(var r=Vt(),i=0,o=e;i<o.length;i++)for(var s=0,u=o[i].mutations;s<u.length;s++){var a=u[s];a instanceof In&&null===n.get(a.key)&&(r=r.add(a.key))}var c=n;return this.vr.getEntries(t,r).next((function(t){return t.forEach((function(t,e){null!==e&&e instanceof On&&(c=c.ot(t,e))})),c}))},t}(),oi=function(){function t(t,e,n,r){this.targetId=t,this.fromCache=e,this.Kr=n,this.Gr=r}return t.zr=function(e,n){for(var r=Vt(),i=Vt(),o=0,s=n.docChanges;o<s.length;o++){var u=s[o];switch(u.type){case 0:r=r.add(u.doc.key);break;case 1:i=i.add(u.doc.key)}}return new t(e,n.fromCache,r,i)},t}();function si(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],s=$(n,i);return 0===s?$(r,o):s}var ui=function(){function t(t){this.Hr=t,this.buffer=new At(si),this.Yr=0}return t.prototype.Jr=function(){return++this.Yr},t.prototype.Xr=function(t){var e=[t,this.Jr()];if(this.buffer.size<this.Hr)this.buffer=this.buffer.add(e);else{var n=this.buffer.last();si(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(t.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!1,configurable:!0}),t}(),ai={Zr:!1,eo:0,no:0,so:0},ci=function(){function t(t,e,n){this.io=t,this.ro=e,this.oo=n}return t.ao=function(e){return new t(e,t.co,t.uo)},t}();ci.ho=-1,ci.lo=1048576,ci._o=41943040,ci.co=10,ci.uo=1e3,ci.fo=new ci(ci._o,ci.co,ci.uo),ci.do=new ci(ci.ho,0,0);var hi=function(){function t(t,e){this.wo=t,this.cs=e,this.mo=!1,this.To=null}return t.prototype.start=function(t){this.wo.params.io!==ci.ho&&this.Eo(t)},t.prototype.stop=function(){this.To&&(this.To.cancel(),this.To=null)},Object.defineProperty(t.prototype,"Ei",{get:function(){return null!==this.To}
2,enumerable:!1,configurable:!0}),t.prototype.Eo=function(t){var e=this,n=this.mo?3e5:6e4;d("LruGarbageCollector","Garbage collection scheduled in "+n+"ms"),this.To=this.cs.yn("lru_garbage_collection",n,(function(){return r.__awaiter(e,void 0,void 0,(function(){var e;return r.__generator(this,(function(n){switch(n.label){case 0:this.To=null,this.mo=!0,n.label=1;case 1:return n.trys.push([1,3,,7]),[4,t.Io(this.wo)];case 2:return n.sent(),[3,7];case 3:return Ir(e=n.sent())?(d("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e),[3,6]):[3,4];case 4:return[4,Lo(e)];case 5:n.sent(),n.label=6;case 6:return[3,7];case 7:return[4,this.Eo(t)];case 8:return n.sent(),[2]}}))}))}))},t}(),fi=function(){function t(t,e){this.Ao=t,this.params=e}return t.prototype.Ro=function(t,e){return this.Ao.Po(t).next((function(t){return Math.floor(e/100*t)}))},t.prototype.yo=function(t,e){var n=this;if(0===e)return mr.resolve(Gr.ai);var r=new ui(e);return this.Ao.Ce(t,(function(t){return r.Xr(t.sequenceNumber)})).next((function(){return n.Ao.Vo(t,(function(t){return r.Xr(t)}))})).next((function(){return r.maxValue}))},t.prototype.po=function(t,e,n){return this.Ao.po(t,e,n)},t.prototype.bo=function(t,e){return this.Ao.bo(t,e)},t.prototype.vo=function(t,e){var n=this;return this.params.io===ci.ho?(d("LruGarbageCollector","Garbage collection skipped; disabled"),mr.resolve(ai)):this.So(t).next((function(r){return r<n.params.io?(d("LruGarbageCollector","Garbage collection skipped; Cache size "+r+" is lower than threshold "+n.params.io),ai):n.Do(t,e)}))},t.prototype.So=function(t){return this.Ao.So(t)},t.prototype.Do=function(t,e){var n,r,i,s,u,a,c,h=this,f=Date.now();return this.Ro(t,this.params.ro).next((function(e){return e>h.params.oo?(d("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+h.params.oo+" from "+e),r=h.params.oo):r=e,s=Date.now(),h.yo(t,r)})).next((function(r){return n=r,u=Date.now(),h.po(t,n,e)})).next((function(e){return i=e,a=Date.now(),h.bo(t,n)})).next((function(t){return c=Date.now(),p()<=o.LogLevel.DEBUG&&d("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(s-f)+"ms\n\tDetermined least recently used "+r+" in "+(u-s)+"ms\n\tRemoved "+i+" targets in "+(a-u)+"ms\n\tRemoved "+t+" documents in "+(c-a)+"ms\nTotal Duration: "+(c-f)+"ms"),mr.resolve({Zr:!0,eo:r,no:i,so:t})}))},t}();function li(t){for(var e="",n=0;n<t.length;n++)e.length>0&&(e=di(e)),e=pi(t.get(n),e);return di(e)}function pi(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+="��";break;case"�":n+="��";break;default:n+=o}}return n}function di(t){return t+"��"}function vi(t){var e=t.length;if(w(e>=2),2===e)return w("�"===t.charAt(0)&&"�"===t.charAt(1)),N.P();for(var n=e-2,r=[],i="",o=0;o<e;){var s=t.indexOf("�",o);switch((s<0||s>n)&&m(),t.charAt(s+1)){case"�":var u=t.substring(o,s),a=void 0;0===i.length?a=u:(a=i+=u,i=""),r.push(a);break;case"�":i+=t.substring(o,s),i+="\0";break;case"�":i+=t.substring(o,s+1);break;default:m()}o=s+2}return new N(r)}var yi=function(t){this.Co=t};function gi(t,e){if(e.document)return function(t,e,n){var r=xe(t,e.name),i=Ne(e.updateTime),o=new xn({mapValue:{fields:e.fields}});return new On(r,i,o,{hasCommittedMutations:!!n})}(t.Co,e.document,!!e.hasCommittedMutations);if(e.noDocument){var n=D.$(e.noDocument.path),r=Ii(e.noDocument.readTime);return new Pn(n,r,{hasCommittedMutations:!!e.hasCommittedMutations})}if(e.unknownDocument){var i=D.$(e.unknownDocument.path),o=Ii(e.unknownDocument.version);return new Vn(i,o)}return m()}function mi(t,e,n){var r=wi(n),i=e.key.path.h().A();if(e instanceof On){var o=function(t,e){return{name:De(t,e.key),fields:e.rn().mapValue.fields,updateTime:Ie(t,e.version.Z())}}(t.Co,e),s=e.hasCommittedMutations;return new Hi(null,null,o,s,r,i)}if(e instanceof Pn){var u=e.key.path.A(),a=bi(e.version),c=e.hasCommittedMutations;return new Hi(null,new Ki(u,a),null,c,r,i)}if(e instanceof Vn){var h=e.key.path.A(),f=bi(e.version);return new Hi(new Qi(h,f),null,null,!0,r,i)}return m()}function wi(t){var e=t.Z();return[e.seconds,e.nanoseconds]}function _i(t){var e=new ut(t[0],t[1]);return at.J(e)}function bi(t){var e=t.Z();return new ji(e.seconds,e.nanoseconds)}
2function Ii(t){var e=new ut(t.seconds,t.nanoseconds);return at.J(e)}function Ei(t,e){var n=(e.baseMutations||[]).map((function(e){return Ue(t.Co,e)})),r=e.mutations.map((function(e){return Ue(t.Co,e)})),i=ut.fromMillis(e.localWriteTimeMs);return new Zr(e.batchId,i,n,r)}function Ti(t){var e,n,r=Ii(t.readTime),i=void 0!==t.lastLimboFreeSnapshotVersion?Ii(t.lastLimboFreeSnapshotVersion):at.min();return void 0!==t.query.documents?(w(1===(n=t.query).documents.length),e=Wn(Fn(ke(n.documents[0])))):e=Me(t.query),new wt(e,t.targetId,0,t.lastListenSequenceNumber,r,i,Z.fromBase64String(t.resumeToken))}function Ni(t,e){var n,r=bi(e.nt),i=bi(e.lastLimboFreeSnapshotVersion);n=yt(e.target)?Ce(t.Co,e.target):Fe(t.Co,e.target);var o=e.resumeToken.toBase64();return new $i(e.targetId,dt(e.target),r,o,e.sequenceNumber,i,n)}var Ai=function(){function t(t,e,n,r){this.userId=t,this.serializer=e,this.Dr=n,this.No=r,this.Fo={}}return t.xo=function(e,n,r,i){return w(""!==e.uid),new t(e.Zs()?e.uid:"",n,r,i)},t.prototype.$o=function(t){var e=!0,n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return xi(t).rs({index:Bi.userMutationsIndex,range:n},(function(t,n,r){e=!1,r.done()})).next((function(){return e}))},t.prototype.ko=function(t,e,n,r){var i=this,o=Li(t),s=xi(t);return s.add({}).next((function(u){w("number"==typeof u);for(var a=new Zr(u,e,n,r),c=function(t,e,n){var r=n.baseMutations.map((function(e){return Ve(t.Co,e)})),i=n.mutations.map((function(e){return Ve(t.Co,e)}));return new Bi(e,n.batchId,n.ar.toMillis(),r,i)}(i.serializer,i.userId,a),h=[],f=new At((function(t,e){return $(t.R(),e.R())})),l=0,p=r;l<p.length;l++){var d=p[l],v=Wi.key(i.userId,d.key.path,u);f=f.add(d.key.path.h()),h.push(s.put(c)),h.push(o.put(v,Wi.PLACEHOLDER))}return f.forEach((function(e){h.push(i.Dr.Mo(t,e))})),t.pr((function(){i.Fo[u]=a.keys()})),mr.$n(h).next((function(){return a}))}))},t.prototype.Oo=function(t,e){var n=this;return xi(t).get(e).next((function(t){return t?(w(t.userId===n.userId),Ei(n.serializer,t)):null}))},t.prototype.Lo=function(t,e){var n=this;return this.Fo[e]?mr.resolve(this.Fo[e]):this.Oo(t,e).next((function(t){if(t){var r=t.keys();return n.Fo[e]=r,r}return null}))},t.prototype.Bo=function(t,e){var n=this,r=e+1,i=IDBKeyRange.lowerBound([this.userId,r]),o=null;return xi(t).rs({index:Bi.userMutationsIndex,range:i},(function(t,e,i){e.userId===n.userId&&(w(e.batchId>=r),o=Ei(n.serializer,e)),i.done()})).next((function(){return o}))},t.prototype.qo=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),n=-1;return xi(t).rs({index:Bi.userMutationsIndex,range:e,reverse:!0},(function(t,e,r){n=e.batchId,r.done()})).next((function(){return n}))},t.prototype.Uo=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return xi(t).ts(Bi.userMutationsIndex,n).next((function(t){return t.map((function(t){return Ei(e.serializer,t)}))}))},t.prototype.Nr=function(t,e){var n=this,r=Wi.prefixForPath(this.userId,e.path),i=IDBKeyRange.lowerBound(r),o=[];return Li(t).rs({range:i},(function(r,i,s){var u=r[0],a=r[1],c=r[2],h=vi(a);if(u===n.userId&&e.path.isEqual(h))return xi(t).get(c).next((function(t){if(!t)throw m();w(t.userId===n.userId),o.push(Ei(n.serializer,t))}));s.done()})).next((function(){return o}))},t.prototype.Or=function(t,e){var n=this,r=new At($),i=[];return e.forEach((function(e){var o=Wi.prefixForPath(n.userId,e.path),s=IDBKeyRange.lowerBound(o),u=Li(t).rs({range:s},(function(t,i,o){var s=t[0],u=t[1],a=t[2],c=vi(u);s===n.userId&&e.path.isEqual(c)?r=r.add(a):o.done()}));i.push(u)})),mr.$n(i).next((function(){return n.Qo(t,r)}))},t.prototype.Wr=function(t,e){var n=this,r=e.path,i=r.length+1,o=Wi.prefixForPath(this.userId,r),s=IDBKeyRange.lowerBound(o),u=new At($);return Li(t).rs({range:s},(function(t,e,o){var s=t[0],a=t[1],c=t[2],h=vi(a);s===n.userId&&r.T(h)?h.length===i&&(u=u.add(c)):o.done()})).next((function(){return n.Qo(t,u)}))},t.prototype.Qo=function(t,e){var n=this,r=[],i=[];return e.forEach((function(e){i.push(xi(t).get(e).next((function(t){if(null===t)throw m();w(t.userId===n.userId),r.push(Ei(n.serializer,t))})))})),mr.$n(i).next((function(){return r}))},t.prototype.Wo=function(t,e){var n=this;return Di(t.jo,this.userId,e).next((function(r){return t.pr((function(){n.Ko(e.batchId)})),mr.forEach(r,(function(e){return n.No.Go(t,e)}))}
2))},t.prototype.Ko=function(t){delete this.Fo[t]},t.prototype.zo=function(t){var e=this;return this.$o(t).next((function(n){if(!n)return mr.resolve();var r=IDBKeyRange.lowerBound(Wi.prefixForUser(e.userId)),i=[];return Li(t).rs({range:r},(function(t,n,r){if(t[0]===e.userId){var o=vi(t[1]);i.push(o)}else r.done()})).next((function(){w(0===i.length)}))}))},t.prototype.Ho=function(t,e){return Si(t,this.userId,e)},t.prototype.Yo=function(t){var e=this;return ki(t).get(this.userId).next((function(t){return t||new zi(e.userId,-1,"")}))},t}();function Si(t,e,n){var r=Wi.prefixForPath(e,n.path),i=r[1],o=IDBKeyRange.lowerBound(r),s=!1;return Li(t).rs({range:o,ss:!0},(function(t,n,r){var o=t[0],u=t[1];t[2],o===e&&u===i&&(s=!0),r.done()})).next((function(){return s}))}function Di(t,e,n){var r=t.store(Bi.store),i=t.store(Wi.store),o=[],s=IDBKeyRange.only(n.batchId),u=0,a=r.rs({range:s},(function(t,e,n){return u++,n.delete()}));o.push(a.next((function(){w(1===u)})));for(var c=[],h=0,f=n.mutations;h<f.length;h++){var l=f[h],p=Wi.key(e,l.key.path,n.batchId);o.push(i.delete(p)),c.push(l.key)}return mr.$n(o).next((function(){return c}))}function xi(t){return lo.Qn(t,Bi.store)}function Li(t){return lo.Qn(t,Wi.store)}function ki(t){return lo.Qn(t,zi.store)}var Ri=function(){function t(t,e){this.serializer=t,this.Dr=e}return t.prototype.Er=function(t,e,n){return Vi(t).put(Ui(e),n)},t.prototype.Ar=function(t,e){var n=Vi(t),r=Ui(e);return n.delete(r)},t.prototype.updateMetadata=function(t,e){var n=this;return this.getMetadata(t).next((function(r){return r.byteSize+=e,n.Jo(t,r)}))},t.prototype.Rr=function(t,e){var n=this;return Vi(t).get(Ui(e)).next((function(t){return n.Xo(t)}))},t.prototype.Zo=function(t,e){var n=this;return Vi(t).get(Ui(e)).next((function(t){var e=n.Xo(t);return e?{ta:e,size:Ci(t)}:null}))},t.prototype.getEntries=function(t,e){var n=this,r=Lt();return this.ea(t,e,(function(t,e){var i=n.Xo(e);r=r.ot(t,i)})).next((function(){return r}))},t.prototype.na=function(t,e){var n=this,r=Lt(),i=new Et(D.i);return this.ea(t,e,(function(t,e){var o=n.Xo(e);o?(r=r.ot(t,o),i=i.ot(t,Ci(e))):(r=r.ot(t,null),i=i.ot(t,0))})).next((function(){return{sa:r,ia:i}}))},t.prototype.ea=function(t,e,n){if(e.m())return mr.resolve();var r=IDBKeyRange.bound(e.first().path.A(),e.last().path.A()),i=e._t(),o=i.It();return Vi(t).rs({range:r},(function(t,e,r){for(var s=D.$(t);o&&D.i(o,s)<0;)n(o,null),o=i.It();o&&o.isEqual(s)&&(n(o,e),o=i.At()?i.It():null),o?r.Xn(o.path.A()):r.done()})).next((function(){for(;o;)n(o,null),o=i.At()?i.It():null}))},t.prototype.Lr=function(t,e,n){var r=this,i=Rt(),o=e.path.length+1,s={};if(n.isEqual(at.min())){var u=e.path.A();s.range=IDBKeyRange.lowerBound(u)}else{var a=e.path.A(),c=wi(n);s.range=IDBKeyRange.lowerBound([a,c],!0),s.index=Hi.collectionReadTimeIndex}return Vi(t).rs(s,(function(t,n,s){if(t.length===o){var u=gi(r.serializer,n);e.path.T(u.key.path)?u instanceof On&&Jn(e,u)&&(i=i.ot(u.key,u)):s.done()}})).next((function(){return i}))},t.prototype.ra=function(t){return new Oi(this,!!t&&t.oa)},t.prototype.aa=function(t){return this.getMetadata(t).next((function(t){return t.byteSize}))},t.prototype.getMetadata=function(t){return Pi(t).get(Yi.key).next((function(t){return w(!!t),t}))},t.prototype.Jo=function(t,e){return Pi(t).put(Yi.key,e)},t.prototype.Xo=function(t){if(t){var e=gi(this.serializer,t);return e instanceof Pn&&e.version.isEqual(at.min())?null:e}return null},t}(),Oi=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).ca=e,r.oa=n,r.ua=new st((function(t){return t.toString()}),(function(t,e){return t.isEqual(e)})),r}return r.__extends(e,t),e.prototype.yr=function(t){var e=this,n=[],r=0,i=new At((function(t,e){return $(t.R(),e.R())}));return this.wr.forEach((function(o,s){var u=e.ua.get(o);if(s){var a=mi(e.ca.serializer,s,e.readTime);i=i.add(o.path.h());var c=Ci(a);r+=c-u,n.push(e.ca.Er(t,o,a))}else if(r-=u,e.oa){var h=mi(e.ca.serializer,new Pn(o,at.min()),e.readTime);n.push(e.ca.Er(t,o,h))}else n.push(e.ca.Ar(t,o))})),i.forEach((function(r){n.push(e.ca.Dr.Mo(t,r))})),n.push(this.ca.updateMetadata(t,r)),mr.$n(n)},e.prototype.gr=function(t,e){var n=this;return this.ca.Zo(t,e).next((function(t){return null===t?(n.ua.set(e,0),null):(n.ua.set(e,t.size),t.ta)}))},e.prototype.Pr=function(t,e){var n=this;return this.ca.na(t,e).next((function(t){var e=t.sa;
2return t.ia.forEach((function(t,e){n.ua.set(t,e)})),e}))},e}(ei);function Pi(t){return lo.Qn(t,Yi.store)}function Vi(t){return lo.Qn(t,Hi.store)}function Ui(t){return t.path.A()}function Ci(t){var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw m();e=t.noDocument}return JSON.stringify(e).length}var Fi=function(){function t(){this.ha=new Mi}return t.prototype.Mo=function(t,e){return this.ha.add(e),mr.resolve()},t.prototype.Qr=function(t,e){return mr.resolve(this.ha.getEntries(e))},t}(),Mi=function(){function t(){this.index={}}return t.prototype.add=function(t){var e=t._(),n=t.h(),r=this.index[e]||new At(N.i),i=!r.has(n);return this.index[e]=r.add(n),i},t.prototype.has=function(t){var e=t._(),n=t.h(),r=this.index[e];return r&&r.has(n)},t.prototype.getEntries=function(t){return(this.index[t]||new At(N.i)).A()},t}(),qi=function(){function t(t){this.serializer=t}return t.prototype.createOrUpgrade=function(t,e,n,r){var i=this;w(n<r&&n>=0&&r<=10);var o=new Er("createOrUpgrade",e);n<1&&r>=1&&(function(t){t.createObjectStore(Gi.store)}(t),function(t){t.createObjectStore(zi.store,{keyPath:zi.keyPath}),t.createObjectStore(Bi.store,{keyPath:Bi.keyPath,autoIncrement:!0}).createIndex(Bi.userMutationsIndex,Bi.userMutationsKeyPath,{unique:!0}),t.createObjectStore(Wi.store)}(t),to(t),function(t){t.createObjectStore(Hi.store)}(t));var s=mr.resolve();return n<3&&r>=3&&(0!==n&&(function(t){t.deleteObjectStore(Xi.store),t.deleteObjectStore($i.store),t.deleteObjectStore(Ji.store)}(t),to(t)),s=s.next((function(){return function(t){var e=t.store(Ji.store),n=new Ji(0,0,at.min().Z(),0);return e.put(Ji.key,n)}(o)}))),n<4&&r>=4&&(0!==n&&(s=s.next((function(){return function(t,e){return e.store(Bi.store).ts().next((function(n){t.deleteObjectStore(Bi.store),t.createObjectStore(Bi.store,{keyPath:Bi.keyPath,autoIncrement:!0}).createIndex(Bi.userMutationsIndex,Bi.userMutationsKeyPath,{unique:!0});var r=e.store(Bi.store),i=n.map((function(t){return r.put(t)}));return mr.$n(i)}))}(t,o)}))),s=s.next((function(){!function(t){t.createObjectStore(eo.store,{keyPath:eo.keyPath})}(t)}))),n<5&&r>=5&&(s=s.next((function(){return i.removeAcknowledgedMutations(o)}))),n<6&&r>=6&&(s=s.next((function(){return function(t){t.createObjectStore(Yi.store)}(t),i.addDocumentGlobal(o)}))),n<7&&r>=7&&(s=s.next((function(){return i.ensureSequenceNumbers(o)}))),n<8&&r>=8&&(s=s.next((function(){return i.createCollectionParentIndex(t,o)}))),n<9&&r>=9&&(s=s.next((function(){!function(t){t.objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges")}(t),function(t){var e=t.objectStore(Hi.store);e.createIndex(Hi.readTimeIndex,Hi.readTimeIndexPath,{unique:!1}),e.createIndex(Hi.collectionReadTimeIndex,Hi.collectionReadTimeIndexPath,{unique:!1})}(e)}))),n<10&&r>=10&&(s=s.next((function(){return i.rewriteCanonicalIds(o)}))),s},t.prototype.addDocumentGlobal=function(t){var e=0;return t.store(Hi.store).rs((function(t,n){e+=Ci(n)})).next((function(){var n=new Yi(e);return t.store(Yi.store).put(Yi.key,n)}))},t.prototype.removeAcknowledgedMutations=function(t){var e=this,n=t.store(zi.store),r=t.store(Bi.store);return n.ts().next((function(n){return mr.forEach(n,(function(n){var i=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return r.ts(Bi.userMutationsIndex,i).next((function(r){return mr.forEach(r,(function(r){w(r.userId===n.userId);var i=Ei(e.serializer,r);return Di(t,n.userId,i).next((function(){}))}))}))}))}))},t.prototype.ensureSequenceNumbers=function(t){var e=t.store(Xi.store),n=t.store(Hi.store);return t.store(Ji.store).get(Ji.key).next((function(t){var r=[];return n.rs((function(n,i){var o=new N(n),s=function(t){return[0,li(t)]}(o);r.push(e.get(s).next((function(n){return n?mr.resolve():function(n){return e.put(new Xi(0,li(n),t.highestListenSequenceNumber))}(o)})))})).next((function(){return mr.$n(r)}))}
2))},t.prototype.createCollectionParentIndex=function(t,e){t.createObjectStore(Zi.store,{keyPath:Zi.keyPath});var n=e.store(Zi.store),r=new Mi,i=function(t){if(r.add(t)){var e=t._(),i=t.h();return n.put({collectionId:e,parent:li(i)})}};return e.store(Hi.store).rs({ss:!0},(function(t,e){var n=new N(t);return i(n.h())})).next((function(){return e.store(Wi.store).rs({ss:!0},(function(t,e){t[0];var n=t[1],r=(t[2],vi(n));return i(r.h())}))}))},t.prototype.rewriteCanonicalIds=function(t){var e=this,n=t.store($i.store);return n.rs((function(t,r){var i=Ti(r),o=Ni(e.serializer,i);return n.put(o)}))},t}(),ji=function(t,e){this.seconds=t,this.nanoseconds=e},Gi=function(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n};Gi.store="owner",Gi.key="owner";var zi=function(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n};zi.store="mutationQueues",zi.keyPath="userId";var Bi=function(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i};Bi.store="mutations",Bi.keyPath="batchId",Bi.userMutationsIndex="userMutationsIndex",Bi.userMutationsKeyPath=["userId","batchId"];var Wi=function(){function t(){}return t.prefixForUser=function(t){return[t]},t.prefixForPath=function(t,e){return[t,li(e)]},t.key=function(t,e,n){return[t,li(e),n]},t}();Wi.store="documentMutations",Wi.PLACEHOLDER=new Wi;var Ki=function(t,e){this.path=t,this.readTime=e},Qi=function(t,e){this.path=t,this.version=e},Hi=function(t,e,n,r,i,o){this.unknownDocument=t,this.noDocument=e,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=o};Hi.store="remoteDocuments",Hi.readTimeIndex="readTimeIndex",Hi.readTimeIndexPath="readTime",Hi.collectionReadTimeIndex="collectionReadTimeIndex",Hi.collectionReadTimeIndexPath=["parentPath","readTime"];var Yi=function(t){this.byteSize=t};Yi.store="remoteDocumentGlobal",Yi.key="remoteDocumentGlobalKey";var $i=function(t,e,n,r,i,o,s){this.targetId=t,this.canonicalId=e,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=o,this.query=s};$i.store="targets",$i.keyPath="targetId",$i.queryTargetsIndexName="queryTargetsIndex",$i.queryTargetsKeyPath=["canonicalId","targetId"];var Xi=function(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n};Xi.store="targetDocuments",Xi.keyPath=["targetId","path"],Xi.documentTargetsIndex="documentTargetsIndex",Xi.documentTargetsKeyPath=["path","targetId"];var Ji=function(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r};Ji.key="targetGlobalKey",Ji.store="targetGlobal";var Zi=function(t,e){this.collectionId=t,this.parent=e};function to(t){t.createObjectStore(Xi.store,{keyPath:Xi.keyPath}).createIndex(Xi.documentTargetsIndex,Xi.documentTargetsKeyPath,{unique:!0}),t.createObjectStore($i.store,{keyPath:$i.keyPath}).createIndex($i.queryTargetsIndexName,$i.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(Ji.store)}Zi.store="collectionParents",Zi.keyPath=["collectionId","parent"];var eo=function(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r};eo.store="clientMetadata",eo.keyPath="clientId";var no=r.__spreadArrays(r.__spreadArrays(r.__spreadArrays([zi.store,Bi.store,Wi.store,Hi.store,$i.store,Gi.store,Ji.store,Xi.store],[eo.store]),[Yi.store]),[Zi.store]),ro=function(){function t(){this.la=new Mi}return t.prototype.Mo=function(t,e){var n=this;if(!this.la.has(e)){var r=e._(),i=e.h();t.pr((function(){n.la.add(e)}));var o={collectionId:r,parent:li(i)};return io(t).put(o)}return mr.resolve()},t.prototype.Qr=function(t,e){var n=[],r=IDBKeyRange.bound([e,""],[J(e),""],!1,!0);return io(t).ts(r).next((function(t){for(var r=0,i=t;r<i.length;r++){var o=i[r];if(o.collectionId!==e)break;n.push(vi(o.parent))}return n}))},t}();function io(t){return lo.Qn(t,Zi.store)}var oo=function(){function t(t){this._a=t}return t.prototype.next=function(){return this._a+=2,this._a},t.fa=function(){return new t(0)},t.da=function(){return new t(-1)},t}
2(),so=function(){function t(t,e){this.No=t,this.serializer=e}return t.prototype.wa=function(t){var e=this;return this.ma(t).next((function(n){var r=new oo(n.highestTargetId);return n.highestTargetId=r.next(),e.Ta(t,n).next((function(){return n.highestTargetId}))}))},t.prototype.Ea=function(t){return this.ma(t).next((function(t){return at.J(new ut(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))}))},t.prototype.Ia=function(t){return this.ma(t).next((function(t){return t.highestListenSequenceNumber}))},t.prototype.Aa=function(t,e,n){var r=this;return this.ma(t).next((function(i){return i.highestListenSequenceNumber=e,n&&(i.lastRemoteSnapshotVersion=n.Z()),e>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=e),r.Ta(t,i)}))},t.prototype.Ra=function(t,e){var n=this;return this.ga(t,e).next((function(){return n.ma(t).next((function(r){return r.targetCount+=1,n.Pa(e,r),n.Ta(t,r)}))}))},t.prototype.ya=function(t,e){return this.ga(t,e)},t.prototype.Va=function(t,e){var n=this;return this.pa(t,e.targetId).next((function(){return uo(t).delete(e.targetId)})).next((function(){return n.ma(t)})).next((function(e){return w(e.targetCount>0),e.targetCount-=1,n.Ta(t,e)}))},t.prototype.po=function(t,e,n){var r=this,i=0,o=[];return uo(t).rs((function(s,u){var a=Ti(u);a.sequenceNumber<=e&&null===n.get(a.targetId)&&(i++,o.push(r.Va(t,a)))})).next((function(){return mr.$n(o)})).next((function(){return i}))},t.prototype.Ce=function(t,e){return uo(t).rs((function(t,n){var r=Ti(n);e(r)}))},t.prototype.ma=function(t){return ao(t).get(Ji.key).next((function(t){return w(null!==t),t}))},t.prototype.Ta=function(t,e){return ao(t).put(Ji.key,e)},t.prototype.ga=function(t,e){return uo(t).put(Ni(this.serializer,e))},t.prototype.Pa=function(t,e){var n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n},t.prototype.ba=function(t){return this.ma(t).next((function(t){return t.targetCount}))},t.prototype.va=function(t,e){var n=dt(e),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]),i=null;return uo(t).rs({range:r,index:$i.queryTargetsIndexName},(function(t,n,r){var o=Ti(n);vt(e,o.target)&&(i=o,r.done())})).next((function(){return i}))},t.prototype.Sa=function(t,e,n){var r=this,i=[],o=co(t);return e.forEach((function(e){var s=li(e.path);i.push(o.put(new Xi(n,s))),i.push(r.No.Da(t,n,e))})),mr.$n(i)},t.prototype.Ca=function(t,e,n){var r=this,i=co(t);return mr.forEach(e,(function(e){var o=li(e.path);return mr.$n([i.delete([n,o]),r.No.Na(t,n,e)])}))},t.prototype.pa=function(t,e){var n=co(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},t.prototype.Fa=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=co(t),i=Vt();return r.rs({range:n,ss:!0},(function(t,e,n){var r=vi(t[1]),o=new D(r);i=i.add(o)})).next((function(){return i}))},t.prototype.Ho=function(t,e){var n=li(e.path),r=IDBKeyRange.bound([n],[J(n)],!1,!0),i=0;return co(t).rs({index:Xi.documentTargetsIndex,ss:!0,range:r},(function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())})).next((function(){return i>0}))},t.prototype.Ue=function(t,e){return uo(t).get(e).next((function(t){return t?Ti(t):null}))},t}();function uo(t){return lo.Qn(t,$i.store)}function ao(t){return lo.Qn(t,Ji.store)}function co(t){return lo.Qn(t,Xi.store)}var ho="Failed to obtain exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",fo=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).jo=e,r.xa=n,r}return r.__extends(e,t),e}(ri),lo=function(){function t(e,n,r,i,o,s,u,a,c,l){if(this.allowTabSynchronization=e,this.persistenceKey=n,this.clientId=r,this.fn=o,this.window=s,this.document=u,this.$a=c,this.ka=l,this.Ma=null,this.Oa=!1,this.isPrimary=!1,this.networkEnabled=!0,this.La=null,this.inForeground=!1,this.Ba=null,this.qa=null,this.Ua=Number.NEGATIVE_INFINITY,this.Qa=function(t){return Promise.resolve()}
2,!t.Ln())throw new f(h.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.No=new yo(this,i),this.Wa=n+"main",this.serializer=new yi(a),this.ja=new wr(this.Wa,10,new qi(this.serializer)),this.Ka=new so(this.No,this.serializer),this.Dr=new ro,this.vr=function(t,e){return new Ri(t,e)}(this.serializer,this.Dr),this.window&&this.window.localStorage?this.Ga=this.window.localStorage:(this.Ga=null,!1===l&&v("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}return t.Qn=function(t,e){if(t instanceof fo)return wr.Qn(t.jo,e);throw m()},t.prototype.start=function(){var t=this;return this.za().then((function(){if(!t.isPrimary&&!t.allowTabSynchronization)throw new f(h.FAILED_PRECONDITION,ho);return t.Ha(),t.Ya(),t.Ja(),t.runTransaction("getHighestListenSequenceNumber","readonly",(function(e){return t.Ka.Ia(e)}))})).then((function(e){t.Ma=new Gr(e,t.$a)})).then((function(){t.Oa=!0})).catch((function(e){return t.ja&&t.ja.close(),Promise.reject(e)}))},t.prototype.Xa=function(t){var e=this;return this.Qa=function(n){return r.__awaiter(e,void 0,void 0,(function(){return r.__generator(this,(function(e){return this.Ei?[2,t(n)]:[2]}))}))},t(this.isPrimary)},t.prototype.Za=function(t){var e=this;this.ja.Kn((function(n){return r.__awaiter(e,void 0,void 0,(function(){return r.__generator(this,(function(e){switch(e.label){case 0:return null===n.newVersion?[4,t()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}
2))}))}))},t.prototype.tc=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.fn.ws((function(){return r.__awaiter(e,void 0,void 0,(function(){return r.__generator(this,(function(t){switch(t.label){case 0:return this.Ei?[4,this.za()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))})))},t.prototype.za=function(){var t=this;return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(function(e){return vo(e).put(new eo(t.clientId,Date.now(),t.networkEnabled,t.inForeground)).next((function(){if(t.isPrimary)return t.ec(e).next((function(e){e||(t.isPrimary=!1,t.fn.Cs((function(){return t.Qa(!1)})))}))})).next((function(){return t.nc(e)})).next((function(n){return t.isPrimary&&!n?t.sc(e).next((function(){return!1})):!!n&&t.ic(e).next((function(){return!0}))}))})).catch((function(e){if(Ir(e))return d("IndexedDbPersistence","Failed to extend owner lease: ",e),t.isPrimary;if(!t.allowTabSynchronization)throw e;return d("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1})).then((function(e){t.isPrimary!==e&&t.fn.Cs((function(){return t.Qa(e)})),t.isPrimary=e}))},t.prototype.ec=function(t){var e=this;return po(t).get(Gi.key).next((function(t){return mr.resolve(e.rc(t))}))},t.prototype.oc=function(t){return vo(t).delete(this.clientId)},t.prototype.ac=function(){return r.__awaiter(this,void 0,void 0,(function(){var e,n,i,o,s=this;return r.__generator(this,(function(r){switch(r.label){case 0:return!this.isPrimary||this.cc(this.Ua,18e5)?[3,2]:(this.Ua=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(function(e){var n=t.Qn(e,eo.store);return n.ts().next((function(t){var e=s.uc(t,18e5),r=t.filter((function(t){return-1===e.indexOf(t)}));return mr.forEach(r,(function(t){return n.delete(t.clientId)})).next((function(){return r}))}))})).catch((function(){return[]}))]);case 1:if(e=r.sent(),this.Ga)for(n=0,i=e;n<i.length;n++)o=i[n],this.Ga.removeItem(this.hc(o.clientId));r.label=2;case 2:return[2]}}
2))}))},t.prototype.Ja=function(){var t=this;this.qa=this.fn.yn("client_metadata_refresh",4e3,(function(){return t.za().then((function(){return t.ac()})).then((function(){return t.Ja()}))}))},t.prototype.rc=function(t){return!!t&&t.ownerId===this.clientId},t.prototype.nc=function(t){var e=this;return this.ka?mr.resolve(!0):po(t).get(Gi.key).next((function(n){if(null!==n&&e.cc(n.leaseTimestampMs,5e3)&&!e.lc(n.ownerId)){if(e.rc(n)&&e.networkEnabled)return!0;if(!e.rc(n)){if(!n.allowTabSynchronization)throw new f(h.FAILED_PRECONDITION,ho);return!1}}return!(!e.networkEnabled||!e.inForeground)||vo(t).ts().next((function(t){return void 0===e.uc(t,5e3).find((function(t){if(e.clientId!==t.clientId){var n=!e.networkEnabled&&t.networkEnabled,r=!e.inForeground&&t.inForeground,i=e.networkEnabled===t.networkEnabled;if(n||r&&i)return!0}return!1}))}))})).next((function(t){return e.isPrimary!==t&&d("IndexedDbPersistence","Client "+(t?"is":"is not")+" eligible for a primary lease."),t}))},t.prototype.Di=function(){return r.__awaiter(this,void 0,void 0,(function(){var t=this;return r.__generator(this,(function(e){switch(e.label){case 0:return this.Oa=!1,this._c(),this.qa&&(this.qa.cancel(),this.qa=null),this.fc(),this.dc(),[4,this.ja.runTransaction("shutdown","readwrite",[Gi.store,eo.store],(function(e){var n=new fo(e,Gr.ai);return t.sc(n).next((function(){return t.oc(n)}))}))];case 1:return e.sent(),this.ja.close(),this.wc(),[2]}}))}))},t.prototype.uc=function(t,e){var n=this;return t.filter((function(t){return n.cc(t.updateTimeMs,e)&&!n.lc(t.clientId)}))},t.prototype.pi=function(){var t=this;return this.runTransaction("getActiveClients","readonly",(function(e){return vo(e).ts().next((function(e){return t.uc(e,18e5).map((function(t){return t.clientId}))}))}))},Object.defineProperty(t.prototype,"Ei",{get:function(){return this.Oa},enumerable:!1,configurable:!0}),t.prototype.mc=function(t){return Ai.xo(t,this.serializer,this.Dr,this.No)},t.prototype.Tc=function(){return this.Ka},t.prototype.Ec=function(){return this.vr},t.prototype.Ic=function(){return this.Dr},t.prototype.runTransaction=function(t,e,n){var r=this;d("IndexedDbPersistence","Starting transaction:",t);var i,o="readonly"===e?"readonly":"readwrite";return this.ja.runTransaction(t,o,no,(function(o){return i=new fo(o,r.Ma?r.Ma.next():Gr.ai),"readwrite-primary"===e?r.ec(i).next((function(t){return!!t||r.nc(i)})).next((function(e){if(!e)throw v("Failed to obtain primary lease for action '"+t+"'."),r.isPrimary=!1,r.fn.Cs((function(){return r.Qa(!1)})),new f(h.FAILED_PRECONDITION,ni);return n(i)})).next((function(t){return r.ic(i).next((function(){return t}))})):r.Ac(i).next((function(){return n(i)}))})).then((function(t){return i.br(),t}))},t.prototype.Ac=function(t){var e=this;return po(t).get(Gi.key).next((function(t){if(null!==t&&e.cc(t.leaseTimestampMs,5e3)&&!e.lc(t.ownerId)&&!e.rc(t)&&!(e.ka||e.allowTabSynchronization&&t.allowTabSynchronization))throw new f(h.FAILED_PRECONDITION,ho)}))},t.prototype.ic=function(t){var e=new Gi(this.clientId,this.allowTabSynchronization,Date.now());return po(t).put(Gi.key,e)},t.Ln=function(){return wr.Ln()},t.prototype.sc=function(t){var e=this,n=po(t);return n.get(Gi.key).next((function(t){return e.rc(t)?(d("IndexedDbPersistence","Releasing primary lease."),n.delete(Gi.key)):mr.resolve()}))},t.prototype.cc=function(t,e){var n=Date.now();return!(t<n-e||t>n&&(v("Detected an update time that is in the future: "+t+" > "+n),1))},t.prototype.Ha=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Ba=function(){t.fn.ws((function(){return t.inForeground="visible"===t.document.visibilityState,t.za()}))},this.document.addEventListener("visibilitychange",this.Ba),this.inForeground="visible"===this.document.visibilityState)},t.prototype.fc=function(){this.Ba&&(this.document.removeEventListener("visibilitychange",this.Ba),this.Ba=null)},t.prototype.Ya=function(){var t,e=this;"function"==typeof(null===(t=this.window)||void 0===t?void 0:t.addEventListener)&&(this.La=function(){e._c(),e.fn.ws((function(){return e.Di()}))},this.window.addEventListener("unload",this.La))},t.prototype.dc=function(){this.La&&(this.window.removeEventListener("unload",this.La),this.La=null)},t.prototype.lc=function(t){var e;try{var n=null!==(null===(e=this.Ga)||void 0===e?void 0:e.getItem(this.hc(t)));return d("IndexedDbPersistence","Client '"+t+"' "+(n?"is":"is not")+" zombied in LocalStorage"),n}catch(t){return v("IndexedDbPersistence","Failed to get zombied client id.",t),!1}},t.prototype._c=function(){if(this.Ga)try{this.Ga.setItem(this.hc(this.clientId),String(Date.now()))}catch(r){v("Failed to set zombie client id.",r)}},t.prototype.wc=function(){if(this.Ga)try{this.Ga.removeItem(this.hc(this.clientId))}catch(r){}},t.prototype.hc=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},t}();function po(t){return lo.Qn(t,Gi.store)}function vo(t){return lo.Qn(t,eo.store)}var yo=function(){function t(t,e){this.db=t,this.wo=new fi(this,e)}return t.prototype.Po=function(t){var e=this.Rc(t);return this.db.Tc().ba(t).next((function(t){return e.next((function(e){return t+e}))}))},t.prototype.Rc=function(t){var e=0;return this.Vo(t,(function(t){e++})).next((function(){return e}))},t.prototype.Ce=function(t,e){return this.db.Tc().Ce(t,e)},t.prototype.Vo=function(t,e){return this.gc(t,(function(t,n){return e(n)}))},t.prototype.Da=function(t,e,n){return go(t,n)},t.prototype.Na=function(t,e,n){return go(t,n)},t.prototype.po=function(t,e,n){return this.db.Tc().po(t,e,n)},t.prototype.Go=function(t,e){return go(t,e)},t.prototype.Pc=function(t,e){return function(t,e){var n=!1;return ki(t).os((function(r){return Si(t,r,e).next((function(t){return t&&(n=!0),mr.resolve(!t)}))})).next((function(){return n}))}(t,e)},t.prototype.bo=function(t,e){var n=this,r=this.db.Ec().ra(),i=[],o=0;return this.gc(t,(function(s,u){if(u<=e){var a=n.Pc(t,s).next((function(e){if(!e)return o++,r.Rr(t,s).next((function(){return r.Ar(s),co(t).delete([0,li(s.path)])}))}));i.push(a)}})).next((function(){return mr.$n(i)})).next((function(){return r.apply(t)})).next((function(){return o}
2))},t.prototype.removeTarget=function(t,e){var n=e.st(t.xa);return this.db.Tc().ya(t,n)},t.prototype.yc=function(t,e){return go(t,e)},t.prototype.gc=function(t,e){var n,r=co(t),i=Gr.ai;return r.rs({index:Xi.documentTargetsIndex},(function(t,r){var o=t[0],s=(t[1],r.path),u=r.sequenceNumber;0===o?(i!==Gr.ai&&e(new D(vi(n)),i),i=u,n=s):i=Gr.ai})).next((function(){i!==Gr.ai&&e(new D(vi(n)),i)}))},t.prototype.So=function(t){return this.db.Ec().aa(t)},t}();function go(t,e){return co(t).put(function(t,e){return new Xi(0,li(t.path),e)}(e,t.xa))}function mo(t,e){var n=t.projectId;return t.j||(n+="."+t.database),"firestore/"+e+"/"+n+"/"}var wo=function(){function t(t,e,n){this.persistence=t,this.Vc=e,this.bc=new Et($),this.vc=new st((function(t){return dt(t)}),vt),this.Sc=at.min(),this.Sr=t.mc(n),this.Dc=t.Ec(),this.Ka=t.Tc(),this.Cc=new ii(this.Dc,this.Sr,this.persistence.Ic()),this.Vc.Nc(this.Cc)}return t.prototype.Io=function(t){var e=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",(function(n){return t.vo(n,e.bc)}))},t}();function _o(t,e){var n=_(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(function(t){var r=e.batch.keys(),i=n.Dc.ra({oa:!0});return function(t,e,n,r){var i=n.batch,o=i.keys(),s=mr.resolve();return o.forEach((function(t){s=s.next((function(){return r.Rr(e,t)})).next((function(e){var o=e,s=n.dr.get(t);w(null!==s),(!o||o.version.L(s)<0)&&(o=i.cr(t,o,n))&&r.Er(o,n._r)}))})),s.next((function(){return t.Sr.Wo(e,i)}))}(n,t,e,i).next((function(){return i.apply(t)})).next((function(){return n.Sr.zo(t)})).next((function(){return n.Cc.kr(t,r)}))}))}function bo(t){var e=_(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(function(t){return e.Ka.Ea(t)}))}function Io(t,e){var n=_(t),r=e.nt,i=n.bc;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(function(t){var o=n.Dc.ra({oa:!0});i=n.bc;var s=[];e.zt.forEach((function(e,o){var u=i.get(o);if(u){s.push(n.Ka.Ca(t,e.se,o).next((function(){return n.Ka.Sa(t,e.ee,o)})));var a=e.resumeToken;if(a.O()>0){var c=u.it(a,r).st(t.xa);i=i.ot(o,c),function(t,e,n){return w(e.resumeToken.O()>0),0===t.resumeToken.O()||e.nt.X()-t.nt.X()>=3e8||n.ee.size+n.ne.size+n.se.size>0}(u,c,e)&&s.push(n.Ka.ya(t,c))}}}));var u=xt(),a=Vt();if(e.Yt.forEach((function(t,e){a=a.add(t)})),s.push(o.getEntries(t,a).next((function(i){e.Yt.forEach((function(a,c){var h=i.get(a);c instanceof Pn&&c.version.isEqual(at.min())?(o.Ar(a,r),u=u.ot(a,c)):null==h||c.version.L(h.version)>0||0===c.version.L(h.version)&&h.hasPendingWrites?(o.Er(c,r),u=u.ot(a,c)):d("LocalStore","Ignoring outdated watch update for ",a,". Current version:",h.version," Watch version:",c.version),e.Jt.has(a)&&s.push(n.persistence.No.yc(t,a))}))}))),!r.isEqual(at.min())){var c=n.Ka.Ea(t).next((function(e){return n.Ka.Aa(t,t.xa,r)}));s.push(c)}return mr.$n(s).next((function(){return o.apply(t)})).next((function(){return n.Cc.Mr(t,u)}))})).then((function(t){return n.bc=i,t}))}function Eo(t,e){var n=_(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(function(t){return void 0===e&&(e=-1),n.Sr.Bo(t,e)}))}function To(t,e){var n=_(t);return n.persistence.runTransaction("Allocate target","readwrite",(function(t){var r;return n.Ka.va(t,e).next((function(i){return i?(r=i,mr.resolve(r)):n.Ka.wa(t).next((function(i){return r=new wt(e,i,0,t.xa),n.Ka.Ra(t,r).next((function(){return r}))}))}))})).then((function(t){var r=n.bc.get(t.targetId);return(null===r||t.nt.L(r.nt)>0)&&(n.bc=n.bc.ot(t.targetId,t),n.vc.set(e,t.targetId)),t}))}function No(t,e,n){return r.__awaiter(this,void 0,void 0,(function(){var i,o,s,u;return r.__generator(this,(function(r){switch(r.label){case 0:i=_(t),o=i.bc.get(e),s=n?"readwrite":"readwrite-primary",r.label=1;case 1:return r.trys.push([1,4,,5]),n?[3,3]:[4,i.persistence.runTransaction("Release target",s,(function(t){return i.persistence.No.removeTarget(t,o)}))];case 2:r.sent(),r.label=3;case 3:return[3,5];case 4:if(!Ir(u=r.sent()))throw u;return d("LocalStore","Failed to update sequence numbers for target "+e+": "+u),[3,5];case 5:return i.bc=i.bc.remove(e),i.vc.delete(o.target),[2]}}))}))}function Ao(t,e,n){var r=_(t),i=at.min(),o=Vt();
2return r.persistence.runTransaction("Execute query","readonly",(function(t){return function(t,e,n){var r=_(t),i=r.vc.get(n);return void 0!==i?mr.resolve(r.bc.get(i)):r.Ka.va(e,n)}(r,t,Wn(e)).next((function(e){if(e)return i=e.lastLimboFreeSnapshotVersion,r.Ka.Fa(t,e.targetId).next((function(t){o=t}))})).next((function(){return r.Vc.Lr(t,e,n?i:at.min(),n?o:Vt())})).next((function(t){return{documents:t,Fc:o}}))}))}function So(t,e){var n=_(t),r=_(n.Ka),i=n.bc.get(e);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(function(t){return r.Ue(t,e).next((function(t){return t?t.target:null}))}))}function Do(t){var e=_(t);return e.persistence.runTransaction("Get new document changes","readonly",(function(t){return function(t,e,n){var r=_(t),i=xt(),o=wi(n),s=Vi(e),u=IDBKeyRange.lowerBound(o,!0);return s.rs({index:Hi.readTimeIndex,range:u},(function(t,e){var n=gi(r.serializer,e);i=i.ot(n.key,n),o=e.readTime})).next((function(){return{xc:i,readTime:_i(o)}}))}(e.Dc,t,e.Sc)})).then((function(t){var n=t.xc,r=t.readTime;return e.Sc=r,n}))}function xo(t){return r.__awaiter(this,void 0,void 0,(function(){var e;return r.__generator(this,(function(n){return[2,(e=_(t)).persistence.runTransaction("Synchronize last document change read time","readonly",(function(t){return function(t){var e=Vi(t),n=at.min();return e.rs({index:Hi.readTimeIndex,reverse:!0},(function(t,e,r){e.readTime&&(n=_i(e.readTime)),r.done()})).next((function(){return n}))}(t)})).then((function(t){e.Sc=t}))]}))}))}function Lo(t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){if(t.code!==h.FAILED_PRECONDITION||t.message!==ni)throw t;return d("LocalStore","Unexpectedly lost primary lease"),[2]}))}))}var ko=function(){function t(){this.$c=new At(Ro.kc),this.Mc=new At(Ro.Oc)}return t.prototype.m=function(){return this.$c.m()},t.prototype.Da=function(t,e){var n=new Ro(t,e);this.$c=this.$c.add(n),this.Mc=this.Mc.add(n)},t.prototype.Lc=function(t,e){var n=this;t.forEach((function(t){return n.Da(t,e)}))},t.prototype.Na=function(t,e){this.Bc(new Ro(t,e))},t.prototype.qc=function(t,e){var n=this;t.forEach((function(t){return n.Na(t,e)}))},t.prototype.Uc=function(t){var e=this,n=new D(new N([])),r=new Ro(n,t),i=new Ro(n,t+1),o=[];return this.Mc.Ft([r,i],(function(t){e.Bc(t),o.push(t.key)})),o},t.prototype.Qc=function(){var t=this;this.$c.forEach((function(e){return t.Bc(e)}))},t.prototype.Bc=function(t){this.$c=this.$c.delete(t),this.Mc=this.Mc.delete(t)},t.prototype.Wc=function(t){var e=new D(new N([])),n=new Ro(e,t),r=new Ro(e,t+1),i=Vt();return this.Mc.Ft([n,r],(function(t){i=i.add(t.key)})),i},t.prototype.Ho=function(t){var e=new Ro(t,0),n=this.$c.$t(e);return null!==n&&t.isEqual(n.key)},t}(),Ro=function(){function t(t,e){this.key=t,this.jc=e}return t.kc=function(t,e){return D.i(t.key,e.key)||$(t.jc,e.jc)},t.Oc=function(t,e){return $(t.jc,e.jc)||D.i(t.key,e.key)},t}(),Oo=function(t,e){this.user=e,this.type="OAuth",this.Kc={},this.Kc.Authorization="Bearer "+t},Po=function(){function t(){this.Gc=null}return t.prototype.getToken=function(){return Promise.resolve(null)},t.prototype.zc=function(){},t.prototype.Hc=function(t){this.Gc=t,t(jr.UNAUTHENTICATED)},t.prototype.Yc=function(){this.Gc=null},t}(),Vo=function(){function t(t){var e=this;this.Jc=null,this.currentUser=jr.UNAUTHENTICATED,this.Xc=!1,this.Zc=0,this.Gc=null,this.forceRefresh=!1,this.Jc=function(){e.Zc++,e.currentUser=e.tu(),e.Xc=!0,e.Gc&&e.Gc(e.currentUser)},this.Zc=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.Jc):(this.Jc(null),t.get().then((function(t){e.auth=t,e.Jc&&e.auth.addAuthTokenListener(e.Jc)}),(function(){})))}return t.prototype.getToken=function(){var t=this,e=this.Zc,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then((function(n){return t.Zc!==e?(d("FirebaseCredentialsProvider","getToken aborted due to token change."),t.getToken()):n?(w("string"==typeof n.accessToken),new Oo(n.accessToken,t.currentUser)):null})):Promise.resolve(null)},t.prototype.zc=function(){this.forceRefresh=!0},t.prototype.Hc=function(t){this.Gc=t,this.Xc&&t(this.currentUser)},t.prototype.Yc=function(){this.auth&&this.auth.removeAuthTokenListener(this.Jc),this.Jc=null,this.Gc=null},t.prototype.tu=function(){var t=this.auth&&this.auth.getUid();return w(null===t||"string"==typeof t),new jr(t)},t}(),Uo=function(){function t(t,e){this.eu=t,this.nu=e,this.type="FirstParty",this.user=jr.ni}return Object.defineProperty(t.prototype,"Kc",{get:function(){var t={"X-Goog-AuthUser":this.nu},e=this.eu.auth.getAuthHeaderValueForFirstParty([]);return e&&(t.Authorization=e),t}
2,enumerable:!1,configurable:!0}),t}(),Co=function(){function t(t,e){this.eu=t,this.nu=e}return t.prototype.getToken=function(){return Promise.resolve(new Uo(this.eu,this.nu))},t.prototype.Hc=function(t){t(jr.ni)},t.prototype.Yc=function(){},t.prototype.zc=function(){},t}(),Fo=function(){function t(t,e,n,r,i,o){this.fn=t,this.su=n,this.iu=r,this.ru=i,this.listener=o,this.state=0,this.ou=0,this.au=null,this.stream=null,this.ys=new gr(t,e)}return t.prototype.cu=function(){return 1===this.state||2===this.state||4===this.state},t.prototype.uu=function(){return 2===this.state},t.prototype.start=function(){3!==this.state?this.auth():this.hu()},t.prototype.stop=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){switch(t.label){case 0:return this.cu()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.lu=function(){this.state=0,this.ys.reset()},t.prototype._u=function(){var t=this;this.uu()&&null===this.au&&(this.au=this.fn.yn(this.su,6e4,(function(){return t.fu()})))},t.prototype.du=function(t){this.wu(),this.stream.send(t)},t.prototype.fu=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return this.uu()?[2,this.close(0)]:[2]}))}))},t.prototype.wu=function(){this.au&&(this.au.cancel(),this.au=null)},t.prototype.close=function(t,e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){switch(n.label){case 0:return this.wu(),this.ys.cancel(),this.ou++,3!==t?this.ys.reset():e&&e.code===h.RESOURCE_EXHAUSTED?(v(e.toString()),v("Using maximum backoff delay to prevent overloading the backend."),this.ys.Rn()):e&&e.code===h.UNAUTHENTICATED&&this.ru.zc(),null!==this.stream&&(this.mu(),this.stream.close(),this.stream=null),this.state=t,[4,this.listener.Tu(e)];case 1:return n.sent(),[2]}}))}))},t.prototype.mu=function(){},t.prototype.auth=function(){var t=this;this.state=1;var e=this.Eu(this.ou),n=this.ou;this.ru.getToken().then((function(e){t.ou===n&&t.Iu(e)}),(function(n){e((function(){var e=new f(h.UNKNOWN,"Fetching auth token failed: "+n.message);return t.Au(e)}))}))},t.prototype.Iu=function(t){var e=this,n=this.Eu(this.ou);this.stream=this.Ru(t),this.stream.gu((function(){n((function(){return e.state=2,e.listener.gu()}))})),this.stream.Tu((function(t){n((function(){return e.Au(t)}))})),this.stream.onMessage((function(t){n((function(){return e.onMessage(t)}))}))},t.prototype.hu=function(){var t=this;this.state=4,this.ys.gn((function(){return r.__awaiter(t,void 0,void 0,(function(){return r.__generator(this,(function(t){return this.state=0,this.start(),[2]}))}))}))},t.prototype.Au=function(t){return d("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},t.prototype.Eu=function(t){var e=this;return function(n){e.fn.ws((function(){return e.ou===t?n():(d("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())}))}},t}(),Mo=function(t){function e(e,n,r,i,o){var s=this;return(s=t.call(this,e,"listen_stream_connection_backoff","listen_stream_idle",n,r,o)||this).serializer=i,s}return r.__extends(e,t),e.prototype.Ru=function(t){return this.iu.Pu("Listen",t)},e.prototype.onMessage=function(t){this.ys.reset();var e=function(t,e){var n;if("targetChange"in e){e.targetChange;var r=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:m()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],o=function(t,e){return t.Qe?(w(void 0===e||"string"==typeof e),Z.fromBase64String(e||"")):(w(void 0===e||e instanceof Uint8Array),Z.fromUint8Array(e||new Uint8Array))}(t,e.targetChange.resumeToken),s=e.targetChange.cause,u=s&&function(t){var e=void 0===t.code?h.UNKNOWN:It(t.code);return new f(e,t.message||"")}(s);n=new Wt(r,i,o,u||null)}else if("documentChange"in e){e.documentChange;var a=e.documentChange;a.document,a.document.name,a.document.updateTime;var c=xe(t,a.document.name),l=Ne(a.document.updateTime),p=new xn({mapValue:{fields:a.document.fields}}),d=new On(c,l,p,{}),v=a.targetIds||[],y=a.removedTargetIds||[];n=new zt(v,y,d.key,d)}else if("documentDelete"in e){e.documentDelete;var g=e.documentDelete;g.document;var _=xe(t,g.document),b=g.readTime?Ne(g.readTime):at.min(),I=new Pn(_,b),E=g.removedTargetIds||[];n=new zt([],E,I.key,I)}else if("documentRemove"in e){e.documentRemove;var T=e.documentRemove;T.document;var N=xe(t,T.document),A=T.removedTargetIds||[];n=new zt([],A,N,null)}else{if(!("filter"in e))return m();e.filter;var S=e.filter;S.targetId;var D=S.count||0,x=new _t(D),L=S.targetId;n=new Bt(L,x)}return n}(this.serializer,t),n=function(t){if(!("targetChange"in t))return at.min();var e=t.targetChange;return e.targetIds&&e.targetIds.length?at.min():e.readTime?Ne(e.readTime):at.min()}(t);return this.listener.yu(e,n)},e.prototype.Vu=function(t){var e={};e.database=Re(this.serializer),e.addTarget=function(t,e){var n,r=e.target;return(n=yt(r)?{documents:Ce(t,r)}:{query:Fe(t,r)}).targetId=e.targetId,e.resumeToken.O()>0&&(n.resumeToken=Ee(t,e.resumeToken)),n}(this.serializer,t);var n=function(t,e){var n=function(t,e){switch(e){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return m()}}(0,e.et);return null==n?null:{"goog-listen-tags":n}}(this.serializer,t);n&&(e.labels=n),this.du(e)},e.prototype.pu=function(t){var e={};e.database=Re(this.serializer),e.removeTarget=t,this.du(e)},e}(Fo),qo=function(t){function e(e,n,r,i,o){var s=this;return(s=t.call(this,e,"write_stream_connection_backoff","write_stream_idle",n,r,o)||this).serializer
2=i,s.bu=!1,s}return r.__extends(e,t),Object.defineProperty(e.prototype,"vu",{get:function(){return this.bu},enumerable:!1,configurable:!0}),e.prototype.start=function(){this.bu=!1,this.lastStreamToken=void 0,t.prototype.start.call(this)},e.prototype.mu=function(){this.bu&&this.Su([])},e.prototype.Ru=function(t){return this.iu.Pu("Write",t)},e.prototype.onMessage=function(t){if(w(!!t.streamToken),this.lastStreamToken=t.streamToken,this.bu){this.ys.reset();var e=function(t,e){return t&&t.length>0?(w(void 0!==e),t.map((function(t){return function(t,e){var n=t.updateTime?Ne(t.updateTime):Ne(e);n.isEqual(at.min())&&(n=Ne(e));var r=null;return t.transformResults&&t.transformResults.length>0&&(r=t.transformResults),new ln(n,r)}(t,e)}))):[]}(t.writeResults,t.commitTime),n=Ne(t.commitTime);return this.listener.Du(n,e)}return w(!t.writeResults||0===t.writeResults.length),this.bu=!0,this.listener.Cu()},e.prototype.Nu=function(){var t={};t.database=Re(this.serializer),this.du(t)},e.prototype.Su=function(t){var e=this,n={streamToken:this.lastStreamToken,writes:t.map((function(t){return Ve(e.serializer,t)}))};this.du(n)},e}(Fo),jo=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).credentials=e,i.iu=n,i.serializer=r,i.Fu=!1,i}return r.__extends(e,t),e.prototype.xu=function(){if(this.Fu)throw new f(h.FAILED_PRECONDITION,"The client has already been terminated.")},e.prototype.$u=function(t,e,n){var r=this;return this.xu(),this.credentials.getToken().then((function(i){return r.iu.$u(t,e,n,i)})).catch((function(t){throw t.code===h.UNAUTHENTICATED&&r.credentials.zc(),t}))},e.prototype.ku=function(t,e,n){var r=this;return this.xu(),this.credentials.getToken().then((function(i){return r.iu.ku(t,e,n,i)})).catch((function(t){throw t.code===h.UNAUTHENTICATED&&r.credentials.zc(),t}))},e.prototype.terminate=function(){this.Fu=!1},e}((function(){})),Go=function(){function t(t,e){this.cs=t,this.di=e,this.state="Unknown",this.Mu=0,this.Ou=null,this.Lu=!0}return t.prototype.Bu=function(){var t=this;0===this.Mu&&(this.qu("Unknown"),this.Ou=this.cs.yn("online_state_timeout",1e4,(function(){return t.Ou=null,t.Uu("Backend didn't respond within 10 seconds."),t.qu("Offline"),Promise.resolve()})))},t.prototype.Qu=function(t){"Online"===this.state?this.qu("Unknown"):(this.Mu++,this.Mu>=1&&(this.Wu(),this.Uu("Connection failed 1 times. Most recent error: "+t.toString()),this.qu("Offline")))},t.prototype.set=function(t){this.Wu(),this.Mu=0,"Online"===t&&(this.Lu=!1),this.qu(t)}
2,t.prototype.qu=function(t){t!==this.state&&(this.state=t,this.di(t))},t.prototype.Uu=function(t){var e="Could not reach Cloud Firestore backend. "+t+"\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.";this.Lu?(v(e),this.Lu=!1):d("OnlineStateTracker",e)},t.prototype.Wu=function(){null!==this.Ou&&(this.Ou.cancel(),this.Ou=null)},t}(),zo=function(t,e,n,i,o){var s=this;this.ju=t,this.Ku=e,this.cs=n,this.Gu={},this.zu=[],this.Hu=new Map,this.Yu=new Set,this.Ju=[],this.Xu=o,this.Xu.Zu((function(t){n.ws((function(){return r.__awaiter(s,void 0,void 0,(function(){return r.__generator(this,(function(t){switch(t.label){case 0:return Zo(this)?(d("RemoteStore","Restarting streams for network reachability change."),[4,function(t){return r.__awaiter(this,void 0,void 0,(function(){var e;return r.__generator(this,(function(n){switch(n.label){case 0:return(e=_(t)).Yu.add(4),[4,Wo(e)];case 1:return n.sent(),e.th.set("Unknown"),e.Yu.delete(4),[4,Bo(e)];case 2:return n.sent(),[2]}}))}))}(this)]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}
2))}))}))})),this.th=new Go(n,i)};function Bo(t){return r.__awaiter(this,void 0,void 0,(function(){var e,n;return r.__generator(this,(function(r){switch(r.label){case 0:if(!Zo(t))return[3,4];e=0,n=t.Ju,r.label=1;case 1:return e<n.length?[4,(0,n[e])(!0)]:[3,4];case 2:r.sent(),r.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))}function Wo(t){return r.__awaiter(this,void 0,void 0,(function(){var e,n;return r.__generator(this,(function(r){switch(r.label){case 0:e=0,n=t.Ju,r.label=1;case 1:return e<n.length?[4,(0,n[e])(!1)]:[3,4];case 2:r.sent(),r.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))}function Ko(t){return r.__awaiter(this,void 0,void 0,(function(){var e;return r.__generator(this,(function(n){switch(n.label){case 0:return e=_(t),d("RemoteStore","RemoteStore shutting down."),e.Yu.add(5),[4,Wo(e)];case 1:return n.sent(),e.Xu.Di(),e.th.set("Unknown"),[2]}}))}))}function Qo(t,e){var n=_(t);n.Hu.has(e.targetId)||(n.Hu.set(e.targetId,e),Jo(n)?Xo(n):ds(n).uu()&&Yo(n,e))}function Ho(t,e){var n=_(t),r=ds(n);n.Hu.delete(e),r.uu()&&$o(n,e),0===n.Hu.size&&(r.uu()?r._u():Zo(n)&&n.th.set("Unknown"))}function Yo(t,e){t.eh.Ie(e.targetId),ds(t).Vu(e)}function $o(t,e){t.eh.Ie(e),ds(t).pu(e)}function Xo(t){t.eh=new Qt({qe:function(e){return t.Gu.qe(e)},Ue:function(e){return t.Hu.get(e)||null}}),ds(t).start(),t.th.Bu()}function Jo(t){return Zo(t)&&!ds(t).cu()&&t.Hu.size>0}function Zo(t){return 0===_(t).Yu.size}function ts(t){t.eh=void 0}function es(t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return t.Hu.forEach((function(e,n){Yo(t,e)})),[2]}))}))}function ns(t,e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return ts(t),Jo(t)?(t.th.Qu(e),Xo(t)):t.th.set("Unknown"),[2]}))}))}function rs(t,e,n){return r.__awaiter(this,void 0,void 0,(function(){var i,o,s;return r.__generator(this,(function(u){switch(u.label){case 0:if(t.th.set("Online"),!(e instanceof Wt&&2===e.state&&e.cause))return[3,6];u.label=1;case 1:return u.trys.push([1,3,,5]),[4,function(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o,s;return r.__generator(this,(function(r){switch(r.label){case 0:n=e.cause,i=0,o=e.targetIds,r.label=1;case 1:return i<o.length?(s=o[i],t.Hu.has(s)?[4,t.Gu.nh(s,n)]:[3,3]):[3,5];case 2:r.sent(),t.Hu.delete(s),t.eh.removeTarget(s),r.label=3;case 3:r.label=4;case 4:return i++,[3,1];case 5:return[2]}}
2))}))}(t,e)];case 2:return u.sent(),[3,5];case 3:return i=u.sent(),d("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),i),[4,is(t,i)];case 4:return u.sent(),[3,5];case 5:return[3,13];case 6:if(e instanceof zt?t.eh.be(e):e instanceof Bt?t.eh.$e(e):t.eh.De(e),n.isEqual(at.min()))return[3,13];u.label=7;case 7:return u.trys.push([7,11,,13]),[4,bo(t.ju)];case 8:return o=u.sent(),n.L(o)>=0?[4,function(t,e){var n=t.eh.Oe(e);return n.zt.forEach((function(n,r){if(n.resumeToken.O()>0){var i=t.Hu.get(r);i&&t.Hu.set(r,i.it(n.resumeToken,e))}})),n.Ht.forEach((function(e){var n=t.Hu.get(e);if(n){t.Hu.set(e,n.it(Z.B,n.nt)),$o(t,e);var r=new wt(n.target,e,1,n.sequenceNumber);Yo(t,r)}})),t.Gu.sh(n)}(t,n)]:[3,10];case 9:u.sent(),u.label=10;case 10:return[3,13];case 11:return d("RemoteStore","Failed to raise snapshot:",s=u.sent()),[4,is(t,s)];case 12:return u.sent(),[3,13];case 13:return[2]}}))}))}function is(t,e,n){return r.__awaiter(this,void 0,void 0,(function(){var i=this;return r.__generator(this,(function(o){switch(o.label){case 0:if(!Ir(e))throw e;return t.Yu.add(1),[4,Wo(t)];case 1:return o.sent(),t.th.set("Offline"),n||(n=function(){return bo(t.ju)}),t.cs.Cs((function(){return r.__awaiter(i,void 0,void 0,(function(){return r.__generator(this,(function(e){switch(e.label){case 0:return d("RemoteStore","Retrying IndexedDB access"),[4,n()];case 1:return e.sent(),t.Yu.delete(1),[4,Bo(t)];case 2:return e.sent(),[2]}}))}))})),[2]}}))}))}function os(t,e){return e().catch((function(n){return is(t,n,e)}))}function ss(t){return r.__awaiter(this,void 0,void 0,(function(){var e,n,i,o,s;return r.__generator(this,(function(r){switch(r.label){case 0:e=_(t),n=vs(e),i=e.zu.length>0?e.zu[e.zu.length-1].batchId:-1,r.label=1;case 1:if(!function(t){return Zo(t)&&t.zu.length<10}(e))return[3,7];r.label=2;case 2:return r.trys.push([2,4,,6]),[4,Eo(e.ju,i)];case 3:return null===(o=r.sent())?(0===e.zu.length&&n._u(),[3,7]):(i=o.batchId,function(t,e){t.zu.push(e);var n=vs(t);n.uu()&&n.vu&&n.Su(e.mutations)}(e,o),[3,6]);case 4:return s=r.sent(),[4,is(e,s)];case 5:return r.sent(),[3,6];case 6:return[3,1];case 7:return us(e)&&as(e),[2]}}))}))}function us(t){return Zo(t)&&!vs(t).cu()&&t.zu.length>0}function as(t){vs(t).start()}function cs(t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return vs(t).Nu(),[2]}))}))}function hs(t){return r.__awaiter(this,void 0,void 0,(function(){var e,n,i,o;return r.__generator(this,(function(r){for(e=vs(t),n=0,i=t.zu;n<i.length;n++)o=i[n],e.Su(o.mutations);return[2]}))}))}function fs(t,e,n){return r.__awaiter(this,void 0,void 0,(function(){var i,o;return r.__generator(this,(function(r){switch(r.label){case 0:return i=t.zu.shift(),o=ti.from(i,e,n),[4,os(t,(function(){return t.Gu.ih(o)}))];case 1:return r.sent(),[4,ss(t)];case 2:return r.sent(),[2]}}))}))}function ls(t,e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){switch(n.label){case 0:return e&&vs(t).vu?[4,function(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i;return r.__generator(this,(function(r){switch(r.label){case 0:return bt(i=e.code)&&i!==h.ABORTED?(n=t.zu.shift(),vs(t).lu(),[4,os(t,(function(){return t.Gu.rh(n.batchId,e)}))]):[3,3];case 1:return r.sent(),[4,ss(t)];case 2:r.sent(),r.label=3;case 3:return[2]}}
2))}))}(t,e)]:[3,2];case 1:n.sent(),n.label=2;case 2:return us(t)&&as(t),[2]}}))}))}function ps(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n;return r.__generator(this,(function(r){switch(r.label){case 0:return n=_(t),e?(n.Yu.delete(2),[4,Bo(n)]):[3,2];case 1:return r.sent(),[3,5];case 2:return e?[3,4]:(n.Yu.add(2),[4,Wo(n)]);case 3:r.sent(),n.th.set("Unknown"),r.label=4;case 4:r.label=5;case 5:return[2]}}))}))}function ds(t){var e=this;return t.oh||(t.oh=function(t,e,n){var r=_(t);return r.xu(),new Mo(e,r.iu,r.credentials,r.serializer,n)}(t.Ku,t.cs,{gu:es.bind(null,t),Tu:ns.bind(null,t),yu:rs.bind(null,t)}),t.Ju.push((function(n){return r.__awaiter(e,void 0,void 0,(function(){return r.__generator(this,(function(e){switch(e.label){case 0:return n?(t.oh.lu(),Jo(t)?Xo(t):t.th.set("Unknown"),[3,3]):[3,1];case 1:return[4,t.oh.stop()];case 2:e.sent(),ts(t),e.label=3;case 3:return[2]}}))}))}))),t.oh}function vs(t){var e=this;return t.ah||(t.ah=function(t,e,n){var r=_(t);return r.xu(),new qo(e,r.iu,r.credentials,r.serializer,n)}(t.Ku,t.cs,{gu:cs.bind(null,t),Tu:ls.bind(null,t),Cu:hs.bind(null,t),Du:fs.bind(null,t)}),t.Ju.push((function(n){return r.__awaiter(e,void 0,void 0,(function(){return r.__generator(this,(function(e){switch(e.label){case 0:return n?(t.ah.lu(),[4,ss(t)]):[3,2];case 1:return e.sent(),[3,4];case 2:return[4,t.ah.stop()];case 3:e.sent(),t.zu.length>0&&(d("RemoteStore","Stopping write stream with "+t.zu.length+" pending writes"),t.zu=[]),e.label=4;case 4:return[2]}}
2))}))}))),t.ah}var ys=function(t){this.key=t},gs=function(t){this.key=t},ms=function(){function t(t,e){this.query=t,this.uh=e,this.hh=null,this.te=!1,this.lh=Vt(),this.Wt=Vt(),this._h=Zn(t),this.fh=new Ft(this._h)}return Object.defineProperty(t.prototype,"dh",{get:function(){return this.uh},enumerable:!1,configurable:!0}),t.prototype.wh=function(t,e){var n=this,r=e?e.mh:new Mt,i=e?e.fh:this.fh,o=e?e.Wt:this.Wt,s=i,u=!1,a=Mn(this.query)&&i.size===this.query.limit?i.last():null,c=qn(this.query)&&i.size===this.query.limit?i.first():null;if(t.ht((function(t,e){var h=i.get(t),f=e instanceof On?e:null;f&&(f=Jn(n.query,f)?f:null);var l=!!h&&n.Wt.has(h.key),p=!!f&&(f.Je||n.Wt.has(f.key)&&f.hasCommittedMutations),d=!1;h&&f?h.data().isEqual(f.data())?l!==p&&(r.track({type:3,doc:f}),d=!0):n.Th(h,f)||(r.track({type:2,doc:f}),d=!0,(a&&n._h(f,a)>0||c&&n._h(f,c)<0)&&(u=!0)):!h&&f?(r.track({type:0,doc:f}),d=!0):h&&!f&&(r.track({type:1,doc:h}),d=!0,(a||c)&&(u=!0)),d&&(f?(s=s.add(f),o=p?o.add(t):o.delete(t)):(s=s.delete(t),o=o.delete(t)))})),Mn(this.query)||qn(this.query))for(;s.size>this.query.limit;){var h=Mn(this.query)?s.last():s.first();s=s.delete(h.key),o=o.delete(h.key),r.track({type:1,doc:h})}return{fh:s,mh:r,Eh:u,Wt:o}},t.prototype.Th=function(t,e){return t.Je&&e.hasCommittedMutations&&!e.Je},t.prototype.yr=function(t,e,n){var r=this,i=this.fh;this.fh=t.fh,this.Wt=t.Wt;var o=t.mh.Ut();o.sort((function(t,e){return function(t,e){var n=function(t){switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return m()}};return n(t)-n(e)}(t.type,e.type)||r._h(t.doc,e.doc)})),this.Ih(n);var s=e?this.Ah():[],u=0===this.lh.size&&this.te?1:0,a=u!==this.hh;return this.hh=u,0!==o.length||a?{snapshot:new qt(this.query,t.fh,i,o,t.Wt,0===u,a,!1),Rh:s}:{Rh:s}},t.prototype.Qs=function(t){return this.te&&"Offline"===t?(this.te=!1,this.yr({fh:this.fh,mh:new Mt,Wt:this.Wt,Eh:!1},!1)):{Rh:[]}},t.prototype.gh=function(t){return!this.uh.has(t)&&!!this.fh.has(t)&&!this.fh.get(t).Je},t.prototype.Ih=function(t){var e=this;t&&(t.ee.forEach((function(t){return e.uh=e.uh.add(t)})),t.ne.forEach((function(t){})),t.se.forEach((function(t){return e.uh=e.uh.delete(t)})),this.te=t.te)},t.prototype.Ah=function(){var t=this;if(!this.te)return[];var e=this.lh;this.lh=Vt(),this.fh.forEach((function(e){t.gh(e.key)&&(t.lh=t.lh.add(e.key))}));var n=[];return e.forEach((function(e){t.lh.has(e)||n.push(new gs(e))})),this.lh.forEach((function(t){e.has(t)||n.push(new ys(t))})),n},t.prototype.Ph=function(t){this.uh=t.Fc,this.lh=Vt();var e=this.wh(t.documents);return this.yr(e,!0)},t.prototype.yh=function(){return qt.Gt(this.query,this.fh,this.Wt,0===this.hh)},t}(),ws=function(t,e,n){this.query=t,this.targetId=e,this.view=n},_s=function(t){this.key=t,this.Vh=!1},bs=function(){function t(t,e,n,r,i,o){this.ju=t,this.ph=e,this.bh=n,this.Sh=r,this.currentUser=i,this.Dh=o,this.Ch={},this.Nh=new st((function(t){return $n(t)}),Yn),this.Fh=new Map,this.xh=[],this.$h=new Et(D.i),this.kh=new Map,this.Mh=new ko,this.Oh={},this.Lh=new Map,this.Bh=oo.da(),this.onlineState="Unknown",this.qh=void 0}return Object.defineProperty(t.prototype,"Uh",{get:function(){return!0===this.qh},enumerable:!1,configurable:!0}),t}();function Is(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o,s,u,a;return r.__generator(this,(function(r){switch(r.label){case 0:return n=Hs(t),(s=n.Nh.get(e))?(i=s.targetId,n.Sh.Oi(i),o=s.view.yh(),[3,4]):[3,1];case 1:return[4,To(n.ju,Wn(e))];case 2:return u=r.sent(),a=n.Sh.Oi(u.targetId),i=u.targetId,[4,Es(n,e,i,"current"===a)];case 3:o=r.sent(),n.Uh&&Qo(n.ph,u),r.label=4;case 4:return[2,o]}}))}))}function Es(t,e,n,i){return r.__awaiter(this,void 0,void 0,(function(){var o,s,u,a,c,h;return r.__generator(this,(function(f){switch(f.label){case 0:return t.Qh=function(e,n,i){return function(t,e,n,i){return r.__awaiter(this,void 0,void 0,(function(){var o,s,u;return r.__generator(this,(function(r){switch(r.label){case 0:return(o=e.view.wh(n)).Eh?[4,Ao(t.ju,e.query,!1).then((function(t){var n=t.documents;return e.view.wh(n,o)}))]:[3,2];case 1:o=r.sent(),r.label=2;case 2:return s=i&&i.zt.get(e.targetId),u=e.view.yr(o,t.Uh,s),[2,(Ps(t,e.targetId,u.Rh),u.snapshot)]}}))}))}(t,e,n,i)},[4,Ao(t.ju,e,!0)];case 1:return o=f.sent(),s=new ms(e,o.Fc),u=s.wh(o.documents),a=Gt.Zt(n,i&&"Offline"!==t.onlineState),c=s.yr(u,t.Uh,a),Ps(t,n,c.Rh),h=new ws(e,n,s),[2,(t.Nh.set(e,h),t.Fh.has(n)?t.Fh.get(n).push(e):t.Fh.set(n,[e]),c.snapshot)]}}))}))}function Ts(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o;return r.__generator(this,(function(r){switch(r.label){case 0:return n=_(t),i=n.Nh.get(e),(o=n.Fh.get(i.targetId)).length>1?[2,(n.Fh.set(i.targetId,o.filter((function(t){return!Yn(t,e)}))),void n.Nh.delete(e))]:n.Uh?(n.Sh.Bi(i.targetId),n.Sh.Fi(i.targetId)?[3,2]:[4,No(n.ju,i.targetId,!1).then((function(){n.Sh.Ui(i.targetId),Ho(n.ph,i.targetId),Rs(n,i.targetId)})).catch(Lo)]):[3,3];case 1:r.sent(),r.label=2;case 2:return[3,5];case 3:return Rs(n,i.targetId),[4,No(n.ju,i.targetId,!0)];case 4:r.sent(),r.label=5;case 5:return[2]}}
2))}))}function Ns(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i;return r.__generator(this,(function(r){switch(r.label){case 0:n=_(t),r.label=1;case 1:return r.trys.push([1,4,,6]),[4,Io(n.ju,e)];case 2:return i=r.sent(),e.zt.forEach((function(t,e){var r=n.kh.get(e);r&&(w(t.ee.size+t.ne.size+t.se.size<=1),t.ee.size>0?r.Vh=!0:t.ne.size>0?w(r.Vh):t.se.size>0&&(w(r.Vh),r.Vh=!1))})),[4,Cs(n,i,e)];case 3:return r.sent(),[3,6];case 4:return[4,Lo(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}))}))}function As(t,e,n){var r=_(t);if(r.Uh&&0===n||!r.Uh&&1===n){var i=[];r.Nh.forEach((function(t,n){var r=n.view.Qs(e);r.snapshot&&i.push(r.snapshot)})),function(t,e){var n=_(t);n.onlineState=e;var r=!1;n.Bs.forEach((function(t,n){for(var i=0,o=n.listeners;i<o.length;i++)o[i].Qs(e)&&(r=!0)})),r&&Mr(n)}(r.bh,e),i.length&&r.Ch.yu(i),r.onlineState=e,r.Uh&&r.Sh.Ki(e)}}function Ss(t,e,n){return r.__awaiter(this,void 0,void 0,(function(){var i,o,s,u,a,c;return r.__generator(this,(function(r){switch(r.label){case 0:return(i=_(t)).Sh.Qi(e,"rejected",n),o=i.kh.get(e),(s=o&&o.key)?(u=(u=new Et(D.i)).ot(s,new Pn(s,at.min())),a=Vt().add(s),c=new jt(at.min(),new Map,new At($),u,a),[4,Ns(i,c)]):[3,2];case 1:return r.sent(),i.$h=i.$h.remove(s),i.kh.delete(e),Us(i),[3,4];case 2:return[4,No(i.ju,e,!1).then((function(){return Rs(i,e,n)})).catch(Lo)];case 3:r.sent(),r.label=4;case 4:return[2]}}
2))}))}function Ds(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o;return r.__generator(this,(function(r){switch(r.label){case 0:n=_(t),i=e.batch.batchId,r.label=1;case 1:return r.trys.push([1,4,,6]),[4,_o(n.ju,e)];case 2:return o=r.sent(),ks(n,i,null),Ls(n,i),n.Sh.ki(i,"acknowledged"),[4,Cs(n,o)];case 3:return r.sent(),[3,6];case 4:return[4,Lo(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}))}))}function xs(t,e,n){return r.__awaiter(this,void 0,void 0,(function(){var i,o;return r.__generator(this,(function(r){switch(r.label){case 0:i=_(t),r.label=1;case 1:return r.trys.push([1,4,,6]),[4,function(t,e){var n=_(t);return n.persistence.runTransaction("Reject batch","readwrite-primary",(function(t){var r;return n.Sr.Oo(t,e).next((function(e){return w(null!==e),r=e.keys(),n.Sr.Wo(t,e)})).next((function(){return n.Sr.zo(t)})).next((function(){return n.Cc.kr(t,r)}))}))}(i.ju,e)];case 2:return o=r.sent(),ks(i,e,n),Ls(i,e),i.Sh.ki(e,"rejected",n),[4,Cs(i,o)];case 3:return r.sent(),[3,6];case 4:return[4,Lo(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}
2))}))}function Ls(t,e){(t.Lh.get(e)||[]).forEach((function(t){t.resolve()})),t.Lh.delete(e)}function ks(t,e,n){var r=_(t),i=r.Oh[r.currentUser.ti()];if(i){var o=i.get(e);o&&(n?o.reject(n):o.resolve(),i=i.remove(e)),r.Oh[r.currentUser.ti()]=i}}function Rs(t,e,n){void 0===n&&(n=null),t.Sh.Bi(e);for(var r=0,i=t.Fh.get(e);r<i.length;r++){var o=i[r];t.Nh.delete(o),n&&t.Ch.Wh(o,n)}t.Fh.delete(e),t.Uh&&t.Mh.Uc(e).forEach((function(e){t.Mh.Ho(e)||Os(t,e)}))}function Os(t,e){var n=t.$h.get(e);null!==n&&(Ho(t.ph,n),t.$h=t.$h.remove(e),t.kh.delete(n),Us(t))}function Ps(t,e,n){for(var r=0,i=n;r<i.length;r++){var o=i[r];o instanceof ys?(t.Mh.Da(o.key,e),Vs(t,o)):o instanceof gs?(d("SyncEngine","Document no longer in limbo: "+o.key),t.Mh.Na(o.key,e),t.Mh.Ho(o.key)||Os(t,o.key)):m()}}function Vs(t,e){var n=e.key;t.$h.get(n)||(d("SyncEngine","New document in limbo: "+n),t.xh.push(n),Us(t))}function Us(t){for(;t.xh.length>0&&t.$h.size<t.Dh;){var e=t.xh.shift(),n=t.Bh.next();t.kh.set(n,new _s(e)),t.$h=t.$h.ot(e,n),Qo(t.ph,new wt(Wn(Fn(e.path)),n,2,Gr.ai))}}function Cs(t,e,n){return r.__awaiter(this,void 0,void 0,(function(){var i,o,s,u;return r.__generator(this,(function(a){switch(a.label){case 0:return i=_(t),o=[],s=[],u=[],i.Nh.m()?[3,3]:(i.Nh.forEac
2h((function(t,r){u.push(i.Qh(r,e,n).then((function(t){if(t){i.Uh&&i.Sh.Qi(r.targetId,t.fromCache?"not-current":"current"),o.push(t);var e=oi.zr(r.targetId,t);s.push(e)}})))})),[4,Promise.all(u)]);case 1:return a.sent(),i.Ch.yu(o),[4,function(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o,s,u,a,c,h,f;return r.__generator(this,(function(r){switch(r.label){case 0:n=_(t),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(function(t){return mr.forEach(e,(function(e){return mr.forEach(e.Kr,(function(r){return n.persistence.No.Da(t,e.targetId,r)})).next((function(){return mr.forEach(e.Gr,(function(r){return n.persistence.No.Na(t,e.targetId,r)}))}))}))}))];case 2:return r.sent(),[3,4];case 3:if(!Ir(i=r.sent()))throw i;return d("LocalStore","Failed to update sequence numbers: "+i),[3,4];case 4:for(o=0,s=e;o<s.length;o++)u=s[o],a=u.targetId,u.fromCache||(c=n.bc.get(a),h=c.nt,f=c.rt(h),n.bc=n.bc.ot(a,f));return[2]}}))}))}(i.ju,s)];case 2:a.sent(),a.label=3;case 3:return[2]}}
2))}))}function Fs(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i;return r.__generator(this,(function(o){switch(o.label){case 0:return(n=_(t)).currentUser.isEqual(e)?[3,3]:(d("SyncEngine","User change. New user:",e.ti()),[4,function(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o,s;return r.__generator(this,(function(r){switch(r.label){case 0:return n=_(t),i=n.Sr,o=n.Cc,[4,n.persistence.runTransaction("Handle user change","readonly",(function(t){var r;return n.Sr.Uo(t).next((function(s){return r=s,i=n.persistence.mc(e),o=new ii(n.Dc,i,n.persistence.Ic()),i.Uo(t)})).next((function(e){for(var n=[],i=[],s=Vt(),u=0,a=r;u<a.length;u++){var c=a[u];n.push(c.batchId);for(var h=0,f=c.mutations;h<f.length;h++){var l=f[h];s=s.add(l.key)}}for(var p=0,d=e;p<d.length;p++){var v=d[p];i.push(v.batchId);for(var y=0,g=v.mutations;y<g.length;y++){var m=g[y];s=s.add(m.key)}}return o.kr(t,s).next((function(t){return{jh:t,Kh:n,Gh:i}}))}))}))];case 1:return s=r.sent(),[2,(n.Sr=i,n.Cc=o,n.Vc.Nc(n.Cc),s)]}}))}))}(n.ju,e)]);case 1:return i=o.sent(),n.currentUser=e,function(t){t.Lh.forEach((function(t){t.forEach((function(t){t.reject(new f(h.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),t.Lh.clear()}(n),n.Sh.ji(e,i.Kh,i.Gh),[4,Cs(n,i.jh)];case 2:o.sent(),o.label=3;case 3:return[2]}}
2))}))}function Ms(t,e){var n=_(t),r=n.kh.get(e);if(r&&r.Vh)return Vt().add(r.key);var i=Vt(),o=n.Fh.get(e);if(!o)return i;for(var s=0,u=o;s<u.length;s++){var a=u[s],c=n.Nh.get(a);i=i.kt(c.view.dh)}return i}function qs(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o;return r.__generator(this,(function(r){switch(r.label){case 0:return[4,Ao((n=_(t)).ju,e.query,!0)];case 1:return i=r.sent(),o=e.view.Ph(i),[2,(n.Uh&&Ps(n,e.targetId,o.Rh),o)]}}))}))}function js(t,e,n,i){return r.__awaiter(this,void 0,void 0,(function(){var o,s;return r.__generator(this,(function(r){switch(r.label){case 0:return[4,function(t,e){var n=_(t),r=_(n.Sr);return n.persistence.runTransaction("Lookup mutation documents","readonly",(function(t){return r.Lo(t,e).next((function(e){return e?n.Cc.kr(t,e):mr.resolve(null)}))}))}((o=_(t)).ju,e)];case 1:return null===(s=r.sent())?[3,6]:"pending"!==n?[3,3]:[4,ss(o.ph)];case 2:return r.sent(),[3,4];case 3:"acknowledged"===n||"rejected"===n?(ks(o,e,i||null),Ls(o,e),function(t,e){_(_(t).Sr).Ko(e)}(o.ju,e)):m(),r.label=4;case 4:return[4,Cs(o,s)];case 5:return r.sent(),[3,7];case 6:d("SyncEngine","Cannot apply mutation batch with id: "+e),r.label=7;case 7:return[2]}}
2))}))}function Gs(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o,s,u,a,c,h;return r.__generator(this,(function(r){switch(r.label){case 0:return Hs(n=_(t)),Ys(n),!0!==e||!0===n.qh?[3,3]:(i=n.Sh.Ci(),[4,zs(n,i.A())]);case 1:return o=r.sent(),n.qh=!0,[4,ps(n.ph,!0)];case 2:for(r.sent(),s=0,u=o;s<u.length;s++)a=u[s],Qo(n.ph,a);return[3,7];case 3:return!1!==e||!1===n.qh?[3,7]:(c=[],h=Promise.resolve(),n.Fh.forEach((function(t,e){n.Sh.qi(e)?c.push(e):h=h.then((function(){return Rs(n,e),No(n.ju,e,!0)})),Ho(n.ph,e)})),[4,h]);case 4:return r.sent(),[4,zs(n,c)];case 5:return r.sent(),function(t){var e=_(t);e.kh.forEach((function(t,n){Ho(e.ph,n)})),e.Mh.Qc(),e.kh=new Map,e.$h=new Et(D.i)}(n),n.qh=!1,[4,ps(n.ph,!1)];case 6:r.sent(),r.label=7;case 7:return[2]}}))}))}function zs(t,e,n){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o,s,u,a,c,h,f,l,p,d,v,y;return r.__generator(this,(function(r){switch(r.label){case 0:n=_(t),i=[],o=[],s=0,u=e,r.label=1;case 1:return s<u.length?(a=u[s],c=void 0,(h=n.Fh.get(a))&&0!==h.length?[4,To(n.ju,Wn(h[0]))]:[3,7]):[3,13];case 2:c=r.sent(),f=0,l=h,r.label=3;case 3:return f<l.length?(p=l[f],d=n.Nh.get(p),[4,qs(n,d)]):[3,6];case 4:(v=r.sent()).snapshot&&o.push(v.snapshot),r.label=5;case 5:return f++,[3,3];case 6:return[3,11];case 7:return[4,So(n.ju,a)];case 8:return y=r.sent(),[4,To(n.ju,y)];case 9:return c=r.sent(),[4,Es(n,Bs(y),a,!1)];case 10:r.sent(),r.label=11;case 11:i.push(c),r.label=12;case 12:return s++,[3,1];case 13:return[2,(n.Ch.yu(o),i)]}}))}))}function Bs(t){return Cn(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)}function Ws(t){var e=_(t);return _(_(e.ju).persistence).pi()}function Ks(t,e,n,i){return r.__awaiter(this,void 0,void 0,(function(){var o,s,u;return r.__generator(this,(function(r){switch(r.label){case 0:return(o=_(t)).qh?(d("SyncEngine","Ignoring unexpected query state notification."),[3,8]):[3,1];case 1:if(!o.Fh.has(e))return[3,8];switch(n){case"current":case"not-current":return[3,2];case"rejected":return[3,5]}return[3,7];case 2:return[4,Do(o.ju)];case 3:return s=r.sent(),u=jt.Xt(e,"current"===n),[4,Cs(o,s,u)];case 4:return r.sent(),[3,8];case 5:return[4,No(o.ju,e,!0)];case 6:return r.sent(),Rs(o,e,i),[3,8];case 7:m(),r.label=8;case 8:return[2]}}
2))}))}function Qs(t,e,n){return r.__awaiter(this,void 0,void 0,(function(){var i,o,s,u,a,c,h,f,l,p;return r.__generator(this,(function(v){switch(v.label){case 0:if(!(i=Hs(t)).qh)return[3,10];o=0,s=e,v.label=1;case 1:return o<s.length?(u=s[o],i.Fh.has(u)?(d("SyncEngine","Adding an already active target "+u),[3,5]):[4,So(i.ju,u)]):[3,6];case 2:return a=v.sent(),[4,To(i.ju,a)];case 3:return c=v.sent(),[4,Es(i,Bs(a),c.targetId,!1)];case 4:v.sent(),Qo(i.ph,c),v.label=5;case 5:return o++,[3,1];case 6:h=function(t){return r.__generator(this,(function(e){switch(e.label){case 0:return i.Fh.has(t)?[4,No(i.ju,t,!1).then((function(){Ho(i.ph,t),Rs(i,t)})).catch(Lo)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))},f=0,l=n,v.label=7;case 7:return f<l.length?(p=l[f],[5,h(p)]):[3,10];case 8:v.sent(),v.label=9;case 9:return f++,[3,7];case 10:return[2]}}))}))}function Hs(t){var e=_(t);return e.ph.Gu.sh=Ns.bind(null,e),e.ph.Gu.qe=Ms.bind(null,e),e.ph.Gu.nh=Ss.bind(null,e),e.Ch.yu=Cr.bind(null,e.bh),e.Ch.Wh=Fr.bind(null,e.bh),e}function Ys(t){var e=_(t);return e.ph.Gu.ih=Ds.bind(null,e),e.ph.Gu.rh=xs.bind(null,e),e}var $s=function(){function t(){}return t.prototype.Nc=function(t){this.zh=t},t.prototype.Lr=function(t,e,n,r){var i=this;return function(t){return 0===t.filters.length&&null===t.limit&&null==t.startAt&&null==t.endAt&&(0===t.on.length||1===t.on.length&&t.on[0].field.p())}(e)||n.isEqual(at.min())?this.Hh(t,e):this.zh.kr(t,r).next((function(s){var u=i.Yh(e,s);return(Mn(e)||qn(e))&&i.Eh(e.an,u,r,n)?i.Hh(t,e):(p()<=o.LogLevel.DEBUG&&d("IndexFreeQueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),Xn(e)),i.zh.Lr(t,e,n).next((function(t){return u.forEach((function(e){t=t.ot(e.key,e)})),t})))}))},t.prototype.Yh=function(t,e){var n=new At(Zn(t));return e.forEach((function(e,r){r instanceof On&&Jn(t,r)&&(n=n.add(r))})),n},t.prototype.Eh=function(t,e,n,r){if(n.size!==e.size)return!0;var i="F"===t?e.last():e.first();return!!i&&(i.hasPendingWrites||i.version.L(r)>0)},t.prototype.Hh=function(t,e){return p()<=o.LogLevel.DEBUG&&d("IndexFreeQueryEngine","Using full collection scan to execute query:",Xn(e)),this.zh.Lr(t,e,at.min())},t}(),Xs=function(){function t(t,e){this.Dr=t,this.No=e,this.Sr=[],this.Jh=1,this.Xh=new At(Ro.kc)}return t.prototype.$o=function(t){return mr.resolve(0===this.Sr.length)},t.prototype.ko=function(t,e,n,r){var i=this.Jh;this.Jh++,this.Sr.length>0&&this.Sr[this.Sr.length-1];var o=new Zr(i,e,n,r);this.Sr.push(o);for(var s=0,u=r;s<u.length;s++){var a=u[s];this.Xh=this.Xh.add(new Ro(a.key,i)),this.Dr.Mo(t,a.key.path.h())}return mr.resolve(o)},t.prototype.Oo=function(t,e){return mr.resolve(this.Zh(e))},t.prototype.Bo=function(t,e){var n=e+1,r=this.tl(n),i=r<0?0:r;return mr.resolve(this.Sr.length>i?this.Sr[i]:null)},t.prototype.qo=function(){return mr.resolve(0===this.Sr.length?-1:this.Jh-1)},t.prototype.Uo=function(t){return mr.resolve(this.Sr.slice())},t.prototype.Nr=function(t,e){var n=this,r=new Ro(e,0),i=new Ro(e,Number.POSITIVE_INFINITY),o=[];return this.Xh.Ft([r,i],(function(t){var e=n.Zh(t.jc);o.push(e)})),mr.resolve(o)},t.prototype.Or=function(t,e){var n=this,r=new At($);return e.forEach((function(t){var e=new Ro(t,0),i=new Ro(t,Number.POSITIVE_INFINITY);n.Xh.Ft([e,i],(function(t){r=r.add(t.jc)}))})),mr.resolve(this.el(r))},t.prototype.Wr=function(t,e){var n=e.path,r=n.length+1,i=n;D.F(i)||(i=i.child(""));var o=new Ro(new D(i),0),s=new At($);return this.Xh.xt((function(t){var e=t.key.path;return!!n.T(e)&&(e.length===r&&(s=s.add(t.jc)),!0)}),o),mr.resolve(this.el(s))},t.prototype.el=function(t){var e=this,n=[];return t.forEach((function(t){var r=e.Zh(t);null!==r&&n.push(r)})),n},t.prototype.Wo=function(t,e){var n=this;w(0===this.nl(e.batchId,"removed")),this.Sr.shift();var r=this.Xh;return mr.forEach(e.mutations,(function(i){var o=new Ro(i.key,e.batchId);return r=r.delete(o),n.No.Go(t,i.key)})).next((function(){n.Xh=r}))},t.prototype.Ko=function(t){},t.prototype.Ho=function(t,e){var n=new Ro(e,0),r=this.Xh.$t(n);return mr.resolve(e.isEqual(r&&r.key))},t.prototype.zo=function(t){return this.Sr.length,mr.resolve()},t.prototype.nl=function(t,e){return this.tl(t)},t.prototype.tl=function(t){return 0===this.Sr.length?0:t-this.Sr[0].batchId},t.prototype.Zh=function(t){var e=this.tl(t);return e<0||e>=this.Sr.length?null:this.Sr[e]},t}(),Js=function(){function t(t,e){this.Dr=t,this.sl=e,this.docs=new Et(D.i),this.size=0}return t.prototype.Er=function(t,e,n){var r=e.key,i=this.docs.get(r),o=i?i.size:0,s=this.sl(e);return this.docs=this.docs.ot(r,{ta:e,size:s,readTime:n}),this.size+=s-o,this.Dr.Mo(t,r.path.h())},t.prototype.Ar=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},t.prototype.Rr=function(t,e){var n=this.docs.get(e);return mr.resolve(n?n.ta:null)},t.prototype.getEntries=function(t,e){var n=this,r=Lt();return e.forEach((function(t){var e=n.docs.get(t);r=r.ot(t,e?e.ta:null)})),mr.resolve(r)},t.prototype.Lr=function(t,e,n){for(var r=Rt(),i=new D(e.path.child("")),o=this.docs.ft(i);o.At();){var s=o.It(),u=s.key,a=s.value,c=a.ta,h=a.readTime;if(!e.path.T(u.path))break;h.L(n)<=0||c instanceof On&&Jn(e,c)&&(r=r.ot(c.key,c))}return mr.resolve(r)},t.prototype.il=function(t,e){return mr.forEach(this.docs,(function(t){return e(t)}))},t.prototype.ra=function(t){return new Zs(this)},t.prototype.aa=function(t){return mr.resolve(this.size)},t}(),Zs=function(t){function e(e){var n=this;return(n=t.call(this)||this).ca=e,n}return r.__extends(e,t),e.prototype.yr=function(t){var e=this,n=[];return this.wr.forEach((function(r,i){i?n.push(e.ca.Er(t,i,e.readTime)):e.ca.Ar(r)})),mr.$n(n)},e.prototype.gr=function(t,e){return this.ca.Rr(t,e)},e.prototype.Pr=function(t,e){return this.ca.getEntries(t,e)},e}
2(ei),tu=function(){function t(t){this.persistence=t,this.rl=new st((function(t){return dt(t)}),vt),this.lastRemoteSnapshotVersion=at.min(),this.highestTargetId=0,this.ol=0,this.al=new ko,this.targetCount=0,this.cl=oo.fa()}return t.prototype.Ce=function(t,e){return this.rl.forEach((function(t,n){return e(n)})),mr.resolve()},t.prototype.Ea=function(t){return mr.resolve(this.lastRemoteSnapshotVersion)},t.prototype.Ia=function(t){return mr.resolve(this.ol)},t.prototype.wa=function(t){return this.highestTargetId=this.cl.next(),mr.resolve(this.highestTargetId)},t.prototype.Aa=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.ol&&(this.ol=e),mr.resolve()},t.prototype.ga=function(t){this.rl.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.cl=new oo(e),this.highestTargetId=e),t.sequenceNumber>this.ol&&(this.ol=t.sequenceNumber)},t.prototype.Ra=function(t,e){return this.ga(e),this.targetCount+=1,mr.resolve()},t.prototype.ya=function(t,e){return this.ga(e),mr.resolve()},t.prototype.Va=function(t,e){return this.rl.delete(e.target),this.al.Uc(e.targetId),this.targetCount-=1,mr.resolve()},t.prototype.po=function(t,e,n){var r=this,i=0,o=[];return this.rl.forEach((function(s,u){u.sequenceNumber<=e&&null===n.get(u.targetId)&&(r.rl.delete(s),o.push(r.pa(t,u.targetId)),i++)})),mr.$n(o).next((function(){return i}))},t.prototype.ba=function(t){return mr.resolve(this.targetCount)},t.prototype.va=function(t,e){var n=this.rl.get(e)||null;return mr.resolve(n)},t.prototype.Sa=function(t,e,n){return this.al.Lc(e,n),mr.resolve()},t.prototype.Ca=function(t,e,n){this.al.qc(e,n);var r=this.persistence.No,i=[];return r&&e.forEach((function(e){i.push(r.Go(t,e))})),mr.$n(i)},t.prototype.pa=function(t,e){return this.al.Uc(e),mr.resolve()},t.prototype.Fa=function(t,e){var n=this.al.Wc(e);return mr.resolve(n)},t.prototype.Ho=function(t,e){return mr.resolve(this.al.Ho(e))},t}(),eu=function(){function t(t){var e=this;this.ul={},this.Ma=new Gr(0),this.Oa=!1,this.Oa=!0,this.No=t(this),this.Ka=new tu(this),this.Dr=new Fi,this.vr=function(t){return new Js(t,(function(t){return e.No.hl(t)}))}(this.Dr)}return t.prototype.start=function(){return Promise.resolve()},t.prototype.Di=function(){return this.Oa=!1,Promise.resolve()},Object.defineProperty(t.prototype,"Ei",{get:function(){return this.Oa},enumerable:!1,configurable:!0}),t.prototype.Za=function(){},t.prototype.tc=function(){},t.prototype.Ic=function(){return this.Dr},t.prototype.mc=function(t){var e=this.ul[t.ti()];return e||(e=new Xs(this.Dr,this.No),this.ul[t.ti()]=e),e},t.prototype.Tc=function(){return this.Ka},t.prototype.Ec=function(){return this.vr},t.prototype.runTransaction=function(t,e,n){var r=this;d("MemoryPersistence","Starting transaction:",t);var i=new nu(this.Ma.next());return this.No.ll(),n(i).next((function(t){return r.No._l(i).next((function(){return t}))})).Fn().then((function(t){return i.br(),t}))},t.prototype.fl=function(t,e){return mr.kn(Object.values(this.ul).map((function(n){return function(){return n.Ho(t,e)}})))},t}(),nu=function(t){function e(e){var n=this;return(n=t.call(this)||this).xa=e,n}return r.__extends(e,t),e}(ri),ru=function(){function t(t){this.persistence=t,this.dl=new ko,this.wl=null}return t.ml=function(e){return new t(e)},Object.defineProperty(t.prototype,"Tl",{get:function(){if(this.wl)return this.wl;throw m()},enumerable:!1,configurable:!0}),t.prototype.Da=function(t,e,n){return this.dl.Da(n,e),this.Tl.delete(n.toString()),mr.resolve()},t.prototype.Na=function(t,e,n){return this.dl.Na(n,e),this.Tl.add(n.toString()),mr.resolve()},t.prototype.Go=function(t,e){return this.Tl.add(e.toString()),mr.resolve()},t.prototype.removeTarget=function(t,e){var n=this;this.dl.Uc(e.targetId).forEach((function(t){return n.Tl.add(t.toString())}));var r=this.persistence.Tc();return r.Fa(t,e.targetId).next((function(t){t.forEach((function(t){return n.Tl.add(t.toString())}))})).next((function(){return r.Va(t,e)}))},t.prototype.ll=function(){this.wl=new Set},t.prototype._l=function(t){var e=this,n=this.persistence.Ec().ra();return mr.forEach(this.Tl,(function(r){var i=D.D(r);return e.El(t,i).next((function(t){t||n.Ar(i)}))})).next((function(){return e.wl=null,n.apply(t)}))},t.prototype.yc=function(t,e){var n=this;return this.El(t,e).next((function(t){t?n.Tl.delete(e.toString()):n.Tl.add(e.toString())}))},t.prototype.hl=function(t){return 0},t.prototype.El=function(t,e){var n=this;return mr.kn([function(){return mr.resolve(n.dl.Ho(e))},function(){return n.persistence.Tc().Ho(t,e)},function(){return n.persistence.fl(t,e)}])},t}(),iu=function(){function t(t){this.Il=t.Il,this.Al=t.Al}return t.prototype.gu=function(t){this.Rl=t},t.prototype.Tu=function(t){this.gl=t},t.prototype.onMessage=function(t){this.Pl=t},t.prototype.close=function(){this.Al()},t.prototype.send=function(t){this.Il(t)},t.prototype.yl=function(){this.Rl()},t.prototype.Vl=function(t){this.gl(t)},t.prototype.pl=function(t){this.Pl(t)},t}(),ou={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"},su=function(t){function e(e){var n=this;return(n=t.call(this,e)||this).forceLongPolling=e.forceLongPolling,n.W=e.W,n}return r.__extends(e,t),e.prototype.Nl=function(t,e,n,r){return new Promise((function(i,o){var s=new u.XhrIo;
2s.listenOnce(u.EventType.COMPLETE,(function(){try{switch(s.getLastErrorCode()){case u.ErrorCode.NO_ERROR:var e=s.getResponseJson();d("Connection","XHR received:",JSON.stringify(e)),i(e);break;case u.ErrorCode.TIMEOUT:d("Connection",'RPC "'+t+'" timed out'),o(new f(h.DEADLINE_EXCEEDED,"Request time out"));break;case u.ErrorCode.HTTP_ERROR:var n=s.getStatus();if(d("Connection",'RPC "'+t+'" failed with status:',n,"response text:",s.getResponseText()),n>0){var r=s.getResponseJson().error;if(r&&r.status&&r.message){var a=function(t){var e=t.toLowerCase().replace("_","-");return Object.values(h).indexOf(e)>=0?e:h.UNKNOWN}(r.status);o(new f(a,r.message))}else o(new f(h.UNKNOWN,"Server responded with status "+s.getStatus()))}else o(new f(h.UNAVAILABLE,"Connection failed."));break;default:m()}}finally{d("Connection",'RPC "'+t+'" completed.')}}));var a=JSON.stringify(r);s.send(e,"POST",a,n,15)}))},e.prototype.Pu=function(t,e){var n=[this.vl,"/","google.firestore.v1.Firestore","/",t,"/channel"],r=u.createWebChannelTransport(),i={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.U.projectId+"/databases/"+this.U.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.W};this.Cl(i.initMessageHeaders,e),s.isMobileCordova()||s.isReactNative()||s.isElectron()||s.isIE()||s.isUWP()||s.isBrowserExtension()||(i.httpHeadersOverwriteParam="$httpHeaders");var o=n.join("");d("Connection","Creating WebChannel: "+o,i);var a=r.createWebChannel(o,i),c=!1,l=!1,p=new iu({Il:function(t){l?d("Connection","Not sending because WebChannel is closed:",t):(c||(d("Connection","Opening WebChannel transport."),a.open(),c=!0),d("Connection","WebChannel sending:",t),a.send(t))},Al:function(){return a.close()}}),v=function(t,e){a.listen(t,(function(t){try{e(t)}catch(t){setTimeout((function(){throw t}),0)}}))};return v(u.WebChannel.EventType.OPEN,(function(){l||d("Connection","WebChannel transport opened.")})),v(u.WebChannel.EventType.CLOSE,(function(){l||(l=!0,d("Connection","WebChannel transport closed"),p.Vl())})),v(u.WebChannel.EventType.ERROR,(function(t){l||(l=!0,y("Connection","WebChannel transport errored:",t),p.Vl(new f(h.UNAVAILABLE,"The operation could not be completed")))})),v(u.WebChannel.EventType.MESSAGE,(function(t){var e;if(!l){var n=t.data[0];w(!!n);var r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){d("Connection","WebChannel received error:",i);var o=i.status,s=function(t){var e=gt[t];if(void 0!==e)return It(e)}(o),u=i.message;void 0===s&&(s=h.INTERNAL,u="Unknown error status: "+o+" with message "+i.message),l=!0,p.Vl(new f(s,u)),a.close()}else d("Connection","WebChannel received:",n),p.pl(n)}})),setTimeout((function(){p.yl()}),0),p},e}(function(){function t(t){this.bl=t,this.U=t.U;var e=t.ssl?"https":"http";this.vl=e+"://"+t.host,this.Sl="projects/"+this.U.projectId+"/databases/"+this.U.database+"/documents"}return t.prototype.$u=function(t,e,n,r){var i=this.Dl(t,e);d("RestConnection","Sending: ",i,n);var o={};return this.Cl(o,r),this.Nl(t,i,o,n).then((function(t){return d("RestConnection","Received: ",t),t}),(function(e){throw y("RestConnection",t+" failed with error: ",e,"url: ",i,"request:",n),e}))},t.prototype.ku=function(t,e,n,r){return this.$u(t,e,n,r)},t.prototype.Cl=function(t,e){if(t["X-Goog-Api-Client"]="gl-js/ fire/7.24.0",t["Content-Type"]="text/plain",e)for(var n in e.Kc)e.Kc.hasOwnProperty(n)&&(t[n]=e.Kc[n])},t.prototype.Dl=function(t,e){var n=ou[t];return this.vl+"/v1/"+e+":"+n},t}()),uu=function(){function t(){var t=this;this.Fl=function(){return t.xl()},this.$l=function(){return t.kl()},this.Ml=[],this.Ol()}return t.prototype.Zu=function(t){this.Ml.push(t)},t.prototype.Di=function(){window.removeEventListener("online",this.Fl),window.removeEventListener("offline",this.$l)},t.prototype.Ol=function(){window.addEventListener("online",this.Fl),window.addEventListener("offline",this.$l)},t.prototype.xl=function(){d("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.Ml;t<e.length;t++)(0,e[t])(0)},t.prototype.kl=function(){d("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.Ml;t<e.length;t++)(0,e[t])(1)},t.Ln=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},t}
2(),au=function(){function t(){}return t.prototype.Zu=function(t){},t.prototype.Di=function(){},t}();function cu(t){return new me(t,!0)}var hu="You are using the memory-only build of Firestore. Persistence support is only available via the @firebase/firestore bundle or the firebase-firestore.js build.",fu=function(){function t(){}return t.prototype.initialize=function(t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){switch(e.label){case 0:return this.Sh=this.Ll(t),this.persistence=this.Bl(t),[4,this.persistence.start()];case 1:return e.sent(),this.ql=this.Ul(t),this.ju=this.Ql(t),[2]}}))}))},t.prototype.Ul=function(t){return null},t.prototype.Ql=function(t){return e=this.persistence,n=new $s,r=t.Wl,new wo(e,n,r);var e,n,r},t.prototype.Bl=function(t){if(t.persistenceSettings.jl)throw new f(h.FAILED_PRECONDITION,hu);return new eu(ru.ml)},t.prototype.Ll=function(t){return new Jr},t.prototype.terminate=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){switch(t.label){case 0:return this.ql&&this.ql.stop(),[4,this.Sh.Di()];case 1:return t.sent(),[4,this.persistence.Di()];case 2:return t.sent(),[2]}}))}))},t.prototype.clearPersistence=function(t,e){throw new f(h.FAILED_PRECONDITION,hu)},t}(),lu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.initialize=function(e){return r.__awaiter(this,void 0,void 0,(function(){var n,i=this;return r.__generator(this,(function(o){switch(o.label){case 0:return[4,t.prototype.initialize.call(this,e)];case 1:return o.sent(),n=this.Kl.fi,this.Sh instanceof Xr?(this.Sh.fi={er:js.bind(null,n),nr:Ks.bind(null,n),sr:Qs.bind(null,n),pi:Ws.bind(null,n)},[4,this.Sh.start()]):[3,3];case 2:o.sent(),o.label=3;case 3:return[4,this.persistence.Xa((function(t){return r.__awaiter(i,void 0,void 0,(function(){return r.__generator(this,(function(e){switch(e.label){case 0:return[4,Gs(this.Kl.fi,t)];case 1:return e.sent(),this.ql&&(t&&!this.ql.Ei?this.ql.start(this.ju):t||this.ql.stop()),[2]}}))}))}))];case 4:return o.sent(),[2]}}))}))},e.prototype.Ll=function(t){if(t.persistenceSettings.jl&&t.persistenceSettings.synchronizeTabs){var e=Dr();if(!Xr.Ln(e))throw new f(h.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=mo(t.bl.U,t.bl.persistenceKey);return new Xr(e,t.cs,n,t.clientId,t.Wl)}return new Jr},e}(function(t){function e(e){var n=this;return(n=t.call(this)||this).Kl=e,n}return r.__extends(e,t),e.prototype.initialize=function(e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){switch(n.label){case 0:return[4,t.prototype.initialize.call(this,e)];case 1:return n.sent(),[4,xo(this.ju)];case 2:return n.sent(),[4,this.Kl.initialize(this,e)];case 3:return n.sent(),[4,Ys(this.Kl.fi)];case 4:return n.sent(),[4,ss(this.Kl.ph)];case 5:return n.sent(),[2]}}))}))},e.prototype.Ul=function(t){var e=this.persistence.No.wo;return new hi(e,t.cs)},e.prototype.Bl=function(t){var e=mo(t.bl.U,t.bl.persistenceKey),n=cu(t.bl.U);return new lo(t.persistenceSettings.synchronizeTabs,e,t.clientId,ci.ao(t.persistenceSettings.cacheSizeBytes),t.cs,Dr(),xr(),n,this.Sh,t.persistenceSettings.ka)},e.prototype.Ll=function(t){return new Jr},e.prototype.clearPersistence=function(t,e){return function(t){return r.__awaiter(this,void 0,void 0,(function(){var e;return r.__generator(this,(function(n){switch(n.label){case 0:return wr.Ln()?(e=t+"main",[4,wr.delete(e)]):[2,Promise.resolve()];case 1:return n.sent(),[2]}}))}))}(mo(t,e))},e}(fu)),pu=function(){function t(){}return t.prototype.initialize=function(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n=this;return r.__generator(this,(function(r){switch(r.label){case 0:return this.ju?[3,2]:(this.ju=t.ju,this.Sh=t.Sh,this.Ku=this.Gl(e),this.ph=this.zl(e),this.bh=this.Hl(e),this.fi=this.Yl(e),this.Sh.di=function(t){return As(n.fi,t,1)},this.ph.Gu.Jl=Fs.bind(null,this.fi),[4,ps(this.ph,this.fi.Uh)]);case 1:r.sent(),r.label=2;case 2:return[2]}}
2))}))},t.prototype.Hl=function(t){return new Pr},t.prototype.Gl=function(t){var e,n=cu(t.bl.U),r=(e=t.bl,new su(e));return function(t,e,n){return new jo(t,e,n)}(t.credentials,r,n)},t.prototype.zl=function(t){var e,n,r,i,o,s=this;return e=this.ju,n=this.Ku,r=t.cs,i=function(t){return As(s.fi,t,0)},o=uu.Ln()?new uu:new au,new zo(e,n,r,i,o)},t.prototype.Yl=function(t){return function(t,e,n,r,i,o,s){var u=new bs(t,e,n,r,i,o);return s&&(u.qh=!0),u}(this.ju,this.ph,this.bh,this.Sh,t.Wl,t.Dh,!t.persistenceSettings.jl||!t.persistenceSettings.synchronizeTabs)},t.prototype.terminate=function(){return Ko(this.ph)},t}(),du=function(){function t(t){this.observer=t,this.muted=!1}return t.prototype.next=function(t){this.observer.next&&this.Xl(this.observer.next,t)},t.prototype.error=function(t){this.observer.error?this.Xl(this.observer.error,t):console.error("Uncaught Error in snapshot listener:",t)},t.prototype.Zl=function(){this.muted=!0},t.prototype.Xl=function(t,e){var n=this;this.muted||setTimeout((function(){n.muted||t(e)}),0)},t}(),vu=function(t){!function(t,e){if(!(e instanceof Array)||e.length<1)throw new f(h.INVALID_ARGUMENT,"Function FieldPath() requires its fieldNames argument to be an array with at least "+Q(1,"element")+".")}(0,t);for(var e=0;e<t.length;++e)if(O("FieldPath","string",e,t[e]),0===t[e].length)throw new f(h.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this.t_=new S(t)},yu=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.call(this,e)||this}return r.__extends(e,t),e.documentId=function(){return new e(S.v().R())},e.prototype.isEqual=function(t){if(!(t instanceof e))throw B("isEqual","FieldPath",1,t);return this.t_.isEqual(t.t_)},e}(vu),gu=new RegExp("[~\\*/\\[\\]]"),mu=function(t){this.e_=t},wu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.n_=function(t){if(2!==t.s_)throw 1===t.s_?t.i_(this.e_+"() can only appear at the top level of your update data"):t.i_(this.e_+"() cannot be used with set() unless you pass {merge:true}");return t.We.push(t.path),null},e.prototype.isEqual=function(t){return t instanceof e},e}(mu);function _u(t,e,n){return new Ru({s_:3,r_:e.settings.r_,methodName:t.e_,o_:n},e.U,e.serializer,e.ignoreUndefinedProperties)}var bu=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.n_=function(t){return new fn(t.path,new en)},e.prototype.isEqual=function(t){return t instanceof e},e}(mu),Iu=function(t){function e(e,n){var r=this;return(r=t.call(this,e)||this).a_=n,r}return r.__extends(e,t),e.prototype.n_=function(t){var e=_u(this,t,!0),n=this.a_.map((function(t){return Fu(t,e)})),r=new nn(n);return new fn(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(mu),Eu=function(t){function e(e,n){var r=this;return(r=t.call(this,e)||this).a_=n,r}return r.__extends(e,t),e.prototype.n_=function(t){var e=_u(this,t,!0),n=this.a_.map((function(t){return Fu(t,e)})),r=new on(n);return new fn(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(mu),Tu=function(t){function e(e,n){var r=this;return(r=t.call(this,e)||this).c_=n,r}return r.__extends(e,t),e.prototype.n_=function(t){var e=new un(t.serializer,be(t.serializer,this.c_));return new fn(t.path,e)},e.prototype.isEqual=function(t){return this===t},e}(mu),Nu=function(){function t(t,e){if(L("GeoPoint",arguments,2),O("GeoPoint","number",1,t),O("GeoPoint","number",2,e),!isFinite(t)||t<-90||t>90)throw new f(h.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new f(h.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this.u_=t,this.h_=e}return Object.defineProperty(t.prototype,"latitude",{get:function(){return this.u_},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"longitude",{get:function(){return this.h_},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){return this.u_===t.u_&&this.h_===t.h_},t.prototype.toJSON=function(){return{latitude:this.u_,longitude:this.h_}},t.prototype.Y=function(t){return $(this.u_,t.u_)||$(this.h_,t.h_)},t}(),Au=function(t){this.l_=t},Su=/^__.*__$/,Du=function(t,e,n){this.__=t,this.f_=e,this.d_=n},xu=function(){function t(t,e,n){this.data=t,this.We=e,this.fieldTransforms=n}return t.prototype.w_=function(t,e){var n=[];return null!==this.We?n.push(new In(t,this.data,this.We,e)):n.push(new bn(t,this.data,e)),this.fieldTransforms.length>0&&n.push(new Tn(t,this.fieldTransforms)),n},t}(),Lu=function(){function t(t,e,n){this.data=t,this.We=e,this.fieldTransforms=n}return t.prototype.w_=function(t,e){var n=[new In(t,this.data,this.We,e)];return this.fieldTransforms.length>0&&n.push(new Tn(t,this.fieldTransforms)),n},t}();function ku(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw m()}}var Ru=function(){function t(t,e,n,r,i,o){this.settings=t,this.U=e,this.serializer
2=n,this.ignoreUndefinedProperties=r,void 0===i&&this.m_(),this.fieldTransforms=i||[],this.We=o||[]}return Object.defineProperty(t.prototype,"path",{get:function(){return this.settings.path},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"s_",{get:function(){return this.settings.s_},enumerable:!1,configurable:!0}),t.prototype.T_=function(e){return new t(Object.assign(Object.assign({},this.settings),e),this.U,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.We)},t.prototype.E_=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.T_({path:n,o_:!1});return r.I_(t),r},t.prototype.A_=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.T_({path:n,o_:!1});return r.m_(),r},t.prototype.R_=function(t){return this.T_({path:void 0,o_:!0})},t.prototype.i_=function(t){return Bu(t,this.settings.methodName,this.settings.g_||!1,this.path,this.settings.r_)},t.prototype.contains=function(t){return void 0!==this.We.find((function(e){return t.T(e)}))||void 0!==this.fieldTransforms.find((function(e){return t.T(e.field)}))},t.prototype.m_=function(){if(this.path)for(var t=0;t<this.path.length;t++)this.I_(this.path.get(t))},t.prototype.I_=function(t){if(0===t.length)throw this.i_("Document fields must not be empty");if(ku(this.s_)&&Su.test(t))throw this.i_('Document fields cannot begin and end with "__"')},t}(),Ou=function(){function t(t,e,n){this.U=t,this.ignoreUndefinedProperties=e,this.serializer=n||cu(t)}return t.prototype.P_=function(t,e,n,r){return void 0===r&&(r=!1),new Ru({s_:t,methodName:e,r_:n,path:S.P(),o_:!1,g_:r},this.U,this.serializer,this.ignoreUndefinedProperties)},t}();function Pu(t,e,n,r,i,o){void 0===o&&(o={});var s=t.P_(o.merge||o.mergeFields?2:0,e,n,i);ju("Data must be an object, but it was:",s,r);var u,a,c=Mu(r,s);if(o.merge)u=new hn(s.We),a=s.fieldTransforms;else if(o.mergeFields){for(var l=[],p=0,d=o.mergeFields;p<d.length;p++){var v=d[p],y=void 0;if(v instanceof vu)y=v.t_;else{if("string"!=typeof v)throw m();y=zu(e,v,n)}if(!s.contains(y))throw new f(h.INVALID_ARGUMENT,"Field '"+y+"' is specified in your field mask but missing from your input data.");Wu(l,y)||l.push(y)}u=new hn(l),a=s.fieldTransforms.filter((function(t){return u.Ye(t.field)}))}else u=null,a=s.fieldTransforms;return new xu(new xn(c),u,a)}function Vu(t,e,n,r){var i=t.P_(1,e,n);ju("Data must be an object, but it was:",i,r);var o=[],s=new Ln;I(r,(function(t,r){var u=zu(e,t,n),a=i.A_(u);if(r instanceof wu||r instanceof Au&&r.l_ instanceof wu)o.push(u);else{var c=Fu(r,a);null!=c&&(o.push(u),s.set(u,c))}}));var u=new hn(o);return new Lu(s.Xe(),u,i.fieldTransforms)}function Uu(t,e,n,r,i,o){var s=t.P_(1,e,n),u=[Gu(e,r,n)],a=[i];if(o.length%2!=0)throw new f(h.INVALID_ARGUMENT,"Function "+e+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var c=0;c<o.length;c+=2)u.push(Gu(e,o[c])),a.push(o[c+1]);for(var l=[],p=new Ln,d=u.length-1;d>=0;--d)if(!Wu(l,u[d])){var v=u[d],y=a[d],g=s.A_(v);if(y instanceof wu||y instanceof Au&&y.l_ instanceof wu)l.push(v);else{var m=Fu(y,g);null!=m&&(l.push(v),p.set(v,m))}}var w=new hn(l);return new Lu(p.Xe(),w,s.fieldTransforms)}function Cu(t,e,n,r){return void 0===r&&(r=!1),Fu(n,t.P_(r?4:3,e))}function Fu(t,e){if(t instanceof Au&&(t=t.l_),qu(t))return ju("Unsupported field value:",e,t),Mu(t,e);if(t instanceof mu)return function(t,e){if(!ku(e.s_))throw e.i_(t.e_+"() can only be used with update() and set()");if(!e.path)throw e.i_(t.e_+"() is not currently supported inside arrays");var n=t.n_(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(e.path&&e.We.push(e.path),t instanceof Array){if(e.settings.o_&&4!==e.s_)throw e.i_("Nested arrays are not supported");return function(t,e){for(var n=[],r=0,i=0,o=t;i<o.length;i++){var s=Fu(o[i],e.R_(r));null==s&&(s={nullValue:"NULL_VALUE"}),n.push(s),r++}return{arrayValue:{values:n}}}(t,e)}return function(t,e){if(null===t)return{nullValue:"NULL_VALUE"};if("number"==typeof t)return be(e.serializer,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){var n=ut.fromDate(t);return{timestampValue:Ie(e.serializer,n)}}
2if(t instanceof ut){var r=new ut(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:Ie(e.serializer,r)}}if(t instanceof Nu)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof tt)return{bytesValue:Ee(e.serializer,t.q)};if(t instanceof Du){var i=e.U,o=t.__;if(!o.isEqual(i))throw e.i_("Document reference is for database "+o.projectId+"/"+o.database+" but should be for database "+i.projectId+"/"+i.database);return{referenceValue:Ae(t.__||e.U,t.f_.path)}}if(void 0===t&&e.ignoreUndefinedProperties)return null;throw e.i_("Unsupported field value: "+j(t))}(t,e)}function Mu(t,e){var n={};return E(t)?e.path&&e.path.length>0&&e.We.push(e.path):I(t,(function(t,r){var i=Fu(r,e.E_(t));null!=i&&(n[t]=i)})),{mapValue:{fields:n}}}function qu(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof ut||t instanceof Nu||t instanceof tt||t instanceof Du||t instanceof mu)}function ju(t,e,n){if(!qu(n)||!q(n)){var r=j(n);throw"an object"===r?e.i_(t+" a custom object"):e.i_(t+" "+r)}}function Gu(t,e,n){if(e instanceof vu)return e.t_;if("string"==typeof e)return zu(t,e);throw Bu("Field path arguments must be of type string or FieldPath.",t,!1,void 0,n)}function zu(t,e,n){try{return function(t){if(t.search(gu)>=0)throw new f(h.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not contain '~', '*', '/', '[', or ']'");try{return new(yu.bind.apply(yu,r.__spreadArrays([void 0],t.split("."))))}catch(r){throw new f(h.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'")}}(e).t_}catch(e){throw Bu((i=e)instanceof Error?i.message:i.toString(),t,!1,void 0,n)}var i}function Bu(t,e,n,r,i){var o=r&&!r.m(),s=void 0!==i,u="Function "+e+"() called with invalid data";n&&(u+=" (via `toFirestore()`)");var a="";return(o||s)&&(a+=" (found",o&&(a+=" in field "+r),s&&(a+=" in document "+i),a+=")"),new f(h.INVALID_ARGUMENT,(u+=". ")+t+a)}function Wu(t,e){return t.some((function(t){return t.isEqual(e)}))}var Ku=function(){function t(t){this.Ku=t,this.y_=new Map,this.mutations=[],this.V_=!1,this.p_=null,this.b_=new Set}return t.prototype.v_=function(t){return r.__awaiter(this,void 0,void 0,(function(){var e,n=this;return r.__generator(this,(function(i){switch(i.label){case 0:if(this.S_(),this.mutations.length>0)throw new f(h.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,function(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o,s,u,a;return r.__generator(this,(function(r){switch(r.label){case 0:return n=_(t),i=Re(n.serializer)+"/documents",o={documents:e.map((function(t){return De(n.serializer,t)}))},[4,n.ku("BatchGetDocuments",i,o)];
2case 1:return s=r.sent(),u=new Map,s.forEach((function(t){var e=function(t,e){return"found"in e?function(t,e){w(!!e.found),e.found.name,e.found.updateTime;var n=xe(t,e.found.name),r=Ne(e.found.updateTime),i=new xn({mapValue:{fields:e.found.fields}});return new On(n,r,i,{})}(t,e):"missing"in e?function(t,e){w(!!e.missing),w(!!e.readTime);var n=xe(t,e.missing),r=Ne(e.readTime);return new Pn(n,r)}(t,e):m()}(n.serializer,t);u.set(e.key.toString(),e)})),a=[],[2,(e.forEach((function(t){var e=u.get(t.toString());w(!!e),a.push(e)})),a)]}}))}))}(this.Ku,t)];case 1:return[2,((e=i.sent()).forEach((function(t){t instanceof Pn||t instanceof On?n.D_(t):m()})),e)]}}))}))},t.prototype.set=function(t,e){this.write(e.w_(t,this.Ge(t))),this.b_.add(t.toString())},t.prototype.update=function(t,e){try{this.write(e.w_(t,this.C_(t)))}catch(t){this.p_=t}this.b_.add(t.toString())},t.prototype.delete=function(t){this.write([new Sn(t,this.Ge(t))]),this.b_.add(t.toString())},t.prototype.commit=function(){return r.__awaiter(this,void 0,void 0,(function(){var t,e=this;return r.__generator(this,(function(n){switch(n.label){case 0:if(this.S_(),this.p_)throw this.p_;return t=this.y_,this.mutations.forEach((function(e){t.delete(e.key.toString())})),t.forEach((function(t,n){var r=D.D(n);e.mutations.push(new Dn(r,e.Ge(r)))})),[4,function(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o;return r.__generator(this,(function(r){switch(r.label){case 0:return n=_(t),i=Re(n.serializer)+"/documents",o={writes:e.map((function(t){return Ve(n.serializer,t)}))},[4,n.$u("Commit",i,o)];case 1:return r.sent(),[2]}}))}))}(this.Ku,this.mutations)];case 1:return n.sent(),this.V_=!0,[2]}}))}))},t.prototype.D_=function(t){var e;if(t instanceof On)e=t.version;else{if(!(t instanceof Pn))throw m();e=at.min()}var n=this.y_.get(t.key.toString());if(n){if(!e.isEqual(n))throw new f(h.ABORTED,"Document version changed between two reads.")}else this.y_.set(t.key.toString(),e)},t.prototype.Ge=function(t){var e=this.y_.get(t.toString());return!this.b_.has(t.toString())&&e?pn.updateTime(e):pn.ze()},t.prototype.C_=function(t){var e=this.y_.get(t.toString());if(!this.b_.has(t.toString())&&e){if(e.isEqual(at.min()))throw new f(h.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return pn.updateTime(e)}return pn.exists(!0)},t.prototype.write=function(t){this.S_(),this.mutations=this.mutations.concat(t)},t.prototype.S_=function(){},t}(),Qu=function(){function t(t,e,n,r){this.cs=t,this.Ku=e,this.updateFunction=n,this.ls=r,this.N_=5,this.ys=new gr(this.cs,"transaction_retry")}return t.prototype.run=function(){this.F_()},t.prototype.F_=function(){var t=this;this.ys.gn((function(){return r.__awaiter(t,void 0,void 0,(function(){var t,e,n=this;return r.__generator(this,(function(r){return t=new Ku(this.Ku),(e=this.x_(t))&&e.then((function(e){n.cs.ws((function(){return t.commit().then((function(){n.ls.resolve(e)})).catch((function(t){n.k_(t)}))}))})).catch((function(t){n.k_(t)})),[2]}))}))}))},t.prototype.x_=function(t){try{var e=this.updateFunction(t);return!ct(e)&&e.catch&&e.then?e:(this.ls.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.ls.reject(t),null}},t.prototype.k_=function(t){var e=this;this.N_>0&&this.M_(t)?(this.N_-=1,this.cs.ws((function(){return e.F_(),Promise.resolve()}))):this.ls.reject(t)},t.prototype.M_=function(t){if("FirebaseError"===t.name){var e=t.code;return"aborted"===e||"failed-precondition"===e||!bt(e)}return!1},t}(),Hu=function(){function t(t,e){this.credentials=t,this.cs=e,this.clientId=Y.k(),this.O_=new yr}return t.prototype.start=function(t,e,n,i){var o=this;this.L_(),this.bl=t;var s=new yr,u=!1;return this.credentials.Hc((function(t){if(!u)return u=!0,d("FirestoreClient","Initializing. user=",t.uid),o.B_(e,n,i,t,s).then(o.O_.resolve,o.O_.reject);o.cs.Cs((function(){return function(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i;return r.__generator(this,(function(r){switch(r.label){case 0:return(n=_(t)).cs.xs(),d("RemoteStore","RemoteStore received new credentials"),i=Zo(n),n.Yu.add(3),[4,Wo(n)];case 1:return r.sent(),i&&n.th.set("Unknown"),[4,n.Gu.Jl(e)];case 2:return r.sent(),n.Yu.delete(3),[4,Bo(n)];case 3:return r.sent(),[2]}}))}))}(o.ph,t)}))})),this.cs.ws((function(){return o.O_.promise})),s.promise},t.prototype.enableNetwork=function(){var t=this;return this.L_(),this.cs.enqueue((function(){return t.persistence.tc(!0),function(t){var e=_(t);return e.Yu.delete(0),Bo(e)}(t.ph)}))},t.prototype.B_=function(t,e,n,i,o){return r.__awaiter(this,void 0,void 0,(function(){var s,u,a=this;return r.__generator(this,(function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),s={cs:this.cs,bl:this.bl,clientId:this.clientId,credentials:this.credentials,Wl:i,Dh:100,persistenceSettings:n},[4,t.initialize(s)];case 1:return c.sent(),[4,e.initialize(t,s)];case 2:return c.sent(),this.persistence=t.persistence,this.Sh=t.Sh,this.ju=t.ju,this.ql=t.ql,this.Ku=e.Ku,this.ph=e.ph,this.fi=e.fi,this.q_=e.bh,this.q_.Us=Is.bind(null,this.fi),this.q_.js=Ts.bind(null,this.fi),this.persistence.Za((function(){return r.__awaiter(a,void 0,void 0,(function(){return r.__generator(this,(function(t){switch(t.label){case 0:return[4,this.terminate()];case 1:return t.sent(),[2]}}))}))})),o.resolve(),[3,4];case 3:if(u=c.sent(),o.reject(u),!this.U_(u))throw u;return[2,(console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+u),this.B_(new fu,new pu,{jl:!1},i,o))];case 4:return[2]}}
2))}))},t.prototype.U_=function(t){return"FirebaseError"===t.name?t.code===h.FAILED_PRECONDITION||t.code===h.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code},t.prototype.L_=function(){if(this.cs.ps)throw new f(h.FAILED_PRECONDITION,"The client has already been terminated.")},t.prototype.disableNetwork=function(){var t=this;return this.L_(),this.cs.enqueue((function(){return t.persistence.tc(!1),function(t){return r.__awaiter(this,void 0,void 0,(function(){var e;return r.__generator(this,(function(n){switch(n.label){case 0:return(e=_(t)).Yu.add(0),[4,Wo(e)];case 1:return n.sent(),e.th.set("Offline"),[2]}}))}))}(t.ph)}))},t.prototype.terminate=function(){var t=this;this.cs.Ds();var e=new yr;return this.cs.bs((function(){return r.__awaiter(t,void 0,void 0,(function(){var t,n;return r.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,4,,5]),this.ql&&this.ql.stop(),[4,Ko(this.ph)];case 1:return r.sent(),[4,this.Sh.Di()];case 2:return r.sent(),[4,this.persistence.Di()];case 3:return r.sent(),this.credentials.Yc(),e.resolve(),[3,5];case 4:return t=r.sent(),n=Rr(t,"Failed to shutdown persistence"),e.reject(n),[3,5];case 5:return[2]}}
2))}))})),e.promise},t.prototype.waitForPendingWrites=function(){var t=this;this.L_();var e=new yr;return this.cs.ws((function(){return function(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o,s,u;return r.__generator(this,(function(r){switch(r.label){case 0:Zo((n=_(t)).ph)||d("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,function(t){var e=_(t);return e.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(function(t){return e.Sr.qo(t)}))}(n.ju)];case 2:return-1===(i=r.sent())?[2,void e.resolve()]:((o=n.Lh.get(i)||[]).push(e),n.Lh.set(i,o),[3,4]);case 3:return s=r.sent(),u=Rr(s,"Initialization of waitForPendingWrites() operation failed"),e.reject(u),[3,4];case 4:return[2]}}))}))}(t.fi,e)})),e.promise},t.prototype.listen=function(t,e,n){var r=this;this.L_();var i=new du(n),o=new qr(t,i,e);return this.cs.ws((function(){return Vr(r.q_,o)})),function(){i.Zl(),r.cs.ws((function(){return Ur(r.q_,o)}))}},t.prototype.Q_=function(t){return r.__awaiter(this,void 0,void 0,(function(){var e,n=this;return r.__generator(this,(function(i){switch(i.label){case 0:return this.L_(),[4,this.O_.promise];case 1:return i.sent(),e=new yr,[2,(this.cs.ws((function(){return function(t,e,n){return r.__awaiter(this,void 0,void 0,(function(){var i,o,s;return r.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,function(t,e){var n=_(t);return n.persistence.runTransaction("read document","readonly",(function(t){return n.Cc.Cr(t,e)}))}(t,e)];case 1:return(i=r.sent())instanceof On?n.resolve(i):i instanceof Pn?n.resolve(null):n.reject(new f(h.UNAVAILABLE,"Failed to get document from cache. (However, this document may exist on the server. Run again without setting 'source' in the GetOptions to attempt to retrieve the document from the server.)")),[3,3];case 2:return o=r.sent(),s=Rr(o,"Failed to get document '"+e+" from cache"),n.reject(s),[3,3];case 3:return[2]}}
2))}))}(n.ju,t,e)})),e.promise)]}}))}))},t.prototype.W_=function(t,e){return void 0===e&&(e={}),r.__awaiter(this,void 0,void 0,(function(){var n,i=this;return r.__generator(this,(function(r){switch(r.label){case 0:return this.L_(),[4,this.O_.promise];case 1:return r.sent(),n=new yr,[2,(this.cs.ws((function(){return function(t,e,n,r,i){var o=new du({next:function(o){e.ws((function(){return Ur(t,s)}));var u=o.docs.has(n);!u&&o.fromCache?i.reject(new f(h.UNAVAILABLE,"Failed to get document because the client is offline.")):u&&o.fromCache&&r&&"server"===r.source?i.reject(new f(h.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(o)},error:function(t){return i.reject(t)}}),s=new qr(Fn(n.path),o,{includeMetadataChanges:!0,Xs:!0});return Vr(t,s)}(i.q_,i.cs,t,e,n)})),n.promise)]}}))}))},t.prototype.j_=function(t){return r.__awaiter(this,void 0,void 0,(function(){var e,n=this;return r.__generator(this,(function(i){switch(i.label){case 0:return this.L_(),[4,this.O_.promise];case 1:return i.sent(),e=new yr,[2,(this.cs.ws((function(){return function(t,e,n){return r.__awaiter(this,void 0,void 0,(function(){var i,o,s,u,a,c;return r.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,Ao(t,e,!0)];case 1:return i=r.sent(),o=new ms(e,i.Fc),s=o.wh(i.documents),u=o.yr(s,!1),n.resolve(u.snapshot),[3,3];case 2:return a=r.sent(),c=Rr(a,"Failed to execute query '"+e+" against cache"),n.reject(c),[3,3];case 3:return[2]}}
2))}))}(n.ju,t,e)})),e.promise)]}}))}))},t.prototype.K_=function(t,e){return void 0===e&&(e={}),r.__awaiter(this,void 0,void 0,(function(){var n,i=this;return r.__generator(this,(function(r){switch(r.label){case 0:return this.L_(),[4,this.O_.promise];case 1:return r.sent(),n=new yr,[2,(this.cs.ws((function(){return function(t,e,n,r,i){var o=new du({next:function(n){e.ws((function(){return Ur(t,s)})),n.fromCache&&"server"===r.source?i.reject(new f(h.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:function(t){return i.reject(t)}}),s=new qr(n,o,{includeMetadataChanges:!0,Xs:!0});return Vr(t,s)}(i.q_,i.cs,t,e,n)})),n.promise)]}}))}))},t.prototype.write=function(t){var e=this;this.L_();var n=new yr;return this.cs.ws((function(){return function(t,e,n){return r.__awaiter(this,void 0,void 0,(function(){var i,o,s,u;return r.__generator(this,(function(r){switch(r.label){case 0:i=Ys(t),r.label=1;case 1:return r.trys.push([1,5,,6]),[4,function(t,e){var n,r=_(t),i=ut.now(),o=e.reduce((function(t,e){return t.add(e.key)}),Vt());return r.persistence.runTransaction("Locally write mutations","readwrite",(function(t){return r.Cc.kr(t,o).next((function(o){n=o;for(var s=[],u=0,a=e;u<a.length;u++){var c=a[u],h=mn(c,n.get(c.key));null!=h&&s.push(new In(c.key,h,kn(h.proto.mapValue),pn.exists(!0)))}return r.Sr.ko(t,i,s,e)}))})).then((function(t){var e=t.lr(n);return{batchId:t.batchId,wr:e}}))}(i.ju,e)];case 2:return o=r.sent(),i.Sh.xi(o.batchId),function(t,e,n){var r=t.Oh[t.currentUser.ti()];r||(r=new Et($)),r=r.ot(e,n),t.Oh[t.currentUser.ti()]=r}(i,o.batchId,n),[4,Cs(i,o.wr)];case 3:return r.sent(),[4,ss(i.ph)];case 4:return r.sent(),[3,6];case 5:return s=r.sent(),u=Rr(s,"Failed to persist write"),n.reject(u),[3,6];case 6:return[2]}}
2))}))}(e.fi,t,n)})),n.promise},t.prototype.U=function(){return this.bl.U},t.prototype.G_=function(t){var e=this;this.L_();var n=new du(t);return this.cs.ws((function(){return r.__awaiter(e,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,function(t,e){_(t).qs.add(e),e.next()}(this.q_,n)]}))}))})),function(){n.Zl(),e.cs.ws((function(){return r.__awaiter(e,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,function(t,e){_(t).qs.delete(e)}(this.q_,n)]}))}))}))}},Object.defineProperty(t.prototype,"z_",{get:function(){return this.cs.ps},enumerable:!1,configurable:!0}),t.prototype.transaction=function(t){var e=this;this.L_();var n=new yr;return this.cs.ws((function(){return new Qu(e.cs,e.Ku,t,n).run(),Promise.resolve()})),n.promise},t}();function Yu(t){return function(t){if("object"!=typeof t||null===t)return!1;for(var e=t,n=0,r=["next","error","complete"];n<r.length;n++){var i=r[n];if(i in e&&"function"==typeof e[i])return!0}return!1}(t)}var $u=function(){function t(t,e,n,r,i){this.U=t,this.timestampsInSnapshots=e,this.H_=n,this.Y_=r,this.J_=i}return t.prototype.X_=function(t){switch(te(t)){case 0:return null;case 1:return t.booleanValue;case 2:return ae(t.integerValue||t.doubleValue);case 3:return this.Z_(t.timestampValue);case 4:return this.tf(t);case 5:return t.stringValue;case 6:return this.J_(ce(t.bytesValue));case 7:return this.ef(t.referenceValue);case 8:return this.nf(t.geoPointValue);case 9:return this.sf(t.arrayValue);case 10:return this.if(t.mapValue);default:throw m()}},t.prototype.if=function(t){var e=this,n={};return I(t.fields||{},(function(t,r){n[t]=e.X_(r)})),n},t.prototype.nf=function(t){return new Nu(ae(t.latitude),ae(t.longitude))},t.prototype.sf=function(t){var e=this;return(t.values||[]).map((function(t){return e.X_(t)}))},t.prototype.tf=function(t){switch(this.H_){case"previous":var e=Xt(t);return null==e?null:this.X_(e);case"estimate":return this.Z_(Jt(t));default:return null}},t.prototype.Z_=function(t){var e=ue(t),n=new ut(e.seconds,e.nanos);return this.timestampsInSnapshots?n:n.toDate()},t.prototype.ef=function(t){var e=N.g(t);w($e(e));var n=new ot(e.get(1),e.get(3)),r=new D(e.u(5));return n.isEqual(this.U)||v("Document "+r+" 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 ("+this.U.projectId+"/"+this.U.database+") instead."),this.Y_(r)},t}(),Xu=ci.ho,Ju=function(){function t(t){var e,n,r,i,o;if(void 0===t.host){if(void 0!==t.ssl)throw new f(h.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else V("settings","non-empty string","host",t.host),this.host=t.host,U("settings","boolean","ssl",t.ssl),this.ssl=null===(e=t.ssl)||void 0===e||e;if(z("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling","experimentalAutoDetectLongPolling","ignoreUndefinedProperties"]),U("settings","object","credentials",t.credentials),this.credentials=t.credentials,U("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),U("settings","boolean","ignoreUndefinedProperties",t.ignoreUndefinedProperties),!0===t.timestampsInSnapshots?v("The setting 'timestampsInSnapshots: true' is no longer required and should be removed."):!1===t.timestampsInSnapshots&&v("Support for 'timestampsInSnapshots: false' will be removed soon. You must update your code to handle Timestamp objects."),this.timestampsInSnapshots=null===(n=t.timestampsInSnapshots)||void 0===n||n,this.ignoreUndefinedProperties=null!==(r=t.ignoreUndefinedProperties)&&void 0!==r&&r,U("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=ci._o;
2else{if(t.cacheSizeBytes!==Xu&&t.cacheSizeBytes<ci.lo)throw new f(h.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+ci.lo);this.cacheSizeBytes=t.cacheSizeBytes}U("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.experimentalForceLongPolling=null!==(i=t.experimentalForceLongPolling)&&void 0!==i&&i,U("settings","boolean","experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling),this.experimentalAutoDetectLongPolling=null!==(o=t.experimentalAutoDetectLongPolling)&&void 0!==o&&o,function(t,e,n,r){if(!0===e&&!0===r)throw new f(h.INVALID_ARGUMENT,"experimentalForceLongPolling and experimentalAutoDetectLongPolling cannot be used together.")}(0,t.experimentalForceLongPolling,0,t.experimentalAutoDetectLongPolling)}return t.prototype.isEqual=function(t){return this.host===t.host&&this.ssl===t.ssl&&this.timestampsInSnapshots===t.timestampsInSnapshots&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties},t}(),Zu=function(){function t(e,n,i,o){var s=this;if(void 0===i&&(i=new fu),void 0===o&&(o=new pu),this.rf=i,this.af=o,this.cf=null,this.uf=new kr,this.INTERNAL={delete:function(){return r.__awaiter(s,void 0,void 0,(function(){return r.__generator(this,(function(t){switch(t.label){case 0:return this.hf(),[4,this.lf.terminate()];case 1:return t.sent(),[2]}}))}))}},"object"==typeof e.options){var u=e;this.cf=u,this.__=t._f(u),this.ff=u.name,this.df=new Vo(n)}else{var a=e;if(!a.projectId)throw new f(h.INVALID_ARGUMENT,"Must provide projectId");this.__=new ot(a.projectId,a.database),this.ff="[DEFAULT]",this.df=new Po}this.wf=new Ju({})}return Object.defineProperty(t.prototype,"mf",{get:function(){return this.Tf||(this.Tf=new Ou(this.__,this.wf.ignoreUndefinedProperties)),this.Tf},enumerable:!1,configurable:!0}),t.prototype.settings=function(t){L("Firestore.settings",arguments,1),O("Firestore.settings","object",1,t),t.merge&&delete(t=Object.assign(Object.assign({},this.wf),t)).merge;var e=new Ju(t);if(this.lf&&!this.wf.isEqual(e))throw new f(h.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only call settings() before calling any other methods on a Firestore object.");this.wf=e,void 0!==e.credentials&&(this.df=function(t){if(!t)return new Po;switch(t.type){case"gapi":var e=t.client;return w(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new Co(e,t.sessionIndex||"0");case"provider":return t.client;default:throw new f(h.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(e.credentials))},t.prototype.enableNetwork=function(){return this.hf(),this.lf.enableNetwork()},t.prototype.disableNetwork=function(){return this.hf(),this.lf.disableNetwork()},t.prototype.enablePersistence=function(t){var e,n;if(this.lf)throw new f(h.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only call enablePersistence() before calling any other methods on a Firestore object.");var r=!1,i=!1;if(t&&(void 0!==t.experimentalTabSynchronization&&v("The 'experimentalTabSynchronization' setting will be removed. Use 'synchronizeTabs' instead."),r=null!==(n=null!==(e=t.synchronizeTabs)&&void 0!==e?e:t.experimentalTabSynchronization)&&void 0!==n&&n,i=!!t.experimentalForceOwningTab&&t.experimentalForceOwningTab,r&&i))throw new f(h.INVALID_ARGUMENT,"The 'experimentalForceOwningTab' setting cannot be used with 'synchronizeTabs'.");return this.Ef(this.rf,this.af,{jl:!0,cacheSizeBytes:this.wf.cacheSizeBytes,synchronizeTabs:r,ka:i})},t.prototype.clearPersistence=function(){return r.__awaiter(this,void 0,void 0,(function(){var t,e=this;return r.__generator(this,(function(n){if(void 0!==this.lf&&!this.lf.z_)throw new f(h.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");return t=new yr,[2,(this.uf.bs((function(){return r.__awaiter(e,void 0,void 0,(function(){var e;return r.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.rf.clearPersistence(this.__,this.ff)];case 1:return n.sent(),t.resolve(),[3,3];case 2:return e=n.sent(),t.reject(e),[3,3];case 3:return[2]}}
2))}))})),t.promise)]}))}))},t.prototype.terminate=function(){return this.app._removeServiceInstance("firestore"),this.INTERNAL.delete()},Object.defineProperty(t.prototype,"If",{get:function(){return this.hf(),this.lf.z_},enumerable:!1,configurable:!0}),t.prototype.waitForPendingWrites=function(){return this.hf(),this.lf.waitForPendingWrites()},t.prototype.onSnapshotsInSync=function(t){if(this.hf(),Yu(t))return this.lf.G_(t);O("Firestore.onSnapshotsInSync","function",1,t);var e={next:t};return this.lf.G_(e)},t.prototype.hf=function(){return this.lf||this.Ef(new fu,new pu,{jl:!1}),this.lf},t.prototype.Af=function(){return new it(this.__,this.ff,this.wf.host,this.wf.ssl,this.wf.experimentalForceLongPolling,this.wf.experimentalAutoDetectLongPolling)},t.prototype.Ef=function(t,e,n){var r=this.Af();return this.lf=new Hu(this.df,this.uf),this.lf.start(r,t,e,n)},t._f=function(t){if(e=t.options,!Object.prototype.hasOwnProperty.call(e,"projectId"))throw new f(h.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');var e,n=t.options.projectId;if(!n||"string"!=typeof n)throw new f(h.INVALID_ARGUMENT,"projectId must be a string in FirebaseApp.options");return new ot(n)},Object.defineProperty(t.prototype,"app",{get:function(){if(!this.cf)throw new f(h.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.cf},enumerable:!1,configurable:!0}),t.prototype.collection=function(t){return L("Firestore.collection",arguments,1),O("Firestore.collection","non-empty string",1,t),this.hf(),new la(N.g(t),this,null)},t.prototype.doc=function(t){return L("Firestore.doc",arguments,1),O("Firestore.doc","non-empty string",1,t),this.hf(),na.Rf(N.g(t),this,null)},t.prototype.collectionGroup=function(t){if(L("Firestore.collectionGroup",arguments,1),O("Firestore.collectionGroup","non-empty string",1,t),t.indexOf("/")>=0)throw new f(h.INVALID_ARGUMENT,"Invalid collection ID '"+t+"' passed to function Firestore.collectionGroup(). Collection IDs must not contain '/'.");return this.hf(),new ha(function(t){return new Un(N.P(),t)}(t),this,null)},t.prototype.runTransaction=function(t){var e=this;return L("Firestore.runTransaction",arguments,1),O("Firestore.runTransaction","function",1,t),this.hf().transaction((function(n){return t(new ta(e,n))}))},t.prototype.batch=function(){return this.hf(),new ea(this)},Object.defineProperty(t,"logLevel",{get:function(){switch(p()){case o.LogLevel.DEBUG:return"debug";case o.LogLevel.ERROR:return"error";case o.LogLevel.SILENT:return"silent";case o.LogLevel.WARN:return"warn";case o.LogLevel.INFO:return"info";case o.LogLevel.VERBOSE:return"verbose";default:return"error"}},enumerable:!1,configurable:!0}),t.setLogLevel=function(t){var e;L("Firestore.setLogLevel",arguments,1),F("setLogLevel",["debug","error","silent","warn","info","verbose"],1,t),e=t,l.setLogLevel(e)},t.prototype.gf=function(){return this.wf.timestampsInSnapshots},t.prototype.Pf=function(){return this.wf},t}(),ta=function(){function t(t,e){this.yf=t,this.Vf=e}return t.prototype.get=function(t){var e=this;L("Transaction.get",arguments,1);var n=ya("Transaction.get",t,this.yf);return this.Vf.v_([n.f_]).then((function(t){if(!t||1!==t.length)return m();var r=t[0];if(r instanceof Pn)return new ia(e.yf,n.f_,null,!1,!1,n.d_);if(r instanceof On)return new ia(e.yf,n.f_,r,!1,!1,n.d_);throw m()}
2))},t.prototype.set=function(t,e,n){R("Transaction.set",arguments,2,3);var r=ya("Transaction.set",t,this.yf);n=pa("Transaction.set",n);var i=ma(r.d_,e,n),o=Pu(this.yf.mf,"Transaction.set",r.f_,i,null!==r.d_,n);return this.Vf.set(r.f_,o),this},t.prototype.update=function(t,e,n){for(var r,i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];return"string"==typeof e||e instanceof yu?(k("Transaction.update",arguments,3),r=ya("Transaction.update",t,this.yf),i=Uu(this.yf.mf,"Transaction.update",r.f_,e,n,o)):(L("Transaction.update",arguments,2),r=ya("Transaction.update",t,this.yf),i=Vu(this.yf.mf,"Transaction.update",r.f_,e)),this.Vf.update(r.f_,i),this},t.prototype.delete=function(t){L("Transaction.delete",arguments,1);var e=ya("Transaction.delete",t,this.yf);return this.Vf.delete(e.f_),this},t}(),ea=function(){function t(t){this.yf=t,this.pf=[],this.bf=!1}return t.prototype.set=function(t,e,n){R("WriteBatch.set",arguments,2,3),this.vf();var r=ya("WriteBatch.set",t,this.yf);n=pa("WriteBatch.set",n);var i=ma(r.d_,e,n),o=Pu(this.yf.mf,"WriteBatch.set",r.f_,i,null!==r.d_,n);return this.pf=this.pf.concat(o.w_(r.f_,pn.ze())),this},t.prototype.update=function(t,e,n){for(var r,i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];return this.vf(),"string"==typeof e||e instanceof yu?(k("WriteBatch.update",arguments,3),r=ya("WriteBatch.update",t,this.yf),i=Uu(this.yf.mf,"WriteBatch.update",r.f_,e,n,o)):(L("WriteBatch.update",arguments,2),r=ya("WriteBatch.update",t,this.yf),i=Vu(this.yf.mf,"WriteBatch.update",r.f_,e)),this.pf=this.pf.concat(i.w_(r.f_,pn.exists(!0))),this},t.prototype.delete=function(t){L("WriteBatch.delete",arguments,1),this.vf();var e=ya("WriteBatch.delete",t,this.yf);return this.pf=this.pf.concat(new Sn(e.f_,pn.ze())),this},t.prototype.commit=function(){return this.vf(),this.bf=!0,this.pf.length>0?this.yf.hf().write(this.pf):Promise.resolve()},t.prototype.vf=function(){if(this.bf)throw new f(h.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},t}(),na=function(t){function e(e,n,r){var i=this;return(i=t.call(this,n.__,e,r)||this).f_=e,i.firestore=n,i.d_=r,i.lf=i.firestore.hf(),i}return r.__extends(e,t),e.Rf=function(t,n,r){if(t.length%2!=0)throw new f(h.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.R()+" has "+t.length);return new e(new D(t),n,r)},Object.defineProperty(e.prototype,"id",{get:function(){return this.f_.path._()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return new la(this.f_.path.h(),this.firestore,this.d_)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this.f_.path.R()},enumerable:!1,configurable:!0}),e.prototype.collection=function(t){if(L("DocumentReference.collection",arguments,1),O("DocumentReference.collection","non-empty string",1,t),!t)throw new f(h.INVALID_ARGUMENT,"Must provide a non-empty collection name to collection()");var e=N.g(t);return new la(this.f_.path.child(e),this.firestore,null)},e.prototype.isEqual=function(t){if(!(t instanceof e))throw B("isEqual","DocumentReference",1,t);return this.firestore===t.firestore&&this.f_.isEqual(t.f_)&&this.d_===t.d_},e.prototype.set=function(t,e){R("DocumentReference.set",arguments,1,2),e=pa("DocumentReference.set",e);var n=ma(this.d_,t,e),r=Pu(this.firestore.mf,"DocumentReference.set",this.f_,n,null!==this.d_,e);return this.lf.write(r.w_(this.f_,pn.ze()))},e.prototype.update=function(t,e){for(var n,r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];return"string"==typeof t||t instanceof yu?(k("DocumentReference.update",arguments,2),n=Uu(this.firestore.mf,"DocumentReference.update",this.f_,t,e,r)):(L("DocumentReference.update",arguments,1),n=Vu(this.firestore.mf,"DocumentReference.update",this.f_,t)),this.lf.write(n.w_(this.f_,pn.exists(!0)))},e.prototype.delete=function(){return L("DocumentReference.delete",arguments,0),this.lf.write([new Sn(this.f_,pn.ze())])},e.prototype.onSnapshot=function(){for(var t,e,n,r=this,i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];R("DocumentReference.onSnapshot",arguments,1,4);var s={includeMetadataChanges:!1},u=0;"object"!=typeof i[u]||Yu(i[u])||(z("DocumentReference.onSnapshot",s=i[u],["includeMetadataChanges"]),U("DocumentReference.onSnapshot","boolean","includeMetadataChanges",s.includeMetadataChanges),u++);var a={includeMetadataChanges:s.includeMetadataChanges};if(Yu(i[u])){var c=i[u];i[u]=null===(t=c.next)||void 0===t?void 0:t.bind(c),i[u+1]=null===(e=c.error)||void 0===e?void 0:e.b
2ind(c),i[u+2]=null===(n=c.complete)||void 0===n?void 0:n.bind(c)}else O("DocumentReference.onSnapshot","function",u,i[u]),P("DocumentReference.onSnapshot","function",u+1,i[u+1]),P("DocumentReference.onSnapshot","function",u+2,i[u+2]);var h={next:function(t){i[u]&&i[u](r.Sf(t))},error:i[u+1],complete:i[u+2]};return this.lf.listen(Fn(this.f_.path),a,h)},e.prototype.get=function(t){var e=this;R("DocumentReference.get",arguments,0,1),va("DocumentReference.get",t);var n=this.firestore.hf();return t&&"cache"===t.source?n.Q_(this.f_).then((function(t){return new ia(e.firestore,e.f_,t,!0,t instanceof On&&t.Je,e.d_)})):n.W_(this.f_,t).then((function(t){return e.Sf(t)}))},e.prototype.withConverter=function(t){return new e(this.f_,this.firestore,t)},e.prototype.Sf=function(t){var e=t.docs.get(this.f_);return new ia(this.firestore,this.f_,e,t.fromCache,t.hasPendingWrites,this.d_)},e}(Du),ra=function(){function t(t,e){this.hasPendingWrites=t,this.fromCache=e}return t.prototype.isEqual=function(t){return this.hasPendingWrites===t.hasPendingWrites&&this.fromCache===t.fromCache},t}(),ia=function(){function t(t,e,n,r,i,o){this.yf=t,this.f_=e,this.Df=n,this.Cf=r,this.Nf=i,this.d_=o}return t.prototype.data=function(t){var e=this;if(R("DocumentSnapshot.data",arguments,0,1),t=da("DocumentSnapshot.data",t),this.Df){if(this.d_){var n=new oa(this.yf,this.f_,this.Df,this.Cf,this.Nf,null);return this.d_.fromFirestore(n,t)}return new $u(this.yf.__,this.yf.gf(),t.serverTimestamps||"none",(function(t){return new na(t,e.yf,null)}),(function(t){return new rt(t)})).X_(this.Df.rn())}},t.prototype.get=function(t,e){var n=this;if(R("DocumentSnapshot.get",arguments,1,2),e=da("DocumentSnapshot.get",e),this.Df){var r=this.Df.data().field(Gu("DocumentSnapshot.get",t,this.f_));if(null!==r)return new $u(this.yf.__,this.yf.gf(),e.serverTimestamps||"none",(function(t){return new na(t,n.yf,n.d_)}),(function(t){return new rt(t)})).X_(r)}},Object.defineProperty(t.prototype,"id",{get:function(){return this.f_.path._()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ref",{get:function(){return new na(this.f_,this.yf,this.d_)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"exists",{get:function(){return null!==this.Df},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metadata",{get:function(){return new ra(this.Nf,this.Cf)},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){if(!(e instanceof t))throw B("isEqual","DocumentSnapshot",1,e);return this.yf===e.yf&&this.Cf===e.Cf&&this.f_.isEqual(e.f_)&&(null===this.Df?null===e.Df:this.Df.isEqual(e.Df))&&this.d_===e.d_},t}(),oa=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.prototype.data=function(e){return t.prototype.data.call(this,e)},e}(ia);function sa(t,e,n){if("string"==typeof n){if(""===n)throw new f(h.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!zn(e)&&-1!==n.indexOf("/"))throw new f(h.INVALID_ARGUMENT,"Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '"+n+"' contains a '/' character.");var r=e.path.child(N.g(n));if(!D.F(r))throw new f(h.INVALID_ARGUMENT,"Invalid query. When querying a collection group by FieldPath.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 he(t,new D(r))}if(n instanceof Du)return he(t,n.f_);throw new f(h.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+j(n)+".")}function ua(t,e){if(!Array.isArray(t)||0===t.length)throw new f(h.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(t.length>10)throw new f(h.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.");if("in"===e||"array-contains-any"===e){if(t.indexOf(null)>=0)throw new f(h.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'null' in the value array.");if(t.filter((function(t){return Number.isNaN(t)})).length>0)throw new f(h.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'NaN' in the value array.")}}function aa(t,e,n){if(!n.isEqual(e))throw new f(h.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, >, or >=) on field '"+e.toString()+"' and so you must also use '"+e.toString()+"' as your first orderBy(), but your first orderBy() is on field '"+n.toString()+"' instead.")}function ca(t){if(qn(t)&&0===t.on.length)throw new f(h.UNIMPLEMENT
2ED,"limitToLast() queries require specifying at least one orderBy() clause")}var ha=function(){function t(t,e,n){this.Ff=t,this.firestore=e,this.d_=n}return t.prototype.where=function(e,n,r){L("Query.where",arguments,3),G("Query.where",3,r);var i=F("Query.where",["<","<=","==","!=",">=",">","array-contains","in","array-contains-any","not-in"],2,n),o=Gu("Query.where",e),s=function(t,e,n,r,i,o,s){var u;if(i.p()){if("array-contains"===o||"array-contains-any"===o)throw new f(h.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o+"' queries on FieldPath.documentId().");if("in"===o||"not-in"===o){ua(s,o);for(var a=[],c=0,l=s;c<l.length;c++){var p=l[c];a.push(sa(r,t,p))}u={arrayValue:{values:a}}}else u=sa(r,t,s)}else"in"!==o&&"not-in"!==o&&"array-contains-any"!==o||ua(s,o),u=Cu(n,e,s,"in"===o||"not-in"===o);var d=tr.create(i,o,u);return function(t,e){if(e.hn()){var n=Gn(t);if(null!==n&&!n.isEqual(e.field))throw new f(h.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, >, or >=) must be on the same field. But you have inequality filters on '"+n.toString()+"' and '"+e.field.toString()+"'");var r=jn(t);null!==r&&aa(0,e.field,r)}var i=function(t,e){for(var n=0,r=t.filters;n<r.length;n++){var i=r[n];if(e.indexOf(i.op)>=0)return i.op}return null}(t,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(null!==i)throw i===e.op?new f(h.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+e.op.toString()+"' filter."):new f(h.INVALID_ARGUMENT,"Invalid query. You cannot use '"+e.op.toString()+"' filters with '"+i.toString()+"' filters.")}(t,d),d}(this.Ff,"Query.where",this.firestore.mf,this.firestore.__,o,i,r);return new t(function(t,e){var n=t.filters.concat([e]);return new Un(t.path,t.collectionGroup,t.on.slice(),n,t.limit,t.an,t.startAt,t.endAt)}(this.Ff,s),this.firestore,this.d_)},t.prototype.orderBy=function(e,n){var r;if(R("Query.orderBy",arguments,1,2),P("Query.orderBy","non-empty string",2,n),void 0===n||"asc"===n)r="asc";else{if("desc"!==n)throw new f(h.INVALID_ARGUMENT,"Function Query.orderBy() has unknown direction '"+n+"', expected 'asc' or 'desc'.");r="desc"}var i=Gu("Query.orderBy",e),o=function(t,e,n){if(null!==t.startAt)throw new f(h.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new f(h.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r=new pr(e,n);return function(t,e){if(null===jn(t)){var n=Gn(t);null!==n&&aa(0,n,e.field)}}(t,r),r}(this.Ff,i,r);return new t(function(t,e){var n=t.on.concat([e]);return new Un(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.an,t.startAt,t.endAt)}(this.Ff,o),this.firestore,this.d_)},t.prototype.limit=function(e){return L("Query.limit",arguments,1),O("Query.limit","number",1,e),W("Query.limit",1,e),new t(Kn(this.Ff,e,"F"),this.firestore,this.d_)},t.prototype.limitToLast=function(e){return L("Query.limitToLast",arguments,1),O("Query.limitToLast","number",1,e),W("Query.limitToLast",1,e),new t(Kn(this.Ff,e,"L"),this.firestore,this.d_)},t.prototype.startAt=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];k("Query.startAt",arguments,1);var i=this.xf("Query.startAt",e,n,!0);return new t(Qn(this.Ff,i),this.firestore,this.d_)},t.prototype.startAfter=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];k("Query.startAfter",arguments,1);var i=this.xf("Query.startAfter",e,n,!1);return new t(Qn(this.Ff,i),this.firestore,this.d_)},t.prototype.endBefore=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];k("Query.endBefore",arguments,1);var i=this.xf("Query.endBefore",e,n,!0);return new t(Hn(this.Ff,i),this.firestore,this.d_)},t.prototype.endAt=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];
2k("Query.endAt",arguments,1);var i=this.xf("Query.endAt",e,n,!1);return new t(Hn(this.Ff,i),this.firestore,this.d_)},t.prototype.isEqual=function(e){if(!(e instanceof t))throw B("isEqual","Query",1,e);return this.firestore===e.firestore&&Yn(this.Ff,e.Ff)&&this.d_===e.d_},t.prototype.withConverter=function(e){return new t(this.Ff,this.firestore,e)},t.prototype.xf=function(t,e,n,i){if(G(t,1,e),e instanceof ia)return L(t,r.__spreadArrays([e],n),1),function(t,e,n,r,i){if(!r)throw new f(h.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+n+"().");for(var o=[],s=0,u=Bn(t);s<u.length;s++){var a=u[s];if(a.field.p())o.push(he(e,r.key));else{var c=r.field(a.field);if($t(c))throw new f(h.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+a.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===c){var l=a.field.R();throw new f(h.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+l+"' (used as the orderBy) does not exist.")}o.push(c)}}return new cr(o,i)}(this.Ff,this.firestore.__,t,e.Df,i);var o=[e].concat(n);return function(t,e,n,r,i,o){var s=t.on;if(i.length>s.length)throw new f(h.INVALID_ARGUMENT,"Too many arguments provided to "+r+"(). The number of arguments must be less than or equal to the number of orderBy() clauses");for(var u=[],a=0;a<i.length;a++){var c=i[a];if(s[a].field.p()){if("string"!=typeof c)throw new f(h.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+r+"(), but got a "+typeof c);if(!zn(t)&&-1!==c.indexOf("/"))throw new f(h.INVALID_ARGUMENT,"Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to "+r+"() must be a plain document ID, but '"+c+"' contains a slash.");var l=t.path.child(N.g(c));if(!D.F(l))throw new f(h.INVALID_ARGUMENT,"Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to "+r+"() must result in a valid document path, but '"+l+"' is not because it contains an odd number of segments.");var p=new D(l);u.push(he(e,p))}else{var d=Cu(n,r,c);u.push(d)}}return new cr(u,o)}(this.Ff,this.firestore.__,this.firestore.mf,t,o,i)},t.prototype.onSnapshot=function(){for(var t,e,n,r=this,i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];R("Query.onSnapshot",arguments,1,4);var s={},u=0;if("object"!=typeof i[u]||Yu(i[u])||(z("Query.onSnapshot",s=i[u],["includeMetadataChanges"]),U("Query.onSnapshot","boolean","includeMetadataChanges",s.includeMetadataChanges),u++),Yu(i[u])){var a=i[u];i[u]=null===(t=a.next)||void 0===t?void 0:t.bind(a),i[u+1]=null===(e=a.error)||void 0===e?void 0:e.bind(a),i[u+2]=null===(n=a.complete)||void 0===n?void 0:n.bind(a)}else O("Query.onSnapshot","function",u,i[u]),P("Query.onSnapshot","function",u+1,i[u+1]),P("Query.onSnapshot","function",u+2,i[u+2]);var c={next:function(t){i[u]&&i[u](new fa(r.firestore,r.Ff,t,r.d_))},error:i[u+1],complete:i[u+2]};return ca(this.Ff),this.firestore.hf().listen(this.Ff,s,c)},t.prototype.get=function(t){var e=this;R("Query.get",arguments,0,1),va("Query.get",t),ca(this.Ff);var n=this.firestore.hf();return(t&&"cache"===t.source?n.j_(this.Ff):n.K_(this.Ff,t)).then((function(t){return new fa(e.firestore,e.Ff,t,e.d_)}))},t}(),fa=function(){function t(t,e,n,r){this.yf=t,this.$f=e,this.kf=n,this.d_=r,this.Mf=null,this.Of=null,this.metadata=new ra(n.hasPendingWrites,n.fromCache)}return Object.defineProperty(t.prototype,"docs",{get:function(){var t=[];return this.forEach((function(e){return t.push(e)})),t},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"empty",{get:function(){return this.kf.docs.m()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this.kf.docs.size},enumerable:!1,configurable:!0}),t.prototype.forEach=function(t,e){var n=this;R("QuerySnapshot.forEach",arguments,1,2),O("QuerySnapshot.forEach","function",1,t),this.kf.docs.forEach((function(r){t.call(e,n.Lf(r,n.metadata.fromCache,n.kf.Wt.has(r.key)))}))},Object.defineProperty(t.prototype,"query",{get:function(){return new ha(this.$f,this.yf,this.d_)}
2,enumerable:!1,configurable:!0}),t.prototype.docChanges=function(t){t&&(z("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),U("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this.kf.Kt)throw new f(h.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this.Mf&&this.Of===e||(this.Mf=function(t,e,n){if(t.Qt.m()){var r=0;return t.docChanges.map((function(e){var i=n(e.doc,t.fromCache,t.Wt.has(e.doc.key));return e.doc,{type:"added",doc:i,oldIndex:-1,newIndex:r++}}))}var i=t.Qt;return t.docChanges.filter((function(t){return e||3!==t.type})).map((function(e){var r=n(e.doc,t.fromCache,t.Wt.has(e.doc.key)),o=-1,s=-1;return 0!==e.type&&(o=i.indexOf(e.doc.key),i=i.delete(e.doc.key)),1!==e.type&&(s=(i=i.add(e.doc)).indexOf(e.doc.key)),{type:ga(e.type),doc:r,oldIndex:o,newIndex:s}}))}(this.kf,e,this.Lf.bind(this)),this.Of=e),this.Mf},t.prototype.isEqual=function(e){if(!(e instanceof t))throw B("isEqual","QuerySnapshot",1,e);return this.yf===e.yf&&Yn(this.$f,e.$f)&&this.kf.isEqual(e.kf)&&this.d_===e.d_},t.prototype.Lf=function(t,e,n){return new oa(this.yf,t.key,t,e,n,this.d_)},t}(),la=function(t){function e(e,n,r){var i=this;if((i=t.call(this,Fn(e),n,r)||this).Bf=e,e.length%2!=1)throw new f(h.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+e.R()+" has "+e.length);return i}return r.__extends(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.Ff.path._()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){var t=this.Ff.path.h();return t.m()?null:new na(new D(t),this.firestore,null)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this.Ff.path.R()},enumerable:!1,configurable:!0}),e.prototype.doc=function(t){R("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=Y.k()),O("CollectionReference.doc","non-empty string",1,t);var e=N.g(t);return na.Rf(this.Ff.path.child(e),this.firestore,this.d_)},e.prototype.add=function(t){L("CollectionReference.add",arguments,1);var e=this.d_?this.d_.toFirestore(t):t;O("CollectionReference.add","object",1,e);var n=this.doc();return new na(n.f_,this.firestore,null).set(e).then((function(){return n}))},e.prototype.withConverter=function(t){return new e(this.Bf,this.firestore,t)},e}(ha);function pa(t,e){if(void 0===e)return{merge:!1};if(z(t,e,["merge","mergeFields"]),U(t,"boolean","merge",e.merge),function(t,e,n,r){void 0!==r&&function(t,e,n,r,i){if(!(r instanceof Array))throw new f(h.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+j(r));for(var o=0;o<r.length;++o)if(!i(r[o]))throw new f(h.INVALID_ARGUMENT,"Function "+t+"() requires all "+e+" elements to be "+n+", but the value at index "+o+" was: "+j(r[o]))}(t,"mergeFields","a string or a FieldPath",r,(function(t){return"string"==typeof t||t instanceof yu}))}(t,0,0,e.mergeFields),void 0!==e.mergeFields&&void 0!==e.merge)throw new f(h.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function da(t,e){return void 0===e?{}:(z(t,e,["serverTimestamps"]),C(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function va(t,e){P(t,"object",1,e),e&&(z(t,e,["source"]),C(t,0,"source",e.source,["default","server","cache"]))}function ya(t,e,n){if(e instanceof Du){if(e.firestore!==n)throw new f(h.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw B(t,"DocumentReference",1,e)}function ga(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return m()}}function ma(t,e,n){return t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e}var wa=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.serverTimestamp=function(){x("FieldValue.serverTimestamp",arguments);var t=new bu("serverTimestamp");return t.e_="FieldValue.serverTimestamp",new e(t)},e.delete=function(){x("FieldValue.delete",arguments);var t=new wu("deleteField");return t.e_="FieldValue.delete",new e(t)},e.arrayUnion=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];
2k("FieldValue.arrayUnion",arguments,1);var r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return k("arrayUnion()",arguments,1),new Iu("arrayUnion",t)}.apply(void 0,t);return r.e_="FieldValue.arrayUnion",new e(r)},e.arrayRemove=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];k("FieldValue.arrayRemove",arguments,1);var r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return k("arrayRemove()",arguments,1),new Eu("arrayRemove",t)}.apply(void 0,t);return r.e_="FieldValue.arrayRemove",new e(r)},e.increment=function(t){O("FieldValue.increment","number",1,t),L("FieldValue.increment",arguments,1);var n=function(t){return new Tu("increment",t)}(t);return n.e_="FieldValue.increment",new e(n)},e.prototype.isEqual=function(t){return this.l_.isEqual(t.l_)},e}(Au),_a={Firestore:Zu,GeoPoint:Nu,Timestamp:ut,Blob:rt,Transaction:ta,WriteBatch:ea,DocumentReference:na,DocumentSnapshot:ia,Query:ha,QueryDocumentSnapshot:oa,QuerySnapshot:fa,CollectionReference:la,FieldPath:yu,FieldValue:wa,setLogLevel:Zu.setLogLevel,CACHE_SIZE_UNLIMITED:Xu};function ba(t){!function(t){t.INTERNAL.registerComponent(new a.Component("firestore",(function(t){return function(t,e){var n=new pu,r=new lu(n);return new Zu(t,e,r,n)}(t.getProvider("app").getImmediate(),t.getProvider("auth-internal"))}),"PUBLIC").setServiceProps(Object.assign({},_a)))}(t),t.registerVersion("@firebase/firestore","1.18.0")}ba(c.default)}}]);
3//# sourceMappingURL=484bcb1e-686a5d2fc4b4a33ca491.js.map

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.