vendor: 4,316 bytes, lines 1-2
1/*! For license information please see init-firebase.e69422d6f61e09924e47.js.LICENSE.txt */ 2(()=>{var e={62999(e,t,n){"use strict";const r=["Registration is a free and easy way to support our truly independent journalism"]},55299(e,t,n){"use strict";n.d(t,{d_k:()=>r,eQT:()=>i});n(62999);const r="js-globals",i="ssr-auth-state"},1626(e){e.exports=function(){"use strict";var e=1e3,t=6e4,n=36e5,r="millisecond",i="second",s="minute",o="hour",a="day",c="week",u="month",l="quarter",h="year",d="date",f="Invalid Date",p=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,m=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}},y=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},v={s:y,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?"+":"-")+y(r,2,"0")+":"+y(i,2,"0")},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),i=t.clone().add(r,u),s=n-i<0,o=t.clone().add(r+(s?-1:1),u);return+(-(r+(n-i)/(s?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:u,y:h,w:c,d:a,D:d,h:o,m:s,s:i,ms:r,Q:l}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},w="en",_={};_[w]=g;var b="$isDayjsObject",E=function(e){return e instanceof C||!(!e||!e[b])},T=function e(t,n,r){var i;if(!t)return w;if("string"==typeof t){var s=t.toLowerCase();_[s]&&(i=s),n&&(_[s]=n,i=s);var o=t.split("-");if(!i&&o.length>1)return e(o[0])}else{var a=t.name;_[a]=t,i=a}return!r&&i&&(w=i),i||!r&&w},I=function(e,t){if(E(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new C(n)},S=v;S.l=T,S.i=E,S.w=function(e,t){return I(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var C=function(){function g(e){this.$L=T(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[b]=!0}var y=g.prototype;return y.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(S.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(p);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(t)}(e),this.init()},y.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},y.$utils=function(){return S},y.isValid=function(){return!(this.$d.toString()===f)},y.isSame=function(e,t){var n=I(e);return this.startOf(t)<=n&&n<=this.endOf(t)},y.isAfter=function(e,t){return I(e)<this.startOf(t)},y.isBefore=function(e,t){return this.endOf(t)<I(e)},y.$g=function(e,t,n){return S.u(e)?this[t]:this.set(n,e)},y.unix=function(){return Math.floor(this.valueOf()/1e3)},y.valueOf=function(){return this.$d.getTime()},y.startOf=function(e,t){var n=this,r=!!S.u(t)||t,l=S.p(e),f=function(e,t){var i=S.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(a)},p=function(e,t){return S.w(n.toDate()[e].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},m=this.$W,g=this.$M,y=this.$D,v="set"+(this.$u?"UTC":"");switch(l){case h:return r?f(1,0):f(31,11);case u:return r?f(1,g):f(0,g+1);case c:var w=this.$locale().weekStart||0,_=(m<w?m+7:m)-w;return f(r?y-_:y+(6-_),g);case a:case d:return p(v+"Hours",0);case o:return p(v+"Minutes",1);case s:return p(v+"Seconds",2);case i:return p(v+"Milliseconds",3);default:return this.clone()}},y.endOf=function(e){return this.startOf(e,!1)},y.$set=function(e,t){var n,c=S.p(e),l="set"+(this.$u?"UTC":""),f=(n={},n[a]=l+"Date",n[d]=l+"Date",n[u]=l+"Month",n[h]=l+"FullYear",n[o]=l+"Hours",n[s]=l+"Minutes",n[i]=l+"Seconds",n[r]=l+"Milliseconds",n)[c],p=c===a?this.$D+(t-this.$W):t;if(c===u||c===h){var m=this.clone().set(d,1);
2m.$d[f](p),m.init(),this.$d=m.set(d,Math.min(this.$D,m.daysInMonth())).$d}else f&&this.$d[f](p);return this.init(),this},y.set=function(e,t){return this.clone().$set(e,t)},y.get=function(e){return this[S.p(e)]()},y.add=function(r,l){var d,f=this;r=Number(r);var p=S.p(l),m=function(e){var t=I(f);return S.w(t.date(t.date()+Math.round(e*r)),f)};if(p===u)return this.set(u,this.$M+r);if(p===h)return this.set(h,this.$y+r);if(p===a)return m(1);if(p===c)return m(7);var g=(d={},d[s]=t,d[o]=n,d[i]=e,d)[p]||1,y=this.$d.getTime()+r*g;return S.w(y,this)},y.subtract=function(e,t){return this.add(-1*e,t)},y.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||f;var r=e||"YYYY-MM-DDTHH:mm:ssZ",i=S.z(this),s=this.$H,o=this.$m,a=this.$M,c=n.weekdays,u=n.months,l=n.meridiem,h=function(e,n,i,s){return e&&(e[n]||e(t,r))||i[n].slice(0,s)},d=function(e){return S.s(s%12||12,e,"0")},p=l||function(e,t,n){var r=e<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(m,function(e,r){return r||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return S.s(t.$y,4,"0");case"M":return a+1;case"MM":return S.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,u,3);case"MMMM":return h(u,a);case"D":return t.$D;case"DD":return S.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return h(n.weekdaysMin,t.$W,c,2);case"ddd":return h(n.weekdaysShort,t.$W,c,3);case"dddd":return c[t.$W];case"H":return String(s);case"HH":return S.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return p(s,o,!0);case"A":return p(s,o,!1);case"m":return String(o);case"mm":return S.s(o,2,"0");case"s":return String(t.$s);case"ss":return S.s(t.$s,2,"0");case"SSS":return S.s(t.$ms,3,"0");case"Z":return i}return null}(e)||i.replace(":","")})},y.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},y.diff=function(r,d,f){var p,m=this,g=S.p(d),y=I(r),v=(y.utcOffset()-this.utcOffset())*t,w=this-y,_=function(){return S.m(m,y)};switch(g){case h:p=_()/12;break;case u:p=_();break;case l:p=_()/3;break;case c:p=(w-v)/6048e5;break;case a:p=(w-v)/864e5;break;case o:p=w/n;break;case s:p=w/t;break;case i:p=w/e;break;default:p=w}return f?p:S.a(p)},y.daysInMonth=function(){return this.endOf(u).$D},y.$locale=function(){return _[this.$L]},y.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=T(e,t,!0);return r&&(n.$L=r),n},y.clone=function(){return S.w(this.$d,this)},y.toDate=function(){return new Date(this.valueOf())},y.toJSON=function(){return this.isValid()?this.toISOString():null},y.toISOString=function(){return this.$d.toISOString()},y.toString=function(){return this.$d.toUTCString()},g}(),A=C.prototype;return I.prototype=A,[["$ms",r],["$s",i],["$m",s],["$H",o],["$W",a],["$M",u],["$y",h],["$D",d]].forEach(function(e){A[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),I.extend=function(e,t){return e.$i||(e(t,C,I),e.$i=!0),I},I.locale=T,I.isDayjs=E,I.unix=function(e){return I(1e3*e)},I.en=_[w],I.Ls=_,I.p={},I}()},42719(e){e.exports=function(){"use strict";var e="minute",t=/[+-]\d\d(?::?\d\d)?/g,n=/([+-]|\d\d)/g;return function(r,i,s){var o=i.prototype;s.utc=function(e){return new i({date:e,utc:!0,args:arguments})},o.utc=function(t){var n=s(this.toDate(),{locale:this.$L,utc:!0});return t?n.add(this.utcOffset(),e):n},o.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var a=o.parse;o.parse=function(e){e.utc&&(this.$u=!0),this.$utils().u(e.$offset)||(this.$offset=e.$offset),a.call(this,e)};var c=o.init;o.init=function(){if(this.$u){var e=this.$d;this.$y=e.getUTCFullYear(),this.$M=e.getUTCMonth(),this.$D=e.getUTCDate(),this.$W=e.getUTCDay(),this.$H=e.getUTCHours(),this.$m=e.getUTCMinutes(),this.$s=e.getUTCSeconds(),this.$ms=e.getUTCMilliseconds()}else c.call(this)};var u=o.utcOffset;o.utcOffset=function(r,i){var s=this.$utils().u;if(s(r))return this.$u?0:s(this.$offset)?u.call(this):this.$offset;if("string"==typeof r&&(r=function(e){void 0===e&&(e="");var r=e.match(t);if(!r)return null;var i=(""+r[0]).match(n)||["-",0,0],s=i[0],o=60*+i[1]+ +i[2];return 0===o?0:"+"===s?o:-o}(r),null===r))return this;var o=Math.abs(r)<=16?60*r:r;if(0===o)return this.utc(i);var a=this.clone();if(i)return a.$offset=o,a.$u=!1,a;var c=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();return(a=this.local().add(o+c,e)).$offset=o,a.$x.$localOffset=c,a};var l=o.format;o.format=function(e){var t=e||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return l.call(this,t)},o.valueOf=function(){var e=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*e},o.isUTC=function(){return!!this.$u},o.toISOString=function(){return this.toDate().toISOString()},o.toString=function(){return this.toDate().toUTCString()};var h=o.toDate;o.toDate=function(e){return"s"===e&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():h.call(this)};var d=o.diff;o.diff=function(e,t,n){if(e&&this.$u===e.$u)return d.call(this,e,t,n);var r=this.local(),i=s(e).local();return d.call(r,i,t,n)}}}()},71012(e,t,n){"use strict";var r=n(55299);window.JSGlobals||(window.JSGlobals=JSON.parse(document.getElementById(r.d_k).textContent))}},t={};function n(r){var i=t[r];
2if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r].call(s.exports,s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";n(71012);const e=function(e){const t=[];let n=0;for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t[n++]=i:i<2048?(t[n++]=i>>6|192,t[n++]=63&i|128):55296==(64512&i)&&r+1<e.length&&56320==(64512&e.charCodeAt(r+1))?(i=65536+((1023&i)<<10)+(1023&e.charCodeAt(++r)),t[n++]=i>>18|240,t[n++]=i>>12&63|128,t[n++]=i>>6&63|128,t[n++]=63&i|128):(t[n++]=i>>12|224,t[n++]=i>>6&63|128,t[n++]=63&i|128)}return t},t={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:"function"==typeof atob,encodeByteArray(e,t){if(!Array.isArray(e))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=t?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let t=0;t<e.length;
2t+=3){const i=e[t],s=t+1<e.length,o=s?e[t+1]:0,a=t+2<e.length,c=a?e[t+2]:0,u=i>>2,l=(3&i)<<4|o>>4;let h=(15&o)<<2|c>>6,d=63&c;a||(d=64,s||(h=64)),r.push(n[u],n[l],n[h],n[d])}return r.join("")},encodeString(t,n){return this.HAS_NATIVE_SUPPORT&&!n?btoa(t):this.encodeByteArray(e(t),n)},decodeString(e,t){return this.HAS_NATIVE_SUPPORT&&!t?atob(e):function(e){const t=[];let n=0,r=0;for(;n<e.length;){const i=e[n++];if(i<128)t[r++]=String.fromCharCode(i);else if(i>191&&i<224){const s=e[n++];t[r++]=String.fromCharCode((31&i)<<6|63&s)}else if(i>239&&i<365){const s=((7&i)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536;t[r++]=String.fromCharCode(55296+(s>>10)),t[r++]=String.fromCharCode(56320+(1023&s))}else{const s=e[n++],o=e[n++];t[r++]=String.fromCharCode((15&i)<<12|(63&s)<<6|63&o)}}return t.join("")}(this.decodeStringToByteArray(e,t))},decodeStringToByteArray(e,t){this.init_();const n=t?this.charToByteMapWebSafe_:this.charToByteMap_,i=[];for(let t=0;t<e.length;){const s=n[e.charAt(t++)],o=t<e.length?n[e.charAt(t)]:0;++t;const a=t<e.length?n[e.charAt(t)]:64;++t;const c=t<e.length?n[e.charAt(t)]:64;if(++t,null==s||null==o||null==a||null==c)throw new r;const u=s<<2|o>>4;if(i.push(u),64!==a){const e=o<<4&240|a>>2;if(i.push(e),64!==c){const e=a<<6&192|c;i.push(e)}}}return i},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let e=0;e<this.ENCODED_VALS.length;e++)this.byteToCharMap_[e]=this.ENCODED_VALS.charAt(e),this.charToByteMap_[this.byteToCharMap_[e]]=e,this.byteToCharMapWebSafe_[e]=this.ENCODED_VALS_WEBSAFE.charAt(e),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[e]]=e,e>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(e)]=e,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(e)]=e)}}};class r extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const i=function(n){return function(n){const r=e(n);return t.encodeByteArray(r,!0)}(n).replace(/\./g,"")},s=function(e){try{return t.decodeString(e,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function o(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n.g)return n.g;throw new Error("Unable to locate global object.")}const a=()=>{try{return o().__FIREBASE_DEFAULTS__||(()=>{if("undefined"==typeof process)return;const e={NODE_ENV:"production",npm_config_domain:""}.__FIREBASE_DEFAULTS__;return e?JSON.parse(e):void 0})()||(()=>{if("undefined"==typeof document)return;let e;try{e=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch(e){return}const t=e&&s(e[1]);return t&&JSON.parse(t)})()}catch(e){return void console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${e}`)}},c=e=>{const t=(e=>{var t,n;return null===(n=null===(t=a())||void 0===t?void 0:t.emulatorHosts)||void 0===n?void 0:n[e]})(e);if(!t)return;const n=t.lastIndexOf(":");if(n<=0||n+1===t.length)throw new Error(`Invalid host ${t} with no separate hostname and port!`);const r=parseInt(t.substring(n+1),10);return"["===t[0]?[t.substring(1,n-1),r]:[t.substring(0,n),r]},u=()=>{var e;return null===(e=a())||void 0===e?void 0:e.config};class l{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}wrapCallback(e){return(t,n)=>{t?this.reject(t):this.resolve(n),"function"==typeof e&&(this.promise.catch(()=>{}),1===e.length?e(t):e(t,n))}}}function h(e){try{return(e.startsWith("http://")||e.startsWith("https://")?new URL(e).hostname:e).endsWith(".cloudworkstations.dev")}catch(e){return!1}}async function d(e){return(await fetch(e,{credentials:"include"})).ok}const f={};let p=!1;function m(e,t){if("undefined"==typeof window||"undefined"==typeof document||!h(window.location.host)||f[e]===t||f[e]||p)return;function n(e){return`__firebase__banner__${e}`}f[e]=t;const r="__firebase__banner",i=function(){const e={prod:[],emulator:[]};for(const t of Object.keys(f))f[t]?e.emulator.push(t):e.prod.push(t);return e}().prod.length>0;function s(){const e=document.createElement("span");
2return e.style.cursor="pointer",e.style.marginLeft="16px",e.style.fontSize="24px",e.innerHTML=" ×",e.onclick=()=>{p=!0,function(){const e=document.getElementById(r);e&&e.remove()}()},e}function o(){const e=function(e){let t=document.getElementById(e),n=!1;return t||(t=document.createElement("div"),t.setAttribute("id",e),n=!0),{created:n,element:t}}(r),t=n("text"),o=document.getElementById(t)||document.createElement("span"),a=n("learnmore"),c=document.getElementById(a)||document.createElement("a"),u=n("preprendIcon"),l=document.getElementById(u)||document.createElementNS("http://www.w3.org/2000/svg","svg");if(e.created){const t=e.element;!function(e){e.style.display="flex",e.style.background="#7faaf0",e.style.position="fixed",e.style.bottom="5px",e.style.left="5px",e.style.padding=".5em",e.style.borderRadius="5px",e.style.alignItems="center"}(t),function(e,t){e.setAttribute("id",t),e.innerText="Learn more",e.href="https://firebase.google.com/docs/studio/preview-apps#preview-backend",e.setAttribute("target","__blank"),e.style.paddingLeft="5px",e.style.textDecoration="underline"}(c,a);const n=s();!function(e,t){e.setAttribute("width","24"),e.setAttribute("id",t),e.setAttribute("height","24"),e.setAttribute("viewBox","0 0 24 24"),e.setAttribute("fill","none"),e.style.marginLeft="-6px"}(l,u),t.append(l,o,c,n),document.body.appendChild(t)}i?(o.innerText="Preview backend disconnected.",l.innerHTML='<g clip-path="url(#clip0_6013_33858)">\n<path d="M4.8 17.6L12 5.6L19.2 17.6H4.8ZM6.91667 16.4H17.0833L12 7.93333L6.91667 16.4ZM12 15.6C12.1667 15.6 12.3056 15.5444 12.4167 15.4333C12.5389 15.3111 12.6 15.1667 12.6 15C12.6 14.8333 12.5389 14.6944 12.4167 14.5833C12.3056 14.4611 12.1667 14.4 12 14.4C11.8333 14.4 11.6889 14.4611 11.5667 14.5833C11.4556 14.6944 11.4 14.8333 11.4 15C11.4 15.1667 11.4556 15.3111 11.5667 15.4333C11.6889 15.5444 11.8333 15.6 12 15.6ZM11.4 13.6H12.6V10.4H11.4V13.6Z" fill="#212121"/>\n</g>\n<defs>\n<clipPath id="clip0_6013_33858">\n<rect width="24" height="24" fill="white"/>\n</clipPath>\n</defs>'):(l.innerHTML='<g clip-path="url(#clip0_6083_34804)">\n<path d="M11.4 15.2H12.6V11.2H11.4V15.2ZM12 10C12.1667 10 12.3056 9.94444 12.4167 9.83333C12.5389 9.71111 12.6 9.56667 12.6 9.4C12.6 9.23333 12.5389 9.09444 12.4167 8.98333C12.3056 8.86111 12.1667 8.8 12 8.8C11.8333 8.8 11.6889 8.86111 11.5667 8.98333C11.4556 9.09444 11.4 9.23333 11.4 9.4C11.4 9.56667 11.4556 9.71111 11.5667 9.83333C11.6889 9.94444 11.8333 10 12 10ZM12 18.4C11.1222 18.4 10.2944 18.2333 9.51667 17.9C8.73889 17.5667 8.05556 17.1111 7.46667 16.5333C6.88889 15.9444 6.43333 15.2611 6.1 14.4833C5.76667 13.7056 5.6 12.8778 5.6 12C5.6 11.1111 5.76667 10.2833 6.1 9.51667C6.43333 8.73889 6.88889 8.06111 7.46667 7.48333C8.05556 6.89444 8.73889 6.43333 9.51667 6.1C10.2944 5.76667 11.1222 5.6 12 5.6C12.8889 5.6 13.7167 5.76667 14.4833 6.1C15.2611 6.43333 15.9389 6.89444 16.5167 7.48333C17.1056 8.06111 17.5667 8.73889 17.9 9.51667C18.2333 10.2833 18.4 11.1111 18.4 12C18.4 12.8778 18.2333 13.7056 17.9 14.4833C17.5667 15.2611 17.1056 15.9444 16.5167 16.5333C15.9389 17.1111 15.2611 17.5667 14.4833 17.9C13.7167 18.2333 12.8889 18.4 12 18.4ZM12 17.2C13.4444 17.2 14.6722 16.6944 15.6833 15.6833C16.6944 14.6722 17.2 13.4444 17.2 12C17.2 10.5556 16.6944 9.32778 15.6833 8.31667C14.6722 7.30555 13.4444 6.8 12 6.8C10.5556 6.8 9.32778 7.30555 8.31667 8.31667C7.30556 9.32778 6.8 10.5556 6.8 12C6.8 13.4444 7.30556 14.6722 8.31667 15.6833C9.32778 16.6944 10.5556 17.2 12 17.2Z" fill="#212121"/>\n</g>\n<defs>\n<clipPath id="clip0_6083_34804">\n<rect width="24" height="24" fill="white"/>\n</clipPath>\n</defs>',o.innerText="Preview backend running in this workspace."),o.setAttribute("id",t)}"loading"===document.readyState?window.addEventListener("DOMContentLoaded",o):o()}function g(){return"undefined"!=typeof navigator&&"string"==typeof navigator.userAgent?navigator.userAgent:""}function y(){var e;const t=null===(e=a())||void 0===e?void 0:e.forceEnvironment;if("node"===t)return!0;if("browser"===t)return!1;try{return"[object process]"===Object.prototype.toString.call(n.g.process)}catch(e){return!1}}function v(){return!y()&&!!navigator.userAgent&&navigator.userAgent.includes("Safari")&&!navigator.userAgent.includes("Chrome")}function w(){try{return"object"==typeof indexedDB}catch(e){return!1}}
2class _ extends Error{constructor(e,t,n){super(t),this.code=e,this.customData=n,this.name="FirebaseError",Object.setPrototypeOf(this,_.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,b.prototype.create)}}class b{constructor(e,t,n){this.service=e,this.serviceName=t,this.errors=n}create(e,...t){const n=t[0]||{},r=`${this.service}/${e}`,i=this.errors[e],s=i?function(e,t){return e.replace(E,(e,n)=>{const r=t[n];return null!=r?String(r):`<${n}?>`})}(i,n):"Error",o=`${this.serviceName}: ${s} (${r}).`;return new _(r,o,n)}}const E=/\{\$([^}]+)}/g;function T(e,t){if(e===t)return!0;const n=Object.keys(e),r=Object.keys(t);for(const i of n){if(!r.includes(i))return!1;const n=e[i],s=t[i];if(I(n)&&I(s)){if(!T(n,s))return!1}else if(n!==s)return!1}for(const e of r)if(!n.includes(e))return!1;return!0}function I(e){return null!==e&&"object"==typeof e}function S(e){const t=[];for(const[n,r]of Object.entries(e))Array.isArray(r)?r.forEach(e=>{t.push(encodeURIComponent(n)+"="+encodeURIComponent(e))}):t.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return t.length?"&"+t.join("&"):""}function C(e){const t={};return e.replace(/^\?/,"").split("&").forEach(e=>{if(e){const[n,r]=e.split("=");
2t[decodeURIComponent(n)]=decodeURIComponent(r)}}),t}function A(e){const t=e.indexOf("?");if(!t)return"";const n=e.indexOf("#",t);return e.substring(t,n>0?n:void 0)}class k{constructor(e,t){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=t,this.task.then(()=>{e(this)}).catch(e=>{this.error(e)})}next(e){this.forEachObserver(t=>{t.next(e)})}error(e){this.forEachObserver(t=>{t.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,t,n){let r;if(void 0===e&&void 0===t&&void 0===n)throw new Error("Missing Observer.");r=function(e,t){if("object"!=typeof e||null===e)return!1;for(const n of t)if(n in e&&"function"==typeof e[n])return!0;return!1}(e,["next","error","complete"])?e:{next:e,error:t,complete:n},void 0===r.next&&(r.next=N),void 0===r.error&&(r.error=N),void 0===r.complete&&(r.complete=N);const i=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?r.error(this.finalError):r.complete()}catch(e){}}),this.observers.push(r),i}unsubscribeOne(e){void 0!==this.observers&&void 0!==this.observers[e]&&(delete this.observers[e],this.observerCount-=1,0===this.observerCount&&void 0!==this.onNoObservers&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let t=0;t<this.observers.length;t++)this.sendOne(t,e)}sendOne(e,t){this.task.then(()=>{if(void 0!==this.observers&&void 0!==this.observers[e])try{t(this.observers[e])}catch(e){"undefined"!=typeof console&&console.error&&console.error(e)}})}close(e){this.finalized||(this.finalized=!0,void 0!==e&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function N(){}function O(e){return e&&e._delegate?e._delegate:e}class D{constructor(e,t,n){this.name=e,this.instanceFactory=t,this.type=n,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}const R="[DEFAULT]";class P{constructor(e,t){this.name=e,this.container=t,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const t=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(t)){const e=new l;if(this.instancesDeferred.set(t,e),this.isInitialized(t)||this.shouldAutoInitialize())try{const n=this.getOrInitializeService({instanceIdentifier:t});n&&e.resolve(n)}catch(e){}}return this.instancesDeferred.get(t).promise}getImmediate(e){var t;const n=this.normalizeInstanceIdentifier(null==e?void 0:e.identifier),r=null!==(t=null==e?void 0:e.optional)&&void 0!==t&&t;if(!this.isInitialized(n)&&!this.shouldAutoInitialize()){if(r)return null;throw Error(`Service ${this.name} is not available`)}try{return this.getOrInitializeService({instanceIdentifier:n})}catch(e){if(r)return null;throw e}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,this.shouldAutoInitialize()){if(function(e){return"EAGER"===e.instantiationMode}(e))try{this.getOrInitializeService({instanceIdentifier:R})}catch(e){}for(const[e,t]of this.instancesDeferred.entries()){const n=this.normalizeInstanceIdentifier(e);try{const e=this.getOrInitializeService({instanceIdentifier:n});t.resolve(e)}catch(e){}}}}clearInstance(e=R){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(e=>"INTERNAL"in e).map(e=>e.INTERNAL.delete()),...e.filter(e=>"_delete"in e).map(e=>e._delete())])}isComponentSet(){return null!=this.component}isInitialized(e=R){return this.instances.has(e)}getOptions(e=R){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:t={}}=e,n=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(n))throw Error(`${this.name}(${n}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const r=this.getOrInitializeService({instanceIdentifier:n,options:t});for(const[e,t]of this.instancesDeferred.entries()){n===this.normalizeInstanceIdentifier(e)&&t.resolve(r)}return r}onInit(e,t){var n;const r=this.normalizeInstanceIdentifier(t),i=null!==(n=this.onInitCallbacks.get(r))&&void 0!==n?n:new Set;i.add(e),this.onInitCallbacks.set(r,i);const s=this.instances.get(r);return s&&e(s,r),()=>{i.delete(e)}}invokeOnInitCallbacks(e,t){const n=this.onInitCallbacks.get(t);if(n)for(const r of n)try{r(e,t)}catch(e){}}getOrInitializeService({instanceIdentifier:e,options:t={}}){let n=this.instances.get(e);if(!n&&this.component&&(n=this.component.instanceFactory(this.container,{instanceIdentifier:(r=e,r===R?void 0:r),options:t}),this.instances.set(e,n),this.instancesOptions.set(e,t),this.invokeOnInitCallbacks(n,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,n)}catch(e){}var r;return n||null}normalizeInstanceIdentifier(e=R){return this.component?this.component.multipleInstances?e:R:e}shouldAutoInitialize(){return!!this.component&&"EXPLICIT"!==this.component.instantiationMode}}class L{constructor(e){this.name=e,this.providers=new Map}addComponent(e){const t=this.getProvider(e.name);if(t.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);t.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const t=new P(e,this);return this.providers.set(e,t),t}getProviders(){return Array.from(this.providers.values())}}const M=[];var x;!function(e){e[e.DEBUG=0]="DEBUG",e[e.VERBOSE=1]="VERBOSE",e[e.INFO=2]="INFO",e[e.WARN=3]="WARN",e[e.E
vendor: 5,657 bytes, line 2
2RROR=4]="ERROR",e[e.SILENT=5]="SILENT"}(x||(x={}));const F={debug:x.DEBUG,verbose:x.VERBOSE,info:x.INFO,warn:x.WARN,error:x.ERROR,silent:x.SILENT},U=x.INFO,V={[x.DEBUG]:"log",[x.VERBOSE]:"log",[x.INFO]:"info",[x.WARN]:"warn",[x.ERROR]:"error"},j=(e,t,...n)=>{if(t<e.logLevel)return;const r=(new Date).toISOString(),i=V[t];if(!i)throw new Error(`Attempted to log a message with an invalid logType (value: ${t})`);console[i](`[${r}] ${e.name}:`,...n)};class ${constructor(e){this.name=e,this._logLevel=U,this._logHandler=j,this._userLogHandler=null,M.push(this)}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in x))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel="string"==typeof e?F[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if("function"!=typeof e)throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,x.DEBUG,...e),this._logHandler(this,x.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,x.VERBOSE,...e),this._logHandler(this,x.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,x.INFO,...e),this._logHandler(this,x.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,x.WARN,...e),this._logHandler(this,x.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,x.ERROR,...e),this._logHandler(this,x.ERROR,...e)}}let B,q;const z=new WeakMap,H=new WeakMap,G=new WeakMap,K=new WeakMap,W=new WeakMap;let Y={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return H.get(e);if("objectStoreNames"===t)return e.objectStoreNames||G.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return X(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function Q(e){return e!==IDBDatabase.prototype.transaction||"objectStoreNames"in IDBTransaction.prototype?(q||(q=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Z(this),t),X(z.get(this))}:function(...t){return X(e.apply(Z(this),t))}:function(t,...n){const r=e.call(Z(this),t,...n);return G.set(r,t.sort?t.sort():[t]),X(r)}}function J(e){return"function"==typeof e?Q(e):(e instanceof IDBTransaction&&function(e){if(H.has(e))return;const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",s),e.removeEventListener("abort",s)},i=()=>{t(),r()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",s),e.addEventListener("abort",s)});H.set(e,t)}(e),t=e,(B||(B=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])).some(e=>t instanceof e)?new Proxy(e,Y):e);var t}function X(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",s)},i=()=>{t(X(e.result)),r()},s=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",s)});return t.then(t=>{t instanceof IDBCursor&&z.set(t,e)}).catch(()=>{}),W.set(t,e),t}(e);if(K.has(e))return K.get(e);const t=J(e);return t!==e&&(K.set(e,t),W.set(t,e)),t}const Z=e=>W.get(e);const ee=["get","getKey","getAll","getAllKeys","count"],te=["put","add","delete","clear"],ne=new Map;function re(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(ne.get(t))return ne.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=te.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!ee.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,i?"readwrite":"readonly");let o=s.store;return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&s.done]))[0]};return ne.set(t,s),s}Y=(e=>({...e,get:(t,n,r)=>re(t,n)||e.get(t,n,r),has:(t,n)=>!!re(t,n)||e.has(t,n)}))(Y);class ie{constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(e=>{if(function(e){const t=e.getComponent();return"VERSION"===(null==t?void 0:t.type)}(e)){const t=e.getImmediate();return`${t.library}/${t.version}`}return null}).filter(e=>e).join(" ")}}const se="@firebase/app",oe="0.13.2",ae=new $("@firebase/app"),ce="@firebase/app-compat",ue="@firebase/analytics-compat",le="@firebase/analytics",he="@firebase/app-check-compat",de="@firebase/app-check",fe="@firebase/auth",pe="@firebase/auth-compat",me="@firebase/database",ge="@firebase/data-connect",ye="@firebase/database-compat",ve="@firebase/functions",we="@firebase/functions-compat",_e="@firebase/installations",be="@firebase/installations-compat",Ee="@firebase/messaging",Te="@firebase/messaging-compat",Ie="@firebase/performance",Se="@firebase/performance-compat",Ce="@firebase/remote-config",Ae="@firebase/remote-config-compat",ke="@firebase/storage",Ne="@firebase/storage-compat",Oe="@firebase/firestore",De="@firebase/ai",Re="@firebase/firestore-compat",Pe="firebase",Le="[DEFAULT]",Me={[se]:"fire-core",[ce]:"fire-core-compat",[le]:"fire-analytics",[ue]:"fire-analytics-compat",[de]:"fire-app-check",[he]:"fire-app-check-compat",[fe]:"fire-auth",[pe]:"fire-auth-compat",[me]:"fire-rtdb",[ge]:"fire-data-connect",[ye]:"fire-rtdb-compat",[ve]:"fire-fn",[we]:"fire-fn-compat",[_e]:"fire-iid",[be]:"fire-iid-compat",[Ee]:"fire-fcm",[Te]:"fire-fcm-compat",[Ie]:"fire-perf",[Se]:"fire-perf-compat",[Ce]:"fire-rc",[Ae]:"fire-rc-compat",[ke]:"fire-g
2cs",[Ne]:"fire-gcs-compat",[Oe]:"fire-fst",[Re]:"fire-fst-compat",[De]:"fire-vertex","fire-js":"fire-js",[Pe]:"fire-js-all"},xe=new Map,Fe=new Map,Ue=new Map;function Ve(e,t){try{e.container.addComponent(t)}catch(n){ae.debug(`Component ${t.name} failed to register with FirebaseApp ${e.name}`,n)}}function je(e){const t=e.name;if(Ue.has(t))return ae.debug(`There were multiple attempts to register component ${t}.`),!1;Ue.set(t,e);for(const t of xe.values())Ve(t,e);for(const t of Fe.values())Ve(t,e);return!0}function $e(e,t){const n=e.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),e.container.getProvider(t)}function Be(e){return null!=e&&void 0!==e.settings}const qe=new b("app","Firebase",{"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different options or config","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invali
2d-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."});class ze{constructor(e,t,n){this._isDeleted=!1,this._options=Object.assign({},e),this._config=Object.assign({},t),this._name=t.name,this._automaticDataCollectionEnabled=t.automaticDataCollectionEnabled,this._container=n,this.container.addComponent(new D("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw qe.create("app-deleted",{appName:this._name})}}const He="11.10.0";function Ge(e,t={}){let n=e;if("object"!=typeof t){t={name:t}}const r=Object.assign({name:Le,automaticDataCollectionEnabled:!0},t),i=r.name;if("string"!=typeof i||!i)throw qe.create("bad-app-name",{appName:String(i)});if(n||(n=u()),!n)throw qe.create("no-options");const s=xe.get(i);if(s){if(T(n,s.options)&&T(r,s.config))return s;throw qe.create("duplicate-app",{appName:i})}const o=new L(i);for(const e of Ue.values())o.addComponent(e);const a=new ze(n,r,o);return xe.set(i,a),a}function Ke(){return Array.from(xe.values())}function We(e,t,n){var r;let i=null!==(r=Me[e])&&void 0!==r?r:e;n&&(i+=`-${n}`);const s=i.match(/\s|\//),o=t.match(/\s|\//);if(s||o){const e=[`Unable to register library "${i}" with version "${t}":`];return s&&e.push(`library name "${i}" contains illegal characters (whitespace or "/")`),s&&o&&e.push("and"),o&&e.push(`version name "${t}" contains illegal characters (whitespace or "/")`),void ae.warn(e.join(" "))}je(new D(`${i}-version`,()=>({library:i,version:t}),"VERSION"))}const Ye="firebase-heartbeat-store";let Qe=null;function Je(){return Qe||(Qe=function(e,t,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(e,t),a=X(o);return r&&o.addEventListener("upgradeneeded",e=>{r(X(o.result),e.oldVersion,e.newVersion,X(o.transaction),e)}),n&&o.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),a.then(e=>{s&&e.addEventListener("close",()=>s()),i&&e.addEventListener("versionchange",e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),a}("firebase-heartbeat-database",1,{upgrade:(e,t)=>{if(0===t)try{e.createObjectStore(Ye)}catch(e){console.warn(e)}}}).catch(e=>{throw qe.create("idb-open",{originalErrorMessage:e.message})})),Qe}async function Xe(e,t){try{const n=(await Je()).transaction(Ye,"readwrite"),r=n.objectStore(Ye);await r.put(t,Ze(e)),await n.done}catch(e){if(e instanceof _)ae.warn(e.message);else{const t=qe.create("idb-set",{originalErrorMessage:null==e?void 0:e.message});ae.warn(t.message)}}}function Ze(e){return`${e.name}!${e.options.appId}`}class et{constructor(e){this.container=e,this._heartbeatsCache=null;const t=this.container.getProvider("app").getImmediate();this._storage=new nt(t),this._heartbeatsCachePromise=this._storage.read().then(e=>(this._heartbeatsCache=e,e))}async triggerHeartbeat(){var e,t;try{const n=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=tt();if(null==(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)&&(this._heartbeatsCache=await this._heartbeatsCachePromise,null==(null===(t=this._heartbeatsCache)||void 0===t?void 0:t.heartbeats)))return;if(this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(e=>e.date===r))return;if(this._heartbeatsCache.heartbeats.push({date:r,agent:n}),this._heartbeatsCache.heartbeats.length>30){const e=function(e){if(0===e.length)return-1;let t=0,n=e[0].date;for(let r=1;r<e.length;r++)e[r].date<n&&(n=e[r].date,t=r);return t}(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(e,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){ae.warn(e)}}async getHeartbeatsHeader(){var e;try{if(null===this._heartbeatsCache&&await this._heartbeatsCachePromise,null==(null===(e=this._heartbeatsCache)||void 0===e?void 0:e.heartbeats)||0===this._heartbeatsCache.heartbeats.length)return"";const t=tt(),{heartbeatsToSend:n,unsentEntries:r}=function(e,t=1024){const n=[];let r=e.slice();for(const i of e){const e=n.find(e=>e.agent===i.agent);if(e){if(e.dates.push(i.date),rt(n)>t){e.dates.pop();break}}else if(n.push({agent:i.agent,dates:[i.date]}),rt(n)>t){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}(this._heartbeatsCache.heartbeats),s=i(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=t,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),s}catch(e){return ae.warn(e),""}}}function tt(){return(new Date).toISOString().substring(0,10)}class nt{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return!!w()&&new Promise((e,t)=>
2{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),e(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{var e;t((null===(e=i.error)||void 0===e?void 0:e.message)||"")}}catch(e){t(e)}}).then(()=>!0).catch(()=>!1)}async read(){if(await this._canUseIndexedDBPromise){const e=await async function(e){try{const t=(await Je()).transaction(Ye),n=await t.objectStore(Ye).get(Ze(e));return await t.done,n}catch(e){if(e instanceof _)ae.warn(e.message);else{const t=qe.create("idb-get",{originalErrorMessage:null==e?void 0:e.message});ae.warn(t.message)}}}(this.app);return(null==e?void 0:e.heartbeats)?e:{heartbeats:[]}}return{heartbeats:[]}}async overwrite(e){var t;if(await this._canUseIndexedDBPromise){const n=await this.read();return Xe(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:e.heartbeats})}}async add(e){var t;if(await this._canUseIndexedDBPromise){const n=await this.read();return Xe(this.app,{lastSentHeartbeatDate:null!==(t=e.lastSentHeartbeatDate)&&void 0!==t?t:n.lastSentHeartbeatDate,heartbeats:[...n.heartbeats,...e.heartbeats]})}}}function rt(e){return i(JSON.stringify({version:2,heartbeats:e})).length}var it;it="",je(new D("platform-logger",e=>new ie(e),"PRIVATE")),je(new D("heartbeat",e=>new et(e),"PRIVATE")),We(se,oe,it),We(se,oe,"esm2017"),We("fire-js","");We("firebase","11.10.0","app");function st(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}Object.create;Object.create;"function"==typeof SuppressedError&&SuppressedError;function ot(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const at=ot,ct=new b("auth","Firebase",{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}),ut=new $("@firebase/auth");function lt(e,...t){ut.logLevel<=x.ERROR&&ut.error(`Auth (${He}): ${e}`,...t)}function ht(e,...t){throw gt(e,...t)}function dt(e,...t){return gt(e,...t)}function ft(e,t,n){const r=Object.assign(Object.assign({},at()),{[t]:n});return new b("auth","Firebase",r).create(t,{appName:e.name})}function pt(e){return ft(e,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function mt(e,t,n){if(!(t instanceof n))throw n.name!==t.constructor.name&&ht(e,"argument-error"),ft(e,"argument-error",`Type of ${t.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function gt(e,...t){if("string"!=typeof e){const n=t[0],r=[...t.slice(1)];return r[0]&&(r[0].appName=e.name),e._errorFactory.create(n,...r)}return ct.create(e,...t)}function yt(e,t,...n){if(!e)throw gt(t,...n)}function vt(e){const t="INTERNAL ASSERTION FAILED: "+e;throw lt(t),new Error(t)}function wt(e,t){e||vt(t)}function _t(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.href)||""}function bt(){return"http:"===Et()||"https:"===Et()}function Et(){var e;return"undefined"!=typeof self&&(null===(e=self.location)||void 0===e?void 0:e.protocol)||null}function Tt(){return!("undefined"!=typeof navigator&&navigator&&"onLine"in navigator&&"boolean"==typeof navigator.onLine&&(bt()||function(){const e="object"==typeof chrome?chrome.runtime:"object"==typeof browser?browser.runtime:void 0;return"object"==typeof e&&void 0!==e.id}()||"connection"in navigator))||navigator.onLine}class It{constructor(e,t){this.shortDelay=e,this.longDelay=t,wt(t>
vendor: 6,226 bytes, line 2
2e,"Short delay should be less than long delay!"),this.isMobile="undefined"!=typeof window&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(g())||"object"==typeof navigator&&"ReactNative"===navigator.product}get(){return Tt()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function St(e,t){wt(e.emulator,"Emulator should always be set here");const{url:n}=e.emulator;return t?`${n}${t.startsWith("/")?t.slice(1):t}`:n}class Ct{static initialize(e,t,n){this.fetchImpl=e,t&&(this.headersImpl=t),n&&(this.responseImpl=n)}static fetch(){return this.fetchImpl?this.fetchImpl:"undefined"!=typeof self&&"fetch"in self?self.fetch:"undefined"!=typeof globalThis&&globalThis.fetch?globalThis.fetch:"undefined"!=typeof fetch?fetch:void vt("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){return this.headersImpl?this.headersImpl:"undefined"!=typeof self&&"Headers"in self?self.Headers:"undefined"!=typeof globalThis&&globalThis.Headers?globalThis.Headers:"undefined"!=typeof Headers?Headers:void vt("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){return this.responseImpl?this.responseImpl:"undefined"!=typeof self&&"Response"in self?self.Response:"undefined"!=typeof globalThis&&globalThis.Response?globalThis.Response:"undefined"!=typeof Response?Response:void vt("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const At={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"},kt=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],Nt=new It(3e4,6e4);function Ot(e,t){return e.tenantId&&!t.tenantId?Object.assign(Object.assign({},t),{tenantId:e.tenantId}):t}async function Dt(e,t,n,r,i={}){return Rt(e,i,async()=>{let i={},s={};r&&("GET"===t?s=r:i={body:JSON.stringify(r)});const o=S(Object.assign({key:e.config.apiKey},s)).slice(1),a=await e._getAdditionalHeaders();a["Content-Type"]="application/json",e.languageCode&&(a["X-Firebase-Locale"]=e.languageCode);const c=Object.assign({method:t,headers:a},i);return"undefined"!=typeof navigator&&"Cloudflare-Workers"===navigator.userAgent||(c.referrerPolicy="no-referrer"),e.emulatorConfig&&h(e.emulatorConfig.host)&&(c.credentials="include"),Ct.fetch()(await Lt(e,e.config.apiHost,n,o),c)})}async function Rt(e,t,n){e._canInitEmulator=!1;const r=Object.assign(Object.assign({},At),t);try{const t=new xt(e),i=await Promise.race([n(),t.promise]);t.clearNetworkTimeout();const s=await i.json();if("needConfirmation"in s)throw Ft(e,"account-exists-with-different-credential",s);if(i.ok&&!("errorMessage"in s))return s;{const t=i.ok?s.errorMessage:s.error.message,[n,o]=t.split(" : ");if("FEDERATED_USER_ID_ALREADY_LINKED"===n)throw Ft(e,"credential-already-in-use",s);if("EMAIL_EXISTS"===n)throw Ft(e,"email-already-in-use",s);if("USER_DISABLED"===n)throw Ft(e,"user-disabled",s);const a=r[n]||n.toLowerCase().replace(/[_\s]+/g,"-");if(o)throw ft(e,a,o);ht(e,a)}}catch(t){if(t instanceof _)throw t;ht(e,"network-request-failed",{message:String(t)})}}async function Pt(e,t,n,r,i={}){const s=await Dt(e,t,n,r,i);return"mfaPendingCredential"in s&&ht(e,"multi-factor-auth-required",{_serverResponse:s}),s}async function Lt(e,t,n,r){const i=`${t}${n}?${r}`,s=e,o=s.config.emulator?St(e.config,i):`${e.config.apiScheme}://${i}`;if(kt.includes(n)&&(await s._persistenceManagerAvailable,"COOKIE"===s._getPersistenceType())){return s._getPersistence()._getFinalTarget(o).toString()}return o}function Mt(e){switch(e){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class xt{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((e,t)=>
2{this.timer=setTimeout(()=>t(dt(this.auth,"network-request-failed")),Nt.get())})}}function Ft(e,t,n){const r={appName:e.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=dt(e,t,r);return i.customData._tokenResponse=n,i}function Ut(e){return void 0!==e&&void 0!==e.enterprise}class Vt{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],void 0===e.recaptchaKey)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||0===this.recaptchaEnforcementState.length)return null;for(const t of this.recaptchaEnforcementState)if(t.provider&&t.provider===e)return Mt(t.enforcementState);return null}isProviderEnabled(e){return"ENFORCE"===this.getProviderEnforcementState(e)||"AUDIT"===this.getProviderEnforcementState(e)}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function jt(e,t){return Dt(e,"GET","/v2/recaptchaConfig",Ot(e,t))}async function $t(e,t){return Dt(e,"POST","/v1/accounts:lookup",t)}function Bt(e){if(e)try{const t=new Date(Number(e));if(!isNaN(t.getTime()))return t.toUTCString()}catch(e){}}function qt(e){return 1e3*Number(e)}function zt(e){const[t,n,r]=e.split(".");if(void 0===t||void 0===n||void 0===r)return lt("JWT malformed, contained fewer than 3 sections"),null;try{const e=s(n);return e?JSON.parse(e):(lt("Failed to decode base64 JWT payload"),null)}catch(e){return lt("Caught error parsing JWT payload as JSON",null==e?void 0:e.toString()),null}}function Ht(e){const t=zt(e);return yt(t,"internal-error"),yt(void 0!==t.exp,"internal-error"),yt(void 0!==t.iat,"internal-error"),Number(t.exp)-Number(t.iat)}async function Gt(e,t,n=!1){if(n)return t;try{return await t}catch(t){throw t instanceof _&&function({code:e}){return"auth/user-disabled"===e||"auth/user-token-expired"===e}(t)&&e.auth.currentUser===e&&await e.auth.signOut(),t}}class Kt{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,null!==this.timerId&&clearTimeout(this.timerId))}getInterval(e){var t;if(e){const e=this.errorBackoff;return this.errorBackoff=Math.min(2*this.errorBackoff,96e4),e}{this.errorBackoff=3e4;const e=(null!==(t=this.user.stsTokenManager.expirationTime)&&void 0!==t?t:0)-Date.now()-3e5;return Math.max(0,e)}}schedule(e=!1){if(!this.isRunning)return;const t=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},t)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){return void("auth/network-request-failed"===(null==e?void 0:e.code)&&this.schedule(!0))}this.schedule()}}class Wt{constructor(e,t){this.createdAt=e,this.lastLoginAt=t,this._initializeTime()}_initializeTime(){this.lastSignInTime=Bt(this.lastLoginAt),this.creationTime=Bt(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function Yt(e){var t;const n=e.auth,r=await e.getIdToken(),i=await Gt(e,$t(n,{idToken:r}));yt(null==i?void 0:i.users.length,n,"internal-error");const s=i.users[0];e._notifyReloadListener(s);const o=(null===(t=s.providerUserInfo)||void 0===t?void 0:t.length)?Qt(s.providerUserInfo):[],a=function(e,t){const n=e.filter(e=>!t.some(t=>t.providerId===e.providerId));return[...n,...t]}(e.providerData,o),c=e.isAnonymous,u=!(e.email&&s.passwordHash||(null==a?void 0:a.length)),l=!!c&&u,h={uid:s.localId,displayName:s.displayName||null,photoURL:s.photoUrl||null,email:s.email||null,emailVerified:s.emailVerified||!1,phoneNumber:s.phoneNumber||null,tenantId:s.tenantId||null,providerData:a,metadata:new Wt(s.createdAt,s.lastLoginAt),isAnonymous:l};Object.assign(e,h)}function Qt(e){return e.map(e=>{var{providerId:t}=e,n=st(e,["providerId"]);return{providerId:t,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}})}class Jt{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){yt(e.idToken,"internal-error"),yt(void 0!==e.idToken,"internal-error"),yt(void 0!==e.refreshToken,"internal-error");
vendor: 20,784 bytes, line 2
2const t="expiresIn"in e&&void 0!==e.expiresIn?Number(e.expiresIn):Ht(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,t)}updateFromIdToken(e){yt(0!==e.length,"internal-error");const t=Ht(e);this.updateTokensAndExpiration(e,null,t)}async getToken(e,t=!1){return t||!this.accessToken||this.isExpired?(yt(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null):this.accessToken}clearRefreshToken(){this.refreshToken=null}async refresh(e,t){const{accessToken:n,refreshToken:r,expiresIn:i}=await async function(e,t){const n=await Rt(e,{},async()=>{const n=S({grant_type:"refresh_token",refresh_token:t}).slice(1),{tokenApiHost:r,apiKey:i}=e.config,s=await Lt(e,r,"/v1/token",`key=${i}`),o=await e._getAdditionalHeaders();o["Content-Type"]="application/x-www-form-urlencoded";const a={method:"POST",headers:o,body:n};return e.emulatorConfig&&h(e.emulatorConfig.host)&&(a.credentials="include"),Ct.fetch()(s,a)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}(e,t);this.updateTokensAndExpiration(n,r,Number(i))}updateTokensAndExpiration(e,t,n){this.refreshToken=t||null,this.accessToken=e||null,this.expirationTime=Date.now()+1e3*n}static fromJSON(e,t){const{refreshToken:n,accessToken:r,expirationTime:i}=t,s=new Jt;return n&&(yt("string"==typeof n,"internal-error",{appName:e}),s.refreshToken=n),r&&(yt("string"==typeof r,"internal-error",{appName:e}),s.accessToken=r),i&&(yt("number"==typeof i,"internal-error",{appName:e}),s.expirationTime=i),s}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new Jt,this.toJSON())}_performRefresh(){return vt("not implemented")}}function Xt(e,t){yt("string"==typeof e||void 0===e,"internal-error",{appName:t})}class Zt{constructor(e){var{uid:t,auth:n,stsTokenManager:r}=e,i=st(e,["uid","auth","stsTokenManager"]);this.providerId="firebase",this.proactiveRefresh=new Kt(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=t,this.auth=n,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.providerData=i.providerData?[...i.providerData]:[],this.metadata=new Wt(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){const t=await Gt(this,this.stsTokenManager.getToken(this.auth,e));return yt(t,this.auth,"internal-error"),this.accessToken!==t&&(this.accessToken=t,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),t}getIdTokenResult(e){return async function(e,t=!1){const n=O(e),r=await n.getIdToken(t),i=zt(r);yt(i&&i.exp&&i.auth_time&&i.iat,n.auth,"internal-error");const s="object"==typeof i.firebase?i.firebase:void 0,o=null==s?void 0:s.sign_in_provider;return{claims:i,token:r,authTime:Bt(qt(i.auth_time)),issuedAtTime:Bt(qt(i.iat)),expirationTime:Bt(qt(i.exp)),signInProvider:o||null,signInSecondFactor:(null==s?void 0:s.sign_in_second_factor)||null}}(this,e)}reload(){return async function(e){const t=O(e);await Yt(t),await t.auth._persistUserIfCurrent(t),t.auth._notifyListenersIfCurrent(t)}(this)}_assign(e){this!==e&&(yt(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(e=>Object.assign({},e)),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const t=new Zt(Object.assign(Object.assign({},this),{auth:e,stsTokenManager:this.stsTokenManager._clone()}));return t.metadata._copy(this.metadata),t}_onReload(e){yt(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,t=!1){let n=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),n=!0),t&&await Yt(this),await this.auth._persistUserIfCurrent(this),n&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(Be(this.auth.app))return Promise.reject(pt(this.auth));const e=await this.getIdToken();return await Gt(this,async function(e,t){return Dt(e,"POST","/v1/accounts:delete",t)}(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return Object.assign(Object.assign({uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>Object.assign({},e)),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId},this.metadata.toJSON()),{apiKey:this.auth.config.apiKey,appName:this.auth.name})}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,t){var n,r,i,s,o,a,c,u;const l=null!==(n=t.displayName)&&void 0!==n?n:void 0,h=null!==(r=t.email)&&void 0!==r?r:void 0,d=null!==(i=t.phoneNumber)&&void 0!==i?i:void 0,f=null!==(s=t.photoURL)&&void 0!==s?s:void 0,p=null!==(o=t.tenantId)&&void 0!==o?o:void 0,m=null!==(a=t._redirectEventId)&&void 0!==a?a:void 0,g=null!==(c=t.createdAt)&&void 0!==c?c:void 0,y=null!==(u=t.lastLoginAt)&&void 0!==u?u:void 0,{uid:v,emailVerified:w,isAnonymous:_,providerData:b,stsTokenManager:E}=t;yt(v&&E,e,"internal-error");const T=Jt.fromJSON(this.name,E);yt("string"==typeof v,e,"internal-error"),Xt(l,e.name),Xt(h,e.name),yt("boolean"==typeof w,e,"internal-error"),yt("boolean"==typeof _,e,"internal-error"),Xt(d,e.name),Xt(f,e.name),Xt(p,e.name),Xt(m,e.name),Xt(g,e.name),Xt(y,e.name);const I=new Zt({uid:v,auth:e,email:h,emailVerified:w,displayName:l,isAnonymous:_,photoURL:f,phoneNumber:d,tenantId:p,stsTokenManager:T,createdAt:g,lastLoginAt:y});return b&&Array.isArray(b)&&(I.providerData=b.map(e=>Object.assign({},e))),m&&(I._redirectEventId=m),I}static async _fromIdTokenResponse(e,t,n=!1){const r=new Jt;r.updateFromServerResponse(t);const i=new Zt({uid:t.localId,auth:e,stsTokenManager:r,isAnonymous:n});return await Yt(i),i}static async _fromGetAccountInfoResponse(e,t,n){const r=t.users[0];yt(void 0!==r.localId,"internal-error");const i=void 0!==r.providerUserInfo?Qt(r.providerUserInfo):[],s=!(r.email&&r.passwordHash||(null==i?void 0:i.length)),o=new Jt;o.updateFromIdToken(n);const a=new Zt({uid:r.localId,auth:e,stsTokenManager:o,isAnonymous:s}),c={uid:r.localId,displayName:r.displayName||null,photoURL:r.photoUrl||null,email:r.email||null,emailVerified:r.emailVerified||!1,phoneNumber:r.phoneNumber||null,tenantId:r.tenantId||null,providerData:i,metadata:new Wt(r.createdAt,r.lastLoginAt),isAnonymous:!(r.email&&r.passwordHash||(null==i?void 0:i.length))};return Object.assign(a,c),a}}const en=new Map;function tn(e){wt(e instanceof Function,"Expected a class definition");let t=en.get(e);return t?(wt(t instanceof e,"Instance stored in cache mismatched with class"),t):(t=new e,en.set(e,t),t)}class nn{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,t){this.storage[e]=t}async _get(e){const t=this.storage[e];return void 0===t?null:t}async _remove(e){delete this.storage[e]}_addListener(e,t){}_removeListener(e,t){}}nn.type="NONE";const rn=nn;function sn(e,t,n){return`firebase:${e}:${t}:${n}`}class on{constructor(e,t,n){this.persistence=e,this.auth=t,this.userKey=n;const{config:r,name:i}=this.auth;this.fullUserKey=sn(this.userKey,r.apiKey,i),this.fullPersistenceKey=sn("persistence",r.apiKey,i),this.boundEventHandler=t._onStorageEvent.bind(t),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if("string"==typeof e){const t=await $t(this.auth,{idToken:e}).catch(()=>{});return t?Zt._fromGetAccountInfoResponse(this.auth,t,e):null}return Zt._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const t=await this.getCurrentUser();return await this.removeCurrentUser(),this.persistence=e,t?this.setCurrentUser(t):void 0}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,t,n="authUser"){if(!t.length)return new on(tn(rn),e,n);const r=(await Promise.all(t.map(async e=>{if(await e._isAvailable())return e}))).filter(e=>e);let i=r[0]||tn(rn);const s=sn(n,e.config.apiKey,e.name);let o=null;for(const n of t)try{const t=await n._get(s);if(t){let r;if("string"==typeof t){const n=await $t(e,{idToken:t}).catch(()=>{});if(!n)break;r=await Zt._fromGetAccountInfoResponse(e,n,t)}else r=Zt._fromJSON(e,t);n!==i&&(o=r),i=n;break}}catch(e){}const a=r.filter(e=>e._shouldAllowMigration);return i._shouldAllowMigration&&a.length?(i=a[0],o&&await i._set(s,o.toJSON()),await Promise.all(t.map(async e=>{if(e!==i)try{await e._remove(s)}catch(e){}})),new on(i,e,n)):new on(i,e,n)}}function an(e){const t=e.toLowerCase();if(t.includes("opera/")||t.includes("opr/")||t.includes("opios/"))return"Opera";if(hn(t))return"IEMobile";if(t.includes("msie")||t.includes("trident/"))return"IE";if(t.includes("edge/"))return"Edge";if(cn(t))return"Firefox";if(t.includes("silk/"))return"Silk";if(fn(t))return"Blackberry";if(pn(t))return"Webos";if(un(t))return"Safari";if((t.includes("chrome/")||ln(t))&&!t.includes("edge/"))return"Chrome";if(dn(t))return"Android";{const t=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,n=e.match(t);if(2===(null==n?void 0:n.length))return n[1]}return"Other"}function cn(e=g()){return/firefox\//i.test(e)}function un(e=g()){const t=e.toLowerCase();return t.includes("safari/")&&!t.includes("chrome/")&&!t.includes("crios/")&&!t.includes("android")}function ln(e=g()){return/crios\//i.test(e)}function hn(e=g()){return/iemobile/i.test(e)}function dn(e=g()){return/android/i.test(e)}function fn(e=g()){return/blackberry/i.test(e)}function pn(e=g()){return/webos/i.test(e)}function mn(e=g()){return/iphone|ipad|ipod/i.test(e)||/macintosh/i.test(e)&&/mobile/i.test(e)}function gn(){return function(){const e=g();return e.indexOf("MSIE ")>=0||e.indexOf("Trident/")>=0}()&&10===document.documentMode}function yn(e=g()){return mn(e)||dn(e)||pn(e)||fn(e)||/windows phone/i.test(e)||hn(e)}function vn(e,t=[]){let n;switch(e){case"Browser":n=an(g());break;case"Worker":n=`${an(g())}-${e}`;break;default:n=e}const r=t.length?t.join(","):"FirebaseCore-web";return`${n}/JsCore/${He}/${r}`}class wn{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,t){const n=t=>new Promise((n,r)=>{try{n(e(t))}catch(e){r(e)}});n.onAbort=t,this.queue.push(n);const r=this.queue.length-1;return()=>{this.queue[r]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const t=[];try{for(const n of this.queue)await n(e),n.onAbort&&t.push(n.onAbort)}catch(e){t.reverse();for(const e of t)try{e()}catch(e){}throw this.auth._errorFactory.create("login-blocked",{originalMessage:null==e?void 0:e.message})}}}class _n{constructor(e){var t,n,r,i;const s=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=null!==(t=s.minPasswordLength)&&void 0!==t?t:6,s.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=s.maxPasswordLength),void 0!==s.containsLowercaseCharacter&&(this.customStrengthOptions.containsLowercaseLetter=s.containsLowercaseCharacter),void 0!==s.containsUppercaseCharacter&&(this.customStrengthOptions.containsUppercaseLetter=s.containsUppercaseCharacter),void 0!==s.containsNumericCharacter&&(this.customStrengthOptions.containsNumericCharacter=s.containsNumericCharacter),void 0!==s.containsNonAlphanumericCharacter&&(this.customStrengthOptions.containsNonAlphanumericCharacter=s.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,"ENFORCEMENT_STATE_UNSPECIFIED"===this.enforcementState&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=null!==(r=null===(n=e.allowedNonAlphanumericCharacters)||void 0===n?void 0:n.join(""))&&void 0!==r?r:"",this.forceUpgradeOnSignin=null!==(i=e.forceUpgradeOnSignin)&&void 0!==i&&i,this.schemaVersion=e.schemaVersion}validatePassword(e){var t,n,r,i,s,o;const a={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,a),this.validatePasswordCharacterOptions(e,a),a.isValid&&(a.isValid=null===(t=a.meetsMinPasswordLength)||void 0===t||t),a.isValid&&(a.isValid=null===(n=a.meetsMaxPasswordLength)||void 0===n||n),a.isValid&&(a.isValid=null===(r=a.containsLowercaseLetter)||void 0===r||r),a.isValid&&(a.isValid=null===(i=a.containsUppercaseLetter)||void 0===i||i),a.isValid&&(a.isValid=null===(s=a.containsNumericCharacter)||void 0===s||s),a.isValid&&(a.isValid=null===(o=a.containsNonAlphanumericCharacter)||void 0===o||o),a}validatePasswordLengthOptions(e,t){const n=this.customStrengthOptions.minPasswordLength,r=this.customStrengthOptions.maxPasswordLength;n&&(t.meetsMinPasswordLength=e.length>=n),r&&(t.meetsMaxPasswordLength=e.length<=r)}validatePasswordCharacterOptions(e,t){let n;this.updatePasswordCharacterOptionsStatuses(t,!1,!1,!1,!1);for(let r=0;r<e.length;r++)n=e.charAt(r),this.updatePasswordCharacterOptionsStatuses(t,n>="a"&&n<="z",n>="A"&&n<="Z",n>="0"&&n<="9",this.allowedNonAlphanumericCharacters.includes(n))}updatePasswordCharacterOptionsStatuses(e,t,n,r,i){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=t)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=n)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=r)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=i))}}class bn{constructor(e,t,n,r){this.app=e,this.heartbeatServiceProvider=t,this.appCheckServiceProvider=n,this.config=r,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new Tn(this),this.idTokenSubscription=new Tn(this),this.beforeStateQueue=new wn(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=ct,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=r.sdkClientVersion,this._persistenceManagerAvailable=new Promise(e=>this._resolvePersistenceManagerAvailable=e)}_initializeWithPersistence(e,t){return t&&(this._popupRedirectResolver=tn(t)),this._initializationPromise=this.queue(async()=>{var n,r,i;if(!this._deleted&&(this.persistenceManager=await on.create(this,e),null===(n=this._resolvePersistenceManagerAvailable)||void 0===n||n.call(this),!this._deleted)){if(null===(r=this._popupRedirectResolver)||void 0===r?void 0:r._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch(e){}await this.initializeCurrentUser(t),this.lastNotifiedUid=(null===(i=this.currentUser)||void 0===i?void 0:i.uid)||null,this._deleted||(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();return this.currentUser||e?this.currentUser&&e&&this.currentUser.uid===e.uid?(this._currentUser._assign(e),void await this.currentUser.getIdToken()):void await this._updateCurrentUser(e,!0):void 0}async initializeCurrentUserFromIdToken(e){try{const t=await $t(this,{idToken:e}),n=await Zt._fromGetAccountInfoResponse(this,t,e);await this.directlySetCurrentUser(n)}catch(e){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",e),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){var t;if(Be(this.app)){const e=this.app.settings.authIdToken;return e?new Promise(t=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(e).then(t,t))}):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let r=n,i=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const n=null===(t=this.redirectUser)||void 0===t?void 0:t._redirectEventId,s=null==r?void 0:r._redirectEventId,o=await this.tryRedirectSignIn(e);n&&n!==s||!(null==o?void 0:o.user)||(r=o.user,i=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(r)}catch(e){r=n,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(e))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return yt(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let t=null;try{t=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch(e){await this._setRedirectUser(null)}return t}async reloadAndSetCurrentUserOrClear(e){try{await Yt(e)}catch(e){if("auth/network-request-failed"!==(null==e?void 0:e.code))return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=function(){if("undefined"==typeof navigator)return null;const e=navigator;return e.languages&&e.languages[0]||e.language||null}()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(Be(this.app))return Promise.reject(pt(this));const t=e?O(e):null;return t&&yt(t.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(t&&t._clone(this))}async _updateCurrentUser(e,t=!1){if(!this._deleted)return e&&yt(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),t||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return Be(this.app)?Promise.reject(pt(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return Be(this.app)?Promise.reject(pt(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(tn(e))})}_getRecaptchaConfig(){return null==this.tenantId?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const t=this._getPasswordPolicyInternal();return t.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):t.validatePassword(e)}_getPasswordPolicyInternal(){return null===this.tenantId?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await async function(e,t={}){return Dt(e,"GET","/v2/passwordPolicy",Ot(e,t))}(this),t=new _n(e);null===this.tenantId?this._projectPasswordPolicy=t:this._tenantPasswordPolicies[this.tenantId]=t}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new b("auth","Firebase",e())}onAuthStateChanged(e,t,n){return this.registerStateListener(this.authStateSubscription,e,t,n)}beforeAuthStateChanged(e,t){return this.beforeStateQueue.pushCallback(e,t)}onIdTokenChanged(e,t,n){return this.registerStateListener(this.idTokenSubscription,e,t,n)}authStateReady(){return new Promise((e,t)=>
2{if(this.currentUser)e();else{const n=this.onAuthStateChanged(()=>{n(),e()},t)}})}async revokeAccessToken(e){if(this.currentUser){const t={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:await this.currentUser.getIdToken()};null!=this.tenantId&&(t.tenantId=this.tenantId),await async function(e,t){return Dt(e,"POST","/v2/accounts:revokeToken",Ot(e,t))}(this,t)}}toJSON(){var e;return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:null===(e=this._currentUser)||void 0===e?void 0:e.toJSON()}}async _setRedirectUser(e,t){const n=await this.getOrInitRedirectPersistenceManager(t);return null===e?n.removeCurrentUser():n.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const t=e&&tn(e)||this._popupRedirectResolver;yt(t,this,"argument-error"),this.redirectPersistenceManager=await on.create(this,[tn(t._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){var t,n;return this._isInitialized&&await this.queue(async()=>{}),(null===(t=this._currentUser)||void 0===t?void 0:t._redirectEventId)===e?this._currentUser:(null===(n=this.redirectUser)||void 0===n?void 0:n._redirectEventId)===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){var e,t;if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const n=null!==(t=null===(e=this.currentUser)||void 0===e?void 0:e.uid)&&void 0!==t?t:null;this.lastNotifiedUid!==n&&(this.lastNotifiedUid=n,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,t,n,r){if(this._deleted)return()=>{};const i="function"==typeof t?t:t.next.bind(t);let s=!1;const o=this._isInitialized?Promise.resolve():this._initializationPromise;if(yt(o,this,"internal-error"),o.then(()=>{s||i(this.currentUser)}),"function"==typeof t){const i=e.addObserver(t,n,r);return()=>{s=!0,i()}}{const n=e.addObserver(t);return()=>{s=!0,n()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return yt(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){e&&!this.frameworks.includes(e)&&(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=vn(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){var e;const t={"X-Client-Version":this.clientVersion};this.app.options.appId&&(t["X-Firebase-gmpid"]=this.app.options.appId);const n=await(null===(e=this.heartbeatServiceProvider.getImmediate({optional:!0}))||void 0===e?void 0:e.getHeartbeatsHeader());n&&(t["X-Firebase-Client"]=n);const r=await this._getAppCheckToken();return r&&(t["X-Firebase-AppCheck"]=r),t}async _getAppCheckToken(){var e;if(Be(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const t=await(null===(e=this.appCheckServiceProvider.getImmediate({optional:!0}))||void 0===e?void 0:e.getToken());return(null==t?void 0:t.error)&&function(e,...t){ut.logLevel<=x.WARN&&ut.warn(`Auth (${He}): ${e}`,...t)}(`Error while retrieving App Check token: ${t.error}`),null==t?void 0:t.token}}function En(e){return O(e)}class Tn{constructor(e){this.auth=e,this.observer=null,this.addObserver=function(e,t){const n=new k(e,t);return n.subscribe.bind(n)}(e=>this.observer=e)}get next(){return yt(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let In={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function Sn(e){return In.loadJS(e)}function Cn(e){return`__${e}${Math.floor(1e6*Math.random())}`}class An{constructor(){this.enterprise=new kn}ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}class kn{ready(e){e()}execute(e,t){return Promise.resolve("token")}render(e,t){return""}}const Nn="NO_RECAPTCHA";class On{constructor(e){this.type="recaptcha-enterprise",this.auth=En(e)}async verify(e="verify",t=!1){function n(t,n,r){const i=window.grecaptcha;Ut(i)?i.enterprise.ready(()=>{i.enterprise.execute(t,{action:e}).then(e=>{n(e)}).catch(()=>{n(Nn)})}):r(Error("No reCAPTCHA enterprise script loaded."))}if(this.auth.settings.appVerificationDisabledForTesting){return(new An).execute("siteKey",{action:"verify"})}return new Promise((e,r)=>{(async function(e){if(!t){if(null==e.tenantId&&null!=e._agentRecaptchaConfig)return e._agentRecaptchaConfig.siteKey;if(null!=e.tenantId&&void 0!==e._tenantRecaptchaConfigs[e.tenantId])return e._tenantRecaptchaConfigs[e.tenantId].siteKey}return new Promise(async(t,n)=>
2{jt(e,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(r=>{if(void 0!==r.recaptchaKey){const n=new Vt(r);return null==e.tenantId?e._agentRecaptchaConfig=n:e._tenantRecaptchaConfigs[e.tenantId]=n,t(n.siteKey)}n(new Error("recaptcha Enterprise site key undefined"))}).catch(e=>{n(e)})})})(this.auth).then(i=>{if(!t&&Ut(window.grecaptcha))n(i,e,r);else{if("undefined"==typeof window)return void r(new Error("RecaptchaVerifier is only supported in browser"));let t=In.recaptchaEnterpriseScript;0!==t.length&&(t+=i),Sn(t).then(()=>{n(i,e,r)}).catch(e=>{r(e)})}}).catch(e=>{r(e)})})}}async function Dn(e,t,n,r=!1,i=!1){const s=new On(e);let o;if(i)o=Nn;else try{o=await s.verify(n)}catch(e){o=await s.verify(n,!0)}const a=Object.assign({},t);if("mfaSmsEnrollment"===n||"mfaSmsSignIn"===n){if("phoneEnrollmentInfo"in a){const e=a.phoneEnrollmentInfo.phoneNumber,t=a.phoneEnrollmentInfo.recaptchaToken;Object.assign(a,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:t,captchaResponse:o,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in a){const e=a.phoneSignInInfo.recaptchaToken;Object.assign(a,{phoneSignInInfo:{recaptchaToken:e,captchaResponse:o,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return a}return r?Object.assign(a,{captchaResp:o}):Object.assign(a,{captchaResponse:o}),Object.assign(a,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(a,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),a}async function Rn(e,t,n,r,i){var s,o;if("EMAIL_PASSWORD_PROVIDER"===i){if(null===(s=e._getRecaptchaConfig())||void 0===s?void 0:s.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const i=await Dn(e,t,n,"getOobCode"===n);return r(e,i)}return r(e,t).catch(async i=>{if("auth/missing-recaptcha-token"===i.code){console.log(`${n} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const i=await Dn(e,t,n,"getOobCode"===n);return r(e,i)}return Promise.reject(i)})}if("PHONE_PROVIDER"===i){if(null===(o=e._getRecaptchaConfig())||void 0===o?void 0:o.isProviderEnabled("PHONE_PROVIDER")){const i=await Dn(e,t,n);return r(e,i).catch(async i=>{var s;if("AUDIT"===(null===(s=e._getRecaptchaConfig())||void 0===s?void 0:s.getProviderEnforcementState("PHONE_PROVIDER"))&&("auth/missing-recaptcha-token"===i.code||"auth/invalid-app-credential"===i.code)){console.log(`Failed to verify with reCAPTCHA Enterprise. Automatically triggering the reCAPTCHA v2 flow to complete the ${n} flow.`);const i=await Dn(e,t,n,!1,!0);return r(e,i)}return Promise.reject(i)})}{const i=await Dn(e,t,n,!1,!0);return r(e,i)}}return Promise.reject(i+" provider is not supported.")}async function Pn(e){const t=En(e),n=await jt(t,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}),r=new Vt(n);if(null==t.tenantId?t._agentRecaptchaConfig=r:t._tenantRecaptchaConfigs[t.tenantId]=r,r.isAnyProviderEnabled()){new On(t).verify()}}function Ln(e,t){const n=$e(e,"auth");if(n.isInitialized()){const e=n.getImmediate();if(T(n.getOptions(),null!=t?t:{}))return e;ht(e,"already-initialized")}return n.initialize({options:t})}function Mn(e,t,n){const r=En(e);yt(/^https?:\/\//.test(t),r,"invalid-emulator-scheme");const i=!!(null==n?void 0:n.disableWarnings),s=xn(t),{host:o,port:a}=function(e){const t=xn(e),n=/(\/\/)?([^?#/]+)/.exec(e.substr(t.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){const e=i[1];return{host:e,port:Fn(r.substr(e.length+1))}}{const[e,t]=r.split(":");return{host:e,port:Fn(t)}}}(t),c=null===a?"":`:${a}`,u={url:`${s}//${o}${c}/`},l=Object.freeze({host:o,port:a,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:i})});if(!r._canInitEmulator)return yt(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),void yt(T(u,r.config.emulator)&&T(l,r.emulatorConfig),r,"emulator-config-failed");r.config.emulator=u,r.emulatorConfig=l,r.settings.appVerificationDisabledForTesting=!0,h(o)?(d(`${s}//${o}${c}`),m("Auth",!0)):i||function(){function e(){const e=document.createElement("p"),t=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",t.position="fixed",t.width="100%",t.backgroundColor="#ffffff",t.border=".1em solid #000000",t.color="#b50000",t.bottom="0px",t.left="0px",t.margin="0px",t.zIndex="10000",t.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}"undefined"!=typeof console&&"function"==typeof console.info&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials.");"undefined"!=typeof window&&"undefined"!=typeof document&&("loading"===document.readyState?window.addEventListener("DOMContentLoaded",e):e())}()}function xn(e){const t=e.indexOf(":");
2return t<0?"":e.substr(0,t+1)}function Fn(e){if(!e)return null;const t=Number(e);return isNaN(t)?null:t}class Un{constructor(e,t){this.providerId=e,this.signInMethod=t}toJSON(){return vt("not implemented")}_getIdTokenResponse(e){return vt("not implemented")}_linkToIdToken(e,t){return vt("not implemented")}_getReauthenticationResolver(e){return vt("not implemented")}}async function Vn(e,t){return Dt(e,"POST","/v1/accounts:resetPassword",Ot(e,t))}async function jn(e,t){return Dt(e,"POST","/v1/accounts:signUp",t)}async function $n(e,t){return Pt(e,"POST","/v1/accounts:signInWithPassword",Ot(e,t))}class Bn extends Un{constructor(e,t,n,r=null){super("password",n),this._email=e,this._password=t,this._tenantId=r}static _fromEmailAndPassword(e,t){return new Bn(e,t,"password")}static _fromEmailAndCode(e,t,n=null){return new Bn(e,t,"emailLink",n)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const t="string"==typeof e?JSON.parse(e):e;if((null==t?void 0:t.email)&&(null==t?void 0:t.password)){if("password"===t.signInMethod)return this._fromEmailAndPassword(t.email,t.password);if("emailLink"===t.signInMethod)return this._fromEmailAndCode(t.email,t.password,t.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":return Rn(e,{returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signInWithPassword",$n,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return async function(e,t){return Pt(e,"POST","/v1/accounts:signInWithEmailLink",Ot(e,t))}(e,{email:this._email,oobCode:this._password});default:ht(e,"internal-error")}}async _linkToIdToken(e,t){switch(this.signInMethod){case"password":return Rn(e,{idToken:t,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"},"signUpPassword",jn,"EMAIL_PASSWORD_PROVIDER");case"emailLink":return async function(e,t){return Pt(e,"POST","/v1/accounts:signInWithEmailLink",Ot(e,t))}(e,{idToken:t,email:this._email,oobCode:this._password});default:ht(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function qn(e,t){return Pt(e,"POST","/v1/accounts:signInWithIdp",Ot(e,t))}class zn extends Un{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const t=new zn(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(t.idToken=e.idToken),e.accessToken&&(t.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(t.nonce=e.nonce),e.pendingToken&&(t.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(t.accessToken=e.oauthToken,t.secret=e.oauthTokenSecret):ht("argument-error"),t}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,n
2once:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const t="string"==typeof e?JSON.parse(e):e,{providerId:n,signInMethod:r}=t,i=st(t,["providerId","signInMethod"]);if(!n||!r)return null;const s=new zn(n,r);return s.idToken=i.idToken||void 0,s.accessToken=i.accessToken||void 0,s.secret=i.secret,s.nonce=i.nonce,s.pendingToken=i.pendingToken||null,s}_getIdTokenResponse(e){return qn(e,this.buildRequest())}_linkToIdToken(e,t){const n=this.buildRequest();return n.idToken=t,qn(e,n)}_getReauthenticationResolver(e){const t=this.buildRequest();return t.autoCreate=!1,qn(e,t)}buildRequest(){const e={requestUri:"http://localhost",returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const t={};this.idToken&&(t.id_token=this.idToken),this.accessToken&&(t.access_token=this.accessToken),this.secret&&(t.oauth_token_secret=this.secret),t.providerId=this.providerId,this.nonce&&!this.pendingToken&&(t.nonce=this.nonce),e.postBody=S(t)}return e}}async function Hn(e,t){return Dt(e,"POST","/v1/accounts:sendVerificationCode",Ot(e,t))}const Gn={USER_NOT_FOUND:"user-not-found"};class Kn extends Un{constructor(e){super("phone","phone"),this.params=e}static _fromVerification(e,t){return new Kn({verificationId:e,verificationCode:t})}static _fromTokenResponse(e,t){return new Kn({phoneNumber:e,temporaryProof:t})}_getIdTokenResponse(e){return async function(e,t){return Pt(e,"POST","/v1/accounts:signInWithPhoneNumber",Ot(e,t))}(e,this._makeVerificationRequest())}_linkToIdToken(e,t){return async function(e,t){const n=await Pt(e,"POST","/v1/accounts:signInWithPhoneNumber",Ot(e,t));if(n.temporaryProof)throw Ft(e,"account-exists-with-different-credential",n);return n}(e,Object.assign({idToken:t},this._makeVerificationRequest()))}_getReauthenticationResolver(e){return async function(e,t){return Pt(e,"POST","/v1/accounts:signInWithPhoneNumber",Ot(e,Object.assign(Object.assign({},t),{operation:"REAUTH"})),Gn)}(e,this._makeVerificationRequest())}_makeVerificationRequest(){const{temporaryProof:e,phoneNumber:t,verificationId:n,verificationCode:r}=this.params;return e&&t?{temporaryProof:e,phoneNumber:t}:{sessionInfo:n,code:r}}toJSON(){const e={providerId:this.providerId};return this.params.phoneNumber&&(e.phoneNumber=this.params.phoneNumber),this.params.temporaryProof&&(e.temporaryProof=this.params.temporaryProof),this.params.verificationCode&&(e.verificationCode=this.params.verificationCode),this.params.verificationId&&(e.verificationId=this.params.verificationId),e}static fromJSON(e){"string"==typeof e&&(e=JSON.parse(e));const{verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}=e;return n||t||r||i?new Kn({verificationId:t,verificationCode:n,phoneNumber:r,temporaryProof:i}):null}}class Wn{constructor(e){var t,n,r,i,s,o;const a=C(A(e)),c=null!==(t=a.apiKey)&&void 0!==t?t:null,u=null!==(n=a.oobCode)&&void 0!==n?n:null,l=function(e){switch(e){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}(null!==(r=a.mode)&&void 0!==r?r:null);yt(c&&u&&l,"argument-error"),this.apiKey=c,this.operation=l,this.code=u,this.continueUrl=null!==(i=a.continueUrl)&&void 0!==i?i:null,this.languageCode=null!==(s=a.lang)&&void 0!==s?s:null,this.tenantId=null!==(o=a.tenantId)&&void 0!==o?o:null}static parseLink(e){const t=function(e){const t=C(A(e)).link,n=t?C(A(t)).deep_link_id:null,r=C(A(e)).deep_link_id;return(r?C(A(r)).link:null)||r||n||t||e}(e);try{return new Wn(t)}catch(e){return null}}}class Yn{constructor(){this.providerId=Yn.PROVIDER_ID}static credential(e,t){return Bn._fromEmailAndPassword(e,t)}static credentialWithLink(e,t){const n=Wn.parseLink(t);return yt(n,"argument-error"),Bn._fromEmailAndCode(e,n.code,n.tenantId)}}Yn.PROVIDER_ID="password",Yn.EMAIL_PASSWORD_SIGN_IN_METHOD="password",Yn.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class Qn{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}class Jn extends Qn{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class Xn extends Jn{constructor(){super("facebook.com")}static credential(e){return zn._fromParams({providerId:Xn.PROVIDER_ID,signInMethod:Xn.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return Xn.credentialFromTaggedObject(e)}static credentialFromError(e){return Xn.credentialFromTaggedObject(e.customData||{})}
2static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return Xn.credential(e.oauthAccessToken)}catch(e){return null}}}Xn.FACEBOOK_SIGN_IN_METHOD="facebook.com",Xn.PROVIDER_ID="facebook.com";class Zn extends Jn{constructor(){super("google.com"),this.addScope("profile")}static credential(e,t){return zn._fromParams({providerId:Zn.PROVIDER_ID,signInMethod:Zn.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:t})}static credentialFromResult(e){return Zn.credentialFromTaggedObject(e)}static credentialFromError(e){return Zn.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:t,oauthAccessToken:n}=e;if(!t&&!n)return null;try{return Zn.credential(t,n)}catch(e){return null}}}Zn.GOOGLE_SIGN_IN_METHOD="google.com",Zn.PROVIDER_ID="google.com";class er extends Jn{constructor(){super("github.com")}static credential(e){return zn._fromParams({providerId:er.PROVIDER_ID,signInMethod:er.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return er.credentialFromTaggedObject(e)}static credentialFromError(e){return er.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e))return null;if(!e.oauthAccessToken)return null;try{return er.credential(e.oauthAccessToken)}catch(e){return null}}}er.GITHUB_SIGN_IN_METHOD="github.com",er.PROVIDER_ID="github.com";class tr extends Jn{constructor(){super("twitter.com")}static credential(e,t){return zn._fromParams({providerId:tr.PROVIDER_ID,signInMethod:tr.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:t})}static credentialFromResult(e){return tr.credentialFromTaggedObject(e)}static credentialFromError(e){return tr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:t,oauthTokenSecret:n}=e;if(!t||!n)return null;try{return tr.credential(t,n)}catch(e){return null}}}tr.TWITTER_SIGN_IN_METHOD="twitter.com",tr.PROVIDER_ID="twitter.com";class nr{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,t,n,r=!1){const i=await Zt._fromIdTokenResponse(e,n,r),s=rr(n);return new nr({user:i,providerId:s,_tokenResponse:n,operationType:t})}static async _forOperation(e,t,n){await e._updateTokensIfNecessary(n,!0);const r=rr(n);return new nr({user:e,providerId:r,_tokenResponse:n,operationType:t})}}function rr(e){return e.providerId?e.providerId:"phoneNumber"in e?"phone":null}class ir extends _{constructor(e,t,n,r){var i;super(t.code,t.message),this.operationType=n,this.user=r,Object.setPrototypeOf(this,ir.prototype),this.customData={appName:e.name,tenantId:null!==(i=e.tenantId)&&void 0!==i?i:void 0,_serverResponse:t.customData._serverResponse,operationType:n}}static _fromErrorAndOperation(e,t,n,r){return new ir(e,t,n,r)}}function sr(e,t,n,r){return("reauthenticate"===t?n._getReauthenticationResolver(e):n._getIdTokenResponse(e)).catch(n=>{if("auth/multi-factor-auth-required"===n.code)throw ir._fromErrorAndOperation(e,n,t,r);throw n})}async function or(e,t,n=!1){const r=await Gt(e,t._linkToIdToken(e.auth,await e.getIdToken()),n);return nr._forOperation(e,"link",r)}async function ar(e,t,n=!1){const{auth:r}=e;if(Be(r.app))return Promise.reject(pt(r));const i="reauthenticate";try{const s=await Gt(e,sr(r,i,t,e),n);yt(s.idToken,r,"internal-error");const o=zt(s.idToken);yt(o,r,"internal-error");const{sub:a}=o;return yt(e.uid===a,r,"user-mismatch"),nr._forOperation(e,i,s)}catch(e){throw"auth/user-not-found"===(null==e?void 0:e.code)&&ht(r,"user-mismatch"),e}}async function cr(e,t,n=!1){if(Be(e.app))return Promise.reject(pt(e));const r="signIn",i=await sr(e,r,t),s=await nr._fromIdTokenResponse(e,r,i);return n||await e._updateCurrentUser(s.user),s}async function ur(e,t){return cr(En(e),t)}async function lr(e,t){return ar(O(e),t)}class hr{constructor(e,t){this.factorId=e,this.uid=t.mfaEnrollmentId,this.enrollmentTime=new Date(t.enrolledAt).toUTCString(),this.displayName=t.displayName}static _fromServerResponse(e,t){return"phoneInfo"in t?dr._fromServerResponse(e,t):"totpInfo"in t?fr._fromServerResponse(e,t):ht(e,"internal-error")}}class dr extends hr{constructor(e){super("phone",e),this.phoneNumber=e.phoneInfo}static _fromServerResponse(e,t){return new dr(t)}}class fr extends hr{constructor(e){super("totp",e)}static _fromServerResponse(e,t){return new fr(t)}}async function pr(e){const t=En(e);t._getPasswordPolicyInternal()&&await t._updatePasswordPolicy()}async function mr(e,t){const{data:n}=await async function(e,t){const n=O(e),r=await Vn(n,{oobCode:t}),i=r.requestType;switch(yt(i,n,"internal-error"),i){case"EMAIL_SIGNIN":break;case"VERIFY_AND_CHANGE_EMAIL":yt(r.newEmail,n,"internal-error");break;case"REVERT_SECOND_FACTOR_ADDITION":yt(r.mfaInfo,n,"internal-error");default:yt(r.email,n,"internal-error")}let s=null;return r.mfaInfo&&(s=hr._fromServerResponse(En(n),r.mfaInfo)),{data:{email:("VERIFY_AND_CHANGE_EMAIL"===r.requestType?r.newEmail:r.email)||null,previousEmail:("VERIFY_AND_CHANGE_EMAIL"===r.requestType?r.email:r.newEmail)||null,multiFactorInfo:s},operation:i}}(O(e),t);return n.email}async function gr(e,{displayName:t,photoURL:n}){if(void 0===t&&void 0===n)return;const r=O(e),i={idToken:await r.getIdToken(),displayName:t,photoUrl:n,returnSecureToken:!0},s=await Gt(r,async function(e,t){return Dt(e,"POST","/v1/accounts:update",t)}(r.auth,i));r.displayName=s.displayName||null,r.photoURL=s.photoUrl||null;const o=r.providerData.find(({providerId:e})=>"password"===e);o&&(o.displayName=r.displayName,o.photoURL=r.photoURL),await r._updateTokensIfNecessary(s)}async function yr(e,t,n){const{auth:r}=e,i={idToken:await e.getIdToken(),returnSecureToken:!0};t&&(i.email=t),n&&(i.password=n);const s=await Gt(e,async function(e,t){return Dt(e,"POST","/v1/accounts:update",t)}(r,i));await e._updateTokensIfNecessary(s,!0)}function vr(e,t,n,r){return O(e).onIdTokenChanged(t,n,r)}function wr(e,t,n,r){return O(e).onAuthStateChanged(t,n,r)}function _r(e,t){return Dt(e,"POST","/v2/accounts/mfaEnrollment:start",Ot(e,t))}new WeakMap;const br="__sak";class Er{constructor(e,t){this.storageRetriever=e,this.type=t}_isAvailable(){try{return this.storage?(this.storage.setItem(br,"1"),this.storage.removeItem(br),Promise.resolve(!0)):Promise.resolve(!1)}catch(e){return Promise.resolve(!1)}}_set(e,t){return this.storage.setItem(e,JSON.stringify(t)),Promise.resolve()}_get(e){const t=this.storage.getItem(e);return Promise.resolve(t?JSON.parse(t):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}
2class Tr extends Er{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,t)=>this.onStorageEvent(e,t),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=yn(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const t of Object.keys(this.listeners)){const n=this.storage.getItem(t),r=this.localCache[t];n!==r&&e(t,r,n)}}onStorageEvent(e,t=!1){if(!e.key)return void this.forAllChangedKeys((e,t,n)=>{this.notifyListeners(e,n)});const n=e.key;t?this.detachListener():this.stopPolling();const r=()=>{const e=this.storage.getItem(n);(t||this.localCache[n]!==e)&&this.notifyListeners(n,e)},i=this.storage.getItem(n);gn()&&i!==e.newValue&&e.newValue!==e.oldValue?setTimeout(r,10):r()}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const e of Array.from(n))e(t?JSON.parse(t):t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,t,n)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:t,newValue:n}),!0)})},1e3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,t){0===Object.keys(this.listeners).length&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&(this.detachListener(),this.stopPolling())}async _set(e,t){await super._set(e,t),this.localCache[e]=JSON.stringify(t)}async _get(e){const t=await super._get(e);return this.localCache[e]=JSON.stringify(t),t}async _remove(e){await super._remove(e),delete this.localCache[e]}}Tr.type="LOCAL";const Ir=Tr;function Sr(e){var t,n;const r=e.replace(/[\\^$.*+?()[\]{}|]/g,"\\$&"),i=RegExp(`${r}=([^;]+)`);return null!==(n=null===(t=document.cookie.match(i))||void 0===t?void 0:t[1])&&void 0!==n?n:null}function Cr(e){return`${"http:"===window.location.protocol?"__dev_":"__HOST-"}FIREBASE_${e.split(":")[3]}`}class Ar{constructor(){this.type="COOKIE",this.listenerUnsubscribes=new Map}_getFinalTarget(e){if(void 0===typeof window)return e;const t=new URL(`${window.location.origin}/__cookies__`);return t.searchParams.set("finalTarget",e),t}async _isAvailable(){var e;return!("boolean"==typeof isSecureContext&&!isSecureContext)&&("undefined"!=typeof navigator&&"undefined"!=typeof document&&(null===(e=navigator.cookieEnabled)||void 0===e||e))}async _set(e,t){}async _get(e){if(!this._isAvailable())return null;const t=Cr(e);if(window.cookieStore){const e=await window.cookieStore.get(t);return null==e?void 0:e.value}return Sr(t)}async _remove(e){if(!this._isAvailable())return;if(!await this._get(e))return;const t=Cr(e);document.cookie=`${t}=;Max-Age=34560000;Partitioned;Secure;SameSite=Strict;Path=/;Priority=High`,await fetch("/__cookies__",{method:"DELETE"}).catch(()=>{})}_addListener(e,t){if(!this._isAvailable())return;const n=Cr(e);if(window.cookieStore){const e=e=>{const r=e.changed.find(e=>e.name===n);r&&t(r.value);e.deleted.find(e=>e.name===n)&&t(null)},r=()=>window.cookieStore.removeEventListener("change",e);return this.listenerUnsubscribes.set(t,r),window.cookieStore.addEventListener("change",e)}let r=Sr(n);const i=setInterval(()=>{const e=Sr(n);e!==r&&(t(e),r=e)},1e3);this.listenerUnsubscribes.set(t,()=>clearInterval(i))}_removeListener(e,t){const n=this.listenerUnsubscribes.get(t);n&&(n(),this.listenerUnsubscribes.delete(t))}}Ar.type="COOKIE";class kr extends Er{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,t){}_removeListener(e,t){}}kr.type="SESSION";const Nr=kr;class Or{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const t=this.receivers.find(t=>t.isListeningto(e));if(t)return t;const n=new Or(e);return this.receivers.push(n),n}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const t=e,{eventId:n,eventType:r,data:i}=t.data,s=this.handlersMap[r];if(!(null==s?void 0:s.size))return;t.ports[0].postMessage({status:"ack",eventId:n,eventType:r});const o=Array.from(s).map(async e=>e(t.origin,i)),a=await function(e){return Promise.all(e.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(e){return{fulfilled:!1,reason:e}}}))}(o);t.ports[0].postMessage({status:"done",eventId:n,eventType:r,response:a})}_subscribe(e,t){0===Object.keys(this.handlersMap).length&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(t)}_unsubscribe(e,t){this.handlersMap[e]&&t&&this.handlersMap[e].delete(t),t&&0!==this.handlersMap[e].size||delete this.handlersMap[e],0===Object.keys(this.handlersMap).length&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}function Dr(e="",t=10){let n="";for(let e=0;e<t;e++)n+=Math.floor(10*Math.random());return e+n}Or.receivers=[];class Rr{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,t,n=50){const r="undefined"!=typeof MessageChannel?new MessageChannel:null;if(!r)throw new Error("connection_unavailable");let i,s;return new Promise((o,a)=>{const c=Dr("",20);r.port1.start();const u=setTimeout(()=>{a(new Error("unsupported_event"))},n);s={messageChannel:r,onMessage(e){const t=e;if(t.data.eventId===c)switch(t.data.status){case"ack":clearTimeout(u),i=setTimeout(()=>{a(new Error("timeout"))},3e3);break;case"done":clearTimeout(i),o(t.data.response);break;default:clearTimeout(u),clearTimeout(i),a(new Error("invalid_response"))}}},this.handlers.add(s),r.port1.addEventListener("message",s.onMessage),this.target.postMessage({eventType:e,eventId:c,data:t},[r.port2])}).finally(()=>{s&&this.removeMessageHandler(s)})}}function Pr(){return window}
2function Lr(){return void 0!==Pr().WorkerGlobalScope&&"function"==typeof Pr().importScripts}const Mr="firebaseLocalStorageDb",xr="firebaseLocalStorage",Fr="fbase_key";class Ur{constructor(e){this.request=e}toPromise(){return new Promise((e,t)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{t(this.request.error)})})}}function Vr(e,t){return e.transaction([xr],t?"readwrite":"readonly").objectStore(xr)}function jr(){const e=indexedDB.open(Mr,1);return new Promise((t,n)=>{e.addEventListener("error",()=>{n(e.error)}),e.addEventListener("upgradeneeded",()=>{const t=e.result;try{t.createObjectStore(xr,{keyPath:Fr})}catch(e){n(e)}}),e.addEventListener("success",async()=>{const n=e.result;n.objectStoreNames.contains(xr)?t(n):(n.close(),await function(){const e=indexedDB.deleteDatabase(Mr);return new Ur(e).toPromise()}(),t(await jr()))})})}async function $r(e,t,n){const r=Vr(e,!0).put({[Fr]:t,value:n});return new Ur(r).toPromise()}function Br(e,t){const n=Vr(e,!0).delete(t);return new Ur(n).toPromise()}class qr{constructor(){this.type="LOCAL",this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){return this.db||(this.db=await jr()),this.db}async _withRetries(e){let t=0;for(;;)try{const t=await this._openDb();return await e(t)}catch(e){if(t++>3)throw e;this.db&&(this.db.close(),this.db=void 0)}}async initializeServiceWorkerMessaging(){return Lr()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Or._getInstance(Lr()?self:null),this.receiver._subscribe("keyChanged",async(e,t)=>({keyProcessed:(await this._poll()).includes(t.key)})),this.receiver._subscribe("ping",async(e,t)=>["keyChanged"])}async initializeSender(){var e,t;if(this.activeServiceWorker=await async function(){if(!(null===navigator||void 0===navigator?void 0:navigator.serviceWorker))return null;try{return(await navigator.serviceWorker.ready).active}catch(e){return null}}(),!this.activeServiceWorker)return;this.sender=new Rr(this.activeServiceWorker);const n=await this.sender._send("ping",{},800);n&&(null===(e=n[0])||void 0===e?void 0:e.fulfilled)&&(null===(t=n[0])||void 0===t?void 0:t.value.includes("keyChanged"))&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){var t;if(this.sender&&this.activeServiceWorker&&((null===(t=null===navigator||void 0===navigator?void 0:navigator.serviceWorker)||void 0===t?void 0:t.controller)||null)===this.activeServiceWorker)try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch(t){}}async _isAvailable(){try{if(!indexedDB)return!1;const e=await jr();return await $r(e,br,"1"),await Br(e,br),!0}catch(e){}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,t){return this._withPendingWrite(async()=>(await this._withRetries(n=>$r(n,e,t)),this.localCache[e]=t,this.notifyServiceWorker(e)))}async _get(e){const t=await this._withRetries(t=>async function(e,t){const n=Vr(e,!1).get(t),r=await new Ur(n).toPromise();return void 0===r?null:r.value}(t,e));return this.localCache[e]=t,t}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(t=>Br(t,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){const e=await this._withRetries(e=>{const t=Vr(e,!1).getAll();return new Ur(t).toPromise()});if(!e)return[];if(0!==this.pendingWrites)return[];const t=[],n=new Set;if(0!==e.length)for(const{fbase_key:r,value:i}of e)n.add(r),JSON.stringify(this.localCache[r])!==JSON.stringify(i)&&(this.notifyListeners(r,i),t.push(r));for(const e of Object.keys(this.localCache))this.localCache[e]&&!n.has(e)&&(this.notifyListeners(e,null),t.push(e));return t}notifyListeners(e,t){this.localCache[e]=t;const n=this.listeners[e];if(n)for(const e of Array.from(n))e(t)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),800)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,t){0===Object.keys(this.listeners).length&&this.startPolling(),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(t)}_removeListener(e,t){this.listeners[e]&&(this.listeners[e].delete(t),0===this.listeners[e].size&&delete this.listeners[e]),0===Object.keys(this.listeners).length&&this.stopPolling()}}qr.type="LOCAL";const zr=qr;function Hr(e,t){return Dt(e,"POST","/v2/accounts/mfaSignIn:start",Ot(e,t))}Cn("rcb"),new It(3e4,6e4);const Gr="recaptcha";async function Kr(e,t,n){var r;if(!e._getRecaptchaConfig())try{await Pn(e)}catch(e){console.log("Failed to initialize reCAPTCHA Enterprise config. Triggering the reCAPTCHA v2 verification.")}try{let i;if(i="string"==typeof t?{phoneNumber:t}
2:t,"session"in i){const t=i.session;if("phoneNumber"in i){yt("enroll"===t.type,e,"internal-error");const r={idToken:t.credential,phoneEnrollmentInfo:{phoneNumber:i.phoneNumber,clientType:"CLIENT_TYPE_WEB"}},s=Rn(e,r,"mfaSmsEnrollment",async(e,t)=>{if(t.phoneEnrollmentInfo.captchaResponse===Nn){yt((null==n?void 0:n.type)===Gr,e,"argument-error");return _r(e,await Wr(e,t,n))}return _r(e,t)},"PHONE_PROVIDER"),o=await s.catch(e=>Promise.reject(e));return o.phoneSessionInfo.sessionInfo}{yt("signin"===t.type,e,"internal-error");const s=(null===(r=i.multiFactorHint)||void 0===r?void 0:r.uid)||i.multiFactorUid;yt(s,e,"missing-multi-factor-info");const o={mfaPendingCredential:t.credential,mfaEnrollmentId:s,phoneSignInInfo:{clientType:"CLIENT_TYPE_WEB"}},a=Rn(e,o,"mfaSmsSignIn",async(e,t)=>{if(t.phoneSignInInfo.captchaResponse===Nn){yt((null==n?void 0:n.type)===Gr,e,"argument-error");return Hr(e,await Wr(e,t,n))}return Hr(e,t)},"PHONE_PROVIDER"),c=await a.catch(e=>Promise.reject(e));return c.phoneResponseInfo.sessionInfo}}{const t={phoneNumber:i.phoneNumber,clientType:"CLIENT_TYPE_WEB"},r=Rn(e,t,"sendVerificationCode",async(e,t)=>{if(t.captchaResponse===Nn){yt((null==n?void 0:n.type)===Gr,e,"argument-error");return Hn(e,await Wr(e,t,n))}return Hn(e,t)},"PHONE_PROVIDER"),s=await r.catch(e=>Promise.reject(e));return s.sessionInfo}}finally{null==n||n._reset()}}async function Wr(e,t,n){yt(n.type===Gr,e,"argument-error");const r=await n.verify();yt("string"==typeof r,e,"argument-error");const i=Object.assign({},t);if("phoneEnrollmentInfo"in i){const e=i.phoneEnrollmentInfo.phoneNumber,t=i.phoneEnrollmentInfo.captchaResponse,n=i.phoneEnrollmentInfo.clientType,s=i.phoneEnrollmentInfo.recaptchaVersion;return Object.assign(i,{phoneEnrollmentInfo:{phoneNumber:e,recaptchaToken:r,captchaResponse:t,clientType:n,recaptchaVersion:s}}),i}if("phoneSignInInfo"in i){const e=i.phoneSignInInfo.captchaResponse,t=i.phoneSignInInfo.clientType,n=i.phoneSignInInfo.recaptchaVersion;return Object.assign(i,{phoneSignInInfo:{recaptchaToken:r,captchaResponse:e,clientType:t,recaptchaVersion:n}}),i}return Object.assign(i,{recaptchaToken:r}),i}class Yr{constructor(e){this.providerId=Yr.PROVIDER_ID,this.auth=En(e)}verifyPhoneNumber(e,t){return Kr(this.auth,e,O(t))}static credential(e,t){return Kn._fromVerification(e,t)}static credentialFromResult(e){const t=e;return Yr.credentialFromTaggedObject(t)}static credentialFromError(e){return Yr.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{phoneNumber:t,temporaryProof:n}=e;return t&&n?Kn._fromTokenResponse(t,n):null}}function Qr(e,t){return t?tn(t):(yt(e._popupRedirectResolver,e,"argument-error"),e._popupRedirectResolver)}Yr.PROVIDER_ID="phone",Yr.PHONE_SIGN_IN_METHOD="phone";class Jr extends Un{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return qn(e,this._buildIdpRequest())}_linkToIdToken(e,t){return qn(e,this._buildIdpRequest(t))}_getReauthenticationResolver(e){return qn(e,this._buildIdpRequest())}_buildIdpRequest(e){const t={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(t.idToken=e),t}}function Xr(e){return cr(e.auth,new Jr(e),e.bypassAuthState)}function Zr(e){const{auth:t,user:n}=e;return yt(n,t,"internal-error"),ar(n,new Jr(e),e.bypassAuthState)}async function ei(e){const{auth:t,user:n}=e;return yt(n,t,"internal-error"),or(n,new Jr(e),e.bypassAuthState)}class ti{constructor(e,t,n,r,i=!1){this.auth=e,this.resolver=n,this.user=r,this.bypassAuthState=i,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(t)?t:[t]}execute(){return new Promise(async(e,t)=>{this.pendingPromise={resolve:e,reject:t};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(e){this.reject(e)}})}async onAuthEvent(e){const{urlResponse:t,sessionId:n,postBody:r,tenantId:i,error:s,type:o}=e;if(s)return void this.reject(s);const a={auth:this.auth,requestUri:t,sessionId:n,tenantId:i||void 0,postBody:r||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(o)(a))}catch(e){this.reject(e)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return Xr;case"linkViaPopup":case"linkViaRedirect":return ei;case"reauthViaPopup":case"reauthViaRedirect":return Zr;default:ht(this.auth,"internal-error")}}resolve(e){wt(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){wt(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const ni=new It(2e3,1e4);
2class ri extends ti{constructor(e,t,n,r,i){super(e,t,r,i),this.provider=n,this.authWindow=null,this.pollId=null,ri.currentPopupAction&&ri.currentPopupAction.cancel(),ri.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return yt(e,this.auth,"internal-error"),e}async onExecution(){wt(1===this.filter.length,"Popup operations only handle one event");const e=Dr();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(e=>{this.reject(e)}),this.resolver._isIframeWebStorageSupported(this.auth,e=>{e||this.reject(dt(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){var e;return(null===(e=this.authWindow)||void 0===e?void 0:e.associatedEvent)||null}cancel(){this.reject(dt(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,ri.currentPopupAction=null}pollUserCancellation(){const e=()=>{var t,n;(null===(n=null===(t=this.authWindow)||void 0===t?void 0:t.window)||void 0===n?void 0:n.closed)?this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(dt(this.auth,"popup-closed-by-user"))},8e3):this.pollId=window.setTimeout(e,ni.get())};e()}}ri.currentPopupAction=null;const ii=new Map;class si extends ti{constructor(e,t,n=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],t,void 0,n),this.eventId=null}async execute(){let e=ii.get(this.auth._key());if(!e){try{const t=await async function(e,t){const n=ci(t),r=ai(e);if(!await r._isAvailable())return!1;const i="true"===await r._get(n);return await r._remove(n),i}(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(t)}catch(t){e=()=>Promise.reject(t)}ii.set(this.auth._key(),e)}return this.bypassAuthState||ii.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if("signInViaRedirect"===e.type)return super.onAuthEvent(e);if("unknown"!==e.type){if(e.eventId){const t=await this.auth._redirectUserForId(e.eventId);if(t)return this.user=t,super.onAuthEvent(e);this.resolve(null)}}else this.resolve(null)}async onExecution(){}cleanUp(){}}function oi(e,t){ii.set(e._key(),t)}function ai(e){return tn(e._redirectPersistence)}function ci(e){return sn("pendingRedirect",e.config.apiKey,e.name)}async function ui(e,t,n=!1){if(Be(e.app))return Promise.reject(pt(e));const r=En(e),i=Qr(r,t),s=new si(r,i,n),o=await s.execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,t)),o}class li{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let t=!1;return this.consumers.forEach(n=>{this.isEventForConsumer(e,n)&&(t=!0,this.sendToConsumer(e,n),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!function(e){switch(e.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return di(e);default:return!1}}(e)||(this.hasHandledPotentialRedirect=!0,t||(this.queuedRedirectEvent=e,t=!0)),t}sendToConsumer(e,t){var n;if(e.error&&!di(e)){const r=(null===(n=e.error.code)||void 0===n?void 0:n.split("auth/")[1])||"internal-error";t.onError(dt(this.auth,r))}else t.onAuthEvent(e)}isEventForConsumer(e,t){const n=null===t.eventId||!!e.eventId&&e.eventId===t.eventId;return t.filter.includes(e.type)&&n}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=6e5&&this.cachedEventUids.clear(),this.cachedEventUids.has(hi(e))}saveEventToCache(e){this.cachedEventUids.add(hi(e)),this.lastProcessedEventTime=
2Date.now()}}function hi(e){return[e.type,e.eventId,e.sessionId,e.tenantId].filter(e=>e).join("-")}function di({type:e,error:t}){return"unknown"===e&&"auth/no-auth-event"===(null==t?void 0:t.code)}const fi=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,pi=/^https?/;async function mi(e){if(e.config.emulator)return;const{authorizedDomains:t}=await async function(e,t={}){return Dt(e,"GET","/v1/projects",t)}(e);for(const e of t)try{if(gi(e))return}catch(e){}ht(e,"unauthorized-domain")}function gi(e){const t=_t(),{protocol:n,hostname:r}=new URL(t);if(e.startsWith("chrome-extension://")){const i=new URL(e);return""===i.hostname&&""===r?"chrome-extension:"===n&&e.replace("chrome-extension://","")===t.replace("chrome-extension://",""):"chrome-extension:"===n&&i.hostname===r}if(!pi.test(n))return!1;if(fi.test(e))return r===e;const i=e.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}const yi=new It(3e4,6e4);function vi(){const e=Pr().___jsl;if(null==e?void 0:e.H)for(const t of Object.keys(e.H))if(e.H[t].r=e.H[t].r||[],e.H[t].L=e.H[t].L||[],e.H[t].r=[...e.H[t].L],e.CP)for(let t=0;t<e.CP.length;t++)e.CP[t]=null}function wi(e){return new Promise((t,n)=>{var r,i,s;function o(){vi(),gapi.load("gapi.iframes",{callback:()=>{t(gapi.iframes.getContext())},ontimeout:()=>{vi(),n(dt(e,"network-request-failed"))},timeout:yi.get()})}if(null===(i=null===(r=Pr().gapi)||void 0===r?void 0:r.iframes)||void 0===i?void 0:i.Iframe)t(gapi.iframes.getContext());else{if(!(null===(s=Pr().gapi)||void 0===s?void 0:s.load)){const t=Cn("iframefcb");return Pr()[t]=()=>{gapi.load?o():n(dt(e,"network-request-failed"))},Sn(`${In.gapiScript}?onload=${t}`).catch(e=>n(e))}o()}}).catch(e=>{throw _i=null,e})}let _i=null;const bi=new It(5e3,15e3),Ei={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},Ti=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function Ii(e){const t=e.config;yt(t.authDomain,e,"auth-domain-config-required");const n=t.emulator?St(t,"emulator/auth/iframe"):`https://${e.config.authDomain}/__/auth/iframe`,r={apiKey:t.apiKey,appName:e.name,v:He},i=Ti.get(e.config.apiHost);i&&(r.eid=i);const s=e._getFrameworks();return s.length&&(r.fw=s.join(",")),`${n}?${S(r).slice(1)}`}async function Si(e){const t=await function(e){return _i=_i||wi(e),_i}(e),n=Pr().gapi;return yt(n,e,"internal-error"),t.open({where:document.body,url:Ii(e),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:Ei,dontclear:!0},t=>new Promise(async(n,r)=>{await t.restyle({setHideOnLeave:!1});const i=dt(e,"network-request-failed"),s=Pr().setTimeout(()=>{r(i)},bi.get());function o(){Pr().clearTimeout(s),n(t)}t.ping(o).then(o,()=>{r(i)})}))}const Ci={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"};class Ai{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch(e){}}}function ki(e,t,n,r=500,i=600){const s=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString();let a="";const c=Object.assign(Object.assign({},Ci),{width:r.toString(),height:i.toString(),top:s,left:o}),u=g().toLowerCase();n&&(a=ln(u)?"_blank":n),cn(u)&&(t=t||"http://localhost",c.scrollbars="yes");const l=Object.entries(c).reduce((e,[t,n])=>`${e}${t}=${n},`,"");if(function(e=g()){var t;return mn(e)&&!!(null===(t=window.navigator)||void 0===t?void 0:t.standalone)}(u)&&"_self"!==a)return function(e,t){const n=document.createElement("a");n.href=e,n.target=t;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}(t||"",a),new Ai(null);const h=window.open(t||"",a,l);yt(h,e,"popup-blocked");try{h.focus()}catch(e){}return new Ai(h)}const Ni="__/auth/handler",Oi="emulator/auth/handler",Di=encodeURIComponent("fac");async function Ri(e,t,n,r,i,s){yt(e.config.authDomain,e,"auth-domain-config-required"),yt(e.config.apiKey,e,"invalid-api-key");
2const o={apiKey:e.config.apiKey,appName:e.name,authType:n,redirectUrl:r,v:He,eventId:i};if(t instanceof Qn){t.setDefaultLanguage(e.languageCode),o.providerId=t.providerId||"",function(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}(t.getCustomParameters())||(o.customParameters=JSON.stringify(t.getCustomParameters()));for(const[e,t]of Object.entries(s||{}))o[e]=t}if(t instanceof Jn){const e=t.getScopes().filter(e=>""!==e);e.length>0&&(o.scopes=e.join(","))}e.tenantId&&(o.tid=e.tenantId);const a=o;for(const e of Object.keys(a))void 0===a[e]&&delete a[e];const c=await e._getAppCheckToken(),u=c?`#${Di}=${encodeURIComponent(c)}`:"";return`${function({config:e}){if(!e.emulator)return`https://${e.authDomain}/${Ni}`;return St(e,Oi)}(e)}?${S(a).slice(1)}${u}`}const Pi="webStorageSupport";const Li=class{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=Nr,this._completeRedirectFn=ui,this._overrideRedirectResult=oi}async _openPopup(e,t,n,r){var i;wt(null===(i=this.eventManagers[e._key()])||void 0===i?void 0:i.manager,"_initialize() not called before _openPopup()");return ki(e,await Ri(e,t,n,_t(),r),Dr())}async _openRedirect(e,t,n,r){await this._originValidation(e);return function(e){Pr().location.href=e}(await Ri(e,t,n,_t(),r)),new Promise(()=>{})}_initialize(e){const t=e._key();if(this.eventManagers[t]){const{manager:e,promise:n}=this.eventManagers[t];return e?Promise.resolve(e):(wt(n,"If manager is not set, promise should be"),n)}const n=this.initAndGetManager(e);return this.eventManagers[t]={promise:n},n.catch(()=>{delete this.eventManagers[t]}),n}async initAndGetManager(e){const t=await Si(e),n=new li(e);return t.register("authEvent",t=>{yt(null==t?void 0:t.authEvent,e,"invalid-auth-event");return{status:n.onEvent(t.authEvent)?"ACK":"ERROR"}},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:n},this.iframes[e._key()]=t,n}_isIframeWebStorageSupported(e,t){this.iframes[e._key()].send(Pi,{type:Pi},n=>{var r;const i=null===(r=null==n?void 0:n[0])||void 0===r?void 0:r[Pi];void 0!==i&&t(!!i),ht(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const t=e._key();return this.originValidationPromises[t]||(this.originValidationPromises[t]=mi(e)),this.originValidationPromises[t]}get _shouldInitProactively(){return yn()||un()||mn()}};var Mi="@firebase/auth",xi="1.10.8";class Fi{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){var e;return this.assertAuthConfigured(),(null===(e=this.auth.currentUser)||void 0===e?void 0:e.uid)||null}async getToken(e){if(this.assertAuthConfigured(),await this.auth._initializationPromise,!this.auth.currentUser)return null;return{accessToken:await this.auth.currentUser.getIdToken(e)}}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const t=this.auth.onIdTokenChanged(t=>{e((null==t?void 0:t.stsTokenManager.accessToken)||null)});this.internalListeners.set(e,t),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const t=this.internalListeners.get(e);t&&(this.internalListeners.delete(e),t(),this.updateProactiveRefresh())}assertAuthConfigured(){yt(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}Ui="authIdTokenMaxAge",null===(Vi=a())||void 0===Vi||Vi[`_${Ui}`];var Ui,Vi;var ji,$i;ji={loadJS:e=>new Promise((t,n)=>{const r=document.createElement("script");r.setAttribute("src",e),r.onload=t,r.onerror=e=>{const t=dt("internal-error");t.customData=e,n(t)},r.type="text/javascript",r.charset="UTF-8",function(){var e,t;return null!==(t=null===(e=document.getElementsByTagName("head"))||void 0===e?void 0:e[0])&&void 0!==t?t:document}().appendChild(r)}),gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="},In=ji,$i="Browser",je(new D("auth",(e,{options:t})=>{const n=e.getProvider("app").getImmediate(),r=e.getProvider("heartbeat"),i=e.getProvider("app-check-internal"),{apiKey:s,authDomain:o}=n.options;yt(s&&!s.includes(":"),"invalid-api-key",{appName:n.name});const a={apiKey:s,authDomain:o,clientPlatform:$i,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:vn($i)},c=new bn(n,r,i,a);return function(e,t){const n=(null==t?void 0:t.persistence)||[],r=(Array.isArray(n)?n:[n]).map(tn);(null==t?void 0:t.errorMap)&&e._updateErrorMap(t.errorMap),e._initializeWithPersistence(r,null==t?void 0:t.popupRedirectResolver)}(c,t),c},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,t,n)=>{e.getProvider("auth-internal").initialize()})),je(new D("auth-internal",e=>(e=>new Fi(e))(En(e.getProvider("auth").getImmediate())),"PRIVATE").setInstantiationMode("EXPLICIT")),We(Mi,xi,function(e){switch(e){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}($i)),We(Mi,xi,"esm2017");var Bi,qi,zi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{},Hi={};(function(){var e;function t(){this.blockSize=-1,this.blockSize=64,this.g=Array(4),this.B=Array(this.blockSize),this.o=this.h=0,this.s()}function n(e,t,n){n||(n=0);var r=Array(16);if("string"==typeof t)for(var i=0;16>i;++i)r[i]=t.charCodeAt(n++)|t.charCodeAt(n++)<<8|t.charCodeAt(n++)<<16|t.charCodeAt(n++)<<24;else for(i=0;16>i;++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];var s=e.g[3],o=t+(s^n&(i^s))+r[0]+3614090360&4294967295;o=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=(n=(i=(s=(t=n+(o<<7&4294967295|o>>>25))+((o=s+(i^t&(n^i))+r[1]+3905402710&4294967295)<<12&4294967295|o>>>20))+((o=i+(n^s&(t^n))+r[2]+606105819&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^i&(s^t))+r[3]+3250441966&4294967295)<<22&4294967295|o>>>10))+((o=t+(s^n&(i^s))+r[4]+4118548399&4294967295)<<7&4294967295|o>>>25))+((o=s+(i^t&(n^i))+r[5]+1200080426&4294967295)<<12&4294967295|o>>>20))+((o=i+(n^s&(t^n))+r[6]+2821735955&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^i&(s^t))+r[7]+4249261313&4294967295)<<22&4294967295|o>>>10))+((o=t+(s^n&(i^s))+r[8]+1770035416&4294967295)<<7&4294967295|o>>>25))+((o=s+(i^t&(n^i))+r[9]+2336552879&4294967295)<<12&4294967295|o>>>20))+((o=i+(n^s&(t^n))+r[10]+4294925233&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^i&(s^t))+r[11]+2304563134&4294967295)<<22&4294967295|o>>>10))+((o=t+(s^n&(i^s))+r[12]+1804603682&4294967295)<<7&4294967295|o>>>25))+((o=s+(i^t&(n^i))+r[13]+4254626195&4294967295)<<12&4294967295|o>>>20))+((o=i+(n^s&(t^n))+r[14]+2792965006&4294967295)<<17&4294967295|o>>>15))+((o=n+(t^i&(s^t))+r[15]+1236535329&4294967295)<<22&4294967295|o>>>10))+((o=t+(i^s&(n^i))+r[1]+4129170786&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^i&(t^n))+r[6]+3225465664&4294967295)<<9&4294967295|o>>>23))+((o=i+(t^n&(s^t))+r[11]+643717713&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(i^s))+r[0]+3921069994&4294967295)<<20&4294967295|o>>>
212))+((o=t+(i^s&(n^i))+r[5]+3593408605&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^i&(t^n))+r[10]+38016083&4294967295)<<9&4294967295|o>>>23))+((o=i+(t^n&(s^t))+r[15]+3634488961&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(i^s))+r[4]+3889429448&4294967295)<<20&4294967295|o>>>12))+((o=t+(i^s&(n^i))+r[9]+568446438&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^i&(t^n))+r[14]+3275163606&4294967295)<<9&4294967295|o>>>23))+((o=i+(t^n&(s^t))+r[3]+4107603335&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(i^s))+r[8]+1163531501&4294967295)<<20&4294967295|o>>>12))+((o=t+(i^s&(n^i))+r[13]+2850285829&4294967295)<<5&4294967295|o>>>27))+((o=s+(n^i&(t^n))+r[2]+4243563512&4294967295)<<9&4294967295|o>>>23))+((o=i+(t^n&(s^t))+r[7]+1735328473&4294967295)<<14&4294967295|o>>>18))+((o=n+(s^t&(i^s))+r[12]+2368359562&4294967295)<<20&4294967295|o>>>12))+((o=t+(n^i^s)+r[5]+4294588738&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^i)+r[8]+2272392833&4294967295)<<11&4294967295|o>>>21))+((o=i+(s^t^n)+r[11]+1839030562&4294967295)<<16&4294967295|o>>>16))+((o=n+(i^s^t)+r[14]+4259657740&4294967295)<<23&4294967295|o>>>9))+((o=t+(n^i^s)+r[1]+2763975236&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^i)+r[4]+1272893353&4294967295)<<11&4294967295|o>>>21))+((o=i+(s^t^n)+r[7]+4139469664&4294967295)<<16&4294967295|o>>>16))+((o=n+(i^s^t)+r[10]+3200236656&4294967295)<<23&4294967295|o>>>9))+((o=t+(n^i^s)+r[13]+681279174&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^i)+r[0]+3936430074&4294967295)<<11&4294967295|o>>>21))+((o=i+(s^t^n)+r[3]+3572445317&4294967295)<<16&4294967295|o>>>16))+((o=n+(i^s^t)+r[6]+76029189&4294967295)<<23&4294967295|o>>>9))+((o=t+(n^i^s)+r[9]+3654602809&4294967295)<<4&4294967295|o>>>28))+((o=s+(t^n^i)+r[12]+3873151461&4294967295)<<11&4294967295|o>>>21))+((o=i+(s^t^n)+r[15]+530742520&4294967295)<<16&4294967295|o>>>16))+((o=n+(i^s^t)+r[2]+3299628645&4294967295)<<23&4294967295|o>>>9))+((o=t+(i^(n|~s))+r[0]+4096336452&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~i))+r[7]+1126891415&4294967295)<<10&4294967295|o>>>22))+((o=i+(t^(s|~n))+r[14]+2878612391&4294967295)<<15&4294967295|o>>>17))+((o=n+(s^(i|~t))+r[5]+4237533241&4294967295)<<21&4294967295|o>>>11))+((o=t+(i^(n|~s))+r[12]+1700485571&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~i))+r[3]+2399980690&4294967295)<<10&4294967295|o>>>22))+((o=i+(t^(s|~n))+r[10]+4293915773&4294967295)<<15&4294967295|o>>>17))+((o=n+(s^(i|~t))+r[1]+2240044497&4294967295)<<21&4294967295|o>>>11))+((o=t+(i^(n|~s))+r[8]+1873313359&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~i))+r[15]+4264355552&4294967295)<<10&4294967295|o>>>22))+((o=i+(t^(s|~n))+r[6]+2734768916&4294967295)<<15&4294967295|o>>>17))+((o=n+(s^(i|~t))+r[13]+1309151649&4294967295)<<21&4294967295|o>>>11))+((s=(t=n+((o=t+(i^(n|~s))+r[4]+4149444226&4294967295)<<6&4294967295|o>>>26))+((o=s+(n^(t|~i))+r[11]+3174756917&4294967295)<<10&4294967295|o>>>22))^((i=s+((o=i+(t^(s|~n))+r[2]+718787259&4294967295)<<15&4294967295|o>>>17))|~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]+s&4294967295}function r(e,t){this.h=t;for(var n=[],r=!0,i=e.length-1;0<=i;i--){var s=0|e[i];r&&s==t||(n[i]=s,r=!1)}this.g=n}!function(e,t){function n(){}n.prototype=t.prototype,e.D=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.C=function(e,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[n].apply(e,i)}}(t,function(){this.blockSize=-1}),t.prototype.s=function(){this.g[0]=1732584193,this.g[1]=4023233417,this.g[2]=2562383102,this.g[3]=271733878,this.o=this.h=0},t.prototype.u=function(e,t){void 0===t&&(t=e.length);for(var r=t-this.blockSize,i=this.B,s=this.h,o=0;o<t;){if(0==s)for(;o<=r;)n(this,e,o),o+=this.blockSize;if("string"==typeof e){for(;o<t;)if(i[s++]=e.charCodeAt(o++),s==this.blockSize){n(this,i),s=0;break}}else for(;o<t;)if(i[s++]=e[o++],s==this.blockSize){n(this,i),s=0;break}}this.h=s,this.o+=t},t.prototype.v=function(){var e=Array((56>this.h?this.blockSize:2*this.blockSize)-this.h);e[0]=128;for(var t=1;t<e.length-8;++t)e[t]=0;var n=8*this.o;for(t=e.length-8;t<e.length;++t)e[t]=255&n,n/=256;for(this.u(e),e=Array(16),t=n=0;4>t;++t)for(var r=0;32>r;r+=8)e[n++]=this.g[t]>>>r&255;return e};var i={};function s(e){return-128<=e&&128>e?function(e,t){var n=i;return Object.prototype.hasOwnProperty.call(n,e)?n[e]:n[e]=t(e)}(e,function(e){return new r([0|e],0>e?-1:0)}):new r([0|e],0>e?-1:0)}function o(e){if(isNaN(e)||!isFinite(e))return a;
2if(0>e)return d(o(-e));for(var t=[],n=1,i=0;e>=n;i++)t[i]=e/n|0,n*=4294967296;return new r(t,0)}var a=s(0),c=s(1),u=s(16777216);function l(e){if(0!=e.h)return!1;for(var t=0;t<e.g.length;t++)if(0!=e.g[t])return!1;return!0}function h(e){return-1==e.h}function d(e){for(var t=e.g.length,n=[],i=0;i<t;i++)n[i]=~e.g[i];return new r(n,~e.h).add(c)}function f(e,t){return e.add(d(t))}function p(e,t){for(;(65535&e[t])!=e[t];)e[t+1]+=e[t]>>>16,e[t]&=65535,t++}function m(e,t){this.g=e,this.h=t}function g(e,t){if(l(t))throw Error("division by zero");if(l(e))return new m(a,a);if(h(e))return t=g(d(e),t),new m(d(t.g),d(t.h));if(h(t))return t=g(e,d(t)),new m(d(t.g),t.h);if(30<e.g.length){if(h(e)||h(t))throw Error("slowDivide_ only works with positive integers.");for(var n=c,r=t;0>=r.l(e);)n=y(n),r=y(r);var i=v(n,1),s=v(r,1);for(r=v(r,2),n=v(n,2);!l(r);){var u=s.add(r);0>=u.l(e)&&(i=i.add(n),s=u),r=v(r,1),n=v(n,1)}return t=f(e,i.j(t)),new m(i,t)}for(i=a;0<=e.l(t);){for(n=Math.max(1,Math.floor(e.m()/t.m())),r=48>=(r=Math.ceil(Math.log(n)/Math.LN2))?1:Math.pow(2,r-48),u=(s=o(n)).j(t);h(u)||0<u.l(e);)u=(s=o(n-=r)).j(t);l(s)&&(s=c),i=i.add(s),e=f(e,u)}return new m(i,e)}function y(e){for(var t=e.g.length+1,n=[],i=0;i<t;i++)n[i]=e.i(i)<<1|e.i(i-1)>>>31;return new r(n,e.h)}function v(e,t){var n=t>>5;t%=32;for(var i=e.g.length-n,s=[],o=0;o<i;o++)s[o]=0<t?e.i(o+n)>>>t|e.i(o+n+1)<<32-t:e.i(o+n);return new r(s,e.h)}(e=r.prototype).m=function(){if(h(this))return-d(this).m();for(var e=0,t=1,n=0;n<this.g.length;n++){var r=this.i(n);e+=(0<=r?r:4294967296+r)*t,t*=4294967296}return e},e.toString=function(e){if(2>(e=e||10)||36<e)throw Error("radix out of range: "+e);if(l(this))return"0";if(h(this))return"-"+d(this).toString(e);for(var t=o(Math.pow(e,6)),n=this,r="";;){var i=g(n,t).g,s=((0<(n=f(n,i.j(t))).g.length?n.g[0]:n.h)>>>0).toString(e);if(l(n=i))return s+r;for(;6>s.length;)s="0"+s;r=s+r}},e.i=function(e){return 0>e?0:e<this.g.length?this.g[e]:this.h},e.l=function(e){return h(e=f(this,e))?-1:l(e)?0:1},e.abs=function(){return h(this)?d(this):this},e.add=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],i=0,s=0;s<=t;s++){var o=i+(65535&this.i(s))+(65535&e.i(s)),a=(o>>>16)+(this.i(s)>>>16)+(e.i(s)>>>16);i=a>>>16,o&=65535,a&=65535,n[s]=a<<16|o}return new r(n,-2147483648&n[n.length-1]?-1:0)},e.j=function(e){if(l(this)||l(e))return a;if(h(this))return h(e)?d(this).j(d(e)):d(d(this).j(e));if(h(e))return d(this.j(d(e)));if(0>this.l(u)&&0>e.l(u))return o(this.m()*e.m());for(var t=this.g.length+e.g.length,n=[],i=0;i<2*t;i++)n[i]=0;for(i=0;i<this.g.length;i++)for(var s=0;s<e.g.length;s++){var c=this.i(i)>>>16,f=65535&this.i(i),m=e.i(s)>>>16,g=65535&e.i(s);n[2*i+2*s]+=f*g,p(n,2*i+2*s),n[2*i+2*s+1]+=c*g,p(n,2*i+2*s+1),n[2*i+2*s+1]+=f*m,p(n,2*i+2*s+1),n[2*i+2*s+2]+=c*m,p(n,2*i+2*s+2)}for(i=0;i<t;i++)n[i]=n[2*i+1]<<16|n[2*i];for(i=t;i<2*t;i++)n[i]=0;return new r(n,0)},e.A=function(e){return g(this,e).h},e.and=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],i=0;i<t;i++)n[i]=this.i(i)&e.i(i);return new r(n,this.h&e.h)},e.or=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],i=0;i<t;i++)n[i]=this.i(i)|e.i(i);return new r(n,this.h|e.h)},e.xor=function(e){for(var t=Math.max(this.g.length,e.g.length),n=[],i=0;i<t;i++)n[i]=this.i(i)^e.i(i);return new r(n,this.h^e.h)},t.prototype.digest=t.prototype.v,t.prototype.reset=t.prototype.s,t.prototype.update=t.prototype.u,qi=Hi.Md5=t,r.prototype.add=r.prototype.add,r.prototype.multiply=r.prototype.j,r.prototype.modulo=r.prototype.A,r.prototype.compare=r.prototype.l,r.prototype.toNumber=r.prototype.m,r.prototype.toString=r.prototype.toString,r.prototype.getBits=r.prototype.i,r.fromNumber=o,r.fromString=function e(t,n){if(0==t.length)throw Error("number format error: empty string");if(2>(n=n||10)||36<n)throw Error("radix out of range: "+n);if("-"==t.charAt(0))return d(e(t.substring(1),n));if(0<=t.indexOf("-"))throw Error('number format error: interior "-" character');for(var r=o(Math.pow(n,8)),i=a,s=0;s<t.length;s+=8){var c=Math.min(8,t.length-s),u=parseInt(t.substring(s,s+c),n);8>c?(c=o(Math.pow(n,c)),i=i.j(c).add(o(u))):i=(i=i.j(r)).add(o(u))}return i},Bi=Hi.Integer=r}).apply(void 0!==zi?zi:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});var Gi,Ki,Wi,Yi,Qi,Ji,Xi,Zi,es="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==n.g?n.g:"undefined"!=typeof self?self:{},ts={};(function(){var e,t="function"==typeof Object.defineProperties?Object.defineProperty:function(e,t,n){return e==Array.prototype||e==Object.prototype||(e[t]=n.value),e};var n=function(e){e=["object"==typeof globalThis&&globalThis,e,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof es&&es];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")}(this);!function(e,r){if(r)e:{var i=n;e=e.split(".");for(var s=0;s<e.length-1;s++){var o=e[s];if(!(o in i))break e;i=i[o]}(r=r(s=i[e=e[e.length-1]]))!=s&&null!=r&&t(i,e,{configurable:!0,writable:!0,value:r})}}("Array.prototype.values",function(e){return e||function(){return function(e,t){e instanceof String&&(e+="");var n=0,r=!1,i={next:function(){if(!r&&n<e.length){var i=n++;return{value:t(i,e[i]),done:!1}}return r=!0,{done:!0,value:void 0}}};return i[Symbol.iterator]=function(){return i},i}(this,function(e,t){return t})}});var r=r||{},i=this||self;function s(e){var t=typeof e;return"array"==(t="object"!=t?t:e?Array.isArray(e)?"array":t:"null")||"object"==t&&"number"==typeof e.length}function o(e){var t=typeof e;return"object"==t&&null!=e||"function"==t}function a(e,t,n){return e.call.apply(e.bind,arguments)}
2function c(e,t,n){if(!e)throw Error();if(2<arguments.length){var r=Array.prototype.slice.call(arguments,2);return function(){var n=Array.prototype.slice.call(arguments);return Array.prototype.unshift.apply(n,r),e.apply(t,n)}}return function(){return e.apply(t,arguments)}}function u(e,t,n){return(u=Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?a:c).apply(null,arguments)}function l(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 h(e,t){function n(){}n.prototype=t.prototype,e.aa=t.prototype,e.prototype=new n,e.prototype.constructor=e,e.Qb=function(e,n,r){for(var i=Array(arguments.length-2),s=2;s<arguments.length;s++)i[s-2]=arguments[s];return t.prototype[n].apply(e,i)}}function d(e){const t=e.length;if(0<t){const n=Array(t);for(let r=0;r<t;r++)n[r]=e[r];return n}return[]}function f(e,t){for(let t=1;t<arguments.length;t++){const n=arguments[t];if(s(n)){const t=e.length||0,r=n.length||0;e.length=t+r;for(let i=0;i<r;i++)e[t+i]=n[i]}else e.push(n)}}function p(e){return/^[\s\xa0]*$/.test(e)}function m(){var e=i.navigator;return e&&(e=e.userAgent)?e:""}function g(e){return g[" "](e),e}g[" "]=function(){};var y=!(-1==m().indexOf("Gecko")||-1!=m().toLowerCase().indexOf("webkit")&&-1==m().indexOf("Edge")||-1!=m().indexOf("Trident")||-1!=m().indexOf("MSIE")||-1!=m().indexOf("Edge"));function v(e,t,n){for(const r in e)t.call(n,e[r],r,e)}function w(e){const t={};for(const n in e)t[n]=e[n];return t}const _="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");function b(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<_.length;t++)n=_[t],Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}}function E(e){var t=1;e=e.split(":");const n=[];for(;0<t&&e.length;)n.push(e.shift()),t--;return e.length&&n.push(e.join(":")),n}function T(e){i.setTimeout(()=>{throw e},0)}function I(){var e=N;let t=null;return e.g&&(t=e.g,e.g=e.g.next,e.g||(e.h=null),t.next=null),t}var S=new class{constructor(e,t){this.i=e,this.j=t,this.h=0,this.g=null}get(){let e;return 0<this.h?(this.h--,e=this.g,this.g=e.next,e.next=null):e=this.i(),e}}(()=>new C,e=>e.reset());class C{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 A,k=!1,N=new class{constructor(){this.h=this.g=null}add(e,t){const n=S.get();n.set(e,t),this.h?this.h.next=n:this.g=n,this.h=n}},O=()=>{const e=i.Promise.resolve(void 0);A=()=>{e.then(D)}};var D=()=>{for(var e;e=I();){try{e.h.call(e.g)}catch(e){T(e)}var t=S;t.j(e),100>t.h&&(t.h++,e.next=t.g,t.g=e)}k=!1};function R(){this.s=this.s,this.C=this.C}function P(e,t){this.type=e,this.g=this.target=t,this.defaultPrevented=!1}R.prototype.s=!1,R.prototype.ma=function(){this.s||(this.s=!0,this.N())},R.prototype.N=function(){if(this.C)for(;this.C.length;)this.C.shift()()},P.prototype.h=function(){this.defaultPrevented=!0};var L=function(){if(!i.addEventListener||!Object.defineProperty)return!1;var e=!1,t=Object.defineProperty({},"passive",{get:function(){e=!0}});try{const e=()=>{};i.addEventListener("test",e,t),i.removeEventListener("test",e,t)}catch(e){}return e}();function M(e,t){if(P.call(this,e?e.type:""),this.relatedTarget=this.g=this.target=null,this.button=this.screenY=this.screenX=this.clientY=this.clientX=0,this.key="",this.metaKey=this.shiftKey=this.altKey=this.ctrlKey=!1,this.state=null,this.pointerId=0,this.pointerType="",this.i=null,e){var n=this.type=e.type,r=e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:null;if(this.target=e.target||e.srcElement,this.g=t,t=e.relatedTarget){if(y){e:{try{g(t.nodeName);var i=!0;break e}catch(e){}i=!1}i||(t=null)}}else"mouseover"==n?t=e.fromElement:"mouseout"==n&&(t=e.toElement);this.relatedTarget=t,r?(this.clientX=void 0!==r.clientX?r.clientX:r.pageX,this.clientY=void 0!==r.clientY?r.clientY:r.pageY,this.screenX=r.screenX||0,this.screenY=r.screenY||0):(this.clientX=void 0!==e.clientX?e.clientX:e.pageX,this.clientY=void 0!==e.clientY?e.clientY:e.pageY,this.screenX=e.screenX||0,this.screenY=e.screenY||0),this.button=e.button,this.key=e.key||"",this.ctrlKey=e.ctrlKey,this.altKey=e.altKey,this.shiftKey=e.shiftKey,this.metaKey=e.metaKey,this.pointerId=e.pointerId||0,this.pointerType="string"==typeof e.pointerType?e.pointerType:x[e.pointerType]||"",this.state=e.state,this.i=e,e.defaultPrevented&&M.aa.h.call(this)}}h(M,P);var x={2:"touch",3:"pen",4:"mouse"};M.prototype.h=function(){M.aa.h.call(this);var e=this.i;e.preventDefault?e.preventDefault():e.returnValue=!1};var F="closure_listenable_"+(1e6*Math.random()|0),U=0;function V(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=++U,this.da=this.fa=!1}function j(e){e.da=!0,e.listener=null,e.proxy=null,e.src=null,e.ha=null}function $(e){this.src=e,this.g={},this.h=0}function B(e,t){var n=t.type;if(n in e.g){var r,i=e.g[n],s=Array.prototype.indexOf.call(i,t,void 0);(r=0<=s)&&Array.prototype.splice.call(i,s,1),r&&(j(t),0==e.g[n].length&&(delete e.g[n],e.h--))}}function q(e,t,n,r){for(var i=0;i<e.length;++i){var s=e[i];if(!s.da&&s.listener==t&&s.capture==!!n&&s.ha==r)return i}return-1}$.prototype.add=function(e,t,n,r,i){var s=e.toString();(e=this.g[s])||(e=this.g[s]=[],this.h++);
2var o=q(e,t,r,i);return-1<o?(t=e[o],n||(t.fa=!1)):((t=new V(t,this.src,s,!!r,i)).fa=n,e.push(t)),t};var z="closure_lm_"+(1e6*Math.random()|0),H={};function G(e,t,n,r,i){if(r&&r.once)return W(e,t,n,r,i);if(Array.isArray(t)){for(var s=0;s<t.length;s++)G(e,t[s],n,r,i);return null}return n=te(n),e&&e[F]?e.K(t,n,o(r)?!!r.capture:!!r,i):K(e,t,n,!1,r,i)}function K(e,t,n,r,i,s){if(!t)throw Error("Invalid event type");var a=o(i)?!!i.capture:!!i,c=Z(e);if(c||(e[z]=c=new $(e)),(n=c.add(t,n,r,a,s)).proxy)return n;if(r=function(){function e(n){return t.call(e.src,e.listener,n)}const t=X;return e}(),n.proxy=r,r.src=e,r.listener=n,e.addEventListener)L||(i=a),void 0===i&&(i=!1),e.addEventListener(t.toString(),r,i);else if(e.attachEvent)e.attachEvent(J(t.toString()),r);else{if(!e.addListener||!e.removeListener)throw Error("addEventListener and attachEvent are unavailable.");e.addListener(r)}return n}function W(e,t,n,r,i){if(Array.isArray(t)){for(var s=0;s<t.length;s++)W(e,t[s],n,r,i);return null}return n=te(n),e&&e[F]?e.L(t,n,o(r)?!!r.capture:!!r,i):K(e,t,n,!0,r,i)}function Y(e,t,n,r,i){if(Array.isArray(t))for(var s=0;s<t.length;s++)Y(e,t[s],n,r,i);else r=o(r)?!!r.capture:!!r,n=te(n),e&&e[F]?(e=e.i,(t=String(t).toString())in e.g&&(-1<(n=q(s=e.g[t],n,r,i))&&(j(s[n]),Array.prototype.splice.call(s,n,1),0==s.length&&(delete e.g[t],e.h--)))):e&&(e=Z(e))&&(t=e.g[t.toString()],e=-1,t&&(e=q(t,n,r,i)),(n=-1<e?t[e]:null)&&Q(n))}function Q(e){if("number"!=typeof e&&e&&!e.da){var t=e.src;if(t&&t[F])B(t.i,e);else{var n=e.type,r=e.proxy;t.removeEventListener?t.removeEventListener(n,r,e.capture):t.detachEvent?t.detachEvent(J(n),r):t.addListener&&t.removeListener&&t.removeListener(r),(n=Z(t))?(B(n,e),0==n.h&&(n.src=null,t[z]=null)):j(e)}}}function J(e){return e in H?H[e]:H[e]="on"+e}function X(e,t){if(e.da)e=!0;else{t=new M(t,this);var n=e.listener,r=e.ha||e.src;e.fa&&Q(e),e=n.call(r,t)}return e}function Z(e){return(e=e[z])instanceof $?e:null}var ee="__closure_events_fn_"+(1e9*Math.random()>>>0);function te(e){return"function"==typeof e?e:(e[ee]||(e[ee]=function(t){return e.handleEvent(t)}),e[ee])}function ne(){R.call(this),this.i=new $(this),this.M=this,this.F=null}function re(e,t){var n,r=e.F;if(r)for(n=[];r;r=r.F)n.push(r);if(e=e.M,r=t.type||t,"string"==typeof t)t=new P(t,e);else if(t instanceof P)t.target=t.target||e;else{var i=t;b(t=new P(r,e),i)}if(i=!0,n)for(var s=n.length-1;0<=s;s--){var o=t.g=n[s];i=ie(o,r,!0,t)&&i}if(i=ie(o=t.g=e,r,!0,t)&&i,i=ie(o,r,!1,t)&&i,n)for(s=0;s<n.length;s++)i=ie(o=t.g=n[s],r,!1,t)&&i}function ie(e,t,n,r){if(!(t=e.i.g[String(t)]))return!0;t=t.concat();for(var i=!0,s=0;s<t.length;++s){var o=t[s];if(o&&!o.da&&o.capture==n){var a=o.listener,c=o.ha||o.src;o.fa&&B(e.i,o),i=!1!==a.call(c,r)&&i}}return i&&!r.defaultPrevented}function se(e,t,n){if("function"==typeof e)n&&(e=u(e,n));else{if(!e||"function"!=typeof e.handleEvent)throw Error("Invalid listener argument");e=u(e.handleEvent,e)}return 2147483647<Number(t)?-1:i.setTimeout(e,t||0)}function oe(e){e.g=se(()=>{e.g=null,e.i&&(e.i=!1,oe(e))},e.l);const t=e.h;e.h=null,e.m.apply(null,t)}h(ne,R),ne.prototype[F]=!0,ne.prototype.removeEventListener=function(e,t,n,r){Y(this,e,t,n,r)},ne.prototype.N=function(){if(ne.aa.N.call(this),this.i){var e,t=this.i;for(e in t.g){for(var n=t.g[e],r=0;r<n.length;r++)j(n[r]);delete t.g[e],t.h--}}this.F=null},ne.prototype.K=function(e,t,n,r){return this.i.add(String(e),t,!1,n,r)},ne.prototype.L=function(e,t,n,r){return this.i.add(String(e),t,!0,n,r)};class ae extends R{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:oe(this)}N(){super.N(),this.g&&(i.clearTimeout(this.g),this.g=null,this.i=!1,this.h=null)}}function ce(e){R.call(this),this.h=e,this.g={}}h(ce,R);var ue=[];function le(e){v(e.g,function(e,t){this.g.hasOwnProperty(t)&&Q(e)},e),e.g={}}ce.prototype.N=function(){ce.aa.N.call(this),le(this)},ce.prototype.handleEvent=function(){throw Error("EventHandler.handleEvent not implemented")};var he=i.JSON.stringify,de=i.JSON.parse,fe=class{stringify(e){return i.JSON.stringify(e,void 0)}parse(e){return i.JSON.parse(e,void 0)}};function pe(){}function me(e){return e.h||(e.h=e.i())}function ge(){}pe.prototype.h=null;var ye={OPEN:"a",kb:"b",Ja:"c",wb:"d"};function ve(){P.call(this,"d")}function we(){P.call(this,"c")}h(ve,P),h(we,P);var _e={},be=null;function Ee(){return be=be||new ne}function Te(e){P.call(this,_e.La,e)}function Ie(e){const t=Ee();re(t,new Te(t))}function Se(e,t){P.call(this,_e.STAT_EVENT,e),this.stat=t}function Ce(e){const t=Ee();re(t,new Se(t,e))}function Ae(e,t){P.call(this,_e.Ma,e),this.size=t}function ke(e,t){if("function"!=typeof e)throw Error("Fn must not be null and must be a function");return i.setTimeout(function(){e()},t)}function Ne(){this.g=!0}function Oe(e,t,n,r){e.info(function(){return"XMLHTTP TEXT ("+t+"): "+function(e,t){if(!e.g)return t;if(!t)return null;try{var n=JSON.parse(t);if(n)for(e=0;e<n.length;e++)if(Array.isArray(n[e])){var r=n[e];if(!(2>r.length)){var i=r[1];if(Array.isArray(i)&&!(1>i.length)){var s=i[0];if("noop"!=s&&"stop"!=s&&"close"!=s)for(var o=1;o<i.length;o++)i[o]=""}}}return he(n)}catch(e){return t}}(e,n)+(r?" "+r:"")})}_e.La="serverreachability",h(Te,P),_e.STAT_EVENT="statevent",h(Se,P),_e.Ma="timingevent",h(Ae,P),Ne.prototype.xa=function(){this.g=!1},Ne.prototype.info=function(){};var De,Re={NO_ERROR:0,gb:1,tb:2,sb:3,nb:4,rb:5,ub:6,Ia:7,TIMEOUT:8,xb:9},Pe={lb:"complete",Hb:"success",Ja:"error",Ia:"abort",zb:"ready",Ab:"readystatechange",TIMEOUT:"timeout",vb:"incrementaldata",yb:"progress",ob:"downloadprogress",Pb:"uploadprogress"};function Le(){}function Me(e,t,n,r){this.j=e,this.i=t,this.l=n,this.R=r||1,this.U=new ce(this),this.I=45e3,this.H=null,this.o=!1,this.m=this.A=this.v=this.L=this.F=this.S=this.B=null,this.D=[],this.g=null,this.C=0,this.s=this.u=null,this.X=-1,this.J=!1,this.O=0,this.M=null,this.W=this.K=this.T=this.P=!1,this.h=new xe}function xe(){this.i=null,this.g="",this.h=!1}h(Le,pe),Le.prototype.g=function(){return new XMLHttpRequest},Le.prototype.i=function(){return{}},De=new Le;var Fe={},Ue={};function Ve(e,t,n){e.L=1,e.v=ht(ot(t)),e.m=n,e.P=!0,je(e,null)}function je(e,t){e.F=Date.now(),qe(e),e.A=ot(e.v);var n=e.A,r=e.R;Array.isArray(r)||(r=[String(r)]),St(n.i,"t",r),e.C=0,n=e.j.J,e.h=new xe,e.g=fn(e.j,n?t:null,!e.m),
20<e.O&&(e.M=new ae(u(e.Y,e,e.g),e.O)),t=e.U,n=e.g,r=e.ca;var i="readystatechange";Array.isArray(i)||(i&&(ue[0]=i.toString()),i=ue);for(var s=0;s<i.length;s++){var o=G(n,i[s],r||t.handleEvent,!1,t.h||t);if(!o)break;t.g[o.key]=o}t=e.H?w(e.H):{},e.m?(e.u||(e.u="POST"),t["Content-Type"]="application/x-www-form-urlencoded",e.g.ea(e.A,e.u,e.m,t)):(e.u="GET",e.g.ea(e.A,e.u,null,t)),Ie(),function(e,t,n,r,i,s){e.info(function(){if(e.g)if(s)for(var o="",a=s.split("&"),c=0;c<a.length;c++){var u=a[c].split("=");if(1<u.length){var l=u[0];u=u[1];var h=l.split("_");o=2<=h.length&&"type"==h[1]?o+(l+"=")+u+"&":o+(l+"=redacted&")}}else o=null;else o=s;return"XMLHTTP REQ ("+r+") [attempt "+i+"]: "+t+"\n"+n+"\n"+o})}(e.i,e.u,e.A,e.l,e.R,e.m)}function $e(e){return!!e.g&&("GET"==e.u&&2!=e.L&&e.j.Ca)}function Be(e,t){var n=e.C,r=t.indexOf("\n",n);return-1==r?Ue:(n=Number(t.substring(n,r)),isNaN(n)?Fe:(r+=1)+n>t.length?Ue:(t=t.slice(r,r+n),e.C=r+n,t))}function qe(e){e.S=Date.now()+e.I,ze(e,e.I)}function ze(e,t){if(null!=e.B)throw Error("WatchDog timer not null");e.B=ke(u(e.ba,e),t)}function He(e){e.B&&(i.clearTimeout(e.B),e.B=null)}function Ge(e){0==e.j.G||e.J||cn(e.j,e)}function Ke(e){He(e);var t=e.M;t&&"function"==typeof t.ma&&t.ma(),e.M=null,le(e.U),e.g&&(t=e.g,e.g=null,t.abort(),t.ma())}function We(e,t){try{var n=e.j;if(0!=n.G&&(n.g==e||Ze(n.h,e)))if(!e.K&&Ze(n.h,e)&&3==n.G){try{var r=n.Da.g.parse(t)}catch(e){r=null}if(Array.isArray(r)&&3==r.length){var i=r;if(0==i[0]){e:if(!n.u){if(n.g){if(!(n.g.F+3e3<e.F))break e;an(n),Qt(n)}rn(n),Ce(18)}}else n.za=i[1],0<n.za-n.T&&37500>i[2]&&n.F&&0==n.v&&!n.C&&(n.C=ke(u(n.Za,n),6e3));if(1>=Xe(n.h)&&n.ca){try{n.ca()}catch(e){}n.ca=void 0}}else ln(n,11)}else if((e.K||n.g==e)&&an(n),!p(t))for(i=n.Da.g.parse(t),t=0;t<i.length;t++){let u=i[t];if(n.T=u[0],u=u[1],2==n.G)if("c"==u[0]){n.K=u[1],n.ia=u[2];const t=u[3];null!=t&&(n.la=t,n.j.info("VER="+n.la));const i=u[4];null!=i&&(n.Aa=i,n.j.info("SVER="+n.Aa));const l=u[5];null!=l&&"number"==typeof l&&0<l&&(r=1.5*l,n.L=r,n.j.info("backChannelRequestTimeoutMs_="+r)),r=n;const h=e.g;if(h){const e=h.g?h.g.getResponseHeader("X-Client-Wire-Protocol"):null;if(e){var s=r.h;s.g||-1==e.indexOf("spdy")&&-1==e.indexOf("quic")&&-1==e.indexOf("h2")||(s.j=s.l,s.g=new Set,s.h&&(et(s,s.h),s.h=null))}if(r.D){const e=h.g?h.g.getResponseHeader("X-HTTP-Session-Id"):null;e&&(r.ya=e,lt(r.I,r.D,e))}}n.G=3,n.l&&n.l.ua(),n.ba&&(n.R=Date.now()-e.F,n.j.info("Handshake RTT: "+n.R+"ms"));var o=e;if((r=n).qa=dn(r,r.J?r.ia:null,r.W),o.K){tt(r.h,o);var a=o,c=r.L;c&&(a.I=c),a.B&&(He(a),qe(a)),r.g=o}else nn(r);0<n.i.length&&Xt(n)}else"stop"!=u[0]&&"close"!=u[0]||ln(n,7);else 3==n.G&&("stop"==u[0]||"close"==u[0]?"stop"==u[0]?ln(n,7):Yt(n):"noop"!=u[0]&&n.l&&n.l.ta(u),n.v=0)}Ie()}catch(e){}}Me.prototype.ca=function(e){e=e.target;const t=this.M;t&&3==Ht(e)?t.j():this.Y(e)},Me.prototype.Y=function(e){try{if(e==this.g)e:{const d=Ht(this.g);var t=this.g.Ba();this.g.Z();if(!(3>d)&&(3!=d||this.g&&(this.h.h||this.g.oa()||Gt(this.g)))){this.J||4!=d||7==t||Ie(),He(this);var n=this.g.Z();this.X=n;t:if($e(this)){var r=Gt(this.g);e="";var s=r.length,o=4==Ht(this.g);if(!this.h.i){if("undefined"==typeof TextDecoder){Ke(this),Ge(this);var a="";break t}this.h.i=new i.TextDecoder}for(t=0;t<s;t++)this.h.h=!0,e+=this.h.i.decode(r[t],{stream:!(o&&t==s-1)});r.length=0,this.h.g+=e,this.C=0,a=this.h.g}else a=this.g.oa();if(this.o=200==n,function(e,t,n,r,i,s,o){e.info(function(){return"XMLHTTP RESP ("+r+") [ attempt "+i+"]: "+t+"\n"+n+"\n"+s+" "+o})}(this.i,this.u,this.A,this.l,this.R,d,n),this.o){if(this.T&&!this.K){t:{if(this.g){var c,u=this.g;if((c=u.g?u.g.getResponseHeader("X-HTTP-Initial-Response"):null)&&!p(c)){var l=c;break t}}l=null}if(!(n=l)){this.o=!1,this.s=3,Ce(12),Ke(this),Ge(this);break e}Oe(this.i,this.l,n,"Initial handshake response via X-HTTP-Initial-Response"),this.K=!0,We(this,n)}if(this.P){let e;for(n=!0;!this.J&&this.C<a.length;){if(e=Be(this,a),e==Ue){4==d&&(this.s=4,Ce(14),n=!1),Oe(this.i,this.l,null,"[Incomplete Response]");break}if(e==Fe){this.s=4,Ce(15),Oe(this.i,this.l,a,"[Invalid Chunk]"),n=!1;break}Oe(this.i,this.l,e,null),We(this,e)}if($e(this)&&0!=this.C&&(this.h.g=this.h.g.slice(this.C),this.C=0),4!=d||0!=a.length||this.h.h||(this.s=1,Ce(16),n=!1),this.o=this.o&&n,n){if(0<a.length&&!this.W){this.W=!0;var h=this.j;h.g==this&&h.ba&&!h.M&&(h.j.info("Great, no buffering proxy detected. Bytes received: "+a.length),sn(h),h.M=!0,Ce(11))}}else Oe(this.i,this.l,a,"[Invalid Chunked Response]"),Ke(this),Ge(this)}else Oe(this.i,this.l,a,null),We(this,a);4==d&&Ke(this),this.o&&!this.J&&(4==d?cn(this.j,this):(this.o=!1,qe(this)))}else(function(e){const t={};e=(e.g&&2<=Ht(e)&&e.g.getAllResponseHeaders()||"").split("\r\n");for(let r=0;r<e.length;r++){if(p(e[r]))continue;var n=E(e[r]);const i=n[0];if("string"!=typeof(n=n[1]))continue;n=n.trim();const s=t[i]||[];t[i]=s,s.push(n)}!function(e,t){for(const n in e)t.call(void 0,e[n],n,e)}(t,function(e){return e.join(", ")})})(this.g),400==n&&0<a.indexOf("Unknown SID")?(this.s=3,Ce(12)):(this.s=0,Ce(13)),Ke(this),Ge(this)}}}catch(e){}},Me.prototype.cancel=function(){this.J=!0,Ke(this)},Me.prototype.ba=function(){this.B=null;const e=Date.now();0<=e-this.S?(function(e,t){e.info(function(){return"TIMEOUT: "+t})}(this.i,this.A),2!=this.L&&(Ie(),Ce(17)),Ke(this),this.s=2,Ge(this)):ze(this,this.S-e)};var Ye=class{constructor(e,t){this.g=e,this.map=t}};function Qe(e){this.l=e||10,i.PerformanceNavigationTiming?e=0<(e=i.performance.getEntriesByType("navigation")).length&&("hq"==e[0].nextHopProtocol||"h2"==e[0].nextHopProtocol):e=!!(i.chrome&&i.chrome.loadTimes&&i.chrome.loadTimes()&&i.chrome.loadTimes().wasFetchedViaSpdy),this.j=e?this.l:1,this.g=null,1<this.j&&(this.g=new Set),this.h=null,this.i=[]}function Je(e){return!!e.h||!!e.g&&e.g.size>=e.j}function Xe(e){return e.h?1:e.g?e.g.size:0}function Ze(e,t){return e.h?e.h==t:!!e.g&&e.g.has(t)}function et(e,t){e.g?e.g.add(t):e.h=t}function tt(e,t){e.h&&e.h==t?e.h=null:e.g&&e.g.has(t)&&e.g.delete(t)}function nt(e){if(null!=e.h)return e.i.concat(e.h.D);if(null!=e.g&&0!==e.g.size){let t=e.i;for(const n of e.g.values())t=t.concat(n.D);return t}return d(e.i)}function rt(e,t){if(e.forEach&&"function"==typeof e.forEach)e.forEach(t,void 0);else if(s(e)||"string"==typeof e)Array.prototype.forEach.call(e,t,void 0);else for(var n=function(e){if(e.na&&"function"==typeof e.na)return e.na();if(!e.V||"function"!=typeof e.V){if("undefined"!=typeof Map&&e instanceof Map)return Array.from(e.keys());if(!("undefined"!=typeof Set&&e instanceof Set)){if(s(e)||"string"==typeof e){var t=[];e=e.length;for(var n=0;n<e;n++)t.push(n);return t}t=[],n=0;for(const r in e)t[n++]=r;return t}}}(e),r=function(e){if(e.V&&"function"==typeof e.V)return e.V();if("undefined"!=typeof Map&&e instanceof Map||"undefined"!=typeof Set&&e instanceof Set)return Array.from(e.values());if("string"==typeof e)return e.split("");
2if(s(e)){for(var t=[],n=e.length,r=0;r<n;r++)t.push(e[r]);return t}for(r in t=[],n=0,e)t[n++]=e[r];return t}(e),i=r.length,o=0;o<i;o++)t.call(void 0,r[o],n&&n[o],e)}Qe.prototype.cancel=function(){if(this.i=nt(this),this.h)this.h.cancel(),this.h=null;else if(this.g&&0!==this.g.size){for(const e of this.g.values())e.cancel();this.g.clear()}};var it=RegExp("^(?:([^:/?#.]+):)?(?://(?:([^\\\\/?#]*)@)?([^\\\\/?#]*?)(?::([0-9]+))?(?=[\\\\/?#]|$))?([^?#]+)?(?:\\?([^#]*))?(?:#([\\s\\S]*))?$");function st(e){if(this.g=this.o=this.j="",this.s=null,this.m=this.l="",this.h=!1,e instanceof st){this.h=e.h,at(this,e.j),this.o=e.o,this.g=e.g,ct(this,e.s),this.l=e.l;var t=e.i,n=new bt;n.i=t.i,t.g&&(n.g=new Map(t.g),n.h=t.h),ut(this,n),this.m=e.m}else e&&(t=String(e).match(it))?(this.h=!1,at(this,t[1]||"",!0),this.o=dt(t[2]||""),this.g=dt(t[3]||"",!0),ct(this,t[4]),this.l=dt(t[5]||"",!0),ut(this,t[6]||"",!0),this.m=dt(t[7]||"")):(this.h=!1,this.i=new bt(null,this.h))}function ot(e){return new st(e)}function at(e,t,n){e.j=n?dt(t,!0):t,e.j&&(e.j=e.j.replace(/:$/,""))}function ct(e,t){if(t){if(t=Number(t),isNaN(t)||0>t)throw Error("Bad port number "+t);e.s=t}else e.s=null}function ut(e,t,n){t instanceof bt?(e.i=t,function(e,t){t&&!e.j&&(Et(e),e.i=null,e.g.forEach(function(e,t){var n=t.toLowerCase();t!=n&&(Tt(this,t),St(this,n,e))},e)),e.j=t}(e.i,e.h)):(n||(t=ft(t,wt)),e.i=new bt(t,e.h))}function lt(e,t,n){e.i.set(t,n)}function ht(e){return lt(e,"zx",Math.floor(2147483648*Math.random()).toString(36)+Math.abs(Math.floor(2147483648*Math.random())^Date.now()).toString(36)),e}function dt(e,t){return e?t?decodeURI(e.replace(/%25/g,"%2525")):decodeURIComponent(e):""}function ft(e,t,n){return"string"==typeof e?(e=encodeURI(e).replace(t,pt),n&&(e=e.replace(/%25([0-9a-fA-F]{2})/g,"%$1")),e):null}function pt(e){return"%"+((e=e.charCodeAt(0))>>4&15).toString(16)+(15&e).toString(16)}st.prototype.toString=function(){var e=[],t=this.j;t&&e.push(ft(t,gt,!0),":");var n=this.g;return(n||"file"==t)&&(e.push("//"),(t=this.o)&&e.push(ft(t,gt,!0),"@"),e.push(encodeURIComponent(String(n)).replace(/%25([0-9a-fA-F]{2})/g,"%$1")),null!=(n=this.s)&&e.push(":",String(n))),(n=this.l)&&(this.g&&"/"!=n.charAt(0)&&e.push("/"),e.push(ft(n,"/"==n.charAt(0)?vt:yt,!0))),(n=this.i.toString())&&e.push("?",n),(n=this.m)&&e.push("#",ft(n,_t)),e.join("")};var mt,gt=/[#\/\?@]/g,yt=/[#\?:]/g,vt=/[#\?]/g,wt=/[#\?@]/g,_t=/#/g;function bt(e,t){this.h=this.g=null,this.i=e||null,this.j=!!t}function Et(e){e.g||(e.g=new Map,e.h=0,e.i&&function(e,t){if(e){e=e.split("&");for(var n=0;n<e.length;n++){var r=e[n].indexOf("="),i=null;if(0<=r){var s=e[n].substring(0,r);i=e[n].substring(r+1)}else s=e[n];t(s,i?decodeURIComponent(i.replace(/\+/g," ")):"")}}}(e.i,function(t,n){e.add(decodeURIComponent(t.replace(/\+/g," ")),n)}))}function Tt(e,t){Et(e),t=Ct(e,t),e.g.has(t)&&(e.i=null,e.h-=e.g.get(t).length,e.g.delete(t))}function It(e,t){return Et(e),t=Ct(e,t),e.g.has(t)}function St(e,t,n){Tt(e,t),0<n.length&&(e.i=null,e.g.set(Ct(e,t),d(n)),e.h+=n.length)}function Ct(e,t){return t=String(t),e.j&&(t=t.toLowerCase()),t}function At(e,t,n,r,i){try{i&&(i.onload=null,i.onerror=null,i.onabort=null,i.ontimeout=null),r(n)}catch(e){}}function kt(){this.g=new fe}function Nt(e,t,n){const r=n||"";try{rt(e,function(e,n){let i=e;o(e)&&(i=he(e)),t.push(r+n+"="+encodeURIComponent(i))})}catch(e){throw t.push(r+"type="+encodeURIComponent("_badmap")),e}}function Ot(e){this.l=e.Ub||null,this.j=e.eb||!1}function Dt(e,t){ne.call(this),this.D=e,this.o=t,this.m=void 0,this.status=this.readyState=0,this.responseType=this.responseText=this.response=this.statusText="",this.onreadystatechange=null,this.u=new Headers,this.h=null,this.B="GET",this.A="",this.g=!1,this.v=this.j=this.l=null}function Rt(e){e.j.read().then(e.Pa.bind(e)).catch(e.ga.bind(e))}function Pt(e){e.readyState=4,e.l=null,e.j=null,e.v=null,Lt(e)}function Lt(e){e.onreadystatechange&&e.onreadystatechange.call(e)}function Mt(e){let t="";return v(e,function(e,n){t+=n,t+=":",t+=e,t+="\r\n"}),t}function xt(e,t,n){e:{for(r in n){var r=!1;break e}r=!0}r||(n=Mt(n),"string"==typeof e?null!=n&&encodeURIComponent(String(n)):lt(e,t,n))}function Ft(e){ne.call(this),this.headers=new Map,this.o=e||null,this.h=!1,this.v=this.g=null,this.D="",this.m=0,this.l="",this.j=this.B=this.u=this.A=!1,this.I=null,this.H="",this.J=!1}(e=bt.prototype).add=function(e,t){Et(this),this.i=null,e=Ct(this,e);var n=this.g.get(e);return n||this.g.set(e,n=[]),n.push(t),this.h+=1,this},e.forEach=function(e,t){Et(this),this.g.forEach(function(n,r){n.forEac
2h(function(n){e.call(t,n,r,this)},this)},this)},e.na=function(){Et(this);const e=Array.from(this.g.values()),t=Array.from(this.g.keys()),n=[];for(let r=0;r<t.length;r++){const i=e[r];for(let e=0;e<i.length;e++)n.push(t[r])}return n},e.V=function(e){Et(this);let t=[];if("string"==typeof e)It(this,e)&&(t=t.concat(this.g.get(Ct(this,e))));else{e=Array.from(this.g.values());for(let n=0;n<e.length;n++)t=t.concat(e[n])}return t},e.set=function(e,t){return Et(this),this.i=null,It(this,e=Ct(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&&0<(e=this.V(e)).length?String(e[0]):t},e.toString=function(){if(this.i)return this.i;if(!this.g)return"";const e=[],t=Array.from(this.g.keys());for(var n=0;n<t.length;n++){var r=t[n];const s=encodeURIComponent(String(r)),o=this.V(r);for(r=0;r<o.length;r++){var i=s;""!==o[r]&&(i+="="+encodeURIComponent(String(o[r]))),e.push(i)}}return this.i=e.join("&")},h(Ot,pe),Ot.prototype.g=function(){return new Dt(this.l,this.j)},Ot.prototype.i=(mt={},function(){return mt}),h(Dt,ne),(e=Dt.prototype).open=function(e,t){if(0!=this.readyState)throw this.abort(),Error("Error reopening a connection");this.B=e,this.A=t,this.readyState=1,Lt(this)},e.send=function(e){if(1!=this.readyState)throw this.abort(),Error("need to call open() first. ");this.g=!0;const t={headers:this.u,method:this.B,credentials:this.m,cache:void 0};e&&(t.body=e),(this.D||i).fetch(new Request(this.A,t)).then(this.Sa.bind(this),this.ga.bind(this))},e.abort=function(){this.response=this.responseText="",this.u=new Headers,this.status=0,this.j&&this.j.cancel("Request was aborted.").catch(()=>{}),1<=this.readyState&&this.g&&4!=this.readyState&&(this.g=!1,Pt(this)),this.readyState=0},e.Sa=function(e){if(this.g&&(this.l=e,this.h||(this.status=this.l.status,this.statusText=this.l.statusText,this.h=e.headers,this.readyState=2,Lt(this)),this.g&&(this.readyState=3,Lt(this),this.g)))if("arraybuffer"===this.responseType)e.arrayBuffer().then(this.Qa.bind(this),this.ga.bind(this));else if(void 0!==i.ReadableStream&&"body"in e){if(this.j=e.body.getReader(),this.o){if(this.responseType)throw Error('responseType must be empty for "streamBinaryChunks" mode responses.');this.response=[]}else this.response=this.responseText="",this.v=new TextDecoder;Rt(this)}else e.text().then(this.Ra.bind(this),this.ga.bind(this))},e.Pa=function(e){if(this.g){if(this.o&&e.value)this.response.push(e.value);else if(!this.o){var t=e.value?e.value:new Uint8Array(0);(t=this.v.decode(t,{stream:!e.done}))&&(this.response=this.responseText+=t)}e.done?Pt(this):Lt(this),3==this.readyState&&Rt(this)}},e.Ra=function(e){this.g&&(this.response=this.responseText=e,Pt(this))},e.Qa=function(e){this.g&&(this.response=e,Pt(this))},e.ga=function(){this.g&&Pt(this)},e.setRequestHeader=function(e,t){this.u.append(e,t)},e.getResponseHeader=function(e){return this.h&&this.h.get(e.toLowerCase())||""},e.getAllResponseHeaders=function(){if(!this.h)return"";const 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\n")},Object.defineProperty(Dt.prototype,"withCredentials",{get:function(){return"include"===this.m},set:function(e){this.m=e?"include":"same-origin"}}),h(Ft,ne);var Ut=/^https?$/i,Vt=["POST","PUT"];function jt(e,t){e.h=!1,e.g&&(e.j=!0,e.g.abort(),e.j=!1),e.l=t,e.m=5,$t(e),qt(e)}function $t(e){e.A||(e.A=!0,re(e,"complete"),re(e,"error"))}function Bt(e){if(e.h&&void 0!==r&&(!e.v[1]||4!=Ht(e)||2!=e.Z()))if(e.u&&4==Ht(e))se(e.Ea,0,e);else if(re(e,"readystatechange"),4==Ht(e)){e.h=!1;try{const r=e.Z();e:switch(r){case 200:case 201:case 202:case 204:case 206:case 304:case 1223:var t=!0;break e;default:t=!1}var n;if(!(n=t)){var s;if(s=0===r){var o=String(e.D).match(it)[1]||null;!o&&i.self&&i.self.location&&(o=i.self.location.protocol.slice(0,-1)),s=!Ut.test(o?o.toLowerCase():"")}n=s}if(n)re(e,"complete"),re(e,"success");else{e.m=6;try{var a=2<Ht(e)?e.g.statusText:""}catch(e){a=""}e.l=a+" ["+e.Z()+"]",$t(e)}}finally{qt(e)}}}function qt(e,t){if(e.g){zt(e);const n=e.g,r=e.v[0]?()=>{}:null;e.g=null,e.v=null,t||re(e,"ready");try{n.onreadystatechange=r}catch(e){}}}function zt(e){e.I&&(i.clearTimeout(e.I),e.I=null)}function Ht(e){return e.g?e.g.readyState:0}function Gt(e){try{if(!e.g)return null;if("response"in e.g)return e.g.response;switch(e.H){case"":case"text":return e.g.responseText;case"arraybuffer":if("mozResponseArrayBuffer"in e.g)return e.g.mozResponseArrayBuffer}return null}catch(e){return null}}
2function Kt(e,t,n){return n&&n.internalChannelParams&&n.internalChannelParams[e]||t}function Wt(e){this.Aa=0,this.i=[],this.j=new Ne,this.ia=this.qa=this.I=this.W=this.g=this.ya=this.D=this.H=this.m=this.S=this.o=null,this.Ya=this.U=0,this.Va=Kt("failFast",!1,e),this.F=this.C=this.u=this.s=this.l=null,this.X=!0,this.za=this.T=-1,this.Y=this.v=this.B=0,this.Ta=Kt("baseRetryDelayMs",5e3,e),this.cb=Kt("retryDelaySeedMs",1e4,e),this.Wa=Kt("forwardChannelMaxRetries",2,e),this.wa=Kt("forwardChannelRequestTimeoutMs",2e4,e),this.pa=e&&e.xmlHttpFactory||void 0,this.Xa=e&&e.Tb||void 0,this.Ca=e&&e.useFetchStreams||!1,this.L=void 0,this.J=e&&e.supportsCrossDomainXhr||!1,this.K="",this.h=new Qe(e&&e.concurrentRequestLimit),this.Da=new kt,this.P=e&&e.fastHandshake||!1,this.O=e&&e.encodeInitMessageHeaders||!1,this.P&&this.O&&(this.O=!1),this.Ua=e&&e.Rb||!1,e&&e.xa&&this.j.xa(),e&&e.forceLongPolling&&(this.X=!1),this.ba=!this.P&&this.X&&e&&e.detectBufferingProxy||!1,this.ja=void 0,e&&e.longPollingTimeout&&0<e.longPollingTimeout&&(this.ja=e.longPollingTimeout),this.ca=void 0,this.R=0,this.M=!1,this.ka=this.A=null}function Yt(e){if(Jt(e),3==e.G){var t=e.U++,n=ot(e.I);if(lt(n,"SID",e.K),lt(n,"RID",t),lt(n,"TYPE","terminate"),en(e,n),(t=new Me(e,e.j,t)).L=2,t.v=ht(ot(n)),n=!1,i.navigator&&i.navigator.sendBeacon)try{n=i.navigator.sendBeacon(t.v.toString(),"")}catch(e){}!n&&i.Image&&((new Image).src=t.v,n=!0),n||(t.g=fn(t.j,null),t.g.ea(t.v)),t.F=Date.now(),qe(t)}hn(e)}function Qt(e){e.g&&(sn(e),e.g.cancel(),e.g=null)}function Jt(e){Qt(e),e.u&&(i.clearTimeout(e.u),e.u=null),an(e),e.h.cancel(),e.s&&("number"==typeof e.s&&i.clearTimeout(e.s),e.s=null)}function Xt(e){if(!Je(e.h)&&!e.s){e.s=!0;var t=e.Ga;A||O(),k||(A(),k=!0),N.add(t,e),e.B=0}}function Zt(e,t){var n;n=t?t.l:e.U++;const r=ot(e.I);lt(r,"SID",e.K),lt(r,"RID",n),lt(r,"AID",e.T),en(e,r),e.m&&e.o&&xt(r,e.m,e.o),n=new Me(e,e.j,n,e.B+1),null===e.m&&(n.H=e.o),t&&(e.i=t.D.concat(e.i)),t=tn(e,n,1e3),n.I=Math.round(.5*e.wa)+Math.round(.5*e.wa*Math.random()),et(e.h,n),Ve(n,r,t)}function en(e,t){e.H&&v(e.H,function(e,n){lt(t,n,e)}),e.l&&rt({},function(e,n){lt(t,n,e)})}function tn(e,t,n){n=Math.min(e.i.length,n);var r=e.l?u(e.l.Na,e.l,e):null;e:{var i=e.i;let t=-1;for(;;){const e=["count="+n];-1==t?0<n?(t=i[0].g,e.push("ofs="+t)):t=0:e.push("ofs="+t);let s=!0;for(let o=0;o<n;o++){let n=i[o].g;const a=i[o].map;if(n-=t,0>n)t=Math.max(0,i[o].g-100),s=!1;else try{Nt(a,e,"req"+n+"_")}catch(e){r&&r(a)}}if(s){r=e.join("&");break e}}}return e=e.i.splice(0,n),t.D=e,r}function nn(e){if(!e.g&&!e.u){e.Y=1;var t=e.Fa;A||O(),k||(A(),k=!0),N.add(t,e),e.v=0}}function rn(e){return!(e.g||e.u||3<=e.v)&&(e.Y++,e.u=ke(u(e.Fa,e),un(e,e.v)),e.v++,!0)}function sn(e){null!=e.A&&(i.clearTimeout(e.A),e.A=null)}function on(e){e.g=new Me(e,e.j,"rpc",e.Y),null===e.m&&(e.g.H=e.o),e.g.O=0;var t=ot(e.qa);lt(t,"RID","rpc"),lt(t,"SID",e.K),lt(t,"AID",e.T),lt(t,"CI",e.F?"0":"1"),!e.F&&e.ja&<(t,"TO",e.ja),lt(t,"TYPE","xmlhttp"),en(e,t),e.m&&e.o&&xt(t,e.m,e.o),e.L&&(e.g.I=e.L);var n=e.g;e=e.ia,n.L=1,n.v=ht(ot(t)),n.m=null,n.P=!0,je(n,e)}function an(e){null!=e.C&&(i.clearTimeout(e.C),e.C=null)}function cn(e,t){var n=null;if(e.g==t){an(e),sn(e),e.g=null;var r=2}else{if(!Ze(e.h,t))return;n=t.D,tt(e.h,t),r=1}if(0!=e.G)if(t.o)if(1==r){n=t.m?t.m.length:0,t=Date.now()-t.F;var i=e.B;re(r=Ee(),new Ae(r,n)),Xt(e)}else nn(e);else if(3==(i=t.s)||0==i&&0<t.X||!(1==r&&function(e,t){return!(Xe(e.h)>=e.h.j-(e.s?1:0)||(e.s?(e.i=t.D.concat(e.i),0):1==e.G||2==e.G||e.B>=(e.Va?0:e.Wa)||(e.s=ke(u(e.Ga,e,t),un(e,e.B)),e.B++,0)))}(e,t)||2==r&&rn(e)))switch(n&&0<n.length&&(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 un(e,t){let n=e.Ta+Math.floor(Math.random()*e.cb);return e.isActive()||(n*=2),n*t}function ln(e,t){if(e.j.info("Error code "+t),2==t){var n=u(e.fb,e),r=e.Xa;const t=!r;r=new st(r||"//www.google.com/images/cleardot.gif"),i.location&&"http"==i.location.protocol||at(r,"https"),ht(r),t?function(e,t){const n=new Ne;if(i.Image){const r=new Image;r.onload=l(At,n,"TestLoadImage: loaded",!0,t,r),r.onerror=l(At,n,"TestLoadImage: error",!1,t,r),r.onabort=l(At,n,"TestLoadImage: abort",!1,t,r),r.ontimeout=l(At,n,"TestLoadImage: timeout",!1,t,r),i.setTimeout(function(){r.ontimeout&&r.ontimeout()},1e4),r.src=e}else t(!1)}
2(r.toString(),n):function(e,t){new Ne;const n=new AbortController,r=setTimeout(()=>{n.abort(),At(0,0,!1,t)},1e4);fetch(e,{signal:n.signal}).then(e=>{clearTimeout(r),e.ok?At(0,0,!0,t):At(0,0,!1,t)}).catch(()=>{clearTimeout(r),At(0,0,!1,t)})}(r.toString(),n)}else Ce(2);e.G=0,e.l&&e.l.sa(t),hn(e),Jt(e)}function hn(e){if(e.G=0,e.ka=[],e.l){const t=nt(e.h);0==t.length&&0==e.i.length||(f(e.ka,t),f(e.ka,e.i),e.h.i.length=0,d(e.i),e.i.length=0),e.l.ra()}}function dn(e,t,n){var r=n instanceof st?ot(n):new st(n);if(""!=r.g)t&&(r.g=t+"."+r.g),ct(r,r.s);else{var s=i.location;r=s.protocol,t=t?t+"."+s.hostname:s.hostname,s=+s.port;var o=new st(null);r&&at(o,r),t&&(o.g=t),s&&ct(o,s),n&&(o.l=n),r=o}return n=e.D,t=e.ya,n&&t&<(r,n,t),lt(r,"VER",e.la),en(e,r),r}function fn(e,t,n){if(t&&!e.J)throw Error("Can't create secondary domain capable XhrIo object.");return(t=e.Ca&&!e.pa?new Ft(new Ot({eb:n})):new Ft(e.pa)).Ha(e.J),t}function pn(){}function mn(){}function gn(e,t){ne.call(this),this.g=new Wt(t),this.l=e,this.h=t&&t.messageUrlParams||null,e=t&&t.messageHeaders||null,t&&t.clientProtocolHeaderRequired&&(e?e["X-Client-Protocol"]="webchannel":e={"X-Client-Protocol":"webchannel"}),this.g.o=e,e=t&&t.initMessageHeaders||null,t&&t.messageContentType&&(e?e["X-WebChannel-Content-Type"]=t.messageContentType:e={"X-WebChannel-Content-Type":t.messageContentType}),t&&t.va&&(e?e["X-WebChannel-Client-Profile"]=t.va:e={"X-WebChannel-Client-Profile":t.va}),this.g.S=e,(e=t&&t.Sb)&&!p(e)&&(this.g.m=e),this.v=t&&t.supportsCrossDomainXhr||!1,this.u=t&&t.sendRawJson||!1,(t=t&&t.httpSessionIdParam)&&!p(t)&&(this.g.D=t,null!==(e=this.h)&&t in e&&(t in(e=this.h)&&delete e[t])),this.j=new wn(this)}function yn(e){ve.call(this),e.__headers__&&(this.headers=e.__headers__,this.statusCode=e.__status__,delete e.__headers__,delete e.__status__);var t=e.__sm__;if(t){e:{for(const n in t){e=n;break e}e=void 0}(this.i=e)&&(e=this.i,t=null!==t&&e in t?t[e]:void 0),this.data=t}else this.data=e}function vn(){we.call(this),this.status=1}function wn(e){this.g=e}(e=Ft.prototype).Ha=function(e){this.J=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.m=0,this.A=!1,this.h=!0,this.g=this.o?this.o.g():De.g(),this.v=this.o?me(this.o):me(De),this.g.onreadystatechange=u(this.Ea,this);try{this.B=!0,this.g.open(t,String(e),!0),this.B=!1}catch(e){return void jt(this,e)}if(e=n||"",n=new Map(this.headers),r)if(Object.getPrototypeOf(r)===Object.prototype)for(var s in r)n.set(s,r[s]);else{if("function"!=typeof r.keys||"function"!=typeof r.get)throw Error("Unknown input type for opt_headers: "+String(r));for(const e of r.keys())n.set(e,r.get(e))}r=Array.from(n.keys()).find(e=>"content-type"==e.toLowerCase()),s=i.FormData&&e instanceof i.FormData,!(0<=Array.prototype.indexOf.call(Vt,t,void 0))||r||s||n.set("Content-Type","application/x-www-form-urlencoded;charset=utf-8");for(const[e,t]of n)this.g.setRequestHeader(e,t);this.H&&(this.g.responseType=this.H),"withCredentials"in this.g&&this.g.withCredentials!==this.J&&(this.g.withCredentials=this.J);try{zt(this),this.u=!0,this.g.send(e),this.u=!1}catch(e){jt(this,e)}},e.abort=function(e){this.g&&this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1,this.m=e||7,re(this,"complete"),re(this,"abort"),qt(this))},e.N=function(){this.g&&(this.h&&(this.h=!1,this.j=!0,this.g.abort(),this.j=!1),qt(this,!0)),Ft.aa.N.call(this)},e.Ea=function(){this.s||(this.B||this.u||this.j?Bt(this):this.bb())},e.bb=function(){Bt(this)},e.isActive=function(){return!!this.g},e.Z=function(){try{return 2<Ht(this)?this.g.status:-1}catch(e){return-1}},e.oa=function(){try{return this.g?this.g.responseText:""}catch(e){return""}},e.Oa=function(e){if(this.g){var t=this.g.responseText;return e&&0==t.indexOf(e)&&(t=t.substring(e.length)),de(t)}},e.Ba=function(){return this.m},e.Ka=function(){return"string"==typeof this.l?this.l:String(this.l)},(e=Wt.prototype).la=8,e.G=1,e.connect=function(e,t,n,r){Ce(0),this.W=e,this.H=t||{},n&&void 0!==r&&(this.H.OSID=n,this.H.OAID=r),this.F=this.X,this.I=dn(this,null,this.W),Xt(this)},e.Ga=function(e){if(this.s)if(this.s=null,1==this.G){if(!e){this.U=Math.floor(1e5*Math.random()),e=this.U++;const i=new Me(this,this.j,e);let s=this.o;if(this.S&&(s?(s=w(s),b(s,this.S)):s=this.S),null!==this.m||this.O||(i.H=s,s=null),this.P)e:{for(var t=0,n=0;n<this.i.length;n++){var r=this.i[n];if(void 0===(r="__data__"in r.map&&"string"==typeof(r=r.map.__data__)?r.length:void 0))break;if(4096<(t+=r)){t=n;break e}if(4096===t||n===this.i.length-1){t=n+1;break e}}t=1e3}else t=1e3;
2t=tn(this,i,t),lt(n=ot(this.I),"RID",e),lt(n,"CVER",22),this.D&<(n,"X-HTTP-Session-Id",this.D),en(this,n),s&&(this.O?t="headers="+encodeURIComponent(String(Mt(s)))+"&"+t:this.m&&xt(n,this.m,s)),et(this.h,i),this.Ua&<(n,"TYPE","init"),this.P?(lt(n,"$req",t),lt(n,"SID","null"),i.T=!0,Ve(i,n,null)):Ve(i,n,t),this.G=2}}else 3==this.G&&(e?Zt(this,e):0==this.i.length||Je(this.h)||Zt(this))},e.Fa=function(){if(this.u=null,on(this),this.ba&&!(this.M||null==this.g||0>=this.R)){var e=2*this.R;this.j.info("BP detection timer enabled: "+e),this.A=ke(u(this.ab,this),e)}},e.ab=function(){this.A&&(this.A=null,this.j.info("BP detection timeout reached."),this.j.info("Buffering proxy detected and switch to long-polling!"),this.F=!1,this.M=!0,Ce(10),Qt(this),on(this))},e.Za=function(){null!=this.C&&(this.C=null,Qt(this),rn(this),Ce(19))},e.fb=function(e){e?(this.j.info("Successfully pinged google.com"),Ce(2)):(this.j.info("Failed to ping google.com"),Ce(1))},e.isActive=function(){return!!this.l&&this.l.isActive(this)},(e=pn.prototype).ua=function(){},e.ta=function(){},e.sa=function(){},e.ra=function(){},e.isActive=function(){return!0},e.Na=function(){},mn.prototype.g=function(e,t){return new gn(e,t)},h(gn,ne),gn.prototype.m=function(){this.g.l=this.j,this.v&&(this.g.J=!0),this.g.connect(this.l,this.h||void 0)},gn.prototype.close=function(){Yt(this.g)},gn.prototype.o=function(e){var t=this.g;if("string"==typeof e){var n={};n.__data__=e,e=n}else this.u&&((n={}).__data__=he(e),e=n);t.i.push(new Ye(t.Ya++,e)),3==t.G&&Xt(t)},gn.prototype.N=function(){this.g.l=null,delete this.j,Yt(this.g),delete this.g,gn.aa.N.call(this)},h(yn,ve),h(vn,we),h(wn,pn),wn.prototype.ua=function(){re(this.g,"a")},wn.prototype.ta=function(e){re(this.g,new yn(e))},wn.prototype.sa=function(e){re(this.g,new vn)},wn.prototype.ra=function(){re(this.g,"b")},mn.prototype.createWebChannel=mn.prototype.g,gn.prototype.send=gn.prototype.o,gn.prototype.open=gn.prototype.m,gn.prototype.close=gn.prototype.close,Zi=ts.createWebChannelTransport=function(){return new mn},Xi=ts.getStatEventTarget=function(){return Ee()},Ji=ts.Event=_e,Qi=ts.Stat={mb:0,pb:1,qb:2,Jb:3,Ob:4,Lb:5,Mb:6,Kb:7,Ib:8,Nb:9,PROXY:10,NOPROXY:11,Gb:12,Cb:13,Db:14,Bb:15,Eb:16,Fb:17,ib:18,hb:19,jb:20},Re.NO_ERROR=0,Re.TIMEOUT=8,Re.HTTP_ERROR=6,Yi=ts.ErrorCode=Re,Pe.COMPLETE="complete",Wi=ts.EventType=Pe,ge.EventType=ye,ye.OPEN="a",ye.CLOSE="b",ye.ERROR="c",ye.MESSAGE="d",ne.prototype.listen=ne.prototype.K,Ki=ts.WebChannel=ge,ts.FetchXmlHttpFactory=Ot,Ft.prototype.listenOnce=Ft.prototype.L,Ft.prototype.getLastError=Ft.prototype.Ka,Ft.prototype.getLastErrorCode=Ft.prototype.Ba,Ft.prototype.getStatus=Ft.prototype.Z,Ft.prototype.getResponseJson=Ft.prototype.Oa,Ft.prototype.getResponseText=Ft.prototype.oa,Ft.prototype.send=Ft.prototype.ea,Ft.prototype.setWithCredentials=Ft.prototype.Ha,Gi=ts.XhrIo=Ft}).apply(void 0!==es?es:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{});const ns="@firebase/firestore",rs="4.8.0";class is{constructor(e){this.uid=e}isAuthenticated(){return null!=this.uid}toKey(){return this.isAuthenticated()?"uid:"+this.uid:"anonymous-user"}isEqual(e){return e.uid===this.uid}}is.UNAUTHENTICATED=new is(null),is.GOOGLE_CREDENTIALS=new is("google-credentials-uid"),is.FIRST_PARTY=new is("first-party-uid"),is.MOCK_USER=new is("mock-user");let ss="11.10.0";const os=new $("@firebase/firestore");function as(){return os.logLevel}function cs(e,...t){if(os.logLevel<=x.DEBUG){const n=t.map(hs);os.debug(`Firestore (${ss}): ${e}`,...n)}}function us(e,...t){if(os.logLevel<=x.ERROR){const n=t.map(hs);os.error(`Firestore (${ss}): ${e}`,...n)}}function ls(e,...t){if(os.logLevel<=x.WARN){const n=t.map(hs);os.warn(`Firestore (${ss}): ${e}`,...n)}}function hs(e){if("string"==typeof e)return e;try{return function(e){return JSON.stringify(e)}(e)}catch(t){return e}}function ds(e,t,n){let r="Unexpected state";"string"==typeof t?r=t:n=t,fs(e,r,n)}function fs(e,t,n){let r=`FIRESTORE (${ss}) INTERNAL ASSERTION FAILED: ${t} (ID: ${e.toString(16)})`;if(void 0!==n)try{r+=" CONTEXT: "+JSON.stringify(n)}catch(e){r+=" CONTEXT: "+n}throw us(r),new Error(r)}function ps(e,t,n,r){let i="Unexpected state";"string"==typeof n?i=n:r=n,e||fs(t,i,r)}function ms(e,t){return e}const gs={OK:"ok",CANCELLED:"cancelled",UNKNOWN:"unknown",INVALID_ARGUMENT:"invalid-argument",DEADLINE_EXCEEDED:"deadline-exceeded",NOT_FOUND:"not-found",ALREADY_EXISTS:"already-exists",PERMISSION_DENIED:"permission-denied",UNAUTHENTICATED:"unauthenticated",RESOURCE_EXHAUSTED:"resource-exhausted",FAILED_PRECONDITION:"failed-precondition",ABORTED:"aborted",OUT_OF_RANGE:"out-of-range",UNIMPLEMENT
2ED:"unimplemented",INTERNAL:"internal",UNAVAILABLE:"unavailable",DATA_LOSS:"data-loss"};class ys extends _{constructor(e,t){super(e,t),this.code=e,this.message=t,this.toString=()=>`${this.name}: [code=${this.code}]: ${this.message}`}}class vs{constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class ws{constructor(e,t){this.user=t,this.type="OAuth",this.headers=new Map,this.headers.set("Authorization",`Bearer ${e}`)}}class _s{getToken(){return Promise.resolve(null)}invalidateToken(){}start(e,t){e.enqueueRetryable(()=>t(is.UNAUTHENTICATED))}shutdown(){}}class bs{constructor(e){this.token=e,this.changeListener=null}getToken(){return Promise.resolve(this.token)}invalidateToken(){}start(e,t){this.changeListener=t,e.enqueueRetryable(()=>t(this.token.user))}shutdown(){this.changeListener=null}}class Es{constructor(e){this.t=e,this.currentUser=is.UNAUTHENTICATED,this.i=0,this.forceRefresh=!1,this.auth=null}start(e,t){ps(void 0===this.o,42304);let n=this.i;const r=e=>this.i!==n?(n=this.i,t(e)):Promise.resolve();let i=new vs;this.o=()=>{this.i++,this.currentUser=this.u(),i.resolve(),i=new vs,e.enqueueRetryable(()=>r(this.currentUser))};const s=()=>{const t=i;e.enqueueRetryable(async()=>{await t.promise,await r(this.currentUser)})},o=e=>{cs("FirebaseAuthCredentialsProvider","Auth detected"),this.auth=e,this.o&&(this.auth.addAuthTokenListener(this.o),s())};this.t.onInit(e=>o(e)),setTimeout(()=>{if(!this.auth){const e=this.t.getImmediate({optional:!0});e?o(e):(cs("FirebaseAuthCredentialsProvider","Auth not yet detected"),i.resolve(),i=new vs)}},0),s()}getToken(){const e=this.i,t=this.forceRefresh;return this.forceRefresh=!1,this.auth?this.auth.getToken(t).then(t=>this.i!==e?(cs("FirebaseAuthCredentialsProvider","getToken aborted due to token change."),this.getToken()):t?(ps("string"==typeof t.accessToken,31837,{l:t}),new ws(t.accessToken,this.currentUser)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.auth&&this.o&&this.auth.removeAuthTokenListener(this.o),this.o=void 0}u(){const e=this.auth&&this.auth.getUid();return ps(null===e||"string"==typeof e,2055,{h:e}),new is(e)}}class Ts{constructor(e,t,n){this.P=e,this.T=t,this.I=n,this.type="FirstParty",this.user=is.FIRST_PARTY,this.A=new Map}R(){return this.I?this.I():null}get headers(){this.A.set("X-Goog-AuthUser",this.P);const e=this.R();return e&&this.A.set("Authorization",e),this.T&&this.A.set("X-Goog-Iam-Authorization-Token",this.T),this.A}}class Is{constructor(e,t,n){this.P=e,this.T=t,this.I=n}getToken(){return Promise.resolve(new Ts(this.P,this.T,this.I))}start(e,t){e.enqueueRetryable(()=>t(is.FIRST_PARTY))}shutdown(){}invalidateToken(){}}class Ss{constructor(e){this.value=e,this.type="AppCheck",this.headers=new Map,e&&e.length>0&&this.headers.set("x-firebase-appcheck",this.value)}}class Cs{constructor(e,t){this.V=t,this.forceRefresh=!1,this.appCheck=null,this.m=null,this.p=null,Be(e)&&e.settings.appCheckToken&&(this.p=e.settings.appCheckToken)}start(e,t){ps(void 0===this.o,3512);const n=e=>{null!=e.error&&cs("FirebaseAppCheckTokenProvider",`Error getting App Check token; using placeholder token instead. Error: ${e.error.message}`);const n=e.token!==this.m;return this.m=e.token,cs("FirebaseAppCheckTokenProvider",`Received ${n?"new":"existing"} token.`),n?t(e.token):Promise.resolve()};this.o=t=>{e.enqueueRetryable(()=>n(t))};const r=e=>{cs("FirebaseAppCheckTokenProvider","AppCheck detected"),this.appCheck=e,this.o&&this.appCheck.addTokenListener(this.o)};this.V.onInit(e=>r(e)),setTimeout(()=>{if(!this.appCheck){const e=this.V.getImmediate({optional:!0});e?r(e):cs("FirebaseAppCheckTokenProvider","AppCheck not yet detected")}},0)}getToken(){if(this.p)return Promise.resolve(new Ss(this.p));const e=this.forceRefresh;return this.forceRefresh=!1,this.appCheck?this.appCheck.getToken(e).then(e=>e?(ps("string"==typeof e.token,44558,{tokenResult:e}),this.m=e.token,new Ss(e.token)):null):Promise.resolve(null)}invalidateToken(){this.forceRefresh=!0}shutdown(){this.appCheck&&this.o&&this.appCheck.removeTokenListener(this.o),this.o=void 0}}function As(e){const t="undefined"!=typeof self&&(self.crypto||self.msCrypto),n=new Uint8Array(e);if(t&&"function"==typeof t.getRandomValues)t.getRandomValues(n);else for(let t=0;t<e;
vendor: 7,948 bytes, line 2
2t++)n[t]=Math.floor(256*Math.random());return n}function ks(){return new TextEncoder}class Ns{static newId(){const e=62*Math.floor(256/62);let t="";for(;t.length<20;){const n=As(40);for(let r=0;r<n.length;++r)t.length<20&&n[r]<e&&(t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(n[r]%62))}return t}}function Os(e,t){return e<t?-1:e>t?1:0}function Ds(e,t){let n=0;for(;n<e.length&&n<t.length;){const r=e.codePointAt(n),i=t.codePointAt(n);if(r!==i){if(r<128&&i<128)return Os(r,i);{const s=ks(),o=Ps(s.encode(Rs(e,n)),s.encode(Rs(t,n)));return 0!==o?o:Os(r,i)}}n+=r>65535?2:1}return Os(e.length,t.length)}function Rs(e,t){return e.codePointAt(t)>65535?e.substring(t,t+2):e.substring(t,t+1)}function Ps(e,t){for(let n=0;n<e.length&&n<t.length;++n)if(e[n]!==t[n])return Os(e[n],t[n]);return Os(e.length,t.length)}function Ls(e,t,n){return e.length===t.length&&e.every((e,r)=>n(e,t[r]))}const Ms="__name__";class xs{constructor(e,t,n){void 0===t?t=0:t>e.length&&ds(637,{offset:t,range:e.length}),void 0===n?n=e.length-t:n>e.length-t&&ds(1746,{length:n,range:e.length-t}),this.segments=e,this.offset=t,this.len=n}get length(){return this.len}isEqual(e){return 0===xs.comparator(this,e)}child(e){const t=this.segments.slice(this.offset,this.limit());return e instanceof xs?e.forEach(e=>{t.push(e)}):t.push(e),this.construct(t)}limit(){return this.offset+this.length}popFirst(e){return e=void 0===e?1:e,this.construct(this.segments,this.offset+e,this.length-e)}popLast(){return this.construct(this.segments,this.offset,this.length-1)}firstSegment(){return this.segments[this.offset]}lastSegment(){return this.get(this.length-1)}get(e){return this.segments[this.offset+e]}isEmpty(){return 0===this.length}isPrefixOf(e){if(e.length<this.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}isImmediateParentOf(e){if(this.length+1!==e.length)return!1;for(let t=0;t<this.length;t++)if(this.get(t)!==e.get(t))return!1;return!0}forEach(e){for(let t=this.offset,n=this.limit();t<n;t++)e(this.segments[t])}toArray(){return this.segments.slice(this.offset,this.limit())}static comparator(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=xs.compareSegments(e.get(r),t.get(r));if(0!==n)return n}return Os(e.length,t.length)}static compareSegments(e,t){const n=xs.isNumericId(e),r=xs.isNumericId(t);return n&&!r?-1:!n&&r?1:n&&r?xs.extractNumericId(e).compare(xs.extractNumericId(t)):Ds(e,t)}static isNumericId(e){return e.startsWith("__id")&&e.endsWith("__")}static extractNumericId(e){return Bi.fromString(e.substring(4,e.length-2))}}class Fs extends xs{construct(e,t,n){return new Fs(e,t,n)}canonicalString(){return this.toArray().join("/")}toString(){return this.canonicalString()}toUriEncodedString(){return this.toArray().map(encodeURIComponent).join("/")}static fromString(...e){const t=[];for(const n of e){if(n.indexOf("//")>=0)throw new ys(gs.INVALID_ARGUMENT,`Invalid segment (${n}). Paths must not contain // in them.`);t.push(...n.split("/").filter(e=>e.length>0))}return new Fs(t)}static emptyPath(){return new Fs([])}}const Us=/^[_a-zA-Z][_a-zA-Z0-9]*$/;class Vs extends xs{construct(e,t,n){return new Vs(e,t,n)}static isValidIdentifier(e){return Us.test(e)}canonicalString(){return this.toArray().map(e=>(e=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`"),Vs.isValidIdentifier(e)||(e="`"+e+"`"),e)).join(".")}toString(){return this.canonicalString()}isKeyField(){return 1===this.length&&this.get(0)===Ms}static keyField(){return new Vs([Ms])}static fromServerFormat(e){const t=[];let n="",r=0;const i=()=>{if(0===n.length)throw new ys(gs.INVALID_ARGUMENT,`Invalid field path (${e}). Paths must not be empty, begin with '.', end with '.', or contain '..'`);t.push(n),n=""};let s=!1;for(;r<e.length;){const t=e[r];if("\\"===t){if(r+1===e.length)throw new ys(gs.INVALID_ARGUMENT,"Path has trailing escape character: "+e);const t=e[r+1];if("\\"!==t&&"."!==t&&"`"!==t)throw new ys(gs.INVALID_ARGUMENT,"Path has invalid escape sequence: "+e);n+=t,r+=2}else"`"===t?(s=!s,r++):"."!==t||s?(n+=t,r++):(i(),r++)}if(i(),s)throw new ys(gs.INVALID_ARGUMENT,"Unterminated ` in path: "+e);return new Vs(t)}static emptyPath(){return new Vs([])}}class js{constructor(e){this.path=e}static fromPath(e){return new js(Fs.fromString(e))}static fromName(e){return new js(Fs.fromString(e).popFirst(5))}static empty(){return new js(Fs.emptyPath())}get collectionGroup(){return this.path.popLast().lastSegment()}hasCollectionId(e){return this.path.length>=2&&this.path.get(this.path.length-2)===e}getCollectionGroup(){return this.path.get(this.path.length-2)}getCollectionPath(){return this.path.popLast()}isEqual(e){return null!==e&&0===Fs.comparator(this.path,e.path)}toString(){return this.path.toString()}static comparator(e,t){return Fs.comparator(e.path,t.path)}static isDocumentKey(e){return e.length%2==0}static fromSegments(e){return new js(new Fs(e.slice()))}}function $s(e,t,n){if(!n)throw new ys(gs.INVALID_ARGUMENT,`Function ${e}() cannot be called with an empty ${t}.`)}function Bs(e){if(!js.isDocumentKey(e))throw new ys(gs.INVALID_ARGUMENT,`Invalid document reference. Document references must have an even number of segments, but ${e} has ${e.length}.`)}function qs(e){return"object"==typeof e&&null!==e&&(Object.getPrototypeOf(e)===Object.prototype||null===Object.getPrototypeOf(e))}function zs(e){if(void 0===e)return"undefined";if(null===e)return"null";if("string"==typeof e)return e.length>20&&(e=`${e.substring(0,20)}...`),JSON.stringify(e);if("number"==typeof e||"boolean"==typeof e)return""+e;if("object"==typeof e){if(e instanceof Array)return"an array";{const t=function(e){return e.constructor?e.constructor.name:null}(e);return t?`a custom ${t} object`:"an object"}}return"function"==typeof e?"a function":ds(12329,{type:typeof e})}function Hs(e,t){if("_delegate"in e&&(e=e._delegate),!(e instanceof t)){if(t.name===e.constructor.name)throw new ys(gs.INVALID_ARGUMENT,"Type does not match the expected instance. Did you pass a reference from a different Firestore SDK?");{const n=zs(e);throw new ys(gs.INVALID_ARGUMENT,`Expected type '${t.name}', but it was: ${n}`)}}return e}function Gs(e,t){const n={typeString:e};return t&&(n.value=t),n}function Ks(e,t){if(!qs(e))throw new ys(gs.INVALID_ARGUMENT,"JSON must be an object");let n;for(const r in t)if(t[r]){const i=t[r].typeString,s="value"in t[r]?{value:t[r].value}:void 0;if(!(r in e)){n=`JSON missing required field: '${r}'`;break}const o=e[r];if(i&&typeof o!==i){n=`JSON field '${r}' must be a ${i}.`;break}if(void 0!==s&&o!==s.value){n=`Expected '${r}' field to equal '${s.value}'`;break}}if(n)throw new ys(gs.INVALID_ARGUMENT,n);return!0}const Ws=-62135596800,Ys=1e6;class Qs{static now(){return Qs.fromMillis(Date.now())}static fromDate(e){return Qs.fromMillis(e.getTime())}static fromMillis(e){const t=Math.floor(e/1e3),n=Math.floor((e-1e3*t)*Ys);return new Qs(t,n)}constructor(e,t){if(this.seconds=e,this.nanoseconds=t,t<0)throw new ys(gs.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(t>=1e9)throw new ys(gs.INVALID_ARGUMENT,"Timestamp nanoseconds out of range: "+t);if(e<Ws)throw new ys(gs.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e);if(e>=253402300800)throw new ys(gs.INVALID_ARGUMENT,"Timestamp seconds out of range: "+e)}toDate(){return new Date(this.toMillis())}toMillis(){return 1e3*this.seconds+this.nanoseconds/Ys}_compareTo(e){return this.seconds===e.seconds?Os(this.nanoseconds,e.nanoseconds):Os(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:Qs._jsonSchemaVersion,seconds:this.seconds,nanoseconds:this.nanoseconds}}static fromJSON(e){if(Ks(e,Qs._jsonSchema))return new Qs(e.seconds,e.nanoseconds)}valueOf(){const e=this.seconds-Ws;return String(e).padStart(12,"0")+"."+String(this.nanoseconds).padStart(9,"0")}
2}Qs._jsonSchemaVersion="firestore/timestamp/1.0",Qs._jsonSchema={type:Gs("string",Qs._jsonSchemaVersion),seconds:Gs("number"),nanoseconds:Gs("number")};class Js{static fromTimestamp(e){return new Js(e)}static min(){return new Js(new Qs(0,0))}static max(){return new Js(new Qs(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}}const Xs=-1;class Zs{constructor(e,t,n,r){this.indexId=e,this.collectionGroup=t,this.fields=n,this.indexState=r}}Zs.UNKNOWN_ID=-1;function eo(e,t){const n=e.toTimestamp().seconds,r=e.toTimestamp().nanoseconds+1,i=Js.fromTimestamp(1e9===r?new Qs(n+1,0):new Qs(n,r));return new no(i,js.empty(),t)}function to(e){return new no(e.readTime,e.key,Xs)}class no{constructor(e,t,n){this.readTime=e,this.documentKey=t,this.largestBatchId=n}static min(){return new no(Js.min(),js.empty(),Xs)}static max(){return new no(Js.max(),js.empty(),Xs)}}function ro(e,t){let n=e.readTime.compareTo(t.readTime);return 0!==n?n:(n=js.comparator(e.documentKey,t.documentKey),0!==n?n:Os(e.largestBatchId,t.largestBatchId))}const io="The current tab is not in the required state to perform this operation. It might be necessary to refresh the browser tab.";class so{constructor(){this.onCommittedListeners=[]}addOnCommittedListener(e){this.onCommittedListeners.push(e)}raiseOnCommittedEvent(){this.onCommittedListeners.forEach(e=>e())}}async function oo(e){if(e.code!==gs.FAILED_PRECONDITION||e.message!==io)throw e;cs("LocalStore","Unexpectedly lost primary lease")}class ao{constructor(e){this.nextCallback=null,this.catchCallback=null,this.result=void 0,this.error=void 0,this.isDone=!1,this.callbackAttached=!1,e(e=>{this.isDone=!0,this.result=e,this.nextCallback&&this.nextCallback(e)},e=>{this.isDone=!0,this.error=e,this.catchCallback&&this.catchCallback(e)})}catch(e){return this.next(void 0,e)}next(e,t){return this.callbackAttached&&ds(59440),this.callbackAttached=!0,this.isDone?this.error?this.wrapFailure(t,this.error):this.wrapSuccess(e,this.result):new ao((n,r)=>{this.nextCallback=t=>{this.wrapSuccess(e,t).next(n,r)},this.catchCallback=e=>{this.wrapFailure(t,e).next(n,r)}})}toPromise(){return new Promise((e,t)=>{this.next(e,t)})}wrapUserFunction(e){try{const t=e();return t instanceof ao?t:ao.resolve(t)}catch(e){return ao.reject(e)}}wrapSuccess(e,t){return e?this.wrapUserFunction(()=>e(t)):ao.resolve(t)}wrapFailure(e,t){return e?this.wrapUserFunction(()=>e(t)):ao.reject(t)}static resolve(e){return new ao((t,n)=>{t(e)})}static reject(e){return new ao((t,n)=>{n(e)})}static waitFor(e){return new ao((t,n)=>{let r=0,i=0,s=!1;e.forEach(e=>{++r,e.next(()=>{++i,s&&i===r&&t()},e=>n(e))}),s=!0,i===r&&t()})}static or(e){let t=ao.resolve(!1);for(const n of e)t=t.next(e=>e?ao.resolve(e):n());return t}static forEach(e,t){const n=[];return e.forEach((e,r)=>{n.push(t.call(this,e,r))}),this.waitFor(n)}static mapArray(e,t){return new ao((n,r)=>{const i=e.length,s=new Array(i);let o=0;for(let a=0;a<i;a++){const c=a;t(e[c]).next(e=>{s[c]=e,++o,o===i&&n(s)},e=>r(e))}})}static doWhile(e,t){return new ao((n,r)=>{const i=()=>{!0===e()?t().next(()=>{i()},r):n()};i()})}}function co(e){const t=e.match(/Android ([\d.]+)/i),n=t?t[1].split(".").slice(0,2).join("."):"-1";return Number(n)}function uo(e){return"IndexedDbTransactionError"===e.name}class lo{constructor(e,t){this.previousValue=e,t&&(t.sequenceNumberHandler=e=>this._e(e),this.ae=e=>t.writeSequenceNumber(e))}_e(e){return this.previousValue=Math.max(e,this.previousValue),this.previousValue}next(){const e=++this.previousValue;return this.ae&&this.ae(e),e}}lo.ue=-1;const ho=-1;function fo(e){return null==e}function po(e){return 0===e&&1/e==-1/0}function mo(e){return"number"==typeof e&&Number.isInteger(e)&&!po(e)&&e<=Number.MAX_SAFE_INTEGER&&e>=Number.MIN_SAFE_INTEGER}const go="�";function yo(e){let t="";for(let n=0;n<e.length;n++)t.length>0&&(t=wo(t)),t=vo(e.get(n),t);return wo(t)}function vo(e,t){let n=t;const r=e.length;for(let t=0;t<r;t++){const r=e.charAt(t);switch(r){case"\0":n+="��";break;case go:n+="��";break;default:n+=r}}return n}function wo(e){return e+go+"�"}
vendor: 5,505 bytes, line 2
2const _o="remoteDocuments",bo="owner",Eo="mutationQueues",To="mutations";const Io="documentMutations",So="remoteDocumentsV14",Co="remoteDocumentGlobal",Ao="targets",ko="targetDocuments",No="targetGlobal",Oo="collectionParents",Do="clientMetadata",Ro="bundles",Po="namedQueries",Lo="indexConfiguration",Mo="indexState",xo="indexEntries",Fo="documentOverlays",Uo="globals",Vo=[Eo,To,Io,_o,Ao,bo,No,ko,Do,Co,Oo,Ro,Po],jo=[Eo,To,Io,So,Ao,bo,No,ko,Do,Co,Oo,Ro,Po,Fo],$o=jo,Bo=[...$o,Lo,Mo,xo];function qo(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function zo(e,t){for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t(n,e[n])}function Ho(e){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}class Go{constructor(e,t){this.comparator=e,this.root=t||Wo.EMPTY}insert(e,t){return new Go(this.comparator,this.root.insert(e,t,this.comparator).copy(null,null,Wo.BLACK,null,null))}remove(e){return new Go(this.comparator,this.root.remove(e,this.comparator).copy(null,null,Wo.BLACK,null,null))}get(e){let t=this.root;for(;!t.isEmpty();){const n=this.comparator(e,t.key);if(0===n)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();){const r=this.comparator(e,n.key);if(0===r)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(){const e=[];return this.inorderTraversal((t,n)=>(e.push(`${t}:${n}`),!1)),`{${e.join(", ")}}`}reverseTraversal(e){return this.root.reverseTraversal(e)}getIterator(){return new Ko(this.root,null,this.comparator,!1)}getIteratorFrom(e){return new Ko(this.root,e,this.comparator,!1)}getReverseIterator(){return new Ko(this.root,null,this.comparator,!0)}getReverseIteratorFrom(e){return new Ko(this.root,e,this.comparator,!0)}}class Ko{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(0===i){this.nodeStack.push(e);break}this.nodeStack.push(e),e=this.isReverse?e.right:e.left}}getNext(){let e=this.nodeStack.pop();const t={key:e.key,value:e.value};if(this.isReverse)for(e=e.left;!e.isEmpty();)this.nodeStack.push(e),e=e.right;else for(e=e.right;!e.isEmpty();)this.nodeStack.push(e),e=e.left;return t}hasNext(){return this.nodeStack.length>0}peek(){if(0===this.nodeStack.length)return null;const e=this.nodeStack[this.nodeStack.length-1];return{key:e.key,value:e.value}}}class Wo{constructor(e,t,n,r,i){this.key=e,this.value=t,this.color=null!=n?n:Wo.RED,this.left=null!=r?r:Wo.EMPTY,this.right=null!=i?i:Wo.EMPTY,this.size=this.left.size+1+this.right.size}copy(e,t,n,r,i){return new Wo(null!=e?e:this.key,null!=t?t:this.value,null!=n?n:this.color,null!=r?r:this.left,null!=i?i:this.right)}isEmpty(){return!1}inorderTraversal(e){return this.left.inorderTraversal(e)||e(this.key,this.value)||this.right.inorderTraversal(e)}reverseTraversal(e){return this.right.reverseTraversal(e)||e(this.key,this.value)||this.left.reverseTraversal(e)}min(){return this.left.isEmpty()?this:this.left.min()}minKey(){return this.min().key}maxKey(){return this.right.isEmpty()?this.key:this.right.maxKey()}insert(e,t,n){let r=this;const i=n(e,r.key);return r=i<0?r.copy(null,null,null,r.left.insert(e,t,n),null):0===i?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 Wo.EMPTY;let e=this;return e.left.isRed()||e.left.left.isRed()||(e=e.moveRedLeft()),e=e.copy(null,null,null,e.left.removeMin(),null),e.fixUp()}remove(e,t){let n,r=this;if(t(e,r.key)<0)r.left.isEmpty()||r.left.isRed()||r.left.left.isRed()||(r=r.moveRedLeft()),r=r.copy(null,null,null,r.left.remove(e,t),null);else{if(r.left.isRed()&&(r=r.rotateRight()),r.right.isEmpty()||r.right.isRed()||r.right.left.isRed()||(r=r.moveRedRight()),0===t(e,r.key)){if(r.right.isEmpty())return Wo.EMPTY;n=r.right.min(),r=r.copy(n.key,n.value,null,null,r.right.removeMin())}r=r.copy(null,null,null,null,r.right.remove(e,t))}return r.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(){const e=this.copy(null,null,Wo.RED,null,this.right.left);return this.right.copy(null,null,this.color,e,null)}rotateRight(){const e=this.copy(null,null,Wo.RED,this.left.right,null);return this.left.copy(null,null,this.color,null,e)}colorFlip(){const 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(){const e=this.check();return Math.pow(2,e)<=this.size+1}check(){if(this.isRed()&&this.left.isRed())throw ds(43730,{key:this.key,value:this.value});if(this.right.isRed())throw ds(14113,{key:this.key,value:this.value});const e=this.left.check();if(e!==this.right.check())throw ds(27949);return e+(this.isRed()?0:1)}}
2Wo.EMPTY=null,Wo.RED=!0,Wo.BLACK=!1,Wo.EMPTY=new class{constructor(){this.size=0}get key(){throw ds(57766)}get value(){throw ds(16141)}get color(){throw ds(16727)}get left(){throw ds(29726)}get right(){throw ds(36894)}copy(e,t,n,r,i){return this}insert(e,t,n){return new Wo(e,t)}remove(e,t){return this}isEmpty(){return!0}inorderTraversal(e){return!1}reverseTraversal(e){return!1}minKey(){return null}maxKey(){return null}isRed(){return!1}checkMaxDepth(){return!0}check(){return 0}};class Yo{constructor(e){this.comparator=e,this.data=new Go(this.comparator)}has(e){return null!==this.data.get(e)}first(){return this.data.minKey()}last(){return this.data.maxKey()}get size(){return this.data.size}indexOf(e){return this.data.indexOf(e)}forEach(e){this.data.inorderTraversal((t,n)=>(e(t),!1))}forEachInRange(e,t){const n=this.data.getIteratorFrom(e[0]);for(;n.hasNext();){const r=n.getNext();if(this.comparator(r.key,e[1])>=0)return;t(r.key)}}forEachWhile(e,t){let n;for(n=void 0!==t?this.data.getIteratorFrom(t):this.data.getIterator();n.hasNext();)if(!e(n.getNext().key))return}firstAfterOrEqual(e){const t=this.data.getIteratorFrom(e);return t.hasNext()?t.getNext().key:null}getIterator(){return new Qo(this.data.getIterator())}getIteratorFrom(e){return new Qo(this.data.getIteratorFrom(e))}add(e){return this.copy(this.data.remove(e).insert(e,!0))}delete(e){return this.has(e)?this.copy(this.data.remove(e)):this}isEmpty(){return this.data.isEmpty()}unionWith(e){let t=this;return t.size<e.size&&(t=e,e=this),e.forEach(e=>{t=t.add(e)}),t}isEqual(e){if(!(e instanceof Yo))return!1;if(this.size!==e.size)return!1;const t=this.data.getIterator(),n=e.data.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(0!==this.comparator(e,r))return!1}return!0}toArray(){const e=[];return this.forEach(t=>{e.push(t)}),e}toString(){const e=[];return this.forEach(t=>e.push(t)),"SortedSet("+e.toString()+")"}copy(e){const t=new Yo(this.comparator);return t.data=e,t}}class Qo{constructor(e){this.iter=e}getNext(){return this.iter.getNext().key}hasNext(){return this.iter.hasNext()}}class Jo{constructor(e){this.fields=e,e.sort(Vs.comparator)}static empty(){return new Jo([])}unionWith(e){let t=new Yo(Vs.comparator);for(const e of this.fields)t=t.add(e);for(const n of e)t=t.add(n);return new Jo(t.toArray())}covers(e){for(const t of this.fields)if(t.isPrefixOf(e))return!0;return!1}isEqual(e){return Ls(this.fields,e.fields,(e,t)=>e.isEqual(t))}}class Xo extends Error{constructor(){super(...arguments),this.name="Base64DecodeError"}}class Zo{constructor(e){this.binaryString=e}static fromBase64String(e){const t=function(e){try{return atob(e)}catch(e){throw"undefined"!=typeof DOMException&&e instanceof DOMException?new Xo("Invalid base64 string: "+e):e}}(e);return new Zo(t)}static fromUint8Array(e){const t=function(e){let t="";for(let n=0;n<e.length;++n)t+=String.fromCharCode(e[n]);return t}(e);return new Zo(t)}[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 e=this.binaryString,btoa(e);var e}toUint8Array(){return function(e){const 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 Os(this.binaryString,e.binaryString)}isEqual(e){return this.binaryString===e.binaryString}}Zo.EMPTY_BYTE_STRING=new Zo("");const ea=new RegExp(/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.(\d+))?Z$/);function ta(e){if(ps(!!e,39018),"string"==typeof e){let t=0;const n=ea.exec(e);if(ps(!!n,46558,{timestamp:e}),n[1]){let e=n[1];e=(e+"000000000").substr(0,9),t=Number(e)}const r=new Date(e);return{seconds:Math.floor(r.getTime()/1e3),nanos:t}}return{seconds:na(e.seconds),nanos:na(e.nanos)}}function na(e){return"number"==typeof e?e:"string"==typeof e?Number(e):0}function ra(e){return"string"==typeof e?Zo.fromBase64String(e):Zo.fromUint8Array(e)}const ia="server_timestamp",sa="__type__",oa="__previous_value__",aa="__local_write_time__";function ca(e){var t,n;return(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{})[sa])||void 0===n?void 0:n.stringValue)===ia}function ua(e){const t=e.mapValue.fields[oa];return ca(t)?ua(t):t}function la(e){const t=ta(e.mapValue.fields[aa].timestampValue);return new Qs(t.seconds,t.nanos)}class ha{constructor(e,t,n,r,i,s,o,a,c,u){this.databaseId=e,this.appId=t,this.persistenceKey=n,this.host=r,this.ssl=i,this.forceLongPolling=s,this.autoDetectLongPolling=o,this.longPollingOptions=a,this.useFetchStreams=c,this.isUsingEmulator=u}}const da="(default)";class fa{constructor(e,t){this.projectId=e,this.database=t||da}static empty(){return new fa("","")}get isDefaultDatabase(){return this.database===da}isEqual(e){return e instanceof fa&&e.projectId===this.projectId&&e.database===this.database}}const pa="__type__",ma="__max__",ga={mapValue:{fields:{__type__:{stringValue:ma}}}},ya="__vector__",va="value";function wa(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?ca(e)?4:Ma(e)?9007199254740991:Pa(e)?10:11:ds(28295,{value:e})}function _a(e,t){if(e===t)return!0;const n=wa(e);if(n!==wa(t))return!1;switch(n){case 0:case 9007199254740991:return!0;case 1:return e.booleanValue===t.booleanValue;case 4:return la(e).isEqual(la(t));case 3:return function(e,t){if("string"==typeof e.timestampValue&&"string"==typeof t.timestampValue&&e.timestampValue.length===t.timestampValue.length)return e.timestampValue===t.timestampValue;const n=ta(e.timestampValue),r=ta(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 ra(e.bytesValue).isEqual(ra(t.bytesValue))}(e,t);case 7:return e.referenceValue===t.referenceValue;case 8:return function(e,t){return na(e.geoPointValue.latitude)===na(t.geoPointValue.latitude)&&na(e.geoPointValue.longitude)===na(t.geoPointValue.longitude)}(e,t);case 2:return function(e,t){if("integerValue"in e&&"integerValue"in t)return na(e.integerValue)===na(t.integerValue);if("doubleValue"in e&&"doubleValue"in t){const n=na(e.doubleValue),r=na(t.doubleValue);return n===r?po(n)===po(r):isNaN(n)&&isNaN(r)}return!1}(e,t);case 9:return Ls(e.arrayValue.values||[],t.arrayValue.values||[],_a);case 10:case 11:return function(e,t){const n=e.mapValue.fields||{},r=t.mapValue.fields||{};if(qo(n)!==qo(r))return!1;for(const e in n)if(n.hasOwnProperty(e)&&(void 0===r[e]||!_a(n[e],r[e])))return!1;return!0}(e,t);default:return ds(52216,{left:e})}}function ba(e,t){return void 0!==(e.values||[]).find(e=>_a(e,t))}function Ea(e,t){if(e===t)return 0;const n=wa(e),r=wa(t);if(n!==r)return Os(n,r);switch(n){case 0:case 9007199254740991:return 0;case 1:return Os(e.booleanValue,t.booleanValue);case 2:return function(e,t){const n=na(e.integerValue||e.doubleValue),r=na(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 Ta(e.timestampValue,t.timestampValue);case 4:return Ta(la(e),la(t));case 5:return Ds(e.stringValue,t.stringValue);case 6:return function(e,t){const n=ra(e),r=ra(t);return n.compareTo(r)}(e.bytesValue,t.bytesValue);case 7:return function(e,t){const n=e.split("/"),r=t.split("/");for(let e=0;e<n.length&&e<r.length;e++){const t=Os(n[e],r[e]);if(0!==t)return t}return Os(n.length,r.length)}(e.referenceValue,t.referenceValue);case 8:return function(e,t){const n=Os(na(e.latitude),na(t.latitude));return 0!==n?n:Os(na(e.longitude),na(t.longitude))}(e.geoPointValue,t.geoPointValue);case 9:return Ia(e.arrayValue,t.arrayValue);case 10:return function(e,t){var n,r,i,s;const o=e.fields||{},a=t.fields||{},c=null===(n=o[va])||void 0===n?void 0:n.arrayValue,u=null===(r=a[va])||void 0===r?void 0:r.arrayValue,l=Os((null===(i=null==c?void 0:c.values)||void 0===i?void 0:i.length)||0,(null===(s=null==u?void 0:u.values)||void 0===s?void 0:s.length)||0);return 0!==l?l:Ia(c,u)}(e.mapValue,t.mapValue);case 11:return function(e,t){if(e===ga.mapValue&&t===ga.mapValue)return 0;if(e===ga.mapValue)return 1;if(t===ga.mapValue)return-1;const n=e.fields||{},r=Object.keys(n),i=t.fields||{},s=Object.keys(i);r.sort(),s.sort();for(let e=0;e<r.length&&e<s.length;++e){const t=Ds(r[e],s[e]);if(0!==t)return t;const o=Ea(n[r[e]],i[s[e]]);if(0!==o)return o}return Os(r.length,s.length)}(e.mapValue,t.mapValue);default:throw ds(23264,{le:n})}}function Ta(e,t){if("string"==typeof e&&"string"==typeof t&&e.length===t.length)return Os(e,t);const n=ta(e),r=ta(t),i=Os(n.seconds,r.seconds);return 0!==i?i:Os(n.nanos,r.nanos)}function Ia(e,t){const n=e.values||[],r=t.values||[];for(let e=0;e<n.length&&e<r.length;++e){const t=Ea(n[e],r[e]);if(t)return t}return Os(n.length,r.length)}function Sa(e){return Ca(e)}function Ca(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){const t=ta(e);return`time(${t.seconds},${t.nanos})`}(e.timestampValue):"stringValue"in e?e.stringValue:"bytesValue"in e?function(e){return ra(e).toBase64()}(e.bytesValue):"referenceValue"in e?function(e){return js.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(const r of e.values||[])n?n=!1:t+=",",t+=Ca(r);return t+"]"}(e.arrayValue):"mapValue"in e?function(e){const t=Object.keys(e.fields||{}).sort();let n="{",r=!0;for(const i of t)r?r=!1:n+=",",n+=`${i}:${Ca(e.fields[i])}`;return n+"}"}(e.mapValue):ds(61005,{value:e})}function Aa(e){switch(wa(e)){case 0:case 1:return 4;case 2:return 8;case 3:case 8:return 16;case 4:const t=ua(e);return t?16+Aa(t):16;case 5:return 2*e.stringValue.length;case 6:return ra(e.bytesValue).approximateByteSize();case 7:return e.referenceValue.length;case 9:return function(e){return(e.values||[]).reduce((e,t)=>
2e+Aa(t),0)}(e.arrayValue);case 10:case 11:return function(e){let t=0;return zo(e.fields,(e,n)=>{t+=e.length+Aa(n)}),t}(e.mapValue);default:throw ds(13486,{value:e})}}function ka(e){return!!e&&"integerValue"in e}function Na(e){return!!e&&"arrayValue"in e}function Oa(e){return!!e&&"nullValue"in e}function Da(e){return!!e&&"doubleValue"in e&&isNaN(Number(e.doubleValue))}function Ra(e){return!!e&&"mapValue"in e}function Pa(e){var t,n;return(null===(n=((null===(t=null==e?void 0:e.mapValue)||void 0===t?void 0:t.fields)||{})[pa])||void 0===n?void 0:n.stringValue)===ya}function La(e){if(e.geoPointValue)return{geoPointValue:Object.assign({},e.geoPointValue)};if(e.timestampValue&&"object"==typeof e.timestampValue)return{timestampValue:Object.assign({},e.timestampValue)};if(e.mapValue){const t={mapValue:{fields:{}}};return zo(e.mapValue.fields,(e,n)=>t.mapValue.fields[e]=La(n)),t}if(e.arrayValue){const t={arrayValue:{values:[]}};for(let n=0;n<(e.arrayValue.values||[]).length;++n)t.arrayValue.values[n]=La(e.arrayValue.values[n]);return t}return Object.assign({},e)}function Ma(e){return(((e.mapValue||{}).fields||{}).__type__||{}).stringValue===ma}class xa{constructor(e){this.value=e}static empty(){return new xa({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)],!Ra(t))return null;return t=(t.mapValue.fields||{})[e.lastSegment()],t||null}}set(e,t){this.getFieldsMap(e.popLast())[e.lastSegment()]=La(t)}setAll(e){let t=Vs.emptyPath(),n={},r=[];e.forEach((e,i)=>{if(!t.isImmediateParentOf(i)){const e=this.getFieldsMap(t);this.applyChanges(e,n,r),n={},r=[],t=i.popLast()}e?n[i.lastSegment()]=La(e):r.push(i.lastSegment())});const i=this.getFieldsMap(t);this.applyChanges(i,n,r)}delete(e){const t=this.field(e.popLast());Ra(t)&&t.mapValue.fields&&delete t.mapValue.fields[e.lastSegment()]}isEqual(e){return _a(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)];Ra(r)&&r.mapValue.fields||(r={mapValue:{fields:{}}},t.mapValue.fields[e.get(n)]=r),t=r}return t.mapValue.fields}applyChanges(e,t,n){zo(t,(t,n)=>e[t]=n);for(const t of n)delete e[t]}clone(){return new xa(La(this.value))}}function Fa(e){const t=[];return zo(e.fields,(e,n)=>{const r=new Vs([e]);if(Ra(n)){const e=Fa(n.mapValue).fields;if(0===e.length)t.push(r);else for(const n of e)t.push(r.child(n))}else t.push(r)}),new Jo(t)}class Ua{constructor(e,t,n,r,i,s,o){this.key=e,this.documentType=t,this.version=n,this.readTime=r,this.createTime=i,this.data=s,this.documentState=o}static newInvalidDocument(e){return new Ua(e,0,Js.min(),Js.min(),Js.min(),xa.empty(),0)}static newFoundDocument(e,t,n,r){return new Ua(e,1,t,Js.min(),n,r,0)}static newNoDocument(e,t){return new Ua(e,2,t,Js.min(),Js.min(),xa.empty(),0)}static newUnknownDocument(e,t){return new Ua(e,3,t,Js.min(),Js.min(),xa.empty(),2)}convertToFoundDocument(e,t){return!this.createTime.isEqual(Js.min())||2!==this.documentType&&0!==this.documentType||(this.createTime=e),this.version=e,this.documentType=1,this.data=t,this.documentState=0,this}convertToNoDocument(e){return this.version=e,this.documentType=2,this.data=xa.empty(),this.documentState=0,this}convertToUnknownDocument(e){return this.version=e,this.documentType=3,this.data=xa.empty(),this.documentState=2,this}setHasCommittedMutations(){return this.documentState=2,this}setHasLocalMutations(){return this.documentState=1,this.version=Js.min(),this}setReadTime(e){return this.readTime=e,this}get hasLocalMutations(){return 1===this.documentState}get hasCommittedMutations(){return 2===this.documentState}get hasPendingWrites(){return this.hasLocalMutations||this.hasCommittedMutations}isValidDocument(){return 0!==this.documentType}isFoundDocument(){return 1===this.documentType}isNoDocument(){return 2===this.documentType}isUnknownDocument(){return 3===this.documentType}isEqual(e){return e instanceof Ua&&this.key.isEqual(e.key)&&this.version.isEqual(e.version)&&this.documentType===e.documentType&&this.documentState===e.documentState&&this.data.isEqual(e.data)}mutableCopy(){return new Ua(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}})`}}
2class Va{constructor(e,t){this.position=e,this.inclusive=t}}function ja(e,t,n){let r=0;for(let i=0;i<e.position.length;i++){const s=t[i],o=e.position[i];if(r=s.field.isKeyField()?js.comparator(js.fromName(o.referenceValue),n.key):Ea(o,n.data.field(s.field)),"desc"===s.dir&&(r*=-1),0!==r)break}return r}function $a(e,t){if(null===e)return null===t;if(null===t)return!1;if(e.inclusive!==t.inclusive||e.position.length!==t.position.length)return!1;for(let n=0;n<e.position.length;n++)if(!_a(e.position[n],t.position[n]))return!1;return!0}class Ba{constructor(e,t="asc"){this.field=e,this.dir=t}}function qa(e,t){return e.dir===t.dir&&e.field.isEqual(t.field)}class za{}class Ha extends za{constructor(e,t,n){super(),this.field=e,this.op=t,this.value=n}static create(e,t,n){return e.isKeyField()?"in"===t||"not-in"===t?this.createKeyFieldInFilter(e,t,n):new Za(e,t,n):"array-contains"===t?new rc(e,n):"in"===t?new ic(e,n):"not-in"===t?new sc(e,n):"array-contains-any"===t?new oc(e,n):new Ha(e,t,n)}static createKeyFieldInFilter(e,t,n){return"in"===t?new ec(e,n):new tc(e,n)}matches(e){const t=e.data.field(this.field);return"!="===this.op?null!==t&&void 0===t.nullValue&&this.matchesComparison(Ea(t,this.value)):null!==t&&wa(this.value)===wa(t)&&this.matchesComparison(Ea(t,this.value))}matchesComparison(e){switch(this.op){case"<":return e<0;case"<=":return e<=0;case"==":return 0===e;case"!=":return 0!==e;case">":return e>0;case">=":return e>=0;default:return ds(47266,{operator:this.op})}}isInequality(){return["<","<=",">",">=","!=","not-in"].indexOf(this.op)>=0}getFlattenedFilters(){return[this]}getFilters(){return[this]}}class Ga extends za{constructor(e,t){super(),this.filters=e,this.op=t,this.he=null}static create(e,t){return new Ga(e,t)}matches(e){return Ka(this)?void 0===this.filters.find(t=>!t.matches(e)):void 0!==this.filters.find(t=>t.matches(e))}getFlattenedFilters(){return null!==this.he||(this.he=this.filters.reduce((e,t)=>e.concat(t.getFlattenedFilters()),[])),this.he}getFilters(){return Object.assign([],this.filters)}}function Ka(e){return"and"===e.op}function Wa(e){return Ya(e)&&Ka(e)}function Ya(e){for(const t of e.filters)if(t instanceof Ga)return!1;return!0}function Qa(e){if(e instanceof Ha)return e.field.canonicalString()+e.op.toString()+Sa(e.value);if(Wa(e))return e.filters.map(e=>Qa(e)).join(",");{const t=e.filters.map(e=>Qa(e)).join(",");return`${e.op}(${t})`}}function Ja(e,t){return e instanceof Ha?function(e,t){return t instanceof Ha&&e.op===t.op&&e.field.isEqual(t.field)&&_a(e.value,t.value)}(e,t):e instanceof Ga?function(e,t){return t instanceof Ga&&e.op===t.op&&e.filters.length===t.filters.length&&e.filters.reduce((e,n,r)=>e&&Ja(n,t.filters[r]),!0)}(e,t):void ds(19439)}function Xa(e){return e instanceof Ha?function(e){return`${e.field.canonicalString()} ${e.op} ${Sa(e.value)}`}(e):e instanceof Ga?function(e){return e.op.toString()+" {"+e.getFilters().map(Xa).join(" ,")+"}"}(e):"Filter"}class Za extends Ha{constructor(e,t,n){super(e,t,n),this.key=js.fromName(n.referenceValue)}matches(e){const t=js.comparator(e.key,this.key);return this.matchesComparison(t)}}class ec extends Ha{constructor(e,t){super(e,"in",t),this.keys=nc("in",t)}matches(e){return this.keys.some(t=>t.isEqual(e.key))}}class tc extends Ha{constructor(e,t){super(e,"not-in",t),this.keys=nc("not-in",t)}matches(e){return!this.keys.some(t=>t.isEqual(e.key))}}function nc(e,t){var n;return((null===(n=t.arrayValue)||void 0===n?void 0:n.values)||[]).map(e=>js.fromName(e.referenceValue))}class rc extends Ha{constructor(e,t){super(e,"array-contains",t)}matches(e){const t=e.data.field(this.field);return Na(t)&&ba(t.arrayValue,this.value)}}class ic extends Ha{constructor(e,t){super(e,"in",t)}matches(e){const t=e.data.field(this.field);return null!==t&&ba(this.value.arrayValue,t)}}class sc extends Ha{constructor(e,t){super(e,"not-in",t)}matches(e){if(ba(this.value.arrayValue,{nullValue:"NULL_VALUE"}))return!1;const t=e.data.field(this.field);return null!==t&&void 0===t.nullValue&&!ba(this.value.arrayValue,t)}}class oc extends Ha{constructor(e,t){super(e,"array-contains-any",t)}matches(e){const t=e.data.field(this.field);return!(!Na(t)||!t.arrayValue.values)&&t.arrayValue.values.some(e=>ba(this.value.arrayValue,e))}}class ac{constructor(e,t=null,n=[],r=[],i=null,s=null,o=null){this.path=e,this.collectionGroup=t,this.orderBy=n,this.filters=r,this.limit=i,this.startAt=s,this.endAt=o,this.Pe=null}}function cc(e,t=null,n=[],r=[],i=null,s=null,o=null){return new ac(e,t,n,r,i,s,o)}function uc(e){const t=ms(e);if(null===t.Pe){let e=t.path.canonicalString();null!==t.collectionGroup&&(e+="|cg:"+t.collectionGroup),e+="|f:",e+=t.filters.map(e=>Qa(e)).join(","),e+="|ob:",e+=t.orderBy.map(e=>function(e){return e.field.canonicalString()+e.dir}(e)).join(","),fo(t.limit)||(e+="|l:",e+=t.limit),t.startAt&&(e+="|lb:",e+=t.startAt.inclusive?"b:":"a:",e+=t.startAt.position.map(e=>Sa(e)).join(",")),t.endAt&&(e+="|ub:",e+=t.endAt.inclusive?"a:":"b:",e+=t.endAt.position.map(e=>Sa(e)).join(",")),t.Pe=e}return t.Pe}function lc(e,t){if(e.limit!==t.limit)return!1;if(e.orderBy.length!==t.orderBy.length)return!1;for(let n=0;n<e.orderBy.length;n++)if(!qa(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(!Ja(e.filters[n],t.filters[n]))return!1;return e.collectionGroup===t.collectionGroup&&!!e.path.isEqual(t.path)&&!!$a(e.startAt,t.startAt)&&$a(e.endAt,t.endAt)}function hc(e){return js.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}class dc{constructor(e,t=null,n=[],r=[],i=null,s="F",o=null,a=null){this.path=e,this.collectionGroup=t,this.explicitOrderBy=n,this.filters=r,this.limit=i,this.limitType=s,this.startAt=o,this.endAt=a,this.Te=null,this.Ie=null,this.de=null,this.startAt,this.endAt}}function fc(e,t,n,r,i,s,o,a){return new dc(e,t,n,r,i,s,o,a)}function pc(e){return new dc(e)}function mc(e){return 0===e.filters.length&&null===e.limit&&null==e.startAt&&null==e.endAt&&(0===e.explicitOrderBy.length||1===e.explicitOrderBy.length&&e.explicitOrderBy[0].field.isKeyField())}function gc(e){return null!==e.collectionGroup}function yc(e){const t=ms(e);if(null===t.Te){t.Te=[];const e=new Set;for(const n of t.explicitOrderBy)t.Te.push(n),e.add(n.field.canonicalString());const n=t.explicitOrderBy.length>0?t.explicitOrderBy[t.explicitOrderBy.length-1].dir:"asc",r=function(e){let t=new Yo(Vs.comparator);
2return e.filters.forEach(e=>{e.getFlattenedFilters().forEach(e=>{e.isInequality()&&(t=t.add(e.field))})}),t}(t);r.forEach(r=>{e.has(r.canonicalString())||r.isKeyField()||t.Te.push(new Ba(r,n))}),e.has(Vs.keyField().canonicalString())||t.Te.push(new Ba(Vs.keyField(),n))}return t.Te}function vc(e){const t=ms(e);return t.Ie||(t.Ie=wc(t,yc(e))),t.Ie}function wc(e,t){if("F"===e.limitType)return cc(e.path,e.collectionGroup,t,e.filters,e.limit,e.startAt,e.endAt);{t=t.map(e=>{const t="desc"===e.dir?"asc":"desc";return new Ba(e.field,t)});const n=e.endAt?new Va(e.endAt.position,e.endAt.inclusive):null,r=e.startAt?new Va(e.startAt.position,e.startAt.inclusive):null;return cc(e.path,e.collectionGroup,t,e.filters,e.limit,n,r)}}function _c(e,t,n){return new dc(e.path,e.collectionGroup,e.explicitOrderBy.slice(),e.filters.slice(),t,n,e.startAt,e.endAt)}function bc(e,t){return lc(vc(e),vc(t))&&e.limitType===t.limitType}function Ec(e){return`${uc(vc(e))}|lt:${e.limitType}`}function Tc(e){return`Query(target=${function(e){let t=e.path.canonicalString();return null!==e.collectionGroup&&(t+=" collectionGroup="+e.collectionGroup),e.filters.length>0&&(t+=`, filters: [${e.filters.map(e=>Xa(e)).join(", ")}]`),fo(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=>Sa(e)).join(",")),e.endAt&&(t+=", endAt: ",t+=e.endAt.inclusive?"a:":"b:",t+=e.endAt.position.map(e=>Sa(e)).join(",")),`Target(${t})`}(vc(e))}; limitType=${e.limitType})`}function Ic(e,t){return t.isFoundDocument()&&function(e,t){const n=t.key.path;return null!==e.collectionGroup?t.key.hasCollectionId(e.collectionGroup)&&e.path.isPrefixOf(n):js.isDocumentKey(e.path)?e.path.isEqual(n):e.path.isImmediateParentOf(n)}(e,t)&&function(e,t){for(const n of yc(e))if(!n.field.isKeyField()&&null===t.data.field(n.field))return!1;return!0}(e,t)&&function(e,t){for(const n of e.filters)if(!n.matches(t))return!1;return!0}(e,t)&&function(e,t){return!(e.startAt&&!function(e,t,n){const r=ja(e,t,n);return e.inclusive?r<=0:r<0}(e.startAt,yc(e),t))&&!(e.endAt&&!function(e,t,n){const r=ja(e,t,n);return e.inclusive?r>=0:r>0}(e.endAt,yc(e),t))}(e,t)}function Sc(e){return e.collectionGroup||(e.path.length%2==1?e.path.lastSegment():e.path.get(e.path.length-2))}function Cc(e){return(t,n)=>{let r=!1;for(const i of yc(e)){const e=Ac(i,t,n);if(0!==e)return e;r=r||i.field.isKeyField()}return 0}}function Ac(e,t,n){const r=e.field.isKeyField()?js.comparator(t.key,n.key):function(e,t,n){const r=t.data.field(e),i=n.data.field(e);return null!==r&&null!==i?Ea(r,i):ds(42886)}(e.field,t,n);switch(e.dir){case"asc":return r;case"desc":return-1*r;default:return ds(19790,{direction:e.dir})}}class kc{constructor(e,t){this.mapKeyFn=e,this.equalsFn=t,this.inner={},this.innerSize=0}get(e){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0!==n)for(const[t,r]of n)if(this.equalsFn(t,e))return r}has(e){return void 0!==this.get(e)}set(e,t){const n=this.mapKeyFn(e),r=this.inner[n];if(void 0===r)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){const t=this.mapKeyFn(e),n=this.inner[t];if(void 0===n)return!1;for(let r=0;r<n.length;r++)if(this.equalsFn(n[r][0],e))return 1===n.length?delete this.inner[t]:n.splice(r,1),this.innerSize--,!0;return!1}forEach(e){zo(this.inner,(t,n)=>{for(const[t,r]of n)e(t,r)})}isEmpty(){return Ho(this.inner)}size(){return this.innerSize}}const Nc=new Go(js.comparator);function Oc(){return Nc}const Dc=new Go(js.comparator);function Rc(...e){let t=Dc;for(const n of e)t=t.insert(n.key,n);return t}function Pc(e){let t=Dc;return e.forEach((e,n)=>t=t.insert(e,n.overlayedDocument)),t}function Lc(){return xc()}function Mc(){return xc()}function xc(){return new kc(e=>e.toString(),(e,t)=>e.isEqual(t))}const Fc=new Go(js.comparator),Uc=new Yo(js.comparator);function Vc(...e){let t=Uc;for(const n of e)t=t.add(n);return t}const jc=new Yo(Os);function $c(){return jc}function Bc(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:po(t)?"-0":t}}function qc(e){return{integerValue:""+e}}function zc(e,t){return mo(t)?qc(t):Bc(e,t)}class Hc{constructor(){this._=void 0}}
2function Gc(e,t,n){return e instanceof Yc?function(e,t){const n={fields:{[sa]:{stringValue:ia},[aa]:{timestampValue:{seconds:e.seconds,nanos:e.nanoseconds}}}};return t&&ca(t)&&(t=ua(t)),t&&(n.fields[oa]=t),{mapValue:n}}(n,t):e instanceof Qc?Jc(e,t):e instanceof Xc?Zc(e,t):function(e,t){const n=Wc(e,t),r=tu(n)+tu(e.Ee);return ka(n)&&ka(e.Ee)?qc(r):Bc(e.serializer,r)}(e,t)}function Kc(e,t,n){return e instanceof Qc?Jc(e,t):e instanceof Xc?Zc(e,t):n}function Wc(e,t){return e instanceof eu?function(e){return ka(e)||function(e){return!!e&&"doubleValue"in e}(e)}(t)?t:{integerValue:0}:null}class Yc extends Hc{}class Qc extends Hc{constructor(e){super(),this.elements=e}}function Jc(e,t){const n=nu(t);for(const t of e.elements)n.some(e=>_a(e,t))||n.push(t);return{arrayValue:{values:n}}}class Xc extends Hc{constructor(e){super(),this.elements=e}}function Zc(e,t){let n=nu(t);for(const t of e.elements)n=n.filter(e=>!_a(e,t));return{arrayValue:{values:n}}}class eu extends Hc{constructor(e,t){super(),this.serializer=e,this.Ee=t}}function tu(e){return na(e.integerValue||e.doubleValue)}function nu(e){return Na(e)&&e.arrayValue.values?e.arrayValue.values.slice():[]}class ru{constructor(e,t){this.version=e,this.transformResults=t}}class iu{constructor(e,t){this.updateTime=e,this.exists=t}static none(){return new iu}static exists(e){return new iu(void 0,e)}static updateTime(e){return new iu(e)}get isNone(){return void 0===this.updateTime&&void 0===this.exists}isEqual(e){return this.exists===e.exists&&(this.updateTime?!!e.updateTime&&this.updateTime.isEqual(e.updateTime):!e.updateTime)}}function su(e,t){return void 0!==e.updateTime?t.isFoundDocument()&&t.version.isEqual(e.updateTime):void 0===e.exists||e.exists===t.isFoundDocument()}class ou{}function au(e,t){if(!e.hasLocalMutations||t&&0===t.fields.length)return null;if(null===t)return e.isNoDocument()?new yu(e.key,iu.none()):new du(e.key,e.data,iu.none());{const n=e.data,r=xa.empty();let i=new Yo(Vs.comparator);for(let e of t.fields)if(!i.has(e)){let t=n.field(e);null===t&&e.length>1&&(e=e.popLast(),t=n.field(e)),null===t?r.delete(e):r.set(e,t),i=i.add(e)}return new fu(e.key,r,new Jo(i.toArray()),iu.none())}}function cu(e,t,n){e instanceof du?function(e,t,n){const r=e.value.clone(),i=mu(e.fieldTransforms,t,n.transformResults);r.setAll(i),t.convertToFoundDocument(n.version,r).setHasCommittedMutations()}(e,t,n):e instanceof fu?function(e,t,n){if(!su(e.precondition,t))return void t.convertToUnknownDocument(n.version);const r=mu(e.fieldTransforms,t,n.transformResults),i=t.data;i.setAll(pu(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 uu(e,t,n,r){return e instanceof du?function(e,t,n,r){if(!su(e.precondition,t))return n;const i=e.value.clone(),s=gu(e.fieldTransforms,r,t);return i.setAll(s),t.convertToFoundDocument(t.version,i).setHasLocalMutations(),null}(e,t,n,r):e instanceof fu?function(e,t,n,r){if(!su(e.precondition,t))return n;const i=gu(e.fieldTransforms,r,t),s=t.data;return s.setAll(pu(e)),s.setAll(i),t.convertToFoundDocument(t.version,s).setHasLocalMutations(),null===n?null:n.unionWith(e.fieldMask.fields).unionWith(e.fieldTransforms.map(e=>e.field))}(e,t,n,r):function(e,t,n){return su(e.precondition,t)?(t.convertToNoDocument(t.version).setHasLocalMutations(),null):n}(e,t,n)}function lu(e,t){let n=null;for(const r of e.fieldTransforms){const e=t.data.field(r.field),i=Wc(r.transform,e||null);null!=i&&(null===n&&(n=xa.empty()),n.set(r.field,i))}return n||null}function hu(e,t){return e.type===t.type&&!!e.key.isEqual(t.key)&&!!e.precondition.isEqual(t.precondition)&&!!function(e,t){return void 0===e&&void 0===t||!(!e||!t)&&Ls(e,t,(e,t)=>function(e,t){return e.field.isEqual(t.field)&&function(e,t){return e instanceof Qc&&t instanceof Qc||e instanceof Xc&&t instanceof Xc?Ls(e.elements,t.elements,_a):e instanceof eu&&t instanceof eu?_a(e.Ee,t.Ee):e instanceof Yc&&t instanceof Yc}(e.transform,t.transform)}(e,t))}(e.fieldTransforms,t.fieldTransforms)&&(0===e.type?e.value.isEqual(t.value):1!==e.type||e.data.isEqual(t.data)&&e.fieldMask.isEqual(t.fieldMask))}class du extends ou{constructor(e,t,n,r=[]){super(),this.key=e,this.value=t,this.prec
2ondition=n,this.fieldTransforms=r,this.type=0}getFieldMask(){return null}}class fu extends ou{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 pu(e){const t=new Map;return e.fieldMask.fields.forEach(n=>{if(!n.isEmpty()){const r=e.data.field(n);t.set(n,r)}}),t}function mu(e,t,n){const r=new Map;ps(e.length===n.length,32656,{Ae:n.length,Re:e.length});for(let i=0;i<n.length;i++){const s=e[i],o=s.transform,a=t.data.field(s.field);r.set(s.field,Kc(o,a,n[i]))}return r}function gu(e,t,n){const r=new Map;for(const i of e){const e=i.transform,s=n.data.field(i.field);r.set(i.field,Gc(e,s,t))}return r}class yu extends ou{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=2,this.fieldTransforms=[]}getFieldMask(){return null}}class vu extends ou{constructor(e,t){super(),this.key=e,this.precondition=t,this.type=3,this.fieldTransforms=[]}getFieldMask(){return null}}class wu{constructor(e,t,n,r){this.batchId=e,this.localWriteTime=t,this.baseMutations=n,this.mutations=r}applyToRemoteDocument(e,t){const n=t.mutationResults;for(let t=0;t<this.mutations.length;t++){const r=this.mutations[t];r.key.isEqual(e.key)&&cu(r,e,n[t])}}applyToLocalView(e,t){for(const n of this.baseMutations)n.key.isEqual(e.key)&&(t=uu(n,e,t,this.localWriteTime));for(const n of this.mutations)n.key.isEqual(e.key)&&(t=uu(n,e,t,this.localWriteTime));return t}applyToLocalDocumentSet(e,t){const n=Mc();return this.mutations.forEach(r=>{const i=e.get(r.key),s=i.overlayedDocument;let o=this.applyToLocalView(s,i.mutatedFields);o=t.has(r.key)?null:o;const a=au(s,o);null!==a&&n.set(r.key,a),s.isValidDocument()||s.convertToNoDocument(Js.min())}),n}keys(){return this.mutations.reduce((e,t)=>e.add(t.key),Vc())}isEqual(e){return this.batchId===e.batchId&&Ls(this.mutations,e.mutations,(e,t)=>hu(e,t))&&Ls(this.baseMutations,e.baseMutations,(e,t)=>hu(e,t))}}class _u{constructor(e,t,n,r){this.batch=e,this.commitVersion=t,this.mutationResults=n,this.docVersions=r}static from(e,t,n){ps(e.mutations.length===n.length,58842,{Ve:e.mutations.length,me:n.length});let r=Fc;const i=e.mutations;for(let e=0;e<i.length;e++)r=r.insert(i[e].key,n[e].version);return new _u(e,t,n,r)}}class bu{constructor(e,t){this.largestBatchId=e,this.mutation=t}getKey(){return this.mutation.key}isEqual(e){return null!==e&&this.mutation===e.mutation}toString(){return`Overlay{\n largestBatchId: ${this.largestBatchId},\n mutation: ${this.mutation.toString()}\n }`}}class Eu{constructor(e,t){this.count=e,this.unchangedNames=t}}var Tu,Iu;function Su(e){switch(e){case gs.OK:return ds(64938);case gs.CANCELLED:case gs.UNKNOWN:case gs.DEADLINE_EXCEEDED:case gs.RESOURCE_EXHAUSTED:case gs.INTERNAL:case gs.UNAVAILABLE:case gs.UNAUTHENTICATED:return!1;case gs.INVALID_ARGUMENT:case gs.NOT_FOUND:case gs.ALREADY_EXISTS:case gs.PERMISSION_DENIED:case gs.FAILED_PRECONDITION:case gs.ABORTED:case gs.OUT_OF_RANGE:case gs.UNIMPLEMENTED:case gs.DATA_LOSS:return!0;default:return ds(15467,{code:e})}}function Cu(e){if(void 0===e)return us("GRPC error has no .code"),gs.UNKNOWN;switch(e){case Tu.OK:return gs.OK;case Tu.CANCELLED:return gs.CANCELLED;case Tu.UNKNOWN:return gs.UNKNOWN;case Tu.DEADLINE_EXCEEDED:return gs.DEADLINE_EXCEEDED;case Tu.RESOURCE_EXHAUSTED:return gs.RESOURCE_EXHAUSTED;case Tu.INTERNAL:return gs.INTERNAL;case Tu.UNAVAILABLE:return gs.UNAVAILABLE;case Tu.UNAUTHENTICATED:return gs.UNAUTHENTICATED;case Tu.INVALID_ARGUMENT:return gs.INVALID_ARGUMENT;case Tu.NOT_FOUND:return gs.NOT_FOUND;case Tu.ALREADY_EXISTS:return gs.ALREADY_EXISTS;case Tu.PERMISSION_DENIED:return gs.PERMISSION_DENIED;case Tu.FAILED_PRECONDITION:return gs.FAILED_PRECONDITION;case Tu.ABORTED:return gs.ABORTED;case Tu.OUT_OF_RANGE:return gs.OUT_OF_RANGE;case Tu.UNIMPLEMENTED:return gs.UNIMPLEMENTED;case Tu.DATA_LOSS:return gs.DATA_LOSS;default:return ds(39323,{code:e})}}(Iu=Tu||(Tu={}))[Iu.OK=0]="OK",Iu[Iu.CANCELLED=1]="CANCELLED",Iu[Iu.UNKNOWN=2]="UNKNOWN",Iu[Iu.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",Iu[Iu.DEADLINE_EXCEEDED=4]="DEADLINE_EXCEEDED",Iu[Iu.NOT_FOUND=5]="NOT_FOUND",Iu[Iu.ALREADY_EXISTS=6]="ALREADY_EXISTS",Iu[Iu.PERMISSION_DENIED=7]="PERMISSION_DENIED",Iu[Iu.UNAUTHENTICATED=16]="UNAUTHENTICATED",Iu[Iu.RESOURCE_EXHAUSTED=8]="RESOURCE_EXHAUSTED",Iu[Iu.FAILED_PRECONDITION=9]="FAILED_PRECONDITION",Iu[Iu.ABORTED=10]="ABORTED",Iu[Iu.OUT_OF_RANGE=11]="OUT_OF_RANGE",Iu[Iu.UNIMPLEMENT
2ED=12]="UNIMPLEMENTED",Iu[Iu.INTERNAL=13]="INTERNAL",Iu[Iu.UNAVAILABLE=14]="UNAVAILABLE",Iu[Iu.DATA_LOSS=15]="DATA_LOSS";let Au=null;const ku=new Bi([4294967295,4294967295],0);function Nu(e){const t=ks().encode(e),n=new qi;return n.update(t),new Uint8Array(n.digest())}function Ou(e){const t=new DataView(e.buffer),n=t.getUint32(0,!0),r=t.getUint32(4,!0),i=t.getUint32(8,!0),s=t.getUint32(12,!0);return[new Bi([n,r],0),new Bi([i,s],0)]}class Du{constructor(e,t,n){if(this.bitmap=e,this.padding=t,this.hashCount=n,t<0||t>=8)throw new Ru(`Invalid padding: ${t}`);if(n<0)throw new Ru(`Invalid hash count: ${n}`);if(e.length>0&&0===this.hashCount)throw new Ru(`Invalid hash count: ${n}`);if(0===e.length&&0!==t)throw new Ru(`Invalid padding when bitmap length is 0: ${t}`);this.fe=8*e.length-t,this.ge=Bi.fromNumber(this.fe)}pe(e,t,n){let r=e.add(t.multiply(Bi.fromNumber(n)));return 1===r.compare(ku)&&(r=new Bi([r.getBits(0),r.getBits(1)],0)),r.modulo(this.ge).toNumber()}ye(e){return!!(this.bitmap[Math.floor(e/8)]&1<<e%8)}mightContain(e){if(0===this.fe)return!1;const t=Nu(e),[n,r]=Ou(t);for(let e=0;e<this.hashCount;e++){const t=this.pe(n,r,e);if(!this.ye(t))return!1}return!0}static create(e,t,n){const r=e%8==0?0:8-e%8,i=new Uint8Array(Math.ceil(e/8)),s=new Du(i,r,t);return n.forEach(e=>s.insert(e)),s}insert(e){if(0===this.fe)return;const t=Nu(e),[n,r]=Ou(t);for(let e=0;e<this.hashCount;e++){const t=this.pe(n,r,e);this.we(t)}}we(e){const t=Math.floor(e/8),n=e%8;this.bitmap[t]|=1<<n}}class Ru extends Error{constructor(){super(...arguments),this.name="BloomFilterError"}}class Pu{constructor(e,t,n,r,i){this.snapshotVersion=e,this.targetChanges=t,this.targetMismatches=n,this.documentUpdates=r,this.resolvedLimboDocuments=i}static createSynthesizedRemoteEventForCurrentChange(e,t,n){const r=new Map;return r.set(e,Lu.createSynthesizedTargetChangeForCurrentChange(e,t,n)),new Pu(Js.min(),r,new Go(Os),Oc(),Vc())}}class Lu{constructor(e,t,n,r,i){this.resumeToken=e,this.current=t,this.addedDocuments=n,this.modifiedDocuments=r,this.removedDocuments=i}static createSynthesizedTargetChangeForCurrentChange(e,t,n){return new Lu(n,t,Vc(),Vc(),Vc())}}class Mu{constructor(e,t,n,r){this.Se=e,this.removedTargetIds=t,this.key=n,this.be=r}}class xu{constructor(e,t){this.targetId=e,this.De=t}}class Fu{constructor(e,t,n=Zo.EMPTY_BYTE_STRING,r=null){this.state=e,this.targetIds=t,this.resumeToken=n,this.cause=r}}class Uu{constructor(){this.ve=0,this.Ce=$u(),this.Fe=Zo.EMPTY_BYTE_STRING,this.Me=!1,this.xe=!0}get current(){return this.Me}get resumeToken(){return this.Fe}get Oe(){return 0!==this.ve}get Ne(){return this.xe}Be(e){e.approximateByteSize()>0&&(this.xe=!0,this.Fe=e)}Le(){let e=Vc(),t=Vc(),n=Vc();return this.Ce.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:ds(38017,{changeType:i})}}),new Lu(this.Fe,this.Me,e,t,n)}ke(){this.xe=!1,this.Ce=$u()}qe(e,t){this.xe=!0,this.Ce=this.Ce.insert(e,t)}Qe(e){this.xe=!0,this.Ce=this.Ce.remove(e)}$e(){this.ve+=1}Ue(){this.ve-=1,ps(this.ve>=0,3241,{ve:this.ve})}Ke(){this.xe=!0,this.Me=!0}}class Vu{constructor(e){this.We=e,this.Ge=new Map,this.ze=Oc(),this.je=ju(),this.Je=ju(),this.He=new Go(Os)}Ye(e){for(const t of e.Se)e.be&&e.be.isFoundDocument()?this.Ze(t,e.be):this.Xe(t,e.key,e.be);for(const t of e.removedTargetIds)this.Xe(t,e.key,e.be)}et(e){this.forEachTarget(e,t=>{const n=this.tt(t);switch(e.state){case 0:this.nt(t)&&n.Be(e.resumeToken);break;case 1:n.Ue(),n.Oe||n.ke(),n.Be(e.resumeToken);break;case 2:n.Ue(),n.Oe||this.removeTarget(t);break;case 3:this.nt(t)&&(n.Ke(),n.Be(e.resumeToken));break;case 4:this.nt(t)&&(this.rt(t),n.Be(e.resumeToken));break;default:ds(56790,{state:e.state})}})}forEachTarget(e,t){e.targetIds.length>0?e.targetIds.forEach(t):this.Ge.forEach((e,n)=>{this.nt(n)&&t(n)})}it(e){const t=e.targetId,n=e.De.count,r=this.st(t);if(r){const i=r.target;if(hc(i))if(0===n){const e=new js(i.path);this.Xe(t,e,Ua.newNoDocument(e,Js.min()))}else ps(1===n,20013,{expectedCount:n});else{const r=this.ot(t);if(r!==n){const n=this._t(e),i=n?this.ut(n,e,r):1;if(0!==i){this.rt(t);const e=2===i?"TargetPurposeExistenceFilterMismatchBloom":"TargetPurposeExistenceFilterMismatch";this.He=this.He.insert(t,e)}null==Au||Au.ct(function(e,t,n,r,i){var s,o,a,c,u,l;const h={localCacheCount:e,existenceFilterCount:t.count,databaseId:n.database,projectId:n.projectId},d=t.unchangedNames;return d&&(h.bloomFilter={applied:0===i,hashCount:null!==(s=null==d?void 0:d.hashCount)&&void 0!==s?s:0,bitmapLength:null!==(c=null===(a=null===(o=null==d?void 0:d.bits)||void 0===o?void 0:o.bitmap)||void 0===a?void 0:a.length)&&void 0!==c?c:0,padding:null!==(l=null===(u=null==d?void 0:d.bits)||void 0===u?void 0:u.padding)&&void 0!==l?l:0,mightContain:e=>{var t;return null!==(t=null==r?void 0:r.mightContain(e))&&void 0!==t&&t}}),h}(r,e.De,this.We.lt(),n,i))}}}}_t(e){const t=e.De.unchangedNames;if(!t||!t.bits)return null;const{bits:{bitmap:n="",padding:r=0},hashCount:i=0}=t;let s,o;try{s=ra(n).toUint8Array()}catch(e){if(e instanceof Xo)return ls("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 Du(s,r,i)}catch(e){return ls(e instanceof Ru?"BloomFilter error: ":"Applying bloom filter failed: ",e),null}return 0===o.fe?null:o}ut(e,t,n){return t.De.count===n-this.ht(e,t.targetId)?0:2}ht(e,t){const n=this.We.getRemoteKeysForTarget(t);let r=0;
2return n.forEach(n=>{const i=this.We.lt(),s=`projects/${i.projectId}/databases/${i.database}/documents/${n.path.canonicalString()}`;e.mightContain(s)||(this.Xe(t,n,null),r++)}),r}Pt(e){const t=new Map;this.Ge.forEach((n,r)=>{const i=this.st(r);if(i){if(n.current&&hc(i.target)){const t=new js(i.target.path);this.Tt(t).has(r)||this.It(r,t)||this.Xe(r,t,Ua.newNoDocument(t,e))}n.Ne&&(t.set(r,n.Le()),n.ke())}});let n=Vc();this.Je.forEach((e,t)=>{let r=!0;t.forEachWhile(e=>{const t=this.st(e);return!t||"TargetPurposeLimboResolution"===t.purpose||(r=!1,!1)}),r&&(n=n.add(e))}),this.ze.forEach((t,n)=>n.setReadTime(e));const r=new Pu(e,t,this.He,this.ze,n);return this.ze=Oc(),this.je=ju(),this.Je=ju(),this.He=new Go(Os),r}Ze(e,t){if(!this.nt(e))return;const n=this.It(e,t.key)?2:0;this.tt(e).qe(t.key,n),this.ze=this.ze.insert(t.key,t),this.je=this.je.insert(t.key,this.Tt(t.key).add(e)),this.Je=this.Je.insert(t.key,this.dt(t.key).add(e))}Xe(e,t,n){if(!this.nt(e))return;const r=this.tt(e);this.It(e,t)?r.qe(t,1):r.Qe(t),this.Je=this.Je.insert(t,this.dt(t).delete(e)),this.Je=this.Je.insert(t,this.dt(t).add(e)),n&&(this.ze=this.ze.insert(t,n))}removeTarget(e){this.Ge.delete(e)}ot(e){const t=this.tt(e).Le();return this.We.getRemoteKeysForTarget(e).size+t.addedDocuments.size-t.removedDocuments.size}$e(e){this.tt(e).$e()}tt(e){let t=this.Ge.get(e);return t||(t=new Uu,this.Ge.set(e,t)),t}dt(e){let t=this.Je.get(e);return t||(t=new Yo(Os),this.Je=this.Je.insert(e,t)),t}Tt(e){let t=this.je.get(e);return t||(t=new Yo(Os),this.je=this.je.insert(e,t)),t}nt(e){const t=null!==this.st(e);return t||cs("WatchChangeAggregator","Detected inactive target",e),t}st(e){const t=this.Ge.get(e);return t&&t.Oe?null:this.We.Et(e)}rt(e){this.Ge.set(e,new Uu),this.We.getRemoteKeysForTarget(e).forEach(t=>{this.Xe(e,t,null)})}It(e,t){return this.We.getRemoteKeysForTarget(e).has(t)}}function ju(){return new Go(js.comparator)}function $u(){return new Go(js.comparator)}const Bu={asc:"ASCENDING",desc:"DESCENDING"},qu={"<":"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"},zu={and:"AND",or:"OR"};class Hu{constructor(e,t){this.databaseId=e,this.useProto3Json=t}}function Gu(e,t){return e.useProto3Json||fo(t)?t:{value:t}}function Ku(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 Wu(e,t){return e.useProto3Json?t.toBase64():t.toUint8Array()}function Yu(e,t){return Ku(e,t.toTimestamp())}function Qu(e){return ps(!!e,49232),Js.fromTimestamp(function(e){const t=ta(e);return new Qs(t.seconds,t.nanos)}(e))}function Ju(e,t){return Xu(e,t).canonicalString()}function Xu(e,t){const n=function(e){return new Fs(["projects",e.projectId,"databases",e.database])}(e).child("documents");return void 0===t?n:n.child(t)}function Zu(e){const t=Fs.fromString(e);return ps(wl(t),10190,{key:t.toString()}),t}function el(e,t){return Ju(e.databaseId,t.path)}function tl(e,t){const n=Zu(t);if(n.get(1)!==e.databaseId.projectId)throw new ys(gs.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 ys(gs.INVALID_ARGUMENT,"Tried to deserialize key from different database: "+n.get(3)+" vs "+e.databaseId.database);return new js(sl(n))}function nl(e,t){return Ju(e.databaseId,t)}function rl(e){const t=Zu(e);return 4===t.length?Fs.emptyPath():sl(t)}function il(e){return new Fs(["projects",e.databaseId.projectId,"databases",e.databaseId.database]).canonicalString()}function sl(e){return ps(e.length>4&&"documents"===e.get(4),29091,{key:e.toString()}),e.popFirst(5)}function ol(e,t,n){return{name:el(e,t),fields:n.value.mapValue.fields}}function al(e,t){let n;if(t instanceof du)n={update:ol(e,t.key,t.value)};else if(t instanceof yu)n={delete:el(e,t.key)};else if(t instanceof fu)n={update:ol(e,t.key,t.data),updateMask:vl
2(t.fieldMask)};else{if(!(t instanceof vu))return ds(16599,{Rt:t.type});n={verify:el(e,t.key)}}return t.fieldTransforms.length>0&&(n.updateTransforms=t.fieldTransforms.map(e=>function(e,t){const n=t.transform;if(n instanceof Yc)return{fieldPath:t.field.canonicalString(),setToServerValue:"REQUEST_TIME"};if(n instanceof Qc)return{fieldPath:t.field.canonicalString(),appendMissingElements:{values:n.elements}};if(n instanceof Xc)return{fieldPath:t.field.canonicalString(),removeAllFromArray:{values:n.elements}};if(n instanceof eu)return{fieldPath:t.field.canonicalString(),increment:n.Ee};throw ds(20930,{transform:t.transform})}(0,e))),t.precondition.isNone||(n.currentDocument=function(e,t){return void 0!==t.updateTime?{updateTime:Yu(e,t.updateTime)}:void 0!==t.exists?{exists:t.exists}:ds(27497)}(e,t.precondition)),n}function cl(e,t){return{documents:[nl(e,t.path)]}}function ul(e,t){const n={structuredQuery:{}},r=t.path;let i;null!==t.collectionGroup?(i=r,n.structuredQuery.from=[{collectionId:t.collectionGroup,allDescendants:!0}]):(i=r.popLast(),n.structuredQuery.from=[{collectionId:r.lastSegment()}]),n.parent=nl(e,i);const s=function(e){if(0!==e.length)return yl(Ga.create(e,"and"))}(t.filters);s&&(n.structuredQuery.where=s);const o=function(e){if(0!==e.length)return e.map(e=>function(e){return{field:ml(e.field),direction:dl(e.dir)}}(e))}(t.orderBy);o&&(n.structuredQuery.orderBy=o);const a=Gu(e,t.limit);return null!==a&&(n.structuredQuery.limit=a),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)),{Vt:n,parent:i}}function ll(e){let t=rl(e.parent);const n=e.structuredQuery,r=n.from?n.from.length:0;let i=null;if(r>0){ps(1===r,65062);const e=n.from[0];e.allDescendants?i=e.collectionId:t=t.child(e.collectionId)}let s=[];n.where&&(s=function(e){const t=hl(e);return t instanceof Ga&&Wa(t)?t.getFilters():[t]}(n.where));let o=[];n.orderBy&&(o=function(e){return e.map(e=>function(e){return new Ba(gl(e.field),function(e){switch(e){case"ASCENDING":return"asc";case"DESCENDING":return"desc";default:return}}(e.direction))}(e))}(n.orderBy));let a=null;n.limit&&(a=function(e){let t;return t="object"==typeof e?e.value:e,fo(t)?null:t}(n.limit));let c=null;n.startAt&&(c=function(e){const t=!!e.before,n=e.values||[];return new Va(n,t)}(n.startAt));let u=null;return n.endAt&&(u=function(e){const t=!e.before,n=e.values||[];return new Va(n,t)}(n.endAt)),fc(t,i,o,s,a,"F",c,u)}function hl(e){return void 0!==e.unaryFilter?function(e){switch(e.unaryFilter.op){case"IS_NAN":const t=gl(e.unaryFilter.field);return Ha.create(t,"==",{doubleValue:NaN});case"IS_NULL":const n=gl(e.unaryFilter.field);return Ha.create(n,"==",{nullValue:"NULL_VALUE"});case"IS_NOT_NAN":const r=gl(e.unaryFilter.field);return Ha.create(r,"!=",{doubleValue:NaN});case"IS_NOT_NULL":const i=gl(e.unaryFilter.field);return Ha.create(i,"!=",{nullValue:"NULL_VALUE"});case"OPERATOR_UNSPECIFIED":return ds(61313);default:return ds(60726)}}(e):void 0!==e.fieldFilter?function(e){return Ha.create(gl(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 ds(58110);default:return ds(50506)}}(e.fieldFilter.op),e.fieldFilter.value)}(e):void 0!==e.compositeFilter?function(e){return Ga.create(e.compositeFilter.filters.map(e=>hl(e)),function(e){switch(e){case"AND":return"and";case"OR":return"or";default:return ds(1026)}}(e.compositeFilter.op))}(e):ds(30097,{filter:e})}function dl(e){return Bu[e]}function fl(e){return qu[e]}function pl(e){return zu[e]}function ml(e){return{fieldPath:e.canonicalString()}}function gl(e){return Vs.fromServerFormat(e.fieldPath)}function yl(e){return e instanceof Ha?function(e){if("=="===e.op){if(Da(e.value))return{unaryFilter:{field:ml(e.field),op:"IS_NAN"}};if(Oa(e.value))return{unaryFilter:{field:ml(e.field),op:"IS_NULL"}}}else if("!="===e.op){if(Da(e.value))return{unaryFilter:{field:ml(e.field),op:"IS_NOT_NA
2N"}};if(Oa(e.value))return{unaryFilter:{field:ml(e.field),op:"IS_NOT_NULL"}}}return{fieldFilter:{field:ml(e.field),op:fl(e.op),value:e.value}}}(e):e instanceof Ga?function(e){const t=e.getFilters().map(e=>yl(e));return 1===t.length?t[0]:{compositeFilter:{op:pl(e.op),filters:t}}}(e):ds(54877,{filter:e})}function vl(e){const t=[];return e.fields.forEach(e=>t.push(e.canonicalString())),{fieldPaths:t}}function wl(e){return e.length>=4&&"projects"===e.get(0)&&"databases"===e.get(2)}class _l{constructor(e,t,n,r,i=Js.min(),s=Js.min(),o=Zo.EMPTY_BYTE_STRING,a=null){this.target=e,this.targetId=t,this.purpose=n,this.sequenceNumber=r,this.snapshotVersion=i,this.lastLimboFreeSnapshotVersion=s,this.resumeToken=o,this.expectedCount=a}withSequenceNumber(e){return new _l(this.target,this.targetId,this.purpose,e,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,this.expectedCount)}withResumeToken(e,t){return new _l(this.target,this.targetId,this.purpose,this.sequenceNumber,t,this.lastLimboFreeSnapshotVersion,e,null)}withExpectedCount(e){return new _l(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,this.lastLimboFreeSnapshotVersion,this.resumeToken,e)}withLastLimboFreeSnapshotVersion(e){return new _l(this.target,this.targetId,this.purpose,this.sequenceNumber,this.snapshotVersion,e,this.resumeToken,this.expectedCount)}}class bl{constructor(e){this.gt=e}}function El(e){const t=ll({parent:e.parent,structuredQuery:e.structuredQuery});return"LAST"===e.limitType?_c(t,t.limit,"L"):t}class Tl{constructor(){}bt(e,t){this.Dt(e,t),t.vt()}Dt(e,t){if("nullValue"in e)this.Ct(t,5);else if("booleanValue"in e)this.Ct(t,10),t.Ft(e.booleanValue?1:0);else if("integerValue"in e)this.Ct(t,15),t.Ft(na(e.integerValue));else if("doubleValue"in e){const n=na(e.doubleValue);isNaN(n)?this.Ct(t,13):(this.Ct(t,15),po(n)?t.Ft(0):t.Ft(n))}else if("timestampValue"in e){let n=e.timestampValue;this.Ct(t,20),"string"==typeof n&&(n=ta(n)),t.Mt(`${n.seconds||""}`),t.Ft(n.nanos||0)}else if("stringValue"in e)this.xt(e.stringValue,t),this.Ot(t);else if("bytesValue"in e)this.Ct(t,30),t.Nt(ra(e.bytesValue)),this.Ot(t);else if("referenceValue"in e)this.Bt(e.referenceValue,t);else if("geoPointValue"in e){const n=e.geoPointValue;this.Ct(t,45),t.Ft(n.latitude||0),t.Ft(n.longitude||0)}else"mapValue"in e?Ma(e)?this.Ct(t,Number.MAX_SAFE_INTEGER):Pa(e)?this.Lt(e.mapValue,t):(this.kt(e.mapValue,t),this.Ot(t)):"arrayValue"in e?(this.qt(e.arrayValue,t),this.Ot(t)):ds(19022,{Qt:e})}xt(e,t){this.Ct(t,25),this.$t(e,t)}$t(e,t){t.Mt(e)}kt(e,t){const n=e.fields||{};this.Ct(t,55);for(const e of Object.keys(n))this.xt(e,t),this.Dt(n[e],t)}Lt(e,t){var n,r;const i=e.fields||{};this.Ct(t,53);const s=va,o=(null===(r=null===(n=i[s].arrayValue)||void 0===n?void 0:n.values)||void 0===r?void 0:r.length)||0;
2this.Ct(t,15),t.Ft(na(o)),this.xt(s,t),this.Dt(i[s],t)}qt(e,t){const n=e.values||[];this.Ct(t,50);for(const e of n)this.Dt(e,t)}Bt(e,t){this.Ct(t,37),js.fromName(e).path.forEach(e=>{this.Ct(t,60),this.$t(e,t)})}Ct(e,t){e.Ft(t)}Ot(e){e.Ft(2)}}Tl.Ut=new Tl;class Il{constructor(){this.Dn=new Sl}addToCollectionParentIndex(e,t){return this.Dn.add(t),ao.resolve()}getCollectionParents(e,t){return ao.resolve(this.Dn.getEntries(t))}addFieldIndex(e,t){return ao.resolve()}deleteFieldIndex(e,t){return ao.resolve()}deleteAllFieldIndexes(e){return ao.resolve()}createTargetIndexes(e,t){return ao.resolve()}getDocumentsMatchingTarget(e,t){return ao.resolve(null)}getIndexType(e,t){return ao.resolve(0)}getFieldIndexes(e,t){return ao.resolve([])}getNextCollectionGroupToUpdate(e){return ao.resolve(null)}getMinOffset(e,t){return ao.resolve(no.min())}getMinOffsetFromCollectionGroup(e,t){return ao.resolve(no.min())}updateCollectionGroup(e,t,n){return ao.resolve()}updateIndexEntries(e,t){return ao.resolve()}}class Sl{constructor(){this.index={}}add(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t]||new Yo(Fs.comparator),i=!r.has(n);return this.index[t]=r.add(n),i}has(e){const t=e.lastSegment(),n=e.popLast(),r=this.index[t];return r&&r.has(n)}getEntries(e){return(this.index[e]||new Yo(Fs.comparator)).toArray()}}new Uint8Array(0);const Cl={didRun:!1,sequenceNumbersCollected:0,targetsRemoved:0,documentsRemoved:0},Al=41943040;class kl{static withCacheSize(e){return new kl(e,kl.DEFAULT_COLLECTION_PERCENTILE,kl.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT)}constructor(e,t,n){this.cacheSizeCollectionThreshold=e,this.percentileToCollect=t,this.maximumSequenceNumbersToCollect=n}}kl.DEFAULT_COLLECTION_PERCENTILE=10,kl.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT=1e3,kl.DEFAULT=new kl(Al,kl.DEFAULT_COLLECTION_PERCENTILE,kl.DEFAULT_MAX_SEQUENCE_NUMBERS_TO_COLLECT),kl.DISABLED=new kl(-1,0,0);class Nl{constructor(e){this._r=e}next(){return this._r+=2,this._r}static ar(){return new Nl(0)}static ur(){return new Nl(-1)}}const Ol="LruGarbageCollector",Dl=1048576;function Rl([e,t],[n,r]){const i=Os(e,n);return 0===i?Os(t,r):i}class Pl{constructor(e){this.Tr=e,this.buffer=new Yo(Rl),this.Ir=0}dr(){return++this.Ir}Er(e){const t=[e,this.dr()];if(this.buffer.size<this.Tr)this.buffer=this.buffer.add(t);else{const e=this.buffer.last();Rl(t,e)<0&&(this.buffer=this.buffer.delete(e).add(t))}}get maxValue(){return this.buffer.last()[0]}}class Ll{constructor(e,t,n){this.garbageCollector=e,this.asyncQueue=t,this.localStore=n,this.Ar=null}start(){-1!==this.garbageCollector.params.cacheSizeCollectionThreshold&&this.Rr(6e4)}stop(){this.Ar&&(this.Ar.cancel(),this.Ar=null)}get started(){return null!==this.Ar}Rr(e){cs(Ol,`Garbage collection scheduled in ${e}ms`),this.Ar=this.asyncQueue.enqueueAfterDelay("lru_garbage_collection",e,async()=>{this.Ar=null;try{await this.localStore.collectGarbage(this.garbageCollector)}catch(e){uo(e)?cs(Ol,"Ignoring IndexedDB error during garbage collection: ",e):await oo(e)}await this.Rr(3e5)})}}class Ml{constructor(e,t){this.Vr=e,this.params=t}calculateTargetCount(e,t){return this.Vr.mr(e).next(e=>Math.floor(t/100*e))}nthSequenceNumber(e,t){if(0===t)return ao.resolve(lo.ue);const n=new Pl(t);return this.Vr.forEachTarget(e,e=>n.Er(e.sequenceNumber)).next(()=>this.Vr.gr(e,e=>n.Er(e))).next(()=>n.maxValue)}removeTargets(e,t,n){return this.Vr.removeTargets(e,t,n)}removeOrphanedDocuments(e,t){return this.Vr.removeOrphanedDocuments(e,t)}collect(e,t){return-1===this.params.cacheSizeCollectionThreshold?(cs("LruGarbageCollector","Garbage collection skipped; disabled"),ao.resolve(Cl)):this.getCacheSize(e).next(n=>n<this.params.cacheSizeCollectionThreshold?(cs("LruGarbageCollector",`Garbage collection skipped; Cache size ${n} is lower than threshold ${this.params.cacheSizeCollectionThreshold}`),Cl):this.pr(e,t))}getCacheSize(e){return this.Vr.getCacheSize(e)}pr(e,t){let n,r,i,s,o,a,c;const u=Date.now();return this.calculateTargetCount(e,this.params.percentileToCollect).next(t=>(t>this.params.maximumSequenceNumbersToCollect?(cs("LruGarbageCollector",`Capping sequence numbers to collect down to the maximum of ${this.params.maximumSequenceNumbersToCollect} from ${t}`),r=this.params.maximumSequenceNumbersToCollect):r=t,s=Date.now(),this.nthSequenceNumber(e,r))).next(r=>(n=r,o=Date.now(),this.removeTargets(e,n,t))).next(t=>(i=t,a=Date.now(),this.removeOrphanedDocuments(e,n))).next(e=>(c=Date.now(),as()<=x.DEBUG&&cs("LruGarbageCollector",`LRU Garbage Collection\n\tCounted targets in ${s-u}ms\n\tDetermined least recently used ${r} in `+(o-s)+"ms\n"+`\tRemoved ${i} targets in `+(a-o)+"ms\n"+`\tRemoved ${e} documents in `+(c-a)+"ms\n"+`Total Duration: ${c-u}ms`),ao.resolve({didRun:!0,sequenceNumbersCollected:r,targetsRemoved:i,documentsRemoved:e})))}}function xl(e,t){return new Ml(e,t)}class Fl{constructor(){this.changes=new kc(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,Ua.newInvalidDocument(e).setReadTime(t))}getEntry(e,t){this.assertNotApplied();const n=this.changes.get(t);return void 0!==n?ao.resolve(n):this.getFromCache(e,t)}getEntries(e,t){return this.getAllFromCache(e,t)}apply(e){return this.assertNotApplied(),this.changesApplied=!0,this.applyChanges(e)}
2assertNotApplied(){}}class Ul{constructor(e,t){this.overlayedDocument=e,this.mutatedFields=t}}class Vl{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=>(null!==n&&uu(n.mutation,e,Jo.empty(),Qs.now()),e))}getDocuments(e,t){return this.remoteDocumentCache.getEntries(e,t).next(t=>this.getLocalViewOfDocuments(e,t,Vc()).next(()=>t))}getLocalViewOfDocuments(e,t,n=Vc()){const r=Lc();return this.populateOverlays(e,r,t).next(()=>this.computeViews(e,t,r,n).next(e=>{let t=Rc();return e.forEach((e,n)=>{t=t.insert(e,n.overlayedDocument)}),t}))}getOverlayedDocuments(e,t){const n=Lc();return this.populateOverlays(e,n,t).next(()=>this.computeViews(e,t,n,Vc()))}populateOverlays(e,t,n){const 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=Oc();const s=xc(),o=xc();return t.forEach((e,t)=>{const o=n.get(t.key);r.has(t.key)&&(void 0===o||o.mutation instanceof fu)?i=i.insert(t.key,t):void 0!==o?(s.set(t.key,o.mutation.getFieldMask()),uu(o.mutation,t,o.mutation.getFieldMask(),Qs.now())):s.set(t.key,Jo.empty())}),this.recalculateAndSaveOverlays(e,i).next(e=>(e.forEach((e,t)=>s.set(e,t)),t.forEach((e,t)=>{var n;return o.set(e,new Ul(t,null!==(n=s.get(e))&&void 0!==n?n:null))}),o))}recalculateAndSaveOverlays(e,t){const n=xc();let r=new Go((e,t)=>e-t),i=Vc();return this.mutationQueue.getAllMutationBatchesAffectingDocumentKeys(e,t).next(e=>{for(const i of e)i.keys().forEach(e=>{const s=t.get(e);if(null===s)return;let o=n.get(e)||Jo.empty();o=i.applyToLocalView(s,o),n.set(e,o);const a=(r.get(i.batchId)||Vc()).add(e);r=r.insert(i.batchId,a)})}).next(()=>{const s=[],o=r.getReverseIterator();for(;o.hasNext();){const r=o.getNext(),a=r.key,c=r.value,u=Mc();c.forEach(e=>{if(!i.has(e)){const r=au(t.get(e),n.get(e));null!==r&&u.set(e,r),i=i.add(e)}}),s.push(this.documentOverlayCache.saveOverlays(e,a,u))}return ao.waitFor(s)}).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 js.isDocumentKey(e.path)&&null===e.collectionGroup&&0===e.filters.length}(t)?this.getDocumentsMatchingDocumentQuery(e,t.path):gc(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=>{const s=r-i.size>0?this.documentOverlayCache.getOverlaysForCollectionGroup(e,t,n.largestBatchId,r-i.size):ao.resolve(Lc());let o=Xs,a=i;return s.next(t=>ao.forEach(t,(t,n)=>(o<n.largestBatchId&&(o=n.largestBatchId),i.get(t)?ao.resolve():this.remoteDocumentCache.getEntry(e,t).next(e=>{a=a.insert(t,e)}))).next(()=>this.populateOverlays(e,t,i)).next(()=>this.computeViews(e,a,t,Vc())).next(e=>({batchId:o,changes:Pc(e)})))})}getDocumentsMatchingDocumentQuery(e,t){return this.getDocument(e,new js(t)).next(e=>{let t=Rc();return e.isFoundDocument()&&(t=t.insert(e.key,e)),t})}getDocumentsMatchingCollectionGroupQuery(e,t,n,r){const i=t.collectionGroup;let s=Rc();return this.indexManager.getCollectionParents(e,i).next(o=>ao.forEach(o,o=>{const a=function(e,t){return new dc(t,null,e.explicitOrderBy.slice(),e.filters.slice(),e.limit,e.limitType,e.startAt,e.endAt)}(t,o.child(i));return this.getDocumentsMatchingCollectionQuery(e,a,n,r).next(e=>{e.forEach((e,t)=>{s=s.insert(e,t)})})}).next(()=>s))}getDocumentsMatchingCollectionQuery(e,t,n,r){let i;return this.documentOverlayCache.getOverlaysForCollection(e,t.path,n.largestBatchId).next(s=>(i=s,this.remoteDocumentCache.getDocumentsMatchingQuery(e,t,n,i,r))).next(e=>{i.forEach((t,n)=>{const r=n.getKey();null===e.get(r)&&(e=e.insert(r,Ua.newInvalidDocument(r)))});let n=Rc();return e.forEach((e,r)=>{const s=i.get(e);void 0!==s&&uu(s.mutation,r,Jo.empty(),Qs.now()),Ic(t,r)&&(n=n.insert(e,r))}),n})}}
2class jl{constructor(e){this.serializer=e,this.Br=new Map,this.Lr=new Map}getBundleMetadata(e,t){return ao.resolve(this.Br.get(t))}saveBundleMetadata(e,t){return this.Br.set(t.id,function(e){return{id:e.id,version:e.version,createTime:Qu(e.createTime)}}(t)),ao.resolve()}getNamedQuery(e,t){return ao.resolve(this.Lr.get(t))}saveNamedQuery(e,t){return this.Lr.set(t.name,function(e){return{name:e.name,query:El(e.bundledQuery),readTime:Qu(e.readTime)}}(t)),ao.resolve()}}class $l{constructor(){this.overlays=new Go(js.comparator),this.kr=new Map}getOverlay(e,t){return ao.resolve(this.overlays.get(t))}getOverlays(e,t){const n=Lc();return ao.forEach(t,t=>this.getOverlay(e,t).next(e=>{null!==e&&n.set(t,e)})).next(()=>n)}saveOverlays(e,t,n){return n.forEach((n,r)=>{this.wt(e,t,r)}),ao.resolve()}removeOverlaysForBatchId(e,t,n){const r=this.kr.get(n);return void 0!==r&&(r.forEach(e=>this.overlays=this.overlays.remove(e)),this.kr.delete(n)),ao.resolve()}getOverlaysForCollection(e,t,n){const r=Lc(),i=t.length+1,s=new js(t.child("")),o=this.overlays.getIteratorFrom(s);for(;o.hasNext();){const e=o.getNext().value,s=e.getKey();if(!t.isPrefixOf(s.path))break;s.path.length===i&&e.largestBatchId>n&&r.set(e.getKey(),e)}return ao.resolve(r)}getOverlaysForCollectionGroup(e,t,n,r){let i=new Go((e,t)=>e-t);const s=this.overlays.getIterator();for(;s.hasNext();){const e=s.getNext().value;if(e.getKey().getCollectionGroup()===t&&e.largestBatchId>n){let t=i.get(e.largestBatchId);null===t&&(t=Lc(),i=i.insert(e.largestBatchId,t)),t.set(e.getKey(),e)}}const o=Lc(),a=i.getIterator();for(;a.hasNext()&&(a.getNext().value.forEach((e,t)=>o.set(e,t)),!(o.size()>=r)););return ao.resolve(o)}wt(e,t,n){const r=this.overlays.get(n.key);if(null!==r){const e=this.kr.get(r.largestBatchId).delete(n.key);this.kr.set(r.largestBatchId,e)}this.overlays=this.overlays.insert(n.key,new bu(t,n));let i=this.kr.get(t);void 0===i&&(i=Vc(),this.kr.set(t,i)),this.kr.set(t,i.add(n.key))}}class Bl{constructor(){this.sessionToken=Zo.EMPTY_BYTE_STRING}getSessionToken(e){return ao.resolve(this.sessionToken)}setSessionToken(e,t){return this.sessionToken=t,ao.resolve()}}class ql{constructor(){this.qr=new Yo(zl.Qr),this.$r=new Yo(zl.Ur)}isEmpty(){return this.qr.isEmpty()}addReference(e,t){const n=new zl(e,t);this.qr=this.qr.add(n),this.$r=this.$r.add(n)}Kr(e,t){e.forEach(e=>this.addReference(e,t))}removeReference(e,t){this.Wr(new zl(e,t))}Gr(e,t){e.forEach(e=>this.removeReference(e,t))}zr(e){const t=new js(new Fs([])),n=new zl(t,e),r=new zl(t,e+1),i=[];return this.$r.forEachInRange([n,r],e=>{this.Wr(e),i.push(e.key)}),i}jr(){this.qr.forEach(e=>this.Wr(e))}Wr(e){this.qr=this.qr.delete(e),this.$r=this.$r.delete(e)}Jr(e){const t=new js(new Fs([])),n=new zl(t,e),r=new zl(t,e+1);let i=Vc();return this.$r.forEachInRange([n,r],e=>{i=i.add(e.key)}),i}containsKey(e){const t=new zl(e,0),n=this.qr.firstAfterOrEqual(t);return null!==n&&e.isEqual(n.key)}}class zl{constructor(e,t){this.key=e,this.Hr=t}static Qr(e,t){return js.comparator(e.key,t.key)||Os(e.Hr,t.Hr)}static Ur(e,t){return Os(e.Hr,t.Hr)||js.comparator(e.key,t.key)}}class Hl{constructor(e,t){this.indexManager=e,this.referenceDelegate=t,this.mutationQueue=[],this.er=1,this.Yr=new Yo(zl.Qr)}checkEmpty(e){return ao.resolve(0===this.mutationQueue.length)}addMutationBatch(e,t,n,r){const i=this.er;this.er++,this.mutationQueue.length>0&&this.mutationQueue[this.mutationQueue.length-1];const s=new wu(i,t,n,r);this.mutationQueue.push(s);for(const t of r)this.Yr=this.Yr.add(new zl(t.key,i)),this.indexManager.addToCollectionParentIndex(e,t.key.path.popLast());return ao.resolve(s)}lookupMutationBatch(e,t){return ao.resolve(this.Zr(t))}getNextMutationBatchAfterBatchId(e,t){const n=t+1,r=this.Xr(n),i=r<0?0:r;return ao.resolve(this.mutationQueue.length>i?this.mutationQueue[i]:null)}getHighestUnacknowledgedBatchId(){return ao.resolve(0===this.mutationQueue.length?ho:this.er-1)}getAllMutationBatches(e){return ao.resolve(this.mutationQueue.slice())}getAllMutationBatchesAffectingDocumentKey(e,t){const n=new zl(t,0),r=new zl(t,Number.POSITIVE_INFINITY),i=[];return this.Yr.forEachInRange([n,r],e=>{const t=this.Zr(e.Hr);i.push(t)}),ao.resolve(i)}getAllMutationBatchesAffectingDocumentKeys(e,t){let n=new Yo(Os);
2return t.forEach(e=>{const t=new zl(e,0),r=new zl(e,Number.POSITIVE_INFINITY);this.Yr.forEachInRange([t,r],e=>{n=n.add(e.Hr)})}),ao.resolve(this.ei(n))}getAllMutationBatchesAffectingQuery(e,t){const n=t.path,r=n.length+1;let i=n;js.isDocumentKey(i)||(i=i.child(""));const s=new zl(new js(i),0);let o=new Yo(Os);return this.Yr.forEachWhile(e=>{const t=e.key.path;return!!n.isPrefixOf(t)&&(t.length===r&&(o=o.add(e.Hr)),!0)},s),ao.resolve(this.ei(o))}ei(e){const t=[];return e.forEach(e=>{const n=this.Zr(e);null!==n&&t.push(n)}),t}removeMutationBatch(e,t){ps(0===this.ti(t.batchId,"removed"),55003),this.mutationQueue.shift();let n=this.Yr;return ao.forEach(t.mutations,r=>{const i=new zl(r.key,t.batchId);return n=n.delete(i),this.referenceDelegate.markPotentiallyOrphaned(e,r.key)}).next(()=>{this.Yr=n})}rr(e){}containsKey(e,t){const n=new zl(t,0),r=this.Yr.firstAfterOrEqual(n);return ao.resolve(t.isEqual(r&&r.key))}performConsistencyCheck(e){return this.mutationQueue.length,ao.resolve()}ti(e,t){return this.Xr(e)}Xr(e){return 0===this.mutationQueue.length?0:e-this.mutationQueue[0].batchId}Zr(e){const t=this.Xr(e);return t<0||t>=this.mutationQueue.length?null:this.mutationQueue[t]}}class Gl{constructor(e){this.ni=e,this.docs=new Go(js.comparator),this.size=0}setIndexManager(e){this.indexManager=e}addEntry(e,t){const n=t.key,r=this.docs.get(n),i=r?r.size:0,s=this.ni(t);return this.docs=this.docs.insert(n,{document:t.mutableCopy(),size:s}),this.size+=s-i,this.indexManager.addToCollectionParentIndex(e,n.path.popLast())}removeEntry(e){const t=this.docs.get(e);t&&(this.docs=this.docs.remove(e),this.size-=t.size)}getEntry(e,t){const n=this.docs.get(t);return ao.resolve(n?n.document.mutableCopy():Ua.newInvalidDocument(t))}getEntries(e,t){let n=Oc();return t.forEach(e=>{const t=this.docs.get(e);n=n.insert(e,t?t.document.mutableCopy():Ua.newInvalidDocument(e))}),ao.resolve(n)}getDocumentsMatchingQuery(e,t,n,r){let i=Oc();const s=t.path,o=new js(s.child("__id-9223372036854775808__")),a=this.docs.getIteratorFrom(o);for(;a.hasNext();){const{key:e,value:{document:o}}=a.getNext();if(!s.isPrefixOf(e.path))break;e.path.length>s.length+1||ro(to(o),n)<=0||(r.has(o.key)||Ic(t,o))&&(i=i.insert(o.key,o.mutableCopy()))}return ao.resolve(i)}getAllFromCollectionGroup(e,t,n,r){ds(9500)}ri(e,t){return ao.forEach(this.docs,e=>t(e))}newChangeBuffer(e){return new Kl(this)}getSize(e){return ao.resolve(this.size)}}class Kl extends Fl{constructor(e){super(),this.Or=e}applyChanges(e){const t=[];
2return this.changes.forEach((n,r)=>{r.isValidDocument()?t.push(this.Or.addEntry(e,r)):this.Or.removeEntry(n)}),ao.waitFor(t)}getFromCache(e,t){return this.Or.getEntry(e,t)}getAllFromCache(e,t){return this.Or.getEntries(e,t)}}class Wl{constructor(e){this.persistence=e,this.ii=new kc(e=>uc(e),lc),this.lastRemoteSnapshotVersion=Js.min(),this.highestTargetId=0,this.si=0,this.oi=new ql,this.targetCount=0,this._i=Nl.ar()}forEachTarget(e,t){return this.ii.forEach((e,n)=>t(n)),ao.resolve()}getLastRemoteSnapshotVersion(e){return ao.resolve(this.lastRemoteSnapshotVersion)}getHighestSequenceNumber(e){return ao.resolve(this.si)}allocateTargetId(e){return this.highestTargetId=this._i.next(),ao.resolve(this.highestTargetId)}setTargetsMetadata(e,t,n){return n&&(this.lastRemoteSnapshotVersion=n),t>this.si&&(this.si=t),ao.resolve()}hr(e){this.ii.set(e.target,e);const t=e.targetId;t>this.highestTargetId&&(this._i=new Nl(t),this.highestTargetId=t),e.sequenceNumber>this.si&&(this.si=e.sequenceNumber)}addTargetData(e,t){return this.hr(t),this.targetCount+=1,ao.resolve()}updateTargetData(e,t){return this.hr(t),ao.resolve()}removeTargetData(e,t){return this.ii.delete(t.target),this.oi.zr(t.targetId),this.targetCount-=1,ao.resolve()}removeTargets(e,t,n){let r=0;const i=[];return this.ii.forEach((s,o)=>{o.sequenceNumber<=t&&null===n.get(o.targetId)&&(this.ii.delete(s),i.push(this.removeMatchingKeysForTargetId(e,o.targetId)),r++)}),ao.waitFor(i).next(()=>r)}getTargetCount(e){return ao.resolve(this.targetCount)}getTargetData(e,t){const n=this.ii.get(t)||null;return ao.resolve(n)}addMatchingKeys(e,t,n){return this.oi.Kr(t,n),ao.resolve()}removeMatchingKeys(e,t,n){this.oi.Gr(t,n);const r=this.persistence.referenceDelegate,i=[];return r&&t.forEach(t=>{i.push(r.markPotentiallyOrphaned(e,t))}),ao.waitFor(i)}removeMatchingKeysForTargetId(e,t){return this.oi.zr(t),ao.resolve()}getMatchingKeysForTargetId(e,t){const n=this.oi.Jr(t);return ao.resolve(n)}containsKey(e,t){return ao.resolve(this.oi.containsKey(t))}}class Yl{constructor(e,t){this.ai={},this.overlays={},this.ui=new lo(0),this.ci=!1,this.ci=!0,this.li=new Bl,this.referenceDelegate=e(this),this.hi=new Wl(this),this.indexManager=new Il,this.remoteDocumentCache=function(e){return new Gl(e)}(e=>this.referenceDelegate.Pi(e)),this.serializer=new bl(t),this.Ti=new jl(this.serializer)}start(){return Promise.resolve()}shutdown(){return this.ci=!1,Promise.resolve()}get started(){return this.ci}setDatabaseDeletedListener(){}setNetworkEnabled(){}getIndexManager(e){return this.indexManager}getDocumentOverlayCache(e){let t=this.overlays[e.toKey()];return t||(t=new $l,this.overlays[e.toKey()]=t),t}getMutationQueue(e,t){let n=this.ai[e.toKey()];return n||(n=new Hl(t,this.referenceDelegate),this.ai[e.toKey()]=n),n}getGlobalsCache(){return this.li}getTargetCache(){return this.hi}getRemoteDocumentCache(){return this.remoteDocumentCache}getBundleCache(){return this.Ti}runTransaction(e,t,n){cs("MemoryPersistence","Starting transaction:",e);const r=new Ql(this.ui.next());return this.referenceDelegate.Ii(),n(r).next(e=>this.referenceDelegate.di(r).next(()=>e)).toPromise().then(e=>(r.raiseOnCommittedEvent(),e))}Ei(e,t){return ao.or(Object.values(this.ai).map(n=>()=>n.containsKey(e,t)))}}class Ql extends so{constructor(e){super(),this.currentSequenceNumber=e}}class Jl{constructor(e){this.persistence=e,this.Ai=new ql,this.Ri=null}static Vi(e){return new Jl(e)}get mi(){if(this.Ri)return this.Ri;throw ds(60996)}addReference(e,t,n){return this.Ai.addReference(n,t),this.mi.delete(n.toString()),ao.resolve()}removeReference(e,t,n){return this.Ai.removeReference(n,t),this.mi.add(n.toString()),ao.resolve()}markPotentiallyOrphaned(e,t){return this.mi.add(t.toString()),ao.resolve()}removeTarget(e,t){this.Ai.zr(t.targetId).forEach(e=>this.mi.add(e.toString()));const n=this.persistence.getTargetCache();return n.getMatchingKeysForTargetId(e,t.targetId).next(e=>{e.forEach(e=>this.mi.add(e.toString()))}).next(()=>n.removeTargetData(e,t))}Ii(){this.Ri=new Set}di(e){const t=this.persistence.getRemoteDocumentCache().newChangeBuffer();
2return ao.forEach(this.mi,n=>{const r=js.fromPath(n);return this.fi(e,r).next(e=>{e||t.removeEntry(r,Js.min())})}).next(()=>(this.Ri=null,t.apply(e)))}updateLimboDocument(e,t){return this.fi(e,t).next(e=>{e?this.mi.delete(t.toString()):this.mi.add(t.toString())})}Pi(e){return 0}fi(e,t){return ao.or([()=>ao.resolve(this.Ai.containsKey(t)),()=>this.persistence.getTargetCache().containsKey(e,t),()=>this.persistence.Ei(e,t)])}}class Xl{constructor(e,t){this.persistence=e,this.gi=new kc(e=>yo(e.path),(e,t)=>e.isEqual(t)),this.garbageCollector=xl(this,t)}static Vi(e,t){return new Xl(e,t)}Ii(){}di(e){return ao.resolve()}forEachTarget(e,t){return this.persistence.getTargetCache().forEachTarget(e,t)}mr(e){const t=this.yr(e);return this.persistence.getTargetCache().getTargetCount(e).next(e=>t.next(t=>e+t))}yr(e){let t=0;return this.gr(e,e=>{t++}).next(()=>t)}gr(e,t){return ao.forEach(this.gi,(n,r)=>this.Sr(e,n,r).next(e=>e?ao.resolve():t(r)))}removeTargets(e,t,n){return this.persistence.getTargetCache().removeTargets(e,t,n)}removeOrphanedDocuments(e,t){let n=0;const r=this.persistence.getRemoteDocumentCache(),i=r.newChangeBuffer();return r.ri(e,r=>this.Sr(e,r,t).next(e=>{e||(n++,i.removeEntry(r,Js.min()))})).next(()=>i.apply(e)).next(()=>n)}markPotentiallyOrphaned(e,t){return this.gi.set(t,e.currentSequenceNumber),ao.resolve()}removeTarget(e,t){const n=t.withSequenceNumber(e.currentSequenceNumber);return this.persistence.getTargetCache().updateTargetData(e,n)}addReference(e,t,n){return this.gi.set(n,e.currentSequenceNumber),ao.resolve()}removeReference(e,t,n){return this.gi.set(n,e.currentSequenceNumber),ao.resolve()}updateLimboDocument(e,t){return this.gi.set(t,e.currentSequenceNumber),ao.resolve()}Pi(e){let t=e.key.toString().length;return e.isFoundDocument()&&(t+=Aa(e.data.value)),t}Sr(e,t,n){return ao.or([()=>this.persistence.Ei(e,t),()=>this.persistence.getTargetCache().containsKey(e,t),()=>{const e=this.gi.get(t);return ao.resolve(void 0!==e&&e>n)}])}getCacheSize(e){return this.persistence.getRemoteDocumentCache().getSize(e)}}class Zl{constructor(e,t,n,r){this.targetId=e,this.fromCache=t,this.Is=n,this.ds=r}static Es(e,t){let n=Vc(),r=Vc();for(const e of t.docChanges)switch(e.type){case 0:n=n.add(e.doc.key);break;case 1:r=r.add(e.doc.key)}return new Zl(e,t.fromCache,n,r)}}class eh{constructor(){this._documentReadCount=0}get documentReadCount(){return this._documentReadCount}incrementDocumentReadCount(e){this._documentReadCount+=e}}class th{constructor(){this.As=!1,this.Rs=!1,this.Vs=100,this.fs=v()?8:co(g())>0?6:4}initialize(e,t){this.gs=e,this.indexManager=t,this.As=!0}getDocumentsMatchingQuery(e,t,n,r){const i={result:null};return this.ps(e,t).next(e=>{i.result=e}).next(()=>{if(!i.result)return this.ys(e,t,r,n).next(e=>{i.result=e})}).next(()=>{if(i.result)return;const n=new eh;return this.ws(e,t,n).next(r=>{if(i.result=r,this.Rs)return this.Ss(e,t,n,r.size)})}).next(()=>i.result)}Ss(e,t,n,r){return n.documentReadCount<this.Vs?(as()<=x.DEBUG&&cs("QueryEngine","SDK will not create cache indexes for query:",Tc(t),"since it only creates cache indexes for collection contains","more than or equal to",this.Vs,"documents"),ao.resolve()):(as()<=x.DEBUG&&cs("QueryEngine","Query:",Tc(t),"scans",n.documentReadCount,"local documents and returns",r,"documents as results."),n.documentReadCount>this.fs*r?(as()<=x.DEBUG&&cs("QueryEngine","The SDK decides to create cache indexes for query:",Tc(t),"as using cache indexes may help improve performance."),this.indexManager.createTargetIndexes(e,vc(t))):ao.resolve())}ps(e,t){if(mc(t))return ao.resolve(null);let n=vc(t);return this.indexManager.getIndexType(e,n).next(r=>0===r?null:(null!==t.limit&&1===r&&(t=_c(t,null,"F"),n=vc(t)),this.indexManager.getDocumentsMatchingTarget(e,n).next(r=>{const i=Vc(...r);return this.gs.getDocuments(e,i).next(r=>this.indexManager.getMinOffset(e,n).next(n=>{const s=this.bs(t,r);return this.Ds(t,s,i,n.readTime)?this.ps(e,_c(t,null,"F")):this.vs(e,s,t,n)}))})))}ys(e,t,n,r){return mc(t)||r.isEqual(Js.min())?ao.resolve(null):this.gs.getDocuments(e,n).next(i=>{const s=this.bs(t,i);return this.Ds(t,s,n,r)?ao.resolve(null):(as()<=x.DEBUG&&cs("QueryEngine","Re-using previous result from %s to execute query: %s",r.toString(),Tc(t)),this.vs(e,s,t,eo(r,Xs)).next(e=>e))})}bs(e,t){let n=new Yo(Cc(e));return t.forEach((t,r)=>{Ic(e,r)&&(n=n.add(r))}),n}Ds(e,t,n,r){if(null===e.limit)return!1;if(n.size!==t.size)return!0;const i="F"===e.limitType?t.last():t.first();return!!i&&(i.hasPendingWrites||i.version.compareTo(r)>0)}ws(e,t,n){return as()<=x.DEBUG&&cs("QueryEngine","Using full collection scan to execute query:",Tc(t)),this.gs.getDocumentsMatchingQuery(e,t,no.min(),n)}vs(e,t,n,r){return this.gs.getDocumentsMatchingQuery(e,n,r).next(e=>(t.forEach(t=>{e=e.insert(t.key,t)}),e))}}const nh="LocalStore";class rh{constructor(e,t,n,r){this.persistence=e,this.Cs=t,this.serializer
2=r,this.Fs=new Go(Os),this.Ms=new kc(e=>uc(e),lc),this.xs=new Map,this.Os=e.getRemoteDocumentCache(),this.hi=e.getTargetCache(),this.Ti=e.getBundleCache(),this.Ns(n)}Ns(e){this.documentOverlayCache=this.persistence.getDocumentOverlayCache(e),this.indexManager=this.persistence.getIndexManager(e),this.mutationQueue=this.persistence.getMutationQueue(e,this.indexManager),this.localDocuments=new Vl(this.Os,this.mutationQueue,this.documentOverlayCache,this.indexManager),this.Os.setIndexManager(this.indexManager),this.Cs.initialize(this.localDocuments,this.indexManager)}collectGarbage(e){return this.persistence.runTransaction("Collect garbage","readwrite-primary",t=>e.collect(t,this.Fs))}}function ih(e,t,n,r){return new rh(e,t,n,r)}async function sh(e,t){const n=ms(e);return await n.persistence.runTransaction("Handle user change","readonly",e=>{let r;return n.mutationQueue.getAllMutationBatches(e).next(i=>(r=i,n.Ns(t),n.mutationQueue.getAllMutationBatches(e))).next(t=>{const i=[],s=[];let o=Vc();for(const e of r){i.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}for(const e of t){s.push(e.batchId);for(const t of e.mutations)o=o.add(t.key)}return n.localDocuments.getDocuments(e,o).next(e=>({Bs:e,removedBatchIds:i,addedBatchIds:s}))})})}function oh(e){const t=ms(e);return t.persistence.runTransaction("Get last remote snapshot version","readonly",e=>t.hi.getLastRemoteSnapshotVersion(e))}function ah(e,t,n){let r=Vc(),i=Vc();return n.forEach(e=>r=r.add(e)),t.getEntries(e,r).next(e=>{let r=Oc();return n.forEach((n,s)=>{const o=e.get(n);s.isFoundDocument()!==o.isFoundDocument()&&(i=i.add(n)),s.isNoDocument()&&s.version.isEqual(Js.min())?(t.removeEntry(n,s.readTime),r=r.insert(n,s)):!o.isValidDocument()||s.version.compareTo(o.version)>0||0===s.version.compareTo(o.version)&&o.hasPendingWrites?(t.addEntry(s),r=r.insert(n,s)):cs(nh,"Ignoring outdated watch update for ",n,". Current version:",o.version," Watch version:",s.version)}),{Ls:r,ks:i}})}function ch(e,t){const n=ms(e);return n.persistence.runTransaction("Get next mutation batch","readonly",e=>(void 0===t&&(t=ho),n.mutationQueue.getNextMutationBatchAfterBatchId(e,t)))}function uh(e,t){const n=ms(e);return n.persistence.runTransaction("Allocate target","readwrite",e=>{let r;return n.hi.getTargetData(e,t).next(i=>i?(r=i,ao.resolve(r)):n.hi.allocateTargetId(e).next(i=>(r=new _l(t,i,"TargetPurposeListen",e.currentSequenceNumber),n.hi.addTargetData(e,r).next(()=>r))))}).then(e=>{const r=n.Fs.get(e.targetId);return(null===r||e.snapshotVersion.compareTo(r.snapshotVersion)>0)&&(n.Fs=n.Fs.insert(e.targetId,e),n.Ms.set(t,e.targetId)),e})}async function lh(e,t,n){const r=ms(e),i=r.Fs.get(t),s=n?"readwrite":"readwrite-primary";try{n||await r.persistence.runTransaction("Release target",s,e=>r.persistence.referenceDelegate.removeTarget(e,i))}catch(e){if(!uo(e))throw e;cs(nh,`Failed to update sequence numbers for target ${t}: ${e}`)}r.Fs=r.Fs.remove(t),r.Ms.delete(i.target)}function hh(e,t,n){const r=ms(e);let i=Js.min(),s=Vc();return r.persistence.runTransaction("Execute query","readwrite",e=>function(e,t,n){const r=ms(e),i=r.Ms.get(n);return void 0!==i?ao.resolve(r.Fs.get(i)):r.hi.getTargetData(t,n)}(r,e,vc(t)).next(t=>{if(t)return i=t.lastLimboFreeSnapshotVersion,r.hi.getMatchingKeysForTargetId(e,t.targetId).next(e=>{s=e})}).next(()=>r.Cs.getDocumentsMatchingQuery(e,t,n?i:Js.min(),n?s:Vc())).next(e=>(dh(r,Sc(t),e),{documents:e,qs:s})))}function dh(e,t,n){let r=e.xs.get(t)||Js.min();n.forEach((e,t)=>{t.readTime.compareTo(r)>0&&(r=t.readTime)}),e.xs.set(t,r)}class fh{constructor(){this.activeTargetIds=$c()}Gs(e){this.activeTargetIds=this.activeTargetIds.add(e)}zs(e){this.activeTargetIds=this.activeTargetIds.delete(e)}Ws(){const e={activeTargetIds:this.activeTargetIds.toArray(),updateTimeMs:Date.now()};return JSON.stringify(e)}}class ph{constructor(){this.Fo=new fh,this.Mo={},this.onlineStateHandler=null,this.sequenceNumberHandler=null}addPendingMutation(e){}updateMutationState(e,t,n){}addLocalQueryTarget(e,t=!0){return t&&this.Fo.Gs(e),this.Mo[e]||"not-current"}updateQueryState(e,t,n){this.Mo[e]=t}removeLocalQueryTarget(e){this.Fo.zs(e)}isLocalQueryTarget(e){return this.Fo.activeTargetIds.has(e)}clearQueryState(e){delete this.Mo[e]}getAllActiveQueryTargets(){return this.Fo.activeTargetIds}isActiveQueryTarget(e){return this.Fo.activeTargetIds.has(e)}start(){return this.Fo=new fh,Promise.resolve()}handleUserChange(e,t,n){}setOnlineState(e){}shutdown(){}writeSequenceNumber(e){}notifyBundleLoaded(e){}}class mh{xo(e){}shutdown(){}}const gh="ConnectivityMonitor";class yh{constructor(){this.Oo=()=>this.No(),this.Bo=()=>this.Lo(),this.ko=[],this.qo()}xo(e){this.ko.push(e)}shutdown(){window.removeEventListener("online",this.Oo),window.removeEventListener("offline",this.Bo)}qo(){window.addEventListener("online",this.Oo),window.addEventListener("offline",this.Bo)}No(){cs(gh,"Network connectivity changed: AVAILABLE");for(const e of this.ko)e(0)}Lo(){cs(gh,"Network connectivity changed: UNAVAILABLE");for(const e of this.ko)e(1)}static C(){return"undefined"!=typeof window&&void 0!==window.addEventListener&&void 0!==window.removeEventListener}}let vh=null;function wh(){return null===vh?vh=268435456+Math.round(2147483648*Math.random()):vh++,"0x"+vh.toString(16)}const _h="RestConnection",bh={BatchGetDocuments:"batchGet",Commit:"commit",RunQuery:"runQuery",RunAggregation
2Query:"runAggregationQuery"};class Eh{get Qo(){return!1}constructor(e){this.databaseInfo=e,this.databaseId=e.databaseId;const t=e.ssl?"https":"http",n=encodeURIComponent(this.databaseId.projectId),r=encodeURIComponent(this.databaseId.database);this.$o=t+"://"+e.host,this.Uo=`projects/${n}/databases/${r}`,this.Ko=this.databaseId.database===da?`project_id=${n}`:`project_id=${n}&database_id=${r}`}Wo(e,t,n,r,i){const s=wh(),o=this.Go(e,t.toUriEncodedString());cs(_h,`Sending RPC '${e}' ${s}:`,o,n);const a={"google-cloud-resource-prefix":this.Uo,"x-goog-request-params":this.Ko};this.zo(a,r,i);const{host:c}=new URL(o),u=h(c);return this.jo(e,o,a,n,u).then(t=>(cs(_h,`Received RPC '${e}' ${s}: `,t),t),t=>{throw ls(_h,`RPC '${e}' ${s} failed with error: `,t,"url: ",o,"request:",n),t})}Jo(e,t,n,r,i,s){return this.Wo(e,t,n,r,i)}zo(e,t,n){e["X-Goog-Api-Client"]="gl-js/ fire/"+ss,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)}Go(e,t){const n=bh[e];return`${this.$o}/v1/${t}:${n}`}terminate(){}}class Th{constructor(e){this.Ho=e.Ho,this.Yo=e.Yo}Zo(e){this.Xo=e}e_(e){this.t_=e}n_(e){this.r_=e}onMessage(e){this.i_=e}close(){this.Yo()}send(e){this.Ho(e)}s_(){this.Xo()}o_(){this.t_()}__(e){this.r_(e)}a_(e){this.i_(e)}}const Ih="WebChannelConnection";class Sh extends Eh{constructor(e){super(e),this.u_=[],this.forceLongPolling=e.forceLongPolling,this.autoDetectLongPolling=e.autoDetectLongPolling,this.useFetchStreams=e.useFetchStreams,this.longPollingOptions=e.longPollingOptions}jo(e,t,n,r,i){const s=wh();return new Promise((i,o)=>{const a=new Gi;a.setWithCredentials(!0),a.listenOnce(Wi.COMPLETE,()=>{try{switch(a.getLastErrorCode()){case Yi.NO_ERROR:const t=a.getResponseJson();cs(Ih,`XHR for RPC '${e}' ${s} received:`,JSON.stringify(t)),i(t);break;case Yi.TIMEOUT:cs(Ih,`RPC '${e}' ${s} timed out`),o(new ys(gs.DEADLINE_EXCEEDED,"Request time out"));break;case Yi.HTTP_ERROR:const n=a.getStatus();if(cs(Ih,`RPC '${e}' ${s} failed with status:`,n,"response text:",a.getResponseText()),n>0){let e=a.getResponseJson();Array.isArray(e)&&(e=e[0]);const t=null==e?void 0:e.error;if(t&&t.status&&t.message){const e=function(e){const t=e.toLowerCase().replace(/_/g,"-");return Object.values(gs).indexOf(t)>=0?t:gs.UNKNOWN}(t.status);o(new ys(e,t.message))}else o(new ys(gs.UNKNOWN,"Server responded with status "+a.getStatus()))}else o(new ys(gs.UNAVAILABLE,"Connection failed."));break;default:ds(9055,{c_:e,streamId:s,l_:a.getLastErrorCode(),h_:a.getLastError()})}}finally{cs(Ih,`RPC '${e}' ${s} completed.`)}});const c=JSON.stringify(r);cs(Ih,`RPC '${e}' ${s} sending request:`,r),a.send(t,"POST",c,n,15)})}P_(e,t,n){const r=wh(),i=[this.$o,"/","google.firestore.v1.Firestore","/",e,"/channel"],s=Zi(),o=Xi(),a={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;void 0!==c&&(a.longPollingTimeout=Math.round(1e3*c)),this.useFetchStreams&&(a.useFetchStreams=!0),this.zo(a.initMessageHeaders,t,n),a.encodeInitMessageHeaders=!0;const u=i.join("");cs(Ih,`Creating RPC '${e}' stream ${r}: ${u}`,a);const l=s.createWebChannel(u,a);this.T_(l);let h=!1,d=!1;const f=new Th({Ho:t=>{d?cs(Ih,`Not sending because RPC '${e}' stream ${r} is closed:`,t):(h||(cs(Ih,`Opening RPC '${e}' stream ${r} transport.`),l.open(),h=!0),cs(Ih,`RPC '${e}' stream ${r} sending:`,t),l.send(t))},Yo:()=>l.close()}),p=(e,t,n)=>{e.listen(t,e=>{try{n(e)}catch(e){setTimeout(()=>{throw e},0)}})};return p(l,Ki.EventType.OPEN,()=>{d||(cs(Ih,`RPC '${e}' stream ${r} transport opened.`),f.s_())}),p(l,Ki.EventType.CLOSE,()=>{d||(d=!0,cs(Ih,`RPC '${e}' stream ${r} transport closed`),f.__(),this.I_(l))}),p(l,Ki.EventType.ERROR,t=>{d||(d=!0,ls(Ih,`RPC '${e}' stream ${r} transport errored. Name:`,t.name,"Message:",t.message),f.__(new ys(gs.UNAVAILABLE,"The operation could not be completed")))}),p(l,Ki.EventType.MESSAGE,t=>{var n;if(!d){const i=t.data[0];ps(!!i,16349);const s=i,o=(null==s?void 0:s.error)||(null===(n=s[0])||void 0===n?void 0:n.error);if(o){cs(Ih,`RPC '${e}' stream ${r} received error:`,o);const t=o.status;let n=function(e){const t=Tu[e];if(void 0!==t)return Cu(t)}(t),i=o.message;void 0===n&&(n=gs.INTERNAL,i="Unknown error status: "+t+" with message "+o.message),d=!0,f.__(new ys(n,i)),l.close()}else cs(Ih,`RPC '${e}' stream ${r} received:`,i),f.a_(i)}}),p(o,Ji.STAT_EVENT,t=>{t.stat===Qi.PROXY?cs(Ih,`RPC '${e}' stream ${r} detected buffering proxy`):t.stat===Qi.NOPROXY&&cs(Ih,`RPC '${e}' stream ${r} detected no buffering proxy`)}),setTimeout(()=>{f.o_()},0),f}
2terminate(){this.u_.forEach(e=>e.close()),this.u_=[]}T_(e){this.u_.push(e)}I_(e){this.u_=this.u_.filter(t=>t===e)}}function Ch(){return"undefined"!=typeof document?document:null}function Ah(e){return new Hu(e,!0)}class kh{constructor(e,t,n=1e3,r=1.5,i=6e4){this.Fi=e,this.timerId=t,this.d_=n,this.E_=r,this.A_=i,this.R_=0,this.V_=null,this.m_=Date.now(),this.reset()}reset(){this.R_=0}f_(){this.R_=this.A_}g_(e){this.cancel();const t=Math.floor(this.R_+this.p_()),n=Math.max(0,Date.now()-this.m_),r=Math.max(0,t-n);r>0&&cs("ExponentialBackoff",`Backing off for ${r} ms (base delay: ${this.R_} ms, delay with jitter: ${t} ms, last attempt: ${n} ms ago)`),this.V_=this.Fi.enqueueAfterDelay(this.timerId,r,()=>(this.m_=Date.now(),e())),this.R_*=this.E_,this.R_<this.d_&&(this.R_=this.d_),this.R_>this.A_&&(this.R_=this.A_)}y_(){null!==this.V_&&(this.V_.skipDelay(),this.V_=null)}cancel(){null!==this.V_&&(this.V_.cancel(),this.V_=null)}p_(){return(Math.random()-.5)*this.R_}}const Nh="PersistentStream";class Oh{constructor(e,t,n,r,i,s,o,a){this.Fi=e,this.w_=n,this.S_=r,this.connection=i,this.authCredentialsProvider=s,this.appCheckCredentialsProvider=o,this.listener=a,this.state=0,this.b_=0,this.D_=null,this.v_=null,this.stream=null,this.C_=0,this.F_=new kh(e,t)}M_(){return 1===this.state||5===this.state||this.x_()}x_(){return 2===this.state||3===this.state}start(){this.C_=0,4!==this.state?this.auth():this.O_()}async stop(){this.M_()&&await this.close(0)}N_(){this.state=0,this.F_.reset()}B_(){this.x_()&&null===this.D_&&(this.D_=this.Fi.enqueueAfterDelay(this.w_,6e4,()=>this.L_()))}k_(e){this.q_(),this.stream.send(e)}async L_(){if(this.x_())return this.close(0)}q_(){this.D_&&(this.D_.cancel(),this.D_=null)}Q_(){this.v_&&(this.v_.cancel(),this.v_=null)}async close(e,t){this.q_(),this.Q_(),this.F_.cancel(),this.b_++,4!==e?this.F_.reset():t&&t.code===gs.RESOURCE_EXHAUSTED?(us(t.toString()),us("Using maximum backoff delay to prevent overloading the backend."),this.F_.f_()):t&&t.code===gs.UNAUTHENTICATED&&3!==this.state&&(this.authCredentialsProvider.invalidateToken(),this.appCheckCredentialsProvider.invalidateToken()),null!==this.stream&&(this.U_(),this.stream.close(),this.stream=null),this.state=e,await this.listener.n_(t)}U_(){}auth(){this.state=1;const e=this.K_(this.b_),t=this.b_;Promise.all([this.authCredentialsProvider.getToken(),this.appCheckCredentialsProvider.getToken()]).then(([e,n])=>{this.b_===t&&this.W_(e,n)},t=>{e(()=>{const e=new ys(gs.UNKNOWN,"Fetching auth token failed: "+t.message);return this.G_(e)})})}W_(e,t){const n=this.K_(this.b_);this.stream=this.z_(e,t),this.stream.Zo(()=>{n(()=>this.listener.Zo())}),this.stream.e_(()=>{n(()=>(this.state=2,this.v_=this.Fi.enqueueAfterDelay(this.S_,1e4,()=>(this.x_()&&(this.state=3),Promise.resolve())),this.listener.e_()))}),this.stream.n_(e=>{n(()=>this.G_(e))}),this.stream.onMessage(e=>{n(()=>1==++this.C_?this.j_(e):this.onNext(e))})}O_(){this.state=5,this.F_.g_(async()=>{this.state=0,this.start()})}G_(e){return cs(Nh,`close with error: ${e}`),this.stream=null,this.close(4,e)}K_(e){return t=>{this.Fi.enqueueAndForget(()=>this.b_===e?t():(cs(Nh,"stream callback skipped by getCloseGuardedDispatcher."),Promise.resolve()))}}}class Dh extends Oh{constructor(e,t,n,r,i,s){super(e,"listen_stream_connection_backoff","listen_stream_idle","health_check_timeout",t,n,r,s),this.serializer=i}z_(e,t){return this.connection.P_("Listen",e,t)}j_(e){return this.onNext(e)}onNext(e){this.F_.reset();const t=function(e,t){let n;if("targetChange"in t){t.targetChange;const r=function(e){return"NO_CHANGE"===e?0:"ADD"===e?1:"REMOVE"===e?2:"CURRENT"===e?3:"RESET"===e?4:ds(39313,{state:e})}(t.targetChange.targetChangeType||"NO_CHANGE"),i=t.targetChange.targetIds||[],s=function(e,t){return e.useProto3Json?(ps(void 0===t||"string"==typeof t,58123),Zo.fromBase64String(t||"")):(ps(void 0===t||t instanceof Buffer||t instanceof Uint8Array,16193),Zo.fromUint8Array(t||new Uint8Array))}(e,t.targetChange.resumeToken),o=t.targetChange.cause,a=o&&function(e){const t=void 0===e.code?gs.UNKNOWN:Cu(e.code);return new ys(t,e.message||"")}(o);n=new Fu(r,i,s,a||null)}else if("documentChange"in t){t.documentChange;const r=t.documentChange;r.document,r.document.name,r.document.updateTime;const i=tl(e,r.document.name),s=Qu(r.document.updateTime),o=r.document.createTime?Qu(r.document.createTime):Js.min(),a=new xa({mapValue:{fields:r.document.fields}}),c=Ua.newFoundDocument(i,s,o,a),u=r.targetIds||[],l=r.removedTargetIds||[];n=new Mu(u,l,c.key,c)}else if("documentDelete"in t){t.documentDelete;const r=t.documentDelete;r.document;const i=tl(e,r.document),s=r.readTime?Qu(r.readTime):Js.min(),o=Ua.newNoDocument(i,s),a=r.removedTargetIds||[];n=new Mu([],a,o.key,o)}else if("documentRemove"in t){t.documentRemove;const r=t.documentRemove;r.document;const i=tl(e,r.document),s=r.removedTargetIds||[];n=new Mu([],s,i,null)}else{if(!("filter"in t))return ds(11601,{At:t});{t.filter;const e=t.filter;e.targetId;const{count:r=0,unchangedNames:i}=e,s=new Eu(r,i),o=e.targetId;n=new xu(o,s)}}return n}(this.serializer,e),n=function(e){if(!("targetChange"in e))return Js.min();const t=e.targetChange;return t.targetIds&&t.targetIds.length?Js.min():t.readTime?Qu(t.readTime):Js.min()}(e);return this.listener.J_(t,n)}H_(e){const t={};t.database=il(this.serializer),t.addTarget=function(e,t){let n;const r=t.target;if(n=hc(r)?{documents:cl(e,r)}:{query:ul(e,r).Vt},n.targetId=t.targetId,t.resumeToken.approximateByteSize()>0){n.resumeToken=Wu(e,t.resumeToken);const r=Gu(e,t.expectedCount);null!==r&&(n.expectedCount=r)}else if(t.snapshotVersion.compareTo(Js.min())>0){n.readTime=Ku(e,t.snapshotVersion.toTimestamp());const r=Gu(e,t.expectedCount);null!==r&&(n.expectedCount=r)}return n}(this.serializer,e);const n=function(e,t){const 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 ds(28987,{purpose:e})}}(t.purpose);return null==n?null:{"goog-listen-tags":n}}(this.serializer,e);n&&(t.labels=n),this.k_(t)}Y_(e){const t={};t.database=il(this.serializer),t.removeTarget=e,this.k_(t)}}class Rh extends Oh{constructor(e,t,n,r,i,s){super(e,"write_stream_connection_backoff","write_stream_idle","health_check_timeout",t,n,r,s
2),this.serializer=i}get Z_(){return this.C_>0}start(){this.lastStreamToken=void 0,super.start()}U_(){this.Z_&&this.X_([])}z_(e,t){return this.connection.P_("Write",e,t)}j_(e){return ps(!!e.streamToken,31322),this.lastStreamToken=e.streamToken,ps(!e.writeResults||0===e.writeResults.length,55816),this.listener.ea()}onNext(e){ps(!!e.streamToken,12678),this.lastStreamToken=e.streamToken,this.F_.reset();const t=function(e,t){return e&&e.length>0?(ps(void 0!==t,14353),e.map(e=>function(e,t){let n=e.updateTime?Qu(e.updateTime):Qu(t);return n.isEqual(Js.min())&&(n=Qu(t)),new ru(n,e.transformResults||[])}(e,t))):[]}(e.writeResults,e.commitTime),n=Qu(e.commitTime);return this.listener.ta(n,t)}na(){const e={};e.database=il(this.serializer),this.k_(e)}X_(e){const t={streamToken:this.lastStreamToken,writes:e.map(e=>al(this.serializer,e))};this.k_(t)}}class Ph{}class Lh extends Ph{constructor(e,t,n,r){super(),this.authCredentials=e,this.appCheckCredentials=t,this.connection=n,this.serializer=r,this.ra=!1}ia(){if(this.ra)throw new ys(gs.FAILED_PRECONDITION,"The client has already been terminated.")}Wo(e,t,n,r){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([i,s])=>this.connection.Wo(e,Xu(t,n),r,i,s)).catch(e=>{throw"FirebaseError"===e.name?(e.code===gs.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new ys(gs.UNKNOWN,e.toString())})}Jo(e,t,n,r,i){return this.ia(),Promise.all([this.authCredentials.getToken(),this.appCheckCredentials.getToken()]).then(([s,o])=>this.connection.Jo(e,Xu(t,n),r,s,o,i)).catch(e=>{throw"FirebaseError"===e.name?(e.code===gs.UNAUTHENTICATED&&(this.authCredentials.invalidateToken(),this.appCheckCredentials.invalidateToken()),e):new ys(gs.UNKNOWN,e.toString())})}terminate(){this.ra=!0,this.connection.terminate()}}class Mh{constructor(e,t){this.asyncQueue=e,this.onlineStateHandler=t,this.state="Unknown",this.sa=0,this.oa=null,this._a=!0}aa(){0===this.sa&&(this.ua("Unknown"),this.oa=this.asyncQueue.enqueueAfterDelay("online_state_timeout",1e4,()=>(this.oa=null,this.ca("Backend didn't respond within 10 seconds."),this.ua("Offline"),Promise.resolve())))}la(e){"Online"===this.state?this.ua("Unknown"):(this.sa++,this.sa>=1&&(this.ha(),this.ca(`Connection failed 1 times. Most recent error: ${e.toString()}`),this.ua("Offline")))}set(e){this.ha(),this.sa=0,"Online"===e&&(this._a=!1),this.ua(e)}ua(e){e!==this.state&&(this.state=e,this.onlineStateHandler(e))}ca(e){const 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._a?(us(t),this._a=!1):cs("OnlineStateTracker",t)}ha(){null!==this.oa&&(this.oa.cancel(),this.oa=null)}}const xh="RemoteStore";class Fh{constructor(e,t,n,r,i){this.localStore=e,this.datastore=t,this.asyncQueue=n,this.remoteSyncer={},this.Pa=[],this.Ta=new Map,this.Ia=new Set,this.da=[],this.Ea=i,this.Ea.xo(e=>{n.enqueueAndForget(async()=>{Gh(this)&&(cs(xh,"Restarting streams for network reachability change."),await async function(e){const t=ms(e);t.Ia.add(4),await Vh(t),t.Aa.set("Unknown"),t.Ia.delete(4),await Uh(t)}(this))})}),this.Aa=new Mh(n,r)}}async function Uh(e){if(Gh(e))for(const t of e.da)await t(!0)}async function Vh(e){for(const t of e.da)await t(!1)}function jh(e,t){const n=ms(e);n.Ta.has(t.targetId)||(n.Ta.set(t.targetId,t),Hh(n)?zh(n):hd(n).x_()&&Bh(n,t))}function $h(e,t){const n=ms(e),r=hd(n);n.Ta.delete(t),r.x_()&&qh(n,t),0===n.Ta.size&&(r.x_()?r.B_():Gh(n)&&n.Aa.set("Unknown"))}function Bh(e,t){if(e.Ra.$e(t.targetId),t.resumeToken.approximateByteSize()>0||t.snapshotVersion.compareTo(Js.min())>0){const n=e.remoteSyncer.getRemoteKeysForTarget(t.targetId).size;t=t.withExpectedCount(n)}hd(e).H_(t)}function qh(e,t){e.Ra.$e(t),hd(e).Y_(t)}function zh(e){e.Ra=new Vu({getRemoteKeysForTarget:t=>e.remoteSyncer.getRemoteKeysForTarget(t),Et:t=>e.Ta.get(t)||null,lt:()=>e.datastore.serializer.databaseId}),hd(e).start(),e.Aa.aa()}function Hh(e){return Gh(e)&&!hd(e).M_()&&e.Ta.size>0}function Gh(e){return 0===ms(e).Ia.size}function Kh(e){e.Ra=void 0}async function Wh(e){e.Aa.set("Online")}async function Yh(e){e.Ta.forEach((t,n)=>{Bh(e,t)})}async function Qh(e,t){Kh(e),Hh(e)?(e.Aa.la(t),zh(e)):e.Aa.set("Unknown")}async function Jh(e,t,n){if(e.Aa.set("Online"),t instanceof Fu&&2===t.state&&t.cause)try{await async function(e,t){const n=t.cause;for(const r of t.targetIds)e.Ta.has(r)&&(await e.remoteSyncer.rejectListen(r,n),e.Ta.delete(r),e.Ra.removeTarget(r))}(e,t)}catch(n){cs(xh,"Failed to remove targets %s: %s ",t.targetIds.join(","),n),await Xh(e,n)}else if(t instanceof Mu?e.Ra.Ye(t):t instanceof xu?e.Ra.it(t):e.Ra.et(t),!n.isEqual(Js.min()))try{const t=await oh(e.localStore);n.compareTo(t)>=0&&await function(e,t){const n=e.Ra.Pt(t);
2return n.targetChanges.forEach((n,r)=>{if(n.resumeToken.approximateByteSize()>0){const i=e.Ta.get(r);i&&e.Ta.set(r,i.withResumeToken(n.resumeToken,t))}}),n.targetMismatches.forEach((t,n)=>{const r=e.Ta.get(t);if(!r)return;e.Ta.set(t,r.withResumeToken(Zo.EMPTY_BYTE_STRING,r.snapshotVersion)),qh(e,t);const i=new _l(r.target,t,n,r.sequenceNumber);Bh(e,i)}),e.remoteSyncer.applyRemoteEvent(n)}(e,n)}catch(t){cs(xh,"Failed to raise snapshot:",t),await Xh(e,t)}}async function Xh(e,t,n){if(!uo(t))throw t;e.Ia.add(1),await Vh(e),e.Aa.set("Offline"),n||(n=()=>oh(e.localStore)),e.asyncQueue.enqueueRetryable(async()=>{cs(xh,"Retrying IndexedDB access"),await n(),e.Ia.delete(1),await Uh(e)})}function Zh(e,t){return t().catch(n=>Xh(e,n,t))}async function ed(e){const t=ms(e),n=dd(t);let r=t.Pa.length>0?t.Pa[t.Pa.length-1].batchId:ho;for(;td(t);)try{const e=await ch(t.localStore,r);if(null===e){0===t.Pa.length&&n.B_();break}r=e.batchId,nd(t,e)}catch(e){await Xh(t,e)}rd(t)&&id(t)}function td(e){return Gh(e)&&e.Pa.length<10}function nd(e,t){e.Pa.push(t);const n=dd(e);n.x_()&&n.Z_&&n.X_(t.mutations)}function rd(e){return Gh(e)&&!dd(e).M_()&&e.Pa.length>0}function id(e){dd(e).start()}async function sd(e){dd(e).na()}async function od(e){const t=dd(e);for(const n of e.Pa)t.X_(n.mutations)}async function ad(e,t,n){const r=e.Pa.shift(),i=_u.from(r,t,n);await Zh(e,()=>e.remoteSyncer.applySuccessfulWrite(i)),await ed(e)}async function cd(e,t){t&&dd(e).Z_&&await async function(e,t){if(function(e){return Su(e)&&e!==gs.ABORTED}(t.code)){const n=e.Pa.shift();dd(e).N_(),await Zh(e,()=>e.remoteSyncer.rejectFailedWrite(n.batchId,t)),await ed(e)}}(e,t),rd(e)&&id(e)}async function ud(e,t){const n=ms(e);n.asyncQueue.verifyOperationInProgress(),cs(xh,"RemoteStore received new credentials");const r=Gh(n);n.Ia.add(3),await Vh(n),r&&n.Aa.set("Unknown"),await n.remoteSyncer.handleCredentialChange(t),n.Ia.delete(3),await Uh(n)}async function ld(e,t){const n=ms(e);t?(n.Ia.delete(2),await Uh(n)):t||(n.Ia.add(2),await Vh(n),n.Aa.set("Unknown"))}function hd(e){return e.Va||(e.Va=function(e,t,n){const r=ms(e);return r.ia(),new Dh(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Zo:Wh.bind(null,e),e_:Yh.bind(null,e),n_:Qh.bind(null,e),J_:Jh.bind(null,e)}),e.da.push(async t=>{t?(e.Va.N_(),Hh(e)?zh(e):e.Aa.set("Unknown")):(await e.Va.stop(),Kh(e))})),e.Va}function dd(e){return e.ma||(e.ma=function(e,t,n){const r=ms(e);return r.ia(),new Rh(t,r.connection,r.authCredentials,r.appCheckCredentials,r.serializer,n)}(e.datastore,e.asyncQueue,{Zo:()=>Promise.resolve(),e_:sd.bind(null,e),n_:cd.bind(null,e),ea:od.bind(null,e),ta:ad.bind(null,e)}),e.da.push(async t=>{t?(e.ma.N_(),await ed(e)):(await e.ma.stop(),e.Pa.length>0&&(cs(xh,`Stopping write stream with ${e.Pa.length} pending writes`),e.Pa=[]))})),e.ma}class fd{constructor(e,t,n,r,i){this.asyncQueue=e,this.timerId=t,this.targetTimeMs=n,this.op=r,this.removalCallback=i,this.deferred=new vs,this.then=this.deferred.promise.then.bind(this.deferred.promise),this.deferred.promise.catch(e=>{})}get promise(){return this.deferred.promise}static createAndSchedule(e,t,n,r,i){const s=Date.now()+n,o=new fd(e,t,s,r,i);return o.start(n),o}start(e){this.timerHandle=setTimeout(()=>this.handleDelayElapsed(),e)}skipDelay(){return this.handleDelayElapsed()}cancel(e){null!==this.timerHandle&&(this.clearTimeout(),this.deferred.reject(new ys(gs.CANCELLED,"Operation cancelled"+(e?": "+e:""))))}handleDelayElapsed(){this.asyncQueue.enqueueAndForget(()=>null!==this.timerHandle?(this.clearTimeout(),this.op().then(e=>this.deferred.resolve(e))):Promise.resolve())}clearTimeout(){null!==this.timerHandle&&(this.removalCallback(this),clearTimeout(this.timerHandle),this.timerHandle=null)}}function pd(e,t){if(us("AsyncQueue",`${t}: ${e}`),uo(e))return new ys(gs.UNAVAILABLE,`${t}: ${e}`);throw e}class md{static emptySet(e){return new md(e.comparator)}constructor(e){this.comparator=e?(t,n)=>e(t,n)||js.comparator(t.key,n.key):(e,t)=>js.comparator(e.key,t.key),this.keyedMap=Rc(),this.sortedSet=new Go(this.comparator)}has(e){return null!=this.keyedMap.get(e)}get(e){return this.keyedMap.get(e)}first(){return this.sortedSet.minKey()}last(){return this.sortedSet.maxKey()}isEmpty(){return this.sortedSet.isEmpty()}indexOf(e){const 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){const t=this.delete(e.key);return t.copy(t.keyedMap.insert(e.key,e),t.sortedSet.insert(e,null))}delete(e){const t=this.get(e);return t?this.copy(this.keyedMap.remove(e),this.sortedSet.remove(t)):this}isEqual(e){if(!(e instanceof md))return!1;if(this.size!==e.size)return!1;const t=this.sortedSet.getIterator(),n=e.sortedSet.getIterator();for(;t.hasNext();){const e=t.getNext().key,r=n.getNext().key;if(!e.isEqual(r))return!1}return!0}toString(){const e=[];return this.forEach(t=>{e.push(t.toString())}),0===e.length?"DocumentSet ()":"DocumentSet (\n "+e.join(" \n")+"\n)"}copy(e,t){const n=new md;return n.comparator=this.comparator,n.keyedMap=e,n.sortedSet=t,n}}class gd{constructor(){this.fa=new Go(js.comparator)}track(e){const t=e.doc.key,n=this.fa.get(t);n?0!==e.type&&3===n.type?this.fa=this.fa.insert(t,e):3===e.type&&1!==n.type?this.fa=this.fa.insert(t,{type:n.type,doc:e.doc}):2===e.type&&2===n.type?this.fa=this.fa.insert(t,{type:2,doc:e.doc}):2===e.type&&0===n.type?this.fa=this.fa.insert(t,{type:0,doc:e.doc}):1===e.type&&0===n.type?this.fa=this.fa.remove(t):1===e.type&&2===n.type?this.fa=this.fa.insert(t,{type:1,doc:n.doc}):0===e.type&&1===n.type?this.fa=this.fa.insert(t,{type:2,doc:e.doc}):ds(63341,{At:e,ga:n}):this.fa=this.fa.insert(t,e)}pa(){const e=[];return this.fa.inorderTraversal((t,n)=>{e.push(n)}),e}}class yd{constructor(e,t,n,r,i,s,o,a,c){this.query=e,this.docs=t,this.oldDocs=n,this.docChanges=r,this.mutatedKeys=i,this.fromCache=s,this.syncStateChanged=o,this.excludesMetadataChanges=a,this.hasCachedResults=c}static fromInitialDocuments(e,t,n,r,i){const s=[];
vendor: 2,041 bytes, line 2
2return t.forEach(e=>{s.push({type:0,doc:e})}),new yd(e,t,md.emptySet(t),s,n,r,!0,!1,i)}get hasPendingWrites(){return!this.mutatedKeys.isEmpty()}isEqual(e){if(!(this.fromCache===e.fromCache&&this.hasCachedResults===e.hasCachedResults&&this.syncStateChanged===e.syncStateChanged&&this.mutatedKeys.isEqual(e.mutatedKeys)&&bc(this.query,e.query)&&this.docs.isEqual(e.docs)&&this.oldDocs.isEqual(e.oldDocs)))return!1;const 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}}class vd{constructor(){this.ya=void 0,this.wa=[]}Sa(){return this.wa.some(e=>e.ba())}}class wd{constructor(){this.queries=_d(),this.onlineState="Unknown",this.Da=new Set}terminate(){!function(e,t){const n=ms(e),r=n.queries;n.queries=_d(),r.forEach((e,n)=>{for(const e of n.wa)e.onError(t)})}(this,new ys(gs.ABORTED,"Firestore shutting down"))}}function _d(){return new kc(e=>Ec(e),bc)}async function bd(e,t){const n=ms(e);let r=3;const i=t.query;let s=n.queries.get(i);s?!s.Sa()&&t.ba()&&(r=2):(s=new vd,r=t.ba()?0:1);try{switch(r){case 0:s.ya=await n.onListen(i,!0);break;case 1:s.ya=await n.onListen(i,!1);break;case 2:await n.onFirstRemoteStoreListen(i)}}catch(e){const n=pd(e,`Initialization of query '${Tc(t.query)}' failed`);return void t.onError(n)}n.queries.set(i,s),s.wa.push(t),t.va(n.onlineState),s.ya&&t.Ca(s.ya)&&Sd(n)}async function Ed(e,t){const n=ms(e),r=t.query;let i=3;const s=n.queries.get(r);if(s){const e=s.wa.indexOf(t);e>=0&&(s.wa.splice(e,1),0===s.wa.length?i=t.ba()?0:1:!s.Sa()&&t.ba()&&(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 Td(e,t){const n=ms(e);let r=!1;for(const e of t){const t=e.query,i=n.queries.get(t);if(i){for(const t of i.wa)t.Ca(e)&&(r=!0);i.ya=e}}r&&Sd(n)}function Id(e,t,n){const r=ms(e),i=r.queries.get(t);if(i)for(const e of i.wa)e.onError(n);r.queries.delete(t)}
2function Sd(e){e.Da.forEach(e=>{e.next()})}var Cd,Ad;(Ad=Cd||(Cd={})).Fa="default",Ad.Cache="cache";class kd{constructor(e,t,n){this.query=e,this.Ma=t,this.xa=!1,this.Oa=null,this.onlineState="Unknown",this.options=n||{}}Ca(e){if(!this.options.includeMetadataChanges){const t=[];for(const n of e.docChanges)3!==n.type&&t.push(n);e=new yd(e.query,e.docs,e.oldDocs,t,e.mutatedKeys,e.fromCache,e.syncStateChanged,!0,e.hasCachedResults)}let t=!1;return this.xa?this.Na(e)&&(this.Ma.next(e),t=!0):this.Ba(e,this.onlineState)&&(this.La(e),t=!0),this.Oa=e,t}onError(e){this.Ma.error(e)}va(e){this.onlineState=e;let t=!1;return this.Oa&&!this.xa&&this.Ba(this.Oa,e)&&(this.La(this.Oa),t=!0),t}Ba(e,t){if(!e.fromCache)return!0;if(!this.ba())return!0;const n="Offline"!==t;return(!this.options.ka||!n)&&(!e.docs.isEmpty()||e.hasCachedResults||"Offline"===t)}Na(e){if(e.docChanges.length>0)return!0;const t=this.Oa&&this.Oa.hasPendingWrites!==e.hasPendingWrites;return!(!e.syncStateChanged&&!t)&&!0===this.options.includeMetadataChanges}La(e){e=yd.fromInitialDocuments(e.query,e.docs,e.mutatedKeys,e.fromCache,e.hasCachedResults),this.xa=!0,this.Ma.next(e)}ba(){return this.options.source!==Cd.Cache}}class Nd{constructor(e){this.key=e}}class Od{constructor(e){this.key=e}}class Dd{constructor(e,t){this.query=e,this.Ha=t,this.Ya=null,this.hasCachedResults=!1,this.current=!1,this.Za=Vc(),this.mutatedKeys=Vc(),this.Xa=Cc(e),this.eu=new md(this.Xa)}get tu(){return this.Ha}nu(e,t){const n=t?t.ru:new gd,r=t?t.eu:this.eu;let i=t?t.mutatedKeys:this.mutatedKeys,s=r,o=!1;const a="F"===this.query.limitType&&r.size===this.query.limit?r.last():null,c="L"===this.query.limitType&&r.size===this.query.limit?r.first():null;if(e.inorderTraversal((e,t)=>{const u=r.get(e),l=Ic(this.query,t)?t:null,h=!!u&&this.mutatedKeys.has(u.key),d=!!l&&(l.hasLocalMutations||this.mutatedKeys.has(l.key)&&l.hasCommittedMutations);let f=!1;u&&l?u.data.isEqual(l.data)?h!==d&&(n.track({type:3,doc:l}),f=!0):this.iu(u,l)||(n.track({type:2,doc:l}),f=!0,(a&&this.Xa(l,a)>0||c&&this.Xa(l,c)<0)&&(o=!0)):!u&&l?(n.track({type:0,doc:l}),f=!0):u&&!l&&(n.track({type:1,doc:u}),f=!0,(a||c)&&(o=!0)),f&&(l?(s=s.add(l),i=d?i.add(e):i.delete(e)):(s=s.delete(e),i=i.delete(e)))}),null!==this.query.limit)for(;s.size>this.query.limit;){const e="F"===this.query.limitType?s.last():s.first();s=s.delete(e.key),i=i.delete(e.key),n.track({type:1,doc:e})}return{eu:s,ru:n,Ds:o,mutatedKeys:i}}iu(e,t){return e.hasLocalMutations&&t.hasCommittedMutations&&!t.hasLocalMutations}applyChanges(e,t,n,r){const i=this.eu;this.eu=e.eu,this.mutatedKeys=e.mutatedKeys;const s=e.ru.pa();s.sort((e,t)=>function(e,t){const n=e=>{switch(e){case 0:return 1;case 2:case 3:return 2;case 1:return 0;default:return ds(20277,{At:e})}};return n(e)-n(t)}(e.type,t.type)||this.Xa(e.doc,t.doc)),this.su(n),r=null!=r&&r;const o=t&&!r?this.ou():[],a=0===this.Za.size&&this.current&&!r?1:0,c=a!==this.Ya;return this.Ya=a,0!==s.length||c?{snapshot:new yd(this.query,e.eu,i,s,e.mutatedKeys,0===a,c,!1,!!n&&n.resumeToken.approximateByteSize()>0),_u:o}:{_u:o}}va(e){return this.current&&"Offline"===e?(this.current=!1,this.applyChanges({eu:this.eu,ru:new gd,mutatedKeys:this.mutatedKeys,Ds:!1},!1)):{_u:[]}}au(e){return!this.Ha.has(e)&&!!this.eu.has(e)&&!this.eu.get(e).hasLocalMutations}su(e){e&&(e.addedDocuments.forEach(e=>this.Ha=this.Ha.add(e)),e.modifiedDocuments.forEach(e=>{}),e.removedDocuments.forEach(e=>this.Ha=this.Ha.delete(e)),this.current=e.current)}ou(){if(!this.current)return[];const e=this.Za;this.Za=Vc(),this.eu.forEach(e=>{this.au(e.key)&&(this.Za=this.Za.add(e.key))});const t=[];return e.forEach(e=>{this.Za.has(e)||t.push(new Od(e))}
2),this.Za.forEach(n=>{e.has(n)||t.push(new Nd(n))}),t}uu(e){this.Ha=e.qs,this.Za=Vc();const t=this.nu(e.documents);return this.applyChanges(t,!0)}cu(){return yd.fromInitialDocuments(this.query,this.eu,this.mutatedKeys,0===this.Ya,this.hasCachedResults)}}const Rd="SyncEngine";class Pd{constructor(e,t,n){this.query=e,this.targetId=t,this.view=n}}class Ld{constructor(e){this.key=e,this.lu=!1}}class Md{constructor(e,t,n,r,i,s){this.localStore=e,this.remoteStore=t,this.eventManager=n,this.sharedClientState=r,this.currentUser=i,this.maxConcurrentLimboResolutions=s,this.hu={},this.Pu=new kc(e=>Ec(e),bc),this.Tu=new Map,this.Iu=new Set,this.du=new Go(js.comparator),this.Eu=new Map,this.Au=new ql,this.Ru={},this.Vu=new Map,this.mu=Nl.ur(),this.onlineState="Unknown",this.fu=void 0}get isPrimaryClient(){return!0===this.fu}}async function xd(e,t,n=!0){const r=rf(e);let i;const s=r.Pu.get(t);return s?(r.sharedClientState.addLocalQueryTarget(s.targetId),i=s.view.cu()):i=await Ud(r,t,n,!0),i}async function Fd(e,t){const n=rf(e);await Ud(n,t,!0,!1)}async function Ud(e,t,n,r){const i=await uh(e.localStore,vc(t)),s=i.targetId,o=e.sharedCl
2ientState.addLocalQueryTarget(s,n);let a;return r&&(a=await Vd(e,t,s,"current"===o,i.resumeToken)),e.isPrimaryClient&&n&&jh(e.remoteStore,i),a}async function Vd(e,t,n,r,i){e.gu=(t,n,r)=>async function(e,t,n,r){let i=t.view.nu(n);i.Ds&&(i=await hh(e.localStore,t.query,!1).then(({documents:e})=>t.view.nu(e,i)));const s=r&&r.targetChanges.get(t.targetId),o=r&&null!=r.targetMismatches.get(t.targetId),a=t.view.applyChanges(i,e.isPrimaryClient,s,o);return Jd(e,t.targetId,a._u),a.snapshot}(e,t,n,r);const s=await hh(e.localStore,t,!0),o=new Dd(t,s.qs),a=o.nu(s.documents),c=Lu.createSynthesizedTargetChangeForCurrentChange(n,r&&"Offline"!==e.onlineState,i),u=o.applyChanges(a,e.isPrimaryClient,c);Jd(e,n,u._u);const l=new Pd(t,n,o);return e.Pu.set(t,l),e.Tu.has(n)?e.Tu.get(n).push(t):e.Tu.set(n,[t]),u.snapshot}async function jd(e,t,n){const r=ms(e),i=r.Pu.get(t),s=r.Tu.get(i.targetId);if(s.length>1)return r.Tu.set(i.targetId,s.filter(e=>!bc(e,t))),void r.Pu.delete(t);r.isPrimaryClient?(r.sharedClientState.removeLocalQueryTarget(i.targetId),r.sharedCl
2ientState.isActiveQueryTarget(i.targetId)||await lh(r.localStore,i.targetId,!1).then(()=>{r.sharedClientState.clearQueryState(i.targetId),n&&$h(r.remoteStore,i.targetId),Yd(r,i.targetId)}).catch(oo)):(Yd(r,i.targetId),await lh(r.localStore,i.targetId,!0))}async function $d(e,t){const n=ms(e),r=n.Pu.get(t),i=n.Tu.get(r.targetId);n.isPrimaryClient&&1===i.length&&(n.sharedClientState.removeLocalQueryTarget(r.targetId),$h(n.remoteStore,r.targetId))}async function Bd(e,t){const n=ms(e);try{const e=await function(e,t){const n=ms(e),r=t.snapshotVersion;let i=n.Fs;return n.persistence.runTransaction("Apply remote event","readwrite-primary",e=>{const s=n.Os.newChangeBuffer({trackRemovals:!0});i=n.Fs;const o=[];t.targetChanges.forEach((s,a)=>{const c=i.get(a);if(!c)return;o.push(n.hi.removeMatchingKeys(e,s.removedDocuments,a).next(()=>n.hi.addMatchingKeys(e,s.addedDocuments,a)));let u=c.withSequenceNumber(e.currentSequenceNumber);null!==t.targetMismatches.get(a)?u=u.withResumeToken(Zo.EMPTY_BYTE_STRING,Js.min()).withLastLimboFreeSnapshotVersion(Js.min()):s.resumeToken.approximateByteSize()>0&&(u=u.withResumeToken(s.resumeToken,r)),i=i.insert(a,u),function(e,t,n){return 0===e.resumeToken.approximateByteSize()||(t.snapshotVersion.toMicroseconds()-e.snapshotVersion.toMicroseconds()>=3e8||n.addedDocuments.size+n.modifiedDocuments.size+n.removedDocuments.size>0)}(c,u,s)&&o.push(n.hi.updateTargetData(e,u))});let a=Oc(),c=Vc();if(t.documentUpdates.forEach(r=>{t.resolvedLimboDocuments.has(r)&&o.push(n.persistence.referenceDelegate.updateLimboDocument(e,r))}),o.push(ah(e,s,t.documentUpdates).next(e=>{a=e.Ls,c=e.ks})),!r.isEqual(Js.min())){const t=n.hi.getLastRemoteSnapshotVersion(e).next(t=>n.hi.setTargetsMetadata(e,e.currentSequenceNumber,r));o.push(t)}return ao.waitFor(o).next(()=>s.apply(e)).next(()=>n.localDocuments.getLocalViewOfDocuments(e,a,c)).next(()=>a)}).then(e=>(n.Fs=i,e))}(n.localStore,t);
2t.targetChanges.forEach((e,t)=>{const r=n.Eu.get(t);r&&(ps(e.addedDocuments.size+e.modifiedDocuments.size+e.removedDocuments.size<=1,22616),e.addedDocuments.size>0?r.lu=!0:e.modifiedDocuments.size>0?ps(r.lu,14607):e.removedDocuments.size>0&&(ps(r.lu,42227),r.lu=!1))}),await ef(n,e,t)}catch(e){await oo(e)}}function qd(e,t,n){const r=ms(e);if(r.isPrimaryClient&&0===n||!r.isPrimaryClient&&1===n){const e=[];r.Pu.forEach((n,r)=>{const i=r.view.va(t);i.snapshot&&e.push(i.snapshot)}),function(e,t){const n=ms(e);n.onlineState=t;let r=!1;n.queries.forEach((e,n)=>{for(const e of n.wa)e.va(t)&&(r=!0)}),r&&Sd(n)}(r.eventManager,t),e.length&&r.hu.J_(e),r.onlineState=t,r.isPrimaryClient&&r.sharedClientState.setOnlineState(t)}}async function zd(e,t,n){const r=ms(e);r.sharedClientState.updateQueryState(t,"rejected",n);const i=r.Eu.get(t),s=i&&i.key;if(s){let e=new Go(js.comparator);e=e.insert(s,Ua.newNoDocument(s,Js.min()));const n=Vc().add(s),i=new Pu(Js.min(),new Map,new Go(Os),e,n);await Bd(r,i),r.du=r.du.remove(s),r.Eu.delete(t),Zd(r)}else await lh(r.localStore,t,!1).then(()=>Yd(r,t,n)).catch(oo)}async function Hd(e,t){const n=ms(e),r=t.batch.batchId;try{const e=await function(e,t){const n=ms(e);return n.persistence.runTransaction("Acknowledge batch","readwrite-primary",e=>{const r=t.batch.keys(),i=n.Os.newChangeBuffer({trackRemovals:!0});return function(e,t,n,r){const i=n.batch,s=i.keys();let o=ao.resolve();return s.forEach(e=>{o=o.next(()=>r.getEntry(t,e)).next(t=>{const s=n.docVersions.get(e);ps(null!==s,48541),t.version.compareTo(s)<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=Vc();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))})}(n.localStore,t);Wd(n,r,null),Kd(n,r),n.sharedClientState.updateMutationState(r,"acknowledged"),await ef(n,e)}catch(e){await oo(e)}}async function Gd(e,t,n){const r=ms(e);try{const e=await function(e,t){const n=ms(e);return n.persistence.runTransaction("Reject batch","readwrite-primary",e=>{let r;
2return n.mutationQueue.lookupMutationBatch(e,t).next(t=>(ps(null!==t,37113),r=t.keys(),n.mutationQueue.removeMutationBatch(e,t))).next(()=>n.mutationQueue.performConsistencyCheck(e)).next(()=>n.documentOverlayCache.removeOverlaysForBatchId(e,r,t)).next(()=>n.localDocuments.recalculateAndSaveOverlaysForDocumentKeys(e,r)).next(()=>n.localDocuments.getDocuments(e,r))})}(r.localStore,t);Wd(r,t,n),Kd(r,t),r.sharedClientState.updateMutationState(t,"rejected",n),await ef(r,e)}catch(n){await oo(n)}}function Kd(e,t){(e.Vu.get(t)||[]).forEach(e=>{e.resolve()}),e.Vu.delete(t)}function Wd(e,t,n){const r=ms(e);let i=r.Ru[r.currentUser.toKey()];if(i){const e=i.get(t);e&&(n?e.reject(n):e.resolve(),i=i.remove(t)),r.Ru[r.currentUser.toKey()]=i}}function Yd(e,t,n=null){e.sharedClientState.removeLocalQueryTarget(t);for(const r of e.Tu.get(t))e.Pu.delete(r),n&&e.hu.pu(r,n);e.Tu.delete(t),e.isPrimaryClient&&e.Au.zr(t).forEach(t=>{e.Au.containsKey(t)||Qd(e,t)})}function Qd(e,t){e.Iu.delete(t.path.canonicalString());const n=e.du.get(t);null!==n&&($h(e.remoteStore,n),e.du=e.du.remove(t),e.Eu.delete(n),Zd(e))}function Jd(e,t,n){for(const r of n)r instanceof Nd?(e.Au.addReference(r.key,t),Xd(e,r)):r instanceof Od?(cs(Rd,"Document no longer in limbo: "+r.key),e.Au.removeReference(r.key,t),e.Au.containsKey(r.key)||Qd(e,r.key)):ds(19791,{yu:r})}function Xd(e,t){const n=t.key,r=n.path.canonicalString();e.du.get(n)||e.Iu.has(r)||(cs(Rd,"New document in limbo: "+n),e.Iu.add(r),Zd(e))}function Zd(e){for(;e.Iu.size>0&&e.du.size<e.maxConcurrentLimboResolutions;){const t=e.Iu.values().next().value;e.Iu.delete(t);const n=new js(Fs.fromString(t)),r=e.mu.next();e.Eu.set(r,new Ld(n)),e.du=e.du.insert(n,r),jh(e.remoteStore,new _l(vc(pc(n.path)),r,"TargetPurposeLimboResolution",lo.ue))}}async function ef(e,t,n){const r=ms(e),i=[],s=[],o=[];r.Pu.isEmpty()||(r.Pu.forEach((e,a)=>{o.push(r.gu(a,t,n).then(e=>{var t;if((e||n)&&r.isPrimaryClient){const i=e?!e.fromCache:null===(t=null==n?void 0:n.targetChanges.get(a.targetId))||void 0===t?void 0:t.current;
2r.sharedClientState.updateQueryState(a.targetId,i?"current":"not-current")}if(e){i.push(e);const t=Zl.Es(a.targetId,e);s.push(t)}}))}),await Promise.all(o),r.hu.J_(i),await async function(e,t){const n=ms(e);try{await n.persistence.runTransaction("notifyLocalViewChanges","readwrite",e=>ao.forEach(t,t=>ao.forEach(t.Is,r=>n.persistence.referenceDelegate.addReference(e,t.targetId,r)).next(()=>ao.forEach(t.ds,r=>n.persistence.referenceDelegate.removeReference(e,t.targetId,r)))))}catch(e){if(!uo(e))throw e;cs(nh,"Failed to update sequence numbers: "+e)}for(const e of t){const t=e.targetId;if(!e.fromCache){const e=n.Fs.get(t),r=e.snapshotVersion,i=e.withLastLimboFreeSnapshotVersion(r);n.Fs=n.Fs.insert(t,i)}}}(r.localStore,s))}async function tf(e,t){const n=ms(e);if(!n.currentUser.isEqual(t)){cs(Rd,"User change. New user:",t.toKey());const e=await sh(n.localStore,t);n.currentUser=t,function(e,t){e.Vu.forEach(e=>{e.forEach(e=>{e.reject(new ys(gs.CANCELLED,t))})}),e.Vu.clear()}(n,"'waitForPendingWrites' promise is rejected due to a user change."),n.sharedClientState.handleUserChange(t,e.removedBatchIds,e.addedBatchIds),await ef(n,e.Bs)}}function nf(e,t){const n=ms(e),r=n.Eu.get(t);if(r&&r.lu)return Vc().add(r.key);{let e=Vc();const r=n.Tu.get(t);if(!r)return e;for(const t of r){const r=n.Pu.get(t);e=e.unionWith(r.view.tu)}return e}}function rf(e){const t=ms(e);return t.remoteStore.remoteSyncer.applyRemoteEvent=Bd.bind(null,t),t.remoteStore.remoteSyncer.getRemoteKeysForTarget=nf.bind(null,t),t.remoteStore.remoteSyncer.rejectListen=zd.bind(null,t),t.hu.J_=Td.bind(null,t.eventManager),t.hu.pu=Id.bind(null,t.eventManager),t}function sf(e){const t=ms(e);return t.remoteStore.remoteSyncer.applySuccessfulWrite=Hd.bind(null,t),t.remoteStore.remoteSyncer.rejectFailedWrite=Gd.bind(null,t),t}class of{constructor(){this.kind="memory",this.synchronizeTabs=!1}async initialize(e){this.serializer=Ah(e.databaseInfo.databaseId),this.sharedClientState=this.bu(e),this.persistence=this.Du(e),await this.persistence.start(),this.localStore=this.vu(e),this.gcScheduler=this.Cu(e,this.localStore),this.indexBackfillerScheduler=this.Fu(e,this.localStore)}Cu(e,t){return null}Fu(e,t){return null}vu(e){return ih(this.persistence,new th,e.initialUser,this.serializer)}Du(e){return new Yl(Jl.Vi,this.serializer)}bu(e){return new ph}async terminate(){var e,t;null===(e=this.gcScheduler)||void 0===e||e.stop(),null===(t=this.indexBackfillerScheduler)||void 0===t||t.stop(),this.sharedClientState.shutdown(),await this.persistence.shutdown()}}of.provider={build:()=>new of};class af extends of{constructor(e){super(),this.cacheSizeBytes=e}Cu(e,t){ps(this.persistence.referenceDelegate instanceof Xl,46915);const n=this.persistence.referenceDelegate.garbageCollector;return new Ll(n,e.asyncQueue,t)}Du(e){const t=void 0!==this.cacheSizeBytes?kl.withCacheSize(this.cacheSizeBytes):kl.DEFAULT;return new Yl(e=>Xl.Vi(e,t),this.serializer)}}class cf{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=>qd(this.syncEngine,e,1),this.remoteStore.remoteSyncer.handleCredentialChange=tf.bind(null,this.syncEngine),await ld(this.remoteStore,this.syncEngine.isPrimaryClient))}createEventManager(e){return new wd}createDatastore(e){const t=Ah(e.databaseInfo.databaseId),n=function(e){return new Sh(e)}(e.databaseInfo);return function(e,t,n,r){return new Lh(e,t,n,r)}(e.authCredentials,e.appCheckCredentials,n,t)}createRemoteStore(e){return function(e,t,n,r,i){return new Fh(e,t,n,r,i)}(this.localStore,this.datastore,e.asyncQueue,e=>qd(this.syncEngine,e,0),yh.C()?new yh:new mh)}createSyncEngine(e,t){return function(e,t,n,r,i,s,o){const a=new Md(e,t,n,r,i,s);return o&&(a.fu=!0),a}(this.localStore,this.remoteStore,this.eventManager,this.sharedClientState,e.initialUser,e.maxConcurrentLimboResolutions,t)}async terminate(){var e,t;await async function(e){const t=ms(e);cs(xh,"RemoteStore shutting down."),t.Ia.add(5),await Vh(t),t.Ea.shutdown(),t.Aa.set("Unknown")}(this.remoteStore),null===(e=this.datastore)||void 0===e||e.terminate(),null===(t=this.eventManager)||void 0===t||t.terminate()}}cf.provider={build:()=>new cf};class uf{constructor(e){this.observer=e,this.muted=!1}next(e){this.muted||this.observer.next&&this.xu(this.observer.next,e)}error(e){this.muted||(this.observer.error?this.xu(this.observer.error,e):us("Uncaught Error in snapshot listener:",e.toString()))}Ou(){this.muted=!0}
2xu(e,t){setTimeout(()=>{this.muted||e(t)},0)}}const lf="FirestoreClient";class hf{constructor(e,t,n,r,i){this.authCredentials=e,this.appCheckCredentials=t,this.asyncQueue=n,this.databaseInfo=r,this.user=is.UNAUTHENTICATED,this.clientId=Ns.newId(),this.authCredentialListener=()=>Promise.resolve(),this.appCheckCredentialListener=()=>Promise.resolve(),this._uninitializedComponentsProvider=i,this.authCredentials.start(n,async e=>{cs(lf,"Received user=",e.uid),await this.authCredentialListener(e),this.user=e}),this.appCheckCredentials.start(n,e=>(cs(lf,"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();const e=new vs;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){const n=pd(t,"Failed to shutdown persistence");e.reject(n)}}),e.promise}}async function df(e,t){e.asyncQueue.verifyOperationInProgress(),cs(lf,"Initializing OfflineComponentProvider");const n=e.configuration;await t.initialize(n);let r=n.initialUser;e.setCredentialChangeListener(async e=>{r.isEqual(e)||(await sh(t.localStore,e),r=e)}),t.persistence.setDatabaseDeletedListener(()=>{ls("Terminating Firestore due to IndexedDb database deletion"),e.terminate().then(()=>{cs("Terminating Firestore due to IndexedDb database deletion completed successfully")}).catch(e=>{ls("Terminating Firestore due to IndexedDb database deletion failed",e)})}),e._offlineComponents=t}async function ff(e,t){e.asyncQueue.verifyOperationInProgress();const n=await pf(e);cs(lf,"Initializing OnlineComponentProvider"),await t.initialize(n,e.configuration),e.setCredentialChangeListener(e=>ud(t.remoteStore,e)),e.setAppCheckTokenChangeListener((e,n)=>ud(t.remoteStore,n)),e._onlineComponents=t}async function pf(e){if(!e._offlineComponents)if(e._uninitializedComponentsProvider){cs(lf,"Using user provided OfflineComponentProvider");try{await df(e,e._uninitializedComponentsProvider._offline)}catch(t){const n=t;if(!function(e){return"FirebaseError"===e.name?e.code===gs.FAILED_PRECONDITION||e.code===gs.UNIMPLEMENTED:!("undefined"!=typeof DOMException&&e instanceof DOMException)||22===e.code||20===e.code||11===e.code}(n))throw n;ls("Error using user provided cache. Falling back to memory cache: "+n),await df(e,new of)}}else cs(lf,"Using default OfflineComponentProvider"),await df(e,new af(void 0));return e._offlineComponents}async function mf(e){return e._onlineComponents||(e._uninitializedComponentsProvider?(cs(lf,"Using user provided OnlineComponentProvider"),await ff(e,e._uninitializedComponentsProvider._online)):(cs(lf,"Using default OnlineComponentProvider"),await ff(e,new cf))),e._onlineComponents}function gf(e){return mf(e).then(e=>e.syncEngine)}async function yf(e){const t=await mf(e),n=t.eventManager;return n.onListen=xd.bind(null,t.syncEngine),n.onUnlisten=jd.bind(null,t.syncEngine),n.onFirstRemoteStoreListen=Fd.bind(null,t.syncEngine),n.onLastRemoteStoreUnlisten=$d.bind(null,t.syncEngine),n}function vf(e,t,n={}){const r=new vs;return e.asyncQueue.enqueueAndForget(async()=>function(e,t,n,r,i){const s=new uf({next:a=>{s.Ou(),t.enqueueAndForget(()=>Ed(e,o));const c=a.docs.has(n);!c&&a.fromCache?i.reject(new ys(gs.UNAVAILABLE,"Failed to get document because the client is offline.")):c&&a.fromCache&&r&&"server"===r.source?i.reject(new ys(gs.UNAVAILABLE,'Failed to get document from server. (However, this document does exist in the local cache. Run again without setting source to "server" to retrieve the cached document.)')):i.resolve(a)},error:e=>i.reject(e)}),o=new kd(pc(n.path),s,{includeMetadataChanges:!0,ka:!0});return bd(e,o)}(await yf(e),e.asyncQueue,t,n,r)),r.promise}function wf(e){const t={};return void 0!==e.timeoutSeconds&&(t.timeoutSeconds=e.timeoutSeconds),t}const _f=new Map,bf="firestore.googleapis.com",Ef=!0;class Tf{constructor(e){var t,n;if(void 0===e.host){if(void 0!==e.ssl)throw new ys(gs.INVALID_ARGUMENT,"Can't provide ssl option if host option is not set");this.host=bf,this.ssl=Ef}else this.host=e.host,this.ssl=null!==(t=e.ssl)&&void 0!==t?t:Ef;if(this.isUsingEmulator=void 0!==e.emulatorOptions,this.credentials=e.credentials,this.ignoreUndefinedProperties=!!e.ignoreUndefinedProperties,this.localCache=e.localCache,void 0===e.cacheSizeBytes)this.cacheSizeBytes=Al;else{if(-1!==e.cacheSizeBytes&&e.cacheSizeBytes<Dl)throw new ys(gs.INVALID_ARGUMENT,"cacheSizeBytes must be at least 1048576");this.cacheSizeBytes=e.cacheSizeBytes}(function(e,t,n,r){if(!0===t&&!0===r)throw new ys(gs.INVALID_ARGUMENT,`${e} and ${n} cannot be used together.`)})("experimentalForceLongPolling",e.experimentalForceLongPolling,"experimentalAutoDetectLongPolling",e.experimentalAutoDetectLongPolling),this.experimentalForceLongPolling=!!e.experimentalForceLongPolling,this.experimentalForceLongPolling?this.experimentalAutoDetectLongPolling=!1:void 0===e.experimentalAutoDetectLongPolling?this.experimentalAutoDetectLongPolling=!0:this.experimentalAutoDetectLongPolling=!!e.experimentalAutoDetectLongPolling,this.experimentalLongPollingOptions=wf(null!==(n=e.experimentalLongPollingOptions)&&void 0!==n?n:{}),function(e){if(void 0!==e.timeoutSeconds){if(isNaN(e.timeoutSeconds))throw new ys(gs.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (must not be NaN)`);if(e.timeoutSeconds<5)throw new ys(gs.INVALID_ARGUMENT,`invalid long polling timeout: ${e.timeoutSeconds} (minimum allowed value is 5)`);if(e.timeoutSeconds>30)throw new ys(gs.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}}class If{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 Tf({}),this._settingsFrozen=!1,this._emulatorOptions={},this._terminateTask="notTerminated"}get app(){if(!this._app)throw new ys(gs.FAILED_PRECONDITION,"Firestore was not initialized using the Firebase SDK. 'app' is not available");return this._app}get _initialized(){return this._settingsFrozen}get _terminated(){return"notTerminated"!==this._terminateTask}_setSettings(e){if(this._settingsFrozen)throw new ys(gs.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 Tf(e),this._emulatorOptions=e.emulatorOptions||{},void 0!==e.credentials&&(this._authCredentials=function(e){if(!e)return new _s;switch(e.type){case"firstParty":return new Is(e.sessionIndex||"0",e.iamToken||null,e.authTokenFactory||null);case"provider":return e.client;default:throw new ys(gs.INVALID_ARGUMENT,"makeAuthCredentialsProvider failed due to invali
2d credential type")}}(e.credentials))}_getSettings(){return this._settings}_getEmulatorOptions(){return this._emulatorOptions}_freezeSettings(){return this._settingsFrozen=!0,this._settings}_delete(){return"notTerminated"===this._terminateTask&&(this._terminateTask=this._terminate()),this._terminateTask}async _restart(){"notTerminated"===this._terminateTask?await this._terminate():this._terminateTask="notTerminated"}toJSON(){return{app:this._app,databaseId:this._databaseId,settings:this._settings}}_terminate(){return function(e){const t=_f.get(e);t&&(cs("ComponentProvider","Removing Datastore"),_f.delete(e),t.terminate())}(this),Promise.resolve()}}function Sf(e,t,n,r={}){var s;e=Hs(e,If);const o=h(t),a=e._getSettings(),c=Object.assign(Object.assign({},a),{emulatorOptions:e._getEmulatorOptions()}),u=`${t}:${n}`;o&&(d(`https://${u}`),m("Firestore",!0)),a.host!==bf&&a.host!==u&&ls("Host has been set in both settings() and connectFirestoreEmulator(), emulator host will be used.");const l=Object.assign(Object.assign({},a),{host:u,ssl:o,emulatorOptions:r});if(!T(l,c)&&(e._setSettings(l),r.mockUserToken)){let t,n;if("string"==typeof r.mockUserToken)t=r.mockUserToken,n=is.MOCK_USER;else{t=function(e,t){if(e.uid)throw new Error('The "uid" field is no longer supported by mockUserToken. Please use "sub" instead for Firebase Auth User ID.');const n=t||"demo-project",r=e.iat||0,s=e.sub||e.user_id;if(!s)throw new Error("mockUserToken must contain 'sub' or 'user_id' field!");const o=Object.assign({iss:`https://securetoken.google.com/${n}`,aud:n,iat:r,exp:r+3600,auth_time:r,sub:s,user_id:s,firebase:{sign_in_provider:"custom",identities:{}}},e);return[i(JSON.stringify({alg:"none",type:"JWT"})),i(JSON.stringify(o)),""].join(".")}(r.mockUserToken,null===(s=e._app)||void 0===s?void 0:s.options.projectId);const o=r.mockUserToken.sub||r.mockUserToken.user_id;if(!o)throw new ys(gs.INVALID_ARGUMENT,"mockUserToken must contain 'sub' or 'user_id' field!");n=new is(o)}e._authCredentials=new bs(new ws(t,n))}}class Cf{constructor(e,t,n){this.converter=t,this._query=n,this.type="query",this.firestore=e}withConverter(e){return new Cf(this.firestore,e,this._query)}}class Af{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 kf(this.firestore,this.converter,this._key.path.popLast())}withConverter(e){return new Af(this.firestore,e,this._key)}toJSON(){return{type:Af._jsonSchemaVersion,referencePath:this._key.toString()}}static fromJSON(e,t,n){if(Ks(t,Af._jsonSchema))return new Af(e,n||null,new js(Fs.fromString(t.referencePath)))}}Af._jsonSchemaVersion="firestore/documentReference/1.0",Af._jsonSchema={type:Gs("string",Af._jsonSchemaVersion),referencePath:Gs("string")};class kf extends Cf{constructor(e,t,n){super(e,t,pc(n)),this._path=n,this.type="collection"}get id(){return this._query.path.lastSegment()}get path(){return this._query.path.canonicalString()}get parent(){const e=this._path.popLast();return e.isEmpty()?null:new Af(this.firestore,null,new js(e))}withConverter(e){return new kf(this.firestore,e,this._path)}}function Nf(e,t,...n){if(e=O(e),1===arguments.length&&(t=Ns.newId()),$s("doc","path",t),e instanceof If){const r=Fs.fromString(t,...n);return Bs(r),new Af(e,null,new js(r))}{if(!(e instanceof Af||e instanceof kf))throw new ys(gs.INVALID_ARGUMENT,"Expected first argument to collection() to be a CollectionReference, a DocumentReference or FirebaseFirestore");const r=e._path.child(Fs.fromString(t,...n));return Bs(r),new Af(e.firestore,e instanceof kf?e.converter:null,new js(r))}}const Of="AsyncQueue";class Df{constructor(e=Promise.resolve()){this.Zu=[],this.Xu=!1,this.ec=[],this.tc=null,this.nc=!1,this.rc=!1,this.sc=[],this.F_=new kh(this,"async_queue_retry"),this.oc=()=>{const e=Ch();e&&cs(Of,"Visibility state changed to "+e.visibilityState),this.F_.y_()},this._c=e;const t=Ch();t&&"function"==typeof t.addEventListener&&t.addEventListener("visibilitychange",this.oc)}get isShuttingDown(){return this.Xu}enqueueAndForget(e){this.enqueue(e)}enqueueAndForgetEvenWhileRestricted(e){this.ac(),this.uc(e)}enterRestrictedMode(e){if(!this.Xu){this.Xu=!0,this.rc=e||!1;const t=Ch();t&&"function"==typeof t.removeEventListener&&t.removeEventListener("visibilitychange",this.oc)}}enqueue(e){if(this.ac(),this.Xu)return new Promise(()=>{});const t=new vs;return this.uc(()=>this.Xu&&this.rc?Promise.resolve():(e().then(t.resolve,t.reject),t.promise)).then(()=>t.promise)}enqueueRetryable(e){this.enqueueAndForget(()=>(this.Zu.push(e),this.cc()))}async cc(){if(0!==this.Zu.length){try{await this.Zu[0](),this.Zu.shift(),this.F_.reset()}catch(e){if(!uo(e))throw e;cs(Of,"Operation failed with retryable error: "+e)}this.Zu.length>0&&this.F_.g_(()=>this.cc())}}uc(e){const t=this._c.then(()=>(this.nc=!0,e().catch(e=>{throw this.tc=e,this.nc=!1,us("INTERNAL UNHANDLED ERROR: ",Rf(e)),e}).then(e=>(this.nc=!1,e))));return this._c=t,t}enqueueAfterDelay(e,t,n){this.ac(),this.sc.indexOf(e)>-1&&(t=0);const r=fd.createAndSchedule(this,e,t,n,e=>this.lc(e));return this.ec.push(r),r}ac(){this.tc&&ds(47125,{hc:Rf(this.tc)})}verifyOperationInProgress(){}async Pc(){let e;do{e=this._c,await e}while(e!==this._c)}Tc(e){for(const t of this.ec)if(t.timerId===e)return!0;return!1}Ic(e){return this.Pc().then(()=>{this.ec.sort((e,t)=>
2e.targetTimeMs-t.targetTimeMs);for(const t of this.ec)if(t.skipDelay(),"all"!==e&&t.timerId===e)break;return this.Pc()})}dc(e){this.sc.push(e)}lc(e){const t=this.ec.indexOf(e);this.ec.splice(t,1)}}function Rf(e){let t=e.message||"";return e.stack&&(t=e.stack.includes(e.message)?e.stack:e.message+"\n"+e.stack),t}class Pf extends If{constructor(e,t,n,r){super(e,t,n,r),this.type="firestore",this._queue=new Df,this._persistenceKey=(null==r?void 0:r.name)||"[DEFAULT]"}async _terminate(){if(this._firestoreClient){const e=this._firestoreClient.terminate();this._queue=new Df(e),this._firestoreClient=void 0,await e}}}function Lf(e,t){const n="object"==typeof e?e:function(e=Le){const t=xe.get(e);if(!t&&e===Le&&u())return Ge();if(!t)throw qe.create("no-app",{appName:e});return t}(),r="string"==typeof e?e:t||da,i=$e(n,"firestore").getImmediate({identifier:r});if(!i._initialized){const e=c("firestore");e&&Sf(i,...e)}return i}function Mf(e){if(e._terminated)throw new ys(gs.FAILED_PRECONDITION,"The client has already been terminated.");return e._firestoreClient||xf(e),e._firestoreClient}function xf(e){var t,n,r;const i=e._freezeSettings(),s=function(e,t,n,r){return new ha(e,t,n,r.host,r.ssl,r.experimentalForceLongPolling,r.experimentalAutoDetectLongPolling,wf(r.experimentalLongPollingOptions),r.useFetchStreams,r.isUsingEmulator)}(e._databaseId,(null===(t=e._app)||void 0===t?void 0:t.options.appId)||"",e._persistenceKey,i);e._componentsProvider||(null===(n=i.localCache)||void 0===n?void 0:n._offlineComponentProvider)&&(null===(r=i.localCache)||void 0===r?void 0:r._onlineComponentProvider)&&(e._componentsProvider={_offline:i.localCache._offlineComponentProvider,_online:i.localCache._onlineComponentProvider}),e._firestoreClient=new hf(e._authCredentials,e._appCheckCredentials,e._queue,s,e._componentsProvider&&function(e){const t=null==e?void 0:e._online.build();return{_offline:null==e?void 0:e._offline.build(t),_online:t}}(e._componentsProvider))}class Ff{constructor(e){this._byteString=e}static fromBase64String(e){try{return new Ff(Zo.fromBase64String(e))}catch(e){throw new ys(gs.INVALID_ARGUMENT,"Failed to construct data from Base64 string: "+e)}}static fromUint8Array(e){return new Ff(Zo.fromUint8Array(e))}toBase64(){return this._byteString.toBase64()}toUint8Array(){return this._byteString.toUint8Array()}toString(){return"Bytes(base64: "+this.toBase64()+")"}isEqual(e){return this._byteString.isEqual(e._byteString)}toJSON(){return{type:Ff._jsonSchemaVersion,bytes:this.toBase64()}}static fromJSON(e){if(Ks(e,Ff._jsonSchema))return Ff.fromBase64String(e.bytes)}}Ff._jsonSchemaVersion="firestore/bytes/1.0",Ff._jsonSchema={type:Gs("string",Ff._jsonSchemaVersion),bytes:Gs("string")};class Uf{constructor(...e){for(let t=0;t<e.length;++t)if(0===e[t].length)throw new ys(gs.INVALID_ARGUMENT,"Invalid field name at argument $(i + 1). Field names must not be empty.");this._internalPath=new Vs(e)}isEqual(e){return this._internalPath.isEqual(e._internalPath)}}class Vf{constructor(e){this._methodName=e}}class jf{constructor(e,t){if(!isFinite(e)||e<-90||e>90)throw new ys(gs.INVALID_ARGUMENT,"Latitude must be a number between -90 and 90, but was: "+e);if(!isFinite(t)||t<-180||t>180)throw new ys(gs.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 Os(this._lat,e._lat)||Os(this._long,e._long)}toJSON(){return{latitude:this._lat,longitude:this._long,type:jf._jsonSchemaVersion}}static fromJSON(e){if(Ks(e,jf._jsonSchema))return new jf(e.latitude,e.longitude)}}jf._jsonSchemaVersion="firestore/geoPoint/1.0",jf._jsonSchema={type:Gs("string",jf._jsonSchemaVersion),latitude:Gs("number"),longitude:Gs("number")};class $f{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:$f._jsonSchemaVersion,vectorValues:this._values}}
2static fromJSON(e){if(Ks(e,$f._jsonSchema)){if(Array.isArray(e.vectorValues)&&e.vectorValues.every(e=>"number"==typeof e))return new $f(e.vectorValues);throw new ys(gs.INVALID_ARGUMENT,"Expected 'vectorValues' field to be a number array")}}}$f._jsonSchemaVersion="firestore/vectorValue/1.0",$f._jsonSchema={type:Gs("string",$f._jsonSchemaVersion),vectorValues:Gs("object")};const Bf=/^__.*__$/;class qf{constructor(e,t,n){this.data=e,this.fieldMask=t,this.fieldTransforms=n}toMutation(e,t){return new fu(e,this.data,this.fieldMask,t,this.fieldTransforms)}}function zf(e){switch(e){case 0:case 2:case 1:return!0;case 3:case 4:return!1;default:throw ds(40011,{Ec:e})}}class Hf{constructor(e,t,n,r,i,s){this.settings=e,this.databaseId=t,this.serializer=n,this.ignoreUndefinedProperties=r,void 0===i&&this.Ac(),this.fieldTransforms=i||[],this.fieldMask=s||[]}get path(){return this.settings.path}get Ec(){return this.settings.Ec}Rc(e){return new Hf(Object.assign(Object.assign({},this.settings),e),this.databaseId,this.serializer,this.ignoreUndefinedProperties,this.fieldTransforms,this.fieldMask)}Vc(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.Rc({path:n,mc:!1});return r.fc(e),r}gc(e){var t;const n=null===(t=this.path)||void 0===t?void 0:t.child(e),r=this.Rc({path:n,mc:!1});return r.Ac(),r}yc(e){return this.Rc({path:void 0,mc:!0})}wc(e){return ip(e,this.settings.methodName,this.settings.Sc||!1,this.path,this.settings.bc)}contains(e){return void 0!==this.fieldMask.find(t=>e.isPrefixOf(t))||void 0!==this.fieldTransforms.find(t=>e.isPrefixOf(t.field))}Ac(){if(this.path)for(let e=0;e<this.path.length;e++)this.fc(this.path.get(e))}fc(e){if(0===e.length)throw this.wc("Document fields must not be empty");if(zf(this.Ec)&&Bf.test(e))throw this.wc('Document fields cannot begin and end with "__"')}}class Gf{constructor(e,t,n){this.databaseId=e,this.ignoreUndefinedProperties=t,this.serializer=n||Ah(e)}Dc(e,t,n,r=!1){return new Hf({Ec:e,methodName:t,bc:n,path:Vs.emptyPath(),mc:!1,Sc:r},this.databaseId,this.serializer,this.ignoreUndefinedProperties)}}function Kf(e){const t=e._freezeSettings(),n=Ah(e._databaseId);return new Gf(e._databaseId,!!t.ignoreUndefinedProperties,n)}class Wf extends Vf{_toFieldTransform(e){if(2!==e.Ec)throw 1===e.Ec?e.wc(`${this._methodName}() can only appear at the top level of your update data`):e.wc(`${this._methodName}() cannot be used with set() unless you pass {merge:true}`);return e.fieldMask.push(e.path),null}isEqual(e){return e instanceof Wf}}function Yf(e,t,n,r){const i=e.Dc(1,t,n);ep("Data must be an object, but it was:",i,r);const s=[],o=xa.empty();zo(r,(e,r)=>{const a=rp(t,e,n);r=O(r);const c=i.gc(a);if(r instanceof Wf)s.push(a);else{const e=Jf(r,c);null!=e&&(s.push(a),o.set(a,e))}});const a=new Jo(s);return new qf(o,a,i.fieldTransforms)}function Qf(e,t,n,r,i,s){const o=e.Dc(1,t,n),a=[tp(t,r,n)],c=[i];if(s.length%2!=0)throw new ys(gs.INVALID_ARGUMENT,`Function ${t}() needs to be called with an even number of arguments that alternate between field names and values.`);for(let e=0;e<s.length;e+=2)a.push(tp(t,s[e])),c.push(s[e+1]);const u=[],l=xa.empty();for(let e=a.length-1;e>=0;--e)if(!sp(u,a[e])){const t=a[e];let n=c[e];n=O(n);const r=o.gc(t);if(n instanceof Wf)u.push(t);else{const e=Jf(n,r);null!=e&&(u.push(t),l.set(t,e))}}const h=new Jo(u);return new qf(l,h,o.fieldTransforms)}function Jf(e,t){if(Zf(e=O(e)))return ep("Unsupported field value:",t,e),Xf(e,t);if(e instanceof Vf)return function(e,t){if(!zf(t.Ec))throw t.wc(`${e._methodName}() can only be used with update() and set()`);if(!t.path)throw t.wc(`${e._methodName}() is not currently supported inside arrays`);const n=e._toFieldTransform(t);n&&t.fieldTransforms.push(n)}(e,t),null;if(void 0===e&&t.ignoreUndefinedProperties)return null;if(t.path&&t.fieldMask.push(t.path),e instanceof Array){if(t.settings.mc&&4!==t.Ec)throw t.wc("Nested arrays are not supported");return function(e,t){const n=[];let r=0;for(const i of e){let e=Jf(i,t.yc(r));null==e&&(e={nullValue:"NULL_VALUE"}),n.push(e),r++}return{arrayValue:{values:n}}}(e,t)}return function(e,t){if(null===(e=O(e)))return{nullValue:"NULL_VALUE"};if("number"==typeof e)return zc(t.serializer,e);if("boolean"==typeof e)return{booleanValue:e};if("string"==typeof e)return{stringValue:e};if(e instanceof Date){const n=Qs.fromDate(e);return{timestampValue:Ku(t.serializer,n)}}if(e instanceof Qs){const n=new Qs(e.seconds,1e3*Math.floor(e.nanoseconds/1e3));return{timestampValue:Ku(t.serializer,n)}}if(e instanceof jf)return{geoPointValue:{latitude:e.latitude,longitude:e.longitude}};if(e instanceof Ff)return{bytesValue:Wu(t.serializer,e._byteString)};if(e instanceof Af){const n=t.databaseId,r=e.firestore._databaseId;if(!r.isEqual(n))throw t.wc(`Document reference is for database ${r.projectId}/${r.database} but should be for database ${n.projectId}/${n.database}`);return{referenceValue:Ju(e.firestore._databaseId||t.databaseId,e._key.path)}}if(e instanceof $f)return function(e,t){return{mapValue:{fields:{[pa]:{stringValue:ya},[va]:{arrayValue:{values:e.toArray().map(e=>{if("number"!=typeof e)throw t.wc("VectorValues must only contain numeric values.");return Bc(t.serializer,e)})}}}}}}(e,t);throw t.wc(`Unsupported field value: ${zs(e)}`)}(e,t)}function Xf(e,t){const n={};return Ho(e)?t.path&&t.path.length>0&&t.fieldMask.push(t.path):zo(e,(e,r)=>{const i=Jf(r,t.Vc(e));null!=i&&(n[e]=i)}),{mapValue:{fields:n}}}function Zf(e){return!("object"!=typeof e||null===e||e instanceof Array||e instanceof Date||e instanceof Qs||e instanceof jf||e instanceof Ff||e instanceof Af||e instanceof Vf||e instanceof $f)}
2function ep(e,t,n){if(!Zf(n)||!qs(n)){const r=zs(n);throw"an object"===r?t.wc(e+" a custom object"):t.wc(e+" "+r)}}function tp(e,t,n){if((t=O(t))instanceof Uf)return t._internalPath;if("string"==typeof t)return rp(e,t);throw ip("Field path arguments must be of type string or ",e,!1,void 0,n)}const np=new RegExp("[~\\*/\\[\\]]");function rp(e,t,n){if(t.search(np)>=0)throw ip(`Invalid field path (${t}). Paths must not contain '~', '*', '/', '[', or ']'`,e,!1,void 0,n);try{return new Uf(...t.split("."))._internalPath}catch(r){throw ip(`Invalid field path (${t}). Paths must not be empty, begin with '.', end with '.', or contain '..'`,e,!1,void 0,n)}}function ip(e,t,n,r,i){const s=r&&!r.isEmpty(),o=void 0!==i;let a=`Function ${t}() called with invalid data`;n&&(a+=" (via `toFirestore()`)"),a+=". ";let c="";return(s||o)&&(c+=" (found",s&&(c+=` in field ${r}`),o&&(c+=` in document ${i}`),c+=")"),new ys(gs.INVALID_ARGUMENT,a+e+c)}function sp(e,t){return e.some(e=>e.isEqual(t))}class op{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 Af(this._firestore,this._converter,this._key)}exists(){return null!==this._document}data(){if(this._document){if(this._converter){const e=new ap(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){const t=this._document.data.field(cp("DocumentSnapshot.get",e));if(null!==t)return this._userDataWriter.convertValue(t)}}}class ap extends op{data(){return super.data()}}function cp(e,t){return"string"==typeof t?rp(e,t):t instanceof Uf?t._internalPath:t._delegate._internalPath}class up{convertValue(e,t="none"){switch(wa(e)){case 0:return null;case 1:return e.booleanValue;case 2:return na(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(ra(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 ds(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const n={};return zo(e,(e,r)=>{n[e]=this.convertValue(r,t)}),n}convertVectorValue(e){var t,n,r;const i=null===(r=null===(n=null===(t=e.fields)||void 0===t?void 0:t[va].arrayValue)||void 0===n?void 0:n.values)||void 0===r?void 0:r.map(e=>na(e.doubleValue));return new $f(i)}convertGeoPoint(e){return new jf(na(e.latitude),na(e.longitude))}convertArray(e,t){return(e.values||[]).map(e=>this.convertValue(e,t))}convertServerTimestamp(e,t){switch(t){case"previous":const n=ua(e);return null==n?null:this.convertValue(n,t);case"estimate":return this.convertTimestamp(la(e));default:return null}}convertTimestamp(e){const t=ta(e);return new Qs(t.seconds,t.nanos)}convertDocumentKey(e,t){const n=Fs.fromString(e);ps(wl(n),9688,{name:e});const r=new fa(n.get(1),n.get(3)),i=new js(n.popFirst(5));return r.isEqual(t)||us(`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}}class lp{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class hp extends op{constructor(e,t,n,r,i,s){super(e,t,n,r,s),this._firestore=e,this._firestoreImpl=e,this.metadata=i}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new dp(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){const n=this._document.data.field(cp("DocumentSnapshot.get",e));if(null!==n)return this._userDataWriter.convertValue(n,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new ys(gs.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,t={};return t.type=hp._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),e&&e.isValidDocument()&&e.isFoundDocument()?(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t):t}}hp._jsonSchemaVersion="firestore/documentSnapshot/1.0",hp._jsonSchema={type:Gs("string",hp._jsonSchemaVersion),bundleSource:Gs("string","DocumentSnapshot"),bundleName:Gs("string"),bundle:Gs("string")};class dp extends hp{data(e={}){return super.data(e)}}class fp{constructor(e,t,n,r){this._firestore=e,this._userDataWriter=t,this._snapshot=r,this.metadata=new lp(r.hasPendingWrites,r.fromCache),this.query=n}get docs(){const e=[];return this.forEach(t=>e.push(t)),e}get size(){return this._snapshot.docs.size}get empty(){return 0===this.size}forEach(e,t){this._snapshot.docs.forEach(n=>{e.call(t,new dp(this._firestore,this._userDataWriter,n.key,n,new lp(this._snapshot.mutatedKeys.has(n.key),this._snapshot.fromCache),this.query.converter))})}
2docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new ys(gs.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=>{const r=new dp(e._firestore,e._userDataWriter,n.doc.key,n.doc,new lp(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||3!==e.type).map(t=>{const r=new dp(e._firestore,e._userDataWriter,t.doc.key,t.doc,new lp(e._snapshot.mutatedKeys.has(t.doc.key),e._snapshot.fromCache),e.query.converter);let i=-1,s=-1;return 0!==t.type&&(i=n.indexOf(t.doc.key),n=n.delete(t.doc.key)),1!==t.type&&(n=n.add(t.doc),s=n.indexOf(t.doc.key)),{type:pp(t.type),doc:r,oldIndex:i,newIndex:s}})}}(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new ys(gs.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=fp._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=Ns.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],n=[],r=[];return this.docs.forEach(e=>{null!==e._document&&(t.push(e._document),n.push(this._userDataWriter.convertObjectMap(e._document.data.value.mapValue.fields,"previous")),r.push(e.ref.path))}),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function pp(e){switch(e){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return ds(61501,{type:e})}}function mp(e){e=Hs(e,Af);const t=Hs(e.firestore,Pf);return vf(Mf(t),e._key).then(n=>wp(t,e,n))}fp._jsonSchemaVersion="firestore/querySnapshot/1.0",fp._jsonSchema={type:Gs("string",fp._jsonSchemaVersion),bundleSource:Gs("string","QuerySnapshot"),bundleName:Gs("string"),bundle:Gs("string")};class gp extends up{constructor(e){super(),this.firestore=e}convertBytes(e){return new Ff(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Af(this.firestore,null,t)}}function yp(e,t,n,...r){e=Hs(e,Af);const i=Hs(e.firestore,Pf),s=Kf(i);let o;return o="string"==typeof(t=O(t))||t instanceof Uf?Qf(s,"updateDoc",e._key,t,n,r):Yf(s,"updateDoc",e._key,t),vp(i,[o.toMutation(e._key,iu.exists(!0))])}function vp(e,t){return function(e,t){const n=new vs;return e.asyncQueue.enqueueAndForget(async()=>async function(e,t,n){const r=sf(e);try{const e=await function(e,t){const n=ms(e),r=Qs.now(),i=t.reduce((e,t)=>e.add(t.key),Vc());let s,o;return n.persistence.runTransaction("Locally write mutations","readwrite",e=>{let a=Oc(),c=Vc();return n.Os.getEntries(e,i).next(e=>{a=e,a.forEach((e,t)=>{t.isValidDocument()||(c=c.add(e))})}).next(()=>n.localDocuments.getOverlayedDocuments(e,a)).next(i=>{s=i;const o=[];for(const e of t){const t=lu(e,s.get(e.key).overlayedDocument);null!=t&&o.push(new fu(e.key,t,Fa(t.value.mapValue),iu.exists(!0)))}
2return n.mutationQueue.addMutationBatch(e,r,o,t)}).next(t=>{o=t;const r=t.applyToLocalDocumentSet(s,c);return n.documentOverlayCache.saveOverlays(e,t.batchId,r)})}).then(()=>({batchId:o.batchId,changes:Pc(s)}))}(r.localStore,t);r.sharedClientState.addPendingMutation(e.batchId),function(e,t,n){let r=e.Ru[e.currentUser.toKey()];r||(r=new Go(Os)),r=r.insert(t,n),e.Ru[e.currentUser.toKey()]=r}(r,e.batchId,n),await ef(r,e.changes),await ed(r.remoteStore)}catch(e){const t=pd(e,"Failed to persist write");n.reject(t)}}(await gf(e),t,n)),n.promise}(Mf(e),t)}function wp(e,t,n){const r=n.docs.get(t._key),i=new gp(e);return new hp(e,i,t._key,r,new lp(n.hasPendingWrites,n.fromCache),t.converter)}new WeakMap;!function(e,t=!0){!function(e){ss=e}(He),je(new D("firestore",(e,{instanceIdentifier:n,options:r})=>{const i=e.getProvider("app").getImmediate(),s=new Pf(new Es(e.getProvider("auth-internal")),new Cs(i,e.getProvider("app-check-internal")),function(e,t){if(!Object.prototype.hasOwnProperty.apply(e.options,["projectId"]))throw new ys(gs.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new fa(e.options.projectId,t)}(i,n),i);return r=Object.assign({useFetchStreams:t},r),s._setSettings(r),s},"PUBLIC").setMultipleInstances(!0)),We(ns,rs,e),We(ns,rs,"esm2017")}();const _p="__session",bp="esi_puid",Ep="esi_registration_date_firestore",Tp="hashed_email",Ip="__DEBUG__",Sp="feat__mos_migration",Cp="ANONYMOUS",Ap="AUTHENTICATED";let kp=function(e){return e.ALL_ACCESS="all-access",e.PAID_MEMBERSHIP="premium",e.STANDARD="standard",e.NEWSLETTER_MEMBER="member",e.AD_FREE="ad-free",e.SUPPORTER="supporter",e.REGISTERED="registered",e.ANONYMOUS="anonymous",e}({});kp.ALL_ACCESS,kp.PAID_MEMBERSHIP,kp.STANDARD,kp.NEWSLETTER_MEMBER,kp.AD_FREE,kp.SUPPORTER,kp.REGISTERED,kp.ANONYMOUS;function Np(e,t){var n;return{status:Ap,loading:!1,__id__:t,email:null!==(n=e.email)&&void 0!==n?n:"",givenName:void 0,familyName:void 0,uid:e.uid,userStatus:kp.REGISTERED,exp:0,isAdFreeUser:!1,isActiveRecurringDonator:!1,adFreeExpiryTimestamp:null,recurringDonatorExpiryTimestamp:null,permutiveId:null}}const Op=e=>{var t;return"undefined"!=typeof window&&Boolean(null===(t=window.JSGlobals)||void 0===t||null===(t=t.featureFlags)||void 0===t?void 0:t[e])};function Dp(e){return Dp="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Dp(e)}function Rp(e){var t=function(e,t){if("object"!=Dp(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=Dp(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==Dp(t)?t:t+""}function Pp(e,t,n){return(t=Rp(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const Lp="/login",Mp="returnPath";var xp=n(55299);const Fp={foreground:31,background:41,light:"#AA0000",dark:"#ed4e4c"},Up={foreground:33,background:43,light:"#AA5500",dark:"#d2c057"},Vp="light",jp="dark";const $p=(e,t=null)=>{var n,r;const i=`; ${document.cookie}`.split(`; ${e}=`);return 2===i.length?decodeURIComponent(null!==(n=null===(r=i.pop())||void 0===r?void 0:r.split(";").shift())&&void 0!==n?n:""):t},Bp=e=>e===Ip?"":`[${e.replace(/^_+|_+$/g,"")}]`,qp=e=>`color: ${e};`,zp=e=>("undefined"==typeof window||"function"!=typeof window.matchMedia?Vp:window.matchMedia("(prefers-color-scheme: dark)").matches?jp:Vp)===jp?e.dark:e.light,Hp=new Map,Gp=e=>{if("undefined"==typeof window)return"prod"!=={NODE_ENV:"production",npm_config_domain:""}.SERVER;if(!Hp.has(e)){var t;const n=new URLSearchParams(null===(t=window)||void 0===t||null===(t=t.location)||void 0===t?void 0:t.search);Hp.set(e,n.has(e))}return Hp.get(e)||"true"===$p(e)};function Kp(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}let Wp;let Yp=0;const Qp=()=>{return"undefined"!=typeof window&&(void 0===Wp&&(Wp=!0===(null===(e=window.JSGlobals)||void 0===e||null===(e=e.featureFlags)||void 0===e?void 0:e.feat__sentry)),Wp);var e},Jp=(e,t)=>{const n=()=>Gp(Ip)||Gp(e),r=(e,n)=>{const r=t.filter(({tag:e})=>""!==e);if(0===r.length)return e;const i=r.map(({tag:e,color:t})=>{const r=null!=n?n:t,i=void 0!==r;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};
2t%2?Kp(Object(n),!0).forEach(function(t){Pp(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kp(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({text:i?(s=e,`%c${s}`):e},i?{style:qp(r)}:{});var s}),[s,o,...a]=e,c=i.reduce((e,{text:t})=>e+t,""),u=i.filter(e=>"style"in e).map(({style:e})=>e);if("string"==typeof s){return"string"==typeof o&&o.includes("color")&&s.startsWith("%c")?[`${c} ${s}`,...u.concat(o),...a]:[c,...u,s,...e.slice(1)]}return[c,...u,...e]};return{log:(...e)=>{n()&&console.log(...Yp>0?e:r(e))},info:(...e)=>{n()&&console.info(...Yp>0?e:r(e))},group:(...e)=>{n()&&(console.group(...r(e)),Yp+=1)},groupCollapsed:(...e)=>{n()&&(console.groupCollapsed(...r(e)),Yp+=1)},groupEnd:(...e)=>{n()&&(Yp=Math.max(0,Yp-1),console.groupEnd(...e))},table:(...e)=>{n()&&console.table(...e)},warn:(...e)=>{var t;n()&&console.warn(...r(e,zp(Up))),Qp()&&(null===(t=window.Sentry)||void 0===t||t.captureException(...e))},error:(...e)=>{var t;n()&&console.error(...r(e,zp(Fp))),Qp()&&(null===(t=window.Sentry)||void 0===t||t.captureException(...e))},extend:(n,r)=>Jp(e,[...t,{tag:n,color:r}]),logDate:e=>e.toLocaleString("en-GB",{timeZone:"UTC"})}},Xp=(({flagName:e,tagSegment:t={}})=>{const{tag:n,color:r}=t;return Jp(e,[{tag:null!=n?n:Bp(e),color:r}])})({flagName:Ip}),{log:Zp,info:em,warn:tm,error:nm,group:rm,groupEnd:im,logDate:sm}=Xp;let om;function am(e=document){if(void 0===e)return null;if(void 0!==om)return om;const t=e.getElementById(xp.eQT),n=null==t?void 0:t.textContent;let r=null;try{if(!n)throw new Error("No auth snapshot found in DOM");r=JSON.parse(atob(n))}catch(e){Zp(e)}finally{var i;null===(i=document.getElementById(xp.eQT))||void 0===i||i.remove()}return om=r,r}function cm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function um(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?cm(Object(n),!0).forEach(function(t){Pp(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cm(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function lm(e){let t=e;const n=new Set;return{get:()=>t,set:e=>{t=e,n.forEach(e=>e(t))},patch:e=>{t=um(um({},t),e),n.forEach(e=>e(t))},subscribe:e=>(n.add(e),()=>n.delete(e))}}const hm=e=>{try{const t=e.split(".")[1].replace(/-/g,"+").replace(/_/g,"/"),n=decodeURIComponent(atob(t));return JSON.parse(n)}catch(e){return null}};function dm(){if(void 0===globalThis.window)return null;const e=(()=>{var e;const t=null!==(e=$p("esi_auth"))&&void 0!==e?e:"";return hm(t)})();if(!e)return null;const{email:t,given_name:n,family_name:r,userStatus:i,pUid:s,exp:o,isAdFreeUser:a,isActiveRecurringDonator:c,adFreeExpiryTimestamp:u,recurringDonatorExpiryTimestamp:l,permutiveId:h}=e;return{email:t,givenName:n,familyName:r,userStatus:i,uid:s,exp:o,isAdFreeUser:a,isActiveRecurringDonator:c,adFreeExpiryTimestamp:u,recurringDonatorExpiryTimestamp:l,permutiveId:h}}function fm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function pm(){var e;const t=Math.random().toString(36).slice(2),n={status:Cp,loading:!1,__id__:t},r=lm(null!==(e="undefined"!=typeof window?am(document):void 0)&&void 0!==e?e:n);return{__id__:t,get:r.get,subscribe:r.subscribe,actions:{set:r.set,patch:r.patch,login:e=>{r.patch({loading:!0});const t=new URL(Lp,window.location.origin);e&&t.searchParams.set(Mp,e),window.location.href=t.toString()},logout:async()=>{r.patch({loading:!0});try{await fetch("/user/logout",{credentials:"include"})}finally{r.set(n)}},loadProfile:()=>{const e=dm();e?r.patch(function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};
2t%2?fm(Object(n),!0).forEach(function(t){Pp(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):fm(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({status:Ap},e)):r.set(n)}}}}function mm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function gm(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?mm(Object(n),!0).forEach(function(t){Pp(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mm(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ym(){var e;const t=Math.random().toString(36).slice(2),n={status:Cp,loading:!0,__id__:t},r=lm(null!==(e="undefined"!=typeof window?am(document):null)&&void 0!==e?e:n);return{__id__:t,get:r.get,subscribe:r.subscribe,actions:{set:r.set,patch:r.patch,login:e=>{r.patch({loading:!0});const t=new URL(Lp,window.location.origin);e&&t.searchParams.set(Mp,e),window.location.href=t.toString()},logout:async()=>{r.patch({loading:!0});try{await async function(){const e=window.__indyFirebaseLogout;if(!e)throw new Error("[Firebase Auth] Firebase logout is not available. Ensure init-firebase.js loaded before invoking logout.");await e()}(),r.set(gm(gm({},n),{},{loading:!1}))}catch(e){throw nm("[Firebase Auth] Logout failed â user remains signed in.",e),r.patch({loading:!1}),e}},loadProfile:()=>{var e,t;null===(e=(t=window).__indyFirebaseRefreshUserProfile)||void 0===e||e.call(t)}}}}const vm="__indyAuthStore";function wm(){if("undefined"==typeof window)return pm();const e=window;if(e[vm])return e[vm];const t=Op(Sp),n=t?ym():pm();var r,i;t||(null===(r=(i=n.actions).loadProfile)||void 0===r||r.call(i));return e[vm]=n,n}const _m=e=>{const t=`${e}=null`,n=`expires=${(new Date).toUTCString()}`;document.cookie=[t,n,"path=/"].join(";")};const bm="independent-web",Em=(kp.NEWSLETTER_MEMBER,kp.SUPPORTER,({isSubscriber:e,isMember:t,isAdLite:n,isAdFree:r,isSupporter:i})=>e?kp.PAID_MEMBERSHIP:n?kp.STANDARD:t?kp.NEWSLETTER_MEMBER:r?kp.AD_FREE:i?kp.SUPPORTER:kp.REGISTERED);function Tm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Im(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Tm(Object(n),!0).forEach(function(t){Pp(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Tm(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Sm(e){if(null==e||""===e)return;const t="number"==typeof e?e:parseInt(String(e),10);return Number.isNaN(t)?void 0:t}function Cm({firstName:e,lastName:t}){return[e,t].map(e=>null==e?void 0:e.trim()).filter(Boolean).join(" ")||null}const Am=Object.values(kp),km={isSubscriber:!1,isMember:!1,isAdLite:!1,isAdFree:!1,isSupporter:!1};function Nm(e,t){if(!t)return e;const n="string"==typeof t.firstName&&t.firstName?t.firstName:void 0,r="string"==typeof t.lastName&&t.lastName?t.lastName:void 0,i=Im(Im({},e),{},{givenName:null!=n?n:e.givenName,familyName:null!=r?r:e.familyName});if(void 0===t.userStatus&&void 0===t.entitlements)return i;const s=function(e){if(null==e)return;const t="string"==typeof e?Am.find(t=>t===e):void 0;if(t&&t!==kp.ANONYMOUS)return t;console.warn("[Firebase Profile] Unusable userStatus claim â falling back to the registered floor.",e)}(t.userStatus),o=function(e){if(!e)return km;const t=e===kp.PAID_MEMBERSHIP||e===kp.ALL_ACCESS;return{isSubscriber:t,isMember:e===kp.NEWSLETTER_MEMBER,isAdLite:e===kp.STANDARD,isAdFree:t||e===kp.AD_FREE,isSupporter:e===kp.SUPPORTER}}(s),a=function(e){if(!Array.isArray(e))return km;const t=e.includes("MEMBERSHIP-ALL-ACCESS")||e.includes("premium");return{isSubscriber:t,isMember:!1,isAdLite:e.includes("MEMBERSHIP-STANDARD"),isAdFree:t||e.includes("ad_free"),isSupporter:!1}}(t.entitlements),c={isSubscriber:o.isSubscriber||a.isSubscriber,isMember:o.isMember,isAdLite:o.isAdLite||a.isAdLite,isAdFree:o.isAdFree||a.isAdFree,isSupporter:o.isSupporter};return Im(Im({},i),{},{userStatus:(u=Em(c),l=s,l===kp.ALL_ACCESS&&u===kp.PAID_MEMBERSHIP?kp.ALL_ACCESS:u),isAdFreeUser:c.isAdFree,isActiveRecurringDonator:c.isSupporter});var u,l}
2function Om(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Dm(e){return Number.isFinite(e)?Math.floor(e/1e3):null}function Rm({app:e,auth:t,userId:n}){var r,i,s;const o=function({authTenantId:e,fallbackTenantId:t}){const n=null!=e?e:t;if(!n)throw new Error("[Firebase Profile] Missing tenant id â required for GCIP multi-tenant user documents.");return n}({authTenantId:null!==(r=null===(i=t.currentUser)||void 0===i?void 0:i.tenantId)&&void 0!==r?r:t.tenantId,fallbackTenantId:null===(s=window.JSGlobals)||void 0===s||null===(s=s.firebase)||void 0===s?void 0:s.authTenantId});return Nf(Lf(e,bm),...function({tenantId:e,userId:t}){return["tenant",e,"user",t]}({tenantId:o,userId:n}))}async function Pm({app:e,auth:t,user:n}){var r;const i=Rm({app:e,auth:t,userId:n.uid}),s=null===(r=(await mp(i)).data())||void 0===r?void 0:r.profile;return s&&"object"==typeof s?function(e){if(e instanceof Date)return Dm(e.getTime());if("string"==typeof e)return Dm(Date.parse(e));if(e&&"object"==typeof e&&"seconds"in e){const{seconds:t}=e;return"number"==typeof t?Dm(1e3*t):null}return null}(s.createdAt):null}async function Lm({app:e,auth:t,user:n,firstName:r,birthYear:i}){const s=Rm({app:e,auth:t,userId:n.uid}),o=Sm(i);await yp(s,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Om(Object(n),!0).forEach(function(t){Pp(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Om(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}({"profile.firstName":r},void 0!==o?{"profile.birthYear":o}:{}))}async function Mm({app:e,auth:t,user:n,input:r,originalEmail:i}){r.email!==i&&await function(e,t){const n=O(e);return Be(n.auth.app)?Promise.reject(pt(n.auth)):yr(n,t,null)}(n,r.email);const s=Rm({app:e,auth:t,userId:n.uid});await yp(s,function(e){const t=Sm(e.birthYear),n={"profile.email":e.email,"profile.firstName":e.firstName,"profile.lastName":e.lastName,"profile.nickname":e.nickname};return void 0!==t&&(n["profile.birthYear"]=t),n}(r)),await gr(n,{displayName:Cm({firstName:r.firstName,lastName:r.lastName})}),await n.getIdToken(!0)}async function xm({app:e,auth:t,user:n,newsletterUpdates:r}){const i=Rm({app:e,auth:t,userId:n.uid});await yp(i,function(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[`newsletter.${e}`,t]))}(r))}async function Fm(){!function(){try{Object.keys(window.localStorage).filter(e=>e.startsWith("firebase:authUser:")).forEach(e=>window.localStorage.removeItem(e))}catch(e){tm("[Firebase Auth] Failed to clear localStorage auth keys.",e)}}(),await new Promise(e=>{var t;if("function"!=typeof(null===(t=window.indexedDB)||void 0===t?void 0:t.deleteDatabase))return void e();const n=window.indexedDB.deleteDatabase("firebaseLocalStorageDb");n.onsuccess=()=>e(),n.onerror=()=>{tm("[Firebase Auth] Failed to delete firebaseLocalStorageDb IndexedDB.",n.error),e()},n.onblocked=()=>{tm("[Firebase Auth] Deleting firebaseLocalStorageDb IndexedDB was blocked by an open connection."),e()}})}const Um="localhost"===location.hostname||"127.0.0.1"===location.hostname||"::1"===location.hostname?"":"; Secure";function Vm(){document.cookie=`${_p}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax${Um}`}async function jm(e,t=!1){if(e)try{const n=await function(e,t=!1){return O(e).getIdToken(t)}(e,t);!function(e){const t=new Date(Date.now()+36e5).toUTCString();document.cookie=`${_p}=${e}; path=/; expires=${t}; SameSite=Lax${Um}`}(n)}catch(e){console.warn("[Firebase] Failed to sync session cookie:",e),t||Vm()}else Vm()}async function $m(e=!1){var t;if(!Op(Sp))return!1;const n=window.__indyFirebaseAuth;await(null==n?void 0:n.authStateReady());const r=null!==(t=null==n?void 0:n.currentUser)&&void 0!==t?t:null;return!!r&&(await jm(r,e),Boolean(document.cookie.includes(`${_p}=`)))}const Bm=async e=>{const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map(e=>e.toString(16).padStart(2,"0")).join("")},qm=["localhost","127.0.0.1","[::1]","::1"],zm=()=>qm.includes(location.hostname),Hm=zm()?"":"; Secure";function Gm(){document.cookie=`${Tp}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax${Hm}`}async function Km(e){if(Op(Sp)&&!$p(Tp)&&e.email)try{!function(e){const t=new Date(Date.now()+432e5).toUTCString();document.cookie=`${Tp}=${e}; path=/; expires=${t}; SameSite=Lax${Hm}`}(await Bm(e.email))}catch(e){console.warn("[Firebase Profile] Failed to write the hashed email cookie.",e)}}const Wm="none";const Ym="user_registration_date";const Qm=function(){window.dataLayer=window.dataLayer||[],window.dataLayer.push(arguments)};var Jm=n(1626),Xm=n.n(Jm),Zm=n(42719),eg=n.n(Zm);Xm().extend(eg());const tg=()=>{const e=$p(Ep);if(!e||e===Wm)return null;const t=Number(e);return Number.isFinite(t)?(n=t,Xm().unix(n).utc().locale("en")).format("dddd, DD MMMM YYYY"):null;var n},ng=zm()?"":"; Secure";let rg=null;function ig(){document.cookie=`${Ep}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT; SameSite=Lax${ng}`,rg=null}async function sg({app:e,auth:t,user:n}){if(!Op(Sp))return;if($p(Ep))return;const r=rg??=async function({app:e,auth:t,user:n}
2){try{const r=await Pm({app:e,auth:t,user:n});!function(e){const t=new Date(Date.now()+31536e6).toUTCString();document.cookie=`${Ep}=${e}; path=/; expires=${t}; SameSite=Lax${ng}`}(null===r?Wm:String(r)),null!==r&&(()=>{const e=tg();e&&(window.digitalData&&(window.digitalData.registration_date=e),window.__GA4__READY&&Qm("set","user_properties",{[Ym]:e}))})()}catch(e){console.warn("[Firebase Profile] Failed to read registration date from Firestore.",e)}}({app:e,auth:t,user:n});try{await r}finally{rg===r&&(rg=null)}}let og=null,ag=null;async function cg(e){Zp("[Firebase Auth] Logout requested â signing out."),await function(e){return O(e).signOut()}(e),await e.authStateReady(),e.currentUser&&(nm("[Firebase Auth] signOut() resolved but auth.currentUser is still set â forcing persistence clear."),await Fm()),Vm(),ig(),Gm(),_m(bp),Zp("[Firebase Auth] Logout complete.")}const ug="__firebaseIntegrationInit";async function lg(e,t){try{const{claims:n}=await e.getIdTokenResult();return Nm(t,n)}catch(e){return console.warn("[Firebase Profile] Failed to read ID token claims.",e),t}}async function hg(e,t,n){const r=wm(),i=Np(n,r.__id__),s=await lg(n,i);try{const i=await async function({app:e,auth:t,user:n}){const r=Rm({app:e,auth:t,userId:n.uid});return function(e){const t=null==e?void 0:e.profile;if(!t||"object"!=typeof t)return null;const n=t,r=n.email;return"string"==typeof r&&r?{email:r,firstName:"string"==typeof n.firstName?n.firstName:void 0,lastName:"string"==typeof n.lastName?n.lastName:void 0,nickname:"string"==typeof n.nickname?n.nickname:void 0,birthYear:"number"==typeof n.birthYear?n.birthYear:void 0}:null}((await mp(r)).data())}({app:e,auth:t,user:n});r.actions.set((o=s,(a=i)?Im(Im({},o),{},{email:a.email||o.email,givenName:a.firstName||void 0,familyName:a.lastName||void 0,nickname:a.nickname||void 0,birthYear:a.birthYear}):o))}catch(e){console.warn("[Firebase Profile] Failed to load Firestore profile.",e),r.actions.set(s)}var o,a}!function(){var e;const t=window;if(t[ug])return;t[ug]=!0;const n=null===(e=window.JSGlobals)||void 0===e?void 0:e.firebase;if(!n){console.warn("[Firebase] No firebase config found in JSGlobals â skipping init."),delete t[ug];const e=wm();return e.actions.set({status:Cp,loading:!1,__id__:e.__id__}),void(t.__firebaseAuthReady=Promise.resolve())}const{authTenantId:r,authEmulator:i,firestoreEmulator:s}=n,o={apiKey:n.apiKey,authDomain:n.authDomain,projectId:n.projectId,appId:n.appId},a=Ke().length>0?Ke()[0]:Ge(o);ag=a,og=Ln(a,{persistence:[zr,Ir],popupRedirectResolver:Li}),s&&Sf(Lf(a,bm),s.host,s.port);const c=new Zn;window.__indyFirebaseAuth=og,window.__indyFirebaseLogout=()=>cg(og),window.__indyFirebaseSignInWithEmailAndPassword=(e,t)=>function(e,t,n){return Be(e.app)?Promise.reject(pt(e)):ur(O(e),Yn.credential(t,n)).catch(async t=>{throw"auth/password-does-not-meet-requirements"===t.code&&pr(e),t})}(og,e,t),window.__indyFirebaseEnsureSessionCookie=$m,window.__indyFirebaseEnsureRegistrationDate=async()=>{var e;const t=null===(e=og)||void 0===e?void 0:e.currentUser;ag&&t&&await sg({app:ag,auth:og,user:t})},window.__indyFirebaseVerifyPasswordResetCode=e=>mr(og,e),window.__indyFirebaseConfirmPasswordReset=(e,t)=>async function(e,t,n){await Vn(O(e),{oobCode:t,newPassword:n}).catch(async t=>{throw"auth/password-does-not-meet-requirements"===t.code&&pr(e),t})}(og,e,t),window.__indyFirebaseSignInWithGoogle=()=>async function(e,t,n){if(Be(e.app))return Promise.reject(dt(e,"operation-not-supported-in-this-environment"));const r=En(e);mt(e,t,Qn);const i=Qr(r,n);return new ri(r,"signInViaPopup",t,i).executeNotNull()}(og,c),window.__indyFirebaseUpdateUserProfile=async e=>{var t;const n=null===(t=og)||void 0===t?void 0:t.currentUser;if(!ag||!n)throw new Error("[Firebase Profile] No signed-in user available.");await Mm({app:ag,auth:og,user:n,input:e,originalEmail:e.originalEmail})},window.__indyFirebaseCompleteProfile=async e=>{var t;const n=null===(t=og)||void 0===t?void 0:t.currentUser;if(!ag||!n)throw new Error("[Firebase Profile] No signed-in user available.");await Lm({app:ag,auth:og,user:n,firstName:e.firstName,birthYear:e.birthYear})},window.__indyFirebaseUpdateCommentingNickname=async e=>{var t;const n=null===(t=og)||void 0===t?void 0:t.currentUser;
2if(!ag||!n)throw new Error("[Firebase Profile] No signed-in user available to update commenting nickname.");await async function({app:e,auth:t,user:n,nickname:r}){const i=Rm({app:e,auth:t,userId:n.uid});await yp(i,{"profile.nickname":r})}({app:ag,auth:og,user:n,nickname:e})},window.__indyFirebaseUpdateNewsletterPreferences=async e=>{var t;const n=null===(t=og)||void 0===t?void 0:t.currentUser;if(!ag||!n)throw new Error("[Firebase Newsletters] No signed-in user available.");await xm({app:ag,auth:og,user:n,newsletterUpdates:e})},window.__indyFirebaseRefreshUserProfile=async()=>{var e;const t=null===(e=og)||void 0===e?void 0:e.currentUser;ag&&t&&await hg(ag,og,t)},window.__indyFirebaseGetBillingStatus=async()=>{var e;const t=null===(e=og)||void 0===e?void 0:e.currentUser;return ag&&t?async function({app:e,auth:t,user:n}){const r=Rm({app:e,auth:t,userId:n.uid}),i=(await mp(r)).data(),s=null==i?void 0:i.billing;if(!s||"object"!=typeof s)return null;const o=s.status;return"string"==typeof o?o:null}({app:ag,auth:og,user:t}):null},window.__indyFirebaseChangePassword=async e=>{var t;const n=null===(t=og)||void 0===t?void 0:t.currentUser;if(!n||!n.email)throw new Error("[Firebase Auth] No signed-in user available.");const r=Yn.credential(n.email,e.currentPassword);await lr(n,r),await function(e,t){return yr(O(e),null,t)}(n,e.newPassword)},r?og.tenantId=r:console.warn("[Firebase] No authTenantId in JSGlobals.firebase â required for GCIP multi-tenant Auth.");const u=null==i?void 0:i.url;u&&Mn(og,u,{disableWarnings:!0});const l=wm();var h;h=og,Op(Sp)&&vr(h,e=>{jm(e)}),wr(og,e=>{!async function(e,t,n,r){var i,s,o;await n.authStateReady();const a=null!==(i=n.currentUser)&&void 0!==i?i:r;if(Zp("[Firebase Auth] onAuthStateChanged settled",{eventUser:null!==(s=null==r?void 0:r.uid)&&void 0!==s?s:null,settledUser:null!==(o=null==a?void 0:a.uid)&&void 0!==o?o:null}),!a)return ig(),Gm(),_m(bp),void e.actions.set({status:Cp,loading:!1,__id__:e.__id__});sg({app:t,auth:n,user:a}),await Km(a),function(){const{pathname:e}=window.location;return"/profile"===e||e.startsWith("/profile/")}()?await hg(t,n,a):await async function(e){const t=wm(),n=Np(e,t.__id__);t.actions.set(await lg(e,n))}(a)}(l,a,og,e)}),t.__firebaseAuthReady=new Promise(e=>{const t=wr(og,()=>{t(),e()})})}()})()})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.