1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6259],{96653:function(t,e,n){n.d(e,{C:function(){return sn},E:function(){return o4},M:function(){return I},Q:function(){return un},T:function(){return o3},U:function(){return ut},W:function(){return ui},X:function(){return uh},Z:function(){return ul},a:function(){return s9},j:function(){return ur},n:function(){return up},o:function(){return uv},q:function(){return s7},r:function(){return um},s:function(){return uy},t:function(){return uf},z:function(){return us}});var r=n(97582),i=n(44589),o=n(14594),s=n(73705),u=n(34155),a=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}();a.o=-1;/** 2 * @license 3 * Copyright 2017 Google LLC 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */var c={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"},h=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),l=new o.Yd("@firebase/firestore");function f(){return l.logLevel}function d(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(l.logLevel<=o.in.DEBUG){var i=e.map(m);l.debug.apply(l,(0,r.ev)(["Firestore (8.10.0): "+t],i))}}function p(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(l.logLevel<=o.in.ERROR){var i=e.map(m);l.error.apply(l,(0,r.ev)(["Firestore (8.10.0): "+t],i))}}function y(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(l.logLevel<=o.in.WARN){var i=e.map(m);l.warn.apply(l,(0,r.ev)(["Firestore (8.10.0): "+t],i))}}function m(t){if("string"==typeof t)return t;try{return JSON.stringify(t)}catch(e){return t}}/** 17 * @license 18 * Copyright 2017 Google LLC 19 * 20 * Licensed under the Apache License, Version 2.0 (the "License"); 21 * you may not use this file except in compliance with the License. 22 * You may obtain a copy of the License at 23 * 24 * http://www.apache.org/licenses/LICENSE-2.0 25 * 26 * Unless required by applicable law or agreed to in writing, software 27 * distributed under the License is distributed on an "AS IS" BASIS, 28 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 29 * See the License for the specific language governing permissions and 30 * limitations under the License. 31 */function v(t){void 0===t&&(t="Unexpected state");var e="FIRESTORE (8.10.0) INTERNAL ASSERTION FAILED: "+t;throw p(e),Error(e)}/** 32 * @license 33 * Copyright 2017 Google LLC 34 * 35 * Licensed under the Apache License, Version 2.0 (the "License"); 36 * you may not use this file except in compliance with the License. 37 * You may obtain a copy of the License at 38 * 39 * http://www.apache.org/licenses/LICENSE-2.0 40 * 41 * Unless required by applicable law or agreed to in writing, software 42 * distributed under the License is distributed on an "AS IS" BASIS, 43 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 44 * See the License for the specific language governing permissions and 45 * limitations under the License. 46 */var g=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=/** 47 * @license 48 * Copyright 2020 Google LLC 49 * 50 * Licensed under the Apache License, Version 2.0 (the "License");
51 * you may not use this file except in compliance with the License. 52 * You may obtain a copy of the License at 53 * 54 * http://www.apache.org/licenses/LICENSE-2.0 55 * 56 * Unless required by applicable law or agreed to in writing, software 57 * distributed under the License is distributed on an "AS IS" BASIS, 58 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 59 * See the License for the specific language governing permissions and 60 * limitations under the License. 61 */function(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}(40),i=0;i<r.length;++i)n.length<20&&r[i]<e&&(n+=t.charAt(r[i]%t.length));return n},t}();function w(t,e){return t<e?-1:t>e?1:0}function b(t,e,n){return t.length===e.length&&t.every(function(t,r){return n(t,e[r])})}/** 62 * @license 63 * Copyright 2017 Google LLC 64 * 65 * Licensed under the Apache License, Version 2.0 (the "License"); 66 * you may not use this file except in compliance with the License. 67 * You may obtain a copy of the License at 68 * 69 * http://www.apache.org/licenses/LICENSE-2.0 70 * 71 * Unless required by applicable law or agreed to in writing, software 72 * distributed under the License is distributed on an "AS IS" BASIS, 73 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 74 * See the License for the specific language governing permissions and 75 * limitations under the License. 76 */var I=function(){function t(t,e){if(this.seconds=t,this.nanoseconds=e,e<0||e>=1e9)throw new h(c.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+e);if(t<-62135596800||t>=253402300800)throw new h(c.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?w(this.nanoseconds,t.nanoseconds):w(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(){return String(this.seconds- -62135596800).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")},t}(),T=function(){function t(t){this.timestamp=t}return t.fromTimestamp=function(e){return new t(e)},t.min=function(){return new t(new I(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}();/** 77 * @license 78 * Copyright 2017 Google LLC 79 * 80 * Licensed under the Apache License, Version 2.0 (the "License"); 81 * you may not use this file except in compliance with the License. 82 * You may obtain a copy of the License at 83 * 84 * http://www.apache.org/licenses/LICENSE-2.0 85 * 86 * Unless required by applicable law or agreed to in writing, software 87 * distributed under the License is distributed on an "AS IS" BASIS, 88 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 89 * See the License for the specific language governing permissions and 90 * limitations under the License. 91 *//** 92 * @license 93 * Copyright 2017 Google LLC 94 * 95 * Licensed under the Apache License, Version 2.0 (the "License"); 96 * you may not use this file except in compliance with the License. 97 * You may obtain a copy of the License at 98 * 99 * http://www.apache.org/licenses/LICENSE-2.0 100 * 101 * Unless required by applicable law or agreed to in writing, softw
101are 102 * distributed under the License is distributed on an "AS IS" BASIS, 103 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 104 * See the License for the specific language governing permissions and 105 * limitations under the License. 106 */function E(t){var e=0;for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function _(t,e){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e(n,t[n])}function S(t){for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}/** 107 * @license 108 * Copyright 2017 Google LLC 109 * 110 * Licensed under the Apache License, Version 2.0 (the "License"); 111 * you may not use this file except in compliance with the License. 112 * You may obtain a copy of the License at 113 * 114 * http://www.apache.org/licenses/LICENSE-2.0 115 * 116 * Unless required by applicable law or agreed to in writing, software 117 * distributed under the License is distributed on an "AS IS" BASIS, 118 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 119 * See the License for the specific language governing permissions and 120 * limitations under the License. 121 */var N=function(){function t(t,e,n){void 0===e?e=0:e>t.length&&v(),void 0===n?n=t.length-e:n>t.length-e&&v(),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}(),D=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;i<t.length;i++){var o=t[i];if(o.indexOf("//")>=0)throw new h(c.INVALID_ARGUMENT,"Invalid segment ("+o+"). Paths must not contain // in them.");r.push.apply(r,o.split("/").filter(function(t){return t.length>0}))}return new e(r)},e.emptyPath=function(){return new e([])},e}(N),A=/^[_a-zA-Z][_a-zA-Z0-9]*$/,k=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 A.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 h(c.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 h(c.INVALID_ARGUMENT,"Path has trailing escape character: "+t);var a=t[i+1];if("\\"!==a&&"."!==a&&"`"!==a)throw new h(c.INVALID_ARGUMENT,"Path has invali
121d escape sequence: "+t);r+=a,i+=2}else"`"===u?(s=!s,i++):"."!==u||s?(r+=u,i++):(o(),i++)}if(o(),s)throw new h(c.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)},e.emptyPath=function(){return new e([])},e}(N),x=function(){function t(t){this.fields=t,t.sort(k.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 b(this.fields,t.fields,function(t,e){return t.isEqual(e)})},t}(),C=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 btoa(this.binaryString)},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 w(this.binaryString,t.binaryString)},t.prototype.isEqual=function(t){return this.binaryString===t.binaryString},t}();C.EMPTY_BYTE_STRING=new C("");var R=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function L(t){if(t||v(),"string"==typeof t){var e=0,n=R.exec(t);if(n||v(),n[1]){var r=n[1];e=Number(r=(r+"000000000").substr(0,9))}return{seconds:Math.floor(new Date(t).getTime()/1e3),nanos:e}}return{seconds:O(t.seconds),nanos:O(t.nanos)}}function O(t){return"number"==typeof t?t:"string"==typeof t?Number(t):0}function P(t){return"string"==typeof t?C.fromBase64String(t):C.fromUint8Array(t)}/** 122 * @license 123 * Copyright 2020 Google LLC 124 * 125 * Licensed under the Apache License, Version 2.0 (the "License"); 126 * you may not use this file except in compliance with the License. 127 * You may obtain a copy of the License at 128 * 129 * http://www.apache.org/licenses/LICENSE-2.0 130 * 131 * Unless required by applicable law or agreed to in writing, software 132 * distributed under the License is distributed on an "AS IS" BASIS, 133 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 134 * See the License for the specific language governing permissions and 135 * limitations under the License. 136 */function F(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 M(t){var e=L(t.mapValue.fields.__local_write_time__.timestampValue);return new I(e.seconds,e.nanos)}/** 137 * @license 138 * Copyright 2017 Google LLC 139 * 140 * Licensed under the Apache License, Version 2.0 (the "License"); 141 * you may not use this file except in compliance with the License. 142 * You may obtain a copy of the License at 143 * 144 * http://www.apache.org/licenses/LICENSE-2.0 145 * 146 * Unless required by applicable law or agreed to in writing, software 147 * distributed under the License is distributed on an "AS IS" BASIS, 148 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 149 * See the License for the specific language governing permissions and 150 * limitations under the License. 151 */function V(t){return null==t}function q(t){return 0===t&&1/t==-1/0}function U(t){return"number"==typeof t&&Number.isInteger(t)&&!q(t)&&t<=Number.MAX_SAFE_INTEGER&&t>=Number.MIN_SAFE_INTEGER}/** 152 * @license 153 * Copyright 2017 Google LLC 154 * 155 * Licensed under the Apache License, Version 2.0 (the "License"); 156 * you may not use this file except in compliance with the License. 157 * You may obtain a copy of the License at 158 * 159 * http://www.apache.org/licenses/LICENSE-2.0 160 * 161 * Unless required by applicable law or agreed to in writing, software 162 * distributed under the License is distributed on an "AS IS" BASIS, 163 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 164 * See the License for the specific language governing permissions and 165 * limitations under the License. 166 */var G=function(){function t(t){this.path=t}return t.fromPath=function(e){return new t(D.fromString(e))},t.fromName=function(e){return new t(D.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===D.comparator(this.path,t.path)},t.prototype.toString=function(){return this.path.toString()},t.comparator=function(t,e){return D.comparator(t.path,e.path)},t.isDocumentKey=function(t){return t.length%2==0},t.fromSegments=function(e){return new t(new D(e.slice()))},t}();/** 167 * @license 168 * Copyright 2020 Google LLC 169 * 170 * Licensed under the Apache License, Version 2.0 (the "License");
171 * you may not use this file except in compliance with the License. 172 * You may obtain a copy of the License at 173 * 174 * http://www.apache.org/licenses/LICENSE-2.0 175 * 176 * Unless required by applicable law or agreed to in writing, software 177 * distributed under the License is distributed on an "AS IS" BASIS, 178 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 179 * See the License for the specific language governing permissions and 180 * limitations under the License. 181 */function B(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?F(t)?4:10:v()}function j(t,e){var n=B(t);if(n!==B(e))return!1;switch(n){case 0:return!0;case 1:return t.booleanValue===e.booleanValue;case 4:return M(t).isEqual(M(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=L(t.timestampValue),r=L(e.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(t,e);case 5:return t.stringValue===e.stringValue;case 6:return P(t.bytesValue).isEqual(P(e.bytesValue));case 7:return t.referenceValue===e.referenceValue;case 8:return O(t.geoPointValue.latitude)===O(e.geoPointValue.latitude)&&O(t.geoPointValue.longitude)===O(e.geoPointValue.longitude);case 2:return function(t,e){if("integerValue"in t&&"integerValue"in e)return O(t.integerValue)===O(e.integerValue);if("doubleValue"in t&&"doubleValue"in e){var n=O(t.doubleValue),r=O(e.doubleValue);return n===r?q(n)===q(r):isNaN(n)&&isNaN(r)}return!1}(t,e);case 9:return b(t.arrayValue.values||[],e.arrayValue.values||[],j);case 10:return function(t,e){var n=t.mapValue.fields||{},r=e.mapValue.fields||{};if(E(n)!==E(r))return!1;for(var i in n)if(n.hasOwnProperty(i)&&(void 0===r[i]||!j(n[i],r[i])))return!1;return!0}(t,e);default:return v()}}function K(t,e){return void 0!==(t.values||[]).find(function(t){return j(t,e)})}function Q(t,e){var n,r,i,o,s,u,a,c,h,l=B(t),f=B(e);if(l!==f)return w(l,f);switch(l){case 0:return 0;case 1:return w(t.booleanValue,e.booleanValue);case 2:return(n=O(t.integerValue||t.doubleValue))<(r=O(e.integerValue||e.doubleValue))?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1;case 3:return z(t.timestampValue,e.timestampValue);case 4:return z(M(t),M(e));case 5:return w(t.stringValue,e.stringValue);case 6:return i=t.bytesValue,o=e.bytesValue,s=P(i),u=P(o),s.compareTo(u);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=w(n[i],r[i]);if(0!==o)return o}return w(n.length,r.length)}(t.referenceValue,e.referenceValue);case 8:return a=t.geoPointValue,c=e.geoPointValue,0!==(h=w(O(a.latitude),O(c.latitude)))?h:w(O(a.longitude),O(c.longitude));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=Q(n[i],r[i]);if(o)return o}return w(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=w(r[s],o[s]);if(0!==u)return u;var a=Q(n[r[s]],i[o[s]]);if(0!==a)return a}return w(r.length,o.length)}(t.mapValue,e.mapValue);default:throw v()}}function z(t,e){if("string"==typeof t&&"string"==typeof e&&t.length===e.length)return w(t,e);var n=L(t),r=L(e),i=w(n.seconds,r.seconds);return 0!==i?i:w(n.nanos,r.nanos)}function J(t){var e,n,r;return"nullValue"in t?"null":"booleanValue"in t?""+t.booleanValue:"integerValue"in t?""+t.integerValue:"doubleValue"in t?""+t.doubleValue:"timestampValue"in t?"time("+(r=L(t.timestampValue)).seconds+","+r.nanos+")":"stringValue"in t?t.stringValue:"bytesValue"in t?P(t.bytesValue).toBase64():"referenceValue"in t?(n=t.referenceValue,G.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+=J(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+":"+J(t.fields[o])}return e+"}"}(t.mapValue):v()}function W(t,e){return{referenceValue:"projects/"+t.projectId+"/databases/"+t.database+"/documents/"+e.path.canonicalString()}}function H(t){return!!t&&"integerValue"in t}function Z(t){return!!t&&"arrayValue"in t}function Y(t){return!!t&&"nullValue"in t}function $(t){return!!t&&"doubleValue"in t&&isNaN(Number(t.doubleValue))}function X(t){return!!t&&"mapValue"in t}function tt(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 _(t.mapValue.fields,function(t,n){return e.mapValue.fields[t]=tt(n)}),e}if(t.arrayValue){for(var n={arrayValue:{values:[]}},r=0;r<(t.arrayValue.values||[]).length;++r)n.arrayValue.values[r]=tt(t.arrayValue.values[r]);return n}return Object.assign({},t)}/** 182 * @license 183 * Copyright 2017 Google LLC 184 * 185 * Licensed under the Apache License, Version 2.0 (the "License");
186 * you may not use this file except in compliance with the License. 187 * You may obtain a copy of the License at 188 * 189 * http://www.apache.org/licenses/LICENSE-2.0 190 * 191 * Unless required by applicable law or agreed to in writing, software 192 * distributed under the License is distributed on an "AS IS" BASIS, 193 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 194 * See the License for the specific language governing permissions and 195 * limitations under the License. 196 */var te=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(!X(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()]=tt(e)},t.prototype.setAll=function(t){var e=this,n=k.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()]=tt(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());X(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)];X(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){_(e,function(e,n){return t[e]=n});for(var r=0;r<n.length;r++){var i=n[r];delete t[i]}},t.prototype.clone=function(){return new t(tt(this.value))},t}(),tn=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,T.min(),te.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,te.empty(),0)},t.newUnknownDocument=function(e,n){return new t(e,3,n,te.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=te.empty(),this.documentState=0,this},t.prototype.convertToUnknownDocument=function(t){return this.version=t,this.documentType=3,this.data=te.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}(),tr=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};/** 197 * @license 198 * Copyright 2019 Google LLC 199 * 200 * Licensed under the Apache License, Version 2.0 (the "License");
201 * you may not use this file except in compliance with the License. 202 * You may obtain a copy of the License at 203 * 204 * http://www.apache.org/licenses/LICENSE-2.0 205 * 206 * Unless required by applicable law or agreed to in writing, software 207 * distributed under the License is distributed on an "AS IS" BASIS, 208 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 209 * See the License for the specific language governing permissions and 210 * limitations under the License. 211 */function ti(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 tr(t,e,n,r,i,o,s)}function to(t){if(null===t.h){var e=t.path.canonicalString();null!==t.collectionGroup&&(e+="|cg:"+t.collectionGroup),e+="|f:"+t.filters.map(function(t){return t.field.canonicalString()+t.op.toString()+J(t.value)}).join(",")+"|ob:"+t.orderBy.map(function(t){return t.field.canonicalString()+t.dir}).join(","),V(t.limit)||(e+="|l:"+t.limit),t.startAt&&(e+="|lb:"+tg(t.startAt)),t.endAt&&(e+="|ub:"+tg(t.endAt)),t.h=e}return t.h}function ts(t,e){if(t.limit!==e.limit||t.orderBy.length!==e.orderBy.length)return!1;for(var n,r,i,o,s=0;s<t.orderBy.length;s++)if(n=t.orderBy[s],r=e.orderBy[s],!(n.dir===r.dir&&n.field.isEqual(r.field)))return!1;if(t.filters.length!==e.filters.length)return!1;for(var u=0;u<t.filters.length;u++)if(i=t.filters[u],o=e.filters[u],i.op!==o.op||!i.field.isEqual(o.field)||!j(i.value,o.value))return!1;return t.collectionGroup===e.collectionGroup&&!!t.path.isEqual(e.path)&&!!tI(t.startAt,e.startAt)&&tI(t.endAt,e.endAt)}function tu(t){return G.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length}var ta=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 tc(t,n,r):"array-contains"===n?new td(t,r):"in"===n?new tp(t,r):"not-in"===n?new ty(t,r):"array-contains-any"===n?new tm(t,r):new e(t,n,r)},e.l=function(t,e,n){return"in"===e?new th(t,n):new tl(t,n)},e.prototype.matches=function(t){var e=t.data.field(this.field);return"!="===this.op?null!==e&&this.m(Q(e,this.value)):null!==e&&B(this.value)===B(e)&&this.m(Q(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 v()}},e.prototype.g=function(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0},e}(function(){}),tc=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n,r)||this).key=G.fromName(r.referenceValue),i}return(0,r.ZT)(e,t),e.prototype.matches=function(t){var e=G.comparator(t.key,this.key);return this.m(e)},e}(ta),th=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"in",n)||this).keys=tf("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}(ta),tl=function(t){function e(e,n){var r=this;return(r=t.call(this,e,"not-in",n)||this).keys=tf("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}(ta);function tf(t,e){var n;return((null===(n=e.arrayValue)||void 0===n?void 0:n.values)||[]).map(function(t){return G.fromName(t.referenceValue)})}var td=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 Z(e)&&K(e.arrayValue,this.value)},e}(ta),tp=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&&K(this.value.arrayValue,e)},e}(ta),ty=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(K(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;var e=t.data.field(this.field);return null!==e&&!K(this.value.arrayValue,e)},e}(ta),tm=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!(!Z(n)||!n.arrayValue.values)&&n.arrayValue.values.some(function(t){return K(e.value.arrayValue,t)})},e}(ta),tv=function(t,e){this.position=t,this.before=e};function tg(t){return(t.before?"b":"a")+":"+t.position.map(function(t){return J(t)}).join(",")}var tw=function(t,e){void 0===e&&(e="asc"),this.field=t,this.dir=e};function tb(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()?G.comparator(G.fromName(s.referenceValue),n.key):Q(s,n.data.field(o.field)),"desc"===o.dir&&(r*=-1),0!==r)break}return t.before?r<=0:r<0}function tI(t,e){if(null===t)return null===e;if(null===e||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}/** 212 * @license 213 * Copyright 2017 Google LLC 214 * 215 * Licensed under the Apache License, Version 2.0 (the "License");
216 * you may not use this file except in compliance with the License. 217 * You may obtain a copy of the License at 218 * 219 * http://www.apache.org/licenses/LICENSE-2.0 220 * 221 * Unless required by applicable law or agreed to in writing, software 222 * distributed under the License is distributed on an "AS IS" BASIS, 223 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 224 * See the License for the specific language governing permissions and 225 * limitations under the License. 226 */var tT=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 tE(t){return new tT(t)}function t_(t){return!V(t.limit)&&"F"===t.limitType}function tS(t){return!V(t.limit)&&"L"===t.limitType}function tN(t){return t.explicitOrderBy.length>0?t.explicitOrderBy[0].field:null}function tD(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 tA(t){return null!==t.collectionGroup}function tk(t){if(null===t.p){t.p=[];var e=tD(t),n=tN(t);if(null!==e&&null===n)e.isKeyField()||t.p.push(new tw(e)),t.p.push(new tw(k.keyField(),"asc"));else{for(var r=!1,i=0,o=t.explicitOrderBy;i<o.length;i++){var s=o[i];t.p.push(s),s.field.isKeyField()&&(r=!0)}if(!r){var u=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc";t.p.push(new tw(k.keyField(),u))}}}return t.p}function tx(t){if(!t.T){if("F"===t.limitType)t.T=ti(t.path,t.collectionGroup,tk(t),t.filters,t.limit,t.startAt,t.endAt);else{for(var e=[],n=0,r=tk(t);n<r.length;n++){var i=r[n],o="desc"===i.dir?"asc":"desc";e.push(new tw(i.field,o))}var s=t.endAt?new tv(t.endAt.position,!t.endAt.before):null,u=t.startAt?new tv(t.startAt.position,!t.startAt.before):null;t.T=ti(t.path,t.collectionGroup,e,t.filters,t.limit,s,u)}}return t.T}function tC(t,e,n){return new tT(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),e,n,t.startAt,t.endAt)}function tR(t,e){return ts(tx(t),tx(e))&&t.limitType===e.limitType}function tL(t){return to(tx(t))+"|lt:"+t.limitType}function tO(t){var e,n;return"Query(target="+(n=(e=tx(t)).path.canonicalString(),null!==e.collectionGroup&&(n+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(n+=", filters: ["+e.filters.map(function(t){return t.field.canonicalString()+" "+t.op+" "+J(t.value)}).join(", ")+"]"),V(e.limit)||(n+=", limit: "+e.limit),e.orderBy.length>0&&(n+=", orderBy: ["+e.orderBy.map(function(t){return t.field.canonicalString()+" ("+t.dir+")"}).join(", ")+"]"),e.startAt&&(n+=", startAt: "+tg(e.startAt)),e.endAt&&(n+=", endAt: "+tg(e.endAt)),"Target("+n+")")+"; limitType="+t.limitType+")"}function tP(t,e){var n;return e.isFoundDocument()&&(n=e.key.path,null!==t.collectionGroup?e.key.hasCollectionId(t.collectionGroup)&&t.path.isPrefixOf(n):G.isDocumentKey(t.path)?t.path.isEqual(n):t.path.isImmediateParentOf(n))&&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)&&!(t.startAt&&!tb(t.startAt,tk(t),e))&&(!t.endAt||!tb(t.endAt,tk(t),e))}function tF(t){return function(e,n){for(var r=!1,i=0,o=tk(t);i<o.length;i++){var s=o[i],u=function(t,e,n){var r,i,o,s=t.field.isKeyField()?G.comparator(e.key,n.key):(r=t.field,i=e.data.field(r),o=n.data.field(r),null!==i&&null!==o?Q(i,o):v());switch(t.dir){case"asc":return s;case"desc":return -1*s;default:return v()}}(s,e,n);if(0!==u)return u;r=r||s.field.isKeyField()}return 0}}/** 227 * @license 228 * Copyright 2020 Google LLC 229 * 230 * Licensed under the Apache License, Version 2.0 (the "License"); 231 * you may not use this file except in compliance with the License. 232 * You may obtain a copy of the License at 233 * 234 * http://www.apache.org/licenses/LICENSE-2.0 235 * 236 * Unless required by applicable law or agreed to in writing, softw
236are 237 * distributed under the License is distributed on an "AS IS" BASIS, 238 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 239 * See the License for the specific language governing permissions and 240 * limitations under the License. 241 */function tM(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:q(e)?"-0":e}}function tV(t){return{integerValue:""+t}}function tq(t,e){return U(e)?tV(e):tM(t,e)}/** 242 * @license 243 * Copyright 2018 Google LLC 244 * 245 * Licensed under the Apache License, Version 2.0 (the "License"); 246 * you may not use this file except in compliance with the License. 247 * You may obtain a copy of the License at 248 * 249 * http://www.apache.org/licenses/LICENSE-2.0 250 * 251 * Unless required by applicable law or agreed to in writing, software 252 * distributed under the License is distributed on an "AS IS" BASIS, 253 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 254 * See the License for the specific language governing permissions and 255 * limitations under the License. 256 */var tU=function(){this._=void 0};function tG(t,e){return t instanceof tJ?H(e)||e&&"doubleValue"in e?e:{integerValue:0}:null}var tB=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return(0,r.ZT)(e,t),e}(tU),tj=function(t){function e(e){var n=this;return(n=t.call(this)||this).elements=e,n}return(0,r.ZT)(e,t),e}(tU);function tK(t,e){for(var n=tH(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 tQ=function(t){function e(e){var n=this;return(n=t.call(this)||this).elements=e,n}return(0,r.ZT)(e,t),e}(tU);function tz(t,e){for(var n=tH(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 tJ=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}(tU);function tW(t){return O(t.integerValue||t.doubleValue)}function tH(t){return Z(t)&&t.arrayValue.values?t.arrayValue.values.slice():[]}/** 257 * @license 258 * Copyright 2017 Google LLC 259 * 260 * Licensed under the Apache License, Version 2.0 (the "License"); 261 * you may not use this file except in compliance with the License. 262 * You may obtain a copy of the License at 263 * 264 * http://www.apache.org/licenses/LICENSE-2.0 265 * 266 * Unless required by applicable law or agreed to in writing, software 267 * distributed under the License is distributed on an "AS IS" BASIS, 268 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 269 * See the License for the specific language governing permissions and 270 * limitations under the License. 271 */var tZ=function(t,e){this.field=t,this.transform=e},tY=function(t,e){this.version=t,this.transformResults=e},t$=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 tX(t,e){return void 0!==t.updateTime?e.isFoundDocument()&&e.version.isEqual(t.updateTime):void 0===t.exists||t.exists===e.isFoundDocument()}var t0=function(){};function t1(t,e,n){t instanceof t3?function(t,e,n){if(tX(t.precondition,e)){var r=t.value.clone(),i=t9(t.fieldTransforms,n,e);r.setAll(i),e.convertToFoundDocument(t4(e),r).setHasLocalMutations()}}(t,e,n):t instanceof t5?function(t,e,n){if(tX(t.precondition,e)){var r=t9(t.fieldTransforms,n,e),i=e.data;i.setAll(t6(t)),i.setAll(r),e.convertToFoundDocument(t4(e),i).setHasLocalMutations()}}(t,e,n):tX(t.precondition,e)&&e.convertToNoDocument(T.min())}function t2(t,e){var n,r;return t.type===e.type&&!!t.key.isEqual(e.key)&&!!t.precondition.isEqual(e.precondition)&&(n=t.fieldTransforms,r=e.fieldTransforms,!!(void 0===n&&void 0===r||!(!n||!r)&&b(n,r,function(t,e){var n,r;return t.field.isEqual(e.field)&&(n=t.transform,r=e.transform,n instanceof tj&&r instanceof tj||n instanceof tQ&&r instanceof tQ?b(n.elements,r.elements,j):n instanceof tJ&&r instanceof tJ?j(n.A,r.A):n instanceof tB&&r instanceof tB)})))&&(0===t.type?t.value.isEqual(e.value):1!==t.type||t.data.isEqual(e.data)&&t.fieldMask.isEqual(e.fieldMask))}function t4(t){return t.isFoundDocument()?t.version:T.min()}var t3=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}(t0),t5=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}(t0);function t6(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 t8(t,e,n){var r=new Map;
271t.length===n.length||v();for(var i=0;i<n.length;i++){var o,s=t[i],u=s.transform,a=e.data.field(s.field);r.set(s.field,(o=n[i],u instanceof tj?tK(u,a):u instanceof tQ?tz(u,a):o))}return r}function t9(t,e,n){for(var r=new Map,i=0;i<t.length;i++){var o=t[i],s=o.transform,u=n.data.field(o.field);r.set(o.field,function(t,e,n){var r,i,o;return t instanceof tB?(r={fields:{__type__:{stringValue:"server_timestamp"},__local_write_time__:{timestampValue:{seconds:n.seconds,nanos:n.nanoseconds}}}},e&&(r.fields.__previous_value__=e),{mapValue:r}):t instanceof tj?tK(t,e):t instanceof tQ?tz(t,e):(o=tW(i=tG(t,e))+tW(t.A),H(i)&&H(t.A)?tV(o):tM(t.R,o))}(s,u,e))}return r}var t7,et,ee=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}(t0),en=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}(t0),er=function(t){this.count=t};function ei(t){switch(t){case c.OK:return v();case c.CANCELLED:case c.UNKNOWN:case c.DEADLINE_EXCEEDED:case c.RESOURCE_EXHAUSTED:case c.INTERNAL:case c.UNAVAILABLE:case c.UNAUTHENTICATED:return!1;case c.INVALID_ARGUMENT:case c.NOT_FOUND:case c.ALREADY_EXISTS:case c.PERMISSION_DENIED:case c.FAILED_PRECONDITION:case c.ABORTED:case c.OUT_OF_RANGE:case c.UNIMPLEMENTED:case c.DATA_LOSS:return!0;default:return v()}}function eo(t){if(void 0===t)return p("GRPC error has no .code"),c.UNKNOWN;switch(t){case t7.OK:return c.OK;case t7.CANCELLED:return c.CANCELLED;case t7.UNKNOWN:return c.UNKNOWN;case t7.DEADLINE_EXCEEDED:return c.DEADLINE_EXCEEDED;case t7.RESOURCE_EXHAUSTED:return c.RESOURCE_EXHAUSTED;case t7.INTERNAL:return c.INTERNAL;case t7.UNAVAILABLE:return c.UNAVAILABLE;case t7.UNAUTHENTICATED:return c.UNAUTHENTICATED;case t7.INVALID_ARGUMENT:return c.INVALID_ARGUMENT;case t7.NOT_FOUND:return c.NOT_FOUND;case t7.ALREADY_EXISTS:return c.ALREADY_EXISTS;case t7.PERMISSION_DENIED:return c.PERMISSION_DENIED;case t7.FAILED_PRECONDITION:return c.FAILED_PRECONDITION;case t7.ABORTED:return c.ABORTED;case t7.OUT_OF_RANGE:return c.OUT_OF_RANGE;case t7.UNIMPLEMENTED:return c.UNIMPLEMENTED;case t7.DATA_LOSS:return c.DATA_LOSS;default:return v()}}(et=t7||(t7={}))[et.OK=0]="OK",et[et.CANCELLED=1]="CANCELLED",et[et.UNKNOWN=2]="UNKNOWN",et[et.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",et[et.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",et[et.NOT_FOUND=5]="NOT_FOUND",et[et.ALREADY_EXISTS=6]="ALREADY_EXISTS",et[et.PERMISSION_DENIED=7]="PERMISSION_DENIED",et[et.UNAUTHENTICATED=16]="UNAUTHENTICATED",et[et.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",et[et.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",et[et.ABORTED=10]="ABORTED",et[et.OUT_OF_RANGE=11]="OUT_OF_RANGE",et[et.UNIMPLEMENTED=12]="UNIMPLEMENTED",et[et.INTERNAL=13]="INTERNAL",et[et.UNAVAILABLE=14]="UNAVAILABLE",et[et.DATA_LOSS=15]="DATA_LOSS";/** 272 * @license 273 * Copyright 2017 Google LLC 274 * 275 * Licensed under the Apache License, Version 2.0 (the "License"); 276 * you may not use this file except in compliance with the License. 277 * You may obtain a copy of the License at 278 * 279 * http://www.apache.org/licenses/LICENSE-2.0 280 * 281 * Unless required by applicable law or agreed to in writing, software 282 * distributed under the License is distributed on an "AS IS" BASIS, 283 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 284 * See the License for the specific language governing permissions and 285 * limitations under the License. 286 */var es=function(){function t(t,e){this.comparator=t,this.root=e||ea.EMPTY}return t.prototype.insert=function(e,n){return new t(this.comparator,this.root.insert(e,n,this.comparator).copy(null,null,ea.BLACK,null,null))},t.prototype.remove=function(e){return new t(this.comparator,this.root.remove(e,this.comparator).copy(null,null,ea.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}
286,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 eu(this.root,null,this.comparator,!1)},t.prototype.getIteratorFrom=function(t){return new eu(this.root,t,this.comparator,!1)},t.prototype.getReverseIterator=function(){return new eu(this.root,null,this.comparator,!0)},t.prototype.getReverseIteratorFrom=function(t){return new eu(this.root,t,this.comparator,!0)},t}(),eu=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}(),ea=function(){function t(e,n,r,i,o){this.key=e,this.value=n,this.color=null!=r?r:t.RED,this.left=null!=i?i:t.EMPTY,this.right=null!=o?o:t.EMPTY,this.size=this.left.size+1+this.right.size}return t.prototype.copy=function(e,n,r,i,o){return new t(null!=e?e:this.key,null!=n?n:this.value,null!=r?r:this.color,null!=i?i:this.left,null!=o?o:this.right)},t.prototype.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(0>n(e,i.key))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(){return Math.pow(2,this.check())<=this.size+1},t.prototype.check=function(){if(this.isRed()&&this.left.isRed()||this.right.isRed())throw v();var t=this.left.check();if(t!==this.right.check())throw v();return t+(this.isRed()?0:1)},t}();
286ea.EMPTY=null,ea.RED=!0,ea.BLACK=!1,ea.EMPTY=new(function(){function t(){this.size=0}return Object.defineProperty(t.prototype,"key",{get:function(){throw v()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){throw v()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){throw v()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){throw v()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){throw v()},enumerable:!1,configurable:!0}),t.prototype.copy=function(t,e,n,r,i){return this},t.prototype.insert=function(t,e,n){return new ea(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}());/** 287 * @license 288 * Copyright 2017 Google LLC 289 * 290 * Licensed under the Apache License, Version 2.0 (the "License"); 291 * you may not use this file except in compliance with the License. 292 * You may obtain a copy of the License at 293 * 294 * http://www.apache.org/licenses/LICENSE-2.0 295 * 296 * Unless required by applicable law or agreed to in writing, software 297 * distributed under the License is distributed on an "AS IS" BASIS, 298 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 299 * See the License for the specific language governing permissions and 300 * limitations under the License. 301 */var ec=function(){function t(t){this.comparator=t,this.data=new es(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},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 eh(this.data.getIterator())},t.prototype.getIteratorFrom=function(t){return new eh(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)||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}(),eh=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}(),el=new es(G.comparator),ef=new es(G.comparator),ed=new es(G.comparator),ep=new ec(G.comparator);function ey(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=ep,r=0;r<t.length;r++){var i=t[r];n=n.add(i)}return n}var em=new ec(w),ev=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,eg.createSynthesizedTargetChangeForCurrentChange(e,n)),new t(T.min(),r,em,el,ey())},t}(),eg=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(C.EMPTY_BYTE_STRING,n,ey(),ey(),ey())},t}(),ew=function(t,e,n,r){this.v=t,this.removedTargetIds=e,this.key=n,this.P=r},eb=function(t,e){this.targetId=t,this.V=e},eI=function(t,e,n,r){void 0===n&&(n=C.EMPTY_BYTE_STRING),void 0===r&&(r=null),this.state=t,this.targetIds=e,this.resumeToken=n,this.cause=r},eT=function(){function t(){this.S=0,this.D=eS(),this.C=C.EMPTY_BYTE_STRING,this.N=!1,this.k=!0}return Object.defineProperty(t.prototype,"current",{get:function(){return this.N}
301,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=ey(),e=ey(),n=ey();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:v()}}),new eg(this.C,this.N,t,e,n)},t.prototype.L=function(){this.k=!1,this.D=eS()},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}(),eE=function(){function t(t){this.W=t,this.G=new Map,this.H=el,this.J=e_(),this.Y=new ec(w)}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:v()}})},t.prototype.forEachTarget=function(t,e){var n=this;t.targetIds.length>
3010?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(tu(i)){if(0===n){var o=new G(i.path);this.tt(e,o,tn.newNoDocument(o,T.min()))}else 1===n||v()}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&&tu(o.target)){var s=new G(o.target.path);null!==e.H.get(s)||e.at(i,s)||e.tt(i,s,tn.newNoDocument(s,t))}r.$&&(n.set(i,r.M()),r.L())}});var r=ey();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 ev(t,n,this.Y,this.H,r);return this.H=el,this.J=e_(),this.Y=new ec(w),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 eT,this.G.set(t,e)),e},t.prototype.ht=function(t){var e=this.J.get(t);return e||(e=new ec(w),this.J=this.J.insert(t,e)),e},t.prototype.st=function(t){var e=null!==this.ot(t);return e||d("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 eT),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 e_(){return new es(G.comparator)}function eS(){return new es(G.comparator)}/** 302 * @license 303 * Copyright 2017 Google LLC 304 * 305 * Licensed under the Apache License, Version 2.0 (the "License"); 306 * you may not use this file except in compliance with the License. 307 * You may obtain a copy of the License at 308 * 309 * http://www.apache.org/licenses/LICENSE-2.0 310 * 311 * Unless required by applicable law or agreed to in writing, software 312 * distributed under the License is distributed on an "AS IS" BASIS, 313 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 314 * See the License for the specific language governing permissions and 315 * limitations under the License. 316 */var eN={asc:"ASCENDING",desc:"DESCENDING"},eD={"<":"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"},eA=function(t,e){this.databaseId=t,this.I=e};function ek(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 ex(t,e){return t.I?e.toBase64():e.toUint8Array()}function eC(t){var e;return t||v(),T.fromTimestamp((e=L(t),new I(e.seconds,e.nanos)))}function eR(t,e){return new D(["projects",t.projectId,"databases",t.database]).child("documents").child(e).canonicalString()}function eL(t){var e=D.fromString(t);return eY(e)||v(),e}function eO(t,e){return eR(t.databaseId,e.path)}function eP(t,e){var n=eL(e);if(n.get(1)!==t.databaseId.projectId)throw new h(c.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 h(c.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+t.databaseId.database);return new G(eq(n))}function eF(t,e){return eR(t.databaseId,e)}function eM(t){var e=eL(t);return 4===e.length?D.emptyPath():eq(e)}function eV(t){return new D(["projects",t.databaseId.projectId,"databases",t.databaseId.database]).canonicalString()}function eq(t){return t.length>
3164&&"documents"===t.get(4)||v(),t.popFirst(5)}function eU(t,e,n){return{name:eO(t,e),fields:n.value.mapValue.fields}}function eG(t,e,n){var r=eP(t,e.name),i=eC(e.updateTime),o=new te({mapValue:{fields:e.fields}}),s=tn.newFoundDocument(r,i,o);return n&&s.setHasCommittedMutations(),n?s.setHasCommittedMutations():s}function eB(t,e){var n,r,i,o;if(e instanceof t3)n={update:eU(t,e.key,e.value)};else if(e instanceof ee)n={delete:eO(t,e.key)};else if(e instanceof t5)n={update:eU(t,e.key,e.data),updateMask:(i=e.fieldMask,o=[],i.fields.forEach(function(t){return o.push(t.canonicalString())}),{fieldPaths:o})};else{if(!(e instanceof en))return v();n={verify:eO(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 tB)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof tj)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof tQ)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof tJ)return{fieldPath:e.field.canonicalString(),increment:n.A};throw v()}(0,t)})),e.precondition.isNone||(n.currentDocument=void 0!==(r=e.precondition).updateTime?{updateTime:ek(t,r.updateTime.toTimestamp())}:void 0!==r.exists?{exists:r.exists}:v()),n}function ej(t,e){var n=e.currentDocument?void 0!==(s=e.currentDocument).updateTime?t$.updateTime(eC(s.updateTime)):void 0!==s.exists?t$.exists(s.exists):t$.none():t$.none(),r=e.updateTransforms?e.updateTransforms.map(function(e){return function(t,e){var n=null;if("setToServerValue"in e)"REQUEST_TIME"===e.setToServerValue||v(),n=new tB;else if("appendMissingElements"in e){var r=e.appendMissingElements.values||[];n=new tj(r)}else if("removeAllFromArray"in e){var i=e.removeAllFromArray.values||[];n=new tQ(i)}else"increment"in e?n=new tJ(t,e.increment):v();var o=k.fromServerFormat(e.fieldPath);return new tZ(o,n)}(t,e)}):[];if(e.update){e.update.name;var i=eP(t,e.update.name),o=new te({mapValue:{fields:e.update.fields}});if(e.updateMask){var s,u,a=(u=e.updateMask.fieldPaths||[],new x(u.map(function(t){return k.fromServerFormat(t)})));return new t5(i,o,a,n,r)}return new t3(i,o,n,r)}if(e.delete){var c=eP(t,e.delete);return new ee(c,n)}if(e.verify){var h=eP(t,e.verify);return new en(h,n)}return v()}function eK(t,e){return{documents:[eF(t,e.path)]}}function eQ(t,e){var n,r={structuredQuery:{}},i=e.path;null!==e.collectionGroup?(r.parent=eF(t,i),r.structuredQuery.from=[{collectionId:e.collectionGroup,allDescendants:!0}]):(r.parent=eF(t,i.popLast()),r.structuredQuery.from=[{collectionId:i.lastSegment()}]);var o=function(t){if(0!==t.length){var e=t.map(function(t){return function(t){if("=="===t.op){if($(t.value))return{unaryFilter:{field:eH(t.field),op:"IS_NAN"}};if(Y(t.value))return{unaryFilter:{field:eH(t.field),op:"IS_NULL"}}}else if("!="===t.op){if($(t.value))return{unaryFilter:{field:eH(t.field),op:"IS_NOT_NAN"}};if(Y(t.value))return{unaryFilter:{field:eH(t.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:eH(t.field),op:eD[t.op],value:t.value}}}(t)});return 1===e.length?e[0]:{compositeFilter:{op:"AND",filters:e}}}}(e.filters);o&&(r.structuredQuery.where=o);var s=function(t){if(0!==t.length)return t.map(function(t){return{field:eH(t.field),direction:eN[t.dir]}})}(e.orderBy);s&&(r.structuredQuery.orderBy=s);var u=(n=e.limit,t.I||V(n)?n:{value:n});return null!==u&&(r.structuredQuery.limit=u),e.startAt&&(r.structuredQuery.startAt=eJ(e.startAt)),e.endAt&&(r.structuredQuery.endAt=eJ(e.endAt)),r}function ez(t){var e,n,r,i,o,s,u,a,c,h=eM(t.parent),l=t.structuredQuery,f=l.from?l.from.length:0,d=null;if(f>0){1===f||v();var p=l.from[0];p.allDescendants?d=p.collectionId:h=h.child(p.collectionId)}var y=[];l.where&&(y=function t(e){return e?void 0!==e.unaryFilter?[function(t){switch(t.unaryFilter.op){case"IS_NAN":var e=eZ(t.unaryFilter.field);return ta.create(e,"==",{doubleValue:NaN});case"IS_NULL":var n=eZ(t.unaryFilter.field);return ta.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":var r=eZ(t.unaryFilter.field);return ta.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":var i=eZ(t.unaryFilter.field);return ta.create(i,"!=",{nullValue:"NULL_VALUE"});default:return v()}}
316(e)]:void 0!==e.fieldFilter?[ta.create(eZ(e.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 v()}}(e.fieldFilter.op),e.fieldFilter.value)]:void 0!==e.compositeFilter?e.compositeFilter.filters.map(function(e){return t(e)}).reduce(function(t,e){return t.concat(e)}):v():[]}(l.where));var m=[];l.orderBy&&(m=l.orderBy.map(function(t){return new tw(eZ(t.field),function(t){switch(t){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(t.direction))}));var g=null;l.limit&&(g=V(n="object"==typeof(e=l.limit)?e.value:e)?null:n);var w=null;l.startAt&&(w=eW(l.startAt));var b=null;return l.endAt&&(b=eW(l.endAt)),r=h,i=d,o=m,s=y,u=g,a=w,c=b,new tT(r,i,o,s,u,"F",a,c)}function eJ(t){return{before:t.before,values:t.position}}function eW(t){var e=!!t.before,n=t.values||[];return new tv(n,e)}function eH(t){return{fieldPath:t.canonicalString()}}function eZ(t){return k.fromServerFormat(t.fieldPath)}function eY(t){return t.length>=4&&"projects"===t.get(0)&&"databases"===t.get(2)}/** 317 * @license 318 * Copyright 2017 Google LLC 319 * 320 * Licensed under the Apache License, Version 2.0 (the "License"); 321 * you may not use this file except in compliance with the License. 322 * You may obtain a copy of the License at 323 * 324 * http://www.apache.org/licenses/LICENSE-2.0 325 * 326 * Unless required by applicable law or agreed to in writing, software 327 * distributed under the License is distributed on an "AS IS" BASIS, 328 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 329 * See the License for the specific language governing permissions and 330 * limitations under the License. 331 */function e$(t){for(var e,n,r="",i=0;i<t.length;i++)r.length>0&&(r+="\x01\x01"),r=function(t,e){for(var n=e,r=t.length,i=0;i<r;i++){var o=t.charAt(i);switch(o){case"\x00":n+="\x01\x10";break;case"\x01":n+="\x01\x11";break;default:n+=o}}return n}(t.get(i),r);return r+"\x01\x01"}function eX(t){var e=t.length;if(e>=2||v(),2===e)return"\x01"===t.charAt(0)&&"\x01"===t.charAt(1)||v(),D.emptyPath();for(var n=e-2,r=[],i="",o=0;o<e;){var s=t.indexOf("\x01",o);switch((s<0||s>n)&&v(),t.charAt(s+1)){case"\x01":var u=t.substring(o,s),a=void 0;0===i.length?a=u:(a=i+=u,i=""),r.push(a);break;case"\x10":i+=t.substring(o,s)+"\x00";break;case"\x11":i+=t.substring(o,s+1);break;default:v()}o=s+2}return new D(r)}/** 332 * @license 333 * Copyright 2017 Google LLC 334 * 335 * Licensed under the Apache License, Version 2.0 (the "License"); 336 * you may not use this file except in compliance with the License. 337 * You may obtain a copy of the License at 338 * 339 * http://www.apache.org/licenses/LICENSE-2.0 340 * 341 * Unless required by applicable law or agreed to in writing, software 342 * distributed under the License is distributed on an "AS IS" BASIS, 343 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 344 * See the License for the specific language governing permissions and 345 * limitations under the License. 346 */var e0=function(t,e){this.seconds=t,this.nanoseconds=e},e1=function(t,e,n){this.ownerId=t,this.allowTabSynchronization=e,this.leaseTimestampMs=n};e1.store="owner",e1.key="owner";var e2=function(t,e,n){this.userId=t,this.lastAcknowledgedBatchId=e,this.lastStreamToken=n};e2.store="mutationQueues",e2.keyPath="userId";var e4=function(t,e,n,r,i){this.userId=t,this.batchId=e,this.localWriteTimeMs=n,this.baseMutations=r,this.mutations=i};e4.store="mutations",e4.keyPath="batchId",e4.userMutationsIndex="userMutationsIndex",e4.userMutationsKeyPath=["userId","batchId"];var e3=function(){function t(){}return t.prefixForUser=function(t){return[t]},t.prefixForPath=function(t,e){return[t,e$(e)]},t.key=function(t,e,n){return[t,e$(e),n]},t}();e3.store="documentMutations",e3.PLACEHOLDER=new e3;var e5=function(t,e){this.path=t,this.readTime=e},e6=function(t,e){this.path=t,this.version=e},e8=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};e8.store="remoteDocuments",e8.readTimeIndex="readTimeIndex",e8.readTimeIndexPath="readTime",e8.collectionReadTimeIndex="collectionReadTimeIndex",e8.collectionReadTimeIndexPath=["parentPath","readTime"];var e9=function(t){this.byteSize=t};e9.store="remoteDocumentGlobal",e9.key="remoteDocumentGlobalKey";var e7=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};e7.store="targets",e7.keyPath="targetId",e7.queryTargetsIndexName="queryTargetsIndex",e7.queryTargetsKeyPath=["canonicalId","targetId"];var nt=function(t,e,n){this.targetId=t,this.path=e,this.sequenceNumber=n};nt.store="targetDocuments",nt.keyPath=["targetId","path"],nt.documentTargetsIndex="documentTargetsIndex",nt.documentTargetsKeyPath=["path","targetId"];var ne=function(t,e,n,r){this.highestTargetId=t,this.highestListenSequenceNumber=e,this.lastRemoteSnapshotVersion=n,this.targetCount=r};ne.key="targetGlobalKey",ne.store="targetGlobal";var nn=function(t,e){this.collectionId=t,this.parent=e};nn.store="collectionParents",nn.keyPath=["collectionId","parent"];var nr=function(t,e,n,r){this.clientId=t,this.updateTimeMs=e,this.networkEnabled=n,this.inForeground=r};nr.store="clientMetadata",nr.keyPath="clientId";var ni=function(t,e,n){this.bundleId=t,this.createTime=e,this.version=n};ni.store="bundles",ni.keyPath="bundleId";var no=function(t,e,n){this.name=t,this.readTime=e,this.bundledQuery=n};no.store="namedQueries",no.keyPath="name";var ns=(0,r.ev)((0,r.ev)([],(0,r.ev)((0,r.ev)([],(0,r.ev)((0,r.ev)([],(0,r.ev)((0,r.ev)([],[e2.store,e4.store,e3.store,e8.store,e7.store,e1.store,
346ne.store,nt.store]),[nr.store])),[e9.store])),[nn.store])),[ni.store,no.store]),nu="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.",na=function(){function t(){this.onCommittedListeners=[]}return t.prototype.addOnCommittedListener=function(t){this.onCommittedListeners.push(t)},t.prototype.raiseOnCommittedEvent=function(){this.onCommittedListeners.forEach(function(t){return t()})},t}(),nc=function(){var t=this;this.promise=new Promise(function(e,n){t.resolve=e,t.reject=n})},nh=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&&v(),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;i<e.length;i++)r(e[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}(),nl=function(){function t(t,e){var n=this;this.action=t,this.transaction=e,this.aborted=!1,this.ft=new nc,this.transaction.oncomplete=function(){n.ft.resolve()},this.transaction.onabort=function(){e.error?n.ft.reject(new np(t,e.error)):n.ft.resolve()},this.transaction.onerror=function(e){var r=nw(e.target.error);n.ft.reject(new np(t,r))}}return t.open=function(e,n,r,i){try{return new t(n,e.transaction(i,r))}catch(t){throw new np(n,t)}},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||(d("SimpleDb","Aborting transaction:",t?t.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())},t.prototype.store=function(t){var e=this.transaction.objectStore(t);return new nm(e)},t}(),nf=function(){function t(e,n,r){this.name=e,this.version=n,this.wt=r,12.2===t._t((0,i.z$)())&&p("Firestore persistence suffers from a bug in iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}return t.delete=function(t){return d("SimpleDb","Removing database:",t),nv(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=t.Et(e);return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||0<n&&n<10||0<r&&r<4.5)},t.gt=function(){var t;return void 0!==u&&"YES"===(null===(t=u.env)||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);return Number(e?e[1].split("_").slice(0,2).join("."):"-1")},t.Et=function(t){var e=t.match(/Android ([\d.]+)/i);return Number(e?e[1].split(".").slice(0,2).join("."):"-1")},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]:(d("SimpleDb","Opening database:",this.name),e=this,[4,new Promise(function(e,r){var i=indexedDB.open(n.name,n.version);i.onsuccess=function(t){e(t.target.result)},i.onblocked=function(){r(new np(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 h(c.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 np(t,n))},i.onupgradeneeded=function(t){d("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(){d("SimpleDb","Database upgrade to version "+n.version+" complete")}
346)}})]);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,l;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(),u=i(e=nl.open(a.db,t,o?"readonly":"readwrite",n)).catch(function(t){return e.abort(t),nh.reject(t)}).toPromise(),c={},u.catch(function(){}),[4,e.dt];case 3:return[2,(c.value=(r.sent(),u),c)];case 4:return l="FirebaseError"!==(h=r.sent()).name&&s<3,d("SimpleDb","Transaction failed with error:",h.message,"Retrying:",l),a.close(),l?[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]}})})},t.prototype.close=function(){this.db&&this.db.close(),this.db=void 0},t}(),nd=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 nv(this.Pt.delete())},t}(),np=function(t){function e(e,n){var r=this;return(r=t.call(this,c.UNAVAILABLE,"IndexedDB transaction '"+e+"' failed: "+n)||this).name="IndexedDbTransactionError",r}return(0,r.ZT)(e,t),e}(h);function ny(t){return"IndexedDbTransactionError"===t.name}var nm=function(){function t(t){this.store=t}return t.prototype.put=function(t,e){var n;return void 0!==e?(d("SimpleDb","PUT",this.store.name,t,e),n=this.store.put(e,t)):(d("SimpleDb","PUT",this.store.name,"<auto-key>",t),n=this.store.put(t)),nv(n)},t.prototype.add=function(t){return d("SimpleDb","ADD",this.store.name,t,t),nv(this.store.add(t))},t.prototype.get=function(t){var e=this;return nv(this.store.get(t)).next(function(n){return void 0===n&&(n=null),d("SimpleDb","GET",e.store.name,t,n),n})},t.prototype.delete=function(t){return d("SimpleDb","DELETE",this.store.name,t),nv(this.store.delete(t))},t.prototype.count=function(){return d("SimpleDb","COUNT",this.store.name),nv(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){d("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){e?n=t:(n={},e=t);var n,r=this.cursor(n);return this.xt(r,e)},t.prototype.Ot=function(t){var e=this.cursor({});return new nh(function(n,r){e.onerror=function(t){r(nw(t.target.error))},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 nh(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 nd(i),s=e(i.primaryKey,i.value,o);if(s instanceof nh){var u=s.catch(function(t){return o.done(),nh.reject(t)});n.push(u)}o.isDone?r():null===o.Dt?i.continue():i.continue(o.Dt)}else r()}}).next(function(){return nh.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 nv(t){return new nh(function(e,n){t.onsuccess=function(t){e(t.target.result)},t.onerror=function(t){n(nw(t.target.error))}})}var ng=!1;function nw(t){var e=nf._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 h("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 ng||(ng=!0,setTimeout(function(){throw r},0)),r}}return t}/** 347 * @license 348 * Copyright 2020 Google LLC 349 * 350 * Licensed under the Apache License, Version 2.0 (the "License");
351 * you may not use this file except in compliance with the License. 352 * You may obtain a copy of the License at 353 * 354 * http://www.apache.org/licenses/LICENSE-2.0 355 * 356 * Unless required by applicable law or agreed to in writing, software 357 * distributed under the License is distributed on an "AS IS" BASIS, 358 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 359 * See the License for the specific language governing permissions and 360 * limitations under the License. 361 */var nb=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}(na);function nI(t,e){return nf.It(t.Mt,e)}/** 362 * @license 363 * Copyright 2017 Google LLC 364 * 365 * Licensed under the Apache License, Version 2.0 (the "License"); 366 * you may not use this file except in compliance with the License. 367 * You may obtain a copy of the License at 368 * 369 * http://www.apache.org/licenses/LICENSE-2.0 370 * 371 * Unless required by applicable law or agreed to in writing, software 372 * distributed under the License is distributed on an "AS IS" BASIS, 373 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 374 * See the License for the specific language governing permissions and 375 * limitations under the License. 376 */var nT=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)&&function(t,e,n){var r,i;t instanceof t3?(r=t.value.clone(),i=t8(t.fieldTransforms,e,n.transformResults),r.setAll(i),e.convertToFoundDocument(n.version,r).setHasCommittedMutations()):t instanceof t5?function(t,e,n){if(tX(t.precondition,e)){var r=t8(t.fieldTransforms,e,n.transformResults),i=e.data;i.setAll(t6(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)}(i,t,n[r])}},t.prototype.applyToLocalView=function(t){for(var e,n=0,r=this.baseMutations;n<r.length;n++)(e=r[n]).key.isEqual(t.key)&&t1(e,t,this.localWriteTime);for(var i=0,o=this.mutations;i<o.length;i++)(e=o[i]).key.isEqual(t.key)&&t1(e,t,this.localWriteTime)},t.prototype.applyToLocalDocumentSet=function(t){var e=this;this.mutations.forEach(function(n){var r=t.get(n.key);e.applyToLocalView(r),r.isValidDocument()||r.convertToNoDocument(T.min())})},t.prototype.keys=function(){return this.mutations.reduce(function(t,e){return t.add(e.key)},ey())},t.prototype.isEqual=function(t){return this.batchId===t.batchId&&b(this.mutations,t.mutations,function(t,e){return t2(t,e)})&&b(this.baseMutations,t.baseMutations,function(t,e){return t2(t,e)})},t}(),nE=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){e.mutations.length===r.length||v();for(var i=ed,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}(),n_=function(){function t(t,e,n,r,i,o,s){void 0===i&&(i=T.min()),void 0===o&&(o=T.min()),void 0===s&&(s=C.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}(),nS=function(t){this.Lt=t};function nN(t,e){if(e.document)return eG(t.Lt,e.document,!!e.hasCommittedMutations);if(e.noDocument){var n=G.fromSegments(e.noDocument.path),r=nC(e.noDocument.readTime),i=tn.newNoDocument(n,r);return e.hasCommittedMutations?i.setHasCommittedMutations():i}if(e.unknownDocument){var o=G.fromSegments(e.unknownDocument.path);return r=nC(e.unknownDocument.version),tn.newUnknownDocument(o,r)}return v()}function nD(t,e,n){var r=nA(n),i=e.key.path.popLast().toArray();if(e.isFoundDocument()){var o,s={name:eO(o=t.Lt,e.key),fields:e.data.value.mapValue.fields,updateTime:ek(o,e.ver
376sion.toTimestamp())},u=e.hasCommittedMutations;return new e8(null,null,s,u,r,i)}if(e.isNoDocument()){var a=e.key.path.toArray(),c=nx(e.version);return u=e.hasCommittedMutations,new e8(null,new e5(a,c),null,u,r,i)}if(e.isUnknownDocument()){var h=e.key.path.toArray(),l=nx(e.version);return new e8(new e6(h,l),null,null,!0,r,i)}return v()}function nA(t){var e=t.toTimestamp();return[e.seconds,e.nanoseconds]}function nk(t){var e=new I(t[0],t[1]);return T.fromTimestamp(e)}function nx(t){var e=t.toTimestamp();return new e0(e.seconds,e.nanoseconds)}function nC(t){var e=new I(t.seconds,t.nanoseconds);return T.fromTimestamp(e)}function nR(t,e){for(var n=(e.baseMutations||[]).map(function(e){return ej(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 ej(t.Lt,e)}),u=I.fromMillis(e.localWriteTimeMs);return new nT(e.batchId,u,n,s)}function nL(t){var e,n,r=nC(t.readTime),i=void 0!==t.lastLimboFreeSnapshotVersion?nC(t.lastLimboFreeSnapshotVersion):T.min();return void 0!==t.query.documents?(1===(n=t.query).documents.length||v(),e=tx(tE(eM(n.documents[0])))):e=tx(ez(t.query)),new n_(e,t.targetId,0,t.lastListenSequenceNumber,r,i,C.fromBase64String(t.resumeToken))}function nO(t,e){var n,r=nx(e.snapshotVersion),i=nx(e.lastLimboFreeSnapshotVersion);n=tu(e.target)?eK(t.Lt,e.target):eQ(t.Lt,e.target);var o=e.resumeToken.toBase64();return new e7(e.targetId,to(e.target),r,o,e.sequenceNumber,i,n)}function nP(t){var e=ez({parent:t.parent,structuredQuery:t.structuredQuery});return"LAST"===t.limitType?tC(e,e.limit,"L"):e}/** 377 * @license 378 * Copyright 2020 Google LLC 379 * 380 * Licensed under the Apache License, Version 2.0 (the "License"); 381 * you may not use this file except in compliance with the License. 382 * You may obtain a copy of the License at 383 * 384 * http://www.apache.org/licenses/LICENSE-2.0 385 * 386 * Unless required by applicable law or agreed to in writing, software 387 * distributed under the License is distributed on an "AS IS" BASIS, 388 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 389 * See the License for the specific language governing permissions and 390 * limitations under the License. 391 */var nF=function(){function t(){}return t.prototype.getBundleMetadata=function(t,e){return nM(t).get(e).next(function(t){if(t)return{id:t.bundleId,createTime:nC(t.createTime),version:t.version}})},t.prototype.saveBundleMetadata=function(t,e){return nM(t).put({bundleId:e.id,createTime:nx(eC(e.createTime)),version:e.version})},t.prototype.getNamedQuery=function(t,e){return nV(t).get(e).next(function(t){if(t)return{name:t.name,query:nP(t.bundledQuery),readTime:nC(t.readTime)}})},t.prototype.saveNamedQuery=function(t,e){return nV(t).put({name:e.name,readTime:nx(eC(e.readTime)),bundledQuery:e.bundledQuery})},t}();function nM(t){return nI(t,ni.store)}function nV(t){return nI(t,no.store)}/** 392 * @license 393 * Copyright 2019 Google LLC 394 * 395 * Licensed under the Apache License, Version 2.0 (the "License"); 396 * you may not use this file except in compliance with the License. 397 * You may obtain a copy of the License at 398 * 399 * http://www.apache.org/licenses/LICENSE-2.0 400 * 401 * Unless required by applicable law or agreed to in writing, software 402 * distributed under the License is distributed on an "AS IS" BASIS, 403 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 404 * See the License for the specific language governing permissions and 405 * limitations under the License. 406 */var nq=function(){function t(){this.Bt=new nU}return t.prototype.addToCollectionParentIndex=function(t,e){return this.Bt.add(e),nh.resolve()},t.prototype.getCollectionParents=function(t,e){return nh.resolve(this.Bt.getEntries(e))},t}(),nU=function(){function t(){this.index={}}return t.prototype.add=function(t){var e=t.lastSegment(),n=t.popLast(),r=this.index[e]||new ec(D.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 ec(D.c
406omparator)).toArray()},t}(),nG=function(){function t(){this.qt=new nU}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:e$(i)};return nB(t).put(o)}return nh.resolve()},t.prototype.getCollectionParents=function(t,e){var n=[],r=IDBKeyRange.bound([e,""],[e+"\x00",""],!1,!0);return nB(t).Nt(r).next(function(t){for(var r=0;r<t.length;r++){var i=t[r];if(i.collectionId!==e)break;n.push(eX(i.parent))}return n})},t}();function nB(t){return nI(t,nn.store)}/** 407 * @license 408 * Copyright 2018 Google LLC 409 * 410 * Licensed under the Apache License, Version 2.0 (the "License"); 411 * you may not use this file except in compliance with the License. 412 * You may obtain a copy of the License at 413 * 414 * http://www.apache.org/licenses/LICENSE-2.0 415 * 416 * Unless required by applicable law or agreed to in writing, software 417 * distributed under the License is distributed on an "AS IS" BASIS, 418 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 419 * See the License for the specific language governing permissions and 420 * limitations under the License. 421 */var nj={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},nK=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}();/** 422 * @license 423 * Copyright 2020 Google LLC 424 * 425 * Licensed under the Apache License, Version 2.0 (the "License"); 426 * you may not use this file except in compliance with the License. 427 * You may obtain a copy of the License at 428 * 429 * http://www.apache.org/licenses/LICENSE-2.0 430 * 431 * Unless required by applicable law or agreed to in writing, software 432 * distributed under the License is distributed on an "AS IS" BASIS, 433 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 434 * See the License for the specific language governing permissions and 435 * limitations under the License. 436 */function nQ(t,e,n){var r=t.store(e4.store),i=t.store(e3.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(){1===u||v()}));for(var c=[],h=0,l=n.mutations;h<l.length;h++){var f=l[h],d=e3.key(e,f.key.path,n.batchId);o.push(i.delete(d)),c.push(f.key)}return nh.waitFor(o).next(function(){return c})}function nz(t){var e;if(!t)return 0;if(t.document)e=t.document;else if(t.unknownDocument)e=t.unknownDocument;else{if(!t.noDocument)throw v();e=t.noDocument}return JSON.stringify(e).length}/** 437 * @license 438 * Copyright 2017 Google LLC 439 * 440 * Licensed under the Apache License, Version 2.0 (the "License"); 441 * you may not use this file except in compliance with the License. 442 * You may obtain a copy of the License at 443 * 444 * http://www.apache.org/licenses/LICENSE-2.0 445 * 446 * Unless required by applicable law or agreed to in writing, software 447 * distributed under the License is distributed on an "AS IS" BASIS, 448 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 449 * See the License for the specific language governing permissions and 450 * limitations under the License. 451 */nK.DEFAULT_COLLECTION_PERCENTILE=10,nK.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,nK.DEFAULT=new nK(41943040,nK.DEFAULT_COLLECTION_PERCENTILE,nK.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),nK.DISABLED=new nK(-1,0,0);var nJ=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""!==e.uid||v(),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 nH(t).$t({index:e4.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=nZ(t),s=nH(t);return s.add({}).next(function(u){"number"==typeof u||v();for(var a,c,h,l,f=new nT(u,e,n,r),d=(a=i.R,c=i.userId,h=f.baseMutations.map(function(t){return eB(a.Lt,t)}),l=f.mutations.map(function(t){return eB(a.Lt,t)}),new e4(c,f.batchId,f.localWriteTime.toMillis(),h,l)),p=[],y=new ec(function(t,e){return w(t.canonicalString(),e.canonicalString())}),m=0;m<r.length;m++){var g=r[m],b=e3.key(i.userId,g.key.path,u);y=y.add(g.key.path.popLast()),p.push(s.put(d)),p.push(o.put(b,e3.PLACEHOLDER))}
451return y.forEach(function(e){p.push(i.Ut.addToCollectionParentIndex(t,e))}),t.addOnCommittedListener(function(){i.Kt[u]=f.keys()}),nh.waitFor(p).next(function(){return f})})},t.prototype.lookupMutationBatch=function(t,e){var n=this;return nH(t).get(e).next(function(t){return t?(t.userId===n.userId||v(),nR(n.R,t)):null})},t.prototype.jt=function(t,e){var n=this;return this.Kt[e]?nh.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 nH(t).$t({index:e4.userMutationsIndex,range:i},function(t,e,i){e.userId===n.userId&&(e.batchId>=r||v(),o=nR(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 nH(t).$t({index:e4.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 nH(t).Nt(e4.userMutationsIndex,n).next(function(t){return t.map(function(t){return nR(e.R,t)})})},t.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,e){var n=this,r=e3.prefixForPath(this.userId,e.path),i=IDBKeyRange.lowerBound(r),o=[];return nZ(t).$t({range:i},function(r,i,s){var u=r[0],a=r[1],c=r[2],h=eX(a);if(u===n.userId&&e.path.isEqual(h))return nH(t).get(c).next(function(t){if(!t)throw v();t.userId===n.userId||v(),o.push(nR(n.R,t))});s.done()}).next(function(){return o})},t.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var n=this,r=new ec(w),i=[];return e.forEach(function(e){var o=e3.prefixForPath(n.userId,e.path),s=IDBKeyRange.lowerBound(o),u=nZ(t).$t({range:s},function(t,i,o){var s=t[0],u=t[1],a=t[2],c=eX(u);s===n.userId&&e.path.isEqual(c)?r=r.add(a):o.done()});i.push(u)}),nh.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=e3.prefixForPath(this.userId,r),s=IDBKeyRange.lowerBound(o),u=new ec(w);return nZ(t).$t({range:s},function(t,e,o){var s=t[0],a=t[1],c=t[2],h=eX(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(nH(t).get(e).next(function(t){if(null===t)throw v();t.userId===n.userId||v(),r.push(nR(n.R,t))}))}),nh.waitFor(i).next(function(){return r})},t.prototype.removeMutationBatch=function(t,e){var n=this;return nQ(t.Mt,this.userId,e).next(function(r){return t.addOnCommittedListener(function(){n.Gt(e.batchId)}
451),nh.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 nh.resolve();var r=IDBKeyRange.lowerBound(e3.prefixForUser(e.userId)),i=[];return nZ(t).$t({range:r},function(t,n,r){if(t[0]===e.userId){var o=eX(t[1]);i.push(o)}else r.done()}).next(function(){0===i.length||v()})})},t.prototype.containsKey=function(t,e){return nW(t,this.userId,e)},t.prototype.zt=function(t){var e=this;return nY(t).get(this.userId).next(function(t){return t||new e2(e.userId,-1,"")})},t}();function nW(t,e,n){var r=e3.prefixForPath(e,n.path),i=r[1],o=IDBKeyRange.lowerBound(r),s=!1;return nZ(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 nH(t){return nI(t,e4.store)}function nZ(t){return nI(t,e3.store)}function nY(t){return nI(t,e2.store)}/** 452 * @license 453 * Copyright 2017 Google LLC 454 * 455 * Licensed under the Apache License, Version 2.0 (the "License"); 456 * you may not use this file except in compliance with the License. 457 * You may obtain a copy of the License at 458 * 459 * http://www.apache.org/licenses/LICENSE-2.0 460 * 461 * Unless required by applicable law or agreed to in writing, software 462 * distributed under the License is distributed on an "AS IS" BASIS, 463 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 464 * See the License for the specific language governing permissions and 465 * limitations under the License. 466 */var n$=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}(),nX=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 n$(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 T.fromTimestamp(new I(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 n0(t).delete(e.targetId)}).next(function(){return n.Xt(t)}).next(function(e){return e.targetCount>0||v(),e.targetCount-=1,n.Zt(t,e)})},t.prototype.removeTargets=function(t,e,n){var r=this,i=0,o=[];return n0(t).$t(function(s,u){var a=nL(u);a.sequenceNumber<=e&&null===n.get(a.targetId)&&(i++,o.push(r.removeTargetData(t,a)))}).next(function(){return nh.waitFor(o)}).next(function(){return i})},t.prototype.forEachTarget=function(t,e){return n0(t).$t(function(t,n){e(nL(n))})},t.prototype.Xt=function(t){return n1(t).get(ne.key).next(function(t){return null!==t||v(),t})},t.prototype.Zt=function(t,e){return n1(t).put(ne.key,e)},t.prototype.te=function(t,e){return n0(t).put(nO(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=to(e),r=IDBKeyRange.bound([n,Number.NEGATIVE_INFINITY],[n,Number.POSITIVE_INFINITY]),i=null;return n0(t).$t({range:r,index:e7.queryTargetsIndexName},function(t,n,r){var o=nL(n);ts(e,o.target)&&(i=o,r.done())}).next(function(){return i})},t.prototype.addMatchingKeys=function(t,e,n){var r=this,i=[],o=n2(t);return e.forEach(function(e){var s=e$(e.path);i.push(o.put(new nt(n,s))),i.push(r.referenceDelegate.addReference(t,n,e))}),nh.waitFor(i)},t.prototype.removeMatchingKeys=function(t,e,n){var r=this,i=n2(t);
466return nh.forEach(e,function(e){var o=e$(e.path);return nh.waitFor([i.delete([n,o]),r.referenceDelegate.removeReference(t,n,e)])})},t.prototype.removeMatchingKeysForTargetId=function(t,e){var n=n2(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=n2(t),i=ey();return r.$t({range:n,Ft:!0},function(t,e,n){var r=eX(t[1]),o=new G(r);i=i.add(o)}).next(function(){return i})},t.prototype.containsKey=function(t,e){var n=e$(e.path),r=IDBKeyRange.bound([n],[n+"\x00"],!1,!0),i=0;return n2(t).$t({index:nt.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 n0(t).get(e).next(function(t){return t?nL(t):null})},t}();/** 467 * @license 468 * Copyright 2017 Google LLC 469 * 470 * Licensed under the Apache License, Version 2.0 (the "License"); 471 * you may not use this file except in compliance with the License. 472 * You may obtain a copy of the License at 473 * 474 * http://www.apache.org/licenses/LICENSE-2.0 475 * 476 * Unless required by applicable law or agreed to in writing, software 477 * distributed under the License is distributed on an "AS IS" BASIS, 478 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 479 * See the License for the specific language governing permissions and 480 * limitations under the License. 481 */function n0(t){return nI(t,e7.store)}function n1(t){return nI(t,ne.store)}function n2(t){return nI(t,nt.store)}/** 482 * @license 483 * Copyright 2017 Google LLC 484 * 485 * Licensed under the Apache License, Version 2.0 (the "License"); 486 * you may not use this file except in compliance with the License. 487 * You may obtain a copy of the License at 488 * 489 * http://www.apache.org/licenses/LICENSE-2.0 490 * 491 * Unless required by applicable law or agreed to in writing, software 492 * distributed under the License is distributed on an "AS IS" BASIS, 493 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 494 * See the License for the specific language governing permissions and 495 * limitations under the License. 496 */function n4(t){return(0,r.mG)(this,void 0,void 0,function(){return(0,r.Jh)(this,function(e){if(t.code!==c.FAILED_PRECONDITION||t.message!==nu)throw t;return d("LocalStore","Unexpectedly lost primary lease"),[2]})})}/** 497 * @license 498 * Copyright 2020 Google LLC 499 * 500 * Licensed under the Apache License, Version 2.0 (the "License"); 501 * you may not use this file except in compliance with the License. 502 * You may obtain a copy of the License at 503 * 504 * http://www.apache.org/licenses/LICENSE-2.0 505 * 506 * Unless required by applicable law or agreed to in writing, software 507 * distributed under the License is distributed on an "AS IS" BASIS, 508 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 509 * See the License for the specific language governing permissions and 510 * limitations under the License. 511 */function n3(t,e){var n=t[0],r=t[1],i=e[0],o=e[1],s=w(n,i);return 0===s?w(r,o):s}var n5=function(){function t(t){this.ne=t,this.buffer=new ec(n3),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();0>n3(e,n)&&(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}(),n6=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;d("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;
511case 1:return n.trys.push([1,3,,7]),[4,t.collectGarbage(this.garbageCollector)];case 2:return n.sent(),[3,7];case 3:return ny(e=n.sent())?(d("LruGarbageCollector","Ignoring IndexedDB error during garbage collection: ",e),[3,6]):[3,4];case 4:return[4,n4(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}(),n8=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 nh.resolve(a.o);var r=new n5(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)})}).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?(d("LruGarbageCollector","Garbage collection skipped; disabled"),nh.resolve(nj)):this.getCacheSize(t).next(function(r){return r<n.params.cacheSizeCollectionThreshold?(d("LruGarbageCollector","Garbage collection skipped; Cache size "+r+" is lower than threshold "+n.params.cacheSizeCollectionThreshold),nj):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,l=Date.now();return this.calculateTargetCount(t,this.params.percentileToCollect).next(function(e){return e>h.params.maximumSequenceNumbersToCollect?(d("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&&d("LruGarbageCollector","LRU Garbage Collection\n Counted targets in "+(s-l)+"ms\n Determined least recently used "+r+" in "+(u-s)+"ms\n Removed "+i+" targets in "+(a-u)+"ms\n Removed "+t+" documents in "+(c-a)+"ms\nTotal Duration: "+(c-l)+"ms"),nh.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:t})})},t}(),n9=function(){function t(t,e){this.db=t,this.garbageCollector=new n8(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 n7(t,n)},t.prototype.removeReference=function(t,e,n){return n7(t,n)},t.prototype.removeTargets=function(t,e,n){return this.db.getTargetCache().removeTargets(t,e,n)},t.prototype.markPotentiallyOrphaned=function(t,e){return n7(t,e)},t.prototype._e=function(t,e){var n;return n=!1,nY(t).Ot(function(r){return nW(t,r,e).next(function(t){return t&&(n=!0),nh.resolve(!t)})}).next(function(){return n})},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),n2(t).delete([0,e$(s.path)])})});i.push(a)}}).next(function(){return nh.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 n7(t,e)},t.prototype.we=function(t,e){var n,r=n2(t),i=a.o;return r.$t({index:nt.documentTargetsIndex},function(t,r){var o=t[0];t[1];var s=r.path,u=r.sequenceNumber;0===o?(i!==a.o&&e(new G(eX(n)),i),i=u,n=s):i=a.o}).next(function(){i!==a.o&&e(new G(eX(n)),i)})},t.prototype.getCacheSize=function(t){return this.db.getRemoteDocumentCache().getSize(t)}
511,t}();function n7(t,e){var n;return n2(t).put((n=t.currentSequenceNumber,new nt(0,e$(e.path),n)))}/** 512 * @license 513 * Copyright 2017 Google LLC 514 * 515 * Licensed under the Apache License, Version 2.0 (the "License"); 516 * you may not use this file except in compliance with the License. 517 * You may obtain a copy of the License at 518 * 519 * http://www.apache.org/licenses/LICENSE-2.0 520 * 521 * Unless required by applicable law or agreed to in writing, software 522 * distributed under the License is distributed on an "AS IS" BASIS, 523 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 524 * See the License for the specific language governing permissions and 525 * limitations under the License. 526 */var rt=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;r<n.length;r++){var i=n[r],o=i[0],s=i[1];if(this.equalsFn(o,t))return s}},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){_(this.inner,function(e,n){for(var r=0;r<n.length;r++){var i=n[r];t(i[0],i[1])}})},t.prototype.isEmpty=function(){return S(this.inner)},t}(),re=function(){function t(){this.changes=new rt(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:T.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:tn.newInvalidDocument(t),readTime:e})},t.prototype.getEntry=function(t,e){this.assertNotApplied();var n=this.changes.get(e);return void 0!==n?nh.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}(),rn=function(){function t(t,e){this.R=t,this.Ut=e}return t.prototype.addEntry=function(t,e,n){return ro(t).put(rs(e),n)},t.prototype.removeEntry=function(t,e){var n=ro(t),r=rs(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 ro(t).get(rs(e)).next(function(t){return n.ye(e,t)})},t.prototype.ge=function(t,e){var n=this;return ro(t).get(rs(e)).next(function(t){return{document:n.ye(e,t),size:nz(t)}})},t.prototype.getEntries=function(t,e){var n=this,r=el;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=el,i=new es(G.comparator);return this.pe(t,e,function(t,e){var o=n.ye(t,e);r=r.insert(t,o),i=i.insert(t,nz(e))}).next(function(){return{documents:r,Te:i}})},t.prototype.pe=function(t,e,n){if(e.isEmpty())return nh.resolve();var r=IDBKeyRange.bound(e.first().path.toArray(),e.last().path.toArray()),i=e.getIterator(),o=i.getNext();return ro(t).$t({range:r},function(t,e,r){for(var s=G.fromSegments(t);o&&0>G.comparator(o,s);)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=el,o=e.path.length+1,s={};if(n.isEqual(T.min())){var u=e.path.toArray();s.range=IDBKeyRange.lowerBound(u)}else{var a=e.path.toArray(),c=nA(n);s.range=IDBKeyRange.lowerBound([a,c],!0),s.index=e8.collectionReadTimeIndex}return ro(t).$t(s,function(t,n,s){if(t.length===o){var u=nN(r.R,n);e.path.isPrefixOf(u.key.path)?tP(e,u)&&(i=i.insert(u.key,u)):s.done()}}).next(function(){return i})},t.prototype.newChangeBuffer=function(t){return new rr(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 ri(t).get(e9.key).next(function(t){return t||v(),t})},t.prototype.me=function(t,e){return ri(t).put(e9.key,e)},t.prototype.ye=function(t,e){if(e){var n=nN(this.R,e);if(!n.isNoDocument()||!n.version.isEqual(T.min()))return n}return tn.newInvalidDocument(t)},t}(),rr=function(t){function e(e,n){var r=this;return(r=t.call(this)||this).Ie=e,r.trackRemovals=n,r.Ae=new rt(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 ec(function(t,e){return w(t.canonicalString(),e.canonicalString())});
526return this.changes.forEach(function(o,s){var u=e.Ae.get(o);if(s.document.isValidDocument()){var a=nD(e.Ie.R,s.document,e.getReadTime(o));i=i.add(o.path.popLast()),r+=nz(a)-u,n.push(e.Ie.addEntry(t,o,a))}else if(r-=u,e.trackRemovals){var c=nD(e.Ie.R,tn.newNoDocument(o,T.min()),e.getReadTime(o));n.push(e.Ie.addEntry(t,o,c))}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)),nh.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}(re);/** 527 * @license 528 * Copyright 2017 Google LLC 529 * 530 * Licensed under the Apache License, Version 2.0 (the "License"); 531 * you may not use this file except in compliance with the License. 532 * You may obtain a copy of the License at 533 * 534 * http://www.apache.org/licenses/LICENSE-2.0 535 * 536 * Unless required by applicable law or agreed to in writing, software 537 * distributed under the License is distributed on an "AS IS" BASIS, 538 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 539 * See the License for the specific language governing permissions and 540 * limitations under the License. 541 */function ri(t){return nI(t,e9.store)}function ro(t){return nI(t,e8.store)}function rs(t){return t.path.toArray()}/** 542 * @license 543 * Copyright 2020 Google LLC 544 * 545 * Licensed under the Apache License, Version 2.0 (the "License"); 546 * you may not use this file except in compliance with the License. 547 * You may obtain a copy of the License at 548 * 549 * http://www.apache.org/licenses/LICENSE-2.0 550 * 551 * Unless required by applicable law or agreed to in writing, software 552 * distributed under the License is distributed on an "AS IS" BASIS, 553 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 554 * See the License for the specific language governing permissions and 555 * limitations under the License. 556 */var ru=function(){function t(t){this.R=t}return t.prototype.Rt=function(t,e,n,r){var i=this;n<r&&n>=0&&r<=11||v();var o=new nl("createOrUpgrade",e);n<1&&r>=1&&(function(t){t.createObjectStore(e1.store)}(t),t.createObjectStore(e2.store,{keyPath:e2.keyPath}),t.createObjectStore(e4.store,{keyPath:e4.keyPath,autoIncrement:!0}).createIndex(e4.userMutationsIndex,e4.userMutationsKeyPath,{unique:!0}),t.createObjectStore(e3.store),ra(t),function(t){t.createObjectStore(e8.store)}(t));var s=nh.resolve();return n<3&&r>=3&&(0!==n&&(t.deleteObjectStore(nt.store),t.deleteObjectStore(e7.store),t.deleteObjectStore(ne.store),ra(t)),s=s.next(function(){var t,e;return t=o.store(ne.store),e=new ne(0,0,T.min().toTimestamp(),0),t.put(ne.key,e)})),n<4&&r>=4&&(0!==n&&(s=s.next(function(){return o.store(e4.store).Nt().next(function(e){t.deleteObjectStore(e4.store),t.createObjectStore(e4.store,{keyPath:e4.keyPath,autoIncrement:!0}).createIndex(e4.userMutationsIndex,e4.userMutationsKeyPath,{unique:!0});var n=o.store(e4.store),r=e.map(function(t){return n.put(t)});return nh.waitFor(r)})})),s=s.next(function(){!function(t){t.createObjectStore(nr.store,{keyPath:nr.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(e9.store)}(t),i.be(o)}
556)),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(){var n;t.objectStoreNames.contains("remoteDocumentChanges")&&t.deleteObjectStore("remoteDocumentChanges"),(n=e.objectStore(e8.store)).createIndex(e8.readTimeIndex,e8.readTimeIndexPath,{unique:!1}),n.createIndex(e8.collectionReadTimeIndex,e8.collectionReadTimeIndexPath,{unique:!1})})),n<10&&r>=10&&(s=s.next(function(){return i.Ve(o)})),n<11&&r>=11&&(s=s.next(function(){(function(t){t.createObjectStore(ni.store,{keyPath:ni.keyPath})})(t),function(t){t.createObjectStore(no.store,{keyPath:no.keyPath})}(t)})),s},t.prototype.be=function(t){var e=0;return t.store(e8.store).$t(function(t,n){e+=nz(n)}).next(function(){var n=new e9(e);return t.store(e9.store).put(e9.key,n)})},t.prototype.Re=function(t){var e=this,n=t.store(e2.store),r=t.store(e4.store);return n.Nt().next(function(n){return nh.forEach(n,function(n){var i=IDBKeyRange.bound([n.userId,-1],[n.userId,n.lastAcknowledgedBatchId]);return r.Nt(e4.userMutationsIndex,i).next(function(r){return nh.forEach(r,function(r){r.userId===n.userId||v();var i=nR(e.R,r);return nQ(t,n.userId,i).next(function(){})})})})})},t.prototype.ve=function(t){var e=t.store(nt.store),n=t.store(e8.store);return t.store(ne.store).get(ne.key).next(function(t){var r=[];return n.$t(function(n,i){var o=new D(n),s=[0,e$(o)];r.push(e.get(s).next(function(n){return n?nh.resolve():e.put(new nt(0,e$(o),t.highestListenSequenceNumber))}))}).next(function(){return nh.waitFor(r)})})},t.prototype.Pe=function(t,e){t.createObjectStore(nn.store,{keyPath:nn.keyPath});var n=e.store(nn.store),r=new nU,i=function(t){if(r.add(t)){var e=t.lastSegment(),i=t.popLast();return n.put({collectionId:e,parent:e$(i)})}};return e.store(e8.store).$t({Ft:!0},function(t,e){return i(new D(t).popLast())}).next(function(){return e.store(e3.store).$t({Ft:!0},function(t,e){t[0];var n=t[1];return t[2],i(eX(n).popLast())})})},t.prototype.Ve=function(t){var e=this,n=t.store(e7.store);return n.$t(function(t,r){var i=nL(r),o=nO(e.R,i);return n.put(o)})},t}();function ra(t){t.createObjectStore(nt.store,{keyPath:nt.keyPath}).createIndex(nt.documentTargetsIndex,nt.documentTargetsKeyPath,{unique:!0}),t.createObjectStore(e7.store,{keyPath:e7.keyPath}).createIndex(e7.queryTargetsIndexName,e7.queryTargetsKeyPath,{unique:!0}),t.createObjectStore(ne.store)}var rc="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.",rh=function(){function t(e,n,r,i,o,s,u,a,l,f){var d,y;if(this.allowTabSynchronization=e,this.persistenceKey=n,this.clientId=r,this.Se=o,this.window=s,this.document=u,this.De=l,this.Ce=f,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 h(c.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new n9(this,i),this.Le=n+"main",this.R=new nS(a),this.Be=new nf(this.Le,11,new ru(this.R)),this.qe=new nX(this.referenceDelegate,this.R),this.Ut=new nG,this.Ue=(d=this.R,y=this.Ut,new rn(d,y)),this.Ke=new nF,this.window&&this.window.localStorage?this.Qe=this.window.localStorage:(this.Qe=null,!1===f&&p("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 h(c.FAILED_PRECONDITION,rc);return t.We(),t.Ge(),t.ze(),t.runTransaction("getHighestListenSequenceNumber","readonly",function(e){return t.qe.getHighestSequenceNumber(e)})}).then(function(e){t.Ne=new a(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]}})})})},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 rf(e).put(new nr(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(ny(e))return d("IndexedDbPersistence","Failed to extend owner lease: ",e),t.isPrimary;if(!t.allowTabSynchronization)throw e;return d("IndexedDbPersistence","Releasing owner lease after error during lease refresh",e),!1}).then(function(e){t.isPrimary!==e&&t.Se.enqueueRetryable(function(){return t.Me(e)}),t.isPrimary=e})},t.prototype.Je=function(t){var e=this;return rl(t).get(e1.key).next(function(t){return nh.resolve(e.tn(t))})},t.prototype.en=function(t){return rf(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=nI(t,nr.store);return e.Nt().next(function(t){var n=o.rn(t,18e5),r=t.filter(function(t){return -1===n.indexOf(t)});
556return nh.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]}})})},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?nh.resolve(!0):rl(t).get(e1.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 h(c.FAILED_PRECONDITION,rc);return!1}}return!(!e.networkEnabled||!e.inForeground)||rf(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&&d("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",[e1.store,nr.store],function(e){var n=new nb(e,a.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 rf(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 nJ.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,i=this;return d("IndexedDbPersistence","Starting transaction:",t),this.Be.runTransaction(t,"readonly"===e?"readonly":"readwrite",ns,function(o){return r=new nb(o,i.Ne?i.Ne.next():a.o),"readwrite-primary"===e?i.Je(r).next(function(t){return!!t||i.Ye(r)}).next(function(e){if(!e)throw p("Failed to obtain primary lease for action '"+t+"'."),i.isPrimary=!1,i.Se.enqueueRetryable(function(){return i.Me(!1)}),new h(c.FAILED_PRECONDITION,nu);return n(r)}).next(function(t){return i.Ze(r).next(function(){return t})}):i.dn(r).next(function(){return n(r)})}).then(function(t){return r.raiseOnCommittedEvent(),t})},t.prototype.dn=function(t){var e=this;return rl(t).get(e1.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 h(c.FAILED_PRECONDITION,rc)})},t.prototype.Ze=function(t){var e=new e1(this.clientId,this.allowTabSynchronization,Date.now());return rl(t).put(e1.key,e)},t.yt=function(){return nf.yt()},t.prototype.Xe=function(t){var e=this,n=rl(t);return n.get(e1.key).next(function(t){return e.tn(t)?(d("IndexedDbPersistence","Releasing primary lease."),n.delete(e1.key)):nh.resolve()})},t.prototype.sn=function(t,e){var n=Date.now();return!(t<n-e||t>n&&(p("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 d("IndexedDbPersistence","Client '"+t+"' "+(n?"is":"is not")+" zombied in LocalStorage"),n}catch(t){return p("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){p("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 rl(t){return nI(t,e1.store)}function rf(t){return nI(t,nr.store)}function rd(t,e){var n=t.projectId;return t.isDefaultDatabase||(n+="."+t.database),"firestore/"+e+"/"+n+"/"/** 557 * @license 558 * Copyright 2020 Google LLC 559 * 560 * Licensed under the Apache License, Version 2.0 (the "License");
561 * you may not use this file except in compliance with the License. 562 * You may obtain a copy of the License at 563 * 564 * http://www.apache.org/licenses/LICENSE-2.0 565 * 566 * Unless required by applicable law or agreed to in writing, software 567 * distributed under the License is distributed on an "AS IS" BASIS, 568 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 569 * See the License for the specific language governing permissions and 570 * limitations under the License. 571 */}var rp=function(t,e){this.progress=t,this.wn=e},ry=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;e<n.length;e++)n[e].applyToLocalView(t);return t})},t.prototype.gn=function(t,e){t.forEach(function(t,n){for(var r=0;r<e.length;r++)e[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 G.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length?this.Tn(t,e.path):tA(e)?this.In(t,e,n):this.An(t,e,n)},t.prototype.Tn=function(t,e){return this.mn(t,new G(e)).next(function(t){var e=ef;return t.isFoundDocument()&&(e=e.insert(t.key,t)),e})},t.prototype.In=function(t,e,n){var r=this,i=e.collectionGroup,o=ef;return this.Ut.getCollectionParents(t,i).next(function(s){return nh.forEach(s,function(s){var u,a=(u=s.child(i),new tT(u,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt));return r.An(t,a,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;e<i.length;e++)for(var n=i[e],o=0,s=n.mutations;o<s.length;o++){var u=s[o],a=u.key,c=r.get(a);null==c&&(c=tn.newInvalidDocument(a),r=r.insert(a,c)),t1(u,c,n.localWriteTime),c.isFoundDocument()||(r=r.remove(a))}})}).next(function(){return r.forEach(function(t,n){tP(e,n)||(r=r.remove(t))}),r})},t.prototype.Rn=function(t,e,n){for(var r=ey(),i=0;i<e.length;i++)for(var o=0,s=e[i].mutations;o<s.length;o++){var u=s[o];u instanceof t5&&null===n.get(u.key)&&(r=r.add(u.key))}var a=n;return this.Ue.getEntries(t,r).next(function(t){return t.forEach(function(t,e){e.isFoundDocument()&&(a=a.insert(t,e))}),a})},t}(),rm=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=ey(),i=ey(),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}(),rv=function(){function t(){}return t.prototype.Vn=function(t){this.Sn=t},t.prototype.getDocumentsMatchingQuery=function(t,e,n,r){var i=this;return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())||n.isEqual(T.min())?this.Dn(t,e):this.Sn.pn(t,r).next(function(s){var u=i.Cn(e,s);return(t_(e)||tS(e))&&i.Nn(e.limitType,u,r,n)?i.Dn(t,e):(f()<=o.in.DEBUG&&d("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),tO(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 ec(tF(t));return e.forEach(function(e,r){tP(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&&d("QueryEngine","Using full collection scan to execute query:",tO(e)),this.Sn.getDocumentsMatchingQuery(t,e,T.min())},t}(),rg=function(){function t(t,e,n,r){this.persistence=t,this.xn=e,this.R=r,this.kn=new es(w),this.Fn=new rt(function(t){return to(t)},ts),this.$n=T.min(),this._n=t.getMutationQueue(n),this.On=t.getRemoteDocumentCache(),this.qe=t.getTargetCache(),this.Mn=new r
571y(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 rw(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 i=(n=t)._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 ry(n.On,i,n.persistence.getIndexManager()),i.getAllMutationBatches(t)}).next(function(e){for(var n=[],i=[],s=ey(),u=0,a=r;u<a.length;u++){var c=a[u];n.push(c.batchId);for(var h=0,l=c.mutations;h<l.length;h++){var f=l[h];s=s.add(f.key)}}for(var d=0;d<e.length;d++){var p=e[d];i.push(p.batchId);for(var y=0,m=p.mutations;y<m.length;y++){var v=m[y];s=s.add(v.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 rb(t){return t.persistence.runTransaction("Get last remote snapshot version","readonly",function(e){return t.qe.getLastRemoteSnapshotVersion(e)})}function rI(t,e,n,r,i){var o=ey();return n.forEach(function(t){return o=o.add(t)}),e.getEntries(t,o).next(function(t){var o=el;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(T.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)):d("LocalStore","Ignoring outdated watch update for ",n,". Current version:",u.version," Watch version:",s.version)}),o})}function rT(t,e){return t.persistence.runTransaction("Allocate target","readwrite",function(n){var r;return t.qe.getTargetData(n,e).next(function(i){return i?(r=i,nh.resolve(r)):t.qe.allocateTargetId(n).next(function(i){return r=new n_(e,i,0,n.currentSequenceNumber),t.qe.addTargetData(n,r).next(function(){return r})})})}).then(function(n){var r=t.kn.get(n.targetId);return(null===r||n.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(t.kn=t.kn.insert(n.targetId,n),t.Fn.set(e,n.targetId)),n})}function rE(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:o=(i=t).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(!ny(u=r.sent()))throw u;return d("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 r_(t,e,n){var r=T.min(),i=ey();return t.persistence.runTransaction("Execute query","readonly",function(o){var s,u;return(s=tx(e),void 0!==(u=t.Fn.get(s))?nh.resolve(t.kn.get(u)):t.qe.getTargetData(o,s)).next(function(e){if(e)return r=e.lastLimboFreeSnapshotVersion,t.qe.getMatchingKeysForTargetId(o,e.targetId).next(function(t){i=t})}).next(function(){return t.xn.getDocumentsMatchingQuery(o,e,n?r:T.min(),n?i:ey())}).next(function(t){return{documents:t,Bn:i}})})}function rS(t,e){var n=t.qe,r=t.kn.get(e);return r?Promise.resolve(r.target):t.persistence.runTransaction("Get target data","readonly",function(t){return n.lt(t,e).next(function(t){return t?t.target:null})})}function rN(t){return t.persistence.runTransaction("Get new document changes","readonly",function(e){var n,r,i,o,s,u;return n=t.On,r=t.$n,i=el,o=nA(r),s=ro(e),u=IDBKeyRange.lowerBound(o,!0),s.$t({index:e8.readTimeIndex,range:u},function(t,e){var r=nN(n.R,e);i=i.insert(r.key,r),o=e.readTime}).next(function(){return{wn:i,readTime:nk(o)}})}).then(function(e){var n=e.wn,r=e.readTime;return t.$n=r,n})}/** 572 * @license 573 * Copyright 2020 Google LLC 574 * 575 * Licensed under the Apache License, Version 2.0 (the "License");
576 * you may not use this file except in compliance with the License. 577 * You may obtain a copy of the License at 578 * 579 * http://www.apache.org/licenses/LICENSE-2.0 580 * 581 * Unless required by applicable law or agreed to in writing, software 582 * distributed under the License is distributed on an "AS IS" BASIS, 583 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 584 * See the License for the specific language governing permissions and 585 * limitations under the License. 586 */var rD=function(){function t(t){this.R=t,this.Qn=new Map,this.jn=new Map}return t.prototype.getBundleMetadata=function(t,e){return nh.resolve(this.Qn.get(e))},t.prototype.saveBundleMetadata=function(t,e){return this.Qn.set(e.id,{id:e.id,version:e.version,createTime:eC(e.createTime)}),nh.resolve()},t.prototype.getNamedQuery=function(t,e){return nh.resolve(this.jn.get(e))},t.prototype.saveNamedQuery=function(t,e){return this.jn.set(e.name,{name:e.name,query:nP(e.bundledQuery),readTime:eC(e.readTime)}),nh.resolve()},t}(),rA=function(){function t(){this.Wn=new ec(rk.Gn),this.zn=new ec(rk.Hn)}return t.prototype.isEmpty=function(){return this.Wn.isEmpty()},t.prototype.addReference=function(t,e){var n=new rk(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 rk(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 G(new D([])),r=new rk(n,t),i=new rk(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 G(new D([])),n=new rk(e,t),r=new rk(e,t+1),i=ey();return this.zn.forEachInRange([n,r],function(t){i=i.add(t.key)}),i},t.prototype.containsKey=function(t){var e=new rk(t,0),n=this.Wn.firstAfterOrEqual(e);return null!==n&&t.isEqual(n.key)},t}(),rk=function(){function t(t,e){this.key=t,this.ns=e}return t.Gn=function(t,e){return G.comparator(t.key,e.key)||w(t.ns,e.ns)},t.Hn=function(t,e){return w(t.ns,e.ns)||G.comparator(t.key,e.key)},t}(),rx=function(){function t(t,e){this.Ut=t,this.referenceDelegate=e,this._n=[],this.ss=1,this.rs=new ec(rk.Gn)}return t.prototype.checkEmpty=function(t){return nh.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 nT(i,e,n,r);this._n.push(o);for(var s=0;s<r.length;s++){var u=r[s];this.rs=this.rs.add(new rk(u.key,i)),this.Ut.addToCollectionParentIndex(t,u.key.path.popLast())}return nh.resolve(o)},t.prototype.lookupMutationBatch=function(t,e){return nh.resolve(this.os(e))},t.prototype.getNextMutationBatchAfterBatchId=function(t,e){var n=this.cs(e+1),r=n<0?0:n;return nh.resolve(this._n.length>r?this._n[r]:null)},t.prototype.getHighestUnacknowledgedBatchId=function(){return nh.resolve(0===this._n.length?-1:this.ss-1)},t.prototype.getAllMutationBatches=function(t){return nh.resolve(this._n.slice())},t.prototype.getAllMutationBatchesAffectingDocumentKey=function(t,e){var n=this,r=new rk(e,0),i=new rk(e,Number.POSITIVE_INFINITY),o=[];return this.rs.forEachInRange([r,i],function(t){var e=n.os(t.ns);o.push(e)}),nh.resolve(o)},t.prototype.getAllMutationBatchesAffectingDocumentKeys=function(t,e){var n=this,r=new ec(w);return e.forEach(function(t){var e=new rk(t,0),i=new rk(t,Number.POSITIVE_INFINITY);n.rs.forEachInRange([e,i],function(t){r=r.add(t.ns)})}),nh.resolve(this.us(r))},t.prototype.getAllMutationBatchesAffectingQuery=function(t,e){var n=e.path,r=n.length+1,i=n;G.isDocumentKey(i)||(i=i.child(""));var o=new rk(new G(i),0),s=new ec(w);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),nh.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;
5860===this.hs(e.batchId,"removed")||v(),this._n.shift();var r=this.rs;return nh.forEach(e.mutations,function(i){var o=new rk(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 rk(e,0),r=this.rs.firstAfterOrEqual(n);return nh.resolve(e.isEqual(r&&r.key))},t.prototype.performConsistencyCheck=function(t){return this._n.length,nh.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}(),rC=function(){function t(t,e){this.Ut=t,this.ls=e,this.docs=new es(G.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 nh.resolve(n?n.document.clone():tn.newInvalidDocument(e))},t.prototype.getEntries=function(t,e){var n=this,r=el;return e.forEach(function(t){var e=n.docs.get(t);r=r.insert(t,e?e.document.clone():tn.newInvalidDocument(t))}),nh.resolve(r)},t.prototype.getDocumentsMatchingQuery=function(t,e,n){for(var r=el,i=new G(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;0>=h.compareTo(n)||tP(e,c)&&(r=r.insert(c.key,c.clone()))}return nh.resolve(r)},t.prototype.fs=function(t,e){return nh.forEach(this.docs,function(t){return e(t)})},t.prototype.newChangeBuffer=function(t){return new rR(this)},t.prototype.getSize=function(t){return nh.resolve(this.size)},t}(),rR=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=[];
586return this.changes.forEach(function(r,i){i.document.isValidDocument()?n.push(e.Ie.addEntry(t,i.document,e.getReadTime(r))):e.Ie.removeEntry(r)}),nh.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}(re),rL=function(){function t(t){this.persistence=t,this.ds=new rt(function(t){return to(t)},ts),this.lastRemoteSnapshotVersion=T.min(),this.highestTargetId=0,this.ws=0,this._s=new rA,this.targetCount=0,this.ys=n$.Jt()}return t.prototype.forEachTarget=function(t,e){return this.ds.forEach(function(t,n){return e(n)}),nh.resolve()},t.prototype.getLastRemoteSnapshotVersion=function(t){return nh.resolve(this.lastRemoteSnapshotVersion)},t.prototype.getHighestSequenceNumber=function(t){return nh.resolve(this.ws)},t.prototype.allocateTargetId=function(t){return this.highestTargetId=this.ys.next(),nh.resolve(this.highestTargetId)},t.prototype.setTargetsMetadata=function(t,e,n){return n&&(this.lastRemoteSnapshotVersion=n),e>this.ws&&(this.ws=e),nh.resolve()},t.prototype.te=function(t){this.ds.set(t.target,t);var e=t.targetId;e>this.highestTargetId&&(this.ys=new n$(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,nh.resolve()},t.prototype.updateTargetData=function(t,e){return this.te(e),nh.resolve()},t.prototype.removeTargetData=function(t,e){return this.ds.delete(e.target),this._s.Zn(e.targetId),this.targetCount-=1,nh.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++)}),nh.waitFor(o).next(function(){return i})},t.prototype.getTargetCount=function(t){return nh.resolve(this.targetCount)},t.prototype.getTargetData=function(t,e){var n=this.ds.get(e)||null;return nh.resolve(n)},t.prototype.addMatchingKeys=function(t,e,n){return this._s.Jn(e,n),nh.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))}),nh.waitFor(i)},t.prototype.removeMatchingKeysForTargetId=function(t,e){return this._s.Zn(e),nh.resolve()},t.prototype.getMatchingKeysForTargetId=function(t,e){var n=this._s.es(e);return nh.resolve(n)},t.prototype.containsKey=function(t,e){return nh.resolve(this._s.containsKey(e))},t}(),rO=function(){function t(t,e){var n,r=this;this.gs={},this.Ne=new a(0),this.xe=!1,this.xe=!0,this.referenceDelegate=t(this),this.qe=new rL(this),this.Ut=new nq,this.Ue=(n=this.Ut,new rC(n,function(t){return r.referenceDelegate.ps(t)})),this.R=new nS(e),this.Ke=new rD(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 rx(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;d("MemoryPersistence","Starting transaction:",t);var i=new rP(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 nh.or(Object.values(this.gs).map(function(n){return function(){return n.containsKey(t,e)}}))},t}(),rP=function(t){function e(e){var n=this;return(n=t.call(this)||this).currentSequenceNumber=e,n}return(0,r.ZT)(e,t),e}(na),rF=function(){function t(t){this.persistence=t,this.As=new rA,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;
586throw v()},enumerable:!1,configurable:!0}),t.prototype.addReference=function(t,e,n){return this.As.addReference(n,e),this.vs.delete(n.toString()),nh.resolve()},t.prototype.removeReference=function(t,e,n){return this.As.removeReference(n,e),this.vs.add(n.toString()),nh.resolve()},t.prototype.markPotentiallyOrphaned=function(t,e){return this.vs.add(e.toString()),nh.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 nh.forEach(this.vs,function(r){var i=G.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 nh.or([function(){return nh.resolve(n.As.containsKey(e))},function(){return n.persistence.getTargetCache().containsKey(t,e)},function(){return n.persistence.Is(t,e)}])},t}(),rM=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}();/** 587 * @license 588 * Copyright 2017 Google LLC 589 * 590 * Licensed under the Apache License, Version 2.0 (the "License"); 591 * you may not use this file except in compliance with the License. 592 * You may obtain a copy of the License at 593 * 594 * http://www.apache.org/licenses/LICENSE-2.0 595 * 596 * Unless required by applicable law or agreed to in writing, software 597 * distributed under the License is distributed on an "AS IS" BASIS, 598 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 599 * See the License for the specific language governing permissions and 600 * limitations under the License. 601 */function rV(t,e){return"firestore_clients_"+t+"_"+e}function rq(t,e,n){var r="firestore_mutations_"+t+"_"+n;return e.isAuthenticated()&&(r+="_"+e.uid),r}function rU(t,e){return"firestore_targets_"+t+"_"+e}rM.UNAUTHENTICATED=new rM(null),rM.GOOGLE_CREDENTIALS=new rM("google-credentials-uid"),rM.FIRST_PARTY=new rM("first-party-uid"),rM.MOCK_USER=new rM("mock-user");var rG=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 h(o.error.code,o.error.message)),s?new t(e,n,o.state,i):(p("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}(),rB=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 h(i.error.code,i.error.message)),o?new t(e,i.state,r):(p("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}(),rj=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=em,s=0;i&&s<r.activeTargetIds.length;++s)i=U(r.activeTargetIds[s]),o=o.add(r.activeTargetIds[s]);
601return i?new t(e,o):(p("SharedClientState","Failed to parse client data for instance '"+e+"': "+n),null)},t}(),rK=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):(p("SharedClientState","Failed to parse online state: "+e),null)},t}(),rQ=function(){function t(){this.activeTargetIds=em}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(){return JSON.stringify({activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()})},t}(),rz=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 es(w),this.started=!1,this.$s=[];var o=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Os=rV(this.persistenceKey,this.Ns),this.Ms="firestore_sequence_number_"+this.persistenceKey,this.Fs=this.Fs.insert(this.Ns,new rQ),this.Ls=RegExp("^firestore_clients_"+o+"_([^_]*)$"),this.Bs=RegExp("^firestore_mutations_"+o+"_(\\d+)(?:_(.*))?$"),this.qs=RegExp("^firestore_targets_"+o+"_(\\d+)$"),this.Us="firestore_online_state_"+this.persistenceKey,this.Ks="firestore_bundle_loaded_"+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,l,f=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(rV(this.persistenceKey,i)))&&(s=rj.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++)l=h[c],this.ks(l);return this.$s=[],this.window.addEventListener("pagehide",function(){return f.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(rU(this.persistenceKey,t));if(n){var r=rB.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(rU(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 d("SharedClientState","READ",t,e),e},t.prototype.setItem=function(t,e){d("SharedClientState","SET",t,e),this.storage.setItem(t,e)},t.prototype.removeItem=function(t){d("SharedClientState","REMOVE",t),this.storage.removeItem(t)},t.prototype.ks=function(t){var e=this;if(t.storageArea===this.storage){if(d("SharedClientState","EVENT",t.key,t.newValue),t.key===this.Os)return void p("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 e,n,i,o,s,u;return(0,r.Jh)(this,function(r){if(this.started){if(null!==t.key){if(this.Ls.test(t.key)){if(null==t.newValue)return e=this.ti(t.key),[2,this.ei(e,null)];if(n=this.ni(t.key,t.newValue))return[2,this.ei(n.clientId,n)]}else if(this.Bs.test(t.key)){if(null!==t.newValue&&(i=this.si(t.key,t.newValue)))return[2,this.ii(i)]}else if(this.qs.test(t.key)){if(null!==t.newValue&&(o=this.ri(t.key,t.newValue)))return[2,this.oi(o)]}else if(t.key===this.Us){if(null!==t.newValue&&(s=this.js(t.newValue)))return[2,this.Ws(s)]}else if(t.key===this.Ms)(u=function(t){var e=a.o;if(null!=t)try{var n=JSON.parse(t);"number"==typeof n||v(),e=n}
601catch(t){p("SharedClientState","Failed to read sequence number from WebStorage",t)}return e}(t.newValue))!==a.o&&this.sequenceNumberHandler(u);else if(t.key===this.Ks)return[2,this.syncEngine.ci()]}}else this.$s.push(t);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 rG(this.currentUser,t,e,n),i=rq(this.persistenceKey,this.currentUser,t);this.setItem(i,r.Ss())},t.prototype.Hs=function(t){var e=rq(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=rU(this.persistenceKey,t),i=new rB(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 rj.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 rG.Vs(new rM(i),r,e)},t.prototype.ri=function(t,e){var n=Number(this.qs.exec(t)[1]);return rB.Vs(n,e)},t.prototype.js=function(t){return rK.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)]:(d("SharedClientState","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=em;return t.forEach(function(t,n){e=e.unionWith(n.activeTargetIds)}),e},t}(),rJ=function(){function t(){this.li=new rQ,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 rQ,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}(),rW=function(){function t(){}return t.prototype.di=function(t){},t.prototype.shutdown=function(){},t}(),rH=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(){d("ConnectivityMonitor","Network connectivity changed: AVAILABLE");for(var t=0,e=this.gi;t<e.length;t++)(0,e[t])(0)},t.prototype.yi=function(){d("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}(),rZ={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery"},rY=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}(),r$=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;
601u.listenOnce(s.tw.COMPLETE,function(){try{switch(u.getLastErrorCode()){case s.jK.NO_ERROR:var e=u.getResponseJson();d("Connection","XHR received:",JSON.stringify(e)),i(e);break;case s.jK.TIMEOUT:d("Connection",'RPC "'+t+'" timed out'),o(new h(c.DEADLINE_EXCEEDED,"Request time out"));break;case s.jK.HTTP_ERROR:var n=u.getStatus();if(d("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 a,l=(a=r.status.toLowerCase().replace(/_/g,"-"),Object.values(c).indexOf(a)>=0?a:c.UNKNOWN);o(new h(l,r.message))}else o(new h(c.UNKNOWN,"Server responded with status "+u.getStatus()))}else o(new h(c.UNAVAILABLE,"Connection failed."));break;default:v()}}finally{d("Connection",'RPC "'+t+'" completed.')}});var a=JSON.stringify(r);u.send(e,"POST",a,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},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 a=n.join("");d("Connection","Creating WebChannel: "+a,u);var l=r.createWebChannel(a,u),f=!1,p=!1,m=new rY({Ei:function(t){p?d("Connection","Not sending because WebChannel is closed:",t):(f||(d("Connection","Opening WebChannel transport."),l.open(),f=!0),d("Connection","WebChannel sending:",t),l.send(t))},Ti:function(){return l.close()}}),g=function(t,e,n){t.listen(e,function(t){try{n(t)}catch(t){setTimeout(function(){throw t},0)}})};return g(l,s.ii.EventType.OPEN,function(){p||d("Connection","WebChannel transport opened.")}),g(l,s.ii.EventType.CLOSE,function(){p||(p=!0,d("Connection","WebChannel transport closed"),m.Vi())}),g(l,s.ii.EventType.ERROR,function(t){p||(p=!0,y("Connection","WebChannel transport errored:",t),m.Vi(new h(c.UNAVAILABLE,"The operation could not be completed")))}),g(l,s.ii.EventType.MESSAGE,function(t){var e;if(!p){var n=t.data[0];n||v();var r=n.error||(null===(e=n[0])||void 0===e?void 0:e.error);if(r){d("Connection","WebChannel received error:",r);var i=r.status,o=function(t){var e=t7[t];if(void 0!==e)return eo(e)}(i),s=r.message;void 0===o&&(o=c.INTERNAL,s="Unknown error status: "+i+" with message "+r.message),p=!0,m.Vi(new h(o,s)),l.close()}else d("Connection","WebChannel received:",n),m.Si(n)}}),g(o,s.ju.STAT_EVENT,function(t){t.stat===s.kN.PROXY?d("Connection","Detected buffering proxy"):t.stat===s.kN.NOPROXY&&d("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);d("RestConnection","Sending: ",i,n);var o={};return this.ki(o,r),this.Fi(t,i,o,n).then(function(t){return d("RestConnection","Received: ",t),t},function(e){throw y("RestConnection",t+" failed with error: ",e,"url: ",i,"request:",n),e})},t.prototype.$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.0",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=rZ[t];return this.Di+"/v1/"+e+":"+n},t}());/** 602 * @license 603 * Copyright 2020 Google LLC 604 * 605 * Licensed under the Apache License, Version 2.0 (the "License"); 606 * you may not use this file except in compliance with the License. 607 * You may obtain a copy of the License at 608 * 609 * http://www.apache.org/licenses/LICENSE-2.0 610 * 611 * Unless required by applicable law or agreed to in writing, softw
611are 612 * distributed under the License is distributed on an "AS IS" BASIS, 613 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 614 * See the License for the specific language governing permissions and 615 * limitations under the License. 616 *//** 617 * @license 618 * Copyright 2020 Google LLC 619 * 620 * Licensed under the Apache License, Version 2.0 (the "License"); 621 * you may not use this file except in compliance with the License. 622 * You may obtain a copy of the License at 623 * 624 * http://www.apache.org/licenses/LICENSE-2.0 625 * 626 * Unless required by applicable law or agreed to in writing, software 627 * distributed under the License is distributed on an "AS IS" BASIS, 628 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 629 * See the License for the specific language governing permissions and 630 * limitations under the License. 631 */function rX(){return"undefined"!=typeof window?window:null}function r0(){return"undefined"!=typeof document?document:null}/** 632 * @license 633 * Copyright 2020 Google LLC 634 * 635 * Licensed under the Apache License, Version 2.0 (the "License"); 636 * you may not use this file except in compliance with the License. 637 * You may obtain a copy of the License at 638 * 639 * http://www.apache.org/licenses/LICENSE-2.0 640 * 641 * Unless required by applicable law or agreed to in writing, software 642 * distributed under the License is distributed on an "AS IS" BASIS, 643 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 644 * See the License for the specific language governing permissions and 645 * limitations under the License. 646 */function r1(t){return new eA(t,!0)}var r2=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&&d("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}(),r4=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 r2(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]}})})},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===c.RESOURCE_EXHAUSTED?(p(e.toString()),p("Using maximum backoff delay to prevent overloading the backend."),this.Zi.Qi()):e&&e.code===c.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 h(c.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 d("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():(d("PersistentStream","stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve())})}},t}(),r3=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,i,o,s,u="NO_CHANGE"===(r=e.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===r?1:"REMOVE"===r?2:"CURRENT"===r?3:"RESET"===r?4:v(),a=e.targetChange.targetIds||[],l=(i=e.targetChange.resumeToken,t.I?(void 0===i||"string"==typeof i||v(),C.fromBase64String(i||"")):(void 0===i||i instanceof Uint8Array||v(),C.fromUint8Array(i||new Uint8Array))),f=(d=e.targetChange.cause)&&(s=void 0===(o=d).code?c.UNKNOWN:eo(o.code),new h(s,o.message||""));n=new eI(u,a,l,f||null)}else if("documentChange"in e){e.documentChange,(u=e.documentChange).document,u.document.name,u.document.updateTime,a=eP(t,u.document.name),l=eC(u.document.updateTime);var d=new te({mapValue:{fields:u.document.fields}}),p=(f=tn.newFoundDocument(a,l,d),u.targetIds||[]),y=u.removedTargetIds||[];n=new ew(p,y,f.key,f)}else if("documentDelete"in e)e.documentDelete,(u=e.documentDelete).document,a=eP(t,u.document),l=u.readTime?eC(u.readTime):T.min(),d=tn.newNoDocument(a,l),f=u.removedTargetIds||[],n=new ew([],f,d.key,d);else if("documentRemove"in e)e.documentRemove,(u=e.documentRemove).document,a=eP(t,u.document),l=u.removedTargetIds||[],n=new ew([],l,a,null);else{if(!("filter"in e))return v();e.filter;var m=e.filter;m.targetId,u=m.count||0,a=new er(u),l=m.targetId,n=new eb(l,a)}return n}(this.R,t),n=function(t){if(!("targetChange"in t))return T.min();var e=t.targetChange;return e.targetIds&&e.targetIds.length?T.min():e.readTime?eC(e.readTime):T.min()}(t);return this.listener._r(e,n)},e.prototype.mr=function(t){var e,n,r,i,o={};o.database=eV(this.R),o.addTarget=(e=this.R,(n=tu(r=t.target)?{documents:eK(e,r)}:{query:eQ(e,r)}).targetId=t.targetId,t.resumeToken.approximateByteSize()>0?n.resumeToken=ex(e,t.resumeToken):t.snapshotVersion.compareTo(T.min())>0&&(n.readTime=ek(e,t.snapshotVersion.toTimestamp())),n);var s=(this.R,null==(i=function(t,e){switch(e){case 0:return null;case 1:return"existence-filter-mismatch";case 2:return"limbo-document";default:return v()}}(0,t.purpose))?null:{"goog-listen-tags":i});s&&(o.labels=s),this.cr(o)},e.prototype.yr=function(t){var e={};e.database=eV(this.R),e.removeTarget=t,this.cr(e)},e}(r4),r5=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}
646,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(t.streamToken||v(),this.lastStreamToken=t.streamToken,this.gr){this.Zi.reset();var e,n,r=(e=t.writeResults,n=t.commitTime,e&&e.length>0?(void 0!==n||v(),e.map(function(t){var e;return(e=t.updateTime?eC(t.updateTime):eC(n)).isEqual(T.min())&&(e=eC(n)),new tY(e,t.transformResults||[])})):[]),i=eC(t.commitTime);return this.listener.Tr(i,r)}return t.writeResults&&0!==t.writeResults.length&&v(),this.gr=!0,this.listener.Ir()},e.prototype.Ar=function(){var t={};t.database=eV(this.R),this.cr(t)},e.prototype.Er=function(t){var e=this,n={streamToken:this.lastStreamToken,writes:t.map(function(t){return eB(e.R,t)})};this.cr(n)},e}(r4),r6=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 h(c.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===c.UNAUTHENTICATED&&r.credentials.invalidateToken(),t):new h(c.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===c.UNAUTHENTICATED&&r.credentials.invalidateToken(),t):new h(c.UNKNOWN,t.toString())})},e.prototype.terminate=function(){this.Rr=!0},e}(function(){}),r8=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?(p(e),this.Vr=!1):d("OnlineStateTracker",e)},t.prototype.kr=function(){null!==this.Pr&&(this.Pr.cancel(),this.Pr=null)},t}(),r9=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 ia(this)?(d("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=t).Or.add(4),[4,it(e)];case 1:return n.sent(),e.Br.set("Unknown"),e.Or.delete(4),[4,r7(e)];case 2:return n.sent(),[2]}})})}(this)]):[3,2];case 1:t.sent(),t.label=2;case 2:return[2]}})})})}),this.Br=new r8(n,i)};/** 647 * @license 648 * Copyright 2017 Google LLC 649 * 650 * Licensed under the Apache License, Version 2.0 (the "License"); 651 * you may not use this file except in compliance with the License. 652 * You may obtain a copy of the License at 653 * 654 * http://www.apache.org/licenses/LICENSE-2.0 655 * 656 * Unless required by applicable law or agreed to in writing, software 657 * distributed under the License is distributed on an "AS IS" BASIS, 658 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 659 * See the License for the specific language governing permissions and 660 * limitations under the License. 661 */function r7(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(!ia(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 it(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 ie(t,e){t.$r.has(e.targetId)||(t.$r.set(e.targetId,e),iu(t)?is(t):iE(t).er()&&ii(t,e))}function ir(t,e){var n=iE(t);t.$r.delete(e),n.er()&&io(t,e),0===t.$r.size&&(n.er()?n.ir():ia(t)&&t.Br.set("Unknown"))}function ii(t,e){t.qr.U(e.targetId),iE(t).mr(e)}function io(t,e){t.qr.U(e),iE(t).yr(e)}function is(t){t.qr=new eE({getRemoteKeysForTarget:function(e){return t.remoteSyncer.getRemoteKeysForTarget(e)},lt:function(e){return t.$r.get(e)||null}}),iE(t).start(),t.Br.Sr()}function iu(t){return ia(t)&&!iE(t).tr()&&t.$r.size>0}function ia(t){return 0===t.Or.size}function ic(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){ii(t,e)}),[2]})})}function ih(t,e){return(0,r.mG)(this,void 0,void 0,function(){return(0,r.Jh)(this,function(n){return t.qr=void 0,iu(t)?(t.Br.Nr(e),is(t)):t.Br.set("Unknown"),[2]})})}function il(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 eI&&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]}})})}(t,e)];case 2:case 4:return u.sent(),[3,5];case 3:return i=u.sent(),d("RemoteStore","Failed to remove targets %s: %s ",e.targetIds.join(","),i),[4,id(t,i)];case 5:return[3,13];case 6:if(e instanceof ew?t.qr.X(e):e instanceof eb?t.qr.rt(e):t.qr.et(e),n.isEqual(T.min()))return[3,13];u.label=7;case 7:return u.trys.push([7,11,,13]),[4,rb(t.localStore)];case 8:var a;return o=u.sent(),n.compareTo(o)>
661=0?[4,((a=t.qr.ut(n)).targetChanges.forEach(function(e,r){if(e.resumeToken.approximateByteSize()>0){var i=t.$r.get(r);i&&t.$r.set(r,i.withResumeToken(e.resumeToken,n))}}),a.targetMismatches.forEach(function(e){var n=t.$r.get(e);n&&(t.$r.set(e,n.withResumeToken(C.EMPTY_BYTE_STRING,n.snapshotVersion)),io(t,e),ii(t,new n_(n.target,e,1,n.sequenceNumber)))}),t.remoteSyncer.applyRemoteEvent(a))]:[3,10];case 9:u.sent(),u.label=10;case 10:return[3,13];case 11:return d("RemoteStore","Failed to raise snapshot:",s=u.sent()),[4,id(t,s)];case 12:return u.sent(),[3,13];case 13:return[2]}})})}function id(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(!ny(e))throw e;return t.Or.add(1),[4,it(t)];case 1:return o.sent(),t.Br.set("Offline"),n||(n=function(){return rb(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 d("RemoteStore","Retrying IndexedDB access"),[4,n()];case 1:return e.sent(),t.Or.delete(1),[4,r7(t)];case 2:return e.sent(),[2]}})})}),[2]}})})}function ip(t,e){return e().catch(function(n){return id(t,n,e)})}function iy(t){return(0,r.mG)(this,void 0,void 0,function(){var e,n,i,o;return(0,r.Jh)(this,function(r){var s,u,a;switch(r.label){case 0:n=i_(e=t),i=e.Fr.length>0?e.Fr[e.Fr.length-1].batchId:-1,r.label=1;case 1:if(!(ia(s=e)&&s.Fr.length<10))return[3,7];r.label=2;case 2:return r.trys.push([2,4,,6]),[4,(u=e.localStore,a=i,u.persistence.runTransaction("Get next mutation batch","readonly",function(t){return void 0===a&&(a=-1),u._n.getNextMutationBatchAfterBatchId(t,a)}))];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=i_(t);n.er()&&n.pr&&n.Er(e.mutations)}(e,o),[3,6]);case 4:return[4,id(e,r.sent())];case 5:return r.sent(),[3,6];case 6:return[3,1];case 7:return im(e)&&iv(e),[2]}})})}function im(t){return ia(t)&&!i_(t).tr()&&t.Fr.length>0}function iv(t){i_(t).start()}function ig(t){return(0,r.mG)(this,void 0,void 0,function(){return(0,r.Jh)(this,function(e){return i_(t).Ar(),[2]})})}function iw(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=i_(t),n=0,i=t.Fr;n<i.length;n++)o=i[n],e.Er(o.mutations);return[2]})})}function ib(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=nE.from(i,e,n),[4,ip(t,function(){return t.remoteSyncer.applySuccessfulWrite(o)})];case 1:return r.sent(),[4,iy(t)];case 2:return r.sent(),[2]}})})}function iI(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&&i_(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 ei(i=e.code)&&i!==c.ABORTED?(n=t.Fr.shift(),i_(t).sr(),[4,ip(t,function(){return t.remoteSyncer.rejectFailedWrite(n.batchId,e)})]):[3,3];case 1:return r.sent(),[4,iy(t)];case 2:r.sent(),r.label=3;case 3:return[2]}})})}(t,e)]:[3,2];case 1:n.sent(),n.label=2;case 2:return im(t)&&iv(t),[2]}})})}function iT(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=t,e?(n.Or.delete(2),[4,r7(n)]):[3,2];case 1:return r.sent(),[3,5];case 2:return e?[3,4]:(n.Or.add(2),[4,it(n)]);case 3:r.sent(),n.Br.set("Unknown"),r.label=4;case 4:r.label=5;case 5:return[2]}})})}function iE(t){var e,n,i,o=this;return t.Ur||(t.Ur=(e=t.datastore,n=t.asyncQueue,i={Ii:ic.bind(null,t),Ri:ih.bind(null,t),_r:il.bind(null,t)},e.br(),new r3(n,e.Hi,e.credentials,e.R,i)),t.Mr.push(function(e){return(0,r.mG)(o,void 0,void 0,function(){return(0,r.Jh)(this,function(n){switch(n.label){case 0:return e?(t.Ur.sr(),iu(t)?is(t):t.Br.set("Unknown"),[3,3]):[3,1];case 1:return[4,t.Ur.stop()];case 2:n.sent(),t.qr=void 0,n.label=3;case 3:return[2]}})})})),t.Ur}function i_(t){var e,n,i,o=this;return t.Kr||(t.Kr=(e=t.datastore,n=t.asyncQueue,i={Ii:ig.bind(null,t),Ri:iI.bind(null,t),Ir:iw.bind(null,t),Tr:ib.bind(null,t)},e.br(),new r5(n,e.Hi,e.credentials,e.R,i)),t.Mr.push(function(e){return(0,r.mG)(o,void 0,void 0,function(){return(0,r.Jh)(this,function(n){switch(n.label){case 0:return e?(t.Kr.sr(),[4,iy(t)]):[3,2];case 1:return n.sent(),[3,4];case 2:return[4,t.Kr.stop()];case 3:n.sent(),t.Fr.length>0&&(d("RemoteStore","Stopping write stream with "+t.Fr.length+" pending writes"),t.Fr=[]),n.label=4;case 4:return[2]}})})})),t.Kr}var iS=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 nc,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 h(c.CANCELLED,"Operation cancelled"+(t?": "+t:"")))
661)},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 iN(t,e){if(p("AsyncQueue",e+": "+t),ny(t))return new h(c.UNAVAILABLE,e+": "+t);throw t}/** 662 * @license 663 * Copyright 2017 Google LLC 664 * 665 * Licensed under the Apache License, Version 2.0 (the "License"); 666 * you may not use this file except in compliance with the License. 667 * You may obtain a copy of the License at 668 * 669 * http://www.apache.org/licenses/LICENSE-2.0 670 * 671 * Unless required by applicable law or agreed to in writing, software 672 * distributed under the License is distributed on an "AS IS" BASIS, 673 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 674 * See the License for the specific language governing permissions and 675 * limitations under the License. 676 */var iD=function(){function t(t){this.comparator=t?function(e,n){return t(e,n)||G.comparator(e.key,n.key)}:function(t,e){return G.comparator(t.key,e.key)},this.keyedMap=ef,this.sortedSet=new es(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)||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}(),iA=function(){function t(){this.Qr=new es(G.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}):v():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}(),ik=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,iD.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)&&tR(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}(),ix=function(){this.Wr=void 0,this.listeners=[]},iC=function(){this.queries=new rt(function(t){return tL(t)},tR),this.onlineState="Unknown",this.Gr=new Set};/** 677 * @license 678 * Copyright 2017 Google LLC 679 * 680 * Licensed under the Apache License, Version 2.0 (the "License");
681 * you may not use this file except in compliance with the License. 682 * You may obtain a copy of the License at 683 * 684 * http://www.apache.org/licenses/LICENSE-2.0 685 * 686 * Unless required by applicable law or agreed to in writing, software 687 * distributed under the License is distributed on an "AS IS" BASIS, 688 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 689 * See the License for the specific language governing permissions and 690 * limitations under the License. 691 */function iR(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:if(n=t,i=e.query,o=!1,(s=n.queries.get(i))||(o=!0,s=new ix),!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=iN(r.sent(),"Initialization of query '"+tO(e.query)+"' failed"),[2,void e.onError(a)];case 4:return n.queries.set(i,s),s.listeners.push(e),e.zr(n.onlineState),s.Wr&&e.Hr(s.Wr)&&iF(n),[2]}})})}function iL(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=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 iO(t,e){for(var n=!1,r=0;r<e.length;r++){var i=e[r],o=i.query,s=t.queries.get(o);if(s){for(var u=0,a=s.listeners;u<a.length;u++)a[u].Hr(i)&&(n=!0);s.Wr=i}}n&&iF(t)}function iP(t,e,n){var r=t.queries.get(e);if(r)for(var i=0,o=r.listeners;i<o.length;i++)o[i].onError(n);t.queries.delete(e)}function iF(t){t.Gr.forEach(function(t){t.next()})}var iM=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 ik(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){return!t.fromCache||!(this.options.so&&"Offline"!==e||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=ik.fromInitialDocuments(t.query,t.docs,t.mutatedKeys,t.fromCache),this.Yr=!0,this.Jr.next(t)},t}(),iV=function(){function t(t,e){this.payload=t,this.byteLength=e}return t.prototype.io=function(){return"metadata"in this.payload},t}(),iq=function(){function t(t){this.R=t}return t.prototype.qn=function(t){return eP(this.R,t)},t.prototype.Un=function(t){return t.metadata.exists?eG(this.R,t.document,!1):tn.newNoDocument(this.qn(t.metadata.name),this.Kn(t.metadata.readTime))},t.prototype.Kn=function(t){return eC(t)},t}();!function(){function t(t,e,n){this.ro=t,this.localStore=e,this.R=n,this.queries=[],this.documents=[],this.progress={taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:t.totalDocuments,totalBytes:t.totalBytes}}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 iq(this.R),r=0;r<t.length;r++){var i=t[r];if(i.metadata.queries)for(var o=n.qn(i.metadata.name),s=0,u=i.metadata.queries;s<u.length;s++){var a=u[s],c=(e.get(a)||ey()).add(o);e.set(a,c)}}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(s){switch(s.label){case 0:return[4,function(t,e,n,i){return(0,r.mG)(this,void 0,void 0,function(){var o,s,u,a,c,h,l,f,d,p;return(0,r.Jh)(this,function(r){switch(r.label){case 0:for(o=t,s=ey(),u=el,a=ed,c=0,h=n;c<h.length;c++)l=h[c],f=e.qn(l.metadata.name),l.document&&(s=s.add(f)),u=u.insert(f,e.Un(l)),a=a.insert(f,e.Kn(l.metadata.readTime));return d=o.On.newChangeBuffer({trackRemovals:!0}),[4,rT(o,tx(tE(D.fromString("__bundle__/docs/"+i))))];case 1:return p=r.sent(),[2,o.persistence.runTransaction("Apply bundle documents","readwrite",function(t){return rI(t,d,u,T.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})})})]}})})}(this.localStore,new iq(this.R),this.documents,this.ro.id)];case 1:t=s.sent(),e=this.co(this.documents),n=0,i=this.queries,s.label=2;case 2:return n<i.length?(o=i[n],[4,function(t,e,n){return void 0===n&&(n=ey()),(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,rT(t,tx(nP(e.bundledQuery)))];case 1:return i=r.sent(),[2,(o=t).persistence.runTransaction("Save named query","readwrite",function(t){var r=eC(e.readTime);if(i.snapshotVersion.compareTo(r)>=0)return o.Ke.saveNamedQuery(t,e);var s=i.withResumeToken(C.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)})})]}})})}(this.localStore,o,e.get(o.name))]):[3,5];case 3:s.sent(),s.label=4;case 4:return n++,[3,2];case 5:return[2,(this.progress.taskState="Success",new rp(Object.assign({},this.progress),t))]}})})}}();/** 692 * @license 693 * Copyright 2017 Google LLC 694 * 695 * Licensed under the Apache License, Version 2.0 (the "License");
696 * you may not use this file except in compliance with the License. 697 * You may obtain a copy of the License at 698 * 699 * http://www.apache.org/licenses/LICENSE-2.0 700 * 701 * Unless required by applicable law or agreed to in writing, software 702 * distributed under the License is distributed on an "AS IS" BASIS, 703 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 704 * See the License for the specific language governing permissions and 705 * limitations under the License. 706 */var iU=function(t){this.key=t},iG=function(t){this.key=t},iB=function(){function t(t,e){this.query=t,this.uo=e,this.ao=null,this.current=!1,this.ho=ey(),this.mutatedKeys=ey(),this.lo=tF(t),this.fo=new iD(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 iA,i=e?e.fo:this.fo,o=e?e.mutatedKeys:this.mutatedKeys,s=i,u=!1,a=t_(this.query)&&i.size===this.query.limit?i.last():null,c=tS(this.query)&&i.size===this.query.limit?i.first():null;if(t.inorderTraversal(function(t,e){var h=i.get(t),l=tP(n.query,e)?e:null,f=!!h&&n.mutatedKeys.has(h.key),d=!!l&&(l.hasLocalMutations||n.mutatedKeys.has(l.key)&&l.hasCommittedMutations),p=!1;h&&l?h.data.isEqual(l.data)?f!==d&&(r.track({type:3,doc:l}),p=!0):n.yo(h,l)||(r.track({type:2,doc:l}),p=!0,(a&&n.lo(l,a)>0||c&&0>n.lo(l,c))&&(u=!0)):!h&&l?(r.track({type:0,doc:l}),p=!0):h&&!l&&(r.track({type:1,doc:h}),p=!0,(a||c)&&(u=!0)),p&&(l?(s=s.add(l),o=d?o.add(t):o.delete(t)):(s=s.delete(t),o=o.delete(t)))}),t_(this.query)||tS(this.query))for(;s.size>this.query.limit;){var h=t_(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){var n,i,o;return n=t.type,i=e.type,(o=function(t){switch(t){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return v()}})(n)-o(i)||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 ik(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 iA,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=ey(),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 iG(e))}),this.ho.forEach(function(t){e.has(t)||n.push(new iU(t))}),n},t.prototype.Ao=function(t){this.uo=t.Bn,this.ho=ey();var e=this._o(t.documents);return this.applyChanges(e,!0)},t.prototype.Ro=function(){return ik.fromInitialDocuments(this.query,this.fo,this.mutatedKeys,0===this.ao)},t}(),ij=function(t,e,n){this.query=t,this.targetId=e,this.view=n},iK=function(t){this.key=t,this.bo=!1},iQ=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 rt(function(t){return tL(t)},tR),this.Vo=new Map,this.So=new Set,this.Do=new es(G.comparator),this.Co=new Map,this.No=new rA,this.xo={},this.ko=new Map,this.Fo=n$.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 iz(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(s=(n=oa(t)).Po.get(e))?(i=s.targetId,n.sharedCl
706ientState.addLocalQueryTarget(i),o=s.view.Ro(),[3,4]):[3,1];case 1:return[4,rT(n.localStore,tx(e))];case 2:return u=r.sent(),a=n.sharedClientState.addLocalQueryTarget(u.targetId),[4,iJ(n,e,i=u.targetId,"current"===a)];case 3:o=r.sent(),n.isPrimaryClient&&ie(n.remoteStore,u),r.label=4;case 4:return[2,o]}})})}function iJ(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(l){switch(l.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,r_(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,(i6(t,e.targetId,u.To),u.snapshot)]}})})}(t,e,n,i)},[4,r_(t.localStore,e,!0)];case 1:return o=l.sent(),u=(s=new iB(e,o.Bn))._o(o.documents),a=eg.createSynthesizedTargetChangeForCurrentChange(n,i&&"Offline"!==t.onlineState),c=s.applyChanges(u,t.isPrimaryClient,a),i6(t,n,c.To),h=new ij(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 iW(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 i=(n=t).Po.get(e),(o=n.Vo.get(i.targetId)).length>1?[2,(n.Vo.set(i.targetId,o.filter(function(t){return!tR(t,e)})),void n.Po.delete(e))]:n.isPrimaryClient?(n.sharedClientState.removeLocalQueryTarget(i.targetId),n.sharedClientState.isActiveQueryTarget(i.targetId)?[3,2]:[4,rE(n.localStore,i.targetId,!1).then(function(){n.sharedClientState.clearQueryState(i.targetId),ir(n.remoteStore,i.targetId),i3(n,i.targetId)}).catch(n4)]):[3,3];case 1:r.sent(),r.label=2;case 2:return[3,5];case 3:return i3(n,i.targetId),[4,rE(n.localStore,i.targetId,!0)];case 4:r.sent(),r.label=5;case 5:return[2]}})})}function iH(t,e,n){return(0,r.mG)(this,void 0,void 0,function(){var i,o,s;return(0,r.Jh)(this,function(r){var u,a,c,h,l,f,d;switch(r.label){case 0:i=oc(t),r.label=1;case 1:return r.trys.push([1,5,,6]),[4,(u=i.localStore,c=I.now(),h=e.reduce(function(t,e){return t.add(e.key)},ey()),u.persistence.runTransaction("Locally write mutations","readwrite",function(t){return u.Mn.pn(t,h).next(function(n){a=n;for(var r=[],i=0;i<e.length;i++){var o=e[i],s=function(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=tG(o.transform,s||null);null!=u&&(null==n&&(n=te.empty()),n.set(o.field,u))}return n||null}(o,a.get(o.key));null!=s&&r.push(new t5(o.key,s,function t(e){var n=[];return _(e.fields,function(e,r){var i=new k([e]);if(X(r)){var o=t(r.mapValue).fields;if(0===o.length)n.push(i);else for(var s=0;s<o.length;s++){var u=o[s];n.push(i.child(u))}}else n.push(i)}),new x(n)}(s.value.mapValue),t$.exists(!0)))}return u._n.addMutationBatch(t,c,r,e)})}).then(function(t){return t.applyToLocalDocumentSet(a),{batchId:t.batchId,changes:a}}))];case 2:return o=r.sent(),i.sharedClientState.addPendingMutation(o.batchId),l=i,f=o.batchId,(d=l.xo[l.currentUser.toKey()])||(d=new es(w)),d=d.insert(f,n),l.xo[l.currentUser.toKey()]=d,[4,i9(i,o.changes)];case 3:return r.sent(),[4,iy(i.remoteStore)];case 4:return r.sent(),[3,6];case 5:return s=iN(r.sent(),"Failed to persist write"),n.reject(s),[3,6];case 6:return[2]}})})}function iZ(t,e){return(0,r.mG)(this,void 0,void 0,function(){var n,i;return(0,r.Jh)(this,function(r){var o,s,u;switch(r.label){case 0:n=t,r.label=1;case 1:return r.trys.push([1,4,,6]),[4,(o=n.localStore,s=e.snapshotVersion,u=o.kn,o.persistence.runTransaction("Apply remote event","readwrite-primary",function(t){var n=o.On.newChangeBuffer({trackRemovals:!0});u=o.kn;var r=[];
706e.targetChanges.forEach(function(e,n){var i=u.get(n);if(i){r.push(o.qe.removeMatchingKeys(t,e.removedDocuments,n).next(function(){return o.qe.addMatchingKeys(t,e.addedDocuments,n)}));var a=e.resumeToken;if(a.approximateByteSize()>0){var c=i.withResumeToken(a,s).withSequenceNumber(t.currentSequenceNumber);u=u.insert(n,c),c.resumeToken.approximateByteSize()>0||v(),(0===i.resumeToken.approximateByteSize()||c.snapshotVersion.toMicroseconds()-i.snapshotVersion.toMicroseconds()>=3e8||e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size>0)&&r.push(o.qe.updateTargetData(t,c))}}});var i=el;if(e.documentUpdates.forEach(function(n,i){e.resolvedLimboDocuments.has(n)&&r.push(o.persistence.referenceDelegate.updateLimboDocument(t,n))}),r.push(rI(t,n,e.documentUpdates,s,void 0).next(function(t){i=t})),!s.isEqual(T.min())){var a=o.qe.getLastRemoteSnapshotVersion(t).next(function(e){return o.qe.setTargetsMetadata(t,t.currentSequenceNumber,s)});r.push(a)}return nh.waitFor(r).next(function(){return n.apply(t)}).next(function(){return o.Mn.En(t,i)}).next(function(){return i})}).then(function(t){return o.kn=u,t}))];
706case 2:return i=r.sent(),e.targetChanges.forEach(function(t,e){var r=n.Co.get(e);r&&(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1||v(),t.addedDocuments.size>0?r.bo=!0:t.modifiedDocuments.size>0?r.bo||v():t.removedDocuments.size>0&&(r.bo||v(),r.bo=!1))}),[4,i9(n,i,e)];case 3:case 5:return r.sent(),[3,6];case 4:return[4,n4(r.sent())];case 6:return[2]}})})}function iY(t,e,n){if(t.isPrimaryClient&&0===n||!t.isPrimaryClient&&1===n){var r,i,o=[];t.Po.forEach(function(t,n){var r=n.view.zr(e);r.snapshot&&o.push(r.snapshot)}),(r=t.eventManager).onlineState=e,i=!1,r.queries.forEach(function(t,n){for(var r=0,o=n.listeners;r<o.length;r++)o[r].zr(e)&&(i=!0)}),i&&iF(r),o.length&&t.vo._r(o),t.onlineState=e,t.isPrimaryClient&&t.sharedClientState.setOnlineState(e)}}function i$(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(i=t).sharedClientState.updateQueryState(e,"rejected",n),(s=(o=i.Co.get(e))&&o.key)?(u=(u=new es(G.comparator)).insert(s,tn.newNoDocument(s,T.min())),a=ey().add(s),[4,iZ(i,new ev(T.min(),new Map,new ec(w),u,a))]):[3,2];case 1:return r.sent(),i.Do=i.Do.remove(s),i.Co.delete(e),i8(i),[3,4];case 2:return[4,rE(i.localStore,e,!1).then(function(){return i3(i,e,n)}).catch(n4)];case 3:r.sent(),r.label=4;case 4:return[2]}})})}function iX(t,e){return(0,r.mG)(this,void 0,void 0,function(){var n,i,o;return(0,r.Jh)(this,function(r){var s;switch(r.label){case 0:n=t,i=e.batch.batchId,r.label=1;case 1:return r.trys.push([1,4,,6]),[4,(s=n.localStore).persistence.runTransaction("Acknowledge batch","readwrite-primary",function(t){var n,r,i,o=e.batch.keys(),u=s.On.newChangeBuffer({trackRemovals:!0});return(r=(n=e.batch).keys(),i=nh.resolve(),r.forEach(function(r){i=i.next(function(){return u.getEntry(t,r)}).next(function(t){var i=e.docVersions.get(r);null!==i||v(),0>t.version.compareTo(i)&&(n.applyToRemoteDocument(t,e),t.isValidDocument()&&u.addEntry(t,e.commitVersion))})}),i.next(function(){return s._n.removeMutationBatch(t,n)})).next(function(){return u.apply(t)}).next(function(){return s._n.performConsistencyCheck(t)}).next(function(){return s.Mn.pn(t,o)})})];case 2:return o=r.sent(),i4(n,i,null),i2(n,i),n.sharedClientState.updateMutationState(i,"acknowledged"),[4,i9(n,o)];case 3:case 5:return r.sent(),[3,6];case 4:return[4,n4(r.sent())];case 6:return[2]}})})}function i0(t,e,n){return(0,r.mG)(this,void 0,void 0,function(){var i,o;return(0,r.Jh)(this,function(r){var s;switch(r.label){case 0:i=t,r.label=1;case 1:return r.trys.push([1,4,,6]),[4,(s=i.localStore).persistence.runTransaction("Reject batch","readwrite-primary",function(t){var n;return s._n.lookupMutationBatch(t,e).next(function(e){return null!==e||v(),n=e.keys(),s._n.removeMutationBatch(t,e)}).next(function(){return s._n.performConsistencyCheck(t)}).next(function(){return s.Mn.pn(t,n)})})];case 2:return o=r.sent(),i4(i,e,n),i2(i,e),i.sharedClientState.updateMutationState(e,"rejected",n),[4,i9(i,o)];case 3:case 5:return r.sent(),[3,6];case 4:return[4,n4(r.sent())];case 6:return[2]}})})}function i1(t,e){return(0,r.mG)(this,void 0,void 0,function(){var n,i,o,s;return(0,r.Jh)(this,function(r){var u;switch(r.label){case 0:ia((n=t).remoteStore)||d("SyncEngine","The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled."),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,(u=n.localStore).persistence.runTransaction("Get highest unacknowledged batch id","readonly",function(t){return u._n.getHighestUnacknowledgedBatchId(t)})];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=iN(r.sent(),"Initialization of waitForPendingWrites() operation failed"),e.reject(s),[3,4];case 4:return[2]}})})}function i2(t,e){(t.ko.get(e)||[]).forEach(function(t){t.resolve()}),t.ko.delete(e)}function i4(t,e,n){var r=t.xo[t.currentUser.toKey()];if(r){var i=r.get(e);i&&(n?i.reject(n):i.resolve(),r=r.remove(e)),t.xo[t.currentUser.toKey()]=r}}
706function i3(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)||i5(t,e)})}function i5(t,e){t.So.delete(e.path.canonicalString());var n=t.Do.get(e);null!==n&&(ir(t.remoteStore,n),t.Do=t.Do.remove(e),t.Co.delete(n),i8(t))}function i6(t,e,n){for(var r=0;r<n.length;r++){var i=n[r];i instanceof iU?(t.No.addReference(i.key,e),function(t,e){var n=e.key,r=n.path.canonicalString();t.Do.get(n)||t.So.has(r)||(d("SyncEngine","New document in limbo: "+n),t.So.add(r),i8(t))}(t,i)):i instanceof iG?(d("SyncEngine","Document no longer in limbo: "+i.key),t.No.removeReference(i.key,e),t.No.containsKey(i.key)||i5(t,i.key)):v()}}function i8(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 G(D.fromString(e)),r=t.Fo.next();t.Co.set(r,new iK(n)),t.Do=t.Do.insert(n,r),ie(t.remoteStore,new n_(tx(tE(n.path)),r,2,a.o))}}function i9(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 o=[],s=[],u=[],(i=t).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=rm.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,l;return(0,r.Jh)(this,function(r){switch(r.label){case 0:n=t,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,n.persistence.runTransaction("notifyLocalViewChanges","readwrite",function(t){return nh.forEach(e,function(e){return nh.forEach(e.bn,function(r){return n.persistence.referenceDelegate.addReference(t,e.targetId,r)}).next(function(){return nh.forEach(e.vn,function(r){return n.persistence.referenceDelegate.removeReference(t,e.targetId,r)})})})})];case 2:return r.sent(),[3,4];case 3:if(!ny(i=r.sent()))throw i;return d("LocalStore","Failed to update sequence numbers: "+i),[3,4];case 4:for(o=0,s=e;o<s.length;o++)a=(u=s[o]).targetId,u.fromCache||(h=(c=n.kn.get(a)).snapshotVersion,l=c.withLastLimboFreeSnapshotVersion(h),n.kn=n.kn.insert(a,l));return[2]}})})}(i.localStore,s)];case 2:a.sent(),a.label=3;case 3:return[2]}})})}function i7(t,e){return(0,r.mG)(this,void 0,void 0,function(){var n,i;return(0,r.Jh)(this,function(r){var o;switch(r.label){case 0:return(n=t).currentUser.isEqual(e)?[3,3]:(d("SyncEngine","User change. New user:",e.toKey()),[4,rw(n.localStore,e)]);case 1:return i=r.sent(),n.currentUser=e,(o=n).ko.forEach(function(t){t.forEach(function(t){t.reject(new h(c.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),o.ko.clear(),n.sharedClientState.handleUserChange(e,i.removedBatchIds,i.addedBatchIds),[4,i9(n,i.Ln)];case 2:r.sent(),r.label=3;case 3:return[2]}})})}function ot(t,e){var n=t.Co.get(e);if(n&&n.bo)return ey().add(n.key);var r=ey(),i=t.Vo.get(e);if(!i)return r;for(var o=0;o<i.length;o++){var s=i[o],u=t.Po.get(s);r=r.unionWith(u.view.wo)}return r}function oe(t){return(0,r.mG)(this,void 0,void 0,function(){var e;return(0,r.Jh)(this,function(n){return[2,rN((e=t).localStore).then(function(t){return i9(e,t)})]})})}function on(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:var u,a;return[4,(a=(u=(o=t).localStore)._n,u.persistence.runTransaction("Lookup mutation documents","readonly",function(t){return a.jt(t,e).next(function(e){return e?u.Mn.pn(t,e):nh.resolve(null)})}))];case 1:return null===(s=r.sent())?[3,6]:"pending"!==n?[3,3]:[4,iy(o.remoteStore)];case 2:return r.sent(),[3,4];case 3:"acknowledged"===n||"rejected"===n?(i4(o,e,i||null),i2(o,e),function(t,e){t._n.Gt(e)}(o.localStore,e)):v(),r.label=4;case 4:return[4,i9(o,s)];case 5:return r.sent(),[3,7];case 6:d("SyncEngine","Cannot apply mutation batch with id: "+e),r.label=7;case 7:return[2]}})})}function or(t,e,n){return(0,r.mG)(this,void 0,void 0,function(){var n,i,o,s,u,a,c,h,l,f,d,p,y,m;return(0,r.Jh)(this,function(v){switch(v.label){case 0:n=t,i=[],o=[],s=0,u=e,v.label=1;case 1:return s<u.length?(a=u[s],c=void 0,(h=n.Vo.get(a))&&0!==h.length?[4,rT(n.localStore,tx(h[0]))]:[3,7]):[3,13];case 2:c=v.sent(),l=0,f=h,v.label=3;case 3:return l<f.length?(d=f[l],p=n.Po.get(d),[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[4,r_((n=t).localStore,e.query,!0)];case 1:return i=r.sent(),o=e.view.Ao(i),[2,(n.isPrimaryClient&&i6(n,e.targetId,o.To),o)]}})})}(n,p)]):[3,6];case 4:(y=v.sent()).snapshot&&o.push(y.snapshot),v.label=5;case 5:return l++,[3,3];case 6:return[3,11];case 7:return[4,rS(n.localStore,a)];case 8:return m=v.sent(),[4,rT(n.localStore,m)];case 9:return c=v.sent(),[4,iJ(n,oi(m),a,!1)];case 10:v.sent(),v.label=11;case 11:i.push(c),v.label=12;case 12:return s++,[3,1];case 13:return[2,(n.vo._r(o),i)]}})})}function oi(t){var e,n,r,i,o,s,u;return e=t.path,n=t.collectionGroup,r=t.orderBy,i=t.filters,o=t.limit,s=t.startAt,u=t.endAt,new tT(e,n,r,i,o,"F",s,u)}function oo(t){return t.localStore.persistence.fn()}function os(t,e,n,i){return(0,r.mG)(this,void 0,void 0,function(){var o;return(0,r.Jh)(this,function(r){switch(r.label){case 0:return(o=t).$o?(d("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,rN(o.localStore)];case 3:return[4,i9(o,r.sent(),ev.createSynthesizedRemoteEventForCurrentChange(e,"current"===n))];case 4:return r.sent(),[3,8];case 5:return[4,rE(o.localStore,e,!0)];case 6:return r.sent(),i3(o,e,i),[3,8];case 7:v(),r.label=8;case 8:return[2]}})})}function ou(t,e,n){return(0,r.mG)(this,void 0,void 0,function(){var i,o,s,u,a,c,h,l,f;return(0,r.Jh)(this,function(p){switch(p.label){case 0:if(!(i=oa(t)).$o)return[3,10];o=0,s=e,p.label=1;case 1:return o<s.length?(u=s[o],i.Vo.has(u)?(d("SyncEngine","Adding an already active target "+u),[3,5]):[4,rS(i.localStore,u)]):[3,6];case 2:return a=p.sent(),[4,rT(i.localStore,a)];case 3:return c=p.sent(),[4,iJ(i,oi(a),c.targetId,!1)];case 4:p.sent(),ie(i.remoteStore,c),p.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,rE(i.localStore,t,!1).then(function(){ir(i.remoteStore,t),i3(i,t)}).catch(n4)]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}})},l=0,f=n,p.label=7;case 7:return l<f.length?[5,h(f[l])]:[3,10];case 8:p.sent(),p.label=9;case 9:return l++,[3,7];case 10:return[2]}})})}function oa(t){return t.remoteStore.remoteSyncer.applyRemoteEvent=iZ.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=ot.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=i$.bind(null,t),t.vo._r=iO.bind(null,t.eventManager),t.vo.Mo=iP.bind(null,t.eventManager),t}function oc(t){return t.remoteStore.remoteSyncer.applySuccessfulWrite=iX.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=i0.bind(null,t),t}var oh=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=r1(t.databaseInfo.databaseId),this.sharedCl
706ientState=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){var e,n,r,i;return e=this.persistence,n=new rv,r=t.initialUser,i=this.R,new rg(e,n,r,i)},t.prototype.qo=function(t){return new rO(rF.bs,this.R)},t.prototype.Bo=function(t){return new rJ},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}(),ol=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(i){switch(i.label){case 0:return[4,t.prototype.initialize.call(this,e)];case 1:return i.sent(),[4,function(t){return(0,r.mG)(this,void 0,void 0,function(){var e;return(0,r.Jh)(this,function(n){return[2,(e=t).persistence.runTransaction("Synchronize last document change read time","readonly",function(t){var e,n;return e=ro(t),n=T.min(),e.$t({index:e8.readTimeIndex,reverse:!0},function(t,e,r){e.readTime&&(n=nk(e.readTime)),r.done()}).next(function(){return n})}).then(function(t){e.$n=t})]})})}(this.localStore)];case 2:return i.sent(),[4,this.Qo.initialize(this,e)];case 3:return i.sent(),[4,oc(this.Qo.syncEngine)];case 4:return i.sent(),[4,iy(this.Qo.remoteStore)];case 5:return i.sent(),[4,this.persistence.He(function(){return n.gcScheduler&&!n.gcScheduler.started&&n.gcScheduler.start(n.localStore),Promise.resolve()})];case 6:return i.sent(),[2]}})})},e.prototype.Ko=function(t){var e,n,r,i;return e=this.persistence,n=new rv,r=t.initialUser,i=this.R,new rg(e,n,r,i)},e.prototype.Uo=function(t){var e=this.persistence.referenceDelegate.garbageCollector;return new n6(e,t.asyncQueue)},e.prototype.qo=function(t){var e=rd(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey),n=void 0!==this.cacheSizeBytes?nK.withCacheSize(this.cacheSizeBytes):nK.DEFAULT;return new rh(this.synchronizeTabs,e,t.clientId,n,t.asyncQueue,rX(),r0(),this.R,this.sharedClientState,!!this.forceOwnership)},e.prototype.Bo=function(t){return new rJ},e}(oh),of=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 rz?(this.sharedClientState.syncEngine={ui:on.bind(null,n),ai:os.bind(null,n),hi:ou.bind(null,n),fn:oo.bind(null,n),ci:oe.bind(null,n)},[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,function(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){var l;switch(r.label){case 0:return oa(n=t),oc(n),!0!==e||!0===n.$o?[3,3]:(i=n.sharedClientState.getAllActiveQueryTargets(),[4,or(n,i.toArray())]);case 1:return o=r.sent(),n.$o=!0,[4,iT(n.remoteStore,!0)];case 2:for(r.sent(),s=0,u=o;s<u.length;s++)a=u[s],ie(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 i3(n,e),rE(n.localStore,e,!0)}),ir(n.remoteStore,e)}),[4,h]);case 4:return r.sent(),[4,or(n,c)];case 5:return r.sent(),(l=n).Co.forEach(function(t,e){ir(l.remoteStore,e)}),l.No.ts(),l.Co=new Map,l.Do=new es(G.comparator),n.$o=!1,[4,iT(n.remoteStore,!1)];case 6:r.sent(),r.label=7;case 7:return[2]}})})}(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=rX();
706if(!rz.yt(e))throw new h(c.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");var n=rd(t.databaseInfo.databaseId,t.databaseInfo.persistenceKey);return new rz(e,t.asyncQueue,n,t.clientId,t.initialUser)},e}(ol),od=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 iY(n.syncEngine,t,1)},this.remoteStore.remoteSyncer.handleCredentialChange=i7.bind(null,this.syncEngine),[4,iT(this.remoteStore,this.syncEngine.isPrimaryClient)]);case 1:r.sent(),r.label=2;case 2:return[2]}})})},t.prototype.createEventManager=function(t){return new iC},t.prototype.createDatastore=function(t){var e,n,r=r1(t.databaseInfo.databaseId),i=(n=t.databaseInfo,new r$(n));return e=t.credentials,new r6(e,i,r)},t.prototype.createRemoteStore=function(t){var e,n,r,i,o=this;return e=this.localStore,n=this.datastore,r=t.asyncQueue,i=rH.yt()?new rH:new rW,new r9(e,n,r,function(t){return iY(o.syncEngine,t,0)},i)},t.prototype.createSyncEngine=function(t,e){var n,r,i,o,s,u,a;return n=this.localStore,r=this.remoteStore,i=this.eventManager,o=this.sharedClientState,s=t.
706initialUser,u=t.maxConcurrentLimboResolutions,a=new iQ(n,r,i,o,s,u),e&&(a.$o=!0),a},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=t,d("RemoteStore","RemoteStore shutting down."),e.Or.add(5),[4,it(e)];case 1:return n.sent(),e.Lr.shutdown(),e.Br.set("Unknown"),[2]}})})}(this.remoteStore)},t}(),op=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}(),oy=(function(){function t(t,e){var n=this;this.Go=t,this.R=e,this.metadata=new nc,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(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]:(isNaN(n=Number(e=this.zo.decode(t)))&&this.Yo("length string ("+e+") is not valid number"),[4,this.Xo(n)]);case 2:return i=r.sent(),[2,new iV(JSON.parse(i),t.length+n)]}})})},t.prototype.Zo=function(){return this.buffer.findIndex(function(t){return 123===t})},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 0>this.Zo()?[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(),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 h(c.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 i=eV((n=t).R)+"/documents",o={documents:e.map(function(t){return eO(n.R,t)})},[4,n.$i("BatchGetDocuments",i,o)];
706case 1:return s=r.sent(),u=new Map,s.forEach(function(t){var e,r,i,o,s,a,c=(e=n.R,"found"in t?(t.found||v(),t.found.name,t.found.updateTime,r=eP(e,t.found.name),i=eC(t.found.updateTime),o=new te({mapValue:{fields:t.found.fields}}),tn.newFoundDocument(r,i,o)):"missing"in t?(t.missing||v(),t.readTime||v(),s=eP(e,t.missing),a=eC(t.readTime),tn.newNoDocument(s,a)):v());u.set(c.key.toString(),c)}),a=[],[2,(e.forEach(function(t){var e=u.get(t.toString());e||v(),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 ee(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=G.fromPath(n);e.mutations.push(new en(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 i=eV((n=t).R)+"/documents",o={writes:e.map(function(t){return eB(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){if(t.isFoundDocument())e=t.version;else{if(!t.isNoDocument())throw v();e=T.min()}var e,n=this.readVersions.get(t.key.toString());if(n){if(!e.isEqual(n))throw new h(c.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?t$.updateTime(e):t$.none()},t.prototype.preconditionForUpdate=function(t){var e=this.readVersions.get(t.toString());if(!this.writtenDocs.has(t.toString())&&e){if(e.isEqual(T.min()))throw new h(c.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return t$.updateTime(e)}return t$.exists(!0)},t.prototype.write=function(t){this.ensureCommitNotCalled(),this.mutations.push(t)},t.prototype.ensureCommitNotCalled=function(){},t}()),om=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 r2(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 oy(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!V(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||!ei(e)}return!1},t}(),ov=function(){function t(t,e,n){var i=this;this.credentials=t,this.asyncQueue=e,this.databaseInfo=n,this.user=rM.UNAUTHENTICATED,this.clientId=g.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 d("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 h(c.FAILED_PRECONDITION,"The client has already been terminated.")},t.prototype.terminate=function(){var t=this;this.asyncQueue.enterRestrictedMode();var e=new nc;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(function(){return(0,r.mG)(t,void 0,void 0,function(){var t;return(0,r.Jh)(this,function(n){switch(n.label){case 0:return n.trys.push([0,5,,6]),this.onlineComponents?[4,this.onlineComponents.terminate()]:[3,2];case 1:n.sent(),n.label=2;case 2:return this.offlineComponents?[4,this.offlineComponents.terminate()]:[3,4];case 3:n.sent(),n.label=4;case 4:return this.credentials.removeChangeListener(),e.resolve(),[3,6];case 5:return t=iN(n.sent(),"Failed to shutdown persistence"),e.reject(t),[3,6];case 6:return[2]}})})}),e.promise},t}();/** 707 * @license 708 * Copyright 2020 Google LLC 709 * 710 * Licensed under the Apache License, Version 2.0 (the "License");
711 * you may not use this file except in compliance with the License. 712 * You may obtain a copy of the License at 713 * 714 * http://www.apache.org/licenses/LICENSE-2.0 715 * 716 * Unless required by applicable law or agreed to in writing, software 717 * distributed under the License is distributed on an "AS IS" BASIS, 718 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 719 * See the License for the specific language governing permissions and 720 * limitations under the License. 721 */function og(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(),d("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,rw(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 ow(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,ob(t)];case 1:return n=o.sent(),d("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=t).asyncQueue.verifyOperationInProgress(),d("RemoteStore","RemoteStore received new credentials"),i=ia(n),n.Or.add(3),[4,it(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,r7(n)];case 3:return r.sent(),[2]}})})}(e.remoteStore,t)}),t.onlineComponents=e,[2]}})})}function ob(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]:(d("FirestoreClient","Using default OfflineComponentProvider"),[4,og(t,new oh)]);case 1:e.sent(),e.label=2;case 2:return[2,t.offlineComponents]}})})}function oI(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]:(d("FirestoreClient","Using default OnlineComponentProvider"),[4,ow(t,new od)]);case 1:e.sent(),e.label=2;case 2:return[2,t.onlineComponents]}})})}function oT(t){return ob(t).then(function(t){return t.persistence})}function oE(t){return ob(t).then(function(t){return t.localStore})}function o_(t){return oI(t).then(function(t){return t.remoteStore})}function oS(t){return oI(t).then(function(t){return t.syncEngine})}function oN(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,oI(t)];case 1:return[2,((n=(e=r.sent()).eventManager).onListen=iz.bind(null,e.syncEngine),n.onUnlisten=iW.bind(null,e.syncEngine),n)]}})})}function oD(t,e,n){var i=this;void 0===n&&(n={});var o=new nc;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 op({next:function(o){e.enqueueAndForget(function(){return iL(t,s)});var u=o.docs.has(n);!u&&o.fromCache?i.reject(new h(c.UNAVAILABLE,"Failed to get document because the client is offline.")):u&&o.fromCache&&r&&"server"===r.source?i.reject(new h(c.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 iM(tE(n.path),o,{includeMetadataChanges:!0,so:!0});return iR(t,s)},[4,oN(t)];case 1:return[2,i.apply(void 0,[r.sent(),t.asyncQueue,e,n,o])]}})})}),o.promise}function oA(t,e,n){var i=this;void 0===n&&(n={});var o=new nc;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 op({next:function(n){e.enqueueAndForget(function(){return iL(t,s)}),n.fromCache&&"server"===r.source?i.reject(new h(c.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 iM(n,o,{includeMetadataChanges:!0,so:!0});
721return iR(t,s)},[4,oN(t)];case 1:return[2,i.apply(void 0,[r.sent(),t.asyncQueue,e,n,o])]}})})}),o.promise}var ok=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},ox=function(){function t(t,e){this.projectId=t,this.database=e||"(default)"}return Object.defineProperty(t.prototype,"isDefaultDatabase",{get:function(){return"(default)"===this.database},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(e){return e instanceof t&&e.projectId===this.projectId&&e.database===this.database},t}(),oC=new Map,oR=function(t,e){this.user=e,this.type="OAuth",this.authHeaders={},this.authHeaders.Authorization="Bearer "+t},oL=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(rM.UNAUTHENTICATED)})},t.prototype.removeChangeListener=function(){this.changeListener=null},t}(),oO=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}(),oP=function(){function t(t){var e=this;this.currentUser=rM.UNAUTHENTICATED,this.oc=new nc,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){d("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):(d("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?(d("FirebaseCredentialsProvider","getToken aborted due to token change."),t.getToken()):n?("string"==typeof n.accessToken||v(),new oR(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 null===t||"string"==typeof t||v(),new rM(t)},t}(),oF=function(){function t(t,e,n){this.hc=t,this.lc=e,this.fc=n,this.type="FirstParty",this.user=rM.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}(),oM=function(){function t(t,e,n){this.hc=t,this.lc=e,this.fc=n}return t.prototype.getToken=function(){return Promise.resolve(new oF(this.hc,this.lc,this.fc))},t.prototype.setChangeListener=function(t,e){t.enqueueRetryable(function(){return e(rM.FIRST_PARTY)})},t.prototype.removeChangeListener=function(){},t.prototype.invalidateToken=function(){},t}();/** 722 * @license 723 * Copyright 2017 Google LLC 724 * 725 * Licensed under the Apache License, Version 2.0 (the "License"); 726 * you may not use this file except in compliance with the License. 727 * You may obtain a copy of the License at 728 * 729 * http://www.apache.org/licenses/LICENSE-2.0 730 * 731 * Unless required by applicable law or agreed to in writing, softw
731are 732 * distributed under the License is distributed on an "AS IS" BASIS, 733 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 734 * See the License for the specific language governing permissions and 735 * limitations under the License. 736 */function oV(t,e,n){if(!n)throw new h(c.INVALID_ARGUMENT,"Function "+t+"() cannot be called with an empty "+e+".")}function oq(t,e){if(void 0===e)return{merge:!1};if(void 0!==e.mergeFields&&void 0!==e.merge)throw new h(c.INVALID_ARGUMENT,"Invalid options passed to function "+t+'(): You cannot specify both "merge" and "mergeFields".');return e}function oU(t,e,n,r){if(!0===e&&!0===r)throw new h(c.INVALID_ARGUMENT,t+" and "+n+" cannot be used together.")}function oG(t){if(!G.isDocumentKey(t))throw new h(c.INVALID_ARGUMENT,"Invalid document reference. Document references must have an even number of segments, but "+t+" has "+t.length+".")}function oB(t){if(G.isDocumentKey(t))throw new h(c.INVALID_ARGUMENT,"Invalid collection reference. Collection references must have an odd number of segments, but "+t+" has "+t.length+".")}function oj(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":v()}function oK(t,e){if("_delegate"in t&&(t=t._delegate),!(t instanceof e)){if(e.name===t.constructor.name)throw new h(c.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");var n=oj(t);throw new h(c.INVALID_ARGUMENT,"Expected type '"+e.name+"', but it was: "+n)}return t}function oQ(t,e){if(e<=0)throw new h(c.INVALID_ARGUMENT,"Function "+t+"() requires a positive number, but it was: "+e+".")}/** 737 * @license 738 * Copyright 2020 Google LLC 739 * 740 * Licensed under the Apache License, Version 2.0 (the "License"); 741 * you may not use this file except in compliance with the License. 742 * You may obtain a copy of the License at 743 * 744 * http://www.apache.org/licenses/LICENSE-2.0 745 * 746 * Unless required by applicable law or agreed to in writing, software 747 * distributed under the License is distributed on an "AS IS" BASIS, 748 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 749 * See the License for the specific language governing permissions and 750 * limitations under the License. 751 */var oz=function(){function t(t){var e;if(void 0===t.host){if(void 0!==t.ssl)throw new h(c.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 h(c.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=t.cacheSizeBytes}this.experimentalForceLongPolling=!!t.experimentalForceLongPolling,this.experimentalAutoDetectLongPolling=!!t.experimentalAutoDetectLongPolling,this.useFetchStreams=!!t.useFetchStreams,oU("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}(),oJ=function(){function t(t,e){this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new oz({}),this._settingsFrozen=!1,t instanceof ox?(this._databaseId=t,this._credentials=new oL):(this._app=t,this._databaseId=function(t){if(!Object.prototype.hasOwnProperty.apply(t.options,["projectId"]))throw new h(c.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new ox(t.options.projectId)}(t),this._credentials=new oP(e))}return Object.defineProperty(t.prototype,"app",{get:function(){if(!this._app)throw new h(c.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}
751,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 h(c.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 oz(t),void 0!==t.credentials&&(this._credentials=function(t){if(!t)return new oL;switch(t.type){case"gapi":var e=t.client;return"object"==typeof e&&null!==e&&e.auth&&e.auth.getAuthHeaderValueForFirstParty||v(),new oM(e,t.sessionIndex||"0",t.iamToken||null);case"provider":return t.client;default:throw new h(c.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(){var t;return(t=oC.get(this))&&(d("ComponentProvider","Removing Datastore"),oC.delete(this),t.terminate()),Promise.resolve()},t}(),oW=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 oZ(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}(),oH=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}(),oZ=function(t){function e(e,n,r){var i=this;return(i=t.call(this,e,n,tE(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 oW(this.firestore,null,new G(t))},enumerable:!1,configurable:!0}),e.prototype.withConverter=function(t){return new e(this.firestore,t,this._path)},e}(oH);/** 752 * @license 753 * Copyright 2020 Google LLC 754 * 755 * Licensed under the Apache License, Version 2.0 (the "License"); 756 * you may not use this file except in compliance with the License. 757 * You may obtain a copy of the License at 758 * 759 * http://www.apache.org/licenses/LICENSE-2.0 760 * 761 * Unless required by applicable law or agreed to in writing, software 762 * distributed under the License is distributed on an "AS IS" BASIS, 763 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 764 * See the License for the specific language governing permissions and 765 * limitations under the License. 766 */function oY(t,e){for(var n,o=[],s=2;s<arguments.length;s++)o[s-2]=arguments[s];if(t=(0,i.m9)(t),oV("collection","path",e),t instanceof oJ)return oB(n=D.fromString.apply(D,(0,r.ev)([e],o))),new oZ(t,null,n);if(!(t instanceof oW||t instanceof oZ))throw new h(c.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return oB(n=D.fromString.apply(D,(0,r.ev)([t.path],o)).child(D.fromString(e))),new oZ(t.firestore,
766null,n)}function o$(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=g.u()),oV("doc","path",e),t instanceof oJ)return oG(n=D.fromString.apply(D,(0,r.ev)([e],o))),new oW(t,null,new G(n));if(!(t instanceof oW||t instanceof oZ))throw new h(c.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");return oG(n=t._path.child(D.fromString.apply(D,(0,r.ev)([e],o)))),new oW(t.firestore,t instanceof oZ?t.converter:null,new G(n))}function oX(t,e){return t=(0,i.m9)(t),e=(0,i.m9)(e),(t instanceof oW||t instanceof oZ)&&(e instanceof oW||e instanceof oZ)&&t.firestore===e.firestore&&t.path===e.path&&t.converter===e.converter}function o0(t,e){return t=(0,i.m9)(t),e=(0,i.m9)(e),t instanceof oH&&e instanceof oH&&t.firestore===e.firestore&&tR(t._query,e._query)&&t.converter===e.converter/** 767 * @license 768 * Copyright 2020 Google LLC 769 * 770 * Licensed under the Apache License, Version 2.0 (the "License"); 771 * you may not use this file except in compliance with the License. 772 * You may obtain a copy of the License at 773 * 774 * http://www.apache.org/licenses/LICENSE-2.0 775 * 776 * Unless required by applicable law or agreed to in writing, software 777 * distributed under the License is distributed on an "AS IS" BASIS, 778 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 779 * See the License for the specific language governing permissions and 780 * limitations under the License. 781 */}var o1=function(){function t(){var t=this;this.dc=Promise.resolve(),this.wc=[],this._c=!1,this.mc=[],this.yc=null,this.gc=!1,this.Ec=!1,this.Tc=[],this.Zi=new r2(this,"async_queue_retry"),this.Ic=function(){var e=r0();e&&d("AsyncQueue","Visibility state changed to "+e.visibilityState),t.Zi.Gi()};var e=r0();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=r0();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 nc;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(!ny(t=n.sent()))throw t;return d("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]}})})},t.prototype.Rc=function(t){var e=this,n=this.dc.then(function(){return e.gc=!0,t().catch(function(t){var n;throw e.yc=t,e.gc=!1,p("INTERNAL UNHANDLED ERROR: ",(n=t.message||"",t.stack&&(n=t.stack.includes(t.message)?t.stack:t.message+"\n"+t.stack),n)),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=iS.createAndSchedule(this,t,e,n,function(t){return r.vc(t)});return this.mc.push(i),i},t.prototype.Ac=function(){this.yc&&v()},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 o2(t){return function(t,e){if("object"!=typeof t||null===t)return!1;for(var n=0,r=["next","error","complete"];n<r.length;n++){var i=r[n];if(i in t&&"function"==typeof t[i])return!0}return!1}(t)}!function(){function t(){this._progressObserver={},this._taskCompletionResolver=new nc,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 o4=-1,o3=function(t){function e(e,n){var r=this;return(r=t.call(this,e,n)||this).type="firestore",r._queue=new o1,r._persistenceKey="name"in e?e.name:"[DEFAULT]",r}return(0,r.ZT)(e,t),e.prototype._terminate=function(){return this._firestoreClient||o6(this),this._firestoreClient.terminate()},e}(oJ);/** 782 * @license 783 * Copyright 2020 Google LLC 784 * 785 * Licensed under the Apache License, Version 2.0 (the "License");
786 * you may not use this file except in compliance with the License. 787 * You may obtain a copy of the License at 788 * 789 * http://www.apache.org/licenses/LICENSE-2.0 790 * 791 * Unless required by applicable law or agreed to in writing, software 792 * distributed under the License is distributed on an "AS IS" BASIS, 793 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 794 * See the License for the specific language governing permissions and 795 * limitations under the License. 796 */function o5(t){return t._firestoreClient||o6(t),t._firestoreClient.verifyNotTerminated(),t._firestoreClient}function o6(t){var e,n,r,i,o=t._freezeSettings(),s=(e=t._databaseId,n=(null===(i=t._app)||void 0===i?void 0:i.options.appId)||"",r=t._persistenceKey,new ok(e,n,r,o.host,o.ssl,o.experimentalForceLongPolling,o.experimentalAutoDetectLongPolling,o.useFetchStreams));t._firestoreClient=new ov(t._credentials,t._queue,s)}function o8(t,e,n){var i=this,o=new nc;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,og(t,n)];case 1:return r.sent(),[4,ow(t,e)];case 2:return r.sent(),o.resolve(),[3,4];case 3:var s;if(!("FirebaseError"===(s=i=r.sent()).name?s.code===c.FAILED_PRECONDITION||s.code===c.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&s instanceof DOMException)||22===s.code||20===s.code||11===s.code))throw i;return console.warn("Error enabling offline persistence. Falling back to persistence disabled: "+i),o.reject(i),[3,4];case 4:return[2]}})})}).then(function(){return o.promise})}function o9(t){if(t._initialized||t._terminated)throw new h(c.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.")}/** 797 * @license 798 * Copyright 2020 Google LLC 799 * 800 * Licensed under the Apache License, Version 2.0 (the "License"); 801 * you may not use this file except in compliance with the License. 802 * You may obtain a copy of the License at 803 * 804 * http://www.apache.org/licenses/LICENSE-2.0 805 * 806 * Unless required by applicable law or agreed to in writing, software 807 * distributed under the License is distributed on an "AS IS" BASIS, 808 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 809 * See the License for the specific language governing permissions and 810 * limitations under the License. 811 */var o7=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 h(c.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new k(t)}return t.prototype.isEqual=function(t){return this._internalPath.isEqual(t._internalPath)},t}(),st=function(){function t(t){this._byteString=t}return t.fromBase64String=function(e){try{return new t(C.fromBase64String(e))}catch(t){throw new h(c.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+t)}},t.fromUint8Array=function(e){return new t(C.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}(),se=function(t){this._methodName=t},sn=function(){function t(t,e){if(!isFinite(t)||t<-90||t>90)throw new h(c.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+t);if(!isFinite(e)||e<-180||e>180)throw new h(c.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 w(this._lat,t._lat)||w(this._long,t._long)},t}(),sr=/^__.*__$/,si=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 t5(t,this.data,this.fieldMask,e,this.fieldTransforms):new t3(t,this.data,e,this.fieldTransforms)},t}(),so=function(){function t(t,e,n){this.data=t,this.fieldMask=e,this.fieldTransforms=n}return t.prototype.toMutation=function(t,e){return new t5(t,this.data,this.fieldMask,e,this.fieldTransforms)},t}();/** 812 * @license 813 * Copyright 2020 Google LLC 814 * 815 * Licensed under the Apache License, Version 2.0 (the "License");
816 * you may not use this file except in compliance with the License. 817 * You may obtain a copy of the License at 818 * 819 * http://www.apache.org/licenses/LICENSE-2.0 820 * 821 * Unless required by applicable law or agreed to in writing, software 822 * distributed under the License is distributed on an "AS IS" BASIS, 823 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 824 * See the License for the specific language governing permissions and 825 * limitations under the License. 826 */function ss(t){switch(t){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw v()}}var su=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 sD(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(ss(this.Nc)&&sr.test(t))throw this.Lc('Document fields cannot begin and end with "__"')},t}(),sa=function(){function t(t,e,n){this.databaseId=t,this.ignoreUndefinedProperties=e,this.R=n||r1(t)}return t.prototype.Uc=function(t,e,n,r){return void 0===r&&(r=!1),new su({Nc:t,methodName:e,qc:n,path:k.emptyPath(),Fc:!1,Bc:r},this.databaseId,this.R,this.ignoreUndefinedProperties)},t}();function sc(t){var e=t._freezeSettings(),n=r1(t._databaseId);return new sa(t._databaseId,!!e.ignoreUndefinedProperties,n)}function sh(t,e,n,r,i,o){void 0===o&&(o={});var s=t.Uc(o.merge||o.mergeFields?2:0,e,n,i);sE("Data must be an object, but it was:",s,r);var u,a,l=sI(r,s);if(o.merge)u=new x(s.fieldMask),a=s.fieldTransforms;else if(o.mergeFields){for(var f=[],d=0,p=o.mergeFields;d<p.length;d++){var y=s_(e,p[d],n);if(!s.contains(y))throw new h(c.INVALID_ARGUMENT,"Field '"+y+"' is specified in your field mask but missing from your input data.");sA(f,y)||f.push(y)}u=new x(f),a=s.fieldTransforms.filter(function(t){return u.covers(t.field)})}else u=null,a=s.fieldTransforms;return new si(new te(l),u,a)}var sl=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}(se);function sf(t,e,n){return new su({Nc:3,qc:e.settings.qc,methodName:t._methodName,Fc:n},e.databaseId,e.R,e.ignoreUndefinedProperties)}var sd=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 tZ(t.path,new tB)},e.prototype.isEqual=function(t){return t instanceof e},e}(se),sp=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=sf(this,t,!0),n=this.Kc.map(function(t){return sb(t,e)}),r=new tj(n);return new tZ(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(se),sy=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=sf(this,t,!0),n=this.Kc.map(function(t){return sb(t,e)}),r=new tQ(n);return new tZ(t.path,r)},e.prototype.isEqual=function(t){return this===t},e}(se),sm=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 tJ(t.R,tq(t.R,this.Qc));return new tZ(t.path,e)},e.prototype.isEqual=function(t){return this===t},e}(se);function sv(t,e,n,r){var o=t.Uc(1,e,n);sE("Data must be an object, but it was:",o,r);var s=[],u=te.empty();_(r,function(t,r){var a=sN(e,t,n);r=(0,i.m9)(r);var c=o.Oc(a);if(r instanceof sl)s.push(a);else{var h=sb(r,c);null!=h&&(s.push(a),u.set(a,h))}});var a=new x(s);return new so(u,a,o.fieldTransforms)}function sg(t,e,n,r,o,s){var u=t.Uc(1,e,n),a=[s_(e,r,n)],l=[o];if(s.length%2!=0)throw new h(c.INVALID_ARGUMENT,"Function "+e+"() needs to be called with an even number of arguments that alternate between field names and values.");for(var f=0;f<s.length;f+=2)a.push(s_(e,s[f])),l.push(s[f+1]);for(var d=[],p=te.empty(),y=a.length-1;y>=0;--y)if(!sA(d,a[y])){var m=a[y],v=l[y];v=(0,i.m9)(v);var g=u.Oc(m);if(v instanceof sl)d.push(m);else{var w=sb(v,g);null!=w&&(d.push(m),p.set(m,w))}}var b=new x(d);return new so(p,b,u.fieldTransforms)}function sw(t,e,n,r){return void 0===r&&(r=!1),sb(n,t.Uc(r?4:3,e))}
826function sb(t,e){if(sT(t=(0,i.m9)(t)))return sE("Unsupported field value:",e,t),sI(t,e);if(t instanceof se)return function(t,e){if(!ss(e.Nc))throw e.Lc(t._methodName+"() can only be used with update() 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;i<t.length;i++){var o=sb(t[i],e.Mc(r));null==o&&(o={nullValue:"NULL_VALUE"}),n.push(o),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 tq(e.R,t);if("boolean"==typeof t)return{booleanValue:t};if("string"==typeof t)return{stringValue:t};if(t instanceof Date){var n=I.fromDate(t);return{timestampValue:ek(e.R,n)}}if(t instanceof I)return n=new I(t.seconds,1e3*Math.floor(t.nanoseconds/1e3)),{timestampValue:ek(e.R,n)};if(t instanceof sn)return{geoPointValue:{latitude:t.latitude,longitude:t.longitude}};if(t instanceof st)return{bytesValue:ex(e.R,t._byteString)};if(t instanceof oW){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:eR(t.firestore._databaseId||e.databaseId,t._key.path)}}throw e.Lc("Unsupported field value: "+oj(t))}(t,e)}function sI(t,e){var n={};return S(t)?e.path&&e.path.length>0&&e.fieldMask.push(e.path):_(t,function(t,r){var i=sb(r,e.kc(t));null!=i&&(n[t]=i)}),{mapValue:{fields:n}}}function sT(t){return!("object"!=typeof t||null===t||t instanceof Array||t instanceof Date||t instanceof I||t instanceof sn||t instanceof st||t instanceof oW||t instanceof se)}function sE(t,e,n){if(!sT(n)||!("object"==typeof n&&null!==n&&(Object.getPrototypeOf(n)===Object.prototype||null===Object.getPrototypeOf(n)))){var r=oj(n);throw"an object"===r?e.Lc(t+" a custom object"):e.Lc(t+" "+r)}}function s_(t,e,n){if((e=(0,i.m9)(e))instanceof o7)return e._internalPath;if("string"==typeof e)return sN(t,e);throw sD("Field path arguments must be of type string or FieldPath.",t,!1,void 0,n)}var sS=RegExp("[~\\*/\\[\\]]");function sN(t,e,n){if(e.search(sS)>=0)throw sD("Invalid field path ("+e+"). Paths must not contain '~', '*', '/', '[', or ']'",t,!1,void 0,n);try{return(new(o7.bind.apply(o7,(0,r.ev)([void 0],e.split(".")))))._internalPath}catch(r){throw sD("Invalid field path ("+e+"). Paths must not be empty, begin with '.', end with '.', or contain '..'",t,!1,void 0,n)}}function sD(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 a="";return(o||s)&&(a+=" (found",o&&(a+=" in field "+r),s&&(a+=" in document "+i),a+=")"),new h(c.INVALID_ARGUMENT,(u+=". ")+t+a)}function sA(t,e){return t.some(function(t){return t.isEqual(e)})}/** 827 * @license 828 * Copyright 2020 Google LLC 829 * 830 * Licensed under the Apache License, Version 2.0 (the "License"); 831 * you may not use this file except in compliance with the License. 832 * You may obtain a copy of the License at 833 * 834 * http://www.apache.org/licenses/LICENSE-2.0 835 * 836 * Unless required by applicable law or agreed to in writing, software 837 * distributed under the License is distributed on an "AS IS" BASIS, 838 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 839 * See the License for the specific language governing permissions and 840 * limitations under the License. 841 */var sk=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 oW(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 sx(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(sC("DocumentSnapshot.get",t));if(null!==e)return this._userDataWriter.convertValue(e)}},t}(),sx=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}(sk);function sC(t,e){return"string"==typeof e?sN(t,e):e instanceof o7?e._internalPath:e._delegate._internalPath}/** 842 * @license 843 * Copyright 2020 Google LLC 844 * 845 * Licensed under the Apache License, Version 2.0 (the "License");
846 * you may not use this file except in compliance with the License. 847 * You may obtain a copy of the License at 848 * 849 * http://www.apache.org/licenses/LICENSE-2.0 850 * 851 * Unless required by applicable law or agreed to in writing, software 852 * distributed under the License is distributed on an "AS IS" BASIS, 853 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 854 * See the License for the specific language governing permissions and 855 * limitations under the License. 856 */var sR=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}(),sL=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 sO(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(sC("DocumentSnapshot.get",t));if(null!==n)return this._userDataWriter.convertValue(n,e.serverTimestamps)}},e}(sk),sO=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}(sL),sP=function(){function t(t,e,n,r){this._firestore=t,this._userDataWriter=e,this._snapshot=r,this.metadata=new sR(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},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 sO(n._firestore,n._userDataWriter,r.key,r,new sR(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 h(c.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 sO(t._firestore,t._userDataWriter,e.doc.key,e.doc,new sR(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 sO(t._firestore,t._userDataWriter,e.doc.key,e.doc,new sR(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:function(t){switch(t){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return v()}}(e.type),doc:n,oldIndex:i,newIndex:o}})}(this,e),this._cachedChangesIncludeMetadataChanges=e),this._cachedChanges},t}();function sF(t,e){return t instanceof sL&&e instanceof sL?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 sP&&e instanceof sP&&t._firestore===e._firestore&&o0(t.query,e.query)&&t.metadata.isEqual(e.metadata)&&t._snapshot.isEqual(e._snapshot)}/** 857 * @license 858 * Copyright 2020 Google LLC 859 * 860 * Licensed under the Apache License, Version 2.0 (the "License");
861 * you may not use this file except in compliance with the License. 862 * You may obtain a copy of the License at 863 * 864 * http://www.apache.org/licenses/LICENSE-2.0 865 * 866 * Unless required by applicable law or agreed to in writing, software 867 * distributed under the License is distributed on an "AS IS" BASIS, 868 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 869 * See the License for the specific language governing permissions and 870 * limitations under the License. 871 */function sM(t){if(tS(t)&&0===t.explicitOrderBy.length)throw new h(c.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}var sV=function(){};function sq(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var r=0;r<e.length;r++)t=e[r]._apply(t);return t}var sU=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,n,r=sc(t.firestore),i=function(t,e,n,r,i,o,s){if(i.isKeyField()){if("array-contains"===o||"array-contains-any"===o)throw new h(c.INVALID_ARGUMENT,"Invalid Query. You can't perform '"+o+"' queries on FieldPath.documentId().");if("in"===o||"not-in"===o){sJ(s,o);for(var u,a=[],l=0;l<s.length;l++){var f=s[l];a.push(sz(r,t,f))}u={arrayValue:{values:a}}}else u=sz(r,t,s)}else"in"!==o&&"not-in"!==o&&"array-contains-any"!==o||sJ(s,o),u=sw(n,"where",s,"in"===o||"not-in"===o);var d=ta.create(i,o,u);return function(t,e){if(e.g()){var n=tD(t);if(null!==n&&!n.isEqual(e.field))throw new h(c.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=tN(t);null!==r&&sW(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 h(c.INVALID_ARGUMENT,"Invalid query. You cannot use more than one '"+e.op.toString()+"' filter."):new h(c.INVALID_ARGUMENT,"Invalid query. You cannot use '"+e.op.toString()+"' filters with '"+i.toString()+"' filters.")}(t,d),d}(t._query,0,r,t.firestore._databaseId,this.jc,this.Wc,this.Gc);return new oH(t.firestore,t.converter,(n=(e=t._query).filters.concat([i]),new tT(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)))},e}(sV),sG=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,n,r=function(t,e,n){if(null!==t.startAt)throw new h(c.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==t.endAt)throw new h(c.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");var r=new tw(e,n);return function(t,e){if(null===tN(t)){var n=tD(t);null!==n&&sW(t,n,e.field)}}(t,r),r}(t._query,this.jc,this.zc);return new oH(t.firestore,t.converter,(n=(e=t._query).explicitOrderBy.concat([r]),new tT(e.path,e.collectionGroup,n,e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)))},e}(sV),sB=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 oH(t.firestore,t.converter,tC(t._query,this.Hc,this.Jc))},e}(sV),sj=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,n=sQ(t,this.type,this.Yc,this.Xc);return new oH(t.firestore,t.converter,(e=t._query,new tT(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,n,e.endAt)))},e}(sV),sK=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,n=sQ(t,this.type,this.Y
871c,this.Xc);return new oH(t.firestore,t.converter,(e=t._query,new tT(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,n)))},e}(sV);function sQ(t,e,n,r){if(n[0]=(0,i.m9)(n[0]),n[0]instanceof sk)return function(t,e,n,r,i){if(!r)throw new h(c.NOT_FOUND,"Can't use a DocumentSnapshot that doesn't exist for "+n+"().");for(var o=[],s=0,u=tk(t);s<u.length;s++){var a=u[s];if(a.field.isKeyField())o.push(W(e,r.key));else{var l=r.data.field(a.field);if(F(l))throw new h(c.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+a.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===l){var f=a.field.canonicalString();throw new h(c.INVALID_ARGUMENT,"Invalid query. You are trying to start or end a query using a document for which the field '"+f+"' (used as the orderBy) does not exist.")}o.push(l)}}return new tv(o,i)}(t._query,t.firestore._databaseId,e,n[0]._document,r);var o=sc(t.firestore);return function(t,e,n,r,i,o){var s=t.explicitOrderBy;if(i.length>s.length)throw new h(c.INVALID_ARGUMENT,"Too many arguments provided to "+r+"(). The number of arguments must be less than or equal to the number of orderBy() clauses");for(var u=[],a=0;a<i.length;a++){var l=i[a];if(s[a].field.isKeyField()){if("string"!=typeof l)throw new h(c.INVALID_ARGUMENT,"Invalid query. Expected a string for document ID in "+r+"(), but got a "+typeof l);if(!tA(t)&&-1!==l.indexOf("/"))throw new h(c.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 '"+l+"' contains a slash.");var f=t.path.child(D.fromString(l));if(!G.isDocumentKey(f))throw new h(c.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 '"+f+"' is not because it contains an odd number of segments.");var d=new G(f);u.push(W(e,d))}else{var p=sw(n,r,l);u.push(p)}}return new tv(u,o)}(t._query,t.firestore._databaseId,o,e,n,r)}function sz(t,e,n){if("string"==typeof(n=(0,i.m9)(n))){if(""===n)throw new h(c.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid document ID, but it was an empty string.");if(!tA(e)&&-1!==n.indexOf("/"))throw new h(c.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(D.fromString(n));if(!G.isDocumentKey(r))throw new h(c.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 W(t,new G(r))}if(n instanceof oW)return W(t,n._key);throw new h(c.INVALID_ARGUMENT,"Invalid query. When querying with FieldPath.documentId(), you must provide a valid string or a DocumentReference, but it was: "+oj(n)+".")}function sJ(t,e){if(!Array.isArray(t)||0===t.length)throw new h(c.INVALID_ARGUMENT,"Invalid Query. A non-empty array is required for '"+e.toString()+"' filters.");if(t.length>10)throw new h(c.INVALID_ARGUMENT,"Invalid Query. '"+e.toString()+"' filters support a maximum of 10 elements in the value array.")}function sW(t,e,n){if(!n.isEqual(e))throw new h(c.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.")}/** 872 * @license 873 * Copyright 2020 Google LLC 874 * 875 * Licensed under the Apache License, Version 2.0 (the "License"); 876 * you may not use this file except in compliance with the License. 877 * You may obtain a copy of the License at 878 * 879 * http://www.apache.org/licenses/LICENSE-2.0 880 * 881 * Unless required by applicable law or agreed to in writing, softw
881are 882 * distributed under the License is distributed on an "AS IS" BASIS, 883 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 884 * See the License for the specific language governing permissions and 885 * limitations under the License. 886 */var sH=function(){function t(){}return t.prototype.convertValue=function(t,e){switch(void 0===e&&(e="none"),B(t)){case 0:return null;case 1:return t.booleanValue;case 2:return O(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(P(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 v()}},t.prototype.convertObject=function(t,e){var n=this,r={};return _(t.fields,function(t,i){r[t]=n.convertValue(i,e)}),r},t.prototype.convertGeoPoint=function(t){return new sn(O(t.latitude),O(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=function t(e){var n=e.mapValue.fields.__previous_value__;return F(n)?t(n):n}(t);return null==n?null:this.convertValue(n,e);case"estimate":return this.convertTimestamp(M(t));default:return null}},t.prototype.convertTimestamp=function(t){var e=L(t);return new I(e.seconds,e.nanos)},t.prototype.convertDocumentKey=function(t,e){var n=D.fromString(t);eY(n)||v();var r=new ox(n.get(1),n.get(3)),i=new G(n.popFirst(5));return r.isEqual(e)||p("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}();/** 887 * @license 888 * Copyright 2020 Google LLC 889 * 890 * Licensed under the Apache License, Version 2.0 (the "License"); 891 * you may not use this file except in compliance with the License. 892 * You may obtain a copy of the License at 893 * 894 * http://www.apache.org/licenses/LICENSE-2.0 895 * 896 * Unless required by applicable law or agreed to in writing, software 897 * distributed under the License is distributed on an "AS IS" BASIS, 898 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 899 * See the License for the specific language governing permissions and 900 * limitations under the License. 901 */function sZ(t,e,n){return t?n&&(n.merge||n.mergeFields)?t.toFirestore(e,n):t.toFirestore(e):e}var sY=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 st(t)},e.prototype.convertReference=function(t){var e=this.convertDocumentKey(t,this.firestore._databaseId);return new oW(this.firestore,null,e)},e}(sH),s$=function(){function t(t,e){this._firestore=t,this._commitHandler=e,this._mutations=[],this._committed=!1,this._dataReader=sc(t)}return t.prototype.set=function(t,e,n){this._verifyNotCommitted();var r=sX(t,this._firestore),i=sZ(r.converter,e,n),o=sh(this._dataReader,"WriteBatch.set",r._key,i,null!==r.converter,n);return this._mutations.push(o.toMutation(r._key,t$.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=sX(t,this._firestore);return s="string"==typeof(e=(0,i.m9)(e))||e instanceof o7?sg(this._dataReader,"WriteBatch.update",u._key,e,n,r):sv(this._dataReader,"WriteBatch.update",u._key,e),this._mutations.push(s.toMutation(u._key,t$.exists(!0))),this},t.prototype.delete=function(t){this._verifyNotCommitted();var e=sX(t,this._firestore);return this._mutations=this._mutations.concat(new ee(e._key,t$.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 h(c.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")},t}();/** 902 * @license 903 * Copyright 2020 Google LLC 904 * 905 * Licensed under the Apache License, Version 2.0 (the "License");
906 * you may not use this file except in compliance with the License. 907 * You may obtain a copy of the License at 908 * 909 * http://www.apache.org/licenses/LICENSE-2.0 910 * 911 * Unless required by applicable law or agreed to in writing, software 912 * distributed under the License is distributed on an "AS IS" BASIS, 913 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 914 * See the License for the specific language governing permissions and 915 * limitations under the License. 916 */function sX(t,e){if((t=(0,i.m9)(t)).firestore!==e)throw new h(c.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return t}/** 917 * @license 918 * Copyright 2020 Google LLC 919 * 920 * Licensed under the Apache License, Version 2.0 (the "License"); 921 * you may not use this file except in compliance with the License. 922 * You may obtain a copy of the License at 923 * 924 * http://www.apache.org/licenses/LICENSE-2.0 925 * 926 * Unless required by applicable law or agreed to in writing, software 927 * distributed under the License is distributed on an "AS IS" BASIS, 928 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 929 * See the License for the specific language governing permissions and 930 * limitations under the License. 931 */var s0=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 st(t)},e.prototype.convertReference=function(t){var e=this.convertDocumentKey(t,this.firestore._databaseId);return new oW(this.firestore,null,e)},e}(sH);function s1(t,e,n){for(var r=[],o=3;o<arguments.length;o++)r[o-3]=arguments[o];t=oK(t,oW);var s=oK(t.firestore,o3),u=sc(s);return s4(s,[("string"==typeof(e=(0,i.m9)(e))||e instanceof o7?sg(u,"updateDoc",t._key,e,n,r):sv(u,"updateDoc",t._key,e)).toMutation(t._key,t$.exists(!0))])}function s2(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[0]||o2(s[c])||(a=s[c],c++);var h,l,f,d={includeMetadataChanges:a.includeMetadataChanges};if(o2(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 oW)l=oK(t.firestore,o3),f=tE(t._key.path),h={next:function(e){s[c]&&s[c](s3(l,t,e))},error:s[c+1],complete:s[c+2]};else{var y=oK(t,oH);l=oK(y.firestore,o3),f=y._query;var m=new s0(l);h={next:function(t){s[c]&&s[c](new sP(l,m,y,t))},error:s[c+1],complete:s[c+2]},sM(t._query)}return function(t,e,n,i){var o=this,s=new op(i),u=new iM(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=iR,[4,oN(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=iL,[4,oN(t)];case 1:return[2,e.apply(void 0,[n.sent(),u])]}})})})}}(o5(l),f,d,h)}function s4(t,e){return function(t,e){var n=this,i=new nc;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=iH,[4,oS(t)];case 1:return[2,n.apply(void 0,[r.sent(),e,i])]}})})}),i.promise}(o5(t),e)}function s3(t,e,n){var r=n.docs.get(e._key),i=new s0(t);return new sL(t,i,e._key,r,new sR(n.hasPendingWrites,n.fromCache),e.converter)}/** 932 * @license 933 * Copyright 2020 Google LLC 934 * 935 * Licensed under the Apache License, Version 2.0 (the "License"); 936 * you may not use this file except in compliance with the License. 937 * You may obtain a copy of the License at 938 * 939 * http://www.apache.org/licenses/LICENSE-2.0 940 * 941 * Unless required by applicable law or agreed to in writing, software 942 * distributed under the License is distributed on an "AS IS" BASIS, 943 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 944 * See the License for the specific language governing permissions and 945 * limitations under the License. 946 */var s5=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=sX(e,this._firestore),i=new s0(this._firestore);return t.prototype.get.call(this,e).then(function(t){return new sL(n._firestore,i,r._key,t._document,new sR(!1,!1),r.converter)})},e}(function(){function t(t,e){this._firestore=t,this._transaction=e,this._dataReader=sc(t)}return t.prototype.get=function(t){var e=this,n=sX(t,this._firestore),r=new sY(this._firestore);return this._transaction.lookup([n._key]).then(function(t){if(!t||1!==t.length)return v();var i=t[0];if(i.isFoundDocument())return new sk(e._firestore,r,i.key,i,n.converter);if(i.isNoDocument())return new sk(e._firestore,r,n._key,null,n.converter);
946throw v()})},t.prototype.set=function(t,e,n){var r=sX(t,this._firestore),i=sZ(r.converter,e,n),o=sh(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=sX(t,this._firestore);return s="string"==typeof(e=(0,i.m9)(e))||e instanceof o7?sg(this._dataReader,"Transaction.update",u._key,e,n,r):sv(this._dataReader,"Transaction.update",u._key,e),this._transaction.update(u._key,s),this},t.prototype.delete=function(t){var e=sX(t,this._firestore);return this._transaction.delete(e._key),this},t}());/** 947 * @license 948 * Copyright 2017 Google LLC 949 * 950 * Licensed under the Apache License, Version 2.0 (the "License"); 951 * you may not use this file except in compliance with the License. 952 * You may obtain a copy of the License at 953 * 954 * http://www.apache.org/licenses/LICENSE-2.0 955 * 956 * Unless required by applicable law or agreed to in writing, software 957 * distributed under the License is distributed on an "AS IS" BASIS, 958 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 959 * See the License for the specific language governing permissions and 960 * limitations under the License. 961 */function s6(){if("undefined"==typeof Uint8Array)throw new h(c.UNIMPLEMENTED,"Uint8Arrays are not available in this environment.")}function s8(){if("undefined"==typeof atob)throw new h(c.UNIMPLEMENTED,"Blobs are unavailable in Firestore in this environment.")}var s9=function(){function t(t){this._delegate=t}return t.fromBase64String=function(e){return s8(),new t(st.fromBase64String(e))},t.fromUint8Array=function(e){return s6(),new t(st.fromUint8Array(e))},t.prototype.toBase64=function(){return s8(),this._delegate.toBase64()},t.prototype.toUint8Array=function(){return s6(),this._delegate.toUint8Array()},t.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},t.prototype.toString=function(){return"Blob(base64: "+this.toBase64()+")"},t}(),s7=function(){function t(){}return t.prototype.enableIndexedDbPersistence=function(t,e){var n,r,i,o,s;return n=t._delegate,r={forceOwnership:e},o9(n=oK(n,o3)),i=o5(n),o=n._freezeSettings(),o8(i,s=new od,new ol(s,o.cacheSizeBytes,null==r?void 0:r.forceOwnership))},t.prototype.enableMultiTabIndexedDbPersistence=function(t){var e,n,r,i;return o9(e=oK(e=t._delegate,o3)),n=o5(e),r=e._freezeSettings(),o8(n,i=new od,new of(i,r.cacheSizeBytes))},t.prototype.clearIndexedDbPersistence=function(t){return function(t){var e=this;if(t._initialized&&!t._terminated)throw new h(c.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");var n=new nc;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 nf.yt()?(e=t+"main",[4,nf.delete(e)]):[2,Promise.resolve()];case 1:return n.sent(),[2]}})})}(rd(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]}})})}),n.promise}(t._delegate)},t}(),ut=function(){function t(t,e,n){var r=this;this._delegate=e,this.Zc=n,this.INTERNAL={delete:function(){return r.terminate()}},t instanceof ox||(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||y("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){void 0===r&&(r={});var o,s,u,a=(t=oK(t,oJ))._getSettings();if("firestore.googleapis.com"!==a.host&&a.host!==e&&y("Host has been set in both settings() and useEmulator(), emulator host will be used"),t._setSettings(Object.assign(Object.assign({},a),{host:e+":"+n,ssl:!1})),r.mockUserToken){if("string"==typeof r.mockUserToken)s=r.mockUserToken,u=rM.MOCK_USER;else{s=(0,i.Sg)(r.mockUserToken,null===(o=t._app)||void 0===o?void 0:o.options.projectId);var l=r.mockUserToken.sub||r.mockUserToken.user_id;if(!l)throw new h(c.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");u=new rM(l)}t._credentials=new oO(new oR(s,u))}}(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,oT(t)];case 1:return e=r.sent(),[4,o_(t)];case 2:return n=r.sent(),[2,(e.setNetworkEnabled(!0),n.Or.delete(0),r7(n))]}})})})}(o5(oK(this._delegate,o3)))},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,oT(t)];case 1:return e=i.sent(),[4,o_(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=t).Or.add(0),[4,it(e)];case 1:return n.sent(),e.Br.set("Offline"),[2]}})})}(n))]}})})})}(o5(oK(this._delegate,o3)))},t.prototype.enablePersistence=function(t){var e=!1,n=!1;return t&&oU("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 nc;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=i1,[4,oS(t)];case 1:return[2,e.apply(void 0,[r.sent(),n])]}})})}),n.promise}(o5(oK(this._delegate,o3)))},t.prototype.onSnapshotsInSync=function(t){var e;return function(t,e){var n=this,i=new op(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){t.Gr.add(e),e.next()},[4,oN(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){t.Gr.delete(e)},[4,oN(t)];case 1:return[2,e.apply(void 0,[n.sent(),i])]}})})})}}(o5(oK(this._delegate,o3)),o2(t)?t:{next:t})},Object.defineProperty(t.prototype,"app",{get:function(){if(!this.tu)throw new h(c.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this.tu}
961,enumerable:!1,configurable:!0}),t.prototype.collection=function(t){try{return new uy(this,oY(this._delegate,t))}catch(t){throw uu(t,"collection()","Firestore.collection()")}},t.prototype.doc=function(t){try{return new us(this,o$(this._delegate,t))}catch(t){throw uu(t,"doc()","Firestore.doc()")}},t.prototype.collectionGroup=function(t){try{return new uf(this,function(t,e){if(t=oK(t,oJ),oV("collectionGroup","collection id",e),e.indexOf("/")>=0)throw new h(c.INVALID_ARGUMENT,"Invalid collection ID '"+e+"' passed to function collectionGroup(). Collection IDs must not contain '/'.");return new oH(t,null,new tT(D.emptyPath(),e))}(this._delegate,t))}catch(t){throw uu(t,"collectionGroup()","Firestore.collectionGroup()")}},t.prototype.runTransaction=function(t){var e,n=this;return function(t,e){var n=this,i=new nc;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,oI(t).then(function(t){return t.datastore})];case 1:return n=r.sent(),new om(t.asyncQueue,n,e,i).run(),[2]}})})}),i.promise}(o5(e=this._delegate),function(r){var i;return i=new s5(e,r),t(new ur(n,i))})},t.prototype.batch=function(){var t=this;return o5(this._delegate),new ui(new s$(this._delegate,function(e){return s4(t._delegate,e)}))},t.prototype.loadBundle=function(t){throw new h(c.FAILED_PRECONDITION,'"loadBundle()" does not exist, have you imported "firebase/firestore/bundle"?')},t.prototype.namedQuery=function(t){throw new h(c.FAILED_PRECONDITION,'"namedQuery()" does not exist, have you imported "firebase/firestore/bundle"?')},t}(),ue=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 s9(new st(t))},e.prototype.convertReference=function(t){var e=this.convertDocumentKey(t,this.firestore._databaseId);return us.eu(e,this.firestore,null)},e}(sH);function un(t){l.setLogLevel(t)}var ur=function(){function t(t,e){this._firestore=t,this._delegate=e,this._userDataWriter=new ue(t)}return t.prototype.get=function(t){var e=this,n=oK(t,oW);return this._delegate.get(n).then(function(t){return new uh(e._firestore,new sL(e._firestore._delegate,e._userDataWriter,t._key,t._document,t.metadata,n.converter))})},t.prototype.set=function(t,e,n){var r=oK(t,oW);return n?(oq("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=oK(t,oW);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=oK(t,oW);return this._delegate.delete(e),this},t}(),ui=function(){function t(t){this._delegate=t}return t.prototype.set=function(t,e,n){var r=oK(t,oW);return n?(oq("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=oK(t,oW);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=oK(t,oW);return this._delegate.delete(e),this},t.prototype.commit=function(){return this._delegate.commit()},t}(),uo=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 sO(this._firestore._delegate,this._userDataWriter,t._key,t._document,t.metadata,null);return this._delegate.fromFirestore(new ul(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 ue(e),n),i.set(n,o)),o},t}();uo.su=new WeakMap;var us=function(){function t(t,e){this.firestore=t,this._delegate=e,this._userDataWriter=new ue(t)}return t.iu=function(e,n,r){if(e.length%2!=0)throw new h(c.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 oW(n._delegate,r,new G(e)))},t.eu=function(e,n,r){return new t(n,new oW(n._delegate,r,e))},Object.defineProperty(t.prototype,"id",{get:function(){return this._delegate.id}
961,enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return new uy(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 uy(this.firestore,oY(this._delegate,t))}catch(t){throw uu(t,"collection()","DocumentReference.collection()")}},t.prototype.isEqual=function(t){return(t=(0,i.m9)(t))instanceof oW&&oX(this._delegate,t)},t.prototype.set=function(t,e){e=oq("DocumentReference.set",e);try{var n,r,i,o;return n=this._delegate,r=e,n=oK(n,oW),i=oK(n.firestore,o3),o=sZ(n.converter,t,r),s4(i,[sh(sc(i),"setDoc",n._key,o,null!==n.converter,r).toMutation(n._key,t$.none())])}catch(t){throw uu(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?s1(this._delegate,t):s1.apply(void 0,(0,r.ev)([this._delegate,t,e],n))}catch(t){throw uu(t,"updateDoc()","DocumentReference.update()")}},t.prototype.delete=function(){var t;return s4(oK((t=this._delegate).firestore,o3),[new ee(t._key,t$.none())])},t.prototype.onSnapshot=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];var r=ua(e),i=uc(e,function(e){return new uh(t.firestore,new sL(t.firestore._delegate,t._userDataWriter,e._key,e._document,e.metadata,t._delegate.converter))});return s2(this._delegate,r,i)},t.prototype.get=function(t){var e,n,i,o,s,u,a,l,f=this;return("cache"===(null==t?void 0:t.source)?(e=oK(e=this._delegate,oW),i=o5(n=oK(e.firestore,o3)),o=new s0(n),(function(t,e){var n=this,i=new nc;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;return(0,r.Jh)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,t.persistence.runTransaction("read document","readonly",function(n){return t.Mn.mn(n,e)})];case 1:return(i=r.sent()).isFoundDocument()?n.resolve(i):i.isNoDocument()?n.resolve(null):n.reject(new h(c.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=iN(r.sent(),"Failed to get document '"+e+" from cache"),n.reject(i),[3,3];case 3:return[2]}})})},[4,oE(t)];case 1:return[2,n.apply(void 0,[o.sent(),e,i])]}})})}),i.promise})(i,e._key).then(function(t){return new sL(n,o,e._key,t,new sR(null!==t&&t.hasLocalMutations,!0),e.converter)})):"server"===(null==t?void 0:t.source)?(s=oK(s=this._delegate,oW),oD(o5(u=oK(s.firestore,o3)),s._key,{source:"server"}).then(function(t){return s3(u,s,t)})):(a=oK(a=this._delegate,oW),oD(o5(l=oK(a.firestore,o3)),a._key).then(function(t){return s3(l,a,t)}))).then(function(t){return new uh(f.firestore,new sL(f.firestore._delegate,f._userDataWriter,t._key,t._document,t.metadata,f._delegate.converter))})},t.prototype.withConverter=function(e){return new t(this.firestore,e?this._delegate.withConverter(uo.nu(this.firestore,e)):this._delegate.withConverter(null))},t}();function uu(t,e,n){return t.message=t.message.replace(e,n),t}function ua(t){for(var e=0;e<t.length;e++){var n=t[e];if("object"==typeof n&&!o2(n))return n}return{}}function uc(t,e){var n,r,i;return{next:function(t){i.next&&i.next(e(t))},error:null===(n=(i=o2(t[0])?t[0]:o2(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 uh=function(){function t(t,e){this._firestore=t,this._delegate=e}return Object.defineProperty(t.prototype,"ref",{get:function(){return new us(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}
961,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 sF(this._delegate,t._delegate)},t}(),ul=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}(uh),uf=function(){function t(t,e){this.firestore=t,this._delegate=e,this._userDataWriter=new ue(t)}return t.prototype.where=function(e,n,r){try{var i;return new t(this.firestore,sq(this._delegate,(i=sC("where",e),new sU(i,n,r))))}catch(t){throw uu(t,/(orderBy|where)\(\)/,"Query.$1()")}},t.prototype.orderBy=function(e,n){try{var r,i,o;return new t(this.firestore,sq(this._delegate,(r=n,void 0===r&&(r="asc"),i=r,o=sC("orderBy",e),new sG(o,i))))}catch(t){throw uu(t,/(orderBy|where)\(\)/,"Query.$1()")}},t.prototype.limit=function(e){try{return new t(this.firestore,sq(this._delegate,(oQ("limit",e),new sB("limit",e,"F"))))}catch(t){throw uu(t,"limit()","Query.limit()")}},t.prototype.limitToLast=function(e){try{return new t(this.firestore,sq(this._delegate,(oQ("limitToLast",e),new sB("limitToLast",e,"L"))))}catch(t){throw uu(t,"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,sq(this._delegate,(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new sj("startAt",t,!0)}).apply(void 0,e)))}catch(t){throw uu(t,"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,sq(this._delegate,(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new sj("startAfter",t,!1)}).apply(void 0,e)))}catch(t){throw uu(t,"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,sq(this._delegate,(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new sK("endBefore",t,!0)}).apply(void 0,e)))}catch(t){throw uu(t,"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,sq(this._delegate,(function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new sK("endAt",t,!1)}).apply(void 0,e)))}catch(t){throw uu(t,"endAt()","Query.endAt()")}},t.prototype.isEqual=function(t){return o0(this._delegate,t._delegate)},t.prototype.get=function(t){var e,n,i,o,s,u,a,c,h,l,f,d,p=this;return("cache"===(null==t?void 0:t.source)?(e=oK(e=this._delegate,oH),i=o5(n=oK(e.firestore,o3)),o=new s0(n),(function(t,e){var n=this,i=new nc;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;return(0,r.Jh)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,r_(t,e,!0)];case 1:return u=r.sent(),o=(i=new iB(e,u.Bn))._o(u.documents),s=i.applyChanges(o,!1),n.resolve(s.snapshot),[3,3];case 2:return u=iN(r.sent(),"Failed to execute query '"+e+" against cache"),n.reject(u),[3,3];case 3:return[2]}})})},[4,oE(t)];case 1:return[2,n.apply(void 0,[o.sent(),e,i])]}})})}),i.promise})(i,e._query).then(function(t){return new sP(n,o,e,t)})):"server"===(null==t?void 0:t.source)?(s=oK(s=this._delegate,oH),a=o5(u=oK(s.firestore,o3)),c=new s0(u),oA(a,s._query,{source:"server"}).then(function(t){return new sP(u,c,s,t)})):(h=oK(h=this._delegate,oH),f=o5(l=oK(h.firestore,o3)),d=new s0(l),sM(h._query),oA(f,h._query).then(function(t){return new sP(l,d,h,t)}))).then(function(t){return new up(p.firestore,new sP(p.firestore._delegate,p._userDataWriter,p._delegate,t._snapshot))})},t.prototype.onSnapshot=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];
961var r=ua(e),i=uc(e,function(e){return new up(t.firestore,new sP(t.firestore._delegate,t._userDataWriter,t._delegate,e._snapshot))});return s2(this._delegate,r,i)},t.prototype.withConverter=function(e){return new t(this.firestore,e?this._delegate.withConverter(uo.nu(this.firestore,e)):this._delegate.withConverter(null))},t}(),ud=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 ul(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}(),up=function(){function t(t,e){this._firestore=t,this._delegate=e}return Object.defineProperty(t.prototype,"query",{get:function(){return new uf(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 ul(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 ud(e._firestore,t)})},t.prototype.forEach=function(t,e){var n=this;this._delegate.forEach(function(r){t.call(e,new ul(n._firestore,r))})},t.prototype.isEqual=function(t){return sF(this._delegate,t._delegate)},t}(),uy=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 us(this.firestore,t):null},enumerable:!1,configurable:!0}),e.prototype.doc=function(t){try{return new us(this.firestore,void 0===t?o$(this._delegate):o$(this._delegate,t))}catch(t){throw uu(t,"doc()","CollectionReference.doc()")}},e.prototype.add=function(t){var e,n,r,i,o=this;return(n=oK((e=this._delegate).firestore,o3),r=o$(e),i=sZ(e.converter,t),s4(n,[sh(sc(e.firestore),"addDoc",r._key,i,null!==e.converter,{}).toMutation(r._key,t$.exists(!1))]).then(function(){return r})).then(function(t){return new us(o.firestore,t)})},e.prototype.isEqual=function(t){return oX(this._delegate,t._delegate)},e.prototype.withConverter=function(t){return new e(this.firestore,t?this._delegate.withConverter(uo.nu(this.firestore,t)):this._delegate.withConverter(null))},e}(uf),um=function(){function t(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this._delegate=new(o7.bind.apply(o7,(0,r.ev)([void 0],t)))}return t.documentId=function(){return new t(k.keyField().canonicalString())},t.prototype.isEqual=function(t){return(t=(0,i.m9)(t))instanceof o7&&this._delegate._internalPath.isEqual(t._internalPath)},t}(),uv=function(){function t(t){this._delegate=t}return t.serverTimestamp=function(){var e=new sd("serverTimestamp");return e._methodName="FieldValue.serverTimestamp",new t(e)},t.delete=function(){var e=new sl("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 sp("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 sy("arrayRemove",t)}).apply(void 0,e);return r._methodName="FieldValue.arrayRemove",new t(r)},t.increment=function(e){var n=new sm("increment",e);return n._methodName="FieldValue.increment",new t(n)},t.prototype.isEqual=function(t){return this._delegate.isEqual(t._delegate)},t}()}}]);
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.