PageSourceSearch

https://www.ivytutoring.net/_next/static/chunks/0wipescm71acx.js?dpl=dpl_9wtYxVzjBiKUrn8pZ9w7bQjoY6rc

js ivytutoring.net collected 2026-09-24 14:25:04 UTC 399,197 bytes, 23 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,6748,(e,t,r)=>{var n={675:function(e,t){"use strict";t.byteLength=function(e){var t=l(e),r=t[0],n=t[1];return(r+n)*3/4-n},t.toByteArray=function(e){var t,r,s=l(e),a=s[0],o=s[1],u=new i((a+o)*3/4-o),h=0,c=o>0?a-4:a;for(r=0;r<c;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],u[h++]=t>>16&255,u[h++]=t>>8&255,u[h++]=255&t;return 2===o&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,u[h++]=255&t),1===o&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,u[h++]=t>>8&255,u[h++]=255&t),u},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,s=[],a=0,o=n-i;a<o;a+=16383)s.push(function(e,t,n){for(var i,s=[],a=t;a<n;a+=3)i=(e[a]<<16&0xff0000)+(e[a+1]<<8&65280)+(255&e[a+2]),s.push(r[i>>18&63]+r[i>>12&63]+r[i>>6&63]+r[63&i]);return s.join("")}(e,a,a+16383>o?o:a+16383));return 1===i?s.push(r[(t=e[n-1])>>2]+r[t<<4&63]+"=="):2===i&&s.push(r[(t=(e[n-2]<<8)+e[n-1])>>10]+r[t>>4&63]+r[t<<2&63]+"="),s.join("")};for(var r=[],n=[],i="u">typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,o=s.length;a<o;++a)r[a]=s[a],n[s.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var n=r===t?0:4-r%4;return[r,n]}n[45]=62,n[95]=63},72:function(e,t,r){"use strict";var n=r(675),i=r(783),s="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function a(e){if(e>0x7fffffff)throw RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return h(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e){var n=e,i=t;if(("string"!=typeof i||""===i)&&(i="utf8"),!o.isEncoding(i))throw TypeError("Unknown encoding: "+i);var s=0|f(n,i),l=a(s),u=l.write(n,i);return u!==s&&(l=l.slice(0,u)),l}if(ArrayBuffer.isView(e))return c(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(D(e,ArrayBuffer)||e&&D(e.buffer,ArrayBuffer)||"u">typeof SharedArrayBuffer&&(D(e,SharedArrayBuffer)||e&&D(e.buffer,SharedArrayBuffer)))return function(e,t,r){var n;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),o.prototype),n}(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var h=e.valueOf&&e.valueOf();if(null!=h&&h!==e)return o.from(h,t,r);var p=function(e){if(o.isBuffer(e)){var t=0|d(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||function(e){return e!=e}(e.length)?a(0):c(e):"Buffer"===e.type&&Array.isArray(e.data)?c(e.data):void 0}(e);if(p)return p;if("u">typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return o.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function u(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function h(e){return u(e),a(e<0?0:0|d(e))}function c(e){for(var t=e.length<0?0:0|d(e.length),r=a(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}t.Buffer=o,t.SlowBuffer=function(e){return+e!=e&&(e=0),o.alloc(+e)},t.INSPECT_MAX_BYTES=50,t.kMaxLength=0x7fffffff,o.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),!o.TYPED_ARRAY_SUPPORT&&"u">typeof console&&"function"==typeof console.error&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(e,t,r){return(u(e),e<=0)?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)},o.allocUnsafe=function(e){return h(e)},o.allocUnsafeSlow=function(e){return h(e)};function d(e){if(e>=0x7fffffff)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function f(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||D(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return S(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return C(e).length;default:if(i)return n?-1:S(e).length;t=(""+t).toLowerCase(),i=!0}}function p(e,t,r){var i,s,a,o=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",s=t;s<r;++s)i+=N[e[s]];return i}(this,t,r);case"utf8":case"utf-8":return v(this,t,r);case"ascii":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}(this,t,r);case"latin1":case"binary":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}(this,t,r);case"base64":return i=this,s=t,a=r,0===s&&a===i.length?n.fromByteArray(i):n.fromByteArray(i.slice(s,a));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}(this,t,r);default:if(o)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function g(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function m(e,t,r,n,i){var s;if(0===e.length)return -1;if("string"==typeof r?(n=r,r=0):r>0x7fffffff?r=0x7fffffff:r<-0x80000000&&(r=-0x80000000),(s=r*=1)!=s&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length)if(i)return -1;else r=e.length-1;else if(r<0)if(!i)return -1;else r=0;if("string"==typeof t&&(t=o.from(t,n)),o.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t){if(t&=255,"function"==typeof Uint8Array.prototype.indexOf)if(i)return Uint8Array.prototype.indexOf.call(e,t,r);else return Uint8Array.prototype.lastIndexOf.call(e,t,r);return y(e,[t],r,n,i)}throw TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var s,a=1,o=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return -1;a=2,o/=2,l/=2,r/=2}function u(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var h=-1;for(s=r;s<o;s++)if(u(e,s)===u(t,-1===h?0:s-h)){if(-1===h&&(h=s),s-h+1===l)return h*a}else -1!==h&&(s-=s-h),h=-1}else for(r+l>o&&(r=o-l),s=r;s>=0;s--){for(var c=!0,d=0;d<l;d++)if(u(e,s+d)!==u(t,d)){c=!1;break}if(c)return s}return -1}o.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==o.prototype},o.compare=function(e,t){if(D(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),D(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:+(n<r)},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;var r,n=o.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var s=e[r];if(D(s,Uint8Array)&&(s=o.from(s)),!o.isBuffer(s))throw TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},o.byteLength=f,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)g(this,t,t+1);return this},o.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)g(this,t,t+3),g(this,t+1,t+2);return this},o.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},o.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?v(this,0,e):p.apply(this,arguments)}
vendor: 10,368 bytes, line 1
1,o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},s&&(o.prototype[s]=o.prototype.inspect),o.prototype.compare=function(e,t,r,n,i){if(D(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var s=i-n,a=r-t,l=Math.min(s,a),u=this.slice(n,i),h=e.slice(t,r),c=0;c<l;++c)if(u[c]!==h[c]){s=u[c],a=h[c];break}return s<a?-1:+(a<s)},o.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},o.prototype.indexOf=function(e,t,r){return m(this,e,t,r,!0)},o.prototype.lastIndexOf=function(e,t,r){return m(this,e,t,r,!1)};function v(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s,a,o,l,u=e[i],h=null,c=u>239?4:u>223?3:u>191?2:1;if(i+c<=r)switch(c){case 1:u<128&&(h=u);break;case 2:(192&(s=e[i+1]))==128&&(l=(31&u)<<6|63&s)>127&&(h=l);break;case 3:s=e[i+1],a=e[i+2],(192&s)==128&&(192&a)==128&&(l=(15&u)<<12|(63&s)<<6|63&a)>2047&&(l<55296||l>57343)&&(h=l);break;case 4:s=e[i+1],a=e[i+2],o=e[i+3],(192&s)==128&&(192&a)==128&&(192&o)==128&&(l=(15&u)<<18|(63&s)<<12|(63&a)<<6|63&o)>65535&&l<1114112&&(h=l)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=c}var d=n,f=d.length;if(f<=4096)return String.fromCharCode.apply(String,d);for(var p="",g=0;g<f;)p+=String.fromCharCode.apply(String,d.slice(g,g+=4096));return p}function w(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function b(e,t,r,n,i,s){if(!o.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw RangeError('"value" argument is out of bounds');if(r+n>e.length)throw RangeError("Index out of range")}function E(e,t,r,n,i,s){if(r+n>e.length||r<0)throw RangeError("Index out of range")}function I(e,t,r,n,s){return t*=1,r>>>=0,s||E(e,t,r,4,34028234663852886e22,-34028234663852886e22),i.write(e,t,r,n,23,4),r+4}function _(e,t,r,n,s){return t*=1,r>>>=0,s||E(e,t,r,8,17976931348623157e292,-17976931348623157e292),i.write(e,t,r,n,52,8),r+8}o.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var i,s,a,o,l,u,h,c,d=this.length-t;if((void 0===r||r>d)&&(r=d),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var f=!1;;)switch(n){case"hex":return function(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=t.length;n>s/2&&(n=s/2);for(var a=0;a<n;++a){var o,l=parseInt(t.substr(2*a,2),16);if((o=l)!=o)break;e[r+a]=l}return a}(this,e,t,r);case"utf8":case"utf-8":return i=t,s=r,A(S(e,this.length-i),this,i,s);case"ascii":return a=t,o=r,A(x(e),this,a,o);case"latin1":case"binary":return function(e,t,r,n){return A(x(t),e,r,n)}(this,e,t,r);case"base64":return l=t,u=r,A(C(e),this,l,u);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return h=t,c=r,A(function(e,t){for(var r,n,i=[],s=0;s<e.length&&!((t-=2)<0);++s)n=(r=e.charCodeAt(s))>>8,i.push(r%256),i.push(n);return i}(e,this.length-h),this,h,c);default:if(f)throw TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),f=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return Object.setPrototypeOf(n,o.prototype),n},o.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n},o.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},o.prototype.readUInt8=function(e,t){return e>>>=0,t||w(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+0x1000000*this[e+3]},o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),0x1000000*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},o.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},o.prototype.readInt8=function(e,t){return(e>>>=0,t||w(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||w(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt16BE=function(e,t){e>>>=0,t||w(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return e>>>=0,t||w(e,4,this.length),i.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||w(e,4,this.length),i.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||w(e,8,this.length),i.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||w(e,8,this.length),i.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,r,n){if(e*=1,t>>>=0,r>>>=0,!n){var i=Math.pow(2,8*r)-1;b(this,e,t,r,i,0)}var s=1,a=0;for(this[t]=255&e;++a<r&&(s*=256);)this[t+a]=e/s&255;return t+r},o.prototype.writeUIntBE=function(e,t,r,n){if(e*=1,t>>>=0,r>>>=0,!n){var i=Math.pow(2,8*r)-1;b(this,e,t,r,i,0)}var s=r-1,a=1;for(this[t+s]=255&e;--s>=0&&(a*=256);)this[t+s]=e/a&255;return t+r},o.prototype.writeUInt8=function(e,t,r){return e*=1,t>>>=0,r||b(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e*=1,t>>>=0,r||b(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUInt16BE=function(e,t,r){return e*=1,t>>>=0,r||b(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUInt32LE=function(e,t,r){return e*=1,t>>>=0,r||b(this,e,t,4,0xffffffff,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},o.prototype.writeUInt32BE=function(e,t,r){return e*=1,t>>>=0,r||b(this,e,t,4,0xffffffff,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeIntLE=function(e,t,r,n){if(e*=1,t>>>=0,!n){var i=Math.pow(2,8*r-1);b(this,e,t,r,i-1,-i)}var s=0,a=1,o=0;for(this[t]=255&e;++s<r&&(a*=256);)e<0&&0===o&&0!==this[t+s-1]&&(o=1),this[t+s]=(e/a|0)-o&255;return t+r},o.prototype.writeIntBE=function(e,t,r,n){if(e*=1,t>>>=0,!n){var i=Math.pow(2,8*r-1);b(this,e,t,r,i-1,-i)}var s=r-1,a=1,o=0;for(this[t+s]=255&e;--s>=0&&(a*=256);)e<0&&0===o&&0!==this[t+s+1]&&(o=1),this[t+s]=(e/a|0)-o&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e*=1,t>>>=0,r||b(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e*=1,t>>>=0,r||b(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,r){return e*=1,t>>>=0,r||b(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,r){return e*=1,t>>>=0,r||b(this,e,t,4,0x7fffffff,-0x80000000),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,r){return e*=1,t>>>=0,r||b(this,e,t,4,0x7fffffff,-0x80000000),e<0&&(e=0xffffffff+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeFloatLE=function(e,t,r){return I(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return I(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return _(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return _(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,n){if(!o.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(n<0)throw RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i=n-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,n);else if(this===e&&r<t&&t<n)for(var s=i-1;s>=0;--s)e[s+t]=this[s+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return i},o.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw TypeError("Unknown encoding: "+n);if(1===e.length){var i,s=e.charCodeAt(0);("utf8"===n&&s<128||"latin1"===n)&&(e=s)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(i=t;i<r;++i)this[i]=e;else{var a=o.isBuffer(e)?e:o.from(e,n),l=a.length;
1if(0===l)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(i=0;i<r-t;++i)this[i+t]=a[i%l]}return this};var T=/[^+/0-9A-Za-z-_]/g;function S(e,t){t=t||1/0;for(var r,n=e.length,i=null,s=[],a=0;a<n;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!i){if(r>56319||a+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return s}function x(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function C(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(T,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function A(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length)&&!(i>=e.length);++i)t[i+r]=e[i];return i}function D(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}var N=function(){for(var e="0123456789abcdef",t=Array(256),r=0;r<16;++r)for(var n=16*r,i=0;i<16;++i)t[n+i]=e[r]+e[i];return t}()},783:function(e,t){t.read=function(e,t,r,n,i){var s,a,o=8*i-n-1,l=(1<<o)-1,u=l>>1,h=-7,c=r?i-1:0,d=r?-1:1,f=e[t+c];for(c+=d,s=f&(1<<-h)-1,f>>=-h,h+=o;h>0;s=256*s+e[t+c],c+=d,h-=8);for(a=s&(1<<-h)-1,s>>=-h,h+=n;h>0;a=256*a+e[t+c],c+=d,h-=8);if(0===s)s=1-u;else{if(s===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),s-=u}return(f?-1:1)*a*Math.pow(2,s-n)},t.write=function(e,t,r,n,i,s){var a,o,l,u=8*s-i-1,h=(1<<u)-1,c=h>>1,d=5960464477539062e-23*(23===i),f=n?0:s-1,p=n?1:-1,g=+(t<0||0===t&&1/t<0);for(isNaN(t=Math.abs(t))||t===1/0?(o=+!!isNaN(t),a=h):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+c>=1?t+=d/l:t+=d*Math.pow(2,1-c),t*l>=2&&(a++,l/=2),a+c>=h?(o=0,a=h):a+c>=1?(o=(t*l-1)*Math.pow(2,i),a+=c):(o=t*Math.pow(2,c-1)*Math.pow(2,i),a=0));i>=8;e[r+f]=255&o,f+=p,o/=256,i-=8);for(a=a<<i|o,u+=i;u>0;e[r+f]=255&a,f+=p,a/=256,u-=8);e[r+f-p]|=128*g}}},i={};function s(e){var t=i[e];if(void 0!==t)return t.exports;var r=i[e]={exports:{}},a=!0;try{n[e](r,r.exports,s),a=!1}finally{a&&delete i[e]}return r.exports}s.ab="/ROOT/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected]_react-d_6f411d02d406389c96e71669832b54ff/node_modules/next/dist/compiled/buffer/",t.exports=s(72)},661113,281673,881879,163971,718044,28075,e=>{"use strict";let t,r,n;var i,s,a,o,l,u,h,c,d,f,p,g,m,y,v,w,b=e.i(578570),E=e.i(6748);let I=function(e){let t=[],r=0;for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);i<128?t[r++]=i:(i<2048?t[r++]=i>>6|192:((64512&i)==55296&&n+1<e.length&&(64512&e.charCodeAt(n+1))==56320?(i=65536+((1023&i)<<10)+(1023&e.charCodeAt(++n)),t[r++]=i>>18|240,t[r++]=i>>12&63|128):t[r++]=i>>12|224,t[r++]=i>>6&63|128),t[r++]=63&i|128)}return t},_=function(e){let t=[],r=0,n=0;for(;r<e.length;){let i=e[r++];if(i<128)t[n++]=String.fromCharCode(i);else if(i>191&&i<224){let s=e[r++];t[n++]=String.fromCharCode((31&i)<<6|63&s)}else if(i>239&&i<365){let s=((7&i)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536;t[n++]=String.fromCharCode(55296+(s>>10)),t[n++]=String.fromCharCode(56320+(1023&s))}else{let s=e[r++],a=e[r++];t[n++]=String.fromCharCode((15&i)<<12|(63&s)<<6|63&a)}}return t.join("")},T={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();let r=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,n=[];for(let t=0;t<e.length;t+=3){let i=e[t],s=t+1<e.length,a=s?e[t+1]:0,o=t+2<e.length,l=o?e[t+2]:0,u=i>>2,h=(3&i)<<4|a>>4,c=(15&a)<<2|l>>6,d=63&l;!o&&(d=64,s||(c=64)),n.push(r[u],r[h],r[c],r[d])}return n.join("")},encodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?btoa(e):this.encodeByteArray(I(e),t)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):_(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();let r=t?this.charToByteMapWebSafe_:this.charToByteMap_,n=[];for(let t=0;t<e.length;){let i=r[e.charAt(t++)],s=t<e.length?r[e.charAt(t)]:0,a=++t<e.length?r[e.charAt(t)]:64,o=++t<e.length?r[e.charAt(t)]:64;if(++t,null==i||null==s||null==a||null==o)throw new S;let l=i<<2|s>>4;if(n.push(l),64!==a){let e=s<<4&240|a>>2;if(n.push(e),64!==o){let e=a<<6&192|o;n.push(e)}}}return n},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};
1class S extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}let x=function(e){let t=I(e);return T.encodeByteArray(t,!0)},C=function(e){return x(e).replace(/\./g,"")},A=function(e){try{return T.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function D(){return"u">typeof self?self:"u">typeof window?window:e.g}let N=()=>{try{return D().__FIREBASE_DEFAULTS__||(()=>{if(void 0===b.default||void 0===b.default.env)return;let e=b.default.env.__FIREBASE_DEFAULTS__;if(e)return JSON.parse(e)})()||(()=>{let e;if("u"<typeof document)return;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}let t=e&&A(e[1]);return t&&JSON.parse(t)})()}catch(e){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`);return}},k=e=>{var t,r;return null==(r=null==(t=N())?void 0:t.emulatorHosts)?void 0:r[e]},O=e=>{let t=k(e);if(!t)return;let r=t.lastIndexOf(":");if(r<=0||r+1===t.length)throw Error(`Invalid host ${t} with no separate hostname and port!`);let n=parseInt(t.substring(r+1),10);return"["===t[0]?[t.substring(1,r-1),n]:[t.substring(0,r),n]},R=()=>{var e;return null==(e=N())?void 0:e.config};class L{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,r)=>{t?this.reject(t):this.resolve(r),"function"==typeof e&&(this.promise.catch(()=>{}),1===e.length?e(t):e(t,r))}}}function M(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch(e){return!1}}async function P(e){return(await fetch(e,{credentials:"include"})).ok}function F(e,t){if(e.uid)throw Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');let r=t||"demo-project",n=e.iat||0,i=e.sub||e.user_id;if(!i)throw Error("mockUserToken must contain 'sub' or 'user_id' field!");let s=Object.assign({iss:`https://securetoken.google.com/${r}`,aud:r,iat:n,exp:n+3600,auth_time:n,sub:i,user_id:i,firebase:{sign_in_provider:"custom",identities:{}}},e);return[C(JSON.stringify({alg:"none",type:"JWT"})),C(JSON.stringify(s)),""].join(".")}let V={},B=!1;function U(e,t){if("u"<typeof window||"u"<typeof document||!M(window.location.host)||V[e]===t||V[e]||B)return;function r(e){return`__firebase__banner__${e}`}V[e]=t;let n="__firebase__banner",i=function(){let e={prod:[],emulator:[]};for(let t of Object.keys(V))V[t]?e.emulator.push(t):e.prod.push(t);return e}().prod.length>0;function s(){let e,t,s=(e=document.getElementById(n),t=!1,e||((e=document.createElement("div")).setAttribute("id",n),t=!0),{created:t,element:e}),a=r("text"),o=document.getElementById(a)||document.createElement("span"),l=r("learnmore"),u=document.getElementById(l)||document.createElement("a"),h=r("preprendIcon"),c=document.getElementById(h)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(s.created){let e,t=s.element;t.style.display="flex",t.style.background="#7faaf0",t.style.position="fixed",t.style.bottom="5px",t.style.left="5px",t.style.padding=".5em",t.style.borderRadius="5px",t.style.alignItems="center",u.setAttribute("id",l),u.innerText="Learn more",u.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",u.setAttribute("target","__blank"),u.style.paddingLeft="5px",u.style.textDecoration="underline";let r=((e=document.createElement("span")).style.cursor="pointer",e.style.marginLeft="16px",e.style.fontSize="24px",e.innerHTML=" &times;",e.onclick=()=>{let e;B=!0,(e=document.getElementById(n))&&e.remove()},e);c.setAttribute("width","24"),c.setAttribute("id",h),c.setAttribute("height","24"),c.setAttribute("viewBox","0 0 24 24"),c.setAttribute("fill","none"),c.style.marginLeft="-6px",t.append(c,o,u,r),document.body.appendChild(t)}i?(o.innerText="Preview backend disconnected.",c.innerHTML=`<g clip-path="url(#clip0_6013_33858)">
2<path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>
3</g>
4<defs>
5<clipPath id="clip0_6013_33858">
6<rect width="24" height="24" fill="white"/>
7</clipPath>
8</defs>`):(c.innerHTML=`<g clip-path="url(#clip0_6083_34804)">
9<path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 
912.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>
10</g>
11<defs>
12<clipPath id="clip0_6083_34804">
13<rect width="24" height="24" fill="white"/>
14</clipPath>
15</defs>`,o.innerText="Preview backend running in this workspace."),o.setAttribute("id",a)}"loading"===document.readyState?window.addEventListener("DOMContentLoaded",s):s()}function q(){return"u">typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function j(){var t;let r=null==(t=N())?void 0:t.forceEnvironment;if("node"===r)return!0;if("browser"===r)return!1;try{return"[object process]"===Object.prototype.toString.call(e.g.process)}catch(e){return!1}}function z(){return"u">typeof WorkerGlobalScope&&"u">typeof self&&self instanceof WorkerGlobalScope}function $(){return!j()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function G(){return!j()&&!!navigator.userAgent&&(navigator.userAgent.includes("Safari")||navigator.userAgent.includes("WebKit"))&&!navigator.userAgent.includes("Chrome")}function K(){try{return"object"==typeof indexedDB}catch(e){return!1}}function Q(){return new Promise((e,t)=>{try{let r=!0,n="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(n);i.onsuccess=()=>{i.result.close(),r||self.indexedDB.deleteDatabase(n),e(!0)},i.onupgradeneeded=()=>{r=!1},i.onerror=()=>{var e;t((null==(e=i.error)?void 0:e.message)||"")}}catch(e){t(e)}})}
15class H extends Error{constructor(e,t,r){super(t),this.code=e,this.customData=r,this.name="FirebaseError",Object.setPrototypeOf(this,H.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,W.prototype.create)}}class W{constructor(e,t,r){this.service=e,this.serviceName=t,this.errors=r}create(e,...t){var r,n;let i=t[0]||{},s=`${this.service}/${e}`,a=this.errors[e],o=a?(r=a,n=i,r.replace(X,(e,t)=>{let r=n[t];return null!=r?String(r):`<${t}?>`})):"Error",l=`${this.serviceName}: ${o} (${s}).`;return new H(s,l,i)}}let X=/\{\$([^}]+)}/g;function J(e,t){if(e===t)return!0;let r=Object.keys(e),n=Object.keys(t);for(let i of r){if(!n.includes(i))return!1;let r=e[i],s=t[i];if(Y(r)&&Y(s)){if(!J(r,s))return!1}else if(r!==s)return!1}for(let e of n)if(!r.includes(e))return!1;return!0}function Y(e){return null!==e&&"object"==typeof e}class Z{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(e=>{this.error(e)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,r){let n;if(void 0===e&&void 0===t&&void 0===r)throw Error("Missing Observer.");void 0===(n=!function(e,t){if("object"!=typeof e||null===e)return!1;for(let r of t)if(r in e&&"function"==typeof e[r])return!0;return!1}(e,["next","error","complete"])?{next:e,error:t,complete:r}:e).next&&(n.next=ee),void 0===n.error&&(n.error=ee),void 0===n.complete&&(n.complete=ee);let i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?n.error(this.finalError):n.complete()}catch(e){}}),this.observers.push(n),i}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(void 0!==this.observers&&void 0!==this.observers[e])try{t(this.observers[e])}catch(e){"u">typeof console&&console.error&&console.error(e)}})}close(e){this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function ee(){}function et(e){return e&&e._delegate?e._delegate:e}e.s(["Deferred",0,L,"ErrorFactory",0,W,"FirebaseError",0,H,"base64Decode",0,A,"base64urlEncodeWithoutPadding",0,C,"createMockUserToken",0,F,"createSubscribe",0,function(e,t){let r=new Z(e,t);return r.subscribe.bind(r)},"deepEqual",0,J,"extractQuerystring",0,function(e){let t=e.indexOf("?");if(!t)return"";let r=e.indexOf("#",t);return e.substring(t,r>0?r:void 0)},"getDefaultAppConfig",0,R,"getDefaultEmulatorHost",0,k,"getDefaultEmulatorHostnameAndPort",0,O,"getExperimentalSetting",0,e=>{var t;return null==(t=N())?void 0:t[`_${e}`]},"getGlobal",0,D,"getModularInstance",0,et,"getUA",0,q,"isBrowser",0,function(){return"u">typeof window||z()},"isBrowserExtension",0,function(){let e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id},"isCloudWorkstation",0,M,"isCloudflareWorker",0,function(){return"u">typeof navigator&&"Cloudflare-Workers"===navigator.userAgent},"isEmpty",0,function(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0},"isIE",0,function(){let e=q();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0},"isIndexedDBAvailable",0,K,"isMobileCordova",0,function(){return"u">typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(q())},"isReactNative",0,function(){return"object"==typeof navigator&&"ReactNative"===navigator.product},"isSafari",0,$,"isSafariOrWebkit",0,G,"isWebWorker",0,z,"pingServer",0,P,"querystring",0,function(e){let t=[];for(let[r,n]of Object.entries(e))Array.isArray(n)?n.forEach(e=>{t.push(encodeURIComponent(r)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(r)+"="+encodeURIComponent(n));return t.length?"&"+t.join("&"):""},"querystringDecode",0,function(e){let t={};
15return e.replace(/^\?/,"").split("&").forEach(e=>{if(e){let[r,n]=e.split("=");t[decodeURIComponent(r)]=decodeURIComponent(n)}}),t},"updateEmulatorBanner",0,U,"validateIndexedDBOpenable",0,Q],281673);class er{constructor(e,t,r){this.name=e,this.instanceFactory=t,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}let en="[DEFAULT]";class ei{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){let t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){let e=new L;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{let r=this.getOrInitializeService({instanceIdentifier:t});r&&e.resolve(r)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;let r=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),n=null!=(t=null==e?void 0:e.optional)&&t;if(this.isInitialized(r)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:r})}catch(e){if(n)return null;throw e}if(n)return null;throw Error(`Service ${this.name} is not available`)}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if("EAGER"===e.instantiationMode)try{this.getOrInitializeService({instanceIdentifier:en})}catch(e){}for(let[e,t]of this.instancesDeferred.entries()){let r=this.normalizeInstanceIdentifier(e);try{let e=this.getOrInitializeService({instanceIdentifier:r});t.resolve(e)}catch(e){}}}}clearInstance(e=en){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){let e=Array.from(this.instances.values());await Promise.all([...e.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return null!=this.component}isInitialized(e=en){return this.instances.has(e)}getOptions(e=en){return this.instancesOptions.get(e)||{}}initialize(e={}){let{options:t={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);let n=this.getOrInitializeService({instanceIdentifier:r,options:t});for(let[e,t]of this.instancesDeferred.entries())r===this.normalizeInstanceIdentifier(e)&&t.resolve(n);return n}onInit(e,t){var r;let n=this.normalizeInstanceIdentifier(t),i=null!=(r=this.onInitCallbacks.get(n))?r:new Set;i.add(e),this.onInitCallbacks.set(n,i);let s=this.instances.get(n);return s&&e(s,n),()=>{i.delete(e)}}invokeOnInitCallbacks(e,t){let r=this.onInitCallbacks.get(t);if(r)for(let n of r)try{n(e,t)}catch(e){}}getOrInitializeService({instanceIdentifier:e,options:t={}}){var r;let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:(r=e)===en?void 0:r,options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch(e){}return n||null}normalizeInstanceIdentifier(e=en){return this.component?this.component.multipleInstances?e:en:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class es{constructor(e){this.name=e,this.providers=new Map}addComponent(e){let t=this.getProvider(e.name);if(t.isComponentSet())throw Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);let t=new ei(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}e.s(["Component",0,er,"ComponentContainer",0,es],881879);let ea=[];(i=s||(s={}))[i.DEBUG=0]="DEBUG",i[i.VERBOSE=1]="VERBOSE",i[i.INFO=2]="INFO",i[i.WARN=3]="WARN",i[i.ERROR=4]="ERROR",i[i.SILENT=5]="SILENT";
15let eo={debug:s.DEBUG,verbose:s.VERBOSE,info:s.INFO,warn:s.WARN,error:s.ERROR,silent:s.SILENT},el=s.INFO,eu={[s.DEBUG]:"log",[s.VERBOSE]:"log",[s.INFO]:"info",[s.WARN]:"warn",[s.ERROR]:"error"},eh=(e,t,...r)=>{if(t<e.logLevel)return;let n=new Date().toISOString(),i=eu[t];if(i)console[i](`[${n}]  ${e.name}:`,...r);else throw Error(`Attempted to log a message with an invalid logType (value: ${t})`)};class ec{constructor(e){this.name=e,this._logLevel=el,this._logHandler=eh,this._userLogHandler=null,ea.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in s))throw TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?eo[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,s.DEBUG,...e),this._logHandler(this,s.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,s.VERBOSE,...e),this._logHandler(this,s.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,s.INFO,...e),this._logHandler(this,s.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,s.WARN,...e),this._logHandler(this,s.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,s.ERROR,...e),this._logHandler(this,s.ERROR,...e)}}e.s(["LogLevel",0,s,"Logger",0,ec,"setLogLevel",0,function(e){ea.forEach(t=>{t.setLogLevel(e)})},"setUserLogHandler",0,function(e,t){for(let r of ea){let n=null;t&&t.level&&(n=eo[t.level]),null===e?r.userLogHandler=null:r.userLogHandler=(t,r,...i)=>{let a=i.map(e=>{if(null==e)return null;if("string"==typeof e)return e;if("number"==typeof e||"boolean"==typeof e)return e.toString();if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch(e){return null}}).filter(e=>e).join(" ");r>=(null!=n?n:t.logLevel)&&e({level:s[r].toLowerCase(),message:a,args:i,type:t.name})}}}],163971);let ed=new WeakMap,ef=new WeakMap,ep=new WeakMap,eg=new WeakMap,em=new WeakMap,ey={get(e,t,r){if(e instanceof IDBTransaction){if("done"===t)return ef.get(e);if("objectStoreNames"===t)return e.objectStoreNames||ep.get(e);if("store"===t)return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return ev(e[t])},set:(e,t,r)=>(e[t]=r,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function ev(e){if(e instanceof IDBRequest){let t;return(t=new Promise((t,r)=>{let n=()=>{e.removeEventListener("success",i),e.removeEventListener("error",s)},i=()=>{t(ev(e.result)),n()},s=()=>{r(e.error),n()};e.addEventListener("success",i),e.addEventListener("error",s)})).then(t=>{t instanceof IDBCursor&&ed.set(t,e)}).catch(()=>{}),em.set(t,e),t}if(eg.has(e))return eg.get(e);let n=function(e){if("function"==typeof e)return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(r||(r=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(ew(this),t),ev(ed.get(this))}:function(...t){return ev(e.apply(ew(this),t))}:function(t,...r){let n=e.call(ew(this),t,...r);return ep.set(n,t.sort?t.sort():[t]),ev(n)};return e instanceof IDBTransaction&&function(e){if(ef.has(e))return;let t=new Promise((t,r)=>{let n=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",s),e.removeEventListener("abort",s)},i=()=>{t(),n()},s=()=>{r(e.error||new DOMException("AbortError","AbortError")),n()};e.addEventListener("complete",i),e.addEventListener("error",s),e.addEventListener("abort",s)});ef.set(e,t)}(e),(t||(t=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some(t=>e instanceof t)?new Proxy(e,ey):e}(e);return n!==e&&(eg.set(e,n),em.set(n,e)),n}let ew=e=>em.get(e),eb=["get","getKey","getAll","getAllKeys","count"],eE=["put","add","delete","clear"],eI=new Map;function e_(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t))return;if(eI.get(t))return eI.get(t);
15let r=t.replace(/FromIndex$/,""),n=t!==r,i=eE.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(i||eb.includes(r)))return;let s=async function(e,...t){let s=this.transaction(e,i?"readwrite":"readonly"),a=s.store;return n&&(a=a.index(t.shift())),(await Promise.all([a[r](...t),i&&s.done]))[0]};return eI.set(t,s),s}ey={...n=ey,get:(e,t,r)=>e_(e,t)||n.get(e,t,r),has:(e,t)=>!!e_(e,t)||n.has(e,t)};class eT{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{let t;if((null==(t=e.getComponent())?void 0:t.type)!=="VERSION")return null;{let t=e.getImmediate();return`${t.library}/${t.version}`}}).filter(e=>e).join(" ")}}let eS="@firebase/app",ex="0.13.2",eC=new ec("@firebase/app"),eA="[DEFAULT]",eD={[eS]:"fire-core","@firebase/app-compat":"fire-core-compat","@firebase/analytics":"fire-analytics","@firebase/analytics-compat":"fire-analytics-compat","@firebase/app-check":"fire-app-check","@firebase/app-check-compat":"fire-app-check-compat","@firebase/auth":"fire-auth","@firebase/auth-compat":"fire-auth-compat","@firebase/database":"fire-rtdb","@firebase/data-connect":"fire-data-connect","@firebase/database-compat":"fire-rtdb-compat","@firebase/functions":"fire-fn","@firebase/functions-compat":"fire-fn-compat","@firebase/installations":"fire-iid","@firebase/installations-compat":"fire-iid-compat","@firebase/messaging":"fire-fcm","@firebase/messaging-compat":"fire-fcm-compat","@firebase/performance":"fire-perf","@firebase/performance-compat":"fire-perf-compat","@firebase/remote-config":"fire-rc","@firebase/remote-config-compat":"fire-rc-compat","@firebase/storage":"fire-gcs","@firebase/storage-compat":"fire-gcs-compat","@firebase/firestore":"fire-fst","@firebase/firestore-compat":"fire-fst-compat","@firebase/ai":"fire-vertex","fire-js":"fire-js",firebase:"fire-js-all"},eN=new Map,ek=new Map,eO=new Map;function eR(e,t){try{e.container.addComponent(t)}catch(r){eC.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,r)}}function eL(e){let t=e.name;if(eO.has(t))return eC.debug(`There were multiple attempts to register component ${t}.`),!1;for(let r of(eO.set(t,e),eN.values()))eR(r,e);for(let t of ek.values())eR(t,e);return!0}function eM(e,t){let r=e.container.getProvider("heartbeat").getImmediate({optional:!0});return r&&r.triggerHeartbeat(),e.container.getProvider(t)}function eP(e,t,r=eA){eM(e,t).clearInstance(r)}function eF(e){return null!=e&&void 0!==e.settings}let eV=new W("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invali
15d-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."});class eB{constructor(e,t,r){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new er("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw eV.create("app-deleted",{appName:this._name})}}let eU="11.10.0";
15function eq(e,t={}){let r=e;"object"!=typeof t&&(t={name:t});let n=Object.assign({name:eA,automaticDataCollectionEnabled:!0},t),i=n.name;if("string"!=typeof i||!i)throw eV.create("bad-app-name",{appName:String(i)});if(r||(r=R()),!r)throw eV.create("no-options");let s=eN.get(i);if(s)if(J(r,s.options)&&J(n,s.config))return s;else throw eV.create("duplicate-app",{appName:i});let a=new es(i);for(let e of eO.values())a.addComponent(e);let o=new eB(r,n,a);return eN.set(i,o),o}function ej(e=eA){let t=eN.get(e);if(!t&&e===eA&&R())return eq();if(!t)throw eV.create("no-app",{appName:e});return t}function ez(e,t,r){var n;let i=null!=(n=eD[e])?n:e;r&&(i+=`-${r}`);let s=i.match(/\s|\//),a=t.match(/\s|\//);if(s||a){let e=[`Unable to register library "${i}" with version "${t}":`];s&&e.push(`library name "${i}" contains illegal characters (whitespace or "/")`),s&&a&&e.push("and"),a&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),eC.warn(e.join(" "));return}eL(new er(`${i}-version`,()=>({library:i,version:t}),"VERSION"))}let e$="firebase-heartbeat-store",eG=null;function eK(){return eG||(eG=(function(e,{blocked:t,upgrade:r,blocking:n,terminated:i}={}){let s=indexedDB.open(e,1),a=ev(s);return r&&s.addEventListener("upgradeneeded",e=>{r(ev(s.result),e.oldVersion,e.newVersion,ev(s.transaction),e)}),t&&s.addEventListener("blocked",e=>t(e.oldVersion,e.newVersion,e)),a.then(e=>{i&&e.addEventListener("close",()=>i()),n&&e.addEventListener("versionchange",e=>n(e.oldVersion,e.newVersion,e))}).catch(()=>{}),a})("firebase-heartbeat-database",{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(e$)}catch(e){console.warn(e)}}}).catch(e=>{throw eV.create("idb-open",{originalErrorMessage:e.message})})),eG}async function eQ(e){try{let t=(await eK()).transaction(e$),r=await t.objectStore(e$).get(eW(e));return await t.done,r}catch(e){if(e instanceof H)eC.warn(e.message);else{let t=eV.create("idb-get",{originalErrorMessage:null==e?void 0:e.message});eC.warn(t.message)}}}async function eH(e,t){try{let r=(await eK()).transaction(e$,"readwrite"),n=r.objectStore(e$);await n.put(t,eW(e)),await r.done}catch(e){if(e instanceof H)eC.warn(e.message);else{let t=eV.create("idb-set",{originalErrorMessage:null==e?void 0:e.message});eC.warn(t.message)}}}function eW(e){return`${e.name}!${e.options.appId}`}class eX{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new eY(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){var e,t;try{let r=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),n=eJ();if((null==(e=this._heartbeatsCache)?void 0:e.heartbeats)==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,(null==(t=this._heartbeatsCache)?void 0:t.heartbeats)==null)||this._heartbeatsCache.lastSentHeartbeatDate===n||this._heartbeatsCache.heartbeats.some(e=>e.date===n))return;if(this._heartbeatsCache.heartbeats.push({date:n,agent:r}),this._heartbeatsCache.heartbeats.length>30){let e=function(e){if(0===e.length)return -1;let t=0,r=e[0].date;for(let n=1;n<e.length;n++)e[n].date<r&&(r=e[n].date,t=n);return t}(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){eC.warn(e)}}async getHeartbeatsHeader(){var e;try{if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,(null==(e=this._heartbeatsCache)?void 0:e.heartbeats)==null||0===this._heartbeatsCache.heartbeats.length)return"";let t=eJ(),{heartbeatsToSend:r,unsentEntries:n}=function(e,t=1024){let r=[],n=e.slice();for(let i of e){let e=r.find(e=>e.agent===i.agent);if(e){if(e.dates.push(i.date),eZ(r)>t){e.dates.pop();break}}else if(r.push({agent:i.agent,dates:[i.date]}),eZ(r)>t){r.pop();break}n=n.slice(1)}return{heartbeatsToSend:r,unsentEntries:n}}(this._heartbeatsCache.heartbeats),i=C(JSON.stringify({version:2,heartbeats:r}));return this._heartbeatsCache.lastSentHeartbeatDate=t,n.length>0?(this._heartbeatsCache.heartbeats=n,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(e){return eC.warn(e),""}}}function eJ(){return new Date().toISOString().substring(0,10)}class eY{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!K()&&Q().then(()=>!0).catch(()=>!1)}async read(){if(!await this._canUseIndexedDBPromise)return{heartbeats:[]};{let e=await eQ(this.app);return(null==e?void 0:e.heartbeats)?e:{heartbeats:[]}}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){let r=await this.read();return eH(this.app,{lastSentHeartbeatDate:null!=(t=e.lastSentHeartbeatDate)?t:r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){var t;if(await this._canUseIndexedDBPromise){let r=await this.read();return eH(this.app,{lastSentHeartbeatDate:null!=(t=e.lastSentHeartbeatDate)?t:r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}}}function eZ(e){return C(JSON.stringify({version:2,heartbeats:e})).length}eL(new er("platform-logger",e=>new eT(e),"PRIVATE")),eL(new er("heartbeat",e=>new eX(e),"PRIVATE")),ez(eS,ex,""),ez(eS,ex,"esm2017"),ez("fire-js",""),e.s(["SDK_VERSION",0,eU,"_getProvider",0,eM,"_isFirebaseServerApp",0,eF,"_registerComponent",0,eL,"_removeServiceInstance",0,eP,"getApp",0,ej,"getApps",0,function(){return Array.from(eN.values())},"initializeApp",0,eq,"registerVersion",0,ez],718044);var e0="u">typeof globalThis?globalThis:"u">typeof window?window:e.g,e1={};(function(){function e(){this.blockSize=-1,this.blockSize=64,this.g=[,,,,],this.B=Array(this.blockSize),this.o=this.h=0,this.s()}var t=function(){this.blockSize=-1};function r(){}function n(e,t,r){r||(r=0);var n=Array(16);if("string"==typeof t)for(var i=0;16>i;++i)n[i]=t.charCodeAt(r++)|t.charCodeAt(r++)<<8|t.charCodeAt(r++)<<16|t.charCodeAt(r++)<<24;else for(i=0;16>i;++i)n[i]=t[r++]|t[r++]<<8|t[r++]<<16|t[r++]<<24;t=e.g[0],r=e.g[1],i=e.g[2];var s=e.g[3],a=t+(s^r&(i^s))+n[0]+0xd76aa478|0;a=s+(i^(t=r+(a<<7|a>>>25))&(r^i))+n[1]+0xe8c7b756|0,a=i+(r^(s=t+(a<<12|a>>>20))&(t^r))+n[2]+0x242070db|0,a=r+(t^(i=s+(a<<17|a>>>15))&(s^t))+n[3]+0xc1bdceee|0,a=t+(s^(r=i+(a<<22|a>>>10))&(i^s))+n[4]+0xf57c0faf|0,a=s+(i^(t=r+(a<<7|a>>>25))&(r^i))+n[5]+0x4787c62a|0,a=i+(r^(s=t+(a<<12|a>>>20))&(t^r))+n[6]+0xa8304613|0,a=r+(t^(i=s+(a<<17|a>>>
1515))&(s^t))+n[7]+0xfd469501|0,a=t+(s^(r=i+(a<<22|a>>>10))&(i^s))+n[8]+0x698098d8|0,a=s+(i^(t=r+(a<<7|a>>>25))&(r^i))+n[9]+0x8b44f7af|0,a=i+(r^(s=t+(a<<12|a>>>20))&(t^r))+n[10]+0xffff5bb1|0,a=r+(t^(i=s+(a<<17|a>>>15))&(s^t))+n[11]+0x895cd7be|0,a=t+(s^(r=i+(a<<22|a>>>10))&(i^s))+n[12]+0x6b901122|0,a=s+(i^(t=r+(a<<7|a>>>25))&(r^i))+n[13]+0xfd987193|0,a=i+(r^(s=t+(a<<12|a>>>20))&(t^r))+n[14]+0xa679438e|0,a=r+(t^(i=s+(a<<17|a>>>15))&(s^t))+n[15]+0x49b40821|0,r=i+(a<<22|a>>>10),a=t+(i^s&(r^i))+n[1]+0xf61e2562|0,t=r+(a<<5|a>>>27),a=s+(r^i&(t^r))+n[6]+0xc040b340|0,s=t+(a<<9|a>>>23),a=i+(t^r&(s^t))+n[11]+0x265e5a51|0,i=s+(a<<14|a>>>18),a=r+(s^t&(i^s))+n[0]+0xe9b6c7aa|0,r=i+(a<<20|a>>>12),a=t+(i^s&(r^i))+n[5]+0xd62f105d|0,t=r+(a<<5|a>>>27),a=s+(r^i&(t^r))+n[10]+0x2441453|0,s=t+(a<<9|a>>>23),a=i+(t^r&(s^t))+n[15]+0xd8a1e681|0,i=s+(a<<14|a>>>18),a=r+(s^t&(i^s))+n[4]+0xe7d3fbc8|0,r=i+(a<<20|a>>>12),a=t+(i^s&(r^i))+n[9]+0x21e1cde6|0,t=r+(a<<5|a>>>27),a=s+(r^i&(t^r))+n[14]+0xc33707d6|0,s=t+(a<<9|a>>>23),a=i+(t^r&(s^t))+n[3]+0xf4d50d87|0,i=s+(a<<14|a>>>18),a=r+(s^t&(i^s))+n[8]+0x455a14ed|0,r=i+(a<<20|a>>>12),a=t+(i^s&(r^i))+n[13]+0xa9e3e905|0,t=r+(a<<5|a>>>27),a=s+(r^i&(t^r))+n[2]+0xfcefa3f8|0,s=t+(a<<9|a>>>23),a=i+(t^r&(s^t))+n[7]+0x676f02d9|0,i=s+(a<<14|a>>>18),a=r+(s^t&(i^s))+n[12]+0x8d2a4c8a|0,a=t+((r=i+(a<<20|a>>>12))^i^s)+n[5]+0xfffa3942|0,a=s+((t=r+(a<<4|a>>>28))^r^i)+n[8]+0x8771f681|0,a=i+((s=t+(a<<11|a>>>21))^t^r)+n[11]+0x6d9d6122|0,a=r+((i=s+(a<<16|a>>>16))^s^t)+n[14]+0xfde5380c|0,a=t+((r=i+(a<<23|a>>>9))^i^s)+n[1]+0xa4beea44|0,a=s+((t=r+(a<<4|a>>>28))^r^i)+n[4]+0x4bdecfa9|0,a=i+((s=t+(a<<11|a>>>21))^t^r)+n[7]+0xf6bb4b60|0,a=r+((i=s+(a<<16|a>>>16))^s^t)+n[10]+0xbebfbc70|0,a=t+((r=i+(a<<23|a>>>9))^i^s)+n[13]+0x289b7ec6|0,a=s+((t=r+(a<<4|a>>>28))^r^i)+n[0]+0xeaa127fa|0,a=i+((s=t+(a<<11|a>>>21))^t^r)+n[3]+0xd4ef3085|0,a=r+((i=s+(a<<16|a>>>16))^s^t)+n[6]+0x4881d05|0,a=t+((r=i+(a<<23|a>>>9))^i^s)+n[9]+0xd9d4d039|0,a=s+((t=r+(a<<4|a>>>28))^r^i)+n[12]+0xe6db99e5|0,a=i+((s=t+(a<<11|a>>>21))^t^r)+n[15]+0x1fa27cf8|0,a=r+((i=s+(a<<16|a>>>16))^s^t)+n[2]+0xc4ac5665|0,r=i+(a<<23|a>>>9),a=t+(i^(r|~s))+n[0]+0xf4292244|0,t=r+(a<<6|a>>>26),a=s+(r^(t|~i))+n[7]+0x432aff97|0,s=t+(a<<10|a>>>22),a=i+(t^(s|~r))+n[14]+0xab9423a7|0,i=s+(a<<15|a>>>17),a=r+(s^(i|~t))+n[5]+0xfc93a039|0,r=i+(a<<21|a>>>11),a=t+(i^(r|~s))+n[12]+0x655b59c3|0,t=r+(a<<6|a>>>26),a=s+(r^(t|~i))+n[3]+0x8f0ccc92|0,s=t+(a<<10|a>>>22),a=i+(t^(s|~r))+n[10]+0xffeff47d|0,i=s+(a<<15|a>>>17),a=r+(s^(i|~t))+n[1]+0x85845dd1|0,r=i+(a<<21|a>>>11),a=t+(i^(r|~s))+n[8]+0x6fa87e4f|0,t=r+(a<<6|a>>>26),a=s+(r^(t|~i))+n[15]+0xfe2ce6e0|0,s=t+(a<<10|a>>>22),a=i+(t^(s|~r))+n[6]+0xa3014314|0,i=s+(a<<15|a>>>17),a=r+(s^(i|~t))+n[13]+0x4e0811a1|0,r=i+(a<<21|a>>>11),a=t+(i^(r|~s))+n[4]+0xf7537e82|0,t=r+(a<<6|a>>>26),a=s+(r^(t|~i))+n[11]+0xbd3af235|0,s=t+(a<<10|a>>>22),a=i+(t^(s|~r))+n[2]+0x2ad7d2bb|0,i=s+(a<<15|a>>>17),a=r+(s^(i|~t))+n[9]+0xeb86d391|0,e.g[0]=e.g[0]+t|0,e.g[1]=e.g[1]+(i+(a<<21|a>>>11))|0,e.g[2]=e.g[2]+i|0,e.g[3]=e.g[3]+s|0}function i(e,t){this.h=t;for(var r=[],n=!0,i=e.length-1;0<=i;i--){var s=0|e[i];n&&s==t||(r[i]=s,n=!1)}this.g=r}r.prototype=t.prototype,e.D=t.prototype,e.prototype=new r,e.prototype.constructor=e,e.C=function(e,r,n){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[r].apply(e,i)},e.prototype.s=function(){this.g[0]=0x67452301,this.g[1]=0xefcdab89,this.g[2]=0x98badcfe,this.g[3]=0x10325476,this.o=this.h=0},e.prototype.u=function(e,t){void 0===t&&(t=e.length);for(var r=t-this.blockSize,i=this.B,s=this.h,a=0;a<t;){if(0==s)for(;a<=r;)n(this,e,a),a+=this.blockSize;if("string"==typeof e){for(;a<t;)if(i[s++]=e.charCodeAt(a++),s==this.blockSize){n(this,i),s=0;break}}else for(;a<t;)if(i[s++]=e[a++],s==this.blockSize){n(this,i),s=0;break}}this.h=s,this.o+=t},e.prototype.v=function(){var e=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;var r=8*this.o;for(t=e.length-8;t<e.length;++t)e[t]=255&r,r/=256;for(this.u(e),e=Array(16),t=r=0;4>t;++t)for(var n=0;32>n;n+=8)e[r++]=this.g[t]>>>n&255;return e};var s,l={};function u(e){var t;return -128<=e&&128>e?(t=function(e){return new i([0|e],0>e?-1:0)},Object.prototype.hasOwnProperty.call(l,e)?l[e]:l[e]=t(e)):new i([0|e],0>e?-1:0)}function h(e){if(isNaN(e)||!isFinite(e))return c;if(0>e)return m(h(-e));for(var t=[],r=1,n=0;e>=r;n++)t[n]=e/r|0,r*=0x100000000;return new i(t,0)}var c=u(0),d=u(1),f=u(0x1000000);function p(e){if(0!=e.h)return!1;for(var t=0;t<e.g.length;t++)if(0!=e.g[t])return!1;return!0}function g(e){return -1==e.h}function m(e){for(var t=e.g.length,r=[],n=0;n<t;n++)r[n]=~e.g[n];return new i(r,~e.h).add(d)}function y(e,t){return e.add(m(t))}function v(e,t){for(;(65535&e[t])!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function w(e,t){this.g=e,this.h=t}function b(e,t){if(p(t))throw Error("division by zero");if(p(e))return new w(c,c);if(g(e))return t=b(m(e),t),new w(m(t.g),m(t.h));if(g(t))return t=b(e,m(t)),new w(m(t.g),t.h);if(30<e.g.length){if(g(e)||g(t))throw Error("slowDivide_ only works with positive integers.");for(var r=d,n=t;0>=n.l(e);)r=E(r),n=E(n);var i=I(r,1),s=I(n,1);for(n=I(n,2),r=I(r,2);!p(n);){var a=s.add(n);0>=a.l(e)&&(i=i.add(r),s=a),n=I(n,1),r=I(r,1)}return t=y(e,i.j(t)),new w(i,t)}for(i=c;0<=e.l(t);){for(n=48>=(n=Math.ceil(Math.log(r=Math.max(1,Math.floor(e.m()/t.m())))/Math.LN2))?1:Math.pow(2,n-48),a=(s=h(r)).j(t);g(a)||0<a.l(e);)r-=n,a=(s=h(r)).j(t);p(s)&&(s=d),i=i.add(s),e=y(e,a)}return new w(i,e)}function E(e){for(var t=e.g.length+1,r=[],n=0;n<t;n++)r[n]=e.i(n)<<1|e.i(n-1)>>>31;return new i(r,e.h)}function I(e,t){var r=t>>5;t%=32;for(var n=e.g.length-r,s=[],a=0;a<n;a++)s[a]=0<t?e.i(a+r)>>>t|e.i(a+r+1)<<32-t:e.i(a+r);return new i(s,e.h)}(s=i.prototype).m=function(){if(g(this))return-m(this).m();for(var e=0,t=1,r=0;r<this.g.length;r++){var n=this.i(r);e+=(0<=n?n:0x100000000+n)*t,t*=0x100000000}return e},s.toString=function(e){if(2>(e=e||10)||36<e)throw Error("radix out of range: "+e);if(p(this))return"0";if(g(this))return"-"+m(this).toString(e);for(var t=h(Math.pow(e,6)),r=this,n="";;){var i=b(r,t).g,s=((0<(r=y(r,i.j(t))).g.length?r.g[0]:r.h)>>>0).toString(e);if(p(r=i))return s+n;for(;6>s.length;)s="0"+s;n=s+n}},s.i=function(e){return 0>e?0:e<this.g.length?this.g[e]:this.h},s.l=function(e){return g(e=y(this,e))?-1:+!p(e)},s.abs=function(){return g(this)?m(this):this},s.add=function(e){for(var t=Math.max(this.g.length,e.g.length),r=[],n=0,s=0;s<=t;s++){var a=n+(65535&this.i(s))+(65535&e.i(s)),o=(a>>>16)+(this.i(s)>>>16)+(e.i(s)>>>16);n=o>>>16,a&=65535,o&=65535,r[s]=o<<16|a}return new i(r,-0x80000000&r[r.length-1]?-1:0)},s.j=function(e){if(p(this)||p(e))return c;if(g(this))return g(e)?m(this).j(m(e)):m(m(this).j(e));if(g(e))return m(this.j(m(e)));if(0>this.l(f)&&0>e.l(f))return h(this.m()*e.m());for(var t=this.g.length+e.g.length,r=[],n=0;n<2*t;n++)r[n]=0;for(n=0;n<this.g.length;n++)for(var s=0;s<e.g.length;s++){var a=this.i(n)>>>16,o=65535&this.i(n),l=e.i(s)>>>16,u=65535&e.i(s);r[2*n+2*s]+=o*u,v(r,2*n+2*s),r[2*n+2*s+1]+=a*u,v(r,2*n+2*s+1),r[2*n+2*s+1]+=o*l,v(r,2*n+2*s+1),r[2*n+2*s+2]+=a*l,v(r,2*n+2*s+2)}for(n=0;n<t;n++)r[n]=r[2*n+1]<<16|r[2*n];for(n=t;n<2*t;n++)r[n]=0;return new i(r,0)},s.A=function(e){return b(this,e).h},s.and=function(e){for(var t=Math.max(this.g.length,e.g.length),r=[],n=0;n<t;n++)r[n]=this.i(n)&e.i(n);return new i(r,this.h&e.h)},s.or=function(e){for(var t=Math.max(this.g.length,e.g.length),r=[],n=0;n<t;n++)r[n]=this.i(n)|e.i(n);return new i(r,this.h|e.h)},s.xor=function(e){for(var t=Math.max(this.g.length,e.g.length),r=[],n=0;n<t;n++)r[n]=this.i(n)^e.i(n);return new i(r,this.h^e.h)},e.prototype.digest=e.prototype.v,e.prototype.reset=e.prototype.s,e.prototype.update=e.prototype.u,o=e1.Md5=e,i.prototype.add=i.prototype.add,i.prototype.multiply=i.prototype.j,i.prototype.modulo=i.prototype.A,i.prototype.compare=i.prototype.l,i.prototype.toNumber=i.prototype.m,i.prototype.toString=i.prototype.toString,i.prototype.getBits=i.prototype.i,i.fromNumber=h,i.fromString=function e(t,r){if(0==t.length)throw Error("number format error: empty string");if(2>(r=r||10)||36<r)throw Error("radix out of range: "+r);if("-"==t.charAt(0))return m(e(t.substring(1),r));if(0<=t.indexOf("-"))throw Error('number format error: interior "-" character');for(var n=h(Math.pow(r,8)),i=c,s=0;s<t.length;s+=8){var a=Math.min(8,t.length-s),o=parseInt(t.substring(s,s+a),r);8>a?(a=h(Math.pow(r,a)),i=i.j(a).add(h(o))):i=(i=i.j(n)).add(h(o))}return i},a=e1.Integer=i}).apply(void 0!==e0?e0:"u">typeof self?self:"u">typeof window?window:{});var e2="u">typeof globalThis?globalThis:"u">typeof window?window:e.g,e6={};(function(){var e,t,r,n="function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,r){return e==Array.prototype||e==Object.prototype||(e[t]=r.value),e},i=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof e2&&e2];for(var t=0;t<e.length;++t){var r=e[t];if(r&&r.Math==Math)return r}throw Error("Cannot find global object")}(this);!function(e,t){if(t)e:{var r=i;e=e.split(".");for(var s=0;s<e.length-1;s++){var a=e[s];if(!(a in r))break e;r=r[a]}(t=t(s=r[e=e[e.length-1]]))!=s&&null!=t&&n(r,e,{configurable:!0,writable:!0,value:t})}}("Array.prototype.values",function(e){return e||function(){var e,t,r,n,i;return e=this,t=function(e,t){return t},e instanceof String&&(e+=""),r=0,n=!1,(i={next:function(){if(!n&&r<e.length){var i=r++;return{value:t(i,e[i]),done:!1}}return n=!0,{done:!0,value:void 0}}})[Symbol.iterator]=function(){return i},i}});var s=s||{},a=this||self;function o(e){var t=typeof e;return"array"==(t="object"!=t?t:e?Array.isArray(e)?"array":t:"null")||"object"==t&&"number"==typeof e.length}function m(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}function y(e,t,r){return e.call.apply(e.bind,arguments)}function v(e,t,r){if(!e)throw Error();if(2<arguments.length){var n=Array.prototype.slice.call(arguments,2);return function(){var r=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(r,n),e.apply(t,r)}}return function(){return e.apply(t,arguments)}}function w(e,t,r){return(w=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?y:v).apply(null,arguments)}
15function b(e,t){var r=Array.prototype.slice.call(arguments,1);return function(){var t=r.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function E(e,t){function r(){}r.prototype=t.prototype,e.aa=t.prototype,e.prototype=new r,e.prototype.constructor=e,e.Qb=function(e,r,n){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[r].apply(e,i)}}function I(e){let t=e.length;if(0<t){let r=Array(t);for(let n=0;n<t;n++)r[n]=e[n];return r}return[]}function _(e,t){for(let t=1;t<arguments.length;t++){let r=arguments[t];if(o(r)){let t=e.length||0,n=r.length||0;e.length=t+n;for(let i=0;i<n;i++)e[t+i]=r[i]}else e.push(r)}}function T(e){return/^[\s\xa0]*$/.test(e)}function S(){var e=a.navigator;return e&&(e=e.userAgent)?e:""}function x(e){return x[" "](e),e}x[" "]=function(){};var C=-1!=S().indexOf("Gecko")&&(-1==S().toLowerCase().indexOf("webkit")||-1!=S().indexOf("Edge"))&&-1==S().indexOf("Trident")&&-1==S().indexOf("MSIE")&&-1==S().indexOf("Edge");function A(e,t,r){for(let n in e)t.call(r,e[n],n,e)}function D(e){let t={};for(let r in e)t[r]=e[r];return t}let N="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function k(e,t){let r,n;for(let t=1;t<arguments.length;t++){for(r in n=arguments[t])e[r]=n[r];for(let t=0;t<N.length;t++)r=N[t],Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}}var O=new class{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return 0<this.h?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}(()=>new R,e=>e.reset());class R{constructor(){this.next=this.g=this.h=null}set(e,t){this.h=e,this.g=t,this.next=null}reset(){this.next=this.g=this.h=null}}let L,M=!1,P=new class{constructor(){this.h=this.g=null}add(e,t){let r=O.get();r.set(e,t),this.h?this.h.next=r:this.g=r,this.h=r}},F=()=>{let e=a.Promise.resolve(void 0);L=()=>{e.then(V)}};var V=()=>{let e;for(var t;e=null,P.g&&(e=P.g,P.g=P.g.next,P.g||(P.h=null),e.next=null),t=e;){try{t.h.call(t.g)}catch(e){!function(e){a.setTimeout(()=>{throw e},0)}(e)}O.j(t),100>O.h&&(O.h++,t.next=O.g,O.g=t)}M=!1};function B(){this.s=this.s,this.C=this.C}function U(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}B.prototype.s=!1,B.prototype.ma=function(){this.s||(this.s=!0,this.N())},B.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},U.prototype.h=function(){this.defaultPrevented=!0};var q=function(){if(!a.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{let e=()=>{};a.addEventListener("test",e,t),a.removeEventListener("test",e,t)}catch(e){}return e}();function j(e,t){if(U.call(this,e?e.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,e){var r=this.type=e.type,n=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;if(this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget){if(C){e:{try{x(t.nodeName);var i=!0;break e}catch(e){}i=!1}i||(t=null)}}else"mouseover"==r?t=e.fromElement:"mouseout"==r&&(t=e.toElement);this.relatedTarget=t,n?(this.clientX=void 0!==n.clientX?n.clientX:n.pageX,this.clientY=void 0!==n.clientY?n.clientY:n.pageY,this.screenX=n.screenX||0,this.screenY=n.screenY||0):(this.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||"",this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType="string"==typeof e.pointerType?e.pointerType:z[e.pointerType]||"",this.state=e.state,this.i=e,e.defaultPrevented&&j.aa.h.call(this)}}E(j,U);var z={2:"touch",3:"pen",4:"mouse"};j.prototype.h=function(){j.aa.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var $="closure_listenable_"+(1e6*Math.random()|0),G=0;function K(e,t,r,n,i){this.listener=e,this.proxy=null,this.src=t,this.type=r,this.capture=!!n,this.ha=i,this.key=++G,this.da=this.fa=!1}function Q(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function H(e){this.src=e,this.g={},this.h=0}function W(e,t){var r=t.type;if(r in e.g){var n,i=e.g[r],s=Array.prototype.indexOf.call(i,t,void 0);(n=0<=s)&&Array.prototype.splice.call(i,s,1),n&&(Q(t),0==e.g[r].length&&(delete e.g[r],e.h--))}}function X(e,t,r,n){for(var i=0;i<e.length;++i){var s=e[i];if(!s.da&&s.listener==t&&!!r==s.capture&&s.ha==n)return i}return -1}H.prototype.add=function(e,t,r,n,i){var s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);var a=X(e,t,n,i);return -1<a?(t=e[a],r||(t.fa=!1)):((t=new K(t,this.src,s,!!n,i)).fa=r,e.push(t)),t};var J="closure_lm_"+(1e6*Math.random()|0),Y={};function Z(e,t,r,n,i,s){if(!t)throw Error("Invalid event type");var a=m(i)?!!i.capture:!!i,o=en(e);if(o||(e[J]=o=new H(e)),(r=o.add(t,r,n,a,s)).proxy)return r;if(n=function e(t){return er.call(e.src,e.listener,t)},r.proxy=n,n.src=e,n.listener=r,e.addEventListener)q||(i=a),void 0===i&&(i=!1),e.addEventListener(t.toString(),n,i);else if(e.attachEvent)e.attachEvent(et(t.toString()),n);else if(e.addListener&&e.removeListener)e.addListener(n);else throw Error("addEventListener and attachEvent are unavailable.");return r}function ee(e){if("number"!=typeof e&&e&&!e.da){var t=e.src;if(t&&t[$])W(t.i,e);else{var r=e.type,n=e.proxy;t.removeEventListener?t.removeEventListener(r,n,e.capture):t.detachEvent?t.detachEvent(et(r),n):t.addListener&&t.removeListener&&t.removeListener(n),(r=en(t))?(W(r,e),
150==r.h&&(r.src=null,t[J]=null)):Q(e)}}}function et(e){return e in Y?Y[e]:Y[e]="on"+e}function er(e,t){if(e.da)e=!0;else{t=new j(t,this);var r=e.listener,n=e.ha||e.src;e.fa&&ee(e),e=r.call(n,t)}return e}function en(e){return(e=e[J])instanceof H?e:null}var ei="__closure_events_fn_"+(1e9*Math.random()>>>0);function es(e){return"function"==typeof e?e:(e[ei]||(e[ei]=function(t){return e.handleEvent(t)}),e[ei])}function ea(){B.call(this),this.i=new H(this),this.M=this,this.F=null}function eo(e,t){var r,n=e.F;if(n)for(r=[];n;n=n.F)r.push(n);if(e=e.M,n=t.type||t,"string"==typeof t)t=new U(t,e);else if(t instanceof U)t.target=t.target||e;else{var i=t;k(t=new U(n,e),i)}if(i=!0,r)for(var s=r.length-1;0<=s;s--){var a=t.g=r[s];i=el(a,n,!0,t)&&i}if(i=el(a=t.g=e,n,!0,t)&&i,i=el(a,n,!1,t)&&i,r)for(s=0;s<r.length;s++)i=el(a=t.g=r[s],n,!1,t)&&i}function el(e,t,r,n){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();for(var i=!0,s=0;s<t.length;++s){var a=t[s];if(a&&!a.da&&a.capture==r){var o=a.listener,l=a.ha||a.src;a.fa&&W(e.i,a),i=!1!==o.call(l,n)&&i}}return i&&!n.defaultPrevented}function eu(e,t,r){if("function"==typeof e)r&&(e=w(e,r));else if(e&&"function"==typeof e.handleEvent)e=w(e.handleEvent,e);else throw Error("Invalid listener argument");return 0x7fffffff<Number(t)?-1:a.setTimeout(e,t||0)}E(ea,B),ea.prototype[$]=!0,ea.prototype.removeEventListener=function(e,t,r,n){!function e(t,r,n,i,s){if(Array.isArray(r))for(var a=0;a<r.length;a++)e(t,r[a],n,i,s);else(i=m(i)?!!i.capture:!!i,n=es(n),t&&t[$])?(t=t.i,(r=String(r).toString())in t.g&&-1<(n=X(a=t.g[r],n,i,s))&&(Q(a[n]),Array.prototype.splice.call(a,n,1),0==a.length&&(delete t.g[r],t.h--))):t&&(t=en(t))&&(r=t.g[r.toString()],t=-1,r&&(t=X(r,n,i,s)),(n=-1<t?r[t]:null)&&ee(n))}(this,e,t,r,n)},ea.prototype.N=function(){if(ea.aa.N.call(this),this.i){var e,t=this.i;for(e in t.g){for(var r=t.g[e],n=0;n<r.length;n++)Q(r[n]);delete t.g[e],t.h--}}this.F=null},ea.prototype.K=function(e,t,r,n){return this.i.add(String(e),t,!1,r,n)},ea.prototype.L=function(e,t,r,n){return this.i.add(String(e),t,!0,r,n)};class eh extends B{constructor(e,t){super(),this.m=e,this.l=t,this.h=null,this.i=!1,this.g=null}j(e){this.h=arguments,this.g?this.i=!0:function e(t){t.g=eu(()=>{t.g=null,t.i&&(t.i=!1,e(t))},t.l);let r=t.h;t.h=null,t.m.apply(null,r)}(this)}N(){super.N(),this.g&&(a.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function ec(e){B.call(this),this.h=e,this.g={}}E(ec,B);var ed=[];function ef(e){A(e.g,function(e,t){this.g.hasOwnProperty(t)&&ee(e)},e),e.g={}}ec.prototype.N=function(){ec.aa.N.call(this),ef(this)},ec.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var ep=a.JSON.stringify,eg=a.JSON.parse,em=class{stringify(e){return a.JSON.stringify(e,void 0)}parse(e){return a.JSON.parse(e,void 0)}};function ey(){}function ev(e){return e.h||(e.h=e.i())}function ew(){}ey.prototype.h=null;var eb={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function eE(){U.call(this,"d")}function eI(){U.call(this,"c")}E(eE,U),E(eI,U);var e_={},eT=null;function eS(){return eT=eT||new ea}function ex(e){U.call(this,e_.La,e)}function eC(e){let t=eS();eo(t,new ex(t))}function eA(e,t){U.call(this,e_.STAT_EVENT,e),this.stat=t}function eD(e){let t=eS();eo(t,new eA(t,e))}function eN(e,t){U.call(this,e_.Ma,e),this.size=t}function ek(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return a.setTimeout(function(){e()},t)}function eO(){this.g=!0}function eR(e,t,r,n){e.info(function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{var r=JSON.parse(t);if(r){for(e=0;e<r.length;e++)if(Array.isArray(r[e])){var n=r[e];if(!(2>n.length)){var i=n[1];if(Array.isArray(i)&&!(1>i.length)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var a=1;a<i.length;a++)i[a]=""}}}}return ep(r)}catch(e){return t}}(e,r)+(n?" "+n:"")})}e_.La="serverreachability",E(ex,U),e_.STAT_EVENT="statevent",E(eA,U),e_.Ma="timingevent",E(eN,U),eO.prototype.xa=function(){this.g=!1},eO.prototype.info=function(){};var eL={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},eM={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"};function eP(){}function eF(e,t,r,n){this.j=e,this.i=t,this.l=r,this.R=n||1,this.U=new ec(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new eV}function eV(){this.i=null,this.g="",this.h=!1}E(eP,ey),eP.prototype.g=function(){return new XMLHttpRequest},eP.prototype.i=function(){return{}},t=new eP;var eB={},eU={};function eq(e,t,r){e.L=1,e.v=ti(e9(t)),e.m=r,e.P=!0,ej(e,null)}function ej(e,t){e.F=Date.now(),e$(e),e.A=e9(e.v);var r,n,i,s,a,o,l=e.A,u=e.R;Array.isArray(u)||(u=[String(u)]),ty(l.i,"t",u),e.C=0,l=e.j.J,e.h=new eV,e.g=t6(e.j,l?t:null,!e.m),
150<e.O&&(e.M=new eh(w(e.Y,e,e.g),e.O)),t=e.U,l=e.g,u=e.ca;var h="readystatechange";Array.isArray(h)||(h&&(ed[0]=h.toString()),h=ed);for(var c=0;c<h.length;c++){var d=function e(t,r,n,i,s){if(i&&i.once)return function e(t,r,n,i,s){if(Array.isArray(r)){for(var a=0;a<r.length;a++)e(t,r[a],n,i,s);return null}return n=es(n),t&&t[$]?t.L(r,n,m(i)?!!i.capture:!!i,s):Z(t,r,n,!0,i,s)}(t,r,n,i,s);if(Array.isArray(r)){for(var a=0;a<r.length;a++)e(t,r[a],n,i,s);return null}return n=es(n),t&&t[$]?t.K(r,n,m(i)?!!i.capture:!!i,s):Z(t,r,n,!1,i,s)}(l,h[c],u||t.handleEvent,!1,t.h||t);if(!d)break;t.g[d.key]=d}t=e.H?D(e.H):{},e.m?(e.u||(e.u="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ea(e.A,e.u,e.m,t)):(e.u="GET",e.g.ea(e.A,e.u,null,t)),eC(),r=e.i,n=e.u,i=e.A,s=e.l,a=e.R,o=e.m,r.info(function(){if(r.g)if(o)for(var e="",t=o.split("&"),l=0;l<t.length;l++){var u=t[l].split("=");if(1<u.length){var h=u[0];u=u[1];var c=h.split("_");e=2<=c.length&&"type"==c[1]?e+(h+"=")+u+"&":e+(h+"=redacted&")}}else e=null;else e=o;return"XMLHTTP REQ ("+s+") [attempt "+a+"]: "+n+"\n"+i+"\n"+e})}function ez(e){return!!e.g&&"GET"==e.u&&2!=e.L&&e.j.Ca}function e$(e){e.S=Date.now()+e.I,eG(e,e.I)}function eG(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=ek(w(e.ba,e),t)}function eK(e){e.B&&(a.clearTimeout(e.B),e.B=null)}function eQ(e){0==e.j.G||e.J||tY(e.j,e)}function eH(e){eK(e);var t=e.M;t&&"function"==typeof t.ma&&t.ma(),e.M=null,ef(e.U),e.g&&(t=e.g,e.g=null,t.abort(),t.ma())}function eW(e,t){try{var r=e.j;if(0!=r.G&&(r.g==e||e0(r.h,e))){if(!e.K&&e0(r.h,e)&&3==r.G){try{var n=r.Da.g.parse(t)}catch(e){n=null}if(Array.isArray(n)&&3==n.length){var i=n;if(0==i[0]){e:if(!r.u){if(r.g)if(r.g.F+3e3<e.F)tJ(r),tq(r);else break e;tH(r),eD(18)}}else r.za=i[1],0<r.za-r.T&&37500>i[2]&&r.F&&0==r.v&&!r.C&&(r.C=ek(w(r.Za,r),6e3));if(1>=eZ(r.h)&&r.ca){try{r.ca()}catch(e){}r.ca=void 0}}else t0(r,11)}else if((e.K||r.g==e)&&tJ(r),!T(t))for(i=r.Da.g.parse(t),t=0;t<i.length;t++){let o=i[t];if(r.T=o[0],o=o[1],2==r.G)if("c"==o[0]){r.K=o[1],r.ia=o[2];let t=o[3];null!=t&&(r.la=t,r.j.info("VER="+r.la));let i=o[4];null!=i&&(r.Aa=i,r.j.info("SVER="+r.Aa));let l=o[5];null!=l&&"number"==typeof l&&0<l&&(r.L=n=1.5*l,r.j.info("backChannelRequestTimeoutMs_="+n)),n=r;let u=e.g;if(u){let e=u.g?u.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(e){var s=n.h;s.g||-1==e.indexOf("spdy")&&-1==e.indexOf("quic")&&-1==e.indexOf("h2")||(s.j=s.l,s.g=new Set,s.h&&(e1(s,s.h),s.h=null))}if(n.D){let e=u.g?u.g.getResponseHeader("X-HTTP-Session-Id"):null;e&&(n.ya=e,tn(n.I,n.D,e))}}if(r.G=3,r.l&&r.l.ua(),r.ba&&(r.R=Date.now()-e.F,r.j.info("Handshake RTT: "+r.R+"ms")),(n=r).qa=t2(n,n.J?n.ia:null,n.W),e.K){e3(n.h,e);var a=n.L;a&&(e.I=a),e.B&&(eK(e),e$(e)),n.g=e}else tQ(n);0<r.i.length&&tz(r)}else"stop"!=o[0]&&"close"!=o[0]||t0(r,7);else 3==r.G&&("stop"==o[0]||"close"==o[0]?"stop"==o[0]?t0(r,7):tU(r):"noop"!=o[0]&&r.l&&r.l.ta(o),r.v=0)}}eC(4)}catch(e){}}eF.prototype.ca=function(e){e=e.target;let t=this.M;t&&3==tP(e)?t.j():this.Y(e)},eF.prototype.Y=function(e){try{if(e==this.g)e:{let v=tP(this.g);var t=this.g.Ba();let w=this.g.Z();if(!(3>v)&&(3!=v||this.g&&(this.h.h||this.g.oa()||tF(this.g)))){this.J||4!=v||7==t||(8==t||0>=w?eC(3):eC(2)),eK(this);var r=this.g.Z();this.X=r;t:if(ez(this)){var n=tF(this.g);e="";var i=n.length,s=4==tP(this.g);if(!this.h.i){if("u"<typeof TextDecoder){eH(this),eQ(this);var o="";break t}this.h.i=new a.TextDecoder}for(t=0;t<i;t++)this.h.h=!0,e+=this.h.i.decode(n[t],{stream:!(s&&t==i-1)});n.length=0,this.h.g+=e,this.C=0,o=this.h.g}else o=this.g.oa();if(this.o=200==r,l=this.i,u=this.u,h=this.A,c=this.l,d=this.R,f=r,l.info(function(){return"XMLHTTP RESP ("+c+") [ attempt "+d+"]: "+u+"\n"+h+"\n"+v+" "+f}),this.o){if(this.T&&!this.K){t:{if(this.g){var l,u,h,c,d,f,p,g=this.g;if((p=g.g?g.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!T(p)){var m=p;break t}}m=null}if(r=m)eR(this.i,this.l,r,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,eW(this,r);else{this.o=!1,this.s=3,eD(12),eH(this),eQ(this);break e}}if(this.P){let e;for(r=!0;!this.J&&this.C<o.length;)if((e=function(e,t){var r=e.C,n=t.indexOf("\n",r);return -1==n?eU:isNaN(r=Number(t.substring(r,n)))?eB:(n+=1)+r>t.length?eU:(t=t.slice(n,n+r),e.C=n+r,t)}(this,o))==eU){4==v&&(this.s=4,eD(14),r=!1),eR(this.i,this.l,null,"[Incomplete Response]");break}else if(e==eB){this.s=4,eD(15),eR(this.i,this.l,o,"[Invalid Chunk]"),r=!1;break}else eR(this.i,this.l,e,null),eW(this,e);if(ez(this)&&0!=this.C&&(this.h.g=this.h.g.slice(this.C),this.C=0),4!=v||0!=o.length||this.h.h||(this.s=1,eD(16),r=!1),this.o=this.o&&r,r){if(0<o.length&&!this.W){this.W=!0;var y=this.j;y.g==this&&y.ba&&!y.M&&(y.j.info("Great, no buffering proxy detected. Bytes received: "+o.length),tW(y),y.M=!0,eD(11))}}else eR(this.i,this.l,o,"[Invalid Chunked Response]"),eH(this),eQ(this)}else eR(this.i,this.l,o,null),eW(this,o);4==v&&eH(this),this.o&&!this.J&&(4==v?tY(this.j,this):(this.o=!1,e$(this)))}else(function(e){let t={};e=(e.g&&2<=tP(e)&&e.g.getAllResponseHeaders()||"").split("\r\n");for(let n=0;n<e.length;n++){if(T(e[n]))continue;var r=function(e){var t=1;e=e.split(":");let r=[];for(;0<t&&e.length;)r.push(e.shift()),t--;return e.length&&r.push(e.join(":")),r}(e[n]);let i=r[0];if("string"!=typeof(r=r[1]))continue;r=r.trim();let s=t[i]||[];t[i]=s,s.push(r)}var n=function(e){return e.join(", ")};for(let e in t)n.call(void 0,t[e],e,t)})(this.g),400==r&&0<o.indexOf("Unknown SID")?(this.s=3,eD(12)):(this.s=0,eD(13)),eH(this),eQ(this)}}}catch(e){}finally{}},eF.prototype.cancel=function(){this.J=!0,eH(this)},eF.prototype.ba=function(){var e,t;this.B=null;let r=Date.now();0<=r-this.S?(e=this.i,t=this.A,e.info(function(){return"TIMEOUT: "+t}),2!=this.L&&(eC(),eD(17)),eH(this),this.s=2,eQ(this)):eG(this,this.S-r)};var eX=class{constructor(e,t){this.g=e,this.map=t}};function eJ(e){this.l=e||10,e=a.PerformanceNavigationTiming?0<(e=a.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):!!(a.chrome&&a.chrome.loadTimes&&a.chrome.loadTimes()&&a.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function eY(e){return!!e.h||!!e.g&&e.g.size>=e.j}function eZ(e){return e.h?1:e.g?e.g.size:0}function e0(e,t){return e.h?e.h==t:!!e.g&&e.g.has(t)}function e1(e,t){e.g?e.g.add(t):e.h=t}function e3(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function e5(e){if(null!=e.h)return e.i.concat(e.h.D);if(null!=e.g&&0!==e.g.size){let t=e.i;for(let r of e.g.values())t=t.concat(r.D);return t}return I(e.i)}function e4(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(o(e)||"string"==typeof e)Array.prototype.forEach.call(e,t,void 0);else for(var r=function(e){if(e.na&&"function"==typeof e.na)return e.na();if(!e.V||"function"!=typeof e.V){if("u">typeof Map&&e instanceof Map)return Array.from(e.keys());if(!("u">typeof Set&&e instanceof Set)){if(o(e)||"string"==typeof e){var t=[];e=e.length;for(var r=0;r<e;r++)t.push(r);return t}for(let n in t=[],r=0,e)t[r++]=n;return t}}}(e),n=function(e){if(e.V&&"function"==typeof e.V)return e.V();if("u">typeof Map&&e instanceof Map||"u">typeof Set&&e instanceof Set)return Array.from(e.values());if("string"==typeof e)return e.split("");
15if(o(e)){for(var t=[],r=e.length,n=0;n<r;n++)t.push(e[n]);return t}for(n in t=[],r=0,e)t[r++]=e[n];return t}(e),i=n.length,s=0;s<i;s++)t.call(void 0,n[s],r&&r[s],e)}eJ.prototype.cancel=function(){if(this.i=e5(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(let e of this.g.values())e.cancel();this.g.clear()}};var e8=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function e7(e){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,e instanceof e7){this.h=e.h,te(this,e.j),this.o=e.o,this.g=e.g,tt(this,e.s),this.l=e.l;var t=e.i,r=new tf;r.i=t.i,t.g&&(r.g=new Map(t.g),r.h=t.h),tr(this,r),this.m=e.m}else e&&(t=String(e).match(e8))?(this.h=!1,te(this,t[1]||"",!0),this.o=ts(t[2]||""),this.g=ts(t[3]||"",!0),tt(this,t[4]),this.l=ts(t[5]||"",!0),tr(this,t[6]||"",!0),this.m=ts(t[7]||"")):(this.h=!1,this.i=new tf(null,this.h))}function e9(e){return new e7(e)}function te(e,t,r){e.j=r?ts(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function tt(e,t){if(t){if(isNaN(t=Number(t))||0>t)throw Error("Bad port number "+t);e.s=t}else e.s=null}function tr(e,t,r){var n,i;t instanceof tf?(e.i=t,n=e.i,(i=e.h)&&!n.j&&(tp(n),n.i=null,n.g.forEach(function(e,t){var r=t.toLowerCase();t!=r&&(tg(this,t),ty(this,r,e))},n)),n.j=i):(r||(t=ta(t,tc)),e.i=new tf(t,e.h))}function tn(e,t,r){e.i.set(t,r)}function ti(e){return tn(e,"zx",Math.floor(0x80000000*Math.random()).toString(36)+Math.abs(Math.floor(0x80000000*Math.random())^Date.now()).toString(36)),e}function ts(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function ta(e,t,r){return"string"==typeof e?(e=encodeURI(e).replace(t,to),r&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function to(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}e7.prototype.toString=function(){var e=[],t=this.j;t&&e.push(ta(t,tl,!0),":");var r=this.g;return(r||"file"==t)&&(e.push("//"),(t=this.o)&&e.push(ta(t,tl,!0),"@"),e.push(encodeURIComponent(String(r)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(r=this.s)&&e.push(":",String(r))),(r=this.l)&&(this.g&&"/"!=r.charAt(0)&&e.push("/"),e.push(ta(r,"/"==r.charAt(0)?th:tu,!0))),(r=this.i.toString())&&e.push("?",r),(r=this.m)&&e.push("#",ta(r,td)),e.join("")};var tl=/[#\/\?@]/g,tu=/[#\?:]/g,th=/[#\?]/g,tc=/[#\?@]/g,td=/#/g;function tf(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function tp(e){e.g||(e.g=new Map,e.h=0,e.i&&function(e,t){if(e){e=e.split("&");for(var r=0;r<e.length;r++){var n=e[r].indexOf("="),i=null;if(0<=n){var s=e[r].substring(0,n);i=e[r].substring(n+1)}else s=e[r];t(s,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(e.i,function(t,r){e.add(decodeURIComponent(t.replace(/\+/g," ")),r)}))}function tg(e,t){tp(e),t=tv(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function tm(e,t){return tp(e),t=tv(e,t),e.g.has(t)}function ty(e,t,r){tg(e,t),0<r.length&&(e.i=null,e.g.set(tv(e,t),I(r)),e.h+=r.length)}function tv(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function tw(e,t,r,n,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),n(r)}catch(e){}}function tb(){this.g=new em}function tE(e){this.l=e.Ub||null,this.j=e.eb||!1}function tI(e,t){ea.call(this),this.D=e,this.o=t,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}function t_(e){e.j.read().then(e.Pa.bind(e)).catch(e.ga.bind(e))}function tT(e){e.readyState=4,e.l=null,e.j=null,e.v=null,tS(e)}function tS(e){e.onreadystatechange&&e.onreadystatechange.call(e)}function tx(e){let t="";return A(e,function(e,r){t+=r,t+=":",t+=e,t+="\r\n"}),t}function tC(e,t,r){e:{for(n in r){var n=!1;break e}n=!0}n||(r=tx(r),"string"==typeof e?null!=r&&encodeURIComponent(String(r)):tn(e,t,r))}function tA(e){ea.call(this),this.headers=new Map,this.o=e||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}(r=tf.prototype).add=function(e,t){tp(this),this.i=null,e=tv(this,e);var r=this.g.get(e);return r||this.g.set(e,r=[]),r.push(t),this.h+=1,this},r.forEach=function(e,t){tp(this),this.g.forEach(function(r,n){r.forEach(function(r){e.call(t,r,n,this)},this)},this)},r.na=function(){tp(this);let e=Array.from(this.g.values()),t=Array.from(this.g.keys()),r=[];for(let n=0;n<t.length;n++){let i=e[n];for(let e=0;e<i.length;e++)r.push(t[n])}return r},r.V=function(e){tp(this);let t=[];if("string"==typeof e)tm(this,e)&&(t=t.concat(this.g.get(tv(this,e))));else{e=Array.from(this.g.values());for(let r=0;r<e.length;r++)t=t.concat(e[r])}return t},r.set=function(e,t){return tp(this),this.i=null,tm(this,e=tv(this,e))&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},r.get=function(e,t){return e&&0<(e=this.V(e)).length?String(e[0]):t},r.toString=function(){if(this.i)return this.i;if(!this.g)return"";let e=[],t=Array.from(this.g.keys());for(var r=0;r<t.length;r++){var n=t[r];let s=encodeURIComponent(String(n)),a=this.V(n);for(n=0;n<a.length;n++){var i=s;""!==a[n]&&(i+="="+encodeURIComponent(String(a[n]))),e.push(i)}}return this.i=e.join("&")},E(tE,ey),tE.prototype.g=function(){return new tI(this.l,this.j)},tE.prototype.i=(e={},function(){return e}),E(tI,ea),(r=tI.prototype).open=function(e,t){if(0!=this.readyState)throw this.abort(),Error("Error reopening a connection");this.B=e,this.A=t,this.readyState=1,tS(this)},r.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;let t={headers:this.u,method:this.B,credentials:this.m,cache:void 0};
15e&&(t.body=e),(this.D||a).fetch(new Request(this.A,t)).then(this.Sa.bind(this),this.ga.bind(this))},r.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,tT(this)),this.readyState=0},r.Sa=function(e){if(this.g&&(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,tS(this)),this.g&&(this.readyState=3,tS(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(void 0!==a.ReadableStream&&"body"in e){if(this.j=e.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;t_(this)}else e.text().then(this.Ra.bind(this),this.ga.bind(this))},r.Pa=function(e){if(this.g){if(this.o&&e.value)this.response.push(e.value);else if(!this.o){var t=e.value?e.value:new Uint8Array(0);(t=this.v.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?tT(this):tS(this),3==this.readyState&&t_(this)}},r.Ra=function(e){this.g&&(this.response=this.responseText=e,tT(this))},r.Qa=function(e){this.g&&(this.response=e,tT(this))},r.ga=function(){this.g&&tT(this)},r.setRequestHeader=function(e,t){this.u.append(e,t)},r.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},r.getAllResponseHeaders=function(){if(!this.h)return"";let e=[],t=this.h.entries();for(var r=t.next();!r.done;)e.push((r=r.value)[0]+": "+r[1]),r=t.next();return e.join("\r\n")},Object.defineProperty(tI.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}}),E(tA,ea);var tD=/^https?$/i,tN=["POST","PUT"];function tk(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.m=5,tO(e),tL(e)}function tO(e){e.A||(e.A=!0,eo(e,"complete"),eo(e,"error"))}function tR(e){if(e.h&&void 0!==s&&(!e.v[1]||4!=tP(e)||2!=e.Z())){if(e.u&&4==tP(e))eu(e.Ea,0,e);else if(eo(e,"readystatechange"),4==tP(e)){e.h=!1;try{let s=e.Z();switch(s){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var t,r,n=!0;break;default:n=!1}if(!(t=n)){if(r=0===s){var i=String(e.D).match(e8)[1]||null;!i&&a.self&&a.self.location&&(i=a.self.location.protocol.slice(0,-1)),r=!tD.test(i?i.toLowerCase():"")}t=r}if(t)eo(e,"complete"),eo(e,"success");else{e.m=6;try{var o=2<tP(e)?e.g.statusText:""}catch(e){o=""}e.l=o+" ["+e.Z()+"]",tO(e)}}finally{tL(e)}}}}function tL(e,t){if(e.g){tM(e);let r=e.g,n=e.v[0]?()=>{}:null;e.g=null,e.v=null,t||eo(e,"ready");try{r.onreadystatechange=n}catch(e){}}}function tM(e){e.I&&(a.clearTimeout(e.I),e.I=null)}function tP(e){return e.g?e.g.readyState:0}function tF(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.H){case"":case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}function tV(e,t,r){return r&&r.internalChannelParams&&r.internalChannelParams[e]||t}function tB(e){this.Aa=0,this.i=[],this.j=new eO,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=tV("failFast",!1,e),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=tV("baseRetryDelayMs",5e3,e),this.cb=tV("retryDelaySeedMs",1e4,e),this.Wa=tV("forwardChannelMaxRetries",2,e),this.wa=tV("forwardChannelRequestTimeoutMs",2e4,e),this.pa=e&&e.xmlHttpFactory||void 0,this.Xa=e&&e.Tb||void 0,this.Ca=e&&e.useFetchStreams||!1,this.L=void 0,this.J=e&&e.supportsCrossDomainXhr||!1,this.K="",this.h=new eJ(e&&e.concurrentRequestLimit),this.Da=new tb,this.P=e&&e.fastHandshake||!1,this.O=e&&e.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=e&&e.Rb||!1,e&&e.xa&&this.j.xa(),e&&e.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&e&&e.detectBufferingProxy||!1,this.ja=void 0,e&&e.longPollingTimeout&&0<e.longPollingTimeout&&(this.ja=e.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}function tU(e){if(tj(e),3==e.G){var t=e.U++,r=e9(e.I);if(tn(r,"SID",e.K),tn(r,"RID",t),tn(r,"TYPE","terminate"),tG(e,r),(t=new eF(e,e.j,t)).L=2,t.v=ti(e9(r)),r=!1,a.navigator&&a.navigator.sendBeacon)try{r=a.navigator.sendBeacon(t.v.toString(),"")}catch(e){}!r&&a.Image&&((new Image).src=t.v,r=!0),r||(t.g=t6(t.j,null),t.g.ea(t.v)),t.F=Date.now(),e$(t)}t1(e)}function tq(e){e.g&&(tW(e),e.g.cancel(),e.g=null)}function tj(e){tq(e),e.u&&(a.clearTimeout(e.u),e.u=null),tJ(e),e.h.cancel(),e.s&&("number"==typeof e.s&&a.clearTimeout(e.s),e.s=null)}function tz(e){if(!eY(e.h)&&!e.s){e.s=!0;var t=e.Ga;L||F(),M||(L(),M=!0),P.add(t,e),e.B=0}}function t$(e,t){var r;r=t?t.l:e.U++;let n=e9(e.I);tn(n,"SID",e.K),tn(n,"RID",r),tn(n,"AID",e.T),tG(e,n),e.m&&e.o&&tC(n,e.m,e.o),r=new eF(e,e.j,r,e.B+1),null===e.m&&(r.H=e.o),t&&(e.i=t.D.concat(e.i)),t=tK(e,r,1e3),r.I=Math.round(.5*e.wa)+Math.round(.5*e.wa*Math.random()),e1(e.h,r),eq(r,n,t)}function tG(e,t){e.H&&A(e.H,function(e,r){tn(t,r,e)}),e.l&&e4({},function(e,r){tn(t,r,e)})}function tK(e,t,r){r=Math.min(e.i.length,r);var n=e.l?w(e.l.Na,e.l,e):null;e:{var i=e.i;let t=-1;for(;;){let e=["count="+r];-1==t?0<r?(t=i[0].g,e.push("ofs="+t)):t=0:e.push("ofs="+t);let s=!0;for(let a=0;a<r;a++){let r=i[a].g,o=i[a].map;if(0>(r-=t))t=Math.max(0,i[a].g-100),s=!1;else try{!function(e,t,r){let n=r||"";try{e4(e,function(e,r){let i=e;m(e)&&(i=ep(e)),t.push(n+r+"="+encodeURIComponent(i))})}catch(e){throw t.push(n+"type="+encodeURIComponent("_badmap")),e}}(o,e,"req"+r+"_")}catch(e){n&&n(o)}}if(s){n=e.join("&");break e}}}return t.D=e=e.i.splice(0,r),n}function tQ(e){if(!e.g&&!e.u){e.Y=1;var t=e.Fa;L||F(),M||(L(),M=!0),P.add(t,e),e.v=0}}function tH(e){return!e.g&&!e.u&&!(3<=e.v)&&(e.Y++,e.u=ek(w(e.Fa,e),tZ(e,e.v)),e.v++,!0)}function tW(e){null!=e.A&&(a.clearTimeout(e.A),e.A=null)}function tX(e){e.g=new eF(e,e.j,"rpc",e.Y),null===e.m&&(e.g.H=e.o),e.g.O=0;var t=e9(e.qa);
15tn(t,"RID","rpc"),tn(t,"SID",e.K),tn(t,"AID",e.T),tn(t,"CI",e.F?"0":"1"),!e.F&&e.ja&&tn(t,"TO",e.ja),tn(t,"TYPE","xmlhttp"),tG(e,t),e.m&&e.o&&tC(t,e.m,e.o),e.L&&(e.g.I=e.L);var r=e.g;e=e.ia,r.L=1,r.v=ti(e9(t)),r.m=null,r.P=!0,ej(r,e)}function tJ(e){null!=e.C&&(a.clearTimeout(e.C),e.C=null)}function tY(e,t){var r,n=null;if(e.g==t){tJ(e),tW(e),e.g=null;var i=2}else{if(!e0(e.h,t))return;n=t.D,e3(e.h,t),i=1}if(0!=e.G){if(t.o)if(1==i){n=t.m?t.m.length:0,t=Date.now()-t.F;var s=e.B;eo(i=eS(),new eN(i,n)),tz(e)}else tQ(e);else if(3==(s=t.s)||0==s&&0<t.X||!(1==i&&(r=t,!(eZ(e.h)>=e.h.j-!!e.s)&&(e.s?(e.i=r.D.concat(e.i),!0):1!=e.G&&2!=e.G&&!(e.B>=(e.Va?0:e.Wa))&&(e.s=ek(w(e.Ga,e,r),tZ(e,e.B)),e.B++,!0)))||2==i&&tH(e)))switch(n&&0<n.length&&((t=e.h).i=t.i.concat(n)),s){case 1:t0(e,5);break;case 4:t0(e,10);break;case 3:t0(e,6);break;default:t0(e,2)}}}function tZ(e,t){let r=e.Ta+Math.floor(Math.random()*e.cb);return e.isActive()||(r*=2),r*t}function t0(e,t){if(e.j.info("Error code "+t),2==t){let t,s,o;var r,n=w(e.fb,e),i=e.Xa;let l=!i;i=new e7(i||"//www.google.com/images/cleardot.gif"),a.location&&"http"==a.location.protocol||te(i,"https"),ti(i),l?function(e,t){let r=new eO;if(a.Image){let n=new Image;n.onload=b(tw,r,"TestLoadImage: loaded",!0,t,n),n.onerror=b(tw,r,"TestLoadImage: error",!1,t,n),n.onabort=b(tw,r,"TestLoadImage: abort",!1,t,n),n.ontimeout=b(tw,r,"TestLoadImage: timeout",!1,t,n),a.setTimeout(function(){n.ontimeout&&n.ontimeout()},1e4),n.src=e}else t(!1)}(i.toString(),n):(r=i.toString(),t=new eO,s=new AbortController,o=setTimeout(()=>{s.abort(),tw(t,"TestPingServer: timeout",!1,n)},1e4),fetch(r,{signal:s.signal}).then(e=>{clearTimeout(o),e.ok?tw(t,"TestPingServer: ok",!0,n):tw(t,"TestPingServer: server error",!1,n)}).catch(()=>{clearTimeout(o),tw(t,"TestPingServer: error",!1,n)}))}else eD(2);e.G=0,e.l&&e.l.sa(t),t1(e),tj(e)}function t1(e){if(e.G=0,e.ka=[],e.l){let t=e5(e.h);(0!=t.length||0!=e.i.length)&&(_(e.ka,t),_(e.ka,e.i),e.h.i.length=0,I(e.i),e.i.length=0),e.l.ra()}}function t2(e,t,r){var n=r instanceof e7?e9(r):new e7(r);if(""!=n.g)t&&(n.g=t+"."+n.g),tt(n,n.s);else{var i=a.location;n=i.protocol,t=t?t+"."+i.hostname:i.hostname,i=+i.port;var s=new e7(null);n&&te(s,n),t&&(s.g=t),i&&tt(s,i),r&&(s.l=r),n=s}return r=e.D,t=e.ya,r&&t&&tn(n,r,t),tn(n,"VER",e.la),tG(e,n),n}function t6(e,t,r){if(t&&!e.J)throw Error("Can't create secondary domain capable XhrIo object.");return(t=new tA(e.Ca&&!e.pa?new tE({eb:r}):e.pa)).Ha(e.J),t}function t3(){}function t5(){}function t4(e,t){ea.call(this),this.g=new tB(t),this.l=e,this.h=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.g.o=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.va&&(e?e["X-WebChannel-Client-Profile"]=t.va:e={"X-WebChannel-Client-Profile":t.va}),this.g.S=e,(e=t&&t.Sb)&&!T(e)&&(this.g.m=e),this.v=t&&t.supportsCrossDomainXhr||!1,this.u=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!T(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&t in(e=this.h)&&delete e[t]),this.j=new t9(this)}function t8(e){eE.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){e:{for(let r in t){e=r;break e}e=void 0}(this.i=e)&&(e=this.i,t=null!==t&&e in t?t[e]:void 0),this.data=t}else this.data=e}function t7(){eI.call(this),this.status=1}function t9(e){this.g=e}(r=tA.prototype).Ha=function(e){this.J=e},r.ea=function(e,r,n,i){if(this.g)throw Error("[goog.net.XhrIo] Object is active with another request="+this.D+"; newUri="+e);r=r?r.toUpperCase():"GET",this.D=e,this.l="",this.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():t.g(),this.v=this.o?ev(this.o):ev(t),this.g.onreadystatechange=w(this.Ea,this);try{this.B=!0,this.g.open(r,String(e),!0),this.B=!1}catch(e){tk(this,e);return}if(e=n||"",n=new Map(this.headers),i)if(Object.getPrototypeOf(i)===Object.prototype)for(var s in i)n.set(s,i[s]);else if("function"==typeof i.keys&&"function"==typeof i.get)for(let e of i.keys())n.set(e,i.get(e));else throw Error("Unknown input type for opt_headers: "+String(i));for(let[t,o]of(i=Array.from(n.keys()).find(e=>"content-type"==e.toLowerCase()),s=a.FormData&&e instanceof a.FormData,!(0<=Array.prototype.indexOf.call(tN,r,void 0))||i||s||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),n))this.g.setRequestHeader(t,o);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{tM(this),this.u=!0,this.g.send(e),this.u=!1}catch(e){tk(this,e)}},r.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=e||7,eo(this,"complete"),eo(this,"abort"),tL(this))},r.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),tL(this,!0)),tA.aa.N.call(this)},r.Ea=function(){this.s||(this.B||this.u||this.j?tR(this):this.bb())},r.bb=function(){tR(this)},r.isActive=function(){return!!this.g},r.Z=function(){try{return 2<tP(this)?this.g.status:-1}catch(e){return -1}},r.oa=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},r.Oa=function(e){if(this.g){var t=this.g.responseText;
15return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),eg(t)}},r.Ba=function(){return this.m},r.Ka=function(){return"string"==typeof this.l?this.l:String(this.l)},(r=tB.prototype).la=8,r.G=1,r.connect=function(e,t,r,n){eD(0),this.W=e,this.H=t||{},r&&void 0!==n&&(this.H.OSID=r,this.H.OAID=n),this.F=this.X,this.I=t2(this,null,this.W),tz(this)},r.Ga=function(e){if(this.s)if(this.s=null,1==this.G){if(!e){this.U=Math.floor(1e5*Math.random()),e=this.U++;let i=new eF(this,this.j,e),s=this.o;if(this.S&&(s?k(s=D(s),this.S):s=this.S),null!==this.m||this.O||(i.H=s,s=null),this.P)e:{for(var t=0,r=0;r<this.i.length;r++){t:{var n=this.i[r];if("__data__"in n.map&&"string"==typeof(n=n.map.__data__)){n=n.length;break t}n=void 0}if(void 0===n)break;if(4096<(t+=n)){t=r;break e}if(4096===t||r===this.i.length-1){t=r+1;break e}}t=1e3}else t=1e3;t=tK(this,i,t),tn(r=e9(this.I),"RID",e),tn(r,"CVER",22),this.D&&tn(r,"X-HTTP-Session-Id",this.D),tG(this,r),s&&(this.O?t="headers="+encodeURIComponent(String(tx(s)))+"&"+t:this.m&&tC(r,this.m,s)),e1(this.h,i),this.Ua&&tn(r,"TYPE","init"),this.P?(tn(r,"$req",t),tn(r,"SID","null"),i.T=!0,eq(i,r,null)):eq(i,r,t),this.G=2}}else 3==this.G&&(e?t$(this,e):0==this.i.length||eY(this.h)||t$(this))},r.Fa=function(){if(this.u=null,tX(this),this.ba&&!(this.M||null==this.g||0>=this.R)){var e=2*this.R;this.j.info("BP detection timer enabled: "+e),this.A=ek(w(this.ab,this),e)}},r.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,eD(10),tq(this),tX(this))},r.Za=function(){null!=this.C&&(this.C=null,tq(this),tH(this),eD(19))},r.fb=function(e){e?(this.j.info("Successfully pinged google.com"),eD(2)):(this.j.info("Failed to ping google.com"),eD(1))},r.isActive=function(){return!!this.l&&this.l.isActive(this)},(r=t3.prototype).ua=function(){},r.ta=function(){},r.sa=function(){},r.ra=function(){},r.isActive=function(){return!0},r.Na=function(){},t5.prototype.g=function(e,t){return new t4(e,t)},E(t4,ea),t4.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},t4.prototype.close=function(){tU(this.g)},t4.prototype.o=function(e){var t=this.g;if("string"==typeof e){var r={};r.__data__=e,e=r}else this.u&&((r={}).__data__=ep(e),e=r);t.i.push(new eX(t.Ya++,e)),3==t.G&&tz(t)},t4.prototype.N=function(){this.g.l=null,delete this.j,tU(this.g),delete this.g,t4.aa.N.call(this)},E(t8,eE),E(t7,eI),E(t9,t3),t9.prototype.ua=function(){eo(this.g,"a")},t9.prototype.ta=function(e){eo(this.g,new t8(e))},t9.prototype.sa=function(e){eo(this.g,new t7)},t9.prototype.ra=function(){eo(this.g,"b")},t5.prototype.createWebChannel=t5.prototype.g,t4.prototype.send=t4.prototype.o,t4.prototype.open=t4.prototype.m,t4.prototype.close=t4.prototype.close,g=e6.createWebChannelTransport=function(){return new t5},p=e6.getStatEventTarget=function(){return eS()},f=e6.Event=e_,d=e6.Stat={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},eL.NO_ERROR=0,eL.TIMEOUT=8,eL.HTTP_ERROR=6,c=e6.ErrorCode=eL,eM.COMPLETE="complete",h=e6.EventType=eM,ew.EventType=eb,eb.OPEN="a",eb.CLOSE="b",eb.ERROR="c",eb.MESSAGE="d",ea.prototype.listen=ea.prototype.K,u=e6.WebChannel=ew,e6.FetchXmlHttpFactory=tE,tA.prototype.listenOnce=tA.prototype.L,tA.prototype.getLastError=tA.prototype.Ka,tA.prototype.getLastErrorCode=tA.prototype.Ba,tA.prototype.getStatus=tA.prototype.Z,tA.prototype.getResponseJson=tA.prototype.Oa,tA.prototype.getResponseText=tA.prototype.oa,tA.prototype.send=tA.prototype.ea,tA.prototype.setWithCredentials=tA.prototype.Ha,l=e6.XhrIo=tA}).apply(void 0!==e2?e2:"u">typeof self?self:"u">typeof window?window:{});let e3="@firebase/firestore",e5="4.8.0";class e4{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}e4.UNAUTHENTICATED=new e4(null),e4.GOOGLE_CREDENTIALS=new e4("google-credentials-uid"),e4.FIRST_PARTY=new e4("first-party-uid"),e4.MOCK_USER=new e4("mock-user");let e8="11.10.0",e7=new ec("@firebase/firestore");function e9(){return e7.logLevel}function te(e,...t){if(e7.logLevel<=s.DEBUG){let r=t.map(tn);e7.debug(`Firestore (${e8}): ${e}`,...r)}}function tt(e,...t){if(e7.logLevel<=s.ERROR){let r=t.map(tn);e7.error(`Firestore (${e8}): ${e}`,...r)}}function tr(e,...t){if(e7.logLevel<=s.WARN){let r=t.map(tn);e7.warn(`Firestore (${e8}): ${e}`,...r)}}function tn(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return e}}function ti(e,t,r){let n="Unexpected state";"string"==typeof t?n=t:r=t,ts(e,n,r)}function ts(e,t,r){let n=`FIRESTORE (${e8}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==r)try{n+=" CONTEXT: "+JSON.stringify(r)}catch(e){n+=" CONTEXT: "+r}throw tt(n),Error(n)}function ta(e,t,r,n){let i="Unexpected state";"string"==typeof r?i=r:n=r,e||ts(t,i,n)}let to={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",UNIMPLEMENT
15ED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class tl extends H{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class tu{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class th{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class tc{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(e4.UNAUTHENTICATED))}shutdown(){}}class td{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}}class tf{constructor(e){this.t=e,this.currentUser=e4.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){ta(void 0===this.o,42304);let r=this.i,n=e=>this.i!==r?(r=this.i,t(e)):Promise.resolve(),i=new tu;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new tu,e.enqueueRetryable(()=>n(this.currentUser))};let s=()=>{let t=i;e.enqueueRetryable(async()=>{await t.promise,await n(this.currentUser)})},a=e=>{te("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),s())};this.t.onInit(e=>a(e)),setTimeout(()=>{if(!this.auth){let e=this.t.getImmediate({optional:!0});e?a(e):(te("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new tu)}},0),s()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(t=>this.i!==e?(te("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(ta("string"==typeof t.accessToken,31837,{l:t}),new th(t.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){let e=this.auth&&this.auth.getUid();return ta(null===e||"string"==typeof e,2055,{h:e}),new e4(e)}}class tp{constructor(e,t,r){this.P=e,this.T=t,this.I=r,this.type="FirstParty",this.user=e4.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);let e=this.R();return e&&this.A.set("Authorization",e),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}}class tg{constructor(e,t,r){this.P=e,this.T=t,this.I=r}getToken(){return Promise.resolve(new tp(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(e4.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class tm{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class ty{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,eF(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){ta(void 0===this.o,3512);let r=e=>{null!=e.error&&te("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);let r=e.token!==this.m;return this.m=e.token,te("FirebaseAppCheckTokenProvider",`Received ${r?"new":"existing"} token.`),r?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable(()=>r(t))};let n=e=>{te("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(e=>n(e)),setTimeout(()=>{if(!this.appCheck){let e=this.V.getImmediate({optional:!0});e?n(e):te("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new tm(this.p));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(ta("string"==typeof e.token,44558,{tokenResult:e}),this.m=e.token,new tm(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}function tv(){return new TextEncoder}class tw{static newId(){let e=62*Math.floor(256/62),t="";for(;t.length<20;){let r=function(){let e="u">typeof self&&(self.crypto||self.msCrypto),t=new Uint8Array(40);if(e&&"function"==typeof e.getRandomValues)e.getRandomValues(t);else for(let e=0;e<40;
15e++)t[e]=Math.floor(256*Math.random());return t}();for(let n=0;n<r.length;++n)t.length<20&&r[n]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(r[n]%62))}return t}}function tb(e,t){return e<t?-1:+(e>t)}function tE(e,t){let r=0;for(;r<e.length&&r<t.length;){let n=e.codePointAt(r),i=t.codePointAt(r);if(n!==i){if(n<128&&i<128)return tb(n,i);{let s=tv(),a=function(e,t){for(let r=0;r<e.length&&r<t.length;++r)if(e[r]!==t[r])return tb(e[r],t[r]);return tb(e.length,t.length)}(s.encode(tI(e,r)),s.encode(tI(t,r)));return 0!==a?a:tb(n,i)}}r+=n>65535?2:1}return tb(e.length,t.length)}function tI(e,t){return e.codePointAt(t)>65535?e.substring(t,t+2):e.substring(t,t+1)}function t_(e,t,r){return e.length===t.length&&e.every((e,n)=>r(e,t[n]))}let tT="__name__";class tS{constructor(e,t,r){void 0===t?t=0:t>e.length&&ti(637,{offset:t,range:e.length}),void 0===r?r=e.length-t:r>e.length-t&&ti(1746,{length:r,range:e.length-t}),this.segments=e,this.offset=t,this.len=r}get length(){return this.len}isEqual(e){return 0===tS.comparator(this,e)}child(e){let t=this.segments.slice(this.offset,this.limit());return e instanceof tS?e.forEach(e=>{t.push(e)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,r=this.limit();t<r;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++){let r=tS.compareSegments(e.get(n),t.get(n));if(0!==r)return r}return tb(e.length,t.length)}static compareSegments(e,t){let r=tS.isNumericId(e),n=tS.isNumericId(t);return r&&!n?-1:!r&&n?1:r&&n?tS.extractNumericId(e).compare(tS.extractNumericId(t)):tE(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return a.fromString(e.substring(4,e.length-2))}}class tx extends tS{construct(e,t,r){return new tx(e,t,r)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){let t=[];for(let r of e){if(r.indexOf("//")>=0)throw new tl(to.INVALID_ARGUMENT,`Invalid segment (${r}). Paths must not contain // in them.`);t.push(...r.split("/").filter(e=>e.length>0))}return new tx(t)}static emptyPath(){return new tx([])}}let tC=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class tA extends tS{construct(e,t,r){return new tA(e,t,r)}static isValidIdentifier(e){return tC.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),tA.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===tT}static keyField(){return new tA([tT])}static fromServerFormat(e){let t=[],r="",n=0,i=()=>{if(0===r.length)throw new tl(to.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(r),r=""},s=!1;for(;n<e.length;){let t=e[n];if("\\"===t){if(n+1===e.length)throw new tl(to.INVALID_ARGUMENT,"Path has trailing escape character: "+e);let t=e[n+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new tl(to.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);r+=t,n+=2}else"`"===t?s=!s:"."!==t||s?r+=t:i(),n++}if(i(),s)throw new tl(to.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new tA(t)}static emptyPath(){return new tA([])}}class tD{constructor(e){this.path=e}static fromPath(e){return new tD(tx.fromString(e))}static fromName(e){return new tD(tx.fromString(e).popFirst(5))}static empty(){return new tD(tx.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return null!==e&&0===tx.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return tx.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new tD(new tx(e.slice()))}}function tN(e,t,r){if(!r)throw new tl(to.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function tk(e,t,r,n){if(!0===t&&!0===n)throw new tl(to.INVALID_ARGUMENT,`${e} and ${r} cannot be used together.`)}function tO(e){if(!tD.isDocumentKey(e))throw new tl(to.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function tR(e){if(tD.isDocumentKey(e))throw new tl(to.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function tL(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function tM(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{var t;let r=(t=e).constructor?t.constructor.name:null;return r?`a custom ${r} object`:"an object"}}return"function"==typeof e?"a function":ti(12329,{type:typeof e})}function tP(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new tl(to.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{let r=tM(e);throw new tl(to.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${r}`)}}return e}function tF(e,t){if(t<=0)throw new tl(to.INVALID_ARGUMENT,`Function ${e}() requires a positive number, but it was: ${t}.`)}function tV(e,t){let r={typeString:e};return t&&(r.value=t),r}function tB(e,t){let r;if(!tL(e))throw new tl(to.INVALID_ARGUMENT,"JSON must be an object");for(let n in t)if(t[n]){let i=t[n].typeString,s="value"in t[n]?{value:t[n].value}:void 0;if(!(n in e)){r=`JSON missing required field: '${n}'`;break}let a=e[n];if(i&&typeof a!==i){r=`JSON field '${n}' must be a ${i}.`;break}if(void 0!==s&&a!==s.value){r=`Expected '${n}' field to equal '${s.value}'`;break}}if(r)throw new tl(to.INVALID_ARGUMENT,r);return!0}class tU{static now(){return tU.fromMillis(Date.now())}static fromDate(e){return tU.fromMillis(e.getTime())}static fromMillis(e){let t=Math.floor(e/1e3),r=Math.floor((e-1e3*t)*1e6);return new tU(t,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0||t>=1e9)throw new tl(to.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<-0xe7791f700||e>=0x3afff44180)throw new tl(to.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/1e6}_compareTo(e){return this.seconds===e.seconds?tb(this.nanoseconds,e.nanoseconds):tb(this.seconds,e.seconds)}isEqual(e){return e.seconds===this.seconds&&e.nanoseconds===this.nanoseconds}toString(){return"Timestamp(seconds="+this.seconds+", nanoseconds="+this.nanoseconds+")"}toJSON(){return{type:tU._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(tB(e,tU._jsonSchema))return new tU(e.seconds,e.nanoseconds)}valueOf(){return String(this.seconds- -0xe7791f700).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}
15}tU._jsonSchemaVersion="firestore/timestamp/1.0",tU._jsonSchema={type:tV("string",tU._jsonSchemaVersion),seconds:tV("number"),nanoseconds:tV("number")};class tq{static fromTimestamp(e){return new tq(e)}static min(){return new tq(new tU(0,0))}static max(){return new tq(new tU(0x3afff4417f,0x3b9ac9ff))}constructor(e){this.timestamp=e}compareTo(e){return this.timestamp._compareTo(e.timestamp)}isEqual(e){return this.timestamp.isEqual(e.timestamp)}toMicroseconds(){return 1e6*this.timestamp.seconds+this.timestamp.nanoseconds/1e3}toString(){return"SnapshotVersion("+this.timestamp.toString()+")"}toTimestamp(){return this.timestamp}}class tj{constructor(e,t,r,n){this.indexId=e,this.collectionGroup=t,this.fields=r,this.indexState=n}}function tz(e){return e.fields.find(e=>2===e.kind)}function t$(e){return e.fields.filter(e=>2!==e.kind)}function tG(e,t){let r=tb(e.collectionGroup,t.collectionGroup);if(0!==r)return r;for(let n=0;n<Math.min(e.fields.length,t.fields.length);++n)if(0!==(r=function(e,t){let r=tA.comparator(e.fieldPath,t.fieldPath);return 0!==r?r:tb(e.kind,t.kind)}(e.fields[n],t.fields[n])))return r;return tb(e.fields.length,t.fields.length)}tj.UNKNOWN_ID=-1;class tK{constructor(e,t){this.fieldPath=e,this.kind=t}}class tQ{constructor(e,t){this.sequenceNumber=e,this.offset=t}static empty(){return new tQ(0,tX.min())}}function tH(e,t){let r=e.toTimestamp().seconds,n=e.toTimestamp().nanoseconds+1;return new tX(tq.fromTimestamp(1e9===n?new tU(r+1,0):new tU(r,n)),tD.empty(),t)}function tW(e){return new tX(e.readTime,e.key,-1)}class tX{constructor(e,t,r){this.readTime=e,this.documentKey=t,this.largestBatchId=r}static min(){return new tX(tq.min(),tD.empty(),-1)}static max(){return new tX(tq.max(),tD.empty(),-1)}}function tJ(e,t){let r=e.readTime.compareTo(t.readTime);return 0!==r||0!==(r=tD.comparator(e.documentKey,t.documentKey))?r:tb(e.largestBatchId,t.largestBatchId)}let tY="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class tZ{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}async function t0(e){if(e.code!==to.FAILED_PRECONDITION||e.message!==tY)throw e;te("LocalStore","Unexpectedly lost primary lease")}class t1{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)},e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&ti(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new t1((r,n)=>{this.nextCallback=t=>{this.wrapSuccess(e,t).next(r,n)},this.catchCallback=e=>{this.wrapFailure(t,e).next(r,n)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{let t=e();return t instanceof t1?t:t1.resolve(t)}catch(e){return t1.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):t1.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):t1.reject(t)}static resolve(e){return new t1((t,r)=>{t(e)})}static reject(e){return new t1((t,r)=>{r(e)})}static waitFor(e){return new t1((t,r)=>{let n=0,i=0,s=!1;e.forEach(e=>{++n,e.next(()=>{++i,s&&i===n&&t()},e=>r(e))}),s=!0,i===n&&t()})}static or(e){let t=t1.resolve(!1);for(let r of e)t=t.next(e=>e?t1.resolve(e):r());return t}static forEach(e,t){let r=[];return e.forEach((e,n)=>{r.push(t.call(this,e,n))}),this.waitFor(r)}static mapArray(e,t){return new t1((r,n)=>{let i=e.length,s=Array(i),a=0;for(let o=0;o<i;o++){let l=o;t(e[l]).next(e=>{s[l]=e,++a===i&&r(s)},e=>n(e))}})}static doWhile(e,t){return new t1((r,n)=>{let i=()=>{!0===e()?t().next(()=>{i()},n):r()};i()})}}let t2="SimpleDb";class t6{static open(e,t,r,n){try{return new t6(t,e.transaction(n,r))}catch(e){throw new t8(t,e)}}constructor(e,t){this.action=e,this.transaction=t,this.aborted=!1,this.S=new tu,this.transaction.oncomplete=()=>{this.S.resolve()},this.transaction.onabort=()=>{t.error?this.S.reject(new t8(e,t.error)):this.S.resolve()},this.transaction.onerror=t=>{let r=rr(t.target.error);this.S.reject(new t8(e,r))}}get D(){return this.S.promise}abort(e){e&&this.S.reject(e),this.aborted||(te(t2,"Aborting transaction:",e?e.message:"Client-initiated abort"),this.aborted=!0,this.transaction.abort())}v(){let e=this.transaction;this.aborted||"function"!=typeof e.commit||e.commit()}store(e){return new t9(this.transaction.objectStore(e))}}class t3{static delete(e){return te(t2,"Removing database:",e),re(D().indexedDB.deleteDatabase(e)).toPromise()}static C(){if(!K())return!1;if(t3.F())return!0;let e=q(),t=t3.M(e),r=t5(e);return!(e.indexOf("MSIE ")>0||e.indexOf("Trident/")>0||e.indexOf("Edge/")>0||0<t&&t<10||0<r&&r<4.5)}static F(){var e;return void 0!==b.default&&"YES"===(null==(e=b.default.__PRIVATE_env)?void 0:e.O)}static N(e,t){return e.store(t)}static M(e){let t=e.match(/i(?:phone|pad|pod) os ([\d_]+)/i);return Number(t?t[1].split("_").slice(0,2).join("."):"-1")}constructor(e,t,r){this.name=e,this.version=t,this.B=r,this.L=null,12.2===t3.M(q())&&tt("Firestore persistence suffers from a bug in 
15iOS 12.2 Safari that may cause your app to stop working. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.")}async k(e){return this.db||(te(t2,"Opening database:",this.name),this.db=await new Promise((t,r)=>{let n=indexedDB.open(this.name,this.version);n.onsuccess=e=>{t(e.target.result)},n.onblocked=()=>{r(new t8(e,"Cannot upgrade IndexedDB schema while another tab is open. Close all tabs that access Firestore and reload this page to proceed."))},n.onerror=t=>{let n=t.target.error;"VersionError"===n.name?r(new tl(to.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.")):"InvalidStateError"===n.name?r(new tl(to.FAILED_PRECONDITION,"Unable to open an IndexedDB connection. This could be due to running in a private browsing session on a browser whose private browsing sessions do not support IndexedDB: "+n)):r(new t8(e,n))},n.onupgradeneeded=e=>{te(t2,'Database "'+this.name+'" requires upgrade from version:',e.oldVersion);let t=e.target.result;if(null!==this.L&&this.L!==e.oldVersion)throw Error(`refusing to open IndexedDB database due to potential corruption of the IndexedDB database data; this corruption could be caused by clicking the "clear site data" button in a web browser; try reloading the web page to re-initialize the IndexedDB database: lastClosedDbVersion=${this.L}, event.oldVersion=${e.oldVersion}, event.newVersion=${e.newVersion}, db.version=${t.version}`);this.B.q(t,n.transaction,e.oldVersion,this.version).next(()=>{te(t2,"Database upgrade to version "+this.version+" complete")})}}),this.db.addEventListener("close",e=>{let t=e.target;this.L=t.version},{passive:!0})),this.db.addEventListener("versionchange",e=>{var t;null===e.newVersion&&(tr('Received "versionchange" event with newVersion===null; notifying the registered DatabaseDeletedListener, if any'),null==(t=this.databaseDeletedListener)||t.call(this))},{passive:!0}),this.db}setDatabaseDeletedListener(e){if(this.databaseDeletedListener)throw Error("setDatabaseDeletedListener() may only be called once, and it has already been called");this.databaseDeletedListener=e}async runTransaction(e,t,r,n){let i="readonly"===t,s=0;for(;;){++s;try{this.db=await this.k(e);let t=t6.open(this.db,e,i?"readonly":"readwrite",r),s=n(t).next(e=>(t.v(),e)).catch(e=>(t.abort(e),t1.reject(e))).toPromise();return s.catch(()=>{}),await t.D,s}catch(t){let e="FirebaseError"!==t.name&&s<3;if(te(t2,"Transaction failed with error:",t.message,"Retrying:",e),this.close(),!e)return Promise.reject(t)}}}close(){this.db&&this.db.close(),this.db=void 0}}function t5(e){let t=e.match(/Android ([\d.]+)/i);return Number(t?t[1].split(".").slice(0,2).join("."):"-1")}class t4{constructor(e){this.$=e,this.U=!1,this.K=null}get isDone(){return this.U}get W(){return this.K}set cursor(e){this.$=e}done(){this.U=!0}G(e){this.K=e}delete(){return re(this.$.delete())}}class t8 extends tl{constructor(e,t){super(to.UNAVAILABLE,`IndexedDB transaction '${e}' failed: ${t}`),this.name="IndexedDbTransactionError"}}function t7(e){return"IndexedDbTransactionError"===e.name}class t9{constructor(e){this.store=e}put(e,t){let r;return void 0!==t?(te(t2,"PUT",this.store.name,e,t),r=this.store.put(t,e)):(te(t2,"PUT",this.store.name,"<auto-key>",e),r=this.store.put(e)),re(r)}add(e){return te(t2,"ADD",this.store.name,e,e),re(this.store.add(e))}get(e){return re(this.store.get(e)).next(t=>(void 0===t&&(t=null),te(t2,"GET",this.store.name,e,t),t))}delete(e){return te(t2,"DELETE",this.store.name,e),re(this.store.delete(e))}count(){return te(t2,"COUNT",this.store.name),re(this.store.count())}j(e,t){let r=this.options(e,t),n=r.index?this.store.index(r.index):this.store;if("function"==typeof n.getAll){let e=n.getAll(r.range);return new t1((t,r)=>{e.onerror=e=>{r(e.target.error)},e.onsuccess=e=>{t(e.target.result)}})}{let e=this.cursor(r),t=[];return this.J(e,(e,r)=>{t.push(r)}).next(()=>t)}}H(e,t){let r=this.store.getAll(e,null===t?void 0:t);return new t1((e,t)=>{r.onerror=e=>{t(e.target.error)},r.onsuccess=t=>{e(t.target.result)}})}Y(e,t){te(t2,"DELETE ALL",this.store.name);let r=this.options(e,t);r.Z=!1;let n=this.cursor(r);return this.J(n,(e,t,r)=>r.delete())}X(e,t){let r;t?r=e:(r={},t=e);let n=this.cursor(r);return this.J(n,t)}ee(e){let t=this.cursor({});return new t1((r,n)=>{t.onerror=e=>{n(rr(e.target.error))},t.onsuccess=t=>{let n=t.target.result;n?e(n.primaryKey,n.value).next(e=>{e?n.continue():r()}):r()}})}J(e,t){let r=[];return new t1((n,i)=>{e.onerror=e=>{i(e.target.error)},e.onsuccess=e=>{let i=e.target.result;if(!i)return void n();let s=new t4(i),a=t(i.primaryKey,i.value,s);if(a instanceof t1){let e=a.catch(e=>(s.done(),t1.reject(e)));r.push(e)}s.isDone?n():null===s.W?i.continue():i.continue(s.W)}}).next(()=>t1.waitFor(r))}options(e,t){let r;return void 0!==e&&("string"==typeof e?r=e:t=e),{index:r,range:t}}cursor(e){let t="next";if(e.reverse&&(t="prev"),e.index){let r=this.store.index(e.index);return e.Z?r.openKeyCursor(e.range,t):r.openCursor(e.range,t)}return this.store.openCursor(e.range,t)}}function re(e){return new t1((t,r)=>{e.onsuccess=e=>{t(e.target.result)},e.onerror=e=>{r(rr(e.target.error))}})}let rt=!1;function rr(e){let t=t3.M(q());if(t>=12.2&&t<13){let t="An internal error was encountered in the Indexed Database server";if(e.message.indexOf(t)>=0){let e=new tl("internal",`IOS_INDEXEDDB_BUG1: IndexedDb has thrown '${t}'. This is likely due to an unavoidable bug in iOS. See https://stackoverflow.com/q/56496296/110915 for details and a potential workaround.`);return rt||(rt=!0,setTimeout(()=>{throw e},0)),e}}return e}let rn="IndexBackfiller";class ri{constructor(e,t){this.asyncQueue=e,this.te=t,this.task=null}start(){this.ne(15e3)}stop(){this.task&&(this.task.cancel(),this.task=null)}get started(){return null!==this.task}ne(e){te(rn,`Scheduled in ${e}ms`),this.task=this.asyncQueue.enqueueAfterDelay("index_backfill",e,async()=>{this.task=null;try{let e=await this.te.re();te(rn,`Documents written: ${e}`)}catch(e){t7(e)?te(rn,"Ignoring IndexedDB error during index backfill: ",e):await t0(e)}await this.ne(6e4)})}}class rs{constructor(e,t){this.localStore=e,this.persistence=t}async re(e=50){return this.persistence.runTransaction("Backfill Indexes","readwrite-primary",t=>this.ie(t,e))}ie(e,t){let r=new Set,n=t,i=!0;
15return t1.doWhile(()=>!0===i&&n>0,()=>this.localStore.indexManager.getNextCollectionGroupToUpdate(e).next(t=>{if(null!==t&&!r.has(t))return te(rn,`Processing collection: ${t}`),this.se(e,t,n).next(e=>{n-=e,r.add(t)});i=!1})).next(()=>t-n)}se(e,t,r){return this.localStore.indexManager.getMinOffsetFromCollectionGroup(e,t).next(n=>this.localStore.localDocuments.getNextDocuments(e,t,n,r).next(r=>{let i=r.changes;return this.localStore.indexManager.updateIndexEntries(e,i).next(()=>this.oe(n,r)).next(r=>(te(rn,`Updating offset: ${r}`),this.localStore.indexManager.updateCollectionGroup(e,t,r))).next(()=>i.size)}))}oe(e,t){let r=e;return t.changes.forEach((e,t)=>{let n=tW(t);tJ(n,r)>0&&(r=n)}),new tX(r.readTime,r.documentKey,Math.max(t.batchId,e.largestBatchId))}}class ra{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this._e(e),this.ae=e=>t.writeSequenceNumber(e))}_e(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this.ae&&this.ae(e),e}}function ro(e){return null==e}function rl(e){return 0===e&&1/e==-1/0}function ru(e){return"number"==typeof e&&Number.isInteger(e)&&!rl(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}function rh(e){let t="";for(let r=0;r<e.length;r++)t.length>0&&(t+="\x01\x01"),t=function(e,t){let r=t,n=e.length;for(let t=0;t<n;t++){let n=e.charAt(t);switch(n){case"\0":r+="\x01\x10";break;case"\x01":r+="\x01\x11";break;default:r+=n}}return r}(e.get(r),t);return t+"\x01\x01"}ra.ue=-1;function rc(e){let t=e.length;if(ta(t>=2,64408,{path:e}),2===t)return ta("\x01"===e.charAt(0)&&"\x01"===e.charAt(1),56145,{path:e}),tx.emptyPath();let r=t-2,n=[],i="";for(let s=0;s<t;){let t=e.indexOf("\x01",s);switch((t<0||t>r)&&ti(50515,{path:e}),e.charAt(t+1)){case"\x01":let a,o=e.substring(s,t);0===i.length?a=o:(i+=o,a=i,i=""),n.push(a);break;case"\x10":i+=e.substring(s,t),i+="\0";break;case"\x11":i+=e.substring(s,t+1);break;default:ti(61167,{path:e})}s=t+2}return new tx(n)}let rd="remoteDocuments",rf="owner",rp="owner",rg="mutationQueues",rm="mutations",ry="batchId",rv="userMutationsIndex",rw=["userId","batchId"],rb={},rE="documentMutations",rI="remoteDocumentsV14",r_=["prefixPath","collectionGroup","readTime","documentId"],rT="documentKeyIndex",rS=["prefixPath","collectionGroup","documentId"],rx="collectionGroupIndex",rC=["collectionGroup","readTime","prefixPath","documentId"],rA="remoteDocumentGlobal",rD="remoteDocumentGlobalKey",rN="targets",rk="queryTargetsIndex",rO=["canonicalId","targetId"],rR="targetDocuments",rL=["targetId","path"],rM="documentTargetsIndex",rP=["path","targetId"],rF="targetGlobalKey",rV="targetGlobal",rB="collectionParents",rU=["collectionId","parent"],rq="clientMetadata",rj="bundles",rz="namedQueries",r$="indexConfiguration",rG="collectionGroupIndex",rK="indexState",rQ=["indexId","uid"],rH="sequenceNumberIndex",rW=["uid","sequenceNumber"],rX="indexEntries",rJ=["indexId","uid","arrayValue","directionalValue","orderedDocumentKey","documentKey"],rY="documentKeyIndex",rZ=["indexId","uid","orderedDocumentKey"],r0="documentOverlays",r1=["userId","collectionPath","documentId"],r2="collectionPathOverlayIndex",r6=["userId","collectionPath","largestBatchId"],r3="collectionGroupOverlayIndex",r5=["userId","collectionGroup","largestBatchId"],r4="globals",r8=[rg,rm,rE,rd,rN,rf,rV,rR,rq,rA,rB,rj,rz],r7=[...r8,r0],r9=[rg,rm,rE,rI,rN,rf,rV,rR,rq,rA,rB,rj,rz,r0],ne=[...r9,r$,rK,rX],nt=[...ne,r4];class nr extends tZ{constructor(e,t){super(),this.ce=e,this.currentSequenceNumber=t}}function nn(e,t){return t3.N(e.ce,t)}function ni(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}function ns(e,t){for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t(r,e[r])}function na(e,t){let r=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.push(t(e[n],n,e));return r}function no(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class nl{constructor(e,t){this.comparator=e,this.root=t||nh.EMPTY}insert(e,t){return new nl(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,nh.BLACK,null,
15null))}remove(e){return new nl(this.comparator,this.root.remove(e,this.comparator).copy(null,null,nh.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let r=this.comparator(e,t.key);if(0===r)return t.value;r<0?t=t.left:r>0&&(t=t.right)}return null}indexOf(e){let t=0,r=this.root;for(;!r.isEmpty();){let n=this.comparator(e,r.key);if(0===n)return t+r.left.size;n<0?r=r.left:(t+=r.left.size+1,r=r.right)}return -1}isEmpty(){return this.root.isEmpty()}get size(){return this.root.size}minKey(){return this.root.minKey()}maxKey(){return this.root.maxKey()}inorderTraversal(e){return this.root.inorderTraversal(e)}forEach(e){this.inorderTraversal((t,r)=>(e(t,r),!1))}toString(){let e=[];return this.inorderTraversal((t,r)=>(e.push(`${t}:${r}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new nu(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new nu(this.root,e,this.comparator,!1)}getReverseIterator(){return new nu(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new nu(this.root,e,this.comparator,!0)}}class nu{constructor(e,t,r,n){this.isReverse=n,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?r(e.key,t):1,t&&n&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(0===i){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop(),t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class nh{constructor(e,t,r,n,i){this.key=e,this.value=t,this.color=null!=r?r:nh.RED,this.left=null!=n?n:nh.EMPTY,this.right=null!=i?i:nh.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,r,n,i){return new nh(null!=e?e:this.key,null!=t?t:this.value,null!=r?r:this.color,null!=n?n:this.left,null!=i?i:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,r){let n=this,i=r(e,n.key);return(n=i<0?n.copy(null,null,null,n.left.insert(e,t,r),null):0===i?n.copy(null,t,null,null,null):n.copy(null,null,null,null,n.right.insert(e,t,r))).fixUp()}removeMin(){if(this.left.isEmpty())return nh.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),(e=e.copy(null,null,null,e.left.removeMin(),null)).fixUp()}remove(e,t){let r,n=this;if(0>t(e,n.key))n.left.isEmpty()||n.left.isRed()||n.left.left.isRed()||(n=n.moveRedLeft()),n=n.copy(null,null,null,n.left.remove(e,t),null);else{if(n.left.isRed()&&(n=n.rotateRight()),n.right.isEmpty()||n.right.isRed()||n.right.left.isRed()||(n=n.moveRedRight()),0===t(e,n.key)){if(n.right.isEmpty())return nh.EMPTY;r=n.right.min(),n=n.copy(r.key,r.value,null,null,n.right.removeMin())}n=n.copy(null,null,null,null,n.right.remove(e,t))}return n.fixUp()}isRed(){return this.color}fixUp(){let e=this;return e.right.isRed()&&!e.left.isRed()&&(e=e.rotateLeft()),e.left.isRed()&&e.left.left.isRed()&&(e=e.rotateRight()),e.left.isRed()&&e.right.isRed()&&(e=e.colorFlip()),e}moveRedLeft(){let e=this.colorFlip();return e.right.left.isRed()&&(e=(e=(e=e.copy(null,null,null,null,e.right.rotateRight())).rotateLeft()).colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=(e=e.rotateRight()).colorFlip()),e}rotateLeft(){let e=this.copy(null,null,nh.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){let e=this.copy(null,null,nh.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){let e=this.left.copy(null,null,!this.left.color,null,null),t=this.right.copy(null,null,!this.right.color,null,null);return this.copy(null,null,!this.color,e,t)}checkMaxDepth(){return Math.pow(2,this.check())<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw ti(43730,{key:this.key,value:this.value});if(this.right.isRed())throw ti(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw ti(27949);return e+ +!this.isRed()}}
15nh.EMPTY=null,nh.RED=!0,nh.BLACK=!1,nh.EMPTY=new class{constructor(){this.size=0}get key(){throw ti(57766)}get value(){throw ti(16141)}get color(){throw ti(16727)}get left(){throw ti(29726)}get right(){throw ti(36894)}copy(e,t,r,n,i){return this}insert(e,t,r){return new nh(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class nc{constructor(e){this.comparator=e,this.data=new nl(this.comparator)}has(e){return null!==this.data.get(e)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,r)=>(e(t),!1))}forEachInRange(e,t){let r=this.data.getIteratorFrom(e[0]);for(;r.hasNext();){let n=r.getNext();if(this.comparator(n.key,e[1])>=0)return;t(n.key)}}forEachWhile(e,t){let r;for(r=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();r.hasNext();)if(!e(r.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new nd(this.data.getIterator())}getIteratorFrom(e){return new nd(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(e=>{t=t.add(e)}),t}isEqual(e){if(!(e instanceof nc)||this.size!==e.size)return!1;let t=this.data.getIterator(),r=e.data.getIterator();for(;t.hasNext();){let e=t.getNext().key,n=r.getNext().key;if(0!==this.comparator(e,n))return!1}return!0}toArray(){let e=[];return this.forEach(t=>{e.push(t)}),e}toString(){let e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){let t=new nc(this.comparator);return t.data=e,t}}class nd{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}function nf(e){return e.hasNext()?e.getNext():void 0}class np{constructor(e){this.fields=e,e.sort(tA.comparator)}static empty(){return new np([])}unionWith(e){let t=new nc(tA.comparator);for(let e of this.fields)t=t.add(e);for(let r of e)t=t.add(r);return new np(t.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return t_(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class ng extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class nm{constructor(e){this.binaryString=e}static fromBase64String(e){return new nm(function(e){try{return atob(e)}catch(e){throw"u">typeof DOMException&&e instanceof DOMException?new ng("Invalid base64 string: "+e):e}}(e))}static fromUint8Array(e){return new nm(function(e){let t="";for(let r=0;r<e.length;++r)t+=String.fromCharCode(e[r]);return t}(e))}[Symbol.iterator](){let e=0;return{next:()=>e<this.binaryString.length?{value:this.binaryString.charCodeAt(e++),done:!1}:{value:void 0,done:!0}}}toBase64(){return btoa(this.binaryString)}toUint8Array(){var e=this.binaryString;let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return tb(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}nm.EMPTY_BYTE_STRING=new nm("");let ny=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function nv(e){if(ta(!!e,39018),"string"==typeof e){let t=0,r=ny.exec(e);if(ta(!!r,46558,{timestamp:e}),r[1]){let e=r[1];t=Number(e=(e+"000000000").substr(0,9))}return{seconds:Math.floor(new Date(e).getTime()/1e3),nanos:t}}return{seconds:nw(e.seconds),nanos:nw(e.nanos)}}function nw(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function nb(e){return"string"==typeof e?nm.fromBase64String(e):nm.fromUint8Array(e)}let nE="server_timestamp",nI="__type__",n_="__previous_value__",nT="__local_write_time__";function nS(e){var t,r;return(null==(r=((null==(t=null==e?void 0:e.mapValue)?void 0:t.fields)||{})[nI])?void 0:r.stringValue)===nE}function nx(e){let t=e.mapValue.fields[n_];return nS(t)?nx(t):t}function nC(e){let t=nv(e.mapValue.fields[nT].timestampValue);return new tU(t.seconds,t.nanos)}class nA{constructor(e,t,r,n,i,s,a,o,l,u){this.databaseId=e,this.appId=t,this.persistenceKey=r,this.host=n,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=a,this.longPollingOptions=o,this.useFetchStreams=l,this.isUsingEmulator=u}}let nD="(default)";class nN{constructor(e,t){this.projectId=e,this.database=t||nD}static empty(){return new nN("","")}get isDefaultDatabase(){return this.database===nD}isEqual(e){return e instanceof nN&&e.projectId===this.projectId&&e.database===this.database}}let nk="__type__",nO="__max__",nR={mapValue:{fields:{__type__:{stringValue:nO}}}},nL="__vector__",nM="value",nP={nullValue:"NULL_VALUE"};function nF(e){return"nullValue"in e?0:"booleanValue"in e?1:"integerValue"in e||"doubleValue"in e?2:"timestampValue"in e?3:"stringValue"in e?5:"bytesValue"in e?6:"referenceValue"in e?7:"geoPointValue"in e?8:"arrayValue"in e?9:"mapValue"in e?nS(e)?4:nY(e)?0x1fffffffffffff:nX(e)?10:11:ti(28295,{value:e})}function nV(e,t){if(e===t)return!0;let r=nF(e);if(r!==nF(t))return!1;switch(r){case 0:case 0x1fffffffffffff:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return nC(e).isEqual(nC(t));case 3:if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;let n=nv(e.timestampValue),i=nv(t.timestampValue);return n.seconds===i.seconds&&n.nanos===i.nanos;case 5:return e.stringValue===t.stringValue;case 6:return nb(e.bytesValue).isEqual(nb(t.bytesValue));case 7:return e.referenceValue===t.referenceValue;case 8:return nw(e.geoPointValue.latitude)===nw(t.geoPointValue.latitude)&&nw(e.geoPointValue.longitude)===nw(t.geoPointValue.longitude);case 2:if("integerValue"in e&&"integerValue"in t)return nw(e.integerValue)===nw(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){let r=nw(e.doubleValue),n=nw(t.doubleValue);return r===n?rl(r)===rl(n):isNaN(r)&&isNaN(n)}return!1;case 9:return t_(e.arrayValue.values||[],t.arrayValue.values||[],nV);case 10:case 11:let s=e.mapValue.fields||{},a=t.mapValue.fields||{};if(ni(s)!==ni(a))return!1;for(let e in s)if(s.hasOwnProperty(e)&&(void 0===a[e]||!nV(s[e],a[e])))return!1;return!0;default:return ti(52216,{left:e})}}function nB(e,t){return void 0!==(e.values||[]).find(e=>nV(e,t))}function nU(e,t){var r,n,i,s,a,o,l,u,h,c;if(e===t)return 0;let d=nF(e),f=nF(t);if(d!==f)return tb(d,f);switch(d){case 0:case 0x1fffffffffffff:return 0;case 1:return tb(e.booleanValue,t.booleanValue);case 2:let p,g;return p=nw(e.integerValue||e.doubleValue),p<(g=nw(t.integerValue||t.doubleValue))?-1:p>g?1:p===g?0:isNaN(p)?isNaN(g)?0:-1:1;case 3:return nq(e.timestampValue,t.timestampValue);case 4:return nq(nC(e),nC(t));case 5:return tE(e.stringValue,t.stringValue);case 6:let m,y;return r=e.bytesValue,n=t.bytesValue,m=nb(r),y=nb(n),m.compareTo(y);case 7:return function(e,t){let r=e.split("/"),n=t.split("/");for(let e=0;e<r.length&&e<n.length;e++){let t=tb(r[e],n[e]);if(0!==t)return t}return tb(r.length,n.length)}(e.referenceValue,t.referenceValue);case 8:let v;return i=e.geoPointValue,s=t.geoPointValue,0!==(v=tb(nw(i.latitude),nw(s.latitude)))?v:tb(nw(i.longitude),nw(s.longitude));case 9:return nj(e.arrayValue,t.arrayValue);case 10:let w,b,E,I,_;return a=e.mapValue,o=t.mapValue,w=a.fields||{},b=o.fields||{},E=null==(l=w[nM])?void 0:l.arrayValue,I=null==(u=b[nM])?void 0:u.arrayValue,0!==(_=tb((null==(h=null==E?void 0:E.values)?void 0:h.length)||0,(null==(c=null==I?void 0:I.values)?void 0:c.length)||0))?_:nj(E,I);case 11:return function(e,t){if(e===nR.mapValue&&t===nR.mapValue)return 0;if(e===nR.mapValue)return 1;if(t===nR.mapValue)return -1;let r=e.fields||{},n=Object.keys(r),i=t.fields||{},s=Object.keys(i);n.sort(),s.sort();for(let e=0;e<n.length&&e<s.length;++e){let t=tE(n[e],s[e]);if(0!==t)return t;let a=nU(r[n[e]],i[s[e]]);if(0!==a)return a}return tb(n.length,s.length)}(e.mapValue,t.mapValue);default:throw ti(23264,{le:d})}}function nq(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return tb(e,t);let r=nv(e),n=nv(t),i=tb(r.seconds,n.seconds);return 0!==i?i:tb(r.nanos,n.nanos)}function nj(e,t){let r=e.values||[],n=t.values||[];for(let e=0;e<r.length&&e<n.length;++e){let t=nU(r[e],n[e]);if(t)return t}return tb(r.length,n.length)}function nz(e){var t,r;let n;return"nullValue"in e?"null":"booleanValue"in e?""+e.booleanValue:"integerValue"in e?""+e.integerValue:"doubleValue"in e?""+e.doubleValue:"timestampValue"in e?(n=nv(e.timestampValue),`time(${n.seconds},${n.nanos}
15)`):"stringValue"in e?e.stringValue:"bytesValue"in e?nb(e.bytesValue).toBase64():"referenceValue"in e?(t=e.referenceValue,tD.fromName(t).toString()):"geoPointValue"in e?(r=e.geoPointValue,`geo(${r.latitude},${r.longitude})`):"arrayValue"in e?function(e){let t="[",r=!0;for(let n of e.values||[])r?r=!1:t+=",",t+=nz(n);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){let t=Object.keys(e.fields||{}).sort(),r="{",n=!0;for(let i of t)n?n=!1:r+=",",r+=`${i}:${nz(e.fields[i])}`;return r+"}"}(e.mapValue):ti(61005,{value:e})}function n$(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function nG(e){return!!e&&"integerValue"in e}function nK(e){return!!e&&"arrayValue"in e}function nQ(e){return!!e&&"nullValue"in e}function nH(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function nW(e){return!!e&&"mapValue"in e}function nX(e){var t,r;return(null==(r=((null==(t=null==e?void 0:e.mapValue)?void 0:t.fields)||{})[nk])?void 0:r.stringValue)===nL}function nJ(e){if(e.geoPointValue)return{geoPointValue:Object.assign({},e.geoPointValue)};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:Object.assign({},e.timestampValue)};if(e.mapValue){let t={mapValue:{fields:{}}};return ns(e.mapValue.fields,(e,r)=>t.mapValue.fields[e]=nJ(r)),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let r=0;r<(e.arrayValue.values||[]).length;++r)t.arrayValue.values[r]=nJ(e.arrayValue.values[r]);return t}return Object.assign({},e)}function nY(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===nO}let nZ={mapValue:{fields:{[nk]:{stringValue:nL},[nM]:{arrayValue:{}}}}};function n0(e,t){let r=nU(e.value,t.value);return 0!==r?r:e.inclusive&&!t.inclusive?-1:!e.inclusive&&t.inclusive?1:0}function n1(e,t){let r=nU(e.value,t.value);return 0!==r?r:e.inclusive&&!t.inclusive?1:!e.inclusive&&t.inclusive?-1:0}class n2{constructor(e){this.value=e}static empty(){return new n2({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let r=0;r<e.length-1;++r)if(!nW(t=(t.mapValue.fields||{})[e.get(r)]))return null;return(t=(t.mapValue.fields||{})[e.lastSegment()])||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=nJ(t)}setAll(e){let t=tA.emptyPath(),r={},n=[];e.forEach((e,i)=>{if(!t.isImmediateParentOf(i)){let e=this.getFieldsMap(t);this.applyChanges(e,r,n),r={},n=[],t=i.popLast()}e?r[i.lastSegment()]=nJ(e):n.push(i.lastSegment())});let i=this.getFieldsMap(t);this.applyChanges(i,r,n)}delete(e){let t=this.field(e.popLast());nW(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return nV(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let r=0;r<e.length;++r){let n=t.mapValue.fields[e.get(r)];nW(n)&&n.mapValue.fields||(n={mapValue:{fields:{}}},t.mapValue.fields[e.get(r)]=n),t=n}return t.mapValue.fields}applyChanges(e,t,r){for(let n of(ns(t,(t,r)=>e[t]=r),r))delete e[n]}clone(){return new n2(nJ(this.value))}}class n6{constructor(e,t,r,n,i,s,a){this.key=e,this.documentType=t,this.version=r,this.readTime=n,this.createTime=i,this.data=s,this.documentState=a}static newInvalidDocument(e){return new n6(e,0,tq.min(),tq.min(),tq.min(),n2.empty(),0)}static newFoundDocument(e,t,r,n){return new n6(e,1,t,tq.min(),r,n,0)}static newNoDocument(e,t){return new n6(e,2,t,tq.min(),tq.min(),n2.empty(),0)}static newUnknownDocument(e,t){return new n6(e,3,t,tq.min(),tq.min(),n2.empty(),2)}convertToFoundDocument(e,t){return this.createTime.isEqual(tq.min())&&(2===this.documentType||0===this.documentType)&&(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=n2.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=n2.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=tq.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(e){return e instanceof n6&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new n6(this.key,this.documentType,this.version,this.readTime,this.createTime,this.data.clone(),this.documentState)}toString(){return`Document(${this.key}, ${this.version}, ${JSON.stringify(this.data.value)}, {createTime: ${this.createTime}}), {documentType: ${this.documentType}}), {documentState: ${this.documentState}})`}}
15class n3{constructor(e,t){this.position=e,this.inclusive=t}}function n5(e,t,r){let n=0;for(let i=0;i<e.position.length;i++){let s=t[i],a=e.position[i];if(n=s.field.isKeyField()?tD.comparator(tD.fromName(a.referenceValue),r.key):nU(a,r.data.field(s.field)),"desc"===s.dir&&(n*=-1),0!==n)break}return n}function n4(e,t){if(null===e)return null===t;if(null===t||e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let r=0;r<e.position.length;r++)if(!nV(e.position[r],t.position[r]))return!1;return!0}class n8{constructor(e,t="asc"){this.field=e,this.dir=t}}class n7{}class n9 extends n7{constructor(e,t,r){super(),this.field=e,this.op=t,this.value=r}static create(e,t,r){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,r):new io(e,t,r):"array-contains"===t?new ic(e,r):"in"===t?new id(e,r):"not-in"===t?new ip(e,r):"array-contains-any"===t?new ig(e,r):new n9(e,t,r)}static createKeyFieldInFilter(e,t,r){return"in"===t?new il(e,r):new iu(e,r)}matches(e){let t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(nU(t,this.value)):null!==t&&nF(this.value)===nF(t)&&this.matchesComparison(nU(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return ti(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class ie extends n7{constructor(e,t){super(),this.filters=e,this.op=t,this.he=null}static create(e,t){return new ie(e,t)}matches(e){return it(this)?void 0===this.filters.find(t=>!t.matches(e)):void 0!==this.filters.find(t=>t.matches(e))}getFlattenedFilters(){return null!==this.he||(this.he=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.he}getFilters(){return Object.assign([],this.filters)}}function it(e){return"and"===e.op}function ir(e){return"or"===e.op}function ii(e){return is(e)&&it(e)}function is(e){for(let t of e.filters)if(t instanceof ie)return!1;return!0}function ia(e,t){let r=e.filters.concat(t);return ie.create(r,e.op)}class io extends n9{constructor(e,t,r){super(e,t,r),this.key=tD.fromName(r.referenceValue)}matches(e){let t=tD.comparator(e.key,this.key);return this.matchesComparison(t)}}class il extends n9{constructor(e,t){super(e,"in",t),this.keys=ih("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class iu extends n9{constructor(e,t){super(e,"not-in",t),this.keys=ih("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function ih(e,t){var r;return((null==(r=t.arrayValue)?void 0:r.values)||[]).map(e=>tD.fromName(e.referenceValue))}class ic extends n9{constructor(e,t){super(e,"array-contains",t)}matches(e){let t=e.data.field(this.field);return nK(t)&&nB(t.arrayValue,this.value)}}class id extends n9{constructor(e,t){super(e,"in",t)}matches(e){let t=e.data.field(this.field);return null!==t&&nB(this.value.arrayValue,t)}}class ip extends n9{constructor(e,t){super(e,"not-in",t)}matches(e){if(nB(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;let t=e.data.field(this.field);return null!==t&&void 0===t.nullValue&&!nB(this.value.arrayValue,t)}}class ig extends n9{constructor(e,t){super(e,"array-contains-any",t)}matches(e){let t=e.data.field(this.field);return!(!nK(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>nB(this.value.arrayValue,e))}}class im{constructor(e,t=null,r=[],n=[],i=null,s=null,a=null){this.path=e,this.collectionGroup=t,this.orderBy=r,this.filters=n,this.limit=i,this.startAt=s,this.endAt=a,this.Pe=null}}function iy(e,t=null,r=[],n=[],i=null,s=null,a=null){return new im(e,t,r,n,i,s,a)}function iv(e){if(null===e.Pe){let t=e.path.canonicalString();null!==e.collectionGroup&&(t+="|cg:"+e.collectionGroup),t+="|f:",t+=e.filters.map(e=>(function e(t){if(t instanceof n9)return t.field.canonicalString()+t.op.toString()+nz(t.value);if(ii(t))return t.filters.map(t=>e(t)).join(",");{let r=t.filters.map(t=>e(t)).join(",");return`${t.op}(${r})`}})(e)).join(","),t+="|ob:",t+=e.orderBy.map(e=>e.field.canonicalString()+e.dir).join(","),ro(e.limit)||(t+="|l:",t+=e.limit),e.startAt&&(t+="|lb:",t+=e.startAt.inclusive?"b:":"a:",t+=e.startAt.position.map(e=>nz(e)).join(",")),e.endAt&&(t+="|ub:",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(e=>nz(e)).join(",")),e.Pe=t}return e.Pe}function iw(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let i=0;i<e.orderBy.length;i++){var r,n;if(r=e.orderBy[i],n=t.orderBy[i],!(r.dir===n.dir&&r.field.isEqual(n.field)))return!1}if(e.filters.length!==t.filters.length)return!1;for(let r=0;r<e.filters.length;r++)if(!function e(t,r){return t instanceof n9?r instanceof n9&&t.op===r.op&&t.field.isEqual(r.field)&&nV(t.value,r.value):t instanceof ie?r instanceof ie&&t.op===r.op&&t.filters.length===r.filters.length&&t.filters.reduce((t,n,i)=>t&&e(n,r.filters[i]),!0):void ti(19439)}(e.filters[r],t.filters[r]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!n4(e.startAt,t.startAt)&&n4(e.endAt,t.endAt)}function ib(e){return tD.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}function iE(e,t){return e.filters.filter(e=>e instanceof n9&&e.field.isEqual(t))}function iI(e,t,r){let n=nP,i=!0;for(let r of iE(e,t)){let e=nP,t=!0;switch(r.op){case"<":case"<=":var s;
15e="nullValue"in(s=r.value)?nP:"booleanValue"in s?{booleanValue:!1}:"integerValue"in s||"doubleValue"in s?{doubleValue:NaN}:"timestampValue"in s?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"stringValue"in s?{stringValue:""}:"bytesValue"in s?{bytesValue:""}:"referenceValue"in s?n$(nN.empty(),tD.empty()):"geoPointValue"in s?{geoPointValue:{latitude:-90,longitude:-180}}:"arrayValue"in s?{arrayValue:{}}:"mapValue"in s?nX(s)?nZ:{mapValue:{}}:ti(35942,{value:s});break;case"==":case"in":case">=":e=r.value;break;case">":e=r.value,t=!1;break;case"!=":case"not-in":e=nP}0>n0({value:n,inclusive:i},{value:e,inclusive:t})&&(n=e,i=t)}if(null!==r){for(let s=0;s<e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){let e=r.position[s];0>n0({value:n,inclusive:i},{value:e,inclusive:r.inclusive})&&(n=e,i=r.inclusive);break}}return{value:n,inclusive:i}}function i_(e,t,r){let n=nR,i=!0;for(let r of iE(e,t)){let e=nR,t=!0;switch(r.op){case">=":case">":var s;e="nullValue"in(s=r.value)?{booleanValue:!1}:"booleanValue"in s?{doubleValue:NaN}:"integerValue"in s||"doubleValue"in s?{timestampValue:{seconds:Number.MIN_SAFE_INTEGER}}:"timestampValue"in s?{stringValue:""}:"stringValue"in s?{bytesValue:""}:"bytesValue"in s?n$(nN.empty(),tD.empty()):"referenceValue"in s?{geoPointValue:{latitude:-90,longitude:-180}}:"geoPointValue"in s?{arrayValue:{}}:"arrayValue"in s?nZ:"mapValue"in s?nX(s)?{mapValue:{}}:nR:ti(61959,{value:s}),t=!1;break;case"==":case"in":case"<=":e=r.value;break;case"<":e=r.value,t=!1;break;case"!=":case"not-in":e=nR}n1({value:n,inclusive:i},{value:e,inclusive:t})>0&&(n=e,i=t)}if(null!==r){for(let s=0;s<e.orderBy.length;++s)if(e.orderBy[s].field.isEqual(t)){let e=r.position[s];n1({value:n,inclusive:i},{value:e,inclusive:r.inclusive})>0&&(n=e,i=r.inclusive);break}}return{value:n,inclusive:i}}class iT{constructor(e,t=null,r=[],n=[],i=null,s="F",a=null,o=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=r,this.filters=n,this.limit=i,this.limitType=s,this.startAt=a,this.endAt=o,this.Te=null,this.Ie=null,this.de=null,this.startAt,this.endAt}}function iS(e){return new iT(e)}function ix(e){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())}function iC(e){return null!==e.collectionGroup}function iA(e){if(null===e.Te){let t;e.Te=[];let r=new Set;for(let t of e.explicitOrderBy)e.Te.push(t),r.add(t.field.canonicalString());let n=e.explicitOrderBy.length>0?e.explicitOrderBy[e.explicitOrderBy.length-1].dir:"asc";(t=new nc(tA.comparator),e.filters.forEach(e=>{e.getFlattenedFilters().forEach(e=>{e.isInequality()&&(t=t.add(e.field))})}),t).forEach(t=>{r.has(t.canonicalString())||t.isKeyField()||e.Te.push(new n8(t,n))}),r.has(tA.keyField().canonicalString())||e.Te.push(new n8(tA.keyField(),n))}return e.Te}function iD(e){return e.Ie||(e.Ie=ik(e,iA(e))),e.Ie}function iN(e){return e.de||(e.de=ik(e,e.explicitOrderBy)),e.de}function ik(e,t){if("F"===e.limitType)return iy(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map(e=>{let t="desc"===e.dir?"asc":"desc";return new n8(e.field,t)});let r=e.endAt?new n3(e.endAt.position,e.endAt.inclusive):null,n=e.startAt?new n3(e.startAt.position,e.startAt.inclusive):null;return iy(e.path,e.collectionGroup,t,e.filters,e.limit,r,n)}}function iO(e,t){let r=e.filters.concat([t]);return new iT(e.path,e.collectionGroup,e.explicitOrderBy.slice(),r,e.limit,e.limitType,e.startAt,e.endAt)}function iR(e,t,r){return new iT(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,r,e.startAt,e.endAt)}function iL(e,t){return iw(iD(e),iD(t))&&e.limitType===t.limitType}function iM(e){return`${iv(iD(e))}|lt:${e.limitType}`}function iP(e){var t;let r;return`Query(target=${r=(t=iD(e)).path.canonicalString(),null!==t.collectionGroup&&(r+=" collectionGroup="+t.collectionGroup),t.filters.length>0&&(r+=`, filters: [${t.filters.map(e=>(function e(t){return t instanceof n9?`${t.field.canonicalString()} ${t.op} ${nz(t.value)}`:t instanceof ie?t.op.toString()+" {"+t.getFilters().map(e).join(" ,")+"}":"Filter"})(e)).join(", ")}]`),ro(t.limit)||(r+=", limit: "+t.limit),t.orderBy.length>0&&(r+=`, orderBy: [${t.orderBy.map(e=>`${e.field.canonicalString()} (${e.dir})`).join(", ")}]`),t.startAt&&(r+=", startAt: ",r+=t.startAt.inclusive?"b:":"a:",r+=t.startAt.position.map(e=>nz(e)).join(",")),t.endAt&&(r+=", endAt: ",r+=t.endAt.inclusive?"a:":"b:",r+=t.endAt.position.map(e=>nz(e)).join(",")),`Target(${r})`}; limitType=${e.limitType})`}function iF(e,t){var r,n,i,s;let a,o,l;
15return t.isFoundDocument()&&(a=t.key.path,null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(a):tD.isDocumentKey(e.path)?e.path.isEqual(a):e.path.isImmediateParentOf(a))&&function(e,t){for(let r of iA(e))if(!r.field.isKeyField()&&null===t.data.field(r.field))return!1;return!0}(e,t)&&function(e,t){for(let r of e.filters)if(!r.matches(t))return!1;return!0}(e,t)&&(r=e,n=t,(!r.startAt||(i=r.startAt,o=n5(i,iA(r),n),i.inclusive?!!(o<=0):!!(o<0)))&&(!r.endAt||(s=r.endAt,l=n5(s,iA(r),n),s.inclusive?!!(l>=0):!!(l>0))))}function iV(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function iB(e){return(t,r)=>{let n=!1;for(let i of iA(e)){let e=function(e,t,r){var n;let i,s,a=e.field.isKeyField()?tD.comparator(t.key,r.key):(n=e.field,i=t.data.field(n),s=r.data.field(n),null!==i&&null!==s?nU(i,s):ti(42886));switch(e.dir){case"asc":return a;case"desc":return -1*a;default:return ti(19790,{direction:e.dir})}}(i,t,r);if(0!==e)return e;n=n||i.field.isKeyField()}return 0}}class iU{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),r=this.inner[t];if(void 0!==r){for(let[t,n]of r)if(this.equalsFn(t,e))return n}}has(e){return void 0!==this.get(e)}set(e,t){let r=this.mapKeyFn(e),n=this.inner[r];if(void 0===n)return this.inner[r]=[[e,t]],void this.innerSize++;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return void(n[r]=[e,t]);n.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),r=this.inner[t];if(void 0===r)return!1;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],e))return 1===r.length?delete this.inner[t]:r.splice(n,1),this.innerSize--,!0;return!1}forEach(e){ns(this.inner,(t,r)=>{for(let[t,n]of r)e(t,n)})}isEmpty(){return no(this.inner)}size(){return this.innerSize}}let iq=new nl(tD.comparator),ij=new nl(tD.comparator);function iz(...e){let t=ij;for(let r of e)t=t.insert(r.key,r);return t}function i$(e){let t=ij;return e.forEach((e,r)=>t=t.insert(e,r.overlayedDocument)),t}function iG(){return new iU(e=>e.toString(),(e,t)=>e.isEqual(t))}let iK=new nl(tD.comparator),iQ=new nc(tD.comparator);function iH(...e){let t=iQ;for(let r of e)t=t.add(r);return t}let iW=new nc(tb);function iX(e,t){if(e.useProto3Json){if(isNaN(t))return{doubleValue:"NaN"};if(t===1/0)return{doubleValue:"Infinity"};if(t===-1/0)return{doubleValue:"-Infinity"}}return{doubleValue:rl(t)?"-0":t}}function iJ(e){return{integerValue:""+e}}function iY(e,t){return ru(t)?iJ(t):iX(e,t)}class iZ{constructor(){this._=void 0}}function i0(e,t){return e instanceof i4?nG(t)||t&&"doubleValue"in t?t:{integerValue:0}:null}class i1 extends iZ{}class i2 extends iZ{constructor(e){super(),this.elements=e}}function i6(e,t){let r=i7(t);for(let t of e.elements)r.some(e=>nV(e,t))||r.push(t);return{arrayValue:{values:r}}}class i3 extends iZ{constructor(e){super(),this.elements=e}}function i5(e,t){let r=i7(t);for(let t of e.elements)r=r.filter(e=>!nV(e,t));return{arrayValue:{values:r}}}class i4 extends iZ{constructor(e,t){super(),this.serializer=e,this.Ee=t}}function i8(e){return nw(e.integerValue||e.doubleValue)}function i7(e){return nK(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class i9{constructor(e,t){this.field=e,this.transform=t}}class se{constructor(e,t){this.version=e,this.transformResults=t}}class st{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new st}static exists(e){return new st(void 0,e)}static updateTime(e){return new st(e)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function sr(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class sn{}function si(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new sd(e.key,st.none()):new so(e.key,e.data,st.none());{let r=e.data,n=n2.empty(),i=new nc(tA.comparator);for(let e of t.fields)if(!i.has(e)){let t=r.field(e);null===t&&e.length>1&&(e=e.popLast(),t=r.field(e)),null===t?n.delete(e):n.set(e,t),i=i.add(e)}return new sl(e.key,n,new np(i.toArray()),st.none())}}function ss(e,t,r,n){return e instanceof so?function(e,t,r,n){if(!sr(e.precondition,t))return r;let i=e.value.clone(),s=sc(e.fieldTransforms,n,t);return i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,r,n):e instanceof sl?function(e,t,r,n){if(!sr(e.precondition,t))return r;let i=sc(e.fieldTransforms,n,t),s=t.data;return(s.setAll(su(e)),s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null===r)?null:r.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(e=>e.field))}(e,t,r,n):sr(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):r}function sa(e,t){var r,n;return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&(r=e.fieldTransforms,n=t.fieldTransforms,!!(void 0===r&&void 0===n||!(!r||!n)&&t_(r,n,(e,t)=>{var r,n;return e.field.isEqual(t.field)&&(r=e.transform,n=t.transform,r instanceof i2&&n instanceof i2||r instanceof i3&&n instanceof i3?t_(r.elements,n.elements,nV):r instanceof i4&&n instanceof i4?nV(r.Ee,n.Ee):r instanceof i1&&n instanceof i1)})))&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class so extends sn{constructor(e,t,r,n=[]){super(),this.key=e,this.value=t,this.prec
15ondition=r,this.fieldTransforms=n,this.type=0}getFieldMask(){return null}}class sl extends sn{constructor(e,t,r,n,i=[]){super(),this.key=e,this.data=t,this.fieldMask=r,this.precondition=n,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}}function su(e){let t=new Map;return e.fieldMask.fields.forEach(r=>{if(!r.isEmpty()){let n=e.data.field(r);t.set(r,n)}}),t}function sh(e,t,r){let n=new Map;ta(e.length===r.length,32656,{Ae:r.length,Re:e.length});for(let s=0;s<r.length;s++){var i;let a=e[s],o=a.transform,l=t.data.field(a.field);n.set(a.field,(i=r[s],o instanceof i2?i6(o,l):o instanceof i3?i5(o,l):i))}return n}function sc(e,t,r){let n=new Map;for(let i of e){let e=i.transform,s=r.data.field(i.field);n.set(i.field,function(e,t,r){var n;let i,s,a;return e instanceof i1?(n=t,i={fields:{[nI]:{stringValue:nE},[nT]:{timestampValue:{seconds:r.seconds,nanos:r.nanoseconds}}}},n&&nS(n)&&(n=nx(n)),n&&(i.fields[n_]=n),{mapValue:i}):e instanceof i2?i6(e,t):e instanceof i3?i5(e,t):(a=i8(s=i0(e,t))+i8(e.Ee),nG(s)&&nG(e.Ee)?iJ(a):iX(e.serializer,a))}(e,s,t))}return n}class sd extends sn{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class sf extends sn{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class sp{constructor(e,t,r,n){this.batchId=e,this.localWriteTime=t,this.baseMutations=r,this.mutations=n}applyToRemoteDocument(e,t){let r=t.mutationResults;for(let t=0;t<this.mutations.length;t++){let n=this.mutations[t];n.key.isEqual(e.key)&&function(e,t,r){let n,i;e instanceof so?(n=e.value.clone(),i=sh(e.fieldTransforms,t,r.transformResults),n.setAll(i),t.convertToFoundDocument(r.version,n).setHasCommittedMutations()):e instanceof sl?function(e,t,r){if(!sr(e.precondition,t))return t.convertToUnknownDocument(r.version);let n=sh(e.fieldTransforms,t,r.transformResults),i=t.data;i.setAll(su(e)),i.setAll(n),t.convertToFoundDocument(r.version,i).setHasCommittedMutations()}(e,t,r):t.convertToNoDocument(r.version).setHasCommittedMutations()}(n,e,r[t])}}applyToLocalView(e,t){for(let r of this.baseMutations)r.key.isEqual(e.key)&&(t=ss(r,e,t,this.localWriteTime));for(let r of this.mutations)r.key.isEqual(e.key)&&(t=ss(r,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let r=iG();return this.mutations.forEach(n=>{let i=e.get(n.key),s=i.overlayedDocument,a=this.applyToLocalView(s,i.mutatedFields),o=si(s,a=t.has(n.key)?null:a);null!==o&&r.set(n.key,o),s.isValidDocument()||s.convertToNoDocument(tq.min())}),r}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),iH())}isEqual(e){return this.batchId===e.batchId&&t_(this.mutations,e.mutations,(e,t)=>sa(e,t))&&t_(this.baseMutations,e.baseMutations,(e,t)=>sa(e,t))}}class sg{constructor(e,t,r,n){this.batch=e,this.commitVersion=t,this.mutationResults=r,this.docVersions=n}static from(e,t,r){ta(e.mutations.length===r.length,58842,{Ve:e.mutations.length,me:r.length});let n=iK,i=e.mutations;for(let e=0;e<i.length;e++)n=n.insert(i[e].key,r[e].version);return new sg(e,t,r,n)}}class sm{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return null!==e&&this.mutation===e.mutation}toString(){return`Overlay{
16      largestBatchId: ${this.largestBatchId},
17      mutation: ${this.mutation.toString()}
18    }`}}class sy{constructor(e,t,r){this.alias=e,this.aggregateType=t,this.fieldPath=r}}class sv{constructor(e,t){this.count=e,this.unchangedNames=t}}function sw(e){switch(e){case to.OK:return ti(64938);case to.CANCELLED:case to.UNKNOWN:case to.DEADLINE_EXCEEDED:case to.RESOURCE_EXHAUSTED:case to.INTERNAL:case to.UNAVAILABLE:case to.UNAUTHENTICATED:return!1;case to.INVALID_ARGUMENT:case to.NOT_FOUND:case to.ALREADY_EXISTS:case to.PERMISSION_DENIED:case to.FAILED_PRECONDITION:case to.ABORTED:case to.OUT_OF_RANGE:case to.UNIMPLEMENTED:case to.DATA_LOSS:return!0;default:return ti(15467,{code:e})}}function sb(e){if(void 0===e)return tt("GRPC error has no .code"),to.UNKNOWN;switch(e){case m.OK:return to.OK;case m.CANCELLED:return to.CANCELLED;case m.UNKNOWN:return to.UNKNOWN;case m.DEADLINE_EXCEEDED:return to.DEADLINE_EXCEEDED;case m.RESOURCE_EXHAUSTED:return to.RESOURCE_EXHAUSTED;case m.INTERNAL:return to.INTERNAL;case m.UNAVAILABLE:return to.UNAVAILABLE;case m.UNAUTHENTICATED:return to.UNAUTHENTICATED;case m.INVALID_ARGUMENT:return to.INVALID_ARGUMENT;case m.NOT_FOUND:return to.NOT_FOUND;case m.ALREADY_EXISTS:return to.ALREADY_EXISTS;case m.PERMISSION_DENIED:return to.PERMISSION_DENIED;case m.FAILED_PRECONDITION:return to.FAILED_PRECONDITION;case m.ABORTED:return to.ABORTED;case m.OUT_OF_RANGE:return to.OUT_OF_RANGE;
18case m.UNIMPLEMENTED:return to.UNIMPLEMENTED;case m.DATA_LOSS:return to.DATA_LOSS;default:return ti(39323,{code:e})}}(y=m||(m={}))[y.OK=0]="OK",y[y.CANCELLED=1]="CANCELLED",y[y.UNKNOWN=2]="UNKNOWN",y[y.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",y[y.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",y[y.NOT_FOUND=5]="NOT_FOUND",y[y.ALREADY_EXISTS=6]="ALREADY_EXISTS",y[y.PERMISSION_DENIED=7]="PERMISSION_DENIED",y[y.UNAUTHENTICATED=16]="UNAUTHENTICATED",y[y.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",y[y.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",y[y.ABORTED=10]="ABORTED",y[y.OUT_OF_RANGE=11]="OUT_OF_RANGE",y[y.UNIMPLEMENTED=12]="UNIMPLEMENTED",y[y.INTERNAL=13]="INTERNAL",y[y.UNAVAILABLE=14]="UNAVAILABLE",y[y.DATA_LOSS=15]="DATA_LOSS";let sE=null,sI=new a([0xffffffff,0xffffffff],0);function s_(e){let t=tv().encode(e),r=new o;return r.update(t),new Uint8Array(r.digest())}function sT(e){let t=new DataView(e.buffer),r=t.getUint32(0,!0),n=t.getUint32(4,!0),i=t.getUint32(8,!0),s=t.getUint32(12,!0);return[new a([r,n],0),new a([i,s],0)]}class sS{constructor(e,t,r){if(this.bitmap=e,this.padding=t,this.hashCount=r,t<0||t>=8)throw new sx(`Invalid padding: ${t}`);if(r<0||e.length>0&&0===this.hashCount)throw new sx(`Invalid hash count: ${r}`);if(0===e.length&&0!==t)throw new sx(`Invalid padding when bitmap length is 0: ${t}`);this.fe=8*e.length-t,this.ge=a.fromNumber(this.fe)}pe(e,t,r){let n=e.add(t.multiply(a.fromNumber(r)));return 1===n.compare(sI)&&(n=new a([n.getBits(0),n.getBits(1)],0)),n.modulo(this.ge).toNumber()}ye(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.fe)return!1;let[t,r]=sT(s_(e));for(let e=0;e<this.hashCount;e++){let n=this.pe(t,r,e);if(!this.ye(n))return!1}return!0}static create(e,t,r){let n=new sS(new Uint8Array(Math.ceil(e/8)),e%8==0?0:8-e%8,t);return r.forEach(e=>n.insert(e)),n}insert(e){if(0===this.fe)return;let[t,r]=sT(s_(e));for(let e=0;e<this.hashCount;e++){let n=this.pe(t,r,e);this.we(n)}}we(e){let t=Math.floor(e/8);this.bitmap[t]|=1<<e%8}}class sx extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class sC{constructor(e,t,r,n,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=r,this.documentUpdates=n,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,r){let n=new Map;return n.set(e,sA.createSynthesizedTargetChangeForCurrentChange(e,t,r)),new sC(tq.min(),n,new nl(tb),iq,iH())}}class sA{constructor(e,t,r,n,i){this.resumeToken=e,this.current=t,this.addedDocuments=r,this.modifiedDocuments=n,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,r){return new sA(r,t,iH(),iH(),iH())}}class sD{constructor(e,t,r,n){this.Se=e,this.removedTargetIds=t,this.key=r,this.be=n}}class sN{constructor(e,t){this.targetId=e,this.De=t}}class sk{constructor(e,t,r=nm.EMPTY_BYTE_STRING,n=null){this.state=e,this.targetIds=t,this.resumeToken=r,this.cause=n}}class sO{constructor(){this.ve=0,this.Ce=sM(),this.Fe=nm.EMPTY_BYTE_STRING,this.Me=!1,this.xe=!0}get current(){return this.Me}get resumeToken(){return this.Fe}get Oe(){return 0!==this.ve}get Ne(){return this.xe}Be(e){e.approximateByteSize()>0&&(this.xe=!0,this.Fe=e)}Le(){let e=iH(),t=iH(),r=iH();return this.Ce.forEach((n,i)=>{switch(i){case 0:e=e.add(n);break;case 2:t=t.add(n);break;case 1:r=r.add(n);break;default:ti(38017,{changeType:i})}}),new sA(this.Fe,this.Me,e,t,r)}ke(){this.xe=!1,this.Ce=sM()}qe(e,t){this.xe=!0,this.Ce=this.Ce.insert(e,t)}Qe(e){this.xe=!0,this.Ce=this.Ce.remove(e)}$e(){this.ve+=1}Ue(){this.ve-=1,ta(this.ve>=0,3241,{ve:this.ve})}Ke(){this.xe=!0,this.Me=!0}}class sR{constructor(e){this.We=e,this.Ge=new Map,this.ze=iq,this.je=sL(),this.Je=sL(),this.He=new nl(tb)}Ye(e){for(let t of e.Se)e.be&&e.be.isFoundDocument()?this.Ze(t,e.be):this.Xe(t,e.key,e.be);for(let t of e.removedTargetIds)this.Xe(t,e.key,e.be)}et(e){this.forEachTarget(e,t=>{let r=this.tt(t);switch(e.state){case 0:this.nt(t)&&r.Be(e.resumeToken);break;case 1:r.Ue(),r.Oe||r.ke(),r.Be(e.resumeToken);break;case 2:r.Ue(),r.Oe||this.removeTarget(t);break;case 3:this.nt(t)&&(r.Ke(),r.Be(e.resumeToken));break;case 4:this.nt(t)&&(this.rt(t),r.Be(e.resumeToken));break;default:ti(56790,{state:e.state})}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Ge.forEach((e,r)=>{this.nt(r)&&t(r)})}it(e){let t=e.targetId,r=e.De.count,n=this.st(t);if(n){let d=n.target;if(ib(d))if(0===r){let e=new tD(d.path);this.Xe(t,e,n6.newNoDocument(e,tq.min()))}else ta(1===r,20013,{expectedCount:r});else{let n=this.ot(t);if(n!==r){var i,s,a,o,l,u,h,c;let r,d,f=this._t(e),p=f?this.ut(f,e,n):1;0!==p&&(this.rt(t),this.He=this.He.insert(t,2===p?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch")),null==sE||sE.ct((i=e.De,s=this.We.lt(),r
18={localCacheCount:n,existenceFilterCount:i.count,databaseId:s.database,projectId:s.projectId},(d=i.unchangedNames)&&(r.bloomFilter={applied:0===p,hashCount:null!=(a=null==d?void 0:d.hashCount)?a:0,bitmapLength:null!=(u=null==(l=null==(o=null==d?void 0:d.bits)?void 0:o.bitmap)?void 0:l.length)?u:0,padding:null!=(c=null==(h=null==d?void 0:d.bits)?void 0:h.padding)?c:0,mightContain:e=>{var t;return null!=(t=null==f?void 0:f.mightContain(e))&&t}}),r))}}}}_t(e){let t,r,n=e.De.unchangedNames;if(!n||!n.bits)return null;let{bits:{bitmap:i="",padding:s=0},hashCount:a=0}=n;try{t=nb(i).toUint8Array()}catch(e){if(e instanceof ng)return tr("Decoding the base64 bloom filter in existence filter failed ("+e.message+"); ignoring the bloom filter and falling back to full re-query."),null;throw e}try{r=new sS(t,s,a)}catch(e){return tr(e instanceof sx?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===r.fe?null:r}ut(e,t,r){return 2*(t.De.count!==r-this.ht(e,t.targetId))}ht(e,t){let r=this.We.getRemoteKeysForTarget(t),n=0;return r.forEach(r=>{let i=this.We.lt(),s=`projects/${i.projectId}/databases/${i.database}/documents/${r.path.canonicalString()}`;e.mightContain(s)||(this.Xe(t,r,null),n++)}),n}Pt(e){let t=new Map;this.Ge.forEach((r,n)=>{let i=this.st(n);if(i){if(r.current&&ib(i.target)){let t=new tD(i.target.path);this.Tt(t).has(n)||this.It(n,t)||this.Xe(n,t,n6.newNoDocument(t,e))}r.Ne&&(t.set(n,r.Le()),r.ke())}});let r=iH();this.Je.forEach((e,t)=>{let n=!0;t.forEachWhile(e=>{let t=this.st(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(n=!1,!1)}),n&&(r=r.add(e))}),this.ze.forEach((t,r)=>r.setReadTime(e));let n=new sC(e,t,this.He,this.ze,r);return this.ze=iq,this.je=sL(),this.Je=sL(),this.He=new nl(tb),n}Ze(e,t){if(!this.nt(e))return;let r=2*!!this.It(e,t.key);this.tt(e).qe(t.key,r),this.ze=this.ze.insert(t.key,t),this.je=this.je.insert(t.key,this.Tt(t.key).add(e)),this.Je=this.Je.insert(t.key,this.dt(t.key).add(e))}Xe(e,t,r){if(!this.nt(e))return;let n=this.tt(e);this.It(e,t)?n.qe(t,1):n.Qe(t),this.Je=this.Je.insert(t,this.dt(t).delete(e)),this.Je=this.Je.insert(t,this.dt(t).add(e)),r&&(this.ze=this.ze.insert(t,r))}removeTarget(e){this.Ge.delete(e)}ot(e){let t=this.tt(e).Le();return this.We.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.tt(e).$e()}tt(e){let t=this.Ge.get(e);return t||(t=new sO,this.Ge.set(e,t)),t}dt(e){let t=this.Je.get(e);return t||(t=new nc(tb),this.Je=this.Je.insert(e,t)),t}Tt(e){let t=this.je.get(e);return t||(t=new nc(tb),this.je=this.je.insert(e,t)),t}nt(e){let t=null!==this.st(e);return t||te("WatchChangeAggregator","Detected inactive target",e),t}st(e){let t=this.Ge.get(e);return t&&t.Oe?null:this.We.Et(e)}rt(e){this.Ge.set(e,new sO),this.We.getRemoteKeysForTarget(e).forEach(t=>{this.Xe(e,t,null)})}It(e,t){return this.We.getRemoteKeysForTarget(e).has(t)}}function sL(){return new nl(tD.comparator)}function sM(){return new nl(tD.comparator)}let sP={asc:"ASCENDING",desc:"DESCENDING"},sF={"<":"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"},sV={and:"AND",or:"OR"};class sB{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function sU(e,t){return e.useProto3Json||ro(t)?t:{value:t}}function sq(e,t){return e.useProto3Json?`${new Date(1e3*t.seconds).toISOString().replace(/\.\d*/,"").replace("Z","")}.${("000000000"+t.nanoseconds).slice(-9)}Z`:{seconds:""+t.seconds,nanos:t.nanoseconds}}function sj(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function sz(e){let t;return ta(!!e,49232),tq.fromTimestamp(new tU((t=nv(e)).seconds,t.nanos))}function s$(e,t){return sG(e,t).canonicalString()}function sG(e,t){let r=new tx(["projects",e.projectId,"databases",e.database]).child("documents");return void 0===t?r:r.child(t)}function sK(e){let t=tx.fromString(e);return ta(s9(t),10190,{key:t.toString()}),t}function sQ(e,t){return s$(e.databaseId,t.path)}function sH(e,t){let r=sK(t);if(r.get(1)!==e.databaseId.projectId)throw new tl(to.INVALID_ARGUMENT,"Tried to deserialize key from different project: "+r.get(1)+" vs "+e.databaseId.projectId);if(r.get(3)!==e.databaseId.database)throw new tl(to.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+r.get(3)+" vs "+e.databaseId.database);return new tD(sY(r))}function sW(e,t){return s$(e.databaseId,t)}function sX(e){let t=sK(e);return 4===t.length?tx.emptyPath():sY(t)}function sJ(e){return new tx(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function sY(e){return ta(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function sZ(e,t,r){return{name:sQ(e,t),fields:r.value.mapValue.fields}}function s0(e,t,r){let n=sH(e,t.name),i=sz(t.updateTime),s=t.createTime?sz(t.createTime):tq.min(),a=new n2({mapValue:{fields:t.fields}}),o=n6.newFoundDocument(n,i,s,a);return r&&o.setHasCommittedMutations(),r?o.setHasCommittedMutations():o}function s1(e,t){var r,n;let i;if(t instanceof so)i={update:sZ(e,t.key,t.value)};else if(t instanceof sd)i={delete:sQ(e,t.key)};else if(t instanceof sl){let r;i={update:sZ(e,t.key,t.data),updateMask:(n=t.fieldMask,r=[],n.fields.forEach(e
18=>r.push(e.canonicalString())),{fieldPaths:r})}}else{if(!(t instanceof sf))return ti(16599,{Rt:t.type});i={verify:sQ(e,t.key)}}return t.fieldTransforms.length>0&&(i.updateTransforms=t.fieldTransforms.map(e=>(function(e){let t=e.transform;if(t instanceof i1)return{fieldPath:e.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(t instanceof i2)return{fieldPath:e.field.canonicalString(),appendMissingElements:{values:t.elements}};if(t instanceof i3)return{fieldPath:e.field.canonicalString(),removeAllFromArray:{values:t.elements}};if(t instanceof i4)return{fieldPath:e.field.canonicalString(),increment:t.Ee};throw ti(20930,{transform:e.transform})})(e))),t.precondition.isNone||(i.currentDocument=void 0!==(r=t.precondition).updateTime?{updateTime:sq(e,r.updateTime.toTimestamp())}:void 0!==r.exists?{exists:r.exists}:ti(27497)),i}function s2(e,t){var r;let n=t.currentDocument?void 0!==(r=t.currentDocument).updateTime?st.updateTime(sz(r.updateTime)):void 0!==r.exists?st.exists(r.exists):st.none():st.none(),i=t.updateTransforms?t.updateTransforms.map(t=>{let r;return r=null,"setToServerValue"in t?(ta("REQUEST_TIME"===t.setToServerValue,16630,{proto:t}),r=new i1):"appendMissingElements"in t?r=new i2(t.appendMissingElements.values||[]):"removeAllFromArray"in t?r=new i3(t.removeAllFromArray.values||[]):"increment"in t?r=new i4(e,t.increment):ti(16584,{proto:t}),new i9(tA.fromServerFormat(t.fieldPath),r)}):[];if(t.update){t.update.name;let r=sH(e,t.update.name),s=new n2({mapValue:{fields:t.update.fields}});return t.updateMask?new sl(r,s,new np((t.updateMask.fieldPaths||[]).map(e=>tA.fromServerFormat(e))),n,i):new so(r,s,n,i)}return t.delete?new sd(sH(e,t.delete),n):t.verify?new sf(sH(e,t.verify),n):ti(1463,{proto:t})}function s6(e,t){return{documents:[sW(e,t.path)]}}function s3(e,t){var r,n;let i,s={structuredQuery:{}},a=t.path;null!==t.collectionGroup?(i=a,s.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=a.popLast(),s.structuredQuery.from=[{collectionId:a.lastSegment()}]),s.parent=sW(e,i);let o=function(e){if(0!==e.length)return function e(t){var r;let n;return t instanceof n9?function(e){if("=="===e.op){if(nH(e.value))return{unaryFilter:{field:s8(e.field),op:"IS_NAN"}};if(nQ(e.value))return{unaryFilter:{field:s8(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(nH(e.value))return{unaryFilter:{field:s8(e.field),op:"IS_NOT_NAN"}};if(nQ(e.value))return{unaryFilter:{field:s8(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:s8(e.field),op:sF[e.op],value:e.value}}}(t):t instanceof ie?1===(n=(r=t).getFilters().map(t=>e(t))).length?n[0]:{compositeFilter:{op:sV[r.op],filters:n}}:ti(54877,{filter:t})}(ie.create(e,"and"))}(t.filters);o&&(s.structuredQuery.where=o);let l=function(e){if(0!==e.length)return e.map(e=>({field:s8(e.field),direction:sP[e.dir]}))}(t.orderBy);l&&(s.structuredQuery.orderBy=l);let u=sU(e,t.limit);return null!==u&&(s.structuredQuery.limit=u),t.startAt&&(s.structuredQuery.startAt={before:(r=t.startAt).inclusive,values:r.position}),t.endAt&&(s.structuredQuery.endAt={before:!(n=t.endAt).inclusive,values:n.position}),{Vt:s,parent:i}}function s5(e,t,r,n){let{Vt:i,parent:s}=s3(e,t),a={},o=[],l=0;return r.forEach(e=>{let t=n?e.alias:"aggregate_"+l++;a[t]=e.alias,"count"===e.aggregateType?o.push({alias:t,count:{}}):"avg"===e.aggregateType?o.push({alias:t,avg:{field:s8(e.fieldPath)}}):"sum"===e.aggregateType&&o.push({alias:t,sum:{field:s8(e.fieldPath)}})}),{request:{structuredAggregationQuery:{aggregations:o,structuredQuery:i.structuredQuery},parent:i.parent},ft:a,parent:s}}function s4(e){var t,r,n;let i,s,a,o,l=sX(e.parent),u=e.structuredQuery,h=u.from?u.from.length:0,c=null;if(h>0){ta(1===h,65062);let e=u.from[0];e.allDescendants?c=e.collectionId:l=l.child(e.collectionId)}let d=[];u.where&&(d=(i=function e(t){return void 0!==t.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":let t=s7(e.unaryFilter.field);return n9.create(t,"==",{doubleValue:NaN});case"IS_NULL":let r=s7(e.unaryFilter.field);return n9.create(r,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":let n=s7(e.unaryFilter.field);return n9.create(n,"!=",{doubleValue:NaN});case"IS_NOT_NULL":let i=s7(e.unaryFilter.field);return n9.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return ti(61313);default:return ti(60726)}}(t):void 0!==t.fieldFilter?n9.create(s7(t.fieldFilter.field),function(e){switch(e){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";case"OPERATOR_UNSPECIFIED":return ti(58110);default:return ti(50506)}}(t.fieldFilter.op),t.fieldFilter.value):void 0!==t.compositeFilter?ie.create(t.compositeFilter.filters.map(t=>e(t)),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return ti(1026)}}(t.compositeFilter.op)):ti(30097,{filter:t})}(u.where))instanceof ie&&ii(i)?i.getFilters():[i]);let f=[];u.orderBy&&(f=u.orderBy.map(e=>new n8(s7(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))));let p=null;u.limit&&(p=ro(s="object"==typeof(t=u.limit)?t.value:t)?null:s);let g=null;u.startAt&&(a=!!(r=u.startAt).before,g=new n3(r.values||[],a));let m=null;return u.endAt&&(o=!(n=u.endAt).before,m=new n3(n.values||[],o)),new iT(l,c,f,d,p,"F",g,m)}function s8(e){return{fieldPath:e.canonicalString()}}function s7(e){return tA.fromServerFormat(e.fieldPath)}function s9(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}class ae{constructor(e,t,r,n,i=tq.min(),s=tq.min(),a=nm.EMPTY_BYTE_STRING,o=null){this.target=e,this.targetId=t,this.purpose=r,this.sequenceNumber=n,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=a,this.expectedCount=o}withSequenceNumber(e){return new ae(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new ae(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new ae(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new ae(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class at{constructor(e){this.gt=e}}function ar(e,t){let r=t.key,n={prefixPath:r.getCollectionPath().popLast().toArray(),collectionGroup:r.collectionGroup,documentId:r.path.lastSegment(),readTime:an(t.readTime),hasCommittedMutations:t.hasCommittedMutations};if(t.isFoundDocument()){var i;n.document={name:sQ(i=e.gt,t.key),fields:t.data.value.mapValue.fields,updateTime:sq(i,t.version.toTimestamp()),createTime:sq(i,t.createTime.toTimestamp())}}else if(t.isNoDocument())n.noDocument={path:r.path.toArray(),readTime:ai(t.version)};else{if(!t.isUnknownDocument())return ti(57904,{document:t});n.unknownDocument={path:r.path.toArray(),version:ai(t.version)}}return n}function an(e){let t=e.toTimestamp();return[t.seconds,t.nanoseconds]}function ai(e){let t=e.toTimestamp();return{seconds:t.seconds,nanoseconds:t.nanoseconds}}function as(e){let t=new tU(e.seconds,e.nanoseconds);return tq.fromTimestamp(t)}function aa(e,t){let r=(t.baseMutations||[]).map(t=>s2(e.gt,t));for(let e=0;e<t.mutations.length-1;++e){let r=t.mutations[e];e+1<t.mutations.length&&void 0!==t.mutations[e+1].transform&&(r.updateTransforms=t.mutations[e+1].transform.fieldTransforms,t.mutations.splice(e+1,1),++e)}let n=t.mutations.map(t=>s2(e.gt,t)),i=tU.fromMillis(t.localWriteTimeMs);return new sp(t.batchId,i,r,n)}function ao(e){var t;let r,n=as(e.readTime),i=void 0!==e.lastLimboFreeSnapshotVersion?as(e.lastLimboFreeSnapshotVersion):tq.min();return new ae(void 0!==e.query.documents?(ta(1===(r=(t=e.query).documents.length),1966,{count:r}),iD(iS(sX(t.documents[0])))):iD(s4(e.query)),e.targetId,"TargetPurposeListen",e.lastListenSequenceNumber,n,i,nm.fromBase64String(e.resumeToken))}function al(e,t){let r,n=ai(t.snapshotVersion),i=ai(t.lastLimboFreeSnapshotVersion);r=ib(t.target)?s6(e.gt,t.target):s3(e.gt,t.target).Vt;let s=t.resumeToken.toBase64();return{targetId:t.targetId,canonicalId:iv(t.target),readTime:n,resumeToken:s,lastListenSequenceNumber:t.sequenceNumber,lastLimboFreeSnapshotVersion:i,query:r}}function au(e){let t=s4({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?iR(t,t.limit,"L"):t}function ah(e,t){return new sm(t.largestBatchId,s2(e.gt,t.overlayMutation))}function ac(e,t){let r=t.path.lastSegment();return[e,rh(t.path.popLast()),r]}function ad(e,t,r,n){return{indexId:e,uid:t,sequenceNumber:r,readTime:ai(n.readTime),documentKey:rh(n.documentKey.path),largestBatchId:n.largestBatchId}}class af{getBundleMetadata(e,t){return nn(e,rj).get(t).next(e=>{if(e)return{id:e.bundleId,createTime:as(e.createTime),version:e.version}})}saveBundleMetadata(e,t){return nn(e,rj).put({bundleId:t.id,createTime:ai(sz(t.createTime)),version:t.version})}getNamedQuery(e,t){return nn(e,rz).get(t).next(e=>{if(e)return{name:e.name,query:au(e.bundledQuery),readTime:as(e.readTime)}})}saveNamedQuery(e,t){return nn(e,rz).put({name:t.name,readTime:ai(sz(t.readTime)),bundledQuery:t.bundledQuery})}}
18class ap{constructor(e,t){this.serializer=e,this.userId=t}static yt(e,t){return new ap(e,t.uid||"")}getOverlay(e,t){return nn(e,r0).get(ac(this.userId,t)).next(e=>e?ah(this.serializer,e):null)}getOverlays(e,t){let r=iG();return t1.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&r.set(t,e)})).next(()=>r)}saveOverlays(e,t,r){let n=[];return r.forEach((r,i)=>{let s=new sm(t,i);n.push(this.wt(e,s))}),t1.waitFor(n)}removeOverlaysForBatchId(e,t,r){let n=new Set;t.forEach(e=>n.add(rh(e.getCollectionPath())));let i=[];return n.forEach(t=>{let n=IDBKeyRange.bound([this.userId,t,r],[this.userId,t,r+1],!1,!0);i.push(nn(e,r0).Y(r2,n))}),t1.waitFor(i)}getOverlaysForCollection(e,t,r){let n=iG(),i=rh(t),s=IDBKeyRange.bound([this.userId,i,r],[this.userId,i,1/0],!0);return nn(e,r0).j(r2,s).next(e=>{for(let t of e){let e=ah(this.serializer,t);n.set(e.getKey(),e)}return n})}getOverlaysForCollectionGroup(e,t,r,n){let i,s=iG(),a=IDBKeyRange.bound([this.userId,t,r],[this.userId,t,1/0],!0);return nn(e,r0).X({index:r3,range:a},(e,t,r)=>{let a=ah(this.serializer,t);s.size()<n||a.largestBatchId===i?(s.set(a.getKey(),a),i=a.largestBatchId):r.done()}).next(()=>s)}wt(e,t){return nn(e,r0).put(function(e,t,r){let[n,i,s]=ac(t,r.mutation.key);return{userId:t,collectionPath:i,documentId:s,collectionGroup:r.mutation.key.getCollectionGroup(),largestBatchId:r.largestBatchId,overlayMutation:s1(e.gt,r.mutation)}}(this.serializer,this.userId,t))}}class ag{St(e){return nn(e,r4)}getSessionToken(e){return this.St(e).get("sessionToken").next(e=>{let t=null==e?void 0:e.value;return t?nm.fromUint8Array(t):nm.EMPTY_BYTE_STRING})}setSessionToken(e,t){return this.St(e).put({name:"sessionToken",value:t.toUint8Array()})}}class am{bt(e,t){this.Dt(e,t),t.vt()}Dt(e,t){if("nullValue"in e)this.Ct(t,5);else if("booleanValue"in e)this.Ct(t,10),t.Ft(+!!e.booleanValue);else if("integerValue"in e)this.Ct(t,15),t.Ft(nw(e.integerValue));else if("doubleValue"in e){let r=nw(e.doubleValue);isNaN(r)?this.Ct(t,13):(this.Ct(t,15),rl(r)?t.Ft(0):t.Ft(r))}else if("timestampValue"in e){let r=e.timestampValue;this.Ct(t,20),"string"==typeof r&&(r=nv(r)),t.Mt(`${r.seconds||""}`),t.Ft(r.nanos||0)}else if("stringValue"in e)this.xt(e.stringValue,t),this.Ot(t);else if("bytesValue"in e)this.Ct(t,30),t.Nt(nb(e.bytesValue)),this.Ot(t);else if("referenceValue"in e)this.Bt(e.referenceValue,t);else if("geoPointValue"in e){let r=e.geoPointValue;this.Ct(t,45),t.Ft(r.latitude||0),t.Ft(r.longitude||0)}else"mapValue"in e?nY(e)?this.Ct(t,Number.MAX_SAFE_INTEGER):nX(e)?this.Lt(e.mapValue,t):(this.kt(e.mapValue,t),this.Ot(t)):"arrayValue"in e?(this.qt(e.arrayValue,t),this.Ot(t)):ti(19022,{Qt:e})}xt(e,t){this.Ct(t,25),this.$t(e,t)}$t(e,t){t.Mt(e)}kt(e,t){let r=e.fields||{};for(let e of(this.Ct(t,55),Object.keys(r)))this.xt(e,t),this.Dt(r[e],t)}Lt(e,t){var r,n;let i=e.fields||{};this.Ct(t,53);let s=(null==(n=null==(r=i[nM].arrayValue)?void 0:r.values)?void 0:n.length)||0;this.Ct(t,15),t.Ft(nw(s)),this.xt(nM,t),this.Dt(i[nM],t)}qt(e,t){let r=e.values||[];for(let e of(this.Ct(t,50),r))this.Dt(e,t)}Bt(e,t){this.Ct(t,37),tD.fromName(e).path.forEach(e=>{this.Ct(t,60),this.$t(e,t)})}Ct(e,t){e.Ft(t)}Ot(e){e.Ft(2)}}function ay(e){return Math.ceil((64-function(e){let t=0;for(let r=0;r<8;++r){let n=function(e){if(0===e)return 8;let t=0;return e>>4||(t+=4,e<<=4),e>>6||(t+=2,e<<=2),e>>7||(t+=1),t}(255&e[r]);if(t+=n,8!==n)break}return t}(e))/8)}am.Ut=new am;class av{constructor(){this.buffer=new Uint8Array(1024),this.position=0}Kt(e){let t=e[Symbol.iterator](),r=t.next();for(;!r.done;)this.Wt(r.value),r=t.next();this.Gt()}zt(e){let t=e[Symbol.iterator](),r=t.next();for(;!r.done;)this.jt(r.value),r=t.next();this.Jt()}Ht(e){for(let t of e){let e=t.charCodeAt(0);if(e<128)this.Wt(e);else if(e<2048)this.Wt(960|e>>>6),this.Wt(128|63&e);else if(t<"\uD800"||"\uDBFF"<t)this.Wt(480|e>>>12),this.Wt(128|63&e>>>6),this.Wt(128|63&e);else{let e=t.codePointAt(0);this.Wt(240|e>>>18),this.Wt(128|63&e>>>12),this.Wt(128|63&e>>>6),this.Wt(128|63&e)}}this.Gt()}Yt(e){for(let t of e){let e=t.charCodeAt(0);if(e<128)this.jt(e);else if(e<2048)this.jt(960|e>>>6),this.jt(128|63&e);else if(t<"\uD800"||"\uDBFF"<t)this.jt(480|e>>>12),this.jt(128|63&e>>>6),this.jt(128|63&e);else{let e=t.codePointAt(0);this.jt(240|e>>>18),this.jt(128|63&e>>>12),this.jt(128|63&e>>>6),this.jt(128|63&e)}}this.Jt()}
18Zt(e){let t=this.Xt(e),r=ay(t);this.en(1+r),this.buffer[this.position++]=255&r;for(let e=t.length-r;e<t.length;++e)this.buffer[this.position++]=255&t[e]}tn(e){let t=this.Xt(e),r=ay(t);this.en(1+r),this.buffer[this.position++]=~(255&r);for(let e=t.length-r;e<t.length;++e)this.buffer[this.position++]=~(255&t[e])}nn(){this.rn(255),this.rn(255)}sn(){this._n(255),this._n(255)}reset(){this.position=0}seed(e){this.en(e.length),this.buffer.set(e,this.position),this.position+=e.length}an(){return this.buffer.slice(0,this.position)}Xt(e){let t,r=((t=new DataView(new ArrayBuffer(8))).setFloat64(0,e,!1),new Uint8Array(t.buffer)),n=!!(128&r[0]);r[0]^=n?255:128;for(let e=1;e<r.length;++e)r[e]^=255*!!n;return r}Wt(e){let t=255&e;0===t?(this.rn(0),this.rn(255)):255===t?(this.rn(255),this.rn(0)):this.rn(t)}jt(e){let t=255&e;0===t?(this._n(0),this._n(255)):255===t?(this._n(255),this._n(0)):this._n(e)}Gt(){this.rn(0),this.rn(1)}Jt(){this._n(0),this._n(1)}rn(e){this.en(1),this.buffer[this.position++]=e}_n(e){this.en(1),this.buffer[this.position++]=~e}en(e){let t=e+this.position;if(t<=this.buffer.length)return;let r=2*this.buffer.length;r<t&&(r=t);let n=new Uint8Array(r);n.set(this.buffer),this.buffer=n}}class aw{constructor(e){this.un=e}Nt(e){this.un.Kt(e)}Mt(e){this.un.Ht(e)}Ft(e){this.un.Zt(e)}vt(){this.un.nn()}}class ab{constructor(e){this.un=e}Nt(e){this.un.zt(e)}Mt(e){this.un.Yt(e)}Ft(e){this.un.tn(e)}vt(){this.un.sn()}}class aE{constructor(){this.un=new av,this.cn=new aw(this.un),this.ln=new ab(this.un)}seed(e){this.un.seed(e)}hn(e){return 0===e?this.cn:this.ln}an(){return this.un.an()}reset(){this.un.reset()}}class aI{constructor(e,t,r,n){this.Pn=e,this.Tn=t,this.In=r,this.dn=n}En(){let e=this.dn.length,t=0===e||255===this.dn[e-1]?e+1:e,r=new Uint8Array(t);return r.set(this.dn,0),t!==e?r.set([0],this.dn.length):++r[r.length-1],new aI(this.Pn,this.Tn,this.In,r)}An(e,t,r){return{indexId:this.Pn,uid:e,arrayValue:aS(this.In),directionalValue:aS(this.dn),orderedDocumentKey:aS(t),documentKey:r.path.toArray()}}Rn(e,t,r){let n=this.An(e,t,r);return[n.indexId,n.uid,n.arrayValue,n.directionalValue,n.orderedDocumentKey,n.documentKey]}}function a_(e,t){let r=e.Pn-t.Pn;return 0!==r||0!==(r=aT(e.In,t.In))||0!==(r=aT(e.dn,t.dn))?r:tD.comparator(e.Tn,t.Tn)}function aT(e,t){for(let r=0;r<e.length&&r<t.length;++r){let n=e[r]-t[r];if(0!==n)return n}return e.length-t.length}function aS(e){return G()?function(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}(e):e}function ax(e){return"string"!=typeof e?e:function(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}(e)}class aC{constructor(e){for(const t of(this.Vn=new nc((e,t)=>tA.comparator(e.field,t.field)),this.collectionId=null!=e.collectionGroup?e.collectionGroup:e.path.lastSegment(),this.mn=e.orderBy,this.fn=[],e.filters))t.isInequality()?this.Vn=this.Vn.add(t):this.fn.push(t)}get gn(){return this.Vn.size>1}pn(e){if(ta(e.collectionGroup===this.collectionId,49279),this.gn)return!1;let t=tz(e);if(void 0!==t&&!this.yn(t))return!1;let r=t$(e),n=new Set,i=0,s=0;for(;i<r.length&&this.yn(r[i]);++i)n=n.add(r[i].fieldPath.canonicalString());if(i===r.length)return!0;if(this.Vn.size>0){let e=this.Vn.getIterator().getNext();if(!n.has(e.field.canonicalString())){let t=r[i];if(!this.wn(e,t)||!this.Sn(this.mn[s++],t))return!1}++i}for(;i<r.length;++i){let e=r[i];if(s>=this.mn.length||!this.Sn(this.mn[s++],e))return!1}return!0}bn(){if(this.gn)return null;let e=new nc(tA.comparator),t=[];for(let r of this.fn)if(!r.field.isKeyField())if("array-contains"===r.op||"array-contains-any"===r.op)t.push(new tK(r.field,2));else{if(e.has(r.field))continue;e=e.add(r.field),t.push(new tK(r.field,0))}for(let r of this.mn)r.field.isKeyField()||e.has(r.field)||(e=e.add(r.field),t.push(new tK(r.field,+("asc"!==r.dir))));return new tj(tj.UNKNOWN_ID,this.collectionId,t,tQ.empty())}yn(e){for(let t of this.fn)if(this.wn(t,e))return!0;return!1}wn(e,t){if(void 0===e||!e.field.isEqual(t.fieldPath))return!1;let r="array-contains"===e.op||"array-contains-any"===e.op;return 2===t.kind===r}Sn(e,t){return!!e.field.isEqual(t.fieldPath)&&(0===t.kind&&"asc"===e.dir||1===t.kind&&"desc"===e.dir)}}function aA(e){return e instanceof n9}function aD(e){return e instanceof ie&&ii(e)}function aN(e){return aA(e)||aD(e)||function(e){if(e instanceof ie&&ir(e)){for(let t of e.getFilters())if(!aA(t)&&!aD(t))return!1;return!0}return!1}(e)}function ak(e,t){return ta(e instanceof n9||e instanceof ie,38388),ta(t instanceof n9||t instanceof ie,25473),aR(e instanceof n9?t instanceof n9?ie.create([e,t],"and"):aO(e,t):t instanceof n9?aO(t,e):function(e,t){if(ta(e.filters.length>0&&t.filters.length>0,48005),it(e)&&it(t))return ia(e,t.getFilters());let r=ir(e)?e:t,n=ir(e)?t:e,i=r.filters.map(e=>ak(e,n));return ie.create(i,"or")}(e,t))}function aO(e,t){if(it(t))return ia(t,e.getFilters());{let r=t.filters.map(t=>ak(e,t));return ie.create(r,"or")}}function aR(e){if(ta(e instanceof n9||e instanceof ie,11850),e instanceof n9)return e;let t=e.getFilters();if(1===t.length)return aR(t[0]);if(is(e))return e;let r=t.map(e=>aR(e)),n=[];return r.forEach(t=>{t instanceof n9?n.push(t):t instanceof ie&&(t.op===e.op?n.push(...t.filters):n.push(t))}),1===n.length?n[0]:ie.create(n,e.op)}class aL{constructor(){this.Dn=new aM}addToCollectionParentIndex(e,t){return this.Dn.add(t),t1.resolve()}getCollectionParents(e,t){return t1.resolve(this.Dn.getEntries(t))}addFieldIndex(e,t){return t1.resolve()}deleteFieldIndex(e,t){return t1.resolve()}deleteAllFieldIndexes(e){return t1.resolve()}createTargetIndexes(e,t){return t1.resolve()}getDocumentsMatchingTarget(e,t){return t1.resolve(null)}getIndexType(e,t){return t1.resolve(0)}getFieldIndexes(e,t){return t1.resolve([])}getNextCollectionGroupToUpdate(e){return t1.resolve(null)}getMinOffset(e,t){return t1.resolve(tX.min())}getMinOffsetFromCollectionGroup(e,t){return t1.resolve(tX.min())}updateCollectionGroup(e,t,r){return t1.resolve()}updateIndexEntries(e,t){return t1.resolve()}}class aM{constructor(){this.index={}}add(e){let t=e.lastSegment(),r=e.popLast(),n=this.index[t]||new nc(tx.comparator),i=!n.has(r);return this.index[t]=n.add(r),i}has(e){let t=e.lastSegment(),r=e.popLast(),n=this.index[t];return n&&n.has(r)}getEntries(e){return(this.index[e]||new nc(tx.comparator)).toArray()}}let aP="IndexedDbIndexManager",aF=new Uint8Array(0);class aV{constructor(e,t){this.databaseId=t,this.vn=new aM,this.Cn=new iU(e=>
18iv(e),(e,t)=>iw(e,t)),this.uid=e.uid||""}addToCollectionParentIndex(e,t){if(!this.vn.has(t)){let r=t.lastSegment(),n=t.popLast();e.addOnCommittedListener(()=>{this.vn.add(t)});let i={collectionId:r,parent:rh(n)};return nn(e,rB).put(i)}return t1.resolve()}getCollectionParents(e,t){let r=[],n=IDBKeyRange.bound([t,""],[t+"\0",""],!1,!0);return nn(e,rB).j(n).next(e=>{for(let n of e){if(n.collectionId!==t)break;r.push(rc(n.parent))}return r})}addFieldIndex(e,t){let r=nn(e,r$),n={indexId:t.indexId,collectionGroup:t.collectionGroup,fields:t.fields.map(e=>[e.fieldPath.canonicalString(),e.kind])};delete n.indexId;let i=r.add(n);if(t.indexState){let r=nn(e,rK);return i.next(e=>{r.put(ad(e,this.uid,t.indexState.sequenceNumber,t.indexState.offset))})}return i.next()}deleteFieldIndex(e,t){let r=nn(e,r$),n=nn(e,rK),i=nn(e,rX);return r.delete(t.indexId).next(()=>n.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0))).next(()=>i.delete(IDBKeyRange.bound([t.indexId],[t.indexId+1],!1,!0)))}deleteAllFieldIndexes(e){let t=nn(e,r$),r=nn(e,rX),n=nn(e,rK);return t.Y().next(()=>r.Y()).next(()=>n.Y())}createTargetIndexes(e,t){return t1.forEach(this.Fn(t),t=>this.getIndexType(e,t).next(r=>{if(0===r||1===r){let r=new aC(t).bn();if(null!=r)return this.addFieldIndex(e,r)}}))}getDocumentsMatchingTarget(e,t){let r=nn(e,rX),n=!0,i=new Map;return t1.forEach(this.Fn(t),t=>this.Mn(e,t).next(e=>{n&&(n=!!e),i.set(t,e)})).next(()=>{if(n){let e=iH(),n=[];return t1.forEach(i,(i,s)=>{te(aP,`Using index id=${i.indexId}|cg=${i.collectionGroup}|f=${i.fields.map(e=>`${e.fieldPath}:${e.kind}`).join(",")} to execute ${iv(t)}`);let a=function(e,t){let r=tz(t);if(void 0===r)return null;for(let t of iE(e,r.fieldPath))switch(t.op){case"array-contains-any":return t.value.arrayValue.values||[];case"array-contains":return[t.value]}return null}(s,i),o=function(e,t){let r=new Map;for(let n of t$(t))for(let t of iE(e,n.fieldPath))switch(t.op){case"==":case"in":r.set(n.fieldPath.canonicalString(),t.value);break;case"not-in":case"!=":return r.set(n.fieldPath.canonicalString(),t.value),Array.from(r.values())}return null}(s,i),l=function(e,t){let r=[],n=!0;for(let i of t$(t)){let t=0===i.kind?iI(e,i.fieldPath,e.startAt):i_(e,i.fieldPath,e.startAt);r.push(t.value),n&&(n=t.inclusive)}return new n3(r,n)}(s,i),u=function(e,t){let r=[],n=!0;for(let i of t$(t)){let t=0===i.kind?i_(e,i.fieldPath,e.endAt):iI(e,i.fieldPath,e.endAt);r.push(t.value),n&&(n=t.inclusive)}return new n3(r,n)}(s,i),h=this.xn(i,s,l),c=this.xn(i,s,u),d=this.On(i,s,o),f=this.Nn(i.indexId,a,h,l.inclusive,c,u.inclusive,d);return t1.forEach(f,i=>r.H(i,t.limit).next(t=>{t.forEach(t=>{let r=tD.fromSegments(t.documentKey);e.has(r)||(e=e.add(r),n.push(r))})}))}).next(()=>n)}return t1.resolve(null)})}Fn(e){let t=this.Cn.get(e);return t||(t=0===e.filters.length?[e]:(function(e){if(0===e.getFilters().length)return[];let t=function e(t){if(ta(t instanceof n9||t instanceof ie,34018),t instanceof n9)return t;if(1===t.filters.length)return e(t.filters[0]);let r=t.filters.map(t=>e(t)),n=ie.create(r,t.op);return aN(n=aR(n))?n:(ta(n instanceof ie,64498),ta(it(n),40251),ta(n.filters.length>1,57927),n.filters.reduce((e,t)=>ak(e,t)))}(function e(t){var r,n;if(ta(t instanceof n9||t instanceof ie,20012),t instanceof n9){if(t instanceof id){let e=(null==(n=null==(r=t.value.arrayValue)?void 0:r.values)?void 0:n.map(e=>n9.create(t.field,"==",e)))||[];return ie.create(e,"or")}return t}let i=t.filters.map(t=>e(t));return ie.create(i,t.op)}(e));return ta(aN(t),7391),aA(t)||aD(t)?[t]:t.getFilters()})(ie.create(e.filters,"and")).map(t=>iy(e.path,e.collectionGroup,e.orderBy,t.getFilters(),e.limit,e.startAt,e.endAt)),this.Cn.set(e,t)),t}Nn(e,t,r,n,i,s,a){let o=(null!=t?t.length:1)*Math.max(r.length,i.length),l=o/(null!=t?t.length:1),u=[];for(let h=0;h<o;++h){let o=t?this.Bn(t[h/l]):aF,c=this.Ln(e,o,r[h%l],n),d=this.kn(e,o,i[h%l],s),f=a.map(t=>this.Ln(e,o,t,!0));u.push(...this.createRange(c,d,f))}return u}Ln(e,t,r,n){let i=new aI(e,tD.empty(),t,r);return n?i:i.En()}kn(e,t,r,n){let i=new aI(e,tD.empty(),t,r);return n?i.En():i}Mn(e,t){let r=new aC(t),n=null!=t.collectionGroup?t.collectionGroup:t.path.lastSegment();return this.getFieldIndexes(e,n).next(e=>{let t=null;for(let n of e)r.pn(n)&&(!t||n.fields.length>t.fields.length)&&(t=n);return t})}getIndexType(e,t){let r=2,n=this.Fn(t);
18return t1.forEach(n,t=>this.Mn(e,t).next(e=>{e?0!==r&&e.fields.length<function(e){let t=new nc(tA.comparator),r=!1;for(let n of e.filters)for(let e of n.getFlattenedFilters())e.field.isKeyField()||("array-contains"===e.op||"array-contains-any"===e.op?r=!0:t=t.add(e.field));for(let r of e.orderBy)r.field.isKeyField()||(t=t.add(r.field));return t.size+ +!!r}(t)&&(r=1):r=0})).next(()=>null!==t.limit&&n.length>1&&2===r?1:r)}qn(e,t){let r=new aE;for(let n of t$(e)){let e=t.data.field(n.fieldPath);if(null==e)return null;let i=r.hn(n.kind);am.Ut.bt(e,i)}return r.an()}Bn(e){let t=new aE;return am.Ut.bt(e,t.hn(0)),t.an()}Qn(e,t){let r,n=new aE;return am.Ut.bt(n$(this.databaseId,t),n.hn(0===(r=t$(e)).length?0:r[r.length-1].kind)),n.an()}On(e,t,r){if(null===r)return[];let n=[];n.push(new aE);let i=0;for(let s of t$(e)){let e=r[i++];for(let r of n)if(this.$n(t,s.fieldPath)&&nK(e))n=this.Un(n,s,e);else{let t=r.hn(s.kind);am.Ut.bt(e,t)}}return this.Kn(n)}xn(e,t,r){return this.On(e,t,r.position)}Kn(e){let t=[];for(let r=0;r<e.length;++r)t[r]=e[r].an();return t}Un(e,t,r){let n=[...e],i=[];for(let e of r.arrayValue.values||[])for(let r of n){let n=new aE;
18n.seed(r.an()),am.Ut.bt(e,n.hn(t.kind)),i.push(n)}return i}$n(e,t){return!!e.filters.find(e=>e instanceof n9&&e.field.isEqual(t)&&("in"===e.op||"not-in"===e.op))}getFieldIndexes(e,t){let r=nn(e,r$),n=nn(e,rK);return(t?r.j(rG,IDBKeyRange.bound(t,t)):r.j()).next(e=>{let t=[];return t1.forEach(e,e=>n.get([e.indexId,this.uid]).next(r=>{let n,i;t.push((n=r?new tQ(r.sequenceNumber,new tX(as(r.readTime),new tD(rc(r.documentKey)),r.largestBatchId)):tQ.empty(),i=e.fields.map(([e,t])=>new tK(tA.fromServerFormat(e),t)),new tj(e.indexId,e.collectionGroup,i,n)))})).next(()=>t)})}getNextCollectionGroupToUpdate(e){return this.getFieldIndexes(e).next(e=>0===e.length?null:(e.sort((e,t)=>{let r=e.indexState.sequenceNumber-t.indexState.sequenceNumber;return 0!==r?r:tb(e.collectionGroup,t.collectionGroup)}),e[0].collectionGroup))}updateCollectionGroup(e,t,r){let n=nn(e,r$),i=nn(e,rK);return this.Wn(e).next(e=>n.j(rG,IDBKeyRange.bound(t,t)).next(t=>t1.forEach(t,t=>i.put(ad(t.indexId,this.uid,e,r)))))}updateIndexEntries(e,t){let r=new Map;return t1.forEach(t,(t,n)=>{let i=r.get(t.collectionGroup);return(i?t1.resolve(i):this.getFieldIndexes(e,t.collectionGroup)).next(i=>(r.set(t.collectionGroup,i),t1.forEach(i,r=>this.Gn(e,t,r).next(t=>{let i=this.zn(n,r);return t.isEqual(i)?t1.resolve():this.jn(e,n,r,t,i)}))))})}Jn(e,t,r,n){return nn(e,rX).put(n.An(this.uid,this.Qn(r,t.key),t.key))}Hn(e,t,r,n){return nn(e,rX).delete(n.Rn(this.uid,this.Qn(r,t.key),t.key))}Gn(e,t,r){let n=nn(e,rX),i=new nc(a_);return n.X({index:rY,range:IDBKeyRange.only([r.indexId,this.uid,aS(this.Qn(r,t))])},(e,n)=>{i=i.add(new aI(r.indexId,t,ax(n.arrayValue),ax(n.directionalValue)))}).next(()=>i)}zn(e,t){let r=new nc(a_),n=this.qn(t,e);if(null==n)return r;let i=tz(t);if(null!=i){let s=e.data.field(i.fieldPath);if(nK(s))for(let i of s.arrayValue.values||[])r=r.add(new aI(t.indexId,e.key,this.Bn(i),n))}else r=r.add(new aI(t.indexId,e.key,aF,n));return r}jn(e,t,r,n,i){te(aP,"Updating index entries for document '%s'",t.key);let s=[];return function(e,t,r,n,i){let s=e.getIterator(),a=t.getIterator(),o=nf(s),l=nf(
18a);for(;o||l;){let e=!1,t=!1;if(o&&l){let n=r(o,l);n<0?t=!0:n>0&&(e=!0)}else null!=o?t=!0:e=!0;e?(n(l),l=nf(a)):t?(i(o),o=nf(s)):(o=nf(s),l=nf(a))}}(n,i,a_,n=>{s.push(this.Jn(e,t,r,n))},n=>{s.push(this.Hn(e,t,r,n))}),t1.waitFor(s)}Wn(e){let t=1;return nn(e,rK).X({index:rH,reverse:!0,range:IDBKeyRange.upperBound([this.uid,Number.MAX_SAFE_INTEGER])},(e,r,n)=>{n.done(),t=r.sequenceNumber+1}).next(()=>t)}createRange(e,t,r){r=r.sort((e,t)=>a_(e,t)).filter((e,t,r)=>!t||0!==a_(e,r[t-1]));let n=[];for(let i of(n.push(e),r)){let r=a_(i,e),s=a_(i,t);if(0===r)n[0]=e.En();else if(r>0&&s<0)n.push(i),n.push(i.En());else if(s>0)break}n.push(t);let i=[];for(let e=0;e<n.length;e+=2){if(this.Yn(n[e],n[e+1]))return[];let t=n[e].Rn(this.uid,aF,tD.empty()),r=n[e+1].Rn(this.uid,aF,tD.empty());i.push(IDBKeyRange.bound(t,r))}return i}Yn(e,t){return a_(e,t)>0}getMinOffsetFromCollectionGroup(e,t){return this.getFieldIndexes(e,t).next(aB)}getMinOffset(e,t){return t1.mapArray(this.Fn(t),t=>this.Mn(e,t).next(e=>e||ti(44426))).next(aB)}}function aB(e){ta(0!==e.length,28825);let t=e[0].indexState.offset,r=t.largestBatchId;for(let n=1;n<e.length;n++){let i=e[n].indexState.offset;0>tJ(i,t)&&(t=i),r<i.largestBatchId&&(r=i.largestBatchId)}return new tX(t.readTime,t.documentKey,r)}let aU={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0};class aq{static withCacheSize(e){return new aq(e,aq.DEFAULT_COLLECTION_PERCENTILE,aq.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,r){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=r}}function aj(e,t,r){let n=e.store(rm),i=e.store(rE),s=[],a=IDBKeyRange.only(r.batchId),o=0,l=n.X({range:a},(e,t,r)=>(o++,r.delete()));s.push(l.next(()=>{ta(1===o,47070,{batchId:r.batchId})}));let u=[];for(let e of r.mutations){var h,c;let n=(h=e.key.path,c=r.batchId,[t,rh(h),c]);s.push(i.delete(n)),u.push(e.key)}return t1.waitFor(s).next(()=>u)}function az(e){let t;if(!e)return 0;if(e.document)t=e.document;else if(e.unknownDocument)t=e.unknownDocument;else{if(!e.noDocument)throw ti(14731);t=e.noDocument}return JSON.stringify(t).length}aq.DEFAULT_COLLECTION_PERCENTILE=10,aq.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,aq.DEFAULT=new aq(0x2800000,aq.DEFAULT_COLLECTION_PERCENTILE,aq.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),aq.DISABLED=new aq(-1,0,0);class a${constructor(e,t,r,n){this.userId=e,this.serializer=t,this.indexManager=r,this.referenceDelegate=n,this.Zn={}}static yt(e,t,r,n){return ta(""!==e.uid,64387),new a$(e.isAuthenticated()?e.uid:"",t,r,n)}checkEmpty(e){let t=!0,r=IDBKeyRange.bound([this.userId,-1/0],[this.userId,1/0]);return aK(e).X({index:rv,range:r},(e,r,n)=>{t=!1,n.done()}).next(()=>t)}addMutationBatch(e,t,r,n){let i=nn(e,rE),s=aK(e);return s.add({}).next(a=>{var o,l,u,h;let c,d;ta("number"==typeof a,49019);let f=new sp(a,t,r,n),p=(o=this.serializer,l=this.userId,c=f.baseMutations.map(e=>s1(o.gt,e)),d=f.mutations.map(e=>s1(o.gt,e)),{userId:l,batchId:f.batchId,localWriteTimeMs:f.localWriteTime.toMillis(),baseMutations:c,mutations:d}),g=[],m=new nc((e,t)=>tb(e.canonicalString(),t.canonicalString()));for(let e of n){let t=(u=this.userId,h=e.key.path,[u,rh(h),a]);m=m.add(e.key.path.popLast()),g.push(s.put(p)),g.push(i.put(t,rb))}return m.forEach(t=>{g.push(this.indexManager.addToCollectionParentIndex(e,t))}),e.addOnCommittedListener(()=>{this.Zn[a]=f.keys()}),t1.waitFor(g).next(()=>f)})}lookupMutationBatch(e,t){return aK(e).get(t).next(e=>e?(ta(e.userId===this.userId,48,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),aa(this.serializer,e)):null)}Xn(e,t){return this.Zn[t]?t1.resolve(this.Zn[t]):this.lookupMutationBatch(e,t).next(e=>{if(e){let r=e.keys();return this.Zn[t]=r,r}return null})}getNextMutationBatchAfterBatchId(e,t){let r=t+1,n=IDBKeyRange.lowerBound([this.userId,r]),i=null;return aK(e).X({index:rv,range:n},(e,t,n)=>{t.userId===this.userId&&(ta(t.batchId>=r,47524,{er:r}),i=aa(this.serializer,t)),n.done()}).next(()=>i)}getHighestUnacknowledgedBatchId(e){let t=IDBKeyRange.upperBound([this.userId,1/0]),r=-1;return aK(e).X({index:rv,range:t,reverse:!0},(e,t,n)=>{r=t.batchId,n.done()}).next(()=>r)}getAllMutationBatches(e){let t=IDBKeyRange.bound([this.userId,-1],[this.userId,1/0]);return aK(e).j(rv,t).next(e=>e.map(e=>aa(this.serializer,e)))}getAllMutationBatchesAffectingDocumentKey(e,t){let r=[this.userId,rh(t.path)],n=IDBKeyRange.lowerBound(r),i=[];return nn(e,rE).X({range:n},(r,n,s)=>{let[a,o,l]=r,u=rc(o);if(a===this.userId&&t.path.isEqual(u))return aK(e).get(l).next(e=>{if(!e)throw ti(61480,{tr:r,batchId:l});ta(e.userId===this.userId,10503,"Unexpected user for mutation batch",{userId:e.userId,batchId:l}),i.push(aa(this.serializer,e))});s.done()}).next(()=>i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new nc(tb),n=[];return t.forEach(t=>{let i=[this.userId,rh(t.path)],s=IDBKeyRange.lowerBound(i),a=nn(e,rE).X({range:s},(e,n,i)=>{let[s,a,o]=e,l=rc(a);s===this.userId&&t.path.isEqual(l)?r=r.add(o):i.done()});n.push(a)}),t1.waitFor(n).next(()=>this.nr(e,r))}getAllMutationBatchesAffectingQuery(e,t){let r=t.path,n=r.length+1,i=[this.userId,rh(r)],s=IDBKeyRange.lowerBound(i),a=new nc(tb);return nn(e,rE).X({range:s},(e,t,i)=>{let[s,o,l]=e,u=rc(o);s===this.userId&&r.isPrefixOf(u)?u.length===n&&(a=a.add(l)):i.done()}).next(()=>this.nr(e,a))}nr(e,t){let r=[],n=[];return t.forEach(t=>{n.push(aK(e).get(t).next(e=>{if(null===e)throw ti(35274,{batchId:t});ta(e.userId===this.userId,9748,"Unexpected user for mutation batch",{userId:e.userId,batchId:t}),r.push(aa(this.serializer,e))}))}),t1.waitFor(n).next(()=>r)}removeMutationBatch(e,t){return aj(e.ce,this.userId,t).next(r=>(e.addOnCommittedListener(()=>{this.rr(t.batchId)}
18),t1.forEach(r,t=>this.referenceDelegate.markPotentiallyOrphaned(e,t))))}rr(e){delete this.Zn[e]}performConsistencyCheck(e){return this.checkEmpty(e).next(t=>{if(!t)return t1.resolve();let r=IDBKeyRange.lowerBound([this.userId]),n=[];return nn(e,rE).X({range:r},(e,t,r)=>{if(e[0]===this.userId){let t=rc(e[1]);n.push(t)}else r.done()}).next(()=>{ta(0===n.length,56720,{ir:n.map(e=>e.canonicalString())})})})}containsKey(e,t){return aG(e,this.userId,t)}sr(e){return nn(e,rg).get(this.userId).next(e=>e||{userId:this.userId,lastAcknowledgedBatchId:-1,lastStreamToken:""})}}function aG(e,t,r){let n=[t,rh(r.path)],i=n[1],s=IDBKeyRange.lowerBound(n),a=!1;return nn(e,rE).X({range:s,Z:!0},(e,r,n)=>{let[s,o,l]=e;s===t&&o===i&&(a=!0),n.done()}).next(()=>a)}function aK(e){return nn(e,rm)}class aQ{constructor(e){this._r=e}next(){return this._r+=2,this._r}static ar(){return new aQ(0)}static ur(){return new aQ(-1)}}class aH{constructor(e,t){this.referenceDelegate=e,this.serializer=t}allocateTargetId(e){return this.cr(e).next(t=>{let r=new aQ(t.highestTargetId);return t.highestTargetId=r.next(),this.lr(e,t).next(()=>t.highestTargetId)})}getLastRemoteSnapshotVersion(e){return this.cr(e).next(e=>tq.fromTimestamp(new tU(e.lastRemoteSnapshotVersion.seconds,e.lastRemoteSnapshotVersion.nanoseconds)))}getHighestSequenceNumber(e){return this.cr(e).next(e=>e.highestListenSequenceNumber)}setTargetsMetadata(e,t,r){return this.cr(e).next(n=>(n.highestListenSequenceNumber=t,r&&(n.lastRemoteSnapshotVersion=r.toTimestamp()),t>n.highestListenSequenceNumber&&(n.highestListenSequenceNumber=t),this.lr(e,n)))}addTargetData(e,t){return this.hr(e,t).next(()=>this.cr(e).next(r=>(r.targetCount+=1,this.Pr(t,r),this.lr(e,r))))}updateTargetData(e,t){return this.hr(e,t)}removeTargetData(e,t){return this.removeMatchingKeysForTargetId(e,t.targetId).next(()=>nn(e,rN).delete(t.targetId)).next(()=>this.cr(e)).next(t=>(ta(t.targetCount>0,8065),t.targetCount-=1,this.lr(e,t)))}removeTargets(e,t,r){let n=0,i=[];return nn(e,rN).X((s,a)=>{let o=ao(a);o.sequenceNumber<=t&&null===r.get(o.targetId)&&(n++,i.push(this.removeTargetData(e,o)))}).next(()=>t1.waitFor(i)).next(()=>n)}forEachTarget(e,t){return nn(e,rN).X((e,r)=>{t(ao(r))})}cr(e){return nn(e,rV).get(rF).next(e=>(ta(null!==e,2888),e))}lr(e,t){return nn(e,rV).put(rF,t)}hr(e,t){return nn(e,rN).put(al(this.serializer,t))}Pr(e,t){let r=!1;return e.targetId>t.highestTargetId&&(t.highestTargetId=e.targetId,r=!0),e.sequenceNumber>t.highestListenSequenceNumber&&(t.highestListenSequenceNumber=e.sequenceNumber,r=!0),r}getTargetCount(e){return this.cr(e).next(e=>e.targetCount)}getTargetData(e,t){let r=iv(t),n=IDBKeyRange.bound([r,-1/0],[r,1/0]),i=null;return nn(e,rN).X({range:n,index:rk},(e,r,n)=>{let s=ao(r);iw(t,s.target)&&(i=s,n.done())}).next(()=>i)}addMatchingKeys(e,t,r){let n=[],i=aW(e);return t.forEach(t=>{let s=rh(t.path);n.push(i.put({targetId:r,path:s})),n.push(this.referenceDelegate.addReference(e,r,t))}),t1.waitFor(n)}removeMatchingKeys(e,t,r){let n=aW(e);return t1.forEach(t,t=>{let i=rh(t.path);return t1.waitFor([n.delete([r,i]),this.referenceDelegate.removeReference(e,r,t)])})}removeMatchingKeysForTargetId(e,t){let r=aW(e),n=IDBKeyRange.bound([t],[t+1],!1,!0);return r.delete(n)}getMatchingKeysForTargetId(e,t){let r=IDBKeyRange.bound([t],[t+1],!1,!0),n=aW(e),i=iH();return n.X({range:r,Z:!0},(e,t,r)=>{let n=new tD(rc(e[1]));i=i.add(n)}).next(()=>i)}containsKey(e,t){let r=rh(t.path),n=IDBKeyRange.bound([r],[r+"\0"],!1,!0),i=0;return aW(e).X({index:rM,Z:!0,range:n},([e,t],r,n)=>{0!==e&&(i++,n.done())}).next(()=>i>0)}Et(e,t){return nn(e,rN).get(t).next(e=>e?ao(e):null)}}function aW(e){return nn(e,rR)}let aX="LruGarbageCollector";function aJ([e,t],[r,n]){let i=tb(e,r);return 0===i?tb(t,n):i}class aY{constructor(e){this.Tr=e,this.buffer=new nc(aJ),this.Ir=0}dr(){return++this.Ir}Er(e){let t=[e,this.dr()];if(this.buffer.size<this.Tr)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();0>aJ(t,e)&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class aZ{constructor(e,t,r){this.garbageCollector=e,this.asyncQueue=t,this.localStore=r,this.Ar=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Rr(6e4)}stop(){this.Ar&&(this.Ar.cancel(),this.Ar=null)}get started(){return null!==this.Ar}Rr(e){te(aX,`Garbage collection scheduled in ${e}ms`),this.Ar=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Ar=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){t7(e)?te(aX,"Ignoring IndexedDB error during garbage collection: ",e):await t0(e)}await this.Rr(3e5)})}}class a0{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.mr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return t1.resolve(ra.ue);let r=new aY(t);return this.Vr.forEachTarget(e,e=>r.Er(e.sequenceNumber)).next(()=>this.Vr.gr(e,e=>r.Er(e))).next(()=>r.maxValue)}removeTargets(e,t,r){return this.Vr.removeTargets(e,t,r)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return -1===this.params.cacheSizeCollectionThreshold?(te("LruGarbageCollector","Garbage collection skipped; disabled"),t1.resolve(aU)):this.getCacheSize(e).next(r=>r<this.params.cacheSizeCollectionThreshold?(te("LruGarbageCollector",`Garbage collection skipped; Cache size ${r} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),aU):this.pr(e,t))}getCacheSize(e){return this.Vr.getCacheSize(e)}pr(e,t){let r,n,i,a,o,l,u,h=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(t=>(t>this.params.maximumSequenceNumbersToCollect?(te("LruGarbageCollector",`C
18apping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),n=this.params.maximumSequenceNumbersToCollect):n=t,a=Date.now(),this.nthSequenceNumber(e,n))).next(n=>(r=n,o=Date.now(),this.removeTargets(e,r,t))).next(t=>(i=t,l=Date.now(),this.removeOrphanedDocuments(e,r))).next(e=>(u=Date.now(),e9()<=s.DEBUG&&te("LruGarbageCollector",`LRU Garbage Collection
19	Counted targets in ${a-h}ms
20	Determined least recently used ${n} in `+(o-a)+"ms\n"+`	Removed ${i} targets in `+(l-o)+"ms\n"+`	Removed ${e} documents in `+(u-l)+"ms\n"+`Total Duration: ${u-h}ms`),t1.resolve({didRun:!0,sequenceNumbersCollected:n,targetsRemoved:i,documentsRemoved:e})))}}class a1{constructor(e,t){this.db=e,this.garbageCollector=function(e,t){return new a0(e,t)}(this,t)}mr(e){let t=this.yr(e);return this.db.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}yr(e){let t=0;return this.gr(e,e=>{t++}).next(()=>t)}forEachTarget(e,t){return this.db.getTargetCache().forEachTarget(e,t)}gr(e,t){return this.wr(e,(e,r)=>t(r))}addReference(e,t,r){return a2(e,r)}removeReference(e,t,r){return a2(e,r)}removeTargets(e,t,r){return this.db.getTargetCache().removeTargets(e,t,r)}markPotentiallyOrphaned(e,t){return a2(e,t)}Sr(e,t){let r;return r=!1,nn(e,rg).ee(n=>aG(e,n,t).next(e=>(e&&(r=!0),t1.resolve(!e)))).next(()=>r)}removeOrphanedDocuments(e,t){let r=this.db.getRemoteDocumentCache().newChangeBuffer(),n=[],i=0;return this.wr(e,(s,a)=>{if(a<=t){let t=this.Sr(e,s).next(t=>{if(!t)return i++,r.getEntry(e,s).next(()=>(r.removeEntry(s,tq.min()),aW(e).delete([0,rh(s.path)])))});n.push(t)}}).next(()=>t1.waitFor(n)).next(()=>r.apply(e)).next(()=>i)}removeTarget(e,t){let r=t.withSequenceNumber(e.currentSequenceNumber);return this.db.getTargetCache().updateTargetData(e,r)}updateLimboDocument(e,t){return a2(e,t)}wr(e,t){let r=aW(e),n,i=ra.ue;return r.X({index:rM},([e,r],{path:s,sequenceNumber:a})=>{0===e?(i!==ra.ue&&t(new tD(rc(n)),i),i=a,n=s):i=ra.ue}).next(()=>{i!==ra.ue&&t(new tD(rc(n)),i)})}getCacheSize(e){return this.db.getRemoteDocumentCache().getSize(e)}}function a2(e,t){var r;return aW(e).put((r=e.currentSequenceNumber,{targetId:0,path:rh(t.path),sequenceNumber:r}))}class a6{constructor(){this.changes=new iU(e=>e.toString(),(e,t)=>e.isEqual(t)),this.changesApplied=!1}addEntry(e){this.assertNotApplied(),this.changes.set(e.key,e)}removeEntry(e,t){this.assertNotApplied(),this.changes.set(e,n6.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let r=this.changes.get(t);return void 0!==r?t1.resolve(r):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}}class a3{constructor(e){this.serializer=e}setIndexManager(e){this.indexManager=e}addEntry(e,t,r){return nn(e,rI).put(r)}removeEntry(e,t,r){let n;return nn(e,rI).delete([(n=t.path.toArray()).slice(0,n.length-2),n[n.length-2],an(r),n[n.length-1]])}updateMetadata(e,t){return this.getMetadata(e).next(r=>(r.byteSize+=t,this.br(e,r)))}getEntry(e,t){let r=n6.newInvalidDocument(t);return nn(e,rI).X({index:rT,range:IDBKeyRange.only(a4(t))},(e,n)=>{r=this.Dr(t,n)}).next(()=>r)}vr(e,t){let r={size:0,document:n6.newInvalidDocument(t)};return nn(e,rI).X({index:rT,range:IDBKeyRange.only(a4(t))},(e,n)=>{r={document:this.Dr(t,n),size:az(n)}}).next(()=>r)}getEntries(e,t){let r=iq;return this.Cr(e,t,(e,t)=>{let n=this.Dr(e,t);r=r.insert(e,n)}).next(()=>r)}Fr(e,t){let r=iq,n=new nl(tD.comparator);return this.Cr(e,t,(e,t)=>{let i=this.Dr(e,t);r=r.insert(e,i),n=n.insert(e,az(t))}).next(()=>({documents:r,Mr:n}))}Cr(e,t,r){if(t.isEmpty())return t1.resolve();let n=new nc(a7);t.forEach(e=>n=n.add(e));let i=IDBKeyRange.bound(a4(n.first()),a4(n.last())),s=n.getIterator(),a=s.getNext();return nn(e,rI).X({index:rT,range:i},(e,t,n)=>{let i=tD.fromSegments([...t.prefixPath,t.collectionGroup,t.documentId]);for(;a&&0>a7(a,i);)r(a,null),a=s.getNext();a&&a.isEqual(i)&&(r(a,t),a=s.hasNext()?s.getNext():null),a?n.G(a4(a)):n.done()}).next(()=>{for(;a;)r(a,null),a=s.hasNext()?s.getNext():null})}getDocumentsMatchingQuery(e,t,r,n,i){let s=t.path,a=[s.popLast().toArray(),s.lastSegment(),an(r.readTime),r.documentKey.path.isEmpty()?"":r.documentKey.path.lastSegment()],o=[s.popLast().toArray(),s.lastSegment(),[Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],""];
20return nn(e,rI).j(IDBKeyRange.bound(a,o,!0)).next(e=>{null==i||i.incrementDocumentReadCount(e.length);let r=iq;for(let i of e){let e=this.Dr(tD.fromSegments(i.prefixPath.concat(i.collectionGroup,i.documentId)),i);e.isFoundDocument()&&(iF(t,e)||n.has(e.key))&&(r=r.insert(e.key,e))}return r})}getAllFromCollectionGroup(e,t,r,n){let i=iq,s=a8(t,r),a=a8(t,tX.max());return nn(e,rI).X({index:rx,range:IDBKeyRange.bound(s,a,!0)},(e,t,r)=>{let s=this.Dr(tD.fromSegments(t.prefixPath.concat(t.collectionGroup,t.documentId)),t);(i=i.insert(s.key,s)).size===n&&r.done()}).next(()=>i)}newChangeBuffer(e){return new a5(this,!!e&&e.trackRemovals)}getSize(e){return this.getMetadata(e).next(e=>e.byteSize)}getMetadata(e){return nn(e,rA).get(rD).next(e=>(ta(!!e,20021),e))}br(e,t){return nn(e,rA).put(rD,t)}Dr(e,t){if(t){let e=function(e,t){var r;let n,i;if(t.document)n=s0(e.gt,t.document,!!t.hasCommittedMutations);else if(t.noDocument){let e=tD.fromSegments(t.noDocument.path),r=as(t.noDocument.readTime);n=n6.newNoDocument(e,r),t.hasCommittedMutations&&n.setHasCommittedMutations()}else{if(!t.unknownDocument)return ti(56709);{let e=tD.fromSegments(t.unknownDocument.path),r=as(t.unknownDocument.version);n=n6.newUnknownDocument(e,r)}}return t.readTime&&n.setReadTime((i=new tU((r=t.readTime)[0],r[1]),tq.fromTimestamp(i))),n}(this.serializer,t);if(!(e.isNoDocument()&&e.version.isEqual(tq.min())))return e}return n6.newInvalidDocument(e)}}class a5 extends a6{constructor(e,t){super(),this.Or=e,this.trackRemovals=t,this.Nr=new iU(e=>e.toString(),(e,t)=>e.isEqual(t))}applyChanges(e){let t=[],r=0,n=new nc((e,t)=>tb(e.canonicalString(),t.canonicalString()));
20return this.changes.forEach((i,s)=>{let a=this.Nr.get(i);if(t.push(this.Or.removeEntry(e,i,a.readTime)),s.isValidDocument()){let o=ar(this.Or.serializer,s);n=n.add(i.path.popLast());let l=az(o);r+=l-a.size,t.push(this.Or.addEntry(e,i,o))}else if(r-=a.size,this.trackRemovals){let r=ar(this.Or.serializer,s.convertToNoDocument(tq.min()));t.push(this.Or.addEntry(e,i,r))}}),n.forEach(r=>{t.push(this.Or.indexManager.addToCollectionParentIndex(e,r))}),t.push(this.Or.updateMetadata(e,r)),t1.waitFor(t)}getFromCache(e,t){return this.Or.vr(e,t).next(e=>(this.Nr.set(t,{size:e.size,readTime:e.document.readTime}),e.document))}getAllFromCache(e,t){return this.Or.Fr(e,t).next(({documents:e,Mr:t})=>(t.forEach((t,r)=>{this.Nr.set(t,{size:r,readTime:e.get(t).readTime})}),e))}}function a4(e){let t=e.path.toArray();return[t.slice(0,t.length-2),t[t.length-2],t[t.length-1]]}function a8(e,t){let r=t.documentKey.path.toArray();return[e,an(t.readTime),r.slice(0,r.length-2),r.length>0?r[r.length-1]:""]}function a7(e,t){let r=e.path.toArray(),n=t.path.toArray(),i=0;for(let e=0;e<r.length-2&&e<n.length-2;++e)if(i=tb(r[e],n[e]))return i;return(i=tb(r.length,n.length))||(i=tb(r[r.length-2],n[n.length-2]))||tb(r[r.length-1],n[n.length-1])}class a9{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class oe{constructor(e,t,r,n){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=r,this.indexManager=n}getDocument(e,t){let r=null;return this.documentOverlayCache.getOverlay(e,t).next(n=>(r=n,this.remoteDocumentCache.getEntry(e,t))).next(e=>(null!==r&&ss(r.mutation,e,np.empty(),tU.now()),e))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.getLocalViewOfDocuments(e,t,iH()).next(()=>t))}getLocalViewOfDocuments(e,t,r=iH()){let n=iG();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,r).next(e=>{let t=iz();return e.forEach((e,r)=>{t=t.insert(e,r.overlayedDocument)}),t}))}getOverlayedDocuments(e,t){let r=iG();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,iH()))}populateOverlays(e,t,r){let n=[];return r.forEach(e=>{t.has(e)||n.push(e)}),this.documentOverlayCache.getOverlays(e,n).next(e=>{e.forEach((e,r)=>{t.set(e,r)})})}computeViews(e,t,r,n){let i=iq,s=iG(),a=iG();return t.forEach((e,t)=>{let a=r.get(t.key);n.has(t.key)&&(void 0===a||a.mutation instanceof sl)?i=i.insert(t.key,t):void 0!==a?(s.set(t.key,a.mutation.getFieldMask()),ss(a.mutation,t,a.mutation.getFieldMask(),tU.now())):s.set(t.key,np.empty())}),this.recalculateAndSaveOverlays(e,i).next(e=>(e.forEach((e,t)=>s.set(e,t)),t.forEach((e,t)=>{var r;return a.set(e,new a9(t,null!=(r=s.get(e))?r:null))}),a))}recalculateAndSaveOverlays(e,t){let r=iG(),n=new nl((e,t)=>e-t),i=iH();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>{for(let i of e)i.keys().forEach(e=>{let s=t.get(e);if(null===s)return;let a=r.get(e)||np.empty();a=i.applyToLocalView(s,a),r.set(e,a);let o=(n.get(i.batchId)||iH()).add(e);n=n.insert(i.batchId,o)})}).next(()=>{let s=[],a=n.getReverseIterator();for(;a.hasNext();){let n=a.getNext(),o=n.key,l=n.value,u=iG();l.forEach(e=>{if(!i.has(e)){let n=si(t.get(e),r.get(e));null!==n&&u.set(e,n),i=i.add(e)}}),s.push(this.documentOverlayCache.saveOverlays(e,o,u))}return t1.waitFor(s)}).next(()=>r)}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.recalculateAndSaveOverlays(e,t))}getDocumentsMatchingQuery(e,t,r,n){return tD.isDocumentKey(t.path)&&null===t.collectionGroup&&0===t.filters.length?this.getDocumentsMatchingDocumentQuery(e,t.path):iC(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,r,n):this.getDocumentsMatchingCollectionQuery(e,t,r,n)}getNextDocuments(e,t,r,n){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,r,n).next(i=>{let s=n-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,r.largestBatchId,n-i.size):t1.resolve(iG()),a=-1,o=i;return s.next(t=>t1.forEach(t,(t,r)=>(a<r.largestBatchId&&(a=r.largestBatchId),i.get(t)?t1.resolve():this.remoteDocumentCache.getEntry(e,t).next(e=>{o=o.insert(t,e)}))).next(()=>this.populateOverlays(e,t,i)).next(()=>this.computeViews(e,o,t,iH())).next(e=>({batchId:a,changes:i$(e)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new tD(t)).next(e=>{let t=iz();
vendor: 4,145 bytes, line 20
20return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}getDocumentsMatchingCollectionGroupQuery(e,t,r,n){let i=t.collectionGroup,s=iz();return this.indexManager.getCollectionParents(e,i).next(a=>t1.forEach(a,a=>{let o=new iT(a.child(i),null,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt);return this.getDocumentsMatchingCollectionQuery(e,o,r,n).next(e=>{e.forEach((e,t)=>{s=s.insert(e,t)})})}).next(()=>s))}getDocumentsMatchingCollectionQuery(e,t,r,n){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,r.largestBatchId).next(s=>(i=s,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,r,i,n))).next(e=>{i.forEach((t,r)=>{let n=r.getKey();null===e.get(n)&&(e=e.insert(n,n6.newInvalidDocument(n)))});let r=iz();return e.forEach((e,n)=>{let s=i.get(e);void 0!==s&&ss(s.mutation,n,np.empty(),tU.now()),iF(t,n)&&(r=r.insert(e,n))}),r})}}class ot{constructor(e){this.serializer=e,this.Br=new Map,this.Lr=new Map}getBundleMetadata(e,t){return t1.resolve(this.Br.get(t))}saveBundleMetadata(e,t){return this.Br.set(t.id,{id:t.id,version:t.version,createTime:sz(t.createTime)}),t1.resolve()}getNamedQuery(e,t){return t1.resolve(this.Lr.get(t))}saveNamedQuery(e,t){return this.Lr.set(t.name,{name:t.name,query:au(t.bundledQuery),readTime:sz(t.readTime)}),t1.resolve()}}class or{constructor(){this.overlays=new nl(tD.comparator),this.kr=new Map}getOverlay(e,t){return t1.resolve(this.overlays.get(t))}getOverlays(e,t){let r=iG();return t1.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&r.set(t,e)})).next(()=>r)}saveOverlays(e,t,r){return r.forEach((r,n)=>{this.wt(e,t,n)}),t1.resolve()}removeOverlaysForBatchId(e,t,r){let n=this.kr.get(r);return void 0!==n&&(n.forEach(e=>this.overlays=this.overlays.remove(e)),this.kr.delete(r)),t1.resolve()}getOverlaysForCollection(e,t,r){let n=iG(),i=t.length+1,s=new tD(t.child("")),a=this.overlays.getIteratorFrom(s);for(;a.hasNext();){let e=a.getNext().value,s=e.getKey();if(!t.isPrefixOf(s.path))break;s.path.length===i&&e.largestBatchId>r&&n.set(e.getKey(),e)}return t1.resolve(n)}getOverlaysForCollectionGroup(e,t,r,n){let i=new nl((e,t)=>e-t),s=this.overlays.getIterator();for(;s.hasNext();){let e=s.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>r){let t=i.get(e.largestBatchId);null===t&&(t=iG(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let a=iG(),o=i.getIterator();for(;o.hasNext()&&(o.getNext().value.forEach((e,t)=>a.set(e,t)),!(a.size()>=n)););return t1.resolve(a)}wt(e,t,r){let n=this.overlays.get(r.key);if(null!==n){let e=this.kr.get(n.largestBatchId).delete(r.key);this.kr.set(n.largestBatchId,e)}this.overlays=this.overlays.insert(r.key,new sm(t,r));let i=this.kr.get(t);void 0===i&&(i=iH(),this.kr.set(t,i)),this.kr.set(t,i.add(r.key))}}class on{constructor(){this.sessionToken=nm.EMPTY_BYTE_STRING}getSessionToken(e){return t1.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,t1.resolve()}}class oi{constructor(){this.qr=new nc(os.Qr),this.$r=new nc(os.Ur)}isEmpty(){return this.qr.isEmpty()}addReference(e,t){let r=new os(e,t);this.qr=this.qr.add(r),this.$r=this.$r.add(r)}Kr(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.Wr(new os(e,t))}Gr(e,t){e.forEach(e=>this.removeReference(e,t))}zr(e){let t=new tD(new tx([])),r=new os(t,e),n=new os(t,e+1),i=[];return this.$r.forEachInRange([r,n],e=>{this.Wr(e),i.push(e.key)}),i}jr(){this.qr.forEach(e=>this.Wr(e))}Wr(e){this.qr=this.qr.delete(e),this.$r=this.$r.delete(e)}Jr(e){let t=new tD(new tx([])),r=new os(t,e),n=new os(t,e+1),i=iH();return this.$r.forEachInRange([r,n],e=>{i=i.add(e.key)}),i}containsKey(e){let t=new os(e,0),r=this.qr.firstAfterOrEqual(t);return null!==r&&e.isEqual(r.key)}}class os{constructor(e,t){this.key=e,this.Hr=t}static Qr(e,t){return tD.comparator(e.key,t.key)||tb(e.Hr,t.Hr)}static Ur(e,t){return tb(e.Hr,t.Hr)||tD.comparator(e.key,t.key)}}class oa{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.er=1,this.Yr=new nc(os.Qr)}checkEmpty(e){return t1.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,r,n){let i=this.er;
20this.er++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let s=new sp(i,t,r,n);for(let t of(this.mutationQueue.push(s),n))this.Yr=this.Yr.add(new os(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return t1.resolve(s)}lookupMutationBatch(e,t){return t1.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){let r=this.Xr(t+1),n=r<0?0:r;return t1.resolve(this.mutationQueue.length>n?this.mutationQueue[n]:null)}getHighestUnacknowledgedBatchId(){return t1.resolve(0===this.mutationQueue.length?-1:this.er-1)}getAllMutationBatches(e){return t1.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let r=new os(t,0),n=new os(t,1/0),i=[];return this.Yr.forEachInRange([r,n],e=>{let t=this.Zr(e.Hr);i.push(t)}),t1.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let r=new nc(tb);return t.forEach(e=>{let t=new os(e,0),n=new os(e,1/0);this.Yr.forEachInRange([t,n],e=>{r=r.add(e.Hr)})}),t1.resolve(this.ei(r))}getAllMutationBatchesAffectingQuery(e,t){let r=t.path,n=r.length+1,i=r;tD.isDocumentKey(i)||(i=i.child(""));let s=new os(new tD(i),0),a=new nc(tb);return this.Yr.forEachWhile(e=>{let t=e.key.path;return!!r.isPrefixOf(t)&&(t.length===n&&(a=a.add(e.Hr)),!0)},s),t1.resolve(this.ei(a))}ei(e){let t=[];return e.forEach(e=>{let r=this.Zr(e);null!==r&&t.push(r)}),t}removeMutationBatch(e,t){ta(0===this.ti(t.batchId,"removed"),55003),this.mutationQueue.shift();let r=this.Yr;return t1.forEach(t.mutations,n=>{let i=new os(n.key,t.batchId);return r=r.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,n.key)}).next(()=>{this.Yr=r})}rr(e){}containsKey(e,t){let r=new os(t,0),n=this.Yr.firstAfterOrEqual(r);return t1.resolve(t.isEqual(n&&n.key))}performConsistencyCheck(e){return this.mutationQueue.length,t1.resolve()}ti(e,t){return this.Xr(e)}Xr(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Zr(e){let t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class oo{constructor(e){this.ni=e,this.docs=new nl(tD.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let r=t.key,n=this.docs.get(r),i=n?n.size:0,s=this.ni(t);return this.docs=this.docs.insert(r,{document:t.mutableCopy(),size:s}),this.size+=s-i,this.indexManager.addToCollectionParentIndex(e,r.path.popLast())}removeEntry(e){let t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){let r=this.docs.get(t);return t1.resolve(r?r.document.mutableCopy():n6.newInvalidDocument(t))}getEntries(e,t){let r=iq;return t.forEach(e=>{let t=this.docs.get(e);r=r.insert(e,t?t.document.mutableCopy():n6.newInvalidDocument(e))}),t1.resolve(r)}getDocumentsMatchingQuery(e,t,r,n){let i=iq,s=t.path,a=new tD(s.child("__id-9223372036854775808__")),o=this.docs.getIteratorFrom(a);for(;o.hasNext();){let{key:e,value:{document:a}}=o.getNext();if(!s.isPrefixOf(e.path))break;e.path.length>s.length+1||0>=tJ(tW(a),r)||(n.has(a.key)||iF(t,a))&&(i=i.insert(a.key,a.mutableCopy()))}return t1.resolve(i)}getAllFromCollectionGroup(e,t,r,n){ti(9500)}ri(e,t){return t1.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new ol(this)}getSize(e){return t1.resolve(this.size)}}class ol extends a6{constructor(e){super(),this.Or=e}applyChanges(e){let t=[];
vendor: 6,226 bytes, line 20
20return this.changes.forEach((r,n)=>{n.isValidDocument()?t.push(this.Or.addEntry(e,n)):this.Or.removeEntry(r)}),t1.waitFor(t)}getFromCache(e,t){return this.Or.getEntry(e,t)}getAllFromCache(e,t){return this.Or.getEntries(e,t)}}class ou{constructor(e){this.persistence=e,this.ii=new iU(e=>iv(e),iw),this.lastRemoteSnapshotVersion=tq.min(),this.highestTargetId=0,this.si=0,this.oi=new oi,this.targetCount=0,this._i=aQ.ar()}forEachTarget(e,t){return this.ii.forEach((e,r)=>t(r)),t1.resolve()}getLastRemoteSnapshotVersion(e){return t1.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return t1.resolve(this.si)}allocateTargetId(e){return this.highestTargetId=this._i.next(),t1.resolve(this.highestTargetId)}setTargetsMetadata(e,t,r){return r&&(this.lastRemoteSnapshotVersion=r),t>this.si&&(this.si=t),t1.resolve()}hr(e){this.ii.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this._i=new aQ(t),this.highestTargetId=t),e.sequenceNumber>this.si&&(this.si=e.sequenceNumber)}addTargetData(e,t){return this.hr(t),this.targetCount+=1,t1.resolve()}updateTargetData(e,t){return this.hr(t),t1.resolve()}removeTargetData(e,t){return this.ii.delete(t.target),this.oi.zr(t.targetId),this.targetCount-=1,t1.resolve()}removeTargets(e,t,r){let n=0,i=[];return this.ii.forEach((s,a)=>{a.sequenceNumber<=t&&null===r.get(a.targetId)&&(this.ii.delete(s),i.push(this.removeMatchingKeysForTargetId(e,a.targetId)),n++)}),t1.waitFor(i).next(()=>n)}getTargetCount(e){return t1.resolve(this.targetCount)}getTargetData(e,t){let r=this.ii.get(t)||null;return t1.resolve(r)}addMatchingKeys(e,t,r){return this.oi.Kr(t,r),t1.resolve()}removeMatchingKeys(e,t,r){this.oi.Gr(t,r);let n=this.persistence.referenceDelegate,i=[];return n&&t.forEach(t=>{i.push(n.markPotentiallyOrphaned(e,t))}),t1.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.oi.zr(t),t1.resolve()}getMatchingKeysForTargetId(e,t){let r=this.oi.Jr(t);return t1.resolve(r)}containsKey(e,t){return t1.resolve(this.oi.containsKey(t))}}class oh{constructor(e,t){this.ai={},this.overlays={},this.ui=new ra(0),this.ci=!1,this.ci=!0,this.li=new on,this.referenceDelegate=e(this),this.hi=new ou(this),this.indexManager=new aL,this.remoteDocumentCache=function(e){return new oo(e)}(e=>this.referenceDelegate.Pi(e)),this.serializer=new at(t),this.Ti=new ot(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ci=!1,Promise.resolve()}get started(){return this.ci}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new or,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let r=this.ai[e.toKey()];return r||(r=new oa(t,this.referenceDelegate),this.ai[e.toKey()]=r),r}getGlobalsCache(){return this.li}getTargetCache(){return this.hi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ti}runTransaction(e,t,r){te("MemoryPersistence","Starting transaction:",e);let n=new oc(this.ui.next());return this.referenceDelegate.Ii(),r(n).next(e=>this.referenceDelegate.di(n).next(()=>e)).toPromise().then(e=>(n.raiseOnCommittedEvent(),e))}Ei(e,t){return t1.or(Object.values(this.ai).map(r=>()=>r.containsKey(e,t)))}}class oc extends tZ{constructor(e){super(),this.currentSequenceNumber=e}}class od{constructor(e){this.persistence=e,this.Ai=new oi,this.Ri=null}static Vi(e){return new od(e)}get mi(){if(this.Ri)return this.Ri;throw ti(60996)}addReference(e,t,r){return this.Ai.addReference(r,t),this.mi.delete(r.toString()),t1.resolve()}removeReference(e,t,r){return this.Ai.removeReference(r,t),this.mi.add(r.toString()),t1.resolve()}markPotentiallyOrphaned(e,t){return this.mi.add(t.toString()),t1.resolve()}removeTarget(e,t){this.Ai.zr(t.targetId).forEach(e=>this.mi.add(e.toString()));let r=this.persistence.getTargetCache();return r.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.mi.add(e.toString()))}).next(()=>r.removeTargetData(e,t))}Ii(){this.Ri=new Set}di(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return t1.forEach(this.mi,r=>{let n=tD.fromPath(r);return this.fi(e,n).next(e=>{e||t.removeEntry(n,tq.min())})}).next(()=>(this.Ri=null,t.apply(e)))}updateLimboDocument(e,t){return this.fi(e,t).next(e=>{e?this.mi.delete(t.toString()):this.mi.add(t.toString())})}Pi(e){return 0}fi(e,t){return t1.or([()=>t1.resolve(this.Ai.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class of{constructor(e,t){this.persistence=e,this.gi=new iU(e=>rh(e.path),(e,t)=>e.isEqual(t)),this.garbageCollector=function(e,t){return new a0(e,t)}(this,t)}static Vi(e,t){return new of(e,t)}Ii(){}di(e){return t1.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}mr(e){let t=this.yr(e);return this.persistence.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}yr(e){let t=0;return this.gr(e,e=>{t++}).next(()=>t)}gr(e,t){return t1.forEach(this.gi,(r,n)=>this.Sr(e,r,n).next(e=>e?t1.resolve():t(n)))}removeTargets(e,t,r){return this.persistence.getTargetCache().removeTargets(e,t,r)}removeOrphanedDocuments(e,t){let r=0,n=this.persistence.getRemoteDocumentCache(),i=n.newChangeBuffer();return n.ri(e,n=>this.Sr(e,n,t).next(e=>{e||(r++,i.removeEntry(n,tq.min()))})).next(()=>i.apply(e)).next(()=>r)}markPotentiallyOrphaned(e,t){return this.gi.set(t,e.currentSequenceNumber),t1.resolve()}removeTarget(e,t){let r=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,r)}addReference(e,t,r){return this.gi.set(r,e.currentSequenceNumber),t1.resolve()}removeReference(e,t,r){return this.gi.set(r,e.currentSequenceNumber),t1.resolve()}updateLimboDocument(e,t){return this.gi.set(t,e.currentSequenceNumber),t1.resolve()}Pi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=function e(t){switch(nF(t)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let r=nx(t);return r?16+e(r):16;case 5:return 2*t.stringValue.length;case 6:return nb(t.bytesValue).approximateByteSize();case 7:return t.referenceValue.length;case 9:return(t.arrayValue.values||[]).reduce((t,r)=>t+e(r),0);case 10:case 11:var n;let i;
20return n=t.mapValue,i=0,ns(n.fields,(t,r)=>{i+=t.length+e(r)}),i;default:throw ti(13486,{value:t})}}(e.data.value)),t}Sr(e,t,r){return t1.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.gi.get(t);return t1.resolve(void 0!==e&&e>r)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class op{constructor(e){this.serializer=e}q(e,t,r,n){let i=new t6("createOrUpgrade",t);r<1&&n>=1&&(e.createObjectStore(rf),e.createObjectStore(rg,{keyPath:"userId"}),e.createObjectStore(rm,{keyPath:ry,autoIncrement:!0}).createIndex(rv,rw,{unique:!0}),e.createObjectStore(rE),og(e),e.createObjectStore(rd));let s=t1.resolve();return r<3&&n>=3&&(0!==r&&(e.deleteObjectStore(rR),e.deleteObjectStore(rN),e.deleteObjectStore(rV),og(e)),s=s.next(()=>{let e,t;return e=i.store(rV),t={highestTargetId:0,highestListenSequenceNumber:0,lastRemoteSnapshotVersion:tq.min().toTimestamp(),targetCount:0},e.put(rF,t)})),r<4&&n>=4&&(0!==r&&(s=s.next(()=>i.store(rm).j().next(t=>{e.deleteObjectStore(rm),e.createObjectStore(rm,{keyPath:ry,autoIncrement:!0}).createIndex(rv,rw,{unique:!0});let r=i.store(rm),n=t.map(e=>r.put(e));return t1.waitFor(n)}))),s=s.next(()=>{e.createObjectStore(rq,{keyPath:"clientId"})})),r<5&&n>=5&&(s=s.next(()=>this.pi(i))),r<6&&n>=6&&(s=s.next(()=>(e.createObjectStore(rA),this.yi(i)))),r<7&&n>=7&&(s=s.next(()=>this.wi(i))),r<8&&n>=8&&(s=s.next(()=>this.Si(e,i))),r<9&&n>=9&&(s=s.next(()=>{e.objectStoreNames.contains("remoteDocumentChanges")&&e.deleteObjectStore("remoteDocumentChanges")})),r<10&&n>=10&&(s=s.next(()=>this.bi(i))),r<11&&n>=11&&(s=s.next(()=>{e.createObjectStore(rj,{keyPath:"bundleId"}),e.createObjectStore(rz,{keyPath:"name"})})),r<12&&n>=12&&(s=s.next(()=>{let t;(t=e.createObjectStore(r0,{keyPath:r1})).createIndex(r2,r6,{unique:!1}),t.createIndex(r3,r5,{unique:!1})})),r<13&&n>=13&&(s=s.next(()=>{let t;(t=e.createObjectStore(rI,{keyPath:r_})).createIndex(rT,rS),t.createIndex(rx,rC)}).next(()=>this.Di(e,i)).next(()=>e.deleteObjectStore(rd))),r<14&&n>=14&&(s=s.next(()=>this.Ci(e,i))),r<15&&n>=15&&(s=s.next(()=>{e.createObjectStore(r$,{keyPath:"indexId",autoIncrement:!0}).createIndex(rG,"collectionGroup",{unique:!1}),e.createObjectStore(rK,{keyPath:rQ}).createIndex(rH,rW,{unique:!1}),e.createObjectStore(rX,{keyPath:rJ}).createIndex(rY,rZ,{unique:!1})})),r<16&&n>=16&&(s=s.next(()=>{t.objectStore(rK).clear()}).next(()=>{t.objectStore(rX).clear()})),r<17&&n>=17&&(s=s.next(()=>{e.createObjectStore(r4,{keyPath:"name"})})),r<18&&n>=18&&G()&&(s=s.next(()=>{t.objectStore(rK).clear()}).next(()=>{t.objectStore(rX).clear()})),s}yi(e){let t=0;return e.store(rd).X((e,r)=>{t+=az(r)}).next(()=>{let r={byteSize:t};return e.store(rA).put(rD,r)})}pi(e){let t=e.store(rg),r=e.store(rm);return t.j().next(t=>t1.forEach(t,t=>{let n=IDBKeyRange.bound([t.userId,-1],[t.userId,t.lastAcknowledgedBatchId]);return r.j(rv,n).next(r=>t1.forEach(r,r=>{ta(r.userId===t.userId,18650,"Cannot process batch from unexpected user",{batchId:r.batchId});let n=aa(this.serializer,r);return aj(e,t.userId,n).next(()=>{})}))}))}wi(e){let t=e.store(rR),r=e.store(rd);return e.store(rV).get(rF).next(e=>{let n=[];return r.X((r,i)=>{let s=new tx(r),a=[0,rh(s)];n.push(t.get(a).next(r=>r?t1.resolve():t.put({targetId:0,path:rh(s),sequenceNumber:e.highestListenSequenceNumber})))}).next(()=>t1.waitFor(n))})}Si(e,t){e.createObjectStore(rB,{keyPath:rU});let r=t.store(rB),n=new aM,i=e=>{if(n.add(e)){let t=e.lastSegment(),n=e.popLast();return r.put({collectionId:t,parent:rh(n)})}};return t.store(rd).X({Z:!0},(e,t)=>i(new tx(e).popLast())).next(()=>t.store(rE).X({Z:!0},([e,t,r],n)=>i(rc(t).popLast())))}bi(e){let t=e.store(rN);return t.X((e,r)=>{let n=ao(r),i=al(this.serializer,n);return t.put(i)})}Di(e,t){let r=t.store(rd),n=[];return r.X((e,r)=>{let i=t.store(rI),s=(r.document?new tD(tx.fromString(r.document.name).popFirst(5)):r.noDocument?tD.fromSegments(r.noDocument.path):r.unknownDocument?tD.fromSegments(r.unknownDocument.path):ti(36783)).path.toArray(),a={prefixPath:s.slice(0,s.length-2),collectionGroup:s[s.length-2],documentId:s[s.length-1],readTime:r.readTime||[0,0],unknownDocument:r.unknownDocument,noDocument:r.noD
20ocument,document:r.document,hasCommittedMutations:!!r.hasCommittedMutations};n.push(i.put(a))}).next(()=>t1.waitFor(n))}Ci(e,t){let r=t.store(rm),n=new a3(this.serializer),i=new oh(od.Vi,this.serializer.gt);return r.j().next(e=>{let r=new Map;return e.forEach(e=>{var t;let n=null!=(t=r.get(e.userId))?t:iH();aa(this.serializer,e).keys().forEach(e=>n=n.add(e)),r.set(e.userId,n)}),t1.forEach(r,(e,r)=>{let s=new e4(r),a=ap.yt(this.serializer,s),o=i.getIndexManager(s);return new oe(n,a$.yt(s,this.serializer,o,i.referenceDelegate),a,o).recalculateAndSaveOverlaysForDocumentKeys(new nr(t,ra.ue),e).next()})})}}function og(e){e.createObjectStore(rR,{keyPath:rL}).createIndex(rM,rP,{unique:!0}),e.createObjectStore(rN,{keyPath:"targetId"}).createIndex(rk,rO,{unique:!0}),e.createObjectStore(rV)}let om="IndexedDbPersistence",oy="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.",ov="main";class ow{constructor(e,t,r,n,i,s,a,o,l,u,h=18){if(this.allowTabSynchronization=e,this.persistenceKey=t,this.clientId=r,this.Fi=i,this.window=s,this.document=a,this.Mi=l,this.xi=u,this.Oi=h,this.ui=null,this.ci=!1,this.isPrimary=!1,this.networkEnabled=!0,this.Ni=null,this.inForeground=!1,this.Bi=null,this.Li=null,this.ki=-1/0,this.qi=e=>Promise.resolve(),!ow.C())throw new tl(to.UNIMPLEMENTED,"This platform is either missing IndexedDB or is known to have an incomplete implementation. Offline persistence has been disabled.");this.referenceDelegate=new a1(this,n),this.Qi=t+ov,this.serializer=new at(o),this.$i=new t3(this.Qi,this.Oi,new op(this.serializer)),this.li=new ag,this.hi=new aH(this.referenceDelegate,this.serializer),this.remoteDocumentCache=function(e){return new a3(e)}(this.serializer),this.Ti=new af,this.window&&this.window.localStorage?this.Ui=this.window.localStorage:(this.Ui=null,!1===u&&tt(om,"LocalStorage is unavailable. As a result, persistence may not work reliably. In particular enablePersistence() could fail immediately after refreshing the page."))}start(){return this.Ki().then(()=>{if(!this.isPrimary&&!this.allowTabSynchronization)throw new tl(to.FAILED_PRECONDITION,oy);return this.Wi(),this.Gi(),this.zi(),this.runTransaction("getHighestListenSequenceNumber","readonly",e=>this.hi.getHighestSequenceNumber(e))}).then(e=>{this.ui=new ra(e,this.Mi)}).then(()=>{this.ci=!0}).catch(e=>(this.$i&&this.$i.close(),Promise.reject(e)))}ji(e){return this.qi=async t=>{if(this.started)return e(t)},e(this.isPrimary)}setDatabaseDeletedListener(e){this.$i.setDatabaseDeletedListener(e)}setNetworkEnabled(e){this.networkEnabled!==e&&(this.networkEnabled=e,this.Fi.enqueueAndForget(async()=>{this.started&&await this.Ki()}))}Ki(){return this.runTransaction("updateClientMetadataAndTryBecomePrimary","readwrite",e=>nn(e,rq).put({clientId:this.clientId,updateTimeMs:Date.now(),networkEnabled:this.networkEnabled,inForeground:this.inForeground}).next(()=>{if(this.isPrimary)return this.Ji(e).next(e=>{e||(this.isPrimary=!1,this.Fi.enqueueRetryable(()=>this.qi(!1)))})}).next(()=>this.Hi(e)).next(t=>this.isPrimary&&!t?this.Yi(e).next(()=>!1):!!t&&this.Zi(e).next(()=>!0))).catch(e=>{if(t7(e))return te(om,"Failed to extend owner lease: ",e),this.isPrimary;if(!this.allowTabSynchronization)throw e;return te(om,"Releasing owner lease after error during lease refresh",e),!1}).then(e=>{this.isPrimary!==e&&this.Fi.enqueueRetryable(()=>this.qi(e)),this.isPrimary=e})}Ji(e){return nn(e,rf).get(rp).next(e=>t1.resolve(this.Xi(e)))}es(e){return nn(e,rq).delete(this.clientId)}async ts(){if(this.isPrimary&&!this.ns(this.ki,18e5)){this.ki=Date.now();let e=await this.runTransaction("maybeGarbageCollectMultiClientState","readwrite-primary",e=>{let t=nn(e,rq);return t.j().next(e=>{let r=this.rs(e,18e5),n=e.filter(e=>-1===r.indexOf(e));return t1.forEach(n,e=>t.delete(e.clientId)).next(()=>n)})}).catch(()=>[]);if(this.Ui)for(let t of e)this.Ui.removeItem(this.ss(t.clientId))}}zi(){this.Li=this.Fi.enqueueAfterDelay("client_metadata_refresh",4e3,()=>this.Ki().then(()=>this.ts()).then(()=>this.zi()))}Xi(e){return!!e&&e.ownerId===this.clientId}Hi(e){return this.xi?t1.resolve(!0):nn(e,rf).get(rp).next(t=>
20{if(null!==t&&this.ns(t.leaseTimestampMs,5e3)&&!this._s(t.ownerId)){if(this.Xi(t)&&this.networkEnabled)return!0;if(!this.Xi(t)){if(!t.allowTabSynchronization)throw new tl(to.FAILED_PRECONDITION,oy);return!1}}return!(!this.networkEnabled||!this.inForeground)||nn(e,rq).j().next(e=>void 0===this.rs(e,5e3).find(e=>{if(this.clientId!==e.clientId){let t=!this.networkEnabled&&e.networkEnabled,r=!this.inForeground&&e.inForeground,n=this.networkEnabled===e.networkEnabled;if(t||r&&n)return!0}return!1}))}).next(e=>(this.isPrimary!==e&&te(om,`Client ${e?"is":"is not"} eligible for a primary lease.`),e))}async shutdown(){this.ci=!1,this.us(),this.Li&&(this.Li.cancel(),this.Li=null),this.cs(),this.ls(),await this.$i.runTransaction("shutdown","readwrite",[rf,rq],e=>{let t=new nr(e,ra.ue);return this.Yi(t).next(()=>this.es(t))}),this.$i.close(),this.hs()}rs(e,t){return e.filter(e=>this.ns(e.updateTimeMs,t)&&!this._s(e.clientId))}Ps(){return this.runTransaction("getActiveClients","readonly",e=>nn(e,rq).j().next(e=>this.rs(e,18e5).map(e=>e.clientId)))}get started(){return this.ci}getGlobalsCache(){return this.li}getMutationQueue(e,t){return a$.yt(e,this.serializer,t,this.referenceDelegate)}getTargetCache(){return this.hi}getRemoteDocumentCache(){return this.remoteDocumentCache}getIndexManager(e){return new aV(e,this.serializer.gt.databaseId)}getDocumentOverlayCache(e){return ap.yt(this.serializer,e)}getBundleCache(){return this.Ti}runTransaction(e,t,r){var n;let i;te(om,"Starting transaction:",e);let s=18===(n=this.Oi)||17===n?nt:16===n||15===n?ne:14===n||13===n?r9:12===n?r7:11===n?r8:void ti(60245);return this.$i.runTransaction(e,"readonly"===t?"readonly":"readwrite",s,n=>(i=new nr(n,this.ui?this.ui.next():ra.ue),"readwrite-primary"===t?this.Ji(i).next(e=>!!e||this.Hi(i)).next(t=>{if(!t)throw tt(`Failed to obtain primary lease for action '${e}'.`),this.isPrimary=!1,this.Fi.enqueueRetryable(()=>this.qi(!1)),new tl(to.FAILED_PRECONDITION,tY);return r(i)}).next(e=>this.Zi(i).next(()=>e)):this.Ts(i).next(()=>r(i)))).then(e=>(i.raiseOnCommittedEvent(),e))}Ts(e){return nn(e,rf).get(rp).next(e=>{if(null!==e&&this.ns(e.leaseTimestampMs,5e3)&&!this._s(e.ownerId)&&!this.Xi(e)&&!(this.xi||this.allowTabSynchronization&&e.allowTabSynchronization))throw new tl(to.FAILED_PRECONDITION,oy)})}Zi(e){let t={ownerId:this.clientId,allowTabSynchronization:this.allowTabSynchronization,leaseTimestampMs:Date.now()};return nn(e,rf).put(rp,t)}static C(){return t3.C()}Yi(e){let t=nn(e,rf);return t.get(rp).next(e=>
20this.Xi(e)?(te(om,"Releasing primary lease."),t.delete(rp)):t1.resolve())}ns(e,t){let r=Date.now();return!(e<r-t)&&(!(e>r)||(tt(`Detected an update time that is in the future: ${e} > ${r}`),!1))}Wi(){null!==this.document&&"function"==typeof this.document.addEventListener&&(this.Bi=()=>{this.Fi.enqueueAndForget(()=>(this.inForeground="visible"===this.document.visibilityState,this.Ki()))},this.document.addEventListener("visibilitychange",this.Bi),this.inForeground="visible"===this.document.visibilityState)}cs(){this.Bi&&(this.document.removeEventListener("visibilitychange",this.Bi),this.Bi=null)}Gi(){var e;"function"==typeof(null==(e=this.window)?void 0:e.addEventListener)&&(this.Ni=()=>{this.us();let e=/(?:Version|Mobile)\/1[456]/;$()&&(navigator.appVersion.match(e)||navigator.userAgent.match(e))&&this.Fi.enterRestrictedMode(!0),this.Fi.enqueueAndForget(()=>this.shutdown())},this.window.addEventListener("pagehide",this.Ni))}ls(){this.Ni&&(this.window.removeEventListener("pagehide",this.Ni),this.Ni=null)}_s(e){var t;try{let r=null!==(null==(t=this.Ui)?void 0:t.getItem(this.ss(e)));return te(om,`Client '${e}' ${r?"is":"is not"} zombied in LocalStorage`),r}catch(e){return tt(om,"Failed to get zombied client id.",e),!1}}us(){if(this.Ui)try{this.Ui.setItem(this.ss(this.clientId),String(Date.now()))}catch(e){tt("Failed to set zombie client id.",e)}}hs(){if(this.Ui)try{this.Ui.removeItem(this.ss(this.clientId))}catch(e){}}ss(e){return`firestore_zombie_${this.persistenceKey}_${e}`}}function ob(e,t){let r=e.projectId;return e.isDefaultDatabase||(r+="."+e.database),"firestore/"+t+"/"+r+"/"}class oE{constructor(e,t,r,n){this.targetId=e,this.fromCache=t,this.Is=r,this.ds=n}static Es(e,t){let r=iH(),n=iH();for(let e of t.docChanges)switch(e.type){case 0:r=r.add(e.doc.key);break;case 1:n=n.add(e.doc.key)}return new oE(e,t.fromCache,r,n)}}class oI{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class o_{constructor(){this.As=!1,this.Rs=!1,this.Vs=100,this.fs=$()?8:t5(q())>0?6:4}initialize(e,t){this.gs=e,this.indexManager=t,this.As=!0}getDocumentsMatchingQuery(e,t,r,n){let i={result:null};return this.ps(e,t).next(e=>{i.result=e}).next(()=>{if(!i.result)return this.ys(e,t,n,r).next(e=>{i.result=e})}).next(()=>{if(i.result)return;let r=new oI;return this.ws(e,t,r).next(n=>{if(i.result=n,this.Rs)return this.Ss(e,t,r,n.size)})}).next(()=>i.result)}Ss(e,t,r,n){return r.documentReadCount<this.Vs?(e9()<=s.DEBUG&&te("QueryEngine","SDK will not create cache indexes for query:",iP(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),t1.resolve()):(e9()<=s.DEBUG&&te("QueryEngine","Query:",iP(t),"scans",r.documentReadCount,"local documents and returns",n,"documents as results."),r.documentReadCount>this.fs*n?(e9()<=s.DEBUG&&te("QueryEngine","The SDK decides to create cache indexes for query:",iP(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,iD(t))):t1.resolve())}ps(e,t){if(ix(t))return t1.resolve(null);let r=iD(t);return this.indexManager.getIndexType(e,r).next(n=>0===n?null:(null!==t.limit&&1===n&&(r=iD(t=iR(t,null,"F"))),this.indexManager.getDocumentsMatchingTarget(e,r).next(n=>{let i=iH(...n);return this.gs.getDocuments(e,i).next(n=>this.indexManager.getMinOffset(e,r).next(r=>{let s=this.bs(t,n);return this.Ds(t,s,i,r.readTime)?this.ps(e,iR(t,null,"F")):this.vs(e,s,t,r)}))})))}ys(e,t,r,n){return ix(t)||n.isEqual(tq.min())?t1.resolve(null):this.gs.getDocuments(e,r).next(i=>{let a=this.bs(t,i);return this.Ds(t,a,r,n)?t1.resolve(null):(e9()<=s.DEBUG&&te("QueryEngine","Re-using previous result from %s to execute query: %s",n.toString(),iP(t)),this.vs(e,a,t,tH(n,-1)).next(e=>e))})}bs(e,t){let r=new nc(iB(e));return t.forEach((t,n)=>{iF(e,n)&&(r=r.add(n))}),r}Ds(e,t,r,n){if(null===e.limit)return!1;if(r.size!==t.size)return!0;let i="F"===e.limitType?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(n)>0)}ws(e,t,r){return e9()<=s.DEBUG&&te("QueryEngine","Using full collection scan to execute query:",iP(t)),this.gs.getDocumentsMatchingQuery(e,t,tX.min(),r)}vs(e,t,r,n){return this.gs.getDocumentsMatchingQuery(e,r,n).next(e=>(t.forEach(t=>{e=e.insert(t.key,t)}),e))}}let oT="LocalStore";class oS{constructor(e,t,r,n){this.persistence=e,this.Cs=t,this.serializer
20=n,this.Fs=new nl(tb),this.Ms=new iU(e=>iv(e),iw),this.xs=new Map,this.Os=e.getRemoteDocumentCache(),this.hi=e.getTargetCache(),this.Ti=e.getBundleCache(),this.Ns(r)}Ns(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new oe(this.Os,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Os.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.Fs))}}async function ox(e,t){return await e.persistence.runTransaction("Handle user change","readonly",r=>{let n;return e.mutationQueue.getAllMutationBatches(r).next(i=>(n=i,e.Ns(t),e.mutationQueue.getAllMutationBatches(r))).next(t=>{let i=[],s=[],a=iH();for(let e of n)for(let t of(i.push(e.batchId),e.mutations))a=a.add(t.key);for(let e of t)for(let t of(s.push(e.batchId),e.mutations))a=a.add(t.key);return e.localDocuments.getDocuments(r,a).next(e=>({Bs:e,removedBatchIds:i,addedBatchIds:s}))})})}function oC(e){return e.persistence.runTransaction("Get last remote snapshot version","readonly",t=>e.hi.getLastRemoteSnapshotVersion(t))}function oA(e,t,r){let n=iH(),i=iH();return r.forEach(e=>n=n.add(e)),t.getEntries(e,n).next(e=>{let n=iq;return r.forEach((r,s)=>{let a=e.get(r);s.isFoundDocument()!==a.isFoundDocument()&&(i=i.add(r)),s.isNoDocument()&&s.version.isEqual(tq.min())?(t.removeEntry(r,s.readTime),n=n.insert(r,s)):!a.isValidDocument()||s.version.compareTo(a.version)>0||0===s.version.compareTo(a.version)&&a.hasPendingWrites?(t.addEntry(s),n=n.insert(r,s)):te(oT,"Ignoring outdated watch update for ",r,". Current version:",a.version," Watch version:",s.version)}),{Ls:n,ks:i}})}function oD(e,t){return e.persistence.runTransaction("Allocate target","readwrite",r=>{let n;return e.hi.getTargetData(r,t).next(i=>i?(n=i,t1.resolve(n)):e.hi.allocateTargetId(r).next(i=>(n=new ae(t,i,"TargetPurposeListen",r.currentSequenceNumber),e.hi.addTargetData(r,n).next(()=>n))))}).then(r=>{let n=e.Fs.get(r.targetId);return(null===n||r.snapshotVersion.compareTo(n.snapshotVersion)>0)&&(e.Fs=e.Fs.insert(r.targetId,r),e.Ms.set(t,r.targetId)),r})}async function oN(e,t,r){let n=e.Fs.get(t);try{r||await e.persistence.runTransaction("Release target",r?"readwrite":"readwrite-primary",t=>e.persistence.referenceDelegate.removeTarget(t,n))}catch(e){if(!t7(e))throw e;te(oT,`Failed to update sequence numbers for target ${t}: ${e}`)}e.Fs=e.Fs.remove(t),e.Ms.delete(n.target)}function ok(e,t,r){let n=tq.min(),i=iH();return e.persistence.runTransaction("Execute query","readwrite",s=>{var a;let o;return(a=iD(t),void 0!==(o=e.Ms.get(a))?t1.resolve(e.Fs.get(o)):e.hi.getTargetData(s,a)).next(t=>{if(t)return n=t.lastLimboFreeSnapshotVersion,e.hi.getMatchingKeysForTargetId(s,t.targetId).next(e=>{i=e})}).next(()=>e.Cs.getDocumentsMatchingQuery(s,t,r?n:tq.min(),r?i:iH())).next(r=>(oL(e,iV(t),r),{documents:r,qs:i}))})}function oO(e,t){let r=e.hi,n=e.Fs.get(t);return n?Promise.resolve(n.target):e.persistence.runTransaction("Get target data","readonly",e=>r.Et(e,t).next(e=>e?e.target:null))}function oR(e,t){let r=e.xs.get(t)||tq.min();return e.persistence.runTransaction("Get new document changes","readonly",n=>e.Os.getAllFromCollectionGroup(n,t,tH(r,-1),Number.MAX_SAFE_INTEGER)).then(r=>(oL(e,t,r),r))}function oL(e,t,r){let n=e.xs.get(t)||tq.min();r.forEach((e,t)=>{t.readTime.compareTo(n)>0&&(n=t.readTime)}),e.xs.set(t,n)}async function oM(e,t,r,n){let i=iH(),s=iq;for(let e of r){let r=t.Qs(e.metadata.name);e.document&&(i=i.add(r));let n=t.$s(e);n.setReadTime(t.Us(e.metadata.readTime)),s=s.insert(r,n)}let a=e.Os.newChangeBuffer({trackRemovals:!0}),o=await oD(e,iD(iS(tx.fromString(`__bundle__/docs/${n}`))));return e.persistence.runTransaction("Apply bundle documents","readwrite",t=>oA(t,a,s).next(e=>(a.apply(t),e)).next(r=>e.hi.removeMatchingKeysForTargetId(t,o.targetId).next(()=>e.hi.addMatchingKeys(t,i,o.targetId)).next(()=>e.localDocuments.getLocalViewOfDocuments(t,r.Ls,r.ks)).next(()=>r.Ls)))}async function oP(e,t,r=iH()){let n=await oD(e,iD(au(t.bundledQuery)));return e.persistence.runTransaction("Save named query","readwrite",i=>{let s=sz(t.readTime);if(n.snapshotVersion.compareTo(s)>=0)return e.Ti.saveNamedQuery(i,t);let a=n.withResumeToken(nm.EMPTY_BYTE_STRING,s);return e.Fs=e.Fs.insert(a.targetId,a),e.hi.updateTargetData(i,a).next(()=>e.hi.removeMatchingKeysForTargetId(i,n.targetId)).next(()=>e.hi.addMatchingKeys(i,r,n.targetId)).next(()=>e.Ti.saveNamedQuery(i,t))})}let oF="firestore_clients";function oV(e,t){return`${oF}_${e}_${t}`}let oB="firestore_mutations";function oU(e,t,r){let n=`${oB}_${e}_${r}`;return t.isAuthenticated()&&(n+=`_${t.uid}`),n}let oq="firestore_targets";function oj(e,t){return`${oq}_${e}_${t}`}
20let oz="SharedClientState";class o${constructor(e,t,r,n){this.user=e,this.batchId=t,this.state=r,this.error=n}static Ks(e,t,r){let n=JSON.parse(r),i,s="object"==typeof n&&-1!==["pending","acknowledged","rejected"].indexOf(n.state)&&(void 0===n.error||"object"==typeof n.error);return s&&n.error&&(s="string"==typeof n.error.message&&"string"==typeof n.error.code)&&(i=new tl(n.error.code,n.error.message)),s?new o$(e,t,n.state,i):(tt(oz,`Failed to parse mutation state for ID '${t}': ${r}`),null)}Ws(){let e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class oG{constructor(e,t,r){this.targetId=e,this.state=t,this.error=r}static Ks(e,t){let r=JSON.parse(t),n,i="object"==typeof r&&-1!==["not-current","current","rejected"].indexOf(r.state)&&(void 0===r.error||"object"==typeof r.error);return i&&r.error&&(i="string"==typeof r.error.message&&"string"==typeof r.error.code)&&(n=new tl(r.error.code,r.error.message)),i?new oG(e,r.state,n):(tt(oz,`Failed to parse target state for ID '${e}': ${t}`),null)}Ws(){let e={state:this.state,updateTimeMs:Date.now()};return this.error&&(e.error={code:this.error.code,message:this.error.message}),JSON.stringify(e)}}class oK{constructor(e,t){this.clientId=e,this.activeTargetIds=t}static Ks(e,t){let r=JSON.parse(t),n="object"==typeof r&&r.activeTargetIds instanceof Array,i=iW;for(let e=0;n&&e<r.activeTargetIds.length;++e)n=ru(r.activeTargetIds[e]),i=i.add(r.activeTargetIds[e]);return n?new oK(e,i):(tt(oz,`Failed to parse client data for instance '${e}': ${t}`),null)}}class oQ{constructor(e,t){this.clientId=e,this.onlineState=t}static Ks(e){let t=JSON.parse(e);return"object"==typeof t&&-1!==["Unknown","Online","Offline"].indexOf(t.onlineState)&&"string"==typeof t.clientId?new oQ(t.clientId,t.onlineState):(tt(oz,`Failed to parse online state: ${e}`),null)}}class oH{constructor(){this.activeTargetIds=iW}Gs(e){this.activeTargetIds=this.activeTargetIds.add(e)}zs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){return JSON.stringify({activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()})}}class oW{constructor(e,t,r,n,i){this.window=e,this.Fi=t,this.persistenceKey=r,this.js=n,this.syncEngine=null,this.onlineStateHandler=null,this.sequenceNumberHandler=null,this.Js=this.Hs.bind(this),this.Ys=new nl(tb),this.started=!1,this.Zs=[];const s=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");this.storage=this.window.localStorage,this.currentUser=i,this.Xs=oV(this.persistenceKey,this.js),this.eo=function(e){return`firestore_sequence_number_${e}`}(this.persistenceKey),this.Ys=this.Ys.insert(this.js,new oH),this.no=RegExp(`^${oF}_${s}_([^_]*)$`),this.ro=RegExp(`^${oB}_${s}_(\\d+)(?:_(.*))?$`),this.io=RegExp(`^${oq}_${s}_(\\d+)$`),this.so=function(e){return`firestore_online_state_${e}`}(this.persistenceKey),this.oo=function(e){return`firestore_bundle_loaded_v2_${e}`}(this.persistenceKey),this.window.addEventListener("storage",this.Js)}static C(e){return!(!e||!e.localStorage)}async start(){for(let e of(await this.syncEngine.Ps())){if(e===this.js)continue;let t=this.getItem(oV(this.persistenceKey,e));if(t){let r=oK.Ks(e,t);r&&(this.Ys=this.Ys.insert(r.clientId,r))}}this._o();let e=this.storage.getItem(this.so);if(e){let t=this.ao(e);t&&this.uo(t)}for(let e of this.Zs)this.Hs(e);this.Zs=[],this.window.addEventListener("pagehide",()=>this.shutdown()),this.started=!0}writeSequenceNumber(e){this.setItem(this.eo,JSON.stringify(e))}getAllActiveQueryTargets(){return this.co(this.Ys)}isActiveQueryTarget(e){let t=!1;return this.Ys.forEach((r,n)=>{n.activeTargetIds.has(e)&&(t=!0)}),t}addPendingMutation(e){this.lo(e,"pending")}updateMutationState(e,t,r){this.lo(e,t,r),this.ho(e)}addLocalQueryTarget(e,t=!0){let r="not-current";if(this.isActiveQueryTarget(e)){let t=this.storage.getItem(oj(this.persistenceKey,e));if(t){let n=oG.Ks(e,t);n&&(r=n.state)}}return t&&this.Po.Gs(e),this._o(),r}removeLocalQueryTarget(e){this.Po.zs(e),this._o()}isLocalQueryTarget(e){return this.Po.activeTargetIds.has(e)}clearQueryState(e){this.removeItem(oj(this.persistenceKey,e))}updateQueryState(e,t,r){this.To(e,t,r)}
20handleUserChange(e,t,r){t.forEach(e=>{this.ho(e)}),this.currentUser=e,r.forEach(e=>{this.addPendingMutation(e)})}setOnlineState(e){this.Io(e)}notifyBundleLoaded(e){this.Eo(e)}shutdown(){this.started&&(this.window.removeEventListener("storage",this.Js),this.removeItem(this.Xs),this.started=!1)}getItem(e){let t=this.storage.getItem(e);return te(oz,"READ",e,t),t}setItem(e,t){te(oz,"SET",e,t),this.storage.setItem(e,t)}removeItem(e){te(oz,"REMOVE",e),this.storage.removeItem(e)}Hs(e){if(e.storageArea===this.storage){if(te(oz,"EVENT",e.key,e.newValue),e.key===this.Xs)return void tt("Received WebStorage notification for local change. Another client might have garbage-collected our state");this.Fi.enqueueRetryable(async()=>{if(this.started){if(null!==e.key){if(this.no.test(e.key)){if(null==e.newValue){let t=this.Ao(e.key);return this.Ro(t,null)}{let t=this.Vo(e.key,e.newValue);if(t)return this.Ro(t.clientId,t)}}else if(this.ro.test(e.key)){if(null!==e.newValue){let t=this.mo(e.key,e.newValue);if(t)return this.fo(t)}}else if(this.io.test(e.key)){if(null!==e.newValue){let t=this.po(e.key,e.newValue);if(t)return this.yo(t)}}else if(e.key===this.so){if(null!==e.newValue){let t=this.ao(e.newValue);if(t)return this.uo(t)}}else if(e.key===this.eo){let t=function(e){let t=ra.ue;if(null!=e)try{let r=JSON.parse(e);ta("number"==typeof r,30636,{wo:e}),t=r}catch(e){tt(oz,"Failed to read sequence number from WebStorage",e)}return t}(e.newValue);t!==ra.ue&&this.sequenceNumberHandler(t)}else if(e.key===this.oo){let t=this.So(e.newValue);await Promise.all(t.map(e=>this.syncEngine.bo(e)))}}}else this.Zs.push(e)})}}get Po(){return this.Ys.get(this.js)}_o(){this.setItem(this.Xs,this.Po.Ws())}lo(e,t,r){let n=new o$(this.currentUser,e,t,r),i=oU(this.persistenceKey,this.currentUser,e);this.setItem(i,n.Ws())}ho(e){let t=oU(this.persistenceKey,this.currentUser,e);this.removeItem(t)}Io(e){let t={clientId:this.js,onlineState:e};this.storage.setItem(this.so,JSON.stringify(t))}To(e,t,r){let n=oj(this.persistenceKey,e),i=new oG(e,t,r);this.setItem(n,i.Ws())}Eo(e){let t=JSON.stringify(Array.from(e));this.setItem(this.oo,t)}Ao(e){let t=this.no.exec(e);return t?t[1]:null}Vo(e,t){let r=this.Ao(e);return oK.Ks(r,t)}mo(e,t){let r=this.ro.exec(e),n=Number(r[1]),i=void 0!==r[2]?r[2]:null;return o$.Ks(new e4(i),n,t)}po(e,t){let r=Number(this.io.exec(e)[1]);return oG.Ks(r,t)}ao(e){return oQ.Ks(e)}So(e){return JSON.parse(e)}async fo(e){if(e.user.uid===this.currentUser.uid)return this.syncEngine.Do(e.batchId,e.state,e.error);te(oz,`Ignoring mutation for non-active user ${e.user.uid}`)}yo(e){return this.syncEngine.vo(e.targetId,e.state,e.error)}Ro(e,t){let r=t?this.Ys.insert(e,t):this.Ys.remove(e),n=this.co(this.Ys),i=this.co(r),s=[],a=[];return i.forEach(e=>{n.has(e)||s.push(e)}),n.forEach(e=>{i.has(e)||a.push(e)}),this.syncEngine.Co(s,a).then(()=>{this.Ys=r})}uo(e){this.Ys.get(e.clientId)&&this.onlineStateHandler(e.onlineState)}co(e){let t=iW;return e.forEach((e,r)=>{t=t.unionWith(r.activeTargetIds)}),t}}class oX{constructor(){this.Fo=new oH,this.Mo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,r){}addLocalQueryTarget(e,t=!0){return t&&this.Fo.Gs(e),this.Mo[e]||"not-current"}updateQueryState(e,t,r){this.Mo[e]=t}removeLocalQueryTarget(e){this.Fo.zs(e)}isLocalQueryTarget(e){return this.Fo.activeTargetIds.has(e)}clearQueryState(e){delete this.Mo[e]}getAllActiveQueryTargets(){return this.Fo.activeTargetIds}isActiveQueryTarget(e){return this.Fo.activeTargetIds.has(e)}start(){return this.Fo=new oH,Promise.resolve()}handleUserChange(e,t,r){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class oJ{xo(e){}shutdown(){}}let oY="ConnectivityMonitor";class oZ{constructor(){this.Oo=()=>this.No(),this.Bo=()=>this.Lo(),this.ko=[],this.qo()}xo(e){this.ko.push(e)}shutdown(){window.removeEventListener("online",this.Oo),window.removeEventListener("offline",this.Bo)}qo(){window.addEventListener("online",this.Oo),window.addEventListener("offline",this.Bo)}No(){for(let e of(te(oY,"Network connectivity changed: AVAILABLE"),this.ko))e(0)}Lo(){for(let e of(te(oY,"Network connectivity changed: UNAVAILABLE"),this.ko))e(1)}static C(){return"u">typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let o0=null;function o1(){return null===o0?o0=0x10000000+Math.round(0x80000000*Math.random()):o0++,"0x"+o0.toString(16)}let o2="RestConnection",o6={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregation
20Query:"runAggregationQuery"};class o3{get Qo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",r=encodeURIComponent(this.databaseId.projectId),n=encodeURIComponent(this.databaseId.database);this.$o=t+"://"+e.host,this.Uo=`projects/${r}/databases/${n}`,this.Ko=this.databaseId.database===nD?`project_id=${r}`:`project_id=${r}&database_id=${n}`}Wo(e,t,r,n,i){let s=o1(),a=this.Go(e,t.toUriEncodedString());te(o2,`Sending RPC '${e}' ${s}:`,a,r);let o={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.Ko};this.zo(o,n,i);let{host:l}=new URL(a),u=M(l);return this.jo(e,a,o,r,u).then(t=>(te(o2,`Received RPC '${e}' ${s}: `,t),t),t=>{throw tr(o2,`RPC '${e}' ${s} failed with error: `,t,"url: ",a,"request:",r),t})}Jo(e,t,r,n,i,s){return this.Wo(e,t,r,n,i)}zo(e,t,r){e["X-Goog-Api-Client"]="gl-js/ fire/"+e8,e["Content-Type"]="text/plain",this.databaseInfo.appId&&(e["X-Firebase-GMPID"]=this.databaseInfo.appId),t&&t.headers.forEach((t,r)=>e[r]=t),r&&r.headers.forEach((t,r)=>e[r]=t)}Go(e,t){let r=o6[e];return`${this.$o}/v1/${t}:${r}`}terminate(){}}class o5{constructor(e){this.Ho=e.Ho,this.Yo=e.Yo}Zo(e){this.Xo=e}e_(e){this.t_=e}n_(e){this.r_=e}onMessage(e){this.i_=e}close(){this.Yo()}send(e){this.Ho(e)}s_(){this.Xo()}o_(){this.t_()}__(e){this.r_(e)}a_(e){this.i_(e)}}let o4="WebChannelConnection";class o8 extends o3{constructor(e){super(e),this.u_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}jo(e,t,r,n,i){let s=o1();return new Promise((i,a)=>{let o=new l;o.setWithCredentials(!0),o.listenOnce(h.COMPLETE,()=>{try{switch(o.getLastErrorCode()){case c.NO_ERROR:let t=o.getResponseJson();te(o4,`XHR for RPC '${e}' ${s} received:`,JSON.stringify(t)),i(t);break;case c.TIMEOUT:te(o4,`RPC '${e}' ${s} timed out`),a(new tl(to.DEADLINE_EXCEEDED,"Request time out"));break;case c.HTTP_ERROR:let r=o.getStatus();if(te(o4,`RPC '${e}' ${s} failed with status:`,r,"response text:",o.getResponseText()),r>0){let e=o.getResponseJson();Array.isArray(e)&&(e=e[0]);let t=null==e?void 0:e.error;if(t&&t.status&&t.message){let e,r=(e=t.status.toLowerCase().replace(/_/g,"-"),Object.values(to).indexOf(e)>=0?e:to.UNKNOWN);a(new tl(r,t.message))}else a(new tl(to.UNKNOWN,"Server responded with status "+o.getStatus()))}else a(new tl(to.UNAVAILABLE,"Connection failed."));break;default:ti(9055,{c_:e,streamId:s,l_:o.getLastErrorCode(),h_:o.getLastError()})}}finally{te(o4,`RPC '${e}' ${s} completed.`)}});let u=JSON.stringify(n);te(o4,`RPC '${e}' ${s} sending request:`,n),o.send(t,"POST",u,r,15)})}P_(e,t,r){let n=o1(),i=[this.$o,"/","google.firestore.v1.Firestore","/",e,"/channel"],s=g(),a=p(),o={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},l=this.longPollingOptions.timeoutSeconds;void 0!==l&&(o.longPollingTimeout=Math.round(1e3*l)),this.useFetchStreams&&(o.useFetchStreams=!0),this.zo(o.initMessageHeaders,t,r),o.encodeInitMessageHeaders=!0;let h=i.join("");te(o4,`Creating RPC '${e}' stream ${n}: ${h}`,o);let c=s.createWebChannel(h,o);this.T_(c);let y=!1,v=!1,w=new o5({Ho:t=>{v?te(o4,`Not sending because RPC '${e}' stream ${n} is closed:`,t):(y||(te(o4,`Opening RPC '${e}' stream ${n} transport.`),c.open(),y=!0),te(o4,`RPC '${e}' stream ${n} sending:`,t),c.send(t))},Yo:()=>c.close()}),b=(e,t,r)=>{e.listen(t,e=>{try{r(e)}catch(e){setTimeout(()=>{throw e},0)}})};return b(c,u.EventType.OPEN,()=>{v||(te(o4,`RPC '${e}' stream ${n} transport opened.`),w.s_())}),b(c,u.EventType.CLOSE,()=>{v||(v=!0,te(o4,`RPC '${e}' stream ${n} transport closed`),w.__(),this.I_(c))}),b(c,u.EventType.ERROR,t=>{v||(v=!0,tr(o4,`RPC '${e}' stream ${n} transport errored. Name:`,t.name,"Message:",t.message),w.__(new tl(to.UNAVAILABLE,"The operation could not be completed")))}),b(c,u.EventType.MESSAGE,t=>{var r;if(!v){let i=t.data[0];ta(!!i,16349);let s=(null==i?void 0:i.error)||(null==(r=i[0])?void 0:r.error);if(s){te(o4,`RPC '${e}' stream ${n} received error:`,s);let t=s.status,r=function(e){let t=m[e];if(void 0!==t)return sb(t)}(t),i=s.message;
20void 0===r&&(r=to.INTERNAL,i="Unknown error status: "+t+" with message "+s.message),v=!0,w.__(new tl(r,i)),c.close()}else te(o4,`RPC '${e}' stream ${n} received:`,i),w.a_(i)}}),b(a,f.STAT_EVENT,t=>{t.stat===d.PROXY?te(o4,`RPC '${e}' stream ${n} detected buffering proxy`):t.stat===d.NOPROXY&&te(o4,`RPC '${e}' stream ${n} detected no buffering proxy`)}),setTimeout(()=>{w.o_()},0),w}terminate(){this.u_.forEach(e=>e.close()),this.u_=[]}T_(e){this.u_.push(e)}I_(e){this.u_=this.u_.filter(t=>t===e)}}function o7(){return"u">typeof window?window:null}function o9(){return"u">typeof document?document:null}function le(e){return new sB(e,!0)}class lt{constructor(e,t,r=1e3,n=1.5,i=6e4){this.Fi=e,this.timerId=t,this.d_=r,this.E_=n,this.A_=i,this.R_=0,this.V_=null,this.m_=Date.now(),this.reset()}reset(){this.R_=0}f_(){this.R_=this.A_}g_(e){this.cancel();let t=Math.floor(this.R_+this.p_()),r=Math.max(0,Date.now()-this.m_),n=Math.max(0,t-r);n>0&&te("ExponentialBackoff",`Backing off for ${n} ms (base delay: ${this.R_} ms, delay with jitter: ${t} ms, last attempt: ${r} ms ago)`),this.V_=this.Fi.enqueueAfterDelay(this.timerId,n,()=>(this.m_=Date.now(),e())),this.R_*=this.E_,this.R_<this.d_&&(this.R_=this.d_),this.R_>this.A_&&(this.R_=this.A_)}y_(){null!==this.V_&&(this.V_.skipDelay(),this.V_=null)}cancel(){null!==this.V_&&(this.V_.cancel(),this.V_=null)}p_(){return(Math.random()-.5)*this.R_}}let lr="PersistentStream";class ln{constructor(e,t,r,n,i,s,a,o){this.Fi=e,this.w_=r,this.S_=n,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=a,this.listener=o,this.state=0,this.b_=0,this.D_=null,this.v_=null,this.stream=null,this.C_=0,this.F_=new lt(e,t)}M_(){return 1===this.state||5===this.state||this.x_()}x_(){return 2===this.state||3===this.state}start(){this.C_=0,4!==this.state?this.auth():this.O_()}async stop(){this.M_()&&await this.close(0)}N_(){this.state=0,this.F_.reset()}B_(){this.x_()&&null===this.D_&&(this.D_=this.Fi.enqueueAfterDelay(this.w_,6e4,()=>this.L_()))}k_(e){this.q_(),this.stream.send(e)}async L_(){if(this.x_())return this.close(0)}q_(){this.D_&&(this.D_.cancel(),this.D_=null)}Q_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.Q_(),this.F_.cancel(),this.b_++,4!==e?this.F_.reset():t&&t.code===to.RESOURCE_EXHAUSTED?(tt(t.toString()),tt("Using maximum backoff delay to prevent overloading the backend."),this.F_.f_()):t&&t.code===to.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.U_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.n_(t)}U_(){}auth(){this.state=1;let e=this.K_(this.b_),t=this.b_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,r])=>{this.b_===t&&this.W_(e,r)},t=>{e(()=>{let e=new tl(to.UNKNOWN,"Fetching auth token failed: "+t.message);return this.G_(e)})})}W_(e,t){let r=this.K_(this.b_);this.stream=this.z_(e,t),this.stream.Zo(()=>{r(()=>this.listener.Zo())}),this.stream.e_(()=>{r(()=>(this.state=2,this.v_=this.Fi.enqueueAfterDelay(this.S_,1e4,()=>(this.x_()&&(this.state=3),Promise.resolve())),this.listener.e_()))}),this.stream.n_(e=>{r(()=>this.G_(e))}),this.stream.onMessage(e=>{r(()=>1==++this.C_?this.j_(e):this.onNext(e))})}O_(){this.state=5,this.F_.g_(async()=>{this.state=0,this.start()})}G_(e){return te(lr,`close with error: ${e}`),this.stream=null,this.close(4,e)}K_(e){return t=>{this.Fi.enqueueAndForget(()=>this.b_===e?t():(te(lr,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class li extends ln{constructor(e,t,r,n,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,r,n,s),this.serializer=i}z_(e,t){return this.connection.P_("Listen",e,t)}j_(e){return this.onNext(e)}onNext(e){this.F_.reset();let t=function(e,t){let r;if("targetChange"in t){var n,i;t.targetChange;let s="NO_CHANGE"===(n=t.targetChange.targetChangeType||"NO_CHANGE")?0:"ADD"===n?1:"REMOVE"===n?2:"CURRENT"===n?3:"RESET"===n?4:ti(39313,{state:n}),a=t.targetChange.targetIds||[],o=(i=t.targetChange.resumeToken,e.useProto3Json?(ta(void 0===i||"string"==typeof i,58123),nm.fromBase64String(i||"")):(ta(void 0===i||i instanceof E.Buffer||i instanceof Uint8Array,16193),nm.fromUint8Array(i||new Uint8Array))),l=t.targetChange.cause;r=new sk(s,a,o,l&&new tl(void 0===l.code?to.UNKNOWN:sb(l.code),l.message||"")||null)}else if("documentChange"in t){t.documentChange;let n=t.documentChange;n.document,n.document.name,n.document.updateTime;let i=sH(e,n.document.name),s=sz(n.document.updateTime),a=n.document.createTime?sz(n.document.createTime):tq.min(),o=new n2({mapValue:{fields:n.document.fields}}),l=n6.newFoundDocument(i,s,a,o);r=new sD(n.targetIds||[],n.removedTargetIds||[],l.key,l)}else if("documentDelete"in t){t.documentDelete;let n=t.documentDelete;n.document;let i=sH(e,n.document),s=n.readTime?sz(n.readTime):tq.min(),a=n6.newNoDocument(i,s);r=new sD([],n.removedTargetIds||[],a.key,a)}else if("documentRemove"in t){t.documentRemove;let n=t.documentRemove;n.document;let i=sH(e,n.document);r=new sD([],n.removedTargetIds||[],i,null)}else{if(!("filter"in t))return ti(11601,{At:t});{t.filter;let e=t.filter;e.targetId;
20let{count:n=0,unchangedNames:i}=e,s=new sv(n,i);r=new sN(e.targetId,s)}}return r}(this.serializer,e),r=function(e){if(!("targetChange"in e))return tq.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?tq.min():t.readTime?sz(t.readTime):tq.min()}(e);return this.listener.J_(t,r)}H_(e){let t,r={};r.database=sJ(this.serializer),r.addTarget=function(e,t){let r,n=t.target;if((r=ib(n)?{documents:s6(e,n)}:{query:s3(e,n).Vt}).targetId=t.targetId,t.resumeToken.approximateByteSize()>0){r.resumeToken=sj(e,t.resumeToken);let n=sU(e,t.expectedCount);null!==n&&(r.expectedCount=n)}else if(t.snapshotVersion.compareTo(tq.min())>0){r.readTime=sq(e,t.snapshotVersion.toTimestamp());let n=sU(e,t.expectedCount);null!==n&&(r.expectedCount=n)}return r}(this.serializer,e);let n=(this.serializer,null==(t=function(e){switch(e){case"TargetPurposeListen":return null;case"TargetPurposeExistenceFilterMismatch":return"existence-filter-mismatch";case"TargetPurposeExistenceFilterMismatchBloom":return"existence-filter-mismatch-bloom";case"TargetPurposeLimboResolution":return"limbo-document";default:return ti(28987,{purpose:e})}}(e.purpose))?null:{"goog-listen-tags":t});n&&(r.labels=n),this.k_(r)}Y_(e){let t={};t.database=sJ(this.serializer),t.removeTarget=e,this.k_(t)}}class ls extends ln{constructor(e,t,r,n,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,r,n,s),this.serializer=i}get Z_(){return this.C_>0}start(){this.lastStreamToken=void 0,super.start()}U_(){this.Z_&&this.X_([])}z_(e,t){return this.connection.P_("Write",e,t)}j_(e){return ta(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,ta(!e.writeResults||0===e.writeResults.length,55816),this.listener.ea()}onNext(e){var t,r;ta(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.F_.reset();let n=(t=e.writeResults,r=e.commitTime,t&&t.length>0?(ta(void 0!==r,14353),t.map(e=>{let t;return(t=e.updateTime?sz(e.updateTime):sz(r)).isEqual(tq.min())&&(t=sz(r)),new se(t,e.transformResults||[])})):[]),i=sz(e.commitTime);return this.listener.ta(i,n)}na(){let e={};e.database=sJ(this.serializer),this.k_(e)}X_(e){let t={streamToken:this.lastStreamToken,writes:e.map(e=>s1(this.serializer,e))};this.k_(t)}}class la{}class lo extends la{constructor(e,t,r,n){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=r,this.serializer=n,this.ra=!1}ia(){if(this.ra)throw new tl(to.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,r,n){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,s])=>this.connection.Wo(e,sG(t,r),n,i,s)).catch(e=>{throw"FirebaseError"===e.name?(e.code===to.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new tl(to.UNKNOWN,e.toString())})}Jo(e,t,r,n,i){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,a])=>this.connection.Jo(e,sG(t,r),n,s,a,i)).catch(e=>{throw"FirebaseError"===e.name?(e.code===to.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new tl(to.UNKNOWN,e.toString())})}terminate(){this.ra=!0,this.connection.terminate()}}class ll{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.sa=0,this.oa=null,this._a=!0}aa(){0===this.sa&&(this.ua("Unknown"),this.oa=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.oa=null,this.ca("Backend didn't respond within 10 seconds."),this.ua("Offline"),Promise.resolve())))}la(e){"Online"===this.state?this.ua("Unknown"):(this.sa++,this.sa>=1&&(this.ha(),this.ca(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ua("Offline")))}set(e){this.ha(),this.sa=0,"Online"===e&&(this._a=!1),this.ua(e)}ua(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}ca(e){let t=`Could not reach Cloud Firestore backend. ${e}
21This 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._a?(tt(t),this._a=!1):te("OnlineStateTracker",t)}ha(){null!==this.oa&&(this.oa.cancel(),this.oa=null)}}let lu="RemoteStore";class lh{constructor(e,t,r,n,i){this.localStore=e,this.datastore=t,this.asyncQueue=r,this.remoteSyncer={},this.Pa=[],this.Ta=new Map,this.Ia=new Set,this.da=[],this.Ea=i,this.Ea.xo(e=>{r.enqueueAndForget(async()=>
21{lw(this)&&(te(lu,"Restarting streams for network reachability change."),await async function(e){e.Ia.add(4),await ld(e),e.Aa.set("Unknown"),e.Ia.delete(4),await lc(e)}(this))})}),this.Aa=new ll(r,n)}}async function lc(e){if(lw(e))for(let t of e.da)await t(!0)}async function ld(e){for(let t of e.da)await t(!1)}function lf(e,t){e.Ta.has(t.targetId)||(e.Ta.set(t.targetId,t),lv(e)?ly(e):lM(e).x_()&&lg(e,t))}function lp(e,t){let r=lM(e);e.Ta.delete(t),r.x_()&&lm(e,t),0===e.Ta.size&&(r.x_()?r.B_():lw(e)&&e.Aa.set("Unknown"))}function lg(e,t){if(e.Ra.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(tq.min())>0){let r=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(r)}lM(e).H_(t)}function lm(e,t){e.Ra.$e(t),lM(e).Y_(t)}function ly(e){e.Ra=new sR({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),Et:t=>e.Ta.get(t)||null,lt:()=>e.datastore.serializer.databaseId}),lM(e).start(),e.Aa.aa()}function lv(e){return lw(e)&&!lM(e).M_()&&e.Ta.size>0}function lw(e){return 0===e.Ia.size}async function lb(e){e.Aa.set("Online")}async function lE(e){e.Ta.forEach((t,r)=>{lg(e,t)})}async function lI(e,t){e.Ra=void 0,lv(e)?(e.Aa.la(t),ly(e)):e.Aa.set("Unknown")}async function l_(e,t,r){if(e.Aa.set("Online"),t instanceof sk&&2===t.state&&t.cause)try{await async function(e,t){let r=t.cause;for(let n of t.targetIds)e.Ta.has(n)&&(await e.remoteSyncer.rejectListen(n,r),e.Ta.delete(n),e.Ra.removeTarget(n))}(e,t)}catch(r){te(lu,"Failed to remove targets %s: %s ",t.targetIds.join(","),r),await lT(e,r)}else if(t instanceof sD?e.Ra.Ye(t):t instanceof sN?e.Ra.it(t):e.Ra.et(t),!r.isEqual(tq.min()))try{let t,n=await oC(e.localStore);r.compareTo(n)>
21=0&&await ((t=e.Ra.Pt(r)).targetChanges.forEach((t,n)=>{if(t.resumeToken.approximateByteSize()>0){let i=e.Ta.get(n);i&&e.Ta.set(n,i.withResumeToken(t.resumeToken,r))}}),t.targetMismatches.forEach((t,r)=>{let n=e.Ta.get(t);if(!n)return;e.Ta.set(t,n.withResumeToken(nm.EMPTY_BYTE_STRING,n.snapshotVersion)),lm(e,t);let i=new ae(n.target,t,r,n.sequenceNumber);lg(e,i)}),e.remoteSyncer.applyRemoteEvent(t))}catch(t){te(lu,"Failed to raise snapshot:",t),await lT(e,t)}}async function lT(e,t,r){if(!t7(t))throw t;e.Ia.add(1),await ld(e),e.Aa.set("Offline"),r||(r=()=>oC(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{te(lu,"Retrying IndexedDB access"),await r(),e.Ia.delete(1),await lc(e)})}function lS(e,t){return t().catch(r=>lT(e,r,t))}async function lx(e){var t;let r=lP(e),n=e.Pa.length>0?e.Pa[e.Pa.length-1].batchId:-1;for(;lw(t=e)&&t.Pa.length<10;)try{let t=await function(e,t){return e.persistence.runTransaction("Get next mutation batch","readonly",r=>(void 0===t&&(t=-1),e.mutationQueue.getNextMutationBatchAfterBatchId(r,t)))}(e.localStore,n);if(null===t){0===e.Pa.length&&r.B_();break}n=t.batchId,function(e,t){e.Pa.push(t);let r=lP(e);r.x_()&&r.Z_&&r.X_(t.mutations)}(e,t)}catch(t){await lT(e,t)}lC(e)&&lA(e)}function lC(e){return lw(e)&&!lP(e).M_()&&e.Pa.length>0}function lA(e){lP(e).start()}async function lD(e){lP(e).na()}async function lN(e){let t=lP(e);for(let r of e.Pa)t.X_(r.mutations)}async function lk(e,t,r){let n=e.Pa.shift(),i=sg.from(n,t,r);await lS(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await lx(e)}async function lO(e,t){t&&lP(e).Z_&&await async function(e,t){var r;if(sw(r=t.code)&&r!==to.ABORTED){let r=e.Pa.shift();lP(e).N_(),await lS(e,()=>e.remoteSyncer.rejectFailedWrite(r.batchId,t)),await lx(e)}}(e,t),lC(e)&&lA(e)}async function lR(e,t){e.asyncQueue.verifyOperationInProgress(),te(lu,"RemoteStore received new credentials");let r=lw(e);e.Ia.add(3),await ld(e),r&&e.Aa.set("Unknown"),await e.remoteSyncer.handleCredentialChange(t),e.Ia.delete(3),await lc(e)}async function lL(e,t){t?(e.Ia.delete(2),await lc(e)):t||(e.Ia.add(2),await ld(e),e.Aa.set("Unknown"))}function lM(e){var t,r,n;return e.Va||(t=e.datastore,r=e.asyncQueue,n={Zo:lb.bind(null,e),e_:lE.bind(null,e),n_:lI.bind(null,e),J_:l_.bind(null,e)},t.ia(),e.Va=new li(r,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,n),e.da.push(async t=>{t?(e.Va.N_(),lv(e)?ly(e):e.Aa.set("Unknown")):(await e.Va.stop(),e.Ra=void 0)})),e.Va}function lP(e){var t,r,n;return e.ma||(t=e.datastore,r=e.asyncQueue,n={Zo:()=>Promise.resolve(),e_:lD.bind(null,e),n_:lO.bind(null,e),ea:lN.bind(null,e),ta:lk.bind(null,e)},t.ia(),e.ma=new ls(r,t.connection,t.authCredentials,t.appCheckCredentials,t.serializer,n),e.da.push(async t=>{t?(e.ma.N_(),await lx(e)):(await e.ma.stop(),e.Pa.length>0&&(te(lu,`Stopping write stream with ${e.Pa.length} pending writes`),e.Pa=[]))})),e.ma}class lF{constructor(e,t,r,n,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=r,this.op=n,this.removalCallback=i,this.deferred=new tu,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(e=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,r,n,i){let s=new lF(e,t,Date.now()+r,n,i);return s.start(r),s}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new tl(to.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function lV(e,t){if(tt("AsyncQueue",`${t}: ${e}`),t7(e))return new tl(to.UNAVAILABLE,`${t}: ${e}`);throw e}class lB{static emptySet(e){return new lB(e.comparator)}constructor(e){this.comparator=e?(t,r)=>e(t,r)||tD.comparator(t.key,r.key):(e,t)=>tD.comparator(e.key,t.key),this.keyedMap=iz(),this.sortedSet=new nl(this.comparator)}has(e){return null!=this.keyedMap.get(e)}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){let t=this.keyedMap.get(e);return t?this.sortedSet.indexOf(t):-1}get size(){return this.sortedSet.size}forEach(e){this.sortedSet.inorderTraversal((t,r)=>(e(t),!1))}add(e){let t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){let t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof lB)||this.size!==e.size)return!1;let t=this.sortedSet.getIterator(),r=e.sortedSet.getIterator();for(;t.hasNext();){let e=t.getNext().key,n=r.getNext().key;if(!e.isEqual(n))return!1}return!0}toString(){let e=[];return this.forEach(t=>{e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n  "+e.join("  \n")+"\n)"}copy(e,t){let r=new lB;return r.comparator=this.comparator,r.keyedMap=e,r.sortedSet=t,r}}class lU{constructor(){this.fa=new nl(tD.comparator)}track(e){let t=e.doc.key,r=this.fa.get(t);r?0!==e.type&&3===r.type?this.fa=this.fa.insert(t,e):3===e.type&&1!==r.type?this.fa=this.fa.insert(t,{type:r.type,doc:e.doc}):2===e.type&&2===r.type?this.fa=this.fa.insert(t,{type:2,doc:e.doc}):2===e.type&&0===r.type?this.fa=this.fa.insert(t,{type:0,doc:e.doc}):1===e.type&&0===r.type?this.fa=this.fa.remove(t):1===e.type&&2===r.type?this.fa=this.fa.insert(t,{type:1,doc:r.doc}):0===e.type&&1===r.type?this.fa=this.fa.insert(t,{type:2,doc:e.doc}):ti(63341,{At:e,ga:r}):this.fa=this.fa.insert(t,e)}pa(){let e=[];return this.fa.inorderTraversal((t,r)=>{e.push(r)}),e}}class lq{constructor(e,t,r,n,i,s,a,o,l){this.query=e,this.docs=t,this.oldDocs=r,this.docChanges=n,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=a,this.excludesMetadataChanges=o,this.hasCachedResults=l}static fromInitialDocuments(e,t,r,n,i){let s=[];
21return t.forEach(e=>{s.push({type:0,doc:e})}),new lq(e,t,lB.emptySet(t),s,r,n,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&iL(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,r=e.docChanges;if(t.length!==r.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==r[e].type||!t[e].doc.isEqual(r[e].doc))return!1;return!0}}class lj{constructor(){this.ya=void 0,this.wa=[]}Sa(){return this.wa.some(e=>e.ba())}}class lz{constructor(){this.queries=l$(),this.onlineState="Unknown",this.Da=new Set}terminate(){var e;let t;e=new tl(to.ABORTED,"Firestore shutting down"),t=this.queries,this.queries=l$(),t.forEach((t,r)=>{for(let t of r.wa)t.onError(e)})}}function l$(){return new iU(e=>iM(e),iL)}async function lG(e,t){let r=3,n=t.query,i=e.queries.get(n);i?!i.Sa()&&t.ba()&&(r=2):(i=new lj,r=+!t.ba());try{switch(r){case 0:i.ya=await e.onListen(n,!0);break;case 1:i.ya=await e.onListen(n,!1);break;case 2:await e.onFirstRemoteStoreListen(n)}}catch(r){let e=lV(r,`Initialization of query '${iP(t.query)}' failed`);return void t.onError(e)}e.queries.set(n,i),i.wa.push(t),t.va(e.onlineState),i.ya&&t.Ca(i.ya)&&lW(e)}async function lK(e,t){let r=t.query,n=3,i=e.queries.get(r);if(i){let e=i.wa.indexOf(t);e>=0&&(i.wa.splice(e,1),0===i.wa.length?n=+!t.ba():!i.Sa()&&t.ba()&&(n=2))}switch(n){case 0:return e.queries.delete(r),e.onUnlisten(r,!0);case 1:return e.queries.delete(r),e.onUnlisten(r,!1);case 2:return e.onLastRemoteStoreUnlisten(r);default:return}}function lQ(e,t){let r=!1;for(let n of t){let t=n.query,i=e.queries.get(t);if(i){for(let e of i.wa)e.Ca(n)&&(r=!0);i.ya=n}}r&&lW(e)}function lH(e,t,r){let n=e.queries.get(t);if(n)for(let e of n.wa)e.onError(r);e.queries.delete(t)}
21function lW(e){e.Da.forEach(e=>{e.next()})}(w=v||(v={})).Fa="default",w.Cache="cache";class lX{constructor(e,t,r){this.query=e,this.Ma=t,this.xa=!1,this.Oa=null,this.onlineState="Unknown",this.options=r||{}}Ca(e){if(!this.options.includeMetadataChanges){let t=[];for(let r of e.docChanges)3!==r.type&&t.push(r);e=new lq(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.xa?this.Na(e)&&(this.Ma.next(e),t=!0):this.Ba(e,this.onlineState)&&(this.La(e),t=!0),this.Oa=e,t}onError(e){this.Ma.error(e)}va(e){this.onlineState=e;let t=!1;return this.Oa&&!this.xa&&this.Ba(this.Oa,e)&&(this.La(this.Oa),t=!0),t}Ba(e,t){return!(e.fromCache&&this.ba())||(!this.options.ka||"Offline"===t)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}Na(e){if(e.docChanges.length>0)return!0;let t=this.Oa&&this.Oa.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}La(e){e=lq.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.xa=!0,this.Ma.next(e)}ba(){return this.options.source!==v.Cache}}class lJ{constructor(e,t){this.qa=e,this.byteLength=t}Qa(){return"metadata"in this.qa}}class lY{constructor(e){this.serializer=e}Qs(e){return sH(this.serializer,e)}$s(e){return e.metadata.exists?s0(this.serializer,e.document,!1):n6.newNoDocument(this.Qs(e.metadata.name),this.Us(e.metadata.readTime))}Us(e){return sz(e)}}class lZ{constructor(e,t){this.$a=e,this.serializer=t,this.Ua=[],this.Ka=[],this.collectionGroups=new Set,this.progress=l0(e)}get queries(){return this.Ua}get documents(){return this.Ka}Wa(e){this.progress.bytesLoaded+=e.byteLength;let t=this.progress.documentsLoaded;if(e.qa.namedQuery)this.Ua.push(e.qa.namedQuery);else if(e.qa.documentMetadata){this.Ka.push({metadata:e.qa.documentMetadata}),e.qa.documentMetadata.exists||++t;let r=tx.fromString(e.qa.documentMetadata.name);this.collectionGroups.add(r.get(r.length-2))}else e.qa.document&&(this.Ka[this.Ka.length-1].document=e.qa.document,++t);return t!==this.progress.documentsLoaded?(this.progress.documentsLoaded=t,Object.assign({},this.progress)):null}Ga(e){let t=new Map,r=new lY(this.serializer);for(let n of e)if(n.metadata.queries){let e=r.Qs(n.metadata.name);for(let r of n.metadata.queries){let n=(t.get(r)||iH()).add(e);t.set(r,n)}}return t}async za(e){let t=await oM(e,new lY(this.serializer),this.Ka,this.$a.id),r=this.Ga(this.documents);for(let t of this.Ua)await oP(e,t,r.get(t.name));return this.progress.taskState="Success",{progress:this.progress,ja:this.collectionGroups,Ja:t}}}function l0(e){return{taskState:"Running",documentsLoaded:0,bytesLoaded:0,totalDocuments:e.totalDocuments,totalBytes:e.totalBytes}}class l1{constructor(e){this.key=e}}class l2{constructor(e){this.key=e}}class l6{constructor(e,t){this.query=e,this.Ha=t,this.Ya=null,this.hasCachedResults=!1,this.current=!1,this.Za=iH(),this.mutatedKeys=iH(),this.Xa=iB(e),this.eu=new lB(this.Xa)}get tu(){return this.Ha}nu(e,t){let r=t?t.ru:new lU,n=t?t.eu:this.eu,i=t?t.mutatedKeys:this.mutatedKeys,s=n,a=!1,o="F"===this.query.limitType&&n.size===this.query.limit?n.last():null,l="L"===this.query.limitType&&n.size===this.query.limit?n.first():null;if(e.inorderTraversal((e,t)=>{let u=n.get(e),h=iF(this.query,t)?t:null,c=!!u&&this.mutatedKeys.has(u.key),d=!!h&&(h.hasLocalMutations||this.mutatedKeys.has(h.key)&&h.hasCommittedMutations),f=!1;u&&h?u.data.isEqual(h.data)?c!==d&&(r.track({type:3,doc:h}),f=!0):this.iu(u,h)||(r.track({type:2,doc:h}),f=!0,(o&&this.Xa(h,o)>0||l&&0>this.Xa(h,l))&&(a=!0)):!u&&h?(r.track({type:0,doc:h}),f=!0):u&&!h&&(r.track({type:1,doc:u}),f=!0,(o||l)&&(a=!0)),f&&(h?(s=s.add(h),i=d?i.add(e):i.delete(e)):(s=s.delete(e),i=i.delete(e)))}),null!==this.query.limit)for(;s.size>this.query.limit;){let e="F"===this.query.limitType?s.last():s.first();s=s.delete(e.key),i=i.delete(e.key),r.track({type:1,doc:e})}return{eu:s,ru:r,Ds:a,mutatedKeys:i}}iu(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,r,n){let i=this.eu;this.eu=e.eu,this.mutatedKeys=e.mutatedKeys;let s=e.ru.pa();s.sort((e,t)=>
21{var r,n;let i;return r=e.type,n=t.type,(i=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return ti(20277,{At:e})}})(r)-i(n)||this.Xa(e.doc,t.doc)}),this.su(r),n=null!=n&&n;let a=t&&!n?this.ou():[],o=0===this.Za.size&&this.current&&!n?1:0,l=o!==this.Ya;return(this.Ya=o,0!==s.length||l)?{snapshot:new lq(this.query,e.eu,i,s,e.mutatedKeys,0===o,l,!1,!!r&&r.resumeToken.approximateByteSize()>0),_u:a}:{_u:a}}va(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({eu:this.eu,ru:new lU,mutatedKeys:this.mutatedKeys,Ds:!1},!1)):{_u:[]}}au(e){return!this.Ha.has(e)&&!!this.eu.has(e)&&!this.eu.get(e).hasLocalMutations}su(e){e&&(e.addedDocuments.forEach(e=>this.Ha=this.Ha.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.Ha=this.Ha.delete(e)),this.current=e.current)}ou(){if(!this.current)return[];let e=this.Za;this.Za=iH(),this.eu.forEach(e=>{this.au(e.key)&&(this.Za=this.Za.add(e.key))});let t=[];return e.forEach(e=>{this.Za.has(e)||t.push(new l2(e))}
21),this.Za.forEach(r=>{e.has(r)||t.push(new l1(r))}),t}uu(e){this.Ha=e.qs,this.Za=iH();let t=this.nu(e.documents);return this.applyChanges(t,!0)}cu(){return lq.fromInitialDocuments(this.query,this.eu,this.mutatedKeys,0===this.Ya,this.hasCachedResults)}}let l3="SyncEngine";class l5{constructor(e,t,r){this.query=e,this.targetId=t,this.view=r}}class l4{constructor(e){this.key=e,this.lu=!1}}class l8{constructor(e,t,r,n,i,s){this.localStore=e,this.remoteStore=t,this.eventManager=r,this.sharedClientState=n,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.hu={},this.Pu=new iU(e=>iM(e),iL),this.Tu=new Map,this.Iu=new Set,this.du=new nl(tD.comparator),this.Eu=new Map,this.Au=new oi,this.Ru={},this.Vu=new Map,this.mu=aQ.ur(),this.onlineState="Unknown",this.fu=void 0}get isPrimaryClient(){return!0===this.fu}}async function l7(e,t,r=!0){let n,i=uD(e),s=i.Pu.get(t);return s?(i.sharedClientState.addLocalQueryTarget(s.targetId),n=s.view.cu()):n=await ue(i,t,r,!0),n}async function l9(e,t){let r=uD(e);await ue(r,t,!0,!1)}async function ue(e,t,r,n){let i,s=await oD(e.localStore,iD(t)),a=s.targetId,o=e.sharedCl
21ientState.addLocalQueryTarget(a,r);return n&&(i=await ut(e,t,a,"current"===o,s.resumeToken)),e.isPrimaryClient&&r&&lf(e.remoteStore,s),i}async function ut(e,t,r,n,i){e.gu=(t,r,n)=>(async function(e,t,r,n){let i=t.view.nu(r);i.Ds&&(i=await ok(e.localStore,t.query,!1).then(({documents:e})=>t.view.nu(e,i)));let s=n&&n.targetChanges.get(t.targetId),a=n&&null!=n.targetMismatches.get(t.targetId),o=t.view.applyChanges(i,e.isPrimaryClient,s,a);return ug(e,t.targetId,o._u),o.snapshot})(e,t,r,n);let s=await ok(e.localStore,t,!0),a=new l6(t,s.qs),o=a.nu(s.documents),l=sA.createSynthesizedTargetChangeForCurrentChange(r,n&&"Offline"!==e.onlineState,i),u=a.applyChanges(o,e.isPrimaryClient,l);ug(e,r,u._u);let h=new l5(t,r,a);return e.Pu.set(t,h),e.Tu.has(r)?e.Tu.get(r).push(t):e.Tu.set(r,[t]),u.snapshot}async function ur(e,t,r){let n=e.Pu.get(t),i=e.Tu.get(n.targetId);i.length>1?(e.Tu.set(n.targetId,i.filter(e=>!iL(e,t))),e.Pu.delete(t)):e.isPrimaryClient?(e.sharedClientState.removeLocalQueryTarget(n.targetId),e.sharedClientState.isActiveQueryTarget(n.targetId)||await oN(e.localStore,n.targetId,!1).then(()=>{e.sharedClientState.clearQueryState(n.targetId),r&&lp(e.remoteStore,n.targetId),uf(e,n.targetId)}).catch(t0)):(uf(e,n.targetId),await oN(e.localStore,n.targetId,!0))}async function un(e,t){let r=e.Pu.get(t),n=e.Tu.get(r.targetId);e.isPrimaryClient&&1===n.length&&(e.sharedClientState.removeLocalQueryTarget(r.targetId),lp(e.remoteStore,r.targetId))}async function ui(e,t,r){let n=uN(e);try{var i,s;let e,a,o,l,u,h=await (i=n.localStore,o=tU.now(),l=t.reduce((e,t)=>e.add(t.key),iH()),i.persistence.runTransaction("Locally write mutations","readwrite",r=>{let n=iq,s=iH();return i.Os.getEntries(r,l).next(e=>{(n=e).forEach((e,t)=>{t.isValidDocument()||(s=s.add(e))})}).next(()=>i.localDocuments.getOverlayedDocuments(r,n)).next(n=>{e=n;let s=[];for(let r of t){let t=function(e,t){let r=null;for(let n of e.fieldTransforms){let e=t.data.field(n.field),i=i0(n.transform,e||null);null!=i&&(null===r&&(r=n2.empty()),r.set(n.field,i))}return r||null}(r,e.get(r.key).overlayedDocument);null!=t&&s.push(new sl(r.key,t,function e(t){let r=[];return ns(t.fields,(t,n)=>{let i=new tA([t]);if(nW(n)){let t=e(n.mapValue).fields;if(0===t.length)r.push(i);else for(let e of t)r.push(i.child(e))}else r.push(i)}),new np(r)}(t.value.mapValue),st.exists(!0)))}
21return i.mutationQueue.addMutationBatch(r,o,s,t)}).next(t=>{a=t;let n=t.applyToLocalDocumentSet(e,s);return i.documentOverlayCache.saveOverlays(r,t.batchId,n)})}).then(()=>({batchId:a.batchId,changes:i$(e)})));n.sharedClientState.addPendingMutation(h.batchId),s=h.batchId,(u=n.Ru[n.currentUser.toKey()])||(u=new nl(tb)),u=u.insert(s,r),n.Ru[n.currentUser.toKey()]=u,await uy(n,h.changes),await lx(n.remoteStore)}catch(t){let e=lV(t,"Failed to persist write");r.reject(e)}}async function us(e,t){try{var r,n;let i,s,a=await (r=e.localStore,i=(n=t).snapshotVersion,s=r.Fs,r.persistence.runTransaction("Apply remote event","readwrite-primary",e=>{let t=r.Os.newChangeBuffer({trackRemovals:!0});s=r.Fs;let a=[];n.targetChanges.forEach((t,o)=>{var l;let u=s.get(o);if(!u)return;a.push(r.hi.removeMatchingKeys(e,t.removedDocuments,o).next(()=>r.hi.addMatchingKeys(e,t.addedDocuments,o)));let h=u.withSequenceNumber(e.currentSequenceNumber);null!==n.targetMismatches.get(o)?h=h.withResumeToken(nm.EMPTY_BYTE_STRING,tq.min()).withLastLimboFreeSnapshotVersion(tq.min()):t.resumeToken.approximateByteSize()>0&&(h=h.withResumeToken(t.resumeToken,i)),s=s.insert(o,h),l=h,(0===u.resumeToken.approximateByteSize()||l.snapshotVersion.toMicroseconds()-u.snapshotVersion.toMicroseconds()>=3e8||t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size>0)&&a.push(r.hi.updateTargetData(e,h))});let o=iq,l=iH();if(n.documentUpdates.forEach(t=>{n.resolvedLimboDocuments.has(t)&&a.push(r.persistence.referenceDelegate.updateLimboDocument(e,t))}),a.push(oA(e,t,n.documentUpdates).next(e=>{o=e.Ls,l=e.ks})),!i.isEqual(tq.min())){let t=r.hi.getLastRemoteSnapshotVersion(e).next(t=>r.hi.setTargetsMetadata(e,e.currentSequenceNumber,i));a.push(t)}return t1.waitFor(a).next(()=>t.apply(e)).next(()=>r.localDocuments.getLocalViewOfDocuments(e,o,l)).next(()=>o)}).then(e=>(r.Fs=s,e)));
21t.targetChanges.forEach((t,r)=>{let n=e.Eu.get(r);n&&(ta(t.addedDocuments.size+t.modifiedDocuments.size+t.removedDocuments.size<=1,22616),t.addedDocuments.size>0?n.lu=!0:t.modifiedDocuments.size>0?ta(n.lu,14607):t.removedDocuments.size>0&&(ta(n.lu,42227),n.lu=!1))}),await uy(e,a,t)}catch(e){await t0(e)}}function ua(e,t,r){if(e.isPrimaryClient&&0===r||!e.isPrimaryClient&&1===r){var n;let r,i=[];e.Pu.forEach((e,r)=>{let n=r.view.va(t);n.snapshot&&i.push(n.snapshot)}),(n=e.eventManager).onlineState=t,r=!1,n.queries.forEach((e,n)=>{for(let e of n.wa)e.va(t)&&(r=!0)}),r&&lW(n),i.length&&e.hu.J_(i),e.onlineState=t,e.isPrimaryClient&&e.sharedClientState.setOnlineState(t)}}async function uo(e,t,r){e.sharedClientState.updateQueryState(t,"rejected",r);let n=e.Eu.get(t),i=n&&n.key;if(i){let r=new nl(tD.comparator);r=r.insert(i,n6.newNoDocument(i,tq.min()));let n=iH().add(i),s=new sC(tq.min(),new Map,new nl(tb),r,n);await us(e,s),e.du=e.du.remove(i),e.Eu.delete(t),um(e)}else await oN(e.localStore,t,!1).then(()=>uf(e,t,r)).catch(t0)}async function ul(e,t){let r=t.batch.batchId;try{var n,i;let s=await (n=e.localStore,i=t,n.persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{let t,r,s,a=i.batch.keys(),o=n.Os.newChangeBuffer({trackRemovals:!0});return(r=(t=i.batch).keys(),s=t1.resolve(),r.forEach(r=>{s=s.next(()=>o.getEntry(e,r)).next(e=>{let n=i.docVersions.get(r);ta(null!==n,48541),0>e.version.compareTo(n)&&(t.applyToRemoteDocument(e,i),e.isValidDocument()&&(e.setReadTime(i.commitVersion),o.addEntry(e)))})}),s.next(()=>n.mutationQueue.removeMutationBatch(e,t))).next(()=>o.apply(e)).next(()=>n.mutationQueue.performConsistencyCheck(e)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(e,a,i.batch.batchId)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=iH();for(let r=0;r<e.mutationResults.length;++r)e.mutationResults[r].transformResults.length>0&&(t=t.add(e.batch.mutations[r].key));return t}(i))).next(()=>n.localDocuments.getDocuments(e,a))}));ud(e,r,null),uc(e,r),e.sharedClientState.updateMutationState(r,"acknowledged"),await uy(e,s)}catch(e){await t0(e)}}async function uu(e,t,r){try{var n;let i=await (n=e.localStore,n.persistence.runTransaction("Reject batch","readwrite-primary",e=>{let r;
21return n.mutationQueue.lookupMutationBatch(e,t).next(t=>(ta(null!==t,37113),r=t.keys(),n.mutationQueue.removeMutationBatch(e,t))).next(()=>n.mutationQueue.performConsistencyCheck(e)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,r)).next(()=>n.localDocuments.getDocuments(e,r))}));ud(e,t,r),uc(e,t),e.sharedClientState.updateMutationState(t,"rejected",r),await uy(e,i)}catch(e){await t0(e)}}async function uh(e,t){lw(e.remoteStore)||te(l3,"The network is disabled. The task returned by 'awaitPendingWrites()' will not complete until the network is enabled.");try{var r;let n=await (r=e.localStore).persistence.runTransaction("Get highest unacknowledged batch id","readonly",e=>r.mutationQueue.getHighestUnacknowledgedBatchId(e));if(-1===n)return void t.resolve();let i=e.Vu.get(n)||[];i.push(t),e.Vu.set(n,i)}catch(r){let e=lV(r,"Initialization of waitForPendingWrites() operation failed");t.reject(e)}}function uc(e,t){(e.Vu.get(t)||[]).forEach(e=>{e.resolve()}),e.Vu.delete(t)}function ud(e,t,r){let n=e.Ru[e.currentUser.toKey()];if(n){let i=n.get(t);i&&(r?i.reject(r):i.resolve(),n=n.remove(t)),e.Ru[e.currentUser.toKey()]=n}}function uf(e,t,r=null){for(let n of(e.sharedClientState.removeLocalQueryTarget(t),e.Tu.get(t)))e.Pu.delete(n),r&&e.hu.pu(n,r);e.Tu.delete(t),e.isPrimaryClient&&e.Au.zr(t).forEach(t=>{e.Au.containsKey(t)||up(e,t)})}function up(e,t){e.Iu.delete(t.path.canonicalString());let r=e.du.get(t);null!==r&&(lp(e.remoteStore,r),e.du=e.du.remove(t),e.Eu.delete(r),um(e))}function ug(e,t,r){for(let n of r)n instanceof l1?(e.Au.addReference(n.key,t),function(e,t){let r=t.key,n=r.path.canonicalString();e.du.get(r)||e.Iu.has(n)||(te(l3,"New document in limbo: "+r),e.Iu.add(n),um(e))}(e,n)):n instanceof l2?(te(l3,"Document no longer in limbo: "+n.key),e.Au.removeReference(n.key,t),e.Au.containsKey(n.key)||up(e,n.key)):ti(19791,{yu:n})}function um(e){for(;e.Iu.size>0&&e.du.size<e.maxConcurrentLimboResolutions;){let t=e.Iu.values().next().value;e.Iu.delete(t);let r=new tD(tx.fromString(t)),n=e.mu.next();e.Eu.set(n,new l4(r)),e.du=e.du.insert(r,n),lf(e.remoteStore,new ae(iD(iS(r.path)),n,"TargetPurposeLimboResolution",ra.ue))}}async function uy(e,t,r){let n=[],i=[],s=[];e.Pu.isEmpty()||(e.Pu.forEach((a,o)=>{s.push(e.gu(o,t,r).then(t=>{var s;if((t||r)&&e.isPrimaryClient){let n=t?!t.fromCache:null==(s=null==r?void 0:r.targetChanges.get(o.targetId))?void 0:s.current;e.sharedClientState.updateQueryState(o.targetId,n?"current":"not-current")}if(t){n.push(t);let e=oE.Es(o.targetId,t);i.push(e)}}))}),await Promise.all(s),e.hu.J_(n),await async function(e,t){try{await e.persistence.runTransaction("notifyLocalViewChanges","readwrite",r=>t1.forEach(t,t=>t1.forEach(t.Is,n=>e.persistence.referenceDelegate.addReference(r,t.targetId,n)).next(()=>t1.forEach(t.ds,n=>e.persistence.referenceDelegate.removeReference(r,t.targetId,n)))))}catch(e){if(!t7(e))throw e;te(oT,"Failed to update sequence numbers: "+e)}for(let r of t){let t=r.targetId;if(!r.fromCache){let r=e.Fs.get(t),n=r.snapshotVersion,i=r.withLastLimboFreeSnapshotVersion(n);e.Fs=e.Fs.insert(t,i)}}}(e.localStore,i))}async function uv(e,t){if(!e.currentUser.isEqual(t)){te(l3,"User change. New user:",t.toKey());let r=await ox(e.localStore,t);e.currentUser=t,e.Vu.forEach(e=>{e.forEach(e=>{e.reject(new tl(to.CANCELLED,"'waitForPendingWrites' promise is rejected due to a user change."))})}),e.Vu.clear(),e.sharedClientState.handleUserChange(t,r.removedBatchIds,r.addedBatchIds),await uy(e,r.Bs)}}function uw(e,t){let r=e.Eu.get(t);if(r&&r.lu)return iH().add(r.key);{let r=iH(),n=e.Tu.get(t);if(!n)return r;for(let t of n){let n=e.Pu.get(t);r=r.unionWith(n.view.tu)}return r}}async function ub(e,t){let r=await ok(e.localStore,t.query,!0),n=t.view.uu(r);return e.isPrimaryClient&&ug(e,t.targetId,n._u),n}async function uE(e,t){return oR(e.localStore,t).then(t=>uy(e,t))}async function uI(e,t,r,n){var i,s;let a,o=await (i=e.localStore,a=i.mutationQueue,i.persistence.runTransaction("Lookup mutation documents","readonly",e=>a.Xn(e,t).next(t=>t?i.localDocuments.getDocuments(e,t):t1.resolve(null))));null!==o?("pending"===r?await lx(e.remoteStore):"acknowledged"===r||"rejected"===r?(ud(e,t,n||null),uc(e,t),s=e.localStore,s.mutation
21Queue.rr(t)):ti(6720,"Unknown batchState",{wu:r}),await uy(e,o)):te(l3,"Cannot apply mutation batch with id: "+t)}async function u_(e,t){if(uD(e),uN(e),!0===t&&!0!==e.fu){let t=e.sharedClientState.getAllActiveQueryTargets(),r=await uT(e,t.toArray());for(let t of(e.fu=!0,await lL(e.remoteStore,!0),r))lf(e.remoteStore,t)}else if(!1===t&&!1!==e.fu){let t=[],r=Promise.resolve();e.Tu.forEach((n,i)=>{e.sharedClientState.isLocalQueryTarget(i)?t.push(i):r=r.then(()=>(uf(e,i),oN(e.localStore,i,!0))),lp(e.remoteStore,i)}),await r,await uT(e,t),e.Eu.forEach((t,r)=>{lp(e.remoteStore,r)}),e.Au.jr(),e.Eu=new Map,e.du=new nl(tD.comparator),e.fu=!1,await lL(e.remoteStore,!1)}}async function uT(e,t,r){let n=[],i=[];for(let r of t){let t,s=e.Tu.get(r);if(s&&0!==s.length)for(let r of(t=await oD(e.localStore,iD(s[0])),s)){let t=e.Pu.get(r),n=await ub(e,t);n.snapshot&&i.push(n.snapshot)}else{let n=await oO(e.localStore,r);t=await oD(e.localStore,n),await ut(e,uS(n),r,!1,t.resumeToken)}n.push(t)}return e.hu.J_(i),n}function uS(e){var t,r,n,i,s;return t=e.path,r=e.collectionGroup,n=e.orderBy,i=e.filters,s=e.limit,new iT(t,r,n,i,s,"F",e.startAt,e.endAt)}function ux(e){return e.localStore.persistence.Ps()}async function uC(e,t,r,n){if(e.fu)return void te(l3,"Ignoring unexpected query state notification.");let i=e.Tu.get(t);if(i&&i.length>0)switch(r){case"current":case"not-current":{let n=await oR(e.localStore,iV(i[0])),s=sC.createSynthesizedRemoteEventForCurrentChange(t,"current"===r,nm.EMPTY_BYTE_STRING);await uy(e,n,s);break}case"rejected":await oN(e.localStore,t,!0),uf(e,t,n);break;default:ti(64155,r)}}async function uA(e,t,r){let n=uD(e);if(n.fu){for(let e of t){if(n.Tu.has(e)&&n.sharedClientState.isActiveQueryTarget(e)){te(l3,"Adding an already active target "+e);continue}let t=await oO(n.localStore,e),r=await oD(n.localStore,t);await ut(n,uS(t),r.targetId,!1,r.resumeToken),lf(n.remoteStore,r)}for(let e of r)n.Tu.has(e)&&await oN(n.localStore,e,!1).then(()=>{lp(n.remoteStore,e),uf(n,e)}).catch(t0)}}function uD(e){return e.remoteStore.remoteSyncer.applyRemoteEvent=us.bind(null,e),e.remoteStore.remoteSyncer.getRemoteKeysForTarget=uw.bind(null,e),e.remoteStore.remoteSyncer.rejectListen=uo.bind(null,e),e.hu.J_=lQ.bind(null,e.eventManager),e.hu.pu=lH.bind(null,e.eventManager),e}function uN(e){return e.remoteStore.remoteSyncer.applySuccessfulWrite=ul.bind(null,e),e.remoteStore.remoteSyncer.rejectFailedWrite=uu.bind(null,e),e}class uk{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=le(e.databaseInfo.databaseId),this.sharedClientState=this.bu(e),this.persistence=this.Du(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Cu(e,this.localStore),this.indexBackfillerScheduler=this.Fu(e,this.localStore)}Cu(e,t){return null}Fu(e,t){return null}vu(e){var t,r;return t=this.persistence,r=new o_,new oS(t,r,e.initialUser,this.serializer)}Du(e){return new oh(od.Vi,this.serializer)}bu(e){return new oX}async terminate(){var e,t;null==(e=this.gcScheduler)||e.stop(),null==(t=this.indexBackfillerScheduler)||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}uk.provider={build:()=>new uk};class uO extends uk{constructor(e){super(),this.cacheSizeBytes=e}Cu(e,t){return ta(this.persistence.referenceDelegate instanceof of,46915),new aZ(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}Du(e){let t=void 0!==this.cacheSizeBytes?aq.withCacheSize(this.cacheSizeBytes):aq.DEFAULT;return new oh(e=>of.Vi(e,t),this.serializer)}}class uR extends uk{constructor(e,t,r){super(),this.Mu=e,this.cacheSizeBytes=t,this.forceOwnership=r,this.kind="persistent",this.synchronizeTabs=!1}async initialize(e){await super.initialize(e),await this.Mu.initialize(this,e),await uN(this.Mu.syncEngine),await lx(this.Mu.remoteStore),await this.persistence.ji(()=>(this.gcScheduler&&!this.gcScheduler.started&&this.gcScheduler.start(),this.indexBackfillerScheduler&&!this.indexBackfillerScheduler.started&&this.indexBackfillerScheduler.start(),Promise.resolve()))}vu(e){var t,r;return t=this.persistence,r=new o_,new oS(t,r,e.initialUser,this.serializer)}Cu(e,t){return new aZ(this.persistence.referenceDelegate.garbageCollector,e.asyncQueue,t)}Fu(e,t){let r=new rs(t,this.persistence);return new ri(e.asyncQueue,r)}Du(e){let t=ob(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey),r=void 0!==this.cacheSizeBytes?aq.withCacheSize(this.cacheSizeBytes):aq.DEFAULT;return new ow(this.synchronizeTabs,t,e.clientId,r,e.asyncQueue,o7(),o9(),this.serializer,this.sharedCl
21ientState,!!this.forceOwnership)}bu(e){return new oX}}class uL extends uR{constructor(e,t){super(e,t,!1),this.Mu=e,this.cacheSizeBytes=t,this.synchronizeTabs=!0}async initialize(e){await super.initialize(e);let t=this.Mu.syncEngine;this.sharedClientState instanceof oW&&(this.sharedClientState.syncEngine={Do:uI.bind(null,t),vo:uC.bind(null,t),Co:uA.bind(null,t),Ps:ux.bind(null,t),bo:uE.bind(null,t)},await this.sharedClientState.start()),await this.persistence.ji(async e=>{await u_(this.Mu.syncEngine,e),this.gcScheduler&&(e&&!this.gcScheduler.started?this.gcScheduler.start():e||this.gcScheduler.stop()),this.indexBackfillerScheduler&&(e&&!this.indexBackfillerScheduler.started?this.indexBackfillerScheduler.start():e||this.indexBackfillerScheduler.stop())})}bu(e){let t=o7();if(!oW.C(t))throw new tl(to.UNIMPLEMENTED,"IndexedDB persistence is only available on platforms that support LocalStorage.");let r=ob(e.databaseInfo.databaseId,e.databaseInfo.persistenceKey);return new oW(t,e.asyncQueue,r,e.clientId,e.initialUser)}}class uM{async initialize(e,t){this.localStore||(this.localStore=e.localStore,this.sharedClientState=e.sharedClientState,this.datastore=this.createDatastore(t),this.remoteStore=this.createRemoteStore(t),this.eventManager=this.createEventManager(t),this.syncEngine=this.createSyncEngine(t,!e.synchronizeTabs),this.sharedClientState.onlineStateHandler=e=>ua(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=uv.bind(null,this.syncEngine),await lL(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new lz}createDatastore(e){var t;let r=le(e.databaseInfo.databaseId),n=new o8(e.databaseInfo);return t=e.authCredentials,new lo(t,e.appCheckCredentials,n,r)}createRemoteStore(e){var t,r;return t=this.localStore,r=this.datastore,new lh(t,r,e.asyncQueue,e=>ua(this.syncEngine,e,0),oZ.C()?new oZ:new oJ)}createSyncEngine(e,t){var r,n,i,s,a,o;let l;return r=this.localStore,n=this.remoteStore,i=this.eventManager,s=this.sharedClientState,a=e.initialUser,o=e.maxConcurrentLimboResolutions,l=new l8(r,n,i,s,a,o),t&&(l.fu=!0),l}async terminate(){var e,t;await async function(e){te(lu,"RemoteStore shutting down."),e.Ia.add(5),await ld(e),e.Ea.shutdown(),e.Aa.set("Unknown")}(this.remoteStore),null==(e=this.datastore)||e.terminate(),null==(t=this.eventManager)||t.terminate()}}function uP(e,t=10240){let r=0;return{async read(){if(r<e.byteLength){let n={value:e.slice(r,r+t),done:!1};return r+=t,n}return{done:!0}},async cancel(){},releaseLock(){},closed:Promise.resolve()}}uM.provider={build:()=>new uM};class uF{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.xu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.xu(this.observer.error,e):tt("Uncaught Error in snapshot listener:",e.toString()))}Ou(){this.muted=!0}xu(e,t){setTimeout(()=>{this.muted||e(t)},0)}}class uV{constructor(e,t){this.Nu=e,this.serializer=t,this.metadata=new tu,this.buffer=new Uint8Array,this.Bu=new TextDecoder("utf-8"),this.Lu().then(e=>{e&&e.Qa()?this.metadata.resolve(e.qa.metadata):this.metadata.reject(Error(`The first element of the bundle is not a metadata, it is
22             ${JSON.stringify(null==e?void 0:e.qa)}`))},e=>this.metadata.reject(e))}close(){return this.Nu.cancel()}async getMetadata(){return this.metadata.promise}async Su(){return await this.getMetadata(),this.Lu()}async Lu(){let e=await this.ku();if(null===e)return null;let t=this.Bu.decode(e),r=Number(t);return isNaN(r)&&this.qu(`length string (${t}) is not valid number`),new lJ(JSON.parse(await this.Qu(r)),e.length+r)}$u(){return this.buffer.findIndex(e=>123===e)}async ku(){for(;0>this.$u()&&!await this.Uu(););if(0===this.buffer.length)return null;let e=this.$u();e<0&&this.qu("Reached the end of bundle when a length string is expected.");let t=this.buffer.slice(0,e);return this.buffer=this.buffer.slice(e),t}async Qu(e){for(;this.buffer.length<e;)await this.Uu()&&this.qu("Reached the end of bundle when more is expected.");let t=this.Bu.decode(this.buffer.slice(0,e));return this.buffer=this.buffer.slice(e),t}qu(e){throw this.Nu.cancel(),Error(`Invalid bundle format: ${e}`)}async Uu(){let e=await this.Nu.read();if(!e.done){let t=new Uint8Array(this.buffer.length+e.value.length);t.set(this.buffer),t.set(e.value,this.buffer.length),this.buffer=t}return e.done}}
22class uB{constructor(e,t){this.bundleData=e,this.serializer=t,this.cursor=0,this.elements=[];let r=this.Su();if(!r||!r.Qa())throw Error(`The first element of the bundle is not a metadata object, it is
23         ${JSON.stringify(null==r?void 0:r.qa)}`);this.metadata=r;do null!==(r=this.Su())&&this.elements.push(r);while(null!==r)}getMetadata(){return this.metadata}Ku(){return this.elements}Su(){if(this.cursor===this.bundleData.length)return null;let e=this.ku();return new lJ(JSON.parse(this.Qu(e)),e)}Qu(e){if(this.cursor+e>this.bundleData.length)throw new tl(to.INTERNAL,"Reached the end of bundle when more is expected.");return this.bundleData.slice(this.cursor,this.cursor+=e)}ku(){let e=this.cursor,t=this.cursor;for(;t<this.bundleData.length;){if("{"===this.bundleData[t]){if(t===e)throw Error("First character is a bracket and not a number");return this.cursor=t,Number(this.bundleData.slice(e,t))}t++}throw Error("Reached the end of bundle when more is expected.")}}class uU{constructor(e){this.datastore=e,this.readVersions=new Map,this.mutations=[],this.committed=!1,this.lastTransactionError=null,this.writtenDocs=new Set}async lookup(e){if(this.ensureCommitNotCalled(),this.mutations.length>0)throw this.lastTransactionError=new tl(to.INVALID_ARGUMENT,"Firestore transactions require all reads to be executed before all writes."),this.lastTransactionError;let t=await async function(e,t){let r={documents:t.map(t=>sQ(e.serializer,t))},n=await e.Jo("BatchGetDocuments",e.serializer.databaseId,tx.emptyPath(),r,t.length),i=new Map;n.forEach(t=>{var r;let n,s,a,o,l,u,h=(r=e.serializer,"found"in t?(ta(!!t.found,43571),t.found.name,t.found.updateTime,n=sH(r,t.found.name),s=sz(t.found.updateTime),a=t.found.createTime?sz(t.found.createTime):tq.min(),o=new n2({mapValue:{fields:t.found.fields}}),n6.newFoundDocument(n,s,a,o)):"missing"in t?(ta(!!t.missing,3894),ta(!!t.readTime,22933),l=sH(r,t.missing),u=sz(t.readTime),n6.newNoDocument(l,u)):ti(7234,{result:t}));i.set(h.key.toString(),h)});let s=[];return t.forEach(e=>{let t=i.get(e.toString());ta(!!t,55234,{key:e}),s.push(t)}),s}(this.datastore,e);return t.forEach(e=>this.recordVersion(e)),t}set(e,t){this.write(t.toMutation(e,this.precondition(e))),this.writtenDocs.add(e.toString())}update(e,t){try{this.write(t.toMutation(e,this.preconditionForUpdate(e)))}catch(e){this.lastTransactionError=e}this.writtenDocs.add(e.toString())}delete(e){this.write(new sd(e,this.precondition(e))),this.writtenDocs.add(e.toString())}async commit(){if(this.ensureCommitNotCalled(),this.lastTransactionError)throw this.lastTransactionError;let e=this.readVersions;this.mutations.forEach(t=>{e.delete(t.key.toString())}),e.forEach((e,t)=>{let r=tD.fromPath(t);this.mutations.push(new sf(r,this.precondition(r)))}),await async function(e,t){let r={writes:t.map(t=>s1(e.serializer,t))};await e.Wo("Commit",e.serializer.databaseId,tx.emptyPath(),r)}(this.datastore,this.mutations),this.committed=!0}recordVersion(e){let t;if(e.isFoundDocument())t=e.version;else{if(!e.isNoDocument())throw ti(50498,{Wu:e.constructor.name});t=tq.min()}let r=this.readVersions.get(e.key.toString());if(r){if(!t.isEqual(r))throw new tl(to.ABORTED,"Document version changed between two reads.")}else this.readVersions.set(e.key.toString(),t)}precondition(e){let t=this.readVersions.get(e.toString());return!this.writtenDocs.has(e.toString())&&t?t.isEqual(tq.min())?st.exists(!1):st.updateTime(t):st.none()}preconditionForUpdate(e){let t=this.readVersions.get(e.toString());if(!this.writtenDocs.has(e.toString())&&t){if(t.isEqual(tq.min()))throw new tl(to.INVALID_ARGUMENT,"Can't update a document that doesn't exist.");return st.updateTime(t)}return st.exists(!0)}write(e){this.ensureCommitNotCalled(),this.mutations.push(e)}ensureCommitNotCalled(){}}class uq{constructor(e,t,r,n,i){this.asyncQueue=e,this.datastore=t,this.options=r,this.updateFunction=n,this.deferred=i,this.Gu=r.maxAttempts,this.F_=new lt(this.asyncQueue,"transaction_retry")}zu(){this.Gu-=1,this.ju()}ju(){this.F_.g_(async()=>{let e=new uU(this.datastore),t=this.Ju(e);t&&t.then(t=>{this.asyncQueue.enqueueAndForget(()=>e.commit().then(()=>{this.deferred.resolve(t)}).catch(e=>{this.Hu(e)}))}).catch(e=>{this.Hu(e)})})}Ju(e){try{let t=this.updateFunction(e);return!ro(t)&&t.catch&&t.then?t:(this.deferred.reject(Error("Transaction callback must return a Promise")),null)}catch(e){return this.deferred.reject(e),null}}Hu(e){this.Gu>0&&this.Yu(e)?(this.Gu-=1,this.asyncQueue.enqueueAndForget(()=>(this.ju(),Promise.resolve()))):this.deferred.reject(e)}Yu(e){if("FirebaseError"===e.name){let t=e.code;return"aborted"===t||"failed-precondition"===t||"already-exists"===t||!sw(t)}return!1}}let uj="FirestoreClient";class uz{constructor(e,t,r,n,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=r,this.databaseInfo=n,this.user=e4.UNAUTHENTICATED,this.clientId=tw.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(r,async e=>{te(uj,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(r,e=>(te(uj,"Received new app check token=",e),this.appCheckCredentialListener(e,this.user)))}get configuration(){return{asyncQueue:this.asyncQueue,databaseInfo:this.databaseInfo,clientId:this.clientId,authCredentials:this.authCredentials,appCheckCredentials:this.appCheckCredentials,initialUser:this.user,maxConcurrentLimboResolutions:100}}setCredentialChangeListener(e){this.authCredentialListener=e}setAppCheckTokenChangeListener(e){this.appCheckCredentialListener=e}terminate(){this.asyncQueue.enterRestrictedMode();let e=new tu;return this.asyncQueue.enqueueAndForgetEvenWhileRestricted(async()=>{try{this._onlineComponents&&await this._onlineComponents.terminate(),this._offlineComponents&&await this._offlineComponents.terminate(),this.authCredentials.shutdown(),this.appCheckCredentials.shutdown(),e.resolve()}catch(r){let t=lV(r,"Failed to shutdown persistence");e.reject(t)}}),e.promise}}async function u$(e,t){e.asyncQueue.verifyOperationInProgress(),te(uj,"Initializing OfflineComponentProvider");let r=e.configuration;await t.initialize(r);let n=r.initialUser;e.setCredentialChangeListener(async e=>{n.isEqual(e)||(await ox(t.localStore,e),n=e)}),t.persistence.setDatabaseDeletedListener(()=>{tr("Terminating Firestore due to IndexedDb database deletion"),e.terminate().then(()=>{te("Terminating Firestore due to IndexedDb database deletion completed successfully")}).catch(e=>{tr("Terminating Firestore due to IndexedDb database deletion failed",e)})}),e._offlineComponents=t}async function uG(e,t){e.asyncQueue.verifyOperationInProgress();let r=await uK(e);te(uj,"Initializing OnlineComponentProvider"),await t.initialize(r,e.configuration),e.setCredentialChangeListener(e=>lR(t.remoteStore,e)),e.setAppCheckTokenChangeListener((e,r)=>lR(t.remoteStore,r)),e._onlineComponents=t}async function uK(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){te(uj,"Using user provided OfflineComponentProvider");try{await u$(e,e._uninitializedComponentsProvider._offline)}catch(t){if(!("FirebaseError"===t.name?t.code===to.FAILED_PRECONDITION||t.code===to.UNI
23MPLEMENTED:!("u">typeof DOMException&&t instanceof DOMException)||22===t.code||20===t.code||11===t.code))throw t;tr("Error using user provided cache. Falling back to memory cache: "+t),await u$(e,new uk)}}else te(uj,"Using default OfflineComponentProvider"),await u$(e,new uO(void 0));return e._offlineComponents}async function uQ(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(te(uj,"Using user provided OnlineComponentProvider"),await uG(e,e._uninitializedComponentsProvider._online)):(te(uj,"Using default OnlineComponentProvider"),await uG(e,new uM))),e._onlineComponents}function uH(e){return uK(e).then(e=>e.persistence)}function uW(e){return uK(e).then(e=>e.localStore)}function uX(e){return uQ(e).then(e=>e.remoteStore)}function uJ(e){return uQ(e).then(e=>e.syncEngine)}function uY(e){return uQ(e).then(e=>e.datastore)}async function uZ(e){let t=await uQ(e),r=t.eventManager;return r.onListen=l7.bind(null,t.syncEngine),r.onUnlisten=ur.bind(null,t.syncEngine),r.onFirstRemoteStoreListen=l9.bind(null,t.syncEngine),r.onLastRemoteStoreUnlisten=un.bind(null,t.syncEngine),r}function u0(e,t,r={}){let n=new tu;return e.asyncQueue.enqueueAndForget(async()=>{var i,s;let a,o;return i=await uZ(e),s=e.asyncQueue,a=new uF({next:e=>{a.Ou(),s.enqueueAndForget(()=>lK(i,o));let l=e.docs.has(t);!l&&e.fromCache?n.reject(new tl(to.UNAVAILABLE,"Failed to get document because the client is offline.")):l&&e.fromCache&&r&&"server"===r.source?n.reject(new tl(to.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.)')):n.resolve(e)},error:e=>n.reject(e)}),lG(i,o=new lX(iS(t.path),a,{includeMetadataChanges:!0,ka:!0}))}),n.promise}function u1(e,t,r={}){let n=new tu;return e.asyncQueue.enqueueAndForget(async()=>{var i,s;let a,o;return i=await uZ(e),s=e.asyncQueue,o=new lX(t,a=new uF({next:e=>{a.Ou(),s.enqueueAndForget(()=>lK(i,o)),e.fromCache&&"server"===r.source?n.reject(new tl(to.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.)')):n.resolve(e)},error:e=>n.reject(e)}),{includeMetadataChanges:!0,ka:!0}),lG(i,o)}),n.promise}function u2(e){let t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}let u6=new Map,u3="firestore.googleapis.com";class u5{constructor(e){var t,r;if(void 0===e.host){if(void 0!==e.ssl)throw new tl(to.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=u3,this.ssl=!0}else this.host=e.host,this.ssl=null==(t=e.ssl)||t;if(this.isUsingEmulator=void 0!==e.emulatorOptions,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,void 0===e.cacheSizeBytes)this.cacheSizeBytes=0x2800000;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<1048576)throw new tl(to.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}tk("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=u2(null!=(r=e.experimentalLongPollingOptions)?r:{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new tl(to.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new tl(to.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new tl(to.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){var t,r;return this.host===e.host&&this.ssl===e.ssl&&this.credentials===e.credentials&&this.cacheSizeBytes===e.cacheSizeBytes&&this.experimentalForceLongPolling===e.experimentalForceLongPolling&&this.experimentalAutoDetectLongPolling===e.experimentalAutoDetectLongPolling&&(t=this.experimentalLongPollingOptions,r=e.experimentalLongPollingOptions,t.timeoutSeconds===r.timeoutSeconds)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}}class u4{constructor(e,t,r,n){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=r,this._app=n,this.type="firestore-lite",this._persistenceKey="(lite)",this._settings=new u5({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new tl(to.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new tl(to.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 u5(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new tc;switch(e.type){case"firstParty":return new tg(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new tl(to.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
23d credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){let e;return(e=u6.get(this))&&(te("ComponentProvider","Removing Datastore"),u6.delete(this),e.terminate()),Promise.resolve()}}function u8(e,t,r,n={}){var i;e=tP(e,u4);let s=M(t),a=e._getSettings(),o=Object.assign(Object.assign({},a),{emulatorOptions:e._getEmulatorOptions()}),l=`${t}:${r}`;s&&(P(`https://${l}`),U("Firestore",!0)),a.host!==u3&&a.host!==l&&tr("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");let u=Object.assign(Object.assign({},a),{host:l,ssl:s,emulatorOptions:n});if(!J(u,o)&&(e._setSettings(u),n.mockUserToken)){let t,r;if("string"==typeof n.mockUserToken)t=n.mockUserToken,r=e4.MOCK_USER;else{t=F(n.mockUserToken,null==(i=e._app)?void 0:i.options.projectId);let s=n.mockUserToken.sub||n.mockUserToken.user_id;if(!s)throw new tl(to.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");r=new e4(s)}e._authCredentials=new td(new th(t,r))}}class u7{constructor(e,t,r){this.converter=t,this._query=r,this.type="query",this.firestore=e}withConverter(e){return new u7(this.firestore,e,this._query)}}class u9{constructor(e,t,r){this.converter=t,this._key=r,this.type="document",this.firestore=e}get _path(){return this._key.path}get id(){return this._key.path.lastSegment()}get path(){return this._key.path.canonicalString()}get parent(){return new he(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new u9(this.firestore,e,this._key)}toJSON(){return{type:u9._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,r){if(tB(t,u9._jsonSchema))return new u9(e,r||null,new tD(tx.fromString(t.referencePath)))}}u9._jsonSchemaVersion="firestore/documentReference/1.0",u9._jsonSchema={type:tV("string",u9._jsonSchemaVersion),referencePath:tV("string")};class he extends u7{constructor(e,t,r){super(e,t,iS(r)),this._path=r,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){let e=this._path.popLast();return e.isEmpty()?null:new u9(this.firestore,null,new tD(e))}withConverter(e){return new he(this.firestore,e,this._path)}}function ht(e,t,...r){if(e=et(e),1==arguments.length&&(t=tw.newId()),tN("doc","path",t),e instanceof u4){let n=tx.fromString(t,...r);return tO(n),new u9(e,null,new tD(n))}{if(!(e instanceof u9||e instanceof he))throw new tl(to.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=e._path.child(tx.fromString(t,...r));return tO(n),new u9(e.firestore,e instanceof he?e.converter:null,new tD(n))}}function hr(e,t){return e=et(e),t=et(t),e instanceof u7&&t instanceof u7&&e.firestore===t.firestore&&iL(e._query,t._query)&&e.converter===t.converter}let hn="AsyncQueue";class hi{constructor(e=Promise.resolve()){this.Zu=[],this.Xu=!1,this.ec=[],this.tc=null,this.nc=!1,this.rc=!1,this.sc=[],this.F_=new lt(this,"async_queue_retry"),this.oc=()=>{let e=o9();e&&te(hn,"Visibility state changed to "+e.visibilityState),this.F_.y_()},this._c=e;const t=o9();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.oc)}get isShuttingDown(){return this.Xu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.ac(),this.uc(e)}enterRestrictedMode(e){if(!this.Xu){this.Xu=!0,this.rc=e||!1;let t=o9();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.oc)}}enqueue(e){if(this.ac(),this.Xu)return new Promise(()=>{});let t=new tu;return this.uc(()=>this.Xu&&this.rc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Zu.push(e),this.cc()))}async cc(){if(0!==this.Zu.length){try{await this.Zu[0](),this.Zu.shift(),this.F_.reset()}catch(e){if(!t7(e))throw e;te(hn,"Operation failed with retryable error: "+e)}this.Zu.length>0&&this.F_.g_(()=>this.cc())}}uc(e){let t=this._c.then(()=>(this.nc=!0,e().catch(e=>{throw this.tc=e,this.nc=!1,tt("INTERNAL UNHANDLED ERROR: ",hs(e)),e}).then(e=>(this.nc=!1,e))));return this._c=t,t}enqueueAfterDelay(e,t,r){this.ac(),this.sc.indexOf(e)>-1&&(t=0);let n=lF.createAndSchedule(this,e,t,r,e=>this.lc(e));return this.ec.push(n),n}ac(){this.tc&&ti(47125,{hc:hs(this.tc)})}verifyOperationInProgress(){}async Pc(){let e;do e=this._c,await e;while(e!==this._c)}Tc(e){for(let t of this.ec)if(t.timerId===e)return!0;return!1}Ic(e){return this.Pc().then(()=>{for(let t of(this.ec.sort((e,t)=>
23e.targetTimeMs-t.targetTimeMs),this.ec))if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.Pc()})}dc(e){this.sc.push(e)}lc(e){let t=this.ec.indexOf(e);this.ec.splice(t,1)}}function hs(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}function ha(e){if("object"!=typeof e||null===e)return!1;for(let t of["next","error","complete"])if(t in e&&"function"==typeof e[t])return!0;return!1}class ho{constructor(){this._progressObserver={},this._taskCompletionResolver=new tu,this._lastProgress={taskState:"Running",totalBytes:0,totalDocuments:0,bytesLoaded:0,documentsLoaded:0}}onProgress(e,t,r){this._progressObserver={next:e,error:t,complete:r}}catch(e){return this._taskCompletionResolver.promise.catch(e)}then(e,t){return this._taskCompletionResolver.promise.then(e,t)}_completeWith(e){this._updateProgress(e),this._progressObserver.complete&&this._progressObserver.complete(),this._taskCompletionResolver.resolve(e)}_failWith(e){this._lastProgress.taskState="Error",this._progressObserver.next&&this._progressObserver.next(this._lastProgress),this._progressObserver.error&&this._progressObserver.error(e),this._taskCompletionResolver.reject(e)}_updateProgress(e){this._lastProgress=e,this._progressObserver.next&&this._progressObserver.next(e)}}class hl extends u4{constructor(e,t,r,n){super(e,t,r,n),this.type="firestore",this._queue=new hi,this._persistenceKey=(null==n?void 0:n.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new hi(e),this._firestoreClient=void 0,await e}}}function hu(e){if(e._terminated)throw new tl(to.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||hh(e),e._firestoreClient}function hh(e){var t,r,n,i,s,a;let o,l=e._freezeSettings(),u=(i=e._databaseId,s=(null==(t=e._app)?void 0:t.options.appId)||"",new nA(i,s,e._persistenceKey,l.host,l.ssl,l.experimentalForceLongPolling,l.experimentalAutoDetectLongPolling,u2(l.experimentalLongPollingOptions),l.useFetchStreams,l.isUsingEmulator));e._componentsProvider||(null==(r=l.localCache)?void 0:r._offlineComponentProvider)&&(null==(n=l.localCache)?void 0:n._onlineComponentProvider)&&(e._componentsProvider={_offline:l.localCache._offlineComponentProvider,_online:l.localCache._onlineComponentProvider}),e._firestoreClient=new uz(e._authCredentials,e._appCheckCredentials,e._queue,u,e._componentsProvider&&(o=null==(a=e._componentsProvider)?void 0:a._online.build(),{_offline:null==a?void 0:a._offline.build(o),_online:o}))}async function hc(e){tr("enableMultiTabIndexedDbPersistence() will be deprecated 
23in the future, you can use `FirestoreSettings.cache` instead.");let t=e._freezeSettings();hd(e,uM.provider,{build:e=>new uL(e,t.cacheSizeBytes)})}function hd(e,t,r){if((e=tP(e,hl))._firestoreClient||e._terminated)throw new tl(to.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.");if(e._componentsProvider||e._getSettings().localCache)throw new tl(to.FAILED_PRECONDITION,"SDK cache is already specified.");e._componentsProvider={_online:t,_offline:r},hh(e)}function hf(e,t){let r=hu(e=tP(e,hl)),n=new ho;return function(e,t,r,n){var i;let s=(i=le(t),new uV(function(e){if(e instanceof Uint8Array)return uP(e,void 0);if(e instanceof ArrayBuffer)return uP(new Uint8Array(e),void 0);if(e instanceof ReadableStream)return e.getReader();throw Error("Source of `toByteStreamReader` has to be a ArrayBuffer or ReadableStream")}("string"==typeof r?tv().encode(r):r),i));e.asyncQueue.enqueueAndForget(async()=>{var t=await uJ(e);(async function(e,t,r){try{var n,i;let s,a=await t.getMetadata();if(await (n=e.localStore,s=sz(a.createTime),n.persistence.runTransaction("hasNewerBundle","readonly",e=>n.Ti.getBundleMetadata(e,a.id)).then(e=>!!e&&e.createTime.compareTo(s)>=0)))return await t.close(),r._completeWith({taskState:"Success",documentsLoaded:a.totalDocuments,bytesLoaded:a.totalBytes,totalDocuments:a.totalDocuments,totalBytes:a.totalBytes}),Promise.resolve(new Set);r._updateProgress(l0(a));let o=new lZ(a,t.serializer),l=await t.Su();for(;l;){let e=await o.Wa(l);e&&r._updateProgress(e),l=await t.Su()}let u=await o.za(e.localStore);return await uy(e,u.Ja,void 0),await (i=e.localStore,i.persistence.runTransaction("Save bundle","readwrite",e=>i.Ti.saveBundleMetadata(e,a))),r._completeWith(u.progress),Promise.resolve(u.ja)}catch(e){return tr(l3,`Loading bundle failed with ${e}`),r._failWith(e),Promise.resolve(new Set)}})(t,s,n).then(e=>{t.sharedClientState.notifyBundleLoaded(e)})})}(r,e._databaseId,t,n),n}function hp(e,t){var r;return(r=hu(e=tP(e,hl)),r.asyncQueue.enqueue(async()=>{var e;return e=await uW(r),e.persistence.runTransaction("Get named query","readonly",r=>e.Ti.getNamedQuery(r,t))})).then(t=>t?new u7(e,null,t.query):null)}class hg{constructor(e="count",t){this._internalFieldPath=t,this.type="AggregateField",this.aggregateType=e}}class hm{constructor(e,t,r){this._userDataWriter=t,this._data=r,this.type="AggregateQuerySnapshot",this.query=e}data(){return this._userDataWriter.convertObjectMap(this._data)}}class hy{constructor(e){this._byteString=e}static fromBase64String(e){try{return new hy(nm.fromBase64String(e))}catch(e){throw new tl(to.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new hy(nm.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:hy._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(tB(e,hy._jsonSchema))return hy.fromBase64String(e.bytes)}}hy._jsonSchemaVersion="firestore/bytes/1.0",hy._jsonSchema={type:tV("string",hy._jsonSchemaVersion),bytes:tV("string")};class hv{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new tl(to.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new tA(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class hw{constructor(e){this._methodName=e}}class hb{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new tl(to.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new tl(to.INVALID_ARGUMENT,"Longitude must be a number between -180 and 180, but was: "+t);this._lat=e,this._long=t}get latitude(){return this._lat}get longitude(){return this._long}isEqual(e){return this._lat===e._lat&&this._long===e._long}_compareTo(e){return tb(this._lat,e._lat)||tb(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:hb._jsonSchemaVersion}}static fromJSON(e){if(tB(e,hb._jsonSchema))return new hb(e.latitude,e.longitude)}}hb._jsonSchemaVersion="firestore/geoPoint/1.0",hb._jsonSchema={type:tV("string",hb._jsonSchemaVersion),latitude:tV("number"),longitude:tV("number")};class hE{constructor(e){this._values=(e||[]).map(e=>e)}toArray(){return this._values.map(e=>e)}isEqual(e){return function(e,t){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(e[r]!==t[r])return!1;return!0}(this._values,e._values)}toJSON(){return{type:hE._jsonSchemaVersion,vectorValues:this._values}}
23static fromJSON(e){if(tB(e,hE._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(e=>"number"==typeof e))return new hE(e.vectorValues);throw new tl(to.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}hE._jsonSchemaVersion="firestore/vectorValue/1.0",hE._jsonSchema={type:tV("string",hE._jsonSchemaVersion),vectorValues:tV("object")};let hI=/^__.*__$/;class h_{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return null!==this.fieldMask?new sl(e,this.data,this.fieldMask,t,this.fieldTransforms):new so(e,this.data,t,this.fieldTransforms)}}class hT{constructor(e,t,r){this.data=e,this.fieldMask=t,this.fieldTransforms=r}toMutation(e,t){return new sl(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function hS(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw ti(40011,{Ec:e})}}class hx{constructor(e,t,r,n,i,s){this.settings=e,this.databaseId=t,this.serializer=r,this.ignoreUndefinedProperties=n,void 0===i&&this.Ac(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get Ec(){return this.settings.Ec}Rc(e){return new hx(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Vc(e){var t;let r=null==(t=this.path)?void 0:t.child(e),n=this.Rc({path:r,mc:!1});return n.fc(e),n}gc(e){var t;let r=null==(t=this.path)?void 0:t.child(e),n=this.Rc({path:r,mc:!1});return n.Ac(),n}yc(e){return this.Rc({path:void 0,mc:!0})}wc(e){return hK(e,this.settings.methodName,this.settings.Sc||!1,this.path,this.settings.bc)}contains(e){return void 0!==this.fieldMask.find(t=>e.isPrefixOf(t))||void 0!==this.fieldTransforms.find(t=>e.isPrefixOf(t.field))}Ac(){if(this.path)for(let e=0;e<this.path.length;e++)this.fc(this.path.get(e))}fc(e){if(0===e.length)throw this.wc("Document fields must not be empty");if(hS(this.Ec)&&hI.test(e))throw this.wc('Document fields cannot begin and end with "__"')}}class hC{constructor(e,t,r){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=r||le(e)}Dc(e,t,r,n=!1){return new hx({Ec:e,methodName:t,bc:r,path:tA.emptyPath(),mc:!1,Sc:n},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function hA(e){let t=e._freezeSettings(),r=le(e._databaseId);return new hC(e._databaseId,!!t.ignoreUndefinedProperties,r)}function hD(e,t,r,n,i,s={}){let a,o,l=e.Dc(s.merge||s.mergeFields?2:0,t,r,i);hj("Data must be an object, but it was:",l,n);let u=hU(n,l);if(s.merge)a=new np(l.fieldMask),o=l.fieldTransforms;else if(s.mergeFields){let e=[];for(let n of s.mergeFields){let i=hz(t,n,r);if(!l.contains(i))throw new tl(to.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);hQ(e,i)||e.push(i)}a=new np(e),o=l.fieldTransforms.filter(e=>a.covers(e.field))}else a=null,o=l.fieldTransforms;return new h_(new n2(u),a,o)}class hN extends hw{_toFieldTransform(e){if(2!==e.Ec)throw 1===e.Ec?e.wc(`${this._methodName}() can only appear at the top level of your update data`):e.wc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof hN}}function hk(e,t,r){return new hx({Ec:3,bc:t.settings.bc,methodName:e._methodName,mc:r},t.databaseId,t.serializer,t.ignoreUndefinedProperties)}class hO extends hw{_toFieldTransform(e){return new i9(e.path,new i1)}isEqual(e){return e instanceof hO}}class hR extends hw{constructor(e,t){super(e),this.vc=t}_toFieldTransform(e){let t=hk(this,e,!0),r=new i2(this.vc.map(e=>hB(e,t)));return new i9(e.path,r)}isEqual(e){return e instanceof hR&&J(this.vc,e.vc)}}class hL extends hw{constructor(e,t){super(e),this.vc=t}_toFieldTransform(e){let t=hk(this,e,!0),r=new i3(this.vc.map(e=>hB(e,t)));return new i9(e.path,r)}isEqual(e){return e instanceof hL&&J(this.vc,e.vc)}}class hM extends hw{constructor(e,t){super(e),this.Cc=t}_toFieldTransform(e){let t=new i4(e.serializer,iY(e.serializer,this.Cc));return new i9(e.path,t)}isEqual(e){return e instanceof hM&&this.Cc===e.Cc}}function hP(e,t,r,n){let i=e.Dc(1,t,r);hj("Data must be an object, but it was:",i,n);let s=[],a=n2.empty();return ns(n,(e,n)=>{let o=hG(t,e,r);n=et(n);let l=i.gc(o);if(n instanceof hN)s.push(o);else{let e=hB(n,l);null!=e&&(s.push(o),a.set(o,e))}}),new hT(a,new np(s),i.fieldTransforms)}function hF(e,t,r,n,i,s){let a=e.Dc(1,t,r),o=[hz(t,n,r)],l=[i];if(s.length%2!=0)throw new tl(to.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<s.length;e+=2)o.push(hz(t,s[e])),l.push(s[e+1]);let u=[],h=n2.empty();for(let e=o.length-1;e>=0;
23--e)if(!hQ(u,o[e])){let t=o[e],r=l[e];r=et(r);let n=a.gc(t);if(r instanceof hN)u.push(t);else{let e=hB(r,n);null!=e&&(u.push(t),h.set(t,e))}}return new hT(h,new np(u),a.fieldTransforms)}function hV(e,t,r,n=!1){return hB(r,e.Dc(n?4:3,t))}function hB(e,t){if(hq(e=et(e)))return hj("Unsupported field value:",t,e),hU(e,t);if(e instanceof hw)return function(e,t){if(!hS(t.Ec))throw t.wc(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.wc(`${e._methodName}() is not currently supported inside arrays`);let r=e._toFieldTransform(t);r&&t.fieldTransforms.push(r)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.mc&&4!==t.Ec)throw t.wc("Nested arrays are not supported");let r=[],n=0;for(let i of e){let e=hB(i,t.yc(n));null==e&&(e={nullValue:"NULL_VALUE"}),r.push(e),n++}return{arrayValue:{values:r}}}var r=e,n=t;if(null===(r=et(r)))return{nullValue:"NULL_VALUE"};if("number"==typeof r)return iY(n.serializer,r);if("boolean"==typeof r)return{booleanValue:r};if("string"==typeof r)return{stringValue:r};if(r instanceof Date){let e=tU.fromDate(r);return{timestampValue:sq(n.serializer,e)}}if(r instanceof tU){let e=new tU(r.seconds,1e3*Math.floor(r.nanoseconds/1e3));return{timestampValue:sq(n.serializer,e)}}if(r instanceof hb)return{geoPointValue:{latitude:r.latitude,longitude:r.longitude}};if(r instanceof hy)return{bytesValue:sj(n.serializer,r._byteString)};if(r instanceof u9){let e=n.databaseId,t=r.firestore._databaseId;if(!t.isEqual(e))throw n.wc(`Document reference is for database ${t.projectId}/${t.database} but should be for database ${e.projectId}/${e.database}`);return{referenceValue:s$(r.firestore._databaseId||n.databaseId,r._key.path)}}if(r instanceof hE)return{mapValue:{fields:{[nk]:{stringValue:nL},[nM]:{arrayValue:{values:r.toArray().map(e=>{if("number"!=typeof e)throw n.wc("VectorValues must only contain numeric values.");return iX(n.serializer,e)})}}}}};throw n.wc(`Unsupported field value: ${tM(r)}`)}function hU(e,t){let r={};return no(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):ns(e,(e,n)=>{let i=hB(n,t.Vc(e));null!=i&&(r[e]=i)}),{mapValue:{fields:r}}}function hq(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof tU||e instanceof hb||e instanceof hy||e instanceof u9||e instanceof hw||e instanceof hE)}function hj(e,t,r){if(!hq(r)||!tL(r)){let n=tM(r);throw"an object"===n?t.wc(e+" a custom object"):t.wc(e+" "+n)}}function hz(e,t,r){if((t=et(t))instanceof hv)return t._internalPath;if("string"==typeof t)return hG(e,t);throw hK("Field path arguments must be of type string or ",e,!1,void 0,r)}let h$=RegExp("[~\\*/\\[\\]]");function hG(e,t,r){if(t.search(h$)>=0)throw hK(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,r);try{return new hv(...t.split("."))._internalPath}catch(n){throw hK(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,r)}}function hK(e,t,r,n,i){let s=n&&!n.isEmpty(),a=void 0!==i,o=`Function ${t}() called with invalid data`;r&&(o+=" (via `toFirestore()`)"),o+=". ";let l="";return(s||a)&&(l+=" (found",s&&(l+=` in field ${n}`),a&&(l+=` in document ${i}`),l+=")"),new tl(to.INVALID_ARGUMENT,o+e+l)}function hQ(e,t){return e.some(e=>e.isEqual(t))}class hH{constructor(e,t,r,n,i){this._firestore=e,this._userDataWriter=t,this._key=r,this._document=n,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new u9(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){let e=new hW(this._firestore,this._userDataWriter,this._key,this._document,null);return this._converter.fromFirestore(e)}return this._userDataWriter.convertValue(this._document.data.value)}}get(e){if(this._document){let t=this._document.data.field(hX("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class hW extends hH{data(){return super.data()}}function hX(e,t){return"string"==typeof t?hG(e,t):t instanceof hv?t._internalPath:t._delegate._internalPath}function hJ(e){if("L"===e.limitType&&0===e.explicitOrderBy.length)throw new tl(to.UNIMPLEMENT
23ED,"limitToLast() queries require specifying at least one orderBy() clause")}class hY{}class hZ extends hY{}class h0 extends hZ{constructor(e,t,r){super(),this._field=e,this._op=t,this._value=r,this.type="where"}static _create(e,t,r){return new h0(e,t,r)}_apply(e){let t=this._parse(e);return h9(e._query,t),new u7(e.firestore,e.converter,iO(e._query,t))}_parse(e){let t=hA(e.firestore);return function(e,t,r,n,i,s,a){let o;if(i.isKeyField()){if("array-contains"===s||"array-contains-any"===s)throw new tl(to.INVALID_ARGUMENT,`Invalid Query. You can't perform '${s}' queries on documentId().`);if("in"===s||"not-in"===s){h7(a,s);let t=[];for(let r of a)t.push(h8(n,e,r));o={arrayValue:{values:t}}}else o=h8(n,e,a)}else"in"!==s&&"not-in"!==s&&"array-contains-any"!==s||h7(a,s),o=hV(r,t,a,"in"===s||"not-in"===s);return n9.create(i,s,o)}(e._query,"where",t,e.firestore._databaseId,this._field,this._op,this._value)}}class h1 extends hY{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(e,t){return new h1(e,t)}_parse(e){let t=this._queryConstraints.map(t=>t._parse(e)).filter(e=>e.getFilters().length>0);return 1===t.length?t[0]:ie.create(t,this._getOperator())}_apply(e){let t=this._parse(e);return 0===t.getFilters().length?e:(function(e,t){let r=e;for(let e of t.getFlattenedFilters())h9(r,e),r=iO(r,e)}(e._query,t),new u7(e.firestore,e.converter,iO(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return"and"===this.type?"and":"or"}}class h2 extends hZ{constructor(e,t){super(),this._field=e,this._direction=t,this.type="orderBy"}static _create(e,t){return new h2(e,t)}_apply(e){var t;let r,n=function(e,t,r){if(null!==e.startAt)throw new tl(to.INVALID_ARGUMENT,"Invalid query. You must not call startAt() or startAfter() before calling orderBy().");if(null!==e.endAt)throw new tl(to.INVALID_ARGUMENT,"Invalid query. You must not call endAt() or endBefore() before calling orderBy().");return new n8(t,r)}(e._query,this._field,this._direction);return new u7(e.firestore,e.converter,(t=e._query,r=t.explicitOrderBy.concat([n]),new iT(t.path,t.collectionGroup,r,t.filters.slice(),t.limit,t.limitType,t.startAt,t.endAt)))}}class h6 extends hZ{constructor(e,t,r){super(),this.type=e,this._limit=t,this._limitType=r}static _create(e,t,r){return new h6(e,t,r)}_apply(e){return new u7(e.firestore,e.converter,iR(e._query,this._limit,this._limitType))}}class h3 extends hZ{constructor(e,t,r){super(),this.type=e,this._docOrFields=t,this._inclusive=r}static _create(e,t,r){return new h3(e,t,r)}_apply(e){var t;let r=h4(e,this.type,this._docOrFields,this._inclusive);return new u7(e.firestore,e.converter,(t=e._query,new iT(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,r,t.endAt)))}}class h5 extends hZ{constructor(e,t,r){super(),this.type=e,this._docOrFields=t,this._inclusive=r}static _create(e,t,r){return new h5(e,t,r)}_apply(e){var t;let r=h4(e,this.type,this._docOrFields,this._inclusive);return new u7(e.firestore,e.converter,(t=e._query,new iT(t.path,t.collectionGroup,t.explicitOrderBy.slice(),t.filters.slice(),t.limit,t.limitType,t.startAt,r)))}}function h4(e,t,r,n){if(r[0]=et(r[0]),r[0]instanceof hH)return function(e,t,r,n,i){if(!n)throw new tl(to.NOT_FOUND,`Can't use a DocumentSnapshot that doesn't exist for ${r}().`);let s=[];for(let r of iA(e))if(r.field.isKeyField())s.push(n$(t,n.key));else{let e=n.data.field(r.field);if(nS(e))throw new tl(to.INVALID_ARGUMENT,'Invalid query. You are trying to start or end a query using a document for which the field "'+r.field+'" is an uncommitted server timestamp. (Since the value of this field is unknown, you cannot start/end a query with it.)');if(null===e){let e=r.field.canonicalString();throw new tl(to.INVALID_ARGUMENT,`Invalid query. You are trying to start or end a query using a document for which the field '${e}' (used as the orderBy) does not exist.`)}s.push(e)}return new n3(s,i)}(e._query,e.firestore._databaseId,t,r[0]._document,n);{let i=hA(e.firestore);return function(e,t,r,n,i,s){let a=e.explicitOrderBy;if(i.length>a.length)throw new tl(to.INVALID_ARGUMENT,`Too many arguments provided to ${n}(). The number of arguments must be less than or equal to the number of orderBy() clauses`);let o=[];for(let s=0;s<i.length;s++){let l=i[s];
23if(a[s].field.isKeyField()){if("string"!=typeof l)throw new tl(to.INVALID_ARGUMENT,`Invalid query. Expected a string for document ID in ${n}(), but got a ${typeof l}`);if(!iC(e)&&-1!==l.indexOf("/"))throw new tl(to.INVALID_ARGUMENT,`Invalid query. When querying a collection and ordering by documentId(), the value passed to ${n}() must be a plain document ID, but '${l}' contains a slash.`);let r=e.path.child(tx.fromString(l));if(!tD.isDocumentKey(r))throw new tl(to.INVALID_ARGUMENT,`Invalid query. When querying a collection group and ordering by documentId(), the value passed to ${n}() must result in a valid document path, but '${r}' is not because it contains an odd number of segments.`);let i=new tD(r);o.push(n$(t,i))}else{let e=hV(r,n,l);o.push(e)}}return new n3(o,s)}(e._query,e.firestore._databaseId,i,t,r,n)}}function h8(e,t,r){if("string"==typeof(r=et(r))){if(""===r)throw new tl(to.INVALID_ARGUMENT,"Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.");if(!iC(t)&&-1!==r.indexOf("/"))throw new tl(to.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${r}' contains a '/' character.`);let n=t.path.child(tx.fromString(r));if(!tD.isDocumentKey(n))throw new tl(to.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${n}' is not because it has an odd number of segments (${n.length}).`);return n$(e,new tD(n))}if(r instanceof u9)return n$(e,r._key);throw new tl(to.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${tM(r)}.`)}function h7(e,t){if(!Array.isArray(e)||0===e.length)throw new tl(to.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function h9(e,t){let r=function(e,t){for(let r of e)for(let e of r.getFlattenedFilters())if(t.indexOf(e.op)>=0)return e.op;return null}(e.filters,function(e){switch(e){case"!=":return["!=","not-in"];case"array-contains-any":case"in":return["not-in"];case"not-in":return["array-contains-any","in","not-in","!="];default:return[]}}(t.op));if(null!==r)throw r===t.op?new tl(to.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new tl(to.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${r.toString()}' filters.`)}function ce(e,t){if(!(t instanceof h0||t instanceof h1))throw new tl(to.INVALID_ARGUMENT,`Function ${e}() requires AppliableConstraints created with a call to 'where(...)', 'or(...)', or 'and(...)'.`)}class ct{convertValue(e,t="none"){switch(nF(e)){case 0:return null;case 1:return e.booleanValue;case 2:return nw(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(nb(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw ti(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){let r={};return ns(e,(e,n)=>{r[e]=this.convertValue(n,t)}),r}convertVectorValue(e){var t,r,n;return new hE(null==(n=null==(r=null==(t=e.fields)?void 0:t[nM].arrayValue)?void 0:r.values)?void 0:n.map(e=>nw(e.doubleValue)))}convertGeoPoint(e){return new hb(nw(e.latitude),nw(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":let r=nx(e);return null==r?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(nC(e));default:return null}}convertTimestamp(e){let t=nv(e);return new tU(t.seconds,t.nanos)}convertDocumentKey(e,t){let r=tx.fromString(e);ta(s9(r),9688,{name:e});let n=new nN(r.get(1),r.get(3)),i=new tD(r.popFirst(5));return n.isEqual(t)||tt(`Document ${i} contains a document reference within a different database (${n.projectId}/${n.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}}function cr(e,t,r){return e?r&&(r.merge||r.mergeFields)?e.toFirestore(t,r):e.toFirestore(t):t}class cn extends ct{constructor(e){super(),this.firestore=e}convertBytes(e){return new hy(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);
23return new u9(this.firestore,null,t)}}function ci(){return new hg("count")}let cs="NOT SUPPORTED";class ca{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class co extends hH{constructor(e,t,r,n,i,s){super(e,t,r,n,s),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new cl(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){let r=this._document.data.field(hX("DocumentSnapshot.get",e));if(null!==r)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new tl(to.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");let e=this._document,t={};return t.type=co._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),e&&e.isValidDocument()&&e.isFoundDocument()&&(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),this._firestore,this.ref.path,t.bundle="NOT SUPPORTED"),t}}co._jsonSchemaVersion="firestore/documentSnapshot/1.0",co._jsonSchema={type:tV("string",co._jsonSchemaVersion),bundleSource:tV("string","DocumentSnapshot"),bundleName:tV("string"),bundle:tV("string")};class cl extends co{data(e={}){return super.data(e)}}class cu{constructor(e,t,r,n){this._firestore=e,this._userDataWriter=t,this._snapshot=n,this.metadata=new ca(n.hasPendingWrites,n.fromCache),this.query=r}get docs(){let e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(e,t){this._snapshot.docs.forEach(r=>{e.call(t,new cl(this._firestore,this._userDataWriter,r.key,r,new ca(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))})}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new tl(to.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=function(e,t){if(e._snapshot.oldDocs.isEmpty()){let t=0;return e._snapshot.docChanges.map(r=>{let n=new cl(e._firestore,e._userDataWriter,r.doc.key,r.doc,new ca(e._snapshot.mutatedKeys.has(r.doc.key),e._snapshot.fromCache),e.query.converter);return r.doc,{type:"added",doc:n,oldIndex:-1,newIndex:t++}})}{let r=e._snapshot.oldDocs;return e._snapshot.docChanges.filter(e=>t||3!==e.type).map(t=>{let n=new cl(e._firestore,e._userDataWriter,t.doc.key,t.doc,new ca(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),i=-1,s=-1;return 0!==t.type&&(i=r.indexOf(t.doc.key),r=r.delete(t.doc.key)),1!==t.type&&(s=(r=r.add(t.doc)).indexOf(t.doc.key)),{type:function(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return ti(61501,{type:e})}}(t.type),doc:n,oldIndex:i,newIndex:s}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new tl(to.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");let e={};e.type=cu._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=tw.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;let t=[],r=[],n=[];return this.docs.forEach(e=>{null!==e._document&&(t.push(e._document),r.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,"previous")),n.push(e.ref.path))}),this._firestore,this.query._query,e.bundleName,e.bundle="NOT SUPPORTED",e}}
23cu._jsonSchemaVersion="firestore/querySnapshot/1.0",cu._jsonSchema={type:tV("string",cu._jsonSchemaVersion),bundleSource:tV("string","QuerySnapshot"),bundleName:tV("string"),bundle:tV("string")};class ch extends ct{constructor(e){super(),this.firestore=e}convertBytes(e){return new hy(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new u9(this.firestore,null,t)}}function cc(e,...t){var r,n,i,s;let a,o,l,u,h;e=et(e);let c={includeMetadataChanges:!1,source:"default"},d=0;"object"!=typeof t[0]||ha(t[d])||(c=t[d++]);let f={includeMetadataChanges:c.includeMetadataChanges,source:c.source};if(ha(t[d])){let e=t[d];t[d]=null==(r=e.next)?void 0:r.bind(e),t[d+1]=null==(n=e.error)?void 0:n.bind(e),t[d+2]=null==(i=e.complete)?void 0:i.bind(e)}if(e instanceof u9)o=tP(e.firestore,hl),l=iS(e._key.path),a={next:r=>{t[d]&&t[d](cf(o,e,r))},error:t[d+1],complete:t[d+2]};else{let r=tP(e,u7);o=tP(r.firestore,hl),l=r._query;let n=new ch(o);a={next:e=>{t[d]&&t[d](new cu(o,n,r,e))},error:t[d+1],complete:t[d+2]},hJ(e._query)}return s=hu(o),h=new lX(l,u=new uF(a),f),s.asyncQueue.enqueueAndForget(async()=>lG(await uZ(s),h)),()=>{u.Ou(),s.asyncQueue.enqueueAndForget(async()=>lK(await uZ(s),h))}}function cd(e,t){var r;let n;return r=hu(e),n=new tu,r.asyncQueue.enqueueAndForget(async()=>ui(await uJ(r),t,n)),n.promise}function cf(e,t,r){let n=r.docs.get(t._key),i=new ch(e);return new co(e,i,t._key,n,new ca(r.hasPendingWrites,r.fromCache),t.converter)}function cp(e,t){var r;let n,i=tP(e.firestore,hl),s=hu(i),a=na(t,(e,t)=>new sy(t,e.aggregateType,e._internalFieldPath));return(r=e._query,n=new tu,s.asyncQueue.enqueueAndForget(async()=>{try{let e=await uY(s);n.resolve(async function(e,t,r){var n;let{request:i,ft:s,parent:a}=s5(e.serializer,iN(t),r);e.connection.Qo||delete i.parent;let o=(await e.Jo("RunAggregationQuery",e.serializer.databaseId,a,i,1)).filter(e=>!!e.result);ta(1===o.length,64727);let l=null==(n=o[0].result)?void 0:n.aggregateFields;return Object.keys(l).reduce((e,t)=>(e[s[t]]=l[t],e),{})}(e,r,a))}catch(e){n.reject(e)}}),n.promise).then(t=>new hm(e,new ch(i),t))}class cg{constructor(e){this.kind="memory",this._onlineComponentProvider=uM.provider,(null==e?void 0:e.garbageCollector)?this._offlineComponentProvider=e.garbageCollector._offlineComponentProvider:this._offlineComponentProvider={build:()=>new uO(void 0)}}toJSON(){return{kind:this.kind}}}class cm{constructor(e){let t;this.kind="persistent",(null==e?void 0:e.tabManager)?(e.tabManager._initialize(e),t=e.tabManager):(t=cE(void 0))._initialize(e),this._onlineComponentProvider=t._onlineComponentProvider,this._offlineComponentProvider=t._offlineComponentProvider}toJSON(){return{kind:this.kind}}}class cy{constructor(){this.kind="memoryEager",this._offlineComponentProvider=uk.provider}toJSON(){return{kind:this.kind}}}class cv{constructor(e){this.kind="memoryLru",this._offlineComponentProvider={build:()=>new uO(e)}}toJSON(){return{kind:this.kind}}}class cw{constructor(e){this.forceOwnership=e,this.kind="persistentSingleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=uM.provider,this._offlineComponentProvider={build:t=>new uR(t,null==e?void 0:e.cacheSizeBytes,this.forceOwnership)}}}class cb{constructor(){this.kind="PersistentMultipleTab"}toJSON(){return{kind:this.kind}}_initialize(e){this._onlineComponentProvider=uM.provider,this._offlineComponentProvider={build:t=>new uL(t,null==e?void 0:e.cacheSizeBytes)}}}function cE(e){return new cw(null==e?void 0:e.forceOwnership)}let cI={maxAttempts:5};class c_{constructor(e,t){this._firestore=e,this._commitHandler=t,this._mutations=[],this._committed=!1,this._dataReader=hA(e)}set(e,t,r){this._verifyNotCommitted();let n=cT(e,this._firestore),i=cr(n.converter,t,r),s=hD(this._dataReader,"WriteBatch.set",n._key,i,null!==n.converter,r);return this._mutations.push(s.toMutation(n._key,st.none())),this}update(e,t,r,...n){let i;this._verifyNotCommitted();let s=cT(e,this._firestore);return i="string"==typeof(t=et(t))||t instanceof hv?hF(this._dataReader,"WriteBatch.update",s._key,t,r,n):hP(this._dataReader,"WriteBatch.update",s._key,t),this._mutations.push(i.toMutation(s._key,st.exists(!0))),this}delete(e){this._verifyNotCommitted();let t=cT(e,this._firestore);return this._mutations=this._mutations.concat(new sd(t._key,st.none())),this}commit(){return this._verifyNotCommitted(),this._committed=!0,this._mutations.length>0?this._commitHandler(this._mutations):Promise.resolve()}_verifyNotCommitted(){if(this._committed)throw new tl(to.FAILED_PRECONDITION,"A write batch can no longer be used after commit() has been called.")}}function cT(e,t){if((e=et(e)).firestore!==t)throw new tl(to.INVALID_ARGUMENT,"Provided document reference is from a different Firestore instance.");return e}class cS{constructor(e,t){this._firestore=e,this._transaction=t,this._dataReader=hA(e)}get(e){let t=cT(e,this._firestore),r=new cn(this._firestore);return this._transaction.lookup([t._key]).then(e=>{if(!e||1!==e.length)return ti(24041);let n=e[0];if(n.isFoundDocument())return new hH(this._firestore,r,n.key,n,t.converter);if(n.isNoDocument())return new hH(this._firestore,r,t._key,null,t.converter);throw ti(18433,{doc:n})})}set(e,t,r){let n=cT(e,this._firestore),i=cr(n.converter,t,r),s=hD(this._dataReader,"Transaction.set",n._key,i,null!==n.converter,r);return this._transaction.set(n._key,s),this}update(e,t,r,...n){let i,s=cT(e,this._firestore);return i="string"==typeof(t=et(t))||t instanceof hv?hF(this._dataReader,"Transaction.update",s._key,t,r,n):hP(this._dataReader,"Transaction.update",s._key,t),this._transaction.update(s._key,i),this}delete(e){let t=cT(e,this._firestore);return this._transaction.delete(t._key),this}}class cx extends cS{constructor(e,t){super(e,t),this._firestore=e}get(e){let t=cT(e,this._firestore),r=new ch(this._firestore);return super.get(e).then(e=>new co(this._firestore,r,t._key,e._document,new ca(!1,!1),t.converter))}}function cC(e,t){if("string"!=typeof e[t])throw new tl(to.INVALID_ARGUMENT,"Missing str
23ing value for: "+t);return e[t]}class cA{constructor(e){this._firestore=e,this.type="PersistentCacheIndexManager"}}function cD(e,t){var r;(r=hu(e._firestore),r.asyncQueue.enqueue(async()=>{var e;return e=await uW(r),void(e.Cs.Rs=t)})).then(e=>te(`setting persistent cache index auto creation isEnabled=${t} succeeded`)).catch(e=>tr(`setting persistent cache index auto creation isEnabled=${t} failed`,e))}let cN=new WeakMap;class ck{constructor(){this.Fc=new Map}static get instance(){return cO||function(e){if(sE)throw Error("a TestingHooksSpi instance is already set");sE=e}(cO=new ck),cO}ct(e){this.Fc.forEach(t=>t(e))}onExistenceFilterMismatch(e){let t=Symbol(),r=this.Fc;return r.set(t,e),()=>r.delete(t)}}let cO=null;!function(e=!0){e8=eU,eL(new er("firestore",(t,{instanceIdentifier:r,options:n})=>{let i=t.getProvider("app").getImmediate(),s=new hl(new tf(t.getProvider("auth-internal")),new ty(i,t.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new tl(to.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new nN(e.options.projectId,t)}(i,r),i);return n=Object.assign({useFetchStreams:e},n),s._setSettings(n),s},"PUBLIC").setMultipleInstances(!0)),ez(e3,e5,void 0),ez(e3,e5,"esm2017")}(),e.s(["AbstractUserDataWriter",0,ct,"AggregateField",0,hg,"AggregateQuerySnapshot",0,hm,"Bytes",0,hy,"CACHE_SIZE_UNLIMITED",0,-1,"CollectionReference",0,he,"DocumentReference",0,u9,"DocumentSnapshot",0,co,"FieldPath",0,hv,"FieldValue",0,hw,"Firestore",0,hl,"FirestoreError",0,tl,"GeoPoint",0,hb,"LoadBundleTask",0,ho,"PersistentCacheIndexManager",0,cA,"Query",0,u7,"QueryCompositeFilterConstraint",0,h1,"QueryConstraint",0,hZ,"QueryDocumentSnapshot",0,cl,"QueryEndAtConstraint",0,h5,"QueryFieldFilterConstraint",0,h0,"QueryLimitConstraint",0,h6,"QueryOrderByConstraint",0,h2,"QuerySnapshot",0,cu,"QueryStartAtConstraint",0,h3,"SnapshotMetadata",0,ca,"Timestamp",0,tU,"Transaction",0,cx,"VectorValue",0,hE,"WriteBatch",0,c_,"_AutoId",0,tw,"_ByteString",0,nm,"_DatabaseId",0,nN,"_DocumentKey",0,tD,"_EmptyAppCheckTokenProvider",0,class{getToken(){return Promise.resolve(new tm(""))}invalidateToken(){}start(e,t){}shutdown(){}},"_EmptyAuthCredentialsProvider",0,tc,"_FieldPath",0,tA,"_TestingHooks",0,class{constructor(){throw Error("instances of this class should not be created")}static onExistenceFilterMismatch(e){return ck.instance.onExistenceFilterMismatch(e)}},"_cast",0,tP,"_debugAssert",0,function(e,t){e||ti(57014,t)},"_internalAggregationQueryToProtoRunAggregationQueryRequest",0,function(e,t){var r;let n=na(t,(e,t)=>new sy(t,e.aggregateType,e._internalFieldPath)),i=null==(r=hu(tP(e.firestore,hl))._onlineComponents)?void 0:r.datastore.serializer;return void 0===i?null:s5(i,iN(e._query),n,!0).request},"_internalQueryToProtoQueryTarget",0,function(e){var t;let r=null==(t=hu(tP(e.firestore,hl))._onlineComponents)?void 0:t.datastore.serializer;return void 0===r?null:s3(r,iD(e._query)).Vt},"_isBase64Available",0,function(){return"u">typeof atob},"_logWarn",0,tr,"_validateIsNotUsedTogether",0,tk,"addDoc",0,function(e,t){let r=tP(e.firestore,hl),n=ht(e),i=cr(e.converter,t);return cd(r,[hD(hA(e.firestore),"addDoc",n._key,i,null!==e.converter,{}).toMutation(n._key,st.exists(!1))]).then(()=>n)},"aggregateFieldEqual",0,function(e,t){var r,n;return e instanceof hg&&t instanceof hg&&e.aggregateType===t.aggregateType&&(null==(r=e._internalFieldPath)?void 0:r.canonicalString())===(null==(n=t._internalFieldPath)?void 0:n.canonicalString())},"aggregateQuerySnapshotEqual",0,function(e,t){return hr(e.query,t.query)&&J(e.data(),t.data())},"and",0,function(...e){return e.forEach(e=>ce("and",e)),h1._create("and",e)},"arrayRemove",0,function(...e){return new hL("arrayRemove",e)},"arrayUnion",0,function(...e){return new hR("arrayUnion",e)},"average",0,function(e){return new hg("avg",hz("average",e))},"clearIndexedDbPersistence",0,function(e){if(e._initialized&&!e._terminated)throw new tl(to.FAILED_PRECONDITION,"Persistence can only be cleared before a Firestore instance is initialized or after it is terminated.");let t=new tu;return e._queue.enqueueAndForgetEvenWhileRestricted(async()=>{try{await async function(e){if(!t3.C())return Promise.resolve();await t3.delete(e+ov)}(ob(e._databaseId,e._persistenceKey)),t.resolve()}catch(e){t.reject(e)}}),t.promise},"collection",0,function(e,t,...r){if(e=et(e),tN("collection","path",t),e instanceof u4){let n=tx.fromString(t,...r);return tR(n),new he(e,null,n)}{if(!(e instanceof u9||e instanceof he))throw new tl(to.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");let n=e._path.child(tx.fromString(t,...r));
23return tR(n),new he(e.firestore,null,n)}},"collectionGroup",0,function(e,t){if(e=tP(e,u4),tN("collectionGroup","collection id",t),t.indexOf("/")>=0)throw new tl(to.INVALID_ARGUMENT,`Invalid collection ID '${t}' passed to function collectionGroup(). Collection IDs must not contain '/'.`);return new u7(e,null,new iT(tx.emptyPath(),t))},"connectFirestoreEmulator",0,u8,"count",0,ci,"deleteAllPersistentCacheIndexes",0,function(e){var t;(t=hu(e._firestore)).asyncQueue.enqueue(async()=>{var e;let r;return r=(e=await uW(t)).indexManager,e.persistence.runTransaction("Delete All Indexes","readwrite",e=>r.deleteAllFieldIndexes(e))}).then(e=>te("deleting all persistent cache indexes succeeded")).catch(e=>tr("deleting all persistent cache indexes failed",e))},"deleteDoc",0,function(e){return cd(tP(e.firestore,hl),[new sd(e._key,st.none())])},"deleteField",0,function(){return new hN("deleteField")},"disableNetwork",0,function(e){var t;return(t=hu(e=tP(e,hl))).asyncQueue.enqueue(async()=>{let e=await uH(t),r=await uX(t);return e.setNetworkEnabled(!1),async function(e){e.Ia.add(0),await ld(e),e.Aa.set("Offline")}(r)})},"disablePersistentCacheIndexAutoCreation",0,function(e){cD(e,!1)},"doc",0,ht,"documentId",0,function(){return new hv(tT)},"documentSnapshotFromJSON",0,function(e,t,r){if(tB(t,co._jsonSchema)){var n;if(t.bundle===cs)throw new tl(to.INVALID_ARGUMENT,"The provided JSON object was created in a client environment, which is not supported.");let i=le(e._databaseId),s=(n=t.bundle,new uB(n,i)),a=s.Ku(),o=new lZ(s.getMetadata(),i);for(let e of a)o.Wa(e);let l=o.documents;if(1!==l.length)throw new tl(to.INVALID_ARGUMENT,`Expected bundle data to contain 1 document, but it contains ${l.length} documents.`);let u=s0(i,l[0].document),h=new tD(tx.fromString(t.bundleName));return new co(e,new cn(e),h,u,new ca(!1,!1),r||null)}},"enableIndexedDbPersistence",0,function(e,t){tr("enableIndexedDbPersistence() will be deprecated 
23in the future, you can use `FirestoreSettings.cache` instead.");let r=e._freezeSettings();return hd(e,uM.provider,{build:e=>new uR(e,r.cacheSizeBytes,null==t?void 0:t.forceOwnership)}),Promise.resolve()},"enableMultiTabIndexedDbPersistence",0,hc,"enableNetwork",0,function(e){var t;return(t=hu(e=tP(e,hl))).asyncQueue.enqueue(async()=>{let e=await uH(t),r=await uX(t);return e.setNetworkEnabled(!0),r.Ia.delete(0),lc(r)})},"enablePersistentCacheIndexAutoCreation",0,function(e){cD(e,!0)},"endAt",0,function(...e){return h5._create("endAt",e,!0)},"endBefore",0,function(...e){return h5._create("endBefore",e,!1)},"ensureFirestoreConfigured",0,hu,"executeWrite",0,cd,"getAggregateFromServer",0,cp,"getCountFromServer",0,function(e){return cp(e,{count:ci()})},"getDoc",0,function(e){e=tP(e,u9);let t=tP(e.firestore,hl);return u0(hu(t),e._key).then(r=>cf(t,e,r))},"getDocFromCache",0,function(e){var t;let r;e=tP(e,u9);let n=tP(e.firestore,hl),i=hu(n),s=new ch(n);return(t=e._key,r=new tu,i.asyncQueue.enqueueAndForget(async()=>(async function(e,t,r){try{let n=await e.persistence.runTransaction("read document","readonly",r=>e.localDocuments.getDocument(r,t));n.isFoundDocument()?r.resolve(n):n.isNoDocument()?r.resolve(null):r.reject(new tl(to.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.)"))}catch(n){let e=lV(n,`Failed to get document '${t} from cache`);r.reject(e)}})(await uW(i),t,r)),r.promise).then(t=>new co(n,s,e._key,t,new ca(null!==t&&t.hasLocalMutations,!0),e.converter))},"getDocFromServer",0,function(e){e=tP(e,u9);let t=tP(e.firestore,hl);return u0(hu(t),e._key,{source:"server"}).then(r=>cf(t,e,r))},"getDocs",0,function(e){e=tP(e,u7);let t=tP(e.firestore,hl),r=hu(t),n=new ch(t);return hJ(e._query),u1(r,e._query).then(r=>new cu(t,n,e,r))},"getDocsFromCache",0,function(e){var t;let r;e=tP(e,u7);let n=tP(e.firestore,hl),i=hu(n),s=new ch(n);return(t=e._query,r=new tu,i.asyncQueue.enqueueAndForget(async()=>(async function(e,t,r){try{let n=await ok(e,t,!0),i=new l6(t,n.qs),s=i.nu(n.documents),a=i.applyChanges(s,!1);r.resolve(a.snapshot)}catch(n){let e=lV(n,`Failed to execute query '${t} against cache`);r.reject(e)}})(await uW(i),t,r)),r.promise).then(t=>new cu(n,s,e,t))},"getDocsFromServer",0,function(e){e=tP(e,u7);let t=tP(e.firestore,hl),r=hu(t),n=new ch(t);return u1(r,e._query,{source:"server"}).then(r=>new cu(t,n,e,r))},"getFirestore",0,function(e,t){let r="object"==typeof e?e:ej(),n="string"==typeof e?e:t||nD,i=eM(r,"firestore").getImmediate({identifier:n});if(!i._initialized){let e=O("firestore");e&&u8(i,...e)}return i},"getPersistentCacheIndexManager",0,function(e){var t;e=tP(e,hl);let r=cN.get(e);if(r)return r;if("persistent"!==(null==(t=hu(e)._uninitializedComponentsProvider)?void 0:t._offline.kind))return null;let n=new cA(e);return cN.set(e,n),n},"increment",0,function(e){return new hM("increment",e)},"initializeFirestore",0,function(e,t,r){r||(r=nD);let n=eM(e,"firestore");if(n.isInitialized(r)){let e=n.getImmediate({identifier:r});if(J(n.getOptions(r),t))return e;throw new tl(to.FAILED_PRECONDITION,"initializeFirestore() has already been called with different options. To avoid this error, call initializeFirestore() with the same options as when it was originally called, or call getFirestore() to return the already initialized instance.")}if(void 0!==t.cacheSizeBytes&&void 0!==t.localCache)throw new tl(to.INVALID_ARGUMENT,"cache and cacheSizeBytes cannot be specified at the same time as cacheSizeBytes willbe deprecated. Instead, specify the cache size in the cache object");if(void 0!==t.cacheSizeBytes&&-1!==t.cacheSizeBytes&&t.cacheSizeBytes<1048576)throw new tl(to.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");return t.host&&M(t.host)&&P(t.host),n.initialize({options:t,instanceIdentifier:r})},"limit",0,function(e){return tF("limit",e),h6._create("limit",e,"F")},"limitToLast",0,function(e){return tF("limitToLast",e),h6._create("limitToLast",e,"L")},"loadBundle",0,hf,"memoryEagerGarbageCollector",0,function(){return new cy},"memoryLocalCache",0,function(e){return new cg(e)},"memoryLruGarbageCollector",0,function(e){return new cv(null==e?void 0:e.cacheSizeBytes)},"namedQuery",0,hp,"onSnapshot",0,cc,"onSnapshotResume",0,function(e,t,...r){var n,i,s,a,o,l;let u=et(e),h=function(e){let t={bundle:"",bundleName:"",bundleSource:""};for(let r of["bundle","bundleName","bundleSource"]){if(!(r in e)){t.error=`snapshotJson missing required field: ${r}`;break}let n=e[r];if("string"!=typeof n){t.error=`snapshotJson field '${r}' must be a string.`;break}if(0===n.length){t.error=`snapshotJson field '${r}
23' cannot be an empty string.`;break}"bundle"===r?t.bundle=n:"bundleName"===r?t.bundleName=n:"bundleSource"===r&&(t.bundleSource=n)}return t}(t);if(h.error)throw new tl(to.INVALID_ARGUMENT,h.error);let c,d=0;if("object"!=typeof r[0]||ha(r[d])||(c=r[d++]),"QuerySnapshot"===h.bundleSource){let e,t,a=null;if("object"==typeof r[d]&&ha(r[d])){let e=r[d++];a={next:e.next,error:e.error,complete:e.complete}}else a={next:r[d++],error:r[d++],complete:r[d++]};return n=c,i=a,s=r[d],t=!1,hf(u,h.bundle).then(()=>hp(u,h.bundleName)).then(r=>{r&&!t&&(s&&r.withConverter(s),e=cc(r,n||{},i))}).catch(e=>(i.error&&i.error(e),()=>{})),()=>{t||(t=!0,e&&e())}}if("DocumentSnapshot"===h.bundleSource){let e,t,n=null;if("object"==typeof r[d]&&ha(r[d])){let e=r[d++];n={next:e.next,error:e.error,complete:e.complete}}else n={next:r[d++],error:r[d++],complete:r[d++]};return a=c,o=n,l=r[d],t=!1,hf(u,h.bundle).then(()=>{t||(e=cc(new u9(u,l||null,tD.fromPath(h.bundleName)),a||{},o))}).catch(e=>(o.error&&o.error(e),()=>{})),()=>{t||(t=!0,e&&e())}}throw new tl(to.INVALID_ARGUMENT,`unsupported bundle source: ${h.bundleSource}`)},"onSnapshotsInSync",0,function(e,t){var r;let n;return r=hu(e=tP(e,hl)),n=new uF(ha(t)?t:{next:t}),r.asyncQueue.enqueueAndForget(async()=>{var e;return e=await uZ(r),void(e.Da.add(n),n.next())}),()=>{n.Ou(),r.asyncQueue.enqueueAndForget(async()=>{var e;return e=await uZ(r),void e.Da.delete(n)})}},"or",0,function(...e){return e.forEach(e=>ce("or",e)),h1._create("or",e)},"orderBy",0,function(e,t="asc"){let r=hX("orderBy",e);return h2._create(r,t)},"persistentLocalCache",0,function(e){return new cm(e)},"persistentMultipleTabManager",0,function(){return new cb},"persistentSingleTabManager",0,cE,"query",0,function(e,t,...r){let n=[];for(let i of(t instanceof hY&&n.push(t),function(e){let t=e.filter(e=>e instanceof h1).length,r=e.filter(e=>e instanceof h0).length;if(t>1||t>0&&r>0)throw new tl(to.INVALID_ARGUMENT,"InvalidQuery. When using composite filters, you cannot use more than one filter at the top level. Consider nesting the multiple filters within an `and(...)` statement. For example: change `query(query, where(...), or(...))` to `query(query, and(where(...), or(...)))`.")}(n=n.concat(r)),n))e=i._apply(e);return e},"queryEqual",0,hr,"querySnapshotFromJSON",0,function(e,t,r){if(tB(t,cu._jsonSchema)){var n;if(t.bundle===cs)throw new tl(to.INVALID_ARGUMENT,"The provided JSON object was created in a client environment, which is not supported.");let i=le(e._databaseId),s=(n=t.bundle,new uB(n,i)),a=s.Ku(),o=new lZ(s.getMetadata(),i);for(let e of a)o.Wa(e);if(1!==o.queries.length)throw new tl(to.INVALID_ARGUMENT,`Snapshot data expected 1 query but found ${o.queries.length} queries.`);let l=au(o.queries[0].bundledQuery),u=o.documents,h=new lB;u.map(e=>{let t=s0(i,e.document);h=h.add(t)});let c=lq.fromInitialDocuments(l,h,iH(),!1,!1),d=new u7(e,r||null,l);return new cu(e,new cn(e),d,c)}},"refEqual",0,function(e,t){return e=et(e),t=et(t),(e instanceof u9||e instanceof he)&&(t instanceof u9||t instanceof he)&&e.firestore===t.firestore&&e.path===t.path&&e.converter===t.converter},"runTransaction",0,function(e,t,r){var n,i;let s;e=tP(e,hl);let a=Object.assign(Object.assign({},cI),r);if(a.maxAttempts<1)throw new tl(to.INVALID_ARGUMENT,"Max attempts must be at least 1");return n=hu(e),i=r=>t(new cx(e,r)),s=new tu,n.asyncQueue.enqueueAndForget(async()=>{let e=await uY(n);new uq(n.asyncQueue,e,a,i,s).zu()}),s.promise},"serverTimestamp",0,function(){return new hO("serverTimestamp")},"setDoc",0,function(e,t,r){e=tP(e,u9);let n=tP(e.firestore,hl),i=cr(e.converter,t,r);return cd(n,[hD(hA(n),"setDoc",e._key,i,null!==e.converter,r).toMutation(e._key,st.none())])},"setIndexConfiguration",0,function(e,t){let r=hu(e=tP(e,hl));if(!r._uninitializedComponentsProvider||"memory"===r._uninitializedComponentsProvider._offline.kind)return tr("Cannot enable indexes when persistence is disabled"),Promise.resolve();let n=function(e){let t="string"==typeof e?function(e){try{return JSON.parse(e)}catch(e){throw new tl(to.INVALID_ARGUMENT,"Failed to parse JSON: "+(null==e?void 0:e.message))}}(e):e,r=[];if(Array.isArray(t.indexes))for(let e of t.indexes){let t=cC(e,"collectionGroup"),n=[];if(Array.isArray(e.fields))for(let t of e.fields){let e=hG("setIndexConfiguration",cC(t,"fieldPath"));"CONTAINS"===t.arrayConfig?n.push(new tK(e,2)):"ASCENDING"===t.order?n.push(new tK(e,0)):"DESCENDING"===t.order&&n.push(new tK(e,1))}r.push(new tj(tj.UNKNOWN_ID,t,n,tQ.empty()))}return r}(t);return r.asyncQueue.enqueue(async()=>(async function(e,t){let r=e.indexManager,n=[];return e.persistence.runTransaction("Configure indexes","readwrite",e=>r.getFieldIndexes(e).next(i=>(function(e,t,r,n,i){t=[...t],(e=[...e]).sort(r),t.sort(r);let s=e.length,a=t.length,o=0,l=0;for(;o<a&&l<s;){let s=r(e[l],t[o]);s<0?i(e[l++]):s>0?n(t[o++]):(o++,l++)}for(;o<a;
23)n(t[o++]);for(;l<s;)i(e[l++])})(i,t,tG,t=>{n.push(r.addFieldIndex(e,t))},t=>{n.push(r.deleteFieldIndex(e,t))})).next(()=>t1.waitFor(n)))})(await uW(r),n))},"setLogLevel",0,function(e){e7.setLogLevel(e)},"snapshotEqual",0,function(e,t){return e instanceof co&&t instanceof co?e._firestore===t._firestore&&e._key.isEqual(t._key)&&(null===e._document?null===t._document:e._document.isEqual(t._document))&&e._converter===t._converter:e instanceof cu&&t instanceof cu&&e._firestore===t._firestore&&hr(e.query,t.query)&&e.metadata.isEqual(t.metadata)&&e._snapshot.isEqual(t._snapshot)},"startAfter",0,function(...e){return h3._create("startAfter",e,!1)},"startAt",0,function(...e){return h3._create("startAt",e,!0)},"sum",0,function(e){return new hg("sum",hz("sum",e))},"terminate",0,function(e){return eP(e.app,"firestore",e._databaseId.database),e._delete()},"updateDoc",0,function(e,t,r,...n){e=tP(e,u9);let i=tP(e.firestore,hl),s=hA(i);return cd(i,[("string"==typeof(t=et(t))||t instanceof hv?hF(s,"updateDoc",e._key,t,r,n):hP(s,"updateDoc",e._key,t)).toMutation(e._key,st.exists(!0))])},"vector",0,function(e){return new hE(e)},"waitForPendingWrites",0,function(e){var t;let r;return t=hu(e=tP(e,hl)),r=new tu,t.asyncQueue.enqueueAndForget(async()=>uh(await uJ(t),r)),r.promise},"where",0,function(e,t,r){let n=hX("where",e);return h0._create(n,t,r)},"writeBatch",0,function(e){return hu(e=tP(e,hl)),new c_(e,t=>cd(e,t))}],28075),e.s([],661113)}]);

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.