text: /*! For license information please see v758ba50aa82e6dea7f6837b447eec6a8d550df1d-33.064477ac520b575bb42a.js.LICENSE.txt */
  (this.webpackJsonpglide=this.webpackJsonpglide||[]).push([[33],{1456:function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(1259),i=n(149),o=n(214),s=n(52),u=n(1260),a=n(133);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.21.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.21.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.21.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.21.0) INTERNAL ASSERTION FAILED: "+t;throw v(e),new Error(e)}function w(t,e){t||m()}function b(t,e){return t}function E(t){var e=0;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function _(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function I(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}(),A=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.P=function(t){if(t.indexOf("//")>=0)throw new f(h.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new e(t.split("/").filter((function(t){return t.length>0})))},e.p=function(){return new e([])},e}(T),N=/^[_a-zA-Z][_a-zA-Z0-9]*$/,k=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.g=function(t){return N.test(t)},e.prototype.R=function(){return this.A().map((function(t){return t=t.replace("\\","\\\\").replace("`","\\`"),e.g(t)||(t="`"+t+"`"),t})).join(".")},e.prototype.toString=function(){return this.R()},e.prototype.V=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 invalid 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),L=function(){function t(t){this.path=t}return t.C=function(e){return new t(A.P(e))},t.D=function(e){return new t(A.P(e).u(5))},t.prototype.F=function(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t},t.prototype.isEqual=function(t){return null!==t&&0===A.i(this.path,t.path)},t.prototype.toString=function(){return this.path.toString()},t.i=function(t,e){return A.i(t.path,e.path)},t.N=function(t){return t.length%2==0},t.$=function(e){return new t(new A(e.slice()))},t}();function V(t,e){if(0!==e.length)throw new f(h.INVALID_ARGUMENT,"Function "+t+"() does not support arguments, but was called with "+K(e.length,"argument")+".")}function D(t,e,n){if(e.length!==n)throw new f(h.INVALID_ARGUMENT,"Function "+t+"() requires "+K(n,"argument")+", but was called with "+K(e.length,"argument")+".")}function R(t,e,n){if(e.length<n)throw new f(h.INVALID_ARGUMENT,"Function "+t+"() requires at least "+K(n,"argument")+", but was called with "+K(e.length,"argument")+".")}function S(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 "+K(e.length,"argument")+".")}function P(t,e,n,r){G(t,e,W(n)+" argument",r)}function U(t,e,n,r){void 0!==r&&P(t,e,n,r)}function O(t,e,n,r){G(t,e,n+" option",r)}function C(t,e,n,r){void 0!==r&&O(t,e,n,r)}function M(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(F(a))}var c=F(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 x(t,e,n,r){if(!e.some((function(t){return t===r})))throw new f(h.INVALID_ARGUMENT,"Invalid value "+F(r)+" provided to function "+t+"() for its "+W(n)+" argument. Acceptable values: "+e.join(", "));return r}function G(t,e,n,r){if(!("object"===e?q(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=F(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 F(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 j(t,e,n){if(void 0===n)throw new f(h.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+W(e)+" argument, but it was undefined.")}function B(t,e,n){_(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 Q(t,e,n,r){var i=F(r);return new f(h.INVALID_ARGUMENT,"Function "+t+"() requires its "+W(n)+" argument to be a "+e+", but it was: "+i)}function z(t,e,n){if(n<=0)throw new f(h.INVALID_ARGUMENT,"Function "+t+"() requires its "+W(e)+" argument to be a positive number, but it was: "+n+".")}function W(t){switch(t){case 1:return"first";case 2:return"second";case 3:return"third";default:return t+"th"}}function K(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=Math.floor(256/t.length)*t.length,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]%t.length));return n},t}();function X(t,e){return t<e?-1:t>e?1:0}function J(t,e,n){return t.length===e.length&&t.every((function(t,r){return n(t,e[r])}))}var Z=function(){function t(t){this.O=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.O,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.O)},t.prototype.M=function(){return 2*this.O.length},t.prototype.L=function(t){return X(this.O,t.O)},t.prototype.isEqual=function(t){return this.O===t.O},t}();Z.q=new Z("");var $=function(){function t(t){this.U=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.U.toBase64()},t.prototype.toUint8Array=function(){return this.U.toUint8Array()},t.prototype.toString=function(){return"Bytes(base64: "+this.toBase64()+")"},t.prototype.isEqual=function(t){return this.U.isEqual(t.U)},t}();function tt(){if("undefined"==typeof Uint8Array)throw new f(h.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function et(){if("undefined"==typeof atob)throw new f(h.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var nt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e.fromBase64String=function(t){D("Blob.fromBase64String",arguments,1),P("Blob.fromBase64String","string",1,t),et();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(D("Blob.fromUint8Array",arguments,1),tt(),!(t instanceof Uint8Array))throw Q("Blob.fromUint8Array","Uint8Array",1,t);return new e(Z.fromUint8Array(t))},e.prototype.toBase64=function(){return D("Blob.toBase64",arguments,0),et(),t.prototype.toBase64.call(this)},e.prototype.toUint8Array=function(){return D("Blob.toUint8Array",arguments,0),tt(),t.prototype.toUint8Array.call(this)},e.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},e}($),rt=function(t,e,n,r,i){this.B=t,this.persistenceKey=e,this.host=n,this.ssl=r,this.forceLongPolling=i},it=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 X(this.projectId,t.projectId)||X(this.database,t.database)},t}(),ot=function(){function t(t,e){this.W=t,this.G=e,this.K={}}return t.prototype.get=function(t){var e=this.W(t),n=this.K[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.W(t),r=this.K[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.K[n]=[[t,e]]},t.prototype.delete=function(t){var e=this.W(t),n=this.K[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.K[e]:n.splice(r,1),!0;return!1},t.prototype.forEach=function(t){_(this.K,(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 I(this.K)},t}(),st=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.H=function(t){return this.seconds===t.seconds?X(this.nanoseconds,t.nanoseconds):X(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}(),ut=function(){function t(t){this.timestamp=t}return t.Y=function(e){return new t(e)},t.min=function(){return new t(new st(0,0))},t.prototype.L=function(t){return this.timestamp.H(t.timestamp)},t.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},t.prototype.J=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},t.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},t.prototype.X=function(){return this.timestamp},t}();function at(t){return null==t}function ct(t){return-0===t&&1/t==-1/0}var ht=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.Z=null};function ft(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 ht(t,e,n,r,i,o,s)}function lt(t){var e=b(t);if(null===e.Z){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()+ne(t.value)}(t)})).join(","),n+="|ob:",n+=e.orderBy.map((function(t){return(e=t).field.R()+e.dir;var e})).join(","),at(e.limit)||(n+="|l:",n+=e.limit),e.startAt&&(n+="|lb:",n+=Yn(e.startAt)),e.endAt&&(n+="|ub:",n+=Yn(e.endAt)),e.Z=n}return e.Z}function pt(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(!tr(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)||!Zt(i.value,o.value))return!1;var i,o;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!Jn(t.startAt,e.startAt)&&Jn(t.endAt,e.endAt)}function dt(t){return L.N(t.path)&&null===t.collectionGroup&&0===t.filters.length}var vt,yt,gt=function(){function t(t,e,n,r,i,o,s){void 0===i&&(i=ut.min()),void 0===o&&(o=ut.min()),void 0===s&&(s=Z.q),this.target=t,this.targetId=e,this.tt=n,this.sequenceNumber=r,this.et=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=s}return t.prototype.nt=function(e){return new t(this.target,this.targetId,this.tt,e,this.et,this.lastLimboFreeSnapshotVersion,this.resumeToken)},t.prototype.st=function(e,n){return new t(this.target,this.targetId,this.tt,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e)},t.prototype.it=function(e){return new t(this.target,this.targetId,this.tt,this.sequenceNumber,this.et,e,this.resumeToken)},t}(),mt=function(t){this.count=t};function wt(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.UNIMPLEMENTED:case h.DATA_LOSS:return!0;default:return m()}}function bt(t){if(void 0===t)return v("GRPC error has no .code"),h.UNKNOWN;switch(t){case vt.OK:return h.OK;case vt.CANCELLED:return h.CANCELLED;case vt.UNKNOWN:return h.UNKNOWN;case vt.DEADLINE_EXCEEDED:return h.DEADLINE_EXCEEDED;case vt.RESOURCE_EXHAUSTED:return h.RESOURCE_EXHAUSTED;case vt.INTERNAL:return h.INTERNAL;case vt.UNAVAILABLE:return h.UNAVAILABLE;case vt.UNAUTHENTICATED:return h.UNAUTHENTICATED;case vt.INVALID_ARGUMENT:return h.INVALID_ARGUMENT;case vt.NOT_FOUND:return h.NOT_FOUND;case vt.ALREADY_EXISTS:return h.ALREADY_EXISTS;case vt.PERMISSION_DENIED:return h.PERMISSION_DENIED;case vt.FAILED_PRECONDITION:return h.FAILED_PRECONDITION;case vt.ABORTED:return h.ABORTED;case vt.OUT_OF_RANGE:return h.OUT_OF_RANGE;case vt.UNIMPLEMENTED:return h.UNIMPLEMENTED;case vt.DATA_LOSS:return h.DATA_LOSS;default:return m()}}(yt=vt||(vt={}))[yt.OK=0]="OK",yt[yt.CANCELLED=1]="CANCELLED",yt[yt.UNKNOWN=2]="UNKNOWN",yt[yt.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",yt[yt.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",yt[yt.NOT_FOUND=5]="NOT_FOUND",yt[yt.ALREADY_EXISTS=6]="ALREADY_EXISTS",yt[yt.PERMISSION_DENIED=7]="PERMISSION_DENIED",yt[yt.UNAUTHENTICATED=16]="UNAUTHENTICATED",yt[yt.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",yt[yt.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",yt[yt.ABORTED=10]="ABORTED",yt[yt.OUT_OF_RANGE=11]="OUT_OF_RANGE",yt[yt.UNIMPLEMENTED=12]="UNIMPLEMENTED",yt[yt.INTERNAL=13]="INTERNAL",yt[yt.UNAVAILABLE=14]="UNAVAILABLE",yt[yt.DATA_LOSS=15]="DATA_LOSS";var Et=function(){function t(t,e){this.i=t,this.root=e||It.EMPTY}return t.prototype.rt=function(e,n){return new t(this.i,this.root.rt(e,n,this.i).copy(null,null,It.ot,null,null))},t.prototype.remove=function(e){return new t(this.i,this.root.remove(e,this.i).copy(null,null,It.ot,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.ut=function(){return this.root.ut()},t.prototype.ct=function(){return this.root.ct()},t.prototype.at=function(t){return this.root.at(t)},t.prototype.forEach=function(t){this.at((function(e,n){return t(e,n),!1}))},t.prototype.toString=function(){var t=[];return this.at((function(e,n){return t.push(e+":"+n),!1})),"{"+t.join(", ")+"}"},t.prototype.ht=function(t){return this.root.ht(t)},t.prototype.lt=function(){return new _t(this.root,null,this.i,!1)},t.prototype._t=function(t){return new _t(this.root,t,this.i,!1)},t.prototype.ft=function(){return new _t(this.root,null,this.i,!0)},t.prototype.dt=function(t){return new _t(this.root,t,this.i,!0)},t}(),_t=function(){function t(t,e,n,r){this.wt=r,this.Tt=[];for(var i=1;!t.m();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.wt?t.left:t.right;else{if(0===i){this.Tt.push(t);break}this.Tt.push(t),t=this.wt?t.right:t.left}}return t.prototype.Et=function(){var t=this.Tt.pop(),e={key:t.key,value:t.value};if(this.wt)for(t=t.left;!t.m();)this.Tt.push(t),t=t.right;else for(t=t.right;!t.m();)this.Tt.push(t),t=t.left;return e},t.prototype.It=function(){return this.Tt.length>0},t.prototype.At=function(){if(0===this.Tt.length)return null;var t=this.Tt[this.Tt.length-1];return{key:t.key,value:t.value}},t}(),It=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.at=function(t){return this.left.at(t)||t(this.key,this.value)||this.right.at(t)},t.prototype.ht=function(t){return this.right.ht(t)||t(this.key,this.value)||this.left.ht(t)},t.prototype.min=function(){return this.left.m()?this:this.left.min()},t.prototype.ut=function(){return this.min().key},t.prototype.ct=function(){return this.right.m()?this.key:this.right.ct()},t.prototype.rt=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.copy(null,null,null,r.left.rt(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.rt(t,e,n))).Rt()},t.prototype.yt=function(){if(this.left.m())return t.EMPTY;var e=this;return e.left.Pt()||e.left.left.Pt()||(e=e.gt()),(e=e.copy(null,null,null,e.left.yt(),null)).Rt()},t.prototype.remove=function(e,n){var r,i=this;if(n(e,i.key)<0)i.left.m()||i.left.Pt()||i.left.left.Pt()||(i=i.gt()),i=i.copy(null,null,null,i.left.remove(e,n),null);else{if(i.left.Pt()&&(i=i.Vt()),i.right.m()||i.right.Pt()||i.right.left.Pt()||(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.yt())}i=i.copy(null,null,null,null,i.right.remove(e,n))}return i.Rt()},t.prototype.Pt=function(){return this.color},t.prototype.Rt=function(){var t=this;return t.right.Pt()&&!t.left.Pt()&&(t=t.bt()),t.left.Pt()&&t.left.left.Pt()&&(t=t.Vt()),t.left.Pt()&&t.right.Pt()&&(t=t.St()),t},t.prototype.gt=function(){var t=this.St();return t.right.left.Pt()&&(t=(t=(t=t.copy(null,null,null,null,t.right.Vt())).bt()).St()),t},t.prototype.vt=function(){var t=this.St();return t.left.left.Pt()&&(t=(t=t.Vt()).St()),t},t.prototype.bt=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.Vt=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.St=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.Dt();return Math.pow(2,t)<=this.size+1},t.prototype.Dt=function(){if(this.Pt()&&this.left.Pt())throw m();if(this.right.Pt())throw m();var t=this.left.Dt();if(t!==this.right.Dt())throw m();return t+(this.Pt()?0:1)},t}();It.EMPTY=null,It.RED=!0,It.ot=!1,It.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.rt=function(t,e,n){return new It(t,e)},t.prototype.remove=function(t,e){return this},t.prototype.m=function(){return!0},t.prototype.at=function(t){return!1},t.prototype.ht=function(t){return!1},t.prototype.ut=function(){return null},t.prototype.ct=function(){return null},t.prototype.Pt=function(){return!1},t.prototype.Ct=function(){return!0},t.prototype.Dt=function(){return 0},t}());var Tt=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.ut()},t.prototype.last=function(){return this.data.ct()},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.at((function(e,n){return t(e),!1}))},t.prototype.Ft=function(t,e){for(var n=this.data._t(t[0]);n.It();){var r=n.Et();if(this.i(r.key,t[1])>=0)return;e(r.key)}},t.prototype.Nt=function(t,e){var n;for(n=void 0!==e?this.data._t(e):this.data.lt();n.It();)if(!t(n.Et().key))return},t.prototype.$t=function(t){var e=this.data._t(t);return e.It()?e.Et().key:null},t.prototype.lt=function(){return new At(this.data.lt())},t.prototype._t=function(t){return new At(this.data._t(t))},t.prototype.add=function(t){return this.copy(this.data.remove(t).rt(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.xt=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.lt(),r=e.data.lt();n.It();){var i=n.Et().key,o=r.Et().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}(),At=function(){function t(t){this.kt=t}return t.prototype.Et=function(){return this.kt.Et().key},t.prototype.It=function(){return this.kt.It()},t}(),Nt=new Et(L.i);function kt(){return Nt}function Lt(){return kt()}var Vt=new Et(L.i);function Dt(){return Vt}var Rt=new Et(L.i),St=new Tt(L.i);function Pt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=St,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var Ut=new Tt(X);function Ot(){return Ut}var Ct=function(){function t(t){this.i=t?function(e,n){return t(e,n)||L.i(e.key,n.key)}:function(t,e){return L.i(t.key,e.key)},this.Ot=Dt(),this.Mt=new Et(this.i)}return t.Lt=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.Mt.ut()},t.prototype.last=function(){return this.Mt.ct()},t.prototype.m=function(){return this.Mt.m()},t.prototype.indexOf=function(t){var e=this.Ot.get(t);return e?this.Mt.indexOf(e):-1},Object.defineProperty(t.prototype,"size",{get:function(){return this.Mt.size},enumerable:!1,configurable:!0}),t.prototype.forEach=function(t){this.Mt.at((function(e,n){return t(e),!1}))},t.prototype.add=function(t){var e=this.delete(t.key);return e.copy(e.Ot.rt(t.key,t),e.Mt.rt(t,null))},t.prototype.delete=function(t){var e=this.get(t);return e?this.copy(this.Ot.remove(t),this.Mt.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.Mt.lt(),r=e.Mt.lt();n.It();){var i=n.Et().key,o=r.Et().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.Mt=n,r},t}(),Mt=function(){function t(){this.qt=new Et(L.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.rt(e,t):3===t.type&&1!==n.type?this.qt=this.qt.rt(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.qt=this.qt.rt(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.qt=this.qt.rt(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.rt(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.qt=this.qt.rt(e,{type:2,doc:t.doc}):m():this.qt=this.qt.rt(e,t)},t.prototype.Ut=function(){var t=[];return this.qt.at((function(e,n){t.push(n)})),t},t}(),xt=function(){function t(t,e,n,r,i,o,s,u){this.query=t,this.docs=e,this.Bt=n,this.docChanges=r,this.Qt=i,this.fromCache=o,this.jt=s,this.Wt=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,Ct.Lt(n),o,r,i,!0,!1)},Object.defineProperty(t.prototype,"hasPendingWrites",{get:function(){return!this.Qt.m()},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.jt===t.jt&&this.Qt.isEqual(t.Qt)&&Un(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.Bt.isEqual(t.Bt)))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}(),Gt=function(){function t(t,e,n,r,i){this.et=t,this.zt=e,this.Kt=n,this.Ht=r,this.Yt=i}return t.Jt=function(e,n){var r=new Map;return r.set(e,qt.Xt(e,n)),new t(ut.min(),r,Ot(),kt(),Pt())},t}(),qt=function(){function t(t,e,n,r,i){this.resumeToken=t,this.Zt=e,this.te=n,this.ee=r,this.ne=i}return t.Xt=function(e,n){return new t(Z.q,n,Pt(),Pt(),Pt())},t}(),Ft=function(t,e,n,r){this.se=t,this.removedTargetIds=e,this.key=n,this.ie=r},jt=function(t,e){this.targetId=t,this.re=e},Bt=function(t,e,n,r){void 0===n&&(n=Z.q),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},Qt=function(){function t(){this.oe=0,this.ue=Kt(),this.ce=Z.q,this.ae=!1,this.he=!0}return Object.defineProperty(t.prototype,"Zt",{get:function(){return this.ae},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resumeToken",{get:function(){return this.ce},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"le",{get:function(){return 0!==this.oe},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_e",{get:function(){return this.he},enumerable:!1,configurable:!0}),t.prototype.fe=function(t){t.M()>0&&(this.he=!0,this.ce=t)},t.prototype.de=function(){var t=Pt(),e=Pt(),n=Pt();return this.ue.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 qt(this.ce,this.ae,t,e,n)},t.prototype.we=function(){this.he=!1,this.ue=Kt()},t.prototype.me=function(t,e){this.he=!0,this.ue=this.ue.rt(t,e)},t.prototype.Te=function(t){this.he=!0,this.ue=this.ue.remove(t)},t.prototype.Ee=function(){this.oe+=1},t.prototype.Ie=function(){this.oe-=1},t.prototype.Ae=function(){this.he=!0,this.ae=!0},t}(),zt=function(){function t(t){this.Re=t,this.ye=new Map,this.Pe=kt(),this.pe=Wt(),this.ge=new Tt(X)}return t.prototype.Ve=function(t){for(var e=0,n=t.se;e<n.length;e++){var r=n[e];t.ie instanceof wn?this.ve(r,t.ie):t.ie instanceof bn&&this.be(r,t.key,t.ie)}for(var i=0,o=t.removedTargetIds;i<o.length;i++){var s=o[i];this.be(s,t.key,t.ie)}},t.prototype.Se=function(t){var e=this;this.Ce(t,(function(n){var r=e.De(n);switch(t.state){case 0:e.Fe(n)&&r.fe(t.resumeToken);break;case 1:r.Ie(),r.le||r.we(),r.fe(t.resumeToken);break;case 2:r.Ie(),r.le||e.removeTarget(n);break;case 3:e.Fe(n)&&(r.Ae(),r.fe(t.resumeToken));break;case 4:e.Fe(n)&&(e.Ne(n),r.fe(t.resumeToken));break;default:m()}}))},t.prototype.Ce=function(t,e){var n=this;t.targetIds.length>0?t.targetIds.forEach(e):this.ye.forEach((function(t,r){n.Fe(r)&&e(r)}))},t.prototype.$e=function(t){var e=t.targetId,n=t.re.count,r=this.xe(e);if(r){var i=r.target;if(dt(i))if(0===n){var o=new L(i.path);this.be(e,o,new bn(o,ut.min()))}else w(1===n);else this.ke(e)!==n&&(this.Ne(e),this.ge=this.ge.add(e))}},t.prototype.Oe=function(t){var e=this,n=new Map;this.ye.forEach((function(r,i){var o=e.xe(i);if(o){if(r.Zt&&dt(o.target)){var s=new L(o.target.path);null!==e.Pe.get(s)||e.Me(i,s)||e.be(i,s,new bn(s,t))}r._e&&(n.set(i,r.de()),r.we())}}));var r=Pt();this.pe.forEach((function(t,n){var i=!0;n.Nt((function(t){var n=e.xe(t);return!n||2===n.tt||(i=!1,!1)})),i&&(r=r.add(t))}));var i=new Gt(t,n,this.ge,this.Pe,r);return this.Pe=kt(),this.pe=Wt(),this.ge=new Tt(X),i},t.prototype.ve=function(t,e){if(this.Fe(t)){var n=this.Me(t,e.key)?2:0;this.De(t).me(e.key,n),this.Pe=this.Pe.rt(e.key,e),this.pe=this.pe.rt(e.key,this.Le(e.key).add(t))}},t.prototype.be=function(t,e,n){if(this.Fe(t)){var r=this.De(t);this.Me(t,e)?r.me(e,1):r.Te(e),this.pe=this.pe.rt(e,this.Le(e).delete(t)),n&&(this.Pe=this.Pe.rt(e,n))}},t.prototype.removeTarget=function(t){this.ye.delete(t)},t.prototype.ke=function(t){var e=this.De(t).de();return this.Re.qe(t).size+e.te.size-e.ne.size},t.prototype.Ee=function(t){this.De(t).Ee()},t.prototype.De=function(t){var e=this.ye.get(t);return e||(e=new Qt,this.ye.set(t,e)),e},t.prototype.Le=function(t){var e=this.pe.get(t);return e||(e=new Tt(X),this.pe=this.pe.rt(t,e)),e},t.prototype.Fe=function(t){var e=null!==this.xe(t);return e||d("WatchChangeAggregator","Detected inactive target",t),e},t.prototype.xe=function(t){var e=this.ye.get(t);return e&&e.le?null:this.Re.Ue(t)},t.prototype.Ne=function(t){var e=this;this.ye.set(t,new Qt),this.Re.qe(t).forEach((function(n){e.be(t,n,null)}))},t.prototype.Me=function(t,e){return this.Re.qe(t).has(e)},t}();function Wt(){return new Et(L.i)}function Kt(){return new Et(L.i)}function Ht(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 Yt(t){var e=re(t.mapValue.fields.__local_write_time__.timestampValue);return new st(e.seconds,e.nanos)}var Xt=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Jt(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?Ht(t)?4:10:m()}function Zt(t,e){var n=Jt(t);if(n!==Jt(e))return!1;switch(n){case 0:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return Yt(t).isEqual(Yt(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=re(t.timestampValue),r=re(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 oe(t.bytesValue).isEqual(oe(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return ie(t.geoPointValue.latitude)===ie(e.geoPointValue.latitude)&&ie(t.geoPointValue.longitude)===ie(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return ie(t.integerValue)===ie(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){var n=ie(t.doubleValue),r=ie(e.doubleValue);return n===r?ct(n)===ct(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return J(t.arrayValue.values||[],e.arrayValue.values||[],Zt);case 10:return function(t,e){var n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(E(n)!==E(r))return!1;for(var i in n)if(n.hasOwnProperty(i)&&(void 0===r[i]||!Zt(n[i],r[i])))return!1;return!0}(t,e);default:return m()}}function $t(t,e){return void 0!==(t.values||[]).find((function(t){return Zt(t,e)}))}function te(t,e){var n=Jt(t),r=Jt(e);if(n!==r)return X(n,r);switch(n){case 0:return 0;case 1:return X(t.booleanValue,e.booleanValue);case 2:return function(t,e){var n=ie(t.integerValue||t.doubleValue),r=ie(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 ee(t.timestampValue,e.timestampValue);case 4:return ee(Yt(t),Yt(e));case 5:return X(t.stringValue,e.stringValue);case 6:return function(t,e){var n=oe(t),r=oe(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=X(n[i],r[i]);if(0!==o)return o}return X(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){var n=X(ie(t.latitude),ie(e.latitude));return 0!==n?n:X(ie(t.longitude),ie(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=te(n[i],r[i]);if(o)return o}return X(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=X(r[s],o[s]);if(0!==u)return u;var a=te(n[r[s]],i[o[s]]);if(0!==a)return a}return X(r.length,o.length)}(t.mapValue,e.mapValue);default:throw m()}}function ee(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return X(t,e);var n=re(t),r=re(e),i=X(n.seconds,r.seconds);return 0!==i?i:X(n.nanos,r.nanos)}function ne(t){return function t(e){return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?function(t){var e=re(t);return"time("+e.seconds+","+e.nanos+")"}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?oe(e.bytesValue).toBase64():"referenceValue"in e?(r=e.referenceValue,L.D(r).toString()):"geoPointValue"in e?"geo("+(n=e.geoPointValue).latitude+","+n.longitude+")":"arrayValue"in e?function(e){for(var n="[",r=!0,i=0,o=e.values||[];i<o.length;i++){var s=o[i];r?r=!1:n+=",",n+=t(s)}return n+"]"}(e.arrayValue):"mapValue"in e?function(e){for(var n="{",r=!0,i=0,o=Object.keys(e.fields||{}).sort();i<o.length;i++){var s=o[i];r?r=!1:n+=",",n+=s+":"+t(e.fields[s])}return n+"}"}(e.mapValue):m();var n,r}(t)}function re(t){if(w(!!t),"string"==typeof t){var e=0,n=Xt.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:ie(t.seconds),nanos:ie(t.nanos)}}function ie(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function oe(t){return"string"==typeof t?Z.fromBase64String(t):Z.fromUint8Array(t)}function se(t,e){return{referenceValue:"projects/"+t.projectId+"/databases/"+t.database+"/documents/"+e.path.R()}}function ue(t){return!!t&&"integerValue"in t}function ae(t){return!!t&&"arrayValue"in t}function ce(t){return!!t&&"nullValue"in t}function he(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function fe(t){return!!t&&"mapValue"in t}var le={asc:"ASCENDING",desc:"DESCENDING"},pe={"<":"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"},de=function(t,e){this.B=t,this.Be=e};function ve(t){return{integerValue:""+t}}function ye(t,e){if(t.Be){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:ct(e)?"-0":e}}function ge(t,e){return function(t){return"number"==typeof t&&Number.isInteger(t)&&!ct(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}(e)?ve(e):ye(t,e)}function me(t,e){return t.Be?new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+e.nanoseconds).slice(-9)+"Z":{seconds:""+e.seconds,nanos:e.nanoseconds}}function we(t,e){return t.Be?e.toBase64():e.toUint8Array()}function be(t,e){return me(t,e.X())}function Ee(t){return w(!!t),ut.Y(function(t){var e=re(t);return new st(e.seconds,e.nanos)}(t))}function _e(t,e){return function(t){return new A(["projects",t.projectId,"databases",t.database])}(t).child("documents").child(e).R()}function Ie(t,e){return _e(t.B,e.path)}function Te(t,e){var n,r=function(t){var e=A.P(t);return w(Ce(e)),e}(e);return w(r.get(1)===t.B.projectId),w(!r.get(3)&&!t.B.database||r.get(3)===t.B.database),new L((w((n=r).length>4&&"documents"===n.get(4)),n.u(5)))}function Ae(t,e){return _e(t.B,e)}function Ne(t){return new A(["projects",t.B.projectId,"databases",t.B.database]).R()}function ke(t,e,n){return{name:Ie(t,e),fields:n.proto.mapValue.fields}}function Le(t,e){var n;if(e instanceof un)n={update:ke(t,e.key,e.value)};else if(e instanceof pn)n={delete:Ie(t,e.key)};else if(e instanceof an)n={update:ke(t,e.key,e.data),updateMask:Oe(e.Qe)};else if(e instanceof hn)n={transform:{document:Ie(t,e.key),fieldTransforms:e.fieldTransforms.map((function(t){return function(t,e){var n=e.transform;if(n instanceof Fe)return{fieldPath:e.field.R(),setToServerValue:"REQUEST_TIME"};if(n instanceof je)return{fieldPath:e.field.R(),appendMissingElements:{values:n.elements}};if(n instanceof Qe)return{fieldPath:e.field.R(),removeAllFromArray:{values:n.elements}};if(n instanceof We)return{fieldPath:e.field.R(),increment:n.je};throw m()}(0,t)}))}};else{if(!(e instanceof dn))return m();n={verify:Ie(t,e.key)}}return e.Ge.We||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:be(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:m()}(t,e.Ge)),n}function Ve(t,e){return{documents:[Ae(t,e.path)]}}function De(t,e){var n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=Ae(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=Ae(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(he(t.value))return{unaryFilter:{field:Ue(t.field),op:"IS_NAN"}};if(ce(t.value))return{unaryFilter:{field:Ue(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(he(t.value))return{unaryFilter:{field:Ue(t.field),op:"IS_NOT_NAN"}};if(ce(t.value))return{unaryFilter:{field:Ue(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Ue(t.field),op:Pe(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:Ue(t.field),direction:Se(t.dir)}}(t)}))}(e.orderBy);o&&(n.structuredQuery.orderBy=o);var s=function(t,e){return t.Be||at(e)?e:{value:e}}(t,e.limit);return null!==s&&(n.structuredQuery.limit=s),e.startAt&&(n.structuredQuery.startAt=Re(e.startAt)),e.endAt&&(n.structuredQuery.endAt=Re(e.endAt)),n}function Re(t){return{before:t.before,values:t.position}}function Se(t){return le[t]}function Pe(t){return pe[t]}function Ue(t){return{fieldPath:t.R()}}function Oe(t){var e=[];return t.fields.forEach((function(t){return e.push(t.R())})),{fieldPaths:e}}function Ce(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}var Me=function(){this.ze=void 0};function xe(t,e,n){return t instanceof Fe?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 je?Be(t,e):t instanceof Qe?ze(t,e):function(t,e){var n=qe(t,e),r=Ke(n)+Ke(t.je);return ue(n)&&ue(t.je)?ve(r):ye(t.serializer,r)}(t,e)}function Ge(t,e,n){return t instanceof je?Be(t,e):t instanceof Qe?ze(t,e):n}function qe(t,e){return t instanceof We?ue(n=e)||function(t){return!!t&&"doubleValue"in t}(n)?e:{integerValue:0}:null;var n}var Fe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r.__extends(e,t),e}(Me),je=function(t){function e(e){var n=this;return(n=t.call(this)||this).elements=e,n}return r.__extends(e,t),e}(Me);function Be(t,e){for(var n=He(e),r=function(t){n.some((function(e){return Zt(e,t)}))||n.push(t)},i=0,o=t.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var Qe=function(t){function e(e){var n=this;return(n=t.call(this)||this).elements=e,n}return r.__extends(e,t),e}(Me);function ze(t,e){for(var n=He(e),r=function(t){n=n.filter((function(e){return!Zt(e,t)}))},i=0,o=t.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var We=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).serializer=e,r.je=n,r}return r.__extends(e,t),e}(Me);function Ke(t){return ie(t.integerValue||t.doubleValue)}function He(t){return ae(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}var Ye=function(){function t(t){this.fields=t,t.sort(k.i)}return t.prototype.Ke=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 J(this.fields,t.fields,(function(t,e){return t.isEqual(e)}))},t}(),Xe=function(t,e){this.field=t,this.transform=e},Je=function(t,e){this.version=t,this.transformResults=e},Ze=function(){function t(t,e){this.updateTime=t,this.exists=e}return t.He=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,"We",{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 $e(t,e){return void 0!==t.updateTime?e instanceof wn&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e instanceof wn}var tn=function(){};function en(t,e,n){return t instanceof un?function(t,e,n){return new wn(t.key,n.version,t.value,{hasCommittedMutations:!0})}(t,0,n):t instanceof an?function(t,e,n){if(!$e(t.Ge,e))return new En(t.key,n.version);var r=cn(t,e);return new wn(t.key,n.version,r,{hasCommittedMutations:!0})}(t,e,n):t instanceof hn?function(t,e,n){if(w(null!=n.transformResults),!$e(t.Ge,e))return new En(t.key,n.version);var r=fn(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 wn&&(u=e.field(o.field)),r.push(Ge(s,u,n[i]))}return r}(t.fieldTransforms,e,n.transformResults),o=n.version,s=ln(t,r.data(),i);return new wn(t.key,o,s,{hasCommittedMutations:!0})}(t,e,n):function(t,e,n){return new bn(t.key,n.version,{hasCommittedMutations:!0})}(t,0,n)}function nn(t,e,n,r){return t instanceof un?function(t,e){if(!$e(t.Ge,e))return e;var n=sn(e);return new wn(t.key,n,t.value,{Ye:!0})}(t,e):t instanceof an?function(t,e){if(!$e(t.Ge,e))return e;var n=sn(e),r=cn(t,e);return new wn(t.key,n,r,{Ye:!0})}(t,e):t instanceof hn?function(t,e,n,r){if(!$e(t.Ge,e))return e;var i=fn(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 wn&&(c=n.field(u.field)),null===c&&r instanceof wn&&(c=r.field(u.field)),i.push(xe(a,c,e))}return i}(t.fieldTransforms,n,e,r),s=ln(t,i.data(),o);return new wn(t.key,i.version,s,{Ye:!0})}(t,e,r,n):function(t,e){return $e(t.Ge,e)?new bn(t.key,ut.min()):e}(t,e)}function rn(t,e){return t instanceof hn?function(t,e){for(var n=null,r=0,i=t.fieldTransforms;r<i.length;r++){var o=i[r],s=e instanceof wn?e.field(o.field):void 0,u=qe(o.transform,s||null);null!=u&&(n=null==n?(new yn).set(o.field,u):n.set(o.field,u))}return n?n.Je():null}(t,e):null}function on(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.Qe.isEqual(e.Qe):2!==t.type||J(t.fieldTransforms,t.fieldTransforms,(function(t,e){return function(t,e){return t.field.isEqual(e.field)&&function(t,e){return t instanceof je&&e instanceof je||t instanceof Qe&&e instanceof Qe?J(t.elements,e.elements,Zt):t instanceof We&&e instanceof We?Zt(t.je,e.je):t instanceof Fe&&e instanceof Fe}(t.transform,e.transform)}(t,e)})))}function sn(t){return t instanceof wn?t.version:ut.min()}var un=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}(tn),an=function(t){function e(e,n,r,i){var o=this;return(o=t.call(this)||this).key=e,o.data=n,o.Qe=r,o.Ge=i,o.type=1,o}return r.__extends(e,t),e}(tn);function cn(t,e){return function(t,e){var n=new yn(e);return t.Qe.fields.forEach((function(e){if(!e.m()){var r=t.data.field(e);null!==r?n.set(e,r):n.delete(e)}})),n.Je()}(t,e instanceof wn?e.data():vn.empty())}var hn=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=Ze.exists(!0),r}return r.__extends(e,t),e}(tn);function fn(t,e){return e}function ln(t,e,n){for(var r=new yn(e),i=0;i<t.fieldTransforms.length;i++){var o=t.fieldTransforms[i];r.set(o.field,n[i])}return r.Je()}var pn=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}(tn),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}(tn),vn=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(!fe(e=e.mapValue.fields[t.get(n)]))return null}return(e=(e.mapValue.fields||{})[t._()])||null},t.prototype.isEqual=function(t){return Zt(this.proto,t.proto)},t}(),yn=function(){function t(t){void 0===t&&(t=vn.empty()),this.Xe=t,this.Ze=new Map}return t.prototype.set=function(t,e){return this.tn(t,e),this},t.prototype.delete=function(t){return this.tn(t,null),this},t.prototype.tn=function(t,e){for(var n=this.Ze,r=0;r<t.length-1;++r){var i=t.get(r),o=n.get(i);o instanceof Map?n=o:o&&10===Jt(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.Je=function(){var t=this.en(k.p(),this.Ze);return null!=t?new vn(t):this.Xe},t.prototype.en=function(t,e){var n=this,r=!1,i=this.Xe.field(t),o=fe(i)?Object.assign({},i.mapValue.fields):{};return e.forEach((function(e,i){if(e instanceof Map){var s=n.en(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 gn(t){var e=[];return _(t.fields||{},(function(t,n){var r=new k([t]);if(fe(n)){var i=gn(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 Ye(e)}var mn=function(t,e){this.key=t,this.version=e},wn=function(t){function e(e,n,r,i){var o=this;return(o=t.call(this,e,n)||this).nn=r,o.Ye=!!i.Ye,o.hasCommittedMutations=!!i.hasCommittedMutations,o}return r.__extends(e,t),e.prototype.field=function(t){return this.nn.field(t)},e.prototype.data=function(){return this.nn},e.prototype.sn=function(){return this.nn.proto},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.Ye===t.Ye&&this.hasCommittedMutations===t.hasCommittedMutations&&this.nn.isEqual(t.nn)},e.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.nn.toString()+", {hasLocalMutations: "+this.Ye+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return this.Ye||this.hasCommittedMutations},enumerable:!1,configurable:!0}),e}(mn),bn=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}(mn),En=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}(mn),_n=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.rn=n,this.filters=r,this.limit=i,this.on=o,this.startAt=s,this.endAt=u,this.un=null,this.cn=null,this.startAt,this.endAt};function In(t){return new _n(t)}function Tn(t){return!at(t.limit)&&"F"===t.on}function An(t){return!at(t.limit)&&"L"===t.on}function Nn(t){return t.rn.length>0?t.rn[0].field:null}function kn(t){for(var e=0,n=t.filters;e<n.length;e++){var r=n[e];if(r.an())return r.field}return null}function Ln(t){return null!==t.collectionGroup}function Vn(t){var e=b(t);if(null===e.un){e.un=[];var n=kn(e),r=Nn(e);if(null!==n&&null===r)n.V()||e.un.push(new Zn(n)),e.un.push(new Zn(k.v(),"asc"));else{for(var i=!1,o=0,s=e.rn;o<s.length;o++){var u=s[o];e.un.push(u),u.field.V()&&(i=!0)}if(!i){var a=e.rn.length>0?e.rn[e.rn.length-1].dir:"asc";e.un.push(new Zn(k.v(),a))}}}return e.un}function Dn(t){var e=b(t);if(!e.cn)if("F"===e.on)e.cn=ft(e.path,e.collectionGroup,Vn(e),e.filters,e.limit,e.startAt,e.endAt);else{for(var n=[],r=0,i=Vn(e);r<i.length;r++){var o=i[r],s="desc"===o.dir?"asc":"desc";n.push(new Zn(o.field,s))}var u=e.endAt?new Hn(e.endAt.position,!e.endAt.before):null,a=e.startAt?new Hn(e.startAt.position,!e.startAt.before):null;e.cn=ft(e.path,e.collectionGroup,n,e.filters,e.limit,u,a)}return e.cn}function Rn(t,e,n){return new _n(t.path,t.collectionGroup,t.rn.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Sn(t,e){return new _n(t.path,t.collectionGroup,t.rn.slice(),t.filters.slice(),t.limit,t.on,e,t.endAt)}function Pn(t,e){return new _n(t.path,t.collectionGroup,t.rn.slice(),t.filters.slice(),t.limit,t.on,t.startAt,e)}function Un(t,e){return pt(Dn(t),Dn(e))&&t.on===e.on}function On(t){return lt(Dn(t))+"|lt:"+t.on}function Cn(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+" "+ne(e.value);var e})).join(", ")+"]"),at(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: "+Yn(t.startAt)),t.endAt&&(e+=", endAt: "+Yn(t.endAt)),"Target("+e+")"}(Dn(t))+"; limitType="+t.on+")"}function Mn(t,e){return function(t,e){var n=e.key.path;return null!==t.collectionGroup?e.key.F(t.collectionGroup)&&t.path.T(n):L.N(t.path)?t.path.isEqual(n):t.path.I(n)}(t,e)&&function(t,e){for(var n=0,r=t.rn;n<r.length;n++){var i=r[n];if(!i.field.V()&&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&&!Xn(t.startAt,Vn(t),e))&&(!t.endAt||!Xn(t.endAt,Vn(t),e))}(t,e)}function xn(t){return function(e,n){for(var r=!1,i=0,o=Vn(t);i<o.length;i++){var s=o[i],u=$n(s,e,n);if(0!==u)return u;r=r||s.field.V()}return 0}}var Gn=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.V())return"in"===n||"not-in"===n?this.hn(t,n,r):new qn(t,n,r);if(ce(r)){if("=="!==n&&"!="!==n)throw new f(h.INVALID_ARGUMENT,"Invalid query. Null only supports '==' and '!=' comparisons.");return new e(t,n,r)}if(he(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 Qn(t,r):"in"===n?new zn(t,r):"not-in"===n?new Wn(t,r):"array-contains-any"===n?new Kn(t,r):new e(t,n,r)},e.hn=function(t,e,n){return"in"===e?new Fn(t,n):new jn(t,n)},e.prototype.matches=function(t){var e=t.field(this.field);return"!="===this.op?null!==e&&this.ln(te(e,this.value)):null!==e&&Jt(this.value)===Jt(e)&&this.ln(te(e,this.value))},e.prototype.ln=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.an=function(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0},e}((function(){})),qn=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n,r)||this).key=L.D(r.referenceValue),i}return r.__extends(e,t),e.prototype.matches=function(t){var e=L.i(t.key,this.key);return this.ln(e)},e}(Gn),Fn=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"in",n)||this).keys=Bn("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}(Gn),jn=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"not-in",n)||this).keys=Bn("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}(Gn);function Bn(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map((function(t){return L.D(t.referenceValue)}))}var Qn=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 ae(e)&&$t(e.arrayValue,this.value)},e}(Gn),zn=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&&$t(this.value.arrayValue,e)},e}(Gn),Wn=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($t(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var e=t.field(this.field);return null!==e&&!$t(this.value.arrayValue,e)},e}(Gn),Kn=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!(!ae(n)||!n.arrayValue.values)&&n.arrayValue.values.some((function(t){return $t(e.value.arrayValue,t)}))},e}(Gn),Hn=function(t,e){this.position=t,this.before=e};function Yn(t){return(t.before?"b":"a")+":"+t.position.map((function(t){return ne(t)})).join(",")}function Xn(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.V()?L.i(L.D(s.referenceValue),n.key):te(s,n.field(o.field)),"desc"===o.dir&&(r*=-1),0!==r)break}return t.before?r<=0:r<0}function Jn(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(!Zt(t.position[n],e.position[n]))return!1;return!0}var Zn=function(t,e){void 0===e&&(e="asc"),this.field=t,this.dir=e};function $n(t,e,n){var r=t.field.V()?L.i(e.key,n.key):function(t,e,n){var r=e.field(t),i=n.field(t);return null!==r&&null!==i?te(r,i):m()}(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return m()}}function tr(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}var er=function(){var t=this;this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))},nr=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._n=t,this.fn=e,this.dn=n,this.wn=r,this.mn=i,this.Tn=0,this.En=null,this.In=Date.now(),this.reset()}return t.prototype.reset=function(){this.Tn=0},t.prototype.An=function(){this.Tn=this.mn},t.prototype.Rn=function(t){var e=this;this.cancel();var n=Math.floor(this.Tn+this.yn()),r=Math.max(0,Date.now()-this.In),i=Math.max(0,n-r);i>0&&d("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.Tn+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.En=this._n.Pn(this.fn,i,(function(){return e.In=Date.now(),t()})),this.Tn*=this.wn,this.Tn<this.dn&&(this.Tn=this.dn),this.Tn>this.mn&&(this.Tn=this.mn)},t.prototype.pn=function(){null!==this.En&&(this.En.gn(),this.En=null)},t.prototype.cancel=function(){null!==this.En&&(this.En.cancel(),this.En=null)},t.prototype.yn=function(){return(Math.random()-.5)*this.Tn},t}(),rr=function(){function t(t){var e=this;this.Vn=null,this.vn=null,this.result=void 0,this.error=void 0,this.bn=!1,this.Sn=!1,t((function(t){e.bn=!0,e.result=t,e.Vn&&e.Vn(t)}),(function(t){e.bn=!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.Sn&&m(),this.Sn=!0,this.bn?this.error?this.Cn(n,this.error):this.Dn(e,this.result):new t((function(t,i){r.Vn=function(n){r.Dn(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.Nn=function(e){try{var n=e();return n instanceof t?n:t.resolve(n)}catch(e){return t.reject(e)}},t.prototype.Dn=function(e,n){return e?this.Nn((function(){return e(n)})):t.resolve(n)},t.prototype.Cn=function(e,n){return e?this.Nn((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.xn=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}();function ir(t){return"IndexedDbTransactionError"===t.name}function or(){return"undefined"!=typeof document?document:null}var sr=function(){function t(t,e,n,r,i){this.kn=t,this.fn=e,this.On=n,this.op=r,this.Mn=i,this.Ln=new er,this.then=this.Ln.promise.then.bind(this.Ln.promise),this.Ln.promise.catch((function(t){}))}return t.qn=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.Un=setTimeout((function(){return e.Bn()}),t)},t.prototype.gn=function(){return this.Bn()},t.prototype.cancel=function(t){null!==this.Un&&(this.clearTimeout(),this.Ln.reject(new f(h.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},t.prototype.Bn=function(){var t=this;this.kn.Qn((function(){return null!==t.Un?(t.clearTimeout(),t.op().then((function(e){return t.Ln.resolve(e)}))):Promise.resolve()}))},t.prototype.clearTimeout=function(){null!==this.Un&&(this.Mn(this),clearTimeout(this.Un),this.Un=null)},t}(),ur=function(){function t(){var t=this;this.jn=Promise.resolve(),this.Wn=[],this.Gn=!1,this.zn=[],this.Kn=null,this.Hn=!1,this.Yn=[],this.Jn=new nr(this,"async_queue_retry"),this.Xn=function(){var e=or();e&&d("AsyncQueue","Visibility state changed to  ",e.visibilityState),t.Jn.pn()};var e=or();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.Xn)}return Object.defineProperty(t.prototype,"Zn",{get:function(){return this.Gn},enumerable:!1,configurable:!0}),t.prototype.Qn=function(t){this.enqueue(t)},t.prototype.ts=function(t){this.es(),this.ns(t)},t.prototype.ss=function(){if(!this.Gn){this.Gn=!0;var t=or();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.Xn)}},t.prototype.enqueue=function(t){return this.es(),this.Gn?new Promise((function(t){})):this.ns(t)},t.prototype.rs=function(t){var e=this;this.Wn.push(t),this.Qn((function(){return e.os()}))},t.prototype.os=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.Wn.length)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.Wn[0]()];case 2:return n.sent(),this.Wn.shift(),this.Jn.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.Wn.length>0&&this.Jn.Rn((function(){return e.os()})),n.label=5;case 5:return[2]}}))}))},t.prototype.ns=function(t){var e=this,n=this.jn.then((function(){return e.Hn=!0,t().catch((function(t){throw e.Kn=t,e.Hn=!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.Hn=!1,t}))}));return this.jn=n,n},t.prototype.Pn=function(t,e,n){var r=this;this.es(),this.Yn.indexOf(t)>-1&&(e=0);var i=sr.qn(this,t,e,n,(function(t){return r.us(t)}));return this.zn.push(i),i},t.prototype.es=function(){this.Kn&&m()},t.prototype.cs=function(){},t.prototype.hs=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.jn];case 1:e.sent(),e.label=2;case 2:if(t!==this.jn)return[3,0];e.label=3;case 3:return[2]}}))}))},t.prototype.ls=function(t){for(var e=0,n=this.zn;e<n.length;e++)if(n[e].fn===t)return!0;return!1},t.prototype._s=function(t){var e=this;return this.hs().then((function(){e.zn.sort((function(t,e){return t.On-e.On}));for(var n=0,r=e.zn;n<r.length;n++){var i=r[n];if(i.gn(),"all"!==t&&i.fn===t)break}return e.hs()}))},t.prototype.fs=function(t){this.Yn.push(t)},t.prototype.us=function(t){var e=this.zn.indexOf(t);this.zn.splice(e,1)},t}();function ar(t,e){if(v("AsyncQueue",e+": "+t),ir(t))return new f(h.UNAVAILABLE,e+": "+t);throw t}var cr=function(){this.ds=void 0,this.listeners=[]},hr=function(){this.ws=new ot((function(t){return On(t)}),Un),this.onlineState="Unknown",this.Ts=new Set};function fr(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=b(t),i=e.query,o=!1,(s=n.ws.get(i))||(o=!0,s=new cr),!o)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),u=s,[4,n.Es(i)];case 2:return u.ds=r.sent(),[3,4];case 3:return a=r.sent(),c=ar(a,"Initialization of query '"+Cn(e.query)+"' failed"),[2,void e.onError(c)];case 4:return n.ws.set(i,s),s.listeners.push(e),e.Is(n.onlineState),s.ds&&e.As(s.ds)&&vr(n),[2]}}))}))}function lr(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=b(t),i=e.query,o=!1,(s=n.ws.get(i))&&(u=s.listeners.indexOf(e))>=0&&(s.listeners.splice(u,1),o=0===s.listeners.length),o?[2,(n.ws.delete(i),n.Rs(i))]:[2]}))}))}function pr(t,e){for(var n=b(t),r=!1,i=0,o=e;i<o.length;i++){var s=o[i],u=s.query,a=n.ws.get(u);if(a){for(var c=0,h=a.listeners;c<h.length;c++)h[c].As(s)&&(r=!0);a.ds=s}}r&&vr(n)}function dr(t,e,n){var r=b(t),i=r.ws.get(e);if(i)for(var o=0,s=i.listeners;o<s.length;o++)s[o].onError(n);r.ws.delete(e)}function vr(t){t.Ts.forEach((function(t){t.next()}))}var yr=function(){function t(t,e,n){this.query=t,this.ys=e,this.Ps=!1,this.ps=null,this.onlineState="Unknown",this.options=n||{}}return t.prototype.As=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 xt(t.query,t.docs,t.Bt,e,t.Qt,t.fromCache,t.jt,!0)}var o=!1;return this.Ps?this.gs(t)&&(this.ys.next(t),o=!0):this.Vs(t,this.onlineState)&&(this.vs(t),o=!0),this.ps=t,o},t.prototype.onError=function(t){this.ys.error(t)},t.prototype.Is=function(t){this.onlineState=t;var e=!1;return this.ps&&!this.Ps&&this.Vs(this.ps,t)&&(this.vs(this.ps),e=!0),e},t.prototype.Vs=function(t,e){if(!t.fromCache)return!0;var n="Offline"!==e;return!(this.options.bs&&n||t.docs.m()&&"Offline"!==e)},t.prototype.gs=function(t){if(t.docChanges.length>0)return!0;var e=this.ps&&this.ps.hasPendingWrites!==t.hasPendingWrites;return!(!t.jt&&!e)&&!0===this.options.includeMetadataChanges},t.prototype.vs=function(t){t=xt.Gt(t.query,t.docs,t.Qt,t.fromCache),this.Ps=!0,this.ys.next(t)},t}(),gr=function(){function t(t){this.uid=t}return t.prototype.Ss=function(){return null!=this.uid},t.prototype.Cs=function(){return this.Ss()?"uid:"+this.uid:"anonymous-user"},t.prototype.isEqual=function(t){return t.uid===this.uid},t}();gr.UNAUTHENTICATED=new gr(null),gr.Ds=new gr("google-credentials-uid"),gr.Fs=new gr("first-party-uid");var mr=function(){function t(t,e){var n=this;this.previousValue=t,e&&(e.Ns=function(t){return n.$s(t)},this.xs=function(t){return e.ks(t)})}return t.prototype.$s=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},t.prototype.next=function(){var t=++this.previousValue;return this.xs&&this.xs(t),t},t}();mr.Os=-1;var wr=function(){function t(){this.activeTargetIds=Ot()}return t.prototype.Ms=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},t.prototype.Ls=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},t.prototype.qs=function(){var t={activeTargetIds:this.activeTargetIds.A(),updateTimeMs:Date.now()};return JSON.stringify(t)},t}(),br=function(){function t(){this.Us=new wr,this.Bs={},this.Qs=null,this.Ns=null}return t.prototype.js=function(t){},t.prototype.Ws=function(t,e,n){},t.prototype.Gs=function(t){return this.Us.Ms(t),this.Bs[t]||"not-current"},t.prototype.zs=function(t,e,n){this.Bs[t]=e},t.prototype.Ks=function(t){this.Us.Ls(t)},t.prototype.Hs=function(t){return this.Us.activeTargetIds.has(t)},t.prototype.Ys=function(t){delete this.Bs[t]},t.prototype.Js=function(){return this.Us.activeTargetIds},t.prototype.Xs=function(t){return this.Us.activeTargetIds.has(t)},t.prototype.start=function(){return this.Us=new wr,Promise.resolve()},t.prototype.Zs=function(t,e,n){},t.prototype.ti=function(t){},t.prototype.ei=function(){},t.prototype.ks=function(t){},t}(),Er=function(){function t(t,e,n,r){this.batchId=t,this.ni=e,this.baseMutations=n,this.mutations=r}return t.prototype.si=function(t,e,n){for(var r=n.ii,i=0;i<this.mutations.length;i++){var o=this.mutations[i];o.key.isEqual(t)&&(e=en(o,e,r[i]))}return e},t.prototype.ri=function(t,e){for(var n=0,r=this.baseMutations;n<r.length;n++){var i=r[n];i.key.isEqual(t)&&(e=nn(i,e,e,this.ni))}for(var o=e,s=0,u=this.mutations;s<u.length;s++){var a=u[s];a.key.isEqual(t)&&(e=nn(a,e,o,this.ni))}return e},t.prototype.oi=function(t){var e=this,n=t;return this.mutations.forEach((function(r){var i=e.ri(r.key,t.get(r.key));i&&(n=n.rt(r.key,i))})),n},t.prototype.keys=function(){return this.mutations.reduce((function(t,e){return t.add(e.key)}),Pt())},t.prototype.isEqual=function(t){return this.batchId===t.batchId&&J(this.mutations,t.mutations,(function(t,e){return on(t,e)}))&&J(this.baseMutations,t.baseMutations,(function(t,e){return on(t,e)}))},t}(),_r=function(){function t(t,e,n,r){this.batch=t,this.ui=e,this.ii=n,this.ci=r}return t.from=function(e,n,r){w(e.mutations.length===r.length);for(var i=Rt,o=e.mutations,s=0;s<o.length;s++)i=i.rt(o[s].key,r[s].version);return new t(e,n,r,i)},t}(),Ir=function(){function t(t,e,n){this.ai=t,this.hi=e,this.li=n}return t.prototype._i=function(t,e){var n=this;return this.hi.fi(t,e).next((function(r){return n.di(t,e,r)}))},t.prototype.di=function(t,e,n){return this.ai.wi(t,e).next((function(t){for(var r=0,i=n;r<i.length;r++)t=i[r].ri(e,t);return t}))},t.prototype.mi=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].ri(t,e);r=r.rt(t,e)})),r},t.prototype.Ti=function(t,e){var n=this;return this.ai.getEntries(t,e).next((function(e){return n.Ei(t,e)}))},t.prototype.Ei=function(t,e){var n=this;return this.hi.Ii(t,e).next((function(r){var i=n.mi(t,e,r),o=kt();return i.forEach((function(t,e){e||(e=new bn(t,ut.min())),o=o.rt(t,e)})),o}))},t.prototype.Ai=function(t,e,n){return function(t){return L.N(t.path)&&null===t.collectionGroup&&0===t.filters.length}(e)?this.Ri(t,e.path):Ln(e)?this.yi(t,e,n):this.Pi(t,e,n)},t.prototype.Ri=function(t,e){return this._i(t,new L(e)).next((function(t){var e=Dt();return t instanceof wn&&(e=e.rt(t.key,t)),e}))},t.prototype.yi=function(t,e,n){var r=this,i=e.collectionGroup,o=Dt();return this.li.pi(t,i).next((function(s){return rr.forEach(s,(function(s){var u=function(t,e){return new _n(e,null,t.rn.slice(),t.filters.slice(),t.limit,t.on,t.startAt,t.endAt)}(e,s.child(i));return r.Pi(t,u,n).next((function(t){t.forEach((function(t,e){o=o.rt(t,e)}))}))})).next((function(){return o}))}))},t.prototype.Pi=function(t,e,n){var r,i,o=this;return this.ai.Ai(t,e,n).next((function(n){return r=n,o.hi.gi(t,e)})).next((function(e){return i=e,o.Vi(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=nn(a,h,h,o.ni);r=f instanceof wn?r.rt(c,f):r.remove(c)}}))})).next((function(){return r.forEach((function(t,n){Mn(e,n)||(r=r.remove(t))})),r}))},t.prototype.Vi=function(t,e,n){for(var r=Pt(),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 an&&null===n.get(a.key)&&(r=r.add(a.key))}var c=n;return this.ai.getEntries(t,r).next((function(t){return t.forEach((function(t,e){null!==e&&e instanceof wn&&(c=c.rt(t,e))})),c}))},t}(),Tr=function(){function t(t,e,n,r){this.targetId=t,this.fromCache=e,this.vi=n,this.bi=r}return t.Si=function(e,n){for(var r=Pt(),i=Pt(),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}(),Ar=function(){function t(t,e,n){this.Ci=t,this.Di=e,this.Fi=n}return t.Ni=function(e){return new t(e,t.$i,t.xi)},t}();Ar.ki=-1,Ar.Oi=1048576,Ar.Mi=41943040,Ar.$i=10,Ar.xi=1e3,Ar.Li=new Ar(Ar.Mi,Ar.$i,Ar.xi),Ar.qi=new Ar(Ar.ki,0,0);var Nr=function(){function t(){this.Ui=new kr}return t.prototype.Bi=function(t,e){return this.Ui.add(e),rr.resolve()},t.prototype.pi=function(t,e){return rr.resolve(this.Ui.getEntries(e))},t}(),kr=function(){function t(){this.index={}}return t.prototype.add=function(t){var e=t._(),n=t.h(),r=this.index[e]||new Tt(A.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 Tt(A.i)).A()},t}(),Lr=function(){function t(t){this.Qi=t}return t.prototype.next=function(){return this.Qi+=2,this.Qi},t.ji=function(){return new t(0)},t.Wi=function(){return new t(-1)},t}(),Vr=function(){function t(t,e,n){this.persistence=t,this.Gi=e,this.zi=new Et(X),this.Ki=new ot((function(t){return lt(t)}),pt),this.Hi=ut.min(),this.hi=t.Yi(n),this.Ji=t.Xi(),this.Zi=t.tr(),this.er=new Ir(this.Ji,this.hi,this.persistence.nr()),this.Gi.sr(this.er)}return t.prototype.ir=function(t){var e=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",(function(n){return t.rr(n,e.zi)}))},t}();function Dr(t,e){var n=b(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(function(t){var r=e.batch.keys(),i=n.Ji.ur({cr:!0});return function(t,e,n,r){var i=n.batch,o=i.keys(),s=rr.resolve();return o.forEach((function(t){s=s.next((function(){return r.wi(e,t)})).next((function(e){var o=e,s=n.ci.get(t);w(null!==s),(!o||o.version.L(s)<0)&&(o=i.si(t,o,n))&&r.ar(o,n.ui)}))})),s.next((function(){return t.hi.hr(e,i)}))}(n,t,e,i).next((function(){return i.apply(t)})).next((function(){return n.hi.lr(t)})).next((function(){return n.er.Ti(t,r)}))}))}function Rr(t){var e=b(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(function(t){return e.Zi._r(t)}))}function Sr(t,e){var n=b(t),r=e.et,i=n.zi;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(function(t){var o=n.Ji.ur({cr:!0});i=n.zi;var s=[];e.zt.forEach((function(e,o){var u=i.get(o);if(u){s.push(n.Zi.dr(t,e.ne,o).next((function(){return n.Zi.wr(t,e.te,o)})));var a=e.resumeToken;if(a.M()>0){var c=u.st(a,r).nt(t.mr);i=i.rt(o,c),function(t,e,n){return w(e.resumeToken.M()>0),0===t.resumeToken.M()||e.et.J()-t.et.J()>=3e8||n.te.size+n.ee.size+n.ne.size>0}(u,c,e)&&s.push(n.Zi.Tr(t,c))}}}));var u=kt(),a=Pt();if(e.Ht.forEach((function(t,e){a=a.add(t)})),s.push(o.getEntries(t,a).next((function(i){e.Ht.forEach((function(a,c){var h=i.get(a);c instanceof bn&&c.version.isEqual(ut.min())?(o.Er(a,r),u=u.rt(a,c)):null==h||c.version.L(h.version)>0||0===c.version.L(h.version)&&h.hasPendingWrites?(o.ar(c,r),u=u.rt(a,c)):d("LocalStore","Ignoring outdated watch update for ",a,". Current version:",h.version," Watch version:",c.version),e.Yt.has(a)&&s.push(n.persistence.Ar.Ir(t,a))}))}))),!r.isEqual(ut.min())){var c=n.Zi._r(t).next((function(e){return n.Zi.Rr(t,t.mr,r)}));s.push(c)}return rr.$n(s).next((function(){return o.apply(t)})).next((function(){return n.er.Ei(t,u)}))})).then((function(t){return n.zi=i,t}))}function Pr(t,e){var n=b(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(function(t){return void 0===e&&(e=-1),n.hi.yr(t,e)}))}function Ur(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=b(t),o=i.zi.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.Ar.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.zi=i.zi.remove(e),i.Ki.delete(o.target),[2]}}))}))}function Or(t,e,n){var r=b(t),i=ut.min(),o=Pt();return r.persistence.runTransaction("Execute query","readonly",(function(t){return function(t,e,n){var r=b(t),i=r.Ki.get(n);return void 0!==i?rr.resolve(r.zi.get(i)):r.Zi.Pr(e,n)}(r,t,Dn(e)).next((function(e){if(e)return i=e.lastLimboFreeSnapshotVersion,r.Zi.pr(t,e.targetId).next((function(t){o=t}))})).next((function(){return r.Gi.Ai(t,e,n?i:ut.min(),n?o:Pt())})).next((function(t){return{documents:t,gr:o}}))}))}function Cr(t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){if(t.code!==h.FAILED_PRECONDITION||"The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab."!==t.message)throw t;return d("LocalStore","Unexpectedly lost primary lease"),[2]}))}))}var Mr=function(){function t(){this.Vr=new Tt(xr.vr),this.br=new Tt(xr.Sr)}return t.prototype.m=function(){return this.Vr.m()},t.prototype.Cr=function(t,e){var n=new xr(t,e);this.Vr=this.Vr.add(n),this.br=this.br.add(n)},t.prototype.Dr=function(t,e){var n=this;t.forEach((function(t){return n.Cr(t,e)}))},t.prototype.Fr=function(t,e){this.Nr(new xr(t,e))},t.prototype.$r=function(t,e){var n=this;t.forEach((function(t){return n.Fr(t,e)}))},t.prototype.kr=function(t){var e=this,n=new L(new A([])),r=new xr(n,t),i=new xr(n,t+1),o=[];return this.br.Ft([r,i],(function(t){e.Nr(t),o.push(t.key)})),o},t.prototype.Or=function(){var t=this;this.Vr.forEach((function(e){return t.Nr(e)}))},t.prototype.Nr=function(t){this.Vr=this.Vr.delete(t),this.br=this.br.delete(t)},t.prototype.Mr=function(t){var e=new L(new A([])),n=new xr(e,t),r=new xr(e,t+1),i=Pt();return this.br.Ft([n,r],(function(t){i=i.add(t.key)})),i},t.prototype.Lr=function(t){var e=new xr(t,0),n=this.Vr.$t(e);return null!==n&&t.isEqual(n.key)},t}(),xr=function(){function t(t,e){this.key=t,this.qr=e}return t.vr=function(t,e){return L.i(t.key,e.key)||X(t.qr,e.qr)},t.Sr=function(t,e){return X(t.qr,e.qr)||L.i(t.key,e.key)},t}(),Gr=function(t,e){this.user=e,this.type="OAuth",this.Ur={},this.Ur.Authorization="Bearer "+t},qr=function(){function t(){this.Br=null}return t.prototype.getToken=function(){return Promise.resolve(null)},t.prototype.Qr=function(){},t.prototype.jr=function(t){this.Br=t,t(gr.UNAUTHENTICATED)},t.prototype.Wr=function(){this.Br=null},t}(),Fr=function(){function t(t){var e=this;this.Gr=null,this.currentUser=gr.UNAUTHENTICATED,this.zr=!1,this.Kr=0,this.Br=null,this.forceRefresh=!1,this.Gr=function(){e.Kr++,e.currentUser=e.Hr(),e.zr=!0,e.Br&&e.Br(e.currentUser)},this.Kr=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.Gr):(this.Gr(null),t.get().then((function(t){e.auth=t,e.Gr&&e.auth.addAuthTokenListener(e.Gr)}),(function(){})))}return t.prototype.getToken=function(){var t=this,e=this.Kr,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then((function(n){return t.Kr!==e?(d("FirebaseCredentialsProvider","getToken aborted due to token change."),t.getToken()):n?(w("string"==typeof n.accessToken),new Gr(n.accessToken,t.currentUser)):null})):Promise.resolve(null)},t.prototype.Qr=function(){this.forceRefresh=!0},t.prototype.jr=function(t){this.Br=t,this.zr&&t(this.currentUser)},t.prototype.Wr=function(){this.auth&&this.auth.removeAuthTokenListener(this.Gr),this.Gr=null,this.Br=null},t.prototype.Hr=function(){var t=this.auth&&this.auth.getUid();return w(null===t||"string"==typeof t),new gr(t)},t}(),jr=function(){function t(t,e){this.Yr=t,this.Jr=e,this.type="FirstParty",this.user=gr.Fs}return Object.defineProperty(t.prototype,"Ur",{get:function(){var t={"X-Goog-AuthUser":this.Jr},e=this.Yr.auth.Xr([]);return e&&(t.Authorization=e),t},enumerable:!1,configurable:!0}),t}(),Br=function(){function t(t,e){this.Yr=t,this.Jr=e}return t.prototype.getToken=function(){return Promise.resolve(new jr(this.Yr,this.Jr))},t.prototype.jr=function(t){t(gr.Fs)},t.prototype.Wr=function(){},t.prototype.Qr=function(){},t}(),Qr=function(){function t(t,e,n,r,i,o){this._n=t,this.Zr=n,this.eo=r,this.no=i,this.listener=o,this.state=0,this.so=0,this.io=null,this.stream=null,this.Jn=new nr(t,e)}return t.prototype.ro=function(){return 1===this.state||2===this.state||4===this.state},t.prototype.oo=function(){return 2===this.state},t.prototype.start=function(){3!==this.state?this.auth():this.uo()},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.ro()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.co=function(){this.state=0,this.Jn.reset()},t.prototype.ao=function(){var t=this;this.oo()&&null===this.io&&(this.io=this._n.Pn(this.Zr,6e4,(function(){return t.ho()})))},t.prototype.lo=function(t){this._o(),this.stream.send(t)},t.prototype.ho=function(){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(t){return this.oo()?[2,this.close(0)]:[2]}))}))},t.prototype._o=function(){this.io&&(this.io.cancel(),this.io=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._o(),this.Jn.cancel(),this.so++,3!==t?this.Jn.reset():e&&e.code===h.RESOURCE_EXHAUSTED?(v(e.toString()),v("Using maximum backoff delay to prevent overloading the backend."),this.Jn.An()):e&&e.code===h.UNAUTHENTICATED&&this.no.Qr(),null!==this.stream&&(this.fo(),this.stream.close(),this.stream=null),this.state=t,[4,this.listener.do(e)];case 1:return n.sent(),[2]}}))}))},t.prototype.fo=function(){},t.prototype.auth=function(){var t=this;this.state=1;var e=this.wo(this.so),n=this.so;this.no.getToken().then((function(e){t.so===n&&t.mo(e)}),(function(n){e((function(){var e=new f(h.UNKNOWN,"Fetching auth token failed: "+n.message);return t.To(e)}))}))},t.prototype.mo=function(t){var e=this,n=this.wo(this.so);this.stream=this.Eo(t),this.stream.Io((function(){n((function(){return e.state=2,e.listener.Io()}))})),this.stream.do((function(t){n((function(){return e.To(t)}))})),this.stream.onMessage((function(t){n((function(){return e.onMessage(t)}))}))},t.prototype.uo=function(){var t=this;this.state=4,this.Jn.Rn((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.To=function(t){return d("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},t.prototype.wo=function(t){var e=this;return function(n){e._n.Qn((function(){return e.so===t?n():(d("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())}))}},t}(),zr=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.Eo=function(t){return this.eo.Ao("Listen",t)},e.prototype.onMessage=function(t){this.Jn.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.Be?(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:bt(t.code);return new f(e,t.message||"")}(s);n=new Bt(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=Te(t,a.document.name),l=Ee(a.document.updateTime),p=new vn({mapValue:{fields:a.document.fields}}),d=new wn(c,l,p,{}),v=a.targetIds||[],y=a.removedTargetIds||[];n=new Ft(v,y,d.key,d)}else if("documentDelete"in e){e.documentDelete;var g=e.documentDelete;g.document;var b=Te(t,g.document),E=g.readTime?Ee(g.readTime):ut.min(),_=new bn(b,E),I=g.removedTargetIds||[];n=new Ft([],I,_.key,_)}else if("documentRemove"in e){e.documentRemove;var T=e.documentRemove;T.document;var A=Te(t,T.document),N=T.removedTargetIds||[];n=new Ft([],N,A,null)}else{if(!("filter"in e))return m();e.filter;var k=e.filter;k.targetId;var L=k.count||0,V=new mt(L),D=k.targetId;n=new jt(D,V)}return n}(this.serializer,t),n=function(t){if(!("targetChange"in t))return ut.min();var e=t.targetChange;return e.targetIds&&e.targetIds.length?ut.min():e.readTime?Ee(e.readTime):ut.min()}(t);return this.listener.Ro(e,n)},e.prototype.yo=function(t){var e={};e.database=Ne(this.serializer),e.addTarget=function(t,e){var n,r=e.target;return(n=dt(r)?{documents:Ve(t,r)}:{query:De(t,r)}).targetId=e.targetId,e.resumeToken.M()>0&&(n.resumeToken=we(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.tt);return null==n?null:{"goog-listen-tags":n}}(this.serializer,t);n&&(e.labels=n),this.lo(e)},e.prototype.Po=function(t){var e={};e.database=Ne(this.serializer),e.removeTarget=t,this.lo(e)},e}(Qr),Wr=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=i,s.po=!1,s}return r.__extends(e,t),Object.defineProperty(e.prototype,"Vo",{get:function(){return this.po},enumerable:!1,configurable:!0}),e.prototype.start=function(){this.po=!1,this.lastStreamToken=void 0,t.prototype.start.call(this)},e.prototype.fo=function(){this.po&&this.vo([])},e.prototype.Eo=function(t){return this.eo.Ao("Write",t)},e.prototype.onMessage=function(t){if(w(!!t.streamToken),this.lastStreamToken=t.streamToken,this.po){this.Jn.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?Ee(t.updateTime):Ee(e);n.isEqual(ut.min())&&(n=Ee(e));var r=null;return t.transformResults&&t.transformResults.length>0&&(r=t.transformResults),new Je(n,r)}(t,e)}))):[]}(t.writeResults,t.commitTime),n=Ee(t.commitTime);return this.listener.bo(n,e)}return w(!t.writeResults||0===t.writeResults.length),this.po=!0,this.listener.So()},e.prototype.Co=function(){var t={};t.database=Ne(this.serializer),this.lo(t)},e.prototype.vo=function(t){var e=this,n={streamToken:this.lastStreamToken,writes:t.map((function(t){return Le(e.serializer,t)}))};this.lo(n)},e}(Qr),Kr=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).credentials=e,i.eo=n,i.serializer=r,i.Do=!1,i}return r.__extends(e,t),e.prototype.Fo=function(){if(this.Do)throw new f(h.FAILED_PRECONDITION,"The client has already been terminated.")},e.prototype.No=function(t,e,n){var r=this;return this.Fo(),this.credentials.getToken().then((function(i){return r.eo.No(t,e,n,i)})).catch((function(t){throw t.code===h.UNAUTHENTICATED&&r.credentials.Qr(),t}))},e.prototype.$o=function(t,e,n){var r=this;return this.Fo(),this.credentials.getToken().then((function(i){return r.eo.$o(t,e,n,i)})).catch((function(t){throw t.code===h.UNAUTHENTICATED&&r.credentials.Qr(),t}))},e.prototype.terminate=function(){this.Do=!1},e}((function(){})),Hr=function(){function t(t,e){this.kn=t,this.Qs=e,this.state="Unknown",this.xo=0,this.ko=null,this.Oo=!0}return t.prototype.Mo=function(){var t=this;0===this.xo&&(this.Lo("Unknown"),this.ko=this.kn.Pn("online_state_timeout",1e4,(function(){return t.ko=null,t.qo("Backend didn't respond within 10 seconds."),t.Lo("Offline"),Promise.resolve()})))},t.prototype.Uo=function(t){"Online"===this.state?this.Lo("Unknown"):(this.xo++,this.xo>=1&&(this.Bo(),this.qo("Connection failed 1 times. Most recent error: "+t.toString()),this.Lo("Offline")))},t.prototype.set=function(t){this.Bo(),this.xo=0,"Online"===t&&(this.Oo=!1),this.Lo(t)},t.prototype.Lo=function(t){t!==this.state&&(this.state=t,this.Qs(t))},t.prototype.qo=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.Oo?(v(e),this.Oo=!1):d("OnlineStateTracker",e)},t.prototype.Bo=function(){null!==this.ko&&(this.ko.cancel(),this.ko=null)},t}(),Yr=function(t,e,n,i,o){var s=this;this.Qo=t,this.jo=e,this.kn=n,this.Wo={},this.Go=[],this.zo=new Map,this.Ko=new Set,this.Ho=[],this.Yo=o,this.Yo.Jo((function(t){n.Qn((function(){return r.__awaiter(s,void 0,void 0,(function(){return r.__generator(this,(function(t){switch(t.label){case 0:return oi(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=b(t)).Ko.add(4),[4,Jr(e)];case 1:return n.sent(),e.Xo.set("Unknown"),e.Ko.delete(4),[4,Xr(e)];case 2:return n.sent(),[2]}}))}))}(this)]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))}))})),this.Xo=new Hr(n,i)};function Xr(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(!oi(t))return[3,4];e=0,n=t.Ho,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 Jr(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.Ho,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 Zr(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=b(t),d("RemoteStore","RemoteStore shutting down."),e.Ko.add(5),[4,Jr(e)];case 1:return n.sent(),e.Yo.ei(),e.Xo.set("Unknown"),[2]}}))}))}function $r(t,e){var n=b(t);n.zo.has(e.targetId)||(n.zo.set(e.targetId,e),ii(n)?ri(n):wi(n).oo()&&ei(n,e))}function ti(t,e){var n=b(t),r=wi(n);n.zo.delete(e),r.oo()&&ni(n,e),0===n.zo.size&&(r.oo()?r.ao():oi(n)&&n.Xo.set("Unknown"))}function ei(t,e){t.Zo.Ee(e.targetId),wi(t).yo(e)}function ni(t,e){t.Zo.Ee(e),wi(t).Po(e)}function ri(t){t.Zo=new zt({qe:function(e){return t.Wo.qe(e)},Ue:function(e){return t.zo.get(e)||null}}),wi(t).start(),t.Xo.Mo()}function ii(t){return oi(t)&&!wi(t).ro()&&t.zo.size>0}function oi(t){return 0===b(t).Ko.size}function si(t){t.Zo=void 0}function ui(t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return t.zo.forEach((function(e,n){ei(t,e)})),[2]}))}))}function ai(t,e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){return si(t),ii(t)?(t.Xo.Uo(e),ri(t)):t.Xo.set("Unknown"),[2]}))}))}function ci(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.Xo.set("Online"),!(e instanceof Bt&&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.zo.has(s)?[4,t.Wo.tu(s,n)]:[3,3]):[3,5];case 2:r.sent(),t.zo.delete(s),t.Zo.removeTarget(s),r.label=3;case 3:r.label=4;case 4:return i++,[3,1];case 5:return[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,hi(t,i)];case 4:return u.sent(),[3,5];case 5:return[3,13];case 6:if(e instanceof Ft?t.Zo.Ve(e):e instanceof jt?t.Zo.$e(e):t.Zo.Se(e),n.isEqual(ut.min()))return[3,13];u.label=7;case 7:return u.trys.push([7,11,,13]),[4,Rr(t.Qo)];case 8:return o=u.sent(),n.L(o)>=0?[4,function(t,e){var n=t.Zo.Oe(e);return n.zt.forEach((function(n,r){if(n.resumeToken.M()>0){var i=t.zo.get(r);i&&t.zo.set(r,i.st(n.resumeToken,e))}})),n.Kt.forEach((function(e){var n=t.zo.get(e);if(n){t.zo.set(e,n.st(Z.q,n.et)),ni(t,e);var r=new gt(n.target,e,1,n.sequenceNumber);ei(t,r)}})),t.Wo.eu(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,hi(t,s)];case 12:return u.sent(),[3,13];case 13:return[2]}}))}))}function hi(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.Ko.add(1),[4,Jr(t)];case 1:return o.sent(),t.Xo.set("Offline"),n||(n=function(){return Rr(t.Qo)}),t.kn.rs((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.Ko.delete(1),[4,Xr(t)];case 2:return e.sent(),[2]}}))}))})),[2]}}))}))}function fi(t,e){return e().catch((function(n){return hi(t,n,e)}))}function li(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=b(t),n=bi(e),i=e.Go.length>0?e.Go[e.Go.length-1].batchId:-1,r.label=1;case 1:if(!function(t){return oi(t)&&t.Go.length<10}(e))return[3,7];r.label=2;case 2:return r.trys.push([2,4,,6]),[4,Pr(e.Qo,i)];case 3:return null===(o=r.sent())?(0===e.Go.length&&n.ao(),[3,7]):(i=o.batchId,function(t,e){t.Go.push(e);var n=bi(t);n.oo()&&n.Vo&&n.vo(e.mutations)}(e,o),[3,6]);case 4:return s=r.sent(),[4,hi(e,s)];case 5:return r.sent(),[3,6];case 6:return[3,1];case 7:return pi(e)&&di(e),[2]}}))}))}function pi(t){return oi(t)&&!bi(t).ro()&&t.Go.length>0}function di(t){bi(t).start()}function vi(t){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(e){return bi(t).Co(),[2]}))}))}function yi(t){return r.__awaiter(this,void 0,void 0,(function(){var e,n,i,o;return r.__generator(this,(function(r){for(e=bi(t),n=0,i=t.Go;n<i.length;n++)o=i[n],e.vo(o.mutations);return[2]}))}))}function gi(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.Go.shift(),o=_r.from(i,e,n),[4,fi(t,(function(){return t.Wo.nu(o)}))];case 1:return r.sent(),[4,li(t)];case 2:return r.sent(),[2]}}))}))}function mi(t,e){return r.__awaiter(this,void 0,void 0,(function(){return r.__generator(this,(function(n){switch(n.label){case 0:return e&&bi(t).Vo?[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 wt(i=e.code)&&i!==h.ABORTED?(n=t.Go.shift(),bi(t).co(),[4,fi(t,(function(){return t.Wo.su(n.batchId,e)}))]):[3,3];case 1:return r.sent(),[4,li(t)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))}(t,e)]:[3,2];case 1:n.sent(),n.label=2;case 2:return pi(t)&&di(t),[2]}}))}))}function wi(t){var e=this;return t.iu||(t.iu=function(t,e,n){var r=b(t);return r.Fo(),new zr(e,r.eo,r.credentials,r.serializer,n)}(t.jo,t.kn,{Io:ui.bind(null,t),do:ai.bind(null,t),Ro:ci.bind(null,t)}),t.Ho.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.iu.co(),ii(t)?ri(t):t.Xo.set("Unknown"),[3,3]):[3,1];case 1:return[4,t.iu.stop()];case 2:e.sent(),si(t),e.label=3;case 3:return[2]}}))}))}))),t.iu}function bi(t){var e=this;return t.ru||(t.ru=function(t,e,n){var r=b(t);return r.Fo(),new Wr(e,r.eo,r.credentials,r.serializer,n)}(t.jo,t.kn,{Io:vi.bind(null,t),do:mi.bind(null,t),So:yi.bind(null,t),bo:gi.bind(null,t)}),t.Ho.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.ru.co(),[4,li(t)]):[3,2];case 1:return e.sent(),[3,4];case 2:return[4,t.ru.stop()];case 3:e.sent(),t.Go.length>0&&(d("RemoteStore","Stopping write stream with "+t.Go.length+" pending writes"),t.Go=[]),e.label=4;case 4:return[2]}}))}))}))),t.ru}var Ei=function(t){this.key=t},_i=function(t){this.key=t},Ii=function(){function t(t,e){this.query=t,this.ou=e,this.uu=null,this.Zt=!1,this.cu=Pt(),this.Qt=Pt(),this.au=xn(t),this.hu=new Ct(this.au)}return Object.defineProperty(t.prototype,"lu",{get:function(){return this.ou},enumerable:!1,configurable:!0}),t.prototype._u=function(t,e){var n=this,r=e?e.fu:new Mt,i=e?e.hu:this.hu,o=e?e.Qt:this.Qt,s=i,u=!1,a=Tn(this.query)&&i.size===this.query.limit?i.last():null,c=An(this.query)&&i.size===this.query.limit?i.first():null;if(t.at((function(t,e){var h=i.get(t),f=e instanceof wn?e:null;f&&(f=Mn(n.query,f)?f:null);var l=!!h&&n.Qt.has(h.key),p=!!f&&(f.Ye||n.Qt.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.du(h,f)||(r.track({type:2,doc:f}),d=!0,(a&&n.au(f,a)>0||c&&n.au(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)))})),Tn(this.query)||An(this.query))for(;s.size>this.query.limit;){var h=Tn(this.query)?s.last():s.first();s=s.delete(h.key),o=o.delete(h.key),r.track({type:1,doc:h})}return{hu:s,fu:r,wu:u,Qt:o}},t.prototype.du=function(t,e){return t.Ye&&e.hasCommittedMutations&&!e.Ye},t.prototype.mu=function(t,e,n){var r=this,i=this.hu;this.hu=t.hu,this.Qt=t.Qt;var o=t.fu.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.au(t.doc,e.doc)})),this.Tu(n);var s=e?this.Eu():[],u=0===this.cu.size&&this.Zt?1:0,a=u!==this.uu;return this.uu=u,0!==o.length||a?{snapshot:new xt(this.query,t.hu,i,o,t.Qt,0===u,a,!1),Iu:s}:{Iu:s}},t.prototype.Is=function(t){return this.Zt&&"Offline"===t?(this.Zt=!1,this.mu({hu:this.hu,fu:new Mt,Qt:this.Qt,wu:!1},!1)):{Iu:[]}},t.prototype.Au=function(t){return!this.ou.has(t)&&!!this.hu.has(t)&&!this.hu.get(t).Ye},t.prototype.Tu=function(t){var e=this;t&&(t.te.forEach((function(t){return e.ou=e.ou.add(t)})),t.ee.forEach((function(t){})),t.ne.forEach((function(t){return e.ou=e.ou.delete(t)})),this.Zt=t.Zt)},t.prototype.Eu=function(){var t=this;if(!this.Zt)return[];var e=this.cu;this.cu=Pt(),this.hu.forEach((function(e){t.Au(e.key)&&(t.cu=t.cu.add(e.key))}));var n=[];return e.forEach((function(e){t.cu.has(e)||n.push(new _i(e))})),this.cu.forEach((function(t){e.has(t)||n.push(new Ei(t))})),n},t.prototype.Ru=function(t){this.ou=t.gr,this.cu=Pt();var e=this._u(t.documents);return this.mu(e,!0)},t.prototype.yu=function(){return xt.Gt(this.query,this.hu,this.Qt,0===this.uu)},t}(),Ti=function(t,e,n){this.query=t,this.targetId=e,this.view=n},Ai=function(t){this.key=t,this.Pu=!1},Ni=function(){function t(t,e,n,r,i,o){this.Qo=t,this.pu=e,this.gu=n,this.Vu=r,this.currentUser=i,this.vu=o,this.bu={},this.Su=new ot((function(t){return On(t)}),Un),this.Cu=new Map,this.Du=[],this.Fu=new Et(L.i),this.Nu=new Map,this.$u=new Mr,this.xu={},this.ku=new Map,this.Ou=Lr.Wi(),this.onlineState="Unknown",this.Mu=void 0}return Object.defineProperty(t.prototype,"Lu",{get:function(){return!0===this.Mu},enumerable:!1,configurable:!0}),t}();function ki(t,e){return r.__awaiter(this,void 0,void 0,(function(){var n,i,o,s,u,a;return r.__generator(this,(function(c){switch(c.label){case 0:return n=function(t){var e=b(t);return e.pu.Wo.eu=Di.bind(null,e),e.pu.Wo.qe=Qi.bind(null,e),e.pu.Wo.tu=Si.bind(null,e),e.bu.Ro=pr.bind(null,e.gu),e.bu.qu=dr.bind(null,e.gu),e}(t),(s=n.Su.get(e))?(i=s.targetId,n.Vu.Gs(i),o=s.view.yu(),[3,4]):[3,1];case 1:return[4,function(t,e){var n=b(t);return n.persistence.runTransaction("Allocate target","readwrite",(function(t){var r;return n.Zi.Pr(t,e).next((function(i){return i?(r=i,rr.resolve(r)):n.Zi.Uu(t).next((function(i){return r=new gt(e,i,0,t.mr),n.Zi.Bu(t,r).next((function(){return r}))}))}))})).then((function(t){var r=n.zi.get(t.targetId);return(null===r||t.et.L(r.et)>0)&&(n.zi=n.zi.rt(t.targetId,t),n.Ki.set(e,t.targetId)),t}))}(n.Qo,Dn(e))];case 2:return u=c.sent(),a=n.Vu.Gs(u.targetId),i=u.targetId,[4,function(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.Qu=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._u(n)).wu?[4,Or(t.Qo,e.query,!1).then((function(t){var n=t.documents;return e.view._u(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.mu(o,t.Lu,s),[2,(Gi(t,e.targetId,u.Iu),u.snapshot)]}}))}))}(t,e,n,i)},[4,Or(t.Qo,e,!0)];case 1:return o=f.sent(),s=new Ii(e,o.gr),u=s._u(o.documents),a=qt.Xt(n,i&&"Offline"!==t.onlineState),c=s.mu(u,t.Lu,a),Gi(t,n,c.Iu),h=new Ti(e,n,s),t.Su.set(e,h),t.Cu.has(n)?t.Cu.get(n).push(e):t.Cu.set(n,[e]),[2,c.snapshot]}}))}))}(n,e,i,"current"===a)];case 3:o=c.sent(),n.Lu&&$r(n.pu,u),c.label=4;case 4:return[2,o]}}))}))}function Li(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=b(t),i=n.Su.get(e),(o=n.Cu.get(i.targetId)).length>1?[2,(n.Cu.set(i.targetId,o.filter((function(t){return!Un(t,e)}))),void n.Su.delete(e))]:n.Lu?(n.Vu.Ks(i.targetId),n.Vu.Xs(i.targetId)?[3,2]:[4,Ur(n.Qo,i.targetId,!1).then((function(){n.Vu.Ys(i.targetId),ti(n.pu,i.targetId),Mi(n,i.targetId)})).catch(Cr)]):[3,3];case 1:r.sent(),r.label=2;case 2:return[3,5];case 3:return Mi(n,i.targetId),[4,Ur(n.Qo,i.targetId,!0)];case 4:r.sent(),r.label=5;case 5:return[2]}}))}))}function Vi(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=function(t){var e=b(t);return e.pu.Wo.nu=Pi.bind(null,e),e.pu.Wo.su=Ui.bind(null,e),e}(t),r.label=1;case 1:return r.trys.push([1,5,,6]),[4,function(t,e){var n,r=b(t),i=st.now(),o=e.reduce((function(t,e){return t.add(e.key)}),Pt());return r.persistence.runTransaction("Locally write mutations","readwrite",(function(t){return r.er.Ti(t,o).next((function(o){n=o;for(var s=[],u=0,a=e;u<a.length;u++){var c=a[u],h=rn(c,n.get(c.key));null!=h&&s.push(new an(c.key,h,gn(h.proto.mapValue),Ze.exists(!0)))}return r.hi.ju(t,i,s,e)}))})).then((function(t){var e=t.oi(n);return{batchId:t.batchId,Wu:e}}))}(i.Qo,e)];case 2:return o=r.sent(),i.Vu.js(o.batchId),function(t,e,n){var r=t.xu[t.currentUser.Cs()];r||(r=new Et(X)),r=r.rt(e,n),t.xu[t.currentUser.Cs()]=r}(i,o.batchId,n),[4,ji(i,o.Wu)];case 3:return r.sent(),[4,li(i.pu)];case 4:return r.sent(),[3,6];case 5:return s=r.sent(),u=ar(s,"Failed to persist write"),n.reject(u),[3,6];case 6:return[2]}}))}))}function Di(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=b(t),r.label=1;case 1:return r.trys.push([1,4,,6]),[4,Sr(n.Qo,e)];case 2:return i=r.sent(),e.zt.forEach((function(t,e){var r=n.Nu.get(e);r&&(w(t.te.size+t.ee.size+t.ne.size<=1),t.te.size>0?r.Pu=!0:t.ee.size>0?w(r.Pu):t.ne.size>0&&(w(r.Pu),r.Pu=!1))})),[4,ji(n,i,e)];case 3:return r.sent(),[3,6];case 4:return[4,Cr(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}))}))}function Ri(t,e,n){var r=b(t);if(r.Lu&&0===n||!r.Lu&&1===n){var i=[];r.Su.forEach((function(t,n){var r=n.view.Is(e);r.snapshot&&i.push(r.snapshot)})),function(t,e){var n=b(t);n.onlineState=e;var r=!1;n.ws.forEach((function(t,n){for(var i=0,o=n.listeners;i<o.length;i++)o[i].Is(e)&&(r=!0)})),r&&vr(n)}(r.gu,e),i.length&&r.bu.Ro(i),r.onlineState=e,r.Lu&&r.Vu.ti(e)}}function Si(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=b(t)).Vu.zs(e,"rejected",n),o=i.Nu.get(e),(s=o&&o.key)?(u=(u=new Et(L.i)).rt(s,new bn(s,ut.min())),a=Pt().add(s),c=new Gt(ut.min(),new Map,new Tt(X),u,a),[4,Di(i,c)]):[3,2];case 1:return r.sent(),i.Fu=i.Fu.remove(s),i.Nu.delete(e),Fi(i),[3,4];case 2:return[4,Ur(i.Qo,e,!1).then((function(){return Mi(i,e,n)})).catch(Cr)];case 3:r.sent(),r.label=4;case 4:return[2]}}))}))}function Pi(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=b(t),i=e.batch.batchId,r.label=1;case 1:return r.trys.push([1,4,,6]),[4,Dr(n.Qo,e)];case 2:return o=r.sent(),Ci(n,i,null),Oi(n,i),n.Vu.Ws(i,"acknowledged"),[4,ji(n,o)];case 3:return r.sent(),[3,6];case 4:return[4,Cr(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}))}))}function Ui(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=b(t),r.label=1;case 1:return r.trys.push([1,4,,6]),[4,function(t,e){var n=b(t);return n.persistence.runTransaction("Reject batch","readwrite-primary",(function(t){var r;return n.hi.Gu(t,e).next((function(e){return w(null!==e),r=e.keys(),n.hi.hr(t,e)})).next((function(){return n.hi.lr(t)})).next((function(){return n.er.Ti(t,r)}))}))}(i.Qo,e)];case 2:return o=r.sent(),Ci(i,e,n),Oi(i,e),i.Vu.Ws(e,"rejected",n),[4,ji(i,o)];case 3:return r.sent(),[3,6];case 4:return[4,Cr(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}))}))}function Oi(t,e){(t.ku.get(e)||[]).forEach((function(t){t.resolve()})),t.ku.delete(e)}function Ci(t,e,n){var r=b(t),i=r.xu[r.currentUser.Cs()];if(i){var o=i.get(e);o&&(n?o.reject(n):o.resolve(),i=i.remove(e)),r.xu[r.currentUser.Cs()]=i}}function Mi(t,e,n){void 0===n&&(n=null),t.Vu.Ks(e);for(var r=0,i=t.Cu.get(e);r<i.length;r++){var o=i[r];t.Su.delete(o),n&&t.bu.qu(o,n)}t.Cu.delete(e),t.Lu&&t.$u.kr(e).forEach((function(e){t.$u.Lr(e)||xi(t,e)}))}function xi(t,e){var n=t.Fu.get(e);null!==n&&(ti(t.pu,n),t.Fu=t.Fu.remove(e),t.Nu.delete(n),Fi(t))}function Gi(t,e,n){for(var r=0,i=n;r<i.length;r++){var o=i[r];o instanceof Ei?(t.$u.Cr(o.key,e),qi(t,o)):o instanceof _i?(d("SyncEngine","Document no longer in limbo: "+o.key),t.$u.Fr(o.key,e),t.$u.Lr(o.key)||xi(t,o.key)):m()}}function qi(t,e){var n=e.key;t.Fu.get(n)||(d("SyncEngine","New document in limbo: "+n),t.Du.push(n),Fi(t))}function Fi(t){for(;t.Du.length>0&&t.Fu.size<t.vu;){var e=t.Du.shift(),n=t.Ou.next();t.Nu.set(n,new Ai(e)),t.Fu=t.Fu.rt(e,n),$r(t.pu,new gt(Dn(In(e.path)),n,2,mr.Os))}}function ji(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=b(t),o=[],s=[],u=[],i.Su.m()?[3,3]:(i.Su.forEach((function(t,r){u.push(i.Qu(r,e,n).then((function(t){if(t){i.Lu&&i.Vu.zs(r.targetId,t.fromCache?"not-current":"current"),o.push(t);var e=Tr.Si(r.targetId,t);s.push(e)}})))})),[4,Promise.all(u)]);case 1:return a.sent(),i.bu.Ro(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=b(t),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(function(t){return rr.forEach(e,(function(e){return rr.forEach(e.vi,(function(r){return n.persistence.Ar.Cr(t,e.targetId,r)})).next((function(){return rr.forEach(e.bi,(function(r){return n.persistence.Ar.Fr(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.zi.get(a),h=c.et,f=c.it(h),n.zi=n.zi.rt(a,f));return[2]}}))}))}(i.Qo,s)];case 2:a.sent(),a.label=3;case 3:return[2]}}))}))}function Bi(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=b(t)).currentUser.isEqual(e)?[3,3]:(d("SyncEngine","User change. New user:",e.Cs()),[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=b(t),i=n.hi,o=n.er,[4,n.persistence.runTransaction("Handle user change","readonly",(function(t){var r;return n.hi.Ku(t).next((function(s){return r=s,i=n.persistence.Yi(e),o=new Ir(n.Ji,i,n.persistence.nr()),i.Ku(t)})).next((function(e){for(var n=[],i=[],s=Pt(),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.Ti(t,s).next((function(t){return{Hu:t,Yu:n,Ju:i}}))}))}))];case 1:return s=r.sent(),[2,(n.hi=i,n.er=o,n.Gi.sr(n.er),s)]}}))}))}(n.Qo,e)]);case 1:return i=o.sent(),n.currentUser=e,function(t,e){t.ku.forEach((function(t){t.forEach((function(t){t.reject(new f(h.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),t.ku.clear()}(n),n.Vu.Zs(e,i.Yu,i.Ju),[4,ji(n,i.Hu)];case 2:o.sent(),o.label=3;case 3:return[2]}}))}))}function Qi(t,e){var n=b(t),r=n.Nu.get(e);if(r&&r.Pu)return Pt().add(r.key);var i=Pt(),o=n.Cu.get(e);if(!o)return i;for(var s=0,u=o;s<u.length;s++){var a=u[s],c=n.Su.get(a);i=i.xt(c.view.lu)}return i}var zi=function(){function t(){}return t.prototype.sr=function(t){this.Xu=t},t.prototype.Ai=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.rn.length||1===t.rn.length&&t.rn[0].field.V())}(e)||n.isEqual(ut.min())?this.Zu(t,e):this.Xu.Ti(t,r).next((function(s){var u=i.tc(e,s);return(Tn(e)||An(e))&&i.wu(e.on,u,r,n)?i.Zu(t,e):(p()<=o.LogLevel.DEBUG&&d("IndexFreeQueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),Cn(e)),i.Xu.Ai(t,e,n).next((function(t){return u.forEach((function(e){t=t.rt(e.key,e)})),t})))}))},t.prototype.tc=function(t,e){var n=new Tt(xn(t));return e.forEach((function(e,r){r instanceof wn&&Mn(t,r)&&(n=n.add(r))})),n},t.prototype.wu=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.Zu=function(t,e){return p()<=o.LogLevel.DEBUG&&d("IndexFreeQueryEngine","Using full collection scan to execute query:",Cn(e)),this.Xu.Ai(t,e,ut.min())},t}(),Wi=function(){function t(t,e){this.li=t,this.Ar=e,this.hi=[],this.ec=1,this.nc=new Tt(xr.vr)}return t.prototype.sc=function(t){return rr.resolve(0===this.hi.length)},t.prototype.ju=function(t,e,n,r){var i=this.ec;this.ec++,this.hi.length>0&&this.hi[this.hi.length-1];var o=new Er(i,e,n,r);this.hi.push(o);for(var s=0,u=r;s<u.length;s++){var a=u[s];this.nc=this.nc.add(new xr(a.key,i)),this.li.Bi(t,a.key.path.h())}return rr.resolve(o)},t.prototype.Gu=function(t,e){return rr.resolve(this.ic(e))},t.prototype.yr=function(t,e){var n=e+1,r=this.rc(n),i=r<0?0:r;return rr.resolve(this.hi.length>i?this.hi[i]:null)},t.prototype.zu=function(){return rr.resolve(0===this.hi.length?-1:this.ec-1)},t.prototype.Ku=function(t){return rr.resolve(this.hi.slice())},t.prototype.fi=function(t,e){var n=this,r=new xr(e,0),i=new xr(e,Number.POSITIVE_INFINITY),o=[];return this.nc.Ft([r,i],(function(t){var e=n.ic(t.qr);o.push(e)})),rr.resolve(o)},t.prototype.Ii=function(t,e){var n=this,r=new Tt(X);return e.forEach((function(t){var e=new xr(t,0),i=new xr(t,Number.POSITIVE_INFINITY);n.nc.Ft([e,i],(function(t){r=r.add(t.qr)}))})),rr.resolve(this.oc(r))},t.prototype.gi=function(t,e){var n=e.path,r=n.length+1,i=n;L.N(i)||(i=i.child(""));var o=new xr(new L(i),0),s=new Tt(X);return this.nc.Nt((function(t){var e=t.key.path;return!!n.T(e)&&(e.length===r&&(s=s.add(t.qr)),!0)}),o),rr.resolve(this.oc(s))},t.prototype.oc=function(t){var e=this,n=[];return t.forEach((function(t){var r=e.ic(t);null!==r&&n.push(r)})),n},t.prototype.hr=function(t,e){var n=this;w(0===this.uc(e.batchId,"removed")),this.hi.shift();var r=this.nc;return rr.forEach(e.mutations,(function(i){var o=new xr(i.key,e.batchId);return r=r.delete(o),n.Ar.cc(t,i.key)})).next((function(){n.nc=r}))},t.prototype.ac=function(t){},t.prototype.Lr=function(t,e){var n=new xr(e,0),r=this.nc.$t(n);return rr.resolve(e.isEqual(r&&r.key))},t.prototype.lr=function(t){return this.hi.length,rr.resolve()},t.prototype.uc=function(t,e){return this.rc(t)},t.prototype.rc=function(t){return 0===this.hi.length?0:t-this.hi[0].batchId},t.prototype.ic=function(t){var e=this.rc(t);return e<0||e>=this.hi.length?null:this.hi[e]},t}(),Ki=function(){function t(t,e){this.li=t,this.hc=e,this.docs=new Et(L.i),this.size=0}return t.prototype.ar=function(t,e,n){var r=e.key,i=this.docs.get(r),o=i?i.size:0,s=this.hc(e);return this.docs=this.docs.rt(r,{lc:e,size:s,readTime:n}),this.size+=s-o,this.li.Bi(t,r.path.h())},t.prototype.Er=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},t.prototype.wi=function(t,e){var n=this.docs.get(e);return rr.resolve(n?n.lc: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.rt(t,e?e.lc:null)})),rr.resolve(r)},t.prototype.Ai=function(t,e,n){for(var r=Dt(),i=new L(e.path.child("")),o=this.docs._t(i);o.It();){var s=o.Et(),u=s.key,a=s.value,c=a.lc,h=a.readTime;if(!e.path.T(u.path))break;h.L(n)<=0||c instanceof wn&&Mn(e,c)&&(r=r.rt(c.key,c))}return rr.resolve(r)},t.prototype._c=function(t,e){return rr.forEach(this.docs,(function(t){return e(t)}))},t.prototype.ur=function(e){return new t.fc(this)},t.prototype.dc=function(t){return rr.resolve(this.size)},t}();Ki.fc=function(t){function e(e){var n=this;return(n=t.call(this)||this).Ac=e,n}return r.__extends(e,t),e.prototype.mu=function(t){var e=this,n=[];return this.Wu.forEach((function(r,i){i?n.push(e.Ac.ar(t,i,e.readTime)):e.Ac.Er(r)})),rr.$n(n)},e.prototype.Ec=function(t,e){return this.Ac.wi(t,e)},e.prototype.Ic=function(t,e){return this.Ac.getEntries(t,e)},e}(function(){function t(){this.Wu=new ot((function(t){return t.toString()}),(function(t,e){return t.isEqual(e)})),this.wc=!1}return Object.defineProperty(t.prototype,"readTime",{get:function(){return this.mc},set:function(t){this.mc=t},enumerable:!1,configurable:!0}),t.prototype.ar=function(t,e){this.Tc(),this.readTime=e,this.Wu.set(t.key,t)},t.prototype.Er=function(t,e){this.Tc(),e&&(this.readTime=e),this.Wu.set(t,null)},t.prototype.wi=function(t,e){this.Tc();var n=this.Wu.get(e);return void 0!==n?rr.resolve(n):this.Ec(t,e)},t.prototype.getEntries=function(t,e){return this.Ic(t,e)},t.prototype.apply=function(t){return this.Tc(),this.wc=!0,this.mu(t)},t.prototype.Tc=function(){},t}());var Hi=function(){function t(t){this.persistence=t,this.Rc=new ot((function(t){return lt(t)}),pt),this.lastRemoteSnapshotVersion=ut.min(),this.highestTargetId=0,this.yc=0,this.Pc=new Mr,this.targetCount=0,this.gc=Lr.ji()}return t.prototype.Ce=function(t,e){return this.Rc.forEach((function(t,n){return e(n)})),rr.resolve()},t.prototype._r=function(t){return rr.resolve(this.lastRemoteSnapshotVersion)},t.prototype.Vc=function(t){return rr.resolve(this.yc)},t.prototype.Uu=function(t){return this.highestTargetId=this.gc.next(),rr.resolve(this.highestTargetId)},t.prototype.Rr=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.yc&&(this.yc=e),rr.resolve()},t.prototype.vc=function(t){this.Rc.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.gc=new Lr(e),this.highestTargetId=e),t.sequenceNumber>this.yc&&(this.yc=t.sequenceNumber)},t.prototype.Bu=function(t,e){return this.vc(e),this.targetCount+=1,rr.resolve()},t.prototype.Tr=function(t,e){return this.vc(e),rr.resolve()},t.prototype.bc=function(t,e){return this.Rc.delete(e.target),this.Pc.kr(e.targetId),this.targetCount-=1,rr.resolve()},t.prototype.Sc=function(t,e,n){var r=this,i=0,o=[];return this.Rc.forEach((function(s,u){u.sequenceNumber<=e&&null===n.get(u.targetId)&&(r.Rc.delete(s),o.push(r.Cc(t,u.targetId)),i++)})),rr.$n(o).next((function(){return i}))},t.prototype.Dc=function(t){return rr.resolve(this.targetCount)},t.prototype.Pr=function(t,e){var n=this.Rc.get(e)||null;return rr.resolve(n)},t.prototype.wr=function(t,e,n){return this.Pc.Dr(e,n),rr.resolve()},t.prototype.dr=function(t,e,n){this.Pc.$r(e,n);var r=this.persistence.Ar,i=[];return r&&e.forEach((function(e){i.push(r.cc(t,e))})),rr.$n(i)},t.prototype.Cc=function(t,e){return this.Pc.kr(e),rr.resolve()},t.prototype.pr=function(t,e){var n=this.Pc.Mr(e);return rr.resolve(n)},t.prototype.Lr=function(t,e){return rr.resolve(this.Pc.Lr(e))},t}(),Yi=function(){function t(t){var e=this;this.Fc={},this.Nc=new mr(0),this.$c=!1,this.$c=!0,this.Ar=t(this),this.Zi=new Hi(this),this.li=new Nr,this.ai=new Ki(this.li,(function(t){return e.Ar.xc(t)}))}return t.prototype.start=function(){return Promise.resolve()},t.prototype.ei=function(){return this.$c=!1,Promise.resolve()},Object.defineProperty(t.prototype,"kc",{get:function(){return this.$c},enumerable:!1,configurable:!0}),t.prototype.Oc=function(){},t.prototype.Mc=function(){},t.prototype.nr=function(){return this.li},t.prototype.Yi=function(t){var e=this.Fc[t.Cs()];return e||(e=new Wi(this.li,this.Ar),this.Fc[t.Cs()]=e),e},t.prototype.tr=function(){return this.Zi},t.prototype.Xi=function(){return this.ai},t.prototype.runTransaction=function(t,e,n){var r=this;d("MemoryPersistence","Starting transaction:",t);var i=new Xi(this.Nc.next());return this.Ar.Lc(),n(i).next((function(t){return r.Ar.qc(i).next((function(){return t}))})).Fn().then((function(t){return i.Uc(),t}))},t.prototype.Bc=function(t,e){return rr.xn(Object.values(this.Fc).map((function(n){return function(){return n.Lr(t,e)}})))},t}(),Xi=function(t){function e(e){var n=this;return(n=t.call(this)||this).mr=e,n}return r.__extends(e,t),e}(function(){function t(){this.Qc=[]}return t.prototype.jc=function(t){this.Qc.push(t)},t.prototype.Uc=function(){this.Qc.forEach((function(t){return t()}))},t}()),Ji=function(){function t(t){this.persistence=t,this.Wc=new Mr,this.Gc=null}return t.zc=function(e){return new t(e)},Object.defineProperty(t.prototype,"Kc",{get:function(){if(this.Gc)return this.Gc;throw m()},enumerable:!1,configurable:!0}),t.prototype.Cr=function(t,e,n){return this.Wc.Cr(n,e),this.Kc.delete(n.toString()),rr.resolve()},t.prototype.Fr=function(t,e,n){return this.Wc.Fr(n,e),this.Kc.add(n.toString()),rr.resolve()},t.prototype.cc=function(t,e){return this.Kc.add(e.toString()),rr.resolve()},t.prototype.removeTarget=function(t,e){var n=this;this.Wc.kr(e.targetId).forEach((function(t){return n.Kc.add(t.toString())}));var r=this.persistence.tr();return r.pr(t,e.targetId).next((function(t){t.forEach((function(t){return n.Kc.add(t.toString())}))})).next((function(){return r.bc(t,e)}))},t.prototype.Lc=function(){this.Gc=new Set},t.prototype.qc=function(t){var e=this,n=this.persistence.Xi().ur();return rr.forEach(this.Kc,(function(r){var i=L.C(r);return e.Hc(t,i).next((function(t){t||n.Er(i)}))})).next((function(){return e.Gc=null,n.apply(t)}))},t.prototype.Ir=function(t,e){var n=this;return this.Hc(t,e).next((function(t){t?n.Kc.delete(e.toString()):n.Kc.add(e.toString())}))},t.prototype.xc=function(t){return 0},t.prototype.Hc=function(t,e){var n=this;return rr.xn([function(){return rr.resolve(n.Wc.Lr(e))},function(){return n.persistence.tr().Lr(t,e)},function(){return n.persistence.Bc(t,e)}])},t}(),Zi=function(){function t(t){this.Yc=t.Yc,this.Jc=t.Jc}return t.prototype.Io=function(t){this.Xc=t},t.prototype.do=function(t){this.Zc=t},t.prototype.onMessage=function(t){this.ta=t},t.prototype.close=function(){this.Jc()},t.prototype.send=function(t){this.Yc(t)},t.prototype.ea=function(){this.Xc()},t.prototype.na=function(t){this.Zc(t)},t.prototype.sa=function(t){this.ta(t)},t}(),$i={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"},to=function(t){function e(e){var n=this;return(n=t.call(this,e)||this).forceLongPolling=e.forceLongPolling,n}return r.__extends(e,t),e.prototype.aa=function(t,e,n,r){return new Promise((function(i,o){var s=new u.XhrIo;s.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.Ao=function(t,e){var n=[this.ra,"/","google.firestore.v1.Firestore","/",t,"/channel"],r=u.createWebChannelTransport(),i={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.B.projectId+"/databases/"+this.B.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling};this.ca(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 Zi({Yc: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))},Jc: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.na())})),v(u.WebChannel.EventType.ERROR,(function(t){l||(l=!0,y("Connection","WebChannel transport errored:",t),p.na(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=vt[t];if(void 0!==e)return bt(e)}(o),u=i.message;void 0===s&&(s=h.INTERNAL,u="Unknown error status: "+o+" with message "+i.message),l=!0,p.na(new f(s,u)),a.close()}else d("Connection","WebChannel received:",n),p.sa(n)}})),setTimeout((function(){p.ea()}),0),p},e}(function(){function t(t){this.ia=t,this.B=t.B;var e=t.ssl?"https":"http";this.ra=e+"://"+t.host,this.oa="projects/"+this.B.projectId+"/databases/"+this.B.database+"/documents"}return t.prototype.No=function(t,e,n,r){var i=this.ua(t,e);d("RestConnection","Sending: ",i,n);var o={};return this.ca(o,r),this.aa(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.$o=function(t,e,n,r){return this.No(t,e,n,r)},t.prototype.ca=function(t,e){if(t["X-Goog-Api-Client"]="gl-js/ fire/7.21.0",t["Content-Type"]="text/plain",e)for(var n in e.Ur)e.Ur.hasOwnProperty(n)&&(t[n]=e.Ur[n])},t.prototype.ua=function(t,e){var n=$i[t];return this.ra+"/v1/"+e+":"+n},t}()),eo=function(){function t(){var t=this;this.ha=function(){return t.la()},this._a=function(){return t.fa()},this.da=[],this.wa()}return t.prototype.Jo=function(t){this.da.push(t)},t.prototype.ei=function(){window.removeEventListener("online",this.ha),window.removeEventListener("offline",this._a)},t.prototype.wa=function(){window.addEventListener("online",this.ha),window.addEventListener("offline",this._a)},t.prototype.la=function(){d("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.da;t<e.length;t++)(0,e[t])(0)},t.prototype.fa=function(){d("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.da;t<e.length;t++)(0,e[t])(1)},t.ma=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},t}(),no=function(){function t(){}return t.prototype.Jo=function(t){},t.prototype.ei=function(){},t}();function ro(t){return new de(t,!0)}var io="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.",oo=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.Vu=this.Ta(t),this.persistence=this.Ea(t),[4,this.persistence.start()];case 1:return e.sent(),this.Ia=this.Aa(t),this.Qo=this.Ra(t),[2]}}))}))},t.prototype.Aa=function(t){return null},t.prototype.Ra=function(t){return e=this.persistence,n=new zi,r=t.ya,new Vr(e,n,r);var e,n,r},t.prototype.Ea=function(t){if(t.persistenceSettings.Pa)throw new f(h.FAILED_PRECONDITION,io);return new Yi(Ji.zc)},t.prototype.Ta=function(t){return new br},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.Ia&&this.Ia.stop(),[4,this.Vu.ei()];case 1:return t.sent(),[4,this.persistence.ei()];case 2:return t.sent(),[2]}}))}))},t.prototype.clearPersistence=function(t,e){throw new f(h.FAILED_PRECONDITION,io)},t}(),so=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(i){switch(i.label){case 0:return this.Qo?[3,2]:(this.Qo=t.Qo,this.Vu=t.Vu,this.jo=this.pa(e),this.pu=this.ga(e),this.gu=this.Va(e),this.va=this.ba(e),this.Vu.Qs=function(t){return Ri(n.va,t,1)},this.pu.Wo.Sa=Bi.bind(null,this.va),[4,function(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=b(t),e?(n.Ko.delete(2),[4,Xr(n)]):[3,2];case 1:return r.sent(),[3,5];case 2:return e?[3,4]:(n.Ko.add(2),[4,Jr(n)]);case 3:r.sent(),n.Xo.set("Unknown"),r.label=4;case 4:r.label=5;case 5:return[2]}}))}))}(this.pu,this.va.Lu)]);case 1:i.sent(),i.label=2;case 2:return[2]}}))}))},t.prototype.Va=function(t){return new hr},t.prototype.pa=function(t){var e,n=ro(t.ia.B),r=(e=t.ia,new to(e));return function(t,e,n){return new Kr(t,e,n)}(t.credentials,r,n)},t.prototype.ga=function(t){var e,n,r,i,o,s=this;return e=this.Qo,n=this.jo,r=t.kn,i=function(t){return Ri(s.va,t,0)},o=eo.ma()?new eo:new no,new Yr(e,n,r,i,o)},t.prototype.ba=function(t){return function(t,e,n,r,i,o,s){var u=new Ni(t,e,n,r,i,o);return s&&(u.Mu=!0),u}(this.Qo,this.pu,this.gu,this.Vu,t.ya,t.vu,!t.persistenceSettings.Pa||!t.persistenceSettings.synchronizeTabs)},t.prototype.terminate=function(){return Zr(this.pu)},t}(),uo=function(){function t(t){this.observer=t,this.muted=!1}return t.prototype.next=function(t){this.observer.next&&this.Ca(this.observer.next,t)},t.prototype.error=function(t){this.observer.error?this.Ca(this.observer.error,t):console.error("Uncaught Error in snapshot listener:",t)},t.prototype.Da=function(){this.muted=!0},t.prototype.Ca=function(t,e){var n=this;this.muted||setTimeout((function(){n.muted||t(e)}),0)},t}(),ao=function(t){!function(t,e,n,r){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 "+K(1,"element")+".")}(0,t);for(var e=0;e<t.length;++e)if(P("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.Fa=new k(t)},co=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(k.v().R())},e.prototype.isEqual=function(t){if(!(t instanceof e))throw Q("isEqual","FieldPath",1,t);return this.Fa.isEqual(t.Fa)},e}(ao),ho=new RegExp("[~\\*/\\[\\]]"),fo=function(){this.Na=this},lo=function(t){function e(e){var n=this;return(n=t.call(this)||this).$a=e,n}return r.__extends(e,t),e.prototype.xa=function(t){if(2!==t.ka)throw 1===t.ka?t.Oa(this.$a+"() can only appear at the top level of your update data"):t.Oa(this.$a+"() cannot be used with set() unless you pass {merge:true}");return t.Qe.push(t.path),null},e.prototype.isEqual=function(t){return t instanceof e},e}(fo);function po(t,e,n){return new ko({ka:3,Ma:e.settings.Ma,methodName:t.$a,La:n},e.B,e.serializer,e.ignoreUndefinedProperties)}var vo=function(t){function e(e){var n=this;return(n=t.call(this)||this).$a=e,n}return r.__extends(e,t),e.prototype.xa=function(t){return new Xe(t.path,new Fe)},e.prototype.isEqual=function(t){return t instanceof e},e}(fo),yo=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).$a=e,r.qa=n,r}return r.__extends(e,t),e.prototype.xa=function(t){var e=po(this,t,!0),n=this.qa.map((function(t){return Po(t,e)})),r=new je(n);return new Xe(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(fo),go=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).$a=e,r.qa=n,r}return r.__extends(e,t),e.prototype.xa=function(t){var e=po(this,t,!0),n=this.qa.map((function(t){return Po(t,e)})),r=new Qe(n);return new Xe(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(fo),mo=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).$a=e,r.Ua=n,r}return r.__extends(e,t),e.prototype.xa=function(t){var e=new We(t.serializer,ge(t.serializer,this.Ua));return new Xe(t.path,e)},e.prototype.isEqual=function(t){return this===t},e}(fo),wo=function(t){function e(){return t.call(this)||this}return r.__extends(e,t),e.delete=function(){return V("FieldValue.delete",arguments),new bo(new lo("FieldValue.delete"))},e.serverTimestamp=function(){return V("FieldValue.serverTimestamp",arguments),new bo(new vo("FieldValue.serverTimestamp"))},e.arrayUnion=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return R("FieldValue.arrayUnion",arguments,1),new bo(new yo("FieldValue.arrayUnion",t))},e.arrayRemove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return R("FieldValue.arrayRemove",arguments,1),new bo(new go("FieldValue.arrayRemove",t))},e.increment=function(t){return P("FieldValue.increment","number",1,t),D("FieldValue.increment",arguments,1),new bo(new mo("FieldValue.increment",t))},e}(fo),bo=function(t){function e(e){var n=this;return(n=t.call(this)||this).Na=e,n.$a=e.$a,n}return r.__extends(e,t),e.prototype.xa=function(t){return this.Na.xa(t)},e.prototype.isEqual=function(t){return t instanceof e&&this.Na.isEqual(t.Na)},e}(wo),Eo=function(){function t(t,e){if(D("GeoPoint",arguments,2),P("GeoPoint","number",1,t),P("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.Ba=t,this.Qa=e}return Object.defineProperty(t.prototype,"latitude",{get:function(){return this.Ba},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"longitude",{get:function(){return this.Qa},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){return this.Ba===t.Ba&&this.Qa===t.Qa},t.prototype.toJSON=function(){return{latitude:this.Ba,longitude:this.Qa}},t.prototype.H=function(t){return X(this.Ba,t.Ba)||X(this.Qa,t.Qa)},t}(),_o=/^__.*__$/,Io=function(t,e,n){this.ja=t,this.Wa=e,this.Ga=n},To=function(){function t(t,e,n){this.data=t,this.Qe=e,this.fieldTransforms=n}return t.prototype.za=function(t,e){var n=[];return null!==this.Qe?n.push(new an(t,this.data,this.Qe,e)):n.push(new un(t,this.data,e)),this.fieldTransforms.length>0&&n.push(new hn(t,this.fieldTransforms)),n},t}(),Ao=function(){function t(t,e,n){this.data=t,this.Qe=e,this.fieldTransforms=n}return t.prototype.za=function(t,e){var n=[new an(t,this.data,this.Qe,e)];return this.fieldTransforms.length>0&&n.push(new hn(t,this.fieldTransforms)),n},t}();function No(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw m()}}var ko=function(){function t(t,e,n,r,i,o){this.settings=t,this.B=e,this.serializer=n,this.ignoreUndefinedProperties=r,void 0===i&&this.Ka(),this.fieldTransforms=i||[],this.Qe=o||[]}return Object.defineProperty(t.prototype,"path",{get:function(){return this.settings.path},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ka",{get:function(){return this.settings.ka},enumerable:!1,configurable:!0}),t.prototype.Ha=function(e){return new t(Object.assign(Object.assign({},this.settings),e),this.B,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.Qe)},t.prototype.Ya=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.Ha({path:n,La:!1});return r.Ja(t),r},t.prototype.Xa=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.Ha({path:n,La:!1});return r.Ka(),r},t.prototype.Za=function(t){return this.Ha({path:void 0,La:!0})},t.prototype.Oa=function(t){return Go(t,this.settings.methodName,this.settings.th||!1,this.path,this.settings.Ma)},t.prototype.contains=function(t){return void 0!==this.Qe.find((function(e){return t.T(e)}))||void 0!==this.fieldTransforms.find((function(e){return t.T(e.field)}))},t.prototype.Ka=function(){if(this.path)for(var t=0;t<this.path.length;t++)this.Ja(this.path.get(t))},t.prototype.Ja=function(t){if(0===t.length)throw this.Oa("Document fields must not be empty");if(No(this.ka)&&_o.test(t))throw this.Oa('Document fields cannot begin and end with "__"')},t}(),Lo=function(){function t(t,e,n){this.B=t,this.ignoreUndefinedProperties=e,this.serializer=n||ro(t)}return t.prototype.eh=function(t,e,n,r){return void 0===r&&(r=!1),new ko({ka:t,methodName:e,Ma:n,path:k.p(),La:!1,th:r},this.B,this.serializer,this.ignoreUndefinedProperties)},t}();function Vo(t,e,n,r,i,o){void 0===o&&(o={});var s=t.eh(o.merge||o.mergeFields?2:0,e,n,i);Co("Data must be an object, but it was:",s,r);var u,a,c=Uo(r,s);if(o.merge)u=new Ye(s.Qe),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 ao)y=v.Fa;else{if("string"!=typeof v)throw m();y=xo(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.");qo(l,y)||l.push(y)}u=new Ye(l),a=s.fieldTransforms.filter((function(t){return u.Ke(t.field)}))}else u=null,a=s.fieldTransforms;return new To(new vn(c),u,a)}function Do(t,e,n,r){var i=t.eh(1,e,n);Co("Data must be an object, but it was:",i,r);var o=[],s=new yn;_(r,(function(t,r){var u=xo(e,t,n),a=i.Xa(u);if(r instanceof fo&&r.Na instanceof lo)o.push(u);else{var c=Po(r,a);null!=c&&(o.push(u),s.set(u,c))}}));var u=new Ye(o);return new Ao(s.Je(),u,i.fieldTransforms)}function Ro(t,e,n,r,i,o){var s=t.eh(1,e,n),u=[Mo(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(Mo(e,o[c])),a.push(o[c+1]);for(var l=[],p=new yn,d=u.length-1;d>=0;--d)if(!qo(l,u[d])){var v=u[d],y=a[d],g=s.Xa(v);if(y instanceof fo&&y.Na instanceof lo)l.push(v);else{var m=Po(y,g);null!=m&&(l.push(v),p.set(v,m))}}var w=new Ye(l);return new Ao(p.Je(),w,s.fieldTransforms)}function So(t,e,n,r){return void 0===r&&(r=!1),Po(n,t.eh(r?4:3,e))}function Po(t,e){if(Oo(t))return Co("Unsupported field value:",e,t),Uo(t,e);if(t instanceof fo)return function(t,e){if(!No(e.ka))throw e.Oa(t.$a+"() can only be used with update() and set()");if(!e.path)throw e.Oa(t.$a+"() is not currently supported inside arrays");var n=t.xa(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(e.path&&e.Qe.push(e.path),t instanceof Array){if(e.settings.La&&4!==e.ka)throw e.Oa("Nested arrays are not supported");return function(t,e){for(var n=[],r=0,i=0,o=t;i<o.length;i++){var s=Po(o[i],e.Za(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 ge(e.serializer,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){var n=st.fromDate(t);return{timestampValue:me(e.serializer,n)}}if(t instanceof st){var r=new st(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:me(e.serializer,r)}}if(t instanceof Eo)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof $)return{bytesValue:we(e.serializer,t.U)};if(t instanceof Io){var i=e.B,o=t.ja;if(!o.isEqual(i))throw e.Oa("Document reference is for database "+o.projectId+"/"+o.database+" but should be for database "+i.projectId+"/"+i.database);return{referenceValue:_e(t.ja||e.B,t.Wa.path)}}if(void 0===t&&e.ignoreUndefinedProperties)return null;throw e.Oa("Unsupported field value: "+F(t))}(t,e)}function Uo(t,e){var n={};return I(t)?e.path&&e.path.length>0&&e.Qe.push(e.path):_(t,(function(t,r){var i=Po(r,e.Ya(t));null!=i&&(n[t]=i)})),{mapValue:{fields:n}}}function Oo(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof st||t instanceof Eo||t instanceof $||t instanceof Io||t instanceof fo)}function Co(t,e,n){if(!Oo(n)||!q(n)){var r=F(n);throw"an object"===r?e.Oa(t+" a custom object"):e.Oa(t+" "+r)}}function Mo(t,e,n){if(e instanceof ao)return e.Fa;if("string"==typeof e)return xo(t,e);throw Go("Field path arguments must be of type string or FieldPath.",t,!1,void 0,n)}function xo(t,e,n){try{return function(t){if(t.search(ho)>=0)throw new f(h.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not contain '~', '*', '/', '[', or ']'");try{return new(co.bind.apply(co,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).Fa}catch(e){throw Go((i=e)instanceof Error?i.message:i.toString(),t,!1,void 0,n)}var i}function Go(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 qo(t,e){return t.some((function(t){return t.isEqual(e)}))}var Fo=function(){function t(t){this.jo=t,this.nh=new Map,this.mutations=[],this.sh=!1,this.ih=null,this.rh=new Set}return t.prototype.oh=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.uh(),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=b(t),i=Ne(n.serializer)+"/documents",o={documents:e.map((function(t){return Ie(n.serializer,t)}))},[4,n.$o("BatchGetDocuments",i,o)];case 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=Te(t,e.found.name),r=Ee(e.found.updateTime),i=new vn({mapValue:{fields:e.found.fields}});return new wn(n,r,i,{})}(t,e):"missing"in e?function(t,e){w(!!e.missing),w(!!e.readTime);var n=Te(t,e.missing),r=Ee(e.readTime);return new bn(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.jo,t)];case 1:return[2,((e=i.sent()).forEach((function(t){t instanceof bn||t instanceof wn?n.ah(t):m()})),e)]}}))}))},t.prototype.set=function(t,e){this.write(e.za(t,this.Ge(t))),this.rh.add(t.toString())},t.prototype.update=function(t,e){try{this.write(e.za(t,this.hh(t)))}catch(t){this.ih=t}this.rh.add(t.toString())},t.prototype.delete=function(t){this.write([new pn(t,this.Ge(t))]),this.rh.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.uh(),this.ih)throw this.ih;return t=this.nh,this.mutations.forEach((function(e){t.delete(e.key.toString())})),t.forEach((function(t,n){var r=L.C(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=b(t),i=Ne(n.serializer)+"/documents",o={writes:e.map((function(t){return Le(n.serializer,t)}))},[4,n.No("Commit",i,o)];case 1:return r.sent(),[2]}}))}))}(this.jo,this.mutations)];case 1:return n.sent(),this.sh=!0,[2]}}))}))},t.prototype.ah=function(t){var e;if(t instanceof wn)e=t.version;else{if(!(t instanceof bn))throw m();e=ut.min()}var n=this.nh.get(t.key.toString());if(n){if(!e.isEqual(n))throw new f(h.ABORTED,"Document version changed between two reads.")}else this.nh.set(t.key.toString(),e)},t.prototype.Ge=function(t){var e=this.nh.get(t.toString());return!this.rh.has(t.toString())&&e?Ze.updateTime(e):Ze.He()},t.prototype.hh=function(t){var e=this.nh.get(t.toString());if(!this.rh.has(t.toString())&&e){if(e.isEqual(ut.min()))throw new f(h.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return Ze.updateTime(e)}return Ze.exists(!0)},t.prototype.write=function(t){this.uh(),this.mutations=this.mutations.concat(t)},t.prototype.uh=function(){},t}(),jo=function(){function t(t,e,n,r){this.kn=t,this.jo=e,this.updateFunction=n,this.Ln=r,this.lh=5,this.Jn=new nr(this.kn,"transaction_retry")}return t.prototype.run=function(){this._h()},t.prototype._h=function(){var t=this;this.Jn.Rn((function(){return r.__awaiter(t,void 0,void 0,(function(){var t,e,n=this;return r.__generator(this,(function(r){return t=new Fo(this.jo),(e=this.fh(t))&&e.then((function(e){n.kn.Qn((function(){return t.commit().then((function(){n.Ln.resolve(e)})).catch((function(t){n.dh(t)}))}))})).catch((function(t){n.dh(t)})),[2]}))}))}))},t.prototype.fh=function(t){try{var e=this.updateFunction(t);return!at(e)&&e.catch&&e.then?e:(this.Ln.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.Ln.reject(t),null}},t.prototype.dh=function(t){var e=this;this.lh>0&&this.wh(t)?(this.lh-=1,this.kn.Qn((function(){return e._h(),Promise.resolve()}))):this.Ln.reject(t)},t.prototype.wh=function(t){if("FirebaseError"===t.name){var e=t.code;return"aborted"===e||"failed-precondition"===e||!wt(e)}return!1},t}(),Bo=function(){function t(t,e){this.credentials=t,this.kn=e,this.clientId=Y.k(),this.mh=new er}return t.prototype.start=function(t,e,n,i){var o=this;this.Th(),this.ia=t;var s=new er,u=!1;return this.credentials.jr((function(t){if(!u)return u=!0,d("FirestoreClient","Initializing. user=",t.uid),o.Eh(e,n,i,t,s).then(o.mh.resolve,o.mh.reject);o.kn.rs((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=b(t)).kn.cs(),d("RemoteStore","RemoteStore received new credentials"),i=oi(n),n.Ko.add(3),[4,Jr(n)];case 1:return r.sent(),i&&n.Xo.set("Unknown"),[4,n.Wo.Sa(e)];case 2:return r.sent(),n.Ko.delete(3),[4,Xr(n)];case 3:return r.sent(),[2]}}))}))}(o.pu,t)}))})),this.kn.Qn((function(){return o.mh.promise})),s.promise},t.prototype.enableNetwork=function(){var t=this;return this.Th(),this.kn.enqueue((function(){return t.persistence.Mc(!0),function(t){var e=b(t);return e.Ko.delete(0),Xr(e)}(t.pu)}))},t.prototype.Eh=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={kn:this.kn,ia:this.ia,clientId:this.clientId,credentials:this.credentials,ya:i,vu: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.Vu=t.Vu,this.Qo=t.Qo,this.Ia=t.Ia,this.jo=e.jo,this.pu=e.pu,this.va=e.va,this.Ih=e.gu,this.Ih.Es=ki.bind(null,this.va),this.Ih.Rs=Li.bind(null,this.va),this.persistence.Oc((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.Ah(u))throw u;return[2,(console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+u),this.Eh(new oo,new so,{Pa:!1},i,o))];case 4:return[2]}}))}))},t.prototype.Ah=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.Th=function(){if(this.kn.Zn)throw new f(h.FAILED_PRECONDITION,"The client has already been terminated.")},t.prototype.disableNetwork=function(){var t=this;return this.Th(),this.kn.enqueue((function(){return t.persistence.Mc(!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=b(t)).Ko.add(0),[4,Jr(e)];case 1:return n.sent(),e.Xo.set("Offline"),[2]}}))}))}(t.pu)}))},t.prototype.terminate=function(){var t=this;this.kn.ss();var e=new er;return this.kn.ts((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.Ia&&this.Ia.stop(),[4,Zr(this.pu)];case 1:return r.sent(),[4,this.Vu.ei()];case 2:return r.sent(),[4,this.persistence.ei()];case 3:return r.sent(),this.credentials.Wr(),e.resolve(),[3,5];case 4:return t=r.sent(),n=ar(t,"Failed to shutdown persistence"),e.reject(n),[3,5];case 5:return[2]}}))}))})),e.promise},t.prototype.waitForPendingWrites=function(){var t=this;this.Th();var e=new er;return this.kn.Qn((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:oi((n=b(t)).pu)||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=b(t);return e.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(function(t){return e.hi.zu(t)}))}(n.Qo)];case 2:return-1===(i=r.sent())?[2,void e.resolve()]:((o=n.ku.get(i)||[]).push(e),n.ku.set(i,o),[3,4]);case 3:return s=r.sent(),u=ar(s,"Initialization of waitForPendingWrites() operation failed"),e.reject(u),[3,4];case 4:return[2]}}))}))}(t.va,e)})),e.promise},t.prototype.listen=function(t,e,n){var r=this;this.Th();var i=new uo(n),o=new yr(t,i,e);return this.kn.Qn((function(){return fr(r.Ih,o)})),function(){i.Da(),r.kn.Qn((function(){return lr(r.Ih,o)}))}},t.prototype.Rh=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.Th(),[4,this.mh.promise];case 1:return i.sent(),e=new er,[2,(this.kn.Qn((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=b(t);return n.persistence.runTransaction("read document","readonly",(function(t){return n.er._i(t,e)}))}(t,e)];case 1:return(i=r.sent())instanceof wn?n.resolve(i):i instanceof bn?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=ar(o,"Failed to get document '"+e+" from cache"),n.reject(s),[3,3];case 3:return[2]}}))}))}(n.Qo,t,e)})),e.promise)]}}))}))},t.prototype.yh=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.Th(),[4,this.mh.promise];case 1:return r.sent(),n=new er,[2,(this.kn.Qn((function(){return function(t,e,n,r,i){var o=new uo({next:function(o){e.Qn((function(){return lr(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 yr(In(n.path),o,{includeMetadataChanges:!0,bs:!0});return fr(t,s)}(i.Ih,i.kn,t,e,n)})),n.promise)]}}))}))},t.prototype.Ph=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.Th(),[4,this.mh.promise];case 1:return i.sent(),e=new er,[2,(this.kn.Qn((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,Or(t,e,!0)];case 1:return i=r.sent(),o=new Ii(e,i.gr),s=o._u(i.documents),u=o.mu(s,!1),n.resolve(u.snapshot),[3,3];case 2:return a=r.sent(),c=ar(a,"Failed to execute query '"+e+" against cache"),n.reject(c),[3,3];case 3:return[2]}}))}))}(n.Qo,t,e)})),e.promise)]}}))}))},t.prototype.ph=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.Th(),[4,this.mh.promise];case 1:return r.sent(),n=new er,[2,(this.kn.Qn((function(){return function(t,e,n,r,i){var o=new uo({next:function(n){e.Qn((function(){return lr(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 yr(n,o,{includeMetadataChanges:!0,bs:!0});return fr(t,s)}(i.Ih,i.kn,t,e,n)})),n.promise)]}}))}))},t.prototype.write=function(t){var e=this;this.Th();var n=new er;return this.kn.Qn((function(){return Vi(e.va,t,n)})),n.promise},t.prototype.B=function(){return this.ia.B},t.prototype.gh=function(t){var e=this;this.Th();var n=new uo(t);return this.kn.Qn((function(){return r.__awaiter(e,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,function(t,e){b(t).Ts.add(e),e.next()}(this.Ih,n)]}))}))})),function(){n.Da(),e.kn.Qn((function(){return r.__awaiter(e,void 0,void 0,(function(){return r.__generator(this,(function(t){return[2,function(t,e){b(t).Ts.delete(e)}(this.Ih,n)]}))}))}))}},Object.defineProperty(t.prototype,"Vh",{get:function(){return this.kn.Zn},enumerable:!1,configurable:!0}),t.prototype.transaction=function(t){var e=this;this.Th();var n=new er;return this.kn.Qn((function(){return new jo(e.kn,e.jo,t,n).run(),Promise.resolve()})),n.promise},t}();function Qo(t){return function(t,e){if("object"!=typeof t||null===t)return!1;for(var n=t,r=0,i=["next","error","complete"];r<i.length;r++){var o=i[r];if(o in n&&"function"==typeof n[o])return!0}return!1}(t)}var zo=function(){function t(t,e,n,r,i){this.B=t,this.timestampsInSnapshots=e,this.bh=n,this.Sh=r,this.Ch=i}return t.prototype.Dh=function(t){switch(Jt(t)){case 0:return null;case 1:return t.booleanValue;case 2:return ie(t.integerValue||t.doubleValue);case 3:return this.Fh(t.timestampValue);case 4:return this.Nh(t);case 5:return t.stringValue;case 6:return this.Ch(oe(t.bytesValue));case 7:return this.$h(t.referenceValue);case 8:return this.xh(t.geoPointValue);case 9:return this.kh(t.arrayValue);case 10:return this.Oh(t.mapValue);default:throw m()}},t.prototype.Oh=function(t){var e=this,n={};return _(t.fields||{},(function(t,r){n[t]=e.Dh(r)})),n},t.prototype.xh=function(t){return new Eo(ie(t.latitude),ie(t.longitude))},t.prototype.kh=function(t){var e=this;return(t.values||[]).map((function(t){return e.Dh(t)}))},t.prototype.Nh=function(t){switch(this.bh){case"previous":var e=function t(e){var n=e.mapValue.fields.__previous_value__;return Ht(n)?t(n):n}(t);return null==e?null:this.Dh(e);case"estimate":return this.Fh(Yt(t));default:return null}},t.prototype.Fh=function(t){var e=re(t),n=new st(e.seconds,e.nanos);return this.timestampsInSnapshots?n:n.toDate()},t.prototype.$h=function(t){var e=A.P(t);w(Ce(e));var n=new it(e.get(1),e.get(3)),r=new L(e.u(5));return n.isEqual(this.B)||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.B.projectId+"/"+this.B.database+") instead."),this.Sh(r)},t}(),Wo=Ar.ki,Ko=function(){function t(t){var e,n,r,i;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 O("settings","non-empty string","host",t.host),this.host=t.host,C("settings","boolean","ssl",t.ssl),this.ssl=null===(e=t.ssl)||void 0===e||e;if(B("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling","ignoreUndefinedProperties"]),C("settings","object","credentials",t.credentials),this.credentials=t.credentials,C("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),C("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,C("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=Ar.Mi;else{if(t.cacheSizeBytes!==Wo&&t.cacheSizeBytes<Ar.Oi)throw new f(h.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+Ar.Oi);this.cacheSizeBytes=t.cacheSizeBytes}C("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.experimentalForceLongPolling=null!==(i=t.experimentalForceLongPolling)&&void 0!==i&&i}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.ignoreUndefinedProperties===t.ignoreUndefinedProperties},t}(),Ho=function(){function t(e,n,i,o){var s=this;if(void 0===i&&(i=new oo),void 0===o&&(o=new so),this.Mh=i,this.Lh=o,this.qh=null,this.Uh=new ur,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.Bh(),[4,this.Qh.terminate()];case 1:return t.sent(),[2]}}))}))}},"object"==typeof e.options){var u=e;this.qh=u,this.ja=t.jh(u),this.Wh=u.name,this.Gh=new Fr(n)}else{var a=e;if(!a.projectId)throw new f(h.INVALID_ARGUMENT,"Must provide projectId");this.ja=new it(a.projectId,a.database),this.Wh="[DEFAULT]",this.Gh=new qr}this.zh=new Ko({})}return Object.defineProperty(t.prototype,"Kh",{get:function(){return this.Hh||(this.Hh=new Lo(this.ja,this.zh.ignoreUndefinedProperties)),this.Hh},enumerable:!1,configurable:!0}),t.prototype.settings=function(t){D("Firestore.settings",arguments,1),P("Firestore.settings","object",1,t),t.merge&&delete(t=Object.assign(Object.assign({},this.zh),t)).merge;var e=new Ko(t);if(this.Qh&&!this.zh.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.zh=e,void 0!==e.credentials&&(this.Gh=function(t){if(!t)return new qr;switch(t.type){case"gapi":var e=t.Yh;return w(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new Br(e,t.Jr||"0");case"provider":return t.Yh;default:throw new f(h.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(e.credentials))},t.prototype.enableNetwork=function(){return this.Bh(),this.Qh.enableNetwork()},t.prototype.disableNetwork=function(){return this.Bh(),this.Qh.disableNetwork()},t.prototype.enablePersistence=function(t){var e,n;if(this.Qh)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.Jh(this.Mh,this.Lh,{Pa:!0,cacheSizeBytes:this.zh.cacheSizeBytes,synchronizeTabs:r,Xh: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.Qh&&!this.Qh.Vh)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 er,[2,(this.Uh.ts((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.Mh.clearPersistence(this.ja,this.Wh)];case 1:return n.sent(),t.resolve(),[3,3];case 2:return e=n.sent(),t.reject(e),[3,3];case 3:return[2]}}))}))})),t.promise)]}))}))},t.prototype.terminate=function(){return this.app._removeServiceInstance("firestore"),this.INTERNAL.delete()},Object.defineProperty(t.prototype,"Zh",{get:function(){return this.Bh(),this.Qh.Vh},enumerable:!1,configurable:!0}),t.prototype.waitForPendingWrites=function(){return this.Bh(),this.Qh.waitForPendingWrites()},t.prototype.onSnapshotsInSync=function(t){if(this.Bh(),Qo(t))return this.Qh.gh(t);P("Firestore.onSnapshotsInSync","function",1,t);var e={next:t};return this.Qh.gh(e)},t.prototype.Bh=function(){return this.Qh||this.Jh(new oo,new so,{Pa:!1}),this.Qh},t.prototype.tl=function(){return new rt(this.ja,this.Wh,this.zh.host,this.zh.ssl,this.zh.experimentalForceLongPolling)},t.prototype.Jh=function(t,e,n){var r=this.tl();return this.Qh=new Bo(this.Gh,this.Uh),this.Qh.start(r,t,e,n)},t.jh=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 it(n)},Object.defineProperty(t.prototype,"app",{get:function(){if(!this.qh)throw new f(h.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.qh},enumerable:!1,configurable:!0}),t.prototype.collection=function(t){return D("Firestore.collection",arguments,1),P("Firestore.collection","non-empty string",1,t),this.Bh(),new cs(A.P(t),this,null)},t.prototype.doc=function(t){return D("Firestore.doc",arguments,1),P("Firestore.doc","non-empty string",1,t),this.Bh(),Jo.el(A.P(t),this,null)},t.prototype.collectionGroup=function(t){if(D("Firestore.collectionGroup",arguments,1),P("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.Bh(),new us(function(t){return new _n(A.p(),t)}(t),this,null)},t.prototype.runTransaction=function(t){var e=this;return D("Firestore.runTransaction",arguments,1),P("Firestore.runTransaction","function",1,t),this.Bh().transaction((function(n){return t(new Yo(e,n))}))},t.prototype.batch=function(){return this.Bh(),new Xo(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;D("Firestore.setLogLevel",arguments,1),x("setLogLevel",["debug","error","silent","warn","info","verbose"],1,t),e=t,l.setLogLevel(e)},t.prototype.nl=function(){return this.zh.timestampsInSnapshots},t.prototype.sl=function(){return this.zh},t}(),Yo=function(){function t(t,e){this.il=t,this.rl=e}return t.prototype.get=function(t){var e=this;D("Transaction.get",arguments,1);var n=ps("Transaction.get",t,this.il);return this.rl.oh([n.Wa]).then((function(t){if(!t||1!==t.length)return m();var r=t[0];if(r instanceof bn)return new $o(e.il,n.Wa,null,!1,!1,n.Ga);if(r instanceof wn)return new $o(e.il,n.Wa,r,!1,!1,n.Ga);throw m()}))},t.prototype.set=function(t,e,n){S("Transaction.set",arguments,2,3);var r=ps("Transaction.set",t,this.il);n=hs("Transaction.set",n);var i=vs(r.Ga,e,n),o=Vo(this.il.Kh,"Transaction.set",r.Wa,i,null!==r.Ga,n);return this.rl.set(r.Wa,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 co?(R("Transaction.update",arguments,3),r=ps("Transaction.update",t,this.il),i=Ro(this.il.Kh,"Transaction.update",r.Wa,e,n,o)):(D("Transaction.update",arguments,2),r=ps("Transaction.update",t,this.il),i=Do(this.il.Kh,"Transaction.update",r.Wa,e)),this.rl.update(r.Wa,i),this},t.prototype.delete=function(t){D("Transaction.delete",arguments,1);var e=ps("Transaction.delete",t,this.il);return this.rl.delete(e.Wa),this},t}(),Xo=function(){function t(t){this.il=t,this.ol=[],this.ul=!1}return t.prototype.set=function(t,e,n){S("WriteBatch.set",arguments,2,3),this.cl();var r=ps("WriteBatch.set",t,this.il);n=hs("WriteBatch.set",n);var i=vs(r.Ga,e,n),o=Vo(this.il.Kh,"WriteBatch.set",r.Wa,i,null!==r.Ga,n);return this.ol=this.ol.concat(o.za(r.Wa,Ze.He())),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.cl(),"string"==typeof e||e instanceof co?(R("WriteBatch.update",arguments,3),r=ps("WriteBatch.update",t,this.il),i=Ro(this.il.Kh,"WriteBatch.update",r.Wa,e,n,o)):(D("WriteBatch.update",arguments,2),r=ps("WriteBatch.update",t,this.il),i=Do(this.il.Kh,"WriteBatch.update",r.Wa,e)),this.ol=this.ol.concat(i.za(r.Wa,Ze.exists(!0))),this},t.prototype.delete=function(t){D("WriteBatch.delete",arguments,1),this.cl();var e=ps("WriteBatch.delete",t,this.il);return this.ol=this.ol.concat(new pn(e.Wa,Ze.He())),this},t.prototype.commit=function(){return this.cl(),this.ul=!0,this.ol.length>0?this.il.Bh().write(this.ol):Promise.resolve()},t.prototype.cl=function(){if(this.ul)throw new f(h.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},t}(),Jo=function(t){function e(e,n,r){var i=this;return(i=t.call(this,n.ja,e,r)||this).Wa=e,i.firestore=n,i.Ga=r,i.Qh=i.firestore.Bh(),i}return r.__extends(e,t),e.el=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 L(t),n,r)},Object.defineProperty(e.prototype,"id",{get:function(){return this.Wa.path._()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return new cs(this.Wa.path.h(),this.firestore,this.Ga)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this.Wa.path.R()},enumerable:!1,configurable:!0}),e.prototype.collection=function(t){if(D("DocumentReference.collection",arguments,1),P("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=A.P(t);return new cs(this.Wa.path.child(e),this.firestore,null)},e.prototype.isEqual=function(t){if(!(t instanceof e))throw Q("isEqual","DocumentReference",1,t);return this.firestore===t.firestore&&this.Wa.isEqual(t.Wa)&&this.Ga===t.Ga},e.prototype.set=function(t,e){S("DocumentReference.set",arguments,1,2),e=hs("DocumentReference.set",e);var n=vs(this.Ga,t,e),r=Vo(this.firestore.Kh,"DocumentReference.set",this.Wa,n,null!==this.Ga,e);return this.Qh.write(r.za(this.Wa,Ze.He()))},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 co?(R("DocumentReference.update",arguments,2),n=Ro(this.firestore.Kh,"DocumentReference.update",this.Wa,t,e,r)):(D("DocumentReference.update",arguments,1),n=Do(this.firestore.Kh,"DocumentReference.update",this.Wa,t)),this.Qh.write(n.za(this.Wa,Ze.exists(!0)))},e.prototype.delete=function(){return D("DocumentReference.delete",arguments,0),this.Qh.write([new pn(this.Wa,Ze.He())])},e.prototype.onSnapshot=function(){for(var t,e,n,r=this,i=[],o=0;o<arguments.length;o++)i[o]=arguments[o];S("DocumentReference.onSnapshot",arguments,1,4);var s={includeMetadataChanges:!1},u=0;"object"!=typeof i[u]||Qo(i[u])||(B("DocumentReference.onSnapshot",s=i[u],["includeMetadataChanges"]),C("DocumentReference.onSnapshot","boolean","includeMetadataChanges",s.includeMetadataChanges),u++);var a={includeMetadataChanges:s.includeMetadataChanges};if(Qo(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.bind(c),i[u+2]=null===(n=c.complete)||void 0===n?void 0:n.bind(c)}else P("DocumentReference.onSnapshot","function",u,i[u]),U("DocumentReference.onSnapshot","function",u+1,i[u+1]),U("DocumentReference.onSnapshot","function",u+2,i[u+2]);var h={next:function(t){i[u]&&i[u](r.al(t))},error:i[u+1],complete:i[u+2]};return this.Qh.listen(In(this.Wa.path),a,h)},e.prototype.get=function(t){var e=this;S("DocumentReference.get",arguments,0,1),ls("DocumentReference.get",t);var n=this.firestore.Bh();return t&&"cache"===t.source?n.Rh(this.Wa).then((function(t){return new $o(e.firestore,e.Wa,t,!0,t instanceof wn&&t.Ye,e.Ga)})):n.yh(this.Wa,t).then((function(t){return e.al(t)}))},e.prototype.withConverter=function(t){return new e(this.Wa,this.firestore,t)},e.prototype.al=function(t){var e=t.docs.get(this.Wa);return new $o(this.firestore,this.Wa,e,t.fromCache,t.hasPendingWrites,this.Ga)},e}(Io),Zo=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}(),$o=function(){function t(t,e,n,r,i,o){this.il=t,this.Wa=e,this.hl=n,this.ll=r,this._l=i,this.Ga=o}return t.prototype.data=function(t){var e=this;if(S("DocumentSnapshot.data",arguments,0,1),t=fs("DocumentSnapshot.data",t),this.hl){if(this.Ga){var n=new ts(this.il,this.Wa,this.hl,this.ll,this._l,null);return this.Ga.fromFirestore(n,t)}return new zo(this.il.ja,this.il.nl(),t.serverTimestamps||"none",(function(t){return new Jo(t,e.il,null)}),(function(t){return new nt(t)})).Dh(this.hl.sn())}},t.prototype.get=function(t,e){var n=this;if(S("DocumentSnapshot.get",arguments,1,2),e=fs("DocumentSnapshot.get",e),this.hl){var r=this.hl.data().field(Mo("DocumentSnapshot.get",t,this.Wa));if(null!==r)return new zo(this.il.ja,this.il.nl(),e.serverTimestamps||"none",(function(t){return new Jo(t,n.il,n.Ga)}),(function(t){return new nt(t)})).Dh(r)}},Object.defineProperty(t.prototype,"id",{get:function(){return this.Wa.path._()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ref",{get:function(){return new Jo(this.Wa,this.il,this.Ga)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"exists",{get:function(){return null!==this.hl},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metadata",{get:function(){return new Zo(this._l,this.ll)},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){if(!(e instanceof t))throw Q("isEqual","DocumentSnapshot",1,e);return this.il===e.il&&this.ll===e.ll&&this.Wa.isEqual(e.Wa)&&(null===this.hl?null===e.hl:this.hl.isEqual(e.hl))&&this.Ga===e.Ga},t}(),ts=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}($o);function es(t,e,n,r,i,o,s){var u;if(i.V()){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){is(s,o);for(var a=[],c=0,l=s;c<l.length;c++){var p=l[c];a.push(rs(r,t,p))}u={arrayValue:{values:a}}}else u=rs(r,t,s)}else"in"!==o&&"not-in"!==o&&"array-contains-any"!==o||is(s,o),u=So(n,e,s,"in"===o||"not-in"===o);var d=Gn.create(i,o,u);return function(t,e){if(e.an()){var n=kn(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=Nn(t);null!==r&&os(t,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}function ns(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 Zn(e,n);return function(t,e){if(null===Nn(t)){var n=kn(t);null!==n&&os(t,n,e.field)}}(t,r),r}function rs(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(!Ln(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(A.P(n));if(!L.N(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 se(t,new L(r))}if(n instanceof Io)return se(t,n.Wa);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: "+F(n)+".")}function is(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 os(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 ss(t){if(An(t)&&0===t.rn.length)throw new f(h.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var us=function(){function t(t,e,n){this.fl=t,this.firestore=e,this.Ga=n}return t.prototype.where=function(e,n,r){D("Query.where",arguments,3),j("Query.where",3,r);var i=x("Query.where",["<","<=","==","!=",">=",">","array-contains","in","array-contains-any","not-in"],2,n),o=Mo("Query.where",e),s=es(this.fl,"Query.where",this.firestore.Kh,this.firestore.ja,o,i,r);return new t(function(t,e){var n=t.filters.concat([e]);return new _n(t.path,t.collectionGroup,t.rn.slice(),n,t.limit,t.on,t.startAt,t.endAt)}(this.fl,s),this.firestore,this.Ga)},t.prototype.orderBy=function(e,n){var r;if(S("Query.orderBy",arguments,1,2),U("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=Mo("Query.orderBy",e),o=ns(this.fl,i,r);return new t(function(t,e){var n=t.rn.concat([e]);return new _n(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.on,t.startAt,t.endAt)}(this.fl,o),this.firestore,this.Ga)},t.prototype.limit=function(e){return D("Query.limit",arguments,1),P("Query.limit","number",1,e),z("Query.limit",1,e),new t(Rn(this.fl,e,"F"),this.firestore,this.Ga)},t.prototype.limitToLast=function(e){return D("Query.limitToLast",arguments,1),P("Query.limitToLast","number",1,e),z("Query.limitToLast",1,e),new t(Rn(this.fl,e,"L"),this.firestore,this.Ga)},t.prototype.startAt=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];R("Query.startAt",arguments,1);var i=this.dl("Query.startAt",e,n,!0);return new t(Sn(this.fl,i),this.firestore,this.Ga)},t.prototype.startAfter=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];R("Query.startAfter",arguments,1);var i=this.dl("Query.startAfter",e,n,!1);return new t(Sn(this.fl,i),this.firestore,this.Ga)},t.prototype.endBefore=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];R("Query.endBefore",arguments,1);var i=this.dl("Query.endBefore",e,n,!0);return new t(Pn(this.fl,i),this.firestore,this.Ga)},t.prototype.endAt=function(e){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];R("Query.endAt",arguments,1);var i=this.dl("Query.endAt",e,n,!1);return new t(Pn(this.fl,i),this.firestore,this.Ga)},t.prototype.isEqual=function(e){if(!(e instanceof t))throw Q("isEqual","Query",1,e);return this.firestore===e.firestore&&Un(this.fl,e.fl)&&this.Ga===e.Ga},t.prototype.withConverter=function(e){return new t(this.fl,this.firestore,e)},t.prototype.dl=function(t,e,n,i){if(j(t,1,e),e instanceof $o)return D(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=Vn(t);s<u.length;s++){var a=u[s];if(a.field.V())o.push(se(e,r.key));else{var c=r.field(a.field);if(Ht(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 Hn(o,i)}(this.fl,this.firestore.ja,t,e.hl,i);var o=[e].concat(n);return function(t,e,n,r,i,o){var s=t.rn;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.V()){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(!Ln(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(A.P(c));if(!L.N(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 L(l);u.push(se(e,p))}else{var d=So(n,r,c);u.push(d)}}return new Hn(u,o)}(this.fl,this.firestore.ja,this.firestore.Kh,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];S("Query.onSnapshot",arguments,1,4);var s={},u=0;if("object"!=typeof i[u]||Qo(i[u])||(B("Query.onSnapshot",s=i[u],["includeMetadataChanges"]),C("Query.onSnapshot","boolean","includeMetadataChanges",s.includeMetadataChanges),u++),Qo(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 P("Query.onSnapshot","function",u,i[u]),U("Query.onSnapshot","function",u+1,i[u+1]),U("Query.onSnapshot","function",u+2,i[u+2]);var c={next:function(t){i[u]&&i[u](new as(r.firestore,r.fl,t,r.Ga))},error:i[u+1],complete:i[u+2]};return ss(this.fl),this.firestore.Bh().listen(this.fl,s,c)},t.prototype.get=function(t){var e=this;S("Query.get",arguments,0,1),ls("Query.get",t),ss(this.fl);var n=this.firestore.Bh();return(t&&"cache"===t.source?n.Ph(this.fl):n.ph(this.fl,t)).then((function(t){return new as(e.firestore,e.fl,t,e.Ga)}))},t}(),as=function(){function t(t,e,n,r){this.il=t,this.wl=e,this.ml=n,this.Ga=r,this.Tl=null,this.El=null,this.metadata=new Zo(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.ml.docs.m()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this.ml.docs.size},enumerable:!1,configurable:!0}),t.prototype.forEach=function(t,e){var n=this;S("QuerySnapshot.forEach",arguments,1,2),P("QuerySnapshot.forEach","function",1,t),this.ml.docs.forEach((function(r){t.call(e,n.Il(r,n.metadata.fromCache,n.ml.Qt.has(r.key)))}))},Object.defineProperty(t.prototype,"query",{get:function(){return new us(this.wl,this.il,this.Ga)},enumerable:!1,configurable:!0}),t.prototype.docChanges=function(t){t&&(B("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),C("QuerySnapshot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this.ml.Wt)throw new f(h.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this.Tl&&this.El===e||(this.Tl=function(t,e,n){if(t.Bt.m()){var r=0;return t.docChanges.map((function(e){var i=n(e.doc,t.fromCache,t.Qt.has(e.doc.key));return e.doc,{type:"added",doc:i,oldIndex:-1,newIndex:r++}}))}var i=t.Bt;return t.docChanges.filter((function(t){return e||3!==t.type})).map((function(e){var r=n(e.doc,t.fromCache,t.Qt.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:ds(e.type),doc:r,oldIndex:o,newIndex:s}}))}(this.ml,e,this.Il.bind(this)),this.El=e),this.Tl},t.prototype.isEqual=function(e){if(!(e instanceof t))throw Q("isEqual","QuerySnapshot",1,e);return this.il===e.il&&Un(this.wl,e.wl)&&this.ml.isEqual(e.ml)&&this.Ga===e.Ga},t.prototype.Il=function(t,e,n){return new ts(this.il,t.key,t,e,n,this.Ga)},t}(),cs=function(t){function e(e,n,r){var i=this;if((i=t.call(this,In(e),n,r)||this).Al=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.fl.path._()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){var t=this.fl.path.h();return t.m()?null:new Jo(new L(t),this.firestore,null)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this.fl.path.R()},enumerable:!1,configurable:!0}),e.prototype.doc=function(t){S("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=Y.k()),P("CollectionReference.doc","non-empty string",1,t);var e=A.P(t);return Jo.el(this.fl.path.child(e),this.firestore,this.Ga)},e.prototype.add=function(t){D("CollectionReference.add",arguments,1);var e=this.Ga?this.Ga.toFirestore(t):t;P("CollectionReference.add","object",1,e);var n=this.doc();return new Jo(n.Wa,this.firestore,null).set(e).then((function(){return n}))},e.prototype.withConverter=function(t){return new e(this.Al,this.firestore,t)},e}(us);function hs(t,e){if(void 0===e)return{merge:!1};if(B(t,e,["merge","mergeFields"]),C(t,"boolean","merge",e.merge),function(t,e,n,r,i){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: "+F(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 a string or a FieldPath, but the value at index "+o+" was: "+F(r[o]))}(t,"mergeFields",0,r,(function(t){return"string"==typeof t||t instanceof co}))}(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 fs(t,e){return void 0===e?{}:(B(t,e,["serverTimestamps"]),M(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function ls(t,e){U(t,"object",1,e),e&&(B(t,e,["source"]),M(t,0,"source",e.source,["default","server","cache"]))}function ps(t,e,n){if(e instanceof Io){if(e.firestore!==n)throw new f(h.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw Q(t,"DocumentReference",1,e)}function ds(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return m()}}function vs(t,e,n){return t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e}var ys={Firestore:Ho,GeoPoint:Eo,Timestamp:st,Blob:nt,Transaction:Yo,WriteBatch:Xo,DocumentReference:Jo,DocumentSnapshot:$o,Query:us,QueryDocumentSnapshot:ts,QuerySnapshot:as,CollectionReference:cs,FieldPath:co,FieldValue:wo,setLogLevel:Ho.setLogLevel,CACHE_SIZE_UNLIMITED:Wo};function gs(t){!function(t,e){t.INTERNAL.registerComponent(new a.Component("firestore",(function(t){return function(t,e){return new Ho(t,e,new oo,new so)}(t.getProvider("app").getImmediate(),t.getProvider("auth-internal"))}),"PUBLIC").setServiceProps(Object.assign({},ys)))}(t),t.registerVersion("@firebase/firestore","1.17.0")}gs(c.default),e.__PRIVATE_registerFirestore=gs},590:function(t,e,n){"use strict";n.r(e);n(1456)}}]);