import{C as e,S as t,_ as n,a as r,b as i,c as a,d as o,f as s,g as c,h as l,l as u,m as d,o as f,p,s as m,t as h,u as g,v as ee,w as te,x as ne,y as _}from"./index.esm-A-QCvYor.js";
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
o(`firebase`,`12.4.0`,`app`);var re=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},ie={},ae,oe;(function(){var e;function t(e,t){function n(){}n.prototype=t.prototype,e.F=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.D=function(e,n,r){for(var i=Array(arguments.length-2),a=2;a<arguments.length;a++)i[a-2]=arguments[a];return t.prototype[n].apply(e,i)}}function n(){this.blockSize=-1}function r(){this.blockSize=-1,this.blockSize=64,this.g=[,,,,],this.C=Array(this.blockSize),this.o=this.h=0,this.u()}t(r,n),r.prototype.u=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0};function i(e,t,n){n||=0;let r=Array(16);if(typeof t==`string`)for(var i=0;i<16;++i)r[i]=t.charCodeAt(n++)|t.charCodeAt(n++)<<8|t.charCodeAt(n++)<<16|t.charCodeAt(n++)<<24;else for(i=0;i<16;++i)r[i]=t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24;t=e.g[0],n=e.g[1],i=e.g[2];let a=e.g[3],o;o=t+(a^n&(i^a))+r[0]+3614090360&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[1]+3905402710&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[2]+606105819&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[3]+3250441966&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(a^n&(i^a))+r[4]+4118548399&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[5]+1200080426&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[6]+2821735955&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[7]+4249261313&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(a^n&(i^a))+r[8]+1770035416&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[9]+2336552879&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[10]+4294925233&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[11]+2304563134&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(a^n&(i^a))+r[12]+1804603682&4294967295,t=n+(o<<7&4294967295|o>>>25),o=a+(i^t&(n^i))+r[13]+4254626195&4294967295,a=t+(o<<12&4294967295|o>>>20),o=i+(n^a&(t^n))+r[14]+2792965006&4294967295,i=a+(o<<17&4294967295|o>>>15),o=n+(t^i&(a^t))+r[15]+1236535329&4294967295,n=i+(o<<22&4294967295|o>>>10),o=t+(i^a&(n^i))+r[1]+4129170786&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[6]+3225465664&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[11]+643717713&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[0]+3921069994&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^a&(n^i))+r[5]+3593408605&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[10]+38016083&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[15]+3634488961&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[4]+3889429448&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^a&(n^i))+r[9]+568446438&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[14]+3275163606&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[3]+4107603335&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[8]+1163531501&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(i^a&(n^i))+r[13]+2850285829&4294967295,t=n+(o<<5&4294967295|o>>>27),o=a+(n^i&(t^n))+r[2]+4243563512&4294967295,a=t+(o<<9&4294967295|o>>>23),o=i+(t^n&(a^t))+r[7]+1735328473&4294967295,i=a+(o<<14&4294967295|o>>>18),o=n+(a^t&(i^a))+r[12]+2368359562&4294967295,n=i+(o<<20&4294967295|o>>>12),o=t+(n^i^a)+r[5]+4294588738&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[8]+2272392833&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[11]+1839030562&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[14]+4259657740&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(n^i^a)+r[1]+2763975236&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[4]+1272893353&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[7]+4139469664&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[10]+3200236656&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(n^i^a)+r[13]+681279174&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[0]+3936430074&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[3]+3572445317&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[6]+76029189&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(n^i^a)+r[9]+3654602809&4294967295,t=n+(o<<4&4294967295|o>>>28),o=a+(t^n^i)+r[12]+3873151461&4294967295,a=t+(o<<11&4294967295|o>>>21),o=i+(a^t^n)+r[15]+530742520&4294967295,i=a+(o<<16&4294967295|o>>>16),o=n+(i^a^t)+r[2]+3299628645&4294967295,n=i+(o<<23&4294967295|o>>>9),o=t+(i^(n|~a))+r[0]+4096336452&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[7]+1126891415&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[14]+2878612391&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[5]+4237533241&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~a))+r[12]+1700485571&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[3]+2399980690&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[10]+4293915773&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[1]+2240044497&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~a))+r[8]+1873313359&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[15]+4264355552&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[6]+2734768916&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[13]+1309151649&4294967295,n=i+(o<<21&4294967295|o>>>11),o=t+(i^(n|~a))+r[4]+4149444226&4294967295,t=n+(o<<6&4294967295|o>>>26),o=a+(n^(t|~i))+r[11]+3174756917&4294967295,a=t+(o<<10&4294967295|o>>>22),o=i+(t^(a|~n))+r[2]+718787259&4294967295,i=a+(o<<15&4294967295|o>>>17),o=n+(a^(i|~t))+r[9]+3951481745&4294967295,e.g[0]=e.g[0]+t&4294967295,e.g[1]=e.g[1]+(i+(o<<21&4294967295|o>>>11))&4294967295,e.g[2]=e.g[2]+i&4294967295,e.g[3]=e.g[3]+a&4294967295}r.prototype.v=function(e,t){t===void 0&&(t=e.length);let n=t-this.blockSize,r=this.C,a=this.h,o=0;for(;o<t;){if(a==0)for(;o<=n;)i(this,e,o),o+=this.blockSize;if(typeof e==`string`){for(;o<t;)if(r[a++]=e.charCodeAt(o++),a==this.blockSize){i(this,r),a=0;break}}else for(;o<t;)if(r[a++]=e[o++],a==this.blockSize){i(this,r),a=0;break}}this.h=a,this.o+=t},r.prototype.A=function(){var e=Array((this.h<56?this.blockSize:this.blockSize*2)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;t=this.o*8;for(var n=e.length-8;n<e.length;++n)e[n]=t&255,t/=256;for(this.v(e),e=Array(16),t=0,n=0;n<4;++n)for(let r=0;r<32;r+=8)e[t++]=this.g[n]>>>r&255;return e};function a(e,t){var n=s;return Object.prototype.hasOwnProperty.call(n,e)?n[e]:n[e]=t(e)}function o(e,t){this.h=t;let n=[],r=!0;for(let i=e.length-1;i>=0;i--){let a=e[i]|0;r&&a==t||(n[i]=a,r=!1)}this.g=n}var s={};function c(e){return-128<=e&&e<128?a(e,function(e){return new o([e|0],e<0?-1:0)}):new o([e|0],e<0?-1:0)}function l(e){if(isNaN(e)||!isFinite(e))return d;if(e<0)return g(l(-e));let t=[],n=1;for(let r=0;e>=n;r++)t[r]=e/n|0,n*=4294967296;return new o(t,0)}function u(e,t){if(e.length==0)throw Error(`number format error: empty string`);if(t||=10,t<2||36<t)throw Error(`radix out of range: `+t);if(e.charAt(0)==`-`)return g(u(e.substring(1),t));if(e.indexOf(`-`)>=0)throw Error(`number format error: interior "-" character`);let n=l(t**8),r=d;for(let a=0;a<e.length;a+=8){var i=Math.min(8,e.length-a);let o=parseInt(e.substring(a,a+i),t);i<8?(i=l(t**+i),r=r.j(i).add(l(o))):(r=r.j(n),r=r.add(l(o)))}return r}var d=c(0),f=c(1),p=c(16777216);e=o.prototype,e.m=function(){if(h(this))return-g(this).m();let e=0,t=1;for(let n=0;n<this.g.length;n++){let r=this.i(n);e+=(r>=0?r:4294967296+r)*t,t*=4294967296}return e},e.toString=function(e){if(e||=10,e<2||36<e)throw Error(`radix out of range: `+e);if(m(this))return`0`;if(h(this))return`-`+g(this).toString(e);let t=l(e**6);var n=this;let r=``;for(;;){let i=_(n,t).g;n=ee(n,i.j(t));let a=((n.g.length>0?n.g[0]:n.h)>>>0).toString(e);if(n=i,m(n))return a+r;for(;a.length<6;)a=`0`+a;r=a+r}},e.i=function(e){return e<0?0:e<this.g.length?this.g[e]:this.h};function m(e){if(e.h!=0)return!1;for(let t=0;t<e.g.length;t++)if(e.g[t]!=0)return!1;return!0}function h(e){return e.h==-1}e.l=function(e){return e=ee(this,e),h(e)?-1:m(e)?0:1};function g(e){let t=e.g.length,n=[];for(let r=0;r<t;r++)n[r]=~e.g[r];return new o(n,~e.h).add(f)}e.abs=function(){return h(this)?g(this):this},e.add=function(e){let t=Math.max(this.g.length,e.g.length),n=[],r=0;for(let i=0;i<=t;i++){let t=r+(this.i(i)&65535)+(e.i(i)&65535),a=(t>>>16)+(this.i(i)>>>16)+(e.i(i)>>>16);r=a>>>16,t&=65535,a&=65535,n[i]=a<<16|t}return new o(n,n[n.length-1]&-2147483648?-1:0)};function ee(e,t){return e.add(g(t))}e.j=function(e){if(m(this)||m(e))return d;if(h(this))return h(e)?g(this).j(g(e)):g(g(this).j(e));if(h(e))return g(this.j(g(e)));if(this.l(p)<0&&e.l(p)<0)return l(this.m()*e.m());let t=this.g.length+e.g.length,n=[];for(var r=0;r<2*t;r++)n[r]=0;for(r=0;r<this.g.length;r++)for(let t=0;t<e.g.length;t++){let i=this.i(r)>>>16,a=this.i(r)&65535,o=e.i(t)>>>16,s=e.i(t)&65535;n[2*r+2*t]+=a*s,te(n,2*r+2*t),n[2*r+2*t+1]+=i*s,te(n,2*r+2*t+1),n[2*r+2*t+1]+=a*o,te(n,2*r+2*t+1),n[2*r+2*t+2]+=i*o,te(n,2*r+2*t+2)}for(e=0;e<t;e++)n[e]=n[2*e+1]<<16|n[2*e];for(e=t;e<2*t;e++)n[e]=0;return new o(n,0)};function te(e,t){for(;(e[t]&65535)!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function ne(e,t){this.g=e,this.h=t}function _(e,t){if(m(t))throw Error(`division by zero`);if(m(e))return new ne(d,d);if(h(e))return t=_(g(e),t),new ne(g(t.g),g(t.h));if(h(t))return t=_(e,g(t)),new ne(g(t.g),t.h);if(e.g.length>30){if(h(e)||h(t))throw Error(`slowDivide_ only works with positive integers.`);for(var n=f,r=t;r.l(e)<=0;)n=re(n),r=re(r);var i=se(n,1),a=se(r,1);for(r=se(r,2),n=se(n,2);!m(r);){var o=a.add(r);o.l(e)<=0&&(i=i.add(n),a=o),r=se(r,1),n=se(n,1)}return t=ee(e,i.j(t)),new ne(i,t)}for(i=d;e.l(t)>=0;){for(n=Math.max(1,Math.floor(e.m()/t.m())),r=Math.ceil(Math.log(n)/Math.LN2),r=r<=48?1:2**(r-48),a=l(n),o=a.j(t);h(o)||o.l(e)>0;)n-=r,a=l(n),o=a.j(t);m(a)&&(a=f),i=i.add(a),e=ee(e,o)}return new ne(i,e)}e.B=function(e){return _(this,e).h},e.and=function(e){let t=Math.max(this.g.length,e.g.length),n=[];for(let r=0;r<t;r++)n[r]=this.i(r)&e.i(r);return new o(n,this.h&e.h)},e.or=function(e){let t=Math.max(this.g.length,e.g.length),n=[];for(let r=0;r<t;r++)n[r]=this.i(r)|e.i(r);return new o(n,this.h|e.h)},e.xor=function(e){let t=Math.max(this.g.length,e.g.length),n=[];for(let r=0;r<t;r++)n[r]=this.i(r)^e.i(r);return new o(n,this.h^e.h)};function re(e){let t=e.g.length+1,n=[];for(let r=0;r<t;r++)n[r]=e.i(r)<<1|e.i(r-1)>>>31;return new o(n,e.h)}function se(e,t){let n=t>>5;t%=32;let r=e.g.length-n,i=[];for(let a=0;a<r;a++)i[a]=t>0?e.i(a+n)>>>t|e.i(a+n+1)<<32-t:e.i(a+n);return new o(i,e.h)}r.prototype.digest=r.prototype.A,r.prototype.reset=r.prototype.u,r.prototype.update=r.prototype.v,oe=ie.Md5=r,o.prototype.add=o.prototype.add,o.prototype.multiply=o.prototype.j,o.prototype.modulo=o.prototype.B,o.prototype.compare=o.prototype.l,o.prototype.toNumber=o.prototype.m,o.prototype.toString=o.prototype.toString,o.prototype.getBits=o.prototype.i,o.fromNumber=l,o.fromString=u,ae=ie.Integer=o}).apply(re===void 0?typeof self<`u`?self:typeof window<`u`?window:{}:re);var se=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},ce={},le,ue,de,fe,pe,me,he,ge;(function(){var e,t=Object.defineProperty;function n(e){e=[typeof globalThis==`object`&&globalThis,e,typeof window==`object`&&window,typeof self==`object`&&self,typeof se==`object`&&se];for(var t=0;t<e.length;++t){var n=e[t];if(n&&n.Math==Math)return n}throw Error(`Cannot find global object`)}var r=n(this);function i(e,n){if(n)a:{var i=r;e=e.split(`.`);for(var a=0;a<e.length-1;a++){var o=e[a];if(!(o in i))break a;i=i[o]}e=e[e.length-1],a=i[e],n=n(a),n!=a&&n!=null&&t(i,e,{configurable:!0,writable:!0,value:n})}}i(`Symbol.dispose`,function(e){return e||Symbol(`Symbol.dispose`)}),i(`Array.prototype.values`,function(e){return e||function(){return this[Symbol.iterator]()}}),i(`Object.entries`,function(e){return e||function(e){var t=[],n;for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push([n,e[n]]);return t}});var a=a||{},o=this||self;function s(e){var t=typeof e;return t==`object`&&e!=null||t==`function`}function c(e,t,n){return e.call.apply(e.bind,arguments)}function l(e,t,n){return l=c,l.apply(null,arguments)}function u(e,t){var n=Array.prototype.slice.call(arguments,1);return function(){var t=n.slice();return t.push.apply(t,arguments),e.apply(this,t)}}function d(e,t){function n(){}n.prototype=t.prototype,e.Z=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Ob=function(e,n,r){for(var i=Array(arguments.length-2),a=2;a<arguments.length;a++)i[a-2]=arguments[a];return t.prototype[n].apply(e,i)}}var f=typeof AsyncContext<`u`&&typeof AsyncContext.Snapshot==`function`?e=>e&&AsyncContext.Snapshot.wrap(e):e=>e;function p(e){let t=e.length;if(t>0){let n=Array(t);for(let r=0;r<t;r++)n[r]=e[r];return n}return[]}function m(e,t){for(let t=1;t<arguments.length;t++){let r=arguments[t];var n=typeof r;if(n=n==`object`?r?Array.isArray(r)?`array`:n:`null`:n,n==`array`||n==`object`&&typeof r.length==`number`){n=e.length||0;let t=r.length||0;e.length=n+t;for(let i=0;i<t;i++)e[n+i]=r[i]}else e.push(r)}}class h{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return this.h>0?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}function g(e){o.setTimeout(()=>{throw e},0)}function ee(){var e=ae;let t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}class te{constructor(){this.h=this.g=null}add(e,t){let n=ne.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}}var ne=new h(()=>new _,e=>e.reset());class _{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 re,ie=!1,ae=new te,oe=()=>{let e=Promise.resolve(void 0);re=()=>{e.then(_e)}};function _e(){for(var e;e=ee();){try{e.h.call(e.g)}catch(e){g(e)}var t=ne;t.j(e),t.h<100&&(t.h++,e.next=t.g,t.g=e)}ie=!1}function ve(){this.u=this.u,this.C=this.C}ve.prototype.u=!1,ve.prototype.dispose=function(){this.u||(this.u=!0,this.N())},ve.prototype[Symbol.dispose]=function(){this.dispose()},ve.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()};function v(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}v.prototype.h=function(){this.defaultPrevented=!0};var ye=function(){if(!o.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},`passive`,{get:function(){e=!0}});try{let e=()=>{};o.addEventListener(`test`,e,t),o.removeEventListener(`test`,e,t)}catch{}return e}();function be(e){return/^[\s\xa0]*$/.test(e)}function xe(e,t){v.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&&this.init(e,t)}d(xe,v),xe.prototype.init=function(e,t){let n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget,t||(n==`mouseover`?t=e.fromElement:n==`mouseout`&&(t=e.toElement)),this.relatedTarget=t,r?(this.clientX=r.clientX===void 0?r.pageX:r.clientX,this.clientY=r.clientY===void 0?r.pageY:r.clientY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=e.clientX===void 0?e.pageX:e.clientX,this.clientY=e.clientY===void 0?e.pageY:e.clientY,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=e.pointerType,this.state=e.state,this.i=e,e.defaultPrevented&&xe.Z.h.call(this)},xe.prototype.h=function(){xe.Z.h.call(this);let e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var y=`closure_listenable_`+(Math.random()*1e6|0),Se=0;function Ce(e,t,n,r,i){this.listener=e,this.proxy=null,this.src=t,this.type=n,this.capture=!!r,this.ha=i,this.key=++Se,this.da=this.fa=!1}function we(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function b(e,t,n){for(let r in e)t.call(n,e[r],r,e)}function Te(e,t){for(let n in e)t.call(void 0,e[n],n,e)}function x(e){let t={};for(let n in e)t[n]=e[n];return t}let S=`constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf`.split(` `);function C(e,t){let n,r;for(let t=1;t<arguments.length;t++){for(n in r=arguments[t],r)e[n]=r[n];for(let t=0;t<S.length;t++)n=S[t],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function w(e){this.src=e,this.g={},this.h=0}w.prototype.add=function(e,t,n,r,i){let a=e.toString();e=this.g[a],e||(e=this.g[a]=[],this.h++);let o=De(e,t,r,i);return o>-1?(t=e[o],n||(t.fa=!1)):(t=new Ce(t,this.src,a,!!r,i),t.fa=n,e.push(t)),t};function Ee(e,t){let n=t.type;if(n in e.g){var r=e.g[n],i=Array.prototype.indexOf.call(r,t,void 0),a;(a=i>=0)&&Array.prototype.splice.call(r,i,1),a&&(we(t),e.g[n].length==0&&(delete e.g[n],e.h--))}}function De(e,t,n,r){for(let i=0;i<e.length;++i){let a=e[i];if(!a.da&&a.listener==t&&a.capture==!!n&&a.ha==r)return i}return-1}var Oe=`closure_lm_`+(Math.random()*1e6|0),ke={};function Ae(e,t,n,r,i){if(r&&r.once)return Ne(e,t,n,r,i);if(Array.isArray(t)){for(let a=0;a<t.length;a++)Ae(e,t[a],n,r,i);return null}return n=ze(n),e&&e[y]?e.J(t,n,s(r)?!!r.capture:!!r,i):je(e,t,n,!1,r,i)}function je(e,t,n,r,i,a){if(!t)throw Error(`Invalid event type`);let o=s(i)?!!i.capture:!!i,c=Le(e);if(c||(e[Oe]=c=new w(e)),n=c.add(t,n,r,o,a),n.proxy)return n;if(r=Me(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)ye||(i=o),i===void 0&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(Ie(t.toString()),r);else if(e.addListener&&e.removeListener)e.addListener(r);else throw Error(`addEventListener and attachEvent are unavailable.`);return n}function Me(){function e(n){return t.call(e.src,e.listener,n)}let t=T;return e}function Ne(e,t,n,r,i){if(Array.isArray(t)){for(let a=0;a<t.length;a++)Ne(e,t[a],n,r,i);return null}return n=ze(n),e&&e[y]?e.K(t,n,s(r)?!!r.capture:!!r,i):je(e,t,n,!0,r,i)}function Pe(e,t,n,r,i){if(Array.isArray(t))for(var a=0;a<t.length;a++)Pe(e,t[a],n,r,i);else r=s(r)?!!r.capture:!!r,n=ze(n),e&&e[y]?(e=e.i,a=String(t).toString(),a in e.g&&(t=e.g[a],n=De(t,n,r,i),n>-1&&(we(t[n]),Array.prototype.splice.call(t,n,1),t.length==0&&(delete e.g[a],e.h--)))):(e&&=Le(e))&&(t=e.g[t.toString()],e=-1,t&&(e=De(t,n,r,i)),(n=e>-1?t[e]:null)&&Fe(n))}function Fe(e){if(typeof e!=`number`&&e&&!e.da){var t=e.src;if(t&&t[y])Ee(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(Ie(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=Le(t))?(Ee(n,e),n.h==0&&(n.src=null,t[Oe]=null)):we(e)}}}function Ie(e){return e in ke?ke[e]:ke[e]=`on`+e}function T(e,t){if(e.da)e=!0;else{t=new xe(t,this);let n=e.listener,r=e.ha||e.src;e.fa&&Fe(e),e=n.call(r,t)}return e}function Le(e){return e=e[Oe],e instanceof w?e:null}var Re=`__closure_events_fn_`+(Math.random()*1e9>>>0);function ze(e){return typeof e==`function`?e:(e[Re]||(e[Re]=function(t){return e.handleEvent(t)}),e[Re])}function E(){ve.call(this),this.i=new w(this),this.M=this,this.G=null}d(E,ve),E.prototype[y]=!0,E.prototype.removeEventListener=function(e,t,n,r){Pe(this,e,t,n,r)};function D(e,t){var n,r=e.G;if(r)for(n=[];r;r=r.G)n.push(r);if(e=e.M,r=t.type||t,typeof t==`string`)t=new v(t,e);else if(t instanceof v)t.target=t.target||e;else{var i=t;t=new v(r,e),C(t,i)}i=!0;let a,o;if(n)for(o=n.length-1;o>=0;o--)a=t.g=n[o],i=Be(a,r,!0,t)&&i;if(a=t.g=e,i=Be(a,r,!0,t)&&i,i=Be(a,r,!1,t)&&i,n)for(o=0;o<n.length;o++)a=t.g=n[o],i=Be(a,r,!1,t)&&i}E.prototype.N=function(){if(E.Z.N.call(this),this.i){var e=this.i;for(let t in e.g){let n=e.g[t];for(let e=0;e<n.length;e++)we(n[e]);delete e.g[t],e.h--}}this.G=null},E.prototype.J=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},E.prototype.K=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};function Be(e,t,n,r){if(t=e.i.g[String(t)],!t)return!0;t=t.concat();let i=!0;for(let a=0;a<t.length;++a){let o=t[a];if(o&&!o.da&&o.capture==n){let t=o.listener,n=o.ha||o.src;o.fa&&Ee(e.i,o),i=t.call(n,r)!==!1&&i}}return i&&!r.defaultPrevented}function Ve(e,t){if(typeof e!=`function`)if(e&&typeof e.handleEvent==`function`)e=l(e.handleEvent,e);else throw Error(`Invalid listener argument`);return Number(t)>2147483647?-1:o.setTimeout(e,t||0)}function O(e){e.g=Ve(()=>{e.g=null,e.i&&(e.i=!1,O(e))},e.l);let t=e.h;e.h=null,e.m.apply(null,t)}class He extends ve{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:O(this)}N(){super.N(),this.g&&(o.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function k(e){ve.call(this),this.h=e,this.g={}}d(k,ve);var A=[];function Ue(e){b(e.g,function(e,t){this.g.hasOwnProperty(t)&&Fe(e)},e),e.g={}}k.prototype.N=function(){k.Z.N.call(this),Ue(this)},k.prototype.handleEvent=function(){throw Error(`EventHandler.handleEvent not implemented`)};var We=o.JSON.stringify,Ge=o.JSON.parse,Ke=class{stringify(e){return o.JSON.stringify(e,void 0)}parse(e){return o.JSON.parse(e,void 0)}};function qe(){}function Je(){}var Ye={OPEN:`a`,hb:`b`,ERROR:`c`,tb:`d`};function j(){v.call(this,`d`)}d(j,v);function Xe(){v.call(this,`c`)}d(Xe,v);var Ze={},Qe=null;function M(){return Qe||=new E}Ze.Ia=`serverreachability`;function N(e){v.call(this,Ze.Ia,e)}d(N,v);function $e(e){let t=M();D(t,new N(t))}Ze.STAT_EVENT=`statevent`;function et(e,t){v.call(this,Ze.STAT_EVENT,e),this.stat=t}d(et,v);function P(e){let t=M();D(t,new et(t,e))}Ze.Ja=`timingevent`;function tt(e,t){v.call(this,Ze.Ja,e),this.size=t}d(tt,v);function nt(e,t){if(typeof e!=`function`)throw Error(`Fn must not be null and must be a function`);return o.setTimeout(function(){e()},t)}function rt(){this.g=!0}rt.prototype.ua=function(){this.g=!1};function it(e,t,n,r,i,a){e.info(function(){if(e.g)if(a){var o=``,s=a.split(`&`);for(let e=0;e<s.length;e++){var c=s[e].split(`=`);if(c.length>1){let e=c[0];c=c[1];let t=e.split(`_`);o=t.length>=2&&t[1]==`type`?o+(e+`=`+c+`&`):o+(e+`=redacted&`)}}}else o=null;else o=a;return`XMLHTTP REQ (`+r+`) [attempt `+i+`]: `+t+`
`+n+`
`+o})}function at(e,t,n,r,i,a,o){e.info(function(){return`XMLHTTP RESP (`+r+`) [ attempt `+i+`]: `+t+`
`+n+`
`+a+` `+o})}function F(e,t,n,r){e.info(function(){return`XMLHTTP TEXT (`+t+`): `+ot(e,n)+(r?` `+r:``)})}function I(e,t){e.info(function(){return`TIMEOUT: `+t})}rt.prototype.info=function(){};function ot(e,t){if(!e.g)return t;if(!t)return null;try{let a=JSON.parse(t);if(a){for(e=0;e<a.length;e++)if(Array.isArray(a[e])){var n=a[e];if(!(n.length<2)){var r=n[1];if(Array.isArray(r)&&!(r.length<1)){var i=r[0];if(i!=`noop`&&i!=`stop`&&i!=`close`)for(let e=1;e<r.length;e++)r[e]=``}}}}return We(a)}catch{return t}}var st={NO_ERROR:0,cb:1,qb:2,pb:3,kb:4,ob:5,rb:6,Ga:7,TIMEOUT:8,ub:9},ct={ib:`complete`,Fb:`success`,ERROR:`error`,Ga:`abort`,xb:`ready`,yb:`readystatechange`,TIMEOUT:`timeout`,sb:`incrementaldata`,wb:`progress`,lb:`downloadprogress`,Nb:`uploadprogress`},lt;function ut(){}d(ut,qe),ut.prototype.g=function(){return new XMLHttpRequest},lt=new ut;function dt(e){return encodeURIComponent(String(e))}function ft(e){var t=1;e=e.split(`:`);let n=[];for(;t>0&&e.length;)n.push(e.shift()),t--;return e.length&&n.push(e.join(`:`)),n}function pt(e,t,n,r){this.j=e,this.i=t,this.l=n,this.S=r||1,this.V=new k(this),this.H=45e3,this.J=null,this.o=!1,this.u=this.B=this.A=this.M=this.F=this.T=this.D=null,this.G=[],this.g=null,this.C=0,this.m=this.v=null,this.X=-1,this.K=!1,this.P=0,this.O=null,this.W=this.L=this.U=this.R=!1,this.h=new mt}function mt(){this.i=null,this.g=``,this.h=!1}var ht={},gt={};function _t(e,t,n){e.M=1,e.A=Lt(Nt(t)),e.u=n,e.R=!0,vt(e,null)}function vt(e,t){e.F=Date.now(),xt(e),e.B=Nt(e.A);var n=e.B,r=e.S;Array.isArray(r)||(r=[String(r)]),Zt(n.i,`t`,r),e.C=0,n=e.j.L,e.h=new mt,e.g=Bn(e.j,n?t:null,!e.u),e.P>0&&(e.O=new He(l(e.Y,e,e.g),e.P)),t=e.V,n=e.g,r=e.ba;var i=`readystatechange`;Array.isArray(i)||(i&&(A[0]=i.toString()),i=A);for(let e=0;e<i.length;e++){let a=Ae(n,i[e],r||t.handleEvent,!1,t.h||t);if(!a)break;t.g[a.key]=a}t=e.J?x(e.J):{},e.u?(e.v||=`POST`,t[`Content-Type`]=`application/x-www-form-urlencoded`,e.g.ea(e.B,e.v,e.u,t)):(e.v=`GET`,e.g.ea(e.B,e.v,null,t)),$e(),it(e.i,e.v,e.B,e.l,e.S,e.u)}pt.prototype.ba=function(e){e=e.target;let t=this.O;t&&_n(e)==3?t.j():this.Y(e)},pt.prototype.Y=function(e){try{if(e==this.g)a:{let s=_n(this.g),c=this.g.ya(),l=this.g.ca();if(!(s<3)&&(s!=3||this.g&&(this.h.h||this.g.la()||vn(this.g)))){this.K||s!=4||c==7||$e(c==8||l<=0?3:2),St(this);var t=this.g.ca();this.X=t;var n=yt(this);if(this.o=t==200,at(this.i,this.v,this.B,this.l,this.S,s,t),this.o){if(this.U&&!this.L){b:{if(this.g){var r,i=this.g;if((r=i.g?i.g.getResponseHeader(`X-HTTP-Initial-Response`):null)&&!be(r)){var a=r;break b}}a=null}if(e=a)F(this.i,this.l,e,`Initial handshake response via X-HTTP-Initial-Response`),this.L=!0,B(this,e);else{this.o=!1,this.m=3,P(12),Ct(this),z(this);break a}}if(this.R){e=!0;let t;for(;!this.K&&this.C<n.length;)if(t=bt(this,n),t==gt){s==4&&(this.m=4,P(14),e=!1),F(this.i,this.l,null,`[Incomplete Response]`);break}else if(t==ht){this.m=4,P(15),F(this.i,this.l,n,`[Invalid Chunk]`),e=!1;break}else F(this.i,this.l,t,null),B(this,t);if(L(this)&&this.C!=0&&(this.h.g=this.h.g.slice(this.C),this.C=0),s!=4||n.length!=0||this.h.h||(this.m=1,P(16),e=!1),this.o=this.o&&e,!e)F(this.i,this.l,n,`[Invalid Chunked Response]`),Ct(this),z(this);else if(n.length>0&&!this.W){this.W=!0;var o=this.j;o.g==this&&o.aa&&!o.P&&(o.j.info(`Great, no buffering proxy detected. Bytes received: `+n.length),Mn(o),o.P=!0,P(11))}}else F(this.i,this.l,n,null),B(this,n);s==4&&Ct(this),this.o&&!this.K&&(s==4?Fn(this.j,this):(this.o=!1,xt(this)))}else yn(this.g),t==400&&n.indexOf(`Unknown SID`)>0?(this.m=3,P(12)):(this.m=0,P(13)),Ct(this),z(this)}}}catch{}};function yt(e){if(!L(e))return e.g.la();let t=vn(e.g);if(t===``)return``;let n=``,r=t.length,i=_n(e.g)==4;if(!e.h.i){if(typeof TextDecoder>`u`)return Ct(e),z(e),``;e.h.i=new o.TextDecoder}for(let a=0;a<r;a++)e.h.h=!0,n+=e.h.i.decode(t[a],{stream:!(i&&a==r-1)});return t.length=0,e.h.g+=n,e.C=0,e.h.g}function L(e){return e.g?e.v==`GET`&&e.M!=2&&e.j.Aa:!1}function bt(e,t){var n=e.C,r=t.indexOf(`
`,n);return r==-1?gt:(n=Number(t.substring(n,r)),isNaN(n)?ht:(r+=1,r+n>t.length?gt:(t=t.slice(r,r+n),e.C=r+n,t)))}pt.prototype.cancel=function(){this.K=!0,Ct(this)};function xt(e){e.T=Date.now()+e.H,R(e,e.H)}function R(e,t){if(e.D!=null)throw Error(`WatchDog timer not null`);e.D=nt(l(e.aa,e),t)}function St(e){e.D&&=(o.clearTimeout(e.D),null)}pt.prototype.aa=function(){this.D=null;let e=Date.now();e-this.T>=0?(I(this.i,this.B),this.M!=2&&($e(),P(17)),Ct(this),this.m=2,z(this)):R(this,this.T-e)};function z(e){e.j.I==0||e.K||Fn(e.j,e)}function Ct(e){St(e);var t=e.O;t&&typeof t.dispose==`function`&&t.dispose(),e.O=null,Ue(e.V),e.g&&(t=e.g,e.g=null,t.abort(),t.dispose())}function B(e,t){try{var n=e.j;if(n.I!=0&&(n.g==e||Dt(n.h,e))){if(!e.L&&Dt(n.h,e)&&n.I==3){try{var r=n.Ba.g.parse(t)}catch{r=null}if(Array.isArray(r)&&r.length==3){var i=r;if(i[0]==0){a:if(!n.v){if(n.g)if(n.g.F+3e3<e.F)Pn(n),Cn(n);else break a;jn(n),P(18)}}else n.xa=i[1],0<n.xa-n.K&&i[2]<37500&&n.F&&n.A==0&&!n.C&&(n.C=nt(l(n.Va,n),6e3));Et(n.h)<=1&&n.ta&&(n.ta=void 0)}else Ln(n,11)}else if((e.L||n.g==e)&&Pn(n),!be(t))for(i=n.Ba.g.parse(t),t=0;t<i.length;t++){let l=i[t],u=l[0];if(!(u<=n.K))if(n.K=u,l=l[1],n.I==2)if(l[0]==`c`){n.M=l[1],n.ba=l[2];let t=l[3];t!=null&&(n.ka=t,n.j.info(`VER=`+n.ka));let i=l[4];i!=null&&(n.za=i,n.j.info(`SVER=`+n.za));let u=l[5];u!=null&&typeof u==`number`&&u>0&&(r=1.5*u,n.O=r,n.j.info(`backChannelRequestTimeoutMs_=`+r)),r=n;let d=e.g;if(d){let e=d.g?d.g.getResponseHeader(`X-Client-Wire-Protocol`):null;if(e){var a=r.h;a.g||e.indexOf(`spdy`)==-1&&e.indexOf(`quic`)==-1&&e.indexOf(`h2`)==-1||(a.j=a.l,a.g=new Set,a.h&&=(Ot(a,a.h),null))}if(r.G){let e=d.g?d.g.getResponseHeader(`X-HTTP-Session-Id`):null;e&&(r.wa=e,U(r.J,r.G,e))}}n.I=3,n.l&&n.l.ra(),n.aa&&(n.T=Date.now()-e.F,n.j.info(`Handshake RTT: `+n.T+`ms`)),r=n;var o=e;if(r.na=zn(r,r.L?r.ba:null,r.W),o.L){kt(r.h,o);var s=o,c=r.O;c&&(s.H=c),s.D&&(St(s),xt(s)),r.g=o}else An(r);n.i.length>0&&Tn(n)}else l[0]!=`stop`&&l[0]!=`close`||Ln(n,7);else n.I==3&&(l[0]==`stop`||l[0]==`close`?l[0]==`stop`?Ln(n,7):Sn(n):l[0]!=`noop`&&n.l&&n.l.qa(l),n.A=0)}}$e(4)}catch{}}var wt=class{constructor(e,t){this.g=e,this.map=t}};function Tt(e){this.l=e||10,o.PerformanceNavigationTiming?(e=o.performance.getEntriesByType(`navigation`),e=e.length>0&&(e[0].nextHopProtocol==`hq`||e[0].nextHopProtocol==`h2`)):e=!!(o.chrome&&o.chrome.loadTimes&&o.chrome.loadTimes()&&o.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,this.j>1&&(this.g=new Set),this.h=null,this.i=[]}function V(e){return e.h?!0:e.g?e.g.size>=e.j:!1}function Et(e){return e.h?1:e.g?e.g.size:0}function Dt(e,t){return e.h?e.h==t:e.g?e.g.has(t):!1}function Ot(e,t){e.g?e.g.add(t):e.h=t}function kt(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}Tt.prototype.cancel=function(){if(this.i=At(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&this.g.size!==0){for(let e of this.g.values())e.cancel();this.g.clear()}};function At(e){if(e.h!=null)return e.i.concat(e.h.G);if(e.g!=null&&e.g.size!==0){let t=e.i;for(let n of e.g.values())t=t.concat(n.G);return t}return p(e.i)}var jt=RegExp(`^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$`);function Mt(e,t){if(e){e=e.split(`&`);for(let n=0;n<e.length;n++){let r=e[n].indexOf(`=`),i,a=null;r>=0?(i=e[n].substring(0,r),a=e[n].substring(r+1)):i=e[n],t(i,a?decodeURIComponent(a.replace(/\+/g,` `)):``)}}}function H(e){this.g=this.o=this.j=``,this.u=null,this.m=this.h=``,this.l=!1;let t;e instanceof H?(this.l=e.l,Pt(this,e.j),this.o=e.o,this.g=e.g,Ft(this,e.u),this.h=e.h,It(this,Qt(e.i)),this.m=e.m):e&&(t=String(e).match(jt))?(this.l=!1,Pt(this,t[1]||``,!0),this.o=Rt(t[2]||``),this.g=Rt(t[3]||``,!0),Ft(this,t[4]),this.h=Rt(t[5]||``,!0),It(this,t[6]||``,!0),this.m=Rt(t[7]||``)):(this.l=!1,this.i=new Kt(null,this.l))}H.prototype.toString=function(){let e=[];var t=this.j;t&&e.push(zt(t,Vt,!0),`:`);var n=this.g;return(n||t==`file`)&&(e.push(`//`),(t=this.o)&&e.push(zt(t,Vt,!0),`@`),e.push(dt(n).replace(/%25([0-9a-fA-F]{2})/g,`%$1`)),n=this.u,n!=null&&e.push(`:`,String(n))),(n=this.h)&&(this.g&&n.charAt(0)!=`/`&&e.push(`/`),e.push(zt(n,n.charAt(0)==`/`?Ut:Ht,!0))),(n=this.i.toString())&&e.push(`?`,n),(n=this.m)&&e.push(`#`,zt(n,Gt)),e.join(``)},H.prototype.resolve=function(e){let t=Nt(this),n=!!e.j;n?Pt(t,e.j):n=!!e.o,n?t.o=e.o:n=!!e.g,n?t.g=e.g:n=e.u!=null;var r=e.h;if(n)Ft(t,e.u);else if(n=!!e.h){if(r.charAt(0)!=`/`)if(this.g&&!this.h)r=`/`+r;else{var i=t.h.lastIndexOf(`/`);i!=-1&&(r=t.h.slice(0,i+1)+r)}if(i=r,i==`..`||i==`.`)r=``;else if(i.indexOf(`./`)!=-1||i.indexOf(`/.`)!=-1){r=i.lastIndexOf(`/`,0)==0,i=i.split(`/`);let e=[];for(let t=0;t<i.length;){let n=i[t++];n==`.`?r&&t==i.length&&e.push(``):n==`..`?((e.length>1||e.length==1&&e[0]!=``)&&e.pop(),r&&t==i.length&&e.push(``)):(e.push(n),r=!0)}r=e.join(`/`)}else r=i}return n?t.h=r:n=e.i.toString()!==``,n?It(t,Qt(e.i)):n=!!e.m,n&&(t.m=e.m),t};function Nt(e){return new H(e)}function Pt(e,t,n){e.j=n?Rt(t,!0):t,e.j&&=e.j.replace(/:$/,``)}function Ft(e,t){if(t){if(t=Number(t),isNaN(t)||t<0)throw Error(`Bad port number `+t);e.u=t}else e.u=null}function It(e,t,n){t instanceof Kt?(e.i=t,en(e.i,e.l)):(n||(t=zt(t,Wt)),e.i=new Kt(t,e.l))}function U(e,t,n){e.i.set(t,n)}function Lt(e){return U(e,`zx`,Math.floor(Math.random()*2147483648).toString(36)+Math.abs(Math.floor(Math.random()*2147483648)^Date.now()).toString(36)),e}function Rt(e,t){return e?t?decodeURI(e.replace(/%25/g,`%2525`)):decodeURIComponent(e):``}function zt(e,t,n){return typeof e==`string`?(e=encodeURI(e).replace(t,Bt),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,`%$1`)),e):null}function Bt(e){return e=e.charCodeAt(0),`%`+(e>>4&15).toString(16)+(e&15).toString(16)}var Vt=/[#\/\?@]/g,Ht=/[#\?:]/g,Ut=/[#\?]/g,Wt=/[#\?@]/g,Gt=/#/g;function Kt(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function qt(e){e.g||(e.g=new Map,e.h=0,e.i&&Mt(e.i,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g,` `)),n)}))}e=Kt.prototype,e.add=function(e,t){qt(this),this.i=null,e=$t(this,e);let n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this};function Jt(e,t){qt(e),t=$t(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function Yt(e,t){return qt(e),t=$t(e,t),e.g.has(t)}e.forEach=function(e,t){qt(this),this.g.forEach(function(n,r){n.forEach(function(n){e.call(t,n,r,this)},this)},this)};function Xt(e,t){qt(e);let n=[];if(typeof t==`string`)Yt(e,t)&&(n=n.concat(e.g.get($t(e,t))));else for(e=Array.from(e.g.values()),t=0;t<e.length;t++)n=n.concat(e[t]);return n}e.set=function(e,t){return qt(this),this.i=null,e=$t(this,e),Yt(this,e)&&(this.h-=this.g.get(e).length),this.g.set(e,[t]),this.h+=1,this},e.get=function(e,t){return e?(e=Xt(this,e),e.length>0?String(e[0]):t):t};function Zt(e,t,n){Jt(e,t),n.length>0&&(e.i=null,e.g.set($t(e,t),p(n)),e.h+=n.length)}e.toString=function(){if(this.i)return this.i;if(!this.g)return``;let e=[],t=Array.from(this.g.keys());for(let r=0;r<t.length;r++){var n=t[r];let i=dt(n);n=Xt(this,n);for(let t=0;t<n.length;t++){let r=i;n[t]!==``&&(r+=`=`+dt(n[t])),e.push(r)}}return this.i=e.join(`&`)};function Qt(e){let t=new Kt;return t.i=e.i,e.g&&(t.g=new Map(e.g),t.h=e.h),t}function $t(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function en(e,t){t&&!e.j&&(qt(e),e.i=null,e.g.forEach(function(e,t){let n=t.toLowerCase();t!=n&&(Jt(this,t),Zt(this,n,e))},e)),e.j=t}function tn(e,t){let n=new rt;if(o.Image){let r=new Image;r.onload=u(rn,n,`TestLoadImage: loaded`,!0,t,r),r.onerror=u(rn,n,`TestLoadImage: error`,!1,t,r),r.onabort=u(rn,n,`TestLoadImage: abort`,!1,t,r),r.ontimeout=u(rn,n,`TestLoadImage: timeout`,!1,t,r),o.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}function nn(e,t){let n=new rt,r=new AbortController,i=setTimeout(()=>{r.abort(),rn(n,`TestPingServer: timeout`,!1,t)},1e4);fetch(e,{signal:r.signal}).then(e=>{clearTimeout(i),e.ok?rn(n,`TestPingServer: ok`,!0,t):rn(n,`TestPingServer: server error`,!1,t)}).catch(()=>{clearTimeout(i),rn(n,`TestPingServer: error`,!1,t)})}function rn(e,t,n,r,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),r(n)}catch{}}function an(){this.g=new Ke}function on(e){this.i=e.Sb||null,this.h=e.ab||!1}d(on,qe),on.prototype.g=function(){return new W(this.i,this.h)};function W(e,t){E.call(this),this.H=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.A=new Headers,this.h=null,this.F=`GET`,this.D=``,this.g=!1,this.B=this.j=this.l=null,this.v=new AbortController}d(W,E),e=W.prototype,e.open=function(e,t){if(this.readyState!=0)throw this.abort(),Error(`Error reopening a connection`);this.F=e,this.D=t,this.readyState=1,ln(this)},e.send=function(e){if(this.readyState!=1)throw this.abort(),Error(`need to call open() first. `);if(this.v.signal.aborted)throw this.abort(),Error(`Request was aborted.`);this.g=!0;let t={headers:this.A,method:this.F,credentials:this.m,cache:void 0,signal:this.v.signal};e&&(t.body=e),(this.H||o).fetch(new Request(this.D,t)).then(this.Pa.bind(this),this.ga.bind(this))},e.abort=function(){this.response=this.responseText=``,this.A=new Headers,this.status=0,this.v.abort(),this.j&&this.j.cancel(`Request was aborted.`).catch(()=>{}),this.readyState>=1&&this.g&&this.readyState!=4&&(this.g=!1,cn(this)),this.readyState=0},e.Pa=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,ln(this)),this.g&&(this.readyState=3,ln(this),this.g)))if(this.responseType===`arraybuffer`)e.arrayBuffer().then(this.Na.bind(this),this.ga.bind(this));else if(o.ReadableStream!==void 0&&`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.B=new TextDecoder;sn(this)}else e.text().then(this.Oa.bind(this),this.ga.bind(this))};function sn(e){e.j.read().then(e.Ma.bind(e)).catch(e.ga.bind(e))}e.Ma=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;(t=this.B.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?cn(this):ln(this),this.readyState==3&&sn(this)}},e.Oa=function(e){this.g&&(this.response=this.responseText=e,cn(this))},e.Na=function(e){this.g&&(this.response=e,cn(this))},e.ga=function(){this.g&&cn(this)};function cn(e){e.readyState=4,e.l=null,e.j=null,e.B=null,ln(e)}e.setRequestHeader=function(e,t){this.A.append(e,t)},e.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||``},e.getAllResponseHeaders=function(){if(!this.h)return``;let e=[],t=this.h.entries();for(var n=t.next();!n.done;)n=n.value,e.push(n[0]+`: `+n[1]),n=t.next();return e.join(`\r
`)};function ln(e){e.onreadystatechange&&e.onreadystatechange.call(e)}Object.defineProperty(W.prototype,`withCredentials`,{get:function(){return this.m===`include`},set:function(e){this.m=e?`include`:`same-origin`}});function un(e){let t=``;return b(e,function(e,n){t+=n,t+=`:`,t+=e,t+=`\r
`}),t}function dn(e,t,n){a:{for(r in n){var r=!1;break a}r=!0}r||(n=un(n),typeof e==`string`||U(e,t,n))}function G(e){E.call(this),this.headers=new Map,this.L=e||null,this.h=!1,this.g=null,this.D=``,this.o=0,this.l=``,this.j=this.B=this.v=this.A=!1,this.m=null,this.F=``,this.H=!1}d(G,E);var K=/^https?$/i,fn=[`POST`,`PUT`];e=G.prototype,e.Fa=function(e){this.H=e},e.ea=function(e,t,n,r){if(this.g)throw Error(`[goog.net.XhrIo] Object is active with another request=`+this.D+`; newUri=`+e);t=t?t.toUpperCase():`GET`,this.D=e,this.l=``,this.o=0,this.A=!1,this.h=!0,this.g=this.L?this.L.g():lt.g(),this.g.onreadystatechange=f(l(this.Ca,this));try{this.B=!0,this.g.open(t,String(e),!0),this.B=!1}catch(e){pn(this,e);return}if(e=n||``,n=new Map(this.headers),r)if(Object.getPrototypeOf(r)===Object.prototype)for(var i in r)n.set(i,r[i]);else if(typeof r.keys==`function`&&typeof r.get==`function`)for(let e of r.keys())n.set(e,r.get(e));else throw Error(`Unknown input type for opt_headers: `+String(r));r=Array.from(n.keys()).find(e=>e.toLowerCase()==`content-type`),i=o.FormData&&e instanceof o.FormData,!(Array.prototype.indexOf.call(fn,t,void 0)>=0)||r||i||n.set(`Content-Type`,`application/x-www-form-urlencoded;charset=utf-8`);for(let[e,t]of n)this.g.setRequestHeader(e,t);this.F&&(this.g.responseType=this.F),`withCredentials`in this.g&&this.g.withCredentials!==this.H&&(this.g.withCredentials=this.H);try{this.m&&=(clearTimeout(this.m),null),this.v=!0,this.g.send(e),this.v=!1}catch(e){pn(this,e)}};function pn(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.o=5,mn(e),gn(e)}function mn(e){e.A||(e.A=!0,D(e,`complete`),D(e,`error`))}e.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.o=e||7,D(this,`complete`),D(this,`abort`),gn(this))},e.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),gn(this,!0)),G.Z.N.call(this)},e.Ca=function(){this.u||(this.B||this.v||this.j?hn(this):this.Xa())},e.Xa=function(){hn(this)};function hn(e){if(e.h&&a!==void 0){if(e.v&&_n(e)==4)setTimeout(e.Ca.bind(e),0);else if(D(e,`readystatechange`),_n(e)==4){e.h=!1;try{let a=e.ca();a:switch(a){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var t=!0;break a;default:t=!1}var n;if(!(n=t)){var r;if(r=a===0){let t=String(e.D).match(jt)[1]||null;!t&&o.self&&o.self.location&&(t=o.self.location.protocol.slice(0,-1)),r=!K.test(t?t.toLowerCase():``)}n=r}if(n)D(e,`complete`),D(e,`success`);else{e.o=6;try{var i=_n(e)>2?e.g.statusText:``}catch{i=``}e.l=i+` [`+e.ca()+`]`,mn(e)}}finally{gn(e)}}}}function gn(e,t){if(e.g){e.m&&=(clearTimeout(e.m),null);let n=e.g;e.g=null,t||D(e,`ready`);try{n.onreadystatechange=null}catch{}}}e.isActive=function(){return!!this.g};function _n(e){return e.g?e.g.readyState:0}e.ca=function(){try{return _n(this)>2?this.g.status:-1}catch{return-1}},e.la=function(){try{return this.g?this.g.responseText:``}catch{return``}},e.La=function(e){if(this.g){var t=this.g.responseText;return e&&t.indexOf(e)==0&&(t=t.substring(e.length)),Ge(t)}};function vn(e){try{if(!e.g)return null;if(`response`in e.g)return e.g.response;switch(e.F){case``:case`text`:return e.g.responseText;case`arraybuffer`:if(`mozResponseArrayBuffer`in e.g)return e.g.mozResponseArrayBuffer}return null}catch{return null}}function yn(e){let t={};e=(e.g&&_n(e)>=2&&e.g.getAllResponseHeaders()||``).split(`\r
`);for(let r=0;r<e.length;r++){if(be(e[r]))continue;var n=ft(e[r]);let i=n[0];if(n=n[1],typeof n!=`string`)continue;n=n.trim();let a=t[i]||[];t[i]=a,a.push(n)}Te(t,function(e){return e.join(`, `)})}e.ya=function(){return this.o},e.Ha=function(){return typeof this.l==`string`?this.l:String(this.l)};function bn(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function xn(e){this.za=0,this.i=[],this.j=new rt,this.ba=this.na=this.J=this.W=this.g=this.wa=this.G=this.H=this.u=this.U=this.o=null,this.Ya=this.V=0,this.Sa=bn(`failFast`,!1,e),this.F=this.C=this.v=this.m=this.l=null,this.X=!0,this.xa=this.K=-1,this.Y=this.A=this.D=0,this.Qa=bn(`baseRetryDelayMs`,5e3,e),this.Za=bn(`retryDelaySeedMs`,1e4,e),this.Ta=bn(`forwardChannelMaxRetries`,2,e),this.va=bn(`forwardChannelRequestTimeoutMs`,2e4,e),this.ma=e&&e.xmlHttpFactory||void 0,this.Ua=e&&e.Rb||void 0,this.Aa=e&&e.useFetchStreams||!1,this.O=void 0,this.L=e&&e.supportsCrossDomainXhr||!1,this.M=``,this.h=new Tt(e&&e.concurrentRequestLimit),this.Ba=new an,this.S=e&&e.fastHandshake||!1,this.R=e&&e.encodeInitMessageHeaders||!1,this.S&&this.R&&(this.R=!1),this.Ra=e&&e.Pb||!1,e&&e.ua&&this.j.ua(),e&&e.forceLongPolling&&(this.X=!1),this.aa=!this.S&&this.X&&e&&e.detectBufferingProxy||!1,this.ia=void 0,e&&e.longPollingTimeout&&e.longPollingTimeout>0&&(this.ia=e.longPollingTimeout),this.ta=void 0,this.T=0,this.P=!1,this.ja=this.B=null}e=xn.prototype,e.ka=8,e.I=1,e.connect=function(e,t,n,r){P(0),this.W=e,this.H=t||{},n&&r!==void 0&&(this.H.OSID=n,this.H.OAID=r),this.F=this.X,this.J=zn(this,null,this.W),Tn(this)};function Sn(e){if(wn(e),e.I==3){var t=e.V++,n=Nt(e.J);if(U(n,`SID`,e.M),U(n,`RID`,t),U(n,`TYPE`,`terminate`),On(e,n),t=new pt(e,e.j,t),t.M=2,t.A=Lt(Nt(n)),n=!1,o.navigator&&o.navigator.sendBeacon)try{n=o.navigator.sendBeacon(t.A.toString(),``)}catch{}!n&&o.Image&&(new Image().src=t.A,n=!0),n||(t.g=Bn(t.j,null),t.g.ea(t.A)),t.F=Date.now(),xt(t)}Rn(e)}function Cn(e){e.g&&=(Mn(e),e.g.cancel(),null)}function wn(e){Cn(e),e.v&&=(o.clearTimeout(e.v),null),Pn(e),e.h.cancel(),e.m&&=(typeof e.m==`number`&&o.clearTimeout(e.m),null)}function Tn(e){if(!V(e.h)&&!e.m){e.m=!0;var t=e.Ea;re||oe(),ie||=(re(),!0),ae.add(t,e),e.D=0}}function En(e,t){return Et(e.h)>=e.h.j-(e.m?1:0)?!1:e.m?(e.i=t.G.concat(e.i),!0):e.I==1||e.I==2||e.D>=(e.Sa?0:e.Ta)?!1:(e.m=nt(l(e.Ea,e,t),In(e,e.D)),e.D++,!0)}e.Ea=function(e){if(this.m)if(this.m=null,this.I==1){if(!e){this.V=Math.floor(Math.random()*1e5),e=this.V++;let i=new pt(this,this.j,e),a=this.o;if(this.U&&(a?(a=x(a),C(a,this.U)):a=this.U),this.u!==null||this.R||(i.J=a,a=null),this.S)a:{for(var t=0,n=0;n<this.i.length;n++){b:{var r=this.i[n];if(`__data__`in r.map&&(r=r.map.__data__,typeof r==`string`)){r=r.length;break b}r=void 0}if(r===void 0)break;if(t+=r,t>4096){t=n;break a}if(t===4096||n===this.i.length-1){t=n+1;break a}}t=1e3}else t=1e3;t=kn(this,i,t),n=Nt(this.J),U(n,`RID`,e),U(n,`CVER`,22),this.G&&U(n,`X-HTTP-Session-Id`,this.G),On(this,n),a&&(this.R?t=`headers=`+dt(un(a))+`&`+t:this.u&&dn(n,this.u,a)),Ot(this.h,i),this.Ra&&U(n,`TYPE`,`init`),this.S?(U(n,`$req`,t),U(n,`SID`,`null`),i.U=!0,_t(i,n,null)):_t(i,n,t),this.I=2}}else this.I==3&&(e?Dn(this,e):this.i.length==0||V(this.h)||Dn(this))};function Dn(e,t){var n=t?t.l:e.V++;let r=Nt(e.J);U(r,`SID`,e.M),U(r,`RID`,n),U(r,`AID`,e.K),On(e,r),e.u&&e.o&&dn(r,e.u,e.o),n=new pt(e,e.j,n,e.D+1),e.u===null&&(n.J=e.o),t&&(e.i=t.G.concat(e.i)),t=kn(e,n,1e3),n.H=Math.round(e.va*.5)+Math.round(e.va*.5*Math.random()),Ot(e.h,n),_t(n,r,t)}function On(e,t){e.H&&b(e.H,function(e,n){U(t,n,e)}),e.l&&b({},function(e,n){U(t,n,e)})}function kn(e,t,n){n=Math.min(e.i.length,n);let r=e.l?l(e.l.Ka,e.l,e):null;a:{var i=e.i;let t=-1;for(;;){let e=[`count=`+n];t==-1?n>0?(t=i[0].g,e.push(`ofs=`+t)):t=0:e.push(`ofs=`+t);let c=!0;for(let l=0;l<n;l++){var a=i[l].g;let n=i[l].map;if(a-=t,a<0)t=Math.max(0,i[l].g-100),c=!1;else try{a=`req`+a+`_`||``;try{var o=n instanceof Map?n:Object.entries(n);for(let[t,n]of o){let r=n;s(n)&&(r=We(n)),e.push(a+t+`=`+encodeURIComponent(r))}}catch(t){throw e.push(a+`type=_badmap`),t}}catch{r&&r(n)}}if(c){o=e.join(`&`);break a}}o=void 0}return e=e.i.splice(0,n),t.G=e,o}function An(e){if(!e.g&&!e.v){e.Y=1;var t=e.Da;re||oe(),ie||=(re(),!0),ae.add(t,e),e.A=0}}function jn(e){return e.g||e.v||e.A>=3?!1:(e.Y++,e.v=nt(l(e.Da,e),In(e,e.A)),e.A++,!0)}e.Da=function(){if(this.v=null,Nn(this),this.aa&&!(this.P||this.g==null||this.T<=0)){var e=4*this.T;this.j.info(`BP detection timer enabled: `+e),this.B=nt(l(this.Wa,this),e)}},e.Wa=function(){this.B&&(this.B=null,this.j.info(`BP detection timeout reached.`),this.j.info(`Buffering proxy detected and switch to long-polling!`),this.F=!1,this.P=!0,P(10),Cn(this),Nn(this))};function Mn(e){e.B!=null&&(o.clearTimeout(e.B),e.B=null)}function Nn(e){e.g=new pt(e,e.j,`rpc`,e.Y),e.u===null&&(e.g.J=e.o),e.g.P=0;var t=Nt(e.na);U(t,`RID`,`rpc`),U(t,`SID`,e.M),U(t,`AID`,e.K),U(t,`CI`,e.F?`0`:`1`),!e.F&&e.ia&&U(t,`TO`,e.ia),U(t,`TYPE`,`xmlhttp`),On(e,t),e.u&&e.o&&dn(t,e.u,e.o),e.O&&(e.g.H=e.O);var n=e.g;e=e.ba,n.M=1,n.A=Lt(Nt(t)),n.u=null,n.R=!0,vt(n,e)}e.Va=function(){this.C!=null&&(this.C=null,Cn(this),jn(this),P(19))};function Pn(e){e.C!=null&&(o.clearTimeout(e.C),e.C=null)}function Fn(e,t){var n=null;if(e.g==t){Pn(e),Mn(e),e.g=null;var r=2}else if(Dt(e.h,t))n=t.G,kt(e.h,t),r=1;else return;if(e.I!=0){if(t.o)if(r==1){n=t.u?t.u.length:0,t=Date.now()-t.F;var i=e.D;r=M(),D(r,new tt(r,n)),Tn(e)}else An(e);else if(i=t.m,i==3||i==0&&t.X>0||!(r==1&&En(e,t)||r==2&&jn(e)))switch(n&&n.length>0&&(t=e.h,t.i=t.i.concat(n)),i){case 1:Ln(e,5);break;case 4:Ln(e,10);break;case 3:Ln(e,6);break;default:Ln(e,2)}}}function In(e,t){let n=e.Qa+Math.floor(Math.random()*e.Za);return e.isActive()||(n*=2),n*t}function Ln(e,t){if(e.j.info(`Error code `+t),t==2){var n=l(e.bb,e),r=e.Ua;let t=!r;r=new H(r||`//www.google.com/images/cleardot.gif`),o.location&&o.location.protocol==`http`||Pt(r,`https`),Lt(r),t?tn(r.toString(),n):nn(r.toString(),n)}else P(2);e.I=0,e.l&&e.l.pa(t),Rn(e),wn(e)}e.bb=function(e){e?(this.j.info(`Successfully pinged google.com`),P(2)):(this.j.info(`Failed to ping google.com`),P(1))};function Rn(e){if(e.I=0,e.ja=[],e.l){let t=At(e.h);(t.length!=0||e.i.length!=0)&&(m(e.ja,t),m(e.ja,e.i),e.h.i.length=0,p(e.i),e.i.length=0),e.l.oa()}}function zn(e,t,n){var r=n instanceof H?Nt(n):new H(n);if(r.g!=``)t&&(r.g=t+`.`+r.g),Ft(r,r.u);else{var i=o.location;r=i.protocol,t=t?t+`.`+i.hostname:i.hostname,i=+i.port;let e=new H(null);r&&Pt(e,r),t&&(e.g=t),i&&Ft(e,i),n&&(e.h=n),r=e}return n=e.G,t=e.wa,n&&t&&U(r,n,t),U(r,`VER`,e.ka),On(e,r),r}function Bn(e,t,n){if(t&&!e.L)throw Error(`Can't create secondary domain capable XhrIo object.`);return t=e.Aa&&!e.ma?new G(new on({ab:n})):new G(e.ma),t.Fa(e.L),t}e.isActive=function(){return!!this.l&&this.l.isActive(this)};function Vn(){}e=Vn.prototype,e.ra=function(){},e.qa=function(){},e.pa=function(){},e.oa=function(){},e.isActive=function(){return!0},e.Ka=function(){};function Hn(){}Hn.prototype.g=function(e,t){return new q(e,t)};function q(e,t){E.call(this),this.g=new xn(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.sa&&(e?e[`X-WebChannel-Client-Profile`]=t.sa:e={"X-WebChannel-Client-Profile":t.sa}),this.g.U=e,(e=t&&t.Qb)&&!be(e)&&(this.g.u=e),this.A=t&&t.supportsCrossDomainXhr||!1,this.v=t&&t.sendRawJson||!1,(t&&=t.httpSessionIdParam)&&!be(t)&&(this.g.G=t,e=this.h,e!==null&&t in e&&(e=this.h,t in e&&delete e[t])),this.j=new Gn(this)}d(q,E),q.prototype.m=function(){this.g.l=this.j,this.A&&(this.g.L=!0),this.g.connect(this.l,this.h||void 0)},q.prototype.close=function(){Sn(this.g)},q.prototype.o=function(e){var t=this.g;if(typeof e==`string`){var n={};n.__data__=e,e=n}else this.v&&(n={},n.__data__=We(e),e=n);t.i.push(new wt(t.Ya++,e)),t.I==3&&Tn(t)},q.prototype.N=function(){this.g.l=null,delete this.j,Sn(this.g),delete this.g,q.Z.N.call(this)};function Un(e){j.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){a:{for(let n in t){e=n;break a}e=void 0}(this.i=e)&&(e=this.i,t=t!==null&&e in t?t[e]:void 0),this.data=t}else this.data=e}d(Un,j);function Wn(){Xe.call(this),this.status=1}d(Wn,Xe);function Gn(e){this.g=e}d(Gn,Vn),Gn.prototype.ra=function(){D(this.g,`a`)},Gn.prototype.qa=function(e){D(this.g,new Un(e))},Gn.prototype.pa=function(e){D(this.g,new Wn)},Gn.prototype.oa=function(){D(this.g,`b`)},Hn.prototype.createWebChannel=Hn.prototype.g,q.prototype.send=q.prototype.o,q.prototype.open=q.prototype.m,q.prototype.close=q.prototype.close,ge=ce.createWebChannelTransport=function(){return new Hn},he=ce.getStatEventTarget=function(){return M()},me=ce.Event=Ze,pe=ce.Stat={jb:0,mb:1,nb:2,Hb:3,Mb:4,Jb:5,Kb:6,Ib:7,Gb:8,Lb:9,PROXY:10,NOPROXY:11,Eb:12,Ab:13,Bb:14,zb:15,Cb:16,Db:17,fb:18,eb:19,gb:20},st.NO_ERROR=0,st.TIMEOUT=8,st.HTTP_ERROR=6,fe=ce.ErrorCode=st,ct.COMPLETE=`complete`,de=ce.EventType=ct,Je.EventType=Ye,Ye.OPEN=`a`,Ye.CLOSE=`b`,Ye.ERROR=`c`,Ye.MESSAGE=`d`,E.prototype.listen=E.prototype.J,ue=ce.WebChannel=Je,ce.FetchXmlHttpFactory=on,G.prototype.listenOnce=G.prototype.K,G.prototype.getLastError=G.prototype.Ha,G.prototype.getLastErrorCode=G.prototype.ya,G.prototype.getStatus=G.prototype.ca,G.prototype.getResponseJson=G.prototype.La,G.prototype.getResponseText=G.prototype.la,G.prototype.send=G.prototype.ea,G.prototype.setWithCredentials=G.prototype.Fa,le=ce.XhrIo=G}).apply(se===void 0?typeof self<`u`?self:typeof window<`u`?window:{}:se);var _e=`@firebase/firestore`,ve=`4.9.2`,v=class{constructor(e){this.uid=e}isAuthenticated(){return this.uid!=null}toKey(){return this.isAuthenticated()?`uid:`+this.uid:`anonymous-user`}isEqual(e){return e.uid===this.uid}};v.UNAUTHENTICATED=new v(null),v.GOOGLE_CREDENTIALS=new v(`google-credentials-uid`),v.FIRST_PARTY=new v(`first-party-uid`),v.MOCK_USER=new v(`mock-user`);
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var ye=`12.3.0`,be=new p(`@firebase/firestore`);function xe(){return be.logLevel}function y(e,...t){if(be.logLevel<=s.DEBUG){let n=t.map(we);be.debug(`Firestore (${ye}): ${e}`,...n)}}function Se(e,...t){if(be.logLevel<=s.ERROR){let n=t.map(we);be.error(`Firestore (${ye}): ${e}`,...n)}}function Ce(e,...t){if(be.logLevel<=s.WARN){let n=t.map(we);be.warn(`Firestore (${ye}): ${e}`,...n)}}function we(e){if(typeof e==`string`)return e;try{
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
return function(e){return JSON.stringify(e)}(e)}catch{return e}}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function b(e,t,n){let r=`Unexpected state`;typeof t==`string`?r=t:n=t,Te(e,r,n)}function Te(e,t,n){let r=`FIRESTORE (${ye}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(n!==void 0)try{r+=` CONTEXT: `+JSON.stringify(n)}catch{r+=` CONTEXT: `+n}throw Se(r),Error(r)}function x(e,t,n,r){let i=`Unexpected state`;typeof n==`string`?i=n:r=n,e||Te(t,i,r)}function S(e,t){return e}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var C={OK:`ok`,CANCELLED:`cancelled`,UNKNOWN:`unknown`,INVALID_ARGUMENT:`invalid-argument`,DEADLINE_EXCEEDED:`deadline-exceeded`,NOT_FOUND:`not-found`,ALREADY_EXISTS:`already-exists`,PERMISSION_DENIED:`permission-denied`,UNAUTHENTICATED:`unauthenticated`,RESOURCE_EXHAUSTED:`resource-exhausted`,FAILED_PRECONDITION:`failed-precondition`,ABORTED:`aborted`,OUT_OF_RANGE:`out-of-range`,UNIMPLEMENTED:`unimplemented`,INTERNAL:`internal`,UNAVAILABLE:`unavailable`,DATA_LOSS:`data-loss`},w=class extends l{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}},Ee=class{constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}},De=class{constructor(e,t){this.user=t,this.type=`OAuth`,this.headers=new Map,this.headers.set(`Authorization`,`Bearer ${e}`)}},Oe=class{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable((()=>t(v.UNAUTHENTICATED)))}shutdown(){}},ke=class{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}},Ae=class{constructor(e){this.t=e,this.currentUser=v.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){x(this.o===void 0,42304);let n=this.i,r=e=>this.i===n?Promise.resolve():(n=this.i,t(e)),i=new Ee;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new Ee,e.enqueueRetryable((()=>r(this.currentUser)))};let a=()=>{let t=i;e.enqueueRetryable((async()=>{await t.promise,await r(this.currentUser)}))},o=e=>{y(`FirebaseAuthCredentialsProvider`,`Auth detected`),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),a())};this.t.onInit((e=>o(e))),setTimeout((()=>{if(!this.auth){let e=this.t.getImmediate({optional:!0});e?o(e):(y(`FirebaseAuthCredentialsProvider`,`Auth not yet detected`),i.resolve(),i=new Ee)}}),0),a()}getToken(){let e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then((t=>this.i===e?t?(x(typeof t.accessToken==`string`,31837,{l:t}),new De(t.accessToken,this.currentUser)):null:(y(`FirebaseAuthCredentialsProvider`,`getToken aborted due to token change.`),this.getToken()))):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 x(e===null||typeof e==`string`,2055,{h:e}),new v(e)}},je=class{constructor(e,t,n){this.P=e,this.T=t,this.I=n,this.type=`FirstParty`,this.user=v.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}},Me=class{constructor(e,t,n){this.P=e,this.T=t,this.I=n}getToken(){return Promise.resolve(new je(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable((()=>t(v.FIRST_PARTY)))}shutdown(){}invalidateToken(){}},Ne=class{constructor(e){this.value=e,this.type=`AppCheck`,this.headers=new Map,e&&e.length>0&&this.headers.set(`x-firebase-appcheck`,this.value)}},Pe=class{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,m(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){x(this.o===void 0,3512);let n=e=>{e.error!=null&&y(`FirebaseAppCheckTokenProvider`,`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);let n=e.token!==this.m;return this.m=e.token,y(`FirebaseAppCheckTokenProvider`,`Received ${n?`new`:`existing`} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable((()=>n(t)))};let r=e=>{y(`FirebaseAppCheckTokenProvider`,`AppCheck detected`),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit((e=>r(e))),setTimeout((()=>{if(!this.appCheck){let e=this.V.getImmediate({optional:!0});e?r(e):y(`FirebaseAppCheckTokenProvider`,`AppCheck not yet detected`)}}),0)}getToken(){if(this.p)return Promise.resolve(new Ne(this.p));let e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then((e=>e?(x(typeof e.token==`string`,44558,{tokenResult:e}),this.m=e.token,new Ne(e.token)):null)):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}};
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function Fe(e){let t=typeof self<`u`&&(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&&typeof t.getRandomValues==`function`)t.getRandomValues(n);else for(let t=0;t<e;t++)n[t]=Math.floor(256*Math.random());return n}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Ie=class{static newId(){let e=``;for(;e.length<20;){let t=Fe(40);for(let n=0;n<t.length;++n)e.length<20&&t[n]<248&&(e+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789`.charAt(t[n]%62))}return e}};function T(e,t){return e<t?-1:e>t?1:0}function Le(e,t){let n=Math.min(e.length,t.length);for(let r=0;r<n;r++){let n=e.charAt(r),i=t.charAt(r);if(n!==i)return E(n)===E(i)?T(n,i):E(n)?1:-1}return T(e.length,t.length)}var Re=55296,ze=57343;function E(e){let t=e.charCodeAt(0);return t>=Re&&t<=ze}function D(e,t,n){return e.length===t.length&&e.every(((e,r)=>n(e,t[r])))}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Be=`__name__`,Ve=class e{constructor(e,t,n){t===void 0?t=0:t>e.length&&b(637,{offset:t,range:e.length}),n===void 0?n=e.length-t:n>e.length-t&&b(1746,{length:n,range:e.length-t}),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(t){return e.comparator(this,t)===0}child(t){let n=this.segments.slice(this.offset,this.limit());return t instanceof e?t.forEach((e=>{n.push(e)})):n.push(t),this.construct(n)}limit(){return this.offset+this.length}popFirst(e){return e=e===void 0?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 this.length===0}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,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(t,n){let r=Math.min(t.length,n.length);for(let i=0;i<r;i++){let r=e.compareSegments(t.get(i),n.get(i));if(r!==0)return r}return T(t.length,n.length)}static compareSegments(t,n){let r=e.isNumericId(t),i=e.isNumericId(n);return r&&!i?-1:!r&&i?1:r&&i?e.extractNumericId(t).compare(e.extractNumericId(n)):Le(t,n)}static isNumericId(e){return e.startsWith(`__id`)&&e.endsWith(`__`)}static extractNumericId(e){return ae.fromString(e.substring(4,e.length-2))}},O=class e extends Ve{construct(t,n,r){return new e(t,n,r)}canonicalString(){return this.toArray().join(`/`)}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join(`/`)}static fromString(...t){let n=[];for(let e of t){if(e.indexOf(`//`)>=0)throw new w(C.INVALID_ARGUMENT,`Invalid segment (${e}). Paths must not contain // in them.`);n.push(...e.split(`/`).filter((e=>e.length>0)))}return new e(n)}static emptyPath(){return new e([])}},He=/^[_a-zA-Z][_a-zA-Z0-9]*$/,k=class e extends Ve{construct(t,n,r){return new e(t,n,r)}static isValidIdentifier(e){return He.test(e)}canonicalString(){return this.toArray().map((t=>(t=t.replace(/\\/g,`\\\\`).replace(/`/g,"\\`"),e.isValidIdentifier(t)||(t="`"+t+"`"),t))).join(`.`)}toString(){return this.canonicalString()}isKeyField(){return this.length===1&&this.get(0)===Be}static keyField(){return new e([Be])}static fromServerFormat(t){let n=[],r=``,i=0,a=()=>{if(r.length===0)throw new w(C.INVALID_ARGUMENT,`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);n.push(r),r=``},o=!1;for(;i<t.length;){let e=t[i];if(e===`\\`){if(i+1===t.length)throw new w(C.INVALID_ARGUMENT,`Path has trailing escape character: `+t);let e=t[i+1];if(e!==`\\`&&e!==`.`&&e!=="`")throw new w(C.INVALID_ARGUMENT,`Path has invalid escape sequence: `+t);r+=e,i+=2}else e==="`"?(o=!o,i++):e!==`.`||o?(r+=e,i++):(a(),i++)}if(a(),o)throw new w(C.INVALID_ARGUMENT,"Unterminated ` in path: "+t);return new e(n)}static emptyPath(){return new e([])}},A=class e{constructor(e){this.path=e}static fromPath(t){return new e(O.fromString(t))}static fromName(t){return new e(O.fromString(t).popFirst(5))}static empty(){return new e(O.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 e!==null&&O.comparator(this.path,e.path)===0}toString(){return this.path.toString()}static comparator(e,t){return O.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(t){return new e(new O(t.slice()))}};
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Ue(e,t,n){if(!n)throw new w(C.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function We(e,t,n,r){if(!0===t&&!0===r)throw new w(C.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)}function Ge(e){if(!A.isDocumentKey(e))throw new w(C.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function Ke(e){if(A.isDocumentKey(e))throw new w(C.INVALID_ARGUMENT,`Invalid collection reference. Collection references must have an odd number of segments, but ${e} has ${e.length}.`)}function qe(e){return typeof e==`object`&&!!e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)}function Je(e){if(e===void 0)return`undefined`;if(e===null)return`null`;if(typeof e==`string`)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if(typeof e==`number`||typeof e==`boolean`)return``+e;if(typeof e==`object`){if(e instanceof Array)return`an array`;{let t=function(e){return e.constructor?e.constructor.name:null}(e);return t?`a custom ${t} object`:`an object`}}return typeof e==`function`?`a function`:b(12329,{type:typeof e})}function Ye(e,t){if(`_delegate`in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new w(C.INVALID_ARGUMENT,`Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?`);{let n=Je(e);throw new w(C.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}
/**
* @license
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function j(e,t){let n={typeString:e};return t&&(n.value=t),n}function Xe(e,t){if(!qe(e))throw new w(C.INVALID_ARGUMENT,`JSON must be an object`);let n;for(let r in t)if(t[r]){let i=t[r].typeString,a=`value`in t[r]?{value:t[r].value}:void 0;if(!(r in e)){n=`JSON missing required field: '${r}'`;break}let o=e[r];if(i&&typeof o!==i){n=`JSON field '${r}' must be a ${i}.`;break}if(a!==void 0&&o!==a.value){n=`Expected '${r}' field to equal '${a.value}'`;break}}if(n)throw new w(C.INVALID_ARGUMENT,n);return!0}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Ze=-62135596800,Qe=1e6,M=class e{static now(){return e.fromMillis(Date.now())}static fromDate(t){return e.fromMillis(t.getTime())}static fromMillis(t){let n=Math.floor(t/1e3),r=Math.floor((t-1e3*n)*Qe);return new e(n,r)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0||t>=1e9)throw new w(C.INVALID_ARGUMENT,`Timestamp nanoseconds out of range: `+t);if(e<Ze||e>=253402300800)throw new w(C.INVALID_ARGUMENT,`Timestamp seconds out of range: `+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/Qe}_compareTo(e){return this.seconds===e.seconds?T(this.nanoseconds,e.nanoseconds):T(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:e._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(t){if(Xe(t,e._jsonSchema))return new e(t.seconds,t.nanoseconds)}valueOf(){let e=this.seconds-Ze;return String(e).padStart(12,`0`)+`.`+String(this.nanoseconds).padStart(9,`0`)}};M._jsonSchemaVersion=`firestore/timestamp/1.0`,M._jsonSchema={type:j(`string`,M._jsonSchemaVersion),seconds:j(`number`),nanoseconds:j(`number`)};
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var N=class e{static fromTimestamp(t){return new e(t)}static min(){return new e(new M(0,0))}static max(){return new e(new M(253402300799,999999999))}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}},$e=-1,et=class{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}};et.UNKNOWN_ID=-1;function P(e,t){let n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1,i=N.fromTimestamp(r===1e9?new M(n+1,0):new M(n,r));return new nt(i,A.empty(),t)}function tt(e){return new nt(e.readTime,e.key,$e)}var nt=class e{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new e(N.min(),A.empty(),$e)}static max(){return new e(N.max(),A.empty(),$e)}};function rt(e,t){let n=e.readTime.compareTo(t.readTime);return n===0?(n=A.comparator(e.documentKey,t.documentKey),n===0?T(e.largestBatchId,t.largestBatchId):n):n}
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var it=`The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.`,at=class{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach((e=>e()))}};
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
async function F(e){if(e.code!==C.FAILED_PRECONDITION||e.message!==it)throw e;y(`LocalStore`,`Unexpectedly lost primary lease`)}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var I=class e{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(t,n){return this.callbackAttached&&b(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(n,this.error):this.wrapSuccess(t,this.result):new e(((e,r)=>{this.nextCallback=n=>{this.wrapSuccess(t,n).next(e,r)},this.catchCallback=t=>{this.wrapFailure(n,t).next(e,r)}}))}toPromise(){return new Promise(((e,t)=>{this.next(e,t)}))}wrapUserFunction(t){try{let n=t();return n instanceof e?n:e.resolve(n)}catch(t){return e.reject(t)}}wrapSuccess(t,n){return t?this.wrapUserFunction((()=>t(n))):e.resolve(n)}wrapFailure(t,n){return t?this.wrapUserFunction((()=>t(n))):e.reject(n)}static resolve(t){return new e(((e,n)=>{e(t)}))}static reject(t){return new e(((e,n)=>{n(t)}))}static waitFor(t){return new e(((e,n)=>{let r=0,i=0,a=!1;t.forEach((t=>{++r,t.next((()=>{++i,a&&i===r&&e()}),(e=>n(e)))})),a=!0,i===r&&e()}))}static or(t){let n=e.resolve(!1);for(let r of t)n=n.next((t=>t?e.resolve(t):r()));return n}static forEach(e,t){let n=[];return e.forEach(((e,r)=>{n.push(t.call(this,e,r))})),this.waitFor(n)}static mapArray(t,n){return new e(((e,r)=>{let i=t.length,a=Array(i),o=0;for(let s=0;s<i;s++){let c=s;n(t[c]).next((t=>{a[c]=t,++o,o===i&&e(a)}),(e=>r(e)))}}))}static doWhile(t,n){return new e(((e,r)=>{let i=()=>{!0===t()?n().next((()=>{i()}),r):e()};i()}))}};function ot(e){let t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(`.`).slice(0,2).join(`.`):`-1`;return Number(n)}function st(e){return e.name===`IndexedDbTransactionError`}
/**
* @license
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var ct=class{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this.ae(e),this.ue=e=>t.writeSequenceNumber(e))}ae(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){let e=++this.previousValue;return this.ue&&this.ue(e),e}};ct.ce=-1;
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var lt=-1;function ut(e){return e==null}function dt(e){return e===0&&1/e==-1/0}function ft(e){return typeof e==`number`&&Number.isInteger(e)&&!dt(e)&&e<=2**53-1&&e>=-(2**53-1)}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var pt=``;function mt(e){let t=``;for(let n=0;n<e.length;n++)t.length>0&&(t=gt(t)),t=ht(e.get(n),t);return gt(t)}function ht(e,t){let n=t,r=e.length;for(let t=0;t<r;t++){let r=e.charAt(t);switch(r){case`\0`:n+=``;break;case pt:n+=``;break;default:n+=r}}return n}function gt(e){return e+pt+``}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function _t(e){let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function vt(e,t){for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function yt(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var L=class e{constructor(e,t){this.comparator=e,this.root=t||xt.EMPTY}insert(t,n){return new e(this.comparator,this.root.insert(t,n,this.comparator).copy(null,null,xt.BLACK,null,null))}remove(t){return new e(this.comparator,this.root.remove(t,this.comparator).copy(null,null,xt.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){let n=this.comparator(e,t.key);if(n===0)return t.value;n<0?t=t.left:n>0&&(t=t.right)}return null}indexOf(e){let t=0,n=this.root;for(;!n.isEmpty();){let r=this.comparator(e,n.key);if(r===0)return t+n.left.size;r<0?n=n.left:(t+=n.left.size+1,n=n.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,n)=>(e(t,n),!1)))}toString(){let e=[];return this.inorderTraversal(((t,n)=>(e.push(`${t}:${n}`),!1))),`{${e.join(`, `)}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new bt(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new bt(this.root,e,this.comparator,!1)}getReverseIterator(){return new bt(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new bt(this.root,e,this.comparator,!0)}},bt=class{constructor(e,t,n,r){this.isReverse=r,this.nodeStack=[];let i=1;for(;!e.isEmpty();)if(i=t?n(e.key,t):1,t&&r&&(i*=-1),i<0)e=this.isReverse?e.left:e.right;else{if(i===0){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(this.nodeStack.length===0)return null;let e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}},xt=class e{constructor(t,n,r,i,a){this.key=t,this.value=n,this.color=r??e.RED,this.left=i??e.EMPTY,this.right=a??e.EMPTY,this.size=this.left.size+1+this.right.size}copy(t,n,r,i,a){return new e(t??this.key,n??this.value,r??this.color,i??this.left,a??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,n){let r=this,i=n(e,r.key);return r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):i===0?r.copy(null,t,null,null,null):r.copy(null,null,null,null,r.right.insert(e,t,n)),r.fixUp()}removeMin(){if(this.left.isEmpty())return e.EMPTY;let t=this;return t.left.isRed()||t.left.left.isRed()||(t=t.moveRedLeft()),t=t.copy(null,null,null,t.left.removeMin(),null),t.fixUp()}remove(t,n){let r,i=this;if(n(t,i.key)<0)i.left.isEmpty()||i.left.isRed()||i.left.left.isRed()||(i=i.moveRedLeft()),i=i.copy(null,null,null,i.left.remove(t,n),null);else{if(i.left.isRed()&&(i=i.rotateRight()),i.right.isEmpty()||i.right.isRed()||i.right.left.isRed()||(i=i.moveRedRight()),n(t,i.key)===0){if(i.right.isEmpty())return e.EMPTY;r=i.right.min(),i=i.copy(r.key,r.value,null,null,i.right.removeMin())}i=i.copy(null,null,null,null,i.right.remove(t,n))}return i.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.copy(null,null,null,null,e.right.rotateRight()),e=e.rotateLeft(),e=e.colorFlip()),e}moveRedRight(){let e=this.colorFlip();return e.left.left.isRed()&&(e=e.rotateRight(),e=e.colorFlip()),e}rotateLeft(){let t=this.copy(null,null,e.RED,null,this.right.left);return this.right.copy(null,null,this.color,t,null)}rotateRight(){let t=this.copy(null,null,e.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,t)}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 2**this.check()<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw b(43730,{key:this.key,value:this.value});if(this.right.isRed())throw b(14113,{key:this.key,value:this.value});let e=this.left.check();if(e!==this.right.check())throw b(27949);return e+(this.isRed()?0:1)}};xt.EMPTY=null,xt.RED=!0,xt.BLACK=!1,xt.EMPTY=new class{constructor(){this.size=0}get key(){throw b(57766)}get value(){throw b(16141)}get color(){throw b(16727)}get left(){throw b(29726)}get right(){throw b(36894)}copy(e,t,n,r,i){return this}insert(e,t,n){return new xt(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}};
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var R=class e{constructor(e){this.comparator=e,this.data=new L(this.comparator)}has(e){return this.data.get(e)!==null}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,n)=>(e(t),!1)))}forEachInRange(e,t){let n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){let r=n.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}forEachWhile(e,t){let n;for(n=t===void 0?this.data.getIterator():this.data.getIteratorFrom(t);n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){let t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new St(this.data.getIterator())}getIteratorFrom(e){return new St(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(t){if(!(t instanceof e)||this.size!==t.size)return!1;let n=this.data.getIterator(),r=t.data.getIterator();for(;n.hasNext();){let e=n.getNext().key,t=r.getNext().key;if(this.comparator(e,t)!==0)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(t){let n=new e(this.comparator);return n.data=t,n}},St=class{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}},z=class e{constructor(e){this.fields=e,e.sort(k.comparator)}static empty(){return new e([])}unionWith(t){let n=new R(k.comparator);for(let e of this.fields)n=n.add(e);for(let e of t)n=n.add(e);return new e(n.toArray())}covers(e){for(let t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return D(this.fields,e.fields,((e,t)=>e.isEqual(t)))}},Ct=class extends Error{constructor(){super(...arguments),this.name=`Base64DecodeError`}},B=class e{constructor(e){this.binaryString=e}static fromBase64String(t){let n=function(e){try{return atob(e)}catch(e){throw typeof DOMException<`u`&&e instanceof DOMException?new Ct(`Invalid base64 string: `+e):e}}(t);return new e(n)}static fromUint8Array(t){let n=function(e){let t=``;for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(t);return new e(n)}[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 function(e){return btoa(e)}(this.binaryString)}toUint8Array(){return function(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}(this.binaryString)}approximateByteSize(){return 2*this.binaryString.length}compareTo(e){return T(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}};B.EMPTY_BYTE_STRING=new B(``);var wt=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function Tt(e){if(x(!!e,39018),typeof e==`string`){let t=0,n=wt.exec(e);if(x(!!n,46558,{timestamp:e}),n[1]){let e=n[1];e=(e+`000000000`).substr(0,9),t=Number(e)}let r=new Date(e);return{seconds:Math.floor(r.getTime()/1e3),nanos:t}}return{seconds:V(e.seconds),nanos:V(e.nanos)}}function V(e){return typeof e==`number`?e:typeof e==`string`?Number(e):0}function Et(e){return typeof e==`string`?B.fromBase64String(e):B.fromUint8Array(e)}
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Dt=`server_timestamp`,Ot=`__type__`,kt=`__previous_value__`,At=`__local_write_time__`;function jt(e){return(e?.mapValue?.fields||{})[Ot]?.stringValue===Dt}function Mt(e){let t=e.mapValue.fields[kt];return jt(t)?Mt(t):t}function H(e){let t=Tt(e.mapValue.fields[At].timestampValue);return new M(t.seconds,t.nanos)}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Nt=class{constructor(e,t,n,r,i,a,o,s,c,l){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=a,this.autoDetectLongPolling=o,this.longPollingOptions=s,this.useFetchStreams=c,this.isUsingEmulator=l}},Pt=`(default)`,Ft=class e{constructor(e,t){this.projectId=e,this.database=t||Pt}static empty(){return new e(``,``)}get isDefaultDatabase(){return this.database===Pt}isEqual(t){return t instanceof e&&t.projectId===this.projectId&&t.database===this.database}},It=`__type__`,U=`__max__`,Lt={mapValue:{fields:{__type__:{stringValue:U}}}},Rt=`__vector__`,zt=`value`;function Bt(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?jt(e)?4:rn(e)?9007199254740991:tn(e)?10:11:b(28295,{value:e})}function Vt(e,t){if(e===t)return!0;let n=Bt(e);if(n!==Bt(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return H(e).isEqual(H(t));case 3:return function(e,t){if(typeof e.timestampValue==`string`&&typeof t.timestampValue==`string`&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;let n=Tt(e.timestampValue),r=Tt(t.timestampValue);return n.seconds===r.seconds&&n.nanos===r.nanos}(e,t);case 5:return e.stringValue===t.stringValue;case 6:return function(e,t){return Et(e.bytesValue).isEqual(Et(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return V(e.geoPointValue.latitude)===V(t.geoPointValue.latitude)&&V(e.geoPointValue.longitude)===V(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if(`integerValue`in e&&`integerValue`in t)return V(e.integerValue)===V(t.integerValue);if(`doubleValue`in e&&`doubleValue`in t){let n=V(e.doubleValue),r=V(t.doubleValue);return n===r?dt(n)===dt(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return D(e.arrayValue.values||[],t.arrayValue.values||[],Vt);case 10:case 11:return function(e,t){let n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(_t(n)!==_t(r))return!1;for(let e in n)if(n.hasOwnProperty(e)&&(r[e]===void 0||!Vt(n[e],r[e])))return!1;return!0}(e,t);default:return b(52216,{left:e})}}function Ht(e,t){return(e.values||[]).find((e=>Vt(e,t)))!==void 0}function Ut(e,t){if(e===t)return 0;let n=Bt(e),r=Bt(t);if(n!==r)return T(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return T(e.booleanValue,t.booleanValue);case 2:return function(e,t){let n=V(e.integerValue||e.doubleValue),r=V(t.integerValue||t.doubleValue);return n<r?-1:n>r?1:n===r?0:isNaN(n)?isNaN(r)?0:-1:1}(e,t);case 3:return Wt(e.timestampValue,t.timestampValue);case 4:return Wt(H(e),H(t));case 5:return Le(e.stringValue,t.stringValue);case 6:return function(e,t){let n=Et(e),r=Et(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){let n=e.split(`/`),r=t.split(`/`);for(let e=0;e<n.length&&e<r.length;e++){let t=T(n[e],r[e]);if(t!==0)return t}return T(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){let n=T(V(e.latitude),V(t.latitude));return n===0?T(V(e.longitude),V(t.longitude)):n}(e.geoPointValue,t.geoPointValue);case 9:return Gt(e.arrayValue,t.arrayValue);case 10:return function(e,t){let n=e.fields||{},r=t.fields||{},i=n[zt]?.arrayValue,a=r[zt]?.arrayValue,o=T(i?.values?.length||0,a?.values?.length||0);return o===0?Gt(i,a):o}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===Lt.mapValue&&t===Lt.mapValue)return 0;if(e===Lt.mapValue)return 1;if(t===Lt.mapValue)return-1;let n=e.fields||{},r=Object.keys(n),i=t.fields||{},a=Object.keys(i);r.sort(),a.sort();for(let e=0;e<r.length&&e<a.length;++e){let t=Le(r[e],a[e]);if(t!==0)return t;let o=Ut(n[r[e]],i[a[e]]);if(o!==0)return o}return T(r.length,a.length)}(e.mapValue,t.mapValue);default:throw b(23264,{he:n})}}function Wt(e,t){if(typeof e==`string`&&typeof t==`string`&&e.length===t.length)return T(e,t);let n=Tt(e),r=Tt(t),i=T(n.seconds,r.seconds);return i===0?T(n.nanos,r.nanos):i}function Gt(e,t){let n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){let t=Ut(n[e],r[e]);if(t)return t}return T(n.length,r.length)}function Kt(e){return qt(e)}function qt(e){return`nullValue`in e?`null`:`booleanValue`in e?``+e.booleanValue:`integerValue`in e?``+e.integerValue:`doubleValue`in e?``+e.doubleValue:`timestampValue`in e?function(e){let t=Tt(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):`stringValue`in e?e.stringValue:`bytesValue`in e?function(e){return Et(e).toBase64()}(e.bytesValue):`referenceValue`in e?function(e){return A.fromName(e).toString()}(e.referenceValue):`geoPointValue`in e?function(e){return`geo(${e.latitude},${e.longitude})`}(e.geoPointValue):`arrayValue`in e?function(e){let t=`[`,n=!0;for(let r of e.values||[])n?n=!1:t+=`,`,t+=qt(r);return t+`]`}(e.arrayValue):`mapValue`in e?function(e){let t=Object.keys(e.fields||{}).sort(),n=`{`,r=!0;for(let i of t)r?r=!1:n+=`,`,n+=`${i}:${qt(e.fields[i])}`;return n+`}`}(e.mapValue):b(61005,{value:e})}function Jt(e){switch(Bt(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:let t=Mt(e);return t?16+Jt(t):16;case 5:return 2*e.stringValue.length;case 6:return Et(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return function(e){return(e.values||[]).reduce(((e,t)=>e+Jt(t)),0)}(e.arrayValue);case 10:case 11:return function(e){let t=0;return vt(e.fields,((e,n)=>{t+=e.length+Jt(n)})),t}(e.mapValue);default:throw b(13486,{value:e})}}function Yt(e,t){return{referenceValue:`projects/${e.projectId}/databases/${e.database}/documents/${t.path.canonicalString()}`}}function Xt(e){return!!e&&`integerValue`in e}function Zt(e){return!!e&&`arrayValue`in e}function Qt(e){return!!e&&`nullValue`in e}function $t(e){return!!e&&`doubleValue`in e&&isNaN(Number(e.doubleValue))}function en(e){return!!e&&`mapValue`in e}function tn(e){return(e?.mapValue?.fields||{})[It]?.stringValue===Rt}function nn(e){if(e.geoPointValue)return{geoPointValue:{...e.geoPointValue}};if(e.timestampValue&&typeof e.timestampValue==`object`)return{timestampValue:{...e.timestampValue}};if(e.mapValue){let t={mapValue:{fields:{}}};return vt(e.mapValue.fields,((e,n)=>t.mapValue.fields[e]=nn(n))),t}if(e.arrayValue){let t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=nn(e.arrayValue.values[n]);return t}return{...e}}function rn(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===U}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var an=class e{constructor(e){this.value=e}static empty(){return new e({mapValue:{}})}field(e){if(e.isEmpty())return this.value;{let t=this.value;for(let n=0;n<e.length-1;++n)if(t=(t.mapValue.fields||{})[e.get(n)],!en(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=nn(t)}setAll(e){let t=k.emptyPath(),n={},r=[];e.forEach(((e,i)=>{if(!t.isImmediateParentOf(i)){let e=this.getFieldsMap(t);this.applyChanges(e,n,r),n={},r=[],t=i.popLast()}e?n[i.lastSegment()]=nn(e):r.push(i.lastSegment())}));let i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){let t=this.field(e.popLast());en(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return Vt(this.value,e.value)}getFieldsMap(e){let t=this.value;t.mapValue.fields||(t.mapValue={fields:{}});for(let n=0;n<e.length;++n){let r=t.mapValue.fields[e.get(n)];en(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){vt(t,((t,n)=>e[t]=n));for(let t of n)delete e[t]}clone(){return new e(nn(this.value))}};function on(e){let t=[];return vt(e.fields,((e,n)=>{let r=new k([e]);if(en(n)){let e=on(n.mapValue).fields;if(e.length===0)t.push(r);else for(let n of e)t.push(r.child(n))}else t.push(r)})),new z(t)}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var W=class e{constructor(e,t,n,r,i,a,o){this.key=e,this.documentType=t,this.version=n,this.readTime=r,this.createTime=i,this.data=a,this.documentState=o}static newInvalidDocument(t){return new e(t,0,N.min(),N.min(),N.min(),an.empty(),0)}static newFoundDocument(t,n,r,i){return new e(t,1,n,N.min(),r,i,0)}static newNoDocument(t,n){return new e(t,2,n,N.min(),N.min(),an.empty(),0)}static newUnknownDocument(t,n){return new e(t,3,n,N.min(),N.min(),an.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(N.min())||this.documentType!==2&&this.documentType!==0||(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=an.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=an.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=N.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return this.documentState===1}get hasCommittedMutations(){return this.documentState===2}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return this.documentType!==0}isFoundDocument(){return this.documentType===1}isNoDocument(){return this.documentType===2}isUnknownDocument(){return this.documentType===3}isEqual(t){return t instanceof e&&this.key.isEqual(t.key)&&this.version.isEqual(t.version)&&this.documentType===t.documentType&&this.documentState===t.documentState&&this.data.isEqual(t.data)}mutableCopy(){return new e(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}})`}},sn=class{constructor(e,t){this.position=e,this.inclusive=t}};function cn(e,t,n){let r=0;for(let i=0;i<e.position.length;i++){let a=t[i],o=e.position[i];if(r=a.field.isKeyField()?A.comparator(A.fromName(o.referenceValue),n.key):Ut(o,n.data.field(a.field)),a.dir===`desc`&&(r*=-1),r!==0)break}return r}function ln(e,t){if(e===null)return t===null;if(t===null||e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!Vt(e.position[n],t.position[n]))return!1;return!0}
/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var un=class{constructor(e,t=`asc`){this.field=e,this.dir=t}};function dn(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}
/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var G=class{},K=class e extends G{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(t,n,r){return t.isKeyField()?n===`in`||n===`not-in`?this.createKeyFieldInFilter(t,n,r):new yn(t,n,r):n===`array-contains`?new Cn(t,r):n===`in`?new wn(t,r):n===`not-in`?new Tn(t,r):n===`array-contains-any`?new En(t,r):new e(t,n,r)}static createKeyFieldInFilter(e,t,n){return t===`in`?new bn(e,n):new xn(e,n)}matches(e){let t=e.data.field(this.field);return this.op===`!=`?t!==null&&t.nullValue===void 0&&this.matchesComparison(Ut(t,this.value)):t!==null&&Bt(this.value)===Bt(t)&&this.matchesComparison(Ut(t,this.value))}matchesComparison(e){switch(this.op){case`<`:return e<0;case`<=`:return e<=0;case`==`:return e===0;case`!=`:return e!==0;case`>`:return e>0;case`>=`:return e>=0;default:return b(47266,{operator:this.op})}}isInequality(){return[`<`,`<=`,`>`,`>=`,`!=`,`not-in`].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}},fn=class e extends G{constructor(e,t){super(),this.filters=e,this.op=t,this.Pe=null}static create(t,n){return new e(t,n)}matches(e){return pn(this)?this.filters.find((t=>!t.matches(e)))===void 0:this.filters.find((t=>t.matches(e)))!==void 0}getFlattenedFilters(){return this.Pe!==null||(this.Pe=this.filters.reduce(((e,t)=>e.concat(t.getFlattenedFilters())),[])),this.Pe}getFilters(){return Object.assign([],this.filters)}};function pn(e){return e.op===`and`}function mn(e){return hn(e)&&pn(e)}function hn(e){for(let t of e.filters)if(t instanceof fn)return!1;return!0}function gn(e){if(e instanceof K)return e.field.canonicalString()+e.op.toString()+Kt(e.value);if(mn(e))return e.filters.map((e=>gn(e))).join(`,`);{let t=e.filters.map((e=>gn(e))).join(`,`);return`${e.op}(${t})`}}function _n(e,t){return e instanceof K?function(e,t){return t instanceof K&&e.op===t.op&&e.field.isEqual(t.field)&&Vt(e.value,t.value)}(e,t):e instanceof fn?function(e,t){return t instanceof fn&&e.op===t.op&&e.filters.length===t.filters.length?e.filters.reduce(((e,n,r)=>e&&_n(n,t.filters[r])),!0):!1}(e,t):void b(19439)}function vn(e){return e instanceof K?function(e){return`${e.field.canonicalString()} ${e.op} ${Kt(e.value)}`}(e):e instanceof fn?function(e){return e.op.toString()+` {`+e.getFilters().map(vn).join(` ,`)+`}`}(e):`Filter`}var yn=class extends K{constructor(e,t,n){super(e,t,n),this.key=A.fromName(n.referenceValue)}matches(e){let t=A.comparator(e.key,this.key);return this.matchesComparison(t)}},bn=class extends K{constructor(e,t){super(e,`in`,t),this.keys=Sn(`in`,t)}matches(e){return this.keys.some((t=>t.isEqual(e.key)))}},xn=class extends K{constructor(e,t){super(e,`not-in`,t),this.keys=Sn(`not-in`,t)}matches(e){return!this.keys.some((t=>t.isEqual(e.key)))}};function Sn(e,t){return(t.arrayValue?.values||[]).map((e=>A.fromName(e.referenceValue)))}var Cn=class extends K{constructor(e,t){super(e,`array-contains`,t)}matches(e){let t=e.data.field(this.field);return Zt(t)&&Ht(t.arrayValue,this.value)}},wn=class extends K{constructor(e,t){super(e,`in`,t)}matches(e){let t=e.data.field(this.field);return t!==null&&Ht(this.value.arrayValue,t)}},Tn=class extends K{constructor(e,t){super(e,`not-in`,t)}matches(e){if(Ht(this.value.arrayValue,{nullValue:`NULL_VALUE`}))return!1;let t=e.data.field(this.field);return t!==null&&t.nullValue===void 0&&!Ht(this.value.arrayValue,t)}},En=class extends K{constructor(e,t){super(e,`array-contains-any`,t)}matches(e){let t=e.data.field(this.field);return!(!Zt(t)||!t.arrayValue.values)&&t.arrayValue.values.some((e=>Ht(this.value.arrayValue,e)))}},Dn=class{constructor(e,t=null,n=[],r=[],i=null,a=null,o=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=a,this.endAt=o,this.Te=null}};function On(e,t=null,n=[],r=[],i=null,a=null,o=null){return new Dn(e,t,n,r,i,a,o)}function kn(e){let t=S(e);if(t.Te===null){let e=t.path.canonicalString();t.collectionGroup!==null&&(e+=`|cg:`+t.collectionGroup),e+=`|f:`,e+=t.filters.map((e=>gn(e))).join(`,`),e+=`|ob:`,e+=t.orderBy.map((e=>function(e){return e.field.canonicalString()+e.dir}(e))).join(`,`),ut(t.limit)||(e+=`|l:`,e+=t.limit),t.startAt&&(e+=`|lb:`,e+=t.startAt.inclusive?`b:`:`a:`,e+=t.startAt.position.map((e=>Kt(e))).join(`,`)),t.endAt&&(e+=`|ub:`,e+=t.endAt.inclusive?`a:`:`b:`,e+=t.endAt.position.map((e=>Kt(e))).join(`,`)),t.Te=e}return t.Te}function An(e,t){if(e.limit!==t.limit||e.orderBy.length!==t.orderBy.length)return!1;for(let n=0;n<e.orderBy.length;n++)if(!dn(e.orderBy[n],t.orderBy[n]))return!1;if(e.filters.length!==t.filters.length)return!1;for(let n=0;n<e.filters.length;n++)if(!_n(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!ln(e.startAt,t.startAt)&&ln(e.endAt,t.endAt)}function jn(e){return A.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Mn=class{constructor(e,t=null,n=[],r=[],i=null,a=`F`,o=null,s=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=a,this.startAt=o,this.endAt=s,this.Ie=null,this.Ee=null,this.de=null,this.startAt,this.endAt}};function Nn(e,t,n,r,i,a,o,s){return new Mn(e,t,n,r,i,a,o,s)}function Pn(e){return new Mn(e)}function Fn(e){return e.filters.length===0&&e.limit===null&&e.startAt==null&&e.endAt==null&&(e.explicitOrderBy.length===0||e.explicitOrderBy.length===1&&e.explicitOrderBy[0].field.isKeyField())}function In(e){return e.collectionGroup!==null}function Ln(e){let t=S(e);if(t.Ie===null){t.Ie=[];let e=new Set;for(let n of t.explicitOrderBy)t.Ie.push(n),e.add(n.field.canonicalString());let n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:`asc`;(function(e){let t=new R(k.comparator);return e.filters.forEach((e=>{e.getFlattenedFilters().forEach((e=>{e.isInequality()&&(t=t.add(e.field))}))})),t})(t).forEach((r=>{e.has(r.canonicalString())||r.isKeyField()||t.Ie.push(new un(r,n))})),e.has(k.keyField().canonicalString())||t.Ie.push(new un(k.keyField(),n))}return t.Ie}function Rn(e){let t=S(e);return t.Ee||=zn(t,Ln(e)),t.Ee}function zn(e,t){if(e.limitType===`F`)return On(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map((e=>{let t=e.dir===`desc`?`asc`:`desc`;return new un(e.field,t)}));let n=e.endAt?new sn(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new sn(e.startAt.position,e.startAt.inclusive):null;return On(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function Bn(e,t){let n=e.filters.concat([t]);return new Mn(e.path,e.collectionGroup,e.explicitOrderBy.slice(),n,e.limit,e.limitType,e.startAt,e.endAt)}function Vn(e,t,n){return new Mn(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function Hn(e,t){return An(Rn(e),Rn(t))&&e.limitType===t.limitType}function q(e){return`${kn(Rn(e))}|lt:${e.limitType}`}function Un(e){return`Query(target=${function(e){let t=e.path.canonicalString();return e.collectionGroup!==null&&(t+=` collectionGroup=`+e.collectionGroup),e.filters.length>0&&(t+=`, filters: [${e.filters.map((e=>vn(e))).join(`, `)}]`),ut(e.limit)||(t+=`, limit: `+e.limit),e.orderBy.length>0&&(t+=`, orderBy: [${e.orderBy.map((e=>function(e){return`${e.field.canonicalString()} (${e.dir})`}(e))).join(`, `)}]`),e.startAt&&(t+=`, startAt: `,t+=e.startAt.inclusive?`b:`:`a:`,t+=e.startAt.position.map((e=>Kt(e))).join(`,`)),e.endAt&&(t+=`, endAt: `,t+=e.endAt.inclusive?`a:`:`b:`,t+=e.endAt.position.map((e=>Kt(e))).join(`,`)),`Target(${t})`}(Rn(e))}; limitType=${e.limitType})`}function Wn(e,t){return t.isFoundDocument()&&function(e,t){let n=t.key.path;return e.collectionGroup===null?A.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n):t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n)}(e,t)&&function(e,t){for(let n of Ln(e))if(!n.field.isKeyField()&&t.data.field(n.field)===null)return!1;return!0}(e,t)&&function(e,t){for(let n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&&function(e,t){return!(e.startAt&&!function(e,t,n){let r=cn(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,Ln(e),t)||e.endAt&&!function(e,t,n){let r=cn(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,Ln(e),t))}(e,t)}function Gn(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function Kn(e){return(t,n)=>{let r=!1;for(let i of Ln(e)){let e=qn(i,t,n);if(e!==0)return e;r||=i.field.isKeyField()}return 0}}function qn(e,t,n){let r=e.field.isKeyField()?A.comparator(t.key,n.key):function(e,t,n){let r=t.data.field(e),i=n.data.field(e);return r!==null&&i!==null?Ut(r,i):b(42886)}(e.field,t,n);switch(e.dir){case`asc`:return r;case`desc`:return-1*r;default:return b(19790,{direction:e.dir})}}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Jn=class{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){let t=this.mapKeyFn(e),n=this.inner[t];if(n!==void 0){for(let[t,r]of n)if(this.equalsFn(t,e))return r}}has(e){return this.get(e)!==void 0}set(e,t){let n=this.mapKeyFn(e),r=this.inner[n];if(r===void 0)return this.inner[n]=[[e,t]],void this.innerSize++;for(let n=0;n<r.length;n++)if(this.equalsFn(r[n][0],e))return void(r[n]=[e,t]);r.push([e,t]),this.innerSize++}delete(e){let t=this.mapKeyFn(e),n=this.inner[t];if(n===void 0)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return n.length===1?delete this.inner[t]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(e){vt(this.inner,((t,n)=>{for(let[t,r]of n)e(t,r)}))}isEmpty(){return yt(this.inner)}size(){return this.innerSize}},Yn=new L(A.comparator);function Xn(){return Yn}var Zn=new L(A.comparator);function Qn(...e){let t=Zn;for(let n of e)t=t.insert(n.key,n);return t}function $n(e){let t=Zn;return e.forEach(((e,n)=>t=t.insert(e,n.overlayedDocument))),t}function er(){return nr()}function tr(){return nr()}function nr(){return new Jn((e=>e.toString()),((e,t)=>e.isEqual(t)))}var rr=new L(A.comparator),ir=new R(A.comparator);function J(...e){let t=ir;for(let n of e)t=t.add(n);return t}var ar=new R(T);function or(){return ar}
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function sr(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:dt(t)?`-0`:t}}function cr(e){return{integerValue:``+e}}function lr(e,t){return ft(t)?cr(t):sr(e,t)}
/**
* @license
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var ur=class{constructor(){this._=void 0}};function dr(e,t,n){return e instanceof mr?function(e,t){let n={fields:{[Ot]:{stringValue:Dt},[At]:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&jt(t)&&(t=Mt(t)),t&&(n.fields[kt]=t),{mapValue:n}}(n,t):e instanceof hr?gr(e,t):e instanceof _r?vr(e,t):function(e,t){let n=pr(e,t),r=br(n)+br(e.Ae);return Xt(n)&&Xt(e.Ae)?cr(r):sr(e.serializer,r)}(e,t)}function fr(e,t,n){return e instanceof hr?gr(e,t):e instanceof _r?vr(e,t):n}function pr(e,t){return e instanceof yr?function(e){return Xt(e)||function(e){return!!e&&`doubleValue`in e}(e)}(t)?t:{integerValue:0}:null}var mr=class extends ur{},hr=class extends ur{constructor(e){super(),this.elements=e}};function gr(e,t){let n=xr(t);for(let t of e.elements)n.some((e=>Vt(e,t)))||n.push(t);return{arrayValue:{values:n}}}var _r=class extends ur{constructor(e){super(),this.elements=e}};function vr(e,t){let n=xr(t);for(let t of e.elements)n=n.filter((e=>!Vt(e,t)));return{arrayValue:{values:n}}}var yr=class extends ur{constructor(e,t){super(),this.serializer=e,this.Ae=t}};function br(e){return V(e.integerValue||e.doubleValue)}function xr(e){return Zt(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}function Sr(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof hr&&t instanceof hr||e instanceof _r&&t instanceof _r?D(e.elements,t.elements,Vt):e instanceof yr&&t instanceof yr?Vt(e.Ae,t.Ae):e instanceof mr&&t instanceof mr}(e.transform,t.transform)}var Cr=class{constructor(e,t){this.version=e,this.transformResults=t}},wr=class e{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new e}static exists(t){return new e(void 0,t)}static updateTime(t){return new e(t)}get isNone(){return this.updateTime===void 0&&this.exists===void 0}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}};function Tr(e,t){return e.updateTime===void 0?e.exists===void 0||e.exists===t.isFoundDocument():t.isFoundDocument()&&t.version.isEqual(e.updateTime)}var Er=class{};function Dr(e,t){if(!e.hasLocalMutations||t&&t.fields.length===0)return null;if(t===null)return e.isNoDocument()?new Lr(e.key,wr.none()):new Mr(e.key,e.data,wr.none());{let n=e.data,r=an.empty(),i=new R(k.comparator);for(let e of t.fields)if(!i.has(e)){let t=n.field(e);t===null&&e.length>1&&(e=e.popLast(),t=n.field(e)),t===null?r.delete(e):r.set(e,t),i=i.add(e)}return new Nr(e.key,r,new z(i.toArray()),wr.none())}}function Or(e,t,n){e instanceof Mr?function(e,t,n){let r=e.value.clone(),i=Fr(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof Nr?function(e,t,n){if(!Tr(e.precondition,t))return void t.convertToUnknownDocument(n.version);let r=Fr(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(Pr(e)),i.setAll(r),t.convertToFoundDocument(n.version,i).setHasCommittedMutations()}(e,t,n):function(e,t,n){t.convertToNoDocument(n.version).setHasCommittedMutations()}(0,t,n)}function kr(e,t,n,r){return e instanceof Mr?function(e,t,n,r){if(!Tr(e.precondition,t))return n;let i=e.value.clone(),a=Ir(e.fieldTransforms,r,t);return i.setAll(a),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof Nr?function(e,t,n,r){if(!Tr(e.precondition,t))return n;let i=Ir(e.fieldTransforms,r,t),a=t.data;return a.setAll(Pr(e)),a.setAll(i),t.convertToFoundDocument(t.version,a).setHasLocalMutations(),n===null?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map((e=>e.field)))}(e,t,n,r):function(e,t,n){return Tr(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function Ar(e,t){let n=null;for(let r of e.fieldTransforms){let e=t.data.field(r.field),i=pr(r.transform,e||null);i!=null&&(n===null&&(n=an.empty()),n.set(r.field,i))}return n||null}function jr(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&!!function(e,t){return e===void 0&&t===void 0||!(!e||!t)&&D(e,t,((e,t)=>Sr(e,t)))}(e.fieldTransforms,t.fieldTransforms)&&(e.type===0?e.value.isEqual(t.value):e.type!==1||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}var Mr=class extends Er{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.precondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}},Nr=class extends Er{constructor(e,t,n,r,i=[]){super(),this.key=e,this.data=t,this.fieldMask=n,this.precondition=r,this.fieldTransforms=i,this.type=1}getFieldMask(){return this.fieldMask}};function Pr(e){let t=new Map;return e.fieldMask.fields.forEach((n=>{if(!n.isEmpty()){let r=e.data.field(n);t.set(n,r)}})),t}function Fr(e,t,n){let r=new Map;x(e.length===n.length,32656,{Re:n.length,Ve:e.length});for(let i=0;i<n.length;i++){let a=e[i],o=a.transform,s=t.data.field(a.field);r.set(a.field,fr(o,s,n[i]))}return r}function Ir(e,t,n){let r=new Map;for(let i of e){let e=i.transform,a=n.data.field(i.field);r.set(i.field,dr(e,a,t))}return r}var Lr=class extends Er{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}},Rr=class extends Er{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}},zr=class{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){let n=t.mutationResults;for(let t=0;t<this.mutations.length;t++){let r=this.mutations[t];r.key.isEqual(e.key)&&Or(r,e,n[t])}}applyToLocalView(e,t){for(let n of this.baseMutations)n.key.isEqual(e.key)&&(t=kr(n,e,t,this.localWriteTime));for(let n of this.mutations)n.key.isEqual(e.key)&&(t=kr(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){let n=tr();return this.mutations.forEach((r=>{let i=e.get(r.key),a=i.overlayedDocument,o=this.applyToLocalView(a,i.mutatedFields);o=t.has(r.key)?null:o;let s=Dr(a,o);s!==null&&n.set(r.key,s),a.isValidDocument()||a.convertToNoDocument(N.min())})),n}keys(){return this.mutations.reduce(((e,t)=>e.add(t.key)),J())}isEqual(e){return this.batchId===e.batchId&&D(this.mutations,e.mutations,((e,t)=>jr(e,t)))&&D(this.baseMutations,e.baseMutations,((e,t)=>jr(e,t)))}},Br=class e{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(t,n,r){x(t.mutations.length===r.length,58842,{me:t.mutations.length,fe:r.length});let i=function(){return rr}(),a=t.mutations;for(let e=0;e<a.length;e++)i=i.insert(a[e].key,r[e].version);return new e(t,n,r,i)}},Vr=class{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return e!==null&&this.mutation===e.mutation}toString(){return`Overlay{\n largestBatchId: ${this.largestBatchId},\n mutation: ${this.mutation.toString()}\n }`}},Hr=class{constructor(e,t){this.count=e,this.unchangedNames=t}},Y,X;function Ur(e){switch(e){case C.OK:return b(64938);case C.CANCELLED:case C.UNKNOWN:case C.DEADLINE_EXCEEDED:case C.RESOURCE_EXHAUSTED:case C.INTERNAL:case C.UNAVAILABLE:case C.UNAUTHENTICATED:return!1;case C.INVALID_ARGUMENT:case C.NOT_FOUND:case C.ALREADY_EXISTS:case C.PERMISSION_DENIED:case C.FAILED_PRECONDITION:case C.ABORTED:case C.OUT_OF_RANGE:case C.UNIMPLEMENTED:case C.DATA_LOSS:return!0;default:return b(15467,{code:e})}}function Wr(e){if(e===void 0)return Se(`GRPC error has no .code`),C.UNKNOWN;switch(e){case Y.OK:return C.OK;case Y.CANCELLED:return C.CANCELLED;case Y.UNKNOWN:return C.UNKNOWN;case Y.DEADLINE_EXCEEDED:return C.DEADLINE_EXCEEDED;case Y.RESOURCE_EXHAUSTED:return C.RESOURCE_EXHAUSTED;case Y.INTERNAL:return C.INTERNAL;case Y.UNAVAILABLE:return C.UNAVAILABLE;case Y.UNAUTHENTICATED:return C.UNAUTHENTICATED;case Y.INVALID_ARGUMENT:return C.INVALID_ARGUMENT;case Y.NOT_FOUND:return C.NOT_FOUND;case Y.ALREADY_EXISTS:return C.ALREADY_EXISTS;case Y.PERMISSION_DENIED:return C.PERMISSION_DENIED;case Y.FAILED_PRECONDITION:return C.FAILED_PRECONDITION;case Y.ABORTED:return C.ABORTED;case Y.OUT_OF_RANGE:return C.OUT_OF_RANGE;case Y.UNIMPLEMENTED:return C.UNIMPLEMENTED;case Y.DATA_LOSS:return C.DATA_LOSS;default:return b(39323,{code:e})}}(X=Y||={})[X.OK=0]=`OK`,X[X.CANCELLED=1]=`CANCELLED`,X[X.UNKNOWN=2]=`UNKNOWN`,X[X.INVALID_ARGUMENT=3]=`INVALID_ARGUMENT`,X[X.DEADLINE_EXCEEDED=4]=`DEADLINE_EXCEEDED`,X[X.NOT_FOUND=5]=`NOT_FOUND`,X[X.ALREADY_EXISTS=6]=`ALREADY_EXISTS`,X[X.PERMISSION_DENIED=7]=`PERMISSION_DENIED`,X[X.UNAUTHENTICATED=16]=`UNAUTHENTICATED`,X[X.RESOURCE_EXHAUSTED=8]=`RESOURCE_EXHAUSTED`,X[X.FAILED_PRECONDITION=9]=`FAILED_PRECONDITION`,X[X.ABORTED=10]=`ABORTED`,X[X.OUT_OF_RANGE=11]=`OUT_OF_RANGE`,X[X.UNIMPLEMENTED=12]=`UNIMPLEMENTED`,X[X.INTERNAL=13]=`INTERNAL`,X[X.UNAVAILABLE=14]=`UNAVAILABLE`,X[X.DATA_LOSS=15]=`DATA_LOSS`;
/**
* @license
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Gr=null;
/**
* @license
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function Kr(){return new TextEncoder}
/**
* @license
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var qr=new ae([4294967295,4294967295],0);function Jr(e){let t=Kr().encode(e),n=new oe;return n.update(t),new Uint8Array(n.digest())}function Yr(e){let t=new DataView(e.buffer),n=t.getUint32(0,!0),r=t.getUint32(4,!0),i=t.getUint32(8,!0),a=t.getUint32(12,!0);return[new ae([n,r],0),new ae([i,a],0)]}var Xr=class e{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new Zr(`Invalid padding: ${t}`);if(n<0||e.length>0&&this.hashCount===0)throw new Zr(`Invalid hash count: ${n}`);if(e.length===0&&t!==0)throw new Zr(`Invalid padding when bitmap length is 0: ${t}`);this.ge=8*e.length-t,this.pe=ae.fromNumber(this.ge)}ye(e,t,n){let r=e.add(t.multiply(ae.fromNumber(n)));return r.compare(qr)===1&&(r=new ae([r.getBits(0),r.getBits(1)],0)),r.modulo(this.pe).toNumber()}we(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(this.ge===0)return!1;let t=Jr(e),[n,r]=Yr(t);for(let e=0;e<this.hashCount;e++){let t=this.ye(n,r,e);if(!this.we(t))return!1}return!0}static create(t,n,r){let i=t%8==0?0:8-t%8,a=new Uint8Array(Math.ceil(t/8)),o=new e(a,i,n);return r.forEach((e=>o.insert(e))),o}insert(e){if(this.ge===0)return;let t=Jr(e),[n,r]=Yr(t);for(let e=0;e<this.hashCount;e++){let t=this.ye(n,r,e);this.Se(t)}}Se(e){let t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}},Zr=class extends Error{constructor(){super(...arguments),this.name=`BloomFilterError`}},Qr=class e{constructor(e,t,n,r,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(t,n,r){let i=new Map;return i.set(t,$r.createSynthesizedTargetChangeForCurrentChange(t,n,r)),new e(N.min(),i,new L(T),Xn(),J())}},$r=class e{constructor(e,t,n,r,i){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(t,n,r){return new e(r,n,J(),J(),J())}},ei=class{constructor(e,t,n,r){this.be=e,this.removedTargetIds=t,this.key=n,this.De=r}},ti=class{constructor(e,t){this.targetId=e,this.Ce=t}},ni=class{constructor(e,t,n=B.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}},ri=class{constructor(){this.ve=0,this.Fe=oi(),this.Me=B.EMPTY_BYTE_STRING,this.xe=!1,this.Oe=!0}get current(){return this.xe}get resumeToken(){return this.Me}get Ne(){return this.ve!==0}get Be(){return this.Oe}Le(e){e.approximateByteSize()>0&&(this.Oe=!0,this.Me=e)}ke(){let e=J(),t=J(),n=J();return this.Fe.forEach(((r,i)=>{switch(i){case 0:e=e.add(r);break;case 2:t=t.add(r);break;case 1:n=n.add(r);break;default:b(38017,{changeType:i})}})),new $r(this.Me,this.xe,e,t,n)}qe(){this.Oe=!1,this.Fe=oi()}Qe(e,t){this.Oe=!0,this.Fe=this.Fe.insert(e,t)}$e(e){this.Oe=!0,this.Fe=this.Fe.remove(e)}Ue(){this.ve+=1}Ke(){--this.ve,x(this.ve>=0,3241,{ve:this.ve})}We(){this.Oe=!0,this.xe=!0}},ii=class{constructor(e){this.Ge=e,this.ze=new Map,this.je=Xn(),this.Je=ai(),this.He=ai(),this.Ye=new L(T)}Ze(e){for(let t of e.be)e.De&&e.De.isFoundDocument()?this.Xe(t,e.De):this.et(t,e.key,e.De);for(let t of e.removedTargetIds)this.et(t,e.key,e.De)}tt(e){this.forEachTarget(e,(t=>{let n=this.nt(t);switch(e.state){case 0:this.rt(t)&&n.Le(e.resumeToken);break;case 1:n.Ke(),n.Ne||n.qe(),n.Le(e.resumeToken);break;case 2:n.Ke(),n.Ne||this.removeTarget(t);break;case 3:this.rt(t)&&(n.We(),n.Le(e.resumeToken));break;case 4:this.rt(t)&&(this.it(t),n.Le(e.resumeToken));break;default:b(56790,{state:e.state})}}))}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.ze.forEach(((e,n)=>{this.rt(n)&&t(n)}))}st(e){let t=e.targetId,n=e.Ce.count,r=this.ot(t);if(r){let i=r.target;if(jn(i))if(n===0){let e=new A(i.path);this.et(t,e,W.newNoDocument(e,N.min()))}else x(n===1,20013,{expectedCount:n});else{let r=this._t(t);if(r!==n){let n=this.ut(e),i=n?this.ct(n,e,r):1;if(i!==0){this.it(t);let e=i===2?`TargetPurposeExistenceFilterMismatchBloom`:`TargetPurposeExistenceFilterMismatch`;this.Ye=this.Ye.insert(t,e)}Gr?.lt(function(e,t,n,r,i){let a={localCacheCount:e,existenceFilterCount:t.count,databaseId:n.database,projectId:n.projectId},o=t.unchangedNames;return o&&(a.bloomFilter={applied:i===0,hashCount:o?.hashCount??0,bitmapLength:o?.bits?.bitmap?.length??0,padding:o?.bits?.padding??0,mightContain:e=>r?.mightContain(e)??!1}),a}(r,e.Ce,this.Ge.ht(),n,i))}}}}ut(e){let t=e.Ce.unchangedNames;if(!t||!t.bits)return null;let{bits:{bitmap:n=``,padding:r=0},hashCount:i=0}=t,a,o;try{a=Et(n).toUint8Array()}catch(e){if(e instanceof Ct)return Ce(`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{o=new Xr(a,r,i)}catch(e){return Ce(e instanceof Zr?`BloomFilter error: `:`Applying bloom filter failed: `,e),null}return o.ge===0?null:o}ct(e,t,n){return t.Ce.count===n-this.Pt(e,t.targetId)?0:2}Pt(e,t){let n=this.Ge.getRemoteKeysForTarget(t),r=0;return n.forEach((n=>{let i=this.Ge.ht(),a=`projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;e.mightContain(a)||(this.et(t,n,null),r++)})),r}Tt(e){let t=new Map;this.ze.forEach(((n,r)=>{let i=this.ot(r);if(i){if(n.current&&jn(i.target)){let t=new A(i.target.path);this.It(t).has(r)||this.Et(r,t)||this.et(r,t,W.newNoDocument(t,e))}n.Be&&(t.set(r,n.ke()),n.qe())}}));let n=J();this.He.forEach(((e,t)=>{let r=!0;t.forEachWhile((e=>{let t=this.ot(e);return!t||t.purpose===`TargetPurposeLimboResolution`||(r=!1,!1)})),r&&(n=n.add(e))})),this.je.forEach(((t,n)=>n.setReadTime(e)));let r=new Qr(e,t,this.Ye,this.je,n);return this.je=Xn(),this.Je=ai(),this.He=ai(),this.Ye=new L(T),r}Xe(e,t){if(!this.rt(e))return;let n=this.Et(e,t.key)?2:0;this.nt(e).Qe(t.key,n),this.je=this.je.insert(t.key,t),this.Je=this.Je.insert(t.key,this.It(t.key).add(e)),this.He=this.He.insert(t.key,this.dt(t.key).add(e))}et(e,t,n){if(!this.rt(e))return;let r=this.nt(e);this.Et(e,t)?r.Qe(t,1):r.$e(t),this.He=this.He.insert(t,this.dt(t).delete(e)),this.He=this.He.insert(t,this.dt(t).add(e)),n&&(this.je=this.je.insert(t,n))}removeTarget(e){this.ze.delete(e)}_t(e){let t=this.nt(e).ke();return this.Ge.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}Ue(e){this.nt(e).Ue()}nt(e){let t=this.ze.get(e);return t||(t=new ri,this.ze.set(e,t)),t}dt(e){let t=this.He.get(e);return t||(t=new R(T),this.He=this.He.insert(e,t)),t}It(e){let t=this.Je.get(e);return t||(t=new R(T),this.Je=this.Je.insert(e,t)),t}rt(e){let t=this.ot(e)!==null;return t||y(`WatchChangeAggregator`,`Detected inactive target`,e),t}ot(e){let t=this.ze.get(e);return t&&t.Ne?null:this.Ge.At(e)}it(e){this.ze.set(e,new ri),this.Ge.getRemoteKeysForTarget(e).forEach((t=>{this.et(e,t,null)}))}Et(e,t){return this.Ge.getRemoteKeysForTarget(e).has(t)}};function ai(){return new L(A.comparator)}function oi(){return new L(A.comparator)}var si=(()=>({asc:`ASCENDING`,desc:`DESCENDING`}))(),ci=(()=>({"<":`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`}))(),li=(()=>({and:`AND`,or:`OR`}))(),ui=class{constructor(e,t){this.databaseId=e,this.useProto3Json=t}};function di(e,t){return e.useProto3Json||ut(t)?t:{value:t}}function fi(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 pi(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function mi(e,t){return fi(e,t.toTimestamp())}function hi(e){return x(!!e,49232),N.fromTimestamp(function(e){let t=Tt(e);return new M(t.seconds,t.nanos)}(e))}function gi(e,t){return _i(e,t).canonicalString()}function _i(e,t){let n=function(e){return new O([`projects`,e.projectId,`databases`,e.database])}(e).child(`documents`);return t===void 0?n:n.child(t)}function vi(e){let t=O.fromString(e);return x(Vi(t),10190,{key:t.toString()}),t}function yi(e,t){return gi(e.databaseId,t.path)}function bi(e,t){let n=vi(t);if(n.get(1)!==e.databaseId.projectId)throw new w(C.INVALID_ARGUMENT,`Tried to deserialize key from different project: `+n.get(1)+` vs `+e.databaseId.projectId);if(n.get(3)!==e.databaseId.database)throw new w(C.INVALID_ARGUMENT,`Tried to deserialize key from different database: `+n.get(3)+` vs `+e.databaseId.database);return new A(wi(n))}function xi(e,t){return gi(e.databaseId,t)}function Si(e){let t=vi(e);return t.length===4?O.emptyPath():wi(t)}function Ci(e){return new O([`projects`,e.databaseId.projectId,`databases`,e.databaseId.database]).canonicalString()}function wi(e){return x(e.length>4&&e.get(4)===`documents`,29091,{key:e.toString()}),e.popFirst(5)}function Ti(e,t,n){return{name:yi(e,t),fields:n.value.mapValue.fields}}function Ei(e,t){let n;if(`targetChange`in t){t.targetChange;let r=function(e){return e===`NO_CHANGE`?0:e===`ADD`?1:e===`REMOVE`?2:e===`CURRENT`?3:e===`RESET`?4:b(39313,{state:e})}(t.targetChange.targetChangeType||`NO_CHANGE`),i=t.targetChange.targetIds||[],a=function(e,t){return e.useProto3Json?(x(t===void 0||typeof t==`string`,58123),B.fromBase64String(t||``)):(x(t===void 0||t instanceof Buffer||t instanceof Uint8Array,16193),B.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),o=t.targetChange.cause,s=o&&function(e){let t=e.code===void 0?C.UNKNOWN:Wr(e.code);return new w(t,e.message||``)}(o);n=new ni(r,i,a,s||null)}else if(`documentChange`in t){t.documentChange;let r=t.documentChange;r.document,r.document.name,r.document.updateTime;let i=bi(e,r.document.name),a=hi(r.document.updateTime),o=r.document.createTime?hi(r.document.createTime):N.min(),s=new an({mapValue:{fields:r.document.fields}}),c=W.newFoundDocument(i,a,o,s),l=r.targetIds||[],u=r.removedTargetIds||[];n=new ei(l,u,c.key,c)}else if(`documentDelete`in t){t.documentDelete;let r=t.documentDelete;r.document;let i=bi(e,r.document),a=r.readTime?hi(r.readTime):N.min(),o=W.newNoDocument(i,a),s=r.removedTargetIds||[];n=new ei([],s,o.key,o)}else if(`documentRemove`in t){t.documentRemove;let r=t.documentRemove;r.document;let i=bi(e,r.document),a=r.removedTargetIds||[];n=new ei([],a,i,null)}else{if(!(`filter`in t))return b(11601,{Rt:t});{t.filter;let e=t.filter;e.targetId;let{count:r=0,unchangedNames:i}=e,a=new Hr(r,i),o=e.targetId;n=new ti(o,a)}}return n}function Di(e,t){let n;if(t instanceof Mr)n={update:Ti(e,t.key,t.value)};else if(t instanceof Lr)n={delete:yi(e,t.key)};else if(t instanceof Nr)n={update:Ti(e,t.key,t.data),updateMask:Bi(t.fieldMask)};else{if(!(t instanceof Rr))return b(16599,{Vt:t.type});n={verify:yi(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map((e=>function(e,t){let n=t.transform;if(n instanceof mr)return{fieldPath:t.field.canonicalString(),setToServerValue:`REQUEST_TIME`};if(n instanceof hr)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof _r)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof yr)return{fieldPath:t.field.canonicalString(),increment:n.Ae};throw b(20930,{transform:t.transform})}(0,e)))),t.precondition.isNone||(n.currentDocument=function(e,t){return t.updateTime===void 0?t.exists===void 0?b(27497):{exists:t.exists}:{updateTime:mi(e,t.updateTime)}}(e,t.precondition)),n}function Oi(e,t){return e&&e.length>0?(x(t!==void 0,14353),e.map((e=>function(e,t){let n=e.updateTime?hi(e.updateTime):hi(t);return n.isEqual(N.min())&&(n=hi(t)),new Cr(n,e.transformResults||[])}(e,t)))):[]}function ki(e,t){return{documents:[xi(e,t.path)]}}function Ai(e,t){let n={structuredQuery:{}},r=t.path,i;t.collectionGroup===null?(i=r.popLast(),n.structuredQuery.from=[{collectionId:r.lastSegment()}]):(i=r,n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]),n.parent=xi(e,i);let a=function(e){if(e.length!==0)return zi(fn.create(e,`and`))}(t.filters);a&&(n.structuredQuery.where=a);let o=function(e){if(e.length!==0)return e.map((e=>function(e){return{field:Li(e.field),direction:Pi(e.dir)}}(e)))}(t.orderBy);o&&(n.structuredQuery.orderBy=o);let s=di(e,t.limit);return s!==null&&(n.structuredQuery.limit=s),t.startAt&&(n.structuredQuery.startAt=function(e){return{before:e.inclusive,values:e.position}}(t.startAt)),t.endAt&&(n.structuredQuery.endAt=function(e){return{before:!e.inclusive,values:e.position}}(t.endAt)),{ft:n,parent:i}}function ji(e){let t=Si(e.parent),n=e.structuredQuery,r=n.from?n.from.length:0,i=null;if(r>0){x(r===1,65062);let e=n.from[0];e.allDescendants?i=e.collectionId:t=t.child(e.collectionId)}let a=[];n.where&&(a=function(e){let t=Ni(e);return t instanceof fn&&mn(t)?t.getFilters():[t]}(n.where));let o=[];n.orderBy&&(o=function(e){return e.map((e=>function(e){return new un(Ri(e.field),function(e){switch(e){case`ASCENDING`:return`asc`;case`DESCENDING`:return`desc`;default:return}}(e.direction))}(e)))}(n.orderBy));let s=null;n.limit&&(s=function(e){let t;return t=typeof e==`object`?e.value:e,ut(t)?null:t}(n.limit));let c=null;n.startAt&&(c=function(e){let t=!!e.before,n=e.values||[];return new sn(n,t)}(n.startAt));let l=null;return n.endAt&&(l=function(e){let t=!e.before,n=e.values||[];return new sn(n,t)}(n.endAt)),Nn(t,i,o,a,s,`F`,c,l)}function Mi(e,t){let n=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 b(28987,{purpose:e})}}(t.purpose);return n==null?null:{"goog-listen-tags":n}}function Ni(e){return e.unaryFilter===void 0?e.fieldFilter===void 0?e.compositeFilter===void 0?b(30097,{filter:e}):function(e){return fn.create(e.compositeFilter.filters.map((e=>Ni(e))),function(e){switch(e){case`AND`:return`and`;case`OR`:return`or`;default:return b(1026)}}(e.compositeFilter.op))}(e):function(e){return K.create(Ri(e.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 b(58110);default:return b(50506)}}(e.fieldFilter.op),e.fieldFilter.value)}(e):function(e){switch(e.unaryFilter.op){case`IS_NAN`:let t=Ri(e.unaryFilter.field);return K.create(t,`==`,{doubleValue:NaN});case`IS_NULL`:let n=Ri(e.unaryFilter.field);return K.create(n,`==`,{nullValue:`NULL_VALUE`});case`IS_NOT_NAN`:let r=Ri(e.unaryFilter.field);return K.create(r,`!=`,{doubleValue:NaN});case`IS_NOT_NULL`:let i=Ri(e.unaryFilter.field);return K.create(i,`!=`,{nullValue:`NULL_VALUE`});case`OPERATOR_UNSPECIFIED`:return b(61313);default:return b(60726)}}(e)}function Pi(e){return si[e]}function Fi(e){return ci[e]}function Ii(e){return li[e]}function Li(e){return{fieldPath:e.canonicalString()}}function Ri(e){return k.fromServerFormat(e.fieldPath)}function zi(e){return e instanceof K?function(e){if(e.op===`==`){if($t(e.value))return{unaryFilter:{field:Li(e.field),op:`IS_NAN`}};if(Qt(e.value))return{unaryFilter:{field:Li(e.field),op:`IS_NULL`}}}else if(e.op===`!=`){if($t(e.value))return{unaryFilter:{field:Li(e.field),op:`IS_NOT_NAN`}};if(Qt(e.value))return{unaryFilter:{field:Li(e.field),op:`IS_NOT_NULL`}}}return{fieldFilter:{field:Li(e.field),op:Fi(e.op),value:e.value}}}(e):e instanceof fn?function(e){let t=e.getFilters().map((e=>zi(e)));return t.length===1?t[0]:{compositeFilter:{op:Ii(e.op),filters:t}}}(e):b(54877,{filter:e})}function Bi(e){let t=[];return e.fields.forEach((e=>t.push(e.canonicalString()))),{fieldPaths:t}}function Vi(e){return e.length>=4&&e.get(0)===`projects`&&e.get(2)===`databases`}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Hi=class e{constructor(e,t,n,r,i=N.min(),a=N.min(),o=B.EMPTY_BYTE_STRING,s=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=a,this.resumeToken=o,this.expectedCount=s}withSequenceNumber(t){return new e(this.target,this.targetId,this.purpose,t,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(t,n){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,n,this.lastLimboFreeSnapshotVersion,t,null)}withExpectedCount(t){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,t)}withLastLimboFreeSnapshotVersion(t){return new e(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,t,this.resumeToken,this.expectedCount)}},Ui=class{constructor(e){this.yt=e}};function Wi(e){let t=ji({parent:e.parent,structuredQuery:e.structuredQuery});return e.limitType===`LAST`?Vn(t,t.limit,`L`):t}
/**
* @license
* Copyright 2021 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Gi=class{constructor(){}Dt(e,t){this.Ct(e,t),t.vt()}Ct(e,t){if(`nullValue`in e)this.Ft(t,5);else if(`booleanValue`in e)this.Ft(t,10),t.Mt(e.booleanValue?1:0);else if(`integerValue`in e)this.Ft(t,15),t.Mt(V(e.integerValue));else if(`doubleValue`in e){let n=V(e.doubleValue);isNaN(n)?this.Ft(t,13):(this.Ft(t,15),dt(n)?t.Mt(0):t.Mt(n))}else if(`timestampValue`in e){let n=e.timestampValue;this.Ft(t,20),typeof n==`string`&&(n=Tt(n)),t.xt(`${n.seconds||``}`),t.Mt(n.nanos||0)}else if(`stringValue`in e)this.Ot(e.stringValue,t),this.Nt(t);else if(`bytesValue`in e)this.Ft(t,30),t.Bt(Et(e.bytesValue)),this.Nt(t);else if(`referenceValue`in e)this.Lt(e.referenceValue,t);else if(`geoPointValue`in e){let n=e.geoPointValue;this.Ft(t,45),t.Mt(n.latitude||0),t.Mt(n.longitude||0)}else `mapValue`in e?rn(e)?this.Ft(t,2**53-1):tn(e)?this.kt(e.mapValue,t):(this.qt(e.mapValue,t),this.Nt(t)):`arrayValue`in e?(this.Qt(e.arrayValue,t),this.Nt(t)):b(19022,{$t:e})}Ot(e,t){this.Ft(t,25),this.Ut(e,t)}Ut(e,t){t.xt(e)}qt(e,t){let n=e.fields||{};this.Ft(t,55);for(let e of Object.keys(n))this.Ot(e,t),this.Ct(n[e],t)}kt(e,t){let n=e.fields||{};this.Ft(t,53);let r=zt,i=n[r].arrayValue?.values?.length||0;this.Ft(t,15),t.Mt(V(i)),this.Ot(r,t),this.Ct(n[r],t)}Qt(e,t){let n=e.values||[];this.Ft(t,50);for(let e of n)this.Ct(e,t)}Lt(e,t){this.Ft(t,37),A.fromName(e).path.forEach((e=>{this.Ft(t,60),this.Ut(e,t)}))}Ft(e,t){e.Mt(t)}Nt(e){e.Mt(2)}};Gi.Kt=new Gi;
/**
* @license
* Copyright 2019 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Ki=class{constructor(){this.Cn=new qi}addToCollectionParentIndex(e,t){return this.Cn.add(t),I.resolve()}getCollectionParents(e,t){return I.resolve(this.Cn.getEntries(t))}addFieldIndex(e,t){return I.resolve()}deleteFieldIndex(e,t){return I.resolve()}deleteAllFieldIndexes(e){return I.resolve()}createTargetIndexes(e,t){return I.resolve()}getDocumentsMatchingTarget(e,t){return I.resolve(null)}getIndexType(e,t){return I.resolve(0)}getFieldIndexes(e,t){return I.resolve([])}getNextCollectionGroupToUpdate(e){return I.resolve(null)}getMinOffset(e,t){return I.resolve(nt.min())}getMinOffsetFromCollectionGroup(e,t){return I.resolve(nt.min())}updateCollectionGroup(e,t,n){return I.resolve()}updateIndexEntries(e,t){return I.resolve()}},qi=class{constructor(){this.index={}}add(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new R(O.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}has(e){let t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}getEntries(e){return(this.index[e]||new R(O.comparator)).toArray()}};new Uint8Array;
/**
* @license
* Copyright 2018 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Ji={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},Yi=41943040,Xi=class e{static withCacheSize(t){return new e(t,e.DEFAULT_COLLECTION_PERCENTILE,e.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}};
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Xi.DEFAULT_COLLECTION_PERCENTILE=10,Xi.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,Xi.DEFAULT=new Xi(Yi,Xi.DEFAULT_COLLECTION_PERCENTILE,Xi.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),Xi.DISABLED=new Xi(-1,0,0);
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Zi=class e{constructor(e){this.ar=e}next(){return this.ar+=2,this.ar}static ur(){return new e(0)}static cr(){return new e(-1)}},Qi=`LruGarbageCollector`,$i=1048576;function ea([e,t],[n,r]){let i=T(e,n);return i===0?T(t,r):i}var ta=class{constructor(e){this.Ir=e,this.buffer=new R(ea),this.Er=0}dr(){return++this.Er}Ar(e){let t=[e,this.dr()];if(this.buffer.size<this.Ir)this.buffer=this.buffer.add(t);else{let e=this.buffer.last();ea(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}},na=class{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Rr=null}start(){this.garbageCollector.params.cacheSizeCollectionThreshold!==-1&&this.Vr(6e4)}stop(){this.Rr&&=(this.Rr.cancel(),null)}get started(){return this.Rr!==null}Vr(e){y(Qi,`Garbage collection scheduled in ${e}ms`),this.Rr=this.asyncQueue.enqueueAfterDelay(`lru_garbage_collection`,e,(async()=>{this.Rr=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){st(e)?y(Qi,`Ignoring IndexedDB error during garbage collection: `,e):await F(e)}await this.Vr(3e5)}))}},ra=class{constructor(e,t){this.mr=e,this.params=t}calculateTargetCount(e,t){return this.mr.gr(e).next((e=>Math.floor(t/100*e)))}nthSequenceNumber(e,t){if(t===0)return I.resolve(ct.ce);let n=new ta(t);return this.mr.forEachTarget(e,(e=>n.Ar(e.sequenceNumber))).next((()=>this.mr.pr(e,(e=>n.Ar(e))))).next((()=>n.maxValue))}removeTargets(e,t,n){return this.mr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.mr.removeOrphanedDocuments(e,t)}collect(e,t){return this.params.cacheSizeCollectionThreshold===-1?(y(`LruGarbageCollector`,`Garbage collection skipped; disabled`),I.resolve(Ji)):this.getCacheSize(e).next((n=>n<this.params.cacheSizeCollectionThreshold?(y(`LruGarbageCollector`,`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Ji):this.yr(e,t)))}getCacheSize(e){return this.mr.getCacheSize(e)}yr(e,t){let n,r,i,a,o,c,l,u=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next((t=>(t>this.params.maximumSequenceNumbersToCollect?(y(`LruGarbageCollector`,`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),r=this.params.maximumSequenceNumbersToCollect):r=t,a=Date.now(),this.nthSequenceNumber(e,r)))).next((r=>(n=r,o=Date.now(),this.removeTargets(e,n,t)))).next((t=>(i=t,c=Date.now(),this.removeOrphanedDocuments(e,n)))).next((e=>(l=Date.now(),xe()<=s.DEBUG&&y(`LruGarbageCollector`,`LRU Garbage Collection\n\tCounted targets in ${a-u}ms\n\tDetermined least recently used ${r} in `+(o-a)+`ms
\tRemoved ${i} targets in `+(c-o)+`ms
\tRemoved ${e} documents in `+(l-c)+`ms
Total Duration: ${l-u}ms`),I.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e}))))}};function ia(e,t){return new ra(e,t)}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var aa=class{constructor(){this.changes=new Jn((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,W.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();let n=this.changes.get(t);return n===void 0?this.getFromCache(e,t):I.resolve(n)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}assertNotApplied(){}},oa=class{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}},sa=class{constructor(e,t,n,r){this.remoteDocumentCache=e,this.mutationQueue=t,this.documentOverlayCache=n,this.indexManager=r}getDocument(e,t){let n=null;return this.documentOverlayCache.getOverlay(e,t).next((r=>(n=r,this.remoteDocumentCache.getEntry(e,t)))).next((e=>(n!==null&&kr(n.mutation,e,z.empty(),M.now()),e)))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.getLocalViewOfDocuments(e,t,J()).next((()=>t))))}getLocalViewOfDocuments(e,t,n=J()){let r=er();return this.populateOverlays(e,r,t).next((()=>this.computeViews(e,t,r,n).next((e=>{let t=Qn();return e.forEach(((e,n)=>{t=t.insert(e,n.overlayedDocument)})),t}))))}getOverlayedDocuments(e,t){let n=er();return this.populateOverlays(e,n,t).next((()=>this.computeViews(e,t,n,J())))}populateOverlays(e,t,n){let r=[];return n.forEach((e=>{t.has(e)||r.push(e)})),this.documentOverlayCache.getOverlays(e,r).next((e=>{e.forEach(((e,n)=>{t.set(e,n)}))}))}computeViews(e,t,n,r){let i=Xn(),a=nr(),o=function(){return nr()}();return t.forEach(((e,t)=>{let o=n.get(t.key);r.has(t.key)&&(o===void 0||o.mutation instanceof Nr)?i=i.insert(t.key,t):o===void 0?a.set(t.key,z.empty()):(a.set(t.key,o.mutation.getFieldMask()),kr(o.mutation,t,o.mutation.getFieldMask(),M.now()))})),this.recalculateAndSaveOverlays(e,i).next((e=>(e.forEach(((e,t)=>a.set(e,t))),t.forEach(((e,t)=>o.set(e,new oa(t,a.get(e)??null)))),o)))}recalculateAndSaveOverlays(e,t){let n=nr(),r=new L(((e,t)=>e-t)),i=J();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next((e=>{for(let i of e)i.keys().forEach((e=>{let a=t.get(e);if(a===null)return;let o=n.get(e)||z.empty();o=i.applyToLocalView(a,o),n.set(e,o);let s=(r.get(i.batchId)||J()).add(e);r=r.insert(i.batchId,s)}))})).next((()=>{let a=[],o=r.getReverseIterator();for(;o.hasNext();){let r=o.getNext(),s=r.key,c=r.value,l=tr();c.forEach((e=>{if(!i.has(e)){let r=Dr(t.get(e),n.get(e));r!==null&&l.set(e,r),i=i.add(e)}})),a.push(this.documentOverlayCache.saveOverlays(e,s,l))}return I.waitFor(a)})).next((()=>n))}recalculateAndSaveOverlaysForDocumentKeys(e,t){return this.remoteDocumentCache.getEntries(e,t).next((t=>this.recalculateAndSaveOverlays(e,t)))}getDocumentsMatchingQuery(e,t,n,r){return function(e){return A.isDocumentKey(e.path)&&e.collectionGroup===null&&e.filters.length===0}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):In(t)?this.getDocumentsMatchingCollectionGroupQuery(e,t,n,r):this.getDocumentsMatchingCollectionQuery(e,t,n,r)}getNextDocuments(e,t,n,r){return this.remoteDocumentCache.getAllFromCollectionGroup(e,t,n,r).next((i=>{let a=r-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-i.size):I.resolve(er()),o=$e,s=i;return a.next((t=>I.forEach(t,((t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),i.get(t)?I.resolve():this.remoteDocumentCache.getEntry(e,t).next((e=>{s=s.insert(t,e)}))))).next((()=>this.populateOverlays(e,t,i))).next((()=>this.computeViews(e,s,t,J()))).next((e=>({batchId:o,changes:$n(e)})))))}))}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new A(t)).next((e=>{let t=Qn();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t}))}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){let i=t.collectionGroup,a=Qn();return this.indexManager.getCollectionParents(e,i).next((o=>I.forEach(o,(o=>{let s=function(e,t){return new Mn(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,o.child(i));return this.getDocumentsMatchingCollectionQuery(e,s,n,r).next((e=>{e.forEach(((e,t)=>{a=a.insert(e,t)}))}))})).next((()=>a))))}getDocumentsMatchingCollectionQuery(e,t,n,r){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next((a=>(i=a,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,i,r)))).next((e=>{i.forEach(((t,n)=>{let r=n.getKey();e.get(r)===null&&(e=e.insert(r,W.newInvalidDocument(r)))}));let n=Qn();return e.forEach(((e,r)=>{let a=i.get(e);a!==void 0&&kr(a.mutation,r,z.empty(),M.now()),Wn(t,r)&&(n=n.insert(e,r))})),n}))}},ca=class{constructor(e){this.serializer=e,this.Lr=new Map,this.kr=new Map}getBundleMetadata(e,t){return I.resolve(this.Lr.get(t))}saveBundleMetadata(e,t){return this.Lr.set(t.id,function(e){return{id:e.id,version:e.version,createTime:hi(e.createTime)}}(t)),I.resolve()}getNamedQuery(e,t){return I.resolve(this.kr.get(t))}saveNamedQuery(e,t){return this.kr.set(t.name,function(e){return{name:e.name,query:Wi(e.bundledQuery),readTime:hi(e.readTime)}}(t)),I.resolve()}},la=class{constructor(){this.overlays=new L(A.comparator),this.qr=new Map}getOverlay(e,t){return I.resolve(this.overlays.get(t))}getOverlays(e,t){let n=er();return I.forEach(t,(t=>this.getOverlay(e,t).next((e=>{e!==null&&n.set(t,e)})))).next((()=>n))}saveOverlays(e,t,n){return n.forEach(((n,r)=>{this.St(e,t,r)})),I.resolve()}removeOverlaysForBatchId(e,t,n){let r=this.qr.get(n);return r!==void 0&&(r.forEach((e=>this.overlays=this.overlays.remove(e))),this.qr.delete(n)),I.resolve()}getOverlaysForCollection(e,t,n){let r=er(),i=t.length+1,a=new A(t.child(``)),o=this.overlays.getIteratorFrom(a);for(;o.hasNext();){let e=o.getNext().value,a=e.getKey();if(!t.isPrefixOf(a.path))break;a.path.length===i&&e.largestBatchId>n&&r.set(e.getKey(),e)}return I.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new L(((e,t)=>e-t)),a=this.overlays.getIterator();for(;a.hasNext();){let e=a.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=i.get(e.largestBatchId);t===null&&(t=er(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}let o=er(),s=i.getIterator();for(;s.hasNext()&&(s.getNext().value.forEach(((e,t)=>o.set(e,t))),!(o.size()>=r)););return I.resolve(o)}St(e,t,n){let r=this.overlays.get(n.key);if(r!==null){let e=this.qr.get(r.largestBatchId).delete(n.key);this.qr.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new Vr(t,n));let i=this.qr.get(t);i===void 0&&(i=J(),this.qr.set(t,i)),this.qr.set(t,i.add(n.key))}},ua=class{constructor(){this.sessionToken=B.EMPTY_BYTE_STRING}getSessionToken(e){return I.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,I.resolve()}},da=class{constructor(){this.Qr=new R(Z.$r),this.Ur=new R(Z.Kr)}isEmpty(){return this.Qr.isEmpty()}addReference(e,t){let n=new Z(e,t);this.Qr=this.Qr.add(n),this.Ur=this.Ur.add(n)}Wr(e,t){e.forEach((e=>this.addReference(e,t)))}removeReference(e,t){this.Gr(new Z(e,t))}zr(e,t){e.forEach((e=>this.removeReference(e,t)))}jr(e){let t=new A(new O([])),n=new Z(t,e),r=new Z(t,e+1),i=[];return this.Ur.forEachInRange([n,r],(e=>{this.Gr(e),i.push(e.key)})),i}Jr(){this.Qr.forEach((e=>this.Gr(e)))}Gr(e){this.Qr=this.Qr.delete(e),this.Ur=this.Ur.delete(e)}Hr(e){let t=new A(new O([])),n=new Z(t,e),r=new Z(t,e+1),i=J();return this.Ur.forEachInRange([n,r],(e=>{i=i.add(e.key)})),i}containsKey(e){let t=new Z(e,0),n=this.Qr.firstAfterOrEqual(t);return n!==null&&e.isEqual(n.key)}},Z=class{constructor(e,t){this.key=e,this.Yr=t}static $r(e,t){return A.comparator(e.key,t.key)||T(e.Yr,t.Yr)}static Kr(e,t){return T(e.Yr,t.Yr)||A.comparator(e.key,t.key)}},fa=class{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.tr=1,this.Zr=new R(Z.$r)}checkEmpty(e){return I.resolve(this.mutationQueue.length===0)}addMutationBatch(e,t,n,r){let i=this.tr;this.tr++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];let a=new zr(i,t,n,r);this.mutationQueue.push(a);for(let t of r)this.Zr=this.Zr.add(new Z(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return I.resolve(a)}lookupMutationBatch(e,t){return I.resolve(this.Xr(t))}getNextMutationBatchAfterBatchId(e,t){let n=t+1,r=this.ei(n),i=r<0?0:r;return I.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return I.resolve(this.mutationQueue.length===0?lt:this.tr-1)}getAllMutationBatches(e){return I.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){let n=new Z(t,0),r=new Z(t,1/0),i=[];return this.Zr.forEachInRange([n,r],(e=>{let t=this.Xr(e.Yr);i.push(t)})),I.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new R(T);return t.forEach((e=>{let t=new Z(e,0),r=new Z(e,1/0);this.Zr.forEachInRange([t,r],(e=>{n=n.add(e.Yr)}))})),I.resolve(this.ti(n))}getAllMutationBatchesAffectingQuery(e,t){let n=t.path,r=n.length+1,i=n;A.isDocumentKey(i)||(i=i.child(``));let a=new Z(new A(i),0),o=new R(T);return this.Zr.forEachWhile((e=>{let t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.Yr)),!0)}),a),I.resolve(this.ti(o))}ti(e){let t=[];return e.forEach((e=>{let n=this.Xr(e);n!==null&&t.push(n)})),t}removeMutationBatch(e,t){x(this.ni(t.batchId,`removed`)===0,55003),this.mutationQueue.shift();let n=this.Zr;return I.forEach(t.mutations,(r=>{let i=new Z(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)})).next((()=>{this.Zr=n}))}ir(e){}containsKey(e,t){let n=new Z(t,0),r=this.Zr.firstAfterOrEqual(n);return I.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,I.resolve()}ni(e,t){return this.ei(e)}ei(e){return this.mutationQueue.length===0?0:e-this.mutationQueue[0].batchId}Xr(e){let t=this.ei(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}},pa=class{constructor(e){this.ri=e,this.docs=function(){return new L(A.comparator)}(),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){let n=t.key,r=this.docs.get(n),i=r?r.size:0,a=this.ri(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:a}),this.size+=a-i,this.indexManager.addToCollectionParentIndex(e,n.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 n=this.docs.get(t);return I.resolve(n?n.document.mutableCopy():W.newInvalidDocument(t))}getEntries(e,t){let n=Xn();return t.forEach((e=>{let t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():W.newInvalidDocument(e))})),I.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let i=Xn(),a=t.path,o=new A(a.child(`__id-9223372036854775808__`)),s=this.docs.getIteratorFrom(o);for(;s.hasNext();){let{key:e,value:{document:o}}=s.getNext();if(!a.isPrefixOf(e.path))break;e.path.length>a.length+1||rt(tt(o),n)<=0||(r.has(o.key)||Wn(t,o))&&(i=i.insert(o.key,o.mutableCopy()))}return I.resolve(i)}getAllFromCollectionGroup(e,t,n,r){b(9500)}ii(e,t){return I.forEach(this.docs,(e=>t(e)))}newChangeBuffer(e){return new ma(this)}getSize(e){return I.resolve(this.size)}},ma=class extends aa{constructor(e){super(),this.Nr=e}applyChanges(e){let t=[];return this.changes.forEach(((n,r)=>{r.isValidDocument()?t.push(this.Nr.addEntry(e,r)):this.Nr.removeEntry(n)})),I.waitFor(t)}getFromCache(e,t){return this.Nr.getEntry(e,t)}getAllFromCache(e,t){return this.Nr.getEntries(e,t)}},ha=class{constructor(e){this.persistence=e,this.si=new Jn((e=>kn(e)),An),this.lastRemoteSnapshotVersion=N.min(),this.highestTargetId=0,this.oi=0,this._i=new da,this.targetCount=0,this.ai=Zi.ur()}forEachTarget(e,t){return this.si.forEach(((e,n)=>t(n))),I.resolve()}getLastRemoteSnapshotVersion(e){return I.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return I.resolve(this.oi)}allocateTargetId(e){return this.highestTargetId=this.ai.next(),I.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.oi&&(this.oi=t),I.resolve()}Pr(e){this.si.set(e.target,e);let t=e.targetId;t>this.highestTargetId&&(this.ai=new Zi(t),this.highestTargetId=t),e.sequenceNumber>this.oi&&(this.oi=e.sequenceNumber)}addTargetData(e,t){return this.Pr(t),this.targetCount+=1,I.resolve()}updateTargetData(e,t){return this.Pr(t),I.resolve()}removeTargetData(e,t){return this.si.delete(t.target),this._i.jr(t.targetId),--this.targetCount,I.resolve()}removeTargets(e,t,n){let r=0,i=[];return this.si.forEach(((a,o)=>{o.sequenceNumber<=t&&n.get(o.targetId)===null&&(this.si.delete(a),i.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)})),I.waitFor(i).next((()=>r))}getTargetCount(e){return I.resolve(this.targetCount)}getTargetData(e,t){let n=this.si.get(t)||null;return I.resolve(n)}addMatchingKeys(e,t,n){return this._i.Wr(t,n),I.resolve()}removeMatchingKeys(e,t,n){this._i.zr(t,n);let r=this.persistence.referenceDelegate,i=[];return r&&t.forEach((t=>{i.push(r.markPotentiallyOrphaned(e,t))})),I.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this._i.jr(t),I.resolve()}getMatchingKeysForTargetId(e,t){let n=this._i.Hr(t);return I.resolve(n)}containsKey(e,t){return I.resolve(this._i.containsKey(t))}},ga=class{constructor(e,t){this.ui={},this.overlays={},this.ci=new ct(0),this.li=!1,this.li=!0,this.hi=new ua,this.referenceDelegate=e(this),this.Pi=new ha(this),this.indexManager=new Ki,this.remoteDocumentCache=function(e){return new pa(e)}((e=>this.referenceDelegate.Ti(e))),this.serializer=new Ui(t),this.Ii=new ca(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.li=!1,Promise.resolve()}get started(){return this.li}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new la,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.ui[e.toKey()];return n||(n=new fa(t,this.referenceDelegate),this.ui[e.toKey()]=n),n}getGlobalsCache(){return this.hi}getTargetCache(){return this.Pi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ii}runTransaction(e,t,n){y(`MemoryPersistence`,`Starting transaction:`,e);let r=new _a(this.ci.next());return this.referenceDelegate.Ei(),n(r).next((e=>this.referenceDelegate.di(r).next((()=>e)))).toPromise().then((e=>(r.raiseOnCommittedEvent(),e)))}Ai(e,t){return I.or(Object.values(this.ui).map((n=>()=>n.containsKey(e,t))))}},_a=class extends at{constructor(e){super(),this.currentSequenceNumber=e}},va=class e{constructor(e){this.persistence=e,this.Ri=new da,this.Vi=null}static mi(t){return new e(t)}get fi(){if(this.Vi)return this.Vi;throw b(60996)}addReference(e,t,n){return this.Ri.addReference(n,t),this.fi.delete(n.toString()),I.resolve()}removeReference(e,t,n){return this.Ri.removeReference(n,t),this.fi.add(n.toString()),I.resolve()}markPotentiallyOrphaned(e,t){return this.fi.add(t.toString()),I.resolve()}removeTarget(e,t){this.Ri.jr(t.targetId).forEach((e=>this.fi.add(e.toString())));let n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next((e=>{e.forEach((e=>this.fi.add(e.toString())))})).next((()=>n.removeTargetData(e,t)))}Ei(){this.Vi=new Set}di(e){let t=this.persistence.getRemoteDocumentCache().newChangeBuffer();return I.forEach(this.fi,(n=>{let r=A.fromPath(n);return this.gi(e,r).next((e=>{e||t.removeEntry(r,N.min())}))})).next((()=>(this.Vi=null,t.apply(e))))}updateLimboDocument(e,t){return this.gi(e,t).next((e=>{e?this.fi.delete(t.toString()):this.fi.add(t.toString())}))}Ti(e){return 0}gi(e,t){return I.or([()=>I.resolve(this.Ri.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ai(e,t)])}},ya=class e{constructor(e,t){this.persistence=e,this.pi=new Jn((e=>mt(e.path)),((e,t)=>e.isEqual(t))),this.garbageCollector=ia(this,t)}static mi(t,n){return new e(t,n)}Ei(){}di(e){return I.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}gr(e){let t=this.wr(e);return this.persistence.getTargetCache().getTargetCount(e).next((e=>t.next((t=>e+t))))}wr(e){let t=0;return this.pr(e,(e=>{t++})).next((()=>t))}pr(e,t){return I.forEach(this.pi,((n,r)=>this.br(e,n,r).next((e=>e?I.resolve():t(r)))))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0,r=this.persistence.getRemoteDocumentCache(),i=r.newChangeBuffer();return r.ii(e,(r=>this.br(e,r,t).next((e=>{e||(n++,i.removeEntry(r,N.min()))})))).next((()=>i.apply(e))).next((()=>n))}markPotentiallyOrphaned(e,t){return this.pi.set(t,e.currentSequenceNumber),I.resolve()}removeTarget(e,t){let n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.pi.set(n,e.currentSequenceNumber),I.resolve()}removeReference(e,t,n){return this.pi.set(n,e.currentSequenceNumber),I.resolve()}updateLimboDocument(e,t){return this.pi.set(t,e.currentSequenceNumber),I.resolve()}Ti(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Jt(e.data.value)),t}br(e,t,n){return I.or([()=>this.persistence.Ai(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{let e=this.pi.get(t);return I.resolve(e!==void 0&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}},ba=class e{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.Es=n,this.ds=r}static As(t,n){let r=J(),i=J();for(let e of n.docChanges)switch(e.type){case 0:r=r.add(e.doc.key);break;case 1:i=i.add(e.doc.key)}return new e(t,n.fromCache,r,i)}},xa=class{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}},Sa=class{constructor(){this.Rs=!1,this.Vs=!1,this.fs=100,this.gs=function(){return t()?8:ot(i())>0?6:4}()}initialize(e,t){this.ps=e,this.indexManager=t,this.Rs=!0}getDocumentsMatchingQuery(e,t,n,r){let i={result:null};return this.ys(e,t).next((e=>{i.result=e})).next((()=>{if(!i.result)return this.ws(e,t,r,n).next((e=>{i.result=e}))})).next((()=>{if(i.result)return;let n=new xa;return this.Ss(e,t,n).next((r=>{if(i.result=r,this.Vs)return this.bs(e,t,n,r.size)}))})).next((()=>i.result))}bs(e,t,n,r){return n.documentReadCount<this.fs?(xe()<=s.DEBUG&&y(`QueryEngine`,`SDK will not create cache indexes for query:`,Un(t),`since it only creates cache indexes for collection contains`,`more than or equal to`,this.fs,`documents`),I.resolve()):(xe()<=s.DEBUG&&y(`QueryEngine`,`Query:`,Un(t),`scans`,n.documentReadCount,`local documents and returns`,r,`documents as results.`),n.documentReadCount>this.gs*r?(xe()<=s.DEBUG&&y(`QueryEngine`,`The SDK decides to create cache indexes for query:`,Un(t),`as using cache indexes may help improve performance.`),this.indexManager.createTargetIndexes(e,Rn(t))):I.resolve())}ys(e,t){if(Fn(t))return I.resolve(null);let n=Rn(t);return this.indexManager.getIndexType(e,n).next((r=>r===0?null:(t.limit!==null&&r===1&&(t=Vn(t,null,`F`),n=Rn(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next((r=>{let i=J(...r);return this.ps.getDocuments(e,i).next((r=>this.indexManager.getMinOffset(e,n).next((n=>{let a=this.Ds(t,r);return this.Cs(t,a,i,n.readTime)?this.ys(e,Vn(t,null,`F`)):this.vs(e,a,t,n)}))))})))))}ws(e,t,n,r){return Fn(t)||r.isEqual(N.min())?I.resolve(null):this.ps.getDocuments(e,n).next((i=>{let a=this.Ds(t,i);return this.Cs(t,a,n,r)?I.resolve(null):(xe()<=s.DEBUG&&y(`QueryEngine`,`Re-using previous result from %s to execute query: %s`,r.toString(),Un(t)),this.vs(e,a,t,P(r,$e)).next((e=>e)))}))}Ds(e,t){let n=new R(Kn(e));return t.forEach(((t,r)=>{Wn(e,r)&&(n=n.add(r))})),n}Cs(e,t,n,r){if(e.limit===null)return!1;if(n.size!==t.size)return!0;let i=e.limitType===`F`?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}Ss(e,t,n){return xe()<=s.DEBUG&&y(`QueryEngine`,`Using full collection scan to execute query:`,Un(t)),this.ps.getDocumentsMatchingQuery(e,t,nt.min(),n)}vs(e,t,n,r){return this.ps.getDocumentsMatchingQuery(e,n,r).next((e=>(t.forEach((t=>{e=e.insert(t.key,t)})),e)))}},Ca=`LocalStore`,wa=3e8,Ta=class{constructor(e,t,n,r){this.persistence=e,this.Fs=t,this.serializer=r,this.Ms=new L(T),this.xs=new Jn((e=>kn(e)),An),this.Os=new Map,this.Ns=e.getRemoteDocumentCache(),this.Pi=e.getTargetCache(),this.Ii=e.getBundleCache(),this.Bs(n)}Bs(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new sa(this.Ns,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Ns.setIndexManager(this.indexManager),this.Fs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction(`Collect garbage`,`readwrite-primary`,(t=>e.collect(t,this.Ms)))}};function Ea(e,t,n,r){return new Ta(e,t,n,r)}async function Da(e,t){let n=S(e);return await n.persistence.runTransaction(`Handle user change`,`readonly`,(e=>{let r;return n.mutationQueue.getAllMutationBatches(e).next((i=>(r=i,n.Bs(t),n.mutationQueue.getAllMutationBatches(e)))).next((t=>{let i=[],a=[],o=J();for(let e of r){i.push(e.batchId);for(let t of e.mutations)o=o.add(t.key)}for(let e of t){a.push(e.batchId);for(let t of e.mutations)o=o.add(t.key)}return n.localDocuments.getDocuments(e,o).next((e=>({Ls:e,removedBatchIds:i,addedBatchIds:a})))}))}))}function Oa(e,t){let n=S(e);return n.persistence.runTransaction(`Acknowledge batch`,`readwrite-primary`,(e=>{let r=t.batch.keys(),i=n.Ns.newChangeBuffer({trackRemovals:!0});return function(e,t,n,r){let i=n.batch,a=i.keys(),o=I.resolve();return a.forEach((e=>{o=o.next((()=>r.getEntry(t,e))).next((t=>{let a=n.docVersions.get(e);x(a!==null,48541),t.version.compareTo(a)<0&&(i.applyToRemoteDocument(t,n),t.isValidDocument()&&(t.setReadTime(n.commitVersion),r.addEntry(t)))}))})),o.next((()=>e.mutationQueue.removeMutationBatch(t,i)))}(n,e,t,i).next((()=>i.apply(e))).next((()=>n.mutationQueue.performConsistencyCheck(e))).next((()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t.batch.batchId))).next((()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,function(e){let t=J();for(let n=0;n<e.mutationResults.length;++n)e.mutationResults[n].transformResults.length>0&&(t=t.add(e.batch.mutations[n].key));return t}(t)))).next((()=>n.localDocuments.getDocuments(e,r)))}))}function ka(e){let t=S(e);return t.persistence.runTransaction(`Get last remote snapshot version`,`readonly`,(e=>t.Pi.getLastRemoteSnapshotVersion(e)))}function Aa(e,t){let n=S(e),r=t.snapshotVersion,i=n.Ms;return n.persistence.runTransaction(`Apply remote event`,`readwrite-primary`,(e=>{let a=n.Ns.newChangeBuffer({trackRemovals:!0});i=n.Ms;let o=[];t.targetChanges.forEach(((a,s)=>{let c=i.get(s);if(!c)return;o.push(n.Pi.removeMatchingKeys(e,a.removedDocuments,s).next((()=>n.Pi.addMatchingKeys(e,a.addedDocuments,s))));let l=c.withSequenceNumber(e.currentSequenceNumber);t.targetMismatches.get(s)===null?a.resumeToken.approximateByteSize()>0&&(l=l.withResumeToken(a.resumeToken,r)):l=l.withResumeToken(B.EMPTY_BYTE_STRING,N.min()).withLastLimboFreeSnapshotVersion(N.min()),i=i.insert(s,l),function(e,t,n){return e.resumeToken.approximateByteSize()===0||t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=wa?!0:n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0}(c,l,a)&&o.push(n.Pi.updateTargetData(e,l))}));let s=Xn(),c=J();if(t.documentUpdates.forEach((r=>{t.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))})),o.push(ja(e,a,t.documentUpdates).next((e=>{s=e.ks,c=e.qs}))),!r.isEqual(N.min())){let t=n.Pi.getLastRemoteSnapshotVersion(e).next((t=>n.Pi.setTargetsMetadata(e,e.currentSequenceNumber,r)));o.push(t)}return I.waitFor(o).next((()=>a.apply(e))).next((()=>n.localDocuments.getLocalViewOfDocuments(e,s,c))).next((()=>s))})).then((e=>(n.Ms=i,e)))}function ja(e,t,n){let r=J(),i=J();return n.forEach((e=>r=r.add(e))),t.getEntries(e,r).next((e=>{let r=Xn();return n.forEach(((n,a)=>{let o=e.get(n);a.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),a.isNoDocument()&&a.version.isEqual(N.min())?(t.removeEntry(n,a.readTime),r=r.insert(n,a)):!o.isValidDocument()||a.version.compareTo(o.version)>0||a.version.compareTo(o.version)===0&&o.hasPendingWrites?(t.addEntry(a),r=r.insert(n,a)):y(Ca,`Ignoring outdated watch update for `,n,`. Current version:`,o.version,` Watch version:`,a.version)})),{ks:r,qs:i}}))}function Ma(e,t){let n=S(e);return n.persistence.runTransaction(`Get next mutation batch`,`readonly`,(e=>(t===void 0&&(t=lt),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t))))}function Na(e,t){let n=S(e);return n.persistence.runTransaction(`Allocate target`,`readwrite`,(e=>{let r;return n.Pi.getTargetData(e,t).next((i=>i?(r=i,I.resolve(r)):n.Pi.allocateTargetId(e).next((i=>(r=new Hi(t,i,`TargetPurposeListen`,e.currentSequenceNumber),n.Pi.addTargetData(e,r).next((()=>r)))))))})).then((e=>{let r=n.Ms.get(e.targetId);return(r===null||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.Ms=n.Ms.insert(e.targetId,e),n.xs.set(t,e.targetId)),e}))}async function Pa(e,t,n){let r=S(e),i=r.Ms.get(t),a=n?`readwrite`:`readwrite-primary`;try{n||await r.persistence.runTransaction(`Release target`,a,(e=>r.persistence.referenceDelegate.removeTarget(e,i)))}catch(e){if(!st(e))throw e;y(Ca,`Failed to update sequence numbers for target ${t}: ${e}`)}r.Ms=r.Ms.remove(t),r.xs.delete(i.target)}function Fa(e,t,n){let r=S(e),i=N.min(),a=J();return r.persistence.runTransaction(`Execute query`,`readwrite`,(e=>function(e,t,n){let r=S(e),i=r.xs.get(n);return i===void 0?r.Pi.getTargetData(t,n):I.resolve(r.Ms.get(i))}(r,e,Rn(t)).next((t=>{if(t)return i=t.lastLimboFreeSnapshotVersion,r.Pi.getMatchingKeysForTargetId(e,t.targetId).next((e=>{a=e}))})).next((()=>r.Fs.getDocumentsMatchingQuery(e,t,n?i:N.min(),n?a:J()))).next((e=>(Ia(r,Gn(t),e),{documents:e,Qs:a})))))}function Ia(e,t,n){let r=e.Os.get(t)||N.min();n.forEach(((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)})),e.Os.set(t,r)}var La=class{constructor(){this.activeTargetIds=or()}zs(e){this.activeTargetIds=this.activeTargetIds.add(e)}js(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Gs(){let e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}},Ra=class{constructor(){this.Mo=new La,this.xo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.Mo.zs(e),this.xo[e]||`not-current`}updateQueryState(e,t,n){this.xo[e]=t}removeLocalQueryTarget(e){this.Mo.js(e)}isLocalQueryTarget(e){return this.Mo.activeTargetIds.has(e)}clearQueryState(e){delete this.xo[e]}getAllActiveQueryTargets(){return this.Mo.activeTargetIds}isActiveQueryTarget(e){return this.Mo.activeTargetIds.has(e)}start(){return this.Mo=new La,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}},za=class{Oo(e){}shutdown(){}},Ba=`ConnectivityMonitor`,Va=class{constructor(){this.No=()=>this.Bo(),this.Lo=()=>this.ko(),this.qo=[],this.Qo()}Oo(e){this.qo.push(e)}shutdown(){window.removeEventListener(`online`,this.No),window.removeEventListener(`offline`,this.Lo)}Qo(){window.addEventListener(`online`,this.No),window.addEventListener(`offline`,this.Lo)}Bo(){y(Ba,`Network connectivity changed: AVAILABLE`);for(let e of this.qo)e(0)}ko(){y(Ba,`Network connectivity changed: UNAVAILABLE`);for(let e of this.qo)e(1)}static v(){return typeof window<`u`&&window.addEventListener!==void 0&&window.removeEventListener!==void 0}},Ha=null;function Ua(){return Ha===null?Ha=function(){return 268435456+Math.round(2147483648*Math.random())}():Ha++,`0x`+Ha.toString(16)}
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Wa=`RestConnection`,Ga={BatchGetDocuments:`batchGet`,Commit:`commit`,RunQuery:`runQuery`,RunAggregationQuery:`runAggregationQuery`},Ka=class{get $o(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;let t=e.ssl?`https`:`http`,n=encodeURIComponent(this.databaseId.projectId),r=encodeURIComponent(this.databaseId.database);this.Uo=t+`://`+e.host,this.Ko=`projects/${n}/databases/${r}`,this.Wo=this.databaseId.database===Pt?`project_id=${n}`:`project_id=${n}&database_id=${r}`}Go(e,t,n,r,i){let a=Ua(),o=this.zo(e,t.toUriEncodedString());y(Wa,`Sending RPC '${e}' ${a}:`,o,n);let s={"google-cloud-resource-prefix":this.Ko,"x-goog-request-params":this.Wo};this.jo(s,r,i);let{host:c}=new URL(o),l=ne(c);return this.Jo(e,o,s,n,l).then((t=>(y(Wa,`Received RPC '${e}' ${a}: `,t),t)),(t=>{throw Ce(Wa,`RPC '${e}' ${a} failed with error: `,t,`url: `,o,`request:`,n),t}))}Ho(e,t,n,r,i,a){return this.Go(e,t,n,r,i)}jo(e,t,n){e[`X-Goog-Api-Client`]=function(){return`gl-js/ fire/`+ye}(),e[`Content-Type`]=`text/plain`,this.databaseInfo.appId&&(e[`X-Firebase-GMPID`]=this.databaseInfo.appId),t&&t.headers.forEach(((t,n)=>e[n]=t)),n&&n.headers.forEach(((t,n)=>e[n]=t))}zo(e,t){let n=Ga[e];return`${this.Uo}/v1/${t}:${n}`}terminate(){}},qa=class{constructor(e){this.Yo=e.Yo,this.Zo=e.Zo}Xo(e){this.e_=e}t_(e){this.n_=e}r_(e){this.i_=e}onMessage(e){this.s_=e}close(){this.Zo()}send(e){this.Yo(e)}o_(){this.e_()}__(){this.n_()}a_(e){this.i_(e)}u_(e){this.s_(e)}},Q=`WebChannelConnection`,Ja=class extends Ka{constructor(e){super(e),this.c_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}Jo(e,t,n,r,i){let a=Ua();return new Promise(((i,o)=>{let s=new le;s.setWithCredentials(!0),s.listenOnce(de.COMPLETE,(()=>{try{switch(s.getLastErrorCode()){case fe.NO_ERROR:let t=s.getResponseJson();y(Q,`XHR for RPC '${e}' ${a} received:`,JSON.stringify(t)),i(t);break;case fe.TIMEOUT:y(Q,`RPC '${e}' ${a} timed out`),o(new w(C.DEADLINE_EXCEEDED,`Request time out`));break;case fe.HTTP_ERROR:let n=s.getStatus();if(y(Q,`RPC '${e}' ${a} failed with status:`,n,`response text:`,s.getResponseText()),n>0){let e=s.getResponseJson();Array.isArray(e)&&(e=e[0]);let t=e?.error;if(t&&t.status&&t.message){let e=function(e){let t=e.toLowerCase().replace(/_/g,`-`);return Object.values(C).indexOf(t)>=0?t:C.UNKNOWN}(t.status);o(new w(e,t.message))}else o(new w(C.UNKNOWN,`Server responded with status `+s.getStatus()))}else o(new w(C.UNAVAILABLE,`Connection failed.`));break;default:b(9055,{l_:e,streamId:a,h_:s.getLastErrorCode(),P_:s.getLastError()})}}finally{y(Q,`RPC '${e}' ${a} completed.`)}}));let c=JSON.stringify(r);y(Q,`RPC '${e}' ${a} sending request:`,r),s.send(t,`POST`,c,n,15)}))}T_(e,t,n){let r=Ua(),i=[this.Uo,`/`,`google.firestore.v1.Firestore`,`/`,e,`/channel`],a=ge(),o=he(),s={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},c=this.longPollingOptions.timeoutSeconds;c!==void 0&&(s.longPollingTimeout=Math.round(1e3*c)),this.useFetchStreams&&(s.useFetchStreams=!0),this.jo(s.initMessageHeaders,t,n),s.encodeInitMessageHeaders=!0;let l=i.join(``);y(Q,`Creating RPC '${e}' stream ${r}: ${l}`,s);let u=a.createWebChannel(l,s);this.I_(u);let d=!1,f=!1,p=new qa({Yo:t=>{f?y(Q,`Not sending because RPC '${e}' stream ${r} is closed:`,t):(d||=(y(Q,`Opening RPC '${e}' stream ${r} transport.`),u.open(),!0),y(Q,`RPC '${e}' stream ${r} sending:`,t),u.send(t))},Zo:()=>u.close()}),m=(e,t,n)=>{e.listen(t,(e=>{try{n(e)}catch(e){setTimeout((()=>{throw e}),0)}}))};return m(u,ue.EventType.OPEN,(()=>{f||(y(Q,`RPC '${e}' stream ${r} transport opened.`),p.o_())})),m(u,ue.EventType.CLOSE,(()=>{f||(f=!0,y(Q,`RPC '${e}' stream ${r} transport closed`),p.a_(),this.E_(u))})),m(u,ue.EventType.ERROR,(t=>{f||(f=!0,Ce(Q,`RPC '${e}' stream ${r} transport errored. Name:`,t.name,`Message:`,t.message),p.a_(new w(C.UNAVAILABLE,`The operation could not be completed`)))})),m(u,ue.EventType.MESSAGE,(t=>{if(!f){let n=t.data[0];x(!!n,16349);let i=n,a=i?.error||i[0]?.error;if(a){y(Q,`RPC '${e}' stream ${r} received error:`,a);let t=a.status,n=function(e){let t=Y[e];if(t!==void 0)return Wr(t)}(t),i=a.message;n===void 0&&(n=C.INTERNAL,i=`Unknown error status: `+t+` with message `+a.message),f=!0,p.a_(new w(n,i)),u.close()}else y(Q,`RPC '${e}' stream ${r} received:`,n),p.u_(n)}})),m(o,me.STAT_EVENT,(t=>{t.stat===pe.PROXY?y(Q,`RPC '${e}' stream ${r} detected buffering proxy`):t.stat===pe.NOPROXY&&y(Q,`RPC '${e}' stream ${r} detected no buffering proxy`)})),setTimeout((()=>{p.__()}),0),p}terminate(){this.c_.forEach((e=>e.close())),this.c_=[]}I_(e){this.c_.push(e)}E_(e){this.c_=this.c_.filter((t=>t===e))}};function Ya(){return typeof document<`u`?document:null}
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Xa(e){return new ui(e,!0)}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Za=class{constructor(e,t,n=1e3,r=1.5,i=6e4){this.Mi=e,this.timerId=t,this.d_=n,this.A_=r,this.R_=i,this.V_=0,this.m_=null,this.f_=Date.now(),this.reset()}reset(){this.V_=0}g_(){this.V_=this.R_}p_(e){this.cancel();let t=Math.floor(this.V_+this.y_()),n=Math.max(0,Date.now()-this.f_),r=Math.max(0,t-n);r>0&&y(`ExponentialBackoff`,`Backing off for ${r} ms (base delay: ${this.V_} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.m_=this.Mi.enqueueAfterDelay(this.timerId,r,(()=>(this.f_=Date.now(),e()))),this.V_*=this.A_,this.V_<this.d_&&(this.V_=this.d_),this.V_>this.R_&&(this.V_=this.R_)}w_(){this.m_!==null&&(this.m_.skipDelay(),this.m_=null)}cancel(){this.m_!==null&&(this.m_.cancel(),this.m_=null)}y_(){return(Math.random()-.5)*this.V_}},Qa=`PersistentStream`,$a=class{constructor(e,t,n,r,i,a,o,s){this.Mi=e,this.S_=n,this.b_=r,this.connection=i,this.authCredentialsProvider=a,this.appCheckCredentialsProvider=o,this.listener=s,this.state=0,this.D_=0,this.C_=null,this.v_=null,this.stream=null,this.F_=0,this.M_=new Za(e,t)}x_(){return this.state===1||this.state===5||this.O_()}O_(){return this.state===2||this.state===3}start(){this.F_=0,this.state===4?this.N_():this.auth()}async stop(){this.x_()&&await this.close(0)}B_(){this.state=0,this.M_.reset()}L_(){this.O_()&&this.C_===null&&(this.C_=this.Mi.enqueueAfterDelay(this.S_,6e4,(()=>this.k_())))}q_(e){this.Q_(),this.stream.send(e)}async k_(){if(this.O_())return this.close(0)}Q_(){this.C_&&=(this.C_.cancel(),null)}U_(){this.v_&&=(this.v_.cancel(),null)}async close(e,t){this.Q_(),this.U_(),this.M_.cancel(),this.D_++,e===4?t&&t.code===C.RESOURCE_EXHAUSTED?(Se(t.toString()),Se(`Using maximum backoff delay to prevent overloading the backend.`),this.M_.g_()):t&&t.code===C.UNAUTHENTICATED&&this.state!==3&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()):this.M_.reset(),this.stream!==null&&(this.K_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.r_(t)}K_(){}auth(){this.state=1;let e=this.W_(this.D_),t=this.D_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then((([e,n])=>{this.D_===t&&this.G_(e,n)}),(t=>{e((()=>{let e=new w(C.UNKNOWN,`Fetching auth token failed: `+t.message);return this.z_(e)}))}))}G_(e,t){let n=this.W_(this.D_);this.stream=this.j_(e,t),this.stream.Xo((()=>{n((()=>this.listener.Xo()))})),this.stream.t_((()=>{n((()=>(this.state=2,this.v_=this.Mi.enqueueAfterDelay(this.b_,1e4,(()=>(this.O_()&&(this.state=3),Promise.resolve()))),this.listener.t_())))})),this.stream.r_((e=>{n((()=>this.z_(e)))})),this.stream.onMessage((e=>{n((()=>++this.F_==1?this.J_(e):this.onNext(e)))}))}N_(){this.state=5,this.M_.p_((async()=>{this.state=0,this.start()}))}z_(e){return y(Qa,`close with error: ${e}`),this.stream=null,this.close(4,e)}W_(e){return t=>{this.Mi.enqueueAndForget((()=>this.D_===e?t():(y(Qa,`stream callback skipped by getCloseGuardedDispatcher.`),Promise.resolve())))}}},eo=class extends $a{constructor(e,t,n,r,i,a){super(e,`listen_stream_connection_backoff`,`listen_stream_idle`,`health_check_timeout`,t,n,r,a),this.serializer=i}j_(e,t){return this.connection.T_(`Listen`,e,t)}J_(e){return this.onNext(e)}onNext(e){this.M_.reset();let t=Ei(this.serializer,e),n=function(e){if(!(`targetChange`in e))return N.min();let t=e.targetChange;return t.targetIds&&t.targetIds.length?N.min():t.readTime?hi(t.readTime):N.min()}(e);return this.listener.H_(t,n)}Y_(e){let t={};t.database=Ci(this.serializer),t.addTarget=function(e,t){let n,r=t.target;if(n=jn(r)?{documents:ki(e,r)}:{query:Ai(e,r).ft},n.targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=pi(e,t.resumeToken);let r=di(e,t.expectedCount);r!==null&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(N.min())>0){n.readTime=fi(e,t.snapshotVersion.toTimestamp());let r=di(e,t.expectedCount);r!==null&&(n.expectedCount=r)}return n}(this.serializer,e);let n=Mi(this.serializer,e);n&&(t.labels=n),this.q_(t)}Z_(e){let t={};t.database=Ci(this.serializer),t.removeTarget=e,this.q_(t)}},to=class extends $a{constructor(e,t,n,r,i,a){super(e,`write_stream_connection_backoff`,`write_stream_idle`,`health_check_timeout`,t,n,r,a),this.serializer=i}get X_(){return this.F_>0}start(){this.lastStreamToken=void 0,super.start()}K_(){this.X_&&this.ea([])}j_(e,t){return this.connection.T_(`Write`,e,t)}J_(e){return x(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,x(!e.writeResults||e.writeResults.length===0,55816),this.listener.ta()}onNext(e){x(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.M_.reset();let t=Oi(e.writeResults,e.commitTime),n=hi(e.commitTime);return this.listener.na(n,t)}ra(){let e={};e.database=Ci(this.serializer),this.q_(e)}ea(e){let t={streamToken:this.lastStreamToken,writes:e.map((e=>Di(this.serializer,e)))};this.q_(t)}},no=class{},ro=class extends no{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=r,this.ia=!1}sa(){if(this.ia)throw new w(C.FAILED_PRECONDITION,`The client has already been terminated.`)}Go(e,t,n,r){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([i,a])=>this.connection.Go(e,_i(t,n),r,i,a))).catch((e=>{throw e.name===`FirebaseError`?(e.code===C.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new w(C.UNKNOWN,e.toString())}))}Ho(e,t,n,r,i){return this.sa(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then((([a,o])=>this.connection.Ho(e,_i(t,n),r,a,o,i))).catch((e=>{throw e.name===`FirebaseError`?(e.code===C.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new w(C.UNKNOWN,e.toString())}))}terminate(){this.ia=!0,this.connection.terminate()}},io=class{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state=`Unknown`,this.oa=0,this._a=null,this.aa=!0}ua(){this.oa===0&&(this.ca(`Unknown`),this._a=this.asyncQueue.enqueueAfterDelay(`online_state_timeout`,1e4,(()=>(this._a=null,this.la(`Backend didn't respond within 10 seconds.`),this.ca(`Offline`),Promise.resolve()))))}ha(e){this.state===`Online`?this.ca(`Unknown`):(this.oa++,this.oa>=1&&(this.Pa(),this.la(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ca(`Offline`)))}set(e){this.Pa(),this.oa=0,e===`Online`&&(this.aa=!1),this.ca(e)}ca(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}la(e){let t=`Could not reach Cloud Firestore backend. ${e}\nThis typically indicates that your device does not have a healthy Internet connection at the moment. The client will operate in offline mode until it is able to successfully connect to the backend.`;this.aa?(Se(t),this.aa=!1):y(`OnlineStateTracker`,t)}Pa(){this._a!==null&&(this._a.cancel(),this._a=null)}},ao=`RemoteStore`,oo=class{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Ta=[],this.Ia=new Map,this.Ea=new Set,this.da=[],this.Aa=i,this.Aa.Oo((e=>{n.enqueueAndForget((async()=>{go(this)&&(y(ao,`Restarting streams for network reachability change.`),await async function(e){let t=S(e);t.Ea.add(4),await co(t),t.Ra.set(`Unknown`),t.Ea.delete(4),await so(t)}(this))}))})),this.Ra=new io(n,r)}};async function so(e){if(go(e))for(let t of e.da)await t(!0)}async function co(e){for(let t of e.da)await t(!1)}function lo(e,t){let n=S(e);n.Ia.has(t.targetId)||(n.Ia.set(t.targetId,t),ho(n)?mo(n):Fo(n).O_()&&fo(n,t))}function uo(e,t){let n=S(e),r=Fo(n);n.Ia.delete(t),r.O_()&&po(n,t),n.Ia.size===0&&(r.O_()?r.L_():go(n)&&n.Ra.set(`Unknown`))}function fo(e,t){if(e.Va.Ue(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(N.min())>0){let n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}Fo(e).Y_(t)}function po(e,t){e.Va.Ue(t),Fo(e).Z_(t)}function mo(e){e.Va=new ii({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),At:t=>e.Ia.get(t)||null,ht:()=>e.datastore.serializer.databaseId}),Fo(e).start(),e.Ra.ua()}function ho(e){return go(e)&&!Fo(e).x_()&&e.Ia.size>0}function go(e){return S(e).Ea.size===0}function _o(e){e.Va=void 0}async function vo(e){e.Ra.set(`Online`)}async function yo(e){e.Ia.forEach(((t,n)=>{fo(e,t)}))}async function bo(e,t){_o(e),ho(e)?(e.Ra.ha(t),mo(e)):e.Ra.set(`Unknown`)}async function xo(e,t,n){if(e.Ra.set(`Online`),t instanceof ni&&t.state===2&&t.cause)try{await async function(e,t){let n=t.cause;for(let r of t.targetIds)e.Ia.has(r)&&(await e.remoteSyncer.rejectListen(r,n),e.Ia.delete(r),e.Va.removeTarget(r))}(e,t)}catch(n){y(ao,`Failed to remove targets %s: %s `,t.targetIds.join(`,`),n),await So(e,n)}else if(t instanceof ei?e.Va.Ze(t):t instanceof ti?e.Va.st(t):e.Va.tt(t),!n.isEqual(N.min()))try{let t=await ka(e.localStore);n.compareTo(t)>=0&&await function(e,t){let n=e.Va.Tt(t);return n.targetChanges.forEach(((n,r)=>{if(n.resumeToken.approximateByteSize()>0){let i=e.Ia.get(r);i&&e.Ia.set(r,i.withResumeToken(n.resumeToken,t))}})),n.targetMismatches.forEach(((t,n)=>{let r=e.Ia.get(t);if(!r)return;e.Ia.set(t,r.withResumeToken(B.EMPTY_BYTE_STRING,r.snapshotVersion)),po(e,t);let i=new Hi(r.target,t,n,r.sequenceNumber);fo(e,i)})),e.remoteSyncer.applyRemoteEvent(n)}(e,n)}catch(t){y(ao,`Failed to raise snapshot:`,t),await So(e,t)}}async function So(e,t,n){if(!st(t))throw t;e.Ea.add(1),await co(e),e.Ra.set(`Offline`),n||=()=>ka(e.localStore),e.asyncQueue.enqueueRetryable((async()=>{y(ao,`Retrying IndexedDB access`),await n(),e.Ea.delete(1),await so(e)}))}function Co(e,t){return t().catch((n=>So(e,n,t)))}async function wo(e){let t=S(e),n=Io(t),r=t.Ta.length>0?t.Ta[t.Ta.length-1].batchId:lt;for(;To(t);)try{let e=await Ma(t.localStore,r);if(e===null){t.Ta.length===0&&n.L_();break}r=e.batchId,Eo(t,e)}catch(e){await So(t,e)}Do(t)&&Oo(t)}function To(e){return go(e)&&e.Ta.length<10}function Eo(e,t){e.Ta.push(t);let n=Io(e);n.O_()&&n.X_&&n.ea(t.mutations)}function Do(e){return go(e)&&!Io(e).x_()&&e.Ta.length>0}function Oo(e){Io(e).start()}async function ko(e){Io(e).ra()}async function Ao(e){let t=Io(e);for(let n of e.Ta)t.ea(n.mutations)}async function jo(e,t,n){let r=e.Ta.shift(),i=Br.from(r,t,n);await Co(e,(()=>e.remoteSyncer.applySuccessfulWrite(i))),await wo(e)}async function Mo(e,t){t&&Io(e).X_&&await async function(e,t){if(function(e){return Ur(e)&&e!==C.ABORTED}(t.code)){let n=e.Ta.shift();Io(e).B_(),await Co(e,(()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t))),await wo(e)}}(e,t),Do(e)&&Oo(e)}async function No(e,t){let n=S(e);n.asyncQueue.verifyOperationInProgress(),y(ao,`RemoteStore received new credentials`);let r=go(n);n.Ea.add(3),await co(n),r&&n.Ra.set(`Unknown`),await n.remoteSyncer.handleCredentialChange(t),n.Ea.delete(3),await so(n)}async function Po(e,t){let n=S(e);t?(n.Ea.delete(2),await so(n)):t||(n.Ea.add(2),await co(n),n.Ra.set(`Unknown`))}function Fo(e){return e.ma||(e.ma=function(e,t,n){let r=S(e);return r.sa(),new eo(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Xo:vo.bind(null,e),t_:yo.bind(null,e),r_:bo.bind(null,e),H_:xo.bind(null,e)}),e.da.push((async t=>{t?(e.ma.B_(),ho(e)?mo(e):e.Ra.set(`Unknown`)):(await e.ma.stop(),_o(e))}))),e.ma}function Io(e){return e.fa||(e.fa=function(e,t,n){let r=S(e);return r.sa(),new to(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Xo:()=>Promise.resolve(),t_:ko.bind(null,e),r_:Mo.bind(null,e),ta:Ao.bind(null,e),na:jo.bind(null,e)}),e.da.push((async t=>{t?(e.fa.B_(),await wo(e)):(await e.fa.stop(),e.Ta.length>0&&(y(ao,`Stopping write stream with ${e.Ta.length} pending writes`),e.Ta=[]))}))),e.fa}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Lo=class e{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new Ee,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch((e=>{}))}get promise(){return this.deferred.promise}static createAndSchedule(t,n,r,i,a){let o=Date.now()+r,s=new e(t,n,o,i,a);return s.start(r),s}start(e){this.timerHandle=setTimeout((()=>this.handleDelayElapsed()),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){this.timerHandle!==null&&(this.clearTimeout(),this.deferred.reject(new w(C.CANCELLED,`Operation cancelled`+(e?`: `+e:``))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget((()=>this.timerHandle===null?Promise.resolve():(this.clearTimeout(),this.op().then((e=>this.deferred.resolve(e))))))}clearTimeout(){this.timerHandle!==null&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}};function Ro(e,t){if(Se(`AsyncQueue`,`${t}: ${e}`),st(e))return new w(C.UNAVAILABLE,`${t}: ${e}`);throw e}
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var zo=class e{static emptySet(t){return new e(t.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||A.comparator(t.key,n.key):(e,t)=>A.comparator(e.key,t.key),this.keyedMap=Qn(),this.sortedSet=new L(this.comparator)}has(e){return this.keyedMap.get(e)!=null}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,n)=>(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(t){if(!(t instanceof e)||this.size!==t.size)return!1;let n=this.sortedSet.getIterator(),r=t.sortedSet.getIterator();for(;n.hasNext();){let e=n.getNext().key,t=r.getNext().key;if(!e.isEqual(t))return!1}return!0}toString(){let e=[];return this.forEach((t=>{e.push(t.toString())})),e.length===0?`DocumentSet ()`:`DocumentSet (
`+e.join(`
`)+`
)`}copy(t,n){let r=new e;return r.comparator=this.comparator,r.keyedMap=t,r.sortedSet=n,r}},Bo=class{constructor(){this.ga=new L(A.comparator)}track(e){let t=e.doc.key,n=this.ga.get(t);n?e.type!==0&&n.type===3?this.ga=this.ga.insert(t,e):e.type===3&&n.type!==1?this.ga=this.ga.insert(t,{type:n.type,doc:e.doc}):e.type===2&&n.type===2?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):e.type===2&&n.type===0?this.ga=this.ga.insert(t,{type:0,doc:e.doc}):e.type===1&&n.type===0?this.ga=this.ga.remove(t):e.type===1&&n.type===2?this.ga=this.ga.insert(t,{type:1,doc:n.doc}):e.type===0&&n.type===1?this.ga=this.ga.insert(t,{type:2,doc:e.doc}):b(63341,{Rt:e,pa:n}):this.ga=this.ga.insert(t,e)}ya(){let e=[];return this.ga.inorderTraversal(((t,n)=>{e.push(n)})),e}},Vo=class e{constructor(e,t,n,r,i,a,o,s,c){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=a,this.syncStateChanged=o,this.excludesMetadataChanges=s,this.hasCachedResults=c}static fromInitialDocuments(t,n,r,i,a){let o=[];return n.forEach((e=>{o.push({type:0,doc:e})})),new e(t,n,zo.emptySet(n),o,r,i,!0,!1,a)}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)&&Hn(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;let t=this.docChanges,n=e.docChanges;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e].type!==n[e].type||!t[e].doc.isEqual(n[e].doc))return!1;return!0}},Ho=class{constructor(){this.wa=void 0,this.Sa=[]}ba(){return this.Sa.some((e=>e.Da()))}},Uo=class{constructor(){this.queries=Wo(),this.onlineState=`Unknown`,this.Ca=new Set}terminate(){(function(e,t){let n=S(e),r=n.queries;n.queries=Wo(),r.forEach(((e,n)=>{for(let e of n.Sa)e.onError(t)}))})(this,new w(C.ABORTED,`Firestore shutting down`))}};function Wo(){return new Jn((e=>q(e)),Hn)}async function Go(e,t){let n=S(e),r=3,i=t.query,a=n.queries.get(i);a?!a.ba()&&t.Da()&&(r=2):(a=new Ho,r=t.Da()?0:1);try{switch(r){case 0:a.wa=await n.onListen(i,!0);break;case 1:a.wa=await n.onListen(i,!1);break;case 2:await n.onFirstRemoteStoreListen(i)}}catch(e){let n=Ro(e,`Initialization of query '${Un(t.query)}' failed`);t.onError(n);return}n.queries.set(i,a),a.Sa.push(t),t.va(n.onlineState),a.wa&&t.Fa(a.wa)&&Yo(n)}async function Ko(e,t){let n=S(e),r=t.query,i=3,a=n.queries.get(r);if(a){let e=a.Sa.indexOf(t);e>=0&&(a.Sa.splice(e,1),a.Sa.length===0?i=t.Da()?0:1:!a.ba()&&t.Da()&&(i=2))}switch(i){case 0:return n.queries.delete(r),n.onUnlisten(r,!0);case 1:return n.queries.delete(r),n.onUnlisten(r,!1);case 2:return n.onLastRemoteStoreUnlisten(r);default:return}}function qo(e,t){let n=S(e),r=!1;for(let e of t){let t=e.query,i=n.queries.get(t);if(i){for(let t of i.Sa)t.Fa(e)&&(r=!0);i.wa=e}}r&&Yo(n)}function Jo(e,t,n){let r=S(e),i=r.queries.get(t);if(i)for(let e of i.Sa)e.onError(n);r.queries.delete(t)}function Yo(e){e.Ca.forEach((e=>{e.next()}))}var Xo,Zo;(Zo=Xo||={}).Ma=`default`,Zo.Cache=`cache`;var Qo=class{constructor(e,t,n){this.query=e,this.xa=t,this.Oa=!1,this.Na=null,this.onlineState=`Unknown`,this.options=n||{}}Fa(e){if(!this.options.includeMetadataChanges){let t=[];for(let n of e.docChanges)n.type!==3&&t.push(n);e=new Vo(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.Oa?this.Ba(e)&&(this.xa.next(e),t=!0):this.La(e,this.onlineState)&&(this.ka(e),t=!0),this.Na=e,t}onError(e){this.xa.error(e)}va(e){this.onlineState=e;let t=!1;return this.Na&&!this.Oa&&this.La(this.Na,e)&&(this.ka(this.Na),t=!0),t}La(e,t){if(!e.fromCache||!this.Da())return!0;let n=t!==`Offline`;return(!this.options.qa||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||t===`Offline`)}Ba(e){if(e.docChanges.length>0)return!0;let t=this.Na&&this.Na.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}ka(e){e=Vo.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.Oa=!0,this.xa.next(e)}Da(){return this.options.source!==Xo.Cache}},$o=class{constructor(e){this.key=e}},es=class{constructor(e){this.key=e}},ts=class{constructor(e,t){this.query=e,this.Ya=t,this.Za=null,this.hasCachedResults=!1,this.current=!1,this.Xa=J(),this.mutatedKeys=J(),this.eu=Kn(e),this.tu=new zo(this.eu)}get nu(){return this.Ya}ru(e,t){let n=t?t.iu:new Bo,r=t?t.tu:this.tu,i=t?t.mutatedKeys:this.mutatedKeys,a=r,o=!1,s=this.query.limitType===`F`&&r.size===this.query.limit?r.last():null,c=this.query.limitType===`L`&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal(((e,t)=>{let l=r.get(e),u=Wn(this.query,t)?t:null,d=!!l&&this.mutatedKeys.has(l.key),f=!!u&&(u.hasLocalMutations||this.mutatedKeys.has(u.key)&&u.hasCommittedMutations),p=!1;l&&u?l.data.isEqual(u.data)?d!==f&&(n.track({type:3,doc:u}),p=!0):this.su(l,u)||(n.track({type:2,doc:u}),p=!0,(s&&this.eu(u,s)>0||c&&this.eu(u,c)<0)&&(o=!0)):!l&&u?(n.track({type:0,doc:u}),p=!0):l&&!u&&(n.track({type:1,doc:l}),p=!0,(s||c)&&(o=!0)),p&&(u?(a=a.add(u),i=f?i.add(e):i.delete(e)):(a=a.delete(e),i=i.delete(e)))})),this.query.limit!==null)for(;a.size>this.query.limit;){let e=this.query.limitType===`F`?a.last():a.first();a=a.delete(e.key),i=i.delete(e.key),n.track({type:1,doc:e})}return{tu:a,iu:n,Cs:o,mutatedKeys:i}}su(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){let i=this.tu;this.tu=e.tu,this.mutatedKeys=e.mutatedKeys;let a=e.iu.ya();a.sort(((e,t)=>function(e,t){let n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return b(20277,{Rt:e})}};return n(e)-n(t)}(e.type,t.type)||this.eu(e.doc,t.doc))),this.ou(n),r??=!1;let o=t&&!r?this._u():[],s=this.Xa.size===0&&this.current&&!r?1:0,c=s!==this.Za;return this.Za=s,a.length!==0||c?{snapshot:new Vo(this.query,e.tu,i,a,e.mutatedKeys,s===0,c,!1,!!n&&n.resumeToken.approximateByteSize()>0),au:o}:{au:o}}va(e){return this.current&&e===`Offline`?(this.current=!1,this.applyChanges({tu:this.tu,iu:new Bo,mutatedKeys:this.mutatedKeys,Cs:!1},!1)):{au:[]}}uu(e){return!this.Ya.has(e)&&!!this.tu.has(e)&&!this.tu.get(e).hasLocalMutations}ou(e){e&&(e.addedDocuments.forEach((e=>this.Ya=this.Ya.add(e))),e.modifiedDocuments.forEach((e=>{})),e.removedDocuments.forEach((e=>this.Ya=this.Ya.delete(e))),this.current=e.current)}_u(){if(!this.current)return[];let e=this.Xa;this.Xa=J(),this.tu.forEach((e=>{this.uu(e.key)&&(this.Xa=this.Xa.add(e.key))}));let t=[];return e.forEach((e=>{this.Xa.has(e)||t.push(new es(e))})),this.Xa.forEach((n=>{e.has(n)||t.push(new $o(n))})),t}cu(e){this.Ya=e.Qs,this.Xa=J();let t=this.ru(e.documents);return this.applyChanges(t,!0)}lu(){return Vo.fromInitialDocuments(this.query,this.tu,this.mutatedKeys,this.Za===0,this.hasCachedResults)}},ns=`SyncEngine`,rs=class{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}},os=class{constructor(e){this.key=e,this.hu=!1}},ss=class{constructor(e,t,n,r,i,a){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=a,this.Pu={},this.Tu=new Jn((e=>q(e)),Hn),this.Iu=new Map,this.Eu=new Set,this.du=new L(A.comparator),this.Au=new Map,this.Ru=new da,this.Vu={},this.mu=new Map,this.fu=Zi.cr(),this.onlineState=`Unknown`,this.gu=void 0}get isPrimaryClient(){return!0===this.gu}};async function cs(e,t,n=!0){let r=As(e),i,a=r.Tu.get(t);return a?(r.sharedClientState.addLocalQueryTarget(a.targetId),i=a.view.lu()):i=await us(r,t,n,!0),i}async function ls(e,t){let n=As(e);await us(n,t,!0,!1)}async function us(e,t,n,r){let i=await Na(e.localStore,Rn(t)),a=i.targetId,o=e.sharedClientState.addLocalQueryTarget(a,n),s;return r&&(s=await ds(e,t,a,o===`current`,i.resumeToken)),e.isPrimaryClient&&n&&lo(e.remoteStore,i),s}async function ds(e,t,n,r,i){e.pu=(t,n,r)=>async function(e,t,n,r){let i=t.view.ru(n);i.Cs&&(i=await Fa(e.localStore,t.query,!1).then((({documents:e})=>t.view.ru(e,i))));let a=r&&r.targetChanges.get(t.targetId),o=r&&r.targetMismatches.get(t.targetId)!=null,s=t.view.applyChanges(i,e.isPrimaryClient,a,o);return ws(e,t.targetId,s.au),s.snapshot}(e,t,n,r);let a=await Fa(e.localStore,t,!0),o=new ts(t,a.Qs),s=o.ru(a.documents),c=$r.createSynthesizedTargetChangeForCurrentChange(n,r&&e.onlineState!==`Offline`,i),l=o.applyChanges(s,e.isPrimaryClient,c);ws(e,n,l.au);let u=new rs(t,n,o);return e.Tu.set(t,u),e.Iu.has(n)?e.Iu.get(n).push(t):e.Iu.set(n,[t]),l.snapshot}async function fs(e,t,n){let r=S(e),i=r.Tu.get(t),a=r.Iu.get(i.targetId);if(a.length>1)return r.Iu.set(i.targetId,a.filter((e=>!Hn(e,t)))),void r.Tu.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedClientState.isActiveQueryTarget(i.targetId)||await Pa(r.localStore,i.targetId,!1).then((()=>{r.sharedClientState.clearQueryState(i.targetId),n&&uo(r.remoteStore,i.targetId),Ss(r,i.targetId)})).catch(F)):(Ss(r,i.targetId),await Pa(r.localStore,i.targetId,!0))}async function ps(e,t){let n=S(e),r=n.Tu.get(t),i=n.Iu.get(r.targetId);n.isPrimaryClient&&i.length===1&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),uo(n.remoteStore,r.targetId))}async function ms(e,t,n){let r=js(e);try{let e=await function(e,t){let n=S(e),r=M.now(),i=t.reduce(((e,t)=>e.add(t.key)),J()),a,o;return n.persistence.runTransaction(`Locally write mutations`,`readwrite`,(e=>{let s=Xn(),c=J();return n.Ns.getEntries(e,i).next((e=>{s=e,s.forEach(((e,t)=>{t.isValidDocument()||(c=c.add(e))}))})).next((()=>n.localDocuments.getOverlayedDocuments(e,s))).next((i=>{a=i;let o=[];for(let e of t){let t=Ar(e,a.get(e.key).overlayedDocument);t!=null&&o.push(new Nr(e.key,t,on(t.value.mapValue),wr.exists(!0)))}return n.mutationQueue.addMutationBatch(e,r,o,t)})).next((t=>{o=t;let r=t.applyToLocalDocumentSet(a,c);return n.documentOverlayCache.saveOverlays(e,t.batchId,r)}))})).then((()=>({batchId:o.batchId,changes:$n(a)})))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.Vu[e.currentUser.toKey()];r||=new L(T),r=r.insert(t,n),e.Vu[e.currentUser.toKey()]=r}(r,e.batchId,n),await Ds(r,e.changes),await wo(r.remoteStore)}catch(e){let t=Ro(e,`Failed to persist write`);n.reject(t)}}async function hs(e,t){let n=S(e);try{let e=await Aa(n.localStore,t);t.targetChanges.forEach(((e,t)=>{let r=n.Au.get(t);r&&(x(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1,22616),e.addedDocuments.size>0?r.hu=!0:e.modifiedDocuments.size>0?x(r.hu,14607):e.removedDocuments.size>0&&(x(r.hu,42227),r.hu=!1))})),await Ds(n,e,t)}catch(e){await F(e)}}function gs(e,t,n){let r=S(e);if(r.isPrimaryClient&&n===0||!r.isPrimaryClient&&n===1){let e=[];r.Tu.forEach(((n,r)=>{let i=r.view.va(t);i.snapshot&&e.push(i.snapshot)})),function(e,t){let n=S(e);n.onlineState=t;let r=!1;n.queries.forEach(((e,n)=>{for(let e of n.Sa)e.va(t)&&(r=!0)})),r&&Yo(n)}(r.eventManager,t),e.length&&r.Pu.H_(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function _s(e,t,n){let r=S(e);r.sharedClientState.updateQueryState(t,`rejected`,n);let i=r.Au.get(t),a=i&&i.key;if(a){let e=new L(A.comparator);e=e.insert(a,W.newNoDocument(a,N.min()));let n=J().add(a),i=new Qr(N.min(),new Map,new L(T),e,n);await hs(r,i),r.du=r.du.remove(a),r.Au.delete(t),Es(r)}else await Pa(r.localStore,t,!1).then((()=>Ss(r,t,n))).catch(F)}async function vs(e,t){let n=S(e),r=t.batch.batchId;try{let e=await Oa(n.localStore,t);xs(n,r,null),bs(n,r),n.sharedClientState.updateMutationState(r,`acknowledged`),await Ds(n,e)}catch(e){await F(e)}}async function ys(e,t,n){let r=S(e);try{let e=await function(e,t){let n=S(e);return n.persistence.runTransaction(`Reject batch`,`readwrite-primary`,(e=>{let r;return n.mutationQueue.lookupMutationBatch(e,t).next((t=>(x(t!==null,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)))}))}(r.localStore,t);xs(r,t,n),bs(r,t),r.sharedClientState.updateMutationState(t,`rejected`,n),await Ds(r,e)}catch(e){await F(e)}}function bs(e,t){(e.mu.get(t)||[]).forEach((e=>{e.resolve()})),e.mu.delete(t)}function xs(e,t,n){let r=S(e),i=r.Vu[r.currentUser.toKey()];if(i){let e=i.get(t);e&&(n?e.reject(n):e.resolve(),i=i.remove(t)),r.Vu[r.currentUser.toKey()]=i}}function Ss(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(let r of e.Iu.get(t))e.Tu.delete(r),n&&e.Pu.yu(r,n);e.Iu.delete(t),e.isPrimaryClient&&e.Ru.jr(t).forEach((t=>{e.Ru.containsKey(t)||Cs(e,t)}))}function Cs(e,t){e.Eu.delete(t.path.canonicalString());let n=e.du.get(t);n!==null&&(uo(e.remoteStore,n),e.du=e.du.remove(t),e.Au.delete(n),Es(e))}function ws(e,t,n){for(let r of n)r instanceof $o?(e.Ru.addReference(r.key,t),Ts(e,r)):r instanceof es?(y(ns,`Document no longer in limbo: `+r.key),e.Ru.removeReference(r.key,t),e.Ru.containsKey(r.key)||Cs(e,r.key)):b(19791,{wu:r})}function Ts(e,t){let n=t.key,r=n.path.canonicalString();e.du.get(n)||e.Eu.has(r)||(y(ns,`New document in limbo: `+n),e.Eu.add(r),Es(e))}function Es(e){for(;e.Eu.size>0&&e.du.size<e.maxConcurrentLimboResolutions;){let t=e.Eu.values().next().value;e.Eu.delete(t);let n=new A(O.fromString(t)),r=e.fu.next();e.Au.set(r,new os(n)),e.du=e.du.insert(n,r),lo(e.remoteStore,new Hi(Rn(Pn(n.path)),r,`TargetPurposeLimboResolution`,ct.ce))}}async function Ds(e,t,n){let r=S(e),i=[],a=[],o=[];r.Tu.isEmpty()||(r.Tu.forEach(((e,s)=>{o.push(r.pu(s,t,n).then((e=>{if((e||n)&&r.isPrimaryClient){let t=e?!e.fromCache:n?.targetChanges.get(s.targetId)?.current;r.sharedClientState.updateQueryState(s.targetId,t?`current`:`not-current`)}if(e){i.push(e);let t=ba.As(s.targetId,e);a.push(t)}})))})),await Promise.all(o),r.Pu.H_(i),await async function(e,t){let n=S(e);try{await n.persistence.runTransaction(`notifyLocalViewChanges`,`readwrite`,(e=>I.forEach(t,(t=>I.forEach(t.Es,(r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r))).next((()=>I.forEach(t.ds,(r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))))))}catch(e){if(!st(e))throw e;y(Ca,`Failed to update sequence numbers: `+e)}for(let e of t){let t=e.targetId;if(!e.fromCache){let e=n.Ms.get(t),r=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(r);n.Ms=n.Ms.insert(t,i)}}}(r.localStore,a))}async function Os(e,t){let n=S(e);if(!n.currentUser.isEqual(t)){y(ns,`User change. New user:`,t.toKey());let e=await Da(n.localStore,t);n.currentUser=t,function(e,t){e.mu.forEach((e=>{e.forEach((e=>{e.reject(new w(C.CANCELLED,t))}))})),e.mu.clear()}(n,`'waitForPendingWrites' promise is rejected due to a user change.`),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await Ds(n,e.Ls)}}function ks(e,t){let n=S(e),r=n.Au.get(t);if(r&&r.hu)return J().add(r.key);{let e=J(),r=n.Iu.get(t);if(!r)return e;for(let t of r){let r=n.Tu.get(t);e=e.unionWith(r.view.nu)}return e}}function As(e){let t=S(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=hs.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=ks.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=_s.bind(null,t),t.Pu.H_=qo.bind(null,t.eventManager),t.Pu.yu=Jo.bind(null,t.eventManager),t}function js(e){let t=S(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=vs.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=ys.bind(null,t),t}var Ms=class{constructor(){this.kind=`memory`,this.synchronizeTabs=!1}async initialize(e){this.serializer=Xa(e.databaseInfo.databaseId),this.sharedClientState=this.Du(e),this.persistence=this.Cu(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Fu(e,this.localStore),this.indexBackfillerScheduler=this.Mu(e,this.localStore)}Fu(e,t){return null}Mu(e,t){return null}vu(e){return Ea(this.persistence,new Sa,e.initialUser,this.serializer)}Cu(e){return new ga(va.mi,this.serializer)}Du(e){return new Ra}async terminate(){this.gcScheduler?.stop(),this.indexBackfillerScheduler?.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}};Ms.provider={build:()=>new Ms};var Ns=class extends Ms{constructor(e){super(),this.cacheSizeBytes=e}Fu(e,t){x(this.persistence.referenceDelegate instanceof ya,46915);let n=this.persistence.referenceDelegate.garbageCollector;return new na(n,e.asyncQueue,t)}Cu(e){let t=this.cacheSizeBytes===void 0?Xi.DEFAULT:Xi.withCacheSize(this.cacheSizeBytes);return new ga((e=>ya.mi(e,t)),this.serializer)}},Ps=class{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=>gs(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=Os.bind(null,this.syncEngine),await Po(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return function(){return new Uo}()}createDatastore(e){let t=Xa(e.databaseInfo.databaseId),n=function(e){return new Ja(e)}(e.databaseInfo);return function(e,t,n,r){return new ro(e,t,n,r)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,r,i){return new oo(e,t,n,r,i)}(this.localStore,this.datastore,e.asyncQueue,(e=>gs(this.syncEngine,e,0)),function(){return Va.v()?new Va:new za}())}createSyncEngine(e,t){return function(e,t,n,r,i,a,o){let s=new ss(e,t,n,r,i,a);return o&&(s.gu=!0),s}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){await async function(e){let t=S(e);y(ao,`RemoteStore shutting down.`),t.Ea.add(5),await co(t),t.Aa.shutdown(),t.Ra.set(`Unknown`)}(this.remoteStore),this.datastore?.terminate(),this.eventManager?.terminate()}};Ps.provider={build:()=>new Ps};
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Fs=class{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.Ou(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.Ou(this.observer.error,e):Se(`Uncaught Error in snapshot listener:`,e.toString()))}Nu(){this.muted=!0}Ou(e,t){setTimeout((()=>{this.muted||e(t)}),0)}},Is=`FirestoreClient`,Ls=class{constructor(e,t,n,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=v.UNAUTHENTICATED,this.clientId=Ie.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,(async e=>{y(Is,`Received user=`,e.uid),await this.authCredentialListener(e),this.user=e})),this.appCheckCredentials.start(n,(e=>(y(Is,`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 Ee;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(t){let n=Ro(t,`Failed to shutdown persistence`);e.reject(n)}})),e.promise}};async function Rs(e,t){e.asyncQueue.verifyOperationInProgress(),y(Is,`Initializing OfflineComponentProvider`);let n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener((async e=>{r.isEqual(e)||(await Da(t.localStore,e),r=e)})),t.persistence.setDatabaseDeletedListener((()=>e.terminate())),e._offlineComponents=t}async function zs(e,t){e.asyncQueue.verifyOperationInProgress();let n=await Bs(e);y(Is,`Initializing OnlineComponentProvider`),await t.initialize(n,e.configuration),e.setCredentialChangeListener((e=>No(t.remoteStore,e))),e.setAppCheckTokenChangeListener(((e,n)=>No(t.remoteStore,n))),e._onlineComponents=t}async function Bs(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){y(Is,`Using user provided OfflineComponentProvider`);try{await Rs(e,e._uninitializedComponentsProvider._offline)}catch(t){let n=t;if(!function(e){return e.name===`FirebaseError`?e.code===C.FAILED_PRECONDITION||e.code===C.UNIMPLEMENTED:!(typeof DOMException<`u`&&e instanceof DOMException)||e.code===22||e.code===20||e.code===11}(n))throw n;Ce(`Error using user provided cache. Falling back to memory cache: `+n),await Rs(e,new Ms)}}else y(Is,`Using default OfflineComponentProvider`),await Rs(e,new Ns(void 0));return e._offlineComponents}async function Vs(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(y(Is,`Using user provided OnlineComponentProvider`),await zs(e,e._uninitializedComponentsProvider._online)):(y(Is,`Using default OnlineComponentProvider`),await zs(e,new Ps))),e._onlineComponents}function Hs(e){return Vs(e).then((e=>e.syncEngine))}async function Us(e){let t=await Vs(e),n=t.eventManager;return n.onListen=cs.bind(null,t.syncEngine),n.onUnlisten=fs.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=ls.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=ps.bind(null,t.syncEngine),n}function Ws(e,t,n={}){let r=new Ee;return e.asyncQueue.enqueueAndForget((async()=>function(e,t,n,r,i){let a=new Fs({next:n=>{a.Nu(),t.enqueueAndForget((()=>Ko(e,o))),n.fromCache&&r.source===`server`?i.reject(new w(C.UNAVAILABLE,`Failed to get documents from server. (However, these documents may exist in the local cache. Run again without setting source to "server" to retrieve the cached documents.)`)):i.resolve(n)},error:e=>i.reject(e)}),o=new Qo(n,a,{includeMetadataChanges:!0,qa:!0});return Go(e,o)}(await Us(e),e.asyncQueue,t,n,r))),r.promise}
/**
* @license
* Copyright 2023 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function Gs(e){let t={};return e.timeoutSeconds!==void 0&&(t.timeoutSeconds=e.timeoutSeconds),t}
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var Ks=new Map,qs=`firestore.googleapis.com`,Js=!0,Ys=class{constructor(e){if(e.host===void 0){if(e.ssl!==void 0)throw new w(C.INVALID_ARGUMENT,`Can't provide ssl option if host option is not set`);this.host=qs,this.ssl=Js}else this.host=e.host,this.ssl=e.ssl??Js;if(this.isUsingEmulator=e.emulatorOptions!==void 0,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,e.cacheSizeBytes===void 0)this.cacheSizeBytes=Yi;else{if(e.cacheSizeBytes!==-1&&e.cacheSizeBytes<$i)throw new w(C.INVALID_ARGUMENT,`cacheSizeBytes must be at least 1048576`);this.cacheSizeBytes=e.cacheSizeBytes}We(`experimentalForceLongPolling`,e.experimentalForceLongPolling,`experimentalAutoDetectLongPolling`,e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:e.experimentalAutoDetectLongPolling===void 0?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=Gs(e.experimentalLongPollingOptions??{}),function(e){if(e.timeoutSeconds!==void 0){if(isNaN(e.timeoutSeconds))throw new w(C.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new w(C.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new w(C.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (maximum allowed value is 30)`)}}(this.experimentalLongPollingOptions),this.useFetchStreams=!!e.useFetchStreams}isEqual(e){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&&function(e,t){return e.timeoutSeconds===t.timeoutSeconds}(this.experimentalLongPollingOptions,e.experimentalLongPollingOptions)&&this.ignoreUndefinedProperties===e.ignoreUndefinedProperties&&this.useFetchStreams===e.useFetchStreams}},Xs=class{constructor(e,t,n,r){this._authCredentials=e,this._appCheckCredentials=t,this._databaseId=n,this._app=r,this.type=`firestore-lite`,this._persistenceKey=`(lite)`,this._settings=new Ys({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask=`notTerminated`}get app(){if(!this._app)throw new w(C.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 this._terminateTask!==`notTerminated`}_setSettings(e){if(this._settingsFrozen)throw new w(C.FAILED_PRECONDITION,`Firestore has already been started and its settings can no longer be changed. You can only modify settings before calling any other methods on a Firestore object.`);this._settings=new Ys(e),this._emulatorOptions=e.emulatorOptions||{},e.credentials!==void 0&&(this._authCredentials=function(e){if(!e)return new Oe;switch(e.type){case`firstParty`:return new Me(e.sessionIndex||`0`,e.iamToken||null,e.authTokenFactory||null);case`provider`:return e.client;default:throw new w(C.INVALID_ARGUMENT,`makeAuthCredentialsProvider failed due to invalid credential type`)}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return this._terminateTask===`notTerminated`&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){this._terminateTask===`notTerminated`?await this._terminate():this._terminateTask=`notTerminated`}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){let t=Ks.get(e);t&&(y(`ComponentProvider`,`Removing Datastore`),Ks.delete(e),t.terminate())}(this),Promise.resolve()}};function Zs(t,r,i,a={}){t=Ye(t,Xs);let o=ne(r),s=t._getSettings(),l={...s,emulatorOptions:t._getEmulatorOptions()},u=`${r}:${i}`;o&&(e(`https://${u}`),te(`Firestore`,!0)),s.host!==qs&&s.host!==u&&Ce(`Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.`);let d={...s,host:u,ssl:o,emulatorOptions:a};if(!n(d,l)&&(t._setSettings(d),a.mockUserToken)){let e,n;if(typeof a.mockUserToken==`string`)e=a.mockUserToken,n=v.MOCK_USER;else{e=c(a.mockUserToken,t._app?.options.projectId);let r=a.mockUserToken.sub||a.mockUserToken.user_id;if(!r)throw new w(C.INVALID_ARGUMENT,`mockUserToken must contain 'sub' or 'user_id' field!`);n=new v(r)}t._authCredentials=new ke(new De(e,n))}}
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Qs=class e{constructor(e,t,n){this.converter=t,this._query=n,this.type=`query`,this.firestore=e}withConverter(t){return new e(this.firestore,t,this._query)}},$=class e{constructor(e,t,n){this.converter=t,this._key=n,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 $s(this.firestore,this.converter,this._key.path.popLast())}withConverter(t){return new e(this.firestore,t,this._key)}toJSON(){return{type:e._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(t,n,r){if(Xe(n,e._jsonSchema))return new e(t,r||null,new A(O.fromString(n.referencePath)))}};$._jsonSchemaVersion=`firestore/documentReference/1.0`,$._jsonSchema={type:j(`string`,$._jsonSchemaVersion),referencePath:j(`string`)};var $s=class e extends Qs{constructor(e,t,n){super(e,t,Pn(n)),this._path=n,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 $(this.firestore,null,new A(e))}withConverter(t){return new e(this.firestore,t,this._path)}};function ec(e,t,...n){if(e=_(e),Ue(`collection`,`path`,t),e instanceof Xs){let r=O.fromString(t,...n);return Ke(r),new $s(e,null,r)}{if(!(e instanceof $||e instanceof $s))throw new w(C.INVALID_ARGUMENT,`Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore`);let r=e._path.child(O.fromString(t,...n));return Ke(r),new $s(e.firestore,null,r)}}function tc(e,t,...n){if(e=_(e),arguments.length===1&&(t=Ie.newId()),Ue(`doc`,`path`,t),e instanceof Xs){let r=O.fromString(t,...n);return Ge(r),new $(e,null,new A(r))}{if(!(e instanceof $||e instanceof $s))throw new w(C.INVALID_ARGUMENT,`Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore`);let r=e._path.child(O.fromString(t,...n));return Ge(r),new $(e.firestore,e instanceof $s?e.converter:null,new A(r))}}
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/var nc=`AsyncQueue`,rc=class{constructor(e=Promise.resolve()){this.Xu=[],this.ec=!1,this.tc=[],this.nc=null,this.rc=!1,this.sc=!1,this.oc=[],this.M_=new Za(this,`async_queue_retry`),this._c=()=>{let e=Ya();e&&y(nc,`Visibility state changed to `+e.visibilityState),this.M_.w_()},this.ac=e;let t=Ya();t&&typeof t.addEventListener==`function`&&t.addEventListener(`visibilitychange`,this._c)}get isShuttingDown(){return this.ec}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.uc(),this.cc(e)}enterRestrictedMode(e){if(!this.ec){this.ec=!0,this.sc=e||!1;let t=Ya();t&&typeof t.removeEventListener==`function`&&t.removeEventListener(`visibilitychange`,this._c)}}enqueue(e){if(this.uc(),this.ec)return new Promise((()=>{}));let t=new Ee;return this.cc((()=>this.ec&&this.sc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise))).then((()=>t.promise))}enqueueRetryable(e){this.enqueueAndForget((()=>(this.Xu.push(e),this.lc())))}async lc(){if(this.Xu.length!==0){try{await this.Xu[0](),this.Xu.shift(),this.M_.reset()}catch(e){if(!st(e))throw e;y(nc,`Operation failed with retryable error: `+e)}this.Xu.length>0&&this.M_.p_((()=>this.lc()))}}cc(e){let t=this.ac.then((()=>(this.rc=!0,e().catch((e=>{throw this.nc=e,this.rc=!1,Se(`INTERNAL UNHANDLED ERROR: `,ic(e)),e})).then((e=>(this.rc=!1,e))))));return this.ac=t,t}enqueueAfterDelay(e,t,n){this.uc(),this.oc.indexOf(e)>-1&&(t=0);let r=Lo.createAndSchedule(this,e,t,n,(e=>this.hc(e)));return this.tc.push(r),r}uc(){this.nc&&b(47125,{Pc:ic(this.nc)})}verifyOperationInProgress(){}async Tc(){let e;do e=this.ac,await e;while(e!==this.ac)}Ic(e){for(let t of this.tc)if(t.timerId===e)return!0;return!1}Ec(e){return this.Tc().then((()=>{this.tc.sort(((e,t)=>e.targetTimeMs-t.targetTimeMs));for(let t of this.tc)if(t.skipDelay(),e!==`all`&&t.timerId===e)break;return this.Tc()}))}dc(e){this.oc.push(e)}hc(e){let t=this.tc.indexOf(e);this.tc.splice(t,1)}};function ic(e){let t=e.message||``;return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+`
`+e.stack),t}var ac=class extends Xs{constructor(e,t,n,r){super(e,t,n,r),this.type=`firestore`,this._queue=new rc,this._persistenceKey=r?.name||`[DEFAULT]`}async _terminate(){if(this._firestoreClient){let e=this._firestoreClient.terminate();this._queue=new rc(e),this._firestoreClient=void 0,await e}}};function oc(e,t){let n=typeof e==`object`?e:u(),r=typeof e==`string`?e:t||Pt,i=f(n,`firestore`).getImmediate({identifier:r});if(!i._initialized){let e=ee(`firestore`);e&&Zs(i,...e)}return i}function sc(e){if(e._terminated)throw new w(C.FAILED_PRECONDITION,`The client has already been terminated.`);return e._firestoreClient||cc(e),e._firestoreClient}function cc(e){let t=e._freezeSettings(),n=function(e,t,n,r){return new Nt(e,t,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,Gs(r.experimentalLongPollingOptions),r.useFetchStreams,r.isUsingEmulator)}(e._databaseId,e._app?.options.appId||``,e._persistenceKey,t);e._componentsProvider||t.localCache?._offlineComponentProvider&&t.localCache?._onlineComponentProvider&&(e._componentsProvider={_offline:t.localCache._offlineComponentProvider,_online:t.localCache._onlineComponentProvider}),e._firestoreClient=new Ls(e._authCredentials,e._appCheckCredentials,e._queue,n,e._componentsProvider&&function(e){let t=e?._online.build();return{_offline:e?._offline.build(t),_online:t}}(e._componentsProvider))}
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var lc=class e{constructor(e){this._byteString=e}static fromBase64String(t){try{return new e(B.fromBase64String(t))}catch(e){throw new w(C.INVALID_ARGUMENT,`Failed to construct data from Base64 string: `+e)}}static fromUint8Array(t){return new e(B.fromUint8Array(t))}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:e._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(t){if(Xe(t,e._jsonSchema))return e.fromBase64String(t.bytes)}};lc._jsonSchemaVersion=`firestore/bytes/1.0`,lc._jsonSchema={type:j(`string`,lc._jsonSchemaVersion),bytes:j(`string`)};
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var uc=class{constructor(...e){for(let t=0;t<e.length;++t)if(e[t].length===0)throw new w(C.INVALID_ARGUMENT,`Invalid field name at argument $(i + 1). Field names must not be empty.`);this._internalPath=new k(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}},dc=class{constructor(e){this._methodName=e}},fc=class e{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new w(C.INVALID_ARGUMENT,`Latitude must be a number between -90 and 90, but was: `+e);if(!isFinite(t)||t<-180||t>180)throw new w(C.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 T(this._lat,e._lat)||T(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:e._jsonSchemaVersion}}static fromJSON(t){if(Xe(t,e._jsonSchema))return new e(t.latitude,t.longitude)}};fc._jsonSchemaVersion=`firestore/geoPoint/1.0`,fc._jsonSchema={type:j(`string`,fc._jsonSchemaVersion),latitude:j(`number`),longitude:j(`number`)};
/**
* @license
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var pc=class e{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 n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}(this._values,e._values)}toJSON(){return{type:e._jsonSchemaVersion,vectorValues:this._values}}static fromJSON(t){if(Xe(t,e._jsonSchema)){if(Array.isArray(t.vectorValues)&&t.vectorValues.every((e=>typeof e==`number`)))return new e(t.vectorValues);throw new w(C.INVALID_ARGUMENT,`Expected 'vectorValues' field to be a number array`)}}};pc._jsonSchemaVersion=`firestore/vectorValue/1.0`,pc._jsonSchema={type:j(`string`,pc._jsonSchemaVersion),vectorValues:j(`object`)};
/**
* @license
* Copyright 2017 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var mc=/^__.*__$/,hc=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return this.fieldMask===null?new Mr(e,this.data,t,this.fieldTransforms):new Nr(e,this.data,this.fieldMask,t,this.fieldTransforms)}},gc=class{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new Nr(e,this.data,this.fieldMask,t,this.fieldTransforms)}};function _c(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw b(40011,{Ac:e})}}var vc=class e{constructor(e,t,n,r,i,a){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,i===void 0&&this.Rc(),this.fieldTransforms=i||[],this.fieldMask=a||[]}get path(){return this.settings.path}get Ac(){return this.settings.Ac}Vc(t){return new e({...this.settings,...t},this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}mc(e){let t=this.path?.child(e),n=this.Vc({path:t,fc:!1});return n.gc(e),n}yc(e){let t=this.path?.child(e),n=this.Vc({path:t,fc:!1});return n.Rc(),n}wc(e){return this.Vc({path:void 0,fc:!0})}Sc(e){return Nc(e,this.settings.methodName,this.settings.bc||!1,this.path,this.settings.Dc)}contains(e){return this.fieldMask.find((t=>e.isPrefixOf(t)))!==void 0||this.fieldTransforms.find((t=>e.isPrefixOf(t.field)))!==void 0}Rc(){if(this.path)for(let e=0;e<this.path.length;e++)this.gc(this.path.get(e))}gc(e){if(e.length===0)throw this.Sc(`Document fields must not be empty`);if(_c(this.Ac)&&mc.test(e))throw this.Sc(`Document fields cannot begin and end with "__"`)}},yc=class{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Xa(e)}Cc(e,t,n,r=!1){return new vc({Ac:e,methodName:t,Dc:n,path:k.emptyPath(),fc:!1,bc:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}};function bc(e){let t=e._freezeSettings(),n=Xa(e._databaseId);return new yc(e._databaseId,!!t.ignoreUndefinedProperties,n)}function xc(e,t,n,r,i,a={}){let o=e.Cc(a.merge||a.mergeFields?2:0,t,n,i);kc(`Data must be an object, but it was:`,o,r);let s=Dc(r,o),c,l;if(a.merge)c=new z(o.fieldMask),l=o.fieldTransforms;else if(a.mergeFields){let e=[];for(let r of a.mergeFields){let i=Ac(t,r,n);if(!o.contains(i))throw new w(C.INVALID_ARGUMENT,`Field '${i}' is specified in your field mask but missing from your input data.`);Pc(e,i)||e.push(i)}c=new z(e),l=o.fieldTransforms.filter((e=>c.covers(e.field)))}else c=null,l=o.fieldTransforms;return new hc(new an(s),c,l)}var Sc=class e extends dc{_toFieldTransform(e){if(e.Ac!==2)throw e.Ac===1?e.Sc(`${this._methodName}() can only appear at the top level of your update data`):e.Sc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(t){return t instanceof e}};function Cc(e,t,n,r){let i=e.Cc(1,t,n);kc(`Data must be an object, but it was:`,i,r);let a=[],o=an.empty();vt(r,((e,r)=>{let s=Mc(t,e,n);r=_(r);let c=i.yc(s);if(r instanceof Sc)a.push(s);else{let e=Ec(r,c);e!=null&&(a.push(s),o.set(s,e))}}));let s=new z(a);return new gc(o,s,i.fieldTransforms)}function wc(e,t,n,r,i,a){let o=e.Cc(1,t,n),s=[Ac(t,r,n)],c=[i];if(a.length%2!=0)throw new w(C.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<a.length;e+=2)s.push(Ac(t,a[e])),c.push(a[e+1]);let l=[],u=an.empty();for(let e=s.length-1;e>=0;--e)if(!Pc(l,s[e])){let t=s[e],n=c[e];n=_(n);let r=o.yc(t);if(n instanceof Sc)l.push(t);else{let e=Ec(n,r);e!=null&&(l.push(t),u.set(t,e))}}let d=new z(l);return new gc(u,d,o.fieldTransforms)}function Tc(e,t,n,r=!1){return Ec(n,e.Cc(r?4:3,t))}function Ec(e,t){if(Oc(e=_(e)))return kc(`Unsupported field value:`,t,e),Dc(e,t);if(e instanceof dc)return function(e,t){if(!_c(t.Ac))throw t.Sc(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.Sc(`${e._methodName}() is not currently supported inside arrays`);let n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(e===void 0&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.fc&&t.Ac!==4)throw t.Sc(`Nested arrays are not supported`);return function(e,t){let n=[],r=0;for(let i of e){let e=Ec(i,t.wc(r));e??={nullValue:`NULL_VALUE`},n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if((e=_(e))===null)return{nullValue:`NULL_VALUE`};if(typeof e==`number`)return lr(t.serializer,e);if(typeof e==`boolean`)return{booleanValue:e};if(typeof e==`string`)return{stringValue:e};if(e instanceof Date){let n=M.fromDate(e);return{timestampValue:fi(t.serializer,n)}}if(e instanceof M){let n=new M(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:fi(t.serializer,n)}}if(e instanceof fc)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof lc)return{bytesValue:pi(t.serializer,e._byteString)};if(e instanceof $){let n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.Sc(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:gi(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof pc)return function(e,t){return{mapValue:{fields:{[It]:{stringValue:Rt},[zt]:{arrayValue:{values:e.toArray().map((e=>{if(typeof e!=`number`)throw t.Sc(`VectorValues must only contain numeric values.`);return sr(t.serializer,e)}))}}}}}}(e,t);throw t.Sc(`Unsupported field value: ${Je(e)}`)}(e,t)}function Dc(e,t){let n={};return yt(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):vt(e,((e,r)=>{let i=Ec(r,t.mc(e));i!=null&&(n[e]=i)})),{mapValue:{fields:n}}}function Oc(e){return!(typeof e!=`object`||!e||e instanceof Array||e instanceof Date||e instanceof M||e instanceof fc||e instanceof lc||e instanceof $||e instanceof dc||e instanceof pc)}function kc(e,t,n){if(!Oc(n)||!qe(n)){let r=Je(n);throw r===`an object`?t.Sc(e+` a custom object`):t.Sc(e+` `+r)}}function Ac(e,t,n){if((t=_(t))instanceof uc)return t._internalPath;if(typeof t==`string`)return Mc(e,t);throw Nc(`Field path arguments must be of type string or `,e,!1,void 0,n)}var jc=RegExp(`[~\\*/\\[\\]]`);function Mc(e,t,n){if(t.search(jc)>=0)throw Nc(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new uc(...t.split(`.`))._internalPath}catch{throw Nc(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function Nc(e,t,n,r,i){let a=r&&!r.isEmpty(),o=i!==void 0,s=`Function ${t}() called with invalid data`;n&&(s+=" (via `toFirestore()`)"),s+=`. `;let c=``;return(a||o)&&(c+=` (found`,a&&(c+=` in field ${r}`),o&&(c+=` in document ${i}`),c+=`)`),new w(C.INVALID_ARGUMENT,s+e+c)}function Pc(e,t){return e.some((e=>e.isEqual(t)))}
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
var Fc=class{constructor(e,t,n,r,i){this._firestore=e,this._userDataWriter=t,this._key=n,this._document=r,this._converter=i}get id(){return this._key.path.lastSegment()}get ref(){return new $(this._firestore,this._converter,this._key)}exists(){return this._document!==null}data(){if(this._document){if(this._converter){let e=new Ic(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(Lc(`DocumentSnapshot.get`,e));if(t!==null)return this._userDataWriter.convertValue(t)}}},Ic=class extends Fc{data(){return super.data()}};function Lc(e,t){return typeof t==`string`?Mc(e,t):t instanceof uc?t._internalPath:t._delegate._internalPath}
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/function Rc(e){if(e.limitType===`L`&&e.explicitOrderBy.length===0)throw new w(C.UNIMPLEMENTED,`limitToLast() queries require specifying at least one orderBy() clause`)}var zc=class{},Bc=class extends zc{};function Vc(e,t,...n){let r=[];t instanceof zc&&r.push(t),r=r.concat(n),function(e){let t=e.filter((e=>e instanceof Uc)).length,n=e.filter((e=>e instanceof Hc)).length;if(t>1||t>0&&n>0)throw new w(C.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(...)))`.")}(r);for(let t of r)e=t._apply(e);return e}var Hc=class e extends Bc{constructor(e,t,n){super(),this._field=e,this._op=t,this._value=n,this.type=`where`}static _create(t,n,r){return new e(t,n,r)}_apply(e){let t=this._parse(e);return Kc(e._query,t),new Qs(e.firestore,e.converter,Bn(e._query,t))}_parse(e){let t=bc(e.firestore);return function(e,t,n,r,i,a,o){let s;if(i.isKeyField()){if(a===`array-contains`||a===`array-contains-any`)throw new w(C.INVALID_ARGUMENT,`Invalid Query. You can't perform '${a}' queries on documentId().`);if(a===`in`||a===`not-in`){Gc(o,a);let t=[];for(let n of o)t.push(Wc(r,e,n));s={arrayValue:{values:t}}}else s=Wc(r,e,o)}else a!==`in`&&a!==`not-in`&&a!==`array-contains-any`||Gc(o,a),s=Tc(n,t,o,a===`in`||a===`not-in`);return K.create(i,a,s)}(e._query,`where`,t,e.firestore._databaseId,this._field,this._op,this._value)}},Uc=class e extends zc{constructor(e,t){super(),this.type=e,this._queryConstraints=t}static _create(t,n){return new e(t,n)}_parse(e){let t=this._queryConstraints.map((t=>t._parse(e))).filter((e=>e.getFilters().length>0));return t.length===1?t[0]:fn.create(t,this._getOperator())}_apply(e){let t=this._parse(e);return t.getFilters().length===0?e:(function(e,t){let n=e,r=t.getFlattenedFilters();for(let e of r)Kc(n,e),n=Bn(n,e)}(e._query,t),new Qs(e.firestore,e.converter,Bn(e._query,t)))}_getQueryConstraints(){return this._queryConstraints}_getOperator(){return this.type===`and`?`and`:`or`}};function Wc(e,t,n){if(typeof(n=_(n))==`string`){if(n===``)throw new w(C.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid document ID, but it was an empty string.`);if(!In(t)&&n.indexOf(`/`)!==-1)throw new w(C.INVALID_ARGUMENT,`Invalid query. When querying a collection by documentId(), you must provide a plain document ID, but '${n}' contains a '/' character.`);let r=t.path.child(O.fromString(n));if(!A.isDocumentKey(r))throw new w(C.INVALID_ARGUMENT,`Invalid query. When querying a collection group by documentId(), the value provided must result in a valid document path, but '${r}' is not because it has an odd number of segments (${r.length}).`);return Yt(e,new A(r))}if(n instanceof $)return Yt(e,n._key);throw new w(C.INVALID_ARGUMENT,`Invalid query. When querying with documentId(), you must provide a valid string or a DocumentReference, but it was: ${Je(n)}.`)}function Gc(e,t){if(!Array.isArray(e)||e.length===0)throw new w(C.INVALID_ARGUMENT,`Invalid Query. A non-empty array is required for '${t.toString()}' filters.`)}function Kc(e,t){let n=function(e,t){for(let n of e)for(let e of n.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(n!==null)throw n===t.op?new w(C.INVALID_ARGUMENT,`Invalid query. You cannot use more than one '${t.op.toString()}' filter.`):new w(C.INVALID_ARGUMENT,`Invalid query. You cannot use '${t.op.toString()}' filters with '${n.toString()}' filters.`)}var qc=class{convertValue(e,t=`none`){switch(Bt(e)){case 0:return null;case 1:return e.booleanValue;case 2:return V(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(Et(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 b(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t=`none`){let n={};return vt(e,((e,r)=>{n[e]=this.convertValue(r,t)})),n}convertVectorValue(e){let t=e.fields?.[zt].arrayValue?.values?.map((e=>V(e.doubleValue)));return new pc(t)}convertGeoPoint(e){return new fc(V(e.latitude),V(e.longitude))}convertArray(e,t){return(e.values||[]).map((e=>this.convertValue(e,t)))}convertServerTimestamp(e,t){switch(t){case`previous`:let n=Mt(e);return n==null?null:this.convertValue(n,t);case`estimate`:return this.convertTimestamp(H(e));default:return null}}convertTimestamp(e){let t=Tt(e);return new M(t.seconds,t.nanos)}convertDocumentKey(e,t){let n=O.fromString(e);x(Vi(n),9688,{name:e});let r=new Ft(n.get(1),n.get(3)),i=new A(n.popFirst(5));return r.isEqual(t)||Se(`Document ${i} contains a document reference within a different database (${r.projectId}/${r.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),i}};
/**
* @license
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function Jc(e,t,n){let r;return r=e?n&&(n.merge||n.mergeFields)?e.toFirestore(t,n):e.toFirestore(t):t,r}var Yc=class{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}},Xc=class e extends Fc{constructor(e,t,n,r,i,a){super(e,t,n,r,a),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){let t=new Zc(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 n=this._document.data.field(Lc(`DocumentSnapshot.get`,e));if(n!==null)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new w(C.FAILED_PRECONDITION,`DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().`);let t=this._document,n={};return n.type=e._jsonSchemaVersion,n.bundle=``,n.bundleSource=`DocumentSnapshot`,n.bundleName=this._key.toString(),!t||!t.isValidDocument()||!t.isFoundDocument()?n:(this._userDataWriter.convertObjectMap(t.data.value.mapValue.fields,`previous`),n.bundle=(this._firestore,this.ref.path,`NOT SUPPORTED`),n)}};Xc._jsonSchemaVersion=`firestore/documentSnapshot/1.0`,Xc._jsonSchema={type:j(`string`,Xc._jsonSchemaVersion),bundleSource:j(`string`,`DocumentSnapshot`),bundleName:j(`string`),bundle:j(`string`)};var Zc=class extends Xc{data(e={}){return super.data(e)}},Qc=class e{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new Yc(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){let e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach((n=>{e.call(t,new Zc(this._firestore,this._userDataWriter,n.key,n,new Yc(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){let t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new w(C.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((n=>{let r=new Zc(e._firestore,e._userDataWriter,n.doc.key,n.doc,new Yc(e._snapshot.mutatedKeys.has(n.doc.key),e._snapshot.fromCache),e.query.converter);return n.doc,{type:`added`,doc:r,oldIndex:-1,newIndex:t++}}))}{let n=e._snapshot.oldDocs;return e._snapshot.docChanges.filter((e=>t||e.type!==3)).map((t=>{let r=new Zc(e._firestore,e._userDataWriter,t.doc.key,t.doc,new Yc(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter),i=-1,a=-1;return t.type!==0&&(i=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),t.type!==1&&(n=n.add(t.doc),a=n.indexOf(t.doc.key)),{type:$c(t.type),doc:r,oldIndex:i,newIndex:a}}))}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new w(C.FAILED_PRECONDITION,`QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().`);let t={};t.type=e._jsonSchemaVersion,t.bundleSource=`QuerySnapshot`,t.bundleName=Ie.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;let n=[],r=[],i=[];return this.docs.forEach((e=>{e._document!==null&&(n.push(e._document),r.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,`previous`)),i.push(e.ref.path))})),t.bundle=(this._firestore,this.query._query,t.bundleName,`NOT SUPPORTED`),t}};function $c(e){switch(e){case 0:return`added`;case 2:case 3:return`modified`;case 1:return`removed`;default:return b(61501,{type:e})}}Qc._jsonSchemaVersion=`firestore/querySnapshot/1.0`,Qc._jsonSchema={type:j(`string`,Qc._jsonSchemaVersion),bundleSource:j(`string`,`QuerySnapshot`),bundleName:j(`string`),bundle:j(`string`)};var el=class extends qc{constructor(e){super(),this.firestore=e}convertBytes(e){return new lc(e)}convertReference(e){let t=this.convertDocumentKey(e,this.firestore._databaseId);return new $(this.firestore,null,t)}};function tl(e){e=Ye(e,Qs);let t=Ye(e.firestore,ac),n=sc(t),r=new el(t);return Rc(e._query),Ws(n,e._query).then((n=>new Qc(t,r,e,n)))}function nl(e,t,n,...r){e=Ye(e,$);let i=Ye(e.firestore,ac),a=bc(i),o;return o=typeof(t=_(t))==`string`||t instanceof uc?wc(a,`updateDoc`,e._key,t,n,r):Cc(a,`updateDoc`,e._key,t),al(i,[o.toMutation(e._key,wr.exists(!0))])}function rl(e){return al(Ye(e.firestore,ac),[new Lr(e._key,wr.none())])}function il(e,t){let n=Ye(e.firestore,ac),r=tc(e),i=Jc(e.converter,t);return al(n,[xc(bc(e.firestore),`addDoc`,r._key,i,e.converter!==null,{}).toMutation(r._key,wr.exists(!1))]).then((()=>r))}function al(e,t){return function(e,t){let n=new Ee;return e.asyncQueue.enqueueAndForget((async()=>ms(await Hs(e),t,n))),n.promise}(sc(e),t)}(function(e,t=!0){(function(e){ye=e})(r),a(new d(`firestore`,((e,{instanceIdentifier:n,options:r})=>{let i=e.getProvider(`app`).getImmediate(),a=new ac(new Ae(e.getProvider(`auth-internal`)),new Pe(i,e.getProvider(`app-check-internal`)),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,[`projectId`]))throw new w(C.INVALID_ARGUMENT,`"projectId" not provided in firebase.initializeApp.`);return new Ft(e.options.projectId,t)}(i,n),i);return r={useFetchStreams:t,...r},a._setSettings(r),a}),`PUBLIC`).setMultipleInstances(!0)),o(_e,ve,e),o(_e,ve,`esm2020`)})();var ol=g({apiKey:`AIzaSyCfgix1rgWIWt_P6Czvu6lvWSvQ_c-zQdY`,authDomain:`faress-portfolio-admin.firebaseapp.com`,projectId:`faress-portfolio-admin`,storageBucket:`faress-portfolio-admin.appspot.com`,messagingSenderId:`833104434405`,appId:`1:833104434405:web:ecad6edafd4d225373300c`,measurementId:`G-8XCB4NDBX6`});const sl=oc(ol),cl=h(ol);export{rl as a,Vc as c,ec as i,nl as l,sl as n,tc as o,il as r,tl as s,cl as t};