PageSourceSearch

https://the-timeline.jp/_next/static/chunks/484bcb1e.0c5816a8962459881180.js

js the-timeline.jp collected 2026-10-04 11:42:19 UTC 251,751 bytes, 1 lines download raw bytes

1(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{"6Joi":function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r,i=n("mrSG"),o=(r=n("wj3C"))&&"object"==typeof r&&"default"in r?r.default:r,s=n("q/0M"),u=n("zVF4"),a=n("S+S0"),c=n("x7I3"),h=o.SDK_VERSION,f=function(){function t(t){this.uid=t}return t.prototype.t=function(){return null!=this.uid},t.prototype.s=function(){return this.t()?"uid:"+this.uid:"anonymous-user"},t.prototype.isEqual=function(t){return t.uid===this.uid},t}();f.UNAUTHENTICATED=new f(null),f.i=new f("google-credentials-uid"),f.h=new f("first-party-uid");var l={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"},p=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 i.__extends(e,t),e}(Error),d=function(t,e){this.user=e,this.type="OAuth",this.o={},this.o.Authorization="Bearer "+t},y=function(){function t(){this.u=null}return t.prototype.getToken=function(){return Promise.resolve(null)},t.prototype._=function(){},t.prototype.l=function(t){this.u=t,t(f.UNAUTHENTICATED)},t.prototype.T=function(){this.u=null},t}(),v=function(){function t(t){var e=this;this.I=null,this.currentUser=f.UNAUTHENTICATED,this.R=!1,this.A=0,this.u=null,this.forceRefresh=!1,this.I=function(){e.A++,e.currentUser=e.m(),e.R=!0,e.u&&e.u(e.currentUser)},this.A=0,this.auth=t.getImmediate({optional:!0}),this.auth?this.auth.addAuthTokenListener(this.I):(this.I(null),t.get().then((function(t){e.auth=t,e.I&&e.auth.addAuthTokenListener(e.I)}),(function(){})))}return t.prototype.getToken=function(){var t=this,e=this.A,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then((function(n){return t.A!==e?(ye("FirebaseCredentialsProvider","getToken aborted due to token change."),t.getToken()):n?(we("string"==typeof n.accessToken),new d(n.accessToken,t.currentUser)):null})):Promise.resolve(null)},t.prototype._=function(){this.forceRefresh=!0},t.prototype.l=function(t){this.u=t,this.R&&t(this.currentUser)},t.prototype.T=function(){this.auth&&this.auth.removeAuthTokenListener(this.I),this.I=null,this.u=null},t.prototype.m=function(){var t=this.auth&&this.auth.getUid();return we(null===t||"string"==typeof t),new f(t)},t}(),g=function(){function t(t,e){this.P=t,this.V=e,this.type="FirstParty",this.user=f.h}return Object.defineProperty(t.prototype,"o",{get:function(){var t={"X-Goog-AuthUser":this.V},e=this.P.auth.g([]);return e&&(t.Authorization=e),t},enumerable:!0,configurable:!0}),t}(),m=function(){function t(t,e){this.P=t,this.V=e}return t.prototype.getToken=function(){return Promise.resolve(new g(this.P,this.V))},t.prototype.l=function(t){t(f.h)},t.prototype.T=function(){},t.prototype._=function(){},t}(),w=function(){function t(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new p(l.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new p(l.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new p(l.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new p(l.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.p=function(t){return this.seconds===t.seconds?be(this.nanoseconds,t.nanoseconds):be(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.valueOf=function(){var t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}
1,t}(),E=function(){function t(t){this.timestamp=t}return t.v=function(e){return new t(e)},t.min=function(){return new t(new w(0,0))},t.prototype.S=function(t){return this.timestamp.p(t.timestamp)},t.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},t.prototype.D=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},t.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},t.prototype.C=function(){return this.timestamp},t}(),_=function(){function t(t,e,n){void 0===e?e=0:e>t.length&&me(),void 0===n?n=t.length-e:n>t.length-e&&me(),this.segments=t,this.offset=e,this.F=n}return Object.defineProperty(t.prototype,"length",{get:function(){return this.F},enumerable:!0,configurable:!0}),t.prototype.isEqual=function(e){return 0===t.N(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.k(n)},t.prototype.limit=function(){return this.offset+this.length},t.prototype.M=function(t){return t=void 0===t?1:t,this.k(this.segments,this.offset+t,this.length-t)},t.prototype.$=function(){return this.k(this.segments,this.offset,this.length-1)},t.prototype.O=function(){return this.segments[this.offset]},t.prototype.L=function(){return this.get(this.length-1)},t.prototype.get=function(t){return this.segments[this.offset+t]},t.prototype.B=function(){return 0===this.length},t.prototype.q=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.U=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.W=function(){return this.segments.slice(this.offset,this.limit())},t.N=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}(),b=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.k=function(t,n,r){return new e(t,n,r)},e.prototype.j=function(){return this.W().join("/")},e.prototype.toString=function(){return this.j()},e.K=function(t){if(t.indexOf("//")>=0)throw new p(l.INVALID_ARGUMENT,"Invalid path ("+t+"). Paths must not contain // in them.");return new e(t.split("/").filter((function(t){return t.length>0})))},e}(_);b.G=new b([]);var T=/^[_a-zA-Z][_a-zA-Z0-9]*$/,I=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.k=function(t,n,r){return new e(t,n,r)},e.H=function(t){return T.test(t)},e.prototype.j=function(){return this.W().map((function(t){return t=t.replace("\\","\\\\").replace("`","\\`"),e.H(t)||(t="`"+t+"`"),t})).join(".")},e.prototype.toString=function(){return this.j()},e.prototype.Y=function(){return 1===this.length&&"__name__"===this.get(0)},e.J=function(){return new e(["__name__"])},e.X=function(t){for(var n=[],r="",i=0,o=function(){if(0===r.length)throw new p(l.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 p(l.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var a=t[i+1];if("\\"!==a&&"."!==a&&"`"!==a)throw new p(l.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 p(l.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)},e}(_);I.G=new I([]);var N=function(){function t(t){this.path=t}return t.Z=function(e){return new t(b.K(e).M(5))},t.prototype.tt=function(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t},t.prototype.isEqual=function(t){return null!==t&&0===b.N(this.path,t.path)},t.prototype.toString=function(){return this.path.toString()},t.N=function(t,e){return b.N(t.path,e.path)},t.et=function(t){return t.length%2==0},t.st=function(e){return new t(new b(e.slice()))},t}();function A(t){var e=0;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function x(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function D(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}
1N.EMPTY=new N(new b([]));var S=function(){function t(t){this.it=t}return t.fromBase64String=function(e){return new t(le.nt().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 le.nt().btoa(this.it)},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.it)},t.prototype.rt=function(){return 2*this.it.length},t.prototype.S=function(t){return be(this.it,t.it)},t.prototype.isEqual=function(t){return this.it===t.it},t}();function R(t){return null==t}function k(t){return-0===t&&1/t==-1/0}function P(t){return"number"==typeof t&&Number.isInteger(t)&&!k(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}function V(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 L(t){var e=B(t.mapValue.fields.__local_write_time__.timestampValue);return new w(e.seconds,e.nanos)}S.ht=new S("");var O=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function U(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?V(t)?4:10:me()}function C(t,e){var n=U(t);if(n!==U(e))return!1;switch(n){case 0:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return L(t).isEqual(L(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=B(t.timestampValue),r=B(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 G(t.bytesValue).isEqual(G(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return z(t.geoPointValue.latitude)===z(e.geoPointValue.latitude)&&z(t.geoPointValue.longitude)===z(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return z(t.integerValue)===z(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){var n=z(t.doubleValue),r=z(e.doubleValue);return n===r?k(n)===k(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return Te(t.arrayValue.values||[],e.arrayValue.values||[],C);case 10:return function(t,e){var n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(A(n)!==A(r))return!1;for(var i in n)if(n.hasOwnProperty(i)&&(void 0===r[i]||!C(n[i],r[i])))return!1;return!0}(t,e);default:return me()}}function q(t,e){return void 0!==(t.values||[]).find((function(t){return C(t,e)}))}function j(t,e){var n=U(t),r=U(e);if(n!==r)return be(n,r);switch(n){case 0:return 0;case 1:return be(t.booleanValue,e.booleanValue);case 2:return function(t,e){var n=z(t.integerValue||t.doubleValue),r=z(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 M(t.timestampValue,e.timestampValue);case 4:return M(L(t),L(e));case 5:return be(t.stringValue,e.stringValue);case 6:return function(t,e){var n=G(t),r=G(e);return n.S(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=be(n[i],r[i]);if(0!==o)return o}return be(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){var n=be(z(t.latitude),z(e.latitude));return 0!==n?n:be(z(t.longitude),z(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=j(n[i],r[i]);if(o)return o}return be(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=be(r[s],o[s]);if(0!==u)return u;var a=j(n[r[s]],i[o[s]]);if(0!==a)return a}return be(r.length,o.length)}(t.mapValue,e.mapValue);default:throw me()}}function M(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return be(t,e);var n=B(t),r=B(e),i=be(n.seconds,r.seconds);return 0!==i?i:be(n.nanos,r.nanos)}function F(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=B(t);return"time("+e.seconds+","+e.nanos+")"}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?G(e.bytesValue).toBase64():"referenceValue"in e?(r=e.referenceValue,N.Z(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):me();var n,r}(t)}function B(t){if(we(!!t),"string"==typeof t){var e=0,n=O.exec(t);if(we(!!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:z(t.seconds),nanos:z(t.nanos)}}function z(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function G(t){return"string"==typeof t?S.fromBase64String(t):S.fromUint8Array(t)}function W(t,e){return{referenceValue:"projects/"+t.projectId+"/databases/"+t.database+"/documents/"+e.path.j()}}function Q(t){return!!t&&"integerValue"in t}function K(t){return!!t&&"arrayValue"in t}function Y(t){return!!t&&"nullValue"in t}function J(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function X(t){return!!t&&"mapValue"in t}var H=function(){function t(){}return t.prototype.ot=function(t,e){return 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}}(e,t)},t.prototype.at=function(t,e){return e},t.prototype.ut=function(t){return null},t.prototype.isEqual=function(e){return e instanceof t},t}();H.instance=new H;var $=function(){function t(t){this.elements=t}return t.prototype.ot=function(t,e){return this.apply(t)},t.prototype.at=function(t,e){return this.apply(t)},t.prototype.apply=function(t){for(var e=et(t),n=function(t){e.some((function(e){return C(e,t)}))||e.push(t)},r=0,i=this.elements;r<i.length;r++)n(i[r]);return{arrayValue:{values:e}}},t.prototype.ut=function(t){return null},t.prototype.isEqual=function(e){return e instanceof t&&Te(this.elements,e.elements,C)},t}(),Z=function(){function t(t){this.elements=t}return t.prototype.ot=function(t,e){return this.apply(t)},t.prototype.at=function(t,e){return this.apply(t)},t.prototype.apply=function(t){for(var e=et(t),n=function(t){e=e.filter((function(e){return!C(e,t)}))},r=0,i=this.elements;r<i.length;r++)n(i[r]);return{arrayValue:{values:e}}},t.prototype.ut=function(t){return null},t.prototype.isEqual=function(e){return e instanceof t&&Te(this.elements,e.elements,C)},t}
1(),tt=function(){function t(t,e){this.serializer=t,this.ct=e}return t.prototype.ot=function(t,e){var n=this.ut(t),r=this.asNumber(n)+this.asNumber(this.ct);return Q(n)&&Q(this.ct)?this.serializer._t(r):this.serializer.lt(r)},t.prototype.at=function(t,e){return e},t.prototype.ut=function(t){return Q(e=t)||function(t){return!!t&&"doubleValue"in t}(e)?t:{integerValue:0};var e},t.prototype.isEqual=function(e){return e instanceof t&&C(this.ct,e.ct)},t.prototype.asNumber=function(t){return z(t.integerValue||t.doubleValue)},t}();function et(t){return K(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}var nt=function(){function t(t){this.fields=t,t.sort(I.N)}return t.prototype.dt=function(t){for(var e=0,n=this.fields;e<n.length;e++)if(n[e].q(t))return!0;return!1},t.prototype.isEqual=function(t){return Te(this.fields,t.fields,(function(t,e){return t.isEqual(e)}))},t}(),rt=function(){function t(t,e){this.field=t,this.transform=e}return t.prototype.isEqual=function(t){return this.field.isEqual(t.field)&&this.transform.isEqual(t.transform)},t}(),it=function(t,e){this.version=t,this.transformResults=e},ot=function(){function t(t,e){this.updateTime=t,this.exists=e}return t.ft=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,"Tt",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!0,configurable:!0}),t.prototype.Et=function(t){return void 0!==this.updateTime?t instanceof mt&&t.version.isEqual(this.updateTime):void 0===this.exists||this.exists===t instanceof mt},t.prototype.isEqual=function(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)},t}(),st=function(){function t(){}return t.prototype.It=function(t){},t.wt=function(t){return t instanceof mt?t.version:E.min()},t}(),ut=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).key=e,i.value=n,i.Rt=r,i.type=0,i}return i.__extends(e,t),e.prototype.at=function(t,e){this.It(t);var n=e.version;return new mt(this.key,n,this.value,{hasCommittedMutations:!0})},e.prototype.ot=function(t,e,n){if(this.It(t),!this.Rt.Et(t))return t;var r=st.wt(t);return new mt(this.key,r,this.value,{At:!0})},e.prototype.Pt=function(t){return null},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.value.isEqual(t.value)&&this.Rt.isEqual(t.Rt)},e}(st),at=function(t){function e(e,n,r,i){var o=this;return(o=t.call(this)||this).key=e,o.data=n,o.Vt=r,o.Rt=i,o.type=1,o}return i.__extends(e,t),e.prototype.at=function(t,e){if(this.It(t),!this.Rt.Et(t))return new Et(this.key,e.version);var n=this.gt(t);return new mt(this.key,e.version,n,{hasCommittedMutations:!0})},e.prototype.ot=function(t,e,n){if(this.It(t),!this.Rt.Et(t))return t;var r=st.wt(t),i=this.gt(t);return new mt(this.key,r,i,{At:!0})},e.prototype.Pt=function(t){return null},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.Vt.isEqual(t.Vt)&&this.Rt.isEqual(t.Rt)},e.prototype.gt=function(t){var e;return e=t instanceof mt?t.data():lt.empty(),this.pt(e)},e.prototype.pt=function(t){var e=this,n=new pt(t);return this.Vt.fields.forEach((function(t){if(!t.B()){var r=e.data.field(t);null!==r?n.set(t,r):n.delete(t)}})),n.yt()},e}(st),ct=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).key=e,r.fieldTransforms=n,r.type=2,r.Rt=ot.exists(!0),r}return i.__extends(e,t),e.prototype.at=function(t,e){if(this.It(t),we(null!=e.transformResults),!this.Rt.Et(t))return new Et(this.key,e.version);var n=this.bt(t),r=this.vt(t,e.transformResults),i=e.version,o=this.St(n.data(),r);return new mt(this.key,i,o,{hasCommittedMutations:!0})},e.prototype.ot=function(t,e,n){if(this.It(t),!this.Rt.Et(t))return t;var r=this.bt(t),i=this.Dt(n,t,e),o=this.St(r.data(),i);return new mt(this.key,r.version,o,{At:!0})},e.prototype.Pt=function(t){for(var e=null,n=0,r=this.fieldTransforms;n<r.length;n++){var i=r[n],o=t instanceof mt?t.field(i.field):void 0,s=i.transform.ut(o||null);null!=s&&(e=null==e?(new pt).set(i.field,s):e.set(i.field,s))}return e?e.yt():null},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&Te(this.fieldTransforms,t.fieldTransforms,(function(t,e){return t.isEqual(e)}))&&this.Rt.isEqual(t.Rt)},e.prototype.bt=function(t){return t},e.prototype.vt=function(t,e){var n=[];we(this.fieldTransforms.length===e.length);for(var r=0;r<e.length;r++){var i=this.fieldTransforms[r],o=i.transform,s=null;t instanceof mt&&(s=t.field(i.field)),n.push(o.at(s,e[r]))}return n},e.prototype.Dt=function(t,e,n){for(var r=[],i=0,o=this.fieldTransforms;i<o.length;i++){var s=o[i],u=s.transform,a=null;e instanceof mt&&(a=e.field(s.field)),null===a&&n instanceof mt&&(a=n.field(s.field)),r.push(u.ot(
1a,t))}return r},e.prototype.St=function(t,e){for(var n=new pt(t),r=0;r<this.fieldTransforms.length;r++){var i=this.fieldTransforms[r].field;n.set(i,e[r])}return n.yt()},e}(st),ht=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).key=e,r.Rt=n,r.type=3,r}return i.__extends(e,t),e.prototype.at=function(t,e){return this.It(t),new wt(this.key,e.version,{hasCommittedMutations:!0})},e.prototype.ot=function(t,e,n){return this.It(t),this.Rt.Et(t)?new wt(this.key,E.min()):t},e.prototype.Pt=function(t){return null},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.Rt.isEqual(t.Rt)},e}(st),ft=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).key=e,r.Rt=n,r.type=4,r}return i.__extends(e,t),e.prototype.at=function(t,e){me()},e.prototype.ot=function(t,e,n){me()},e.prototype.Pt=function(t){me()},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.Rt.isEqual(t.Rt)},e}(st),lt=function(){function t(t){this.proto=t}return t.empty=function(){return new t({mapValue:{}})},t.prototype.field=function(t){if(t.B())return this.proto;for(var e=this.proto,n=0;n<t.length-1;++n){if(!e.mapValue.fields)return null;if(!X(e=e.mapValue.fields[t.get(n)]))return null}return(e=(e.mapValue.fields||{})[t.L()])||null},t.prototype.isEqual=function(t){return C(this.proto,t.proto)},t}(),pt=function(){function t(t){void 0===t&&(t=lt.empty()),this.Ct=t,this.Ft=new Map}return t.prototype.set=function(t,e){return this.Nt(t,e),this},t.prototype.delete=function(t){return this.Nt(t,null),this},t.prototype.Nt=function(t,e){for(var n=this.Ft,r=0;r<t.length-1;++r){var i=t.get(r),o=n.get(i);o instanceof Map?n=o:o&&10===U(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.L(),e)},t.prototype.yt=function(){var t=this.kt(I.G,this.Ft);return null!=t?new lt(t):this.Ct},t.prototype.kt=function(t,e){var n=this,r=!1,i=this.Ct.field(t),o=X(i)?Object.assign({},i.mapValue.fields):{};return e.forEach((function(e,i){if(e instanceof Map){var s=n.kt(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 dt(t){var e=[];return x(t.fields||{},(function(t,n){var r=new I([t]);if(X(n)){var i=dt(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 nt(e)}var yt,vt,gt=function(t,e){this.key=t,this.version=e},mt=function(t){function e(e,n,r,i){var o=this;return(o=t.call(this,e,n)||this).Mt=r,o.At=!!i.At,o.hasCommittedMutations=!!i.hasCommittedMutations,o}return i.__extends(e,t),e.prototype.field=function(t){return this.Mt.field(t)},e.prototype.data=function(){return this.Mt},e.prototype.xt=function(){return this.Mt.proto},e.prototype.isEqual=function(t){return t instanceof e&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.At===t.At&&this.hasCommittedMutations===t.hasCommittedMutations&&this.Mt.isEqual(t.Mt)},e.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+this.Mt.toString()+", {hasLocalMutations: "+this.At+"}), {hasCommittedMutations: "+this.hasCommittedMutations+"})"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return this.At||this.hasCommittedMutations},enumerable:!0,configurable:!0}),e}(gt),wt=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n)||this).hasCommittedMutations=!(!r||!r.hasCommittedMutations),i}return i.__extends(e,t),e.prototype.toString=function(){return"NoDocument("+this.key+", "+this.version+")"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return this.hasCommittedMutations},enumerable:!0,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}(gt),Et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.toString=function(){return"UnknownDocument("+this.key+", "+this.version+")"},Object.defineProperty(e.prototype,"hasPendingWrites",{get:function(){return!0},enumerable:!0,configurable:!0}),e.prototype.isEqual=function(t){return t instanceof e&&t.version.isEqual(this.version)&&t.key.isEqual(this.key)},e}(gt),_t=function(){function t(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.$t=null}return t.prototype.canonicalId=function(){if(null===this.$t){var t=this.path.j();null!==this.collectionGroup&&(t+="|cg:"+this.collectionGroup),t+="|f:",t+=this.filters.map((function(t){return t.canonicalId()})).join(","),t+="|ob:",t+=this.orderBy.map((function(t){return t.canonicalId()})).join(","),R(this.limit)||(t+="|l:",t+=this.limit),this.startAt&&(t+="|lb:",t+=this.startAt.canonicalId()),this.endAt&&(t+="|ub:",t+=this.endAt.canonicalId()),this.$t=t}return this.$t},t.prototype.toString=function(){var t=this.path.j();return null!==this.collectionGroup&&(t+=" collectionGroup="+this.collectionGroup),this.filters.length>0&&(t+=", filters: ["+this.filters.join(", ")+"]"),R(this.limit)||(t+=", limit: "+this.limit),this.orderBy.length>0&&(t+=", orderBy: ["+this.orderBy.join(", ")+"]"),this.startAt&&(t+=", startAt: "+this.startAt.canonicalId()),this.endAt&&(t+=", endAt: "+this.endAt.canonicalId()),"Target("+t+")"},t.prototype.isEqual=function(t){if(this.limit!==t.limit)return!1;if(this.orderBy.length!==t.orderBy.length)return!1;for(var e=0;e<this.orderBy.length;e++)if(!this.orderBy[e].isEqual(t.orderBy[e]))return!1;if(this.filters.length!==t.filters.length)return!1;for(var n=0;n<this.filters.length;n++)if(!this.filters[n].isEqual(t.filters[n]))return!1;return this.collectionGroup===t.collectionGroup&&!!this.path.isEqual(t.path)&&!!(null!==this.startAt?this.startAt.isEqual(t.startAt):null===t.startAt)&&(null!==this.endAt?this.endAt.isEqual(t.endAt):null===t.endAt)},t.prototype.Ot=function(){return N.et(this.path)&&null===this.collectionGroup&&0===this.filters.length},t}(),bt=function(){function t(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.Lt=n,this.filters=r,this.limit=i,this.Bt=o,this.startAt=s,this.endAt=u,this.qt=null,this.Ut=null,this.startAt&&this.Qt(this.startAt),this.endAt&&this.Qt(this.endAt)}return t.Wt=function(e){return new t(e)},Object.defineProperty(t.prototype,"orderBy",{get:function(){if(null===this.qt){this.qt=[];var t=this.jt(),e=this.Kt();if(null!==t&&null===e)t.Y()||this.qt.push(new Rt(t)),this.qt.push(new Rt(I.J(
1),"asc"));else{for(var n=!1,r=0,i=this.Lt;r<i.length;r++){var o=i[r];this.qt.push(o),o.field.Y()&&(n=!0)}if(!n){var s=this.Lt.length>0?this.Lt[this.Lt.length-1].dir:"asc";this.qt.push(new Rt(I.J(),s))}}}return this.qt},enumerable:!0,configurable:!0}),t.prototype.Gt=function(e){var n=this.filters.concat([e]);return new t(this.path,this.collectionGroup,this.Lt.slice(),n,this.limit,this.Bt,this.startAt,this.endAt)},t.prototype.zt=function(e){var n=this.Lt.concat([e]);return new t(this.path,this.collectionGroup,n,this.filters.slice(),this.limit,this.Bt,this.startAt,this.endAt)},t.prototype.Ht=function(e){return new t(this.path,this.collectionGroup,this.Lt.slice(),this.filters.slice(),e,"F",this.startAt,this.endAt)},t.prototype.Yt=function(e){return new t(this.path,this.collectionGroup,this.Lt.slice(),this.filters.slice(),e,"L",this.startAt,this.endAt)},t.prototype.Jt=function(e){return new t(this.path,this.collectionGroup,this.Lt.slice(),this.filters.slice(),this.limit,this.Bt,e,this.endAt)},t.prototype.Xt=function(e){return new t(this.path,this.collectionGroup,this.Lt.slice(),this.filters.slice(),this.limit,this.Bt,this.startAt,e)},t.prototype.Zt=function(e){return new t(e,null,this.Lt.slice(),this.filters.slice(),this.limit,this.Bt,this.startAt,this.endAt)},t.prototype.te=function(){return 0===this.filters.length&&null===this.limit&&null==this.startAt&&null==this.endAt&&(0===this.Lt.length||1===this.Lt.length&&this.Lt[0].field.Y())},t.prototype.canonicalId=function(){return this.ee().canonicalId()+"|lt:"+this.Bt},t.prototype.toString=function(){return"Query(target="+this.ee().toString()+"; limitType="+this.Bt+")"},t.prototype.isEqual=function(t){return this.ee().isEqual(t.ee())&&this.Bt===t.Bt},t.prototype.se=function(t,e){for(var n=!1,r=0,i=this.orderBy;r<i.length;r++){var o=i[r],s=o.compare(t,e);if(0!==s)return s;n=n||o.field.Y()}return 0},t.prototype.matches=function(t){return this.ie(t)&&this.ne(t)&&this.re(t)&&this.he(t)},t.prototype.oe=function(){return!R(this.limit)&&"F"===this.Bt},t.prototype.ae=function(){return!R(this.limit)&&"L"===this.Bt},t.prototype.Kt=function(){return this.Lt.length>0?this.Lt[0].field:null},t.prototype.jt=function(){for(var t=0,e=this.filters;t<e.length;t++){var n=e[t];if(n instanceof Tt&&n.ue())return n.field}return null},t.prototype.ce=function(t){for(var e=0,n=this.filters;e<n.length;e++){var r=n[e];if(r instanceof Tt&&t.indexOf(r.op)>=0)return r.op}return null},t.prototype.Ot=function(){return this.ee().Ot()},t.prototype._e=function(){return null!==this.collectionGroup},t.prototype.ee=function(){if(!this.Ut)if("F"===this.Bt)this.Ut=new _t(this.path,this.collectionGroup,this.orderBy,this.filters,this.limit,this.startAt,this.endAt);else{for(var t=[],e=0,n=this.orderBy;e<n.length;e++){var r=n[e],i="desc"===r.dir?"asc":"desc";t.push(new Rt(r.field,i))}var o=this.endAt?new St(this.endAt.position,!this.endAt.before):null,s=this.startAt?new St(this.startAt.position,!this.startAt.before):null;this.Ut=new _t(this.path,this.collectionGroup,t,this.filters,this.limit,o,s)}return this.Ut},t.prototype.ie=function(t){var e=t.key.path;return null!==this.collectionGroup?t.key.tt(this.collectionGroup)&&this.path.q(e):N.et(this.path)?this.path.isEqual(e):this.path.U(e)},t.prototype.ne=function(t){for(var e=0,n=this.Lt;e<n.length;e++){var r=n[e];if(!r.field.Y()&&null===t.field(r.field))return!1}return!0},t.prototype.re=function(t){for(var e=0,n=this.filters;e<n.length;e++)if(!n[e].matches(t))return!1;return!0},t.prototype.he=function(t){return!(this.startAt&&!this.startAt.le(this.orderBy,t)||this.endAt&&this.endAt.le(this.orderBy,t))},t.prototype.Qt=function(t){},t}(),Tt=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 i.__extends(e,t),e.create=function(t,n,r){if(t.Y())return"in"===n?new Nt(t,r):new It(t,n,r);if(Y(r)){if("=="!==n)throw new p(l.INVALID_ARGUMENT,"Invalid query. Null supports only equality comparisons.");return new e(t,n,r)}if(J(r)){if("=="!==n)throw new p(l.INVALID_ARGUMENT,"Invalid query. NaN supports only equality comparisons.");return new e(t,n,r)}return"array-contains"===n?new At(t,r):"in"===n?new xt(t,r):"array-contains-any"===n?new Dt(t,r):new e(t,n,r)},e.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&U(this.value)===U(e)&&this.de(j(e,this.value))},e.prototype.de=function(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case">":return t>0;case">=":return t>=0;default:return me()}},e.prototype.ue=function(){return["<","<=",">",">="].indexOf(this.op)>=0},e.prototype.canonicalId=function(){return this.field.j()+this.op.toString()+F(this.value)},e.prototype.isEqual=function(t){return t instanceof e&&this.op===t.op&&this.field.isEqual(t.field)&&C(this.value,t.value)},e.prototype.toString=function(){return this.field.j()+" "+this.op+" "+F(this.value)},e}((function(){})),It=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n,r)||this).key=N.Z(r.referenceValue),i}return i.__extends(e,t),e.prototype.matches=function(t){var e=N.N(t.key,this.key);return this.de(e)},e}(Tt),Nt=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"in",n)||this).keys=(n.arrayValue.values||[]).map((function(t){return N.Z(t.referenceValue)})),r}return i.__extends(e,t),e.prototype.matches=function(t){return this.keys.some((function(e){return e.isEqual(t.key)}))},e}(Tt),At=function(t){function e(e,n){return t.call(this,e,"array-contains",n)||this}return i.__extends(e,t),e.prototype.matches=function(t){var e=t.field(this.field);return K(e)&&q(e.arrayValue,this.value)},e}(Tt),xt=function(t){function e(e,n){return t.call(this,e,"in",n)||this}return i.__extends(e,t),e.prototype.matches=function(t){var e=t.field(this.field);return null!==e&&q(this.value.arrayValue,e)},e}(Tt),Dt=function(t){function e(e,n){return t.call(this,e,"array-contains-any",n)||this}return i.__extends(e,t),e.prototype.matches=function(t){var e=this,n=t.field(this.field);return!(!K(n)||!n.arrayValue.values)&&n.arrayValue.values.some((function(t){return q(e.value.arrayValue,t)}))},e}(Tt),St=function(){function t(t,e){this.position=t,this.before=e}return t.prototype.canonicalId=function(){return(this.before?"b":"a")+":"+this.position.map((function(t){return F(t)})).join(",")},t.prototype.le=function(t,e){for(var n=0,r=0;r<this.position.length;r++){var i=t[r],o=this.position[r];if(n=i.field.Y()?N.N(N.Z(o.referenceValue),e.key):j(o,e.field(i.field)),"desc"===i.dir&&(n*=-1),0!==n)break}return this.before?n<=0:n<0},t.prototype.isEqual=function(t){if(null===t)return!1;if(this.before!==t.before||this.position.length!==t.position.length)return!1;for(var e=0;e<this.position.length;e++)if(!C(this.position[e],t.position[e]))return!1;return!0},t}(),Rt=function(){function t(t,e){this.field=t,void 0===e&&(e="asc"),this.dir=e,this.fe=t.Y()}return t.prototype.compare=function(t,e){var n=this.fe?N.N(t.key,e.key):function(t,e,n){var r=e.field(t),i=n.field(t);return null!==r&&null!==i?j(r,i):me()}(this.field,t,e);switch(this.dir){case"asc":return n;
1case"desc":return-1*n;default:return me()}},t.prototype.canonicalId=function(){return this.field.j()+this.dir.toString()},t.prototype.toString=function(){return this.field.j()+" ("+this.dir+")"},t.prototype.isEqual=function(t){return this.dir===t.dir&&this.field.isEqual(t.field)},t}(),kt=function(){function t(t,e,n,r,i,o,s){void 0===i&&(i=E.min()),void 0===o&&(o=E.min()),void 0===s&&(s=S.ht),this.target=t,this.targetId=e,this.Te=n,this.sequenceNumber=r,this.Ee=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=s}return t.prototype.Ie=function(e){return new t(this.target,this.targetId,this.Te,e,this.Ee,this.lastLimboFreeSnapshotVersion,this.resumeToken)},t.prototype.we=function(e,n){return new t(this.target,this.targetId,this.Te,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e)},t.prototype.Re=function(e){return new t(this.target,this.targetId,this.Te,this.sequenceNumber,this.Ee,e,this.resumeToken)},t}(),Pt=function(t){this.count=t};function Vt(t){switch(t){case l.OK:return me();case l.CANCELLED:case l.UNKNOWN:case l.DEADLINE_EXCEEDED:case l.RESOURCE_EXHAUSTED:case l.INTERNAL:case l.UNAVAILABLE:case l.UNAUTHENTICATED:return!1;case l.INVALID_ARGUMENT:case l.NOT_FOUND:case l.ALREADY_EXISTS:case l.PERMISSION_DENIED:case l.FAILED_PRECONDITION:case l.ABORTED:case l.OUT_OF_RANGE:case l.UNIMPLEMENTED:case l.DATA_LOSS:return!0;default:return me()}}function Lt(t){if(void 0===t)return ve("GRPC error has no .code"),l.UNKNOWN;switch(t){case yt.OK:return l.OK;case yt.CANCELLED:return l.CANCELLED;case yt.UNKNOWN:return l.UNKNOWN;case yt.DEADLINE_EXCEEDED:return l.DEADLINE_EXCEEDED;case yt.RESOURCE_EXHAUSTED:return l.RESOURCE_EXHAUSTED;case yt.INTERNAL:return l.INTERNAL;case yt.UNAVAILABLE:return l.UNAVAILABLE;case yt.UNAUTHENTICATED:return l.UNAUTHENTICATED;case yt.INVALID_ARGUMENT:return l.INVALID_ARGUMENT;case yt.NOT_FOUND:return l.NOT_FOUND;case yt.ALREADY_EXISTS:return l.ALREADY_EXISTS;case yt.PERMISSION_DENIED:return l.PERMISSION_DENIED;case yt.FAILED_PRECONDITION:return l.FAILED_PRECONDITION;case yt.ABORTED:return l.ABORTED;case yt.OUT_OF_RANGE:return l.OUT_OF_RANGE;case yt.UNIMPLEMENTED:return l.UNIMPLEMENTED;case yt.DATA_LOSS:return l.DATA_LOSS;default:return me()}}(vt=yt||(yt={}))[vt.OK=0]="OK",vt[vt.CANCELLED=1]="CANCELLED",vt[vt.UNKNOWN=2]="UNKNOWN",vt[vt.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",vt[vt.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",vt[vt.NOT_FOUND=5]="NOT_FOUND",vt[vt.ALREADY_EXISTS=6]="ALREADY_EXISTS",vt[vt.PERMISSION_DENIED=7]="PERMISSION_DENIED",vt[vt.UNAUTHENTICATED=16]="UNAUTHENTICATED",vt[vt.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",vt[vt.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",vt[vt.ABORTED=10]="ABORTED",vt[vt.OUT_OF_RANGE=11]="OUT_OF_RANGE",vt[vt.UNIMPLEMENTED=12]="UNIMPLEMENTED",vt[vt.INTERNAL=13]="INTERNAL",vt[vt.UNAVAILABLE=14]="UNAVAILABLE",vt[vt.DATA_LOSS=15]="DATA_LOSS";var Ot=function(){function t(t,e){this.N=t,this.root=e||Ct.EMPTY}return t.prototype.Ae=function(e,n){return new t(this.N,this.root.Ae(e,n,this.N).me(null,null,Ct.Pe,null,null))},t.prototype.remove=function(e){return new t(this.N,this.root.remove(e,this.N).me(null,null,Ct.Pe,null,null))},t.prototype.get=function(t){for(var e=this.root;!e.B();){var n=this.N(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.B();){var r=this.N(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.B=function(){return this.root.B()},Object.defineProperty(t.prototype,"size",{get:function(){return this.root.size},enumerable:!0,configurable:!0}),t.prototype.Ve=function(){return this.root.Ve()},t.prototype.ge=function(){return this.root.ge()},t.prototype.pe=function(t){return this.root.pe(t)},t.prototype.forEach=function(t){this.pe((function(e,n){return t(e,n),!1}))},t.prototype.toString=function(){var t=[];return this.pe((function(e,n){return t.push(e+":"+n),!1})),"{"+t.join(", ")+"}"},t.prototype.ye=function(t){return this.root.ye(t)},t.prototype.be=function(){return new Ut(this.root,null,this.N,!1)},t.prototype.ve=function(t){return new Ut(this.root,t,this.N,!1)},t.prototype.Se=function(){return new Ut(this.root,null,this.N,!0)},t.prototype.De=function(t){return new Ut(this.root,t,this.N,!0)},t}(),Ut=function(){function t(t,e,n,r){this.Ce=r,this.Fe=[];for(var i=1;!t.B();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.Ce?t.left:t.right;else{if(0===i){this.Fe.push(t);break}this.Fe.push(t),t=this.Ce?t.right:t.left}}return t.prototype.Ne=function(){var t=this.Fe.pop(),e={key:t.key,value:t.value};if(this.Ce)for(t=t.left;!t.B();)this.Fe.push(t),t=t.right;else for(t=t.right;!t.B();)this.Fe.push(t),t=t.left;return e},t.prototype.ke=function(){return this.Fe.length>0},t.prototype.Me=function(){if(0===this.Fe.length)return null;var t=this.Fe[this.Fe.length-1];return{key:t.key,value:t.value}},t}(),Ct=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.me=function(e,n,r,i,o){return new t(null!=e?e:this.key,null!=n?n:this.value,
1null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},t.prototype.B=function(){return!1},t.prototype.pe=function(t){return this.left.pe(t)||t(this.key,this.value)||this.right.pe(t)},t.prototype.ye=function(t){return this.right.ye(t)||t(this.key,this.value)||this.left.ye(t)},t.prototype.min=function(){return this.left.B()?this:this.left.min()},t.prototype.Ve=function(){return this.min().key},t.prototype.ge=function(){return this.right.B()?this.key:this.right.ge()},t.prototype.Ae=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.me(null,null,null,r.left.Ae(t,e,n),null):0===i?r.me(null,e,null,null,null):r.me(null,null,null,null,r.right.Ae(t,e,n))).xe()},t.prototype.$e=function(){if(this.left.B())return t.EMPTY;var e=this;return e.left.Oe()||e.left.left.Oe()||(e=e.Le()),(e=e.me(null,null,null,e.left.$e(),null)).xe()},t.prototype.remove=function(e,n){var r,i=this;if(n(e,i.key)<0)i.left.B()||i.left.Oe()||i.left.left.Oe()||(i=i.Le()),i=i.me(null,null,null,i.left.remove(e,n),null);else{if(i.left.Oe()&&(i=i.Be()),i.right.B()||i.right.Oe()||i.right.left.Oe()||(i=i.qe()),0===n(e,i.key)){if(i.right.B())return t.EMPTY;r=i.right.min(),i=i.me(r.key,r.value,null,null,i.right.$e())}i=i.me(null,null,null,null,i.right.remove(e,n))}return i.xe()},t.prototype.Oe=function(){return this.color},t.prototype.xe=function(){var t=this;return t.right.Oe()&&!t.left.Oe()&&(t=t.Ue()),t.left.Oe()&&t.left.left.Oe()&&(t=t.Be()),t.left.Oe()&&t.right.Oe()&&(t=t.Qe()),t},t.prototype.Le=function(){var t=this.Qe();return t.right.left.Oe()&&(t=(t=(t=t.me(null,null,null,null,t.right.Be())).Ue()).Qe()),t},t.prototype.qe=function(){var t=this.Qe();return t.left.left.Oe()&&(t=(t=t.Be()).Qe()),t},t.prototype.Ue=function(){var e=this.me(null,null,t.RED,null,this.right.left);return this.right.me(null,null,this.color,e,null)},t.prototype.Be=function(){var e=this.me(null,null,t.RED,this.left.right,null);return this.left.me(null,null,this.color,null,e)},t.prototype.Qe=function(){var t=this.left.me(null,null,!this.left.color,null,null),e=this.right.me(null,null,!this.right.color,null,null);return this.me(null,null,!this.color,t,e)},t.prototype.We=function(){var t=this.je();return Math.pow(2,t)<=this.size+1},t.prototype.je=function(){if(this.Oe()&&this.left.Oe())throw me();if(this.right.Oe())throw me();var t=this.left.je();if(t!==this.right.je())throw me();return t+(this.Oe()?0:1)},t}();Ct.EMPTY=null,Ct.RED=!0,Ct.Pe=!1,Ct.EMPTY=new(function(){function t(){this.size=0}return Object.defineProperty(t.prototype,"key",{get:function(){throw me()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){throw me()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){throw me()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){throw me()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){throw me()},enumerable:!0,configurable:!0}),t.prototype.me=function(t,e,n,r,i){return this},t.prototype.Ae=function(t,e,n){return new Ct(t,e)},t.prototype.remove=function(t,e){return this},t.prototype.B=function(){return!0},t.prototype.pe=function(t){return!1},t.prototype.ye=function(t){return!1},t.prototype.Ve=function(){return null},t.prototype.ge=function(){return null},t.prototype.Oe=function(){return!1},t.prototype.We=function(){return!0},t.prototype.je=function(){return 0},t}());var qt=function(){function t(t){this.N=t,this.data=new Ot(this.N)}return t.prototype.has=function(t){return null!==this.data.get(t)},t.prototype.first=function(){return this.data.Ve()},t.prototype.last=function(){return this.data.ge()},Object.defineProperty(t.prototype,"size",{get:function(){return this.data.size},enumerable:!0,configurable:!0}),t.prototype.indexOf=function(t){return this.data.indexOf(t)},t.prototype.forEach=function(t){this.data.pe((function(e,n){return t(e),!1}))},t.prototype.Ke=function(t,e){for(var n=this.data.ve(t[0]);n.ke();){var r=n.Ne();if(this.N(r.key,t[1])>=0)return;e(r.key)}},t.prototype.Ge=function(t,e){var n;for(n=void 0!==e?this.data.ve(e):this.data.be();n.ke();
1)if(!t(n.Ne().key))return},t.prototype.ze=function(t){var e=this.data.ve(t);return e.ke()?e.Ne().key:null},t.prototype.be=function(){return new jt(this.data.be())},t.prototype.ve=function(t){return new jt(this.data.ve(t))},t.prototype.add=function(t){return this.me(this.data.remove(t).Ae(t,!0))},t.prototype.delete=function(t){return this.has(t)?this.me(this.data.remove(t)):this},t.prototype.B=function(){return this.data.B()},t.prototype.He=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.be(),r=e.data.be();n.ke();){var i=n.Ne().key,o=r.Ne().key;if(0!==this.N(i,o))return!1}return!0},t.prototype.W=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.me=function(e){var n=new t(this.N);return n.data=e,n},t}(),jt=function(){function t(t){this.Ye=t}return t.prototype.Ne=function(){return this.Ye.Ne().key},t.prototype.ke=function(){return this.Ye.ke()},t}(),Mt=new Ot(N.N);function Ft(){return Mt}function Bt(){return Ft()}var zt=new Ot(N.N);function Gt(){return zt}var Wt=new Ot(N.N),Qt=new qt(N.N);function Kt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=Qt,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var Yt=new qt(be);function Jt(){return Yt}var Xt=function(){function t(t){this.N=t?function(e,n){return t(e,n)||N.N(e.key,n.key)}:function(t,e){return N.N(t.key,e.key)},this.Je=Gt(),this.Xe=new Ot(this.N)}return t.Ze=function(e){return new t(e.N)},t.prototype.has=function(t){return null!=this.Je.get(t)},t.prototype.get=function(t){return this.Je.get(t)},t.prototype.first=function(){return this.Xe.Ve()},t.prototype.last=function(){return this.Xe.ge()},t.prototype.B=function(){return this.Xe.B()},t.prototype.indexOf=function(t){var e=this.Je.get(t);return e?this.Xe.indexOf(e):-1},Object.defineProperty(t.prototype,"size",{get:function(){return this.Xe.size},enumerable:!0,configurable:!0}),t.prototype.forEach=function(t){this.Xe.pe((function(e,n){return t(e),!1}))},t.prototype.add=function(t){var e=this.delete(t.key);return e.me(e.Je.Ae(t.key,t),e.Xe.Ae(t,null))},t.prototype.delete=function(t){var e=this.get(t);return e?this.me(this.Je.remove(t),this.Xe.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.Xe.be(),r=e.Xe.be();n.ke();){var i=n.Ne().key,o=r.Ne().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.me=function(e,n){var r=new t;return r.N=this.N,r.Je=e,r.Xe=n,r},t}(),Ht=function(){function t(){this.ts=new Ot(N.N)}return t.prototype.track=function(t){var e=t.doc.key,n=this.ts.get(e);n?0!==t.type&&3===n.type?this.ts=this.ts.Ae(e,t):3===t.type&&1!==n.type?this.ts=this.ts.Ae(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.ts=this.ts.Ae(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.ts=this.ts.Ae(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.ts=this.ts.remove(e):1===t.type&&2===n.type?this.ts=this.ts.Ae(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.ts=this.ts.Ae(e,{type:2,doc:t.doc}
1):me():this.ts=this.ts.Ae(e,t)},t.prototype.es=function(){var t=[];return this.ts.pe((function(e,n){t.push(n)})),t},t}(),$t=function(){function t(t,e,n,r,i,o,s,u){this.query=t,this.docs=e,this.ss=n,this.docChanges=r,this.ns=i,this.fromCache=o,this.rs=s,this.hs=u}return t.os=function(e,n,r,i){var o=[];return n.forEach((function(t){o.push({type:0,doc:t})})),new t(e,n,Xt.Ze(n),o,r,i,!0,!1)},Object.defineProperty(t.prototype,"hasPendingWrites",{get:function(){return!this.ns.B()},enumerable:!0,configurable:!0}),t.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.rs===t.rs&&this.ns.isEqual(t.ns)&&this.query.isEqual(t.query)&&this.docs.isEqual(t.docs)&&this.ss.isEqual(t.ss)))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}(),Zt=function(){function t(t,e,n,r,i){this.Ee=t,this.as=e,this.us=n,this.cs=r,this._s=i}return t.ls=function(e,n){var r=new Map;return r.set(e,te.ds(e,n)),new t(E.min(),r,Jt(),Ft(),Kt())},t}(),te=function(){function t(t,e,n,r,i){this.resumeToken=t,this.fs=e,this.Ts=n,this.Es=r,this.Is=i}return t.ds=function(e,n){return new t(S.ht,n,Kt(),Kt(),Kt())},t}(),ee=function(t,e,n,r){this.ws=t,this.removedTargetIds=e,this.key=n,this.Rs=r},ne=function(t,e){this.targetId=t,this.As=e},re=function(t,e,n,r){void 0===n&&(n=S.ht),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},ie=function(){function t(){this.ms=0,this.Ps=ue(),this.Vs=S.ht,this.gs=!1,this.ps=!0}return Object.defineProperty(t.prototype,"fs",{get:function(){return this.gs},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"resumeToken",{get:function(){return this.Vs},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ys",{get:function(){return 0!==this.ms},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bs",{get:function(){return this.ps},enumerable:!0,configurable:!0}),t.prototype.vs=function(t){t.rt()>0&&(this.ps=!0,this.Vs=t)},t.prototype.Ss=function(){var t=Kt(),e=Kt(),n=Kt();return this.Ps.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:me()}})),new te(this.Vs,this.gs,t,e,n)},t.prototype.Ds=function(){this.ps=!1,this.Ps=ue()},t.prototype.Cs=function(t,e){this.ps=!0,this.Ps=this.Ps.Ae(t,e)},t.prototype.Fs=function(t){this.ps=!0,this.Ps=this.Ps.remove(t)},t.prototype.Ns=function(){this.ms+=1},t.prototype.ks=function(){this.ms-=1},t.prototype.Ms=function(){this.ps=!0,this.gs=!0},t}(),oe=function(){function t(t){this.xs=t,this.$s=new Map,this.Os=Ft(),this.Ls=se(),this.Bs=new qt(be)}return t.prototype.qs=function(t){for(var e=0,n=t.ws;e<n.length;e++){var r=n[e];t.Rs instanceof mt?this.Us(r,t.Rs):t.Rs instanceof wt&&this.Qs(r,t.key,t.Rs)}for(var i=0,o=t.removedTargetIds;i<o.length;i++){var s=o[i];this.Qs(s,t.key,t.Rs)}},t.prototype.Ws=function(t){var e=this;this.js(t,(function(n){var r=e.Ks(n);switch(t.state){case 0:e.Gs(n)&&r.vs(t.resumeToken);break;case 1:r.ks(),r.ys||r.Ds(),r.vs(t.resumeToken);break;case 2:r.ks(),r.ys||e.removeTarget(n);break;case 3:e.Gs(n)&&(r.Ms(),r.vs(t.resumeToken));break;case 4:e.Gs(n)&&(e.zs(n),r.vs(t.resumeToken));break;default:me()}}))},t.prototype.js=function(t,e){var n=this;t.targetIds.length>0?t.targetIds.forEach(e):this.$s.forEach((function(t,r){n.Gs(r)&&e(r)}))},t.prototype.Hs=function(t){var e=t.targetId,n=t.As.count,r=this.Ys(e);if(r){var i=r.target;if(i.Ot())if(0===n){var o=new N(i.path);this.Qs(e,o,new wt(o,E.min()))}else we(1===n);else this.Js(e)!==n&&(this.zs(e),this.Bs=this.Bs.add(e))}},t.prototype.Xs=function(t){var e=this,n=new Map;this.$s.forEach((function(r,i){var o=e.Ys(i);if(o){if(r.fs&&o.target.Ot()){var s=new N(o.target.path);null!==e.Os.get(s)||e.Zs(i,s)||e.Qs(i,s,new wt(s,t))}r.bs&&(n.set(i,r.Ss()),r.Ds())}}));var r=Kt();this.Ls.forEach((function(t,n){var i=!0;n.Ge((function(t){var n=e.Ys(t);return!n||2===n.Te||(i=!1,!1)})),i&&(r=r.add(t))}));var i=new Zt(t,n,this.Bs,this.Os,r);return this.Os=Ft(),this.Ls=se(),this.Bs=new qt(be),i},t.prototype.Us=function(t,e){if(this.Gs(t)){var n=this.Zs(t,e.key)?2:0;this.Ks(t).Cs(e.key,n),this.Os=this.Os.Ae(e.key,e),this.Ls=this.Ls.Ae(e.key,this.ti(e.key).add(t))}},t.prototype.Qs=function(t,e,n){if(this.Gs(t)){var r=this.Ks(t);this.Zs(t,e)?r.Cs(e,1):r.Fs(e),this.Ls=this.Ls.Ae(e,this.ti(e).delete(t)),n&&(this.Os=this.Os.Ae(e,n))}},t.prototype.removeTarget=function(t){this.$s.delete(t)},t.prototype.Js=function(t){var e=this.Ks(t).Ss();return this.xs.ei(t).size+e.Ts.size-e.Is.size},t.prototype.Ns=function(t){this.Ks(t).Ns()},t.prototype.Ks=function(t){var e=this.$s.get(t);return e||(e=new ie,this.$s.set(t,e)),e},t.prototype.ti=function(t){var e=this.Ls.get(t);return e||(e=new qt(be),this.Ls=this.Ls.Ae(t,e)),e},t.prototype.Gs=function(t){var e=null!==this.Ys(t);return e||ye("WatchChangeAggregator","Detected inactive target",t),e},t.prototype.Ys=function(t){var e=this.$s.get(t);return e&&e.ys?null:this.xs.si(t)},t.prototype.zs=function(t){var e=this;this.$s.set(t,new ie),this.xs.ei(t).forEach((function(n){e.Qs(t,n,null)}))},t.prototype.Zs=function(t,e){return this.xs.ei(t).has(e)},t}();function se(){return new Ot(N.N)}function ue(){return new Ot(N.N)}var ae={asc:"ASCENDING",desc:"DESCENDING"},ce={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","array-contains-any":"ARRAY_CONTAINS_ANY"},he=function(){function t(t,e){this.ii=t,this.options=e}return t.prototype.ni=function(t){var e=void 0===t.code?l.UNKNOWN:Lt(t.code);return new p(e,t.message||"")},t.prototype.ri=function(t){return this.options.hi||R(t)?t:{value:t}},t.prototype.oi=function(t){var e;return R(e="object"==typeof t?t.value:t)?null:e},t.prototype._t=function(t){return{integerValue:""+t}},t.prototype.lt=function(t){if(this.options.hi){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:k(t)?"-0":t}},t.prototype.ai=function(t){return P(t)?this._t(t):this.lt(t)},t.prototype.C=function(t){return this.options.hi?new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+t.nanoseconds).slice(-9)+"Z":{seconds:""+t.seconds,nanos:t.nanoseconds}},t.prototype.v=function(t){var e=B(t);return new w(e.seconds,e.nanos)},t.prototype.ui=function(t){return this.options.hi?t.toBase64():t.toUint8Array()},t.prototype.ci=function(t){return this.options.hi?(we(void 0===t||"string"==typeof t),S.fromBase64String(t||"")):(we(void 0===t||t instanceof Uint8Array),S.fromUint8Array(t||new Uint8Array))},t.prototype.toVersion=function(t){return this.C(t.C())},t.prototype.fromVersion=function(t){return we(!!t),E.v(this.v(t))},t.prototype._i=function(t,e){return this.li(e||this.ii).child("documents").child(t).j()},t.prototype.di=function(t){var e=b.K(t);return we(fe(e)),e},t.prototype.fi=function(t){return this._i(t.path)},t.prototype.Z=function(t){var e=this.di(t);return we(e.get(1)===this.ii.projectId),we(!e.get(3)&&!this.ii.database||e.get(3)===this.ii.database),new N(this.Ti(e))},t.prototype.Ei=function(t){return this._i(t)},t.prototype.Ii=function(t){var e=this.di(t);return 4===e.length?b.G:this.Ti(e)},Object.defineProperty(t.prototype,"wi",{get:function(){return new b(["projects",this.ii.projectId,"databases",this.ii.database]).j()},enumerable:!0,configurable:!0}),t.prototype.li=function(t){return new b(["projects",t.projectId,"databases",t.database])},t.prototype.Ti=function(t){return we(t.length>4&&"documents"===t.get(4)),t.M(5)},t.prototype.Ri=function(t,e){return{name:this.fi(t),fields:e.proto.mapValue.fields}},t.prototype.Ai=function(t){return{name:this.fi(t.key),fields:t.xt().mapValue.fields,updateTime:this.C(t.version.C())}},t.prototype.mi=function(t,e){var n=this.Z(t.name),r=this.fromVersion(t.updateTime),i=new lt({mapValue:{fields:t.fields}});return new mt(n,r,i,{hasCommittedMutations:!!e})},t.prototype.Pi=function(t){we(!!t.found),t.found.name,t.found.updateTime;var e=this.Z(t.found.name),n=this.fromVersion(t.found.updateTime),r=new lt({mapValue:{fields:t.found.fields}});return new mt(e,n,r,{})},t.prototype.Vi=function(t){we(!!t.missing),we(!!t.readTime);var e=this.Z(t.missing),n=this.fromVersion(t.readTime);return new wt(e,n)},t.prototype.gi=function(t){return"found"in t?this.Pi(t):"missing"in t?this.Vi(t):me()},t.prototype.pi=function(t){var e;if("targetChange"in t){t.targetChange;var n=this.yi(t.targetChange.targetChangeType||"NO_CHANGE"),r=t.targetChange.targetIds||[],i=this.ci(t.targetChange.resumeToken),o=t.targetChange.cause,s=o&&this.ni(o);e=new re(n,r,i,s||null)}else if("documentChange"in t){t.documentChange;var u=t.documentChange;u.document,u.document.name,u.document.updateTime;var a=this.Z(u.document.name),c=this.fromVersion(u.document.updateTime),h=new lt({mapValue:{fields:u.document.fields}}),f=new mt(a,c,h,{}),l=u.targetIds||[],p=u.removedTargetIds||[];
1e=new ee(l,p,f.key,f)}else if("documentDelete"in t){t.documentDelete;var d=t.documentDelete;d.document;var y=this.Z(d.document),v=d.readTime?this.fromVersion(d.readTime):E.min(),g=new wt(y,v),m=d.removedTargetIds||[];e=new ee([],m,g.key,g)}else if("documentRemove"in t){t.documentRemove;var w=t.documentRemove;w.document;var _=this.Z(w.document),b=w.removedTargetIds||[];e=new ee([],b,_,null)}else{if(!("filter"in t))return me();t.filter;var T=t.filter;T.targetId;var I=T.count||0,N=new Pt(I),A=T.targetId;e=new ne(A,N)}return e},t.prototype.yi=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:me()},t.prototype.bi=function(t){if(!("targetChange"in t))return E.min();var e=t.targetChange;return e.targetIds&&e.targetIds.length?E.min():e.readTime?this.fromVersion(e.readTime):E.min()},t.prototype.vi=function(t){var e,n=this;if(t instanceof ut)e={update:this.Ri(t.key,t.value)};else if(t instanceof ht)e={delete:this.fi(t.key)};else if(t instanceof at)e={update:this.Ri(t.key,t.data),updateMask:this.Si(t.Vt)};else if(t instanceof ct)e={transform:{document:this.fi(t.key),fieldTransforms:t.fieldTransforms.map((function(t){return n.Di(t)}))}};else{if(!(t instanceof ft))return me();e={verify:this.fi(t.key)}}return t.Rt.Tt||(e.currentDocument=this.Ci(t.Rt)),e},t.prototype.Fi=function(t){var e=this,n=t.currentDocument?this.Ni(t.currentDocument):ot.ft();if(t.update){t.update.name;var r=this.Z(t.update.name),i=new lt({mapValue:{fields:t.update.fields}});if(t.updateMask){var o=this.ki(t.updateMask);return new at(r,i,o,n)}return new ut(r,i,n)}if(t.delete){var s=this.Z(t.delete);return new ht(s,n)}if(t.transform){var u=this.Z(t.transform.document),a=t.transform.fieldTransforms.map((function(t){return e.Mi(t)}));return we(!0===n.exists),new ct(u,a)}if(t.verify){var c=this.Z(t.verify);return new ft(c,n)}return me()},t.prototype.Ci=function(t){return void 0!==t.updateTime?{updateTime:this.toVersion(t.updateTime)}:void 0!==t.exists?{exists:t.exists}:me()},t.prototype.Ni=function(t){return void 0!==t.updateTime?ot.updateTime(this.fromVersion(t.updateTime)):void 0!==t.exists?ot.exists(t.exists):ot.ft()},t.prototype.xi=function(t,e){var n=t.updateTime?this.fromVersion(t.updateTime):this.fromVersion(e);n.isEqual(E.min())&&(n=this.fromVersion(e));var r=null;return t.transformResults&&t.transformResults.length>0&&(r=t.transformResults),new it(n,r)},t.prototype.$i=function(t,e){var n=this;return t&&t.length>0?(we(void 0!==e),t.map((function(t){return n.xi(t,e)}))):[]},t.prototype.Di=function(t){var e=t.transform;if(e instanceof H)return{fieldPath:t.field.j(),setToServerValue:"REQUEST_TIME"};if(e instanceof $)return{fieldPath:t.field.j(),appendMissingElements:{values:e.elements}};if(e instanceof Z)return{fieldPath:t.field.j(),removeAllFromArray:{values:e.elements}};if(e instanceof tt)return{fieldPath:t.field.j(),increment:e.ct};throw me()},t.prototype.Mi=function(t){var e=null;if("setToServerValue"in t)we("REQUEST_TIME"===t.setToServerValue),e=H.instance;else if("appendMissingElements"in t){var n=t.appendMissingElements.values||[];e=new $(n)}else if("removeAllFromArray"in t){var r=t.removeAllFromArray.values||[];e=new Z(r)}else"increment"in t?e=new tt(this,t.increment):me();var i=I.X(t.fieldPath);return new rt(i,e)},t.prototype.Oi=function(t){return{documents:[this.Ei(t.path)]}},t.prototype.Li=function(t){we(1===t.documents.length);var e=t.documents[0];return bt.Wt(this.Ii(e)).ee()},t.prototype.Bi=function(t){var e={structuredQuery:{}},n=t.path;null!==t.collectionGroup?(e.parent=this.Ei(n),e.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(e.parent=this.Ei(n.$()),e.structuredQuery.from=[{collectionId:n.L()}]);var r=this.qi(t.filters);r&&(e.structuredQuery.where=r);var i=this.Ui(t.orderBy);i&&(e.structuredQuery.orderBy=i);var o=this.ri(t.limit);return null!==o&&(e.structuredQuery.limit=o),t.startAt&&(e.structuredQuery.startAt=this.Qi(t.startAt)),t.endAt&&(e.structuredQuery.endAt=this.Qi(t.endAt)),e},t.prototype.Wi=function(t){var e=this.Ii(t.parent),n=t.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){we(1===r);var o=n.from[0];o.allDescendants?i=o.collectionId:e=e.child(o.collectionId)}var s=[];n.where&&(s=this.ji(n.where));var u=[];n.orderBy&&(u=this.Ki(n.orderBy));var a=null;n.limit&&(a=this.oi(n.limit));var c=null;n.startAt&&(c=this.Gi(n.startAt));var h=null;return n.endAt&&(h=this.Gi(n.endAt)),new bt(e,i,u,s,a,"F",c,h).ee()},t.prototype.zi=function(t){var e=this.Hi(t.Te);return null==e?null:{"goog-listen-tags":e}},t.prototype.Hi=function(t){switch(t){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return me()}},t.prototype.ee=function(t){var e,n=t.target;return(e=n.Ot()?{documents:this.Oi(n)}:{query:this.Bi(n)}).targetId=t.targetId,t.resumeToken.rt()>0&&(e.resumeToken=this.ui(t.resumeToken)),e},t.prototype.qi=function(t){var e=this;if(0!==t.length){var n=t.map((function(t){return t instanceof Tt?e.Yi(t):me()}));return 1===n.length?n[0]:{compositeFilter:{op:"AND",filters:n}}}},t.prototype.ji=function(t){var e=this;return t?void 0!==t.unaryFilter?[this.Ji(t)]:void 0!==t.fieldFilter?[this.Xi(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map((function(t){return e.ji(t)})).reduce((function(t,e){return t.concat(e)})):me():[]},t.prototype.Ui=function(t){var e=this;if(0!==t.length)return t.map((function(t){return e.Zi(t)}))},t.prototype.Ki=function(t){var e=this;return t.map((function(t){return e.tn(t)}))},t.prototype.Qi=function(t){return{before:t.before,values:t.position}},t.prototype.Gi=function(t){var e=!!t.before,n=t.values||[];return new St(n,e)},t.prototype.en=function(t){return ae[t]},t.prototype.sn=function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}},t.prototype.nn=function(t){return ce[t]},t.prototype.rn=function(t){switch(t){case"EQUAL":return"==";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";case"OPERATOR_UNSPECIFIED":default:return me()}},t.prototype.hn=function(t){return{fieldPath:t.j()}},t.prototype.on=function(t){return I.X(t.fieldPath)},t.prototype.Zi=function(t){return{field:this.hn(t.field),direction:this.en(t.dir)}},t.prototype.tn=function(t){return new Rt(this.on(t.field),this.sn(t.direction))},t.prototype.Xi=function(t){return Tt.create(this.on(t.fieldFilter.field),this.rn(t.fieldFilter.op),t.fieldFilter.value)},t.prototype.Yi=function(t){if("=="===t.op){if(J(t.value))return{unaryFilter:{field:this.hn(t.field),op:"IS_NAN"}};if(Y(t.value))return{unaryFilter:{field:this.hn(t.field),op:"IS_NULL"}}}return{fieldFilter:{field:this.hn(t.field),op:this.nn(t.op),value:t.value}}},t.prototype.Ji=function(t){switch(t.unaryFilter.op){case"IS_NAN":var e=this.on(t.unaryFilter.field);return Tt.create(e,"==",{doubleValue:NaN});case"IS_NULL":var n=this.on(t.unaryFilter.field);return Tt.create(n,"==",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":default:return me()}},t.prototype.Si=function(t){var e=[];return t.fields.forEach((function(t){return e.push(t.j())})),{fieldPaths:e}},t.prototype.ki=function(t){var e=t.fieldPaths||[];return new nt(e.map((function(t){return I.X(t)})))},t}();function fe(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}var le=function(){function t(){}return t.an=function(e){t.platform&&me(),t.platform=e},t.nt=function(){return t.platform||me(),t.platform},t}(),pe=new s.Logger("@firebase/firestore");function de(){return pe.logLevel}function ye(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(pe.logLevel<=s.LogLevel.DEBUG){var r=e.map(ge);pe.debug.apply(pe,i.__spreadArrays(["Firestore ("+h+"): "+t],r))}}function ve(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(pe.logLevel<=s.LogLevel.ERROR){var r=e.map(ge);pe.error.apply(pe,i.__spreadArrays(["Firestore ("+h+"): "+t],r))}}function ge(t){if("string"==typeof t)return t;var e=le.nt();try{return e.un(t)}catch(e){return t}}function me(t){void 0===t&&(t="Unexpected state");var e="FIRESTORE ("+h+") INTERNAL ASSERTION FAILED: "+t;throw ve(e),new Error(e)}function we(t,e){t||me()}function Ee(t,e){return t}var _e=function(){function t(){}return t.cn=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length,n="";n.length<20;)for(var r=le.nt()._n(40),i=0;i<r.length;++i)n.length<20&&r[i]<e&&(n+=t.charAt(r[i]%t.length));return n},t}();function be(t,e){return t<e?-1:t>e?1:0}function Te(t,e,n){return t.length===e.length&&t.every((function(t,r){return n(t,e[r])}))}function Ie(t){return t+"\0"}var Ne=function(t,e,n,r,i){this.ii=t,this.persistenceKey=e,this.host=n,this.ssl=r,this.forceLongPolling=i},Ae=function(){function t(t,e){this.projectId=t,this.database=e||"(default)"}return Object.defineProperty(t.prototype,"ln",{get:function(){return"(default)"===this.database},enumerable:!0,configurable:!0}),t.prototype.isEqual=function(e){return e instanceof t&&e.projectId===this.projectId&&e.database===this.database},t.prototype.S=function(t){return be(this.projectId,t.projectId)||be(this.database,t.database)},t}(),xe=function(){function t(t){this.dn=t,this.fn={}}return t.prototype.get=function(t){var e=this.dn(t),n=this.fn[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(s.isEqual(t))return u}},t.prototype.has=function(t){return void 0!==this.get(t)},t.prototype.set=function(t,e){var n=this.dn(t),r=this.fn[n];if(void 0!==r){for(var i=0;i<r.length;i++)if(r[i][0].isEqual(t))return void(r[i]=[t,e]);r.push([t,e])}else this.fn[n]=[[t,e]]},t.prototype.delete=function(t){var e=this.dn(t),n=this.fn[e];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(n[r][0].isEqual(t))return 1===n.length?delete this.fn[e]:n.splice(r,1),!0;return!1},t.prototype.forEach=function(t){x(this.fn,(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)}}
1))},t.prototype.B=function(){return D(this.fn)},t}(),De=function(){function t(t,e,n,r){this.batchId=t,this.Tn=e,this.baseMutations=n,this.mutations=r}return t.prototype.at=function(t,e,n){for(var r=n.En,i=0;i<this.mutations.length;i++){var o=this.mutations[i];if(o.key.isEqual(t)){var s=r[i];e=o.at(e,s)}}return e},t.prototype.ot=function(t,e){for(var n=0,r=this.baseMutations;n<r.length;n++){var i=r[n];i.key.isEqual(t)&&(e=i.ot(e,e,this.Tn))}for(var o=e,s=0,u=this.mutations;s<u.length;s++){var a=u[s];a.key.isEqual(t)&&(e=a.ot(e,o,this.Tn))}return e},t.prototype.In=function(t){var e=this,n=t;return this.mutations.forEach((function(r){var i=e.ot(r.key,t.get(r.key));i&&(n=n.Ae(r.key,i))})),n},t.prototype.keys=function(){return this.mutations.reduce((function(t,e){return t.add(e.key)}),Kt())},t.prototype.isEqual=function(t){return this.batchId===t.batchId&&Te(this.mutations,t.mutations,(function(t,e){return t.isEqual(e)}))&&Te(this.baseMutations,t.baseMutations,(function(t,e){return t.isEqual(e)}))},t}(),Se=function(){function t(t,e,n,r){this.batch=t,this.wn=e,this.En=n,this.Rn=r}return t.from=function(e,n,r){we(e.mutations.length===r.length);for(var i=Wt,o=e.mutations,s=0;s<o.length;s++)i=i.Ae(o[s].key,r[s].version);return new t(e,n,r,i)},t}(),Re=function(){function t(t){var e=this;this.An=null,this.mn=null,this.result=void 0,this.error=void 0,this.Pn=!1,this.Vn=!1,t((function(t){e.Pn=!0,e.result=t,e.An&&e.An(t)}),(function(t){e.Pn=!0,e.error=t,e.mn&&e.mn(t)}))}return t.prototype.catch=function(t){return this.next(void 0,t)},t.prototype.next=function(e,n){var r=this;return this.Vn&&me(),this.Vn=!0,this.Pn?this.error?this.gn(n,this.error):this.pn(e,this.result):new t((function(t,i){r.An=function(n){r.pn(e,n).next(t,i)},r.mn=function(e){r.gn(n,e).next(t,i)}}))},t.prototype.yn=function(){var t=this;return new Promise((function(e,n){t.next(e,n)}))},t.prototype.bn=function(e){try{var n=e();return n instanceof t?n:t.resolve(n)}catch(e){return t.reject(e)}},t.prototype.pn=function(e,n){return e?this.bn((function(){return e(n)})):t.resolve(n)},t.prototype.gn=function(e,n){return e?this.bn((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.vn=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.Sn=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.vn(r)},t}(),ke=function(){function t(){this.Dn=new xe((function(t){return t.toString()})),this.Cn=!1}return Object.defineProperty(t.prototype,"readTime",{get:function(){return this.Fn},set:function(t){this.Fn=t},enumerable:!0,configurable:!0}),t.prototype.Nn=function(t,e){this.kn(),this.readTime=e,this.Dn.set(t.key,t)},t.prototype.Mn=function(t,e){this.kn(),e&&(this.readTime=e),this.Dn.set(t,null)},t.prototype.xn=function(t,e){this.kn();var n=this.Dn.get(e);return void 0!==n?Re.resolve(n):this.$n(t,e)},t.prototype.getEntries=function(t,e){return this.On(t,e)},t.prototype.apply=function(t){return this.kn(),this.Cn=!0,this.Ln(t)},t.prototype.kn=function(){},t}(),Pe="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",Ve=function(){function t(){this.Bn=[]}return t.prototype.qn=function(t){this.Bn.push(t)},t.prototype.Un=function(){this.Bn.forEach((function(t){return t()}))},t}(),Le=function(){function t(t,e,n){this.Qn=t,this.Wn=e,this.jn=n}return t.prototype.Kn=function(t,e){var n=this;return this.Wn.Gn(t,e).next((function(r){return n.zn(t,e,r)}))},t.prototype.zn=function(t,e,n){return this.Qn.xn(t,e).next((function(t){for(var r=0,i=n;r<i.length;r++)t=i[r].ot(e,t);return t}))},t.prototype.Hn=function(t,e,n){var r=Bt();return e.forEach((function(t,e){for(var i=0,o=n;i<o.length;i++)e=o[i].ot(t,e);r=r.Ae(t,e)})),r},t.prototype.Yn=function(t,e){var n=this;return this.Qn.getEntries(t,e).next((function(e){return n.Jn(t,e)}))},t.prototype.Jn=function(t,e){var n=this;return this.Wn.Xn(t,e).next((function(r){var i=n.Hn(t,e,r),o=Ft();
1return i.forEach((function(t,e){e||(e=new wt(t,E.min())),o=o.Ae(t,e)})),o}))},t.prototype.Zn=function(t,e,n){return e.Ot()?this.tr(t,e.path):e._e()?this.er(t,e,n):this.sr(t,e,n)},t.prototype.tr=function(t,e){return this.Kn(t,new N(e)).next((function(t){var e=Gt();return t instanceof mt&&(e=e.Ae(t.key,t)),e}))},t.prototype.er=function(t,e,n){var r=this,i=e.collectionGroup,o=Gt();return this.jn.ir(t,i).next((function(s){return Re.forEach(s,(function(s){var u=e.Zt(s.child(i));return r.sr(t,u,n).next((function(t){t.forEach((function(t,e){o=o.Ae(t,e)}))}))})).next((function(){return o}))}))},t.prototype.sr=function(t,e,n){var r,i,o=this;return this.Qn.Zn(t,e,n).next((function(n){return r=n,o.Wn.nr(t,e)})).next((function(e){return i=e,o.rr(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=a.ot(h,h,o.Tn);r=f instanceof mt?r.Ae(c,f):r.remove(c)}}))})).next((function(){return r.forEach((function(t,n){e.matches(n)||(r=r.remove(t))})),r}))},t.prototype.rr=function(t,e,n){for(var r=Kt(),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 at&&null===n.get(a.key)&&(r=r.add(a.key))}var c=n;return this.Qn.getEntries(t,r).next((function(t){return t.forEach((function(t,e){null!==e&&e instanceof mt&&(c=c.Ae(t,e))})),c}))},t}(),Oe=function(){function t(t,e,n,r){this.targetId=t,this.fromCache=e,this.hr=n,this.or=r}return t.ar=function(e,n){for(var r=Kt(),i=Kt(),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}(),Ue=function(){function t(t,e){var n=this;this.previousValue=t,e&&(e.ur=function(t){return n.cr(t)},this._r=function(t){return e.lr(t)})}return t.prototype.cr=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},t.prototype.next=function(){var t=++this.previousValue;return this._r&&this._r(t),t},t}();Ue.dr=-1;var Ce=function(){var t=this;this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))},qe=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.Tr=t,this.Er=e,this.Ir=n,this.wr=r,this.Rr=i,this.Ar=0,this.mr=null,this.Pr=Date.now(),this.reset()}return t.prototype.reset=function(){this.Ar=0},t.prototype.Vr=function(){this.Ar=this.Rr},t.prototype.gr=function(t){var e=this;this.cancel();var n=Math.floor(this.Ar+this.pr()),r=Math.max(0,Date.now()-this.Pr),i=Math.max(0,n-r);i>0&&ye("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.Ar+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.mr=this.Tr.yr(this.Er,i,(function(){return e.Pr=Date.now(),t()})),this.Ar*=this.wr,this.Ar<this.Ir&&(this.Ar=this.Ir),this.Ar>this.Rr&&(this.Ar=this.Rr)},t.prototype.br=function(){null!==this.mr&&(this.mr.vr(),this.mr=null)},t.prototype.cancel=function(){null!==this.mr&&(this.mr.cancel(),this.mr=null)},t.prototype.pr=function(){return(Math.random()-.5)*this.Ar},t}();function je(t){for(var e="",n=0;n<t.length;n++)e.length>0&&(e=Fe(e)),e=Me(t.get(n),e);return Fe(e)}function Me(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+="\x01\x10";break;case"\x01":n+="\x01\x11";break;default:n+=o}}return n}function Fe(t){return t+"\x01\x01"}function Be(t){var e=t.length;if(we(e>=2),2===e)return we("\x01"===t.charAt(0)&&"\x01"===t.charAt(1)),b.G;for(var n=e-2,r=[],i="",o=0;o<e;){var s=t.indexOf("\x01",o);switch((s<0||s>n)&&me(),t.charAt(s+1)){case"\x01":var u=t.substring(o,s),a=void 0;0===i.length?a=u:(a=i+=u,i=""),r.push(a);break;case"\x10":i+=t.substring(o,s),i+="\0";break;case"\x11":i+=t.substring(o,s+1);break;default:me()}o=s+2}return new b(r)}var ze=function(){function t(){this.Sr=new Ge}return t.prototype.Dr=function(t,e){return this.Sr.add(e),Re.resolve()},t.prototype.ir=function(t,e){return Re.resolve(this.Sr.getEntries(e))},t}(),Ge=function(){function t(){this.index={}}return t.prototype.add=function(t){var e=t.L(),n=t.$(),r=this.index[e]||new qt(b.N),i=!r.has(n);return this.index[e]=r.add(n),i},t.prototype.has=function(t){var e=t.L(),n=t.$(),r=this.index[e];return r&&r.has(n)},t.prototype.getEntries=function(t){return(this.index[t]||new qt(b.N)).W()},t}(),We=function(){function t(){this.Cr=new Ge}return t.prototype.Dr=function(t,e){var n=this;if(!this.Cr.has(e)){var r=e.L(),i=e.$();t.qn((function(){n.Cr.add(e)}));var o={collectionId:r,parent:je(i)};return Qe(t).put(o)}return Re.resolve()},t.prototype.ir=function(t,e){var n=[],r=IDBKeyRange.bound([e,""],[Ie(e),""],!1,!0);return Qe(t).Fr(r).next((function(t){for(var r=0,i=t;r<i.length;r++){var o=i[r];if(o.collectionId!==e)break;n.push(Be(o.parent))}return n}))},t}();function Qe(t){return un.Nr(t,Pn.store)}
1var Ke=function(){function t(t,e){this.serializer=t,this.jn=e}return t.prototype.Nn=function(t,e,n){return Je(t).put(Xe(e),n)},t.prototype.Mn=function(t,e){var n=Je(t),r=Xe(e);return n.delete(r)},t.prototype.updateMetadata=function(t,e){var n=this;return this.getMetadata(t).next((function(r){return r.byteSize+=e,n.kr(t,r)}))},t.prototype.xn=function(t,e){var n=this;return Je(t).get(Xe(e)).next((function(t){return n.Mr(t)}))},t.prototype.xr=function(t,e){var n=this;return Je(t).get(Xe(e)).next((function(t){var e=n.Mr(t);return e?{$r:e,size:He(t)}:null}))},t.prototype.getEntries=function(t,e){var n=this,r=Bt();return this.Or(t,e,(function(t,e){var i=n.Mr(e);r=r.Ae(t,i)})).next((function(){return r}))},t.prototype.Lr=function(t,e){var n=this,r=Bt(),i=new Ot(N.N);return this.Or(t,e,(function(t,e){var o=n.Mr(e);o?(r=r.Ae(t,o),i=i.Ae(t,He(e))):(r=r.Ae(t,null),i=i.Ae(t,0))})).next((function(){return{Br:r,qr:i}}))},t.prototype.Or=function(t,e,n){if(e.B())return Re.resolve();var r=IDBKeyRange.bound(e.first().path.W(),e.last().path.W()),i=e.be(),o=i.Ne();return Je(t).Ur({range:r},(function(t,e,r){for(var s=N.st(t);o&&N.N(o,s)<0;)n(o,null),o=i.Ne();o&&o.isEqual(s)&&(n(o,e),o=i.ke()?i.Ne():null),o?r.Qr(o.path.W()):r.done()})).next((function(){for(;o;)n(o,null),o=i.ke()?i.Ne():null}))},t.prototype.Zn=function(t,e,n){var r=this,i=Gt(),o=e.path.length+1,s={};if(n.isEqual(E.min())){var u=e.path.W();s.range=IDBKeyRange.lowerBound(u)}else{var a=e.path.W(),c=this.serializer.Wr(n);s.range=IDBKeyRange.lowerBound([a,c],!0),s.index=xn.collectionReadTimeIndex}return Je(t).Ur(s,(function(t,n,s){if(t.length===o){var u=r.serializer.jr(n);e.path.q(u.key.path)?u instanceof mt&&e.matches(u)&&(i=i.Ae(u.key,u)):s.done()}})).next((function(){return i}))},t.prototype.Kr=function(t,e){var n=this,r=Ft(),i=this.serializer.Wr(e),o=Je(t),s=IDBKeyRange.lowerBound(i,!0);return o.Ur({index:xn.readTimeIndex,range:s},(function(t,e){var o=n.serializer.jr(e);r=r.Ae(o.key,o),i=e.readTime})).next((function(){return{Gr:r,readTime:n.serializer.zr(i)}}))},t.prototype.Hr=function(t){var e=this,n=Je(t),r=E.min();return n.Ur({index:xn.readTimeIndex,reverse:!0},(function(t,n,i){n.readTime&&(r=e.serializer.zr(n.readTime)),i.done()})).next((function(){return r}))},t.prototype.Yr=function(e){return new t.Jr(this,!!e&&e.Xr)},t.prototype.Zr=function(t){return this.getMetadata(t).next((function(t){return t.byteSize}))},t.prototype.getMetadata=function(t){return Ye(t).get(Dn.key).next((function(t){return we(!!t),t}))},t.prototype.kr=function(t,e){return Ye(t).put(Dn.key,e)},t.prototype.Mr=function(t){if(t){var e=this.serializer.jr(t);return e instanceof wt&&e.version.isEqual(E.min())?null:e}return null},t}();function Ye(t){return un.Nr(t,Dn.store)}function Je(t){return un.Nr(t,xn.store)}function Xe(t){return t.path.W()}function He(t){var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw me();e=t.noDocument}return JSON.stringify(e).length}Ke.Jr=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).th=e,r.Xr=n,r.eh=new xe((function(t){return t.toString()})),r}return i.__extends(e,t),e.prototype.Ln=function(t){var e=this,n=[],r=0,i=new qt((function(t,e){return be(t.j(),e.j())}));return this.Dn.forEach((function(o,s){var u=e.eh.get(o);if(s){var a=e.th.serializer.sh(s,e.readTime);i=i.add(o.path.$());var c=He(a);r+=c-u,n.push(e.th.Nn(t,o,a))}else if(r-=u,e.Xr){var h=e.th.serializer.sh(new wt(o,E.min()),e.readTime);n.push(e.th.Nn(t,o,h))}else n.push(e.th.Mn(t,o))})),i.forEach((function(r){n.push(e.th.jn.Dr(t,r))})),n.push(this.th.updateMetadata(t,r)),Re.vn(n)},e.prototype.$n=function(t,e){var n=this;return this.th.xr(t,e).next((function(t){return null===t?(n.eh.set(e,0),null):(n.eh.set(e,t.size),t.$r)}))},e.prototype.On=function(t,e){var n=this;return this.th.Lr(t,e).next((function(t){var e=t.Br;return t.qr.forEach((function(t,e){n.eh.set(t,e)})),e}))},e}(ke);var $e=function(){function t(t){this.ih=t}return t.prototype.next=function(){return this.ih+=2,this.ih},t.nh=function(){return new t(0)},t.rh=function(){return new t(-1)},t}
1(),Ze=function(){function t(t,e){this.hh=t,this.serializer=e}return t.prototype.oh=function(t){var e=this;return this.ah(t).next((function(n){var r=new $e(n.highestTargetId);return n.highestTargetId=r.next(),e.uh(t,n).next((function(){return n.highestTargetId}))}))},t.prototype._h=function(t){return this.ah(t).next((function(t){return E.v(new w(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))}))},t.prototype.lh=function(t){return this.ah(t).next((function(t){return t.highestListenSequenceNumber}))},t.prototype.dh=function(t,e,n){var r=this;return this.ah(t).next((function(i){return i.highestListenSequenceNumber=e,n&&(i.lastRemoteSnapshotVersion=n.C()),e>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=e),r.uh(t,i)}))},t.prototype.fh=function(t,e){var n=this;return this.Th(t,e).next((function(){return n.ah(t).next((function(r){return r.targetCount+=1,n.Eh(e,r),n.uh(t,r)}))}))},t.prototype.Ih=function(t,e){return this.Th(t,e)},t.prototype.wh=function(t,e){var n=this;return this.Rh(t,e.targetId).next((function(){return tn(t).delete(e.targetId)})).next((function(){return n.ah(t)})).next((function(e){return we(e.targetCount>0),e.targetCount-=1,n.uh(t,e)}))},t.prototype.Ah=function(t,e,n){var r=this,i=0,o=[];return tn(t).Ur((function(s,u){var a=r.serializer.mh(u);a.sequenceNumber<=e&&null===n.get(a.targetId)&&(i++,o.push(r.wh(t,a)))})).next((function(){return Re.vn(o)})).next((function(){return i}))},t.prototype.js=function(t,e){var n=this;return tn(t).Ur((function(t,r){var i=n.serializer.mh(r);e(i)}))},t.prototype.ah=function(t){return en(t).get(kn.key).next((function(t){return we(null!==t),t}))},t.prototype.uh=function(t,e){return en(t).put(kn.key,e)},t.prototype.Th=function(t,e){return tn(t).put(this.serializer.Ph(e))},t.prototype.Eh=function(t,e){var n=!1;return t.targetId>e.highestTargetId&&(e.highestTargetId=t.targetId,n=!0),t.sequenceNumber>e.highestListenSequenceNumber&&(e.highestListenSequenceNumber=t.sequenceNumber,n=!0),n},t.prototype.Vh=function(t){return this.ah(t).next((function(t){return t.targetCount}))},t.prototype.gh=function(t,e){var n=this,r=e.canonicalId(),i=IDBKeyRange.bound([r,Number.NEGATIVE_INFINITY],[r,Number.POSITIVE_INFINITY]),o=null;return tn(t).Ur({range:i,index:Sn.queryTargetsIndexName},(function(t,r,i){var s=n.serializer.mh(r);e.isEqual(s.target)&&(o=s,i.done())})).next((function(){return o}))},t.prototype.ph=function(t,e,n){var r=this,i=[],o=nn(t);return e.forEach((function(e){var s=je(e.path);i.push(o.put(new Rn(n,s))),i.push(r.hh.yh(t,n,e))})),Re.vn(i)},t.prototype.bh=function(t,e,n){var r=this,i=nn(t);return Re.forEach(e,(function(e){var o=je(e.path);return Re.vn([i.delete([n,o]),r.hh.vh(t,n,e)])}))},t.prototype.Rh=function(t,e){var n=nn(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},t.prototype.Sh=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=nn(t),i=Kt();return r.Ur({range:n,Dh:!0},(function(t,e,n){var r=Be(t[1]),o=new N(r);i=i.add(o)})).next((function(){return i}))},t.prototype.Ch=function(t,e){var n=je(e.path),r=IDBKeyRange.bound([n],[Ie(n)],!1,!0),i=0;return nn(t).Ur({index:Rn.documentTargetsIndex,Dh:!0,range:r},(function(t,e,n){var r=t[0];t[1],0!==r&&(i++,n.done())})).next((function(){return i>0}))},t.prototype.si=function(t,e){var n=this;return tn(t).get(e).next((function(t){return t?n.serializer.mh(t):null}))},t}();function tn(t){return un.Nr(t,Sn.store)}function en(t){return un.Nr(t,kn.store)}function nn(t){return un.Nr(t,Rn.store)}var rn=function(){function t(t){this.Fh=t}return t.prototype.jr=function(t){if(t.document)return this.Fh.mi(t.document,!!t.hasCommittedMutations);if(t.noDocument){var e=N.st(t.noDocument.path),n=this.Nh(t.noDocument.readTime);return new wt(e,n,{hasCommittedMutations:!!t.hasCommittedMutations})}if(t.unknownDocument){var r=N.st(t.unknownDocument.path),i=this.Nh(t.unknownDocument.version);return new Et(r,i)}return me()},t.prototype.sh=function(t,e){var n=this.Wr(e),r=t.key.path.$().W();if(t instanceof mt){var i=this.Fh.Ai(t),o=t.hasCommittedMutations;return new xn(null,null,i,o,n,r)}if(t instanceof wt){var s=t.key.path.W(),u=this.kh(t.version),a=t.hasCommittedMutations;return new xn(null,new Nn(s,u),null,a,n,r)}if(t instanceof Et){var c=t.key.path.W(),h=this.kh(t.version);return new xn(new An(c,h),null,null,!0,n,r)}return me()},t.prototype.Wr=function(t){var e=t.C();return[e.seconds,e.nanoseconds]},t.prototype.zr=function(t){var e=new w(t[0],t[1]);return E.v(e)},t.prototype.kh=function(t){var e=t.C();return new En(e.seconds,e.nanoseconds)},t.prototype.Nh=function(t){var e=new w(t.seconds,t.nanoseconds);return E.v(e)},t.prototype.Mh=function(t,e){var n=this,r=e.baseMutations.map((function(t){return n.Fh.vi(t)})),i=e.mutations.map((function(t){return n.Fh.vi(t)}));return new Tn(t,e.batchId,e.Tn.toMillis(),r,i)},t.prototype.xh=function(t){var e=this,n=(t.baseMutations||[]).map((function(t){return e.Fh.Fi(t)})),r=t.mutations.map((function(t){return e.Fh.Fi(t)})),i=w.fromMillis(t.localWriteTimeMs);return new De(t.batchId,i,n,r)},t.prototype.mh=function(t){var e,n=this.Nh(t.readTime),r=void 0!==t.lastLimboFreeSnapshotVersion?this.Nh(t.lastLimboFreeSnapshotVersion):E.min();return e=void 0!==t.query.documents?this.Fh.Li(t.query):this.Fh.Wi(t.query),new kt(e,t.targetId,0,t.lastListenSequenceNumber,n,r,S.fromBase64String(t.resumeToken))},t.prototype.Ph=function(t){var e,n=this.kh(t.Ee),r=this.kh(t.lastLimboFreeSnapshotVersion);e=t.target.Ot()?this.Fh.Oi(t.target):this.Fh.Bi(t.target);var i=t.resumeToken.toBase64();return new Sn(t.targetId,t.target.canonicalId(),n,i,t.sequenceNumber,r,e)},t}(),on="Failed to obtain exclusive access to the persistence layer. To allow shared access, make sure to invoke `enablePersistence()` with `synchronizeTabs:true` in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",sn=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).$h=e,r.Oh=n,r}return i.__extends(e,t),e}(Ve),un=function(){function t(e,n,r,i,o,s,u,a,c){if(this.allowTabSynchronization=e,this.persistenceKey=n,this.clientId=r,this.Tr=s,this.Lh=a,this.Bh=c,this.qh=null,this.Uh=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Qh=null,this.inForeground=!1,this.Wh=null,this.jh=null,this.Kh=Number.NEGATIVE_INFINITY,this.Gh=function(t){return Promise.resolve()}
1,!t.zh())throw new p(l.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.hh=new hn(this,o),this.Hh=n+t.Yh,this.serializer=new rn(u),this.document=i.document,this.Jh=new Ze(this.hh,this.serializer),this.jn=new We,this.Qn=new Ke(this.serializer,this.jn),this.window=i.window,i.window&&i.window.localStorage?this.Xh=i.window.localStorage:(this.Xh=null,!1===c&&ve("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}return t.Nr=function(t,e){if(t instanceof sn)return Un.Nr(t.$h,e);throw me()},t.prototype.start=function(){var t=this;return Un.Zh(this.Hh,mn,new wn(this.serializer)).then((function(e){return t.to=e,t.eo()})).then((function(){if(!t.isPrimary&&!t.allowTabSynchronization)throw new p(l.FAILED_PRECONDITION,on);return t.so(),t.io(),t.no(),t.runTransaction("getHighestListenSequenceNumber","readonly",(function(e){return t.Jh.lh(e)}))})).then((function(e){t.qh=new Ue(e,t.Lh)})).then((function(){t.Uh=!0})).catch((function(e){return t.to&&t.to.close(),Promise.reject(e)}))},t.prototype.ro=function(t){var e=this;return this.Gh=function(n){return i.__awaiter(e,void 0,void 0,(function(){return i.__generator(this,(function(e){return this.ho?[2,t(n)]:[2]}))}))},t(this.isPrimary)},t.prototype.oo=function(t){var e=this;this.to.ao((function(n){return i.__awaiter(e,void 0,void 0,(function(){return i.__generator(this,(function(e){switch(e.label){case 0:return null===n.newVersion?[4,t()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}
1))}))}))},t.prototype.uo=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.Tr.co((function(){return i.__awaiter(e,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return this.ho?[4,this.eo()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))})))},t.prototype.eo=function(){var t=this;return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(function(e){return cn(e).put(new Ln(t.clientId,Date.now(),t.networkEnabled,t.inForeground)).next((function(){if(t.isPrimary)return t._o(e).next((function(e){e||(t.isPrimary=!1,t.Tr.lo((function(){return t.Gh(!1)})))}))})).next((function(){return t.do(e)})).next((function(n){return t.isPrimary&&!n?t.fo(e).next((function(){return!1})):!!n&&t.To(e).next((function(){return!0}))}))})).catch((function(e){if(jn(e))return ye("IndexedDbPersistence","Failed to extend owner lease: ",e),t.isPrimary;if(!t.allowTabSynchronization)throw e;return ye("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1})).then((function(e){t.isPrimary!==e&&t.Tr.lo((function(){return t.Gh(e)})),t.isPrimary=e}))},t.prototype._o=function(t){var e=this;return an(t).get(_n.key).next((function(t){return Re.resolve(e.Eo(t))}))},t.prototype.Io=function(t){return cn(t).delete(this.clientId)},t.prototype.wo=function(){return i.__awaiter(this,void 0,void 0,(function(){var e,n,r,o,s=this;return i.__generator(this,(function(i){switch(i.label){case 0:return!this.isPrimary||this.Ro(this.Kh,18e5)?[3,2]:(this.Kh=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(function(e){var n=t.Nr(e,Ln.store);return n.Fr().next((function(t){var e=s.Ao(t,18e5),r=t.filter((function(t){return-1===e.indexOf(t)}));return Re.forEach(r,(function(t){return n.delete(t.clientId)})).next((function(){return r}))}))})).catch((function(){return[]}))]);case 1:if(e=i.sent(),this.Xh)for(n=0,r=e;n<r.length;n++)o=r[n],this.Xh.removeItem(this.mo(o.clientId));i.label=2;case 2:return[2]}}
1))}))},t.prototype.no=function(){var t=this;this.jh=this.Tr.yr("client_metadata_refresh",4e3,(function(){return t.eo().then((function(){return t.wo()})).then((function(){return t.no()}))}))},t.prototype.Eo=function(t){return!!t&&t.ownerId===this.clientId},t.prototype.do=function(t){var e=this;return this.Bh?Re.resolve(!0):an(t).get(_n.key).next((function(n){if(null!==n&&e.Ro(n.leaseTimestampMs,5e3)&&!e.Po(n.ownerId)){if(e.Eo(n)&&e.networkEnabled)return!0;if(!e.Eo(n)){if(!n.allowTabSynchronization)throw new p(l.FAILED_PRECONDITION,on);return!1}}return!(!e.networkEnabled||!e.inForeground)||cn(t).Fr().next((function(t){return void 0===e.Ao(t,5e3).find((function(t){if(e.clientId!==t.clientId){var n=!e.networkEnabled&&t.networkEnabled,r=!e.inForeground&&t.inForeground,i=e.networkEnabled===t.networkEnabled;if(n||r&&i)return!0}return!1}))}))})).next((function(t){return e.isPrimary!==t&&ye("IndexedDbPersistence","Client "+(t?"is":"is not")+" eligible for a primary lease."),t}))},t.prototype.Vo=function(){return i.__awaiter(this,void 0,void 0,(function(){var t=this;return i.__generator(this,(function(e){switch(e.label){case 0:return this.Uh=!1,this.po(),this.jh&&(this.jh.cancel(),this.jh=null),this.yo(),this.bo(),[4,this.runTransaction("shutdown","readwrite",(function(e){return t.fo(e).next((function(){return t.Io(e)}))})).catch((function(t){ye("IndexedDbPersistence","Proceeding with shutdown despite failure: ",t)}))];case 1:return e.sent(),this.to.close(),this.vo(),[2]}}))}))},t.prototype.Ao=function(t,e){var n=this;return t.filter((function(t){return n.Ro(t.updateTimeMs,e)&&!n.Po(t.clientId)}))},t.prototype.So=function(){var t=this;return this.runTransaction("getActiveClients","readonly",(function(e){return cn(e).Fr().next((function(e){return t.Ao(e,18e5).map((function(t){return t.clientId}))}))}))},t.clearPersistence=function(e){return i.__awaiter(this,void 0,void 0,(function(){var n;return i.__generator(this,(function(r){switch(r.label){case 0:return t.zh()?(n=e+t.Yh,[4,Un.delete(n)]):[2,Promise.resolve()];case 1:return r.sent(),[2]}}))}))},Object.defineProperty(t.prototype,"ho",{get:function(){return this.Uh},enumerable:!0,configurable:!0}),t.prototype.Do=function(t){return ln.Co(t,this.serializer,this.jn,this.hh)},t.prototype.Fo=function(){return this.Jh},t.prototype.No=function(){return this.Qn},t.prototype.ko=function(){return this.jn},t.prototype.runTransaction=function(t,e,n){var r=this;ye("IndexedDbPersistence","Starting transaction:",t);var i,o="readonly"===e?"readonly":"readwrite";return this.to.runTransaction(o,On,(function(o){return i=new sn(o,r.qh?r.qh.next():Ue.dr),"readwrite-primary"===e?r._o(i).next((function(t){return!!t||r.do(i)})).next((function(e){if(!e)throw ve("Failed to obtain primary lease for action '"+t+"'."),r.isPrimary=!1,r.Tr.lo((function(){return r.Gh(!1)})),new p(l.FAILED_PRECONDITION,Pe);return n(i)})).next((function(t){return r.To(i).next((function(){return t}))})):r.Mo(i).next((function(){return n(i)}))})).then((function(t){return i.Un(),t}))},t.prototype.Mo=function(t){var e=this;return an(t).get(_n.key).next((function(t){if(null!==t&&e.Ro(t.leaseTimestampMs,5e3)&&!e.Po(t.ownerId)&&!e.Eo(t)&&!(e.Bh||e.allowTabSynchronization&&t.allowTabSynchronization))throw new p(l.FAILED_PRECONDITION,on)}))},t.prototype.To=function(t){var e=new _n(this.clientId,this.allowTabSynchronization,Date.now());return an(t).put(_n.key,e)},t.zh=function(){return Un.zh()},t.xo=function(t){var e=t.ii.projectId;return t.ii.ln||(e+="."+t.ii.database),"firestore/"+t.persistenceKey+"/"+e+"/"},t.prototype.fo=function(t){var e=this,n=an(t);return n.get(_n.key).next((function(t){return e.Eo(t)?(ye("IndexedDbPersistence","Releasing primary lease."),n.delete(_n.key)):Re.resolve()}))},t.prototype.Ro=function(t,e){var n=Date.now();return!(t<n-e||t>n&&(ve("Detected an update time that is in the future: "+t+" > "+n),1))},t.prototype.so=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Wh=function(){t.Tr.co((function(){return t.inForeground="visible"===t.document.visibilityState,t.eo()}))},this.document.addEventListener("visibilitychange",this.Wh),this.inForeground="visible"===this.document.visibilityState)},t.prototype.yo=function(){this.Wh&&(this.document.removeEventListener("visibilitychange",this.Wh),this.Wh=null)},t.prototype.io=function(){var t,e=this;"function"==typeof(null===(t=this.window)||void 0===t?void 0:t.addEventListener)&&(this.Qh=function(){e.po(),e.Tr.co((function(){return e.Vo()}))},this.window.addEventListener("unload",this.Qh))},t.prototype.bo=function(){this.Qh&&(this.window.removeEventListener("unload",this.Qh),this.Qh=null)},t.prototype.Po=function(t){var e;try{var n=null!==(null===(e=this.Xh)||void 0===e?void 0:e.getItem(this.mo(t)));return ye("IndexedDbPersistence","Client '"+t+"' "+(n?"is":"is not")+" zombied in LocalStorage"),n}catch(t){return ve("IndexedDbPersistence","Failed to get zombied client id.",t),!1}},t.prototype.po=function(){if(this.Xh)try{this.Xh.setItem(this.mo(this.clientId),String(Date.now()))}catch(t){ve("Failed to set zombie client id.",t)}},t.prototype.vo=function(){if(this.Xh)try{this.Xh.removeItem(this.mo(this.clientId))}catch(t){}},t.prototype.mo=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},t}();function an(t){return un.Nr(t,_n.store)}function cn(t){return un.Nr(t,Ln.store)}un.Yh="main";var hn=function(){function t(t,e){this.db=t,this.$o=new Zn(this,e)}return t.prototype.Oo=function(t){var e=this.Lo(t);return this.db.Fo().Vh(t).next((function(t){return e.next((function(e){return t+e}))}))},t.prototype.Lo=function(t){var e=0;return this.Bo(t,(function(t){e++})).next((function(){return e}))},t.prototype.js=function(t,e){return this.db.Fo().js(t,e)},t.prototype.Bo=function(t,e){return this.qo(t,(function(t,n){return e(n)}))},t.prototype.yh=function(t,e,n){return fn(t,n)},t.prototype.vh=function(t,e,n){return fn(t,n)},t.prototype.Ah=function(t,e,n){return this.db.Fo().Ah(t,e,n)},t.prototype.Uo=function(t,e){return fn(t,e)},t.prototype.Qo=function(t,e){return function(t,e){var n=!1;return gn(t).Wo((function(r){return pn(t,r,e).next((function(t){return t&&(n=!0),Re.resolve(!t)}))})).next((function(){return n}))}(t,e)},t.prototype.jo=function(t,e){var n=this,r=this.db.No().Yr(),i=[],o=0;return this.qo(t,(function(s,u){if(u<=e){var a=n.Qo(t,s).next((function(e){if(!e)return o++,r.xn(t,s).next((function(){return r.Mn(s),nn(t).delete([0,je(s.path)])}))}));i.push(a)}})).next((function(){return Re.vn(i)})).next((function(){return r.apply(t)})).next((function(){return o}
1))},t.prototype.removeTarget=function(t,e){var n=e.Ie(t.Oh);return this.db.Fo().Ih(t,n)},t.prototype.Ko=function(t,e){return fn(t,e)},t.prototype.qo=function(t,e){var n,r=nn(t),i=Ue.dr;return r.Ur({index:Rn.documentTargetsIndex},(function(t,r){var o=t[0],s=(t[1],r.path),u=r.sequenceNumber;0===o?(i!==Ue.dr&&e(new N(Be(n)),i),i=u,n=s):i=Ue.dr})).next((function(){i!==Ue.dr&&e(new N(Be(n)),i)}))},t.prototype.Go=function(t){return this.db.No().Zr(t)},t}();function fn(t,e){return nn(t).put(function(t,e){return new Rn(0,je(t.path),e)}(e,t.Oh))}var ln=function(){function t(t,e,n,r){this.userId=t,this.serializer=e,this.jn=n,this.hh=r,this.zo={}}return t.Co=function(e,n,r,i){return we(""!==e.uid),new t(e.t()?e.uid:"",n,r,i)},t.prototype.Ho=function(t){var e=!0,n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return yn(t).Ur({index:Tn.userMutationsIndex,range:n},(function(t,n,r){e=!1,r.done()})).next((function(){return e}))},t.prototype.Yo=function(t,e,n,r){var i=this,o=vn(t),s=yn(t);return s.add({}).next((function(u){we("number"==typeof u);for(var a=new De(u,e,n,r),c=i.serializer.Mh(i.userId,a),h=[],f=new qt((function(t,e){return be(t.j(),e.j())})),l=0,p=r;l<p.length;l++){var d=p[l],y=In.key(i.userId,d.key.path,u);f=f.add(d.key.path.$()),h.push(s.put(c)),h.push(o.put(y,In.PLACEHOLDER))}return f.forEach((function(e){h.push(i.jn.Dr(t,e))})),t.qn((function(){i.zo[u]=a.keys()})),Re.vn(h).next((function(){return a}))}))},t.prototype.Jo=function(t,e){var n=this;return yn(t).get(e).next((function(t){return t?(we(t.userId===n.userId),n.serializer.xh(t)):null}))},t.prototype.Xo=function(t,e){var n=this;return this.zo[e]?Re.resolve(this.zo[e]):this.Jo(t,e).next((function(t){if(t){var r=t.keys();return n.zo[e]=r,r}return null}))},t.prototype.Zo=function(t,e){var n=this,r=e+1,i=IDBKeyRange.lowerBound([this.userId,r]),o=null;return yn(t).Ur({index:Tn.userMutationsIndex,range:i},(function(t,e,i){e.userId===n.userId&&(we(e.batchId>=r),o=n.serializer.xh(e)),i.done()})).next((function(){return o}))},t.prototype.ta=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),n=-1;return yn(t).Ur({index:Tn.userMutationsIndex,range:e,reverse:!0},(function(t,e,r){n=e.batchId,r.done()})).next((function(){return n}))},t.prototype.ea=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return yn(t).Fr(Tn.userMutationsIndex,n).next((function(t){return t.map((function(t){return e.serializer.xh(t)}))}))},t.prototype.Gn=function(t,e){var n=this,r=In.prefixForPath(this.userId,e.path),i=IDBKeyRange.lowerBound(r),o=[];return vn(t).Ur({range:i},(function(r,i,s){var u=r[0],a=r[1],c=r[2],h=Be(a);if(u===n.userId&&e.path.isEqual(h))return yn(t).get(c).next((function(t){if(!t)throw me();we(t.userId===n.userId),o.push(n.serializer.xh(t))}));s.done()})).next((function(){return o}))},t.prototype.Xn=function(t,e){var n=this,r=new qt(be),i=[];return e.forEach((function(e){var o=In.prefixForPath(n.userId,e.path),s=IDBKeyRange.lowerBound(o),u=vn(t).Ur({range:s},(function(t,i,o){var s=t[0],u=t[1],a=t[2],c=Be(u);s===n.userId&&e.path.isEqual(c)?r=r.add(a):o.done()}));i.push(u)})),Re.vn(i).next((function(){return n.sa(t,r)}))},t.prototype.nr=function(t,e){var n=this,r=e.path,i=r.length+1,o=In.prefixForPath(this.userId,r),s=IDBKeyRange.lowerBound(o),u=new qt(be);return vn(t).Ur({range:s},(function(t,e,o){var s=t[0],a=t[1],c=t[2],h=Be(a);s===n.userId&&r.q(h)?h.length===i&&(u=u.add(c)):o.done()})).next((function(){return n.sa(t,u)}))},t.prototype.sa=function(t,e){var n=this,r=[],i=[];return e.forEach((function(e){i.push(yn(t).get(e).next((function(t){if(null===t)throw me();we(t.userId===n.userId),r.push(n.serializer.xh(t))})))})),Re.vn(i).next((function(){return r}))},t.prototype.ia=function(t,e){var n=this;return dn(t.$h,this.userId,e).next((function(r){return t.qn((function(){n.na(e.batchId)})),Re.forEach(r,(function(e){return n.hh.Uo(t,e)}))}))},t.prototype.na=function(t){delete this.zo[t]},t.prototype.ra=function(t){var e=this;return this.Ho(t).next((function(n){if(!n)return Re.resolve();
1var r=IDBKeyRange.lowerBound(In.prefixForUser(e.userId)),i=[];return vn(t).Ur({range:r},(function(t,n,r){if(t[0]===e.userId){var o=Be(t[1]);i.push(o)}else r.done()})).next((function(){we(0===i.length)}))}))},t.prototype.Ch=function(t,e){return pn(t,this.userId,e)},t.prototype.ha=function(t){var e=this;return gn(t).get(this.userId).next((function(t){return t||new bn(e.userId,-1,"")}))},t}();function pn(t,e,n){var r=In.prefixForPath(e,n.path),i=r[1],o=IDBKeyRange.lowerBound(r),s=!1;return vn(t).Ur({range:o,Dh:!0},(function(t,n,r){var o=t[0],u=t[1];t[2],o===e&&u===i&&(s=!0),r.done()})).next((function(){return s}))}function dn(t,e,n){var r=t.store(Tn.store),i=t.store(In.store),o=[],s=IDBKeyRange.only(n.batchId),u=0,a=r.Ur({range:s},(function(t,e,n){return u++,n.delete()}));o.push(a.next((function(){we(1===u)})));for(var c=[],h=0,f=n.mutations;h<f.length;h++){var l=f[h],p=In.key(e,l.key.path,n.batchId);o.push(i.delete(p)),c.push(l.key)}return Re.vn(o).next((function(){return c}))}function yn(t){return un.Nr(t,Tn.store)}function vn(t){return un.Nr(t,In.store)}function gn(t){return un.Nr(t,bn.store)}var mn=10,wn=function(){function t(t){this.serializer=t}return t.prototype.createOrUpgrade=function(t,e,n,r){var i=this;we(n<r&&n>=0&&r<=mn);var o=new Mn(e);n<1&&r>=1&&(function(t){t.createObjectStore(_n.store)}(t),function(t){t.createObjectStore(bn.store,{keyPath:bn.keyPath}),t.createObjectStore(Tn.store,{keyPath:Tn.keyPath,autoIncrement:!0}).createIndex(Tn.userMutationsIndex,Tn.userMutationsKeyPath,{unique:!0}),t.createObjectStore(In.store)}(t),Vn(t),function(t){t.createObjectStore(xn.store)}(t));var s=Re.resolve();return n<3&&r>=3&&(0!==n&&(function(t){t.deleteObjectStore(Rn.store),t.deleteObjectStore(Sn.store),t.deleteObjectStore(kn.store)}(t),Vn(t)),s=s.next((function(){return function(t){var e=t.store(kn.store),n=new kn(0,0,E.min().C(),0);return e.put(kn.key,n)}(o)}))),n<4&&r>=4&&(0!==n&&(s=s.next((function(){return function(t,e){return e.store(Tn.store).Fr().next((function(n){t.deleteObjectStore(Tn.store),t.createObjectStore(Tn.store,{keyPath:Tn.keyPath,autoIncrement:!0}).createIndex(Tn.userMutationsIndex,Tn.userMutationsKeyPath,{unique:!0});var r=e.store(Tn.store),i=n.map((function(t){return r.put(t)}));return Re.vn(i)}))}(t,o)}))),s=s.next((function(){!function(t){t.createObjectStore(Ln.store,{keyPath:Ln.keyPath})}(t)}))),n<5&&r>=5&&(s=s.next((function(){return i.removeAcknowledgedMutations(o)}))),n<6&&r>=6&&(s=s.next((function(){return function(t){t.createObjectStore(Dn.store)}(t),i.addDocumentGlobal(o)}))),n<7&&r>=7&&(s=s.next((function(){return i.ensureSequenceNumbers(o)}))),n<8&&r>=8&&(s=s.next((function(){return i.createCollectionParentIndex(t,o)}))),n<9&&r>=9&&(s=s.next((function(){!function(t){t.objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges")}(t),function(t){var e=t.objectStore(xn.store);e.createIndex(xn.readTimeIndex,xn.readTimeIndexPath,{unique:!1}),e.createIndex(xn.collectionReadTimeIndex,xn.collectionReadTimeIndexPath,{unique:!1})}(e)}))),n<10&&r>=10&&(s=s.next((function(){return i.rewriteCanonicalIds(o)}))),s},t.prototype.addDocumentGlobal=function(t){var e=0;return t.store(xn.store).Ur((function(t,n){e+=He(n)})).next((function(){var n=new Dn(e);return t.store(Dn.store).put(Dn.key,n)}))},t.prototype.removeAcknowledgedMutations=function(t){var e=this,n=t.store(bn.store),r=t.store(Tn.store);return n.Fr().next((function(n){return Re.forEach(n,(function(n){var i=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return r.Fr(Tn.userMutationsIndex,i).next((function(r){return Re.forEach(r,(function(r){we(r.userId===n.userId);var i=e.serializer.xh(r);return dn(t,n.userId,i).next((function(){}))}))}))}))}))},t.prototype.ensureSequenceNumbers=function(t){var e=t.store(Rn.store),n=t.store(xn.store);return t.store(kn.store).get(kn.key).next((function(t){var r=[];return n.Ur((function(n,i){var o=new b(n),s=function(t){return[0,je(t)]}(o);r.push(e.get(s).next((function(n){return n?Re.resolve():function(n){return e.put(new Rn(0,je(n),t.highestListenSequenceNumber))}(o)})))})).next((function(){return Re.vn(r)}))}
1))},t.prototype.createCollectionParentIndex=function(t,e){t.createObjectStore(Pn.store,{keyPath:Pn.keyPath});var n=e.store(Pn.store),r=new Ge,i=function(t){if(r.add(t)){var e=t.L(),i=t.$();return n.put({collectionId:e,parent:je(i)})}};return e.store(xn.store).Ur({Dh:!0},(function(t,e){var n=new b(t);return i(n.$())})).next((function(){return e.store(In.store).Ur({Dh:!0},(function(t,e){t[0];var n=t[1],r=(t[2],Be(n));return i(r.$())}))}))},t.prototype.rewriteCanonicalIds=function(t){var e=this,n=t.store(Sn.store);return n.Ur((function(t,r){var i=e.serializer.mh(r),o=e.serializer.Ph(i);return n.put(o)}))},t}(),En=function(t,e){this.seconds=t,this.nanoseconds=e},_n=function(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n};_n.store="owner",_n.key="owner";var bn=function(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n};bn.store="mutationQueues",bn.keyPath="userId";var Tn=function(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i};Tn.store="mutations",Tn.keyPath="batchId",Tn.userMutationsIndex="userMutationsIndex",Tn.userMutationsKeyPath=["userId","batchId"];var In=function(){function t(){}return t.prefixForUser=function(t){return[t]},t.prefixForPath=function(t,e){return[t,je(e)]},t.key=function(t,e,n){return[t,je(e),n]},t}();In.store="documentMutations",In.PLACEHOLDER=new In;var Nn=function(t,e){this.path=t,this.readTime=e},An=function(t,e){this.path=t,this.version=e},xn=function(t,e,n,r,i,o){this.unknownDocument=t,this.noDocument=e,this.document=n,this.hasCommittedMutations=r,this.readTime=i,this.parentPath=o};xn.store="remoteDocuments",xn.readTimeIndex="readTimeIndex",xn.readTimeIndexPath="readTime",xn.collectionReadTimeIndex="collectionReadTimeIndex",xn.collectionReadTimeIndexPath=["parentPath","readTime"];var Dn=function(t){this.byteSize=t};Dn.store="remoteDocumentGlobal",Dn.key="remoteDocumentGlobalKey";var Sn=function(t,e,n,r,i,o,s){this.targetId=t,this.canonicalId=e,this.readTime=n,this.resumeToken=r,this.lastListenSequenceNumber=i,this.lastLimboFreeSnapshotVersion=o,this.query=s};Sn.store="targets",Sn.keyPath="targetId",Sn.queryTargetsIndexName="queryTargetsIndex",Sn.queryTargetsKeyPath=["canonicalId","targetId"];var Rn=function(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n};Rn.store="targetDocuments",Rn.keyPath=["targetId","path"],Rn.documentTargetsIndex="documentTargetsIndex",Rn.documentTargetsKeyPath=["path","targetId"];var kn=function(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r};kn.key="targetGlobalKey",kn.store="targetGlobal";var Pn=function(t,e){this.collectionId=t,this.parent=e};function Vn(t){t.createObjectStore(Rn.store,{keyPath:Rn.keyPath}).createIndex(Rn.documentTargetsIndex,Rn.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(Sn.store,{keyPath:Sn.keyPath}).createIndex(Sn.queryTargetsIndexName,Sn.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(kn.store)}Pn.store="collectionParents",Pn.keyPath=["collectionId","parent"];var Ln=function(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r};Ln.store="clientMetadata",Ln.keyPath="clientId";var On=i.__spreadArrays(i.__spreadArrays(i.__spreadArrays([bn.store,Tn.store,In.store,xn.store,Sn.store,_n.store,kn.store,Rn.store],[Ln.store]),[Dn.store]),[Pn.store]),Un=function(){function t(e){this.db=e,12.2===t.oa(u.getUA())&&ve("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}return t.Zh=function(e,n,r){return ye("SimpleDb","Opening database:",e),new Re((function(i,o){var s=indexedDB.open(e,n);s.onsuccess=function(e){var n=e.target.result;i(new t(n))},s.onblocked=function(){o(new p(l.FAILED_PRECONDITION,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},s.onerror=function(t){var e=t.target.error;"VersionError"===e.name?o(new p(l.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):o(e)},s.onupgradeneeded=function(t){ye("SimpleDb",'Database "'+e+'" requires upgrade from version:',t.oldVersion);var n=t.target.result;r.createOrUpgrade(n,s.transaction,t.oldVersion,mn).next((function(){ye("SimpleDb","Database upgrade to version "+mn+" complete")}
1))}})).yn()},t.delete=function(t){return ye("SimpleDb","Removing database:",t),Bn(window.indexedDB.deleteDatabase(t)).yn()},t.zh=function(){if("undefined"==typeof indexedDB)return!1;if(t.aa())return!0;var e=u.getUA(),n=t.oa(e),r=0<n&&n<10,i=t.ua(e),o=0<i&&i<4.5;return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||r||o)},t.aa=function(){var t;return"undefined"!=typeof __PRIVATE_process&&"YES"===(null===(t=__PRIVATE_process.__PRIVATE_env)||void 0===t?void 0:t.ca)},t.Nr=function(t,e){return t.store(e)},t.oa=function(t){var e=t.match(/i(?:phone|pad|pod) os ([\d_]+)/i),n=e?e[1].split("_").slice(0,2).join("."):"-1";return Number(n)},t.ua=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},t.prototype.ao=function(t){this.db.onversionchange=function(e){return t(e)}},t.prototype.runTransaction=function(t,e,n){return i.__awaiter(this,void 0,void 0,(function(){var r,o,s,u,a;return i.__generator(this,(function(c){switch(c.label){case 0:r="readonly"===t,o=0,s=function(){var t,s,a,c,h;return i.__generator(this,(function(i){switch(i.label){case 0:++o,t=Mn.open(u.db,r?"readonly":"readwrite",e),i.label=1;case 1:return i.trys.push([1,3,,4]),s=n(t).catch((function(e){return t.abort(e),Re.reject(e)})).yn(),a={},s.catch((function(){})),[4,t._a];case 2:return[2,(a.value=(i.sent(),s),a)];case 3:return c=i.sent(),h="FirebaseError"!==c.name&&o<3,ye("SimpleDb","Transaction failed with error: %s. Retrying: %s.",c.message,h),h?[3,4]:[2,{value:Promise.reject(c)}];case 4:return[2]}}
1))},u=this,c.label=1;case 1:return[5,s()];case 2:if("object"==typeof(a=c.sent()))return[2,a.value];c.label=3;case 3:return[3,1];case 4:return[2]}}))}))},t.prototype.close=function(){this.db.close()},t}(),Cn=function(){function t(t){this.la=t,this.da=!1,this.fa=null}return Object.defineProperty(t.prototype,"Pn",{get:function(){return this.da},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"Ta",{get:function(){return this.fa},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cursor",{set:function(t){this.la=t},enumerable:!0,configurable:!0}),t.prototype.done=function(){this.da=!0},t.prototype.Qr=function(t){this.fa=t},t.prototype.delete=function(){return Bn(this.la.delete())},t}(),qn=function(t){function e(e){var n=this;return(n=t.call(this,l.UNAVAILABLE,"IndexedDB transaction failed: "+e)||this).name="IndexedDbTransactionError",n}return i.__extends(e,t),e}(p);function jn(t){return"IndexedDbTransactionError"===t.name}var Mn=function(){function t(t){var e=this;this.transaction=t,this.aborted=!1,this.Ea=new Ce,this.transaction.oncomplete=function(){e.Ea.resolve()},this.transaction.onabort=function(){t.error?e.Ea.reject(new qn(t.error)):e.Ea.resolve()},this.transaction.onerror=function(t){var n=Gn(t.target.error);e.Ea.reject(new qn(n))}}return t.open=function(e,n,r){return new t(e.transaction(r,n))},Object.defineProperty(t.prototype,"_a",{get:function(){return this.Ea.promise},enumerable:!0,configurable:!0}),t.prototype.abort=function(t){t&&this.Ea.reject(t),this.aborted||(ye("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},t.prototype.store=function(t){var e=this.transaction.objectStore(t);return new Fn(e)},t}(),Fn=function(){function t(t){this.store=t}return t.prototype.put=function(t,e){var n;return void 0!==e?(ye("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(ye("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),Bn(n)},t.prototype.add=function(t){return ye("SimpleDb","ADD",this.store.name,t,t),Bn(this.store.add(t))},t.prototype.get=function(t){var e=this;return Bn(this.store.get(t)).next((function(n){return void 0===n&&(n=null),ye("SimpleDb","GET",e.store.name,t,n),n}))},t.prototype.delete=function(t){return ye("SimpleDb","DELETE",this.store.name,t),Bn(this.store.delete(t))},t.prototype.count=function(){return ye("SimpleDb","COUNT",this.store.name),Bn(this.store.count())},t.prototype.Fr=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.Ia(n,(function(t,e){r.push(e)})).next((function(){return r}))},t.prototype.wa=function(t,e){ye("SimpleDb","DELETE ALL",this.store.name);var n=this.options(t,e);n.Dh=!1;var r=this.cursor(n);return this.Ia(r,(function(t,e,n){return n.delete()}))},t.prototype.Ur=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.Ia(r,e)},t.prototype.Wo=function(t){var e=this.cursor({});return new Re((function(n,r){e.onerror=function(t){var e=Gn(t.target.error);r(e)},e.onsuccess=function(e){var r=e.target.result;r?t(r.primaryKey,r.value).next((function(t){t?r.continue():n()})):n()}}))},t.prototype.Ia=function(t,e){var n=[];return new Re((function(r,i){t.onerror=function(t){i(t.target.error)},t.onsuccess=function(t){var i=t.target.result;if(i){var o=new Cn(i),s=e(i.primaryKey,i.value,o);if(s instanceof Re){var u=s.catch((function(t){return o.done(),Re.reject(t)}));n.push(u)}o.Pn?r():null===o.Ta?i.continue():i.continue(o.Ta)}else r()}})).next((function(){return Re.vn(n)}))},t.prototype.options=function(t,e){var n=void 0;return void 0!==t&&("string"==typeof t?n=t:e=t),{index:n,range:e}},t.prototype.cursor=function(t){var e="next";if(t.reverse&&(e="prev"),t.index){var n=this.store.index(t.index);return t.Dh?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},t}();function Bn(t){return new Re((function(e,n){t.onsuccess=function(t){var n=t.target.result;e(n)},t.onerror=function(t){var e=Gn(t.target.error);n(e)}}))}var zn=!1;function Gn(t){var e=Un.oa(u.getUA());if(e>=12.2&&e<13){var n="An internal error was encountered in the Indexed Database server";if(t.message.indexOf(n)>=0){var r=new p("internal","IOS_INDEXEDDB_BUG1: IndexedDb has thrown '"+n+"'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.");return zn||(zn=!0,setTimeout((function(){throw r}),0)),r}}return t}var Wn=function(){function t(t,e,n,r,i){this.Ra=t,this.Er=e,this.Aa=n,this.op=r,this.ma=i,this.Pa=new Ce,this.then=this.Pa.promise.then.bind(this.Pa.promise),this.Pa.promise.catch((function(t){}))}return t.Va=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.ga=setTimeout((function(){return e.pa()}),t)},t.prototype.vr=function(){return this.pa()},t.prototype.cancel=function(t){null!==this.ga&&(this.clearTimeout(),this.Pa.reject(new p(l.CANCELLED,"Operation cancelled"+(t?": "+t:"")))
1)},t.prototype.pa=function(){var t=this;this.Ra.co((function(){return null!==t.ga?(t.clearTimeout(),t.op().then((function(e){return t.Pa.resolve(e)}))):Promise.resolve()}))},t.prototype.clearTimeout=function(){null!==this.ga&&(this.ma(this),clearTimeout(this.ga),this.ga=null)},t}(),Qn=function(){function t(){var t=this;this.ya=Promise.resolve(),this.ba=Promise.resolve(),this.va=!1,this.Sa=[],this.Da=null,this.Ca=!1,this.Fa=[],this.Na=new qe(this,"async_queue_retry"),this.ka=function(){return t.Na.br()};var e=le.nt().window;e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.ka)}return Object.defineProperty(t.prototype,"Ma",{get:function(){return this.va},enumerable:!0,configurable:!0}),t.prototype.co=function(t){this.enqueue(t)},t.prototype.xa=function(t){this.$a(),this.Oa(t)},t.prototype.La=function(t){return this.$a(),this.Oa(t)},t.prototype.Ba=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e;return i.__generator(this,(function(n){switch(n.label){case 0:return this.$a(),this.va?[3,2]:(this.va=!0,(e=le.nt().window)&&e.removeEventListener("visibilitychange",this.ka),[4,this.La(t)]);case 1:n.sent(),n.label=2;case 2:return[2]}}
1))}))},t.prototype.enqueue=function(t){return this.$a(),this.va?new Promise((function(t){})):this.Oa(t)},t.prototype.lo=function(t){var e=this;this.$a(),this.va||(this.ba=this.ba.then((function(){var n=new Ce,r=function(){return i.__awaiter(e,void 0,void 0,(function(){var e;return i.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,t()];case 1:return i.sent(),n.resolve(),this.Na.reset(),[3,3];case 2:if(!jn(e=i.sent()))throw n.resolve(),e;return ye("AsyncQueue","Operation failed with retryable error: "+e),this.Na.gr(r),[3,3];case 3:return[2]}}))}))};return e.co(r),n.promise})))},t.prototype.Oa=function(t){var e=this,n=this.ya.then((function(){return e.Ca=!0,t().catch((function(t){throw e.Da=t,e.Ca=!1,ve("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.Ca=!1,t}))}));return this.ya=n,n},t.prototype.yr=function(t,e,n){var r=this;this.$a(),this.Fa.indexOf(t)>-1&&(e=0);var i=Wn.Va(this,t,e,n,(function(t){return r.qa(t)}));return this.Sa.push(i),i},t.prototype.$a=function(){this.Da&&me()},t.prototype.Ua=function(){},t.prototype.Qa=function(){return i.__awaiter(this,void 0,void 0,(function(){var t;return i.__generator(this,(function(e){switch(e.label){case 0:return[4,t=this.ya];case 1:e.sent(),e.label=2;case 2:if(t!==this.ya)return[3,0];e.label=3;case 3:return[2]}}
1))}))},t.prototype.Wa=function(t){for(var e=0,n=this.Sa;e<n.length;e++)if(n[e].Er===t)return!0;return!1},t.prototype.ja=function(t){var e=this;return this.Qa().then((function(){e.Sa.sort((function(t,e){return t.Aa-e.Aa}));for(var n=0,r=e.Sa;n<r.length;n++){var i=r[n];if(i.vr(),"all"!==t&&i.Er===t)break}return e.Qa()}))},t.prototype.Ka=function(t){this.Fa.push(t)},t.prototype.qa=function(t){var e=this.Sa.indexOf(t);this.Sa.splice(e,1)},t}();function Kn(t,e){if(ve("AsyncQueue",e+": "+t),jn(t))return new p(l.UNAVAILABLE,e+": "+t);throw t}function Yn(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],s=be(n,i);return 0===s?be(r,o):s}var Jn=function(){function t(t){this.Ga=t,this.buffer=new qt(Yn),this.za=0}return t.prototype.Ha=function(){return++this.za},t.prototype.Ya=function(t){var e=[t,this.Ha()];if(this.buffer.size<this.Ga)this.buffer=this.buffer.add(e);else{var n=this.buffer.last();Yn(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(t.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!0,configurable:!0}),t}(),Xn={Ja:!1,Xa:0,Za:0,tu:0},Hn=function(){function t(t,e,n){this.eu=t,this.su=e,this.iu=n}return t.nu=function(e){return new t(e,t.ru,t.hu)},t}();Hn.ou=-1,Hn.au=1048576,Hn.uu=41943040,Hn.ru=10,Hn.hu=1e3,Hn.cu=new Hn(Hn.uu,Hn.ru,Hn.hu),Hn.DISABLED=new Hn(Hn.ou,0,0);var $n=function(){function t(t,e){this.$o=t,this.Ra=e,this._u=!1,this.lu=null}return t.prototype.start=function(t){this.$o.du.eu!==Hn.ou&&this.fu(t)},t.prototype.stop=function(){this.lu&&(this.lu.cancel(),this.lu=null)},Object.defineProperty(t.prototype,"ho",{get:function(){return null!==this.lu},enumerable:!0,configurable:!0}),t.prototype.fu=function(t){var e=this,n=this._u?3e5:6e4;ye("LruGarbageCollector","Garbage collection scheduled in "+n+"ms"),this.lu=this.Ra.yr("lru_garbage_collection",n,(function(){return i.__awaiter(e,void 0,void 0,(function(){var e;return i.__generator(this,(function(n){switch(n.label){case 0:this.lu=null,this._u=!0,n.label=1;case 1:return n.trys.push([1,3,,7]),[4,t.Tu(this.$o)];case 2:return n.sent(),[3,7];case 3:return jn(e=n.sent())?(ye("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e),[3,6]):[3,4];case 4:return[4,nr(e)];case 5:n.sent(),n.label=6;case 6:return[3,7];case 7:return[4,this.fu(t)];case 8:return n.sent(),[2]}}))}))}))},t}(),Zn=function(){function t(t,e){this.Eu=t,this.du=e}return t.prototype.Iu=function(t,e){return this.Eu.Oo(t).next((function(t){return Math.floor(e/100*t)}))},t.prototype.wu=function(t,e){var n=this;if(0===e)return Re.resolve(Ue.dr);var r=new Jn(e);return this.Eu.js(t,(function(t){return r.Ya(t.sequenceNumber)})).next((function(){return n.Eu.Bo(t,(function(t){return r.Ya(t)}))})).next((function(){return r.maxValue}))},t.prototype.Ah=function(t,e,n){return this.Eu.Ah(t,e,n)},t.prototype.jo=function(t,e){return this.Eu.jo(t,e)},t.prototype.Ru=function(t,e){var n=this;return this.du.eu===Hn.ou?(ye("LruGarbageCollector","Garbage collection skipped; disabled"),Re.resolve(Xn)):this.Go(t).next((function(r){return r<n.du.eu?(ye("LruGarbageCollector","Garbage collection skipped; Cache size "+r+" is lower than threshold "+n.du.eu),Xn):n.Au(t,e)}))},t.prototype.Go=function(t){return this.Eu.Go(t)},t.prototype.Au=function(t,e){var n,r,i,o,u,a,c,h=this,f=Date.now();return this.Iu(t,this.du.su).next((function(e){return e>h.du.iu?(ye("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+h.du.iu+" from "+e),r=h.du.iu):r=e,o=Date.now(),h.wu(t,r)})).next((function(r){return n=r,u=Date.now(),h.Ah(t,n,e)})).next((function(e){return i=e,a=Date.now(),h.jo(t,n)})).next((function(t){return c=Date.now(),de()<=s.LogLevel.DEBUG&&ye("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(o-f)+"ms\n\tDetermined least recently used "+r+" in "+(u-o)+"ms\n\tRemoved "+i+" targets in "+(a-u)+"ms\n\tRemoved "+t+" documents in "+(c-a)+"ms\nTotal Duration: "+(c-f)+"ms"),Re.resolve({Ja:!0,Xa:r,Za:i,tu:t})}))},t}(),tr=function(){function t(t,e,n){this.persistence=t,this.mu=e,this.Pu=new Ot(be),this.Vu=new xe((function(t){return t.canonicalId()})),this.gu=E.min(),this.Wn=t.Do(n),this.pu=t.No(),this.Jh=t.Fo(),this.yu=new Le(this.pu,this.Wn,this.persistence.ko()),this.mu.bu(this.yu)}return t.prototype.start=function(){return Promise.resolve()},t.prototype.vu=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n,r,o=this;return i.__generator(this,(function(i){switch(i.label){case 0:return e=this.Wn,n=this.yu,[4,this.persistence.runTransaction("Handle user change","readonly",(function(r){var i;return o.Wn.ea(r).next((function(s){return i=s,e=o.persistence.Do(t),n=new Le(o.pu,e,o.persistence.ko()),e.ea(r)})).next((function(t){for(var e=[],o=[],s=Kt(),u=0,a=i;u<a.length;u++){var c=a[u];e.push(c.batchId);for(var h=0,f=c.mutations;h<f.length;h++){var l=f[h];
1s=s.add(l.key)}}for(var p=0,d=t;p<d.length;p++){var y=d[p];o.push(y.batchId);for(var v=0,g=y.mutations;v<g.length;v++){var m=g[v];s=s.add(m.key)}}return n.Yn(r,s).next((function(t){return{Su:t,Du:e,Cu:o}}))}))}))];case 1:return r=i.sent(),[2,(this.Wn=e,this.yu=n,this.mu.bu(this.yu),r)]}}))}))},t.prototype.Fu=function(t){var e,n=this,r=w.now(),i=t.reduce((function(t,e){return t.add(e.key)}),Kt());return this.persistence.runTransaction("Locally write mutations","readwrite",(function(o){return n.yu.Yn(o,i).next((function(i){e=i;for(var s=[],u=0,a=t;u<a.length;u++){var c=a[u],h=c.Pt(e.get(c.key));null!=h&&s.push(new at(c.key,h,dt(h.proto.mapValue),ot.exists(!0)))}return n.Wn.Yo(o,r,s,t)}))})).then((function(t){var n=t.In(e);return{batchId:t.batchId,Dn:n}}))},t.prototype.Nu=function(t){var e=this;return this.persistence.runTransaction("Acknowledge batch","readwrite-primary",(function(n){var r=t.batch.keys(),i=e.pu.Yr({Xr:!0});return e.ku(n,t,i).next((function(){return i.apply(n)})).next((function(){return e.Wn.ra(n)})).next((function(){return e.yu.Yn(n,r)}))}))},t.prototype.Mu=function(t){var e=this;return this.persistence.runTransaction("Reject batch","readwrite-primary",(function(n){var r;return e.Wn.Jo(n,t).next((function(t){return we(null!==t),r=t.keys(),e.Wn.ia(n,t)})).next((function(){return e.Wn.ra(n)})).next((function(){return e.yu.Yn(n,r)}))}))},t.prototype.ta=function(){var t=this;return this.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(function(e){return t.Wn.ta(e)}))},t.prototype._h=function(){var t=this;return this.persistence.runTransaction("Get last remote snapshot version","readonly",(function(e){return t.Jh._h(e)}))},t.prototype.xu=function(e){var n=this,r=e.Ee,i=this.Pu;return this.persistence.runTransaction("Apply remote event","readwrite-primary",(function(o){var s=n.pu.Yr({Xr:!0});i=n.Pu;var u=[];e.as.forEach((function(e,s){var a=i.get(s);if(a){u.push(n.Jh.bh(o,e.Is,s).next((function(){return n.Jh.ph(o,e.Ts,s)})));var c=e.resumeToken;if(c.rt()>0){var h=a.we(c,r).Ie(o.Oh);i=i.Ae(s,h),t.$u(a,h,e)&&u.push(n.Jh.Ih(o,h))}}}));var a=Ft(),c=Kt();if(e.cs.forEach((function(t,e){c=c.add(t)})),u.push(s.getEntries(o,c).next((function(t){e.cs.forEach((function(i,c){var h=t.get(i);c instanceof wt&&c.version.isEqual(E.min())?(s.Mn(i,r),a=a.Ae(i,c)):null==h||c.version.S(h.version)>0||0===c.version.S(h.version)&&h.hasPendingWrites?(s.Nn(c,r),a=a.Ae(i,c)):ye("LocalStore","Ignoring outdated watch update for ",i,". Current version:",h.version," Watch version:",c.version),e._s.has(i)&&u.push(n.persistence.hh.Ko(o,i))}))}))),!r.isEqual(E.min())){var h=n.Jh._h(o).next((function(t){return n.Jh.dh(o,o.Oh,r)}));u.push(h)}return Re.vn(u).next((function(){return s.apply(o)})).next((function(){return n.yu.Jn(o,a)}))})).then((function(t){return n.Pu=i,t}))},t.$u=function(t,e,n){return we(e.resumeToken.rt()>0),0===t.resumeToken.rt()||e.Ee.D()-t.Ee.D()>=this.Ou||n.Ts.size+n.Es.size+n.Is.size>0},t.prototype.Lu=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n,r,o,s,u,a,c,h=this;return i.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.persistence.runTransaction("notifyLocalViewChanges","readwrite",(function(e){return Re.forEach(t,(function(t){return Re.forEach(t.hr,(function(n){return h.persistence.hh.yh(e,t.targetId,n)})).next((function(){return Re.forEach(t.or,(function(n){return h.persistence.hh.vh(e,t.targetId,n)}))}))}))}))];case 1:return i.sent(),[3,3];case 2:if(!jn(e=i.sent()))throw e;return ye("LocalStore","Failed to update sequence numbers: "+e),[3,3];case 3:for(n=0,r=t;n<r.length;n++)o=r[n],s=o.targetId,o.fromCache||(u=this.Pu.get(s),a=u.Ee,c=u.Re(a),this.Pu=this.Pu.Ae(s,c));return[2]}}))}))},t.prototype.Bu=function(t){var e=this;return this.persistence.runTransaction("Get next mutation batch","readonly",(function(n){return void 0===t&&(t=-1),e.Wn.Zo(n,t)}))},t.prototype.qu=function(t){var e=this;return this.persistence.runTransaction("read document","readonly",(function(n){return e.yu.Kn(n,t)}))},t.prototype.Uu=function(t){var e=this;return this.persistence.runTransaction("Allocate target","readwrite",(function(n){var r;return e.Jh.gh(n,t).next((function(i){return i?(r=i,Re.resolve(r)):e.Jh.oh(n).next((function(i){return r=new kt(t,i,0,n.Oh),e.Jh.fh(n,r).next((function(){return r}))}))}))})).then((function(n){var r=e.Pu.get(n.targetId);return(null===r||n.Ee.S(r.Ee)>0)&&(e.Pu=e.Pu.Ae(n.targetId,n),e.Vu.set(t,n.targetId)),n}))},t.prototype.gh=function(t,e){var n=this.Vu.get(e);return void 0!==n?Re.resolve(this.Pu.get(n)):this.Jh.gh(t,e)},t.prototype.Qu=function(t,e){var n=this,r=this.Pu.get(t),i=e?"readwrite":"readwrite-primary";return this.persistence.runTransaction("Release target",i,(function(t){return e?Re.resolve():n.persistence.hh.removeTarget(t,r)})).then((function(){n.Pu=n.Pu.remove(t),n.Vu.delete(r.target)}))},t.prototype.Wu=function(t,e){var n=this,r=E.min(),i=Kt();
1return this.persistence.runTransaction("Execute query","readonly",(function(o){return n.gh(o,t.ee()).next((function(t){if(t)return r=t.lastLimboFreeSnapshotVersion,n.Jh.Sh(o,t.targetId).next((function(t){i=t}))})).next((function(){return n.mu.Zn(o,t,e?r:E.min(),e?i:Kt())})).next((function(t){return{documents:t,ju:i}}))}))},t.prototype.ku=function(t,e,n){var r=this,i=e.batch,o=i.keys(),s=Re.resolve();return o.forEach((function(r){s=s.next((function(){return n.xn(t,r)})).next((function(t){var o=t,s=e.Rn.get(r);we(null!==s),(!o||o.version.S(s)<0)&&(o=i.at(r,o,e))&&n.Nn(o,e.wn)}))})),s.next((function(){return r.Wn.ia(t,i)}))},t.prototype.Tu=function(t){var e=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",(function(n){return t.Ru(n,e.Pu)}))},t}();tr.Ou=3e8;var er=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n,r)||this).persistence=e,i.Wn=e.Do(r),i.pu=e.No(),i.Jh=e.Fo(),i}return i.__extends(e,t),e.prototype.start=function(){return this.Ku()},e.prototype.Gu=function(t){var e=this;return this.persistence.runTransaction("Lookup mutation documents","readonly",(function(n){return e.Wn.Xo(n,t).next((function(t){return t?e.yu.Yn(n,t):Re.resolve(null)}))}))},e.prototype.zu=function(t){this.Wn.na(t)},e.prototype.uo=function(t){this.persistence.uo(t)},e.prototype.So=function(){return this.persistence.So()},e.prototype.Hu=function(t){var e=this,n=this.Pu.get(t);return n?Promise.resolve(n.target):this.persistence.runTransaction("Get target data","readonly",(function(n){return e.Jh.si(n,t).next((function(t){return t?t.target:null}))}))},e.prototype.Kr=function(){var t=this;return this.persistence.runTransaction("Get new document changes","readonly",(function(e){return t.pu.Kr(e,t.gu)})).then((function(e){var n=e.Gr,r=e.readTime;return t.gu=r,n}))},e.prototype.Ku=function(){return i.__awaiter(this,void 0,void 0,(function(){var t,e=this;return i.__generator(this,(function(n){switch(n.label){case 0:return t=this,[4,this.persistence.runTransaction("Synchronize last document change read time","readonly",(function(t){return e.pu.Hr(t)}))];case 1:return t.gu=n.sent(),[2]}}))}))},e}(tr);function nr(t){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(e){if(t.code!==l.FAILED_PRECONDITION||t.message!==Pe)throw t;return ye("LocalStore","Unexpectedly lost primary lease"),[2]}))}))}var rr=function(){function t(){this.Yu=new qt(ir.Ju),this.Xu=new qt(ir.Zu)}return t.prototype.B=function(){return this.Yu.B()},t.prototype.yh=function(t,e){var n=new ir(t,e);this.Yu=this.Yu.add(n),this.Xu=this.Xu.add(n)},t.prototype.tc=function(t,e){var n=this;t.forEach((function(t){return n.yh(t,e)}))},t.prototype.vh=function(t,e){this.ec(new ir(t,e))},t.prototype.sc=function(t,e){var n=this;t.forEach((function(t){return n.vh(t,e)}))},t.prototype.ic=function(t){var e=this,n=N.EMPTY,r=new ir(n,t),i=new ir(n,t+1),o=[];return this.Xu.Ke([r,i],(function(t){e.ec(t),o.push(t.key)})),o},t.prototype.nc=function(){var t=this;this.Yu.forEach((function(e){return t.ec(e)}))},t.prototype.ec=function(t){this.Yu=this.Yu.delete(t),this.Xu=this.Xu.delete(t)},t.prototype.rc=function(t){var e=N.EMPTY,n=new ir(e,t),r=new ir(e,t+1),i=Kt();return this.Xu.Ke([n,r],(function(t){i=i.add(t.key)})),i},t.prototype.Ch=function(t){var e=new ir(t,0),n=this.Yu.ze(e);return null!==n&&t.isEqual(n.key)},t}(),ir=function(){function t(t,e){this.key=t,this.hc=e}return t.Ju=function(t,e){return N.N(t.key,e.key)||be(t.hc,e.hc)},t.Zu=function(t,e){return be(t.hc,e.hc)||N.N(t.key,e.key)},t}();function or(t,e){if(0!==e.length)throw new p(l.INVALID_ARGUMENT,"Function "+t+"() does not support arguments, but was called with "+Tr(e.length,"argument")+".")}function sr(t,e,n){if(e.length!==n)throw new p(l.INVALID_ARGUMENT,"Function "+t+"() requires "+Tr(n,"argument")+", but was called with "+Tr(e.length,"argument")+".")}function ur(t,e,n){if(e.length<n)throw new p(l.INVALID_ARGUMENT,"Function "+t+"() requires at least "+Tr(n,"argument")+", but was called with "+Tr(e.length,"argument")+".")}function ar(t,e,n,r){if(e.length<n||e.length>r)throw new p(l.INVALID_ARGUMENT,"Function "+t+"() requires between "+n+" and "+r+" arguments, but was called with "+Tr(e.length,"argument")+".")}
1function cr(t,e,n,r){yr(t,e,br(n)+" argument",r)}function hr(t,e,n,r){void 0!==r&&cr(t,e,n,r)}function fr(t,e,n,r){yr(t,e,n+" option",r)}function lr(t,e,n,r){void 0!==r&&fr(t,e,n,r)}function pr(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(gr(a))}var c=gr(r);throw new p(l.INVALID_ARGUMENT,"Invalid value "+c+" provided to function "+t+'() for option "'+n+'". Acceptable values: '+o.join(", "))}(t,0,n,r,i)}function dr(t,e,n,r){if(!e.some((function(t){return t===r})))throw new p(l.INVALID_ARGUMENT,"Invalid value "+gr(r)+" provided to function "+t+"() for its "+br(n)+" argument. Acceptable values: "+e.join(", "));return r}function yr(t,e,n,r){if(!("object"===e?vr(r):"non-empty string"===e?"string"==typeof r&&""!==r:typeof r===e)){var i=gr(r);throw new p(l.INVALID_ARGUMENT,"Function "+t+"() requires its "+n+" to be of type "+e+", but it was: "+i)}}function vr(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}function gr(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":me()}function mr(t,e,n){if(void 0===n)throw new p(l.INVALID_ARGUMENT,"Function "+t+"() requires a valid "+br(e)+" argument, but it was undefined.")}function wr(t,e,n){x(e,(function(e,r){if(n.indexOf(e)<0)throw new p(l.INVALID_ARGUMENT,"Unknown option '"+e+"' passed to function "+t+"(). Available options: "+n.join(", "))}))}function Er(t,e,n,r){var i=gr(r);return new p(l.INVALID_ARGUMENT,"Function "+t+"() requires its "+br(n)+" argument to be a "+e+", but it was: "+i)}function _r(t,e,n){if(n<=0)throw new p(l.INVALID_ARGUMENT,"Function "+t+"() requires its "+br(e)+" argument to be a positive number, but it was: "+n+".")}function br(t){switch(t){case 1:return"first";
1case 2:return"second";case 3:return"third";default:return t+"th"}}function Tr(t,e){return t+" "+e+(1===t?"":"s")}function Ir(){if("undefined"==typeof Uint8Array)throw new p(l.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function Nr(){if(!le.nt().oc)throw new p(l.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var Ar=function(){function t(t){Nr(),this.ac=t}return t.fromBase64String=function(e){sr("Blob.fromBase64String",arguments,1),cr("Blob.fromBase64String","string",1,e),Nr();try{return new t(S.fromBase64String(e))}catch(e){throw new p(l.INVALID_ARGUMENT,"Failed to construct Blob from Base64 string: "+e)}},t.fromUint8Array=function(e){if(sr("Blob.fromUint8Array",arguments,1),Ir(),!(e instanceof Uint8Array))throw Er("Blob.fromUint8Array","Uint8Array",1,e);return new t(S.fromUint8Array(e))},t.prototype.toBase64=function(){return sr("Blob.toBase64",arguments,0),Nr(),this.ac.toBase64()},t.prototype.toUint8Array=function(){return sr("Blob.toUint8Array",arguments,0),Ir(),this.ac.toUint8Array()},t.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},t.prototype.isEqual=function(t){return this.ac.isEqual(t.ac)},t}(),xr=function(t){!function(t,e,n,r){if(!(e instanceof Array)||e.length<1)throw new p(l.INVALID_ARGUMENT,"Function FieldPath() requires its fieldNames argument to be an array with at least "+Tr(1,"element")+".")}(0,t);for(var e=0;e<t.length;++e)if(cr("FieldPath","string",e,t[e]),0===t[e].length)throw new p(l.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this.uc=new I(t)},Dr=function(t){function e(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return t.call(this,e)||this}return i.__extends(e,t),e.documentId=function(){return e.cc},e.prototype.isEqual=function(t){if(!(t instanceof e))throw Er("isEqual","FieldPath",1,t);return this.uc.isEqual(t.uc)},e}(xr);Dr.cc=new Dr(I.J().j());var Sr=new RegExp("[~\\*/\\[\\]]"),Rr=function(){this._c=this},kr=function(t){function e(e){var n=this;return(n=t.call(this)||this).lc=e,n}return i.__extends(e,t),e.prototype.dc=function(t){if(2!==t.fc)throw 1===t.fc?t.Tc(this.lc+"() can only appear at the top level of your update data"):t.Tc(this.lc+"() cannot be used with set() unless you pass {merge:true}");return t.Vt.push(t.path),null},e.prototype.isEqual=function(t){return t instanceof e},e}(Rr),Pr=function(t){function e(e){var n=this;return(n=t.call(this)||this).lc=e,n}return i.__extends(e,t),e.prototype.dc=function(t){return new rt(t.path,H.instance)},e.prototype.isEqual=function(t){return t instanceof e},e}(Rr),Vr=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).lc=e,r.Ec=n,r}return i.__extends(e,t),e.prototype.dc=function(t){var e=new Gr({fc:3,methodName:this.lc,Ic:!0},t.ii,t.serializer,t.ignoreUndefinedProperties),n=this.Ec.map((function(t){return Qr(t,e)})),r=new $(n);return new rt(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(Rr),Lr=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).lc=e,r.Ec=n,r}return i.__extends(e,t),e.prototype.dc=function(t){var e=new Gr({fc:3,methodName:this.lc,Ic:!0},t.ii,t.serializer,t.ignoreUndefinedProperties),n=this.Ec.map((function(t){return Qr(t,e)})),r=new Z(n);return new rt(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(Rr),Or=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).lc=e,r.wc=n,r}return i.__extends(e,t),e.prototype.dc=function(t){var e=new Gr({fc:3,methodName:this.lc},t.ii,t.serializer,t.ignoreUndefinedProperties),n=Qr(this.wc,e),r=new tt(t.serializer,n);return new rt(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(Rr),Ur=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.delete=function(){return or("FieldValue.delete",arguments),new Cr(new kr("FieldValue.delete"))},e.serverTimestamp=function(){return or("FieldValue.serverTimestamp",arguments),new Cr(new Pr("FieldValue.serverTimestamp"))},e.arrayUnion=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];
1return ur("FieldValue.arrayUnion",arguments,1),new Cr(new Vr("FieldValue.arrayUnion",t))},e.arrayRemove=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return ur("FieldValue.arrayRemove",arguments,1),new Cr(new Lr("FieldValue.arrayRemove",t))},e.increment=function(t){return cr("FieldValue.increment","number",1,t),sr("FieldValue.increment",arguments,1),new Cr(new Or("FieldValue.increment",t))},e}(Rr),Cr=function(t){function e(e){var n=this;return(n=t.call(this)||this)._c=e,n.lc=e.lc,n}return i.__extends(e,t),e.prototype.dc=function(t){return this._c.dc(t)},e.prototype.isEqual=function(t){return t instanceof e&&this._c.isEqual(t._c)},e}(Ur),qr=function(){function t(t,e){if(sr("GeoPoint",arguments,2),cr("GeoPoint","number",1,t),cr("GeoPoint","number",2,e),!isFinite(t)||t<-90||t>90)throw new p(l.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new p(l.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this.Rc=t,this.Ac=e}return Object.defineProperty(t.prototype,"latitude",{get:function(){return this.Rc},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"longitude",{get:function(){return this.Ac},enumerable:!0,configurable:!0}),t.prototype.isEqual=function(t){return this.Rc===t.Rc&&this.Ac===t.Ac},t.prototype.p=function(t){return be(this.Rc,t.Rc)||be(this.Ac,t.Ac)},t}(),jr=/^__.*__$/,Mr=function(t,e,n){this.mc=t,this.Pc=e,this.Vc=n},Fr=function(){function t(t,e,n){this.data=t,this.Vt=e,this.fieldTransforms=n}return t.prototype.gc=function(t,e){var n=[];return null!==this.Vt?n.push(new at(t,this.data,this.Vt,e)):n.push(new ut(t,this.data,e)),this.fieldTransforms.length>0&&n.push(new ct(t,this.fieldTransforms)),n},t}(),Br=function(){function t(t,e,n){this.data=t,this.Vt=e,this.fieldTransforms=n}return t.prototype.gc=function(t,e){var n=[new at(t,this.data,this.Vt,e)];return this.fieldTransforms.length>0&&n.push(new ct(t,this.fieldTransforms)),n},t}();function zr(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw me()}}var Gr=function(){function t(t,e,n,r,i,o){this.settings=t,this.ii=e,this.serializer=n,this.ignoreUndefinedProperties=r,void 0===i&&this.pc(),this.fieldTransforms=i||[],this.Vt=o||[]}return Object.defineProperty(t.prototype,"path",{get:function(){return this.settings.path},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fc",{get:function(){return this.settings.fc},enumerable:!0,configurable:!0}),t.prototype.yc=function(e){return new t(Object.assign(Object.assign({},this.settings),e),this.ii,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.Vt)},t.prototype.bc=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.yc({path:n,Ic:!1});return r.vc(t),r},t.prototype.Sc=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.yc({path:n,Ic:!1});return r.pc(),r},t.prototype.Dc=function(t){return this.yc({path:void 0,Ic:!0})},t.prototype.Tc=function(t){var e=!this.path||this.path.B()?"":" (found in field "+this.path.toString()+")";return new p(l.INVALID_ARGUMENT,"Function "+this.settings.methodName+"() called with invalid data. "+t+e)},t.prototype.contains=function(t){return void 0!==this.Vt.find((function(e){return t.q(e)}))||void 0!==this.fieldTransforms.find((function(e){return t.q(e.field)}))},t.prototype.pc=function(){if(this.path)for(var t=0;t<this.path.length;t++)this.vc(this.path.get(t))},t.prototype.vc=function(t){if(0===t.length)throw this.Tc("Document fields must not be empty");if(zr(this.fc)&&jr.test(t))throw this.Tc('Document fields cannot begin and end with "__"')},t}(),Wr=function(){function t(t,e,n){this.ii=t,this.ignoreUndefinedProperties=e,this.serializer=n||le.nt().Cc(t)}return t.prototype.Fc=function(t,e,n){void 0===n&&(n={});var r=this.Nc(n.merge||n.mergeFields?2:0,t);Jr("Data must be an object, but it was:",r,e);var i,o,s=Kr(e,r);if(n.merge)i=new nt(r.Vt),o=r.fieldTransforms;else if(n.mergeFields){for(var u=[],a=0,c=n.mergeFields;a<c.length;a++){var h=c[a],f=void 0;if(h instanceof xr)f=h.uc;else{if("string"!=typeof h)throw me();f=Hr(t,h)}if(!r.contains(f))throw new p(l.INVALID_ARGUMENT,"Field '"+f+"' is specified in your field mask but missing from your input data.");$r(u,f)||u.push(f)}i=new nt(u),o=r.fieldTransforms.filter((function(t){return i.dt(t.field)}))}else i=null,o=r.fieldTransforms;return new Fr(new lt(s),i,o)},t.prototype.kc=function(t,e){var n=this.Nc(1,t);Jr("Data must be an object, but it was:",n,e);var r=[],i=new pt;x(e,(function(e,o){var s=Hr(t,e),u=n.Sc(s);if(o instanceof Rr&&o._c instanceof kr)r.push(s);else{var a=Qr(o,u);null!=a&&(r.push(s),i.set(s,a))}}));var o=new nt(r);return new Br(i.yt(),o,n.fieldTransforms)},t.prototype.Mc=function(t,e,n,r){var i=this.Nc(1,t),o=[Xr(t,e)],s=[n];if(r.length%2!=0)throw new p(l.INVALID_ARGUMENT,"Function "+t+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var u=0;u<r.length;u+=2)o.push(Xr(t,r[u])),s.push(r[u+1]);for(var a=[],c=new pt,h=o.length-1;h>=0;--h)if(!$r(a,o[h])){var f=o[h],d=s[h],y=i.Sc(f);if(d instanceof Rr&&d._c instanceof kr)a.push(f);else{var v=Qr(d,y);null!=v&&(a.push(f),c.set(f,v))}}var g=new nt(a);return new Br(c.yt(),g,i.fieldTransforms)},t.prototype.Nc=function(t,e){return new Gr({fc:t,methodName:e,path:I.G,Ic:!1},this.ii,this.serializer,this.ignoreUndefinedProperties)},t.prototype.xc=function(t,e,n){return void 0===n&&(n=!1),Qr(e,this.Nc(n?4:3,t))},t}();function Qr(t,e){if(Yr(t))return Jr("Unsupported field value:",e,t),Kr(t,e);if(t instanceof Rr)return function(t,e){if(!zr(e.fc))throw e.Tc(t.lc+"() can only be used with update(
1) and set()");if(!e.path)throw e.Tc(t.lc+"() is not currently supported inside arrays");var n=t.dc(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(e.path&&e.Vt.push(e.path),t instanceof Array){if(e.settings.Ic&&4!==e.fc)throw e.Tc("Nested arrays are not supported");return function(t,e){for(var n=[],r=0,i=0,o=t;i<o.length;i++){var s=Qr(o[i],e.Dc(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 e.serializer.ai(t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){var n=w.fromDate(t);return{timestampValue:e.serializer.C(n)}}if(t instanceof w){var r=new w(t.seconds,1e3*Math.floor(t.nanoseconds/1e3));return{timestampValue:e.serializer.C(r)}}if(t instanceof qr)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof Ar)return{bytesValue:e.serializer.ui(t)};if(t instanceof Mr){var i=e.ii,o=t.mc;if(!o.isEqual(i))throw e.Tc("Document reference is for database "+o.projectId+"/"+o.database+" but should be for database "+i.projectId+"/"+i.database);return{referenceValue:e.serializer._i(t.Pc.path,t.mc)}}if(void 0===t&&e.ignoreUndefinedProperties)return null;throw e.Tc("Unsupported field value: "+gr(t))}(t,e)}function Kr(t,e){var n={};return D(t)?e.path&&e.path.length>0&&e.Vt.push(e.path):x(t,(function(t,r){var i=Qr(r,e.bc(t));null!=i&&(n[t]=i)})),{mapValue:{fields:n}}}function Yr(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof w||t instanceof qr||t instanceof Ar||t instanceof Mr||t instanceof Rr)}function Jr(t,e,n){if(!Yr(n)||!vr(n)){var r=gr(n);throw"an object"===r?e.Tc(t+" a custom object"):e.Tc(t+" "+r)}}function Xr(t,e){if(e instanceof xr)return e.uc;if("string"==typeof e)return Hr(t,e);throw new p(l.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. Field path arguments must be of type string or FieldPath.")}function Hr(t,e){try{return function(t){if(t.search(Sr)>=0)throw new p(l.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not contain '~', '*', '/', '[', or ']'");try{return new(Dr.bind.apply(Dr,i.__spreadArrays([void 0],t.split("."))))}catch(i){throw new p(l.INVALID_ARGUMENT,"Invalid field path ("+t+"). Paths must not be empty, begin with '.', end with '.', or contain '..'")}}(e).uc}catch(e){var n=(r=e)instanceof Error?r.message:r.toString();throw new p(l.INVALID_ARGUMENT,"Function "+t+"() called with invalid data. "+n)}var r}function $r(t,e){return t.some((function(t){return t.isEqual(e)}))}var Zr=function(){function t(t,e,n,r,i,o){this.Tr=t,this.$c=n,this.Oc=r,this.Lc=i,this.listener=o,this.state=0,this.Bc=0,this.qc=null,this.stream=null,this.Na=new qe(t,e)}return t.prototype.Uc=function(){return 1===this.state||2===this.state||4===this.state},t.prototype.Qc=function(){return 2===this.state},t.prototype.start=function(){3!==this.state?this.auth():this.Wc()},t.prototype.stop=function(){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return this.Uc()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}
1))}))},t.prototype.jc=function(){this.state=0,this.Na.reset()},t.prototype.Kc=function(){var t=this;this.Qc()&&null===this.qc&&(this.qc=this.Tr.yr(this.$c,6e4,(function(){return t.Gc()})))},t.prototype.zc=function(t){this.Hc(),this.stream.send(t)},t.prototype.Gc=function(){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(t){return this.Qc()?[2,this.close(0)]:[2]}))}))},t.prototype.Hc=function(){this.qc&&(this.qc.cancel(),this.qc=null)},t.prototype.close=function(t,e){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(n){switch(n.label){case 0:return this.Hc(),this.Na.cancel(),this.Bc++,3!==t?this.Na.reset():e&&e.code===l.RESOURCE_EXHAUSTED?(ve(e.toString()),ve("Using maximum backoff delay to prevent overloading the backend."),this.Na.Vr()):e&&e.code===l.UNAUTHENTICATED&&this.Lc._(),null!==this.stream&&(this.Yc(),this.stream.close(),this.stream=null),this.state=t,[4,this.listener.Jc(e)];case 1:return n.sent(),[2]}}))}))},t.prototype.Yc=function(){},t.prototype.auth=function(){var t=this;this.state=1;var e=this.Xc(this.Bc),n=this.Bc;this.Lc.getToken().then((function(e){t.Bc===n&&t.Zc(e)}),(function(n){e((function(){var e=new p(l.UNKNOWN,"Fetching auth token failed: "+n.message);return t.t_(e)}))}))},t.prototype.Zc=function(t){var e=this,n=this.Xc(this.Bc);this.stream=this.e_(t),this.stream.s_((function(){n((function(){return e.state=2,e.listener.s_()}))})),this.stream.Jc((function(t){n((function(){return e.t_(t)}))})),this.stream.onMessage((function(t){n((function(){return e.onMessage(t)}))}))},t.prototype.Wc=function(){var t=this;this.state=4,this.Na.gr((function(){return i.__awaiter(t,void 0,void 0,(function(){return i.__generator(this,(function(t){return this.state=0,this.start(),[2]}))}))}))},t.prototype.t_=function(t){return ye("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},t.prototype.Xc=function(t){var e=this;return function(n){e.Tr.co((function(){return e.Bc===t?n():(ye("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())}))}},t}(),ti=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 i.__extends(e,t),e.prototype.e_=function(t){return this.Oc.i_("Listen",t)},e.prototype.onMessage=function(t){this.Na.reset();var e=this.serializer.pi(t),n=this.serializer.bi(t);return this.listener.n_(e,n)},e.prototype.r_=function(t){var e={};e.database=this.serializer.wi,e.addTarget=this.serializer.ee(t);var n=this.serializer.zi(t);n&&(e.labels=n),this.zc(e)},e.prototype.h_=function(t){var e={};e.database=this.serializer.wi,e.removeTarget=t,this.zc(e)},e}(Zr),ei=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.o_=!1,s.lastStreamToken=S.ht,s}return i.__extends(e,t),Object.defineProperty(e.prototype,"a_",{get:function(){return this.o_},enumerable:!0,configurable:!0}),e.prototype.start=function(){this.o_=!1,this.lastStreamToken=S.ht,t.prototype.start.call(this)},e.prototype.Yc=function(){this.o_&&this.u_([])},e.prototype.e_=function(t){return this.Oc.i_("Write",t)},e.prototype.onMessage=function(t){if(we(!!t.streamToken),this.lastStreamToken=this.serializer.ci(t.streamToken),this.o_){this.Na.reset();var e=this.serializer.$i(t.writeResults,t.commitTime),n=this.serializer.fromVersion(t.commitTime);return this.listener.c_(n,e)}return we(!t.writeResults||0===t.writeResults.length),this.o_=!0,this.listener.__()},e.prototype.l_=function(){var t={};t.database=this.serializer.wi,this.zc(t)},e.prototype.u_=function(t){var e=this,n={streamToken:this.serializer.ui(this.lastStreamToken),writes:t.map((function(t){return e.serializer.vi(t)}))};this.zc(n)},e}(Zr),ni=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).Oc=e,i.credentials=n,i.serializer=r,i.f_=!1,i}return i.__extends(e,t),e.prototype.T_=function(){if(this.f_)throw new p(l.FAILED_PRECONDITION,"The client has already been terminated.")},e.prototype.E_=function(t,e){var n=this;return this.T_(),this.credentials.getToken().then((function(r){return n.Oc.E_(t,e,r)})).catch((function(t){throw t.code===l.UNAUTHENTICATED&&n.credentials._(),t}))},e.prototype.I_=function(t,e){var n=this;return this.T_(),this.credentials.getToken().then((function(r){return n.Oc.I_(t,e,r)})).catch((function(t){throw t.code===l.UNAUTHENTICATED&&n.credentials._(),t}))},e}((function(){this.d_=void 0})),ri=function(){function t(t){this.w_=t,this.R_=new Map,this.mutations=[],this.A_=!1,this.m_=null,this.P_=new Set}return t.prototype.V_=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n=this;return i.__generator(this,(function(r){switch(r.label){case 0:if(this.g_(),this.mutations.length>0)throw new p(l.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,function(t,e){return i.__awaiter(this,void 0,void 0,(function(){var n,r,o,s,u;return i.__generator(this,(function(i){switch(i.label){case 0:return n=Ee(t),r={database:n.seri
1alizer.wi,documents:e.map((function(t){return n.serializer.fi(t)}))},[4,n.I_("BatchGetDocuments",r)];case 1:return o=i.sent(),s=new Map,o.forEach((function(t){var e=n.serializer.gi(t);s.set(e.key.toString(),e)})),u=[],[2,(e.forEach((function(t){var e=s.get(t.toString());we(!!e),u.push(e)})),u)]}}))}))}(this.w_,t)];case 1:return[2,((e=r.sent()).forEach((function(t){t instanceof wt||t instanceof mt?n.p_(t):me()})),e)]}}))}))},t.prototype.set=function(t,e){this.write(e.gc(t,this.Rt(t))),this.P_.add(t)},t.prototype.update=function(t,e){try{this.write(e.gc(t,this.y_(t)))}catch(t){this.m_=t}this.P_.add(t)},t.prototype.delete=function(t){this.write([new ht(t,this.Rt(t))]),this.P_.add(t)},t.prototype.commit=function(){return i.__awaiter(this,void 0,void 0,(function(){var t,e=this;return i.__generator(this,(function(n){switch(n.label){case 0:if(this.g_(),this.m_)throw this.m_;return t=this.R_,this.mutations.forEach((function(e){t.delete(e.key.toString())})),t.forEach((function(t,n){var r=new N(b.K(n));e.mutations.push(new ft(r,e.Rt(r)))})),[4,function(t,e){return i.__awaiter(this,void 0,void 0,(function(){var n,r;return i.__generator(this,(function(i){switch(i.label){case 0:return n=Ee(t),r={database:n.seri
1alizer.wi,writes:e.map((function(t){return n.serializer.vi(t)}))},[4,n.E_("Commit",r)];case 1:return i.sent(),[2]}}))}))}(this.w_,this.mutations)];case 1:return n.sent(),this.A_=!0,[2]}}))}))},t.prototype.p_=function(t){var e;if(t instanceof mt)e=t.version;else{if(!(t instanceof wt))throw me();e=E.min()}var n=this.R_.get(t.key.toString());if(n){if(!e.isEqual(n))throw new p(l.ABORTED,"Document version changed between two reads.")}else this.R_.set(t.key.toString(),e)},t.prototype.Rt=function(t){var e=this.R_.get(t.toString());return!this.P_.has(t)&&e?ot.updateTime(e):ot.ft()},t.prototype.y_=function(t){var e=this.R_.get(t.toString());if(!this.P_.has(t)&&e){if(e.isEqual(E.min()))throw new p(l.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return ot.updateTime(e)}return ot.exists(!0)},t.prototype.write=function(t){this.g_(),this.mutations=this.mutations.concat(t)},t.prototype.g_=function(){},t}(),ii=function(){function t(t,e){this.Ra=t,this.b_=e,this.state="Unknown",this.v_=0,this.S_=null,this.D_=!0}return t.prototype.C_=function(){var t=this;0===this.v_&&(this.F_("Unknown"),this.S_=this.Ra.yr("online_state_timeout",1e4,(function(){return t.S_=null,t.N_("Backend didn't respond within 10 seconds."),t.F_("Offline"),Promise.resolve()})))},t.prototype.k_=function(t){"Online"===this.state?this.F_("Unknown"):(this.v_++,this.v_>=1&&(this.M_(),this.N_("Connection failed 1 times. Most recent error: "+t.toString()),this.F_("Offline")))},t.prototype.set=function(t){this.M_(),this.v_=0,"Online"===t&&(this.D_=!1),this.F_(t)},t.prototype.F_=function(t){t!==this.state&&(this.state=t,this.b_(t))},t.prototype.N_=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.D_?(ve(e),this.D_=!1):ye("OnlineStateTracker",e)},t.prototype.M_=function(){null!==this.S_&&(this.S_.cancel(),this.S_=null)},t}(),oi=function(){function t(t,e,n,r,o){var s=this;this.x_=t,this.w_=e,this.Ra=n,this.O_=[],this.L_=new Map,this.B_=null,this.networkEnabled=!1,this.isPrimary=!1,this.q_=!1,this.U_=o,this.U_.Q_((function(t){n.co((function(){return i.__awaiter(s,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return this.W_()?(ye("RemoteStore","Restarting streams for network reachability change."),[4,this.j_()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}
1))}))}))})),this.K_=new ii(n,r),this.G_=function(t,e,n){var r=Ee(t);return new ti(e,r.Oc,r.credentials,r.serializer,n)}(this.w_,n,{s_:this.z_.bind(this),Jc:this.H_.bind(this),n_:this.Y_.bind(this)}),this.J_=function(t,e,n){var r=Ee(t);return new ei(e,r.Oc,r.credentials,r.serializer,n)}(this.w_,n,{s_:this.X_.bind(this),Jc:this.Z_.bind(this),__:this.tl.bind(this),c_:this.c_.bind(this)})}return t.prototype.start=function(){return this.enableNetwork()},t.prototype.enableNetwork=function(){return this.networkEnabled=!0,this.el()},t.prototype.el=function(){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return this.W_()?(this.sl()?this.il():this.K_.set("Unknown"),[4,this.nl()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.disableNetwork=function(){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.rl()];case 1:return t.sent(),this.K_.set("Offline"),[2]}}))}))},t.prototype.rl=function(){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return[4,this.J_.stop()];case 1:return t.sent(),[4,this.G_.stop()];case 2:return t.sent(),this.O_.length>0&&(ye("RemoteStore","Stopping write stream with "+this.O_.length+" pending writes"),this.O_=[]),this.hl(),[2]}}))}))},t.prototype.Vo=function(){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return ye("RemoteStore","RemoteStore shutting down."),this.networkEnabled=!1,[4,this.rl()];case 1:return t.sent(),this.U_.Vo(),this.K_.set("Unknown"),[2]}}))}))},t.prototype.listen=function(t){this.L_.has(t.targetId)||(this.L_.set(t.targetId,t),this.sl()?this.il():this.G_.Qc()&&this.ol(t))},t.prototype.al=function(t){this.L_.delete(t),this.G_.Qc()&&this.ul(t),0===this.L_.size&&(this.G_.Qc()?this.G_.Kc():this.W_()&&this.K_.set("Unknown"))},t.prototype.si=function(t){return this.L_.get(t)||null},t.prototype.ei=function(t){return this.cl.ei(t)},t.prototype.ol=function(t){this.B_.Ns(t.targetId),this.G_.r_(t)},t.prototype.ul=function(t){this.B_.Ns(t),this.G_.h_(t)},t.prototype.il=function(){this.B_=new oe(this),this.G_.start(),this.K_.C_()},t.prototype.sl=function(){return this.W_()&&!this.G_.Uc()&&this.L_.size>0},t.prototype.W_=function(){return!this.q_&&this.isPrimary&&this.networkEnabled},t.prototype.hl=function(){this.B_=null},t.prototype.z_=function(){return i.__awaiter(this,void 0,void 0,(function(){var t=this;return i.__generator(this,(function(e){return this.L_.forEach((function(e,n){t.ol(e)})),[2]}))}))},t.prototype.H_=function(t){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(e){return this.hl(),this.sl()?(this.K_.k_(t),this.il()):this.K_.set("Unknown"),[2]}))}))},t.prototype.Y_=function(t,e){return i.__awaiter(this,void 0,void 0,(function(){var n,r,o;return i.__generator(this,(function(i){switch(i.label){case 0:if(this.K_.set("Online"),!(t instanceof re&&2===t.state&&t.cause))return[3,6];i.label=1;case 1:return i.trys.push([1,3,,5]),[4,this._l(t)];case 2:return i.sent(),[3,5];case 3:return n=i.sent(),ye("RemoteStore","Failed to remove targets %s: %s ",t.targetIds.join(","),n),[4,this.ll(n)];case 4:return i.sent(),[3,5];case 5:return[3,13];case 6:if(t instanceof ee?this.B_.qs(t):t instanceof ne?this.B_.Hs(t):this.B_.Ws(t),e.isEqual(E.min()))return[3,13];i.label=7;case 7:return i.trys.push([7,11,,13]),[4,this.x_._h()];case 8:return r=i.sent(),e.S(r)>=0?[4,this.dl(e)]:[3,10];case 9:i.sent(),i.label=10;case 10:return[3,13];case 11:return ye("RemoteStore","Failed to raise snapshot:",o=i.sent()),[4,this.ll(o)];case 12:return i.sent(),[3,13];case 13:return[2]}}
1))}))},t.prototype.ll=function(t,e){return i.__awaiter(this,void 0,void 0,(function(){var n=this;return i.__generator(this,(function(r){switch(r.label){case 0:if(!jn(t))throw t;return this.q_=!0,[4,this.rl()];case 1:return r.sent(),this.K_.set("Offline"),e||(e=function(){return n.x_._h()}),this.Ra.lo((function(){return i.__awaiter(n,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return ye("RemoteStore","Retrying IndexedDB access"),[4,e()];case 1:return t.sent(),this.q_=!1,[4,this.el()];case 2:return t.sent(),[2]}}))}))})),[2]}}))}))},t.prototype.fl=function(t){var e=this;return t().catch((function(n){return e.ll(n,t)}))},t.prototype.dl=function(t){var e=this,n=this.B_.Xs(t);return n.as.forEach((function(n,r){if(n.resumeToken.rt()>0){var i=e.L_.get(r);i&&e.L_.set(r,i.we(n.resumeToken,t))}})),n.us.forEach((function(t){var n=e.L_.get(t);if(n){e.L_.set(t,n.we(S.ht,n.Ee)),e.ul(t);var r=new kt(n.target,t,1,n.sequenceNumber);e.ol(r)}})),this.cl.xu(n)},t.prototype._l=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n,r,o;return i.__generator(this,(function(i){switch(i.label){case 0:e=t.cause,n=0,r=t.targetIds,i.label=1;case 1:return n<r.length?(o=r[n],this.L_.has(o)?[4,this.cl.Tl(o,e)]:[3,3]):[3,5];case 2:i.sent(),this.L_.delete(o),this.B_.removeTarget(o),i.label=3;case 3:i.label=4;case 4:return n++,[3,1];case 5:return[2]}}
1))}))},t.prototype.nl=function(){return i.__awaiter(this,void 0,void 0,(function(){var t,e,n;return i.__generator(this,(function(r){switch(r.label){case 0:t=this.O_.length>0?this.O_[this.O_.length-1].batchId:-1,r.label=1;case 1:if(!this.El())return[3,7];r.label=2;case 2:return r.trys.push([2,4,,6]),[4,this.x_.Bu(t)];case 3:return null===(e=r.sent())?(0===this.O_.length&&this.J_.Kc(),[3,7]):(t=e.batchId,this.Il(e),[3,6]);case 4:return n=r.sent(),[4,this.ll(n)];case 5:return r.sent(),[3,6];case 6:return[3,1];case 7:return this.wl()&&this.Rl(),[2]}}))}))},t.prototype.El=function(){return this.W_()&&this.O_.length<10},t.prototype.Al=function(){return this.O_.length},t.prototype.Il=function(t){this.O_.push(t),this.J_.Qc()&&this.J_.a_&&this.J_.u_(t.mutations)},t.prototype.wl=function(){return this.W_()&&!this.J_.Uc()&&this.O_.length>0},t.prototype.Rl=function(){this.J_.start()},t.prototype.X_=function(){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(t){return this.J_.l_(),[2]}))}))},t.prototype.tl=function(){return i.__awaiter(this,void 0,void 0,(function(){var t,e,n;return i.__generator(this,(function(r){for(t=0,e=this.O_;t<e.length;t++)n=e[t],this.J_.u_(n.mutations);return[2]}))}))},t.prototype.c_=function(t,e){return i.__awaiter(this,void 0,void 0,(function(){var n,r,o=this;return i.__generator(this,(function(i){switch(i.label){case 0:return n=this.O_.shift(),r=Se.from(n,t,e),[4,this.fl((function(){return o.cl.ml(r)}))];case 1:return i.sent(),[4,this.nl()];case 2:return i.sent(),[2]}}))}))},t.prototype.Z_=function(t){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(e){switch(e.label){case 0:return t&&this.J_.a_?[4,this.Pl(t)]:[3,2];case 1:e.sent(),e.label=2;case 2:return this.wl()&&this.Rl(),[2]}}))}))},t.prototype.Pl=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n,r=this;return i.__generator(this,(function(i){switch(i.label){case 0:return Vt(n=t.code)&&n!==l.ABORTED?(e=this.O_.shift(),this.J_.jc(),[4,this.fl((function(){return r.cl.Vl(e.batchId,t)}))]):[3,3];case 1:return i.sent(),[4,this.nl()];case 2:i.sent(),i.label=3;case 3:return[2]}}
1))}))},t.prototype.gl=function(){return new ri(this.w_)},t.prototype.j_=function(){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return this.networkEnabled=!1,[4,this.rl()];case 1:return t.sent(),this.K_.set("Unknown"),[4,this.enableNetwork()];case 2:return t.sent(),[2]}}))}))},t.prototype.pl=function(){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return this.W_()?(ye("RemoteStore","RemoteStore restarting streams for new credential"),[4,this.j_()]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.yl=function(t){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(e){switch(e.label){case 0:return this.isPrimary=t,t&&this.networkEnabled?[4,this.enableNetwork()]:[3,2];case 1:return e.sent(),[3,5];case 2:return t?[3,4]:[4,this.rl()];case 3:e.sent(),this.K_.set("Unknown"),e.label=4;case 4:e.label=5;case 5:return[2]}}))}))},t}();function si(t,e){return"firestore_clients_"+t+"_"+e}function ui(t,e,n){var r="firestore_mutations_"+t+"_"+n;return e.t()&&(r+="_"+e.uid),r}function ai(t,e){return"firestore_targets_"+t+"_"+e}var ci=function(){function t(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}return t.bl=function(e,n,r){var i=JSON.parse(r),o="object"==typeof i&&-1!==["pending","acknowledged","rejected"].indexOf(i.state)&&(void 0===i.error||"object"==typeof i.error),s=void 0;return o&&i.error&&(o="string"==typeof i.error.message&&"string"==typeof i.error.code)&&(s=new p(i.error.code,i.error.message)),o?new t(e,n,i.state,s):(ve("SharedClientState","Failed to parse mutation state for ID '"+n+"': "+r),null)},t.prototype.vl=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},t}(),hi=function(){function t(t,e,n){this.targetId=t,this.state=e,this.error=n}return t.bl=function(e,n){var r=JSON.parse(n),i="object"==typeof r&&-1!==["not-current","current","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error),o=void 0;return i&&r.error&&(i="string"==typeof r.error.message&&"string"==typeof r.error.code)&&(o=new p(r.error.code,r.error.message)),i?new t(e,r.state,o):(ve("SharedClientState","Failed to parse target state for ID '"+e+"': "+n),null)},t.prototype.vl=function(){var t={state:this.state,updateTimeMs:Date.now()};return this.error&&(t.error={code:this.error.code,message:this.error.message}),JSON.stringify(t)},t}(),fi=function(){function t(t,e){this.clientId=t,this.activeTargetIds=e}return t.bl=function(e,n){for(var r=JSON.parse(n),i="object"==typeof r&&r.activeTargetIds instanceof Array,o=Jt(),s=0;i&&s<r.activeTargetIds.length;++s)i=P(r.activeTargetIds[s]),o=o.add(r.activeTargetIds[s]);return i?new t(e,o):(ve("SharedClientState","Failed to parse client data for instance '"+e+"': "+n),null)},t}(),li=function(){function t(t,e){this.clientId=t,this.onlineState=e}return t.bl=function(e){var n=JSON.parse(e);return"object"==typeof n&&-1!==["Unknown","Online","Offline"].indexOf(n.onlineState)&&"string"==typeof n.clientId?new t(n.clientId,n.onlineState):(ve("SharedClientState","Failed to parse online state: "+e),null)},t}(),pi=function(){function t(){this.activeTargetIds=Jt()}return t.prototype.Sl=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},t.prototype.Dl=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},t.prototype.vl=function(){var t={activeTargetIds:this.activeTargetIds.W(),updateTimeMs:Date.now()};return JSON.stringify(t)},t}(),di=function(){function t(e,n,r,i,o){if(this.Tr=e,this.platform=n,this.persistenceKey=r,this.Cl=i,this.cl=null,this.b_=null,this.ur=null,this.Fl=this.Nl.bind(this),this.kl=new Ot(be),this.ho=!1,this.Ml=[],!t.zh(this.platform))throw new p(l.UNIMPLEMENTED,"LocalStorage is not available on this platform.");var s=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.platform.window.localStorage,this.currentUser=o,this.xl=si(this.persistenceKey,this.Cl),this.$l=function(t){return"firestore_sequence_number_"+t}(this.persistenceKey),this.kl=this.kl.Ae(this.Cl,new pi),this.Ol=new RegExp("^firestore_clients_"+s+"_([^_]*)$"),this.Ll=new RegExp("^firestore_mutations_"+s+"_(\\d+)(?:_(.*))?$"),this.Bl=new RegExp("^firestore_targets_"+s+"_(\\d+)$"),this.ql=function(t){return"firestore_online_state_"+t}(this.persistenceKey),this.platform.window.addEventListener("storage",this.Fl)}
1return t.zh=function(t){return!(!t.window||null==t.window.localStorage)},t.prototype.start=function(){return i.__awaiter(this,void 0,void 0,(function(){var t,e,n,r,o,s,u,a,c,h,f,l=this;return i.__generator(this,(function(i){switch(i.label){case 0:return[4,this.cl.So()];case 1:for(t=i.sent(),e=0,n=t;e<n.length;e++)(r=n[e])!==this.Cl&&(o=this.getItem(si(this.persistenceKey,r)))&&(s=fi.bl(r,o))&&(this.kl=this.kl.Ae(s.clientId,s));for(this.Ul(),(u=this.storage.getItem(this.ql))&&(a=this.Ql(u))&&this.Wl(a),c=0,h=this.Ml;c<h.length;c++)f=h[c],this.Nl(f);return this.Ml=[],this.platform.window.addEventListener("unload",(function(){return l.Vo()})),this.ho=!0,[2]}}))}))},t.prototype.lr=function(t){this.setItem(this.$l,JSON.stringify(t))},t.prototype.jl=function(){return this.Kl(this.kl)},t.prototype.Gl=function(t){var e=!1;return this.kl.forEach((function(n,r){r.activeTargetIds.has(t)&&(e=!0)})),e},t.prototype.zl=function(t){this.Hl(t,"pending")},t.prototype.Yl=function(t,e,n){this.Hl(t,e,n),this.Jl(t)},t.prototype.Xl=function(t){var e="not-current";if(this.Gl(t)){var n=this.storage.getItem(ai(this.persistenceKey,t));if(n){var r=hi.bl(t,n);r&&(e=r.state)}}return this.Zl.Sl(t),this.Ul(),e},t.prototype.td=function(t){this.Zl.Dl(t),this.Ul()},t.prototype.ed=function(t){return this.Zl.activeTargetIds.has(t)},t.prototype.sd=function(t){this.removeItem(ai(this.persistenceKey,t))},t.prototype.nd=function(t,e,n){this.rd(t,e,n)},t.prototype.vu=function(t,e,n){var r=this;e.forEach((function(t){r.Jl(t)})),this.currentUser=t,n.forEach((function(t){r.zl(t)}))},t.prototype.hd=function(t){this.od(t)},t.prototype.Vo=function(){this.ho&&(this.platform.window.removeEventListener("storage",this.Fl),this.removeItem(this.xl),this.ho=!1)},t.prototype.getItem=function(t){var e=this.storage.getItem(t);return ye("SharedClientState","READ",t,e),e},t.prototype.setItem=function(t,e){ye("SharedClientState","SET",t,e),this.storage.setItem(t,e)},t.prototype.removeItem=function(t){ye("SharedClientState","REMOVE",t),this.storage.removeItem(t)},t.prototype.Nl=function(t){var e=this;if(t.storageArea===this.storage){if(ye("SharedClientState","EVENT",t.key,t.newValue),t.key===this.xl)return void ve("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Tr.lo((function(){return i.__awaiter(e,void 0,void 0,(function(){var e,n,r,o,s,u;return i.__generator(this,(function(i){if(this.ho){if(null!==t.key)if(this.Ol.test(t.key)){if(null==t.newValue)return e=this.ad(t.key),[2,this.ud(e,null)];if(n=this._d(t.key,t.newValue))return[2,this.ud(n.clientId,n)]}else if(this.Ll.test(t.key)){if(null!==t.newValue&&(r=this.ld(t.key,t.newValue)))return[2,this.dd(r)]}else if(this.Bl.test(t.key)){if(null!==t.newValue&&(o=this.fd(t.key,t.newValue)))return[2,this.Td(o)]}else if(t.key===this.ql){if(null!==t.newValue&&(s=this.Ql(t.newValue)))return[2,this.Wl(s)]}else t.key===this.$l&&(u=function(t){var e=Ue.dr;if(null!=t)try{var n=JSON.parse(t);we("number"==typeof n),e=n}catch(t){ve("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(t.newValue))!==Ue.dr&&this.ur(u)}else this.Ml.push(t);return[2]}))}))}))}},Object.defineProperty(t.prototype,"Zl",{get:function(){return this.kl.get(this.Cl)},enumerable:!0,configurable:!0}),t.prototype.Ul=function(){this.setItem(this.xl,this.Zl.vl())},t.prototype.Hl=function(t,e,n){var r=new ci(this.currentUser,t,e,n),i=ui(this.persistenceKey,this.currentUser,t);this.setItem(i,r.vl())},t.prototype.Jl=function(t){var e=ui(this.persistenceKey,this.currentUser,t);this.removeItem(e)},t.prototype.od=function(t){var e={clientId:this.Cl,onlineState:t};this.storage.setItem(this.ql,JSON.stringify(e))},t.prototype.rd=function(t,e,n){var r=ai(this.persistenceKey,t),i=new hi(t,e,n);this.setItem(r,i.vl())},t.prototype.ad=function(t){var e=this.Ol.exec(t);return e?e[1]:null},t.prototype._d=function(t,e){var n=this.ad(t);return fi.bl(n,e)},t.prototype.ld=function(t,e){var n=this.Ll.exec(t),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return ci.bl(new f(i),r,e)},t.prototype.fd=function(t,e){var n=this.Bl.exec(t),r=Number(n[1]);return hi.bl(r,e)},t.prototype.Ql=function(t){return li.bl(t)},t.prototype.dd=function(t){return i.__awaiter(this,void 0,void 0,(function(){return i.__generator(this,(function(e){return t.user.uid===this.currentUser.uid?[2,this.cl.Ed(t.batchId,t.state,t.error)]:(ye("SharedCl
1ientState","Ignoring mutation for non-active user "+t.user.uid),[2])}))}))},t.prototype.Td=function(t){return this.cl.Id(t.targetId,t.state,t.error)},t.prototype.ud=function(t,e){var n=this,r=e?this.kl.Ae(t,e):this.kl.remove(t),i=this.Kl(this.kl),o=this.Kl(r),s=[],u=[];return o.forEach((function(t){i.has(t)||s.push(t)})),i.forEach((function(t){o.has(t)||u.push(t)})),this.cl.wd(s,u).then((function(){n.kl=r}))},t.prototype.Wl=function(t){this.kl.get(t.clientId)&&this.b_(t.onlineState)},t.prototype.Kl=function(t){var e=Jt();return t.forEach((function(t,n){e=e.He(n.activeTargetIds)})),e},t}(),yi=function(){function t(){this.Rd=new pi,this.Ad={},this.cl=null,this.b_=null,this.ur=null}return t.prototype.zl=function(t){},t.prototype.Yl=function(t,e,n){},t.prototype.Xl=function(t){return this.Rd.Sl(t),this.Ad[t]||"not-current"},t.prototype.nd=function(t,e,n){this.Ad[t]=e},t.prototype.td=function(t){this.Rd.Dl(t)},t.prototype.ed=function(t){return this.Rd.activeTargetIds.has(t)},t.prototype.sd=function(t){delete this.Ad[t]},t.prototype.jl=function(){return this.Rd.activeTargetIds},t.prototype.Gl=function(t){return this.Rd.activeTargetIds.has(t)},t.prototype.start=function(){return this.Rd=new pi,Promise.resolve()},t.prototype.vu=function(t,e,n){},t.prototype.hd=function(t){},t.prototype.Vo=function(){},t.prototype.lr=function(t){},t}(),vi=function(t){this.key=t},gi=function(t){this.key=t},mi=function(){function t(t,e){this.query=t,this.md=e,this.Pd=null,this.fs=!1,this.Vd=Kt(),this.ns=Kt(),this.gd=new Xt(t.se.bind(t))}return Object.defineProperty(t.prototype,"pd",{get:function(){return this.md},enumerable:!0,configurable:!0}),t.prototype.yd=function(t,e){var n=this,r=e?e.bd:new Ht,i=e?e.gd:this.gd,o=e?e.ns:this.ns,s=i,u=!1,a=this.query.oe()&&i.size===this.query.limit?i.last():null,c=this.query.ae()&&i.size===this.query.limit?i.first():null;if(t.pe((function(t,e){var h=i.get(t),f=e instanceof mt?e:null;f&&(f=n.query.matches(f)?f:null);var l=!!h&&n.ns.has(h.key),p=!!f&&(f.At||n.ns.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.vd(h,f)||(r.track({type:2,doc:f}),d=!0,(a&&n.query.se(f,a)>0||c&&n.query.se(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)))})),this.query.oe()||this.query.ae())for(;s.size>this.query.limit;){var h=this.query.oe()?s.last():s.first();s=s.delete(h.key),o=o.delete(h.key),r.track({type:1,doc:h})}return{gd:s,bd:r,Sd:u,ns:o}},t.prototype.vd=function(t,e){return t.At&&e.hasCommittedMutations&&!e.At},t.prototype.Ln=function(t,e,n){var r=this,i=this.gd;this.gd=t.gd,this.ns=t.ns;var o=t.bd.es();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 me()}};return n(t)-n(e)}(t.type,e.type)||r.query.se(t.doc,e.doc)})),this.Dd(n);var s=e?this.Cd():[],u=0===this.Vd.size&&this.fs?1:0,a=u!==this.Pd;return this.Pd=u,0!==o.length||a?{snapshot:new $t(this.query,t.gd,i,o,t.ns,0===u,a,!1),Fd:s}:{Fd:s}},t.prototype.Nd=function(t){return this.fs&&"Offline"===t?(this.fs=!1,this.Ln({gd:this.gd,bd:new Ht,ns:this.ns,Sd:!1},!1)):{Fd:[]}},t.prototype.kd=function(t){return!this.md.has(t)&&!!this.gd.has(t)&&!this.gd.get(t).At},t.prototype.Dd=function(t){var e=this;t&&(t.Ts.forEach((function(t){return e.md=e.md.add(t)})),t.Es.forEach((function(t){})),t.Is.forEach((function(t){return e.md=e.md.delete(t)})),this.fs=t.fs)},t.prototype.Cd=function(){var t=this;if(!this.fs)return[];var e=this.Vd;this.Vd=Kt(),this.gd.forEach((function(e){t.kd(e.key)&&(t.Vd=t.Vd.add(e.key))}));var n=[];return e.forEach((function(e){t.Vd.has(e)||n.push(new gi(e))})),this.Vd.forEach((function(t){e.has(t)||n.push(new vi(t))})),n},t.prototype.Md=function(t){this.md=t.ju,this.Vd=Kt();var e=this.yd(t.documents);return this.Ln(e,!0)},t.prototype.xd=function(){return $t.os(this.query,this.gd,this.ns,0===this.Pd)},t}(),wi=function(){function t(t,e,n,r){this.Ra=t,this.w_=e,this.updateFunction=n,this.Pa=r,this.$d=5,this.Na=new qe(this.Ra,"transaction_retry")}return t.prototype.Od=function(){this.Ld()},t.prototype.Ld=function(){var t=this;this.Na.gr((function(){return i.__awaiter(t,void 0,void 0,(function(){var t,e,n=this;return i.__generator(this,(function(r){return t=new ri(this.w_),(e=this.Bd(t))&&e.then((function(e){n.Ra.co((function(){return t.commit().then((function(){n.Pa.resolve(e)})).catch((function(t){n.qd(t)}))}))})).catch((function(t){n.qd(t)})),[2]}))}
1))}))},t.prototype.Bd=function(t){try{var e=this.updateFunction(t);return!R(e)&&e.catch&&e.then?e:(this.Pa.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.Pa.reject(t),null}},t.prototype.qd=function(t){var e=this;this.$d>0&&this.Ud(t)?(this.$d-=1,this.Ra.co((function(){return e.Ld(),Promise.resolve()}))):this.Pa.reject(t)},t.prototype.Ud=function(t){if("FirebaseError"===t.name){var e=t.code;return"aborted"===e||"failed-precondition"===e||!Vt(e)}return!1},t}(),Ei=function(t,e,n){this.query=t,this.targetId=e,this.view=n},_i=function(t){this.key=t,this.Qd=!1},bi=function(){function t(t,e,n,r,i,o){this.x_=t,this.Wd=e,this.w_=n,this.jd=r,this.currentUser=i,this.Kd=o,this.Gd=null,this.zd=new xe((function(t){return t.canonicalId()})),this.Hd=new Map,this.Yd=[],this.Jd=new Ot(N.N),this.Xd=new Map,this.Zd=new rr,this.tf={},this.ef=new Map,this.sf=$e.rh(),this.onlineState="Unknown"}return Object.defineProperty(t.prototype,"if",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype.subscribe=function(t){this.Gd=t},t.prototype.listen=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n,r,o,s;return i.__generator(this,(function(i){switch(i.label){case 0:return this.nf("listen()"),(r=this.zd.get(t))?(e=r.targetId,this.jd.Xl(e),n=r.view.xd(),[3,4]):[3,1];case 1:return[4,this.x_.Uu(t.ee())];case 2:return o=i.sent(),s=this.jd.Xl(o.targetId),e=o.targetId,[4,this.rf(t,e,"current"===s)];case 3:n=i.sent(),this.if&&this.Wd.listen(o),i.label=4;case 4:return[2,n]}}))}))},t.prototype.rf=function(t,e,n){return i.__awaiter(this,void 0,void 0,(function(){var r,o,s,u,a,c;return i.__generator(this,(function(i){switch(i.label){case 0:return[4,this.x_.Wu(t,!0)];case 1:return r=i.sent(),o=new mi(t,r.ju),s=o.yd(r.documents),u=te.ds(e,n&&"Offline"!==this.onlineState),a=o.Ln(s,this.if,u),this.hf(e,a.Fd),c=new Ei(t,e,o),[2,(this.zd.set(t,c),this.Hd.has(e)?this.Hd.get(e).push(t):this.Hd.set(e,[t]),a.snapshot)]}}))}))},t.prototype.al=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n,r=this;return i.__generator(this,(function(i){switch(i.label){case 0:return this.nf("unlisten()"),e=this.zd.get(t),(n=this.Hd.get(e.targetId)).length>1?[2,(this.Hd.set(e.targetId,n.filter((function(e){return!e.isEqual(t)}))),void this.zd.delete(t))]:this.if?(this.jd.td(e.targetId),this.jd.Gl(e.targetId)?[3,2]:[4,this.x_.Qu(e.targetId,!1).then((function(){r.jd.sd(e.targetId),r.Wd.al(e.targetId),r.af(e.targetId)})).catch(nr)]):[3,3];case 1:i.sent(),i.label=2;case 2:return[3,5];case 3:return this.af(e.targetId),[4,this.x_.Qu(e.targetId,!0)];case 4:i.sent(),i.label=5;case 5:return[2]}}
1))}))},t.prototype.write=function(t,e){return i.__awaiter(this,void 0,void 0,(function(){var n,r,o;return i.__generator(this,(function(i){switch(i.label){case 0:this.nf("write()"),i.label=1;case 1:return i.trys.push([1,5,,6]),[4,this.x_.Fu(t)];case 2:return n=i.sent(),this.jd.zl(n.batchId),this.uf(n.batchId,e),[4,this.cf(n.Dn)];case 3:return i.sent(),[4,this.Wd.nl()];case 4:return i.sent(),[3,6];case 5:return r=i.sent(),o=Kn(r,"Failed to persist write"),e.reject(o),[3,6];case 6:return[2]}}))}))},t.prototype.runTransaction=function(t,e,n){new wi(t,this.w_,e,n).Od()},t.prototype.xu=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n=this;return i.__generator(this,(function(r){switch(r.label){case 0:this.nf("applyRemoteEvent()"),r.label=1;case 1:return r.trys.push([1,4,,6]),[4,this.x_.xu(t)];case 2:return e=r.sent(),t.as.forEach((function(t,e){var r=n.Xd.get(e);r&&(we(t.Ts.size+t.Es.size+t.Is.size<=1),t.Ts.size>0?r.Qd=!0:t.Es.size>0?we(r.Qd):t.Is.size>0&&(we(r.Qd),r.Qd=!1))})),[4,this.cf(e,t)];case 3:return r.sent(),[3,6];case 4:return[4,nr(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}
1))}))},t.prototype.Nd=function(t,e){this.nf("applyOnlineStateChange()");var n=[];this.zd.forEach((function(e,r){var i=r.view.Nd(t);i.snapshot&&n.push(i.snapshot)})),this.Gd._f(t),this.Gd.n_(n),this.onlineState=t},t.prototype.Tl=function(t,e){return i.__awaiter(this,void 0,void 0,(function(){var n,r,o,s,u,a=this;return i.__generator(this,(function(i){switch(i.label){case 0:return this.nf("rejectListens()"),this.jd.nd(t,"rejected",e),n=this.Xd.get(t),(r=n&&n.key)?(o=(o=new Ot(N.N)).Ae(r,new wt(r,E.min())),s=Kt().add(r),u=new Zt(E.min(),new Map,new qt(be),o,s),[4,this.xu(u)]):[3,2];case 1:return i.sent(),this.Jd=this.Jd.remove(r),this.Xd.delete(t),this.lf(),[3,4];case 2:return[4,this.x_.Qu(t,!1).then((function(){return a.af(t,e)})).catch(nr)];case 3:i.sent(),i.label=4;case 4:return[2]}}))}))},t.prototype.ml=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n;return i.__generator(this,(function(r){switch(r.label){case 0:this.nf("applySuccessfulWrite()"),e=t.batch.batchId,r.label=1;case 1:return r.trys.push([1,4,,6]),[4,this.x_.Nu(t)];case 2:return n=r.sent(),this.df(e,null),this.ff(e),this.jd.Yl(e,"acknowledged"),[4,this.cf(n)];case 3:return r.sent(),[3,6];case 4:return[4,nr(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}
1))}))},t.prototype.Vl=function(t,e){return i.__awaiter(this,void 0,void 0,(function(){var n;return i.__generator(this,(function(r){switch(r.label){case 0:this.nf("rejectFailedWrite()"),r.label=1;case 1:return r.trys.push([1,4,,6]),[4,this.x_.Mu(t)];case 2:return n=r.sent(),this.df(t,e),this.ff(t),this.jd.Yl(t,"rejected",e),[4,this.cf(n)];case 3:return r.sent(),[3,6];case 4:return[4,nr(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}))}))},t.prototype.Tf=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n,r,o;return i.__generator(this,(function(i){switch(i.label){case 0:this.Wd.W_()||ye("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this.x_.ta()];case 2:return-1===(e=i.sent())?[2,void t.resolve()]:((n=this.ef.get(e)||[]).push(t),this.ef.set(e,n),[3,4]);case 3:return r=i.sent(),o=Kn(r,"Initialization of waitForPendingWrites() operation failed"),t.reject(o),[3,4];case 4:return[2]}}
1))}))},t.prototype.ff=function(t){(this.ef.get(t)||[]).forEach((function(t){t.resolve()})),this.ef.delete(t)},t.prototype.Ef=function(t){this.ef.forEach((function(e){e.forEach((function(e){e.reject(new p(l.CANCELLED,t))}))})),this.ef.clear()},t.prototype.uf=function(t,e){var n=this.tf[this.currentUser.s()];n||(n=new Ot(be)),n=n.Ae(t,e),this.tf[this.currentUser.s()]=n},t.prototype.df=function(t,e){var n=this.tf[this.currentUser.s()];if(n){var r=n.get(t);r&&(e?r.reject(e):r.resolve(),n=n.remove(t)),this.tf[this.currentUser.s()]=n}},t.prototype.af=function(t,e){var n=this;void 0===e&&(e=null),this.jd.td(t);for(var r=0,i=this.Hd.get(t);r<i.length;r++){var o=i[r];this.zd.delete(o),e&&this.Gd.If(o,e)}this.Hd.delete(t),this.if&&this.Zd.ic(t).forEach((function(t){n.Zd.Ch(t)||n.wf(t)}))},t.prototype.wf=function(t){var e=this.Jd.get(t);null!==e&&(this.Wd.al(e),this.Jd=this.Jd.remove(t),this.Xd.delete(e),this.lf())},t.prototype.hf=function(t,e){for(var n=0,r=e;n<r.length;n++){var i=r[n];i instanceof vi?(this.Zd.yh(i.key,t),this.Rf(i)):i instanceof gi?(ye("SyncEngine","Document no longer in limbo: "+i.key),this.Zd.vh(i.key,t),this.Zd.Ch(i.key)||this.wf(i.key)):me()}},t.prototype.Rf=function(t){var e=t.key;this.Jd.get(e)||(ye("SyncEngine","New document in limbo: "+e),this.Yd.push(e),this.lf())},t.prototype.lf=function(){for(;this.Yd.length>0&&this.Jd.size<this.Kd;){var t=this.Yd.shift(),e=this.sf.next();this.Xd.set(e,new _i(t)),this.Jd=this.Jd.Ae(t,e),this.Wd.listen(new kt(bt.Wt(t.path).ee(),e,2,Ue.dr))}},t.prototype.Af=function(){return this.Jd},t.prototype.mf=function(){return this.Yd},t.prototype.cf=function(t,e){return i.__awaiter(this,void 0,void 0,(function(){var n,r,o,s=this;return i.__generator(this,(function(i){switch(i.label){case 0:return n=[],r=[],o=[],this.zd.forEach((function(i,u){o.push(Promise.resolve().then((function(){var e=u.view.yd(t);return e.Sd?s.x_.Wu(u.query,!1).then((function(t){var n=t.documents;return u.view.yd(n,e)})):e})).then((function(t){var i=e&&e.as.get(u.targetId),o=u.view.Ln(t,s.if,i);if(s.hf(u.targetId,o.Fd),o.snapshot){s.if&&s.jd.nd(u.targetId,o.snapshot.fromCache?"not-current":"current"),n.push(o.snapshot);var a=Oe.ar(u.targetId,o.snapshot);r.push(a)}})))})),[4,Promise.all(o)];case 1:return i.sent(),this.Gd.n_(n),[4,this.x_.Lu(r)];case 2:return i.sent(),[2]}}))}))},t.prototype.nf=function(t){},t.prototype.pl=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e;return i.__generator(this,(function(n){switch(n.label){case 0:return this.currentUser.isEqual(t)?[3,3]:[4,this.x_.vu(t)];case 1:return e=n.sent(),this.currentUser=t,this.Ef("'waitForPendingWrites' promise is rejected due to a user change."),this.jd.vu(t,e.Du,e.Cu),[4,this.cf(e.Su)];case 2:n.sent(),n.label=3;case 3:return[4,this.Wd.pl()];case 4:return n.sent(),[2]}}))}))},t.prototype.enableNetwork=function(){return this.Wd.enableNetwork()},t.prototype.disableNetwork=function(){return this.Wd.disableNetwork()},t.prototype.ei=function(t){var e=this.Xd.get(t);if(e&&e.Qd)return Kt().add(e.key);var n=Kt(),r=this.Hd.get(t);if(!r)return n;for(var i=0,o=r;i<o.length;i++){var s=o[i],u=this.zd.get(s);n=n.He(u.view.pd)}return n},t}(),Ti=function(t){function e(e,n,r,i,o,s){var u=this;return(u=t.call(this,e,n,r,i,o,s)||this).x_=e,u.Pf=void 0,u}return i.__extends(e,t),Object.defineProperty(e.prototype,"if",{get:function(){return!0===this.Pf},enumerable:!0,configurable:!0}),e.prototype.enableNetwork=function(){return this.x_.uo(!0),t.prototype.enableNetwork.call(this)},e.prototype.disableNetwork=function(){return this.x_.uo(!1),t.prototype.disableNetwork.call(this)},e.prototype.Vf=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n;return i.__generator(this,(function(r){switch(r.label){case 0:return[4,this.x_.Wu(t.query,!0)];case 1:return e=r.sent(),n=t.view.Md(e),[2,(this.Pf&&this.hf(t.targetId,n.Fd),n)]}}))}))},e.prototype.Nd=function(e,n){this.if&&0===n&&(t.prototype.Nd.call(this,e,n),this.jd.hd(e)),this.if||1!==n||t.prototype.Nd.call(this,e,n)},e.prototype.Ed=function(t,e,n){return i.__awaiter(this,void 0,void 0,(function(){var r;return i.__generator(this,(function(i){switch(i.label){case 0:return this.nf("applyBatchState()"),[4,this.x_.Gu(t)];case 1:return null===(r=i.sent())?[3,6]:"pending"!==e?[3,3]:[4,this.Wd.nl()];case 2:return i.sent(),[3,4];case 3:"acknowledged"===e||"rejected"===e?(this.df(t,n||null),this.x_.zu(t)):me(),i.label=4;case 4:return[4,this.cf(r)];case 5:return i.sent(),[3,7];case 6:ye("SyncEngine","Cannot apply mutation batch with id: "+t),i.label=7;case 7:return[2]}}
1))}))},e.prototype.yl=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n,r,o,s,u,a,c=this;return i.__generator(this,(function(i){switch(i.label){case 0:return!0!==t||!0===this.Pf?[3,3]:(e=this.jd.jl(),[4,this.gf(e.W(),!0)]);case 1:return n=i.sent(),this.Pf=!0,[4,this.Wd.yl(!0)];case 2:for(i.sent(),r=0,o=n;r<o.length;r++)s=o[r],this.Wd.listen(s);return[3,7];case 3:return!1!==t||!1===this.Pf?[3,7]:(u=[],a=Promise.resolve(),this.Hd.forEach((function(t,e){c.jd.ed(e)?u.push(e):a=a.then((function(){return c.af(e),c.x_.Qu(e,!0)})),c.Wd.al(e)})),[4,a]);case 4:return i.sent(),[4,this.gf(u,!1)];case 5:return i.sent(),this.pf(),this.Pf=!1,[4,this.Wd.yl(!1)];case 6:i.sent(),i.label=7;case 7:return[2]}}))}))},e.prototype.pf=function(){var t=this;this.Xd.forEach((function(e,n){t.Wd.al(n)})),this.Zd.nc(),this.Xd=new Map,this.Jd=new Ot(N.N)},e.prototype.gf=function(t,e){return i.__awaiter(this,void 0,void 0,(function(){var e,n,r,o,s,u,a,c,h,f,l,p,d;return i.__generator(this,(function(i){switch(i.label){case 0:e=[],n=[],r=0,o=t,i.label=1;case 1:return r<o.length?(s=o[r],u=void 0,(a=this.Hd.get(s))&&0!==a.length?[4,this.x_.Uu(a[0].ee())]:[3,7]):[3,13];case 2:u=i.sent(),c=0,h=a,i.label=3;case 3:return c<h.length?(f=h[c],l=this.zd.get(f),[4,this.Vf(l)]):[3,6];case 4:(p=i.sent()).snapshot&&n.push(p.snapshot),i.label=5;case 5:return c++,[3,3];case 6:return[3,11];case 7:return[4,this.x_.Hu(s)];case 8:return d=i.sent(),[4,this.x_.Uu(d)];case 9:return u=i.sent(),[4,this.rf(this.yf(d),s,!1)];case 10:i.sent(),i.label=11;case 11:e.push(u),i.label=12;case 12:return r++,[3,1];case 13:return[2,(this.Gd.n_(n),e)]}}))}))},e.prototype.yf=function(t){return new bt(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)},e.prototype.So=function(){return this.x_.So()},e.prototype.Id=function(t,e,n){return i.__awaiter(this,void 0,void 0,(function(){var r,o;return i.__generator(this,(function(i){switch(i.label){case 0:return this.Pf?(ye("SyncEngine","Ignoring unexpected query state notification."),[3,8]):[3,1];case 1:if(!this.Hd.has(t))return[3,8];switch(e){case"current":case"not-current":return[3,2];case"rejected":return[3,5]}return[3,7];case 2:return[4,this.x_.Kr()];case 3:return r=i.sent(),o=Zt.ls(t,"current"===e),[4,this.cf(r,o)];case 4:return i.sent(),[3,8];case 5:return[4,this.x_.Qu(t,!0)];case 6:return i.sent(),this.af(t,n),[3,8];case 7:me(),i.label=8;case 8:return[2]}}
1))}))},e.prototype.wd=function(t,e){return i.__awaiter(this,void 0,void 0,(function(){var n,r,o,s,u,a,c,h,f,l,p=this;return i.__generator(this,(function(d){switch(d.label){case 0:if(!this.Pf)return[3,10];n=0,r=t,d.label=1;case 1:return n<r.length?(o=r[n],this.Hd.has(o)?(ye("SyncEngine","Adding an already active target "+o),[3,5]):[4,this.x_.Hu(o)]):[3,6];case 2:return s=d.sent(),[4,this.x_.Uu(s)];case 3:return u=d.sent(),[4,this.rf(this.yf(s),u.targetId,!1)];case 4:d.sent(),this.Wd.listen(u),d.label=5;case 5:return n++,[3,1];case 6:a=function(t){return i.__generator(this,(function(e){switch(e.label){case 0:return c.Hd.has(t)?[4,c.x_.Qu(t,!1).then((function(){p.Wd.al(t),p.af(t)})).catch(nr)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))},c=this,h=0,f=e,d.label=7;case 7:return h<f.length?(l=f[h],[5,a(l)]):[3,10];case 8:d.sent(),d.label=9;case 9:return h++,[3,7];case 10:return[2]}}))}))},e}(bi),Ii=function(){this.bf=void 0,this.vf=[]},Ni=function(){function t(t){this.cl=t,this.Sf=new xe((function(t){return t.canonicalId()})),this.onlineState="Unknown",this.Df=new Set,this.cl.subscribe(this)}return t.prototype.listen=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n,r,o,s,u;return i.__generator(this,(function(i){switch(i.label){case 0:if(e=t.query,n=!1,(r=this.Sf.get(e))||(n=!0,r=new Ii),!n)return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),o=r,[4,this.cl.listen(e)];case 2:return o.bf=i.sent(),[3,4];case 3:return s=i.sent(),u=Kn(s,"Initialization of query '"+t.query+"' failed"),[2,void t.onError(u)];case 4:return this.Sf.set(e,r),r.vf.push(t),t.Nd(this.onlineState),r.bf&&t.Cf(r.bf)&&this.Ff(),[2]}}))}))},t.prototype.al=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n,r,o;return i.__generator(this,(function(i){return e=t.query,n=!1,(r=this.Sf.get(e))&&(o=r.vf.indexOf(t))>=0&&(r.vf.splice(o,1),n=0===r.vf.length),n?[2,(this.Sf.delete(e),this.cl.al(e))]:[2]}))}))},t.prototype.n_=function(t){for(var e=!1,n=0,r=t;n<r.length;n++){var i=r[n],o=i.query,s=this.Sf.get(o);if(s){for(var u=0,a=s.vf;u<a.length;u++)a[u].Cf(i)&&(e=!0);s.bf=i}}e&&this.Ff()},t.prototype.If=function(t,e){var n=this.Sf.get(t);if(n)for(var r=0,i=n.vf;r<i.length;r++)i[r].onError(e);this.Sf.delete(t)},t.prototype._f=function(t){this.onlineState=t;var e=!1;this.Sf.forEach((function(n,r){for(var i=0,o=r.vf;i<o.length;i++)o[i].Nd(t)&&(e=!0)})),e&&this.Ff()},t.prototype.Nf=function(t){this.Df.add(t),t.next()},t.prototype.kf=function(t){this.Df.delete(t)},t.prototype.Ff=function(){this.Df.forEach((function(t){t.next()}))},t}(),Ai=function(){function t(t,e,n){this.query=t,this.Mf=e,this.xf=!1,this.$f=null,this.onlineState="Unknown",this.options=n||{}}return t.prototype.Cf=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 $t(t.query,t.docs,t.ss,e,t.ns,t.fromCache,t.rs,!0)}var o=!1;return this.xf?this.Of(t)&&(this.Mf.next(t),o=!0):this.Lf(t,this.onlineState)&&(this.Bf(t),o=!0),this.$f=t,o},t.prototype.onError=function(t){this.Mf.error(t)},t.prototype.Nd=function(t){this.onlineState=t;var e=!1;return this.$f&&!this.xf&&this.Lf(this.$f,t)&&(this.Bf(this.$f),e=!0),e},t.prototype.Lf=function(t,e){if(!t.fromCache)return!0;var n="Offline"!==e;return!(this.options.qf&&n||t.docs.B()&&"Offline"!==e)},t.prototype.Of=function(t){if(t.docChanges.length>0)return!0;var e=this.$f&&this.$f.hasPendingWrites!==t.hasPendingWrites;return!(!t.rs&&!e)&&!0===this.options.includeMetadataChanges},t.prototype.Bf=function(t){t=$t.os(t.query,t.docs,t.ns,t.fromCache),this.xf=!0,this.Mf.next(t)},t}(),xi=function(){function t(){}return t.prototype.bu=function(t){this.Uf=t},t.prototype.Zn=function(t,e,n,r){var i=this;return e.te()||n.isEqual(E.min())?this.Qf(t,e):this.Uf.Yn(t,r).next((function(o){var u=i.Wf(e,o);return(e.oe()||e.ae())&&i.Sd(e.Bt,u,r,n)?i.Qf(t,e):(de()<=s.LogLevel.DEBUG&&ye("IndexFreeQueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),e.toString()),i.Uf.Zn(t,e,n).next((function(t){return u.forEach((function(e){t=t.Ae(e.key,e)})),t})))}))},t.prototype.Wf=function(t,e){var n=new qt((function(e,n){return t.se(e,n)}));return e.forEach((function(e,r){r instanceof mt&&t.matches(r)&&(n=n.add(r))})),n},t.prototype.Sd=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.S(r)>0)},t.prototype.Qf=function(t,e){return de()<=s.LogLevel.DEBUG&&ye("IndexFreeQueryEngine","Using full collection scan to execute query:",e.toString()),this.Uf.Zn(t,e,E.min())},t}(),Di=function(){function t(t,e){this.jn=t,this.hh=e,this.Wn=[],this.jf=1,this.Kf=new qt(ir.Ju)}return t.prototype.Ho=function(t){return Re.resolve(0===this.Wn.length)},t.prototype.Yo=function(t,e,n,r){var i=this.jf;this.jf++,this.Wn.length>0&&this.Wn[this.Wn.length-1];var o=new De(i,e,n,r);this.Wn.push(o);for(var s=0,u=r;s<u.length;s++){var a=u[s];this.Kf=this.Kf.add(new ir(a.key,i)),this.jn.Dr(t,a.key.path.$())}return Re.resolve(o)},t.prototype.Jo=function(t,e){return Re.resolve(this.Gf(e))},t.prototype.Zo=function(t,e){var n=e+1,r=this.zf(n),i=r<0?0:r;return Re.resolve(this.Wn.length>i?this.Wn[i]:null)},t.prototype.ta=function(){return Re.resolve(0===this.Wn.length?-1:this.jf-1)},t.prototype.ea=function(t){return Re.resolve(this.Wn.slice())},t.prototype.Gn=function(t,e){var n=this,r=new ir(e,0),i=new ir(e,Number.POSITIVE_INFINITY),o=[];return this.Kf.Ke([r,i],(function(t){var e=n.Gf(t.hc);o.push(e)})),Re.resolve(o)},t.prototype.Xn=function(t,e){var n=this,r=new qt(be);return e.forEach((function(t){var e=new ir(t,0),i=new ir(t,Number.POSITIVE_INFINITY);n.Kf.Ke([e,i],(function(t){r=r.add(t.hc)}))})),Re.resolve(this.Hf(r))},t.prototype.nr=function(t,e){var n=e.path,r=n.length+1,i=n;N.et(i)||(i=i.child(""));var o=new ir(new N(i),0),s=new qt(be);return this.Kf.Ge((function(t){var e=t.key.path;return!!n.q(e)&&(e.length===r&&(s=s.add(t.hc)),!0)}),o),Re.resolve(this.Hf(s))},t.prototype.Hf=function(t){var e=this,n=[];return t.forEach((function(t){var r=e.Gf(t);null!==r&&n.push(r)})),n},t.prototype.ia=function(t,e){var n=this;we(0===this.Yf(e.batchId,"removed")),this.Wn.shift();var r=this.Kf;return Re.forEach(e.mutations,(function(i){var o=new ir(i.key,e.batchId);return r=r.delete(o),n.hh.Uo(t,i.key)})).next((function(){n.Kf=r}))},t.prototype.na=function(t){},t.prototype.Ch=function(t,e){var n=new ir(e,0),r=this.Kf.ze(n);return Re.resolve(e.isEqual(r&&r.key))},t.prototype.ra=function(t){return this.Wn.length,Re.resolve()},t.prototype.Yf=function(t,e){return this.zf(t)},t.prototype.zf=function(t){return 0===this.Wn.length?0:t-this.Wn[0].batchId},t.prototype.Gf=function(t){var e=this.zf(t);return e<0||e>=this.Wn.length?null:this.Wn[e]},t}(),Si=function(){function t(t,e){this.jn=t,this.Jf=e,this.docs=new Ot(N.N),this.size=0}return t.prototype.Nn=function(t,e,n){var r=e.key,i=this.docs.get(r),o=i?i.size:0,s=this.Jf(e);return this.docs=this.docs.Ae(r,{$r:e,size:s,readTime:n}),this.size+=s-o,this.jn.Dr(t,r.path.$())},t.prototype.Mn=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},t.prototype.xn=function(t,e){var n=this.docs.get(e);return Re.resolve(n?n.$r:null)},t.prototype.getEntries=function(t,e){var n=this,r=Bt();return e.forEach((function(t){var e=n.docs.get(t);r=r.Ae(t,e?e.$r:null)})),Re.resolve(r)},t.prototype.Zn=function(t,e,n){for(var r=Gt(),i=new N(e.path.child("")),o=this.docs.ve(i);o.ke();){var s=o.Ne(),u=s.key,a=s.value,c=a.$r,h=a.readTime;if(!e.path.q(u.path))break;h.S(n)<=0||c instanceof mt&&e.matches(c)&&(r=r.Ae(c.key,c))}return Re.resolve(r)},t.prototype.Xf=function(t,e){return Re.forEach(this.docs,(function(t){return e(t)}))},t.prototype.Yr=function(e){return new t.Jr(this)},t.prototype.Zr=function(t){return Re.resolve(this.size)},t}();Si.Jr=function(t){function e(e){var n=this;return(n=t.call(this)||this).th=e,n}return i.__extends(e,t),e.prototype.Ln=function(t){var e=this,n=[];return this.Dn.forEach((function(r,i){i?n.push(e.th.Nn(t,i,e.readTime)):e.th.Mn(r)})),Re.vn(n)},e.prototype.$n=function(t,e){return this.th.xn(t,e)},e.prototype.On=function(t,e){return this.th.getEntries(t,e)},e}(ke);var Ri=function(){function t(t){this.persistence=t,this.Zf=new xe((function(t){return t.canonicalId()})),this.lastRemoteSnapshotVersion=E.min(),this.highestTargetId=0,this.tT=0,this.eT=new rr,this.targetCount=0,this.sT=$e.nh()}return t.prototype.js=function(t,e){return this.Zf.forEach((function(t,n){return e(n)})),Re.resolve()},t.prototype._h=function(t){return Re.resolve(this.lastRemoteSnapshotVersion)},t.prototype.lh=function(t){return Re.resolve(this.tT)},t.prototype.oh=function(t){return this.highestTargetId=this.sT.next(),Re.resolve(this.highestTargetId)},t.prototype.dh=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.tT&&(this.tT=e),Re.resolve()},t.prototype.Th=function(t){this.Zf.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.sT=new $e(e),this.highestTargetId=e),t.sequenceNumber>this.tT&&(this.tT=t.sequenceNumber)},t.prototype.fh=function(t,e){return this.Th(e),this.targetCount+=1,Re.resolve()},t.prototype.Ih=function(t,e){return this.Th(e),Re.resolve()},t.prototype.wh=function(t,e){return this.Zf.delete(e.target),this.eT.ic(e.targetId),this.targetCount-=1,Re.resolve()},t.prototype.Ah=function(t,e,n){var r=this,i=0,o=[];return this.Zf.forEach((function(s,u){u.sequenceNumber<=e&&null===n.get(u.targetId)&&(r.Zf.delete(s),o.push(r.Rh(t,u.targetId)),i++)})),Re.vn(o).next((function(){return i}))},t.prototype.Vh=function(t){return Re.resolve(this.targetCount)},t.prototype.gh=function(t,e){var n=this.Zf.get(e)||null;return Re.resolve(n)},t.prototype.ph=function(t,e,n){return this.eT.tc(e,n),Re.resolve()},t.prototype.bh=function(t,e,n){this.eT.sc(e,n);var r=this.persistence.hh,i=[];return r&&e.forEach((function(e){i.push(r.Uo(t,e))})),Re.vn(i)},t.prototype.Rh=function(t,e){return this.eT.ic(e),Re.resolve()},t.prototype.Sh=function(t,e){var n=this.eT.rc(e);return Re.resolve(n)},t.prototype.Ch=function(t,e){return Re.resolve(this.eT.Ch(e))},t}(),ki=function(){function t(t){var e=this;this.iT={},this.qh=new Ue(0),this.Uh=!1,this.Uh=!0,this.hh=t(this),this.Jh=new Ri(this),this.jn=new ze,this.Qn=new Si(this.jn,(function(t){return e.hh.nT(t)}))}return t.prototype.start=function(){return Promise.resolve()},t.prototype.Vo=function(){return this.Uh=!1,Promise.resolve()},Object.defineProperty(t.prototype,"ho",{get:function(){return this.Uh},enumerable:!0,configurable:!0}),t.prototype.oo=function(){},t.prototype.ko=function(){return this.jn},t.prototype.Do=function(t){var e=this.iT[t.s()];return e||(e=new Di(this.jn,this.hh),this.iT[t.s()]=e),e},t.prototype.Fo=function(){return this.Jh},t.prototype.No=function(){return this.Qn},t.prototype.runTransaction=function(t,e,n){var r=this;ye("MemoryPersistence","Starting transaction:",t);var i=new Pi(this.qh.next());return this.hh.rT(),n(i).next((function(t){return r.hh.hT(i).next((function(){return t}))})).yn().then((function(t){return i.Un(),t}))},t.prototype.oT=function(t,e){return Re.Sn(Object.values(this.iT).map((function(n){return function(){return n.Ch(t,e)}})))},t}(),Pi=function(t){function e(e){var n=this;return(n=t.call(this)||this).Oh=e,n}return i.__extends(e,t),e}(Ve),Vi=function(){function t(t){this.persistence=t,this.aT=new rr,this.uT=null}return t.cT=function(e){return new t(e)},Object.defineProperty(t.prototype,"_T",{get:function(){if(this.uT)return this.uT;throw me()},enumerable:!0,configurable:!0}),t.prototype.yh=function(t,e,n){return this.aT.yh(n,e),this._T.delete(n),Re.resolve()},t.prototype.vh=function(t,e,n){return this.aT.vh(n,e),this._T.add(n),Re.resolve()},t.prototype.Uo=function(t,e){return this._T.add(e),Re.resolve()},t.prototype.removeTarget=function(t,e){var n=this;
1this.aT.ic(e.targetId).forEach((function(t){return n._T.add(t)}));var r=this.persistence.Fo();return r.Sh(t,e.targetId).next((function(t){t.forEach((function(t){return n._T.add(t)}))})).next((function(){return r.wh(t,e)}))},t.prototype.rT=function(){this.uT=new Set},t.prototype.hT=function(t){var e=this,n=this.persistence.No().Yr();return Re.forEach(this._T,(function(r){return e.lT(t,r).next((function(t){t||n.Mn(r)}))})).next((function(){return e.uT=null,n.apply(t)}))},t.prototype.Ko=function(t,e){var n=this;return this.lT(t,e).next((function(t){t?n._T.delete(e):n._T.add(e)}))},t.prototype.nT=function(t){return 0},t.prototype.lT=function(t,e){var n=this;return Re.Sn([function(){return Re.resolve(n.aT.Ch(e))},function(){return n.persistence.Fo().Ch(t,e)},function(){return n.persistence.oT(t,e)}])},t}(),Li="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.",Oi=function(){function t(){}return t.prototype.initialize=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e=this;return i.__generator(this,(function(n){switch(n.label){case 0:return this.jd=this.dT(t),this.persistence=this.fT(t),[4,this.persistence.start()];case 1:return n.sent(),this.TT=this.ET(t),this.x_=this.IT(t),this.Wd=this.wT(t),this.cl=this.RT(t),this.AT=this.mT(t),this.jd.b_=function(t){return e.cl.Nd(t,1)},this.Wd.cl=this.cl,[4,this.x_.start()];case 2:return n.sent(),[4,this.jd.start()];case 3:return n.sent(),[4,this.Wd.start()];case 4:return n.sent(),[4,this.Wd.yl(this.cl.if)];case 5:return n.sent(),[2]}}))}))},t.prototype.mT=function(t){return new Ni(this.cl)},t.prototype.ET=function(t){return null},t.prototype.IT=function(t){return new tr(this.persistence,new xi,t.PT)},t.prototype.fT=function(t){if(t.gT.VT)throw new p(l.FAILED_PRECONDITION,Li);return new ki(Vi.cT)},t.prototype.wT=function(t){var e=this;return new oi(this.x_,t.w_,t.Ra,(function(t){return e.cl.Nd(t,0)}),t.platform.pT())},t.prototype.dT=function(t){return new yi},t.prototype.RT=function(t){return new bi(this.x_,this.Wd,t.w_,this.jd,t.PT,t.Kd)},t.prototype.clearPersistence=function(t){throw new p(l.FAILED_PRECONDITION,Li)},t}(),Ui=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.initialize=function(e){return i.__awaiter(this,void 0,void 0,(function(){var n=this;return i.__generator(this,(function(r){switch(r.label){case 0:return[4,t.prototype.initialize.call(this,e)];case 1:return r.sent(),[4,this.persistence.ro((function(t){return i.__awaiter(n,void 0,void 0,(function(){return i.__generator(this,(function(e){switch(e.label){case 0:return[4,this.cl.yl(t)];case 1:return e.sent(),this.TT&&(t&&!this.TT.ho?this.TT.start(this.x_):t||this.TT.stop()),[2]}}))}))}))];case 2:return r.sent(),[2]}}))}))},e.prototype.IT=function(t){return new er(this.persistence,new xi,t.PT)},e.prototype.RT=function(t){var e=new Ti(this.x_,this.Wd,t.w_,this.jd,t.PT,t.Kd);return this.jd instanceof di&&(this.jd.cl=e),e},e.prototype.ET=function(t){var e=this.persistence.hh.$o;return new $n(e,t.Ra)},e.prototype.fT=function(t){var e=un.xo(t.yT),n=t.platform.Cc(t.yT.ii);return new un(t.gT.synchronizeTabs,e,t.clientId,t.platform,Hn.nu(t.gT.cacheSizeBytes),t.Ra,n,this.jd,t.gT.Bh)},e.prototype.dT=function(t){if(t.gT.VT&&t.gT.synchronizeTabs){if(!di.zh(t.platform))throw new p(l.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var e=un.xo(t.yT);return new di(t.Ra,t.platform,e,t.clientId,t.PT)}return new yi},e.prototype.clearPersistence=function(t){var e=un.xo(t);return un.clearPersistence(e)},e}(Oi),Ci=function(){function t(t,e,n,r){this.platform=t,this.yT=e,this.credentials=n,this.Ra=r,this.clientId=_e.cn()}return t.prototype.start=function(t,e){var n=this;this.T_();var r=new Ce,i=new Ce,o=!1;return this.credentials.l((function(s){if(!o)return o=!0,ye("FirestoreClient","Initializing. user=",s.uid),n.bT(t,e,s,i).then(r.resolve,r.reject);n.Ra.lo((function(){return n.pl(s)}))})),this.Ra.co((function(){return r.promise})),i.promise},t.prototype.enableNetwork=function(){var t=this;return this.T_(),this.Ra.enqueue((function(){return t.cl.enableNetwork()}))},t.prototype.bT=function(t,e,n,r){return i.__awaiter(this,void 0,void 0,(function(){var o,s,u,a,c=this;return i.__generator(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,4]),[4,this.platform.vT(this.yT)];case 1:return o=h.sent(),s=this.platform.Cc(this.yT.ii),u=function(t,e,n){return new ni(t,e,n)}(o,this.credentials,s),[4,t.initialize({Ra:this.Ra,yT:this.yT,platform:this.platform,w_:u,clientId:this.clientId,PT:n,Kd:100,gT:e})];case 2:return h.sent(),this.persistence=t.persistence,this.jd=t.jd,this.x_=t.x_,this.Wd=t.Wd,this.cl=t.cl,this.TT=t.TT,this.ST=t.AT,this.persistence.oo((function(){return i.__awaiter(c,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return[4,this.terminate()];case 1:return t.sent(),[2]}}))}))})),r.resolve(),[3,4];case 3:if(a=h.sent(),r.reject(a),!this.DT(a))throw a;return[2,(console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+a),this.bT(new Oi,{VT:!1},n,r))];case 4:return[2]}}
1))}))},t.prototype.DT=function(t){return"FirebaseError"===t.name?t.code===l.FAILED_PRECONDITION||t.code===l.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code},t.prototype.T_=function(){if(this.Ra.Ma)throw new p(l.FAILED_PRECONDITION,"The client has already been terminated.")},t.prototype.pl=function(t){return this.Ra.Ua(),ye("FirestoreClient","Credential Changed. Current user: "+t.uid),this.cl.pl(t)},t.prototype.disableNetwork=function(){var t=this;return this.T_(),this.Ra.enqueue((function(){return t.cl.disableNetwork()}))},t.prototype.terminate=function(){var t=this;return this.Ra.Ba((function(){return i.__awaiter(t,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return this.TT&&this.TT.stop(),[4,this.Wd.Vo()];case 1:return t.sent(),[4,this.jd.Vo()];case 2:return t.sent(),[4,this.persistence.Vo()];case 3:return t.sent(),this.credentials.T(),[2]}}))}))}))},t.prototype.waitForPendingWrites=function(){var t=this;this.T_();var e=new Ce;
1return this.Ra.co((function(){return t.cl.Tf(e)})),e.promise},t.prototype.listen=function(t,e,n){var r=this;this.T_();var i=new Ai(t,e,n);return this.Ra.co((function(){return r.ST.listen(i)})),i},t.prototype.al=function(t){var e=this;this.CT||this.Ra.co((function(){return e.ST.al(t)}))},t.prototype.FT=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n=this;return i.__generator(this,(function(r){switch(r.label){case 0:return this.T_(),e=new Ce,[4,this.Ra.enqueue((function(){return i.__awaiter(n,void 0,void 0,(function(){var n,r,o;return i.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.x_.qu(t)];case 1:return(n=i.sent())instanceof mt?e.resolve(n):n instanceof wt?e.resolve(null):e.reject(new p(l.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 r=i.sent(),o=Kn(r,"Failed to get document '"+t+" from cache"),e.reject(o),[3,3];case 3:return[2]}}
1))}))}))];case 1:return[2,(r.sent(),e.promise)]}}))}))},t.prototype.NT=function(t){return i.__awaiter(this,void 0,void 0,(function(){var e,n=this;return i.__generator(this,(function(r){switch(r.label){case 0:return this.T_(),e=new Ce,[4,this.Ra.enqueue((function(){return i.__awaiter(n,void 0,void 0,(function(){var n,r,o,s,u,a;return i.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.x_.Wu(t,!0)];case 1:return n=i.sent(),r=new mi(t,n.ju),o=r.yd(n.documents),s=r.Ln(o,!1),e.resolve(s.snapshot),[3,3];case 2:return u=i.sent(),a=Kn(u,"Failed to execute query '"+t+" against cache"),e.reject(a),[3,3];case 3:return[2]}}))}))}))];case 1:return[2,(r.sent(),e.promise)]}}))}))},t.prototype.write=function(t){var e=this;this.T_();var n=new Ce;return this.Ra.co((function(){return e.cl.write(t,n)})),n.promise},t.prototype.ii=function(){return this.yT.ii},t.prototype.Nf=function(t){var e=this;this.T_(),this.Ra.co((function(){return e.ST.Nf(t),Promise.resolve()}))},t.prototype.kf=function(t){var e=this;this.CT||this.Ra.co((function(){return e.ST.kf(t),Promise.resolve()}))},Object.defineProperty(t.prototype,"CT",{get:function(){return this.Ra.Ma},enumerable:!0,configurable:!0}),t.prototype.transaction=function(t){var e=this;this.T_();var n=new Ce;
1return this.Ra.co((function(){return e.cl.runTransaction(e.Ra,t,n),Promise.resolve()})),n.promise},t}(),qi=function(){function t(t){this.observer=t,this.muted=!1}return t.prototype.next=function(t){this.kT(this.observer.next,t)},t.prototype.error=function(t){this.kT(this.observer.error,t)},t.prototype.MT=function(){this.muted=!0},t.prototype.kT=function(t,e){var n=this;this.muted||setTimeout((function(){n.muted||t(e)}),0)},t}();function ji(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 Mi=function(){function t(t,e,n,r){this.ii=t,this.timestampsInSnapshots=e,this.xT=n,this.$T=r}return t.prototype.OT=function(t){switch(U(t)){case 0:return null;case 1:return t.booleanValue;case 2:return z(t.integerValue||t.doubleValue);case 3:return this.LT(t.timestampValue);case 4:return this.BT(t);case 5:return t.stringValue;case 6:return new Ar(G(t.bytesValue));case 7:return this.qT(t.referenceValue);case 8:return this.UT(t.geoPointValue);case 9:return this.QT(t.arrayValue);case 10:return this.WT(t.mapValue);default:throw me()}},t.prototype.WT=function(t){var e=this,n={};return x(t.fields||{},(function(t,r){n[t]=e.OT(r)})),n},t.prototype.UT=function(t){return new qr(z(t.latitude),z(t.longitude))},t.prototype.QT=function(t){var e=this;return(t.values||[]).map((function(t){return e.OT(t)}))},t.prototype.BT=function(t){switch(this.xT){case"previous":var e=function t(e){var n=e.mapValue.fields.__previous_value__;return V(n)?t(n):n}(t);return null==e?null:this.OT(e);case"estimate":return this.LT(L(t));default:return null}},t.prototype.LT=function(t){var e=B(t),n=new w(e.seconds,e.nanos);return this.timestampsInSnapshots?n:n.toDate()},t.prototype.qT=function(t){var e=b.K(t);we(fe(e));var n=new Ae(e.get(1),e.get(3)),r=new N(e.M(5));return n.isEqual(this.ii)||ve("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.ii.projectId+"/"+this.ii.database+") instead."),this.$T(r)},t}(),Fi=Hn.ou,Bi=function(){function t(t){var e,n,r,i;if(void 0===t.host){if(void 0!==t.ssl)throw new p(l.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else fr("settings","non-empty string","host",t.host),this.host=t.host,lr("settings","boolean","ssl",t.ssl),this.ssl=null===(e=t.ssl)||void 0===e||e;if(wr("settings",t,["host","ssl","credentials","timestampsInSnapshots","cacheSizeBytes","experimentalForceLongPolling","ignoreUndefinedProperties"]),lr("settings","object","credentials",t.credentials),this.credentials=t.credentials,lr("settings","boolean","timestampsInSnapshots",t.timestampsInSnapshots),lr("settings","boolean","ignoreUndefinedProperties",t.ignoreUndefinedProperties),!0===t.timestampsInSnapshots?ve("The setting 'timestampsInSnapshots: true' is no longer required and should be removed."):!1===t.timestampsInSnapshots&&ve("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,lr("settings","number","cacheSizeBytes",t.cacheSizeBytes),void 0===t.cacheSizeBytes)this.cacheSizeBytes=Hn.uu;else{if(t.cacheSizeBytes!==Fi&&t.cacheSizeBytes<Hn.au)throw new p(l.INVALID_ARGUMENT,"cacheSizeBytes must be at least "+Hn.au);this.cacheSizeBytes=t.cacheSizeBytes}lr("settings","boolean","experimentalForceLongPolling",t.experimentalForceLongPolling),this.forceLongPolling=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.forceLongPolling===t.forceLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties},t}(),zi=function(){function t(e,n,r){var o=this;if(void 0===r&&(r=new Oi),this.jT=null,this.KT=new Qn,this.INTERNAL={delete:function(){return i.__awaiter(o,void 0,void 0,(function(){return i.__generator(this,(function(t){switch(t.label){case 0:return this.GT(),[4,this.zT.terminate()];case 1:return t.sent(),[2]}}))}))}}
1,"object"==typeof e.options){var s=e;this.jT=s,this.mc=t.HT(s),this.YT=s.name,this.JT=new v(n)}else{var u=e;if(!u.projectId)throw new p(l.INVALID_ARGUMENT,"Must provide projectId");this.mc=new Ae(u.projectId,u.database),this.YT="[DEFAULT]",this.JT=new y}this.XT=r,this.ZT=new Bi({})}return Object.defineProperty(t.prototype,"tE",{get:function(){return this.eE||(this.eE=new Wr(this.mc,this.ZT.ignoreUndefinedProperties)),this.eE},enumerable:!0,configurable:!0}),t.prototype.settings=function(t){sr("Firestore.settings",arguments,1),cr("Firestore.settings","object",1,t);var e=new Bi(t);if(this.zT&&!this.ZT.isEqual(e))throw new p(l.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.ZT=e,void 0!==e.credentials&&(this.JT=function(t){if(!t)return new y;switch(t.type){case"gapi":var e=t.sE;return we(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new m(e,t.V||"0");case"provider":return t.sE;default:throw new p(l.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(e.credentials))},t.prototype.enableNetwork=function(){return this.GT(),this.zT.enableNetwork()},t.prototype.disableNetwork=function(){return this.GT(),this.zT.disableNetwork()},t.prototype.enablePersistence=function(t){var e,n;if(this.zT)throw new p(l.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&&ve("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 p(l.INVALID_ARGUMENT,"The 'experimentalForceOwningTab' setting cannot be used with 'synchronizeTabs'.");return this.iE(this.XT,{VT:!0,cacheSizeBytes:this.ZT.cacheSizeBytes,synchronizeTabs:r,Bh:i})},t.prototype.clearPersistence=function(){return i.__awaiter(this,void 0,void 0,(function(){var t,e=this;return i.__generator(this,(function(n){if(void 0!==this.zT&&!this.zT.CT)throw new p(l.FAILED_PRECONDITION,"Persistence cannot be cleared after this Firestore instance is initialized.");return t=new Ce,[2,(this.KT.xa((function(){return i.__awaiter(e,void 0,void 0,(function(){var e,n;return i.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e=this.nE(),[4,this.XT.clearPersistence(e)];case 1:return r.sent(),t.resolve(),[3,3];case 2:return n=r.sent(),t.reject(n),[3,3];case 3:return[2]}}
1))}))})),t.promise)]}))}))},t.prototype.terminate=function(){return this.app._removeServiceInstance("firestore"),this.INTERNAL.delete()},Object.defineProperty(t.prototype,"rE",{get:function(){return this.GT(),this.zT.CT},enumerable:!0,configurable:!0}),t.prototype.waitForPendingWrites=function(){return this.GT(),this.zT.waitForPendingWrites()},t.prototype.onSnapshotsInSync=function(t){if(this.GT(),ji(t))return this.hE(t);cr("Firestore.onSnapshotsInSync","function",1,t);var e={next:t};return this.hE(e)},t.prototype.hE=function(t){var e=this,n=new qi({next:function(){t.next&&t.next()},error:function(t){throw me()}});return this.zT.Nf(n),function(){n.MT(),e.zT.kf(n)}},t.prototype.GT=function(){return this.zT||this.iE(new Oi,{VT:!1}),this.zT},t.prototype.nE=function(){return new Ne(this.mc,this.YT,this.ZT.host,this.ZT.ssl,this.ZT.forceLongPolling)},t.prototype.iE=function(t,e){var n=this.nE();return this.zT=new Ci(le.nt(),n,this.JT,this.KT),this.zT.start(t,e)},t.HT=function(t){if(e=t.options,!Object.prototype.hasOwnProperty.call(e,"projectId"))throw new p(l.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');var e,n=t.options.projectId;if(!n||"string"!=typeof n)throw new p(l.INVALID_ARGUMENT,"projectId must be a string in FirebaseApp.options");return new Ae(n)},Object.defineProperty(t.prototype,"app",{get:function(){if(!this.jT)throw new p(l.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.jT},enumerable:!0,configurable:!0}),t.prototype.collection=function(t){return sr("Firestore.collection",arguments,1),cr("Firestore.collection","non-empty string",1,t),this.GT(),new $i(b.K(t),this,null)},t.prototype.doc=function(t){return sr("Firestore.doc",arguments,1),cr("Firestore.doc","non-empty string",1,t),this.GT(),Qi.oE(b.K(t),this,null)},t.prototype.collectionGroup=function(t){if(sr("Firestore.collectionGroup",arguments,1),cr("Firestore.collectionGroup","non-empty string",1,t),t.indexOf("/")>=0)throw new p(l.INVALID_ARGUMENT,"Invalid collection ID '"+t+"' passed to function Firestore.collectionGroup(). Collection IDs must not contain '/'.");return this.GT(),new Xi(new bt(b.G,t),this,null)},t.prototype.runTransaction=function(t){var e=this;return sr("Firestore.runTransaction",arguments,1),cr("Firestore.runTransaction","function",1,t),this.GT().transaction((function(n){return t(new Gi(e,n))}))},t.prototype.batch=function(){return this.GT(),new Wi(this)},Object.defineProperty(t,"logLevel",{get:function(){switch(de()){case s.LogLevel.DEBUG:return"debug";case s.LogLevel.ERROR:return"error";case s.LogLevel.SILENT:return"silent";case s.LogLevel.WARN:return"warn";case s.LogLevel.INFO:return"info";case s.LogLevel.VERBOSE:return"verbose";default:return"error"}},enumerable:!0,configurable:!0}),t.setLogLevel=function(t){var e;sr("Firestore.setLogLevel",arguments,1),dr("setLogLevel",["debug","error","silent","warn","info","verbose"],1,t),e=t,pe.setLogLevel(e)},t.prototype.aE=function(){return this.ZT.timestampsInSnapshots},t}(),Gi=function(){function t(t,e){this.uE=t,this.cE=e}return t.prototype.get=function(t){var e=this;sr("Transaction.get",arguments,1);var n=no("Transaction.get",t,this.uE);return this.cE.V_([n.Pc]).then((function(t){if(!t||1!==t.length)return me();var r=t[0];if(r instanceof wt)return new Yi(e.uE,n.Pc,null,!1,!1,n.Vc);if(r instanceof mt)return new Yi(e.uE,n.Pc,r,!1,!1,n.Vc);throw me()}))},t.prototype.set=function(t,e,n){ar("Transaction.set",arguments,2,3);var r=no("Transaction.set",t,this.uE);n=Zi("Transaction.set",n);var i=io(r.Vc,e,"Transaction.set"),o=i[0],s=i[1],u=this.uE.tE.Fc(s,o,n);return this.cE.set(r.Pc,u),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 Dr?(ur("Transaction.update",arguments,3),r=no("Transaction.update",t,this.uE),i=this.uE.tE.Mc("Transaction.update",e,n,o)):(sr("Transaction.update",arguments,2),r=no("Transaction.update",t,this.uE),i=this.uE.tE.kc("Transaction.update",e)),this.cE.update(r.Pc,i),this},t.prototype.delete=function(t){sr("Transaction.delete",arguments,1
1);var e=no("Transaction.delete",t,this.uE);return this.cE.delete(e.Pc),this},t}(),Wi=function(){function t(t){this.uE=t,this._E=[],this.lE=!1}return t.prototype.set=function(t,e,n){ar("WriteBatch.set",arguments,2,3),this.dE();var r=no("WriteBatch.set",t,this.uE);n=Zi("WriteBatch.set",n);var i=io(r.Vc,e,"WriteBatch.set"),o=i[0],s=i[1],u=this.uE.tE.Fc(s,o,n);return this._E=this._E.concat(u.gc(r.Pc,ot.ft())),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.dE(),"string"==typeof e||e instanceof Dr?(ur("WriteBatch.update",arguments,3),r=no("WriteBatch.update",t,this.uE),i=this.uE.tE.Mc("WriteBatch.update",e,n,o)):(sr("WriteBatch.update",arguments,2),r=no("WriteBatch.update",t,this.uE),i=this.uE.tE.kc("WriteBatch.update",e)),this._E=this._E.concat(i.gc(r.Pc,ot.exists(!0))),this},t.prototype.delete=function(t){sr("WriteBatch.delete",arguments,1),this.dE();var e=no("WriteBatch.delete",t,this.uE);return this._E=this._E.concat(new ht(e.Pc,ot.ft())),this},t.prototype.commit=function(){return this.dE(),this.lE=!0,this._E.length>0?this.uE.GT().write(this._E):Promise.resolve()},t.prototype.dE=function(){if(this.lE)throw new p(l.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},t}(),Qi=function(t){function e(e,n,r){var i=this;return(i=t.call(this,n.mc,e,r)||this).Pc=e,i.firestore=n,i.Vc=r,i.zT=i.firestore.GT(),i}return i.__extends(e,t),e.oE=function(t,n,r){if(t.length%2!=0)throw new p(l.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t.j()+" has "+t.length);return new e(new N(t),n,r)},Object.defineProperty(e.prototype,"id",{get:function(){return this.Pc.path.L()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return new $i(this.Pc.path.$(),this.firestore,this.Vc)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this.Pc.path.j()},enumerable:!0,configurable:!0}),e.prototype.collection=function(t){if(sr("DocumentReference.collection",arguments,1),cr("DocumentReference.collection","non-empty string",1,t),!t)throw new p(l.INVALID_ARGUMENT,"Must provide a non-empty collection name to collection()");var e=b.K(t);return new $i(this.Pc.path.child(e),this.firestore,null)},e.prototype.isEqual=function(t){if(!(t instanceof e))throw Er("isEqual","DocumentReference",1,t);return this.firestore===t.firestore&&this.Pc.isEqual(t.Pc)&&this.Vc===t.Vc},e.prototype.set=function(t,e){ar("DocumentReference.set",arguments,1,2),e=Zi("DocumentReference.set",e);var n=io(this.Vc,t,"DocumentReference.set"),r=n[0],i=n[1],o=this.firestore.tE.Fc(i,r,e);return this.zT.write(o.gc(this.Pc,ot.ft()))},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 Dr?(ur("DocumentReference.update",arguments,2),n=this.firestore.tE.Mc("DocumentReference.update",t,e,r)):(sr("DocumentReference.update",arguments,1),n=this.firestore.tE.kc("DocumentReference.update",t)),this.zT.write(n.gc(this.Pc,ot.exists(!0)))},e.prototype.delete=function(){return sr("DocumentReference.delete",arguments,0),this.zT.write([new ht(this.Pc,ot.ft())])},e.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];ar("DocumentReference.onSnapshot",arguments,1,4);var n,r={includeMetadataChanges:!1},i=0;"object"!=typeof t[i]||ji(t[i])||(wr("DocumentReference.onSnapshot",r=t[i],["includeMetadataChanges"]),lr("DocumentReference.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++);var o={includeMetadataChanges:r.includeMetadataChanges};return ji(t[i])?n=t[i]:(cr("DocumentReference.onSnapshot","function",i,t[i]),hr("DocumentReference.onSnapshot","function",i+1,t[i+1]),hr("DocumentReference.onSnapshot","function",i+2,t[i+2]),n={next:t[i],error:t[i+1],complete:t[i+2]}),this.fE(o,n)},e.prototype.fE=function(t,e){var n=this,r=function(t){console.error("Uncaught Error in onSnapshot:",t)};e.error&&(r=e.error.bind(e));var i=new qi({next:function(t){if(e.next){var r=t.docs.get(n.Pc);
1e.next(new Yi(n.firestore,n.Pc,r,t.fromCache,t.hasPendingWrites,n.Vc))}},error:r}),o=this.zT.listen(bt.Wt(this.Pc.path),i,t);return function(){i.MT(),n.zT.al(o)}},e.prototype.get=function(t){var e=this;return ar("DocumentReference.get",arguments,0,1),eo("DocumentReference.get",t),new Promise((function(n,r){t&&"cache"===t.source?e.firestore.GT().FT(e.Pc).then((function(t){n(new Yi(e.firestore,e.Pc,t,!0,t instanceof mt&&t.At,e.Vc))}),r):e.TE(n,r,t)}))},e.prototype.TE=function(t,e,n){var r=this.fE({includeMetadataChanges:!0,qf:!0},{next:function(i){r(),!i.exists&&i.metadata.fromCache?e(new p(l.UNAVAILABLE,"Failed to get document because the client is offline.")):i.exists&&i.metadata.fromCache&&n&&"server"===n.source?e(new p(l.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.)')):t(i)},error:e})},e.prototype.withConverter=function(t){return new e(this.Pc,this.firestore,t)},e}(Mr),Ki=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}(),Yi=function(){function t(t,e,n,r,i,o){this.uE=t,this.Pc=e,this.EE=n,this.IE=r,this.wE=i,this.Vc=o}return t.prototype.data=function(t){var e=this;if(ar("DocumentSnapshot.data",arguments,0,1),t=to("DocumentSnapshot.data",t),this.EE){if(this.Vc){var n=new Ji(this.uE,this.Pc,this.EE,this.IE,this.wE,null);return this.Vc.fromFirestore(n,t)}return new Mi(this.uE.mc,this.uE.aE(),t.serverTimestamps||"none",(function(t){return new Qi(t,e.uE,null)})).OT(this.EE.xt())}},t.prototype.get=function(t,e){var n=this;if(ar("DocumentSnapshot.get",arguments,1,2),e=to("DocumentSnapshot.get",e),this.EE){var r=this.EE.data().field(Xr("DocumentSnapshot.get",t));if(null!==r)return new Mi(this.uE.mc,this.uE.aE(),e.serverTimestamps||"none",(function(t){return new Qi(t,n.uE,n.Vc)})).OT(r)}},Object.defineProperty(t.prototype,"id",{get:function(){return this.Pc.path.L()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ref",{get:function(){return new Qi(this.Pc,this.uE,this.Vc)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"exists",{get:function(){return null!==this.EE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"metadata",{get:function(){return new Ki(this.wE,this.IE)},enumerable:!0,configurable:!0}),t.prototype.isEqual=function(e){if(!(e instanceof t))throw Er("isEqual","DocumentSnapshot",1,e);return this.uE===e.uE&&this.IE===e.IE&&this.Pc.isEqual(e.Pc)&&(null===this.EE?null===e.EE:this.EE.isEqual(e.EE))&&this.Vc===e.Vc},t}(),Ji=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.data=function(e){return t.prototype.data.call(this,e)},e}(Yi),Xi=function(t){function e(e,n,r){var i=this;return(i=t.call(this,n.mc,n.tE,e)||this).RE=e,i.firestore=n,i.Vc=r,i}return i.__extends(e,t),e.prototype.where=function(t,n,r){sr("Query.where",arguments,3),mr("Query.where",3,r);var i=dr("Query.where",["<","<=","==",">=",">","array-contains","in","array-contains-any"],2,n),o=Xr("Query.where",t),s=this.AE(o,i,r);return new e(this.RE.Gt(s),this.firestore,this.Vc)},e.prototype.orderBy=function(t,n){var r;if(ar("Query.orderBy",arguments,1,2),hr("Query.orderBy","non-empty string",2,n),void 0===n||"asc"===n)r="asc";else{if("desc"!==n)throw new p(l.INVALID_ARGUMENT,"Function Query.orderBy() has unknown direction '"+n+"', expected 'asc' or 'desc'.");r="desc"}var i=Xr("Query.orderBy",t),o=this.gE(i,r);return new e(this.RE.zt(o),this.firestore,this.Vc)},e.prototype.limit=function(t){return sr("Query.limit",arguments,1),cr("Query.limit","number",1,t),_r("Query.limit",1,t),new e(this.RE.Ht(t),this.firestore,this.Vc)},e.prototype.limitToLast=function(t){return sr("Query.limitToLast",arguments,1),cr("Query.limitToLast","number",1,t),_r("Query.limitToLast",1,t),new e(this.RE.Yt(t),this.firestore,this.Vc)},e.prototype.startAt=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];
1ur("Query.startAt",arguments,1);var i=this.DE("Query.startAt",t,n,!0);return new e(this.RE.Jt(i),this.firestore,this.Vc)},e.prototype.startAfter=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];ur("Query.startAfter",arguments,1);var i=this.DE("Query.startAfter",t,n,!1);return new e(this.RE.Jt(i),this.firestore,this.Vc)},e.prototype.endBefore=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];ur("Query.endBefore",arguments,1);var i=this.DE("Query.endBefore",t,n,!0);return new e(this.RE.Xt(i),this.firestore,this.Vc)},e.prototype.endAt=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];ur("Query.endAt",arguments,1);var i=this.DE("Query.endAt",t,n,!1);return new e(this.RE.Xt(i),this.firestore,this.Vc)},e.prototype.isEqual=function(t){if(!(t instanceof e))throw Er("isEqual","Query",1,t);return this.firestore===t.firestore&&this.RE.isEqual(t.RE)&&this.Vc===t.Vc},e.prototype.withConverter=function(t){return new e(this.RE,this.firestore,t)},e.prototype.DE=function(t,e,n,r){if(mr(t,1,e),e instanceof Yi)return sr(t,i.__spreadArrays([e],n),1),this.yE(t,e.EE,r);var o=[e].concat(n);return this.bE(t,o,r)},e.prototype.onSnapshot=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];ar("Query.onSnapshot",arguments,1,4);var n,r={},i=0;return"object"!=typeof t[i]||ji(t[i])||(wr("Query.onSnapshot",r=t[i],["includeMetadataChanges"]),lr("Query.onSnapshot","boolean","includeMetadataChanges",r.includeMetadataChanges),i++),ji(t[i])?n=t[i]:(cr("Query.onSnapshot","function",i,t[i]),hr("Query.onSnapshot","function",i+1,t[i+1]),hr("Query.onSnapshot","function",i+2,t[i+2]),n={next:t[i],error:t[i+1],complete:t[i+2]}),this.vE(this.RE),this.fE(r,n)},e.prototype.fE=function(t,e){var n=this,r=function(t){console.error("Uncaught Error in onSnapshot:",t)};e.error&&(r=e.error.bind(e));var i=new qi({next:function(t){e.next&&e.next(new Hi(n.firestore,n.RE,t,n.Vc))},error:r}),o=this.firestore.GT(),s=o.listen(this.RE,i,t);return function(){i.MT(),o.al(s)}},e.prototype.get=function(t){var e=this;return ar("Query.get",arguments,0,1),eo("Query.get",t),this.vE(this.RE),new Promise((function(n,r){t&&"cache"===t.source?e.firestore.GT().NT(e.RE).then((function(t){n(new Hi(e.firestore,e.RE,t,e.Vc))}),r):e.TE(n,r,t)}))},e.prototype.TE=function(t,e,n){var r=this.fE({includeMetadataChanges:!0,qf:!0},{next:function(i){r(),i.metadata.fromCache&&n&&"server"===n.source?e(new p(l.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.)')):t(i)},error:e})},e}(function(){function t(t,e,n){this.mc=t,this.tE=e,this.RE=n}return t.prototype.AE=function(t,e,n){var r;if(t.Y()){if("array-contains"===e||"array-contains-any"===e)throw new p(l.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+e+"' queries on FieldPath.documentId().");if("in"===e){this.mE(n,e);for(var i=[],o=0,s=n;o<s.length;o++){var u=s[o];i.push(this.PE(u))}r={arrayValue:{values:i}}}else r=this.PE(n)}else"in"!==e&&"array-contains-any"!==e||this.mE(n,e),r=this.tE.xc("Query.where",n,"in"===e);var a=Tt.create(t,e,r);return this.VE(a),a},t.prototype.gE=function(t,e){if(null!==this.RE.startAt)throw new p(l.INVALID_ARGUMENT,"Invalid query. You must not call Query.startAt() or Query.startAfter() before calling Query.orderBy().");if(null!==this.RE.endAt)throw new p(l.INVALID_ARGUMENT,"Invalid query. You must not call Query.endAt() or Query.endBefore() before calling Query.orderBy().");var n=new Rt(t,e);return this.pE(n),n},t.prototype.yE=function(t,e,n){if(!e)throw new p(l.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+t+"().");for(var r=[],i=0,o=this.RE.orderBy;i<o.length;i++){var s=o[i];if(s.field.Y())r.push(W(this.mc,e.key));else{var u=e.field(s.field);if(V(u))throw new p(l.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+s.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===u){var a=s.field.j();throw new p(l.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+a+"' (used as the orderBy) does not exist.")}r.push(u)}}return new St(r,n)},t.prototype.bE=function(t,e,n){var r=this.RE.Lt;if(e.length>r.length)throw new p(l.INVALID_ARGUMENT,"Too many arguments provided to "+t+"(). The number of arguments must be less than or equal to the number of Query.orderBy() clauses");for(var i=[],o=0;o<e.length;o++){var s=e[o];if(r[o].field.Y()){if("string"!=typeof s)throw new p(l.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+t+"(), but got a "+typeof s);if(!this.RE._e()&&-1!==s.indexOf("/"))throw new p(l.INVALID_ARGUMENT,"Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to "+t+"() must be a plain document ID, but '"+s+"' contains a slash.");var u=this.RE.path.child(b.K(s));if(!N.et(u))throw new p(l.INVALID_ARGUMENT,"Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to "+t+"() must result in a valid document path, but '"+u+"' is not because it c
1ontains an odd number of segments.");var a=new N(u);i.push(W(this.mc,a))}else{var c=this.tE.xc(t,s);i.push(c)}}return new St(i,n)},t.prototype.vE=function(t){if(t.ae()&&0===t.Lt.length)throw new p(l.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")},t.prototype.PE=function(t){if("string"==typeof t){if(""===t)throw new p(l.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!this.RE._e()&&-1!==t.indexOf("/"))throw new p(l.INVALID_ARGUMENT,"Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '"+t+"' contains a '/' character.");var e=this.RE.path.child(b.K(t));if(!N.et(e))throw new p(l.INVALID_ARGUMENT,"Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '"+e+"' is not because it has an odd number of segments ("+e.length+").");return W(this.mc,new N(e))}if(t instanceof Mr)return W(this.mc,t.Pc);throw new p(l.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+gr(t)+".")},t.prototype.mE=function(t,e){if(!Array.isArray(t)||0===t.length)throw new p(l.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(t.length>10)throw new p(l.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.");if(t.indexOf(null)>=0)throw new p(l.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 p(l.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters cannot contain 'NaN' in the value array.")},t.prototype.VE=function(t){if(t instanceof Tt){var e=["array-contains","array-contains-any"],n=["in","array-contains-any"],r=e.indexOf(t.op)>=0,i=n.indexOf(t.op)>=0;if(t.ue()){var o=this.RE.jt();if(null!==o&&!o.isEqual(t.field))throw new p(l.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, >, or >=) must be on the same field. But you have inequality filters on '"+o.toString()+"' and '"+t.field.toString()+"'");var s=this.RE.Kt();null!==s&&this.SE(t.field,s)}else if(i||r){var u=null;if(i&&(u=this.RE.ce(n)),null===u&&r&&(u=this.RE.ce(e)),null!=u)throw u===t.op?new p(l.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+t.op.toString()+"' filter."):new p(l.INVALID_ARGUMENT,"Invalid query. You cannot use '"+t.op.toString()+"' filters with '"+u.toString()+"' filters.")}}},t.prototype.pE=function(t){if(null===this.RE.Kt()){var e=this.RE.jt();null!==e&&this.SE(e,t.field)}},t.prototype.SE=function(t,e){if(!e.isEqual(t))throw new p(l.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, >, or >=) on field '"+t.toString()+"' and so you must also use '"+t.toString()+"' as your first Query.orderBy(), but your first Query.orderBy() is on field '"+e.toString()+"' instead.")},t}()),Hi=function(){function t(t,e,n,r){this.uE=t,this.CE=e,this.FE=n,this.Vc=r,this.NE=null,this.kE=null,this.metadata=new Ki(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:!0,configurable:!0}),Object.defineProperty(t.prototype,"empty",{get:function(){return this.FE.docs.B()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this.FE.docs.size},enumerable:!0,configurable:!0}),t.prototype.forEach=function(t,e){var n=this;ar("QuerySnapshot.forEach",arguments,1,2),cr("QuerySnapshot.forEach","function",1,t),this.FE.docs.forEach((function(r){t.call(e,n.ME(r))}))},Object.defineProperty(t.prototype,"query",{get:function(){return new Xi(this.CE,this.uE,this.Vc)},enumerable:!0,configurable:!0}),t.prototype.docChanges=function(t){t&&(wr("QuerySnapshot.docChanges",t,["includeMetadataChanges"]),lr("QuerySnapsh
1ot.docChanges","boolean","includeMetadataChanges",t.includeMetadataChanges));var e=!(!t||!t.includeMetadataChanges);if(e&&this.FE.hs)throw new p(l.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this.NE&&this.kE===e||(this.NE=function(t,e,n,r){if(n.ss.B()){var i=0;return n.docChanges.map((function(e){var o=new Ji(t,e.doc.key,e.doc,n.fromCache,n.ns.has(e.doc.key),r);return e.doc,{type:"added",doc:o,oldIndex:-1,newIndex:i++}}))}var o=n.ss;return n.docChanges.filter((function(t){return e||3!==t.type})).map((function(e){var i=new Ji(t,e.doc.key,e.doc,n.fromCache,n.ns.has(e.doc.key),r),s=-1,u=-1;return 0!==e.type&&(s=o.indexOf(e.doc.key),o=o.delete(e.doc.key)),1!==e.type&&(u=(o=o.add(e.doc)).indexOf(e.doc.key)),{type:ro(e.type),doc:i,oldIndex:s,newIndex:u}}))}(this.uE,e,this.FE,this.Vc),this.kE=e),this.NE},t.prototype.isEqual=function(e){if(!(e instanceof t))throw Er("isEqual","QuerySnapshot",1,e);return this.uE===e.uE&&this.CE.isEqual(e.CE)&&this.FE.isEqual(e.FE)&&this.Vc===e.Vc},t.prototype.ME=function(t){return new Ji(this.uE,t.key,t,this.metadata.fromCache,this.FE.ns.has(t.key),this.Vc)},t}(),$i=function(t){function e(e,n,r){var i=this;if((i=t.call(this,bt.Wt(e),n,r)||this).xE=e,e.length%2!=1)throw new p(l.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+e.j()+" has "+e.length);return i}return i.__extends(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this.RE.path.L()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){var t=this.RE.path.$();return t.B()?null:new Qi(new N(t),this.firestore,null)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this.RE.path.j()},enumerable:!0,configurable:!0}),e.prototype.doc=function(t){ar("CollectionReference.doc",arguments,0,1),0===arguments.length&&(t=_e.cn()),cr("CollectionReference.doc","non-empty string",1,t);var e=b.K(t);return Qi.oE(this.RE.path.child(e),this.firestore,this.Vc)},e.prototype.add=function(t){sr("CollectionReference.add",arguments,1),cr("CollectionReference.add","object",1,this.Vc?this.Vc.toFirestore(t):t);var e=this.doc();return e.set(t).then((function(){return e}))},e.prototype.withConverter=function(t){return new e(this.xE,this.firestore,t)},e}(Xi);function Zi(t,e){if(void 0===e)return{merge:!1};if(wr(t,e,["merge","mergeFields"]),lr(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 p(l.INVALID_ARGUMENT,"Function "+t+"() requires its "+e+" option to be an array, but it was: "+gr(r));for(var o=0;o<r.length;++o)if(!i(r[o]))throw new p(l.INVALID_ARGUMENT,"Function "+t+"() requires all "+e+" elements to be a string or a FieldPath, but the value at index "+o+" was: "+gr(r[o]))}(t,"mergeFields",0,r,(function(t){return"string"==typeof t||t instanceof Dr}))}(t,0,0,e.mergeFields),void 0!==e.mergeFields&&void 0!==e.merge)throw new p(l.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function to(t,e){return void 0===e?{}:(wr(t,e,["serverTimestamps"]),pr(t,0,"serverTimestamps",e.serverTimestamps,["estimate","previous","none"]),e)}function eo(t,e){hr(t,"object",1,e),e&&(wr(t,e,["source"]),pr(t,0,"source",e.source,["default","server","cache"]))}function no(t,e,n){if(e instanceof Mr){if(e.firestore!==n)throw new p(l.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}throw Er(t,"DocumentReference",1,e)}function ro(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return me()}}function io(t,e,n){var r;return t?(r=t.toFirestore(e),n="toFirestore() in "+n):r=e,[r,n]}function oo(t,e){function n(){var t="This constructor is private.";throw e&&(t+=" ",t+=e),new p(l.INVALID_ARGUMENT,t)}return n.prototype=t.prototype,Object.assign(n,t),n}var so=oo(zi,"Use firebase.firestore() instead."),uo=oo(Gi,"Use firebase.firestore().runTransaction() instead."),ao=oo(Wi,"Use firebase.firestore().batch() instead."),co=oo(Qi,"Use firebase.firestore().doc() instead."),ho=oo(Yi),fo=oo(Ji),lo=oo(Xi),po=oo(Hi),yo=oo($i,"Use firebase.firestore().collection() instead."),vo=oo(Ur,"Use FieldValue.<field>() instead."),go=oo(Ar,"Use Blob.fromUint8Array() or Blob.fromBase64String() instead."),mo={Firestore:so,GeoPoint:qr,Timestamp:w,Blob:go,Transaction:uo,WriteBatch:ao,DocumentReference:co,DocumentSnapshot:ho,Query:lo,QueryDocumentSnapshot:fo,QuerySnapsh
1ot:po,CollectionReference:yo,FieldPath:Dr,FieldValue:vo,setLogLevel:zi.setLogLevel,CACHE_SIZE_UNLIMITED:Fi},wo=function(){function t(){}return t.prototype.Q_=function(t){},t.prototype.Vo=function(){},t}(),Eo=function(){function t(){var t=this;this.$E=function(){return t.OE()},this.LE=function(){return t.BE()},this.qE=[],this.UE()}return t.prototype.Q_=function(t){this.qE.push(t)},t.prototype.Vo=function(){window.removeEventListener("online",this.$E),window.removeEventListener("offline",this.LE)},t.prototype.UE=function(){window.addEventListener("online",this.$E),window.addEventListener("offline",this.LE)},t.prototype.OE=function(){ye("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.qE;t<e.length;t++)(0,e[t])(0)},t.prototype.BE=function(){ye("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.qE;t<e.length;t++)(0,e[t])(1)},t.zh=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},t}(),_o=function(){function t(t){this.QE=t.QE,this.WE=t.WE}return t.prototype.s_=function(t){this.jE=t},t.prototype.Jc=function(t){this.KE=t},t.prototype.onMessage=function(t){this.GE=t},t.prototype.close=function(){this.WE()},t.prototype.send=function(t){this.QE(t)},t.prototype.zE=function(){this.jE()},t.prototype.HE=function(t){this.KE(t)},t.prototype.YE=function(t){this.GE(t)},t}(),bo={BatchGetDocuments:"batchGet",Commit:"commit"},To="gl-js/ fire/"+h,Io=function(){function t(t){this.ii=t.ii;var e=t.ssl?"https":"http";this.JE=e+"://"+t.host,this.forceLongPolling=t.forceLongPolling}return t.prototype.XE=function(t,e){if(e)for(var n in e.o)e.o.hasOwnProperty(n)&&(t[n]=e.o[n]);t["X-Goog-Api-Client"]=To},t.prototype.E_=function(t,e,n){var r=this,i=this.ZE(t);return new Promise((function(o,s){var u=new c.XhrIo;u.listenOnce(c.EventType.COMPLETE,(function(){try{switch(u.getLastErrorCode()){case c.ErrorCode.NO_ERROR:var e=u.getResponseJson();ye("Connection","XHR received:",JSON.stringify(e)),o(e);break;case c.ErrorCode.TIMEOUT:ye("Connection",'RPC "'+t+'" timed out'),s(new p(l.DEADLINE_EXCEEDED,"Request time out"));break;case c.ErrorCode.HTTP_ERROR:var n=u.getStatus();if(ye("Connection",'RPC "'+t+'" failed with status:',n,"response text:",u.getResponseText()),n>0){var r=u.getResponseJson().error;if(r&&r.status&&r.message){var i=function(t){var e=t.toLowerCase().replace("_","-");return Object.values(l).indexOf(e)>=0?e:l.UNKNOWN}(r.status);s(new p(i,r.message))}else s(new p(l.UNKNOWN,"Server responded with status "+u.getStatus()))}else ye("Connection",'RPC "'+t+'" failed'),s(new p(l.UNAVAILABLE,"Connection failed."));break;default:me()}}finally{ye("Connection",'RPC "'+t+'" completed.')}}));var a=Object.assign({},e);delete a.database;var h=JSON.stringify(a);ye("Connection","XHR sending: ",i+" "+h);var f={"Content-Type":"text/plain"};r.XE(f,n),u.send(i,"POST",h,f,15)}))},t.prototype.I_=function(t,e,n){return this.E_(t,e,n)},t.prototype.i_=function(t,e){var n=[this.JE,"/","google.firestore.v1.Firestore","/",t,"/channel"],r=c.createWebChannelTransport(),o={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.ii.projectId+"/databases/"+this.ii.database},sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling};this.XE(o.initMessageHeaders,e),u.isMobileCordova()||u.isReactNative()||u.isElectron()||u.isIE()||u.isUWP()||u.isBrowserExtension()||(o.httpHeadersOverwriteParam="$httpHeaders");var a=n.join("");ye("Connection","Creating WebChannel: "+a+" "+o);var f=r.createWebChannel(a,o),d=!1,y=!1,v=new _o({QE:function(t){y?ye("Connection","Not sending because WebChannel is closed:",t):(d||(ye("Connection","Opening WebChannel transport."),f.open(),d=!0),ye("Connection","WebChannel sending:",t),f.send(t))},WE:function(){return f.close()}}),g=function(t,e){f.listen(t,(function(t){try{e(t)}catch(t){setTimeout((function(){throw t}),0)}}))};return g(c.WebChannel.EventType.OPEN,(function(){y||ye("Connection","WebChannel transport opened.")}
1)),g(c.WebChannel.EventType.CLOSE,(function(){y||(y=!0,ye("Connection","WebChannel transport closed"),v.HE())})),g(c.WebChannel.EventType.ERROR,(function(t){y||(y=!0,function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(pe.logLevel<=s.LogLevel.WARN){var r=e.map(ge);pe.warn.apply(pe,i.__spreadArrays(["Firestore ("+h+"): "+t],r))}}("Connection","WebChannel transport errored:",t),v.HE(new p(l.UNAVAILABLE,"The operation could not be completed")))})),g(c.WebChannel.EventType.MESSAGE,(function(t){var e;if(!y){var n=t.data[0];we(!!n);var r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){ye("Connection","WebChannel received error:",i);var o=i.status,s=function(t){var e=yt[t];if(void 0!==e)return Lt(e)}(o),u=i.message;void 0===s&&(s=l.INTERNAL,u="Unknown error status: "+o+" with message "+i.message),y=!0,v.HE(new p(s,u)),f.close()}else ye("Connection","WebChannel received:",n),v.YE(n)}})),setTimeout((function(){v.zE()}),0),v},t.prototype.ZE=function(t){var e=bo[t];return this.JE+"/v1/projects/"+this.ii.projectId+"/databases/"+this.ii.database+"/documents:"+e},t}();function No(t){!function(t,e){t.INTERNAL.registerComponent(new a.Component("firestore",(function(t){return function(t,e){return new zi(t,e,new Ui)}(t.getProvider("app").getImmediate(),t.getProvider("auth-internal"))}),"PUBLIC").setServiceProps(Object.assign({},mo)))}(t),t.registerVersion("@firebase/firestore","1.15.4")}le.an(new(function(){function t(){this.oc="undefined"!=typeof atob}return Object.defineProperty(t.prototype,"document",{get:function(){return"undefined"!=typeof document?document:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"window",{get:function(){return"undefined"!=typeof window?window:null},enumerable:!0,configurable:!0}),t.prototype.vT=function(t){return Promise.resolve(new Io(t))},t.prototype.pT=function(){return Eo.zh()?new Eo:new wo},t.prototype.Cc=function(t){return new he(t,{hi:!0})},t.prototype.un=function(t){return JSON.stringify(t)},t.prototype.atob=function(t){return atob(t)},t.prototype.btoa=function(t){return btoa(t)},t.prototype._n=function(t){var e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e)e.getRandomValues(n);else for(var r=0;r<t;r++)n[r]=Math.floor(256*Math.random());return n},t}())),No(o),e.__PRIVATE_registerFirestore=No}}]);

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