PageSourceSearch

https://itransform2022.netlify.app/a2267787-5c171f7dc71a6541f5a9.js

js itransform2022.netlify.app collected 2026-10-03 10:55:59 UTC 290,086 bytes, 3 lines download raw bytes

1/*! For license information please see a2267787-5c171f7dc71a6541f5a9.js.LICENSE.txt */
2"use strict";(self.webpackChunkitransform=self.webpackChunkitransform||[]).push([[972],{7840:function(t,e,n){n.d(e,{C:function(){return zu},E:function(){return Mu},G:function(){return sc},H:function(){return ac},K:function(){return nc},L:function(){return tc},M:function(){return _},T:function(){return Vu},U:function(){return ec},W:function(){return oc},Z:function(){return lc},c:function(){return bc},e:function(){return pc},i:function(){return vc},j:function(){return ic},o:function(){return wc},s:function(){return mc},t:function(){return dc}});var r=n(7763),i=n(9277),o=n(5190),s=n(8689),u=function(){function t(t,e){var n=this;this.previousValue=t,e&&(e.sequenceNumberHandler=function(t){return n.t(t)},this.i=function(t){return e.writeSequenceNumber(t)})}return t.prototype.t=function(t){return this.previousValue=Math.max(t,this.previousValue),this.previousValue},t.prototype.next=function(){var t=++this.previousValue;return this.i&&this.i(t),t},t}();u.o=-1;var a={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"},c=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(0,r.ZT)(e,t),e}(Error),h=new o.Yd("@firebase/firestore");function f(){return h.logLevel}function l(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(h.logLevel<=o.in.DEBUG){var i=e.map(y);h.debug.apply(h,(0,r.ev)(["Firestore (8.10.1): "+t],i))}}function d(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(h.logLevel<=o.in.ERROR){var i=e.map(y);h.error.apply(h,(0,r.ev)(["Firestore (8.10.1): "+t],i))}}function p(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(h.logLevel<=o.in.WARN){var i=e.map(y);h.warn.apply(h,(0,r.ev)(["Firestore (8.10.1): "+t],i))}}function y(t){if("string"==typeof t)return t;try{return e=t,JSON.stringify(e)}catch(e){return t}var e}function m(t){void 0===t&&(t="Unexpected state");var e="FIRESTORE (8.10.1) INTERNAL ASSERTION FAILED: "+t;throw d(e),new Error(e)}function v(t,e){t||m()}function g(t,e){return t}function w(t){var e="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(t);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(n);else for(var r=0;r<t;r++)n[r]=Math.floor(256*Math.random());return n}var b=function(){function t(){}return t.u=function(){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e=Math.floor(256/t.length)*t.length,n="";n.length<20;)for(var r=w(40),i=0;i<r.length;++i)n.length<20&&r[i]<e&&(n+=t.charAt(r[i]%t.length));return n},t}();function I(t,e){return t<e?-1:t>e?1:0}function T(t,e,n){return t.length===e.length&&t.every((function(t,r){return n(t,e[r])}))}function E(t){return t+"\0"}var _=function(){function t(t,e){if(this.seconds=t,this.nanoseconds=e,e<0)throw new c(a.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(e>=1e9)throw new c(a.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800)throw new c(a.INVALID_ARGUMENT,"Timestamp seconds out of range: "+t);if(t>=253402300800)throw new c(a.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,Math.floor(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._compareTo=function(t){return this.seconds===t.seconds?I(this.nanoseconds,t.nanoseconds):I(this.seconds,t.seconds)},t.prototype.isEqual=function(t){return t.seconds===this.seconds&&t.nanoseconds===this.nanoseconds},t.prototype.toString=function(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"},t.prototype.toJSON=function(){return{seconds:this.seconds,nanoseconds:this.nanoseconds}},t.prototype.valueOf=function(){var t=this.seconds- -62135596800;return String(t).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}
2,t}(),S=function(){function t(t){this.timestamp=t}return t.fromTimestamp=function(e){return new t(e)},t.min=function(){return new t(new _(0,0))},t.prototype.compareTo=function(t){return this.timestamp._compareTo(t.timestamp)},t.prototype.isEqual=function(t){return this.timestamp.isEqual(t.timestamp)},t.prototype.toMicroseconds=function(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3},t.prototype.toString=function(){return"SnapshotVersion("+this.timestamp.toString()+")"},t.prototype.toTimestamp=function(){return this.timestamp},t}();function N(t){var e=0;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function D(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function A(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}var k=function(){function t(t,e,n){void 0===e?e=0:e>t.length&&m(),void 0===n?n=t.length-e:n>t.length-e&&m(),this.segments=t,this.offset=e,this.len=n}return Object.defineProperty(t.prototype,"length",{get:function(){return this.len},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){return 0===t.comparator(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.construct(n)},t.prototype.limit=function(){return this.offset+this.length},t.prototype.popFirst=function(t){return t=void 0===t?1:t,this.construct(this.segments,this.offset+t,this.length-t)},t.prototype.popLast=function(){return this.construct(this.segments,this.offset,this.length-1)},t.prototype.firstSegment=function(){return this.segments[this.offset]},t.prototype.lastSegment=function(){return this.get(this.length-1)},t.prototype.get=function(t){return this.segments[this.offset+t]},t.prototype.isEmpty=function(){return 0===this.length},t.prototype.isPrefixOf=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.isImmediateParentOf=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.toArray=function(){return this.segments.slice(this.offset,this.limit())},t.comparator=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}(),C=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,r.ZT)(e,t),e.prototype.construct=function(t,n,r){return new e(t,n,r)},e.prototype.canonicalString=function(){return this.toArray().join("/")},e.prototype.toString=function(){return this.canonicalString()},e.fromString=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=[],i=0,o=t;i<o.length;i++){var s=o[i];if(s.indexOf("//")>=0)throw new c(a.INVALID_ARGUMENT,"Invalid segment ("+s+"). Paths must not contain // in them.");r.push.apply(r,s.split("/").filter((function(t){return t.length>0})))}return new e(r)},e.emptyPath=function(){return new e([])},e}(k),x=/^[_a-zA-Z][_a-zA-Z0-9]*$/,R=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,r.ZT)(e,t),e.prototype.construct=function(t,n,r){return new e(t,n,r)},e.isValidIdentifier=function(t){return x.test(t)},e.prototype.canonicalString=function(){return this.toArray().map((function(t){return t=t.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),e.isValidIdentifier(t)||(t="`"+t+"`"),t})).join(".")},e.prototype.toString=function(){return this.canonicalString()},e.prototype.isKeyField=function(){return 1===this.length&&"__name__"===this.get(0)},e.keyField=function(){return new e(["__name__"])},e.fromServerFormat=function(t){for(var n=[],r="",i=0,o=function(){if(0===r.length)throw new c(a.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 c(a.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var h=t[i+1];if("\\"!==h&&"."!==h&&"`"!==h)throw new c(a.INVALID_ARGUMENT,"Path has invali
2d escape sequence: "+t);r+=h,i+=2}else"`"===u?(s=!s,i++):"."!==u||s?(r+=u,i++):(o(),i++)}if(o(),s)throw new c(a.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)},e.emptyPath=function(){return new e([])},e}(k),L=function(){function t(t){this.fields=t,t.sort(R.comparator)}return t.prototype.covers=function(t){for(var e=0,n=this.fields;e<n.length;e++)if(n[e].isPrefixOf(t))return!0;return!1},t.prototype.isEqual=function(t){return T(this.fields,t.fields,(function(t,e){return t.isEqual(e)}))},t}(),O=function(){function t(t){this.binaryString=t}return t.fromBase64String=function(e){return new t(atob(e))},t.fromUint8Array=function(e){return new t(function(t){for(var e="",n=0;n<t.length;++n)e+=String.fromCharCode(t[n]);return e}(e))},t.prototype.toBase64=function(){return t=this.binaryString,btoa(t);var t},t.prototype.toUint8Array=function(){return function(t){for(var e=new Uint8Array(t.length),n=0;n<t.length;n++)e[n]=t.charCodeAt(n);return e}(this.binaryString)},t.prototype.approximateByteSize=function(){return 2*this.binaryString.length},t.prototype.compareTo=function(t){return I(this.binaryString,t.binaryString)},t.prototype.isEqual=function(t){return this.binaryString===t.binaryString},t}();O.EMPTY_BYTE_STRING=new O("");var P=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function F(t){if(v(!!t),"string"==typeof t){var e=0,n=P.exec(t);if(v(!!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:M(t.seconds),nanos:M(t.nanos)}}function M(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function V(t){return"string"==typeof t?O.fromBase64String(t):O.fromUint8Array(t)}function q(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 U(t){var e=t.mapValue.fields.__previous_value__;return q(e)?U(e):e}function G(t){var e=F(t.mapValue.fields.__local_write_time__.timestampValue);return new _(e.seconds,e.nanos)}function B(t){return null==t}function j(t){return 0===t&&1/t==-1/0}function K(t){return"number"==typeof t&&Number.isInteger(t)&&!j(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}var Q=function(){function t(t){this.path=t}return t.fromPath=function(e){return new t(C.fromString(e))},t.fromName=function(e){return new t(C.fromString(e).popFirst(5))},t.prototype.hasCollectionId=function(t){return this.path.length>=2&&this.path.get(this.path.length-2)===t},t.prototype.isEqual=function(t){return null!==t&&0===C.comparator(this.path,t.path)},t.prototype.toString=function(){return this.path.toString()},t.comparator=function(t,e){return C.comparator(t.path,e.path)},t.isDocumentKey=function(t){return t.length%2==0},t.fromSegments=function(e){return new t(new C(e.slice()))},t}();function z(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?q(t)?4:10:m()}function J(t,e){var n=z(t);if(n!==z(e))return!1;switch(n){case 0:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return G(t).isEqual(G(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=F(t.timestampValue),r=F(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 V(t.bytesValue).isEqual(V(e.bytesValue))}(t,e);case 7:return t.referenceValue===e.referenceValue;case 8:return function(t,e){return M(t.geoPointValue.latitude)===M(e.geoPointValue.latitude)&&M(t.geoPointValue.longitude)===M(e.geoPointValue.longitude)}(t,e);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return M(t.integerValue)===M(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){var n=M(t.doubleValue),r=M(e.doubleValue);return n===r?j(n)===j(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return T(t.arrayValue.values||[],e.arrayValue.values||[],J);case 10:return function(t,e){var n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(N(n)!==N(r))return!1;for(var i in n)if(n.hasOwnProperty(i)&&(void 0===r[i]||!J(n[i],r[i])))return!1;return!0}(t,e);default:return m()}}function W(t,e){return void 0!==(t.values||[]).find((function(t){return J(t,e)}))}function H(t,e){var n=z(t),r=z(e);
2if(n!==r)return I(n,r);switch(n){case 0:return 0;case 1:return I(t.booleanValue,e.booleanValue);case 2:return function(t,e){var n=M(t.integerValue||t.doubleValue),r=M(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 Z(t.timestampValue,e.timestampValue);case 4:return Z(G(t),G(e));case 5:return I(t.stringValue,e.stringValue);case 6:return function(t,e){var n=V(t),r=V(e);return n.compareTo(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=I(n[i],r[i]);if(0!==o)return o}return I(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return function(t,e){var n=I(M(t.latitude),M(e.latitude));return 0!==n?n:I(M(t.longitude),M(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=H(n[i],r[i]);if(o)return o}return I(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=I(r[s],o[s]);if(0!==u)return u;var a=H(n[r[s]],i[o[s]]);if(0!==a)return a}return I(r.length,o.length)}(t.mapValue,e.mapValue);default:throw m()}}function Z(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return I(t,e);var n=F(t),r=F(e),i=I(n.seconds,r.seconds);return 0!==i?i:I(n.nanos,r.nanos)}function Y(t){return $(t)}function $(t){return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?function(t){var e=F(t);return"time("+e.seconds+","+e.nanos+")"}(t.timestampValue):"stringValue"in t?t.stringValue:"bytesValue"in t?V(t.bytesValue).toBase64():"referenceValue"in t?(n=t.referenceValue,Q.fromName(n).toString()):"geoPointValue"in t?"geo("+(e=t.geoPointValue).latitude+","+e.longitude+")":"arrayValue"in t?function(t){for(var e="[",n=!0,r=0,i=t.values||[];r<i.length;r++)n?n=!1:e+=",",e+=$(i[r]);return e+"]"}(t.arrayValue):"mapValue"in t?function(t){for(var e="{",n=!0,r=0,i=Object.keys(t.fields||{}).sort();r<i.length;r++){var o=i[r];n?n=!1:e+=",",e+=o+":"+$(t.fields[o])}return e+"}"}(t.mapValue):m();var e,n}function X(t,e){return{referenceValue:"projects/"+t.projectId+"/databases/"+t.database+"/documents/"+e.path.canonicalString()}}function tt(t){return!!t&&"integerValue"in t}function et(t){return!!t&&"arrayValue"in t}function nt(t){return!!t&&"nullValue"in t}function rt(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function it(t){return!!t&&"mapValue"in t}function ot(t){if(t.geoPointValue)return{geoPointValue:Object.assign({},t.geoPointValue)};if(t.timestampValue&&"object"==typeof t.timestampValue)return{timestampValue:Object.assign({},t.timestampValue)};if(t.mapValue){var e={mapValue:{fields:{}}};return D(t.mapValue.fields,(function(t,n){return e.mapValue.fields[t]=ot(n)})),e}if(t.arrayValue){for(var n={arrayValue:{values:[]}},r=0;r<(t.arrayValue.values||[]).length;++r)n.arrayValue.values[r]=ot(t.arrayValue.values[r]);return n}return Object.assign({},t)}var st=function(){function t(t){this.value=t}return t.empty=function(){return new t({mapValue:{}})},t.prototype.field=function(t){if(t.isEmpty())return this.value;for(var e=this.value,n=0;n<t.length-1;++n)if(!it(e=(e.mapValue.fields||{})[t.get(n)]))return null;return(e=(e.mapValue.fields||{})[t.lastSegment()])||null},t.prototype.set=function(t,e){this.getFieldsMap(t.popLast())[t.lastSegment()]=ot(e)},t.prototype.setAll=function(t){var e=this,n=R.emptyPath(),r={},i=[];t.forEach((function(t,o){if(!n.isImmediateParentOf(o)){var s=e.getFieldsMap(n);e.applyChanges(s,r,i),r={},i=[],n=o.popLast()}t?r[o.lastSegment()]=ot(t):i.push(o.lastSegment())}));var o=this.getFieldsMap(n);this.applyChanges(o,r,i)},t.prototype.delete=function(t){var e=this.field(t.popLast());it(e)&&e.mapValue.fields&&delete e.mapValue.fields[t.lastSegment()]},t.prototype.isEqual=function(t){return J(this.value,t.value)},t.prototype.getFieldsMap=function(t){var e=this.value;e.mapValue.fields||(e.mapValue={fields:{}});for(var n=0;n<t.length;++n){var r=e.mapValue.fields[t.get(n)];it(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},e.mapValue.fields[t.get(n)]=r),e=r}return e.mapValue.fields},t.prototype.applyChanges=function(t,e,n){D(e,(function(e,n){return t[e]=n}));for(var r=0,i=n;r<i.length;r++){var o=i[r];delete t[o]}},t.prototype.clone=function(){return new t(ot(this.value))},t}();function ut(t){var e=[];return D(t.fields,(function(t,n){var r=new R([t]);if(it(n)){var i=ut(n.mapValue).fields;
2if(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 L(e)}var at=function(){function t(t,e,n,r,i){this.key=t,this.documentType=e,this.version=n,this.data=r,this.documentState=i}return t.newInvalidDocument=function(e){return new t(e,0,S.min(),st.empty(),0)},t.newFoundDocument=function(e,n,r){return new t(e,1,n,r,0)},t.newNoDocument=function(e,n){return new t(e,2,n,st.empty(),0)},t.newUnknownDocument=function(e,n){return new t(e,3,n,st.empty(),2)},t.prototype.convertToFoundDocument=function(t,e){return this.version=t,this.documentType=1,this.data=e,this.documentState=0,this},t.prototype.convertToNoDocument=function(t){return this.version=t,this.documentType=2,this.data=st.empty(),this.documentState=0,this},t.prototype.convertToUnknownDocument=function(t){return this.version=t,this.documentType=3,this.data=st.empty(),this.documentState=2,this},t.prototype.setHasCommittedMutations=function(){return this.documentState=2,this},t.prototype.setHasLocalMutations=function(){return this.documentState=1,this},Object.defineProperty(t.prototype,"hasLocalMutations",{get:function(){return 1===this.documentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasCommittedMutations",{get:function(){return 2===this.documentState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPendingWrites",{get:function(){return this.hasLocalMutations||this.hasCommittedMutations},enumerable:!1,configurable:!0}),t.prototype.isValidDocument=function(){return 0!==this.documentType},t.prototype.isFoundDocument=function(){return 1===this.documentType},t.prototype.isNoDocument=function(){return 2===this.documentType},t.prototype.isUnknownDocument=function(){return 3===this.documentType},t.prototype.isEqual=function(e){return e instanceof t&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)},t.prototype.clone=function(){return new t(this.key,this.documentType,this.version,this.data.clone(),this.documentState)},t.prototype.toString=function(){return"Document("+this.key+", "+this.version+", "+JSON.stringify(this.data.value)+", {documentType: "+this.documentType+"}), {documentState: "+this.documentState+"})"},t}(),ct=function(t,e,n,r,i,o,s){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===s&&(s=null),this.path=t,this.collectionGroup=e,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=o,this.endAt=s,this.h=null};function ht(t,e,n,r,i,o,s){return void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o=null),void 0===s&&(s=null),new ct(t,e,n,r,i,o,s)}function ft(t){var e=g(t);if(null===e.h){var n=e.path.canonicalString();null!==e.collectionGroup&&(n+="|cg:"+e.collectionGroup),n+="|f:",n+=e.filters.map((function(t){return function(t){return t.field.canonicalString()+t.op.toString()+Y(t.value)}(t)})).join(","),n+="|ob:",n+=e.orderBy.map((function(t){return function(t){return t.field.canonicalString()+t.dir}(t)})).join(","),B(e.limit)||(n+="|l:",n+=e.limit),e.startAt&&(n+="|lb:",n+=_t(e.startAt)),e.endAt&&(n+="|ub:",n+=_t(e.endAt)),e.h=n}return e.h}function lt(t,e){if(t.limit!==e.limit)return!1;if(t.orderBy.length!==e.orderBy.length)return!1;for(var n=0;n<t.orderBy.length;n++)if(!Nt(t.orderBy[n],e.orderBy[n]))return!1;if(t.filters.length!==e.filters.length)return!1;for(var r=0;r<t.filters.length;r++)if(i=t.filters[r],o=e.filters[r],i.op!==o.op||!i.field.isEqual(o.field)||!J(i.value,o.value))return!1;var i,o;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!At(t.startAt,e.startAt)&&At(t.endAt,e.endAt)}function dt(t){return Q.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}var pt=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(0,r.ZT)(e,t),e.create=function(t,n,r){return t.isKeyField()?"in"===n||"not-in"===n?this.l(t,n,r):new yt(t,n,r):"array-contains"===n?new wt(t,r):"in"===n?new bt(t,r):"not-in"===n?new It(t,r):"array-contains-any"===n?new Tt(t,r):new e(t,n,r)},e.l=function(t,e,n){return"in"===e?new mt(t,n):new vt(t,n)},e.prototype.matches=function(t){var e=t.data.field(this.field);return"!="===this.op?null!==e&&this.m(H(e,this.value)):null!==e&&z(this.value)===z(e)&&this.m(H(e,this.value))},e.prototype.m=function(t){switch(this.op){case"<":return t<0;case"<=":return t<=0;case"==":return 0===t;case"!=":return 0!==t;case">":return t>0;case">=":return t>=0;default:return m()}},e.prototype.g=function(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0},e}((function(){})),yt=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n,r)||this).key=Q.fromName(r.referenceValue),i}return(0,r.ZT)(e,t),e.prototype.matches=function(t){var e=Q.comparator(t.key,this.key);return this.m(e)},e}(pt),mt=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"in",n)||this).keys=gt("in",n),r}return(0,r.ZT)(e,t),e.prototype.matches=function(t){return this.keys.some((function(e){return e.isEqual(t.key)}))},e}(pt),vt=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"not-in",n)||this).keys=gt("not-in",n),r}return(0,r.ZT)(e,t),e.prototype.matches=function(t){return!this.keys.some((function(e){return e.isEqual(t.key)}))},e}(pt);function gt(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map((function(t){return Q.fromName(t.referenceValue)}))}var wt=function(t){function e(e,n){return t.call(this,e,"array-contains",n)||this}return(0,r.ZT)(e,t),e.prototype.matches=function(t){var e=t.data.field(this.field);return et(e)&&W(e.arrayValue,this.value)},e}(pt),bt=function(t){function e(e,n){return t.call(this,e,"in",n)||this}return(0,r.ZT)(e,t),e.prototype.matches=function(t){var e=t.data.field(this.field);return null!==e&&W(this.value.arrayValue,e)},e}(pt),It=function(t){function e(e,n){return t.call(this,e,"not-in",n)||this}return(0,r.ZT)(e,t),e.prototype.matches=function(t){if(W(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var e=t.data.field(this.field);return null!==e&&!W(this.value.arrayValue,e)},e}(pt),Tt=function(t){function e(e,n){return t.call(this,e,"array-contains-any",n)||this}return(0,r.ZT)(e,t),e.prototype.matches=function(t){var e=this,n=t.data.field(this.field);return!(!et(n)||!n.arrayValue.values)&&n.arrayValue.values.some((function(t){return W(e.value.arrayValue,t)}))},e}(pt),Et=function(t,e){this.position=t,this.before=e};function _t(t){return(t.before?"b":"a")+":"+t.position.map((function(t){return Y(t)})).join(",")}var St=function(t,e){void 0===e&&(e="asc"),this.field=t,this.dir=e};function Nt(t,e){return t.dir===e.dir&&t.field.isEqual(e.field)}function Dt(t,e,n){for(var r=0,i=0;i<t.position.length;i++){var o=e[i],s=t.position[i];if(r=o.field.isKeyField()?Q.comparator(Q.fromName(s.referenceValue),n.key):H(s,n.data.field(o.field)),"desc"===o.dir&&(r*=-1),0!==r)break}return t.before?r<=0:r<0}function At(t,e){if(null===t)return null===e;if(null===e)return!1;if(t.before!==e.before||t.position.length!==e.position.length)return!1;for(var n=0;n<t.position.length;n++)if(!J(t.position[n],e.position[n]))return!1;return!0}var kt=function(t,e,n,r,i,o,s,u){void 0===e&&(e=null),void 0===n&&(n=[]),void 0===r&&(r=[]),void 0===i&&(i=null),void 0===o&&(o="F"),void 0===s&&(s=null),void 0===u&&(u=null),this.path=t,this.collectionGroup=e,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=o,this.startAt=s,this.endAt=u,this.p=null,this.T=null,this.startAt,this.endAt};function Ct(t,e,n,r,i,o,s,u){return new kt(t,e,n,r,i,o,s,u)}function xt(t){return new kt(t)}function Rt(t){return!B(t.limit)&&"F"===t.limitType}function Lt(t){return!B(t.limit)&&"L"===t.limitType}function Ot(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function Pt(t){for(var e=0,n=t.filters;e<n.length;e++){var r=n[e];if(r.g())return r.field}return null}function Ft(t){return null!==t.collectionGroup}function Mt(t){var e=g(t);if(null===e.p){e.p=[];var n=Pt(e),r=Ot(e);if(null!==n&&null===r)n.isKeyField()||e.p.push(new St(n)),e.p.push(new St(R.keyField(),"asc"));else{for(var i=!1,o=0,s=e.explicitOrderBy;o<s.length;o++){var u=s[o];e.p.push(u),u.field.isKeyField()&&(i=!0)}if(!i){var a=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";e.p.push(new St(R.keyField(),a))}}}return e.p}function Vt(t){var e=g(t);if(!e.T)if("F"===e.limitType)e.T=ht(e.path,e.collectionGroup,Mt(e),e.filters,e.limit,e.startAt,e.endAt);else{for(var n=[],r=0,i=Mt(e);r<i.length;r++){var o=i[r],s="desc"===o.dir?"asc":"desc";n.push(new St(o.field,s))}var u=e.endAt?new Et(e.endAt.position,!e.endAt.before):null,a=e.startAt?new Et(e.startAt.position,!e.startAt.before):null;e.T=ht(e.path,e.collectionGroup,n,e.filters,e.limit,u,a)}return e.T}function qt(t,e,n){return new kt(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function Ut(t,e){return lt(Vt(t),Vt(e))&&t.limitType===e.limitType}function Gt(t){return ft(Vt(t))+"|lt:"+t.limitType}function Bt(t){return"Query(target="+function(t){var e=t.path.canonicalString();return null!==t.collectionGroup&&(e+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(e+=", filters: ["+t.filters.map((function(t){return(e=t).field.canonicalString()+" "+e.op+" "+Y(e.value);var e})).join(", ")+"]"),B(t.limit)||(e+=", limit: "+t.limit),t.orderBy.length>0&&(e+=", orderBy: ["+t.orderBy.map((function(t){return function(t){return t.field.canonicalString()+" ("+t.dir+")"}(t)})).join(", ")+"]"),t.startAt&&(e+=", startAt: "+_t(t.startAt)),t.endAt&&(e+=", endAt: "+_t(t.endAt)),"Target("+e+")"}(Vt(t))+"; limitType="+t.limitType+")"}function jt(t,e){return e.isFoundDocument()&&function(t,e){var n=e.key.path;return null!==t.collectionGroup?e.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(n):Q.isDocumentKey(t.path)?t.path.isEqual(n):t.path.isImmediateParentOf(n)}(t,e)&&function(t,e){for(var n=0,r=t.explicitOrderBy;n<r.length;n++){var i=r[n];if(!i.field.isKeyField()&&null===e.data.field(i.field))return!1}return!0}(t,e)&&function(t,e){for(var n=0,r=t.filters;n<r.length;n++)if(!r[n].matches(e))return!1;return!0}(t,e)&&function(t,e){return!(t.startAt&&!Dt(t.startAt,Mt(t),e)||t.endAt&&Dt(t.endAt,Mt(t),e))}(t,e)}function Kt(t){return function(e,n){for(var r=!1,i=0,o=Mt(t);i<o.length;i++){var s=o[i],u=Qt(s,e,n);if(0!==u)return u;r=r||s.field.isKeyField()}return 0}}function Qt(t,e,n){var r=t.field.isKeyField()?Q.comparator(e.key,n.key):function(t,e,n){var r=e.data.field(t),i=n.data.field(t);return null!==r&&null!==i?H(r,i):m()}
2(t.field,e,n);switch(t.dir){case"asc":return r;case"desc":return-1*r;default:return m()}}function zt(t,e){if(t.I){if(isNaN(e))return{doubleValue:"NaN"};if(e===1/0)return{doubleValue:"Infinity"};if(e===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:j(e)?"-0":e}}function Jt(t){return{integerValue:""+t}}function Wt(t,e){return K(e)?Jt(e):zt(t,e)}var Ht=function(){this._=void 0};function Zt(t,e,n){return t instanceof Xt?function(t,e){var n={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:t.seconds,nanos:t.nanoseconds}}}};return e&&(n.fields.__previous_value__=e),{mapValue:n}}(n,e):t instanceof te?ee(t,e):t instanceof ne?re(t,e):function(t,e){var n=$t(t,e),r=oe(n)+oe(t.A);return tt(n)&&tt(t.A)?Jt(r):zt(t.R,r)}(t,e)}function Yt(t,e,n){return t instanceof te?ee(t,e):t instanceof ne?re(t,e):n}function $t(t,e){return t instanceof ie?tt(n=e)||function(t){return!!t&&"doubleValue"in t}(n)?e:{integerValue:0}:null;var n}var Xt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,r.ZT)(e,t),e}(Ht),te=function(t){function e(e){var n=this;return(n=t.call(this)||this).elements=e,n}return(0,r.ZT)(e,t),e}(Ht);function ee(t,e){for(var n=se(e),r=function(t){n.some((function(e){return J(e,t)}))||n.push(t)},i=0,o=t.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var ne=function(t){function e(e){var n=this;return(n=t.call(this)||this).elements=e,n}return(0,r.ZT)(e,t),e}(Ht);function re(t,e){for(var n=se(e),r=function(t){n=n.filter((function(e){return!J(e,t)}))},i=0,o=t.elements;i<o.length;i++)r(o[i]);return{arrayValue:{values:n}}}var ie=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).R=e,r.A=n,r}return(0,r.ZT)(e,t),e}(Ht);function oe(t){return M(t.integerValue||t.doubleValue)}function se(t){return et(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}var ue=function(t,e){this.field=t,this.transform=e},ae=function(t,e){this.version=t,this.transformResults=e},ce=function(){function t(t,e){this.updateTime=t,this.exists=e}return t.none=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,"isNone",{get:function(){return void 0===this.updateTime&&void 0===this.exists},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){return this.exists===t.exists&&(this.updateTime?!!t.updateTime&&this.updateTime.isEqual(t.updateTime):!t.updateTime)},t}();function he(t,e){return void 0!==t.updateTime?e.isFoundDocument()&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e.isFoundDocument()}var fe=function(){};function le(t,e,n){t instanceof ve?function(t,e,n){var r=t.value.clone(),i=be(t.fieldTransforms,e,n.transformResults);r.setAll(i),e.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(t,e,n):t instanceof ge?function(t,e,n){if(he(t.precondition,e)){var r=be(t.fieldTransforms,e,n.transformResults),i=e.data;i.setAll(we(t)),i.setAll(r),e.convertToFoundDocument(n.version,i).setHasCommittedMutations()}else e.convertToUnknownDocument(n.version)}(t,e,n):function(t,e,n){e.convertToNoDocument(n.version).setHasCommittedMutations()}(0,e,n)}function de(t,e,n){t instanceof ve?function(t,e,n){if(he(t.precondition,e)){var r=t.value.clone(),i=Ie(t.fieldTransforms,n,e);r.setAll(i),e.convertToFoundDocument(me(e),r).setHasLocalMutations()}}(t,e,n):t instanceof ge?function(t,e,n){if(he(t.precondition,e)){var r=Ie(t.fieldTransforms,n,e),i=e.data;i.setAll(we(t)),i.setAll(r),e.convertToFoundDocument(me(e),i).setHasLocalMutations()}}(t,e,n):function(t,e){he(t.precondition,e)&&e.convertToNoDocument(S.min())}(t,e)}function pe(t,e){for(var n=null,r=0,i=t.fieldTransforms;r<i.length;r++){var o=i[r],s=e.data.field(o.field),u=$t(o.transform,s||null);null!=u&&(null==n&&(n=st.empty()),n.set(o.field,u))}return n||null}function ye(t,e){return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&!!function(t,e){return void 0===t&&void 0===e||!(!t||!e)&&T(t,e,(function(t,e){return function(t,e){return t.field.isEqual(e.field)&&function(t,e){return t instanceof te&&e instanceof te||t instanceof ne&&e instanceof ne?T(t.elements,e.elements,J):t instanceof ie&&e instanceof ie?J(t.A,e.A):t instanceof Xt&&e instanceof Xt}(t.transform,e.transform)}(t,e)}))}(t.fieldTransforms,e.fieldTransforms)&&(0===t.type?t.value.isEqual(e.value):1!==t.type||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask))}function me(t){return t.isFoundDocument()?t.version:S.min()}var ve=function(t){function e(e,n,r,i){void 0===i&&(i=[]);var o=this;return(o=t.call(this)||this).key=e,o.value=n,o.precondition=r,o.fieldTransforms=i,o.type=0,o}return(0,r.ZT)(e,t),e}(fe),ge=function(t){function e(e,n,r,i,o){void 0===o&&(o=[]);var s=this;return(s=t.call(this)||this).key=e,s.data=n,s.fieldMask=r,s.precondition=i,s.fieldTransforms=o,s.type=1,s}return(0,r.ZT)(e,t),e}(fe);function we(t){var e=new Map;return t.fieldMask.fields.forEach((function(n){if(!n.isEmpty()){var r=t.data.field(n);e.set(n,r)}})),e}function be(t,e,n){var r=new Map;v(t.length===n.length);for(var i=0;i<n.length;i++){var o=t[i],s=o.transform,u=e.data.field(o.field);r.set(o.field,Yt(s,u,n[i]))}return r}function Ie(t,e,n){for(var r=new Map,i=0,o=t;i<o.length;i++){var s=o[i],u=s.transform,a=n.data.field(s.field);r.set(s.field,Zt(u,a,e))}return r}var Te,Ee,_e=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).key=e,r.precondition=n,r.type=2,r.fieldTransforms=[],r}return(0,r.ZT)(e,t),e}(fe),Se=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).key=e,r.precondition=n,r.type=3,r.fieldTransforms=[],r}return(0,r.ZT)(e,t),e}(fe),Ne=function(t){this.count=t};function De(t){switch(t){default:return m();case a.CANCELLED:case a.UNKNOWN:case a.DEADLINE_EXCEEDED:case a.RESOURCE_EXHAUSTED:case a.INT
2ERNAL:case a.UNAVAILABLE:case a.UNAUTHENTICATED:return!1;case a.INVALID_ARGUMENT:case a.NOT_FOUND:case a.ALREADY_EXISTS:case a.PERMISSION_DENIED:case a.FAILED_PRECONDITION:case a.ABORTED:case a.OUT_OF_RANGE:case a.UNIMPLEMENTED:case a.DATA_LOSS:return!0}}function Ae(t){if(void 0===t)return d("GRPC error has no .code"),a.UNKNOWN;switch(t){case Te.OK:return a.OK;case Te.CANCELLED:return a.CANCELLED;case Te.UNKNOWN:return a.UNKNOWN;case Te.DEADLINE_EXCEEDED:return a.DEADLINE_EXCEEDED;case Te.RESOURCE_EXHAUSTED:return a.RESOURCE_EXHAUSTED;case Te.INTERNAL:return a.INTERNAL;case Te.UNAVAILABLE:return a.UNAVAILABLE;case Te.UNAUTHENTICATED:return a.UNAUTHENTICATED;case Te.INVALID_ARGUMENT:return a.INVALID_ARGUMENT;case Te.NOT_FOUND:return a.NOT_FOUND;case Te.ALREADY_EXISTS:return a.ALREADY_EXISTS;case Te.PERMISSION_DENIED:return a.PERMISSION_DENIED;case Te.FAILED_PRECONDITION:return a.FAILED_PRECONDITION;case Te.ABORTED:return a.ABORTED;case Te.OUT_OF_RANGE:return a.OUT_OF_RANGE;case Te.UNIMPLEMENTED:return a.UNIMPLEMENTED;case Te.DATA_LOSS:return a.DATA_LOSS;default:return m()}}(Ee=Te||(Te={}))[Ee.OK=0]="OK",Ee[Ee.CANCELLED=1]="CANCELLED",Ee[Ee.UNKNOWN=2]="UNKNOWN",Ee[Ee.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Ee[Ee.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Ee[Ee.NOT_FOUND=5]="NOT_FOUND",Ee[Ee.ALREADY_EXISTS=6]="ALREADY_EXISTS",Ee[Ee.PERMISSION_DENIED=7]="PERMISSION_DENIED",Ee[Ee.UNAUTHENTICATED=16]="UNAUTHENTICATED",Ee[Ee.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Ee[Ee.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Ee[Ee.ABORTED=10]="ABORTED",Ee[Ee.OUT_OF_RANGE=11]="OUT_OF_RANGE",Ee[Ee.UNIMPLEMENTED=12]="UNIMPLEMENTED",Ee[Ee.INTERNAL=13]="INTERNAL",Ee[Ee.UNAVAILABLE=14]="UNAVAILABLE",Ee[Ee.DATA_LOSS=15]="DATA_LOSS";var ke=function(){function t(t,e){this.comparator=t,this.root=e||xe.EMPTY}return t.prototype.insert=function(e,n){return new t(this.comparator,this.root.insert(e,n,this.comparator).copy(null,null,xe.BLACK,null,null))},t.prototype.remove=function(e){return new t(this.comparator,this.root.remove(e,this.comparator).copy(null,null,xe.BLACK,null,null))},t.prototype.get=function(t){for(var e=this.root;!e.isEmpty();){var n=this.comparator(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.isEmpty();){var r=this.comparator(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.isEmpty=function(){return this.root.isEmpty()},Object.defineProperty(t.prototype,"size",{get:function(){return this.root.size},enumerable:!1,configurable:!0}),t.prototype.minKey=function(){return this.root.minKey()},t.prototype.maxKey=function(){return this.root.maxKey()},t.prototype.inorderTraversal=function(t){return this.root.inorderTraversal(t)},t.prototype.forEach=function(t){this.inorderTraversal((function(e,n){return t(e,n),!1}))},t.prototype.toString=function(){var t=[];return this.inorderTraversal((function(e,n){return t.push(e+":"+n),!1})),"{"+t.join(", ")+"}"},t.prototype.reverseTraversal=function(t){return this.root.reverseTraversal(t)},t.prototype.getIterator=function(){return new Ce(this.root,null,this.comparator,!1)},t.prototype.getIteratorFrom=function(t){return new Ce(this.root,t,this.comparator,!1)},t.prototype.getReverseIterator=function(){return new Ce(this.root,null,this.comparator,!0)},t.prototype.getReverseIteratorFrom=function(t){return new Ce(this.root,t,this.comparator,!0)},t}(),Ce=function(){function t(t,e,n,r){this.isReverse=r,this.nodeStack=[];for(var i=1;!t.isEmpty();)if(i=e?n(t.key,e):1,r&&(i*=-1),i<0)t=this.isReverse?t.left:t.right;else{if(0===i){this.nodeStack.push(t);break}this.nodeStack.push(t),t=this.isReverse?t.right:t.left}}return t.prototype.getNext=function(){var t=this.nodeStack.pop(),e={key:t.key,value:t.value};if(this.isReverse)for(t=t.left;!t.isEmpty();)this.nodeStack.push(t),t=t.right;else for(t=t.right;!t.isEmpty();)this.nodeStack.push(t),t=t.left;return e},t.prototype.hasNext=function(){return this.nodeStack.length>0},t.prototype.peek=function(){if(0===this.nodeStack.length)return null;var t=this.nodeStack[this.nodeStack.length-1];return{key:t.key,value:t.value}},t}(),xe=function(){function t(e,n,r,i,o){this.key=e,this.value=n,this.color=null!=r?r:t.RED,this.left=null!=i?i:t.EMPTY,this.right=null!=o?o:t.EMPTY,this.size=this.left.size+1+this.right.size}return t.prototype.copy=function(e,n,r,i,o){return new t(null!=e?e:this.key,null!=n?n:this.value,
2null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},t.prototype.isEmpty=function(){return!1},t.prototype.inorderTraversal=function(t){return this.left.inorderTraversal(t)||t(this.key,this.value)||this.right.inorderTraversal(t)},t.prototype.reverseTraversal=function(t){return this.right.reverseTraversal(t)||t(this.key,this.value)||this.left.reverseTraversal(t)},t.prototype.min=function(){return this.left.isEmpty()?this:this.left.min()},t.prototype.minKey=function(){return this.min().key},t.prototype.maxKey=function(){return this.right.isEmpty()?this.key:this.right.maxKey()},t.prototype.insert=function(t,e,n){var r=this,i=n(t,r.key);return(r=i<0?r.copy(null,null,null,r.left.insert(t,e,n),null):0===i?r.copy(null,e,null,null,null):r.copy(null,null,null,null,r.right.insert(t,e,n))).fixUp()},t.prototype.removeMin=function(){if(this.left.isEmpty())return t.EMPTY;var e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),(e=e.copy(null,null,null,e.left.removeMin(),null)).fixUp()},t.prototype.remove=function(e,n){var r,i=this;if(n(e,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(e,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),0===n(e,i.key)){if(i.right.isEmpty())return t.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(e,n))}return i.fixUp()},t.prototype.isRed=function(){return this.color},t.prototype.fixUp=function(){var t=this;return t.right.isRed()&&!t.left.isRed()&&(t=t.rotateLeft()),t.left.isRed()&&t.left.left.isRed()&&(t=t.rotateRight()),t.left.isRed()&&t.right.isRed()&&(t=t.colorFlip()),t},t.prototype.moveRedLeft=function(){var t=this.colorFlip();return t.right.left.isRed()&&(t=(t=(t=t.copy(null,null,null,null,t.right.rotateRight())).rotateLeft()).colorFlip()),t},t.prototype.moveRedRight=function(){var t=this.colorFlip();return t.left.left.isRed()&&(t=(t=t.rotateRight()).colorFlip()),t},t.prototype.rotateLeft=function(){var e=this.copy(null,null,t.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)},t.prototype.rotateRight=function(){var e=this.copy(null,null,t.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)},t.prototype.colorFlip=function(){var t=this.left.copy(null,null,!this.left.color,null,null),e=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,t,e)},t.prototype.checkMaxDepth=function(){var t=this.check();return Math.pow(2,t)<=this.size+1},t.prototype.check=function(){if(this.isRed()&&this.left.isRed())throw m();if(this.right.isRed())throw m();var t=this.left.check();if(t!==this.right.check())throw m();return t+(this.isRed()?0:1)},t}();xe.EMPTY=null,xe.RED=!0,xe.BLACK=!1,xe.EMPTY=new(function(){function t(){this.size=0}return Object.defineProperty(t.prototype,"key",{get:function(){throw m()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){throw m()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){throw m()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){throw m()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){throw m()},enumerable:!1,configurable:!0}),t.prototype.copy=function(t,e,n,r,i){return this},t.prototype.insert=function(t,e,n){return new xe(t,e)},t.prototype.remove=function(t,e){return this},t.prototype.isEmpty=function(){return!0},t.prototype.inorderTraversal=function(t){return!1},t.prototype.reverseTraversal=function(t){return!1},t.prototype.minKey=function(){return null},t.prototype.maxKey=function(){return null},t.prototype.isRed=function(){return!1},t.prototype.checkMaxDepth=function(){return!0},t.prototype.check=function(){return 0},t}());var Re=function(){function t(t){this.comparator=t,this.data=new ke(this.comparator)}return t.prototype.has=function(t){return null!==this.data.get(t)},t.prototype.first=function(){return this.data.minKey()},t.prototype.last=function(){return this.data.maxKey()},Object.defineProperty(t.prototype,"size",{get:function(){return this.data.size}
2,enumerable:!1,configurable:!0}),t.prototype.indexOf=function(t){return this.data.indexOf(t)},t.prototype.forEach=function(t){this.data.inorderTraversal((function(e,n){return t(e),!1}))},t.prototype.forEachInRange=function(t,e){for(var n=this.data.getIteratorFrom(t[0]);n.hasNext();){var r=n.getNext();if(this.comparator(r.key,t[1])>=0)return;e(r.key)}},t.prototype.forEachWhile=function(t,e){var n;for(n=void 0!==e?this.data.getIteratorFrom(e):this.data.getIterator();n.hasNext();)if(!t(n.getNext().key))return},t.prototype.firstAfterOrEqual=function(t){var e=this.data.getIteratorFrom(t);return e.hasNext()?e.getNext().key:null},t.prototype.getIterator=function(){return new Le(this.data.getIterator())},t.prototype.getIteratorFrom=function(t){return new Le(this.data.getIteratorFrom(t))},t.prototype.add=function(t){return this.copy(this.data.remove(t).insert(t,!0))},t.prototype.delete=function(t){return this.has(t)?this.copy(this.data.remove(t)):this},t.prototype.isEmpty=function(){return this.data.isEmpty()},t.prototype.unionWith=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.getIterator(),r=e.data.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(0!==this.comparator(i,o))return!1}return!0},t.prototype.toArray=function(){var t=[];return this.forEach((function(e){t.push(e)})),t},t.prototype.toString=function(){var t=[];return this.forEach((function(e){return t.push(e)})),"SortedSet("+t.toString()+")"},t.prototype.copy=function(e){var n=new t(this.comparator);return n.data=e,n},t}(),Le=function(){function t(t){this.iter=t}return t.prototype.getNext=function(){return this.iter.getNext().key},t.prototype.hasNext=function(){return this.iter.hasNext()},t}(),Oe=new ke(Q.comparator);function Pe(){return Oe}var Fe=new ke(Q.comparator);function Me(){return Fe}var Ve=new ke(Q.comparator);function qe(){return Ve}var Ue=new Re(Q.comparator);function Ge(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=Ue,r=0,i=t;r<i.length;r++){var o=i[r];n=n.add(o)}return n}var Be=new Re(I);function je(){return Be}var Ke=function(){function t(t,e,n,r,i){this.snapshotVersion=t,this.targetChanges=e,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}return t.createSynthesizedRemoteEventForCurrentChange=function(e,n){var r=new Map;return r.set(e,Qe.createSynthesizedTargetChangeForCurrentChange(e,n)),new t(S.min(),r,je(),Pe(),Ge())},t}(),Qe=function(){function t(t,e,n,r,i){this.resumeToken=t,this.current=e,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}return t.createSynthesizedTargetChangeForCurrentChange=function(e,n){return new t(O.EMPTY_BYTE_STRING,n,Ge(),Ge(),Ge())},t}(),ze=function(t,e,n,r){this.v=t,this.removedTargetIds=e,this.key=n,this.P=r},Je=function(t,e){this.targetId=t,this.V=e},We=function(t,e,n,r){void 0===n&&(n=O.EMPTY_BYTE_STRING),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},He=function(){function t(){this.S=0,this.D=$e(),this.C=O.EMPTY_BYTE_STRING,this.N=!1,this.k=!0}return Object.defineProperty(t.prototype,"current",{get:function(){return this.N},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"resumeToken",{get:function(){return this.C},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"F",{get:function(){return 0!==this.S},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"$",{get:function(){return this.k},enumerable:!1,configurable:!0}),t.prototype.O=function(t){t.approximateByteSize()>0&&(this.k=!0,this.C=t)},t.prototype.M=function(){var t=Ge(),e=Ge(),n=Ge();return this.D.forEach((function(r,i){switch(i){case 0:t=t.add(r);break;case 2:e=e.add(r);break;case 1:n=n.add(r);break;default:m()}})),new Qe(this.C,this.N,t,e,n)},t.prototype.L=function(){this.k=!1,this.D=$e()},t.prototype.B=function(t,e){this.k=!0,this.D=this.D.insert(t,e)},t.prototype.q=function(t){this.k=!0,this.D=this.D.remove(t)},t.prototype.U=function(){this.S+=1},t.prototype.K=function(){this.S-=1},t.prototype.j=function(){this.k=!0,this.N=!0},t}(),Ze=function(){function t(t){this.W=t,this.G=new Map,this.H=Pe(),this.J=Ye(),this.Y=new Re(I)}return t.prototype.X=function(t){for(var e=0,n=t.v;e<n.length;e++){var r=n[e];t.P&&t.P.isFoundDocument()?this.Z(r,t.P):this.tt(r,t.key,t.P)}for(var i=0,o=t.removedTargetIds;i<o.length;i++)r=o[i],this.tt(r,t.key,t.P)},t.prototype.et=function(t){var e=this;this.forEachTarget(t,(function(n){var r=e.nt(n);switch(t.state){case 0:e.st(n)&&r.O(t.resumeToken);break;case 1:r.K(),r.F||r.L(),r.O(t.resumeToken);break;case 2:r.K(),r.F||e.removeTarget(n);break;case 3:e.st(n)&&(r.j(),r.O(t.resumeToken));break;case 4:e.st(n)&&(e.it(n),r.O(t.resumeToken));break;default:m()}}))},t.prototype.forEachTarget=function(t,e){var n=this;t.targetIds.length>
20?t.targetIds.forEach(e):this.G.forEach((function(t,r){n.st(r)&&e(r)}))},t.prototype.rt=function(t){var e=t.targetId,n=t.V.count,r=this.ot(e);if(r){var i=r.target;if(dt(i))if(0===n){var o=new Q(i.path);this.tt(e,o,at.newNoDocument(o,S.min()))}else v(1===n);else this.ct(e)!==n&&(this.it(e),this.Y=this.Y.add(e))}},t.prototype.ut=function(t){var e=this,n=new Map;this.G.forEach((function(r,i){var o=e.ot(i);if(o){if(r.current&&dt(o.target)){var s=new Q(o.target.path);null!==e.H.get(s)||e.at(i,s)||e.tt(i,s,at.newNoDocument(s,t))}r.$&&(n.set(i,r.M()),r.L())}}));var r=Ge();this.J.forEach((function(t,n){var i=!0;n.forEachWhile((function(t){var n=e.ot(t);return!n||2===n.purpose||(i=!1,!1)})),i&&(r=r.add(t))}));var i=new Ke(t,n,this.Y,this.H,r);return this.H=Pe(),this.J=Ye(),this.Y=new Re(I),i},t.prototype.Z=function(t,e){if(this.st(t)){var n=this.at(t,e.key)?2:0;this.nt(t).B(e.key,n),this.H=this.H.insert(e.key,e),this.J=this.J.insert(e.key,this.ht(e.key).add(t))}},t.prototype.tt=function(t,e,n){if(this.st(t)){var r=this.nt(t);this.at(t,e)?r.B(e,1):r.q(e),this.J=this.J.insert(e,this.ht(e).delete(t)),n&&(this.H=this.H.insert(e,n))}},t.prototype.removeTarget=function(t){this.G.delete(t)},t.prototype.ct=function(t){var e=this.nt(t).M();return this.W.getRemoteKeysForTarget(t).size+e.addedDocuments.size-e.removedDocuments.size},t.prototype.U=function(t){this.nt(t).U()},t.prototype.nt=function(t){var e=this.G.get(t);return e||(e=new He,this.G.set(t,e)),e},t.prototype.ht=function(t){var e=this.J.get(t);return e||(e=new Re(I),this.J=this.J.insert(t,e)),e},t.prototype.st=function(t){var e=null!==this.ot(t);return e||l("WatchChangeAggregator","Detected inactive target",t),e},t.prototype.ot=function(t){var e=this.G.get(t);return e&&e.F?null:this.W.lt(t)},t.prototype.it=function(t){var e=this;this.G.set(t,new He),this.W.getRemoteKeysForTarget(t).forEach((function(n){e.tt(t,n,null)}))},t.prototype.at=function(t,e){return this.W.getRemoteKeysForTarget(t).has(e)},t}();function Ye(){return new ke(Q.comparator)}function $e(){return new ke(Q.comparator)}var Xe={asc:"ASCENDING",desc:"DESCENDING"},tn={"<":"LESS_THAN","<=":"LESS_THAN_OR_EQUAL",">":"GREATER_THAN",">=":"GREATER_THAN_OR_EQUAL","==":"EQUAL","!=":"NOT_EQUAL","array-contains":"ARRAY_CONTAINS",in:"IN","not-in":"NOT_IN","array-contains-any":"ARRAY_CONTAINS_ANY"},en=function(t,e){this.databaseId=t,this.I=e};function nn(t,e){return t.I?new Date(1e3*e.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")+"."+("000000000"+e.nanoseconds).slice(-9)+"Z":{seconds:""+e.seconds,nanos:e.nanoseconds}}function rn(t,e){return t.I?e.toBase64():e.toUint8Array()}function on(t,e){return nn(t,e.toTimestamp())}function sn(t){return v(!!t),S.fromTimestamp(function(t){var e=F(t);return new _(e.seconds,e.nanos)}(t))}function un(t,e){return function(t){return new C(["projects",t.projectId,"databases",t.database])}(t).child("documents").child(e).canonicalString()}function an(t){var e=C.fromString(t);return v(Rn(e)),e}function cn(t,e){return un(t.databaseId,e.path)}function hn(t,e){var n=an(e);if(n.get(1)!==t.databaseId.projectId)throw new c(a.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+n.get(1)+" vs "+t.databaseId.projectId);if(n.get(3)!==t.databaseId.database)throw new c(a.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new Q(pn(n))}function fn(t,e){return un(t.databaseId,e)}function ln(t){var e=an(t);return 4===e.length?C.emptyPath():pn(e)}function dn(t){return new C(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function pn(t){return v(t.length>4&&"documents"===t.get(4)),t.popFirst(5)}function yn(t,e,n){return{name:cn(t,e),fields:n.value.mapValue.fields}}function mn(t,e,n){var r=hn(t,e.name),i=sn(e.updateTime),o=new st({mapValue:{fields:e.fields}}),s=at.newFoundDocument(r,i,o);return n&&s.setHasCommittedMutations(),n?s.setHasCommittedMutations():s}function vn(t,e){var n;if(e instanceof ve)n={update:yn(t,e.key,e.value)};else if(e instanceof _e)n={delete:cn(t,e.key)};else if(e instanceof ge)n={update:yn(t,e.key,e.data),updateMask:xn(e.f
2ieldMask)};else{if(!(e instanceof Se))return m();n={verify:cn(t,e.key)}}return e.fieldTransforms.length>0&&(n.updateTransforms=e.fieldTransforms.map((function(t){return function(t,e){var n=e.transform;if(n instanceof Xt)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof te)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof ne)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof ie)return{fieldPath:e.field.canonicalString(),increment:n.A};throw m()}(0,t)}))),e.precondition.isNone||(n.currentDocument=function(t,e){return void 0!==e.updateTime?{updateTime:on(t,e.updateTime)}:void 0!==e.exists?{exists:e.exists}:m()}(t,e.precondition)),n}function gn(t,e){var n=e.currentDocument?function(t){return void 0!==t.updateTime?ce.updateTime(sn(t.updateTime)):void 0!==t.exists?ce.exists(t.exists):ce.none()}(e.currentDocument):ce.none(),r=e.updateTransforms?e.updateTransforms.map((function(e){return function(t,e){var n=null;if("setToServerValue"in e)v("REQUEST_TIME"===e.setToServerValue),n=new Xt;else if("appendMissingElements"in e){var r=e.appendMissingElements.values||[];n=new te(r)}else if("removeAllFromArray"in e){var i=e.removeAllFromArray.values||[];n=new ne(i)}else"increment"in e?n=new ie(t,e.increment):m();var o=R.fromServerFormat(e.fieldPath);return new ue(o,n)}(t,e)})):[];if(e.update){e.update.name;var i=hn(t,e.update.name),o=new st({mapValue:{fields:e.update.fields}});if(e.updateMask){var s=function(t){var e=t.fieldPaths||[];return new L(e.map((function(t){return R.fromServerFormat(t)})))}(e.updateMask);return new ge(i,o,s,n,r)}return new ve(i,o,n,r)}if(e.delete){var u=hn(t,e.delete);return new _e(u,n)}if(e.verify){var a=hn(t,e.verify);return new Se(a,n)}return m()}function wn(t,e){return{documents:[fn(t,e.path)]}}function bn(t,e){var n={structuredQuery:{}},r=e.path;null!==e.collectionGroup?(n.parent=fn(t,r),n.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(n.parent=fn(t,r.popLast()),n.structuredQuery.from=[{collectionId:r.lastSegment()}]);var i=function(t){if(0!==t.length){var e=t.map((function(t){return function(t){if("=="===t.op){if(rt(t.value))return{unaryFilter:{field:Dn(t.field),op:"IS_NAN"}};if(nt(t.value))return{unaryFilter:{field:Dn(t.field),op:"IS_NULL"}}}else if("!="===t.op){if(rt(t.value))return{unaryFilter:{field:Dn(t.field),op:"IS_NOT_NAN"}};if(nt(t.value))return{unaryFilter:{field:Dn(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:Dn(t.field),op:Nn(t.op),value:t.value}}}(t)}));return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}}(e.filters);i&&(n.structuredQuery.where=i);var o=function(t){if(0!==t.length)return t.map((function(t){return function(t){return{field:Dn(t.field),direction:Sn(t.dir)}}(t)}))}(e.orderBy);o&&(n.structuredQuery.orderBy=o);var s=function(t,e){return t.I||B(e)?e:{value:e}}(t,e.limit);return null!==s&&(n.structuredQuery.limit=s),e.startAt&&(n.structuredQuery.startAt=En(e.startAt)),e.endAt&&(n.structuredQuery.endAt=En(e.endAt)),n}function In(t){var e=ln(t.parent),n=t.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){v(1===r);var o=n.from[0];o.allDescendants?i=o.collectionId:e=e.child(o.collectionId)}var s=[];n.where&&(s=Tn(n.where));var u=[];n.orderBy&&(u=n.orderBy.map((function(t){return function(t){return new St(An(t.field),function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(t.direction))}(t)})));var a=null;n.limit&&(a=function(t){var e;return B(e="object"==typeof t?t.value:t)?null:e}(n.limit));var c=null;n.startAt&&(c=_n(n.startAt));var h=null;return n.endAt&&(h=_n(n.endAt)),Ct(e,i,u,s,a,"F",c,h)}function Tn(t){return t?void 0!==t.unaryFilter?[Cn(t)]:void 0!==t.fieldFilter?[kn(t)]:void 0!==t.compositeFilter?t.compositeFilter.filters.map((function(t){return Tn(t)})).reduce((function(t,e){return t.concat(e)})):m():[]}function En(t){return{before:t.before,values:t.position}}function _n(t){var e=!!t.before,n=t.values||[];return new Et(n,e)}function Sn(t){return Xe[t]}function Nn(t){return tn[t]}function Dn(t){return{fieldPath:t.canonicalString()}}function An(t){return R.fromServerFormat(t.fieldPath)}function kn(t){return pt.create(An(t.fieldFilter.field),function(t){switch(t){case"EQUAL":return"==";case"NOT_EQUAL":return"!=";case"GREATER_THAN":return">";case"GREATER_THAN_OR_EQUAL":return">=";case"LESS_THAN":return"<";case"LESS_THAN_OR_EQUAL":return"<=";case"ARRAY_CONTAINS":return"array-contains";case"IN":return"in";case"NOT_IN":return"not-in";case"ARRAY_CONTAINS_ANY":return"array-contains-any";default:return m()}}(t.fieldFilter.op),t.fieldFilter.value)}function Cn(t){switch(t.unaryFilter.op){case"IS_NAN":var e=An(t.unaryFilter.field);return pt.create(e,"==",{doubleValue:NaN});
2case"IS_NULL":var n=An(t.unaryFilter.field);return pt.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var r=An(t.unaryFilter.field);return pt.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":var i=An(t.unaryFilter.field);return pt.create(i,"!=",{nullValue:"NULL_VALUE"});default:return m()}}function xn(t){var e=[];return t.fields.forEach((function(t){return e.push(t.canonicalString())})),{fieldPaths:e}}function Rn(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}function Ln(t){for(var e="",n=0;n<t.length;n++)e.length>0&&(e=Pn(e)),e=On(t.get(n),e);return Pn(e)}function On(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\0":n+="��";break;case"�":n+="��";break;default:n+=o}}return n}function Pn(t){return t+"��"}function Fn(t){var e=t.length;if(v(e>=2),2===e)return v("�"===t.charAt(0)&&"�"===t.charAt(1)),C.emptyPath();for(var n=e-2,r=[],i="",o=0;o<e;){var s=t.indexOf("�",o);switch((s<0||s>n)&&m(),t.charAt(s+1)){case"�":var u=t.substring(o,s),a=void 0;0===i.length?a=u:(a=i+=u,i=""),r.push(a);break;case"�":i+=t.substring(o,s),i+="\0";break;case"�":i+=t.substring(o,s+1);break;default:m()}o=s+2}return new C(r)}var Mn=function(t,e){this.seconds=t,this.nanoseconds=e},Vn=function(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n};Vn.store="owner",Vn.key="owner";var qn=function(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n};qn.store="mutationQueues",qn.keyPath="userId";var Un=function(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i};Un.store="mutations",Un.keyPath="batchId",Un.userMutationsIndex="userMutationsIndex",Un.userMutationsKeyPath=["userId","batchId"];var Gn=function(){function t(){}return t.prefixForUser=function(t){return[t]},t.prefixForPath=function(t,e){return[t,Ln(e)]},t.key=function(t,e,n){return[t,Ln(e),n]},t}();Gn.store="documentMutations",Gn.PLACEHOLDER=new Gn;var Bn=function(t,e){this.path=t,this.readTime=e},jn=function(t,e){this.path=t,this.version=e},Kn=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};Kn.store="remoteDocuments",Kn.readTimeIndex="readTimeIndex",Kn.readTimeIndexPath="readTime",Kn.collectionReadTimeIndex="collectionReadTimeIndex",Kn.collectionReadTimeIndexPath=["parentPath","readTime"];var Qn=function(t){this.byteSize=t};Qn.store="remoteDocumentGlobal",Qn.key="remoteDocumentGlobalKey";var zn=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};zn.store="targets",zn.keyPath="targetId",zn.queryTargetsIndexName="queryTargetsIndex",zn.queryTargetsKeyPath=["canonicalId","targetId"];var Jn=function(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n};Jn.store="targetDocuments",Jn.keyPath=["targetId","path"],Jn.documentTargetsIndex="documentTargetsIndex",Jn.documentTargetsKeyPath=["path","targetId"];var Wn=function(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r};Wn.key="targetGlobalKey",Wn.store="targetGlobal";var Hn=function(t,e){this.collectionId=t,this.parent=e};Hn.store="collectionParents",Hn.keyPath=["collectionId","parent"];var Zn=function(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r};Zn.store="clientMetadata",Zn.keyPath="clientId";var Yn=function(t,e,n){this.bundleId=t,this.createTime=e,this.version=n};Yn.store="bundles",Yn.keyPath="bundleId";var $n=function(t,e,n){this.name=t,this.readTime=e,this.bundledQuery=n};$n.store="namedQueries",$n.keyPath="name";var Xn=(0,r.ev)((0,r.ev)([],(0,r.ev)((0,r.ev)([],(0,r.ev)((0,r.ev)([],(0,r.ev)((0,r.ev)([],[qn.store,Un.store,Gn.store,Kn.store,zn.store,Vn.store,Wn.store,Jn.store]),[Zn.store])),[Qn.store])),[Hn.store])),[Yn.store,$n.store]),tr="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",er=function(){function t(){this.onCommittedListeners=[]}return t.prototype.addOnCommittedListener=function(t){this.onCommittedListeners.push(t)},t.prototype.raiseOnCommittedEvent=function(){this.onCommittedListeners.forEac
2h((function(t){return t()}))},t}(),nr=function(){var t=this;this.promise=new Promise((function(e,n){t.resolve=e,t.reject=n}))},rr=function(){function t(t){var e=this;this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,t((function(t){e.isDone=!0,e.result=t,e.nextCallback&&e.nextCallback(t)}),(function(t){e.isDone=!0,e.error=t,e.catchCallback&&e.catchCallback(t)}))}return t.prototype.catch=function(t){return this.next(void 0,t)},t.prototype.next=function(e,n){var r=this;return this.callbackAttached&&m(),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(e,this.result):new t((function(t,i){r.nextCallback=function(n){r.wrapSuccess(e,n).next(t,i)},r.catchCallback=function(e){r.wrapFailure(n,e).next(t,i)}}))},t.prototype.toPromise=function(){var t=this;return new Promise((function(e,n){t.next(e,n)}))},t.prototype.wrapUserFunction=function(e){try{var n=e();return n instanceof t?n:t.resolve(n)}catch(e){return t.reject(e)}},t.prototype.wrapSuccess=function(e,n){return e?this.wrapUserFunction((function(){return e(n)})):t.resolve(n)},t.prototype.wrapFailure=function(e,n){return e?this.wrapUserFunction((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.waitFor=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.or=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.waitFor(r)},t}(),ir=function(){function t(t,e){var n=this;this.action=t,this.transaction=e,this.aborted=!1,this.ft=new nr,this.transaction.oncomplete=function(){n.ft.resolve()},this.transaction.onabort=function(){e.error?n.ft.reject(new ur(t,e.error)):n.ft.resolve()},this.transaction.onerror=function(e){var r=lr(e.target.error);n.ft.reject(new ur(t,r))}}return t.open=function(e,n,r,i){try{return new t(n,e.transaction(i,r))}catch(e){throw new ur(n,e)}},Object.defineProperty(t.prototype,"dt",{get:function(){return this.ft.promise},enumerable:!1,configurable:!0}),t.prototype.abort=function(t){t&&this.ft.reject(t),this.aborted||(l("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 cr(e)},t}(),or=function(){function t(e,n,r){this.name=e,this.version=n,this.wt=r,12.2===t._t((0,i.z$)())&&d("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}return t.delete=function(t){return l("SimpleDb","Removing database:",t),hr(window.indexedDB.deleteDatabase(t)).toPromise()},t.yt=function(){if("undefined"==typeof indexedDB)return!1;if(t.gt())return!0;var e=(0,i.z$)(),n=t._t(e),r=0<n&&n<10,o=t.Et(e),s=0<o&&o<4.5;return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||r||s)},t.gt=function(){var t;return"undefined"!=typeof process&&"YES"===(null===(t={})||void 0===t?void 0:t.Tt)},t.It=function(t,e){return t.store(e)},t._t=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.Et=function(t){var e=t.match(/Android ([\d.]+)/i),n=e?e[1].split(".").slice(0,2).join("."):"-1";return Number(n)},t.prototype.At=function(t){return(0,r.mG)(this,void 0,void 0,(function(){var e,n=this;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return this.db?[3,2]:(l("SimpleDb","Opening database:",this.name),e=this,[4,new Promise((function(e,r){var i=indexedDB.open(n.name,n.version);i.onsuccess=function(t){var n=t.target.result;e(n)},i.onblocked=function(){r(new ur(t,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},i.onerror=function(e){var n=e.target.error;"VersionError"===n.name?r(new c(a.FAILED_PRECONDITION,"A newer version of the Firestore SDK was previously used and so the persisted data is not compatible with the version of the SDK you are now using. The SDK will operate with persistence disabled. If you need persistence, please re-upgrade to a newer version of the SDK or else clear the persisted IndexedDB data for your app to start fresh.")):r(new ur(t,n))},i.onupgradeneeded=function(t){l("SimpleDb",'Database "'+n.name+'" requires upgrade from version:',t.oldVersion);var e=t.target.result;n.wt.Rt(e,i.transaction,t.oldVersion,n.version).next((function(){l("SimpleDb","Database upgrade to version "+n.version+" complete")}
2))}}))]);case 1:e.db=r.sent(),r.label=2;case 2:return[2,(this.bt&&(this.db.onversionchange=function(t){return n.bt(t)}),this.db)]}}))}))},t.prototype.vt=function(t){this.bt=t,this.db&&(this.db.onversionchange=function(e){return t(e)})},t.prototype.runTransaction=function(t,e,n,i){return(0,r.mG)(this,void 0,void 0,(function(){var o,s,u,a,c;return(0,r.Jh)(this,(function(h){switch(h.label){case 0:o="readonly"===e,s=0,u=function(){var e,u,c,h,f;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:++s,r.label=1;case 1:return r.trys.push([1,4,,5]),[4,a.At(t)];case 2:return a.db=r.sent(),e=ir.open(a.db,t,o?"readonly":"readwrite",n),u=i(e).catch((function(t){return e.abort(t),rr.reject(t)})).toPromise(),c={},u.catch((function(){})),[4,e.dt];case 3:return[2,(c.value=(r.sent(),u),c)];case 4:return h=r.sent(),f="FirebaseError"!==h.name&&s<3,l("SimpleDb","Transaction failed with error:",h.message,"Retrying:",f),a.close(),f?[3,5]:[2,{value:Promise.reject(h)}];case 5:return[2]}}))},a=this,h.label=1;case 1:return[5,u()];case 2:if("object"==typeof(c=h.sent()))return[2,c.value];h.label=3;case 3:return[3,1];case 4:return[2]}}
2))}))},t.prototype.close=function(){this.db&&this.db.close(),this.db=void 0},t}(),sr=function(){function t(t){this.Pt=t,this.Vt=!1,this.St=null}return Object.defineProperty(t.prototype,"isDone",{get:function(){return this.Vt},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Dt",{get:function(){return this.St},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cursor",{set:function(t){this.Pt=t},enumerable:!1,configurable:!0}),t.prototype.done=function(){this.Vt=!0},t.prototype.Ct=function(t){this.St=t},t.prototype.delete=function(){return hr(this.Pt.delete())},t}(),ur=function(t){function e(e,n){var r=this;return(r=t.call(this,a.UNAVAILABLE,"IndexedDB transaction '"+e+"' failed: "+n)||this).name="IndexedDbTransactionError",r}return(0,r.ZT)(e,t),e}(c);function ar(t){return"IndexedDbTransactionError"===t.name}var cr=function(){function t(t){this.store=t}return t.prototype.put=function(t,e){var n;return void 0!==e?(l("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(l("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),hr(n)},t.prototype.add=function(t){return l("SimpleDb","ADD",this.store.name,t,t),hr(this.store.add(t))},t.prototype.get=function(t){var e=this;return hr(this.store.get(t)).next((function(n){return void 0===n&&(n=null),l("SimpleDb","GET",e.store.name,t,n),n}))},t.prototype.delete=function(t){return l("SimpleDb","DELETE",this.store.name,t),hr(this.store.delete(t))},t.prototype.count=function(){return l("SimpleDb","COUNT",this.store.name),hr(this.store.count())},t.prototype.Nt=function(t,e){var n=this.cursor(this.options(t,e)),r=[];return this.xt(n,(function(t,e){r.push(e)})).next((function(){return r}))},t.prototype.kt=function(t,e){l("SimpleDb","DELETE ALL",this.store.name);var n=this.options(t,e);n.Ft=!1;var r=this.cursor(n);return this.xt(r,(function(t,e,n){return n.delete()}))},t.prototype.$t=function(t,e){var n;e?n=t:(n={},e=t);var r=this.cursor(n);return this.xt(r,e)},t.prototype.Ot=function(t){var e=this.cursor({});return new rr((function(n,r){e.onerror=function(t){var e=lr(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.xt=function(t,e){var n=[];return new rr((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 sr(i),s=e(i.primaryKey,i.value,o);if(s instanceof rr){var u=s.catch((function(t){return o.done(),rr.reject(t)}));n.push(u)}o.isDone?r():null===o.Dt?i.continue():i.continue(o.Dt)}else r()}})).next((function(){return rr.waitFor(n)}))},t.prototype.options=function(t,e){var n;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.Ft?n.openKeyCursor(t.range,e):n.openCursor(t.range,e)}return this.store.openCursor(t.range,e)},t}();function hr(t){return new rr((function(e,n){t.onsuccess=function(t){var n=t.target.result;e(n)},t.onerror=function(t){var e=lr(t.target.error);n(e)}}))}var fr=!1;function lr(t){var e=or._t((0,i.z$)());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 c("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 fr||(fr=!0,setTimeout((function(){throw r}),0)),r}}return t}var dr=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).Mt=e,r.currentSequenceNumber=n,r}return(0,r.ZT)(e,t),e}(er);function pr(t,e){var n=g(t);return or.It(n.Mt,e)}var yr=function(){function t(t,e,n,r){this.batchId=t,this.localWriteTime=e,this.baseMutations=n,this.mutations=r}return t.prototype.applyToRemoteDocument=function(t,e){for(var n=e.mutationResults,r=0;r<this.mutations.length;r++){var i=this.mutations[r];i.key.isEqual(t.key)&&le(i,t,n[r])}},t.prototype.applyToLocalView=function(t){for(var e=0,n=this.baseMutations;e<n.length;e++)(o=n[e]).key.isEqual(t.key)&&de(o,t,this.localWriteTime);for(var r=0,i=this.mutations;r<i.length;r++){var o;(o=i[r]).key.isEqual(t.key)&&de(o,t,this.localWriteTime)}},t.prototype.applyToLocalDocumentSet=function(t){var e=this;this.mutations.forEach((function(n){var r=t.get(n.key),i=r;
2e.applyToLocalView(i),r.isValidDocument()||i.convertToNoDocument(S.min())}))},t.prototype.keys=function(){return this.mutations.reduce((function(t,e){return t.add(e.key)}),Ge())},t.prototype.isEqual=function(t){return this.batchId===t.batchId&&T(this.mutations,t.mutations,(function(t,e){return ye(t,e)}))&&T(this.baseMutations,t.baseMutations,(function(t,e){return ye(t,e)}))},t}(),mr=function(){function t(t,e,n,r){this.batch=t,this.commitVersion=e,this.mutationResults=n,this.docVersions=r}return t.from=function(e,n,r){v(e.mutations.length===r.length);for(var i=qe(),o=e.mutations,s=0;s<o.length;s++)i=i.insert(o[s].key,r[s].version);return new t(e,n,r,i)},t}(),vr=function(){function t(t,e,n,r,i,o,s){void 0===i&&(i=S.min()),void 0===o&&(o=S.min()),void 0===s&&(s=O.EMPTY_BYTE_STRING),this.target=t,this.targetId=e,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=o,this.resumeToken=s}return t.prototype.withSequenceNumber=function(e){return new t(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken)},t.prototype.withResumeToken=function(e,n){return new t(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,e)},t.prototype.withLastLimboFreeSnapshotVersion=function(e){return new t(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken)},t}(),gr=function(t){this.Lt=t};function wr(t,e){if(e.document)return mn(t.Lt,e.document,!!e.hasCommittedMutations);if(e.noDocument){var n=Q.fromSegments(e.noDocument.path),r=_r(e.noDocument.readTime),i=at.newNoDocument(n,r);return e.hasCommittedMutations?i.setHasCommittedMutations():i}if(e.unknownDocument){var o=Q.fromSegments(e.unknownDocument.path);return r=_r(e.unknownDocument.version),at.newUnknownDocument(o,r)}return m()}function br(t,e,n){var r=Ir(n),i=e.key.path.popLast().toArray();if(e.isFoundDocument()){var o=function(t,e){return{name:cn(t,e.key),fields:e.data.value.mapValue.fields,updateTime:nn(t,e.version.toTimestamp())}}(t.Lt,e),s=e.hasCommittedMutations;return new Kn(null,null,o,s,r,i)}if(e.isNoDocument()){var u=e.key.path.toArray(),a=Er(e.version);return s=e.hasCommittedMutations,new Kn(null,new Bn(u,a),null,s,r,i)}if(e.isUnknownDocument()){var c=e.key.path.toArray(),h=Er(e.version);return new Kn(new jn(c,h),null,null,!0,r,i)}return m()}function Ir(t){var e=t.toTimestamp();return[e.seconds,e.nanoseconds]}function Tr(t){var e=new _(t[0],t[1]);return S.fromTimestamp(e)}function Er(t){var e=t.toTimestamp();return new Mn(e.seconds,e.nanoseconds)}function _r(t){var e=new _(t.seconds,t.nanoseconds);return S.fromTimestamp(e)}function Sr(t,e){for(var n=(e.baseMutations||[]).map((function(e){return gn(t.Lt,e)})),r=0;r<e.mutations.length-1;++r){var i=e.mutations[r];if(r+1<e.mutations.length&&void 0!==e.mutations[r+1].transform){var o=e.mutations[r+1];i.updateTransforms=o.transform.fieldTransforms,e.mutations.splice(r+1,1),++r}}var s=e.mutations.map((function(e){return gn(t.Lt,e)})),u=_.fromMillis(e.localWriteTimeMs);return new yr(e.batchId,u,n,s)}function Nr(t){var e,n,r=_r(t.readTime),i=void 0!==t.lastLimboFreeSnapshotVersion?_r(t.lastLimboFreeSnapshotVersion):S.min();return void 0!==t.query.documents?(v(1===(n=t.query).documents.length),e=Vt(xt(ln(n.documents[0])))):e=function(t){return Vt(In(t))}(t.query),new vr(e,t.targetId,0,t.lastListenSequenceNumber,r,i,O.fromBase64String(t.resumeToken))}function Dr(t,e){var n,r=Er(e.snapshotVersion),i=Er(e.lastLimboFreeSnapshotVersion);n=dt(e.target)?wn(t.Lt,e.target):bn(t.Lt,e.target);var o=e.resumeToken.toBase64();return new zn(e.targetId,ft(e.target),r,o,e.sequenceNumber,i,n)}function Ar(t){var e=In({parent:t.parent,structuredQuery:t.structuredQuery});return"LAST"===t.limitType?qt(e,e.limit,"L"):e}var kr=function(){function t(){}return t.prototype.getBundleMetadata=function(t,e){return Cr(t).get(e).next((function(t){if(t)return{id:(e=t).bundleId,createTime:_r(e.createTime),version:e.version};var e}))},t.prototype.saveBundleMetadata=function(t,e){return Cr(t).put({bundleId:(n=e).id,createTime:Er(sn(n.createTime)),version:n.version});var n}
2,t.prototype.getNamedQuery=function(t,e){return xr(t).get(e).next((function(t){if(t)return{name:(e=t).name,query:Ar(e.bundledQuery),readTime:_r(e.readTime)};var e}))},t.prototype.saveNamedQuery=function(t,e){return xr(t).put(function(t){return{name:t.name,readTime:Er(sn(t.readTime)),bundledQuery:t.bundledQuery}}(e))},t}();function Cr(t){return pr(t,Yn.store)}function xr(t){return pr(t,$n.store)}var Rr=function(){function t(){this.Bt=new Lr}return t.prototype.addToCollectionParentIndex=function(t,e){return this.Bt.add(e),rr.resolve()},t.prototype.getCollectionParents=function(t,e){return rr.resolve(this.Bt.getEntries(e))},t}(),Lr=function(){function t(){this.index={}}return t.prototype.add=function(t){var e=t.lastSegment(),n=t.popLast(),r=this.index[e]||new Re(C.comparator),i=!r.has(n);return this.index[e]=r.add(n),i},t.prototype.has=function(t){var e=t.lastSegment(),n=t.popLast(),r=this.index[e];return r&&r.has(n)},t.prototype.getEntries=function(t){return(this.index[t]||new Re(C.comparator)).toArray()},t}(),Or=function(){function t(){this.qt=new Lr}return t.prototype.addToCollectionParentIndex=function(t,e){var n=this;if(!this.qt.has(e)){var r=e.lastSegment(),i=e.popLast();t.addOnCommittedListener((function(){n.qt.add(e)}));var o={collectionId:r,parent:Ln(i)};return Pr(t).put(o)}return rr.resolve()},t.prototype.getCollectionParents=function(t,e){var n=[],r=IDBKeyRange.bound([e,""],[E(e),""],!1,!0);return Pr(t).Nt(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(Fn(o.parent))}return n}))},t}();function Pr(t){return pr(t,Hn.store)}var Fr={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},Mr=function(){function t(t,e,n){this.cacheSizeCollectionThreshold=t,this.percentileToCollect=e,this.maximumSequenceNumbersToCollect=n}return t.withCacheSize=function(e){return new t(e,t.DEFAULT_COLLECTION_PERCENTILE,t.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)},t}();function Vr(t,e,n){var r=t.store(Un.store),i=t.store(Gn.store),o=[],s=IDBKeyRange.only(n.batchId),u=0,a=r.$t({range:s},(function(t,e,n){return u++,n.delete()}));o.push(a.next((function(){v(1===u)})));for(var c=[],h=0,f=n.mutations;h<f.length;h++){var l=f[h],d=Gn.key(e,l.key.path,n.batchId);o.push(i.delete(d)),c.push(l.key)}return rr.waitFor(o).next((function(){return c}))}function qr(t){if(!t)return 0;var e;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw m();e=t.noDocument}return JSON.stringify(e).length}Mr.DEFAULT_COLLECTION_PERCENTILE=10,Mr.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Mr.DEFAULT=new Mr(41943040,Mr.DEFAULT_COLLECTION_PERCENTILE,Mr.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Mr.DISABLED=new Mr(-1,0,0);var Ur=function(){function t(t,e,n,r){this.userId=t,this.R=e,this.Ut=n,this.referenceDelegate=r,this.Kt={}}return t.Qt=function(e,n,r,i){return v(""!==e.uid),new t(e.isAuthenticated()?e.uid:"",n,r,i)},t.prototype.checkEmpty=function(t){var e=!0,n=IDBKeyRange.bound([this.userId,Number.NEGATIVE_INFINITY],[this.userId,Number.POSITIVE_INFINITY]);return Br(t).$t({index:Un.userMutationsIndex,range:n},(function(t,n,r){e=!1,r.done()})).next((function(){return e}))},t.prototype.addMutationBatch=function(t,e,n,r){var i=this,o=jr(t),s=Br(t);return s.add({}).next((function(u){v("number"==typeof u);for(var a=new yr(u,e,n,r),c=function(t,e,n){var r=n.baseMutations.map((function(e){return vn(t.Lt,e)})),i=n.mutations.map((function(e){return vn(t.Lt,e)}));return new Un(e,n.batchId,n.localWriteTime.toMillis(),r,i)}(i.R,i.userId,a),h=[],f=new Re((function(t,e){return I(t.canonicalString(),e.canonicalString())})),l=0,d=r;l<d.length;l++){var p=d[l],y=Gn.key(i.userId,p.key.path,u);f=f.add(p.key.path.popLast()),h.push(s.put(c)),h.push(o.put(y,Gn.PLACEHOLDER))}return f.forEach((function(e){h.push(i.Ut.addToCollectionParentIndex(t,e))})),t.addOnCommittedListener((function(){i.Kt[u]=a.keys()})),rr.waitFor(h).next((function(){return a}))}))},t.prototype.lookupMutationBatch=function(t,e){var n=this;return Br(t).get(e).next((function(t){return t?(v(t.userId===n.userId),Sr(n.R,t)):null}))},t.prototype.jt=function(t,e){var n=this;return this.Kt[e]?rr.resolve(this.Kt[e]):this.lookupMutationBatch(t,e).next((function(t){if(t){var r=t.keys();return n.Kt[e]=r,r}return null}))},t.prototype.getNextMutationBatchAfterBatchId=function(t,e){var n=this,r=e+1,i=IDBKeyRange.lowerBound([this.userId,r]),o=null;return Br(t).$t({index:Un.userMutationsIndex,range:i}
2,(function(t,e,i){e.userId===n.userId&&(v(e.batchId>=r),o=Sr(n.R,e)),i.done()})).next((function(){return o}))},t.prototype.getHighestUnacknowledgedBatchId=function(t){var e=IDBKeyRange.upperBound([this.userId,Number.POSITIVE_INFINITY]),n=-1;return Br(t).$t({index:Un.userMutationsIndex,range:e,reverse:!0},(function(t,e,r){n=e.batchId,r.done()})).next((function(){return n}))},t.prototype.getAllMutationBatches=function(t){var e=this,n=IDBKeyRange.bound([this.userId,-1],[this.userId,Number.POSITIVE_INFINITY]);return Br(t).Nt(Un.userMutationsIndex,n).next((function(t){return t.map((function(t){return Sr(e.R,t)}))}))},t.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,e){var n=this,r=Gn.prefixForPath(this.userId,e.path),i=IDBKeyRange.lowerBound(r),o=[];return jr(t).$t({range:i},(function(r,i,s){var u=r[0],a=r[1],c=r[2],h=Fn(a);if(u===n.userId&&e.path.isEqual(h))return Br(t).get(c).next((function(t){if(!t)throw m();v(t.userId===n.userId),o.push(Sr(n.R,t))}));s.done()})).next((function(){return o}))},t.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var n=this,r=new Re(I),i=[];return e.forEach((function(e){var o=Gn.prefixForPath(n.userId,e.path),s=IDBKeyRange.lowerBound(o),u=jr(t).$t({range:s},(function(t,i,o){var s=t[0],u=t[1],a=t[2],c=Fn(u);s===n.userId&&e.path.isEqual(c)?r=r.add(a):o.done()}));i.push(u)})),rr.waitFor(i).next((function(){return n.Wt(t,r)}))},t.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var n=this,r=e.path,i=r.length+1,o=Gn.prefixForPath(this.userId,r),s=IDBKeyRange.lowerBound(o),u=new Re(I);return jr(t).$t({range:s},(function(t,e,o){var s=t[0],a=t[1],c=t[2],h=Fn(a);s===n.userId&&r.isPrefixOf(h)?h.length===i&&(u=u.add(c)):o.done()})).next((function(){return n.Wt(t,u)}))},t.prototype.Wt=function(t,e){var n=this,r=[],i=[];return e.forEach((function(e){i.push(Br(t).get(e).next((function(t){if(null===t)throw m();v(t.userId===n.userId),r.push(Sr(n.R,t))})))})),rr.waitFor(i).next((function(){return r}))},t.prototype.removeMutationBatch=function(t,e){var n=this;return Vr(t.Mt,this.userId,e).next((function(r){return t.addOnCommittedListener((function(){n.Gt(e.batchId)})),rr.forEach(r,(function(e){return n.referenceDelegate.markPotentiallyOrphaned(t,e)}))}))},t.prototype.Gt=function(t){delete this.Kt[t]},t.prototype.performConsistencyCheck=function(t){var e=this;return this.checkEmpty(t).next((function(n){if(!n)return rr.resolve();var r=IDBKeyRange.lowerBound(Gn.prefixForUser(e.userId)),i=[];return jr(t).$t({range:r},(function(t,n,r){if(t[0]===e.userId){var o=Fn(t[1]);i.push(o)}else r.done()})).next((function(){v(0===i.length)}))}))},t.prototype.containsKey=function(t,e){return Gr(t,this.userId,e)},t.prototype.zt=function(t){var e=this;return Kr(t).get(this.userId).next((function(t){return t||new qn(e.userId,-1,"")}))},t}();function Gr(t,e,n){var r=Gn.prefixForPath(e,n.path),i=r[1],o=IDBKeyRange.lowerBound(r),s=!1;return jr(t).$t({range:o,Ft:!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 Br(t){return pr(t,Un.store)}function jr(t){return pr(t,Gn.store)}function Kr(t){return pr(t,qn.store)}var Qr=function(){function t(t){this.Ht=t}return t.prototype.next=function(){return this.Ht+=2,this.Ht},t.Jt=function(){return new t(0)},t.Yt=function(){return new t(-1)},t}(),zr=function(){function t(t,e){this.referenceDelegate=t,this.R=e}return t.prototype.allocateTargetId=function(t){var e=this;return this.Xt(t).next((function(n){var r=new Qr(n.highestTargetId);return n.highestTargetId=r.next(),e.Zt(t,n).next((function(){return n.highestTargetId}))}))},t.prototype.getLastRemoteSnapshotVersion=function(t){return this.Xt(t).next((function(t){return S.fromTimestamp(new _(t.lastRemoteSnapshotVersion.seconds,t.lastRemoteSnapshotVersion.nanoseconds))}))},t.prototype.getHighestSequenceNumber=function(t){return this.Xt(t).next((function(t){return t.highestListenSequenceNumber}))},t.prototype.setTargetsMetadata=function(t,e,n){var r=this;return this.Xt(t).next((function(i){return i.highestListenSequenceNumber=e,n&&(i.lastRemoteSnapshotVersion=n.toTimestamp()),e>i.highestListenSequenceNumber&&(i.highestListenSequenceNumber=e),r.Zt(t,i)}))},t.prototype.addTargetData=function(t,e){var n=this;return this.te(t,e).next((function(){return n.Xt(t).next((function(r){return r.targetCount+=1,n.ee(e,r),n.Zt(t,r)}))}))},t.prototype.updateTargetData=function(t,e){return this.te(t,e)},t.prototype.removeTargetData=function(t,e){var n=this;return this.removeMatchingKeysForTargetId(t,e.targetId).next((function(){return Jr(t).delete(e.targetId)})).next((function(){return n.Xt(t)})).next((function(e){return v(e.targetCount>0),e.targetCount-=1,n.Zt(t,e)}))},t.prototype.removeTargets=function(t,e,n){var r=this,i=0,o=[];
2return Jr(t).$t((function(s,u){var a=Nr(u);a.sequenceNumber<=e&&null===n.get(a.targetId)&&(i++,o.push(r.removeTargetData(t,a)))})).next((function(){return rr.waitFor(o)})).next((function(){return i}))},t.prototype.forEachTarget=function(t,e){return Jr(t).$t((function(t,n){var r=Nr(n);e(r)}))},t.prototype.Xt=function(t){return Wr(t).get(Wn.key).next((function(t){return v(null!==t),t}))},t.prototype.Zt=function(t,e){return Wr(t).put(Wn.key,e)},t.prototype.te=function(t,e){return Jr(t).put(Dr(this.R,e))},t.prototype.ee=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.getTargetCount=function(t){return this.Xt(t).next((function(t){return t.targetCount}))},t.prototype.getTargetData=function(t,e){var n=ft(e),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]),i=null;return Jr(t).$t({range:r,index:zn.queryTargetsIndexName},(function(t,n,r){var o=Nr(n);lt(e,o.target)&&(i=o,r.done())})).next((function(){return i}))},t.prototype.addMatchingKeys=function(t,e,n){var r=this,i=[],o=Hr(t);return e.forEach((function(e){var s=Ln(e.path);i.push(o.put(new Jn(n,s))),i.push(r.referenceDelegate.addReference(t,n,e))})),rr.waitFor(i)},t.prototype.removeMatchingKeys=function(t,e,n){var r=this,i=Hr(t);return rr.forEach(e,(function(e){var o=Ln(e.path);return rr.waitFor([i.delete([n,o]),r.referenceDelegate.removeReference(t,n,e)])}))},t.prototype.removeMatchingKeysForTargetId=function(t,e){var n=Hr(t),r=IDBKeyRange.bound([e],[e+1],!1,!0);return n.delete(r)},t.prototype.getMatchingKeysForTargetId=function(t,e){var n=IDBKeyRange.bound([e],[e+1],!1,!0),r=Hr(t),i=Ge();return r.$t({range:n,Ft:!0},(function(t,e,n){var r=Fn(t[1]),o=new Q(r);i=i.add(o)})).next((function(){return i}))},t.prototype.containsKey=function(t,e){var n=Ln(e.path),r=IDBKeyRange.bound([n],[E(n)],!1,!0),i=0;return Hr(t).$t({index:Jn.documentTargetsIndex,Ft:!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.lt=function(t,e){return Jr(t).get(e).next((function(t){return t?Nr(t):null}))},t}();function Jr(t){return pr(t,zn.store)}function Wr(t){return pr(t,Wn.store)}function Hr(t){return pr(t,Jn.store)}function Zr(t){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){if(t.code!==a.FAILED_PRECONDITION||t.message!==tr)throw t;return l("LocalStore","Unexpectedly lost primary lease"),[2]}))}))}function Yr(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],s=I(n,i);return 0===s?I(r,o):s}var $r=function(){function t(t){this.ne=t,this.buffer=new Re(Yr),this.se=0}return t.prototype.ie=function(){return++this.se},t.prototype.re=function(t){var e=[t,this.ie()];if(this.buffer.size<this.ne)this.buffer=this.buffer.add(e);else{var n=this.buffer.last();Yr(e,n)<0&&(this.buffer=this.buffer.delete(n).add(e))}},Object.defineProperty(t.prototype,"maxValue",{get:function(){return this.buffer.last()[0]},enumerable:!1,configurable:!0}),t}(),Xr=function(){function t(t,e){this.garbageCollector=t,this.asyncQueue=e,this.oe=!1,this.ce=null}return t.prototype.start=function(t){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.ue(t)},t.prototype.stop=function(){this.ce&&(this.ce.cancel(),this.ce=null)},Object.defineProperty(t.prototype,"started",{get:function(){return null!==this.ce},enumerable:!1,configurable:!0}),t.prototype.ue=function(t){var e=this,n=this.oe?3e5:6e4;l("LruGarbageCollector","Garbage collection scheduled in "+n+"ms"),this.ce=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",n,(function(){return(0,r.mG)(e,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:this.ce=null,this.oe=!0,n.label=1;case 1:return n.trys.push([1,3,,7]),[4,t.collectGarbage(this.garbageCollector)];case 2:return n.sent(),[3,7];case 3:return ar(e=n.sent())?(l("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e),[3,6]):[3,4];case 4:return[4,Zr(e)];case 5:n.sent(),n.label=6;case 6:return[3,7];case 7:return[4,this.ue(t)];case 8:return n.sent(),[2]}}))}))}))},t}(),ti=function(){function t(t,e){this.ae=t,this.params=e}return t.prototype.calculateTargetCount=function(t,e){return this.ae.he(t).next((function(t){return Math.floor(e/100*t)}))},t.prototype.nthSequenceNumber=function(t,e){var n=this;if(0===e)return rr.resolve(u.o);var r=new $r(e);return this.ae.forEachTarget(t,(function(t){return r.re(t.sequenceNumber)})).next((function(){return n.ae.le(t,(function(t){return r.re(t)}))}
2)).next((function(){return r.maxValue}))},t.prototype.removeTargets=function(t,e,n){return this.ae.removeTargets(t,e,n)},t.prototype.removeOrphanedDocuments=function(t,e){return this.ae.removeOrphanedDocuments(t,e)},t.prototype.collect=function(t,e){var n=this;return-1===this.params.cacheSizeCollectionThreshold?(l("LruGarbageCollector","Garbage collection skipped; disabled"),rr.resolve(Fr)):this.getCacheSize(t).next((function(r){return r<n.params.cacheSizeCollectionThreshold?(l("LruGarbageCollector","Garbage collection skipped; Cache size "+r+" is lower than threshold "+n.params.cacheSizeCollectionThreshold),Fr):n.fe(t,e)}))},t.prototype.getCacheSize=function(t){return this.ae.getCacheSize(t)},t.prototype.fe=function(t,e){var n,r,i,s,u,a,c,h=this,d=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next((function(e){return e>h.params.maximumSequenceNumbersToCollect?(l("LruGarbageCollector","Capping sequence numbers to collect down to the maximum of "+h.params.maximumSequenceNumbersToCollect+" from "+e),r=h.params.maximumSequenceNumbersToCollect):r=e,s=Date.now(),h.nthSequenceNumber(t,r)})).next((function(r){return n=r,u=Date.now(),h.removeTargets(t,n,e)})).next((function(e){return i=e,a=Date.now(),h.removeOrphanedDocuments(t,n)})).next((function(t){return c=Date.now(),f()<=o.in.DEBUG&&l("LruGarbageCollector","LRU Garbage Collection\n\tCounted targets in "+(s-d)+"ms\n\tDetermined least recently used "+r+" in "+(u-s)+"ms\n\tRemoved "+i+" targets in "+(a-u)+"ms\n\tRemoved "+t+" documents in "+(c-a)+"ms\nTotal Duration: "+(c-d)+"ms"),rr.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:t})}))},t}(),ei=function(){function t(t,e){this.db=t,this.garbageCollector=function(t,e){return new ti(t,e)}(this,e)}return t.prototype.he=function(t){var e=this.de(t);return this.db.getTargetCache().getTargetCount(t).next((function(t){return e.next((function(e){return t+e}))}))},t.prototype.de=function(t){var e=0;return this.le(t,(function(t){e++})).next((function(){return e}))},t.prototype.forEachTarget=function(t,e){return this.db.getTargetCache().forEachTarget(t,e)},t.prototype.le=function(t,e){return this.we(t,(function(t,n){return e(n)}))},t.prototype.addReference=function(t,e,n){return ni(t,n)},t.prototype.removeReference=function(t,e,n){return ni(t,n)},t.prototype.removeTargets=function(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)},t.prototype.markPotentiallyOrphaned=function(t,e){return ni(t,e)},t.prototype._e=function(t,e){return function(t,e){var n=!1;return Kr(t).Ot((function(r){return Gr(t,r,e).next((function(t){return t&&(n=!0),rr.resolve(!t)}))})).next((function(){return n}))}(t,e)},t.prototype.removeOrphanedDocuments=function(t,e){var n=this,r=this.db.getRemoteDocumentCache().newChangeBuffer(),i=[],o=0;return this.we(t,(function(s,u){if(u<=e){var a=n._e(t,s).next((function(e){if(!e)return o++,r.getEntry(t,s).next((function(){return r.removeEntry(s),Hr(t).delete([0,Ln(s.path)])}))}));i.push(a)}})).next((function(){return rr.waitFor(i)})).next((function(){return r.apply(t)})).next((function(){return o}))},t.prototype.removeTarget=function(t,e){var n=e.withSequenceNumber(t.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(t,n)},t.prototype.updateLimboDocument=function(t,e){return ni(t,e)},t.prototype.we=function(t,e){var n,r=Hr(t),i=u.o;return r.$t({index:Jn.documentTargetsIndex},(function(t,r){var o=t[0];t[1];var s=r.path,a=r.sequenceNumber;0===o?(i!==u.o&&e(new Q(Fn(n)),i),i=a,n=s):i=u.o})).next((function(){i!==u.o&&e(new Q(Fn(n)),i)}))},t.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)},t}();function ni(t,e){return Hr(t).put(function(t,e){return new Jn(0,Ln(t.path),e)}(e,t.currentSequenceNumber))}var ri=function(){function t(t,e){this.mapKeyFn=t,this.equalsFn=e,this.inner={}}return t.prototype.get=function(t){var e=this.mapKeyFn(t),n=this.inner[e];if(void 0!==n)for(var r=0,i=n;r<i.length;r++){var o=i[r],s=o[0],u=o[1];if(this.equalsFn(s,t))return u}},t.prototype.has=function(t){return void 0!==this.get(t)},t.prototype.set=function(t,e){var n=this.mapKeyFn(t),r=this.inner[n];if(void 0!==r){for(var i=0;i<r.length;i++)if(this.equalsFn(r[i][0],t))return void(r[i]=[t,e]);r.push([t,e])}else this.inner[n]=[[t,e]]},t.prototype.delete=function(t){var e=this.mapKeyFn(t),n=this.inner[e];if(void 0===n)return!1;for(var r=0;r<n.length;r++)if(this.equalsFn(n[r][0],t))return 1===n.length?delete this.inner[e]:n.splice(r,1),!0;return!1},t.prototype.forEach=function(t){D(this.inner,(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)}}
2))},t.prototype.isEmpty=function(){return A(this.inner)},t}(),ii=function(){function t(){this.changes=new ri((function(t){return t.toString()}),(function(t,e){return t.isEqual(e)})),this.changesApplied=!1}return t.prototype.getReadTime=function(t){var e=this.changes.get(t);return e?e.readTime:S.min()},t.prototype.addEntry=function(t,e){this.assertNotApplied(),this.changes.set(t.key,{document:t,readTime:e})},t.prototype.removeEntry=function(t,e){void 0===e&&(e=null),this.assertNotApplied(),this.changes.set(t,{document:at.newInvalidDocument(t),readTime:e})},t.prototype.getEntry=function(t,e){this.assertNotApplied();var n=this.changes.get(e);return void 0!==n?rr.resolve(n.document):this.getFromCache(t,e)},t.prototype.getEntries=function(t,e){return this.getAllFromCache(t,e)},t.prototype.apply=function(t){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(t)},t.prototype.assertNotApplied=function(){},t}(),oi=function(){function t(t,e){this.R=t,this.Ut=e}return t.prototype.addEntry=function(t,e,n){return ai(t).put(ci(e),n)},t.prototype.removeEntry=function(t,e){var n=ai(t),r=ci(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.me(t,r)}))},t.prototype.getEntry=function(t,e){var n=this;return ai(t).get(ci(e)).next((function(t){return n.ye(e,t)}))},t.prototype.ge=function(t,e){var n=this;return ai(t).get(ci(e)).next((function(t){return{document:n.ye(e,t),size:qr(t)}}))},t.prototype.getEntries=function(t,e){var n=this,r=Pe();return this.pe(t,e,(function(t,e){var i=n.ye(t,e);r=r.insert(t,i)})).next((function(){return r}))},t.prototype.Ee=function(t,e){var n=this,r=Pe(),i=new ke(Q.comparator);return this.pe(t,e,(function(t,e){var o=n.ye(t,e);r=r.insert(t,o),i=i.insert(t,qr(e))})).next((function(){return{documents:r,Te:i}}))},t.prototype.pe=function(t,e,n){if(e.isEmpty())return rr.resolve();var r=IDBKeyRange.bound(e.first().path.toArray(),e.last().path.toArray()),i=e.getIterator(),o=i.getNext();return ai(t).$t({range:r},(function(t,e,r){for(var s=Q.fromSegments(t);o&&Q.comparator(o,s)<0;)n(o,null),o=i.getNext();o&&o.isEqual(s)&&(n(o,e),o=i.hasNext()?i.getNext():null),o?r.Ct(o.path.toArray()):r.done()})).next((function(){for(;o;)n(o,null),o=i.hasNext()?i.getNext():null}))},t.prototype.getDocumentsMatchingQuery=function(t,e,n){var r=this,i=Pe(),o=e.path.length+1,s={};if(n.isEqual(S.min())){var u=e.path.toArray();s.range=IDBKeyRange.lowerBound(u)}else{var a=e.path.toArray(),c=Ir(n);s.range=IDBKeyRange.lowerBound([a,c],!0),s.index=Kn.collectionReadTimeIndex}return ai(t).$t(s,(function(t,n,s){if(t.length===o){var u=wr(r.R,n);e.path.isPrefixOf(u.key.path)?jt(e,u)&&(i=i.insert(u.key,u)):s.done()}})).next((function(){return i}))},t.prototype.newChangeBuffer=function(t){return new si(this,!!t&&t.trackRemovals)},t.prototype.getSize=function(t){return this.getMetadata(t).next((function(t){return t.byteSize}))},t.prototype.getMetadata=function(t){return ui(t).get(Qn.key).next((function(t){return v(!!t),t}))},t.prototype.me=function(t,e){return ui(t).put(Qn.key,e)},t.prototype.ye=function(t,e){if(e){var n=wr(this.R,e);if(!n.isNoDocument()||!n.version.isEqual(S.min()))return n}return at.newInvalidDocument(t)},t}(),si=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).Ie=e,r.trackRemovals=n,r.Ae=new ri((function(t){return t.toString()}),(function(t,e){return t.isEqual(e)})),r}return(0,r.ZT)(e,t),e.prototype.applyChanges=function(t){var e=this,n=[],r=0,i=new Re((function(t,e){return I(t.canonicalString(),e.canonicalString())}));
2return this.changes.forEach((function(o,s){var u=e.Ae.get(o);if(s.document.isValidDocument()){var a=br(e.Ie.R,s.document,e.getReadTime(o));i=i.add(o.path.popLast());var c=qr(a);r+=c-u,n.push(e.Ie.addEntry(t,o,a))}else if(r-=u,e.trackRemovals){var h=br(e.Ie.R,at.newNoDocument(o,S.min()),e.getReadTime(o));n.push(e.Ie.addEntry(t,o,h))}else n.push(e.Ie.removeEntry(t,o))})),i.forEach((function(r){n.push(e.Ie.Ut.addToCollectionParentIndex(t,r))})),n.push(this.Ie.updateMetadata(t,r)),rr.waitFor(n)},e.prototype.getFromCache=function(t,e){var n=this;return this.Ie.ge(t,e).next((function(t){return n.Ae.set(e,t.size),t.document}))},e.prototype.getAllFromCache=function(t,e){var n=this;return this.Ie.Ee(t,e).next((function(t){var e=t.documents;return t.Te.forEach((function(t,e){n.Ae.set(t,e)})),e}))},e}(ii);function ui(t){return pr(t,Qn.store)}function ai(t){return pr(t,Kn.store)}function ci(t){return t.path.toArray()}var hi=function(){function t(t){this.R=t}return t.prototype.Rt=function(t,e,n,r){var i=this;v(n<r&&n>=0&&r<=11);var o=new ir("createOrUpgrade",e);n<1&&r>=1&&(function(t){t.createObjectStore(Vn.store)}(t),function(t){t.createObjectStore(qn.store,{keyPath:qn.keyPath}),t.createObjectStore(Un.store,{keyPath:Un.keyPath,autoIncrement:!0}).createIndex(Un.userMutationsIndex,Un.userMutationsKeyPath,{unique:!0}),t.createObjectStore(Gn.store)}(t),fi(t),function(t){t.createObjectStore(Kn.store)}(t));var s=rr.resolve();return n<3&&r>=3&&(0!==n&&(function(t){t.deleteObjectStore(Jn.store),t.deleteObjectStore(zn.store),t.deleteObjectStore(Wn.store)}(t),fi(t)),s=s.next((function(){return function(t){var e=t.store(Wn.store),n=new Wn(0,0,S.min().toTimestamp(),0);return e.put(Wn.key,n)}(o)}))),n<4&&r>=4&&(0!==n&&(s=s.next((function(){return function(t,e){return e.store(Un.store).Nt().next((function(n){t.deleteObjectStore(Un.store),t.createObjectStore(Un.store,{keyPath:Un.keyPath,autoIncrement:!0}).createIndex(Un.userMutationsIndex,Un.userMutationsKeyPath,{unique:!0});var r=e.store(Un.store),i=n.map((function(t){return r.put(t)}));return rr.waitFor(i)}))}(t,o)}))),s=s.next((function(){!function(t){t.createObjectStore(Zn.store,{keyPath:Zn.keyPath})}(t)}))),n<5&&r>=5&&(s=s.next((function(){return i.Re(o)}))),n<6&&r>=6&&(s=s.next((function(){return function(t){t.createObjectStore(Qn.store)}(t),i.be(o)}
2))),n<7&&r>=7&&(s=s.next((function(){return i.ve(o)}))),n<8&&r>=8&&(s=s.next((function(){return i.Pe(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(Kn.store);e.createIndex(Kn.readTimeIndex,Kn.readTimeIndexPath,{unique:!1}),e.createIndex(Kn.collectionReadTimeIndex,Kn.collectionReadTimeIndexPath,{unique:!1})}(e)}))),n<10&&r>=10&&(s=s.next((function(){return i.Ve(o)}))),n<11&&r>=11&&(s=s.next((function(){!function(t){t.createObjectStore(Yn.store,{keyPath:Yn.keyPath})}(t),function(t){t.createObjectStore($n.store,{keyPath:$n.keyPath})}(t)}))),s},t.prototype.be=function(t){var e=0;return t.store(Kn.store).$t((function(t,n){e+=qr(n)})).next((function(){var n=new Qn(e);return t.store(Qn.store).put(Qn.key,n)}))},t.prototype.Re=function(t){var e=this,n=t.store(qn.store),r=t.store(Un.store);return n.Nt().next((function(n){return rr.forEach(n,(function(n){var i=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return r.Nt(Un.userMutationsIndex,i).next((function(r){return rr.forEach(r,(function(r){v(r.userId===n.userId);var i=Sr(e.R,r);return Vr(t,n.userId,i).next((function(){}))}))}))}))}))},t.prototype.ve=function(t){var e=t.store(Jn.store),n=t.store(Kn.store);return t.store(Wn.store).get(Wn.key).next((function(t){var r=[];return n.$t((function(n,i){var o=new C(n),s=function(t){return[0,Ln(t)]}(o);r.push(e.get(s).next((function(n){return n?rr.resolve():function(n){return e.put(new Jn(0,Ln(n),t.highestListenSequenceNumber))}(o)})))})).next((function(){return rr.waitFor(r)}))}))},t.prototype.Pe=function(t,e){t.createObjectStore(Hn.store,{keyPath:Hn.keyPath});var n=e.store(Hn.store),r=new Lr,i=function(t){if(r.add(t)){var e=t.lastSegment(),i=t.popLast();return n.put({collectionId:e,parent:Ln(i)})}};return e.store(Kn.store).$t({Ft:!0},(function(t,e){var n=new C(t);return i(n.popLast())})).next((function(){return e.store(Gn.store).$t({Ft:!0},(function(t,e){t[0];var n=t[1];t[2];var r=Fn(n);return i(r.popLast())}))}))},t.prototype.Ve=function(t){var e=this,n=t.store(zn.store);return n.$t((function(t,r){var i=Nr(r),o=Dr(e.R,i);return n.put(o)}))},t}();function fi(t){t.createObjectStore(Jn.store,{keyPath:Jn.keyPath}).createIndex(Jn.documentTargetsIndex,Jn.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(zn.store,{keyPath:zn.keyPath}).createIndex(zn.queryTargetsIndexName,zn.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(Wn.store)}var li="Failed to obtain exclusive access to the persistence layer. To allow shared access, multi-tab synchronization has to be enabled in all tabs. If you are using `experimentalForceOwningTab:true`, make sure that only one tab has persistence enabled at any given time.",di=function(){function t(e,n,r,i,o,s,u,h,f,l){if(this.allowTabSynchronization=e,this.persistenceKey=n,this.clientId=r,this.Se=o,this.window=s,this.document=u,this.De=f,this.Ce=l,this.Ne=null,this.xe=!1,this.isPrimary=!1,this.networkEnabled=!0,this.ke=null,this.inForeground=!1,this.Fe=null,this.$e=null,this.Oe=Number.NEGATIVE_INFINITY,this.Me=function(t){return Promise.resolve()},!t.yt())throw new c(a.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new ei(this,i),this.Le=n+"main",this.R=new gr(h),this.Be=new or(this.Le,11,new hi(this.R)),this.qe=new zr(this.referenceDelegate,this.R),this.Ut=new Or,this.Ue=function(t,e){return new oi(t,e)}(this.R,this.Ut),this.Ke=new kr,this.window&&this.window.localStorage?this.Qe=this.window.localStorage:(this.Qe=null,!1===l&&d("IndexedDbPersistence","LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}return t.prototype.start=function(){var t=this;return this.je().then((function(){if(!t.isPrimary&&!t.allowTabSynchronization)throw new c(a.FAILED_PRECONDITION,li);return t.We(),t.Ge(),t.ze(),t.runTransaction("getHighestListenSequenceNumber","readonly",(function(e){return t.qe.getHighestSequenceNumber(e)}))})).then((function(e){t.Ne=new u(e,t.De)})).then((function(){t.xe=!0})).catch((function(e){return t.Be&&t.Be.close(),Promise.reject(e)}))},t.prototype.He=function(t){var e=this;return this.Me=function(n){return(0,r.mG)(e,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){return this.started?[2,t(n)]:[2]}))}))},t(this.isPrimary)},t.prototype.setDatabaseDeletedListener=function(t){var e=this;this.Be.vt((function(n){return(0,r.mG)(e,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return null===n.newVersion?[4,t()]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}
2))}))}))},t.prototype.setNetworkEnabled=function(t){var e=this;this.networkEnabled!==t&&(this.networkEnabled=t,this.Se.enqueueAndForget((function(){return(0,r.mG)(e,void 0,void 0,(function(){return(0,r.Jh)(this,(function(t){switch(t.label){case 0:return this.started?[4,this.je()]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}))}))})))},t.prototype.je=function(){var t=this;return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",(function(e){return yi(e).put(new Zn(t.clientId,Date.now(),t.networkEnabled,t.inForeground)).next((function(){if(t.isPrimary)return t.Je(e).next((function(e){e||(t.isPrimary=!1,t.Se.enqueueRetryable((function(){return t.Me(!1)})))}))})).next((function(){return t.Ye(e)})).next((function(n){return t.isPrimary&&!n?t.Xe(e).next((function(){return!1})):!!n&&t.Ze(e).next((function(){return!0}))}))})).catch((function(e){if(ar(e))return l("IndexedDbPersistence","Failed to extend owner lease: ",e),t.isPrimary;if(!t.allowTabSynchronization)throw e;return l("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1})).then((function(e){t.isPrimary!==e&&t.Se.enqueueRetryable((function(){return t.Me(e)})),t.isPrimary=e}))},t.prototype.Je=function(t){var e=this;return pi(t).get(Vn.key).next((function(t){return rr.resolve(e.tn(t))}))},t.prototype.en=function(t){return yi(t).delete(this.clientId)},t.prototype.nn=function(){return(0,r.mG)(this,void 0,void 0,(function(){var t,e,n,i,o=this;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return!this.isPrimary||this.sn(this.Oe,18e5)?[3,2]:(this.Oe=Date.now(),[4,this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",(function(t){var e=pr(t,Zn.store);return e.Nt().next((function(t){var n=o.rn(t,18e5),r=t.filter((function(t){return-1===n.indexOf(t)}));return rr.forEach(r,(function(t){return e.delete(t.clientId)})).next((function(){return r}))}))})).catch((function(){return[]}))]);case 1:if(t=r.sent(),this.Qe)for(e=0,n=t;e<n.length;e++)i=n[e],this.Qe.removeItem(this.on(i.clientId));r.label=2;case 2:return[2]}}
2))}))},t.prototype.ze=function(){var t=this;this.$e=this.Se.enqueueAfterDelay("client_metadata_refresh",4e3,(function(){return t.je().then((function(){return t.nn()})).then((function(){return t.ze()}))}))},t.prototype.tn=function(t){return!!t&&t.ownerId===this.clientId},t.prototype.Ye=function(t){var e=this;return this.Ce?rr.resolve(!0):pi(t).get(Vn.key).next((function(n){if(null!==n&&e.sn(n.leaseTimestampMs,5e3)&&!e.cn(n.ownerId)){if(e.tn(n)&&e.networkEnabled)return!0;if(!e.tn(n)){if(!n.allowTabSynchronization)throw new c(a.FAILED_PRECONDITION,li);return!1}}return!(!e.networkEnabled||!e.inForeground)||yi(t).Nt().next((function(t){return void 0===e.rn(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&&l("IndexedDbPersistence","Client "+(t?"is":"is not")+" eligible for a primary lease."),t}))},t.prototype.shutdown=function(){return(0,r.mG)(this,void 0,void 0,(function(){var t=this;return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return this.xe=!1,this.un(),this.$e&&(this.$e.cancel(),this.$e=null),this.an(),this.hn(),[4,this.Be.runTransaction("shutdown","readwrite",[Vn.store,Zn.store],(function(e){var n=new dr(e,u.o);return t.Xe(n).next((function(){return t.en(n)}))}))];case 1:return e.sent(),this.Be.close(),this.ln(),[2]}}))}))},t.prototype.rn=function(t,e){var n=this;return t.filter((function(t){return n.sn(t.updateTimeMs,e)&&!n.cn(t.clientId)}))},t.prototype.fn=function(){var t=this;return this.runTransaction("getActiveClients","readonly",(function(e){return yi(e).Nt().next((function(e){return t.rn(e,18e5).map((function(t){return t.clientId}))}))}))},Object.defineProperty(t.prototype,"started",{get:function(){return this.xe},enumerable:!1,configurable:!0}),t.prototype.getMutationQueue=function(t){return Ur.Qt(t,this.R,this.Ut,this.referenceDelegate)},t.prototype.getTargetCache=function(){return this.qe},t.prototype.getRemoteDocumentCache=function(){return this.Ue},t.prototype.getIndexManager=function(){return this.Ut},t.prototype.getBundleCache=function(){return this.Ke},t.prototype.runTransaction=function(t,e,n){var r=this;l("IndexedDbPersistence","Starting transaction:",t);var i,o="readonly"===e?"readonly":"readwrite";return this.Be.runTransaction(t,o,Xn,(function(o){return i=new dr(o,r.Ne?r.Ne.next():u.o),"readwrite-primary"===e?r.Je(i).next((function(t){return!!t||r.Ye(i)})).next((function(e){if(!e)throw d("Failed to obtain primary lease for action '"+t+"'."),r.isPrimary=!1,r.Se.enqueueRetryable((function(){return r.Me(!1)})),new c(a.FAILED_PRECONDITION,tr);return n(i)})).next((function(t){return r.Ze(i).next((function(){return t}))})):r.dn(i).next((function(){return n(i)}))})).then((function(t){return i.raiseOnCommittedEvent(),t}))},t.prototype.dn=function(t){var e=this;return pi(t).get(Vn.key).next((function(t){if(null!==t&&e.sn(t.leaseTimestampMs,5e3)&&!e.cn(t.ownerId)&&!e.tn(t)&&!(e.Ce||e.allowTabSynchronization&&t.allowTabSynchronization))throw new c(a.FAILED_PRECONDITION,li)}))},t.prototype.Ze=function(t){var e=new Vn(this.clientId,this.allowTabSynchronization,Date.now());return pi(t).put(Vn.key,e)},t.yt=function(){return or.yt()},t.prototype.Xe=function(t){var e=this,n=pi(t);return n.get(Vn.key).next((function(t){return e.tn(t)?(l("IndexedDbPersistence","Releasing primary lease."),n.delete(Vn.key)):rr.resolve()}))},t.prototype.sn=function(t,e){var n=Date.now();return!(t<n-e||t>n&&(d("Detected an update time that is in the future: "+t+" > "+n),1))},t.prototype.We=function(){var t=this;null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Fe=function(){t.Se.enqueueAndForget((function(){return t.inForeground="visible"===t.document.visibilityState,t.je()}))},this.document.addEventListener("visibilitychange",this.Fe),this.inForeground="visible"===this.document.visibilityState)},t.prototype.an=function(){this.Fe&&(this.document.removeEventListener("visibilitychange",this.Fe),this.Fe=null)},t.prototype.Ge=function(){var t,e=this;"function"==typeof(null===(t=this.window)||void 0===t?void 0:t.addEventListener)&&(this.ke=function(){e.un(),(0,i.G6)()&&navigator.appVersion.match("Version/14")&&e.Se.enterRestrictedMode(!0),e.Se.enqueueAndForget((function(){return e.shutdown()}))},this.window.addEventListener("pagehide",this.ke))},t.prototype.hn=function(){this.ke&&(this.window.removeEventListener("pagehide",this.ke),this.ke=null)},t.prototype.cn=function(t){var e;try{var n=null!==(null===(e=this.Qe)||void 0===e?void 0:e.getItem(this.on(t)));return l("IndexedDbPersistence","Client '"+t+"' "+(n?"is":"is not")+" zombied in LocalStorage"),n}catch(t){return d("IndexedDbPersistence","Failed to get zombied client id.",t),!1}},t.prototype.un=function(){if(this.Qe)try{this.Qe.setItem(this.on(this.clientId),String(Date.now()))}catch(t){d("Failed to set zombie client id.",t)}},t.prototype.ln=function(){if(this.Qe)try{this.Qe.removeItem(this.on(this.clientId))}catch(t){}},t.prototype.on=function(t){return"firestore_zombie_"+this.persistenceKey+"_"+t},t}();function pi(t){return pr(t,Vn.store)}function yi(t){return pr(t,Zn.store)}function mi(t,e){var n=t.projectId;return t.isDefaultDatabase||(n+="."+t.database),"firestore/"+e+"/"+n+"/"}var vi=function(t,e){this.progress=t,this.wn=e},gi=function(){function t(t,e,n){this.Ue=t,this._n=e,this.Ut=n}return t.prototype.mn=function(t,e){var n=this;return this._n.getAllMutationBatchesAffectingDocumentKey(t,e).next((function(r){return n.yn(t,e,r)}))},t.prototype.yn=function(t,e,n){return this.Ue.getEntry(t,e).next((function(t){for(var e=0,r=n;e<r.length;e++)r[e].applyToLocalView(t);return t}))},t.prototype.gn=function(t,e){t.forEach((function(t,n){for(var r=0,i=e;r<i.length;r++)i[r].applyToLocalView(n)}))},t.prototype.pn=function(t,e){var n=this;return this.Ue.getEntries(t,e).next((function(e){return n.En(t,e).next((function(){return e}))}))},t.prototype.En=function(t,e){var n=this;return this._n.getAllMutationBatchesAffectingDocumentKeys(t,e).next((function(t){return n.gn(e,t)}))},t.prototype.getDocumentsMatchingQuery=function(t,e,n){return function(t){return Q.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}(e)?this.Tn(t,e.path):Ft(e)?this.In(t,e,n):this.An(t,e,n)},t.prototype.Tn=function(t,e){return this.mn(t,new Q(e)).next((function(t){var e=Me();
2return t.isFoundDocument()&&(e=e.insert(t.key,t)),e}))},t.prototype.In=function(t,e,n){var r=this,i=e.collectionGroup,o=Me();return this.Ut.getCollectionParents(t,i).next((function(s){return rr.forEach(s,(function(s){var u=function(t,e){return new kt(e,null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(e,s.child(i));return r.An(t,u,n).next((function(t){t.forEach((function(t,e){o=o.insert(t,e)}))}))})).next((function(){return o}))}))},t.prototype.An=function(t,e,n){var r,i,o=this;return this.Ue.getDocumentsMatchingQuery(t,e,n).next((function(n){return r=n,o._n.getAllMutationBatchesAffectingQuery(t,e)})).next((function(e){return i=e,o.Rn(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);null==h&&(h=at.newInvalidDocument(c),r=r.insert(c,h)),de(a,h,o.localWriteTime),h.isFoundDocument()||(r=r.remove(c))}}))})).next((function(){return r.forEach((function(t,n){jt(e,n)||(r=r.remove(t))})),r}))},t.prototype.Rn=function(t,e,n){for(var r=Ge(),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 ge&&null===n.get(a.key)&&(r=r.add(a.key))}var c=n;return this.Ue.getEntries(t,r).next((function(t){return t.forEach((function(t,e){e.isFoundDocument()&&(c=c.insert(t,e))})),c}))},t}(),wi=function(){function t(t,e,n,r){this.targetId=t,this.fromCache=e,this.bn=n,this.vn=r}return t.Pn=function(e,n){for(var r=Ge(),i=Ge(),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}(),bi=function(){function t(){}return t.prototype.Vn=function(t){this.Sn=t},t.prototype.getDocumentsMatchingQuery=function(t,e,n,r){var i=this;return function(t){return 0===t.filters.length&&null===t.limit&&null==t.startAt&&null==t.endAt&&(0===t.explicitOrderBy.length||1===t.explicitOrderBy.length&&t.explicitOrderBy[0].field.isKeyField())}(e)||n.isEqual(S.min())?this.Dn(t,e):this.Sn.pn(t,r).next((function(s){var u=i.Cn(e,s);return(Rt(e)||Lt(e))&&i.Nn(e.limitType,u,r,n)?i.Dn(t,e):(f()<=o.in.DEBUG&&l("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),Bt(e)),i.Sn.getDocumentsMatchingQuery(t,e,n).next((function(t){return u.forEach((function(e){t=t.insert(e.key,e)})),t})))}))},t.prototype.Cn=function(t,e){var n=new Re(Kt(t));return e.forEach((function(e,r){jt(t,r)&&(n=n.add(r))})),n},t.prototype.Nn=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.compareTo(r)>0)},t.prototype.Dn=function(t,e){return f()<=o.in.DEBUG&&l("QueryEngine","Using full collection scan to execute query:",Bt(e)),this.Sn.getDocumentsMatchingQuery(t,e,S.min())},t}(),Ii=function(){function t(t,e,n,r){this.persistence=t,this.xn=e,this.R=r,this.kn=new ke(I),this.Fn=new ri((function(t){return ft(t)}),lt),this.$n=S.min(),this._n=t.getMutationQueue(n),this.On=t.getRemoteDocumentCache(),this.qe=t.getTargetCache(),this.Mn=new gi(this.On,this._n,this.persistence.getIndexManager()),this.Ke=t.getBundleCache(),this.xn.Vn(this.Mn)}return t.prototype.collectGarbage=function(t){var e=this;return this.persistence.runTransaction("Collect garbage","readwrite-primary",(function(n){return t.collect(n,e.kn)}))},t}();function Ti(t,e,n,r){return new Ii(t,e,n,r)}function Ei(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o,s;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return n=g(t),i=n._n,o=n.Mn,[4,n.persistence.runTransaction("Handle user change","readonly",(function(t){var r;return n._n.getAllMutationBatches(t).next((function(s){return r=s,i=n.persistence.getMutationQueue(e),o=new gi(n.On,i,n.persistence.getIndexManager()),i.getAllMutationBatches(t)})).next((function(e){for(var n=[],i=[],s=Ge(),u=0,a=r;u<a.length;u++){var c=a[u];n.push(c.batchId);for(var h=0,f=c.mutations;h<f.length;h++){var l=f[h];s=s.add(l.key)}}for(var d=0,p=e;d<p.length;d++){var y=p[d];i.push(y.batchId);for(var m=0,v=y.mutations;m<v.length;m++){var g=v[m];s=s.add(g.key)}}return o.pn(t,s).next((function(t){return{Ln:t,removedBatchIds:n,addedBatchIds:i}}))}))}))];case 1:return s=r.sent(),[2,(n._n=i,n.Mn=o,n.xn.Vn(n.Mn),s)]}}))}))}function _i(t,e){var n=g(t);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",(function(t){var r=e.batch.keys(),i=n.On.newChangeBuffer({trackRemovals:!0});return function(t,e,n,r){var i=n.batch,o=i.keys(),s=rr.resolve();return o.forEach((function(t){s=s.next((function(){return r.getEntry(e,t)})).next((function(e){var o=n.docVersions.get(t);v(null!==o),e.version.compareTo(o)<0&&(i.applyToRemoteDocument(e,n),e.isValidDocument()&&r.addEntry(e,n.commitVersion))}))})),s.next((function(){return t._n.removeMutationBatch(e,i)}))}(n,t,e,i).next((function(){return i.apply(t)})).next((function(){return n._n.performConsistencyCheck(t)})).next((function(){return n.Mn.pn(t,r)}))}))}function Si(t){var e=g(t);return e.persistence.runTransaction("Get last remote snapshot version","readonly",(function(t){return e.qe.getLastRemoteSnapshotVersion(t)}))}function Ni(t,e){var n=g(t),r=e.snapshotVersion,i=n.kn;return n.persistence.runTransaction("Apply remote event","readwrite-primary",(function(t){var o=n.On.newChangeBuffer({trackRemovals:!0});i=n.kn;var s=[];
2e.targetChanges.forEach((function(e,o){var u=i.get(o);if(u){s.push(n.qe.removeMatchingKeys(t,e.removedDocuments,o).next((function(){return n.qe.addMatchingKeys(t,e.addedDocuments,o)})));var a=e.resumeToken;if(a.approximateByteSize()>0){var c=u.withResumeToken(a,r).withSequenceNumber(t.currentSequenceNumber);i=i.insert(o,c),function(t,e,n){return v(e.resumeToken.approximateByteSize()>0),0===t.resumeToken.approximateByteSize()||e.snapshotVersion.toMicroseconds()-t.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(u,c,e)&&s.push(n.qe.updateTargetData(t,c))}}}));var u=Pe();if(e.documentUpdates.forEach((function(r,i){e.resolvedLimboDocuments.has(r)&&s.push(n.persistence.referenceDelegate.updateLimboDocument(t,r))})),s.push(Di(t,o,e.documentUpdates,r,void 0).next((function(t){u=t}))),!r.isEqual(S.min())){var a=n.qe.getLastRemoteSnapshotVersion(t).next((function(e){return n.qe.setTargetsMetadata(t,t.currentSequenceNumber,r)}));s.push(a)}return rr.waitFor(s).next((function(){return o.apply(t)})).next((function(){return n.Mn.En(t,u)})).next((function(){return u}))})).then((function(t){return n.kn=i,t}))}function Di(t,e,n,r,i){var o=Ge();return n.forEach((function(t){return o=o.add(t)})),e.getEntries(t,o).next((function(t){var o=Pe();return n.forEach((function(n,s){var u=t.get(n),a=(null==i?void 0:i.get(n))||r;s.isNoDocument()&&s.version.isEqual(S.min())?(e.removeEntry(n,a),o=o.insert(n,s)):!u.isValidDocument()||s.version.compareTo(u.version)>0||0===s.version.compareTo(u.version)&&u.hasPendingWrites?(e.addEntry(s,a),o=o.insert(n,s)):l("LocalStore","Ignoring outdated watch update for ",n,". Current version:",u.version," Watch version:",s.version)})),o}))}function Ai(t,e){var n=g(t);return n.persistence.runTransaction("Get next mutation batch","readonly",(function(t){return void 0===e&&(e=-1),n._n.getNextMutationBatchAfterBatchId(t,e)}))}function ki(t,e){var n=g(t);return n.persistence.runTransaction("Allocate target","readwrite",(function(t){var r;return n.qe.getTargetData(t,e).next((function(i){return i?(r=i,rr.resolve(r)):n.qe.allocateTargetId(t).next((function(i){return r=new vr(e,i,0,t.currentSequenceNumber),n.qe.addTargetData(t,r).next((function(){return r}))}))}))})).then((function(t){var r=n.kn.get(t.targetId);return(null===r||t.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.kn=n.kn.insert(t.targetId,t),n.Fn.set(e,t.targetId)),t}))}function Ci(t,e,n){return(0,r.mG)(this,void 0,void 0,(function(){var i,o,s,u;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:i=g(t),o=i.kn.get(e),s=n?"readwrite":"readwrite-primary",r.label=1;case 1:return r.trys.push([1,4,,5]),n?[3,3]:[4,i.persistence.runTransaction("Release target",s,(function(t){return i.persistence.referenceDelegate.removeTarget(t,o)}))];case 2:r.sent(),r.label=3;case 3:return[3,5];case 4:if(!ar(u=r.sent()))throw u;return l("LocalStore","Failed to update sequence numbers for target "+e+": "+u),[3,5];case 5:return i.kn=i.kn.remove(e),i.Fn.delete(o.target),[2]}}))}))}function xi(t,e,n){var r=g(t),i=S.min(),o=Ge();return r.persistence.runTransaction("Execute query","readonly",(function(t){return function(t,e,n){var r=g(t),i=r.Fn.get(n);return void 0!==i?rr.resolve(r.kn.get(i)):r.qe.getTargetData(e,n)}(r,t,Vt(e)).next((function(e){if(e)return i=e.lastLimboFreeSnapshotVersion,r.qe.getMatchingKeysForTargetId(t,e.targetId).next((function(t){o=t}))})).next((function(){return r.xn.getDocumentsMatchingQuery(t,e,n?i:S.min(),n?o:Ge())})).next((function(t){return{documents:t,Bn:o}}))}))}function Ri(t,e){var n=g(t),r=g(n.qe),i=n.kn.get(e);return i?Promise.resolve(i.target):n.persistence.runTransaction("Get target data","readonly",(function(t){return r.lt(t,e).next((function(t){return t?t.target:null}))}))}function Li(t){var e=g(t);return e.persistence.runTransaction("Get new document changes","readonly",(function(t){return function(t,e,n){var r=g(t),i=Pe(),o=Ir(n),s=ai(e),u=IDBKeyRange.lowerBound(o,!0);return s.$t({index:Kn.readTimeIndex,range:u},(function(t,e){var n=wr(r.R,e);i=i.insert(n.key,n),o=e.readTime})).next((function(){return{wn:i,readTime:Tr(o)}}))}(e.On,t,e.$n)}
2)).then((function(t){var n=t.wn,r=t.readTime;return e.$n=r,n}))}function Oi(t){return(0,r.mG)(this,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(n){return[2,(e=g(t)).persistence.runTransaction("Synchronize last document change read time","readonly",(function(t){return function(t){var e=ai(t),n=S.min();return e.$t({index:Kn.readTimeIndex,reverse:!0},(function(t,e,r){e.readTime&&(n=Tr(e.readTime)),r.done()})).next((function(){return n}))}(t)})).then((function(t){e.$n=t}))]}))}))}function Pi(t,e,n,i){return(0,r.mG)(this,void 0,void 0,(function(){var o,s,u,a,c,h,f,l,d,p;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:for(o=g(t),s=Ge(),u=Pe(),a=qe(),c=0,h=n;c<h.length;c++)f=h[c],l=e.qn(f.metadata.name),f.document&&(s=s.add(l)),u=u.insert(l,e.Un(f)),a=a.insert(l,e.Kn(f.metadata.readTime));return d=o.On.newChangeBuffer({trackRemovals:!0}),[4,ki(o,function(t){return Vt(xt(C.fromString("__bundle__/docs/"+t)))}(i))];case 1:return p=r.sent(),[2,o.persistence.runTransaction("Apply bundle documents","readwrite",(function(t){return Di(t,d,u,S.min(),a).next((function(e){return d.apply(t),e})).next((function(e){return o.qe.removeMatchingKeysForTargetId(t,p.targetId).next((function(){return o.qe.addMatchingKeys(t,s,p.targetId)})).next((function(){return o.Mn.En(t,e)})).next((function(){return e}))}))}))]}}))}))}function Fi(t,e,n){return void 0===n&&(n=Ge()),(0,r.mG)(this,void 0,void 0,(function(){var i,o;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return[4,ki(t,Vt(Ar(e.bundledQuery)))];case 1:return i=r.sent(),[2,(o=g(t)).persistence.runTransaction("Save named query","readwrite",(function(t){var r=sn(e.readTime);if(i.snapshotVersion.compareTo(r)>=0)return o.Ke.saveNamedQuery(t,e);var s=i.withResumeToken(O.EMPTY_BYTE_STRING,r);return o.kn=o.kn.insert(s.targetId,s),o.qe.updateTargetData(t,s).next((function(){return o.qe.removeMatchingKeysForTargetId(t,i.targetId)})).next((function(){return o.qe.addMatchingKeys(t,n,i.targetId)})).next((function(){return o.Ke.saveNamedQuery(t,e)}))}))]}}))}))}var Mi=function(){function t(t){this.R=t,this.Qn=new Map,this.jn=new Map}return t.prototype.getBundleMetadata=function(t,e){return rr.resolve(this.Qn.get(e))},t.prototype.saveBundleMetadata=function(t,e){var n;return this.Qn.set(e.id,{id:(n=e).id,version:n.version,createTime:sn(n.createTime)}),rr.resolve()},t.prototype.getNamedQuery=function(t,e){return rr.resolve(this.jn.get(e))},t.prototype.saveNamedQuery=function(t,e){return this.jn.set(e.name,function(t){return{name:t.name,query:Ar(t.bundledQuery),readTime:sn(t.readTime)}}(e)),rr.resolve()},t}(),Vi=function(){function t(){this.Wn=new Re(qi.Gn),this.zn=new Re(qi.Hn)}return t.prototype.isEmpty=function(){return this.Wn.isEmpty()},t.prototype.addReference=function(t,e){var n=new qi(t,e);this.Wn=this.Wn.add(n),this.zn=this.zn.add(n)},t.prototype.Jn=function(t,e){var n=this;t.forEach((function(t){return n.addReference(t,e)}))},t.prototype.removeReference=function(t,e){this.Yn(new qi(t,e))},t.prototype.Xn=function(t,e){var n=this;t.forEach((function(t){return n.removeReference(t,e)}))},t.prototype.Zn=function(t){var e=this,n=new Q(new C([])),r=new qi(n,t),i=new qi(n,t+1),o=[];return this.zn.forEachInRange([r,i],(function(t){e.Yn(t),o.push(t.key)})),o},t.prototype.ts=function(){var t=this;this.Wn.forEach((function(e){return t.Yn(e)}))},t.prototype.Yn=function(t){this.Wn=this.Wn.delete(t),this.zn=this.zn.delete(t)},t.prototype.es=function(t){var e=new Q(new C([])),n=new qi(e,t),r=new qi(e,t+1),i=Ge();return this.zn.forEachInRange([n,r],(function(t){i=i.add(t.key)})),i},t.prototype.containsKey=function(t){var e=new qi(t,0),n=this.Wn.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)},t}(),qi=function(){function t(t,e){this.key=t,this.ns=e}return t.Gn=function(t,e){return Q.comparator(t.key,e.key)||I(t.ns,e.ns)},t.Hn=function(t,e){return I(t.ns,e.ns)||Q.comparator(t.key,e.key)},t}(),Ui=function(){function t(t,e){this.Ut=t,this.referenceDelegate=e,this._n=[],this.ss=1,this.rs=new Re(qi.Gn)}return t.prototype.checkEmpty=function(t){return rr.resolve(0===this._n.length)},t.prototype.addMutationBatch=function(t,e,n,r){var i=this.ss;this.ss++,this._n.length>0&&this._n[this._n.length-1];var o=new yr(i,e,n,r);this._n.push(o);for(var s=0,u=r;s<u.length;s++){var a=u[s];this.rs=this.rs.add(new qi(a.key,i)),this.Ut.addToCollectionParentIndex(t,a.key.path.popLast())}return rr.resolve(o)},t.prototype.lookupMutationBatch=function(t,e){return rr.resolve(this.os(e))},t.prototype.getNextMutationBatchAfterBatchId=function(t,e){var n=e+1,r=this.cs(n),i=r
2<0?0:r;return rr.resolve(this._n.length>i?this._n[i]:null)},t.prototype.getHighestUnacknowledgedBatchId=function(){return rr.resolve(0===this._n.length?-1:this.ss-1)},t.prototype.getAllMutationBatches=function(t){return rr.resolve(this._n.slice())},t.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,e){var n=this,r=new qi(e,0),i=new qi(e,Number.POSITIVE_INFINITY),o=[];return this.rs.forEachInRange([r,i],(function(t){var e=n.os(t.ns);o.push(e)})),rr.resolve(o)},t.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var n=this,r=new Re(I);return e.forEach((function(t){var e=new qi(t,0),i=new qi(t,Number.POSITIVE_INFINITY);n.rs.forEachInRange([e,i],(function(t){r=r.add(t.ns)}))})),rr.resolve(this.us(r))},t.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var n=e.path,r=n.length+1,i=n;Q.isDocumentKey(i)||(i=i.child(""));var o=new qi(new Q(i),0),s=new Re(I);return this.rs.forEachWhile((function(t){var e=t.key.path;return!!n.isPrefixOf(e)&&(e.length===r&&(s=s.add(t.ns)),!0)}),o),rr.resolve(this.us(s))},t.prototype.us=function(t){var e=this,n=[];return t.forEach((function(t){var r=e.os(t);null!==r&&n.push(r)})),n},t.prototype.removeMutationBatch=function(t,e){var n=this;v(0===this.hs(e.batchId,"removed")),this._n.shift();var r=this.rs;return rr.forEach(e.mutations,(function(i){var o=new qi(i.key,e.batchId);return r=r.delete(o),n.referenceDelegate.markPotentiallyOrphaned(t,i.key)})).next((function(){n.rs=r}))},t.prototype.Gt=function(t){},t.prototype.containsKey=function(t,e){var n=new qi(e,0),r=this.rs.firstAfterOrEqual(n);return rr.resolve(e.isEqual(r&&r.key))},t.prototype.performConsistencyCheck=function(t){return this._n.length,rr.resolve()},t.prototype.hs=function(t,e){return this.cs(t)},t.prototype.cs=function(t){return 0===this._n.length?0:t-this._n[0].batchId},t.prototype.os=function(t){var e=this.cs(t);return e<0||e>=this._n.length?null:this._n[e]},t}(),Gi=function(){function t(t,e){this.Ut=t,this.ls=e,this.docs=new ke(Q.comparator),this.size=0}return t.prototype.addEntry=function(t,e,n){var r=e.key,i=this.docs.get(r),o=i?i.size:0,s=this.ls(e);return this.docs=this.docs.insert(r,{document:e.clone(),size:s,readTime:n}),this.size+=s-o,this.Ut.addToCollectionParentIndex(t,r.path.popLast())},t.prototype.removeEntry=function(t){var e=this.docs.get(t);e&&(this.docs=this.docs.remove(t),this.size-=e.size)},t.prototype.getEntry=function(t,e){var n=this.docs.get(e);return rr.resolve(n?n.document.clone():at.newInvalidDocument(e))},t.prototype.getEntries=function(t,e){var n=this,r=Pe();return e.forEach((function(t){var e=n.docs.get(t);r=r.insert(t,e?e.document.clone():at.newInvalidDocument(t))})),rr.resolve(r)},t.prototype.getDocumentsMatchingQuery=function(t,e,n){for(var r=Pe(),i=new Q(e.path.child("")),o=this.docs.getIteratorFrom(i);o.hasNext();){var s=o.getNext(),u=s.key,a=s.value,c=a.document,h=a.readTime;if(!e.path.isPrefixOf(u.path))break;h.compareTo(n)<=0||jt(e,c)&&(r=r.insert(c.key,c.clone()))}return rr.resolve(r)},t.prototype.fs=function(t,e){return rr.forEach(this.docs,(function(t){return e(t)}))},t.prototype.newChangeBuffer=function(t){return new Bi(this)},t.prototype.getSize=function(t){return rr.resolve(this.size)},t}(),Bi=function(t){function e(e){var n=this;return(n=t.call(this)||this).Ie=e,n}return(0,r.ZT)(e,t),e.prototype.applyChanges=function(t){var e=this,n=[];
2return this.changes.forEach((function(r,i){i.document.isValidDocument()?n.push(e.Ie.addEntry(t,i.document,e.getReadTime(r))):e.Ie.removeEntry(r)})),rr.waitFor(n)},e.prototype.getFromCache=function(t,e){return this.Ie.getEntry(t,e)},e.prototype.getAllFromCache=function(t,e){return this.Ie.getEntries(t,e)},e}(ii),ji=function(){function t(t){this.persistence=t,this.ds=new ri((function(t){return ft(t)}),lt),this.lastRemoteSnapshotVersion=S.min(),this.highestTargetId=0,this.ws=0,this._s=new Vi,this.targetCount=0,this.ys=Qr.Jt()}return t.prototype.forEachTarget=function(t,e){return this.ds.forEach((function(t,n){return e(n)})),rr.resolve()},t.prototype.getLastRemoteSnapshotVersion=function(t){return rr.resolve(this.lastRemoteSnapshotVersion)},t.prototype.getHighestSequenceNumber=function(t){return rr.resolve(this.ws)},t.prototype.allocateTargetId=function(t){return this.highestTargetId=this.ys.next(),rr.resolve(this.highestTargetId)},t.prototype.setTargetsMetadata=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.ws&&(this.ws=e),rr.resolve()},t.prototype.te=function(t){this.ds.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.ys=new Qr(e),this.highestTargetId=e),t.sequenceNumber>this.ws&&(this.ws=t.sequenceNumber)},t.prototype.addTargetData=function(t,e){return this.te(e),this.targetCount+=1,rr.resolve()},t.prototype.updateTargetData=function(t,e){return this.te(e),rr.resolve()},t.prototype.removeTargetData=function(t,e){return this.ds.delete(e.target),this._s.Zn(e.targetId),this.targetCount-=1,rr.resolve()},t.prototype.removeTargets=function(t,e,n){var r=this,i=0,o=[];return this.ds.forEach((function(s,u){u.sequenceNumber<=e&&null===n.get(u.targetId)&&(r.ds.delete(s),o.push(r.removeMatchingKeysForTargetId(t,u.targetId)),i++)})),rr.waitFor(o).next((function(){return i}))},t.prototype.getTargetCount=function(t){return rr.resolve(this.targetCount)},t.prototype.getTargetData=function(t,e){var n=this.ds.get(e)||null;return rr.resolve(n)},t.prototype.addMatchingKeys=function(t,e,n){return this._s.Jn(e,n),rr.resolve()},t.prototype.removeMatchingKeys=function(t,e,n){this._s.Xn(e,n);var r=this.persistence.referenceDelegate,i=[];return r&&e.forEach((function(e){i.push(r.markPotentiallyOrphaned(t,e))})),rr.waitFor(i)},t.prototype.removeMatchingKeysForTargetId=function(t,e){return this._s.Zn(e),rr.resolve()},t.prototype.getMatchingKeysForTargetId=function(t,e){var n=this._s.es(e);return rr.resolve(n)},t.prototype.containsKey=function(t,e){return rr.resolve(this._s.containsKey(e))},t}(),Ki=function(){function t(t,e){var n=this;this.gs={},this.Ne=new u(0),this.xe=!1,this.xe=!0,this.referenceDelegate=t(this),this.qe=new ji(this),this.Ut=new Rr,this.Ue=function(t,e){return new Gi(t,(function(t){return n.referenceDelegate.ps(t)}))}(this.Ut),this.R=new gr(e),this.Ke=new Mi(this.R)}return t.prototype.start=function(){return Promise.resolve()},t.prototype.shutdown=function(){return this.xe=!1,Promise.resolve()},Object.defineProperty(t.prototype,"started",{get:function(){return this.xe},enumerable:!1,configurable:!0}),t.prototype.setDatabaseDeletedListener=function(){},t.prototype.setNetworkEnabled=function(){},t.prototype.getIndexManager=function(){return this.Ut},t.prototype.getMutationQueue=function(t){var e=this.gs[t.toKey()];return e||(e=new Ui(this.Ut,this.referenceDelegate),this.gs[t.toKey()]=e),e},t.prototype.getTargetCache=function(){return this.qe},t.prototype.getRemoteDocumentCache=function(){return this.Ue},t.prototype.getBundleCache=function(){return this.Ke},t.prototype.runTransaction=function(t,e,n){var r=this;l("MemoryPersistence","Starting transaction:",t);var i=new Qi(this.Ne.next());return this.referenceDelegate.Es(),n(i).next((function(t){return r.referenceDelegate.Ts(i).next((function(){return t}))})).toPromise().then((function(t){return i.raiseOnCommittedEvent(),t}))},t.prototype.Is=function(t,e){return rr.or(Object.values(this.gs).map((function(n){return function(){return n.containsKey(t,e)}})))},t}(),Qi=function(t){function e(e){var n=this;return(n=t.call(this)||this).currentSequenceNumber=e,n}return(0,r.ZT)(e,t),e}(er),zi=function(){function t(t){this.persistence=t,this.As=new Vi,this.Rs=null}return t.bs=function(e){return new t(e)},Object.defineProperty(t.prototype,"vs",{get:function(){if(this.Rs)return this.Rs;throw m()}
2,enumerable:!1,configurable:!0}),t.prototype.addReference=function(t,e,n){return this.As.addReference(n,e),this.vs.delete(n.toString()),rr.resolve()},t.prototype.removeReference=function(t,e,n){return this.As.removeReference(n,e),this.vs.add(n.toString()),rr.resolve()},t.prototype.markPotentiallyOrphaned=function(t,e){return this.vs.add(e.toString()),rr.resolve()},t.prototype.removeTarget=function(t,e){var n=this;this.As.Zn(e.targetId).forEach((function(t){return n.vs.add(t.toString())}));var r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(t,e.targetId).next((function(t){t.forEach((function(t){return n.vs.add(t.toString())}))})).next((function(){return r.removeTargetData(t,e)}))},t.prototype.Es=function(){this.Rs=new Set},t.prototype.Ts=function(t){var e=this,n=this.persistence.getRemoteDocumentCache().newChangeBuffer();return rr.forEach(this.vs,(function(r){var i=Q.fromPath(r);return e.Ps(t,i).next((function(t){t||n.removeEntry(i)}))})).next((function(){return e.Rs=null,n.apply(t)}))},t.prototype.updateLimboDocument=function(t,e){var n=this;return this.Ps(t,e).next((function(t){t?n.vs.delete(e.toString()):n.vs.add(e.toString())}))},t.prototype.ps=function(t){return 0},t.prototype.Ps=function(t,e){var n=this;return rr.or([function(){return rr.resolve(n.As.containsKey(e))},function(){return n.persistence.getTargetCache().containsKey(t,e)},function(){return n.persistence.Is(t,e)}])},t}(),Ji=function(){function t(t){this.uid=t}return t.prototype.isAuthenticated=function(){return null!=this.uid},t.prototype.toKey=function(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"},t.prototype.isEqual=function(t){return t.uid===this.uid},t}();function Wi(t,e){return"firestore_clients_"+t+"_"+e}function Hi(t,e,n){var r="firestore_mutations_"+t+"_"+n;return e.isAuthenticated()&&(r+="_"+e.uid),r}function Zi(t,e){return"firestore_targets_"+t+"_"+e}Ji.UNAUTHENTICATED=new Ji(null),Ji.GOOGLE_CREDENTIALS=new Ji("google-credentials-uid"),Ji.FIRST_PARTY=new Ji("first-party-uid"),Ji.MOCK_USER=new Ji("mock-user");var Yi=function(){function t(t,e,n,r){this.user=t,this.batchId=e,this.state=n,this.error=r}return t.Vs=function(e,n,r){var i,o=JSON.parse(r),s="object"==typeof o&&-1!==["pending","acknowledged","rejected"].indexOf(o.state)&&(void 0===o.error||"object"==typeof o.error);return s&&o.error&&(s="string"==typeof o.error.message&&"string"==typeof o.error.code)&&(i=new c(o.error.code,o.error.message)),s?new t(e,n,o.state,i):(d("SharedClientState","Failed to parse mutation state for ID '"+n+"': "+r),null)},t.prototype.Ss=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}(),$i=function(){function t(t,e,n){this.targetId=t,this.state=e,this.error=n}return t.Vs=function(e,n){var r,i=JSON.parse(n),o="object"==typeof i&&-1!==["not-current","current","rejected"].indexOf(i.state)&&(void 0===i.error||"object"==typeof i.error);return o&&i.error&&(o="string"==typeof i.error.message&&"string"==typeof i.error.code)&&(r=new c(i.error.code,i.error.message)),o?new t(e,i.state,r):(d("SharedClientState","Failed to parse target state for ID '"+e+"': "+n),null)},t.prototype.Ss=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}(),Xi=function(){function t(t,e){this.clientId=t,this.activeTargetIds=e}return t.Vs=function(e,n){for(var r=JSON.parse(n),i="object"==typeof r&&r.activeTargetIds instanceof Array,o=je(),s=0;i&&s<r.activeTargetIds.length;++s)i=K(r.activeTargetIds[s]),o=o.add(r.activeTargetIds[s]);return i?new t(e,o):(d("SharedClientState","Failed to parse client data for instance '"+e+"': "+n),null)},t}(),to=function(){function t(t,e){this.clientId=t,this.onlineState=e}return t.Vs=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):(d("SharedClientState","Failed to parse online state: "+e),null)},t}(),eo=function(){function t(){this.activeTargetIds=je()}return t.prototype.Ds=function(t){this.activeTargetIds=this.activeTargetIds.add(t)},t.prototype.Cs=function(t){this.activeTargetIds=this.activeTargetIds.delete(t)},t.prototype.Ss=function(){var t={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(t)},t}(),no=function(){function t(t,e,n,r,i){this.window=t,this.Se=e,this.persistenceKey=n,this.Ns=r,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.xs=this.ks.bind(this),this.Fs=new ke(I),this.started=!1,this.$s=[];var o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Os=Wi(this.persistenceKey,this.Ns),this.Ms=function(t){return"firestore_sequence_number_"+t}(this.persistenceKey),this.Fs=this.Fs.insert(this.Ns,new eo),this.Ls=new RegExp("^firestore_clients_"+o+"_([^_]*)$"),this.Bs=new RegExp("^firestore_mutations_"+o+"_(\\d+)(?:_(.*))?$"),this.qs=new RegExp("^firestore_targets_"+o+"_(\\d+)$"),this.Us=function(t){return"firestore_online_state_"+t}(this.persistenceKey),this.Ks=function(t){return"firestore_bundle_loaded_"+t}(this.persistenceKey),this.window.addEventListener("storage",this.xs)}return t.yt=function(t){return!(!t||!t.localStorage)},t.prototype.start=function(){return(0,r.mG)(this,void 0,void 0,(function(){var t,e,n,i,o,s,u,a,c,h,f,l=this;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return[4,this.syncEngine.fn()];case 1:for(t=r.sent(),e=0,n=t;e<n.length;e++)(i=n[e])!==this.Ns&&(o=this.getItem(Wi(this.persistenceKey,i)))&&
2(s=Xi.Vs(i,o))&&(this.Fs=this.Fs.insert(s.clientId,s));for(this.Qs(),(u=this.storage.getItem(this.Us))&&(a=this.js(u))&&this.Ws(a),c=0,h=this.$s;c<h.length;c++)f=h[c],this.ks(f);return this.$s=[],this.window.addEventListener("pagehide",(function(){return l.shutdown()})),this.started=!0,[2]}}))}))},t.prototype.writeSequenceNumber=function(t){this.setItem(this.Ms,JSON.stringify(t))},t.prototype.getAllActiveQueryTargets=function(){return this.Gs(this.Fs)},t.prototype.isActiveQueryTarget=function(t){var e=!1;return this.Fs.forEach((function(n,r){r.activeTargetIds.has(t)&&(e=!0)})),e},t.prototype.addPendingMutation=function(t){this.zs(t,"pending")},t.prototype.updateMutationState=function(t,e,n){this.zs(t,e,n),this.Hs(t)},t.prototype.addLocalQueryTarget=function(t){var e="not-current";if(this.isActiveQueryTarget(t)){var n=this.storage.getItem(Zi(this.persistenceKey,t));if(n){var r=$i.Vs(t,n);r&&(e=r.state)}}return this.Js.Ds(t),this.Qs(),e},t.prototype.removeLocalQueryTarget=function(t){this.Js.Cs(t),this.Qs()},t.prototype.isLocalQueryTarget=function(t){return this.Js.activeTargetIds.has(t)},t.prototype.clearQueryState=function(t){this.removeItem(Zi(this.persistenceKey,t))},t.prototype.updateQueryState=function(t,e,n){this.Ys(t,e,n)},t.prototype.handleUserChange=function(t,e,n){var r=this;e.forEach((function(t){r.Hs(t)})),this.currentUser=t,n.forEach((function(t){r.addPendingMutation(t)}))},t.prototype.setOnlineState=function(t){this.Xs(t)},t.prototype.notifyBundleLoaded=function(){this.Zs()},t.prototype.shutdown=function(){this.started&&(this.window.removeEventListener("storage",this.xs),this.removeItem(this.Os),this.started=!1)},t.prototype.getItem=function(t){var e=this.storage.getItem(t);return l("SharedClientState","READ",t,e),e},t.prototype.setItem=function(t,e){l("SharedClientState","SET",t,e),this.storage.setItem(t,e)},t.prototype.removeItem=function(t){l("SharedClientState","REMOVE",t),this.storage.removeItem(t)},t.prototype.ks=function(t){var e=this,n=t;if(n.storageArea===this.storage){if(l("SharedClientState","EVENT",n.key,n.newValue),n.key===this.Os)return void d("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Se.enqueueRetryable((function(){return(0,r.mG)(e,void 0,void 0,(function(){var t,e,i,o,s,a;return(0,r.Jh)(this,(function(r){if(this.started){if(null!==n.key)if(this.Ls.test(n.key)){if(null==n.newValue)return t=this.ti(n.key),[2,this.ei(t,null)];if(e=this.ni(n.key,n.newValue))return[2,this.ei(e.clientId,e)]}else if(this.Bs.test(n.key)){if(null!==n.newValue&&(i=this.si(n.key,n.newValue)))return[2,this.ii(i)]}else if(this.qs.test(n.key)){if(null!==n.newValue&&(o=this.ri(n.key,n.newValue)))return[2,this.oi(o)]}else if(n.key===this.Us){if(null!==n.newValue&&(s=this.js(n.newValue)))return[2,this.Ws(s)]}else if(n.key===this.Ms)(a=function(t){var e=u.o;if(null!=t)try{var n=JSON.parse(t);v("number"==typeof n),e=n}catch(t){d("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(n.newValue))!==u.o&&this.sequenceNumberHandler(a);else if(n.key===this.Ks)return[2,this.syncEngine.ci()]}else this.$s.push(n);return[2]}))}))}))}},Object.defineProperty(t.prototype,"Js",{get:function(){return this.Fs.get(this.Ns)},enumerable:!1,configurable:!0}),t.prototype.Qs=function(){this.setItem(this.Os,this.Js.Ss())},t.prototype.zs=function(t,e,n){var r=new Yi(this.currentUser,t,e,n),i=Hi(this.persistenceKey,this.currentUser,t);this.setItem(i,r.Ss())},t.prototype.Hs=function(t){var e=Hi(this.persistenceKey,this.currentUser,t);this.removeItem(e)},t.prototype.Xs=function(t){var e={clientId:this.Ns,onlineState:t};this.storage.setItem(this.Us,JSON.stringify(e))},t.prototype.Ys=function(t,e,n){var r=Zi(this.persistenceKey,t),i=new $i(t,e,n);this.setItem(r,i.Ss())},t.prototype.Zs=function(){this.setItem(this.Ks,"value-not-used")},t.prototype.ti=function(t){var e=this.Ls.exec(t);return e?e[1]:null},t.prototype.ni=function(t,e){var n=this.ti(t);return Xi.Vs(n,e)},t.prototype.si=function(t,e){var n=this.Bs.exec(t),r=Number(n[1]),i=void 0!==n[2]?n[2]:null;return Yi.Vs(new Ji(i),r,e)},t.prototype.ri=function(t,e){var n=this.qs.exec(t),r=Number(n[1]);return $i.Vs(r,e)},t.prototype.js=function(t){return to.Vs(t)},t.prototype.ii=function(t){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){return t.user.uid===this.currentUser.uid?[2,this.syncEngine.ui(t.batchId,t.state,t.error)]:(l("SharedCl
2ientState","Ignoring mutation for non-active user "+t.user.uid),[2])}))}))},t.prototype.oi=function(t){return this.syncEngine.ai(t.targetId,t.state,t.error)},t.prototype.ei=function(t,e){var n=this,r=e?this.Fs.insert(t,e):this.Fs.remove(t),i=this.Gs(this.Fs),o=this.Gs(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.syncEngine.hi(s,u).then((function(){n.Fs=r}))},t.prototype.Ws=function(t){this.Fs.get(t.clientId)&&this.onlineStateHandler(t.onlineState)},t.prototype.Gs=function(t){var e=je();return t.forEach((function(t,n){e=e.unionWith(n.activeTargetIds)})),e},t}(),ro=function(){function t(){this.li=new eo,this.fi={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}return t.prototype.addPendingMutation=function(t){},t.prototype.updateMutationState=function(t,e,n){},t.prototype.addLocalQueryTarget=function(t){return this.li.Ds(t),this.fi[t]||"not-current"},t.prototype.updateQueryState=function(t,e,n){this.fi[t]=e},t.prototype.removeLocalQueryTarget=function(t){this.li.Cs(t)},t.prototype.isLocalQueryTarget=function(t){return this.li.activeTargetIds.has(t)},t.prototype.clearQueryState=function(t){delete this.fi[t]},t.prototype.getAllActiveQueryTargets=function(){return this.li.activeTargetIds},t.prototype.isActiveQueryTarget=function(t){return this.li.activeTargetIds.has(t)},t.prototype.start=function(){return this.li=new eo,Promise.resolve()},t.prototype.handleUserChange=function(t,e,n){},t.prototype.setOnlineState=function(t){},t.prototype.shutdown=function(){},t.prototype.writeSequenceNumber=function(t){},t.prototype.notifyBundleLoaded=function(){},t}(),io=function(){function t(){}return t.prototype.di=function(t){},t.prototype.shutdown=function(){},t}(),oo=function(){function t(){var t=this;this.wi=function(){return t._i()},this.mi=function(){return t.yi()},this.gi=[],this.pi()}return t.prototype.di=function(t){this.gi.push(t)},t.prototype.shutdown=function(){window.removeEventListener("online",this.wi),window.removeEventListener("offline",this.mi)},t.prototype.pi=function(){window.addEventListener("online",this.wi),window.addEventListener("offline",this.mi)},t.prototype._i=function(){l("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.gi;t<e.length;t++)(0,e[t])(0)},t.prototype.yi=function(){l("ConnectivityMonitor","Network connectivity changed: UNAVAILABLE");for(var t=0,e=this.gi;t<e.length;t++)(0,e[t])(1)},t.yt=function(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener},t}(),so={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"},uo=function(){function t(t){this.Ei=t.Ei,this.Ti=t.Ti}return t.prototype.Ii=function(t){this.Ai=t},t.prototype.Ri=function(t){this.bi=t},t.prototype.onMessage=function(t){this.vi=t},t.prototype.close=function(){this.Ti()},t.prototype.send=function(t){this.Ei(t)},t.prototype.Pi=function(){this.Ai()},t.prototype.Vi=function(t){this.bi(t)},t.prototype.Si=function(t){this.vi(t)},t}(),ao=function(t){function e(e){var n=this;return(n=t.call(this,e)||this).forceLongPolling=e.forceLongPolling,n.autoDetectLongPolling=e.autoDetectLongPolling,n.useFetchStreams=e.useFetchStreams,n}return(0,r.ZT)(e,t),e.prototype.Fi=function(t,e,n,r){return new Promise((function(i,o){var u=new s.JJ;u.listenOnce(s.tw.COMPLETE,(function(){try{switch(u.getLastErrorCode()){case s.jK.NO_ERROR:var e=u.getResponseJson();l("Connection","XHR received:",JSON.stringify(e)),i(e);break;case s.jK.TIMEOUT:l("Connection",'RPC "'+t+'" timed out'),o(new c(a.DEADLINE_EXCEEDED,"Request time out"));break;case s.jK.HTTP_ERROR:var n=u.getStatus();if(l("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 h=function(t){var e=t.toLowerCase().replace(/_/g,"-");return Object.values(a).indexOf(e)>=0?e:a.UNKNOWN}(r.status);o(new c(h,r.message))}else o(new c(a.UNKNOWN,"Server responded with status "+u.getStatus()))}else o(new c(a.UNAVAILABLE,"Connection failed."));break;default:m()}}finally{l("Connection",'RPC "'+t+'" completed.')}}));var h=JSON.stringify(r);u.send(e,"POST",h,n,15)}))},e.prototype.Oi=function(t,e){var n=[this.Di,"/","google.firestore.v1.Firestore","/",t,"/channel"],r=(0,s.UE)(),o=(0,s.FJ)(),u={httpSessionIdParam:"gsessionid",initMessageHeaders:{},messageUrlParams:{database:"projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database}
2,sendRawJson:!0,supportsCrossDomainXhr:!0,internalChannelParams:{forwardChannelRequestTimeoutMs:6e5},forceLongPolling:this.forceLongPolling,detectBufferingProxy:this.autoDetectLongPolling};this.useFetchStreams&&(u.xmlHttpFactory=new s.zI({})),this.ki(u.initMessageHeaders,e),(0,i.uI)()||(0,i.b$)()||(0,i.d)()||(0,i.w1)()||(0,i.Mn)()||(0,i.ru)()||(u.httpHeadersOverwriteParam="$httpHeaders");var h=n.join("");l("Connection","Creating WebChannel: "+h,u);var f=r.createWebChannel(h,u),d=!1,y=!1,m=new uo({Ei:function(t){y?l("Connection","Not sending because WebChannel is closed:",t):(d||(l("Connection","Opening WebChannel transport."),f.open(),d=!0),l("Connection","WebChannel sending:",t),f.send(t))},Ti:function(){return f.close()}}),g=function(t,e,n){t.listen(e,(function(t){try{n(t)}catch(t){setTimeout((function(){throw t}),0)}}))};return g(f,s.ii.EventType.OPEN,(function(){y||l("Connection","WebChannel transport opened.")})),g(f,s.ii.EventType.CLOSE,(function(){y||(y=!0,l("Connection","WebChannel transport closed"),m.Vi())})),g(f,s.ii.EventType.ERROR,(function(t){y||(y=!0,p("Connection","WebChannel transport errored:",t),m.Vi(new c(a.UNAVAILABLE,"The operation could not be completed")))})),g(f,s.ii.EventType.MESSAGE,(function(t){var e;if(!y){var n=t.data[0];v(!!n);var r=n,i=r.error||(null===(e=r[0])||void 0===e?void 0:e.error);if(i){l("Connection","WebChannel received error:",i);var o=i.status,s=function(t){var e=Te[t];if(void 0!==e)return Ae(e)}(o),u=i.message;void 0===s&&(s=a.INTERNAL,u="Unknown error status: "+o+" with message "+i.message),y=!0,m.Vi(new c(s,u)),f.close()}else l("Connection","WebChannel received:",n),m.Si(n)}})),g(o,s.ju.STAT_EVENT,(function(t){t.stat===s.kN.PROXY?l("Connection","Detected buffering proxy"):t.stat===s.kN.NOPROXY&&l("Connection","Detected no buffering proxy")})),setTimeout((function(){m.Pi()}),0),m},e}(function(){function t(t){this.databaseInfo=t,this.databaseId=t.databaseId;var e=t.ssl?"https":"http";this.Di=e+"://"+t.host,this.Ci="projects/"+this.databaseId.projectId+"/databases/"+this.databaseId.database+"/documents"}return t.prototype.Ni=function(t,e,n,r){var i=this.xi(t,e);l("RestConnection","Sending: ",i,n);var o={};return this.ki(o,r),this.Fi(t,i,o,n).then((function(t){return l("RestConnection","Received: ",t),t}),(function(e){throw p("RestConnection",t+" failed with error: ",e,"url: ",i,"request:",n),e}))},t.prototype.$i=function(t,e,n,r){return this.Ni(t,e,n,r)},t.prototype.ki=function(t,e){if(t["X-Goog-Api-Client"]="gl-js/ fire/8.10.1",t["Content-Type"]="text/plain",this.databaseInfo.appId&&(t["X-Firebase-GMPID"]=this.databaseInfo.appId),e)for(var n in e.authHeaders)e.authHeaders.hasOwnProperty(n)&&(t[n]=e.authHeaders[n])},t.prototype.xi=function(t,e){var n=so[t];return this.Di+"/v1/"+e+":"+n},t}());function co(){return"undefined"!=typeof window?window:null}function ho(){return"undefined"!=typeof document?document:null}function fo(t){return new en(t,!0)}var lo=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.Se=t,this.timerId=e,this.Mi=n,this.Li=r,this.Bi=i,this.qi=0,this.Ui=null,this.Ki=Date.now(),this.reset()}return t.prototype.reset=function(){this.qi=0},t.prototype.Qi=function(){this.qi=this.Bi},t.prototype.ji=function(t){var e=this;this.cancel();var n=Math.floor(this.qi+this.Wi()),r=Math.max(0,Date.now()-this.Ki),i=Math.max(0,n-r);i>0&&l("ExponentialBackoff","Backing off for "+i+" ms (base delay: "+this.qi+" ms, delay with jitter: "+n+" ms, last attempt: "+r+" ms ago)"),this.Ui=this.Se.enqueueAfterDelay(this.timerId,i,(function(){return e.Ki=Date.now(),t()})),this.qi*=this.Li,this.qi<this.Mi&&(this.qi=this.Mi),this.qi>this.Bi&&(this.qi=this.Bi)},t.prototype.Gi=function(){null!==this.Ui&&(this.Ui.skipDelay(),this.Ui=null)},t.prototype.cancel=function(){null!==this.Ui&&(this.Ui.cancel(),this.Ui=null)},t.prototype.Wi=function(){return(Math.random()-.5)*this.qi},t}(),po=function(){function t(t,e,n,r,i,o){this.Se=t,this.zi=n,this.Hi=r,this.Ji=i,this.listener=o,this.state=0,this.Yi=0,this.Xi=null,this.stream=null,this.Zi=new lo(t,e)}return t.prototype.tr=function(){return 1===this.state||2===this.state||4===this.state},t.prototype.er=function(){return 2===this.state},t.prototype.start=function(){3!==this.state?this.auth():this.nr()},t.prototype.stop=function(){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(t){switch(t.label){case 0:return this.tr()?[4,this.close(0)]:[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}
2))}))},t.prototype.sr=function(){this.state=0,this.Zi.reset()},t.prototype.ir=function(){var t=this;this.er()&&null===this.Xi&&(this.Xi=this.Se.enqueueAfterDelay(this.zi,6e4,(function(){return t.rr()})))},t.prototype.cr=function(t){this.ur(),this.stream.send(t)},t.prototype.rr=function(){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(t){return this.er()?[2,this.close(0)]:[2]}))}))},t.prototype.ur=function(){this.Xi&&(this.Xi.cancel(),this.Xi=null)},t.prototype.close=function(t,e){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return this.ur(),this.Zi.cancel(),this.Yi++,3!==t?this.Zi.reset():e&&e.code===a.RESOURCE_EXHAUSTED?(d(e.toString()),d("Using maximum backoff delay to prevent overloading the backend."),this.Zi.Qi()):e&&e.code===a.UNAUTHENTICATED&&this.Ji.invalidateToken(),null!==this.stream&&(this.ar(),this.stream.close(),this.stream=null),this.state=t,[4,this.listener.Ri(e)];case 1:return n.sent(),[2]}}))}))},t.prototype.ar=function(){},t.prototype.auth=function(){var t=this;this.state=1;var e=this.hr(this.Yi),n=this.Yi;this.Ji.getToken().then((function(e){t.Yi===n&&t.lr(e)}),(function(n){e((function(){var e=new c(a.UNKNOWN,"Fetching auth token failed: "+n.message);return t.dr(e)}))}))},t.prototype.lr=function(t){var e=this,n=this.hr(this.Yi);this.stream=this.wr(t),this.stream.Ii((function(){n((function(){return e.state=2,e.listener.Ii()}))})),this.stream.Ri((function(t){n((function(){return e.dr(t)}))})),this.stream.onMessage((function(t){n((function(){return e.onMessage(t)}))}))},t.prototype.nr=function(){var t=this;this.state=4,this.Zi.ji((function(){return(0,r.mG)(t,void 0,void 0,(function(){return(0,r.Jh)(this,(function(t){return this.state=0,this.start(),[2]}))}))}))},t.prototype.dr=function(t){return l("PersistentStream","close with error: "+t),this.stream=null,this.close(3,t)},t.prototype.hr=function(t){var e=this;return function(n){e.Se.enqueueAndForget((function(){return e.Yi===t?n():(l("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())}))}},t}(),yo=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).R=i,s}return(0,r.ZT)(e,t),e.prototype.wr=function(t){return this.Hi.Oi("Listen",t)},e.prototype.onMessage=function(t){this.Zi.reset();var e=function(t,e){var n;if("targetChange"in e){e.targetChange;var r=function(t){return"NO_CHANGE"===t?0:"ADD"===t?1:"REMOVE"===t?2:"CURRENT"===t?3:"RESET"===t?4:m()}(e.targetChange.targetChangeType||"NO_CHANGE"),i=e.targetChange.targetIds||[],o=function(t,e){return t.I?(v(void 0===e||"string"==typeof e),O.fromBase64String(e||"")):(v(void 0===e||e instanceof Uint8Array),O.fromUint8Array(e||new Uint8Array))}(t,e.targetChange.resumeToken),s=(u=e.targetChange.cause)&&function(t){var e=void 0===t.code?a.UNKNOWN:Ae(t.code);return new c(e,t.message||"")}(u);n=new We(r,i,o,s||null)}else if("documentChange"in e){e.documentChange,(r=e.documentChange).document,r.document.name,r.document.updateTime,i=hn(t,r.document.name),o=sn(r.document.updateTime);var u=new st({mapValue:{fields:r.document.fields}}),h=(s=at.newFoundDocument(i,o,u),r.targetIds||[]),f=r.removedTargetIds||[];n=new ze(h,f,s.key,s)}else if("documentDelete"in e)e.documentDelete,(r=e.documentDelete).document,i=hn(t,r.document),o=r.readTime?sn(r.readTime):S.min(),u=at.newNoDocument(i,o),s=r.removedTargetIds||[],n=new ze([],s,u.key,u);else if("documentRemove"in e)e.documentRemove,(r=e.documentRemove).document,i=hn(t,r.document),o=r.removedTargetIds||[],n=new ze([],o,i,null);else{if(!("filter"in e))return m();e.filter;var l=e.filter;l.targetId,r=l.count||0,i=new Ne(r),o=l.targetId,n=new Je(o,i)}return n}(this.R,t),n=function(t){if(!("targetChange"in t))return S.min();var e=t.targetChange;return e.targetIds&&e.targetIds.length?S.min():e.readTime?sn(e.readTime):S.min()}(t);return this.listener._r(e,n)},e.prototype.mr=function(t){var e={};e.database=dn(this.R),e.addTarget=function(t,e){var n,r=e.target;return(n=dt(r)?{documents:wn(t,r)}:{query:bn(t,r)}).targetId=e.targetId,e.resumeToken.approximateByteSize()>0?n.resumeToken=rn(t,e.resumeToken):e.snapshotVersion.compareTo(S.min())>0&&(n.readTime=nn(t,e.snapshotVersion.toTimestamp())),n}(this.R,t);var n=function(t,e){var n=function(t,e){switch(e){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return m()}}(0,e.purpose);return null==n?null:{"goog-listen-tags":n}}(this.R,t);n&&(e.labels=n),this.cr(e)},e.prototype.yr=function(t){var e={};e.database=dn(this.R),e.removeTarget=t,this.cr(e)},e}(po),mo=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).R=i,s.gr=!1,s}return(0,r.ZT)(e,t),Object.defineProperty(e.prototype,"pr",{get:function(){return this.gr}
2,enumerable:!1,configurable:!0}),e.prototype.start=function(){this.gr=!1,this.lastStreamToken=void 0,t.prototype.start.call(this)},e.prototype.ar=function(){this.gr&&this.Er([])},e.prototype.wr=function(t){return this.Hi.Oi("Write",t)},e.prototype.onMessage=function(t){if(v(!!t.streamToken),this.lastStreamToken=t.streamToken,this.gr){this.Zi.reset();var e=function(t,e){return t&&t.length>0?(v(void 0!==e),t.map((function(t){return function(t,e){var n=t.updateTime?sn(t.updateTime):sn(e);return n.isEqual(S.min())&&(n=sn(e)),new ae(n,t.transformResults||[])}(t,e)}))):[]}(t.writeResults,t.commitTime),n=sn(t.commitTime);return this.listener.Tr(n,e)}return v(!t.writeResults||0===t.writeResults.length),this.gr=!0,this.listener.Ir()},e.prototype.Ar=function(){var t={};t.database=dn(this.R),this.cr(t)},e.prototype.Er=function(t){var e=this,n={streamToken:this.lastStreamToken,writes:t.map((function(t){return vn(e.R,t)}))};this.cr(n)},e}(po),vo=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).credentials=e,i.Hi=n,i.R=r,i.Rr=!1,i}return(0,r.ZT)(e,t),e.prototype.br=function(){if(this.Rr)throw new c(a.FAILED_PRECONDITION,"The client has already been terminated.")},e.prototype.Ni=function(t,e,n){var r=this;return this.br(),this.credentials.getToken().then((function(i){return r.Hi.Ni(t,e,n,i)})).catch((function(t){throw"FirebaseError"===t.name?(t.code===a.UNAUTHENTICATED&&r.credentials.invalidateToken(),t):new c(a.UNKNOWN,t.toString())}))},e.prototype.$i=function(t,e,n){var r=this;return this.br(),this.credentials.getToken().then((function(i){return r.Hi.$i(t,e,n,i)})).catch((function(t){throw"FirebaseError"===t.name?(t.code===a.UNAUTHENTICATED&&r.credentials.invalidateToken(),t):new c(a.UNKNOWN,t.toString())}))},e.prototype.terminate=function(){this.Rr=!0},e}((function(){})),go=function(){function t(t,e){this.asyncQueue=t,this.onlineStateHandler=e,this.state="Unknown",this.vr=0,this.Pr=null,this.Vr=!0}return t.prototype.Sr=function(){var t=this;0===this.vr&&(this.Dr("Unknown"),this.Pr=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,(function(){return t.Pr=null,t.Cr("Backend didn't respond within 10 seconds."),t.Dr("Offline"),Promise.resolve()})))},t.prototype.Nr=function(t){"Online"===this.state?this.Dr("Unknown"):(this.vr++,this.vr>=1&&(this.kr(),this.Cr("Connection failed 1 times. Most recent error: "+t.toString()),this.Dr("Offline")))},t.prototype.set=function(t){this.kr(),this.vr=0,"Online"===t&&(this.Vr=!1),this.Dr(t)},t.prototype.Dr=function(t){t!==this.state&&(this.state=t,this.onlineStateHandler(t))},t.prototype.Cr=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.Vr?(d(e),this.Vr=!1):l("OnlineStateTracker",e)},t.prototype.kr=function(){null!==this.Pr&&(this.Pr.cancel(),this.Pr=null)},t}(),wo=function(t,e,n,i,o){var s=this;this.localStore=t,this.datastore=e,this.asyncQueue=n,this.remoteSyncer={},this.Fr=[],this.$r=new Map,this.Or=new Set,this.Mr=[],this.Lr=o,this.Lr.di((function(t){n.enqueueAndForget((function(){return(0,r.mG)(s,void 0,void 0,(function(){return(0,r.Jh)(this,(function(t){switch(t.label){case 0:return Ao(this)?(l("RemoteStore","Restarting streams for network reachability change."),[4,function(t){return(0,r.mG)(this,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return(e=g(t)).Or.add(4),[4,Io(e)];case 1:return n.sent(),e.Br.set("Unknown"),e.Or.delete(4),[4,bo(e)];case 2:return n.sent(),[2]}}))}))}(this)]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}}
2))}))}))})),this.Br=new go(n,i)};function bo(t){return(0,r.mG)(this,void 0,void 0,(function(){var e,n;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:if(!Ao(t))return[3,4];e=0,n=t.Mr,r.label=1;case 1:return e<n.length?[4,(0,n[e])(!0)]:[3,4];case 2:r.sent(),r.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))}function Io(t){return(0,r.mG)(this,void 0,void 0,(function(){var e,n;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:e=0,n=t.Mr,r.label=1;case 1:return e<n.length?[4,(0,n[e])(!1)]:[3,4];case 2:r.sent(),r.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))}function To(t,e){var n=g(t);n.$r.has(e.targetId)||(n.$r.set(e.targetId,e),Do(n)?No(n):jo(n).er()&&_o(n,e))}function Eo(t,e){var n=g(t),r=jo(n);n.$r.delete(e),r.er()&&So(n,e),0===n.$r.size&&(r.er()?r.ir():Ao(n)&&n.Br.set("Unknown"))}function _o(t,e){t.qr.U(e.targetId),jo(t).mr(e)}function So(t,e){t.qr.U(e),jo(t).yr(e)}function No(t){t.qr=new Ze({getRemoteKeysForTarget:function(e){return t.remoteSyncer.getRemoteKeysForTarget(e)},lt:function(e){return t.$r.get(e)||null}}),jo(t).start(),t.Br.Sr()}function Do(t){return Ao(t)&&!jo(t).tr()&&t.$r.size>0}function Ao(t){return 0===g(t).Or.size}function ko(t){t.qr=void 0}function Co(t){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){return t.$r.forEach((function(e,n){_o(t,e)})),[2]}))}))}function xo(t,e){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(n){return ko(t),Do(t)?(t.Br.Nr(e),No(t)):t.Br.set("Unknown"),[2]}))}))}function Ro(t,e,n){return(0,r.mG)(this,void 0,void 0,(function(){var i,o,s;return(0,r.Jh)(this,(function(u){switch(u.label){case 0:if(t.Br.set("Online"),!(e instanceof We&&2===e.state&&e.cause))return[3,6];u.label=1;case 1:return u.trys.push([1,3,,5]),[4,function(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o,s;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:n=e.cause,i=0,o=e.targetIds,r.label=1;case 1:return i<o.length?(s=o[i],t.$r.has(s)?[4,t.remoteSyncer.rejectListen(s,n)]:[3,3]):[3,5];case 2:r.sent(),t.$r.delete(s),t.qr.removeTarget(s),r.label=3;case 3:r.label=4;case 4:return i++,[3,1];case 5:return[2]}}
2))}))}(t,e)];case 2:return u.sent(),[3,5];case 3:return i=u.sent(),l("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),i),[4,Lo(t,i)];case 4:return u.sent(),[3,5];case 5:return[3,13];case 6:if(e instanceof ze?t.qr.X(e):e instanceof Je?t.qr.rt(e):t.qr.et(e),n.isEqual(S.min()))return[3,13];u.label=7;case 7:return u.trys.push([7,11,,13]),[4,Si(t.localStore)];case 8:return o=u.sent(),n.compareTo(o)>=0?[4,function(t,e){var n=t.qr.ut(e);return n.targetChanges.forEach((function(n,r){if(n.resumeToken.approximateByteSize()>0){var i=t.$r.get(r);i&&t.$r.set(r,i.withResumeToken(n.resumeToken,e))}})),n.targetMismatches.forEach((function(e){var n=t.$r.get(e);if(n){t.$r.set(e,n.withResumeToken(O.EMPTY_BYTE_STRING,n.snapshotVersion)),So(t,e);var r=new vr(n.target,e,1,n.sequenceNumber);_o(t,r)}})),t.remoteSyncer.applyRemoteEvent(n)}(t,n)]:[3,10];case 9:u.sent(),u.label=10;case 10:return[3,13];case 11:return l("RemoteStore","Failed to raise snapshot:",s=u.sent()),[4,Lo(t,s)];case 12:return u.sent(),[3,13];case 13:return[2]}}
2))}))}function Lo(t,e,n){return(0,r.mG)(this,void 0,void 0,(function(){var i=this;return(0,r.Jh)(this,(function(o){switch(o.label){case 0:if(!ar(e))throw e;return t.Or.add(1),[4,Io(t)];case 1:return o.sent(),t.Br.set("Offline"),n||(n=function(){return Si(t.localStore)}),t.asyncQueue.enqueueRetryable((function(){return(0,r.mG)(i,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return l("RemoteStore","Retrying IndexedDB access"),[4,n()];case 1:return e.sent(),t.Or.delete(1),[4,bo(t)];case 2:return e.sent(),[2]}}))}))})),[2]}}))}))}function Oo(t,e){return e().catch((function(n){return Lo(t,n,e)}))}function Po(t){return(0,r.mG)(this,void 0,void 0,(function(){var e,n,i,o,s;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:e=g(t),n=Ko(e),i=e.Fr.length>0?e.Fr[e.Fr.length-1].batchId:-1,r.label=1;case 1:if(!function(t){return Ao(t)&&t.Fr.length<10}(e))return[3,7];r.label=2;case 2:return r.trys.push([2,4,,6]),[4,Ai(e.localStore,i)];case 3:return null===(o=r.sent())?(0===e.Fr.length&&n.ir(),[3,7]):(i=o.batchId,function(t,e){t.Fr.push(e);var n=Ko(t);n.er()&&n.pr&&n.Er(e.mutations)}(e,o),[3,6]);case 4:return s=r.sent(),[4,Lo(e,s)];case 5:return r.sent(),[3,6];case 6:return[3,1];case 7:return Fo(e)&&Mo(e),[2]}}))}))}function Fo(t){return Ao(t)&&!Ko(t).tr()&&t.Fr.length>0}function Mo(t){Ko(t).start()}function Vo(t){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){return Ko(t).Ar(),[2]}))}))}function qo(t){return(0,r.mG)(this,void 0,void 0,(function(){var e,n,i,o;return(0,r.Jh)(this,(function(r){for(e=Ko(t),n=0,i=t.Fr;n<i.length;n++)o=i[n],e.Er(o.mutations);return[2]}))}))}function Uo(t,e,n){return(0,r.mG)(this,void 0,void 0,(function(){var i,o;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return i=t.Fr.shift(),o=mr.from(i,e,n),[4,Oo(t,(function(){return t.remoteSyncer.applySuccessfulWrite(o)}))];case 1:return r.sent(),[4,Po(t)];case 2:return r.sent(),[2]}}))}))}function Go(t,e){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return e&&Ko(t).pr?[4,function(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return De(i=e.code)&&i!==a.ABORTED?(n=t.Fr.shift(),Ko(t).sr(),[4,Oo(t,(function(){return t.remoteSyncer.rejectFailedWrite(n.batchId,e)}))]):[3,3];case 1:return r.sent(),[4,Po(t)];case 2:r.sent(),r.label=3;case 3:return[2]}}
2))}))}(t,e)]:[3,2];case 1:n.sent(),n.label=2;case 2:return Fo(t)&&Mo(t),[2]}}))}))}function Bo(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return n=g(t),e?(n.Or.delete(2),[4,bo(n)]):[3,2];case 1:return r.sent(),[3,5];case 2:return e?[3,4]:(n.Or.add(2),[4,Io(n)]);case 3:r.sent(),n.Br.set("Unknown"),r.label=4;case 4:r.label=5;case 5:return[2]}}))}))}function jo(t){var e=this;return t.Ur||(t.Ur=function(t,e,n){var r=g(t);return r.br(),new yo(e,r.Hi,r.credentials,r.R,n)}(t.datastore,t.asyncQueue,{Ii:Co.bind(null,t),Ri:xo.bind(null,t),_r:Ro.bind(null,t)}),t.Mr.push((function(n){return(0,r.mG)(e,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return n?(t.Ur.sr(),Do(t)?No(t):t.Br.set("Unknown"),[3,3]):[3,1];case 1:return[4,t.Ur.stop()];case 2:e.sent(),ko(t),e.label=3;case 3:return[2]}}))}))}))),t.Ur}function Ko(t){var e=this;return t.Kr||(t.Kr=function(t,e,n){var r=g(t);return r.br(),new mo(e,r.Hi,r.credentials,r.R,n)}(t.datastore,t.asyncQueue,{Ii:Vo.bind(null,t),Ri:Go.bind(null,t),Ir:qo.bind(null,t),Tr:Uo.bind(null,t)}),t.Mr.push((function(n){return(0,r.mG)(e,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return n?(t.Kr.sr(),[4,Po(t)]):[3,2];case 1:return e.sent(),[3,4];case 2:return[4,t.Kr.stop()];case 3:e.sent(),t.Fr.length>0&&(l("RemoteStore","Stopping write stream with "+t.Fr.length+" pending writes"),t.Fr=[]),e.label=4;case 4:return[2]}}
2))}))}))),t.Kr}var Qo=function(){function t(t,e,n,r,i){this.asyncQueue=t,this.timerId=e,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new nr,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((function(t){}))}return t.createAndSchedule=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.timerHandle=setTimeout((function(){return e.handleDelayElapsed()}),t)},t.prototype.skipDelay=function(){return this.handleDelayElapsed()},t.prototype.cancel=function(t){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new c(a.CANCELLED,"Operation cancelled"+(t?": "+t:""))))},t.prototype.handleDelayElapsed=function(){var t=this;this.asyncQueue.enqueueAndForget((function(){return null!==t.timerHandle?(t.clearTimeout(),t.op().then((function(e){return t.deferred.resolve(e)}))):Promise.resolve()}))},t.prototype.clearTimeout=function(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)},t}();function zo(t,e){if(d("AsyncQueue",e+": "+t),ar(t))return new c(a.UNAVAILABLE,e+": "+t);throw t}var Jo=function(){function t(t){this.comparator=t?function(e,n){return t(e,n)||Q.comparator(e.key,n.key)}:function(t,e){return Q.comparator(t.key,e.key)},this.keyedMap=Me(),this.sortedSet=new ke(this.comparator)}return t.emptySet=function(e){return new t(e.comparator)},t.prototype.has=function(t){return null!=this.keyedMap.get(t)},t.prototype.get=function(t){return this.keyedMap.get(t)},t.prototype.first=function(){return this.sortedSet.minKey()},t.prototype.last=function(){return this.sortedSet.maxKey()},t.prototype.isEmpty=function(){return this.sortedSet.isEmpty()},t.prototype.indexOf=function(t){var e=this.keyedMap.get(t);return e?this.sortedSet.indexOf(e):-1},Object.defineProperty(t.prototype,"size",{get:function(){return this.sortedSet.size},enumerable:!1,configurable:!0}),t.prototype.forEach=function(t){this.sortedSet.inorderTraversal((function(e,n){return t(e),!1}))},t.prototype.add=function(t){var e=this.delete(t.key);return e.copy(e.keyedMap.insert(t.key,t),e.sortedSet.insert(t,null))},t.prototype.delete=function(t){var e=this.get(t);return e?this.copy(this.keyedMap.remove(t),this.sortedSet.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.sortedSet.getIterator(),r=e.sortedSet.getIterator();n.hasNext();){var i=n.getNext().key,o=r.getNext().key;if(!i.isEqual(o))return!1}return!0},t.prototype.toString=function(){var t=[];return this.forEach((function(e){t.push(e.toString())})),0===t.length?"DocumentSet ()":"DocumentSet (\n  "+t.join("  \n")+"\n)"},t.prototype.copy=function(e,n){var r=new t;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=n,r},t}(),Wo=function(){function t(){this.Qr=new ke(Q.comparator)}return t.prototype.track=function(t){var e=t.doc.key,n=this.Qr.get(e);n?0!==t.type&&3===n.type?this.Qr=this.Qr.insert(e,t):3===t.type&&1!==n.type?this.Qr=this.Qr.insert(e,{type:n.type,doc:t.doc}):2===t.type&&2===n.type?this.Qr=this.Qr.insert(e,{type:2,doc:t.doc}):2===t.type&&0===n.type?this.Qr=this.Qr.insert(e,{type:0,doc:t.doc}):1===t.type&&0===n.type?this.Qr=this.Qr.remove(e):1===t.type&&2===n.type?this.Qr=this.Qr.insert(e,{type:1,doc:n.doc}):0===t.type&&1===n.type?this.Qr=this.Qr.insert(e,{type:2,doc:t.doc}):m():this.Qr=this.Qr.insert(e,t)},t.prototype.jr=function(){var t=[];return this.Qr.inorderTraversal((function(e,n){t.push(n)})),t},t}(),Ho=function(){function t(t,e,n,r,i,o,s,u){this.query=t,this.docs=e,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=o,this.syncStateChanged=s,this.excludesMetadataChanges=u}return t.fromInitialDocuments=function(e,n,r,i){var o=[];return n.forEach((function(t){o.push({type:0,doc:t})})),new t(e,n,Jo.emptySet(n),o,r,i,!0,!1)},Object.defineProperty(t.prototype,"hasPendingWrites",{get:function(){return!this.mutatedKeys.isEmpty()},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){if(!(this.fromCache===t.fromCache&&this.syncStateChanged===t.syncStateChanged&&this.mutatedKeys.isEqual(t.mutatedKeys)&&Ut(this.query,t.query)&&this.docs.isEqual(t.docs)&&this.oldDocs.isEqual(t.oldDocs)))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}(),Zo=function(){this.Wr=void 0,this.listeners=[]},Yo=function(){this.queries=new ri((function(t){return Gt(t)}),Ut),this.onlineState="Unknown",this.Gr=new Set};function $o(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o,s,u,a,c;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:if(n=g(t),i=e.query,o=!1,(s=n.queries.get(i))||(o=!0,s=new Zo),!o)return[3,4];r.label=1;case 1:return r.trys.push([1,3,,4]),u=s,[4,n.onListen(i)];case 2:return u.Wr=r.sent(),[3,4];case 3:return a=r.sent(),c=zo(a,"Initialization of query '"+Bt(e.query)+"' failed"),[2,void e.onError(c)];case 4:return n.queries.set(i,s),s.listeners.push(e),e.zr(n.onlineState),s.Wr&&e.Hr(s.Wr)&&ns(n),[2]}}))}))}function Xo(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o,s,u;return(0,r.Jh)(this,(function(r){return n=g(t),i=e.query,o=!1,(s=n.queries.get(i))&&(u=s.listeners.indexOf(e))>=0&&(s.listeners.splice(u,1),o=0===s.listeners.length),o?[2,(n.queries.delete(i),n.onUnlisten(i))]:[2]}))}))}function ts(t,e){for(var n=g(t),r=!1,i=0,o=e;i<o.length;i++){var s=o[i],u=s.query,a=n.queries.get(u);if(a){for(var c=0,h=a.listeners;c<h.length;c++)h[c].Hr(s)&&(r=!0);a.Wr=s}}r&&ns(n)}function es(t,e,n){var r=g(t),i=r.queries.get(e);if(i)for(var o=0,s=i.listeners;o<s.length;o++)s[o].onError(n);r.queries.delete(e)}function ns(t){t.Gr.forEach((function(t){t.next()}))}
2var rs=function(){function t(t,e,n){this.query=t,this.Jr=e,this.Yr=!1,this.Xr=null,this.onlineState="Unknown",this.options=n||{}}return t.prototype.Hr=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 Ho(t.query,t.docs,t.oldDocs,e,t.mutatedKeys,t.fromCache,t.syncStateChanged,!0)}var o=!1;return this.Yr?this.Zr(t)&&(this.Jr.next(t),o=!0):this.eo(t,this.onlineState)&&(this.no(t),o=!0),this.Xr=t,o},t.prototype.onError=function(t){this.Jr.error(t)},t.prototype.zr=function(t){this.onlineState=t;var e=!1;return this.Xr&&!this.Yr&&this.eo(this.Xr,t)&&(this.no(this.Xr),e=!0),e},t.prototype.eo=function(t,e){if(!t.fromCache)return!0;var n="Offline"!==e;return!(this.options.so&&n||t.docs.isEmpty()&&"Offline"!==e)},t.prototype.Zr=function(t){if(t.docChanges.length>0)return!0;var e=this.Xr&&this.Xr.hasPendingWrites!==t.hasPendingWrites;return!(!t.syncStateChanged&&!e)&&!0===this.options.includeMetadataChanges},t.prototype.no=function(t){t=Ho.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.Yr=!0,this.Jr.next(t)},t}(),is=function(){function t(t,e){this.payload=t,this.byteLength=e}return t.prototype.io=function(){return"metadata"in this.payload},t}(),os=function(){function t(t){this.R=t}return t.prototype.qn=function(t){return hn(this.R,t)},t.prototype.Un=function(t){return t.metadata.exists?mn(this.R,t.document,!1):at.newNoDocument(this.qn(t.metadata.name),this.Kn(t.metadata.readTime))},t.prototype.Kn=function(t){return sn(t)},t}();!function(){function t(t,e,n){this.ro=t,this.localStore=e,this.R=n,this.queries=[],this.documents=[],this.progress=ss(t)}t.prototype.oo=function(t){this.progress.bytesLoaded+=t.byteLength;var e=this.progress.documentsLoaded;return t.payload.namedQuery?this.queries.push(t.payload.namedQuery):t.payload.documentMetadata?(this.documents.push({metadata:t.payload.documentMetadata}),t.payload.documentMetadata.exists||++e):t.payload.document&&(this.documents[this.documents.length-1].document=t.payload.document,++e),e!==this.progress.documentsLoaded?(this.progress.documentsLoaded=e,Object.assign({},this.progress)):null},t.prototype.co=function(t){for(var e=new Map,n=new os(this.R),r=0,i=t;r<i.length;r++){var o=i[r];if(o.metadata.queries)for(var s=n.qn(o.metadata.name),u=0,a=o.metadata.queries;u<a.length;u++){var c=a[u],h=(e.get(c)||Ge()).add(s);e.set(c,h)}}return e},t.prototype.complete=function(){return(0,r.mG)(this,void 0,void 0,(function(){var t,e,n,i,o;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return[4,Pi(this.localStore,new os(this.R),this.documents,this.ro.id)];case 1:t=r.sent(),e=this.co(this.documents),n=0,i=this.queries,r.label=2;case 2:return n<i.length?(o=i[n],[4,Fi(this.localStore,o,e.get(o.name))]):[3,5];case 3:r.sent(),r.label=4;case 4:return n++,[3,2];case 5:return[2,(this.progress.taskState="Success",new vi(Object.assign({},this.progress),t))]}}))}))}}();function ss(t){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}var us=function(t){this.key=t},as=function(t){this.key=t},cs=function(){function t(t,e){this.query=t,this.uo=e,this.ao=null,this.current=!1,this.ho=Ge(),this.mutatedKeys=Ge(),this.lo=Kt(t),this.fo=new Jo(this.lo)}return Object.defineProperty(t.prototype,"wo",{get:function(){return this.uo},enumerable:!1,configurable:!0}),t.prototype._o=function(t,e){var n=this,r=e?e.mo:new Wo,i=e?e.fo:this.fo,o=e?e.mutatedKeys:this.mutatedKeys,s=i,u=!1,a=Rt(this.query)&&i.size===this.query.limit?i.last():null,c=Lt(this.query)&&i.size===this.query.limit?i.first():null;if(t.inorderTraversal((function(t,e){var h=i.get(t),f=jt(n.query,e)?e:null,l=!!h&&n.mutatedKeys.has(h.key),d=!!f&&(f.hasLocalMutations||n.mutatedKeys.has(f.key)&&f.hasCommittedMutations),p=!1;h&&f?h.data.isEqual(f.data)?l!==d&&(r.track({type:3,doc:f}),p=!0):n.yo(h,f)||(r.track({type:2,doc:f}),p=!0,(a&&n.lo(f,a)>0||c&&n.lo(f,c)<0)&&(u=!0)):!h&&f?(r.track({type:0,doc:f}),p=!0):h&&!f&&(r.track({type:1,doc:h}),p=!0,(a||c)&&(u=!0)),p&&(f?(s=s.add(f),o=d?o.add(t):o.delete(t)):(s=s.delete(t),o=o.delete(t)))})),Rt(this.query)||Lt(this.query))for(;s.size>this.query.limit;
2){var h=Rt(this.query)?s.last():s.first();s=s.delete(h.key),o=o.delete(h.key),r.track({type:1,doc:h})}return{fo:s,mo:r,Nn:u,mutatedKeys:o}},t.prototype.yo=function(t,e){return t.hasLocalMutations&&e.hasCommittedMutations&&!e.hasLocalMutations},t.prototype.applyChanges=function(t,e,n){var r=this,i=this.fo;this.fo=t.fo,this.mutatedKeys=t.mutatedKeys;var o=t.mo.jr();o.sort((function(t,e){return function(t,e){var n=function(t){switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return m()}};return n(t)-n(e)}(t.type,e.type)||r.lo(t.doc,e.doc)})),this.po(n);var s=e?this.Eo():[],u=0===this.ho.size&&this.current?1:0,a=u!==this.ao;return this.ao=u,0!==o.length||a?{snapshot:new Ho(this.query,t.fo,i,o,t.mutatedKeys,0===u,a,!1),To:s}:{To:s}},t.prototype.zr=function(t){return this.current&&"Offline"===t?(this.current=!1,this.applyChanges({fo:this.fo,mo:new Wo,mutatedKeys:this.mutatedKeys,Nn:!1},!1)):{To:[]}},t.prototype.Io=function(t){return!this.uo.has(t)&&!!this.fo.has(t)&&!this.fo.get(t).hasLocalMutations},t.prototype.po=function(t){var e=this;t&&(t.addedDocuments.forEach((function(t){return e.uo=e.uo.add(t)})),t.modifiedDocuments.forEach((function(t){})),t.removedDocuments.forEach((function(t){return e.uo=e.uo.delete(t)})),this.current=t.current)},t.prototype.Eo=function(){var t=this;if(!this.current)return[];var e=this.ho;this.ho=Ge(),this.fo.forEach((function(e){t.Io(e.key)&&(t.ho=t.ho.add(e.key))}));var n=[];return e.forEach((function(e){t.ho.has(e)||n.push(new as(e))})),this.ho.forEach((function(t){e.has(t)||n.push(new us(t))})),n},t.prototype.Ao=function(t){this.uo=t.Bn,this.ho=Ge();var e=this._o(t.documents);return this.applyChanges(e,!0)},t.prototype.Ro=function(){return Ho.fromInitialDocuments(this.query,this.fo,this.mutatedKeys,0===this.ao)},t}(),hs=function(t,e,n){this.query=t,this.targetId=e,this.view=n},fs=function(t){this.key=t,this.bo=!1},ls=function(){function t(t,e,n,r,i,o){this.localStore=t,this.remoteStore=e,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=o,this.vo={},this.Po=new ri((function(t){return Gt(t)}),Ut),this.Vo=new Map,this.So=new Set,this.Do=new ke(Q.comparator),this.Co=new Map,this.No=new Vi,this.xo={},this.ko=new Map,this.Fo=Qr.Yt(),this.onlineState="Unknown",this.$o=void 0}return Object.defineProperty(t.prototype,"isPrimaryClient",{get:function(){return!0===this.$o},enumerable:!1,configurable:!0}),t}();function ds(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o,s,u,a;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return n=Bs(t),(s=n.Po.get(e))?(i=s.targetId,n.sharedClientState.addLocalQueryTarget(i),o=s.view.Ro(),[3,4]):[3,1];case 1:return[4,ki(n.localStore,Vt(e))];case 2:return u=r.sent(),a=n.sharedClientState.addLocalQueryTarget(u.targetId),i=u.targetId,[4,ps(n,e,i,"current"===a)];case 3:o=r.sent(),n.isPrimaryClient&&To(n.remoteStore,u),r.label=4;case 4:return[2,o]}}))}))}function ps(t,e,n,i){return(0,r.mG)(this,void 0,void 0,(function(){var o,s,u,a,c,h;return(0,r.Jh)(this,(function(f){switch(f.label){case 0:return t.Oo=function(e,n,i){return function(t,e,n,i){return(0,r.mG)(this,void 0,void 0,(function(){var o,s,u;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return(o=e.view._o(n)).Nn?[4,xi(t.localStore,e.query,!1).then((function(t){var n=t.documents;return e.view._o(n,o)}))]:[3,2];case 1:o=r.sent(),r.label=2;case 2:return s=i&&i.targetChanges.get(e.targetId),u=e.view.applyChanges(o,t.isPrimaryClient,s),[2,(Ds(t,e.targetId,u.To),u.snapshot)]}}))}))}(t,e,n,i)},[4,xi(t.localStore,e,!0)];case 1:return o=f.sent(),s=new cs(e,o.Bn),u=s._o(o.documents),a=Qe.createSynthesizedTargetChangeForCurrentChange(n,i&&"Offline"!==t.onlineState),c=s.applyChanges(u,t.isPrimaryClient,a),Ds(t,n,c.To),h=new hs(e,n,s),[2,(t.Po.set(e,h),t.Vo.has(n)?t.Vo.get(n).push(e):t.Vo.set(n,[e]),c.snapshot)]}}))}))}function ys(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return n=g(t),i=n.Po.get(e),(o=n.Vo.get(i.targetId)).length>1?[2,(n.Vo.set(i.targetId,o.filter((function(t){return!Ut(t,e)}
2))),void n.Po.delete(e))]:n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(i.targetId),n.sharedClientState.isActiveQueryTarget(i.targetId)?[3,2]:[4,Ci(n.localStore,i.targetId,!1).then((function(){n.sharedClientState.clearQueryState(i.targetId),Eo(n.remoteStore,i.targetId),Ss(n,i.targetId)})).catch(Zr)]):[3,3];case 1:r.sent(),r.label=2;case 2:return[3,5];case 3:return Ss(n,i.targetId),[4,Ci(n.localStore,i.targetId,!0)];case 4:r.sent(),r.label=5;case 5:return[2]}}))}))}function ms(t,e,n){return(0,r.mG)(this,void 0,void 0,(function(){var i,o,s,u;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:i=js(t),r.label=1;case 1:return r.trys.push([1,5,,6]),[4,function(t,e){var n,r=g(t),i=_.now(),o=e.reduce((function(t,e){return t.add(e.key)}),Ge());return r.persistence.runTransaction("Locally write mutations","readwrite",(function(t){return r.Mn.pn(t,o).next((function(o){n=o;for(var s=[],u=0,a=e;u<a.length;u++){var c=a[u],h=pe(c,n.get(c.key));null!=h&&s.push(new ge(c.key,h,ut(h.value.mapValue),ce.exists(!0)))}return r._n.addMutationBatch(t,i,s,e)}))})).then((function(t){return t.applyToLocalDocumentSet(n),{batchId:t.batchId,changes:n}}))}(i.localStore,e)];case 2:return o=r.sent(),i.sharedClientState.addPendingMutation(o.batchId),function(t,e,n){var r=t.xo[t.currentUser.toKey()];r||(r=new ke(I)),r=r.insert(e,n),t.xo[t.currentUser.toKey()]=r}(i,o.batchId,n),[4,Cs(i,o.changes)];case 3:return r.sent(),[4,Po(i.remoteStore)];case 4:return r.sent(),[3,6];case 5:return s=r.sent(),u=zo(s,"Failed to persist write"),n.reject(u),[3,6];case 6:return[2]}}
2))}))}function vs(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:n=g(t),r.label=1;case 1:return r.trys.push([1,4,,6]),[4,Ni(n.localStore,e)];case 2:return i=r.sent(),e.targetChanges.forEach((function(t,e){var r=n.Co.get(e);r&&(v(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1),t.addedDocuments.size>0?r.bo=!0:t.modifiedDocuments.size>0?v(r.bo):t.removedDocuments.size>0&&(v(r.bo),r.bo=!1))})),[4,Cs(n,i,e)];case 3:return r.sent(),[3,6];case 4:return[4,Zr(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}))}))}function gs(t,e,n){var r=g(t);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){var i=[];r.Po.forEach((function(t,n){var r=n.view.zr(e);r.snapshot&&i.push(r.snapshot)})),function(t,e){var n=g(t);n.onlineState=e;var r=!1;n.queries.forEach((function(t,n){for(var i=0,o=n.listeners;i<o.length;i++)o[i].zr(e)&&(r=!0)})),r&&ns(n)}(r.eventManager,e),i.length&&r.vo._r(i),r.onlineState=e,r.isPrimaryClient&&r.sharedClientState.setOnlineState(e)}}function ws(t,e,n){return(0,r.mG)(this,void 0,void 0,(function(){var i,o,s,u,a,c;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return(i=g(t)).sharedClientState.updateQueryState(e,"rejected",n),o=i.Co.get(e),(s=o&&o.key)?(u=(u=new ke(Q.comparator)).insert(s,at.newNoDocument(s,S.min())),a=Ge().add(s),c=new Ke(S.min(),new Map,new Re(I),u,a),[4,vs(i,c)]):[3,2];case 1:return r.sent(),i.Do=i.Do.remove(s),i.Co.delete(e),ks(i),[3,4];case 2:return[4,Ci(i.localStore,e,!1).then((function(){return Ss(i,e,n)})).catch(Zr)];case 3:r.sent(),r.label=4;case 4:return[2]}}
2))}))}function bs(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:n=g(t),i=e.batch.batchId,r.label=1;case 1:return r.trys.push([1,4,,6]),[4,_i(n.localStore,e)];case 2:return o=r.sent(),_s(n,i,null),Es(n,i),n.sharedClientState.updateMutationState(i,"acknowledged"),[4,Cs(n,o)];case 3:return r.sent(),[3,6];case 4:return[4,Zr(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}))}))}function Is(t,e,n){return(0,r.mG)(this,void 0,void 0,(function(){var i,o;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:i=g(t),r.label=1;case 1:return r.trys.push([1,4,,6]),[4,function(t,e){var n=g(t);return n.persistence.runTransaction("Reject batch","readwrite-primary",(function(t){var r;return n._n.lookupMutationBatch(t,e).next((function(e){return v(null!==e),r=e.keys(),n._n.removeMutationBatch(t,e)})).next((function(){return n._n.performConsistencyCheck(t)})).next((function(){return n.Mn.pn(t,r)}))}))}(i.localStore,e)];case 2:return o=r.sent(),_s(i,e,n),Es(i,e),i.sharedClientState.updateMutationState(e,"rejected",n),[4,Cs(i,o)];case 3:return r.sent(),[3,6];case 4:return[4,Zr(r.sent())];case 5:return r.sent(),[3,6];case 6:return[2]}}
2))}))}function Ts(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o,s,u;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:Ao((n=g(t)).remoteStore)||l("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,function(t){var e=g(t);return e.persistence.runTransaction("Get highest unacknowledged batch id","readonly",(function(t){return e._n.getHighestUnacknowledgedBatchId(t)}))}(n.localStore)];case 2:return-1===(i=r.sent())?[2,void e.resolve()]:((o=n.ko.get(i)||[]).push(e),n.ko.set(i,o),[3,4]);case 3:return s=r.sent(),u=zo(s,"Initialization of waitForPendingWrites() operation failed"),e.reject(u),[3,4];case 4:return[2]}}))}))}function Es(t,e){(t.ko.get(e)||[]).forEach((function(t){t.resolve()})),t.ko.delete(e)}function _s(t,e,n){var r=g(t),i=r.xo[r.currentUser.toKey()];if(i){var o=i.get(e);o&&(n?o.reject(n):o.resolve(),i=i.remove(e)),r.xo[r.currentUser.toKey()]=i}}function Ss(t,e,n){void 0===n&&(n=null),t.sharedClientState.removeLocalQueryTarget(e);for(var r=0,i=t.Vo.get(e);r<i.length;r++){var o=i[r];t.Po.delete(o),n&&t.vo.Mo(o,n)}t.Vo.delete(e),t.isPrimaryClient&&t.No.Zn(e).forEach((function(e){t.No.containsKey(e)||Ns(t,e)}))}function Ns(t,e){t.So.delete(e.path.canonicalString());var n=t.Do.get(e);null!==n&&(Eo(t.remoteStore,n),t.Do=t.Do.remove(e),t.Co.delete(n),ks(t))}function Ds(t,e,n){for(var r=0,i=n;r<i.length;r++){var o=i[r];o instanceof us?(t.No.addReference(o.key,e),As(t,o)):o instanceof as?(l("SyncEngine","Document no longer in limbo: "+o.key),t.No.removeReference(o.key,e),t.No.containsKey(o.key)||Ns(t,o.key)):m()}}function As(t,e){var n=e.key,r=n.path.canonicalString();t.Do.get(n)||t.So.has(r)||(l("SyncEngine","New document in limbo: "+n),t.So.add(r),ks(t))}function ks(t){for(;t.So.size>0&&t.Do.size<t.maxConcurrentLimboResolutions;){var e=t.So.values().next().value;t.So.delete(e);var n=new Q(C.fromString(e)),r=t.Fo.next();t.Co.set(r,new fs(n)),t.Do=t.Do.insert(n,r),To(t.remoteStore,new vr(Vt(xt(n.path)),r,2,u.o))}}function Cs(t,e,n){return(0,r.mG)(this,void 0,void 0,(function(){var i,o,s,u;return(0,r.Jh)(this,(function(a){switch(a.label){case 0:return i=g(t),o=[],s=[],u=[],i.Po.isEmpty()?[3,3]:(i.Po.forEach((function(t,r){u.push(i.Oo(r,e,n).then((function(t){if(t){i.isPrimaryClient&&i.sharedClientState.updateQueryState(r.targetId,t.fromCache?"not-current":"current"),o.push(t);var e=wi.Pn(r.targetId,t);s.push(e)}})))})),[4,Promise.all(u)]);case 1:return a.sent(),i.vo._r(o),[4,function(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o,s,u,a,c,h,f;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:n=g(t),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,n.persistence.runTransaction("notifyLocalViewChanges","readwrite",(function(t){return rr.forEach(e,(function(e){return rr.forEach(e.bn,(function(r){return n.persistence.referenceDelegate.addReference(t,e.targetId,r)})).next((function(){return rr.forEach(e.vn,(function(r){return n.persistence.referenceDelegate.removeReference(t,e.targetId,r)}))}))}))}))];case 2:return r.sent(),[3,4];case 3:if(!ar(i=r.sent()))throw i;return l("LocalStore","Failed to update sequence numbers: "+i),[3,4];case 4:for(o=0,s=e;o<s.length;o++)u=s[o],a=u.targetId,u.fromCache||(c=n.kn.get(a),h=c.snapshotVersion,f=c.withLastLimboFreeSnapshotVersion(h),n.kn=n.kn.insert(a,f));return[2]}}))}))}(i.localStore,s)];case 2:a.sent(),a.label=3;case 3:return[2]}}
2))}))}function xs(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return(n=g(t)).currentUser.isEqual(e)?[3,3]:(l("SyncEngine","User change. New user:",e.toKey()),[4,Ei(n.localStore,e)]);case 1:return i=r.sent(),n.currentUser=e,function(t,e){t.ko.forEach((function(t){t.forEach((function(t){t.reject(new c(a.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))}))})),t.ko.clear()}(n),n.sharedClientState.handleUserChange(e,i.removedBatchIds,i.addedBatchIds),[4,Cs(n,i.Ln)];case 2:r.sent(),r.label=3;case 3:return[2]}}))}))}function Rs(t,e){var n=g(t),r=n.Co.get(e);if(r&&r.bo)return Ge().add(r.key);var i=Ge(),o=n.Vo.get(e);if(!o)return i;for(var s=0,u=o;s<u.length;s++){var a=u[s],c=n.Po.get(a);i=i.unionWith(c.view.wo)}return i}function Ls(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return[4,xi((n=g(t)).localStore,e.query,!0)];case 1:return i=r.sent(),o=e.view.Ao(i),[2,(n.isPrimaryClient&&Ds(n,e.targetId,o.To),o)]}}))}))}function Os(t){return(0,r.mG)(this,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(n){return[2,Li((e=g(t)).localStore).then((function(t){return Cs(e,t)}))]}))}))}function Ps(t,e,n,i){return(0,r.mG)(this,void 0,void 0,(function(){var o,s;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return[4,function(t,e){var n=g(t),r=g(n._n);return n.persistence.runTransaction("Lookup mutation documents","readonly",(function(t){return r.jt(t,e).next((function(e){return e?n.Mn.pn(t,e):rr.resolve(null)}))}))}((o=g(t)).localStore,e)];case 1:return null===(s=r.sent())?[3,6]:"pending"!==n?[3,3]:[4,Po(o.remoteStore)];case 2:return r.sent(),[3,4];case 3:"acknowledged"===n||"rejected"===n?(_s(o,e,i||null),Es(o,e),function(t,e){g(g(t)._n).Gt(e)}(o.localStore,e)):m(),r.label=4;case 4:return[4,Cs(o,s)];case 5:return r.sent(),[3,7];case 6:l("SyncEngine","Cannot apply mutation batch with id: "+e),r.label=7;case 7:return[2]}}
2))}))}function Fs(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o,s,u,a,c,h;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return Bs(n=g(t)),js(n),!0!==e||!0===n.$o?[3,3]:(i=n.sharedClientState.getAllActiveQueryTargets(),[4,Ms(n,i.toArray())]);case 1:return o=r.sent(),n.$o=!0,[4,Bo(n.remoteStore,!0)];case 2:for(r.sent(),s=0,u=o;s<u.length;s++)a=u[s],To(n.remoteStore,a);return[3,7];case 3:return!1!==e||!1===n.$o?[3,7]:(c=[],h=Promise.resolve(),n.Vo.forEach((function(t,e){n.sharedClientState.isLocalQueryTarget(e)?c.push(e):h=h.then((function(){return Ss(n,e),Ci(n.localStore,e,!0)})),Eo(n.remoteStore,e)})),[4,h]);case 4:return r.sent(),[4,Ms(n,c)];case 5:return r.sent(),function(t){var e=g(t);e.Co.forEach((function(t,n){Eo(e.remoteStore,n)})),e.No.ts(),e.Co=new Map,e.Do=new ke(Q.comparator)}(n),n.$o=!1,[4,Bo(n.remoteStore,!1)];case 6:r.sent(),r.label=7;case 7:return[2]}}))}))}function Ms(t,e,n){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o,s,u,a,c,h,f,l,d,p,y,m;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:n=g(t),i=[],o=[],s=0,u=e,r.label=1;case 1:return s<u.length?(a=u[s],c=void 0,(h=n.Vo.get(a))&&0!==h.length?[4,ki(n.localStore,Vt(h[0]))]:[3,7]):[3,13];case 2:c=r.sent(),f=0,l=h,r.label=3;case 3:return f<l.length?(d=l[f],p=n.Po.get(d),[4,Ls(n,p)]):[3,6];case 4:(y=r.sent()).snapshot&&o.push(y.snapshot),r.label=5;case 5:return f++,[3,3];case 6:return[3,11];case 7:return[4,Ri(n.localStore,a)];case 8:return m=r.sent(),[4,ki(n.localStore,m)];case 9:return c=r.sent(),[4,ps(n,Vs(m),a,!1)];case 10:r.sent(),r.label=11;case 11:i.push(c),r.label=12;case 12:return s++,[3,1];case 13:return[2,(n.vo._r(o),i)]}}))}))}function Vs(t){return Ct(t.path,t.collectionGroup,t.orderBy,t.filters,t.limit,"F",t.startAt,t.endAt)}function qs(t){var e=g(t);return g(g(e.localStore).persistence).fn()}function Us(t,e,n,i){return(0,r.mG)(this,void 0,void 0,(function(){var o,s,u;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return(o=g(t)).$o?(l("SyncEngine","Ignoring unexpected query state notification."),[3,8]):[3,1];case 1:if(!o.Vo.has(e))return[3,8];switch(n){case"current":case"not-current":return[3,2];case"rejected":return[3,5]}return[3,7];case 2:return[4,Li(o.localStore)];case 3:return s=r.sent(),u=Ke.createSynthesizedRemoteEventForCurrentChange(e,"current"===n),[4,Cs(o,s,u)];case 4:return r.sent(),[3,8];case 5:return[4,Ci(o.localStore,e,!0)];case 6:return r.sent(),Ss(o,e,i),[3,8];case 7:m(),r.label=8;case 8:return[2]}}
2))}))}function Gs(t,e,n){return(0,r.mG)(this,void 0,void 0,(function(){var i,o,s,u,a,c,h,f,d,p;return(0,r.Jh)(this,(function(y){switch(y.label){case 0:if(!(i=Bs(t)).$o)return[3,10];o=0,s=e,y.label=1;case 1:return o<s.length?(u=s[o],i.Vo.has(u)?(l("SyncEngine","Adding an already active target "+u),[3,5]):[4,Ri(i.localStore,u)]):[3,6];case 2:return a=y.sent(),[4,ki(i.localStore,a)];case 3:return c=y.sent(),[4,ps(i,Vs(a),c.targetId,!1)];case 4:y.sent(),To(i.remoteStore,c),y.label=5;case 5:return o++,[3,1];case 6:h=function(t){return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return i.Vo.has(t)?[4,Ci(i.localStore,t,!1).then((function(){Eo(i.remoteStore,t),Ss(i,t)})).catch(Zr)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))},f=0,d=n,y.label=7;case 7:return f<d.length?(p=d[f],[5,h(p)]):[3,10];case 8:y.sent(),y.label=9;case 9:return f++,[3,7];case 10:return[2]}}))}))}function Bs(t){var e=g(t);return e.remoteStore.remoteSyncer.applyRemoteEvent=vs.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=Rs.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=ws.bind(null,e),e.vo._r=ts.bind(null,e.eventManager),e.vo.Mo=es.bind(null,e.eventManager),e}function js(t){var e=g(t);return e.remoteStore.remoteSyncer.applySuccessfulWrite=bs.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=Is.bind(null,e),e}var Ks=function(){function t(){this.synchronizeTabs=!1}return t.prototype.initialize=function(t){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return this.R=fo(t.databaseInfo.databaseId),this.sharedClientState=this.Bo(t),this.persistence=this.qo(t),[4,this.persistence.start()];case 1:return e.sent(),this.gcScheduler=this.Uo(t),this.localStore=this.Ko(t),[2]}}))}))},t.prototype.Uo=function(t){return null},t.prototype.Ko=function(t){return Ti(this.persistence,new bi,t.initialUser,this.R)},t.prototype.qo=function(t){return new Ki(zi.bs,this.R)},t.prototype.Bo=function(t){return new ro},t.prototype.terminate=function(){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(t){switch(t.label){case 0:return this.gcScheduler&&this.gcScheduler.stop(),[4,this.sharedClientState.shutdown()];case 1:return t.sent(),[4,this.persistence.shutdown()];case 2:return t.sent(),[2]}}))}))},t}(),Qs=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).Qo=e,i.cacheSizeBytes=n,i.forceOwnership=r,i.synchronizeTabs=!1,i}return(0,r.ZT)(e,t),e.prototype.initialize=function(e){return(0,r.mG)(this,void 0,void 0,(function(){var n=this;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return[4,t.prototype.initialize.call(this,e)];case 1:return r.sent(),[4,Oi(this.localStore)];case 2:return r.sent(),[4,this.Qo.initialize(this,e)];case 3:return r.sent(),[4,js(this.Qo.syncEngine)];case 4:return r.sent(),[4,Po(this.Qo.remoteStore)];case 5:return r.sent(),[4,this.persistence.He((function(){return n.gcScheduler&&!n.gcScheduler.started&&n.gcScheduler.start(n.localStore),Promise.resolve()}))];case 6:return r.sent(),[2]}}))}))},e.prototype.Ko=function(t){return Ti(this.persistence,new bi,t.initialUser,this.R)},e.prototype.Uo=function(t){var e=this.persistence.referenceDelegate.garbageCollector;return new Xr(e,t.asyncQueue)},e.prototype.qo=function(t){var e=mi(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?Mr.withCacheSize(this.cacheSizeBytes):Mr.DEFAULT;return new di(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,co(),ho(),this.R,this.sharedClientState,!!this.forceOwnership)},e.prototype.Bo=function(t){return new ro},e}(Ks),zs=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n,!1)||this).Qo=e,r.cacheSizeBytes=n,r.synchronizeTabs=!0,r}return(0,r.ZT)(e,t),e.prototype.initialize=function(e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i=this;return(0,r.Jh)(this,(function(o){switch(o.label){case 0:return[4,t.prototype.initialize.call(this,e)];case 1:return o.sent(),n=this.Qo.syncEngine,this.sharedClientState instanceof no?(this.sharedClientState.syncEngine={ui:Ps.bind(null,n),ai:Us.bind(null,n),hi:Gs.bind(null,n),fn:qs.bind(null,n),ci:Os.bind(null,n)}
2,[4,this.sharedClientState.start()]):[3,3];case 2:o.sent(),o.label=3;case 3:return[4,this.persistence.He((function(t){return(0,r.mG)(i,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return[4,Fs(this.Qo.syncEngine,t)];case 1:return e.sent(),this.gcScheduler&&(t&&!this.gcScheduler.started?this.gcScheduler.start(this.localStore):t||this.gcScheduler.stop()),[2]}}))}))}))];case 4:return o.sent(),[2]}}))}))},e.prototype.Bo=function(t){var e=co();if(!no.yt(e))throw new c(a.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=mi(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new no(e,t.asyncQueue,n,t.clientId,t.initialUser)},e}(Qs),Js=function(){function t(){}return t.prototype.initialize=function(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n=this;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return this.localStore?[3,2]:(this.localStore=t.localStore,this.sharedClientState=t.sharedClientState,this.datastore=this.createDatastore(e),this.remoteStore=this.createRemoteStore(e),this.eventManager=this.createEventManager(e),this.syncEngine=this.createSyncEngine(e,!t.synchronizeTabs),this.sharedClientState.onlineStateHandler=function(t){return gs(n.syncEngine,t,1)},this.remoteStore.remoteSyncer.handleCredentialChange=xs.bind(null,this.syncEngine),[4,Bo(this.remoteStore,this.syncEngine.isPrimaryClient)]);case 1:r.sent(),r.label=2;case 2:return[2]}}
2))}))},t.prototype.createEventManager=function(t){return new Yo},t.prototype.createDatastore=function(t){var e,n=fo(t.databaseInfo.databaseId),r=(e=t.databaseInfo,new ao(e));return function(t,e,n){return new vo(t,e,n)}(t.credentials,r,n)},t.prototype.createRemoteStore=function(t){var e,n,r,i,o,s=this;return e=this.localStore,n=this.datastore,r=t.asyncQueue,i=function(t){return gs(s.syncEngine,t,0)},o=oo.yt()?new oo:new io,new wo(e,n,r,i,o)},t.prototype.createSyncEngine=function(t,e){return function(t,e,n,r,i,o,s){var u=new ls(t,e,n,r,i,o);return s&&(u.$o=!0),u}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,t.initialUser,t.maxConcurrentLimboResolutions,e)},t.prototype.terminate=function(){return function(t){return(0,r.mG)(this,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return e=g(t),l("RemoteStore","RemoteStore shutting down."),e.Or.add(5),[4,Io(e)];case 1:return n.sent(),e.Lr.shutdown(),e.Br.set("Unknown"),[2]}}))}))}(this.remoteStore)},t}();var Ws=function(){function t(t){this.observer=t,this.muted=!1}return t.prototype.next=function(t){this.observer.next&&this.jo(this.observer.next,t)},t.prototype.error=function(t){this.observer.error?this.jo(this.observer.error,t):console.error("Uncaught Error in snapshot listener:",t)},t.prototype.Wo=function(){this.muted=!0},t.prototype.jo=function(t,e){var n=this;this.muted||setTimeout((function(){n.muted||t(e)}),0)},t}(),Hs=(function(){function t(t,e){var n=this;this.Go=t,this.R=e,this.metadata=new nr,this.buffer=new Uint8Array,this.zo=new TextDecoder("utf-8"),this.Ho().then((function(t){t&&t.io()?n.metadata.resolve(t.payload.metadata):n.metadata.reject(new Error("The first element of the bundle is not a metadata, it is\n             "+JSON.stringify(null==t?void 0:t.payload)))}),(function(t){return n.metadata.reject(t)}))}t.prototype.close=function(){return this.Go.cancel()},t.prototype.getMetadata=function(){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(t){return[2,this.metadata.promise]}))}))},t.prototype.Lo=function(){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(t){switch(t.label){case 0:return[4,this.getMetadata()];case 1:return[2,(t.sent(),this.Ho())]}}))}))},t.prototype.Ho=function(){return(0,r.mG)(this,void 0,void 0,(function(){var t,e,n,i;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return[4,this.Jo()];case 1:return null===(t=r.sent())?[2,null]:(e=this.zo.decode(t),n=Number(e),isNaN(n)&&this.Yo("length string ("+e+") is not valid number"),[4,this.Xo(n)]);case 2:return i=r.sent(),[2,new is(JSON.parse(i),t.length+n)]}}))}))},t.prototype.Zo=function(){return this.buffer.findIndex((function(t){return t==="{".charCodeAt(0)}))},t.prototype.Jo=function(){return(0,r.mG)(this,void 0,void 0,(function(){var t,e;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return this.Zo()<0?[4,this.tc()]:[3,3];case 1:if(n.sent())return[3,3];n.label=2;case 2:return[3,0];case 3:return 0===this.buffer.length?[2,null]:((t=this.Zo())<0&&this.Yo("Reached the end of bundle when a length string is expected."),e=this.buffer.slice(0,t),[2,(this.buffer=this.buffer.slice(t),e)])}}))}))},t.prototype.Xo=function(t){return(0,r.mG)(this,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return this.buffer.length<t?[4,this.tc()]:[3,3];case 1:n.sent()&&this.Yo("Reached the end of bundle when more is expected."),n.label=2;case 2:return[3,0];case 3:return e=this.zo.decode(this.buffer.slice(0,t)),[2,(this.buffer=this.buffer.slice(t),e)]}}))}))},t.prototype.Yo=function(t){throw this.Go.cancel(),new Error("Invalid bundle format: "+t)},t.prototype.tc=function(){return(0,r.mG)(this,void 0,void 0,(function(){var t,e;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return[4,this.Go.read()];case 1:return(t=n.sent()).done||((e=new Uint8Array(this.buffer.length+t.value.length)).set(this.buffer),e.set(t.value,this.buffer.length),this.buffer=e),[2,t.done]}}))}))}}(),function(){function t(t){this.datastore=t,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastWriteError=null,this.writtenDocs=new Set}return t.prototype.lookup=function(t){return(0,r.mG)(this,void 0,void 0,(function(){var e,n=this;return(0,r.Jh)(this,(function(i){switch(i.label){case 0:if(this.ensureCommitNotCalled(),this.mutations.length>0)throw new c(a.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes.");return[4,function(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o,s,u,a;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return n=g(t),i=dn(n.R)+"/documents",o={documents:e.map((function(t){return cn(n.R,t)}))},[4,n.$i("BatchGetDocuments",i,o)];
2case 1:return s=r.sent(),u=new Map,s.forEach((function(t){var e=function(t,e){return"found"in e?function(t,e){v(!!e.found),e.found.name,e.found.updateTime;var n=hn(t,e.found.name),r=sn(e.found.updateTime),i=new st({mapValue:{fields:e.found.fields}});return at.newFoundDocument(n,r,i)}(t,e):"missing"in e?function(t,e){v(!!e.missing),v(!!e.readTime);var n=hn(t,e.missing),r=sn(e.readTime);return at.newNoDocument(n,r)}(t,e):m()}(n.R,t);u.set(e.key.toString(),e)})),a=[],[2,(e.forEach((function(t){var e=u.get(t.toString());v(!!e),a.push(e)})),a)]}}))}))}(this.datastore,t)];case 1:return[2,((e=i.sent()).forEach((function(t){return n.recordVersion(t)})),e)]}}))}))},t.prototype.set=function(t,e){this.write(e.toMutation(t,this.precondition(t))),this.writtenDocs.add(t.toString())},t.prototype.update=function(t,e){try{this.write(e.toMutation(t,this.preconditionForUpdate(t)))}catch(t){this.lastWriteError=t}this.writtenDocs.add(t.toString())},t.prototype.delete=function(t){this.write(new _e(t,this.precondition(t))),this.writtenDocs.add(t.toString())},t.prototype.commit=function(){return(0,r.mG)(this,void 0,void 0,(function(){var t,e=this;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:if(this.ensureCommitNotCalled(),this.lastWriteError)throw this.lastWriteError;return t=this.readVersions,this.mutations.forEach((function(e){t.delete(e.key.toString())})),t.forEach((function(t,n){var r=Q.fromPath(n);e.mutations.push(new Se(r,e.precondition(r)))})),[4,function(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return n=g(t),i=dn(n.R)+"/documents",o={writes:e.map((function(t){return vn(n.R,t)}))},[4,n.Ni("Commit",i,o)];case 1:return r.sent(),[2]}}))}))}(this.datastore,this.mutations)];case 1:return n.sent(),this.committed=!0,[2]}}))}))},t.prototype.recordVersion=function(t){var e;if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw m();e=S.min()}var n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new c(a.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(t.key.toString(),e)},t.prototype.precondition=function(t){var e=this.readVersions.get(t.toString());return!this.writtenDocs.has(t.toString())&&e?ce.updateTime(e):ce.none()},t.prototype.preconditionForUpdate=function(t){var e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(S.min()))throw new c(a.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return ce.updateTime(e)}return ce.exists(!0)},t.prototype.write=function(t){this.ensureCommitNotCalled(),this.mutations.push(t)},t.prototype.ensureCommitNotCalled=function(){},t}()),Zs=function(){function t(t,e,n,r){this.asyncQueue=t,this.datastore=e,this.updateFunction=n,this.deferred=r,this.ec=5,this.Zi=new lo(this.asyncQueue,"transaction_retry")}return t.prototype.run=function(){this.ec-=1,this.nc()},t.prototype.nc=function(){var t=this;this.Zi.ji((function(){return(0,r.mG)(t,void 0,void 0,(function(){var t,e,n=this;return(0,r.Jh)(this,(function(r){return t=new Hs(this.datastore),(e=this.sc(t))&&e.then((function(e){n.asyncQueue.enqueueAndForget((function(){return t.commit().then((function(){n.deferred.resolve(e)})).catch((function(t){n.ic(t)}))}))})).catch((function(t){n.ic(t)})),[2]}))}))}))},t.prototype.sc=function(t){try{var e=this.updateFunction(t);return!B(e)&&e.catch&&e.then?e:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(t){return this.deferred.reject(t),null}},t.prototype.ic=function(t){var e=this;this.ec>0&&this.rc(t)?(this.ec-=1,this.asyncQueue.enqueueAndForget((function(){return e.nc(),Promise.resolve()}))):this.deferred.reject(t)},t.prototype.rc=function(t){if("FirebaseError"===t.name){var e=t.code;return"aborted"===e||"failed-precondition"===e||!De(e)}return!1},t}(),Ys=function(){function t(t,e,n){var i=this;this.credentials=t,this.asyncQueue=e,this.databaseInfo=n,this.user=Ji.UNAUTHENTICATED,this.clientId=b.u(),this.credentialListener=function(){return Promise.resolve()},this.credentials.setChangeListener(e,(function(t){return(0,r.mG)(i,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return l("FirestoreClient","Received user=",t.uid),[4,this.credentialListener(t)];case 1:return e.sent(),this.user=t,[2]}}))}))}))}return t.prototype.getConfiguration=function(){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(t){return[2,{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,credentials:this.credentials,initialUser:this.user,maxConcurrentLimboResolutions:100}]}))}))},t.prototype.setCredentialChangeListener=function(t){this.credentialListener=t},t.prototype.verifyNotTerminated=function(){if(this.asyncQueue.isShuttingDown)throw new c(a.FAILED_PRECONDITION,"The client has already been terminated.")},t.prototype.terminate=function(){var t=this;this.asyncQueue.enterRestrictedMode();var e=new nr;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted((function(){return(0,r.mG)(t,void 0,void 0,(function(){var t,n;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,5,,6]),this.onlineComponents?[4,this.onlineComponents.terminate()]:[3,2];case 1:r.sent(),r.label=2;case 2:return this.offlineComponents?[4,this.offlineComponents.terminate()]:[3,4];case 3:r.sent(),r.label=4;case 4:return this.credentials.removeChangeListener(),e.resolve(),[3,6];case 5:return t=r.sent(),n=zo(t,"Failed to shutdown persistence"),e.reject(n),[3,6];case 6:return[2]}}
2))}))})),e.promise},t}();function $s(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i,o=this;return(0,r.Jh)(this,(function(s){switch(s.label){case 0:return t.asyncQueue.verifyOperationInProgress(),l("FirestoreClient","Initializing OfflineComponentProvider"),[4,t.getConfiguration()];case 1:return n=s.sent(),[4,e.initialize(n)];case 2:return s.sent(),i=n.initialUser,t.setCredentialChangeListener((function(t){return(0,r.mG)(o,void 0,void 0,(function(){return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return i.isEqual(t)?[3,2]:[4,Ei(e.localStore,t)];case 1:n.sent(),i=t,n.label=2;case 2:return[2]}}))}))})),e.persistence.setDatabaseDeletedListener((function(){return t.terminate()})),t.offlineComponents=e,[2]}}))}))}function Xs(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i;return(0,r.Jh)(this,(function(o){switch(o.label){case 0:return t.asyncQueue.verifyOperationInProgress(),[4,tu(t)];case 1:return n=o.sent(),l("FirestoreClient","Initializing OnlineComponentProvider"),[4,t.getConfiguration()];case 2:return i=o.sent(),[4,e.initialize(n,i)];case 3:return o.sent(),t.setCredentialChangeListener((function(t){return function(t,e){return(0,r.mG)(this,void 0,void 0,(function(){var n,i;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return(n=g(t)).asyncQueue.verifyOperationInProgress(),l("RemoteStore","RemoteStore received new credentials"),i=Ao(n),n.Or.add(3),[4,Io(n)];case 1:return r.sent(),i&&n.Br.set("Unknown"),[4,n.remoteSyncer.handleCredentialChange(e)];case 2:return r.sent(),n.Or.delete(3),[4,bo(n)];case 3:return r.sent(),[2]}}))}))}(e.remoteStore,t)})),t.onlineComponents=e,[2]}}))}))}function tu(t){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return t.offlineComponents?[3,2]:(l("FirestoreClient","Using default OfflineComponentProvider"),[4,$s(t,new Ks)]);case 1:e.sent(),e.label=2;case 2:return[2,t.offlineComponents]}}))}))}function eu(t){return(0,r.mG)(this,void 0,void 0,(function(){return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return t.onlineComponents?[3,2]:(l("FirestoreClient","Using default OnlineComponentProvider"),[4,Xs(t,new Js)]);case 1:e.sent(),e.label=2;case 2:return[2,t.onlineComponents]}}))}))}function nu(t){return tu(t).then((function(t){return t.persistence}))}function ru(t){return tu(t).then((function(t){return t.localStore}))}function iu(t){return eu(t).then((function(t){return t.remoteStore}))}function ou(t){return eu(t).then((function(t){return t.syncEngine}))}function su(t){return(0,r.mG)(this,void 0,void 0,(function(){var e,n;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return[4,eu(t)];case 1:return e=r.sent(),[2,((n=e.eventManager).onListen=ds.bind(null,e.syncEngine),n.onUnlisten=ys.bind(null,e.syncEngine),n)]}}))}))}function uu(t,e,n){var i=this;void 0===n&&(n={});var o=new nr;return t.asyncQueue.enqueueAndForget((function(){return(0,r.mG)(i,void 0,void 0,(function(){var i;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return i=function(t,e,n,r,i){var o=new Ws({next:function(o){e.enqueueAndForget((function(){return Xo(t,s)}));var u=o.docs.has(n);!u&&o.fromCache?i.reject(new c(a.UNAVAILABLE,"Failed to get document because the client is offline.")):u&&o.fromCache&&r&&"server"===r.source?i.reject(new c(a.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):i.resolve(o)},error:function(t){return i.reject(t)}}),s=new rs(xt(n.path),o,{includeMetadataChanges:!0,so:!0});return $o(t,s)},[4,su(t)];case 1:return[2,i.apply(void 0,[r.sent(),t.asyncQueue,e,n,o])]}}))}))})),o.promise}function au(t,e,n){var i=this;void 0===n&&(n={});var o=new nr;return t.asyncQueue.enqueueAndForget((function(){return(0,r.mG)(i,void 0,void 0,(function(){var i;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return i=function(t,e,n,r,i){var o=new Ws({next:function(n){e.enqueueAndForget((function(){return Xo(t,s)})),n.fromCache&&"server"===r.source?i.reject(new c(a.UNAVAILABLE,'Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)')):i.resolve(n)},error:function(t){return i.reject(t)}}),s=new rs(n,o,{includeMetadataChanges:!0,so:!0});return $o(t,s)},[4,su(t)];case 1:return[2,i.apply(void 0,[r.sent(),t.asyncQueue,e,n,o])]}}))}))})),o.promise}var cu=function(t,e,n,r,i,o,s,u){this.databaseId=t,this.appId=e,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=o,this.autoDetectLongPolling=s,this.useFetchStreams=u},hu=function(){function t(t,e){this.projectId=t,this.database=e||"(default)"}return Object.defineProperty(t.prototype,"isDefaultDatabase",{get:function(){return"(default)"===this.database}
2,enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){return e instanceof t&&e.projectId===this.projectId&&e.database===this.database},t}(),fu=new Map,lu=function(t,e){this.user=e,this.type="OAuth",this.authHeaders={},this.authHeaders.Authorization="Bearer "+t},du=function(){function t(){this.changeListener=null}return t.prototype.getToken=function(){return Promise.resolve(null)},t.prototype.invalidateToken=function(){},t.prototype.setChangeListener=function(t,e){this.changeListener=e,t.enqueueRetryable((function(){return e(Ji.UNAUTHENTICATED)}))},t.prototype.removeChangeListener=function(){this.changeListener=null},t}(),pu=function(){function t(t){this.token=t,this.changeListener=null}return t.prototype.getToken=function(){return Promise.resolve(this.token)},t.prototype.invalidateToken=function(){},t.prototype.setChangeListener=function(t,e){var n=this;this.changeListener=e,t.enqueueRetryable((function(){return e(n.token.user)}))},t.prototype.removeChangeListener=function(){this.changeListener=null},t}(),yu=function(){function t(t){var e=this;this.currentUser=Ji.UNAUTHENTICATED,this.oc=new nr,this.cc=0,this.forceRefresh=!1,this.auth=null,this.asyncQueue=null,this.uc=function(){e.cc++,e.currentUser=e.ac(),e.oc.resolve(),e.changeListener&&e.asyncQueue.enqueueRetryable((function(){return e.changeListener(e.currentUser)}))};var n=function(t){l("FirebaseCredentialsProvider","Auth detected"),e.auth=t,e.auth.addAuthTokenListener(e.uc)};t.onInit((function(t){return n(t)})),setTimeout((function(){if(!e.auth){var r=t.getImmediate({optional:!0});r?n(r):(l("FirebaseCredentialsProvider","Auth not yet detected"),e.oc.resolve())}}),0)}return t.prototype.getToken=function(){var t=this,e=this.cc,n=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(n).then((function(n){return t.cc!==e?(l("FirebaseCredentialsProvider","getToken aborted due to token change."),t.getToken()):n?(v("string"==typeof n.accessToken),new lu(n.accessToken,t.currentUser)):null})):Promise.resolve(null)},t.prototype.invalidateToken=function(){this.forceRefresh=!0},t.prototype.setChangeListener=function(t,e){var n=this;this.asyncQueue=t,this.asyncQueue.enqueueRetryable((function(){return(0,r.mG)(n,void 0,void 0,(function(){return(0,r.Jh)(this,(function(t){switch(t.label){case 0:return[4,this.oc.promise];case 1:return t.sent(),[4,e(this.currentUser)];case 2:return t.sent(),this.changeListener=e,[2]}}))}))}))},t.prototype.removeChangeListener=function(){this.auth&&this.auth.removeAuthTokenListener(this.uc),this.changeListener=function(){return Promise.resolve()}},t.prototype.ac=function(){var t=this.auth&&this.auth.getUid();return v(null===t||"string"==typeof t),new Ji(t)},t}(),mu=function(){function t(t,e,n){this.hc=t,this.lc=e,this.fc=n,this.type="FirstParty",this.user=Ji.FIRST_PARTY}return Object.defineProperty(t.prototype,"authHeaders",{get:function(){var t={"X-Goog-AuthUser":this.lc},e=this.hc.auth.getAuthHeaderValueForFirstParty([]);return e&&(t.Authorization=e),this.fc&&(t["X-Goog-Iam-Authorization-Token"]=this.fc),t},enumerable:!1,configurable:!0}),t}(),vu=function(){function t(t,e,n){this.hc=t,this.lc=e,this.fc=n}return t.prototype.getToken=function(){return Promise.resolve(new mu(this.hc,this.lc,this.fc))},t.prototype.setChangeListener=function(t,e){t.enqueueRetryable((function(){return e(Ji.FIRST_PARTY)}))},t.prototype.removeChangeListener=function(){},t.prototype.invalidateToken=function(){},t}();function gu(t,e,n){if(!n)throw new c(a.INVALID_ARGUMENT,"Function "+t+"() cannot be called with an empty "+e+".")}function wu(t,e){if(void 0===e)return{merge:!1};if(void 0!==e.mergeFields&&void 0!==e.merge)throw new c(a.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function bu(t,e,n,r){if(!0===e&&!0===r)throw new c(a.INVALID_ARGUMENT,t+" and "+n+" cannot be used together.")}function Iu(t){if(!Q.isDocumentKey(t))throw new c(a.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t+" has "+t.length+".")}function Tu(t){if(Q.isDocumentKey(t))throw new c(a.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t+" has "+t.length+".")}function Eu(t){if(void 0===t)return"undefined";if(null===t)return"null";if("string"==typeof t)return t.length>20&&(t=t.substring(0,20)+"..."),JSON.stringify(t);if("number"==typeof t||"boolean"==typeof t)return""+t;if("object"==typeof t){if(t instanceof Array)return"an array";var e=function(t){if(t.constructor){var e=/function\s+([^\s(]+)\s*\(/.exec(t.constructor.toString());if(e&&e.length>1)return e[1]}return null}(t);return e?"a custom "+e+" object":"an object"}return"function"==typeof t?"a function":m()}function _u(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new c(a.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=Eu(t);throw new c(a.INVALID_ARGUMENT,"Expected type '"+e.name+"', but it was: "+n)}return t}function Su(t,e){if(e<=0)throw new c(a.INVALID_ARGUMENT,"Function "+t+"() requires a positive number, but it was: "+e+".")}var Nu=function(){function t(t){var e;if(void 0===t.host){if(void 0!==t.ssl)throw new c(a.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host="firestore.googleapis.com",this.ssl=!0}else this.host=t.host,this.ssl=null===(e=t.ssl)||void 0===e||e;if(this.credentials=t.credentials,this.ignoreUndefinedProperties=!!t.ignoreUndefinedProperties,void 0===t.cacheSizeBytes)this.cacheSizeBytes=41943040;else{if(-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new c(a.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.useFetchStreams=!!t.useFetchStreams,bu("experimentalForceLongPolling",t.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",t.experimentalAutoDetectLongPolling)}return t.prototype.isEqual=function(t){return this.host===t.host&&this.ssl===t.ssl&&this.credentials===t.credentials&&this.cacheSizeBytes===t.cacheSizeBytes&&this.experimentalForceLongPolling===t.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===t.experimentalAutoDetectLongPolling&&this.ignoreUndefinedProperties===t.ignoreUndefinedProperties&&this.useFetchStreams===t.useFetchStreams},t}(),Du=function(){function t(t,e){this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new Nu({}),this._settingsFrozen=!1,t instanceof hu?(this._databaseId=t,this._credentials=new du):(this._app=t,this._databaseId=function(t){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new c(a.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new hu(t.options.projectId)}(t),this._credentials=new yu(e))}return Object.defineProperty(t.prototype,"app",{get:function(){if(!this._app)throw new c(a.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}
2,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_initialized",{get:function(){return this._settingsFrozen},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_terminated",{get:function(){return void 0!==this._terminateTask},enumerable:!1,configurable:!0}),t.prototype._setSettings=function(t){if(this._settingsFrozen)throw new c(a.FAILED_PRECONDITION,"Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.");this._settings=new Nu(t),void 0!==t.credentials&&(this._credentials=function(t){if(!t)return new du;switch(t.type){case"gapi":var e=t.client;return v(!("object"!=typeof e||null===e||!e.auth||!e.auth.getAuthHeaderValueForFirstParty)),new vu(e,t.sessionIndex||"0",t.iamToken||null);case"provider":return t.client;default:throw new c(a.INVALID_ARGUMENT,"makeCredentialsProvider failed due to invalid credential type")}}(t.credentials))},t.prototype._getSettings=function(){return this._settings},t.prototype._freezeSettings=function(){return this._settingsFrozen=!0,this._settings},t.prototype._delete=function(){return this._terminateTask||(this._terminateTask=this._terminate()),this._terminateTask},t.prototype.toJSON=function(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}},t.prototype._terminate=function(){return this,(t=fu.get(this))&&(l("ComponentProvider","Removing Datastore"),fu.delete(this),t.terminate()),Promise.resolve();var t},t}(),Au=function(){function t(t,e,n){this.converter=e,this._key=n,this.type="document",this.firestore=t}return Object.defineProperty(t.prototype,"_path",{get:function(){return this._key.path},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return this._key.path.canonicalString()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return new Cu(this.firestore,this.converter,this._key.path.popLast())},enumerable:!1,configurable:!0}),t.prototype.withConverter=function(e){return new t(this.firestore,e,this._key)},t}(),ku=function(){function t(t,e,n){this.converter=e,this._query=n,this.type="query",this.firestore=t}return t.prototype.withConverter=function(e){return new t(this.firestore,e,this._query)},t}(),Cu=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n,xt(r))||this)._path=r,i.type="collection",i}return(0,r.ZT)(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this._query.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this._query.path.canonicalString()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){var t=this._path.popLast();return t.isEmpty()?null:new Au(this.firestore,null,new Q(t))},enumerable:!1,configurable:!0}),e.prototype.withConverter=function(t){return new e(this.firestore,t,this._path)},e}(ku);function xu(t,e){for(var n,o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];if(t=(0,i.m9)(t),gu("collection","path",e),t instanceof Du)return Tu(n=C.fromString.apply(C,(0,r.ev)([e],o))),new Cu(t,null,n);if(!(t instanceof Au||t instanceof Cu))throw new c(a.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return Tu(n=C.fromString.apply(C,(0,r.ev)([t.path],o)).child(C.fromString(e))),new Cu(t.firestore,null,n)}function Ru(t,e){for(var n,o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];if(t=(0,i.m9)(t),1===arguments.length&&(e=b.u()),gu("doc","path",e),t instanceof Du)return Iu(n=C.fromString.apply(C,(0,r.ev)([e],o))),new Au(t,null,new Q(n));if(!(t instanceof Au||t instanceof Cu))throw new c(a.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return Iu(n=t._path.child(C.fromString.apply(C,(0,r.ev)([e],o)))),new Au(t.firestore,t instanceof Cu?t.converter:null,new Q(n))}function Lu(t,e){return t=(0,i.m9)(t),e=(0,i.m9)(e),(t instanceof Au||t instanceof Cu)&&(e instanceof Au||e instanceof Cu)&&t.firestore===e.firestore&&t.path===e.path&&t.converter===e.converter}function Ou(t,e){return t=(0,i.m9)(t),e=(0,i.m9)(e),t instanceof ku&&e instanceof ku&&t.firestore===e.firestore&&Ut(t._query,e._query)&&t.converter===e.converter}var Pu=function(){function t(){var t=this;
2this.dc=Promise.resolve(),this.wc=[],this._c=!1,this.mc=[],this.yc=null,this.gc=!1,this.Ec=!1,this.Tc=[],this.Zi=new lo(this,"async_queue_retry"),this.Ic=function(){var e=ho();e&&l("AsyncQueue","Visibility state changed to "+e.visibilityState),t.Zi.Gi()};var e=ho();e&&"function"==typeof e.addEventListener&&e.addEventListener("visibilitychange",this.Ic)}return Object.defineProperty(t.prototype,"isShuttingDown",{get:function(){return this._c},enumerable:!1,configurable:!0}),t.prototype.enqueueAndForget=function(t){this.enqueue(t)},t.prototype.enqueueAndForgetEvenWhileRestricted=function(t){this.Ac(),this.Rc(t)},t.prototype.enterRestrictedMode=function(t){if(!this._c){this._c=!0,this.Ec=t||!1;var e=ho();e&&"function"==typeof e.removeEventListener&&e.removeEventListener("visibilitychange",this.Ic)}},t.prototype.enqueue=function(t){var e=this;if(this.Ac(),this._c)return new Promise((function(){}));var n=new nr;return this.Rc((function(){return e._c&&e.Ec?Promise.resolve():(t().then(n.resolve,n.reject),n.promise)})).then((function(){return n.promise}))},t.prototype.enqueueRetryable=function(t){var e=this;this.enqueueAndForget((function(){return e.wc.push(t),e.bc()}))},t.prototype.bc=function(){return(0,r.mG)(this,void 0,void 0,(function(){var t,e=this;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:if(0===this.wc.length)return[3,5];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.wc[0]()];case 2:return n.sent(),this.wc.shift(),this.Zi.reset(),[3,4];case 3:if(!ar(t=n.sent()))throw t;return l("AsyncQueue","Operation failed with retryable error: "+t),[3,4];case 4:this.wc.length>0&&this.Zi.ji((function(){return e.bc()})),n.label=5;case 5:return[2]}}
2))}))},t.prototype.Rc=function(t){var e=this,n=this.dc.then((function(){return e.gc=!0,t().catch((function(t){throw e.yc=t,e.gc=!1,d("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.gc=!1,t}))}));return this.dc=n,n},t.prototype.enqueueAfterDelay=function(t,e,n){var r=this;this.Ac(),this.Tc.indexOf(t)>-1&&(e=0);var i=Qo.createAndSchedule(this,t,e,n,(function(t){return r.vc(t)}));return this.mc.push(i),i},t.prototype.Ac=function(){this.yc&&m()},t.prototype.verifyOperationInProgress=function(){},t.prototype.Pc=function(){return(0,r.mG)(this,void 0,void 0,(function(){var t;return(0,r.Jh)(this,(function(e){switch(e.label){case 0:return[4,t=this.dc];case 1:e.sent(),e.label=2;case 2:if(t!==this.dc)return[3,0];e.label=3;case 3:return[2]}}))}))},t.prototype.Vc=function(t){for(var e=0,n=this.mc;e<n.length;e++)if(n[e].timerId===t)return!0;return!1},t.prototype.Sc=function(t){var e=this;return this.Pc().then((function(){e.mc.sort((function(t,e){return t.targetTimeMs-e.targetTimeMs}));for(var n=0,r=e.mc;n<r.length;n++){var i=r[n];if(i.skipDelay(),"all"!==t&&i.timerId===t)break}return e.Pc()}))},t.prototype.Dc=function(t){this.Tc.push(t)},t.prototype.vc=function(t){var e=this.mc.indexOf(t);this.mc.splice(e,1)},t}();function Fu(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)}!function(){function t(){this._progressObserver={},this._taskCompletionResolver=new nr,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}t.prototype.onProgress=function(t,e,n){this._progressObserver={next:t,error:e,complete:n}},t.prototype.catch=function(t){return this._taskCompletionResolver.promise.catch(t)},t.prototype.then=function(t,e){return this._taskCompletionResolver.promise.then(t,e)},t.prototype._completeWith=function(t){this._updateProgress(t),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(t)},t.prototype._failWith=function(t){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(t),this._taskCompletionResolver.reject(t)},t.prototype._updateProgress=function(t){this._lastProgress=t,this._progressObserver.next&&this._progressObserver.next(t)}}();var Mu=-1,Vu=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n)||this).type="firestore",r._queue=new Pu,r._persistenceKey="name"in e?e.name:"[DEFAULT]",r}return(0,r.ZT)(e,t),e.prototype._terminate=function(){return this._firestoreClient||Uu(this),this._firestoreClient.terminate()},e}(Du);function qu(t){return t._firestoreClient||Uu(t),t._firestoreClient.verifyNotTerminated(),t._firestoreClient}function Uu(t){var e,n=t._freezeSettings(),r=function(t,e,n,r){return new cu(t,e,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,r.useFetchStreams)}(t._databaseId,(null===(e=t._app)||void 0===e?void 0:e.options.appId)||"",t._persistenceKey,n);t._firestoreClient=new Ys(t._credentials,t._queue,r)}function Gu(t,e,n){var i=this,o=new nr;return t.asyncQueue.enqueue((function(){return(0,r.mG)(i,void 0,void 0,(function(){var i;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,$s(t,n)];case 1:return r.sent(),[4,Xs(t,e)];case 2:return r.sent(),o.resolve(),[3,4];case 3:if(!function(t){return"FirebaseError"===t.name?t.code===a.FAILED_PRECONDITION||t.code===a.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code}(i=r.sent()))throw i;return console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+i),o.reject(i),[3,4];case 4:return[2]}}
2))}))})).then((function(){return o.promise}))}function Bu(t){if(t._initialized||t._terminated)throw new c(a.FAILED_PRECONDITION,"Firestore has already been started and persistence can no longer be enabled. You can only enable persistence before calling any other methods on a Firestore object.")}var ju=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0;n<t.length;++n)if(0===t[n].length)throw new c(a.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new R(t)}return t.prototype.isEqual=function(t){return this._internalPath.isEqual(t._internalPath)},t}(),Ku=function(){function t(t){this._byteString=t}return t.fromBase64String=function(e){try{return new t(O.fromBase64String(e))}catch(e){throw new c(a.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}},t.fromUint8Array=function(e){return new t(O.fromUint8Array(e))},t.prototype.toBase64=function(){return this._byteString.toBase64()},t.prototype.toUint8Array=function(){return this._byteString.toUint8Array()},t.prototype.toString=function(){return"Bytes(base64: "+this.toBase64()+")"},t.prototype.isEqual=function(t){return this._byteString.isEqual(t._byteString)},t}(),Qu=function(t){this._methodName=t},zu=function(){function t(t,e){if(!isFinite(t)||t<-90||t>90)throw new c(a.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new c(a.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+e);this._lat=t,this._long=e}return Object.defineProperty(t.prototype,"latitude",{get:function(){return this._lat},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"longitude",{get:function(){return this._long},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){return this._lat===t._lat&&this._long===t._long},t.prototype.toJSON=function(){return{latitude:this._lat,longitude:this._long}},t.prototype._compareTo=function(t){return I(this._lat,t._lat)||I(this._long,t._long)},t}(),Ju=/^__.*__$/,Wu=function(){function t(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}return t.prototype.toMutation=function(t,e){return null!==this.fieldMask?new ge(t,this.data,this.fieldMask,e,this.fieldTransforms):new ve(t,this.data,e,this.fieldTransforms)},t}(),Hu=function(){function t(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}return t.prototype.toMutation=function(t,e){return new ge(t,this.data,this.fieldMask,e,this.fieldTransforms)},t}();function Zu(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw m()}}var Yu=function(){function t(t,e,n,r,i,o){this.settings=t,this.databaseId=e,this.R=n,this.ignoreUndefinedProperties=r,void 0===i&&this.Cc(),this.fieldTransforms=i||[],this.fieldMask=o||[]}return Object.defineProperty(t.prototype,"path",{get:function(){return this.settings.path},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"Nc",{get:function(){return this.settings.Nc},enumerable:!1,configurable:!0}),t.prototype.xc=function(e){return new t(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.R,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)},t.prototype.kc=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.xc({path:n,Fc:!1});return r.$c(t),r},t.prototype.Oc=function(t){var e,n=null===(e=this.path)||void 0===e?void 0:e.child(t),r=this.xc({path:n,Fc:!1});return r.Cc(),r},t.prototype.Mc=function(t){return this.xc({path:void 0,Fc:!0})},t.prototype.Lc=function(t){return va(t,this.settings.methodName,this.settings.Bc||!1,this.path,this.settings.qc)},t.prototype.contains=function(t){return void 0!==this.fieldMask.find((function(e){return t.isPrefixOf(e)}))||void 0!==this.fieldTransforms.find((function(e){return t.isPrefixOf(e.field)}))},t.prototype.Cc=function(){if(this.path)for(var t=0;t<this.path.length;t++)this.$c(this.path.get(t))},t.prototype.$c=function(t){if(0===t.length)throw this.Lc("Document fields must not be empty");if(Zu(this.Nc)&&Ju.test(t))throw this.Lc('Document fields cannot begin and end with "__"')},t}(),$u=function(){function t(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.R=n||fo(t)}return t.prototype.Uc=function(t,e,n,r){return void 0===r&&(r=!1),new Yu({Nc:t,methodName:e,qc:n,path:R.emptyPath(),Fc:!1,Bc:r},this.databaseId,this.R,this.ignoreUndefinedProperties)},t}();function Xu(t){var e=t._freezeSettings(),n=fo(t._databaseId);return new $u(t._databaseId,!!e.ignoreUndefinedProperties,n)}function ta(t,e,n,r,i,o){void 0===o&&(o={});var s=t.Uc(o.merge||o.mergeFields?2:0,e,n,i);da("Data must be an object, but it was:",s,r);var u,h,f=fa(r,s);if(o.merge)u=new L(s.fieldMask),h=s.fieldTransforms;else if(o.mergeFields){for(var l=[],d=0,p=o.mergeFields;d<p.length;d++){var y=pa(e,p[d],n);if(!s.contains(y))throw new c(a.INVALID_ARGUMENT,"Field '"+y+"' is specified in your field mask but missing from your input data.");ga(l,y)||l.push(y)}u=new L(l),h=s.fieldTransforms.filter((function(t){return u.covers(t.field)}))}else u=null,h=s.fieldTransforms;return new Wu(new st(f),u,h)}var ea=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,r.ZT)(e,t),e.prototype._toFieldTransform=function(t){if(2!==t.Nc)throw 1===t.Nc?t.Lc(this._methodName+"() can only appear at the top level of your update data"):t.Lc(this._methodName+"() cannot be used with set() unless you pass {merge:true}");return t.fieldMask.push(t.path),null},e.prototype.isEqual=function(t){return t instanceof e},e}(Qu);function na(t,e,n){return new Yu({Nc:3,qc:e.settings.qc,methodName:t._methodName,Fc:n},e.databaseId,e.R,e.ignoreUndefinedProperties)}var ra=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,r.ZT)(e,t),e.prototype._toFieldTransform=function(t){return new ue(t.path,new Xt)},e.prototype.isEqual=function(t){return t instanceof e},e}(Qu),ia=function(t){function e(e,n){var r=this;return(r=t.call(this,e)||this).Kc=n,r}return(0,r.ZT)(e,t),e.prototype._toFieldTransform=function(t){var e=na(this,t,!0),n=this.Kc.map((function(t){return ha(t,e)})),r=new te(n);return new ue(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(Qu),oa=function(t){function e(e,n){var r=this;return(r=t.call(this,e)||this).Kc=n,r}return(0,r.ZT)(e,t),e.prototype._toFieldTransform=function(t){var e=na(this,t,!0),n=this.Kc.map((function(t){return ha(t,e)})),r=new ne(n);return new ue(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(Qu),sa=function(t){function e(e,n){var r=this;return(r=t.call(this,e)||this).Qc=n,r}return(0,r.ZT)(e,t),e.prototype._toFieldTransform=function(t){var e=new ie(t.R,Wt(t.R,this.Qc));return new ue(t.path,e)},e.prototype.isEqual=function(t){return this===t},e}(Qu);function ua(t,e,n,r){var o=t.Uc(1,e,n);da("Data must be an object, but it was:",o,r);var s=[],u=st.empty();D(r,(function(t,r){var a=ma(e,t,n);r=(0,i.m9)(r);var c=o.Oc(a);if(r instanceof ea)s.push(a);else{var h=ha(r,c);null!=h&&(s.push(a),u.set(a,h))}}));var a=new L(s);return new Hu(u,a,o.fieldTransforms)}function aa(t,e,n,r,o,s){var u=t.Uc(1,e,n),h=[pa(e,r,n)],f=[o];if(s.length%2!=0)throw new c(a.INVALID_ARGUMENT,"Function "+e+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var l=0;l<s.length;l+=2)h.push(pa(e,s[l])),f.push(s[l+1]);for(var d=[],p=st.empty(),y=h.length-1;y>=0;--y)if(!ga(d,h[y])){var m=h[y],v=f[y];v=(0,i.m9)(v);var g=u.Oc(m);if(v instanceof ea)d.push(m);else{var w=ha(v,g);null!=w&&(d.push(m),p.set(m,w))}}var b=new L(d);return new Hu(p,b,u.fieldTransforms)}function ca(t,e,n,r){return void 0===r&&(r=!1),ha(n,t.Uc(r?4:3,e))}function ha(t,e){if(la(t=(0,i.m9)(t)))return da("Unsupported field value:",e,t),fa(t,e);if(t instanceof Qu)return function(t,e){if(!Zu(e.Nc))throw e.Lc(t._methodName+"() can only be used with update(
2) and set()");if(!e.path)throw e.Lc(t._methodName+"() is not currently supported inside arrays");var n=t._toFieldTransform(e);n&&e.fieldTransforms.push(n)}(t,e),null;if(void 0===t&&e.ignoreUndefinedProperties)return null;if(e.path&&e.fieldMask.push(e.path),t instanceof Array){if(e.settings.Fc&&4!==e.Nc)throw e.Lc("Nested arrays are not supported");return function(t,e){for(var n=[],r=0,i=0,o=t;i<o.length;i++){var s=ha(o[i],e.Mc(r));null==s&&(s={nullValue:"NULL_VALUE"}),n.push(s),r++}return{arrayValue:{values:n}}}(t,e)}return function(t,e){if(null===(t=(0,i.m9)(t)))return{nullValue:"NULL_VALUE"};if("number"==typeof t)return Wt(e.R,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){var n=_.fromDate(t);return{timestampValue:nn(e.R,n)}}if(t instanceof _)return n=new _(t.seconds,1e3*Math.floor(t.nanoseconds/1e3)),{timestampValue:nn(e.R,n)};if(t instanceof zu)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof Ku)return{bytesValue:rn(e.R,t._byteString)};if(t instanceof Au){n=e.databaseId;var r=t.firestore._databaseId;if(!r.isEqual(n))throw e.Lc("Document reference is for database "+r.projectId+"/"+r.database+" but should be for database "+n.projectId+"/"+n.database);return{referenceValue:un(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e.Lc("Unsupported field value: "+Eu(t))}(t,e)}function fa(t,e){var n={};return A(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):D(t,(function(t,r){var i=ha(r,e.kc(t));null!=i&&(n[t]=i)})),{mapValue:{fields:n}}}function la(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof _||t instanceof zu||t instanceof Ku||t instanceof Au||t instanceof Qu)}function da(t,e,n){if(!la(n)||!function(t){return"object"==typeof t&&null!==t&&(Object.getPrototypeOf(t)===Object.prototype||null===Object.getPrototypeOf(t))}(n)){var r=Eu(n);throw"an object"===r?e.Lc(t+" a custom object"):e.Lc(t+" "+r)}}function pa(t,e,n){if((e=(0,i.m9)(e))instanceof ju)return e._internalPath;if("string"==typeof e)return ma(t,e);throw va("Field path arguments must be of type string or FieldPath.",t,!1,void 0,n)}var ya=new RegExp("[~\\*/\\[\\]]");function ma(t,e,n){if(e.search(ya)>=0)throw va("Invalid field path ("+e+"). Paths must not contain '~', '*', '/', '[', or ']'",t,!1,void 0,n);try{return(new(ju.bind.apply(ju,(0,r.ev)([void 0],e.split(".")))))._internalPath}catch(i){throw va("Invalid field path ("+e+"). Paths must not be empty, begin with '.', end with '.', or contain '..'",t,!1,void 0,n)}}function va(t,e,n,r,i){var o=r&&!r.isEmpty(),s=void 0!==i,u="Function "+e+"() called with invalid data";n&&(u+=" (via `toFirestore()`)");var h="";return(o||s)&&(h+=" (found",o&&(h+=" in field "+r),s&&(h+=" in document "+i),h+=")"),new c(a.INVALID_ARGUMENT,(u+=". ")+t+h)}function ga(t,e){return t.some((function(t){return t.isEqual(e)}))}var wa=function(){function t(t,e,n,r,i){this._firestore=t,this._userDataWriter=e,this._key=n,this._document=r,this._converter=i}return Object.defineProperty(t.prototype,"id",{get:function(){return this._key.path.lastSegment()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ref",{get:function(){return new Au(this._firestore,this._converter,this._key)},enumerable:!1,configurable:!0}),t.prototype.exists=function(){return null!==this._document},t.prototype.data=function(){if(this._document){if(this._converter){var t=new ba(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(t)}return this._userDataWriter.convertValue(this._document.data.value)}},t.prototype.get=function(t){if(this._document){var e=this._document.data.field(Ia("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}},t}(),ba=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,r.ZT)(e,t),e.prototype.data=function(){return t.prototype.data.call(this)},e}(wa);function Ia(t,e){return"string"==typeof e?ma(t,e):e instanceof ju?e._internalPath:e._delegate._internalPath}var Ta=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}(),Ea=function(t){function e(e,n,r,i,o,s){var u=this;return(u=t.call(this,e,n,r,i,s)||this)._firestore=e,u._firestoreImpl=e,u.metadata=o,u}return(0,r.ZT)(e,t),e.prototype.exists=function(){return t.prototype.exists.call(this)},e.prototype.data=function(t){if(void 0===t&&(t={}),this._document){if(this._converter){var e=new _a(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(e,t)}return this._userDataWriter.convertValue(this._document.data.value,t.serverTimestamps)}},e.prototype.get=function(t,e){if(void 0===e&&(e={}),this._document){var n=this._document.data.field(Ia("DocumentSnapshot.get",t));if(null!==n)return this._userDataWriter.convertValue(n,e.serverTimestamps)}},e}(wa),_a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,r.ZT)(e,t),e.prototype.data=function(e){return void 0===e&&(e={}),t.prototype.data.call(this,e)},e}(Ea),Sa=function(){function t(t,e,n,r){this._firestore=t,this._userDataWriter=e,this._snapshot=r,this.metadata=new Ta(r.hasPendingWrites,r.fromCache),this.query=n}return Object.defineProperty(t.prototype,"docs",{get:function(){var t=[];return this.forEach((function(e){return t.push(e)})),t}
2,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this._snapshot.docs.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"empty",{get:function(){return 0===this.size},enumerable:!1,configurable:!0}),t.prototype.forEach=function(t,e){var n=this;this._snapshot.docs.forEach((function(r){t.call(e,new _a(n._firestore,n._userDataWriter,r.key,r,new Ta(n._snapshot.mutatedKeys.has(r.key),n._snapshot.fromCache),n.query.converter))}))},t.prototype.docChanges=function(t){void 0===t&&(t={});var e=!!t.includeMetadataChanges;if(e&&this._snapshot.excludesMetadataChanges)throw new c(a.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===e||(this._cachedChanges=function(t,e){if(t._snapshot.oldDocs.isEmpty()){var n=0;return t._snapshot.docChanges.map((function(e){return{type:"added",doc:new _a(t._firestore,t._userDataWriter,e.doc.key,e.doc,new Ta(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query.converter),oldIndex:-1,newIndex:n++}}))}var r=t._snapshot.oldDocs;return t._snapshot.docChanges.filter((function(t){return e||3!==t.type})).map((function(e){var n=new _a(t._firestore,t._userDataWriter,e.doc.key,e.doc,new Ta(t._snapshot.mutatedKeys.has(e.doc.key),t._snapshot.fromCache),t.query.converter),i=-1,o=-1;return 0!==e.type&&(i=r.indexOf(e.doc.key),r=r.delete(e.doc.key)),1!==e.type&&(o=(r=r.add(e.doc)).indexOf(e.doc.key)),{type:Na(e.type),doc:n,oldIndex:i,newIndex:o}}))}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges},t}();function Na(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return m()}}function Da(t,e){return t instanceof Ea&&e instanceof Ea?t._firestore===e._firestore&&t._key.isEqual(e._key)&&(null===t._document?null===e._document:t._document.isEqual(e._document))&&t._converter===e._converter:t instanceof Sa&&e instanceof Sa&&t._firestore===e._firestore&&Ou(t.query,e.query)&&t.metadata.isEqual(e.metadata)&&t._snapshot.isEqual(e._snapshot)}function Aa(t){if(Lt(t)&&0===t.explicitOrderBy.length)throw new c(a.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var ka=function(){};function Ca(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0,i=e;r<i.length;r++){var o=i[r];t=o._apply(t)}return t}var xa=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).jc=e,i.Wc=n,i.Gc=r,i.type="where",i}return(0,r.ZT)(e,t),e.prototype._apply=function(t){var e=Xu(t.firestore),n=function(t,e,n,r,i,o,s){var u;if(i.isKeyField()){if("array-contains"===o||"array-contains-any"===o)throw new c(a.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o+"' queries on FieldPath.documentId().");if("in"===o||"not-in"===o){Va(s,o);for(var h=[],f=0,l=s;f<l.length;f++){var d=l[f];h.push(Ma(r,t,d))}u={arrayValue:{values:h}}}else u=Ma(r,t,s)}else"in"!==o&&"not-in"!==o&&"array-contains-any"!==o||Va(s,o),u=ca(n,"where",s,"in"===o||"not-in"===o);var p=pt.create(i,o,u);return function(t,e){if(e.g()){var n=Pt(t);if(null!==n&&!n.isEqual(e.field))throw new c(a.INVALID_ARGUMENT,"Invalid query. All where filters with an inequality (<, <=, !=, not-in, >, or >=) must be on the same field. But you have inequality filters on '"+n.toString()+"' and '"+e.field.toString()+"'");var r=Ot(t);null!==r&&qa(t,e.field,r)}var i=function(t,e){for(var n=0,r=t.filters;n<r.length;n++){var i=r[n];if(e.indexOf(i.op)>=0)return i.op}return null}(t,function(t){switch(t){case"!=":return["!=","not-in"];case"array-contains":return["array-contains","array-contains-any","not-in"];case"in":return["array-contains-any","in","not-in"];case"array-contains-any":return["array-contains","array-contains-any","in","not-in"];case"not-in":return["array-contains","array-contains-any","in","not-in","!="];default:return[]}}(e.op));if(null!==i)throw i===e.op?new c(a.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+e.op.toString()+"' filter."):new c(a.INVALID_ARGUMENT,"Invalid query. You cannot use '"+e.op.toString()+"' filters with '"+i.toString()+"' filters.")}(t,p),p}
2(t._query,0,e,t.firestore._databaseId,this.jc,this.Wc,this.Gc);return new ku(t.firestore,t.converter,function(t,e){var n=t.filters.concat([e]);return new kt(t.path,t.collectionGroup,t.explicitOrderBy.slice(),n,t.limit,t.limitType,t.startAt,t.endAt)}(t._query,n))},e}(ka),Ra=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).jc=e,r.zc=n,r.type="orderBy",r}return(0,r.ZT)(e,t),e.prototype._apply=function(t){var e=function(t,e,n){if(null!==t.startAt)throw new c(a.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new c(a.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r=new St(e,n);return function(t,e){if(null===Ot(t)){var n=Pt(t);null!==n&&qa(t,n,e.field)}}(t,r),r}(t._query,this.jc,this.zc);return new ku(t.firestore,t.converter,function(t,e){var n=t.explicitOrderBy.concat([e]);return new kt(t.path,t.collectionGroup,n,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)}(t._query,e))},e}(ka),La=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).type=e,i.Hc=n,i.Jc=r,i}return(0,r.ZT)(e,t),e.prototype._apply=function(t){return new ku(t.firestore,t.converter,qt(t._query,this.Hc,this.Jc))},e}(ka),Oa=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).type=e,i.Yc=n,i.Xc=r,i}return(0,r.ZT)(e,t),e.prototype._apply=function(t){var e=Fa(t,this.type,this.Yc,this.Xc);return new ku(t.firestore,t.converter,function(t,e){return new kt(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,e,t.endAt)}(t._query,e))},e}(ka),Pa=function(t){function e(e,n,r){var i=this;return(i=t.call(this)||this).type=e,i.Yc=n,i.Xc=r,i}return(0,r.ZT)(e,t),e.prototype._apply=function(t){var e=Fa(t,this.type,this.Yc,this.Xc);return new ku(t.firestore,t.converter,function(t,e){return new kt(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,e)}(t._query,e))},e}(ka);function Fa(t,e,n,r){if(n[0]=(0,i.m9)(n[0]),n[0]instanceof wa)return function(t,e,n,r,i){if(!r)throw new c(a.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+n+"().");for(var o=[],s=0,u=Mt(t);s<u.length;s++){var h=u[s];if(h.field.isKeyField())o.push(X(e,r.key));else{var f=r.data.field(h.field);if(q(f))throw new c(a.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+h.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===f){var l=h.field.canonicalString();throw new c(a.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+l+"' (used as the orderBy) does not exist.")}o.push(f)}}return new Et(o,i)}(t._query,t.firestore._databaseId,e,n[0]._document,r);var o=Xu(t.firestore);return function(t,e,n,r,i,o){var s=t.explicitOrderBy;if(i.length>s.length)throw new c(a.INVALID_ARGUMENT,"Too many arguments provided to "+r+"(). The number of arguments must be less than or equal to the number of orderBy() clauses");for(var u=[],h=0;h<i.length;h++){var f=i[h];if(s[h].field.isKeyField()){if("string"!=typeof f)throw new c(a.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+r+"(), but got a "+typeof f);if(!Ft(t)&&-1!==f.indexOf("/"))throw new c(a.INVALID_ARGUMENT,"Invalid query. When querying a collection and ordering by FieldPath.documentId(), the value passed to "+r+"() must be a plain document ID, but '"+f+"' contains a slash.");var l=t.path.child(C.fromString(f));if(!Q.isDocumentKey(l))throw new c(a.INVALID_ARGUMENT,"Invalid query. When querying a collection group and ordering by FieldPath.documentId(), the value passed to "+r+"() must result in a valid document path, but '"+l+"' is not because it contains an odd number of segments.");var d=new Q(l);u.push(X(e,d))}else{var p=ca(n,r,f);u.push(p)}}return new Et(u,o)}(t._query,t.firestore._databaseId,o,e,n,r)}function Ma(t,e,n){if("string"==typeof(n=(0,i.m9)(n))){if(""===n)throw new c(a.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!Ft(e)&&-1!==n.indexOf("/"))throw new c(a.INVALID_ARGUMENT,"Invalid query. When querying a collection by FieldPath.documentId(), you must provide a plain document ID, but '"+n+"' contains a '/' character.");var r=e.path.child(C.fromString(n));if(!Q.isDocumentKey(r))throw new c(a.INVALID_ARGUMENT,"Invalid query. When querying a collection group by FieldPath.documentId(), the value provided must result in a valid document path, but '"+r+"' is not because it has an odd number of segments ("+r.length+").");return X(t,new Q(r))}if(n instanceof Au)return X(t,n._key);throw new c(a.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+Eu(n)+".")}function Va(t,e){if(!Array.isArray(t)||0===t.length)throw new c(a.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(t.length>10)throw new c(a.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.")}function qa(t,e,n){if(!n.isEqual(e))throw new c(a.INVALID_ARGUMENT,"Invalid query. You have a where filter with an inequality (<, <=, !=, not-in, >, or >=) on field '"+e.toString()+"' and so you must also use '"+e.toString()+"' as your first argument to orderBy(), but your first orderBy() is on field '"+n.toString()+"' instead.")}var Ua=function(){function t(){}return t.prototype.convertValue=function(t,e){switch(void 0===e&&(e="none"),z(t)){case 0:return null;case 1:return t.booleanValue;case 2:return M(t.integerValue||t.doubleValue);case 3:return this.convertTimestamp(t.timestampValue);case 4:return this.convertServerTimestamp(t,e);case 5:return t.stringValue;case 6:return this.convertBytes(V(t.bytesValue));case 7:return this.convertReference(t.referenceValue);case 8:return this.convertGeoPoint(t.geoPointValue);case 9:return this.convertArray(t.arrayValue,e);case 10:return this.convertObject(t.mapValue,e);default:throw m()}},t.prototype.convertObject=function(t,e){var n=this,r={};return D(t.fields,(function(t,i){r[t]=n.convertValue(i,e)})),r},t.prototype.convertGeoPoint=function(t){return new zu(M(t.latitude),M(t.longitude))},t.prototype.convertArray=function(t,e){var n=this;return(t.values||[]).map((function(t){return n.convertValue(t,e)}))},t.prototype.convertServerTimestamp=function(t,e){switch(e){case"previous":var n=U(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(G(t));default:return null}},t.prototype.convertTimestamp=function(t){var e=F(t);return new _(e.seconds,e.nanos)},t.prototype.convertDocumentKey=function(t,e){var n=C.fromString(t);v(Rn(n));var r=new hu(n.get(1),n.get(3)),i=new Q(n.popFirst(5));return r.isEqual(e)||d("Document "+i+" contains a document reference within a different database ("+r.projectId+"/"+r.database+") which is not supported. It will be treated as a reference in the current database ("+e.projectId+"/"+e.database+") instead."),i},t}();function Ga(t,e,n){return t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e}var Ba=function(t){function e(e){var n=this;return(n=t.call(this)||this).firestore=e,n}return(0,r.ZT)(e,t),e.prototype.convertBytes=function(t){return new Ku(t)},e.prototype.convertReference=function(t){var e=this.convertDocumentKey(t,this.firestore._databaseId);
2return new Au(this.firestore,null,e)},e}(Ua),ja=function(){function t(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=Xu(t)}return t.prototype.set=function(t,e,n){this._verifyNotCommitted();var r=Ka(t,this._firestore),i=Ga(r.converter,e,n),o=ta(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(o.toMutation(r._key,ce.none())),this},t.prototype.update=function(t,e,n){for(var r=[],o=3;o<arguments.length;o++)r[o-3]=arguments[o];this._verifyNotCommitted();var s,u=Ka(t,this._firestore);return s="string"==typeof(e=(0,i.m9)(e))||e instanceof ju?aa(this._dataReader,"WriteBatch.update",u._key,e,n,r):ua(this._dataReader,"WriteBatch.update",u._key,e),this._mutations.push(s.toMutation(u._key,ce.exists(!0))),this},t.prototype.delete=function(t){this._verifyNotCommitted();var e=Ka(t,this._firestore);return this._mutations=this._mutations.concat(new _e(e._key,ce.none())),this},t.prototype.commit=function(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()},t.prototype._verifyNotCommitted=function(){if(this._committed)throw new c(a.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},t}();function Ka(t,e){if((t=(0,i.m9)(t)).firestore!==e)throw new c(a.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return t}var Qa=function(t){function e(e){var n=this;return(n=t.call(this)||this).firestore=e,n}return(0,r.ZT)(e,t),e.prototype.convertBytes=function(t){return new Ku(t)},e.prototype.convertReference=function(t){var e=this.convertDocumentKey(t,this.firestore._databaseId);return new Au(this.firestore,null,e)},e}(Ua);function za(t,e,n){t=_u(t,Au);var r=_u(t.firestore,Vu),i=Ga(t.converter,e,n);return Ha(r,[ta(Xu(r),"setDoc",t._key,i,null!==t.converter,n).toMutation(t._key,ce.none())])}function Ja(t,e,n){for(var r=[],o=3;o<arguments.length;o++)r[o-3]=arguments[o];t=_u(t,Au);var s=_u(t.firestore,Vu),u=Xu(s);return Ha(s,[("string"==typeof(e=(0,i.m9)(e))||e instanceof ju?aa(u,"updateDoc",t._key,e,n,r):ua(u,"updateDoc",t._key,e)).toMutation(t._key,ce.exists(!0))])}function Wa(t){for(var e,n,o,s=[],u=1;u<arguments.length;u++)s[u-1]=arguments[u];t=(0,i.m9)(t);var a={includeMetadataChanges:!1},c=0;"object"!=typeof s[c]||Fu(s[c])||(a=s[c],c++);var h,f,l,d={includeMetadataChanges:a.includeMetadataChanges};if(Fu(s[c])){var p=s[c];s[c]=null===(e=p.next)||void 0===e?void 0:e.bind(p),s[c+1]=null===(n=p.error)||void 0===n?void 0:n.bind(p),s[c+2]=null===(o=p.complete)||void 0===o?void 0:o.bind(p)}if(t instanceof Au)f=_u(t.firestore,Vu),l=xt(t._key.path),h={next:function(e){s[c]&&s[c](Za(f,t,e))},error:s[c+1],complete:s[c+2]};else{var y=_u(t,ku);f=_u(y.firestore,Vu),l=y._query;var m=new Qa(f);h={next:function(t){s[c]&&s[c](new Sa(f,m,y,t))},error:s[c+1],complete:s[c+2]},Aa(t._query)}return function(t,e,n,i){var o=this,s=new Ws(i),u=new rs(e,s,n);return t.asyncQueue.enqueueAndForget((function(){return(0,r.mG)(o,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return e=$o,[4,su(t)];case 1:return[2,e.apply(void 0,[n.sent(),u])]}}))}))})),function(){s.Wo(),t.asyncQueue.enqueueAndForget((function(){return(0,r.mG)(o,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return e=Xo,[4,su(t)];case 1:return[2,e.apply(void 0,[n.sent(),u])]}}))}))}))}}(qu(f),l,d,h)}function Ha(t,e){return function(t,e){var n=this,i=new nr;return t.asyncQueue.enqueueAndForget((function(){return(0,r.mG)(n,void 0,void 0,(function(){var n;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return n=ms,[4,ou(t)];case 1:return[2,n.apply(void 0,[r.sent(),e,i])]}}))}))})),i.promise}(qu(t),e)}function Za(t,e,n){var r=n.docs.get(e._key),i=new Qa(t);return new Ea(t,i,e._key,r,new Ta(n.hasPendingWrites,n.fromCache),e.converter)}var Ya=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n)||this)._firestore=e,r}return(0,r.ZT)(e,t),e.prototype.get=function(e){var n=this,r=Ka(e,this._firestore),i=new Qa(this._firestore);return t.prototype.get.call(this,e).then((function(t){return new Ea(n._firestore,i,r._key,t._document,new Ta(!1,!1),r.converter)}))},e}(function(){function t(t,e){this._firestore=t,this._transaction=e,this._dataReader=Xu(t)}return t.prototype.get=function(t){var e=this,n=Ka(t,this._firestore),r=new Ba(this._firestore);return this._transaction.lookup([n._key]).then((function(t){if(!t||1!==t.length)return m();var i=t[0];if(i.isFoundDocument())return new wa(e._firestore,r,i.key,i,n.converter);if(i.isNoDocument())return new wa(e._firestore,r,n._key,null,n.converter);throw m()}
2))},t.prototype.set=function(t,e,n){var r=Ka(t,this._firestore),i=Ga(r.converter,e,n),o=ta(this._dataReader,"Transaction.set",r._key,i,null!==r.converter,n);return this._transaction.set(r._key,o),this},t.prototype.update=function(t,e,n){for(var r=[],o=3;o<arguments.length;o++)r[o-3]=arguments[o];var s,u=Ka(t,this._firestore);return s="string"==typeof(e=(0,i.m9)(e))||e instanceof ju?aa(this._dataReader,"Transaction.update",u._key,e,n,r):ua(this._dataReader,"Transaction.update",u._key,e),this._transaction.update(u._key,s),this},t.prototype.delete=function(t){var e=Ka(t,this._firestore);return this._transaction.delete(e._key),this},t}());function $a(){if("undefined"==typeof Uint8Array)throw new c(a.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function Xa(){if("undefined"==typeof atob)throw new c(a.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var tc=function(){function t(t){this._delegate=t}return t.fromBase64String=function(e){return Xa(),new t(Ku.fromBase64String(e))},t.fromUint8Array=function(e){return $a(),new t(Ku.fromUint8Array(e))},t.prototype.toBase64=function(){return Xa(),this._delegate.toBase64()},t.prototype.toUint8Array=function(){return $a(),this._delegate.toUint8Array()},t.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},t.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},t}(),ec=function(){function t(){}return t.prototype.enableIndexedDbPersistence=function(t,e){return function(t,e){Bu(t=_u(t,Vu));var n=qu(t),r=t._freezeSettings(),i=new Js;return Gu(n,i,new Qs(i,r.cacheSizeBytes,null==e?void 0:e.forceOwnership))}(t._delegate,{forceOwnership:e})},t.prototype.enableMultiTabIndexedDbPersistence=function(t){return function(t){Bu(t=_u(t,Vu));var e=qu(t),n=t._freezeSettings(),r=new Js;return Gu(e,r,new zs(r,n.cacheSizeBytes))}(t._delegate)},t.prototype.clearIndexedDbPersistence=function(t){return function(t){var e=this;if(t._initialized&&!t._terminated)throw new c(a.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");var n=new nr;return t._queue.enqueueAndForgetEvenWhileRestricted((function(){return(0,r.mG)(e,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,function(t){return(0,r.mG)(this,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return or.yt()?(e=t+"main",[4,or.delete(e)]):[2,Promise.resolve()];case 1:return n.sent(),[2]}}))}))}(mi(t._databaseId,t._persistenceKey))];case 1:return i.sent(),n.resolve(),[3,3];case 2:return e=i.sent(),n.reject(e),[3,3];case 3:return[2]}}
2))}))})),n.promise}(t._delegate)},t}(),nc=function(){function t(t,e,n){var r=this;this._delegate=e,this.Zc=n,this.INTERNAL={delete:function(){return r.terminate()}},t instanceof hu||(this.tu=t)}return Object.defineProperty(t.prototype,"_databaseId",{get:function(){return this._delegate._databaseId},enumerable:!1,configurable:!0}),t.prototype.settings=function(t){var e=this._delegate._getSettings();t.merge||e.host===t.host||p("You are overriding the original host. If you did not intend to override your settings, use {merge: true}."),t.merge&&delete(t=Object.assign(Object.assign({},e),t)).merge,this._delegate._setSettings(t)},t.prototype.useEmulator=function(t,e,n){void 0===n&&(n={}),function(t,e,n,r){var o;void 0===r&&(r={});var s=(t=_u(t,Du))._getSettings();if("firestore.googleapis.com"!==s.host&&s.host!==e&&p("Host has been set in both settings() and useEmulator(), emulator host will be used"),t._setSettings(Object.assign(Object.assign({},s),{host:e+":"+n,ssl:!1})),r.mockUserToken){var u,h;if("string"==typeof r.mockUserToken)u=r.mockUserToken,h=Ji.MOCK_USER;else{u=(0,i.Sg)(r.mockUserToken,null===(o=t._app)||void 0===o?void 0:o.options.projectId);var f=r.mockUserToken.sub||r.mockUserToken.user_id;if(!f)throw new c(a.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");h=new Ji(f)}t._credentials=new pu(new lu(u,h))}}(this._delegate,t,e,n)},t.prototype.enableNetwork=function(){return function(t){var e=this;return t.asyncQueue.enqueue((function(){return(0,r.mG)(e,void 0,void 0,(function(){var e,n;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return[4,nu(t)];case 1:return e=r.sent(),[4,iu(t)];case 2:return n=r.sent(),[2,(e.setNetworkEnabled(!0),function(t){var e=g(t);return e.Or.delete(0),bo(e)}(n))]}}))}))}))}(qu(_u(this._delegate,Vu)))},t.prototype.disableNetwork=function(){return function(t){var e=this;return t.asyncQueue.enqueue((function(){return(0,r.mG)(e,void 0,void 0,(function(){var e,n;return(0,r.Jh)(this,(function(i){switch(i.label){case 0:return[4,nu(t)];case 1:return e=i.sent(),[4,iu(t)];case 2:return n=i.sent(),[2,(e.setNetworkEnabled(!1),function(t){return(0,r.mG)(this,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return(e=g(t)).Or.add(0),[4,Io(e)];case 1:return n.sent(),e.Br.set("Offline"),[2]}}))}))}(n))]}}))}))}))}(qu(_u(this._delegate,Vu)))},t.prototype.enablePersistence=function(t){var e=!1,n=!1;return t&&bu("synchronizeTabs",e=!!t.synchronizeTabs,"experimentalForceOwningTab",n=!!t.experimentalForceOwningTab),e?this.Zc.enableMultiTabIndexedDbPersistence(this):this.Zc.enableIndexedDbPersistence(this,n)},t.prototype.clearPersistence=function(){return this.Zc.clearIndexedDbPersistence(this)},t.prototype.terminate=function(){return this.tu&&(this.tu._removeServiceInstance("firestore"),this.tu._removeServiceInstance("firestore-exp")),this._delegate._delete()},t.prototype.waitForPendingWrites=function(){return function(t){var e=this,n=new nr;return t.asyncQueue.enqueueAndForget((function(){return(0,r.mG)(e,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return e=Ts,[4,ou(t)];case 1:return[2,e.apply(void 0,[r.sent(),n])]}}))}))})),n.promise}(qu(_u(this._delegate,Vu)))},t.prototype.onSnapshotsInSync=function(t){return function(t,e){return function(t,e){var n=this,i=new Ws(e);return t.asyncQueue.enqueueAndForget((function(){return(0,r.mG)(n,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return e=function(t,e){g(t).Gr.add(e),e.next()},[4,su(t)];case 1:return[2,e.apply(void 0,[n.sent(),i])]}}))}))})),function(){i.Wo(),t.asyncQueue.enqueueAndForget((function(){return(0,r.mG)(n,void 0,void 0,(function(){var e;return(0,r.Jh)(this,(function(n){switch(n.label){case 0:return e=function(t,e){g(t).Gr.delete(e)},[4,su(t)];case 1:return[2,e.apply(void 0,[n.sent(),i])]}}))}))}))}}(qu(t=_u(t,Vu)),Fu(e)?e:{next:e})}(this._delegate,t)},Object.defineProperty(t.prototype,"app",{get:function(){if(!this.tu)throw new c(a.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.tu}
2,enumerable:!1,configurable:!0}),t.prototype.collection=function(t){try{return new vc(this,xu(this._delegate,t))}catch(t){throw cc(t,"collection()","Firestore.collection()")}},t.prototype.doc=function(t){try{return new ac(this,Ru(this._delegate,t))}catch(t){throw cc(t,"doc()","Firestore.doc()")}},t.prototype.collectionGroup=function(t){try{return new pc(this,function(t,e){if(t=_u(t,Du),gu("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new c(a.INVALID_ARGUMENT,"Invalid collection ID '"+e+"' passed to function collectionGroup(). Collection IDs must not contain '/'.");return new ku(t,null,function(t){return new kt(C.emptyPath(),t)}(e))}(this._delegate,t))}catch(t){throw cc(t,"collectionGroup()","Firestore.collectionGroup()")}},t.prototype.runTransaction=function(t){var e=this;return function(t,e){return function(t,e){var n=this,i=new nr;return t.asyncQueue.enqueueAndForget((function(){return(0,r.mG)(n,void 0,void 0,(function(){var n;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return[4,function(t){return eu(t).then((function(t){return t.datastore}))}(t)];case 1:return n=r.sent(),new Zs(t.asyncQueue,n,e,i).run(),[2]}}))}))})),i.promise}(qu(t),(function(n){return e(new Ya(t,n))}
2))}(this._delegate,(function(n){return t(new oc(e,n))}))},t.prototype.batch=function(){var t=this;return qu(this._delegate),new sc(new ja(this._delegate,(function(e){return Ha(t._delegate,e)})))},t.prototype.loadBundle=function(t){throw new c(a.FAILED_PRECONDITION,'"loadBundle()" does not exist, have you imported "firebase/firestore/bundle"?')},t.prototype.namedQuery=function(t){throw new c(a.FAILED_PRECONDITION,'"namedQuery()" does not exist, have you imported "firebase/firestore/bundle"?')},t}(),rc=function(t){function e(e){var n=this;return(n=t.call(this)||this).firestore=e,n}return(0,r.ZT)(e,t),e.prototype.convertBytes=function(t){return new tc(new Ku(t))},e.prototype.convertReference=function(t){var e=this.convertDocumentKey(t,this.firestore._databaseId);return ac.eu(e,this.firestore,null)},e}(Ua);function ic(t){var e;e=t,h.setLogLevel(e)}var oc=function(){function t(t,e){this._firestore=t,this._delegate=e,this._userDataWriter=new rc(t)}return t.prototype.get=function(t){var e=this,n=gc(t);return this._delegate.get(n).then((function(t){return new lc(e._firestore,new Ea(e._firestore._delegate,e._userDataWriter,t._key,t._document,t.metadata,n.converter))}))},t.prototype.set=function(t,e,n){var r=gc(t);return n?(wu("Transaction.set",n),this._delegate.set(r,e,n)):this._delegate.set(r,e),this},t.prototype.update=function(t,e,n){for(var i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];var u=gc(t);return 2===arguments.length?this._delegate.update(u,e):(i=this._delegate).update.apply(i,(0,r.ev)([u,e,n],o)),this},t.prototype.delete=function(t){var e=gc(t);return this._delegate.delete(e),this},t}(),sc=function(){function t(t){this._delegate=t}return t.prototype.set=function(t,e,n){var r=gc(t);return n?(wu("WriteBatch.set",n),this._delegate.set(r,e,n)):this._delegate.set(r,e),this},t.prototype.update=function(t,e,n){for(var i,o=[],s=3;s<arguments.length;s++)o[s-3]=arguments[s];var u=gc(t);return 2===arguments.length?this._delegate.update(u,e):(i=this._delegate).update.apply(i,(0,r.ev)([u,e,n],o)),this},t.prototype.delete=function(t){var e=gc(t);return this._delegate.delete(e),this},t.prototype.commit=function(){return this._delegate.commit()},t}(),uc=function(){function t(t,e,n){this._firestore=t,this._userDataWriter=e,this._delegate=n}return t.prototype.fromFirestore=function(t,e){var n=new _a(this._firestore._delegate,this._userDataWriter,t._key,t._document,t.metadata,null);return this._delegate.fromFirestore(new dc(this._firestore,n),null!=e?e:{})},t.prototype.toFirestore=function(t,e){return e?this._delegate.toFirestore(t,e):this._delegate.toFirestore(t)},t.nu=function(e,n){var r=t.su,i=r.get(e);i||(i=new WeakMap,r.set(e,i));var o=i.get(n);return o||(o=new t(e,new rc(e),n),i.set(n,o)),o},t}();uc.su=new WeakMap;var ac=function(){function t(t,e){this.firestore=t,this._delegate=e,this._userDataWriter=new rc(t)}return t.iu=function(e,n,r){if(e.length%2!=0)throw new c(a.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+e.canonicalString()+" has "+e.length);return new t(n,new Au(n._delegate,r,new Q(e)))},t.eu=function(e,n,r){return new t(n,new Au(n._delegate,r,e))},Object.defineProperty(t.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return new vc(this.firestore,this._delegate.parent)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"path",{get:function(){return this._delegate.path},enumerable:!1,configurable:!0}),t.prototype.collection=function(t){try{return new vc(this.firestore,xu(this._delegate,t))}catch(t){throw cc(t,"collection()","DocumentReference.collection()")}},t.prototype.isEqual=function(t){return(t=(0,i.m9)(t))instanceof Au&&Lu(this._delegate,t)},t.prototype.set=function(t,e){e=wu("DocumentReference.set",e);try{return e?za(this._delegate,t,e):za(this._delegate,t)}catch(t){throw cc(t,"setDoc()","DocumentReference.set()")}},t.prototype.update=function(t,e){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];try{return 1===arguments.length?Ja(this._delegate,t):Ja.apply(void 0,(0,r.ev)([this._delegate,t,e],n))}
2catch(t){throw cc(t,"updateDoc()","DocumentReference.update()")}},t.prototype.delete=function(){return Ha(_u((t=this._delegate).firestore,Vu),[new _e(t._key,ce.none())]);var t},t.prototype.onSnapshot=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=hc(e),i=fc(e,(function(e){return new lc(t.firestore,new Ea(t.firestore._delegate,t._userDataWriter,e._key,e._document,e.metadata,t._delegate.converter))}));return Wa(this._delegate,r,i)},t.prototype.get=function(t){var e=this;return("cache"===(null==t?void 0:t.source)?function(t){t=_u(t,Au);var e=_u(t.firestore,Vu),n=qu(e),i=new Qa(e);return function(t,e){var n=this,i=new nr;return t.asyncQueue.enqueueAndForget((function(){return(0,r.mG)(n,void 0,void 0,(function(){var n;return(0,r.Jh)(this,(function(o){switch(o.label){case 0:return n=function(t,e,n){return(0,r.mG)(this,void 0,void 0,(function(){var i,o;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,function(t,e){var n=g(t);return n.persistence.runTransaction("read document","readonly",(function(t){return n.Mn.mn(t,e)}))}(t,e)];case 1:return(o=r.sent()).isFoundDocument()?n.resolve(o):o.isNoDocument()?n.resolve(null):n.reject(new c(a.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 i=r.sent(),o=zo(i,"Failed to get document '"+e+" from cache"),n.reject(o),[3,3];case 3:return[2]}}
2))}))},[4,ru(t)];case 1:return[2,n.apply(void 0,[o.sent(),e,i])]}}))}))})),i.promise}(n,t._key).then((function(n){return new Ea(e,i,t._key,n,new Ta(null!==n&&n.hasLocalMutations,!0),t.converter)}))}(this._delegate):"server"===(null==t?void 0:t.source)?function(t){t=_u(t,Au);var e=_u(t.firestore,Vu);return uu(qu(e),t._key,{source:"server"}).then((function(n){return Za(e,t,n)}))}(this._delegate):function(t){t=_u(t,Au);var e=_u(t.firestore,Vu);return uu(qu(e),t._key).then((function(n){return Za(e,t,n)}))}(this._delegate)).then((function(t){return new lc(e.firestore,new Ea(e.firestore._delegate,e._userDataWriter,t._key,t._document,t.metadata,e._delegate.converter))}))},t.prototype.withConverter=function(e){return new t(this.firestore,e?this._delegate.withConverter(uc.nu(this.firestore,e)):this._delegate.withConverter(null))},t}();function cc(t,e,n){return t.message=t.message.replace(e,n),t}function hc(t){for(var e=0,n=t;e<n.length;e++){var r=n[e];if("object"==typeof r&&!Fu(r))return r}return{}}function fc(t,e){var n,r,i;return{next:function(t){i.next&&i.next(e(t))},error:null===(n=(i=Fu(t[0])?t[0]:Fu(t[1])?t[1]:"function"==typeof t[0]?{next:t[0],error:t[1],complete:t[2]}:{next:t[1],error:t[2],complete:t[3]}).error)||void 0===n?void 0:n.bind(i),complete:null===(r=i.complete)||void 0===r?void 0:r.bind(i)}}var lc=function(){function t(t,e){this._firestore=t,this._delegate=e}return Object.defineProperty(t.prototype,"ref",{get:function(){return new ac(this._firestore,this._delegate.ref)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metadata",{get:function(){return this._delegate.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"exists",{get:function(){return this._delegate.exists()},enumerable:!1,configurable:!0}),t.prototype.data=function(t){return this._delegate.data(t)},t.prototype.get=function(t,e){return this._delegate.get(t,e)},t.prototype.isEqual=function(t){return Da(this._delegate,t._delegate)},t}(),dc=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,r.ZT)(e,t),e.prototype.data=function(t){return this._delegate.data(t)},e}(lc),pc=function(){function t(t,e){this.firestore=t,this._delegate=e,this._userDataWriter=new rc(t)}return t.prototype.where=function(e,n,r){try{return new t(this.firestore,Ca(this._delegate,function(t,e,n){var r=e,i=Ia("where",t);return new xa(i,r,n)}(e,n,r)))}catch(e){throw cc(e,/(orderBy|where)\(\)/,"Query.$1()")}},t.prototype.orderBy=function(e,n){try{return new t(this.firestore,Ca(this._delegate,function(t,e){void 0===e&&(e="asc");var n=e,r=Ia("orderBy",t);return new Ra(r,n)}(e,n)))}catch(e){throw cc(e,/(orderBy|where)\(\)/,"Query.$1()")}},t.prototype.limit=function(e){try{return new t(this.firestore,Ca(this._delegate,function(t){return Su("limit",t),new La("limit",t,"F")}(e)))}catch(e){throw cc(e,"limit()","Query.limit()")}},t.prototype.limitToLast=function(e){try{return new t(this.firestore,Ca(this._delegate,function(t){return Su("limitToLast",t),new La("limitToLast",t,"L")}(e)))}catch(e){throw cc(e,"limitToLast()","Query.limitToLast()")}},t.prototype.startAt=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return new t(this.firestore,Ca(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Oa("startAt",t,!0)}.apply(void 0,e)))}catch(e){throw cc(e,"startAt()","Query.startAt()")}},t.prototype.startAfter=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return new t(this.firestore,Ca(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Oa("startAfter",t,!1)}.apply(void 0,e)))}catch(e){throw cc(e,"startAfter()","Query.startAfter()")}},t.prototype.endBefore=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return new t(this.firestore,Ca(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Pa("endBefore",t,!0)}.apply(void 0,e)))}catch(e){throw cc(e,"endBefore()","Query.endBefore()")}},t.prototype.endAt=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return new t(this.firestore,Ca(this._delegate,function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new Pa("endAt",t,!1)}.apply(void 0,e)))}catch(e){throw cc(e,"endAt()","Query.endAt()")}},t.prototype.isEqual=function(t){return Ou(this._delegate,t._delegate)},t.prototype.get=function(t){var e=this;
2return("cache"===(null==t?void 0:t.source)?function(t){t=_u(t,ku);var e=_u(t.firestore,Vu),n=qu(e),i=new Qa(e);return function(t,e){var n=this,i=new nr;return t.asyncQueue.enqueueAndForget((function(){return(0,r.mG)(n,void 0,void 0,(function(){var n;return(0,r.Jh)(this,(function(o){switch(o.label){case 0:return n=function(t,e,n){return(0,r.mG)(this,void 0,void 0,(function(){var i,o,s,u,a;return(0,r.Jh)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,xi(t,e,!0)];case 1:return a=r.sent(),i=new cs(e,a.Bn),o=i._o(a.documents),s=i.applyChanges(o,!1),n.resolve(s.snapshot),[3,3];case 2:return u=r.sent(),a=zo(u,"Failed to execute query '"+e+" against cache"),n.reject(a),[3,3];case 3:return[2]}}))}))},[4,ru(t)];case 1:return[2,n.apply(void 0,[o.sent(),e,i])]}}))}))})),i.promise}(n,t._query).then((function(n){return new Sa(e,i,t,n)}))}(this._delegate):"server"===(null==t?void 0:t.source)?function(t){t=_u(t,ku);var e=_u(t.firestore,Vu),n=qu(e),r=new Qa(e);return au(n,t._query,{source:"server"}).then((function(n){return new Sa(e,r,t,n)}))}(this._delegate):function(t){t=_u(t,ku);var e=_u(t.firestore,Vu),n=qu(e),r=new Qa(e);return Aa(t._query),au(n,t._query).then((function(n){return new Sa(e,r,t,n)}))}(this._delegate)).then((function(t){return new mc(e.firestore,new Sa(e.firestore._delegate,e._userDataWriter,e._delegate,t._snapshot))}))},t.prototype.onSnapshot=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=hc(e),i=fc(e,(function(e){return new mc(t.firestore,new Sa(t.firestore._delegate,t._userDataWriter,t._delegate,e._snapshot))}));return Wa(this._delegate,r,i)},t.prototype.withConverter=function(e){return new t(this.firestore,e?this._delegate.withConverter(uc.nu(this.firestore,e)):this._delegate.withConverter(null))},t}(),yc=function(){function t(t,e){this._firestore=t,this._delegate=e}return Object.defineProperty(t.prototype,"type",{get:function(){return this._delegate.type},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"doc",{get:function(){return new dc(this._firestore,this._delegate.doc)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"oldIndex",{get:function(){return this._delegate.oldIndex},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"newIndex",{get:function(){return this._delegate.newIndex},enumerable:!1,configurable:!0}),t}(),mc=function(){function t(t,e){this._firestore=t,this._delegate=e}return Object.defineProperty(t.prototype,"query",{get:function(){return new pc(this._firestore,this._delegate.query)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metadata",{get:function(){return this._delegate.metadata},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this._delegate.size},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"empty",{get:function(){return this._delegate.empty},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"docs",{get:function(){var t=this;return this._delegate.docs.map((function(e){return new dc(t._firestore,e)}))},enumerable:!1,configurable:!0}),t.prototype.docChanges=function(t){var e=this;return this._delegate.docChanges(t).map((function(t){return new yc(e._firestore,t)}))},t.prototype.forEach=function(t,e){var n=this;this._delegate.forEach((function(r){t.call(e,new dc(n._firestore,r))}))},t.prototype.isEqual=function(t){return Da(this._delegate,t._delegate)},t}(),vc=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n)||this).firestore=e,r._delegate=n,r}return(0,r.ZT)(e,t),Object.defineProperty(e.prototype,"id",{get:function(){return this._delegate.id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"path",{get:function(){return this._delegate.path},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){var t=this._delegate.parent;return t?new ac(this.firestore,t):null},enumerable:!1,configurable:!0}),e.prototype.doc=function(t){try{return new ac(this.firestore,void 0===t?Ru(this._delegate):Ru(this._delegate,t))}catch(t){throw cc(t,"doc()","CollectionReference.doc()")}},e.prototype.add=function(t){var e=this;return function(t,e){var n=_u(t.firestore,Vu),r=Ru(t),i=Ga(t.converter,e);return Ha(n,[ta(Xu(t.firestore),"addDoc",r._key,i,null!==t.converter,{}).toMutation(r._key,ce.exists(!1))]).then((function(){return r}))}(this._delegate,t).then((function(t){return new ac(e.firestore,t)}))},e.prototype.isEqual=function(t){return Lu(this._delegate,t._delegate)},e.prototype.withConverter=function(t){return new e(this.firestore,t?this._delegate.withConverter(uc.nu(this.firestore,t)):this._delegate.withConverter(null))},e}(pc);function gc(t){return _u(t,Au)}var wc=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._delegate=new(ju.bind.apply(ju,(0,r.ev)([void 0],t)))}return t.documentId=function(){return new t(R.keyField().canonicalString())},t.prototype.isEqual=function(t){return(t=(0,i.m9)(t))instanceof ju&&this._delegate._internalPath.isEqual(t._internalPath)},t}(),bc=function(){function t(t){this._delegate=t}return t.serverTimestamp=function(){var e=new ra("serverTimestamp");return e._methodName="FieldValue.serverTimestamp",new t(e)},t.delete=function(){var e=new ea("deleteField");return e._methodName="FieldValue.delete",new t(e)},t.arrayUnion=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new ia("arrayUnion",t)}.apply(void 0,e);return r._methodName="FieldValue.arrayUnion",new t(r)},t.arrayRemove=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new oa("arrayRemove",t)}.apply(void 0,e);return r._methodName="FieldValue.arrayRemove",new t(r)},t.increment=function(e){var n=function(t){return new sa("increment",t)}(e);return n._methodName="FieldValue.increment",new t(n)},t.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},t}()}}]);
3//# sourceMappingURL=a2267787-5c171f7dc71a6541f5a9.js.map

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